Module Name:    src
Committed By:   dholland
Date:           Sat May  9 23:12:57 UTC 2015

Modified Files:
        src/usr.bin/rpcgen: rpc_cout.c rpc_hout.c rpc_main.c rpc_parse.c
            rpc_scan.c rpc_util.c

Log Message:
Polish the error messages.

Don't use warn/err to print error messages about the input, as
prepending the program name to those both isn't helpful and confuses
programs that try to parse compile logs.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/usr.bin/rpcgen/rpc_cout.c
cvs rdiff -u -r1.22 -r1.23 src/usr.bin/rpcgen/rpc_hout.c
cvs rdiff -u -r1.41 -r1.42 src/usr.bin/rpcgen/rpc_main.c
cvs rdiff -u -r1.18 -r1.19 src/usr.bin/rpcgen/rpc_parse.c
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/rpcgen/rpc_scan.c
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/rpcgen/rpc_util.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/rpcgen/rpc_cout.c
diff -u src/usr.bin/rpcgen/rpc_cout.c:1.33 src/usr.bin/rpcgen/rpc_cout.c:1.34
--- src/usr.bin/rpcgen/rpc_cout.c:1.33	Sun Dec 15 00:40:17 2013
+++ src/usr.bin/rpcgen/rpc_cout.c	Sat May  9 23:12:57 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: rpc_cout.c,v 1.33 2013/12/15 00:40:17 christos Exp $	*/
+/*	$NetBSD: rpc_cout.c,v 1.34 2015/05/09 23:12:57 dholland Exp $	*/
 /*
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  * unrestricted use provided that this legend is included on all tape
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)rpc_cout.c 1.13 89/02/22 (C) 1987 SMI";
 #else
-__RCSID("$NetBSD: rpc_cout.c,v 1.33 2013/12/15 00:40:17 christos Exp $");
+__RCSID("$NetBSD: rpc_cout.c,v 1.34 2015/05/09 23:12:57 dholland Exp $");
 #endif
 #endif
 
@@ -112,7 +112,7 @@ emit(definition *def)
 		break;
 	case DEF_PROGRAM:
 	case DEF_CONST:
-		errx(1, "Internal error %s, %d: Case %d not handled",
+		errx(1, "Internal error at %s:%d: Case %d not handled",
 		    __FILE__, __LINE__, def->def_kind);
 		break;
 	}
@@ -660,7 +660,7 @@ emit_inline(declaration *decl, int flag)
 		break;
 	case REL_ARRAY:
 	case REL_POINTER:
-		errx(1, "Internal error %s, %d: Case %d not handled",
+		errx(1, "Internal error at %s:%d: Case %d not handled",
 		    __FILE__, __LINE__, decl->rel);
 	}
 }

Index: src/usr.bin/rpcgen/rpc_hout.c
diff -u src/usr.bin/rpcgen/rpc_hout.c:1.22 src/usr.bin/rpcgen/rpc_hout.c:1.23
--- src/usr.bin/rpcgen/rpc_hout.c:1.22	Sun Dec 15 00:40:17 2013
+++ src/usr.bin/rpcgen/rpc_hout.c	Sat May  9 23:12:57 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: rpc_hout.c,v 1.22 2013/12/15 00:40:17 christos Exp $	*/
+/*	$NetBSD: rpc_hout.c,v 1.23 2015/05/09 23:12:57 dholland Exp $	*/
 /*
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  * unrestricted use provided that this legend is included on all tape
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)rpc_hout.c 1.12 89/02/22 (C) 1987 SMI";
 #else
-__RCSID("$NetBSD: rpc_hout.c,v 1.22 2013/12/15 00:40:17 christos Exp $");
+__RCSID("$NetBSD: rpc_hout.c,v 1.23 2015/05/09 23:12:57 dholland Exp $");
 #endif
 #endif
 
@@ -281,7 +281,7 @@ define_printed(proc_list *stop, version_
 				}
 		}
 	}
-	errx(1, "Internal error %s, %d: procedure not found",
+	errx(1, "Internal error at %s:%d: procedure not found",
 	    __FILE__, __LINE__);
 	/* NOTREACHED */
 }

