Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/units Correctly ignore duplicate definitions. "cont...
details: https://anonhg.NetBSD.org/src/rev/b48ee207f549
branches: trunk
changeset: 783615:b48ee207f549
user: apb <apb%NetBSD.org@localhost>
date: Tue Jan 01 11:44:00 2013 +0000
description:
Correctly ignore duplicate definitions. "continue" applies only to the
innermost loop.
diffstat:
usr.bin/units/units.c | 41 ++++++++++++++++++++++++++---------------
1 files changed, 26 insertions(+), 15 deletions(-)
diffs (72 lines):
diff -r be6db8a8dd68 -r b48ee207f549 usr.bin/units/units.c
--- a/usr.bin/units/units.c Tue Jan 01 00:01:23 2013 +0000
+++ b/usr.bin/units/units.c Tue Jan 01 11:44:00 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: units.c,v 1.19 2012/12/28 17:07:03 apb Exp $ */
+/* $NetBSD: units.c,v 1.20 2013/01/01 11:44:00 apb Exp $ */
/*
* units.c Copyright (c) 1993 by Adrian Mariano (adrian%cam.cornell.edu@localhost)
@@ -109,7 +109,7 @@
{
FILE *unitfile;
char line[80], *lineptr;
- int len, linenum, i;
+ int len, linenum, i, isdup;
unitcount = 0;
linenum = 0;
@@ -173,14 +173,20 @@
continue;
}
lineptr[strlen(lineptr) - 1] = 0;
+ for (isdup = 0, i = 0; i < prefixcount; i++) {
+ if (!strcmp(prefixtable[i].prefixname,
+ lineptr)) {
+ isdup = 1;
+ break;
+ }
+ }
+ if (isdup) {
+ warnx(
+ "Redefinition of prefix '%s' on line %d ignored",
+ lineptr, linenum);
+ continue;
+ }
prefixtable[prefixcount].prefixname = dupstr(lineptr);
- for (i = 0; i < prefixcount; i++)
- if (!strcmp(prefixtable[i].prefixname, lineptr)) {
- warnx(
- "Redefinition of prefix '%s' on line %d ignored",
- lineptr, linenum);
- continue;
- }
lineptr += len + 1;
if (!strlen(lineptr)) {
readerror(linenum);
@@ -197,14 +203,19 @@
linenum);
continue;
}
- unittable[unitcount].uname = dupstr(lineptr);
- for (i = 0; i < unitcount; i++)
+ for (isdup = 0, i = 0; i < unitcount; i++) {
if (!strcmp(unittable[i].uname, lineptr)) {
- warnx(
+ isdup = 1;
+ break;
+ }
+ }
+ if (isdup) {
+ warnx(
"Redefinition of unit '%s' on line %d ignored",
- lineptr, linenum);
- continue;
- }
+ lineptr, linenum);
+ continue;
+ }
+ unittable[unitcount].uname = dupstr(lineptr);
lineptr += len + 1;
lineptr += strspn(lineptr, " \n\t");
if (!strlen(lineptr)) {
Home |
Main Index |
Thread Index |
Old Index