New upstream version 4.19.0
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
|
||||
#include <config.h>
|
||||
#include "config.h"
|
||||
|
||||
#include "string/strtok/astrsep2ls.h"
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -6,24 +6,28 @@
|
||||
#define SHADOW_INCLUDE_LIB_STRING_STRTOK_ASTRSEP2LS_H_
|
||||
|
||||
|
||||
#include <config.h>
|
||||
#include "config.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "alloc/malloc.h"
|
||||
#include "attr.h"
|
||||
#include "exit_if_null.h"
|
||||
#include "string/strchr/strchrscnt.h"
|
||||
#include "string/strtok/strsep2ls.h"
|
||||
|
||||
|
||||
// xastrsep2ls - exit-on-error allocate string separate to list-of-strings
|
||||
#define xastrsep2ls(s, delim, np) exit_if_null(astrsep2ls(s, delim, np))
|
||||
|
||||
|
||||
ATTR_ACCESS(read_write, 1) ATTR_ACCESS(write_only, 3)
|
||||
ATTR_STRING(1) ATTR_STRING(2)
|
||||
inline char **astrsep2ls(char *restrict s, const char *restrict delim,
|
||||
size_t *restrict np);
|
||||
|
||||
|
||||
// allocate string separate to list-of-strings
|
||||
// Like strsep2ls(), but allocate the list array.
|
||||
// astrsep2ls - allocate string separate to list-of-strings
|
||||
inline char **
|
||||
astrsep2ls(char *s, const char *restrict delim, size_t *restrict np)
|
||||
{
|
||||
@@ -32,7 +36,7 @@ astrsep2ls(char *s, const char *restrict delim, size_t *restrict np)
|
||||
|
||||
n = strchrscnt(s, delim) + 2;
|
||||
|
||||
ls = MALLOC(n, char *);
|
||||
ls = malloc_T(n, char *);
|
||||
if (ls == NULL)
|
||||
return NULL;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
|
||||
#include <config.h>
|
||||
#include "config.h"
|
||||
|
||||
#include "string/strtok/stpsep.h"
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#define SHADOW_INCLUDE_LIB_STRING_STRTOK_STPSEP_H_
|
||||
|
||||
|
||||
#include <config.h>
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
|
||||
#include <config.h>
|
||||
#include "config.h"
|
||||
|
||||
#include "string/strtok/strsep2arr.h"
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#define SHADOW_INCLUDE_LIB_STRING_STRTOK_STRSEP2ARR_H_
|
||||
|
||||
|
||||
#include <config.h>
|
||||
#include "config.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <stddef.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])
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
|
||||
#include <config.h>
|
||||
#include "config.h"
|
||||
|
||||
#include "string/strtok/strsep2ls.h"
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#define SHADOW_INCLUDE_LIB_STRING_STRTOK_STRSEP2LS_H_
|
||||
|
||||
|
||||
#include <config.h>
|
||||
#include "config.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <stddef.h>
|
||||
@@ -17,7 +17,8 @@
|
||||
#include "string/strtok/strsep2arr.h"
|
||||
|
||||
|
||||
#define STRSEP2LS(s, delim, ls) strsep2ls(s, delim, countof(ls), ls)
|
||||
// strsep2ls_a - string separate to list-of-strings array
|
||||
#define strsep2ls_a(s, delim, ls) strsep2ls(s, delim, countof(ls), ls)
|
||||
|
||||
|
||||
ATTR_ACCESS(read_write, 1) ATTR_ACCESS(write_only, 4, 3)
|
||||
@@ -26,7 +27,7 @@ inline ssize_t strsep2ls(char *s, const char *restrict delim,
|
||||
size_t n, char *ls[restrict n]);
|
||||
|
||||
|
||||
// string separate to list-of-strings
|
||||
// strsep2ls - string separate to list-of-strings
|
||||
// Like strsep2arr(), but add a NULL terminator.
|
||||
inline ssize_t
|
||||
strsep2ls(char *s, const char *restrict delim, size_t n, char *ls[restrict n])
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
// SPDX-FileCopyrightText: 2024, 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);
|
||||
@@ -1,46 +0,0 @@
|
||||
// SPDX-FileCopyrightText: 2024, Alejandro Colomar <alx@kernel.org>
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
|
||||
#ifndef SHADOW_INCLUDE_LIB_STRING_STRTOK_XASTRSEP2LS_H_
|
||||
#define SHADOW_INCLUDE_LIB_STRING_STRTOK_XASTRSEP2LS_H_
|
||||
|
||||
|
||||
#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 "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);
|
||||
}
|
||||
|
||||
|
||||
#endif // include guard
|
||||
Reference in New Issue
Block a user