diff --git a/usr.bin/error/error.h b/usr.bin/error/error.h index d7344ee41437..d8f2254efef7 100644 --- a/usr.bin/error/error.h +++ b/usr.bin/error/error.h @@ -1,4 +1,4 @@ -/* $NetBSD: error.h,v 1.20 2023/08/26 14:50:53 rillig Exp $ */ +/* $NetBSD: error.h,v 1.21 2023/08/26 15:18:27 rillig Exp $ */ /* * Copyright (c) 1980, 1993 @@ -281,6 +281,6 @@ char *substitute(char *, char, char); bool touchfiles(int, Eptr **, int *, char ***); const char *verbform(int); void wordvbuild(char *, int*, char ***); -int wordvcmp(char **, int, char **); +bool wordv_eq(char **, int, char **); void wordvprint(FILE *, int, char **); char **wordvsplice(int, int, char **); diff --git a/usr.bin/error/input.c b/usr.bin/error/input.c index beb0d8b58270..8a20ad14e09f 100644 --- a/usr.bin/error/input.c +++ b/usr.bin/error/input.c @@ -1,4 +1,4 @@ -/* $NetBSD: input.c,v 1.20 2023/08/26 14:50:53 rillig Exp $ */ +/* $NetBSD: input.c,v 1.21 2023/08/26 15:18:27 rillig Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)input.c 8.1 (Berkeley) 6/6/93"; #endif -__RCSID("$NetBSD: input.c,v 1.20 2023/08/26 14:50:53 rillig Exp $"); +__RCSID("$NetBSD: input.c,v 1.21 2023/08/26 15:18:27 rillig Exp $"); #endif /* not lint */ #include @@ -488,8 +488,8 @@ lint3(void) { if (cur_wordc < 3) return C_UNKNOWN; - if (wordvcmp(cur_wordv+2, 4, Lint31) == 0 - || wordvcmp(cur_wordv+2, 6, Lint32) == 0) { + if (wordv_eq(cur_wordv+2, 4, Lint31) + || wordv_eq(cur_wordv+2, 6, Lint32)) { language = INLINT; return C_NONSPEC; } @@ -526,7 +526,7 @@ f77(void) * Warning on line %d of %s: %s * Error. No assembly. */ - if (cur_wordc == 3 && wordvcmp(cur_wordv+1, 3, F77_no_ass) == 0) { + if (cur_wordc == 3 && wordv_eq(cur_wordv+1, 3, F77_no_ass)) { cur_wordc = 0; return C_SYNC; } @@ -534,9 +534,9 @@ f77(void) return C_UNKNOWN; if (lastchar(cur_wordv[6]) == ':' && ( - wordvcmp(cur_wordv+1, 3, F77_fatal) == 0 - || wordvcmp(cur_wordv+1, 3, F77_error) == 0 - || wordvcmp(cur_wordv+1, 3, F77_warning) == 0 + wordv_eq(cur_wordv+1, 3, F77_fatal) + || wordv_eq(cur_wordv+1, 3, F77_error) + || wordv_eq(cur_wordv+1, 3, F77_warning) ) ) { language = INF77; @@ -563,11 +563,11 @@ DECL_STRINGS_5(static, Make_NotRemade, static Errorclass make(void) { - if (wordvcmp(cur_wordv+1, 3, Make_Croak) == 0) { + if (wordv_eq(cur_wordv+1, 3, Make_Croak)) { language = INMAKE; return C_SYNC; } - if (wordvcmp(cur_wordv+2, 5, Make_NotRemade) == 0) { + if (wordv_eq(cur_wordv+2, 5, Make_NotRemade)) { language = INMAKE; return C_SYNC; } diff --git a/usr.bin/error/pi.c b/usr.bin/error/pi.c index 5e0ad960a2d8..2517e45c2dff 100644 --- a/usr.bin/error/pi.c +++ b/usr.bin/error/pi.c @@ -1,4 +1,4 @@ -/* $NetBSD: pi.c,v 1.23 2023/08/26 14:59:44 rillig Exp $ */ +/* $NetBSD: pi.c,v 1.24 2023/08/26 15:18:27 rillig Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)pi.c 8.1 (Berkeley) 6/6/93"; #endif -__RCSID("$NetBSD: pi.c,v 1.23 2023/08/26 14:59:44 rillig Exp $"); +__RCSID("$NetBSD: pi.c,v 1.24 2023/08/26 15:18:27 rillig Exp $"); #endif /* not lint */ #include @@ -329,10 +329,10 @@ pi(void) int wordindex; language = INPI; - if ((undefined = (wordvcmp(cur_wordv+2, 3, pi_und1) == 0)) - || (undefined = (wordvcmp(cur_wordv+2, 3, pi_und2) == 0)) - || wordvcmp(cur_wordv+2, 4, pi_imp1) == 0 - || wordvcmp(cur_wordv+2, 4, pi_imp2) == 0 + if ((undefined = wordv_eq(cur_wordv+2, 3, pi_und1)) + || (undefined = wordv_eq(cur_wordv+2, 3, pi_und2)) + || wordv_eq(cur_wordv+2, 4, pi_imp1) + || wordv_eq(cur_wordv+2, 4, pi_imp2) ) { for (wordindex = undefined ? 5 : 6; wordindex <= cur_wordc; @@ -419,10 +419,10 @@ pi(void) structured = false; multiple = false; if ( - (cur_wordc == 6 && wordvcmp(cur_wordv+1, 2, pi_Endmatched) == 0) - || (cur_wordc == 8 && wordvcmp(cur_wordv+1, 4, pi_Inserted) == 0) - || (multiple = (cur_wordc == 9 && wordvcmp(cur_wordv+1,6, pi_multiple) == 0)) - || (structured = (cur_wordc == 10 && wordvcmp(cur_wordv+6,5, pi_structured) == 0)) + (cur_wordc == 6 && wordv_eq(cur_wordv+1, 2, pi_Endmatched)) + || (cur_wordc == 8 && wordv_eq(cur_wordv+1, 4, pi_Inserted)) + || (multiple = (cur_wordc == 9 && wordv_eq(cur_wordv+1,6, pi_multiple))) + || (structured = (cur_wordc == 10 && wordv_eq(cur_wordv+6,5, pi_structured))) ) { language = INPI; nwordv = wordvsplice(2, cur_wordc, cur_wordv+1); diff --git a/usr.bin/error/subr.c b/usr.bin/error/subr.c index 2a872ad1a082..7917f3aed3d9 100644 --- a/usr.bin/error/subr.c +++ b/usr.bin/error/subr.c @@ -1,4 +1,4 @@ -/* $NetBSD: subr.c,v 1.25 2023/08/26 15:07:14 rillig Exp $ */ +/* $NetBSD: subr.c,v 1.26 2023/08/26 15:18:27 rillig Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)subr.c 8.1 (Berkeley) 6/6/93"; #endif -__RCSID("$NetBSD: subr.c,v 1.25 2023/08/26 15:07:14 rillig Exp $"); +__RCSID("$NetBSD: subr.c,v 1.26 2023/08/26 15:18:27 rillig Exp $"); #endif /* not lint */ #include @@ -347,18 +347,14 @@ wordvbuild(char *string, int *r_wordc, char ***r_wordv) /* * Compare two 0 based wordvectors */ -int -wordvcmp(char **wordv1, int wordc, char **wordv2) +bool +wordv_eq(char **wordv1, int wordc, char **wordv2) { - int back; - - for (int i = 0; i < wordc; i++) { - if (wordv1[i] == NULL || wordv2[i] == NULL) - return -1; - if ((back = strcmp(wordv1[i], wordv2[i])) != 0) - return back; - } - return 0; /* they are equal */ + for (int i = 0; i < wordc; i++) + if (wordv1[i] == NULL || wordv2[i] == NULL + || strcmp(wordv1[i], wordv2[i]) != 0) + return false; + return true; } /*