diff options
author | 2019-05-15 09:33:34 +0000 | |
---|---|---|
committer | 2019-05-15 09:33:34 +0000 | |
commit | eedbfd81833279ae275cb664e72363df3743cbc7 (patch) | |
tree | 94179c6dd175ce92c03268f796cea7043437cbbd | |
parent | s3 is never NULL since s2 (formerly used for SSLv2) does not exist, so there is (diff) | |
download | wireguard-openbsd-eedbfd81833279ae275cb664e72363df3743cbc7.tar.xz wireguard-openbsd-eedbfd81833279ae275cb664e72363df3743cbc7.zip |
re-indent bwscoll() after previous commit; no binary change
-rw-r--r-- | usr.bin/sort/bwstring.c | 158 |
1 files changed, 79 insertions, 79 deletions
diff --git a/usr.bin/sort/bwstring.c b/usr.bin/sort/bwstring.c index 5ccb96a7a11..c899462f179 100644 --- a/usr.bin/sort/bwstring.c +++ b/usr.bin/sort/bwstring.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bwstring.c,v 1.8 2019/05/15 09:07:46 schwarze Exp $ */ +/* $OpenBSD: bwstring.c,v 1.9 2019/05/15 09:33:34 schwarze Exp $ */ /*- * Copyright (C) 2009 Gabor Kovesdan <gabor@FreeBSD.org> @@ -684,91 +684,91 @@ bwscoll(const struct bwstring *bws1, const struct bwstring *bws2, size_t offset) if (len1 <= offset) return (len2 <= offset) ? 0 : -1; - if (len2 <= offset) - return 1; + if (len2 <= offset) + return 1; - len1 -= offset; - len2 -= offset; + len1 -= offset; + len2 -= offset; - if (sort_mb_cur_max == 1) { - const unsigned char *s1, *s2; - int res; + if (sort_mb_cur_max == 1) { + const unsigned char *s1, *s2; + int res; + + s1 = bws1->data.cstr + offset; + s2 = bws2->data.cstr + offset; + + if (len1 > len2) { + res = memcmp(s1, s2, len2); + if (!res) + res = +1; + } else if (len1 < len2) { + res = memcmp(s1, s2, len1); + if (!res) + res = -1; + } else + res = memcmp(s1, s2, len1); + + return res; + } else { + const wchar_t *s1, *s2; + size_t i, maxlen; + int res = 0; - s1 = bws1->data.cstr + offset; - s2 = bws2->data.cstr + offset; + s1 = bws1->data.wstr + offset; + s2 = bws2->data.wstr + offset; - if (len1 > len2) { - res = memcmp(s1, s2, len2); - if (!res) - res = +1; - } else if (len1 < len2) { - res = memcmp(s1, s2, len1); - if (!res) - res = -1; - } else - res = memcmp(s1, s2, len1); - - return res; - } else { - const wchar_t *s1, *s2; - size_t i, maxlen; - int res = 0; + i = 0; + maxlen = len1; - s1 = bws1->data.wstr + offset; - s2 = bws2->data.wstr + offset; + if (maxlen > len2) + maxlen = len2; - i = 0; - maxlen = len1; - - if (maxlen > len2) - maxlen = len2; - - while (i < maxlen) { - - /* goto next non-zero part: */ - while ((i < maxlen) && - !s1[i] && !s2[i]) - ++i; - - if (i >= maxlen) - break; - - if (s1[i] == 0) { - if (s2[i] == 0) - /* NOTREACHED */ - err(2, "bwscoll error 1"); - else - return -1; - } else if (s2[i] == 0) - return 1; - - res = wide_str_coll(s1 + i, s2 + i); - if (res) - return res; - - while ((i < maxlen) && s1[i] && s2[i]) - ++i; - - if (i >= maxlen) - break; - - if (s1[i] == 0) { - if (s2[i] == 0) { - ++i; - continue; - } else - return -1; - } else if (s2[i] == 0) - return 1; - else - /* NOTREACHED */ - err(2, "bwscoll error 2"); - } + while (i < maxlen) { - if (len1 == len2) - return 0; - return len1 < len2 ? -1 : 1; - } + /* goto next non-zero part: */ + while (i < maxlen && + s1[i] == L'\0' && s2[i] == L'\0') + ++i; + + if (i >= maxlen) + break; + + if (s1[i] == L'\0') { + if (s2[i] == L'\0') + /* NOTREACHED */ + err(2, "bwscoll error 1"); + else + return -1; + } else if (s2[i] == L'\0') + return 1; + + res = wide_str_coll(s1 + i, s2 + i); + if (res) + return res; + + while (i < maxlen && s1[i] != L'\0' && s2[i] != L'\0') + ++i; + + if (i >= maxlen) + break; + + if (s1[i] == L'\0') { + if (s2[i] == L'\0') { + ++i; + continue; + } else + return -1; + } else if (s2[i] == L'\0') + return 1; + else + /* NOTREACHED */ + err(2, "bwscoll error 2"); + } + + if (len1 == len2) + return 0; + return len1 < len2 ? -1 : 1; + } } /* |