Mercurial > hg > octave-lyh > gnulib-hg
changeset 11470:ecb28ce608f1
filevercmp: fix regression
author | Kamil Dudka <kdudka@redhat.com> |
---|---|
date | Thu, 09 Apr 2009 13:22:23 +0200 |
parents | 11e65378c669 |
children | 8557d9d3cace |
files | ChangeLog lib/filevercmp.c tests/test-filevercmp.c |
diffstat | 3 files changed, 22 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-04-09 Kamil Dudka <kdudka@redhat.com> + + Fix regression in 'filevercmp' module. Thanks Sven Joachim + for reporting it. + * lib/filevercmp.c: Special handle for "", "." and "..". + * tests/test-filevercmp.c: Enlarge the set suite. + 2009-04-07 Jim Meyering <meyering@redhat.com> useless-if-before-free: show how to remove braced useless free, too
--- a/lib/filevercmp.c +++ b/lib/filevercmp.c @@ -135,14 +135,19 @@ if (simple_cmp == 0) return 0; - /* handle hidden files */ - while (*s1 == '.' || *s2 == '.') - { - if (*s1 != *s2) - return *s1 - *s2; - s1++; - s2++; - } + /* special handle for "", "." and ".." */ + if (!*s1) + return -1; + if (!*s2) + return 1; + if (0 == strcmp (".", s1)) + return -1; + if (0 == strcmp (".", s2)) + return 1; + if (0 == strcmp ("..", s1)) + return -1; + if (0 == strcmp ("..", s2)) + return 1; /* "cut" file suffixes */ s1_pos = s1;
--- a/tests/test-filevercmp.c +++ b/tests/test-filevercmp.c @@ -37,6 +37,7 @@ /* set of well sorted examples */ static const char *const examples[] = { + "", ".", "..", ".a~", @@ -73,6 +74,7 @@ "nss_ldap-1.0-0.1a.tar.gz", "nss_ldap-10beta1.fc8.tar.gz", "nss_ldap-10.11.8.6.20040204cvs.fc10.ebuild", + "#.b#", NULL };