From 7a35a4670ffc3b1f87f808351fbc540942b4be3a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?=
 <grubba@grubba.org>
Date: Mon, 14 Aug 2000 19:18:06 +0200
Subject: [PATCH] Fixed a few warnings.

Rev: bin/mkpeep.pike:1.18
Rev: src/peep.c:1.34
Rev: src/peep.h:1.6
---
 bin/mkpeep.pike | 85 ++++++++++++++++++++++++-------------------------
 src/peep.c      | 44 +++++++++++++------------
 src/peep.h      | 28 ++++++++--------
 3 files changed, 80 insertions(+), 77 deletions(-)

diff --git a/bin/mkpeep.pike b/bin/mkpeep.pike
index d46c8f7c91..d486097231 100755
--- a/bin/mkpeep.pike
+++ b/bin/mkpeep.pike
@@ -2,7 +2,7 @@
 
 #pragma strict_types
 
-/* $Id: mkpeep.pike,v 1.17 2000/06/10 11:12:51 mast Exp $ */
+/* $Id: mkpeep.pike,v 1.18 2000/08/14 17:14:34 grubba Exp $ */
 
 #define JUMPBACK 3
 
@@ -95,7 +95,8 @@ array(string) explode_comma_expr(string s)
 /* Splitline into components */
 array(int|string|array(string)) split(string s)
 {
-  string *a,*b,tmp;
+  array(string) a, b;
+  string tmp;
   int i,e,opcodes;
   string line=s;
   opcodes=0;
@@ -193,13 +194,13 @@ array(int|string|array(string)) split(string s)
 #endif
 
   i=0;
-  array newa=({});
+  array(string) newa=({});
   for(e=0;e<sizeof(a);e++)
   {
     switch(a[e][0])
     {
       case '(':
-	array tmp=explode_comma_expr(a[e][1..strlen(a[e])-2]);
+	array(string) tmp=explode_comma_expr(a[e][1..strlen(a[e])-2]);
 	for(int x=0;x<sizeof(tmp);x++)
 	{
 	  string arg=sprintf("$%d%c", i, 'a'+x);
@@ -241,7 +242,7 @@ array(int|string|array(string)) split(string s)
 string treat(string expr)
 {
   int e;
-  string *tmp;
+  array(string) tmp;
   tmp=expr/"$";
   for(e=1;e<sizeof(tmp);e++)
   {
@@ -264,13 +265,12 @@ string treat(string expr)
 }
 
 /* Dump C co(d|r)e */
-void dump2(array(mixed) data,int ind)
+void dump2(array(array(array(string))) data,int ind)
 {
   int e,i,max,maxe;
-  mixed a,b,tmp;
+  mixed tmp;
   string test;
-  mapping(int:array(string))|mapping(string:array(string)) d;
-  mapping(string:mapping(string:array(string))) foo;
+  mapping(string:mapping(string:array(array(array(string))))) foo;
   mixed cons, var;
 
   foo=([]);
@@ -282,10 +282,10 @@ void dump2(array(mixed) data,int ind)
     /* First we create a mapping:
      * foo [ meta variable ] [ condition ] = ({ lines });
      */
-    foreach(data,d)
+    foreach(data, array(array(string)) d)
     {
-      a=d[0];
-      b=d[1];
+      array(string) a = d[0];
+      array(string) b = d[1];
       for(e=0;e<sizeof(a);e++)
       {
 	if(sscanf(a[e],"F_%[A-Z0-9_]==%s",cons,var)==2 ||
@@ -301,7 +301,7 @@ void dump2(array(mixed) data,int ind)
 
     /* Check what variable has most values */
     max=maxe=e=0; 
-    foreach(values(foo),d)
+    foreach(values(foo), mapping(string:array(array(array(string)))) d)
     {
       if(sizeof(d)>max)
       {
@@ -319,9 +319,9 @@ void dump2(array(mixed) data,int ind)
     write(sprintf("%*nswitch(%s)\n",ind,treat(test)));
     write(sprintf("%*n{\n",ind));
 
-    d=values(foo)[maxe];
-    a=indices(d);
-    b=values(d);
+    mapping(string:array(array(array(string)))) d = values(foo)[maxe];
+    array(string) a = indices(d);
+    array(array(array(array(string)))) b = values(d);
 
 
     /* foo: variable
@@ -341,7 +341,7 @@ void dump2(array(mixed) data,int ind)
       
       write(sprintf("%*ncase %s:\n",ind,cons+""));
 
-      foreach(b[e],d) d[0]-=({a[e]});
+      foreach(b[e], array(array(string)) d) d[0]-=({a[e]});
       dump2(b[e],ind+2);
       write(sprintf("%*n  break;\n",ind));
       write("\n");
@@ -353,12 +353,9 @@ void dump2(array(mixed) data,int ind)
   /* Take care of whatever is left */
   if(sizeof(data))
   {
-    foreach(data,d)
+    foreach(data, array(array(string)) d)
     {
-      mixed q;
-
       write(sprintf("%*n/* %s */\n",ind,d[3]));
-
       
       if(sizeof(d[0]))
       {
@@ -398,7 +395,7 @@ void dump2(array(mixed) data,int ind)
   
 
 
-int main(int argc, string *argv)
+int main(int argc, array(string) argv)
 {
   int e,max,maxe;
   string f;
@@ -411,7 +408,7 @@ int main(int argc, string *argv)
   f=cpp(Stdio.read_bytes(argv[1]),argv[1]);
   foreach(f/"\n",f)
   {
-    string *a,*b;
+    array(string) a, b;
     mapping tmp;
 
     sscanf(f,"%s#",f);
@@ -427,26 +424,28 @@ int main(int argc, string *argv)
 
 //  write(sprintf("%O\n",data));
 
-  write("  len=instrbuf.s.len/sizeof(p_instr);\n");
-  write("  instructions=(p_instr *)instrbuf.s.str;\n");
-  write("  instrbuf.s.str=0;\n");
-  write("  fifo_len=0;\n");
-  write("  init_bytecode();\n\n");
-  write("  for(eye=0;eye<len || fifo_len;)\n  {\n");
-  write("    INT32 current_line;\n");
-  write("    struct pike_string *current_file;\n");
-  write("\n");
-  write("#ifdef PIKE_DEBUG\n");
-  write("    if(a_flag>6) {\n");
-  write("      int e;\n");
-  write("      fprintf(stderr,\"#%d,%d:\",eye,fifo_len);\n");
-  write("      for(e=0;e<4;e++) {\n");
-  write("        fprintf(stderr,\" \");\n");
-  write("        dump_instr(instr(e));\n");
-  write("      }\n");
-  write("      fprintf(stderr,\"\\n\");\n");
-  write("    }\n");
-  write("#endif\n\n");
+  write("  len=instrbuf.s.len/sizeof(p_instr);\n"
+	"  instructions=(p_instr *)instrbuf.s.str;\n"
+	"  instrbuf.s.str=0;\n"
+	"  fifo_len=0;\n"
+	"  init_bytecode();\n\n"
+	"  for(eye=0;eye<len || fifo_len;)\n  {\n"
+	"    INT32 current_line;\n"
+	"    struct pike_string *current_file;\n"
+	"\n"
+	"#ifdef PIKE_DEBUG\n"
+	"    if(a_flag>6) {\n"
+	"      int e;\n"
+	"      fprintf(stderr, \"#%ld,%d:\",\n"
+	"              DO_NOT_WARN((long)eye),\n"
+	"              fifo_len);\n"
+	"      for(e=0;e<4;e++) {\n"
+	"        fprintf(stderr,\" \");\n"
+	"        dump_instr(instr(e));\n"
+	"      }\n"
+	"      fprintf(stderr,\"\\n\");\n"
+	"    }\n"
+	"#endif\n\n");
 
   dump2(data,4);
 
diff --git a/src/peep.c b/src/peep.c
index e838b201e7..00cb6dca15 100644
--- a/src/peep.c
+++ b/src/peep.c
@@ -15,7 +15,7 @@
 #include "bignum.h"
 #include "opcodes.h"
 
-RCSID("$Id: peep.c,v 1.33 2000/05/11 14:09:46 grubba Exp $");
+RCSID("$Id: peep.c,v 1.34 2000/08/14 17:18:06 grubba Exp $");
 
 struct p_instr_s
 {
@@ -65,7 +65,7 @@ void init_bytecode(void)
 
 void exit_bytecode(void)
 {
-  INT32 e,length;
+  ptrdiff_t e, length;
   p_instr *c;
 
   c=(p_instr *)instrbuf.s.str;
@@ -76,11 +76,11 @@ void exit_bytecode(void)
   toss_buffer(&instrbuf);
 }
 
-int insert_opcode2(unsigned int f,
-		  INT32 b,
-		  INT32 c,
-		  INT32 current_line,
-		  struct pike_string *current_file)
+ptrdiff_t insert_opcode2(unsigned int f,
+			 INT32 b,
+			 INT32 c,
+			 INT32 current_line,
+			 struct pike_string *current_file)
 {
   p_instr *p;
 
@@ -106,10 +106,10 @@ int insert_opcode2(unsigned int f,
   return p - (p_instr *)instrbuf.s.str;
 }
 
-int insert_opcode1(unsigned int f,
-		  INT32 b,
-		  INT32 current_line,
-		  struct pike_string *current_file)
+ptrdiff_t insert_opcode1(unsigned int f,
+			 INT32 b,
+			 INT32 current_line,
+			 struct pike_string *current_file)
 {
 #ifdef PIKE_DEBUG
   if(!hasarg(f) && b)
@@ -119,7 +119,7 @@ int insert_opcode1(unsigned int f,
   return insert_opcode2(f,b,0,current_line,current_file);
 }
 
-int insert_opcode0(int f,int current_line, struct pike_string *current_file)
+ptrdiff_t insert_opcode0(int f,int current_line, struct pike_string *current_file)
 {
 #ifdef PIKE_DEBUG
   if(hasarg(f))
@@ -221,8 +221,9 @@ static void ins_f_byte_with_2_args(unsigned int a,
 
 void assemble(void)
 {
-  INT32 e,d,length,max_label,tmp;
+  INT32 d,max_label,tmp;
   INT32 *labels, *jumps, *uses;
+  ptrdiff_t e, length;
   p_instr *c;
 
   c=(p_instr *)instrbuf.s.str;
@@ -248,7 +249,7 @@ void assemble(void)
   c=(p_instr *)instrbuf.s.str;
   for(e=0;e<length;e++)
     if(c[e].opcode == F_LABEL && c[e].arg>=0)
-      labels[c[e].arg]=e;
+      labels[c[e].arg]=DO_NOT_WARN((INT32)e);
 
   for(e=0;e<length;e++)
   {
@@ -412,10 +413,11 @@ void assemble(void)
 /**** Peephole optimizer ****/
 
 int remove_clear_locals=0x7fffffff;
-static int fifo_len, eye,len;
+static int fifo_len;
+static ptrdiff_t eye, len;
 static p_instr *instructions;
 
-int insopt2(int f, INT32 a, INT32 b, int cl, struct pike_string *cf)
+ptrdiff_t insopt2(int f, INT32 a, INT32 b, int cl, struct pike_string *cf)
 {
   p_instr *p;
 
@@ -446,7 +448,7 @@ int insopt2(int f, INT32 a, INT32 b, int cl, struct pike_string *cf)
   return p - (p_instr *)instrbuf.s.str;
 }
 
-int insopt1(int f, INT32 a, int cl, struct pike_string *cf)
+ptrdiff_t insopt1(int f, INT32 a, int cl, struct pike_string *cf)
 {
 #ifdef PIKE_DEBUG
   if(!hasarg(f) && a)
@@ -456,7 +458,7 @@ int insopt1(int f, INT32 a, int cl, struct pike_string *cf)
   return insopt2(f,a,0,cl, cf);
 }
 
-int insopt0(int f, int cl, struct pike_string *cf)
+ptrdiff_t insopt0(int f, int cl, struct pike_string *cf)
 {
 #ifdef PIKE_DEBUG
   if(hasarg(f))
@@ -654,7 +656,8 @@ static void asm_opt(void)
   if(a_flag > 3)
   {
     p_instr *c;
-    INT32 e,length;
+    ptrdiff_t e, length;
+
     c=(p_instr *)instrbuf.s.str;
     length=instrbuf.s.len / sizeof(p_instr);
 
@@ -676,7 +679,8 @@ static void asm_opt(void)
   if(a_flag > 4)
   {
     p_instr *c;
-    INT32 e,length;
+    ptrdiff_t e, length;
+
     c=(p_instr *)instrbuf.s.str;
     length=instrbuf.s.len / sizeof(p_instr);
 
diff --git a/src/peep.h b/src/peep.h
index 16a38c1d3f..979f90cec6 100644
--- a/src/peep.h
+++ b/src/peep.h
@@ -1,5 +1,5 @@
 /*
- * $Id: peep.h,v 1.5 2000/04/20 02:41:45 hubbe Exp $
+ * $Id: peep.h,v 1.6 2000/08/14 17:18:06 grubba Exp $
  */
 #ifndef PEEP_H
 #define PEEP_H
@@ -11,22 +11,22 @@ extern dynamic_buffer instrbuf;
 struct p_instr_s;
 void init_bytecode(void);
 void exit_bytecode(void);
-int insert_opcode2(unsigned int f,
-		  INT32 b,
-		  INT32 c,
-		  INT32 current_line,
-		  struct pike_string *current_file);
-int insert_opcode1(unsigned int f,
-		  INT32 b,
-		  INT32 current_line,
-		  struct pike_string *current_file);
-int insert_opcode0(int f,int current_line, struct pike_string *current_file);
+ptrdiff_t insert_opcode2(unsigned int f,
+			 INT32 b,
+			 INT32 c,
+			 INT32 current_line,
+			 struct pike_string *current_file);
+ptrdiff_t insert_opcode1(unsigned int f,
+			 INT32 b,
+			 INT32 current_line,
+			 struct pike_string *current_file);
+ptrdiff_t insert_opcode0(int f,int current_line, struct pike_string *current_file);
 void update_arg(int instr,INT32 arg);
 void ins_f_byte(unsigned int b);
 void assemble(void);
-int insopt2(int f, INT32 a, INT32 b, int cl, struct pike_string *cf);
-int insopt1(int f, INT32 a, int cl, struct pike_string *cf);
-int insopt0(int f, int cl, struct pike_string *cf);
+ptrdiff_t insopt2(int f, INT32 a, INT32 b, int cl, struct pike_string *cf);
+ptrdiff_t insopt1(int f, INT32 a, int cl, struct pike_string *cf);
+ptrdiff_t insopt0(int f, int cl, struct pike_string *cf);
 /* Prototypes end here */
 
 #endif
-- 
GitLab