X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fstrverscmp.c;h=c138df53283f550df035f0a985bdfe50e01552a0;hb=ea12546cdee0548bded92ecffcf257aa5b6a125f;hp=067000e30537ad7921e229ac95c07174b114934e;hpb=20d419623aa1b6de80ac4e364a3ea6c98c40ba45;p=gnulib.git diff --git a/lib/strverscmp.c b/lib/strverscmp.c index 067000e30..c138df532 100644 --- a/lib/strverscmp.c +++ b/lib/strverscmp.c @@ -18,11 +18,15 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if HAVE_CONFIG_H +# include +#endif + #include #include /* states: S_N: normal, S_I: comparing integral part, S_F: comparing - Fractionnal parts, S_Z: idem but with leading Zeroes only */ + Fractional parts, S_Z: idem but with leading Zeroes only */ #define S_N 0x0 #define S_I 0x4 #define S_F 0x8 @@ -67,11 +71,11 @@ strverscmp (s1, s2) /* S_N */ CMP, CMP, CMP, CMP, CMP, LEN, CMP, CMP, CMP, CMP, CMP, CMP, CMP, CMP, CMP, CMP, - /* S_I */ CMP, -1, -1, CMP, +1, LEN, LEN, CMP, - +1, LEN, LEN, CMP, CMP, CMP, CMP, CMP, + /* S_I */ CMP, -1, -1, CMP, 1, LEN, LEN, CMP, + 1, LEN, LEN, CMP, CMP, CMP, CMP, CMP, /* S_F */ CMP, CMP, CMP, CMP, CMP, LEN, CMP, CMP, CMP, CMP, CMP, CMP, CMP, CMP, CMP, CMP, - /* S_Z */ CMP, +1, +1, CMP, -1, CMP, CMP, CMP, + /* S_Z */ CMP, 1, 1, CMP, -1, CMP, CMP, CMP, -1, CMP, CMP, CMP }; @@ -81,7 +85,7 @@ strverscmp (s1, s2) c1 = *p1++; c2 = *p2++; /* Hint: '0' is a digit too. */ - state = S_N | (c1 == '0') + (isdigit (c1) != 0); + state = S_N | ((c1 == '0') + (isdigit (c1) != 0)); while ((diff = c1 - c2) == 0 && c1 != '\0') { @@ -94,7 +98,7 @@ strverscmp (s1, s2) state = result_type[state << 2 | ((c2 == '0') + (isdigit (c2) != 0))]; switch (state) - { + { case CMP: return diff; @@ -107,5 +111,5 @@ strverscmp (s1, s2) default: return state; - } + } }