shuf: another tweak to COMMON_PREFIX_HACK code
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
7c1f975cdd
commit
8b72877bab
1 changed files with 4 additions and 8 deletions
|
@ -67,7 +67,7 @@ static void shuffle_lines(char **lines, unsigned numlines, unsigned outlines)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We can handle insanity like this:
|
/* We can handle insanity like this:
|
||||||
* shuf -i 3333333333333333333333333333333333333333333333333333333333333123456789001-3333333333333333333333333333333333333333333333333333333333333123456789019
|
* shuf -i 333333333333333333333333333333001-333333333333333333333333333333019
|
||||||
* but do we want to have +200 bytes of code (~40% code growth)?
|
* but do we want to have +200 bytes of code (~40% code growth)?
|
||||||
*/
|
*/
|
||||||
#define COMMON_PREFIX_HACK 0
|
#define COMMON_PREFIX_HACK 0
|
||||||
|
@ -128,16 +128,12 @@ int shuf_main(int argc, char **argv)
|
||||||
if (padding_width > 5 && padding_width == strlen(b)) {
|
if (padding_width > 5 && padding_width == strlen(b)) {
|
||||||
/* How long is it? */
|
/* How long is it? */
|
||||||
pfx = a;
|
pfx = a;
|
||||||
while (isdigit(*a) && *a == *b) {
|
while (isdigit(*a) && *a == *b
|
||||||
|
&& a[1] /* "111111-111111" case: avoid xatoull("") */
|
||||||
|
) {
|
||||||
a++;
|
a++;
|
||||||
b++;
|
b++;
|
||||||
}
|
}
|
||||||
if (*a == '\0') {
|
|
||||||
/* "123456-123456", and we 'ate' all of them */
|
|
||||||
/* prevent trying to xatoull("") */
|
|
||||||
a--;
|
|
||||||
b--;
|
|
||||||
}
|
|
||||||
pfx_len = a - pfx; /* can end up being 0 */
|
pfx_len = a - pfx; /* can end up being 0 */
|
||||||
padding_width -= pfx_len;
|
padding_width -= pfx_len;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue