A bug in strverscmp.c?
H . J . Lu
hjl@valinux.com
Thu Feb 1 09:49:00 GMT 2001
This testcase prints "-45". I was expecting a positive number. How about this
patch?
--
H.J. Lu (hjl@valinux.com)
--
#include <string.h>
#include <stdio.h>
main ()
{
printf ("%d\n", strverscmp ("2.8", "2.8-0.4"));
}
---
2001-02-01 H.J. Lu <hjl@gnu.org>
* string/strverscmp.c (__strverscmp): Treat '\0' as the
lowest version.
Index: string/strverscmp.c
===================================================================
RCS file: /work/cvs/gnu/glibc/string/strverscmp.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 strverscmp.c
--- string/strverscmp.c 2000/05/21 21:11:27 1.1.1.1
+++ string/strverscmp.c 2001/02/01 17:45:55
@@ -83,7 +83,7 @@ __strverscmp (s1, s2)
/* Hint: '0' is a digit too. */
state = S_N | ((c1 == '0') + (isdigit (c1) != 0));
- while ((diff = c1 - c2) == 0 && c1 != '\0')
+ while ((diff = c1 ? c1 - c2 : c2) == 0 && c1 != '\0')
{
state = next_state[state];
c1 = *p1++;
More information about the Libc-alpha
mailing list