diff options
| author | Takashi Iwai <tiwai@suse.de> | 2009-12-01 09:58:15 -0500 |
|---|---|---|
| committer | Takashi Iwai <tiwai@suse.de> | 2009-12-01 09:58:15 -0500 |
| commit | b00615d163cd24fa98d155acfc1f9d81d6fe1103 (patch) | |
| tree | dde815788aaea3e336aaaf24763311ce63a22e1b /lib/string.c | |
| parent | 75639e7ee1401b3876c7a00ffe96ea8027668690 (diff) | |
| parent | d6797322231af98b9bb4afb175dd614cf511e5f7 (diff) | |
Merge branch 'topic/pcm-dma-fix' into topic/core-change
Diffstat (limited to 'lib/string.c')
| -rw-r--r-- | lib/string.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/string.c b/lib/string.c index b19b87af65a3..e96421ab9a9a 100644 --- a/lib/string.c +++ b/lib/string.c | |||
| @@ -246,13 +246,17 @@ EXPORT_SYMBOL(strlcat); | |||
| 246 | #undef strcmp | 246 | #undef strcmp |
| 247 | int strcmp(const char *cs, const char *ct) | 247 | int strcmp(const char *cs, const char *ct) |
| 248 | { | 248 | { |
| 249 | signed char __res; | 249 | unsigned char c1, c2; |
| 250 | 250 | ||
| 251 | while (1) { | 251 | while (1) { |
| 252 | if ((__res = *cs - *ct++) != 0 || !*cs++) | 252 | c1 = *cs++; |
| 253 | c2 = *ct++; | ||
| 254 | if (c1 != c2) | ||
| 255 | return c1 < c2 ? -1 : 1; | ||
| 256 | if (!c1) | ||
| 253 | break; | 257 | break; |
| 254 | } | 258 | } |
| 255 | return __res; | 259 | return 0; |
| 256 | } | 260 | } |
| 257 | EXPORT_SYMBOL(strcmp); | 261 | EXPORT_SYMBOL(strcmp); |
| 258 | #endif | 262 | #endif |
| @@ -266,14 +270,18 @@ EXPORT_SYMBOL(strcmp); | |||
| 266 | */ | 270 | */ |
| 267 | int strncmp(const char *cs, const char *ct, size_t count) | 271 | int strncmp(const char *cs, const char *ct, size_t count) |
| 268 | { | 272 | { |
| 269 | signed char __res = 0; | 273 | unsigned char c1, c2; |
| 270 | 274 | ||
| 271 | while (count) { | 275 | while (count) { |
| 272 | if ((__res = *cs - *ct++) != 0 || !*cs++) | 276 | c1 = *cs++; |
| 277 | c2 = *ct++; | ||
| 278 | if (c1 != c2) | ||
| 279 | return c1 < c2 ? -1 : 1; | ||
| 280 | if (!c1) | ||
| 273 | break; | 281 | break; |
| 274 | count--; | 282 | count--; |
| 275 | } | 283 | } |
| 276 | return __res; | 284 | return 0; |
| 277 | } | 285 | } |
| 278 | EXPORT_SYMBOL(strncmp); | 286 | EXPORT_SYMBOL(strncmp); |
| 279 | #endif | 287 | #endif |
