From: Alejandro Colomar Date: Tue, 14 Oct 2025 11:16:31 +0000 (+0200) Subject: */: s/STRSEP2ARR/strsep2arr_a/ X-Git-Tag: 4.19.0-rc1~66 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=af3f3202d0912b147f3bb034f91ff45aa1dac81f;p=thirdparty%2Fshadow.git */: s/STRSEP2ARR/strsep2arr_a/ This name better reflects that it handles arrays, and doesn't shout. This case is slightly different, as this macro does a little bit more than just enforcing arrays. It changes the return value too. However, that is related-enough to the handling of arrays that I'm inclined to accept it as a minor inconsistency. Signed-off-by: Alejandro Colomar --- diff --git a/lib/port.c b/lib/port.c index d5338a8ad..357be218c 100644 --- a/lib/port.c +++ b/lib/port.c @@ -148,7 +148,7 @@ next: stpsep(buf, "\n"); - if (STRSEP2ARR(buf, ":", fields) == -1) + if (strsep2arr_a(buf, ":", fields) == -1) goto next; /* diff --git a/lib/shadow/group/sgetgrent.c b/lib/shadow/group/sgetgrent.c index 744a8f5cb..2a13091ef 100644 --- a/lib/shadow/group/sgetgrent.c +++ b/lib/shadow/group/sgetgrent.c @@ -71,7 +71,7 @@ sgetgrent(const char *s) stpsep(dup, "\n"); - if (STRSEP2ARR(dup, ":", fields) == -1) + if (strsep2arr_a(dup, ":", fields) == -1) return NULL; if (streq(fields[2], "")) diff --git a/lib/shadow/gshadow/sgetsgent.c b/lib/shadow/gshadow/sgetsgent.c index 38dce1c0c..a239b45ad 100644 --- a/lib/shadow/gshadow/sgetsgent.c +++ b/lib/shadow/gshadow/sgetsgent.c @@ -43,7 +43,7 @@ sgetsgent(const char *s) stpsep(dup, "\n"); - if (STRSEP2ARR(dup, ":", fields) == -1) + if (strsep2arr_a(dup, ":", fields) == -1) return NULL; sgroup.sg_namp = fields[0]; diff --git a/lib/shadow/passwd/sgetpwent.c b/lib/shadow/passwd/sgetpwent.c index ddea1384b..1d4a06070 100644 --- a/lib/shadow/passwd/sgetpwent.c +++ b/lib/shadow/passwd/sgetpwent.c @@ -53,7 +53,7 @@ sgetpwent(const char *s) stpsep(dup, "\n"); - if (STRSEP2ARR(dup, ":", fields) == -1) + if (strsep2arr_a(dup, ":", fields) == -1) return NULL; /* diff --git a/lib/string/README b/lib/string/README index 431a81d4d..192b7eb3a 100644 --- a/lib/string/README +++ b/lib/string/README @@ -264,7 +264,7 @@ strsep/ - String separation Loop around strsep(3) to fill an array of buffers with all the delimited strings that have been split. Useful when the number of delimiter-separated fields is known. - STRSEP2ARR() + strsep2arr_a() Like strsep2arr(), but take an array, and simplify error checks. strsep2ls() diff --git a/lib/string/strtok/strsep2arr.h b/lib/string/strtok/strsep2arr.h index 6c98502f9..f96ddfdd7 100644 --- a/lib/string/strtok/strsep2arr.h +++ b/lib/string/strtok/strsep2arr.h @@ -17,7 +17,8 @@ #include "sizeof.h" -#define STRSEP2ARR(s, delim, a) \ +// strsep2arr_a - string separate to array-of-strings array +#define strsep2arr_a(s, delim, a) \ ( \ strsep2arr(s, delim, countof(a), a) == countof(a) ? 0 : -1 \ ) @@ -29,9 +30,7 @@ inline ssize_t strsep2arr(char *s, const char *restrict delim, size_t n, char *a[restrict n]); -// string separate to array-of-strings -// strsep(3) a string into an array of strings. -// Return the number of fields in the string, or -1 on error. +// strsep2arr - string separate to array-of-strings inline ssize_t strsep2arr(char *s, const char *restrict delim, size_t n, char *a[restrict n]) { diff --git a/lib/subordinateio.c b/lib/subordinateio.c index 37f6ab2f8..ff9e75b88 100644 --- a/lib/subordinateio.c +++ b/lib/subordinateio.c @@ -97,7 +97,7 @@ subordinate_parse(const char *line) return NULL; /* fail if too long */ strcpy (rangebuf, line); - if (STRSEP2ARR(rangebuf, ":", fields) == -1) + if (strsep2arr_a(rangebuf, ":", fields) == -1) return NULL; if (streq(fields[0], "")) diff --git a/src/newusers.c b/src/newusers.c index 818f73fa2..fe2b2a908 100644 --- a/src/newusers.c +++ b/src/newusers.c @@ -1117,7 +1117,7 @@ int main (int argc, char **argv) fail_exit (EXIT_FAILURE, process_selinux); } - if (STRSEP2ARR(buf, ":", fields) == -1) { + if (strsep2arr_a(buf, ":", fields) == -1) { fprintf (stderr, _("%s: line %jd: invalid line\n"), Prog, line); fail_exit (EXIT_FAILURE, process_selinux);