Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 29064
b: refs/heads/master
c: 481fad4
h: refs/heads/master
v: v3
  • Loading branch information
Pekka Enberg authored and Linus Torvalds committed Jun 23, 2006
1 parent e3ddc9a commit 7f418e3
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3fa2164d03fb7af17fcfe4f8800dd754fbd99ff7
refs/heads/master: 481fad483487ea967fe20bbc9e565d787f7bf20f
1 change: 1 addition & 0 deletions trunk/include/linux/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ extern char * strnchr(const char *, size_t, int);
#ifndef __HAVE_ARCH_STRRCHR
extern char * strrchr(const char *,int);
#endif
extern char * strstrip(char *);
#ifndef __HAVE_ARCH_STRSTR
extern char * strstr(const char *,const char *);
#endif
Expand Down
30 changes: 30 additions & 0 deletions trunk/lib/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,36 @@ char *strnchr(const char *s, size_t count, int c)
EXPORT_SYMBOL(strnchr);
#endif

/**
* strstrip - Removes leading and trailing whitespace from @s.
* @s: The string to be stripped.
*
* Note that the first trailing whitespace is replaced with a %NUL-terminator
* in the given string @s. Returns a pointer to the first non-whitespace
* character in @s.
*/
char *strstrip(char *s)
{
size_t size;
char *end;

size = strlen(s);

if (!size)
return s;

end = s + size - 1;
while (end != s && isspace(*end))
end--;
*(end + 1) = '\0';

while (*s && isspace(*s))
s++;

return s;
}
EXPORT_SYMBOL(strstrip);

#ifndef __HAVE_ARCH_STRLEN
/**
* strlen - Find the length of a string
Expand Down

0 comments on commit 7f418e3

Please sign in to comment.