| Line | |
|---|
| 1 | /* fast strcmp -- Copyright (C) 2003 Thomas M. Ogrisegg <tom@hi-tek.fnord.at> */ |
|---|
| 2 | #include <string.h> |
|---|
| 3 | #include "dietfeatures.h" |
|---|
| 4 | #include "dietstring.h" |
|---|
| 5 | |
|---|
| 6 | int |
|---|
| 7 | strcmp (const char *s1, const char *s2) |
|---|
| 8 | { |
|---|
| 9 | #ifdef WANT_SMALL_STRING_ROUTINES |
|---|
| 10 | while (*s1 && *s1 == *s2) |
|---|
| 11 | s1++, s2++; |
|---|
| 12 | return (*s1 - *s2); |
|---|
| 13 | #else |
|---|
| 14 | const unsigned long *lx1, *lx2; |
|---|
| 15 | unsigned long l1, l2; |
|---|
| 16 | int tmp; |
|---|
| 17 | |
|---|
| 18 | if (UNALIGNED(s1, s2)) { |
|---|
| 19 | while (*s1 && *s1 == *s2) s1++, s2++; |
|---|
| 20 | return (*s1 - *s2); |
|---|
| 21 | } |
|---|
| 22 | |
|---|
| 23 | if ((tmp = STRALIGN(s1))) |
|---|
| 24 | for (; tmp--; s1++, s2++) |
|---|
| 25 | if (!*s1 || *s1 != *s2) |
|---|
| 26 | return (*s1 - *s2); |
|---|
| 27 | |
|---|
| 28 | lx1 = (unsigned long *) s1; |
|---|
| 29 | lx2 = (unsigned long *) s2; |
|---|
| 30 | |
|---|
| 31 | while (1) { |
|---|
| 32 | l1 = *lx1++; |
|---|
| 33 | l2 = *lx2++; |
|---|
| 34 | if ((((l1 - MKW(0x1ul)) & ~l1) & MKW(0x80ul)) || |
|---|
| 35 | ((((l2 - MKW(0x1ul)) & ~l2) & MKW(0x80ul))) || l1 != l2) { |
|---|
| 36 | unsigned char c1, c2; |
|---|
| 37 | while (1) { |
|---|
| 38 | c1 = GFC(l1); |
|---|
| 39 | c2 = GFC(l2); |
|---|
| 40 | if (!c1 || c1 != c2) |
|---|
| 41 | return (c1 - c2); |
|---|
| 42 | INCSTR(l1); |
|---|
| 43 | INCSTR(l2); |
|---|
| 44 | } |
|---|
| 45 | } |
|---|
| 46 | } |
|---|
| 47 | #endif |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | int strcoll(const char *s,const char* t) __attribute__((weak,alias("strcmp"))); |
|---|
Note: See
TracBrowser
for help on using the repository browser.