Index: src/usr.bin/rpcgen/rpc_main.c
diff -u src/usr.bin/rpcgen/rpc_main.c:1.41 src/usr.bin/rpcgen/rpc_main.c:1.42
--- src/usr.bin/rpcgen/rpc_main.c:1.41	Sat May  9 22:58:22 2015
+++ src/usr.bin/rpcgen/rpc_main.c	Sat May  9 23:12:57 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: rpc_main.c,v 1.41 2015/05/09 22:58:22 dholland Exp $	*/
+/*	$NetBSD: rpc_main.c,v 1.42 2015/05/09 23:12:57 dholland Exp $	*/
 
 /*
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)rpc_main.c 1.30 89/03/30 (C) 1987 SMI";
 #else
-__RCSID("$NetBSD: rpc_main.c,v 1.41 2015/05/09 22:58:22 dholland Exp $");
+__RCSID("$NetBSD: rpc_main.c,v 1.42 2015/05/09 23:12:57 dholland Exp $");
 #endif
 #endif
 
@@ -300,11 +300,11 @@ open_output(const char *infile, const ch
 		return;
 	}
 	if (infile != NULL && streq(outfile, infile)) {
-		errx(EXIT_FAILURE, "output would overwrite `%s'", infile);
+		errx(EXIT_FAILURE, "Output would overwrite `%s'", infile);
 	}
 	fout = fopen(outfile, "w");
 	if (fout == NULL) {
-		err(EXIT_FAILURE, "Can't to open `%s'", outfile);
+		err(EXIT_FAILURE, "Can't open `%s'", outfile);
 	}
 	record_open(outfile);
 
@@ -359,7 +359,7 @@ open_input(const char *infile, const cha
 
 		retval = spawnvp(P_WAIT, arglist[0], arglist);
 		if (retval != 0) {
-			err(EXIT_FAILURE, "C PreProcessor failed");
+			err(EXIT_FAILURE, "C preprocessor failed");
 		}
 		fnsplit(infile, drive, dir, name, ext);
 		fnmerge(cppfile, drive, dir, name, ".i");
@@ -832,7 +832,7 @@ static void
 addarg(const char *cp)
 {
 	if (argcount >= ARGLISTLEN) {
-		errx(EXIT_FAILURE, "too many defines");
+		errx(EXIT_FAILURE, "Internal error: too many defines");
 		/* NOTREACHED */
 	}
 	arglist[argcount++] = cp;
