clang-format
This commit is contained in:
@@ -44,47 +44,44 @@
|
||||
* sort order.
|
||||
*/
|
||||
|
||||
int
|
||||
strcmp(const char *a, const char *b)
|
||||
{
|
||||
size_t i;
|
||||
int strcmp(const char *a, const char *b) {
|
||||
size_t i;
|
||||
|
||||
/*
|
||||
* Walk down both strings until either they're different
|
||||
* or we hit the end of A.
|
||||
*
|
||||
* If A and B strings are not the same length, when the
|
||||
* shorter one ends, the two will be different, and we'll
|
||||
* stop before running off the end of either.
|
||||
*
|
||||
* If they *are* the same length, it's sufficient to check
|
||||
* that we haven't run off the end of A, because that's the
|
||||
* same as checking to make sure we haven't run off the end of
|
||||
* B.
|
||||
*/
|
||||
/*
|
||||
* Walk down both strings until either they're different
|
||||
* or we hit the end of A.
|
||||
*
|
||||
* If A and B strings are not the same length, when the
|
||||
* shorter one ends, the two will be different, and we'll
|
||||
* stop before running off the end of either.
|
||||
*
|
||||
* If they *are* the same length, it's sufficient to check
|
||||
* that we haven't run off the end of A, because that's the
|
||||
* same as checking to make sure we haven't run off the end of
|
||||
* B.
|
||||
*/
|
||||
|
||||
for (i=0; a[i]!=0 && a[i]==b[i]; i++) {
|
||||
/* nothing */
|
||||
}
|
||||
for (i = 0; a[i] != 0 && a[i] == b[i]; i++) {
|
||||
/* nothing */
|
||||
}
|
||||
|
||||
/*
|
||||
* If A is greater than B, return 1. If A is less than B,
|
||||
* return -1. If they're the same, return 0. Since we have
|
||||
* stopped at the first character of difference (or the end of
|
||||
* both strings) checking the character under I accomplishes
|
||||
* this.
|
||||
*
|
||||
* Note that strcmp does not handle accented characters,
|
||||
* internationalization, or locale sort order; strcoll() does
|
||||
* that.
|
||||
*
|
||||
* The rules say we compare order in terms of *unsigned* char.
|
||||
*/
|
||||
if ((unsigned char)a[i] > (unsigned char)b[i]) {
|
||||
return 1;
|
||||
}
|
||||
else if (a[i] == b[i]) {
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
/*
|
||||
* If A is greater than B, return 1. If A is less than B,
|
||||
* return -1. If they're the same, return 0. Since we have
|
||||
* stopped at the first character of difference (or the end of
|
||||
* both strings) checking the character under I accomplishes
|
||||
* this.
|
||||
*
|
||||
* Note that strcmp does not handle accented characters,
|
||||
* internationalization, or locale sort order; strcoll() does
|
||||
* that.
|
||||
*
|
||||
* The rules say we compare order in terms of *unsigned* char.
|
||||
*/
|
||||
if ((unsigned char)a[i] > (unsigned char)b[i]) {
|
||||
return 1;
|
||||
} else if (a[i] == b[i]) {
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user