-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 According to Jim Meyering on 9/22/2008 6:21 AM: > Kamil, you may expect to use the new function in ls, too. > The more I think of this, the more I'm convinced producing > sensible results is what matters here. Being completely > compatible with older versions of ls -v is not important.
How does the proposed filevercmp function compare with m4sugar's m4_version_compare function? That one behaves a bit differently than glibc's strverscmp; for example, strverscmp says "00" is less than "0", whereas m4_version_compare says they are equal. m4_version_compare does not currently handle all bytes, but could possibly be generalized to do so, if its algorithm is deemed desirable. The m4 algorithm is: separate the candidate strings into fields at all ',', '.', and '-' separators. Then, for each field, any alphabetic strings are taken as the insertion of two new fields, a -1 and then the base-36 value of the alphabetic string. The comparison then visits one field at a time, treating blank fields as 0; leading zeros are ignored. Thus, "1" compares less than "1a" ("1.-1.10"), which in turn is less than "2". On the other hand, the fact that strverscmp provides a distinction based on leading zeros is nice, as it guarantees a stable sort (no two strings that differ on strcmp will compare equal with strverscmp). - -- Don't work too hard, make some time for fun as well! Eric Blake [EMAIL PROTECTED] -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkjXkTIACgkQ84KuGfSFAYCh/ACgrUs9ZLlX9+KmmUCIWMw3W8ac geYAoLrD7PFMgVJ4sZf54kSEYZ/4Tgy2 =eCSF -----END PGP SIGNATURE-----