Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

lib/string/: Compact files#1651

Open
alejandro-colomar wants to merge 3 commits into
shadow-maint:master from
alejandro-colomar:sspn
Open

lib/string/: Compact files #1651
alejandro-colomar wants to merge 3 commits into
shadow-maint:master from
alejandro-colomar:sspn

Conversation

@alejandro-colomar

@alejandro-colomar alejandro-colomar commented Jun 20, 2026
edited
Loading

Copy link
Copy Markdown
Collaborator

(And use stpspn() in one more place, to simplify some code, and make it more explicit.)


Revisions:

v2
  • Also compact lib/string/strcmp/.
$ git rd 
1: f865a4ba61bb = 1: f865a4ba61bb lib/, src/, lib/string/strspn/: Compact files
2: 5274442fc893 = 2: 5274442fc893 lib/limits.c: Use stpspn() to simplify
-: ------------ > 3: 0b112a7cc9eb lib/, src/, lib/string/strcmp/: Compact files
v2b
  • Reduce whitespace.
  • Improve comment.
$ git rd 
1: f865a4ba61bb ! 1: fe4ccbda8b05 lib/, src/, lib/string/strspn/: Compact files
 @@ lib/string/strspn/stprspn.h (deleted)
 -})
 -
 -
 +-#endif // include guard
 +
 + ## lib/string/strspn/stpspn.h (deleted) ##
 +@@
 +-// 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
 
 ## lib/string/strspn/strrcspn.h ##
 @@ lib/string/strspn/stpspn.c => lib/string/strspn/strspn.c
 -#include "string/strspn/stpspn.h"
 +#include "string/strspn/strspn.h"
 
 - ## lib/string/strspn/stpspn.h => lib/string/strspn/strspn.h ##
 + ## lib/string/strspn/strspn.h (new) ##
 @@
 - // SPDX-License-Identifier: BSD-3-Clause
 - 
 - 
 --#ifndef SHADOW_INCLUDE_LIB_STRING_STRSPN_STPSPN_H_
 --#define SHADOW_INCLUDE_LIB_STRING_STRSPN_STPSPN_H_
 ++// SPDX-FileCopyrightText: 2024, Alejandro Colomar <alx@kernel.org>
 ++// SPDX-License-Identifier: BSD-3-Clause
 ++
 ++
 +#ifndef SHADOW_INCLUDE_LIB_STRING_STRSPN_STRSPN_H_
 +#define SHADOW_INCLUDE_LIB_STRING_STRSPN_STRSPN_H_
 - 
 - 
 - #include "config.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'.
 -+// stpspn - string offset-pointer substring prefix length
 - #define stpspn(s, accept) \
 - ({ \
 - __auto_type s_ = s; \
 ++
 ++
 ++#include "config.h"
 ++
 ++#include <string.h>
 ++
 ++#include "attr.h"
 ++
 ++
 ++// stpspn - string offset-pointer span
 ++#define stpspn(s, accept) \
 ++({ \
 ++ __auto_type s_ = s; \
 ++ \
 ++ s_ + strspn(s_, accept); \
 ++})
 ++
 ++
 ++#endif // include guard
 
 ## src/login_nopam.c ##
 @@
2: 5274442fc893 = 2: 6bac1f4b8951 lib/limits.c: Use stpspn() to simplify
3: 0b112a7cc9eb = 3: c4a36d59e349 lib/, src/, lib/string/strcmp/: Compact files

@alejandro-colomar alejandro-colomar changed the title (削除) lib/string/strspn/: Compact files (削除ここまで) (追記) lib/string/: Compact files (追記ここまで) Jun 20, 2026
Put together str*() and corresponding stp*() APIs in the same file.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
This loop accepts and skips contiguous commas. Let's acknowledge that
by using code that explicitly does this (and which is also simpler,
avoiding a conditional operator).
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Comment thread lib/limits.c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@hallyn hallyn Awaiting requested review from hallyn
@ikerexxe ikerexxe Awaiting requested review from ikerexxe

At least 1 approving review is required to merge this pull request.

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /