Module Name:    src
Committed By:   lukem
Date:           Sun Apr 12 11:09:49 UTC 2009

Modified Files:
        src/usr.bin/indent: args.c indent.c indent_globs.h io.c lexi.c

Log Message:
Fix WARNS=4 issues (-Wshadow -Wcast-qual -Wsign-compare)


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/indent/args.c
cvs rdiff -u -r1.17 -r1.18 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/indent/indent_globs.h
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/indent/io.c
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/indent/lexi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/indent/args.c
diff -u src/usr.bin/indent/args.c:1.9 src/usr.bin/indent/args.c:1.10
--- src/usr.bin/indent/args.c:1.9	Thu Aug  7 11:14:07 2003
+++ src/usr.bin/indent/args.c	Sun Apr 12 11:09:49 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: args.c,v 1.9 2003/08/07 11:14:07 agc Exp $	*/
+/*	$NetBSD: args.c,v 1.10 2009/04/12 11:09:49 lukem Exp $	*/
 
 /*
  * Copyright (c) 1980, 1993
@@ -68,7 +68,7 @@
 #if 0
 static char sccsid[] = "@(#)args.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: args.c,v 1.9 2003/08/07 11:14:07 agc Exp $");
+__RCSID("$NetBSD: args.c,v 1.10 2009/04/12 11:09:49 lukem Exp $");
 #endif
 #endif				/* not lint */
 
@@ -99,7 +99,7 @@
 #define	STDIN		3	/* use stdin */
 #define	KEY		4	/* type (keyword) */
 
-char   *option_source = "?";
+const char *option_source = "?";
 
 /*
  * N.B.: because of the way the table here is scanned, options whose names are
@@ -108,7 +108,7 @@
  * default value is the one actually assigned.
  */
 struct pro {
-	char   *p_name;		/* name, eg -bl, -cli */
+	const char *p_name;	/* name, eg -bl, -cli */
 	int     p_type;		/* type (int, bool, special) */
 	int     p_default;	/* the default value (if int) */
 	int     p_special;	/* depends on type */
@@ -351,10 +351,10 @@
 	}
 }
 
-char   *param_start;
+const char *param_start;
 
 int