@@ -843,7 +843,7 @@ static void
 putarg(int pwhere, const char *cp)
 {
 	if (pwhere >= ARGLISTLEN) {
-		errx(EXIT_FAILURE, "arglist coding error");
+		errx(EXIT_FAILURE, "Internal error: arglist coding error");
 		/* NOTREACHED */
 	}
 	arglist[pwhere] = cp;
@@ -871,7 +871,7 @@ checkfiles(const char *infile, const cha
 			return;	/* file does not exist */
 		else {
 			errx(EXIT_FAILURE,
-			    "`%s' already exists and may be overwritten",
+			    "`%s' already exists and would be overwritten",
 			    outfile);
 		}
 	}

Index: src/usr.bin/rpcgen/rpc_parse.c
diff -u src/usr.bin/rpcgen/rpc_parse.c:1.18 src/usr.bin/rpcgen/rpc_parse.c:1.19
--- src/usr.bin/rpcgen/rpc_parse.c:1.18	Sun Dec 15 00:40:17 2013
+++ src/usr.bin/rpcgen/rpc_parse.c	Sat May  9 23:12:57 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: rpc_parse.c,v 1.18 2013/12/15 00:40:17 christos Exp $	*/
+/*	$NetBSD: rpc_parse.c,v 1.19 2015/05/09 23:12:57 dholland Exp $	*/
 /*
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  * unrestricted use provided that this legend is included on all tape
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)rpc_parse.c 1.8 89/02/22 (C) 1987 SMI";
 #else
-__RCSID("$NetBSD: rpc_parse.c,v 1.18 2013/12/15 00:40:17 christos Exp $");
+__RCSID("$NetBSD: rpc_parse.c,v 1.19 2015/05/09 23:12:57 dholland Exp $");
 #endif
 #endif
 
@@ -103,7 +103,7 @@ get_definition(void)
 		free(defp);
 		return (NULL);
 	default:
-		error("definition keyword expected");
+		error("Expected definition keyword");
 	}
 	scan(TOK_SEMICOLON, &tok);
 	isdefined(defp);
@@ -175,7 +175,7 @@ def_program(definition *defp)
 			get_type(&plist->res_prefix, &plist->res_type,
 			    DEF_PROGRAM);
 			if (streq(plist->res_type, "opaque")) {
-				error("illegal result type");
+				error("Illegal result type");
 			}
 			scan(TOK_IDENT, &tok);
 			plist->proc_name = tok.str;
@@ -207,10 +207,10 @@ def_program(definition *defp)
 			}
 			/* multiple arguments are only allowed in newstyle */
 			if (!newstyle && num_args > 1) {
-				error("only one argument is allowed");
+				error("Only one argument is allowed");
 			}
 			if (isvoid && num_args > 1) {
-				error("illegal use of void in program definition");
+				error("Illegal use of void in program definition");
 			}
 			*tailp = NULL;
 			scan(TOK_RPAREN, &tok);
@@ -382,7 +382,7 @@ check_type_name(const char *name, int ne
 	for (i = 0; reserved_words[i] != NULL; i++) {
 		if (strcmp(name, reserved_words[i]) == 0) {
 			sprintf(tmp,
-			    "illegal (reserved) name :\'%s\' in type definition", name);
+			    "Illegal (reserved) name '%s' in type definition", name);
 			error(tmp);
 		}
 	}
@@ -390,7 +390,7 @@ check_type_name(const char *name, int ne
 		for (i = 0; reserved_types[i] != NULL; i++) {
 			if (strcmp(name, reserved_types[i]) == 0) {
 				sprintf(tmp,
-				    "illegal (reserved) name :\'%s\' in type definition", name);
+				    "Illegal (reserved) name '%s' in type definition", name);
 				error(tmp);
 			}
 		}
@@ -432,7 +432,7 @@ get_declaration(declaration *dec, defkin
 	dec->name = tok.str;
 	if (peekscan(TOK_LBRACKET, &tok)) {
 		if (dec->rel == REL_POINTER) {
-			error("no array-of-pointer declarations -- use typedef");
+			error("No array-of-pointer declarations -- use typedef");
 		}
 		dec->rel = REL_VECTOR;
 		scan_num(&tok);
@@ -441,7 +441,7 @@ get_declaration(declaration *dec, defkin
 	} else
 		if (peekscan(TOK_LANGLE, &tok)) {
 			if (dec->rel == REL_POINTER) {
-				error("no array-of-pointer declarations -- use typedef");
+				error("No array-of-pointer declarations -- use typedef");
 			}
 			dec->rel = REL_ARRAY;
 			if (peekscan(TOK_RANGLE, &tok)) {
@@ -455,12 +455,12 @@ get_declaration(declaration *dec, defkin
 		}
 	if (streq(dec->type, "opaque")) {
 		if (dec->rel != REL_ARRAY && dec->rel != REL_VECTOR) {
-			error("array declaration expected");
+			error("Array declaration expected");
 		}
 	} else
 		if (streq(dec->type, "string")) {
 			if (dec->rel != REL_ARRAY) {
-				error("variable-length array declaration expected");
+				error("Variable-length array declaration expected");
 			}
 		}
 }
@@ -495,11 +495,11 @@ get_prog_declaration(declaration *dec, d
 		return;
 	}
 	if (streq(dec->type, "opaque")) {
-		error("opaque -- illegal argument type");
+		error("Opaque -- illegal argument type");
 	}
 	if (peekscan(TOK_STAR, &tok)) {
 		if (streq(dec->type, "string")) {
-			error("pointer to string not allowed in program arguments\n");
+			error("Pointer to string not allowed in program arguments\n");
 		}
 		dec->rel = REL_POINTER;
 		if (peekscan(TOK_IDENT, &tok))	/* optional name of argument */
@@ -507,7 +507,7 @@ get_prog_declaration(declaration *dec, d
 	}
 	if (peekscan(TOK_LANGLE, &tok)) {
 		if (!streq(dec->type, "string")) {
-			error("arrays cannot be declared as arguments to procedures -- use typedef");
+			error("Arrays cannot be declared as arguments to procedures -- use typedef");
 		}
 		dec->rel = REL_ARRAY;
 		if (peekscan(TOK_RANGLE, &tok)) {
@@ -567,7 +567,7 @@ get_type(const char **prefixp, const cha
 		break;
 	case TOK_VOID:
 		if (dkind != DEF_UNION && dkind != DEF_PROGRAM) {
-			error("voids allowed only inside union and program definitions with one argument");
+			error("Void is allowed only inside union and program definitions with one argument");
 		}
 		*typep = tok.str;
 		break;
@@ -582,7 +582,7 @@ get_type(const char **prefixp, const cha
 		*typep = tok.str;
 		break;
 	default:
-		error("expected type specifier");
+		error("Type specifier expected");
 	}
 }
 

Index: src/usr.bin/rpcgen/rpc_scan.c
diff -u src/usr.bin/rpcgen/rpc_scan.c:1.13 src/usr.bin/rpcgen/rpc_scan.c:1.14
--- src/usr.bin/rpcgen/rpc_scan.c:1.13	Sun Dec 15 00:40:17 2013
+++ src/usr.bin/rpcgen/rpc_scan.c	Sat May  9 23:12:57 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: rpc_scan.c,v 1.13 2013/12/15 00:40:17 christos Exp $	*/
+/*	$NetBSD: rpc_scan.c,v 1.14 2015/05/09 23:12:57 dholland Exp $	*/
 /*
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  * unrestricted use provided that this legend is included on all tape
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)rpc_scan.c 1.11 89/02/22 (C) 1987 SMI";
 #else
-__RCSID("$NetBSD: rpc_scan.c,v 1.13 2013/12/15 00:40:17 christos Exp $");
+__RCSID("$NetBSD: rpc_scan.c,v 1.14 2015/05/09 23:12:57 dholland Exp $");
 #endif
 #endif
 
@@ -115,7 +115,7 @@ scan_num(token *tokp)
 	case TOK_IDENT:
 		break;
 	default:
-		error("constant or identifier expected");
+		error("Expected constant or identifier");
 	}
 }
 /*
@@ -286,7 +286,7 @@ get_token(token *tokp)
 			char    buf[100];
 			char   *p;
 
-			s_print(buf, "illegal character in file: ");
+			s_print(buf, "Illegal character in file: ");
 			p = buf + strlen(buf);
 			if (isprint((unsigned char)*where)) {
 				s_print(p, "%c", *where);
@@ -319,7 +319,7 @@ findstrconst(char **str, const char **va
 		p++;
 	} while (*p && *p != '"');
 	if (*p == 0) {
-		error("unterminated string constant");
+		error("Unterminated string constant");
 	}
 	p++;
 	size = p - *str;
@@ -342,12 +342,12 @@ findchrconst(char **str, const char **va
 		p++;
 	} while (*p && *p != '\'');
 	if (*p == 0) {
-		error("unterminated string constant");
+		error("Unterminated string constant");
 	}
 	p++;
 	size = p - *str;
 	if (size != 3) {
-		error("empty char string");
+		error("Empty character");
 	}
 	tmp = alloc(size + 1);
 	(void) strncpy(tmp, *str, size);
@@ -477,7 +477,7 @@ docppline(char *line, int *lineno, const
 		line++;
 	}
 	if (*line != '"') {
-		error("preprocessor error");
+		error("Preprocessor error");
 	}
 	line++;
 	p = file = alloc(strlen(line) + 1);
@@ -485,7 +485,7 @@ docppline(char *line, int *lineno, const
 		*p++ = *line++;
 	}
 	if (*line == 0) {
-		error("preprocessor error");
+		error("Preprocessor error");
 	}
 	*p = 0;
 	if (*file == 0) {

Index: src/usr.bin/rpcgen/rpc_util.c
diff -u src/usr.bin/rpcgen/rpc_util.c:1.14 src/usr.bin/rpcgen/rpc_util.c:1.15
--- src/usr.bin/rpcgen/rpc_util.c:1.14	Sat May  9 21:44:47 2015
+++ src/usr.bin/rpcgen/rpc_util.c	Sat May  9 23:12:57 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: rpc_util.c,v 1.14 2015/05/09 21:44:47 christos Exp $	*/
+/*	$NetBSD: rpc_util.c,v 1.15 2015/05/09 23:12:57 dholland Exp $	*/
 /*
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  * unrestricted use provided that this legend is included on all tape
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)rpc_util.c 1.11 89/02/22 (C) 1987 SMI";
 #else
-__RCSID("$NetBSD: rpc_util.c,v 1.14 2015/05/09 21:44:47 christos Exp $");
+__RCSID("$NetBSD: rpc_util.c,v 1.15 2015/05/09 23:12:57 dholland Exp $");
 #endif
 #endif
 
@@ -258,7 +258,8 @@ void
 error(const char *msg)
 {
 	printwhere();
-	errx(EXIT_FAILURE, "%s, line %d: %s", infilename, linenum, msg);
+	f_print(stderr, "%s:%d: %s", infilename, linenum, msg);
+	errx(EXIT_FAILURE, "Cannot recover from this error");
 }
 /*
  * Something went wrong, unlink any files that we may have created and then
@@ -283,7 +284,7 @@ record_open(const char *file)
 	if (nfiles < NFILES) {
 		outfiles[nfiles++] = file;
 	} else {
-		errx(EXIT_FAILURE, "too many files!");
+		errx(EXIT_FAILURE, "Too many files!");
 	}
 }
 
@@ -295,7 +296,7 @@ static char expectbuf[100];
 void
 expected1(tok_kind exp1)
 {
-	s_print(expectbuf, "expected '%s'",
+	s_print(expectbuf, "Expected '%s'",
 	    toktostr(exp1));
 	error(expectbuf);
 }
@@ -305,7 +306,7 @@ expected1(tok_kind exp1)
 void
 expected2(tok_kind exp1, tok_kind exp2)
 {
-	s_print(expectbuf, "expected '%s' or '%s'",
+	s_print(expectbuf, "Expected '%s' or '%s'",
 	    toktostr(exp1),
 	    toktostr(exp2));
 	error(expectbuf);
@@ -316,7 +317,7 @@ expected2(tok_kind exp1, tok_kind exp2)
 void
 expected3(tok_kind exp1, tok_kind exp2, tok_kind exp3)
 {
-	s_print(expectbuf, "expected '%s', '%s' or '%s'",
+	s_print(expectbuf, "Expected '%s', '%s', or '%s'",
 	    toktostr(exp1),
 	    toktostr(exp2),
 	    toktostr(exp3));

Reply via email to