Skip to content

Re-design strr[c]spn(), to make it simpler and more useful#1559

Open
alejandro-colomar wants to merge 2 commits intoshadow-maint:masterfrom
alejandro-colomar:strrspn
Open

Re-design strr[c]spn(), to make it simpler and more useful#1559
alejandro-colomar wants to merge 2 commits intoshadow-maint:masterfrom
alejandro-colomar:strrspn

Conversation

@alejandro-colomar
Copy link
Collaborator

@alejandro-colomar alejandro-colomar commented Mar 1, 2026

Cc: @kees


Revisions:

v1b
  • Rebase
$ git rd 
1:  a9b6d5b2 = 1:  8378517b lib/string/strspn/: strr[c]spn(): Return the length counting from the end
2:  f7aa9729 = 2:  adb25eda src/login_nopam.c: from_match(): Use strrspn_() instead of its pattern

@alejandro-colomar alejandro-colomar self-assigned this Mar 1, 2026
… end

Instead of returning the offset from the start of the string, return the
length of the span counting from the end.

This makes the name of the function more representative of its behavior,
and also makes the functions more useful: one can use them as booleans
to determine whether a string ends in a set of characters or not.

	if (strrspn(s, "xyz"))  // Does 's' end in any chars of "xyz"?

Currently, the only uses of strr[c]spn() are for implementing
stpr[c]spn(), so we had to update those too.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant