Clean up the Spiff code so that it emits fewer warnings. This
authorBrian Gaeke <gaeke@uiuc.edu>
Tue, 13 Apr 2004 03:24:45 +0000 (03:24 +0000)
committerBrian Gaeke <gaeke@uiuc.edu>
Tue, 13 Apr 2004 03:24:45 +0000 (03:24 +0000)
consists mostly of changing sloppy K&R C code to slightly more
disciplined K&R C code, and doing the usual things to shut gcc up.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12877 91177308-0d34-0410-b5e6-96231b3b80d8

18 files changed:
utils/Spiff/comment.c
utils/Spiff/comment.h
utils/Spiff/compare.c
utils/Spiff/exact.c
utils/Spiff/float.c
utils/Spiff/float.h
utils/Spiff/floatrep.c
utils/Spiff/line.c
utils/Spiff/miller.c
utils/Spiff/misc.c
utils/Spiff/output.c
utils/Spiff/parse.c
utils/Spiff/spiff.c
utils/Spiff/strings.c
utils/Spiff/strings.h
utils/Spiff/tol.c
utils/Spiff/tol.h
utils/Spiff/visual.c

index f9a38275895da8b69090a6231f46aa63e99a70f4..8f2e22d8275632d80ae3edf25fc9f7f8eae57c2a 100644 (file)
@@ -187,6 +187,7 @@ char *str;
        return(W_BOLNULL);
 }
 
+int
 W_is_bol(ptr)
 W_bol ptr;
 {
@@ -234,6 +235,7 @@ char *str;
        return(W_LITNULL);
 }
 
+int
 W_is_lit(ptr)
 W_lit ptr;
 {
@@ -281,6 +283,7 @@ char *str;
        return(W_COMNULL);
 }
 
+int
 W_is_com(ptr)
 W_com ptr;
 {
@@ -300,6 +303,7 @@ W_com ptr;
        return(0);
 }
 
