]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/string/strtok/: xastrsep2ls() Reimplement in terms of exit_if_null()
authorAlejandro Colomar <alx@kernel.org>
Sat, 7 Jun 2025 17:29:10 +0000 (19:29 +0200)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Mon, 27 Oct 2025 13:32:06 +0000 (14:32 +0100)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/string/strtok/xastrsep2ls.c
lib/string/strtok/xastrsep2ls.h

index d0711e870d16e1ace68e9845eec47f88ed79f102..c3d43b90cf348c53f40073a10ba283d832986c84 100644 (file)
@@ -1,13 +1,7 @@
-// SPDX-FileCopyrightText: 2024, Alejandro Colomar <alx@kernel.org>
+// SPDX-FileCopyrightText: 2024-2025, Alejandro Colomar <alx@kernel.org>
 // SPDX-License-Identifier: BSD-3-Clause
 
 
 #include "config.h"
 
 #include "string/strtok/xastrsep2ls.h"
-
-#include <stddef.h>
-
-
-extern inline char **xastrsep2ls(char *restrict s, const char *restrict delim,
-    size_t *restrict np);
index b5382cbb217097cb5249424c3114d72b9f29010a..d9710db87f58e36b1e5717a25af3837832337e38 100644 (file)
@@ -1,4 +1,4 @@
-// SPDX-FileCopyrightText: 2024, Alejandro Colomar <alx@kernel.org>
+// SPDX-FileCopyrightText: 2024-2025, Alejandro Colomar <alx@kernel.org>
 // SPDX-License-Identifier: BSD-3-Clause
 
 
@@ -8,39 +8,11 @@
 
 #include "config.h"
 
-#include <errno.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "attr.h"
-#include "shadowlog.h"
+#include "exit_if_null.h"
 #include "string/strtok/astrsep2ls.h"
 
 
-ATTR_ACCESS(read_write, 1) ATTR_ACCESS(write_only, 3)
-ATTR_STRING(1) ATTR_STRING(2)
-inline char **xastrsep2ls(char *restrict s, const char *restrict delim,
-    size_t *restrict np);
-
-
-// exit-on-error allocate string separate to list-of-strings
-inline char **
-xastrsep2ls(char *s, const char *restrict delim, size_t *restrict np)
-{
-       char     **ls;
-
-       ls = astrsep2ls(s, delim, np);
-       if (ls == NULL)
-               goto x;
-
-       return ls;
-x:
-       fprintf(log_get_logfd(), "%s: %s\n",
-               log_get_progname(), strerror(errno));
-       exit(13);
-}
+#define xastrsep2ls(s, delim, np)  exit_if_null(astrsep2ls(s, delim, np))
 
 
 #endif  // include guard