diff options
-rw-r--r-- | coreutils/cut.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/coreutils/cut.c b/coreutils/cut.c index 8cae2eca3..f7b501a46 100644 --- a/coreutils/cut.c +++ b/coreutils/cut.c | |||
@@ -276,8 +276,12 @@ int cut_main(int argc UNUSED_PARAM, char **argv) | |||
276 | s = xatoi_positive(ntok); | 276 | s = xatoi_positive(ntok); |
277 | /* account for the fact that arrays are zero based, while | 277 | /* account for the fact that arrays are zero based, while |
278 | * the user expects the first char on the line to be char #1 */ | 278 | * the user expects the first char on the line to be char #1 */ |
279 | #if !ENABLE_PLATFORM_MINGW32 | ||
279 | if (s != 0) | 280 | if (s != 0) |
280 | s--; | 281 | s--; |
282 | #else | ||
283 | s--; | ||
284 | #endif | ||
281 | } | 285 | } |
282 | 286 | ||
283 | /* get the end pos */ | 287 | /* get the end pos */ |
@@ -287,21 +291,20 @@ int cut_main(int argc UNUSED_PARAM, char **argv) | |||
287 | e = INT_MAX; | 291 | e = INT_MAX; |
288 | } else { | 292 | } else { |
289 | e = xatoi_positive(ltok); | 293 | e = xatoi_positive(ltok); |
290 | /* if the user specified and end position of 0, | 294 | /* if the user specified no end position, |
291 | * that means "til the end of the line" */ | 295 | * that means "til the end of the line" */ |
296 | #if !ENABLE_PLATFORM_MINGW32 | ||
292 | if (!*ltok) | 297 | if (!*ltok) |
293 | e = INT_MAX; | 298 | e = INT_MAX; |
294 | #if !ENABLE_PLATFORM_MINGW32 | ||
295 | else if (e < s) | 299 | else if (e < s) |
296 | bb_error_msg_and_die("%d<%d", e, s); | 300 | bb_error_msg_and_die("%d<%d", e, s); |
297 | e--; /* again, arrays are zero based, lines are 1 based */ | ||
298 | #else | ||
299 | else if (e != 0) | ||
300 | e--; /* again, zero based arrays, one based lines */ | ||
301 | if (e < s) | ||
302 | bb_error_msg_and_die("%d<%d", e, s); | ||
303 | #endif | 301 | #endif |
302 | e--; /* again, arrays are zero based, lines are 1 based */ | ||
304 | } | 303 | } |
304 | #if ENABLE_PLATFORM_MINGW32 | ||
305 | if (s < 0 || e < s) | ||
306 | bb_error_msg_and_die("invalid range %s-%s", ntok, ltok ?: ntok); | ||
307 | #endif | ||
305 | 308 | ||
306 | /* add the new list */ | 309 | /* add the new list */ |
307 | cut_lists = xrealloc_vector(cut_lists, 4, nlists); | 310 | cut_lists = xrealloc_vector(cut_lists, 4, nlists); |