summaryrefslogtreecommitdiff
path: root/src/system.h
diff options
context:
space:
mode:
authorBernhard Voelker <mail@bernhard-voelker.de>2015-02-17 08:46:56 +0100
committerBernhard Voelker <mail@bernhard-voelker.de>2015-02-17 08:50:34 +0100
commit9f5dce80702d494535ab332273d20da1f9ca4365 (patch)
tree6b86c2256ba1d4675513f62bb2454d6eec80c998 /src/system.h
parent321bd11352d1f378128d65746852e073f86319d3 (diff)
downloadcoreutils-9f5dce80702d494535ab332273d20da1f9ca4365.tar.xz
maint: prefer STREQ_LEN and STRPREFIX over strncmp in all cases
* cfg.mk (sc_prohibit_strncmp): Improve the search pattern: use _sc_search_regexp to find all invocations of strncmp except when used on a macro definition line; just match the function name with an opening parenthesis. Before, the expression missed places where the comparison against 0 was in a subsequent line. * src/system.h (STRNCMP_LIT): Shorten 'literal' to 'lit' to move the whole definition of the macro into one line - thus making sc_prohibit_strncmp pass. (STRPREFIX): Add space before parenthesis. * src/du.c (main): Prefer STREQ_LEN over strncmp. * src/pinky.c (scan_entries): Likewise. * src/tac.c (tac_seekable): Likewise. * src/who.c (scan_entries): Likewise.
Diffstat (limited to 'src/system.h')
-rw-r--r--src/system.h5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/system.h b/src/system.h
index b6c971d30..46edd07d5 100644
--- a/src/system.h
+++ b/src/system.h
@@ -193,12 +193,11 @@ select_plural (uintmax_t n)
#define STREQ(a, b) (strcmp (a, b) == 0)
#define STREQ_LEN(a, b, n) (strncmp (a, b, n) == 0)
-#define STRPREFIX(a, b) (strncmp(a, b, strlen (b)) == 0)
+#define STRPREFIX(a, b) (strncmp (a, b, strlen (b)) == 0)
/* Just like strncmp, but the second argument must be a literal string
and you don't specify the length; that comes from the literal. */
-#define STRNCMP_LIT(s, literal) \
- strncmp (s, "" literal "", sizeof (literal) - 1)
+#define STRNCMP_LIT(s, lit) strncmp (s, "" lit "", sizeof (lit) - 1)
#if !HAVE_DECL_GETLOGIN
char *getlogin ();