Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
bbeabef1
Commit
bbeabef1
authored
Nov 16, 2002
by
Rusty Russell
Committed by
Linus Torvalds
Nov 16, 2002
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PATCH] add strcspn() library function
This patch implements a generic strcspn.
parent
66f67a6b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
1 deletion
+24
-1
include/linux/string.h
include/linux/string.h
+1
-1
lib/string.c
lib/string.c
+23
-0
No files found.
include/linux/string.h
View file @
bbeabef1
...
...
@@ -15,7 +15,7 @@ extern "C" {
extern
char
*
strpbrk
(
const
char
*
,
const
char
*
);
extern
char
*
strsep
(
char
**
,
const
char
*
);
extern
__kernel_size_t
strspn
(
const
char
*
,
const
char
*
);
extern
__kernel_size_t
strcspn
(
const
char
*
,
const
char
*
);
/*
* Include machine specific inline routines
...
...
lib/string.c
View file @
bbeabef1
...
...
@@ -272,6 +272,29 @@ size_t strspn(const char *s, const char *accept)
}
#endif
/**
* strcspn - Calculate the length of the initial substring of @s which does
* not contain letters in @reject
* @s: The string to be searched
* @reject: The string to avoid
*/
size_t
strcspn
(
const
char
*
s
,
const
char
*
reject
)
{
const
char
*
p
;
const
char
*
r
;
size_t
count
=
0
;
for
(
p
=
s
;
*
p
!=
'\0'
;
++
p
)
{
for
(
r
=
reject
;
*
r
!=
'\0'
;
++
r
)
{
if
(
*
p
==
*
r
)
return
count
;
}
++
count
;
}
return
count
;
}
#ifndef __HAVE_ARCH_STRPBRK
/**
* strpbrk - Find the first occurrence of a set of characters
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment