New upstream version 4.17.3
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
// SPDX-FileCopyrightText: 2024, Alejandro Colomar <alx@kernel.org>
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "string/strspn/stprcspn.h"
|
||||
@@ -0,0 +1,25 @@
|
||||
// SPDX-FileCopyrightText: 2024, Alejandro Colomar <alx@kernel.org>
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
|
||||
#ifndef SHADOW_INCLUDE_LIB_STRING_STRSPN_STPRCSPN_H_
|
||||
#define SHADOW_INCLUDE_LIB_STRING_STRSPN_STPRCSPN_H_
|
||||
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "string/strspn/strrcspn.h"
|
||||
|
||||
|
||||
// string returns-pointer rear complement substring prefix length
|
||||
#define stprcspn(s, reject) \
|
||||
({ \
|
||||
__auto_type s_ = (s); \
|
||||
\
|
||||
s_ + strrcspn(s_, reject); \
|
||||
})
|
||||
|
||||
|
||||
#endif // include guard
|
||||
@@ -0,0 +1,7 @@
|
||||
// SPDX-FileCopyrightText: 2024, Alejandro Colomar <alx@kernel.org>
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "string/strspn/stprspn.h"
|
||||
@@ -0,0 +1,27 @@
|
||||
// SPDX-FileCopyrightText: 2024, Alejandro Colomar <alx@kernel.org>
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
|
||||
#ifndef SHADOW_INCLUDE_LIB_STRING_STRSPN_STPRSPN_H_
|
||||
#define SHADOW_INCLUDE_LIB_STRING_STRSPN_STPRSPN_H_
|
||||
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "string/strspn/strrspn.h"
|
||||
|
||||
|
||||
// string returns-pointer rear substring prefix length
|
||||
// Available in Oracle Solaris as strrspn(3GEN).
|
||||
// <https://docs.oracle.com/cd/E36784_01/html/E36877/strrspn-3gen.html>
|
||||
#define stprspn(s, accept) \
|
||||
({ \
|
||||
__auto_type s_ = (s); \
|
||||
\
|
||||
s_ + strrspn_(s_, accept); \
|
||||
})
|
||||
|
||||
|
||||
#endif // include guard
|
||||
@@ -0,0 +1,7 @@
|
||||
// SPDX-FileCopyrightText: 2024, Alejandro Colomar <alx@kernel.org>
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "string/strspn/stpspn.h"
|
||||
@@ -0,0 +1,27 @@
|
||||
// SPDX-FileCopyrightText: 2024, Alejandro Colomar <alx@kernel.org>
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
|
||||
#ifndef SHADOW_INCLUDE_LIB_STRING_STRSPN_STPSPN_H_
|
||||
#define SHADOW_INCLUDE_LIB_STRING_STRSPN_STPSPN_H_
|
||||
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "attr.h"
|
||||
|
||||
|
||||
// string returns-pointer substring prefix length
|
||||
// Similar to strspn(3), but return a pointer instead of an offset.
|
||||
// Similar to strchrnul(3), but search for any bytes not in 'accept'.
|
||||
#define stpspn(s, accept) \
|
||||
({ \
|
||||
__auto_type s_ = s; \
|
||||
\
|
||||
s_ + strspn(s_, accept); \
|
||||
})
|
||||
|
||||
|
||||
#endif // include guard
|
||||
@@ -0,0 +1,12 @@
|
||||
// SPDX-FileCopyrightText: 2024, Alejandro Colomar <alx@kernel.org>
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "string/strspn/strrcspn.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
|
||||
extern inline size_t strrcspn(const char *s, const char *reject);
|
||||
@@ -0,0 +1,39 @@
|
||||
// SPDX-FileCopyrightText: 2024, Alejandro Colomar <alx@kernel.org>
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
|
||||
#ifndef SHADOW_INCLUDE_LIB_STRING_STRSPN_STRRCSPN_H_
|
||||
#define SHADOW_INCLUDE_LIB_STRING_STRSPN_STRRCSPN_H_
|
||||
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "attr.h"
|
||||
#include "string/strchr/strnul.h"
|
||||
|
||||
|
||||
ATTR_STRING(1)
|
||||
ATTR_STRING(2)
|
||||
inline size_t strrcspn(const char *s, const char *reject);
|
||||
|
||||
|
||||
// string rear complement substring prefix length
|
||||
inline size_t
|
||||
strrcspn(const char *s, const char *reject)
|
||||
{
|
||||
char *p;
|
||||
|
||||
p = strnul(s);
|
||||
while (p > s) {
|
||||
p--;
|
||||
if (strchr(reject, *p) != NULL)
|
||||
return p + 1 - s;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#endif // include guard
|
||||
@@ -0,0 +1,12 @@
|
||||
// SPDX-FileCopyrightText: 2024, Alejandro Colomar <alx@kernel.org>
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "string/strspn/strrspn.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
|
||||
extern inline size_t strrspn_(const char *s, const char *accept);
|
||||
@@ -0,0 +1,39 @@
|
||||
// SPDX-FileCopyrightText: 2024, Alejandro Colomar <alx@kernel.org>
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
|
||||
#ifndef SHADOW_INCLUDE_LIB_STRING_STRSPN_STRRSPN_H_
|
||||
#define SHADOW_INCLUDE_LIB_STRING_STRSPN_STRRSPN_H_
|
||||
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "attr.h"
|
||||
#include "string/strchr/strnul.h"
|
||||
|
||||
|
||||
ATTR_STRING(1)
|
||||
ATTR_STRING(2)
|
||||
inline size_t strrspn_(const char *s, const char *accept);
|
||||
|
||||
|
||||
// string rear substring prefix length
|
||||
inline size_t
|
||||
strrspn_(const char *s, const char *accept)
|
||||
{
|
||||
char *p;
|
||||
|
||||
p = strnul(s);
|
||||
while (p > s) {
|
||||
p--;
|
||||
if (strchr(accept, *p) == NULL)
|
||||
return p + 1 - s;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#endif // include guard
|
||||
Reference in New Issue
Block a user