aboutsummaryrefslogtreecommitdiff
path: root/coreutils/cut.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-10-08 12:49:22 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-10-08 12:49:22 +0000
commit1385899416a4396385ad421ae1f532be7103738a (patch)
treefc4d14a910593d1235318bb36abe5e9f72d2039e /coreutils/cut.c
parent5625415085e68ac5e150f54e685417c866620d76 (diff)
downloadbusybox-w32-1385899416a4396385ad421ae1f532be7103738a.tar.gz
busybox-w32-1385899416a4396385ad421ae1f532be7103738a.tar.bz2
busybox-w32-1385899416a4396385ad421ae1f532be7103738a.zip
attempt to regularize atoi mess.
Diffstat (limited to 'coreutils/cut.c')
-rw-r--r--coreutils/cut.c16
1 files changed, 3 insertions, 13 deletions
diff --git a/coreutils/cut.c b/coreutils/cut.c
index 69f28fa8d..7ba947fae 100644
--- a/coreutils/cut.c
+++ b/coreutils/cut.c
@@ -163,17 +163,7 @@ static void cut_file(FILE * file)
163 } 163 }
164} 164}
165 165
166static int getval(char *ntok) 166static const char _op_on_field[] = " only when operating on fields";
167{
168 char *junk;
169 int i = strtoul(ntok, &junk, 10);
170
171 if (*junk != '\0' || i < 0)
172 bb_error_msg_and_die("invalid byte or field list");
173 return i;
174}
175
176static const char * const _op_on_field = " only when operating on fields";
177 167
178int cut_main(int argc, char **argv) 168int cut_main(int argc, char **argv)
179{ 169{
@@ -231,7 +221,7 @@ int cut_main(int argc, char **argv)
231 } else if (strlen(ntok) == 0) { 221 } else if (strlen(ntok) == 0) {
232 s = BOL; 222 s = BOL;
233 } else { 223 } else {
234 s = getval(ntok); 224 s = xatoi_u(ntok);
235 /* account for the fact that arrays are zero based, while 225 /* account for the fact that arrays are zero based, while
236 * the user expects the first char on the line to be char #1 */ 226 * the user expects the first char on the line to be char #1 */
237 if (s != 0) 227 if (s != 0)
@@ -245,7 +235,7 @@ int cut_main(int argc, char **argv)
245 } else if (strlen(ntok) == 0) { 235 } else if (strlen(ntok) == 0) {
246 e = EOL; 236 e = EOL;
247 } else { 237 } else {
248 e = getval(ntok); 238 e = xatoi_u(ntok);
249 /* if the user specified and end position of 0, that means "til the 239 /* if the user specified and end position of 0, that means "til the
250 * end of the line */ 240 * end of the line */
251 if (e == 0) 241 if (e == 0)