/* * 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) { 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; }