Rev | Line | |
---|
[32] | 1 | /* strncmp.c (emx+gcc) -- Copyright (c) 1990-1995 by Eberhard Mattes */
|
---|
| 2 |
|
---|
| 3 | #include <string.h>
|
---|
| 4 |
|
---|
| 5 | int strcmp (const char *string1, const char *string2)
|
---|
| 6 | {
|
---|
| 7 | int d;
|
---|
| 8 |
|
---|
| 9 | for (;;)
|
---|
| 10 | {
|
---|
| 11 | d = (int)(unsigned char)*string1 - (int)(unsigned char)*string2;
|
---|
| 12 | if (d != 0 || *string1 == 0 || *string2 == 0)
|
---|
| 13 | return d;
|
---|
| 14 | ++string1; ++string2;
|
---|
| 15 | }
|
---|
| 16 | }
|
---|
| 17 |
|
---|
| 18 | int strncmp (const char *string1, const char *string2, size_t count)
|
---|
| 19 | {
|
---|
| 20 | int d;
|
---|
| 21 |
|
---|
| 22 | while (count != 0)
|
---|
| 23 | {
|
---|
| 24 | d = (int)(unsigned char)*string1 - (int)(unsigned char)*string2;
|
---|
| 25 | if (d != 0 || *string1 == 0 || *string2 == 0)
|
---|
| 26 | return d;
|
---|
| 27 | ++string1; ++string2;
|
---|
| 28 | --count;
|
---|
| 29 | }
|
---|
| 30 | return 0;
|
---|
| 31 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.