diff options
-rw-r--r-- | coreutils/shuf.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/coreutils/shuf.c b/coreutils/shuf.c index 107899a10..466969745 100644 --- a/coreutils/shuf.c +++ b/coreutils/shuf.c | |||
@@ -67,7 +67,7 @@ static void shuffle_lines(char **lines, unsigned numlines, unsigned outlines) | |||
67 | } | 67 | } |
68 | 68 | ||
69 | /* We can handle insanity like this: | 69 | /* We can handle insanity like this: |
70 | * shuf -i 3333333333333333333333333333333333333333333333333333333333333123456789001-3333333333333333333333333333333333333333333333333333333333333123456789019 | 70 | * shuf -i 333333333333333333333333333333001-333333333333333333333333333333019 |
71 | * but do we want to have +200 bytes of code (~40% code growth)? | 71 | * but do we want to have +200 bytes of code (~40% code growth)? |
72 | */ | 72 | */ |
73 | #define COMMON_PREFIX_HACK 0 | 73 | #define COMMON_PREFIX_HACK 0 |
@@ -128,16 +128,12 @@ int shuf_main(int argc, char **argv) | |||
128 | if (padding_width > 5 && padding_width == strlen(b)) { | 128 | if (padding_width > 5 && padding_width == strlen(b)) { |
129 | /* How long is it? */ | 129 | /* How long is it? */ |
130 | pfx = a; | 130 | pfx = a; |
131 | while (isdigit(*a) && *a == *b) { | 131 | while (isdigit(*a) && *a == *b |
132 | && a[1] /* "111111-111111" case: avoid xatoull("") */ | ||
133 | ) { | ||
132 | a++; | 134 | a++; |
133 | b++; | 135 | b++; |
134 | } | 136 | } |
135 | if (*a == '\0') { | ||
136 | /* "123456-123456", and we 'ate' all of them */ | ||
137 | /* prevent trying to xatoull("") */ | ||
138 | a--; | ||
139 | b--; | ||
140 | } | ||
141 | pfx_len = a - pfx; /* can end up being 0 */ | 137 | pfx_len = a - pfx; /* can end up being 0 */ |
142 | padding_width -= pfx_len; | 138 | padding_width -= pfx_len; |
143 | } else { | 139 | } else { |