diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-01-16 15:27:25 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-01-16 15:27:25 -0500 |
| commit | 6ccc347b699681a0b21c2f7b1a1f85500a58c6b8 (patch) | |
| tree | abe33c75ae53d445abde0e5986b96ef696501d38 /lib | |
| parent | eb29a5cc0b601c458bae9df2f6c3696d75c2d383 (diff) | |
| parent | d1303dd1d6b220cab375f24fa91a5640e54e169e (diff) | |
Merge branch 'tracing-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'tracing-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
tracing/filters: Add comment for match callbacks
tracing/filters: Fix MATCH_FULL filter matching for PTR_STRING
tracing/filters: Fix MATCH_MIDDLE_ONLY filter matching
lib: Introduce strnstr()
tracing/filters: Fix MATCH_END_ONLY filter matching
tracing/filters: Fix MATCH_FRONT_ONLY filter matching
ftrace: Fix MATCH_END_ONLY function filter
tracing/x86: Derive arch from bits argument in recordmcount.pl
ring-buffer: Add rb_list_head() wrapper around new reader page next field
ring-buffer: Wrap a list.next reference with rb_list_head()
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/string.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/lib/string.c b/lib/string.c index 9f75b4ec50b8..a1cdcfcc42d0 100644 --- a/lib/string.c +++ b/lib/string.c | |||
| @@ -667,7 +667,7 @@ EXPORT_SYMBOL(memscan); | |||
| 667 | */ | 667 | */ |
| 668 | char *strstr(const char *s1, const char *s2) | 668 | char *strstr(const char *s1, const char *s2) |
| 669 | { | 669 | { |
| 670 | int l1, l2; | 670 | size_t l1, l2; |
| 671 | 671 | ||
| 672 | l2 = strlen(s2); | 672 | l2 = strlen(s2); |
| 673 | if (!l2) | 673 | if (!l2) |
| @@ -684,6 +684,31 @@ char *strstr(const char *s1, const char *s2) | |||
| 684 | EXPORT_SYMBOL(strstr); | 684 | EXPORT_SYMBOL(strstr); |
| 685 | #endif | 685 | #endif |
| 686 | 686 | ||
| 687 | #ifndef __HAVE_ARCH_STRNSTR | ||
| 688 | /** | ||
| 689 | * strnstr - Find the first substring in a length-limited string | ||
| 690 | * @s1: The string to be searched | ||
| 691 | * @s2: The string to search for | ||
| 692 | * @len: the maximum number of characters to search | ||
| 693 | */ | ||
| 694 | char *strnstr(const char *s1, const char *s2, size_t len) | ||
| 695 | { | ||
| 696 | size_t l1 = len, l2; | ||
| 697 | |||
| 698 | l2 = strlen(s2); | ||
| 699 | if (!l2) | ||
| 700 | return (char *)s1; | ||
| 701 | while (l1 >= l2) { | ||
| 702 | l1--; | ||
| 703 | if (!memcmp(s1, s2, l2)) | ||
| 704 | return (char *)s1; | ||
| 705 | s1++; | ||
| 706 | } | ||
| 707 | return NULL; | ||
| 708 | } | ||
| 709 | EXPORT_SYMBOL(strnstr); | ||
| 710 | #endif | ||
| 711 | |||
| 687 | #ifndef __HAVE_ARCH_MEMCHR | 712 | #ifndef __HAVE_ARCH_MEMCHR |
| 688 | /** | 713 | /** |
| 689 | * memchr - Find a character in an area of memory. | 714 | * memchr - Find a character in an area of memory. |
