diff options
| author | Steve French <sfrench@us.ibm.com> | 2008-05-06 13:55:32 -0400 |
|---|---|---|
| committer | Steve French <sfrench@us.ibm.com> | 2008-05-06 13:55:32 -0400 |
| commit | a815752ac0ffdb910e92958d41d28f4fb28e5296 (patch) | |
| tree | a3aa16a282354da0debe8e3a3a7ed8aac6e54001 /lib/string.c | |
| parent | 5ade9deaaa3e1f7291467d97b238648e43eae15e (diff) | |
| parent | a15306365a16380f3bafee9e181ba01231d4acd7 (diff) | |
Merge branch 'master' of /pub/scm/linux/kernel/git/torvalds/linux-2.6
Diffstat (limited to 'lib/string.c')
| -rw-r--r-- | lib/string.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/string.c b/lib/string.c index 5efafed3d6b6..b19b87af65a3 100644 --- a/lib/string.c +++ b/lib/string.c | |||
| @@ -493,6 +493,33 @@ char *strsep(char **s, const char *ct) | |||
| 493 | EXPORT_SYMBOL(strsep); | 493 | EXPORT_SYMBOL(strsep); |
| 494 | #endif | 494 | #endif |
| 495 | 495 | ||
| 496 | /** | ||
| 497 | * sysfs_streq - return true if strings are equal, modulo trailing newline | ||
| 498 | * @s1: one string | ||
| 499 | * @s2: another string | ||
| 500 | * | ||
| 501 | * This routine returns true iff two strings are equal, treating both | ||
| 502 | * NUL and newline-then-NUL as equivalent string terminations. It's | ||
| 503 | * geared for use with sysfs input strings, which generally terminate | ||
| 504 | * with newlines but are compared against values without newlines. | ||
| 505 | */ | ||
| 506 | bool sysfs_streq(const char *s1, const char *s2) | ||
| 507 | { | ||
| 508 | while (*s1 && *s1 == *s2) { | ||
| 509 | s1++; | ||
| 510 | s2++; | ||
| 511 | } | ||
| 512 | |||
| 513 | if (*s1 == *s2) | ||
| 514 | return true; | ||
| 515 | if (!*s1 && *s2 == '\n' && !s2[1]) | ||
| 516 | return true; | ||
| 517 | if (*s1 == '\n' && !s1[1] && !*s2) | ||
| 518 | return true; | ||
| 519 | return false; | ||
| 520 | } | ||
| 521 | EXPORT_SYMBOL(sysfs_streq); | ||
| 522 | |||
| 496 | #ifndef __HAVE_ARCH_MEMSET | 523 | #ifndef __HAVE_ARCH_MEMSET |
| 497 | /** | 524 | /** |
| 498 | * memset - Fill a region of memory with the given value | 525 | * memset - Fill a region of memory with the given value |
