diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2014-03-07 14:32:39 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2014-03-07 14:32:39 +0100 |
commit | 102f0d0d073c4781b5a58f679bdfd0999eea5e71 (patch) | |
tree | ed6225c4eb714995e636dc7816a6fb19618975ad /coreutils | |
parent | 190693ced1bb82d96c5dedbe850840aae9246a5c (diff) | |
download | busybox-w32-102f0d0d073c4781b5a58f679bdfd0999eea5e71.tar.gz busybox-w32-102f0d0d073c4781b5a58f679bdfd0999eea5e71.tar.bz2 busybox-w32-102f0d0d073c4781b5a58f679bdfd0999eea5e71.zip |
shuf: do not use strings for -i RANGE case
function old new delta
shuf_main 482 496 +14
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils')
-rw-r--r-- | coreutils/shuf.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/coreutils/shuf.c b/coreutils/shuf.c index e0c2fbf1f..d1cd39db7 100644 --- a/coreutils/shuf.c +++ b/coreutils/shuf.c | |||
@@ -79,7 +79,6 @@ int shuf_main(int argc, char **argv) | |||
79 | /* Prepare lines for shuffling - either: */ | 79 | /* Prepare lines for shuffling - either: */ |
80 | if (opts & OPT_e) { | 80 | if (opts & OPT_e) { |
81 | /* make lines from command-line arguments */ | 81 | /* make lines from command-line arguments */ |
82 | |||
83 | numlines = argc; | 82 | numlines = argc; |
84 | lines = argv; | 83 | lines = argv; |
85 | } else | 84 | } else |
@@ -103,7 +102,7 @@ int shuf_main(int argc, char **argv) | |||
103 | numlines = (hi+1) - lo; | 102 | numlines = (hi+1) - lo; |
104 | lines = xmalloc(numlines * sizeof(lines[0])); | 103 | lines = xmalloc(numlines * sizeof(lines[0])); |
105 | for (i = 0; i < numlines; i++) { | 104 | for (i = 0; i < numlines; i++) { |
106 | lines[i] = xstrdup(utoa(lo)); | 105 | lines[i] = (char*)(uintptr_t)lo; |
107 | lo++; | 106 | lo++; |
108 | } | 107 | } |
109 | } else { | 108 | } else { |
@@ -144,7 +143,10 @@ int shuf_main(int argc, char **argv) | |||
144 | eol = '\0'; | 143 | eol = '\0'; |
145 | 144 | ||
146 | for (i = 0; i < numlines; i++) { | 145 | for (i = 0; i < numlines; i++) { |
147 | printf("%s%c", lines[i], eol); | 146 | if (opts & OPT_i) |
147 | printf("%u%c", (unsigned)(uintptr_t)lines[i], eol); | ||
148 | else | ||
149 | printf("%s%c", lines[i], eol); | ||
148 | } | 150 | } |
149 | 151 | ||
150 | fflush_stdout_and_exit(EXIT_SUCCESS); | 152 | fflush_stdout_and_exit(EXIT_SUCCESS); |