commit 21b9e883f440de900764a2e4077752268724c4db Author: Isaac Dunham Date: Wed Dec 5 10:48:33 2012 -0800 Fix strverscmp. The original version used strcmp, resulting in incorrect sorting order. This version, based on a version Brad Conroy (technosaurus) published, behaves similarly to the glibc version. diff --git a/src/string/strverscmp.c b/src/string/strverscmp.c index 7054967..bab3e64 100644 --- a/src/string/strverscmp.c +++ b/src/string/strverscmp.c @@ -1,7 +1,27 @@ +/* + * Based on an implementation by Brad Conroy (technosaurus) + * published on the Puppy Linux forums. + * + * This work is released to the Public Domain. + * In locales that do not recognize public domain it is: + * Copyright Brad Conroy 2012, permission is hereby granted to use this work in + * accordance with any license approved by the Open Source Initiative for any + * purpose without restriction in perpetuity. + */ #include int strverscmp(const char *l, const char *r) { - /* FIXME */ - return strcmp(l, r); + int ret=0, buf=0; + while ( *l && *r && l[0]==r[0] ) { + l++; + r++; + } + do { + ret=(10 * ret) + l++[0] - '0'; + } while ( '0' <= l[0] && l[0] <= '9') ; + do { + buf=(10 * buf) + r++[0] - '0'; + } while ( '0' <= r[0] && r[0] <= '9'); + return ret - buf; }