X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fstrverscmp.c;h=1e87461905a0a08daf6290deb62e7cb976e1eb25;hb=e911cfd715b17d7314df5882f00b86a2cef6c3ad;hp=defef435522cbe00ec9846f239c1bffe2b1da6a8;hpb=3ec28ba4f3c84ef294f14c8a7cff3c9e934c4944;p=gnulib.git diff --git a/lib/strverscmp.c b/lib/strverscmp.c index defef4355..1e8746190 100644 --- a/lib/strverscmp.c +++ b/lib/strverscmp.c @@ -18,6 +18,10 @@ 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 @@ -39,9 +43,7 @@ */ int -strverscmp (s1, s2) - const char *s1; - const char *s2; +strverscmp (const char *s1, const char *s2) { const unsigned char *p1 = (const unsigned char *) s1; const unsigned char *p2 = (const unsigned char *) s2; @@ -67,11 +69,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 +83,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 +96,7 @@ strverscmp (s1, s2) state = result_type[state << 2 | ((c2 == '0') + (isdigit (c2) != 0))]; switch (state) - { + { case CMP: return diff; @@ -107,5 +109,5 @@ strverscmp (s1, s2) default: return state; - } + } }