author | Rich Felker <dalias@aerifal.cx> | 2022年11月07日 22:17:55 -0500 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2022年11月07日 22:33:24 -0500 |
commit | b50eb8c36c20f967bd0ed70c0b0db38a450886ba (patch) | |
tree | 9f7cb320d7b0c6d72c07c0a18a8054df88be3327 /src/string/strverscmp.c | |
parent | ad5dcd398b9509cf43672e3a7f02c4b18035998c (diff) | |
download | musl-b50eb8c36c20f967bd0ed70c0b0db38a450886ba.tar.gz |
-rw-r--r-- | src/string/strverscmp.c | 6 |
diff --git a/src/string/strverscmp.c b/src/string/strverscmp.c index 4daf276d..16c1da22 100644 --- a/src/string/strverscmp.c +++ b/src/string/strverscmp.c @@ -18,9 +18,9 @@ int strverscmp(const char *l0, const char *r0) else if (c!='0') z=0; } - if (l[dp]!='0' && r[dp]!='0') { - /* If we're not looking at a digit sequence that began - * with a zero, longest digit string is greater. */ + if (l[dp]-'1'<9U && r[dp]-'1'<9U) { + /* If we're looking at non-degenerate digit sequences starting + * with nonzero digits, longest digit string is greater. */ for (j=i; isdigit(l[j]); j++) if (!isdigit(r[j])) return 1; if (isdigit(r[j])) return -1; |