+int
 W_is_nesting(ptr)
 W_com ptr;
 {
index 01d84230213fa471ffa1c44d12e33169e4e62505..60bb6ed35adf75a657b936988976766aa03436a3 100644 (file)
@@ -66,6 +66,7 @@ extern W_com W_iscom();
 extern int W_is_bol();
 extern int W_is_lit();
 extern int W_is_com();
+extern int W_is_nesting();
 
 extern _W_bolstruct _W_bols[];
 extern _W_litstruct _W_lits[];
index 90af24b3d8da9a2afb57d561521d5bdaf0b2f9ed..edcbfeef334b1d7ae31a89d5d3c1bf7bfabc9042 100644 (file)
@@ -21,6 +21,11 @@ static char rcsid[]= "$Header$";
 
 #include <ctype.h>
 
+static int _X_strcmp();
+static int _X_cmptokens();
+static int _X_floatdiff();
+
+int
 X_com(a,b,flags)
 int a,b,flags;
 {
index 3bcce5c69483796ccc8138466698064d5219eb06..c09e9c7d52b78d4aea7adcbdab7af8046677194f 100644 (file)
@@ -13,6 +13,8 @@ static char rcsid[]= "$Header$";
 
 #include "misc.h"
 #include "edit.h"
+#include "compare.h"
+#include <stdio.h>
 
 /*
 **     routine to compare each object with its ordinal twin
index f6f9e87a0fe740dcea40bedc48102362a55dff96..b20efb70d6965f401e520c676e00bbe734ce0e1b 100644 (file)
@@ -11,6 +11,8 @@
 static char rcsid[]= "$Header$";
 #endif
 
+#include <stdio.h>
+#include <stdlib.h>
 #include <ctype.h>
 #include "misc.h"
 #include "floatrep.h"
@@ -37,6 +39,7 @@ int floatcnt = 0;
 **     returns 0 if string can't be interpreted as a float
 **     otherwise returns the number of digits that will be used in F_atof
 */
+int
 F_isfloat(str,need_decimal,allow_sign)
 char *str;
 int need_decimal;      /* if non-zero, require that a decimal point be present
@@ -367,7 +370,7 @@ F_floatsub(p1,p2)
 F_float  p1,p2;
 {
        static F_float result;
-       static needinit = 1;
+       static int needinit = 1;
        static char man1[R_MANMAX],man2[R_MANMAX],diff[R_MANMAX];
        int exp1,exp2;
        char *diffptr,*big,*small;
@@ -500,6 +503,7 @@ F_float  p1,p2;
        return(result);
 }
 
+int
 F_floatcmp(f1,f2)
 F_float f1,f2;
 {
@@ -645,14 +649,18 @@ F_float f1,f2;
        return(result);
 }
 
+int
 _F_xor(x,y)
+int x, y;
 {
        return(((x) && !(y)) || (!(x) && (y)));
 }
 #define        _F_SAMESIGN(x,y)        _F_xor((x<0),(y<0))
 #define _F_ABSADD(x,y)         (Z_ABS(x) + Z_ABS(y))
 
+int
 _F_ABSDIFF(x,y)
+int x, y;
 {
        if (Z_ABS(x) < Z_ABS(y))
        {
index 9a96255122d8cc66a64d158eda1bb8d8d7e3647c..82c24247676337efb4f6bf4ecca108f64288ef75 100644 (file)
@@ -27,6 +27,8 @@ extern F_float F_atof();
 extern F_float F_floatmul();
 extern F_float F_floatmagadd();
 extern F_float F_floatsub();
+extern int F_floatcmp();
+extern int F_isfloat();
 
 #define F_null ((F_float) 0)
 
index 4847f4772336a62de8186f77d618a9d11926fdf3..22fd78526fae19044309deac3fc5e405b4398ecd 100644 (file)
@@ -24,6 +24,7 @@ R_makefloat()
        return(retval);
 }
 
+int
 R_getexp(ptr)
 R_float ptr;
 {
index 947f1faa4820fbf9b91db63912d4d540f61eb5bf..e358a1806c6708c27507705640d3b281fc292e9e 100644 (file)
@@ -63,6 +63,7 @@ char *str;
 **
 **     stores data and sets maximum counts
 */
+int
 L_init_file(fnumber,fname)
 int fnumber;
 char *fname;
index 63c7660a7a7be636bf00005f2f24c4d7db929c09..ed83d640cb46504c0ee5ba9fa940936e2b4ba8f4 100644 (file)
 static char rcsid[]= "$Header$";
 #endif
 
+#include <stdio.h>
 #include "misc.h"
 #include "token.h"
 #include "edit.h"
+#include "compare.h"
 
 #define MAXT   K_MAXTOKENS
 #define ORIGIN (max_obj/2)
@@ -78,7 +80,7 @@ int comflags;
                for (k = lower; k<= upper; k+= 2) {
                        new = E_edit_alloc();
 
-                       if (k == ORIGIN-d || k!= ORIGIN+d && last_d[k+1] >= last_d[k-1]) {
+                       if (k == ORIGIN-d || (k!= ORIGIN+d && last_d[k+1] >= last_d[k-1])) {
                                row = last_d[k+1]+1;
                                E_setnext(new,script[k+1]);
                                E_setop(new,E_DELETE);
index 3bdf164f27683adc05e51821cff0f18eb73a825e..3c77673a9d8584c3a3320a085e4d47f4a0d6ee86 100644 (file)
@@ -15,6 +15,7 @@ static char rcsid[]= "$Header$";
 #include "misc.h"
 #include "visual.h"
 #include "output.h"
+#include <stdlib.h>
 
 /*
 **     various routines used throughout the program
@@ -101,7 +102,7 @@ _Z_myalloc(k)
 int k;
 {
        int *tmp;
-       if (tmp = (int*) calloc((unsigned)k,(unsigned)1))
+       if ((tmp = (int*) calloc((unsigned)k,(unsigned)1)))
        {
                return(tmp);
        }
index 3db9044a05f44cf328b3a421b9bad0b4f8f77ba6..db157468d21ed20a2f168670a8d6102dc7164120 100644 (file)
@@ -12,6 +12,8 @@ static char rcsid[]= "$Header$";
 #endif
 
 #include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
 
 #ifdef M_TERMINFO
 #include <curses.h>
@@ -171,7 +173,7 @@ int start,end;
 **     convert a 0 origin token number to a 1 orgin token
 **             number or 1 origin line number as appropriate
 */
-static
+static int
 _O_con_line(numb,flags,filenum)
 int numb, flags,filenum;
 {
index 55722b701d5095a89425da1f00121d133abd1cb2..1d2fd18480b786f6442c2bedda8e549440cefc67 100644 (file)
@@ -21,7 +21,6 @@ static char rcsid[]= "$Header$";
 #include "comment.h"
 #include "parse.h"
 
-
 #include <ctype.h>
 
 #define _P_PARSE_CHATTER       1000
@@ -64,7 +63,7 @@ _P_alpha_clear()
        *_P_alpha = '\0';
 }
 
-static
+static int
 _P_in_alpha(chr)
 char chr;
 {
@@ -128,13 +127,13 @@ _P_initparser()
 }
 
 
-static
+static int
 _P_needmore()
 {
        return(*_P_nextchr == '\0');
 }
 
-static
+static int
 _P_nextline()
 {
        /*
@@ -370,7 +369,7 @@ W_bol bolptr;
 /*
 **     pass over a comment -- look for nexting
 */
-static
+static int
 _P_comsnarf(comptr)
 W_com comptr; 
 {
@@ -640,9 +639,9 @@ _P_do_parse()
                /*
                **      see if this is a floating point number
                */
-               else if (tmp = F_isfloat(_P_nextchr,
+               else if ((tmp = F_isfloat(_P_nextchr,
                                       _P_flags & U_NEED_DECIMAL,
-                                      _P_flags & U_INC_SIGN))
+                                      _P_flags & U_INC_SIGN)))
                {
                        K_saventext(newtoken,_P_nextchr,tmp);
                        K_settype(newtoken,K_FLO_NUM);
index eb0c75588704874751422e6e1fe0fc5860f8af2f..9d547850c888f76455a3ff68b070be59a27eb202 100644 (file)
@@ -13,6 +13,7 @@ static char rcsid[]= "$Header$";
 
 
 #include <stdio.h>
+#include <stdlib.h>
 #include "misc.h"
 #include "flagdefs.h"
 #include "parse.h"
@@ -27,7 +28,10 @@ static char rcsid[]= "$Header$";
 #include "visual.h"
 #include "output.h"
 
-extern void _Y_doargs();
+extern int L_init_file();
+extern int V_visual();
+
+static void _Y_doargs();
 
 static int _Y_eflag = 0;       /* use exact match algorithm */
 static int _Y_vflag = 0;       /* use visual mode */
@@ -38,6 +42,7 @@ static int _Y_vflag = 0;      /* use visual mode */
 */
 static int _Y_flags;
 
+int
 main(argc,argv)
 int argc;
 char *argv[];
index 07745635c672d956c10c476ed628d465ee2a6ded..ebd1427bc4d82b5cfccf0a9d1b633e49e141bf31 100644 (file)
@@ -142,6 +142,7 @@ char **to,*from;
 void
 S_savenstr(to,from,cnt)
 char **to,*from;
+int cnt;
 {
        S_allocstr(to,cnt);
        (void) strncpy(*to,from,cnt);
index b2656800470dbbbd4db5943da2b681124f38a3ad..95c341b6537bb002f16b5041a50601768cdbbe92 100644 (file)
@@ -7,6 +7,7 @@
 */
 
 #ifndef S_INCLUDED
+#include <string.h>
 extern void S_wordcpy();
 extern void S_skipword();
 extern void S_skipspace();
index 6812355cc485d2db8e825fe2d23ecf1ccc1c5b5e..bc14778f256d1337343e9fefbb6c9e68f1468389 100644 (file)
@@ -11,6 +11,7 @@
 static char rcsid[]= "$Header$";
 #endif
 
+#include <stdio.h>
 #include "misc.h"
 #include "float.h"
 #include "tol.h"
@@ -213,7 +214,9 @@ char *str;
        }
 }
 
+int
 T_moretols(next_tol)
+int next_tol;
 {
        return((next_tol >= 0) &&
                (_T_TOLMAX-1 > next_tol) &&
index 87c291133a2ed9f46c0f40e80d6238a73f7c116e..b03673afea70046e8b9eff091901ae75acb5a625 100644 (file)
@@ -35,6 +35,7 @@ extern void T_initdefault();
 extern void T_setdef();
 extern void T_tolline();
 extern T_tol T_picktol();
+extern int T_moretols();
 
 #define T_gettype(x)   (x->tol_type)
 #define T_getfloat(x)  (x->flo_tol)
index 93fb38e4e0888d432d4aa8c7a51e2acb09d6bff7..121614b8a66d52458b0df1426a691ed940981278 100644 (file)
@@ -396,6 +396,7 @@ V_cleanup()
 **     dummy code for systems that don't have
 **     the mgr window manager installed
 */
+int
 V_visual(d)
 int d;
 {