-eqin(char *s1, char *s2)
+eqin(const char *s1, const char *s2)
 {
 	while (*s1) {
 		if (*s1++ != *s2++)

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.17 src/usr.bin/indent/indent.c:1.18
--- src/usr.bin/indent/indent.c:1.17	Mon Jul 21 14:19:23 2008
+++ src/usr.bin/indent/indent.c	Sun Apr 12 11:09:49 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.17 2008/07/21 14:19:23 lukem Exp $	*/
+/*	$NetBSD: indent.c,v 1.18 2009/04/12 11:09:49 lukem Exp $	*/
 
 /*
  * Copyright (c) 1980, 1993
@@ -75,7 +75,7 @@
 #if 0
 static char sccsid[] = "@(#)indent.c	5.17 (Berkeley) 6/7/93";
 #else
-__RCSID("$NetBSD: indent.c,v 1.17 2008/07/21 14:19:23 lukem Exp $");
+__RCSID("$NetBSD: indent.c,v 1.18 2009/04/12 11:09:49 lukem Exp $");
 #endif
 #endif				/* not lint */
 
@@ -94,10 +94,10 @@
 #undef  EXTERN
 #include "indent_codes.h"
 
-char   *in_name = "Standard Input";	/* will always point to name of input
-					 * file */
-char   *out_name = "Standard Output";	/* will always point to name of output
-					 * file */
+const char *in_name = "Standard Input";		/* will always point to name of
+						 * input file */
+const char *out_name = "Standard Output";	/* will always point to name of
+						 * output file */
 char    bakfile[MAXPATHLEN] = "";
 
 int main(int, char **);
@@ -122,7 +122,7 @@
 	int     squest;		/* when this is positive, we have seen a ?
 				 * without the matching : in a <c>?<s>:<s>
 				 * construct */
-	char   *t_ptr;		/* used for copying tokens */
+	const char *t_ptr;	/* used for copying tokens */
 	int     type_code;	/* the type of token, returned by lexi */
 
 	int     last_else = 0;	/* true iff last keyword was an else */
@@ -309,7 +309,7 @@
 			ps.ind_level = ps.i_l_follow = col / ps.ind_size;
 	}
 	if (troff) {
-		char   *p = in_name, *beg = in_name;
+		const char   *p = in_name, *beg = in_name;
 
 		while (*p)
 			if (*p++ == '/')
@@ -648,7 +648,7 @@
 				ps.dumped_decl_indent = 1;
 				e_code += strlen(e_code);
 			} else {
-				char   *res = token;
+				const char *res = token;
 
 				if (ps.in_decl && !ps.block_init) {	/* if this is a unary op
 									 * in a declaration, we
@@ -674,7 +674,7 @@
 			if (ps.want_blank)
 				*e_code++ = ' ';
 			{
-				char   *res = token;
+				const char *res = token;
 
 				if (troff)
 					switch (token[0]) {
@@ -1179,7 +1179,7 @@
 					while ((c = getc(input)) == '\n');
 					ungetc(c, input);
 				}
-				if (ifdef_level < sizeof state_stack / sizeof state_stack[0]) {
+				if (ifdef_level < (int)(sizeof state_stack / sizeof state_stack[0])) {
 					match_state[ifdef_level].tos = -1;
 					state_stack[ifdef_level++] = ps;
 				} else
@@ -1246,7 +1246,7 @@
 {
 	int     n, bakchn;
 	char    buff[8 * 1024];
-	char   *p;
+	const char *p;
 
 	/* construct file name .Bfile */
 	for (p = in_name; *p; p++);	/* skip to end of string */

Index: src/usr.bin/indent/indent_globs.h
diff -u src/usr.bin/indent/indent_globs.h:1.8 src/usr.bin/indent/indent_globs.h:1.9
--- src/usr.bin/indent/indent_globs.h:1.8	Thu Aug  7 11:14:08 2003
+++ src/usr.bin/indent/indent_globs.h	Sun Apr 12 11:09:49 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent_globs.h,v 1.8 2003/08/07 11:14:08 agc Exp $	*/
+/*	$NetBSD: indent_globs.h,v 1.9 2009/04/12 11:09:49 lukem Exp $	*/
 
 /*
  * Copyright (c) 1980, 1993
@@ -343,9 +343,9 @@
 int compute_code_target(void);
 int compute_label_target(void);
 int count_spaces(int, char *);
-void diag(int, char *,...);
+void diag(int, const char *,...) __attribute__((__format__(__printf__, 2, 3)));
 void dump_line(void);
-int eqin(char *, char *);
+int eqin(const char *, const char *);
 void fill_buffer(void);
 int pad_output(int, int);
 void scan_profile(FILE *);
@@ -354,7 +354,7 @@
 void addkey(char *, int);
 void set_profile(void);
 char *chfont(struct fstate *, struct fstate *, char *);
-void parsefont(struct fstate *, char *);
+void parsefont(struct fstate *, const char *);
 void writefdef(struct fstate *, int);
 int lexi(void);
 void reduce(void);

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.13 src/usr.bin/indent/io.c:1.14
--- src/usr.bin/indent/io.c:1.13	Thu Oct 16 06:51:22 2003
+++ src/usr.bin/indent/io.c	Sun Apr 12 11:09:49 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.13 2003/10/16 06:51:22 itojun Exp $	*/
+/*	$NetBSD: io.c,v 1.14 2009/04/12 11:09:49 lukem Exp $	*/
 
 /*
  * Copyright (c) 1980, 1993
@@ -68,7 +68,7 @@
 #if 0
 static char sccsid[] = "@(#)io.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: io.c,v 1.13 2003/10/16 06:51:22 itojun Exp $");
+__RCSID("$NetBSD: io.c,v 1.14 2009/04/12 11:09:49 lukem Exp $");
 #endif
 #endif				/* not lint */
 
@@ -585,7 +585,7 @@
 int     found_err;
 
 void
-diag(int level, char *msg,...)
+diag(int level, const char *msg, ...)
 {
 	va_list ap;
 
@@ -642,9 +642,9 @@
 
 
 void
-parsefont(struct fstate *f, char *s0)
+parsefont(struct fstate *f, const char *s0)
 {
-	char   *s = s0;
+	const char *s = s0;
 	int     sizedelta = 0;
 	memset(f, 0, sizeof *f);
 	while (*s) {

Index: src/usr.bin/indent/lexi.c
diff -u src/usr.bin/indent/lexi.c:1.12 src/usr.bin/indent/lexi.c:1.13
--- src/usr.bin/indent/lexi.c:1.12	Thu Aug  7 11:14:09 2003
+++ src/usr.bin/indent/lexi.c	Sun Apr 12 11:09:49 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: lexi.c,v 1.12 2003/08/07 11:14:09 agc Exp $	*/
+/*	$NetBSD: lexi.c,v 1.13 2009/04/12 11:09:49 lukem Exp $	*/
 
 /*
  * Copyright (c) 1980, 1993
@@ -68,7 +68,7 @@
 #if 0
 static char sccsid[] = "@(#)lexi.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: lexi.c,v 1.12 2003/08/07 11:14:09 agc Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.13 2009/04/12 11:09:49 lukem Exp $");
 #endif
 #endif				/* not lint */
 
@@ -89,8 +89,8 @@
 #define opchar 3
 
 struct templ {
-	char   *rwd;
-	int     rwcode;
+	const char	*rwd;
+	int		rwcode;
 };
 
 struct templ specials[1000] =
@@ -181,8 +181,7 @@
 		/*
 		 * we have a character or number
 		 */
-		char   *j;	/* used for searching thru list of
-				 * 
+		const char *j;	/* used for searching thru list of
 				 * reserved words */
 		struct templ *p;
 
@@ -280,17 +279,17 @@
 		 * This loop will check if the token is a keyword.
 		 */
 		for (p = specials; (j = p->rwd) != 0; p++) {
-			char   *p = s_token;	/* point at scanned token */
-			if (*j++ != *p++ || *j++ != *p++)
+			char   *pt = s_token;	/* point at scanned token */
+			if (*j++ != *pt++ || *j++ != *pt++)
 				continue;	/* This test depends on the
 						 * fact that identifiers are
 						 * always at least 1 character
 						 * long (ie. the first two
 						 * bytes of the identifier are
 						 * always meaningful) */
-			if (p[-1] == 0)
+			if (pt[-1] == 0)
 				break;	/* If its a one-character identifier */
-			while (*p++ == *j)
+			while (*pt++ == *j)
 				if (*j++ == 0)
 					goto found_keyword;	/* I wish that C had a
 								 * multi-level break... */

Reply via email to