From a6a447fc58a01598682f0914f978d0a3c1cfc4dc Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Tue, 22 May 2007 14:25:19 +0200 Subject: cut: diagnose a range starting with 0 (-f 0-2) as invalid, and give a better diagnostic for a field-number/offset of 0. * NEWS: Mention the fix. * src/cut.c (ADD_RANGE_PAIR): Add an explicit check for 0. Based on a patch from James Youngman. * tests/misc/cut: Add tests for the above. --- src/cut.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/cut.c b/src/cut.c index ab14abcb2..e89460e1b 100644 --- a/src/cut.c +++ b/src/cut.c @@ -57,6 +57,8 @@ #define ADD_RANGE_PAIR(rp, low, high) \ do \ { \ + if (low == 0 || high == 0) \ + FATAL_ERROR (_("fields and positions are numbered from 1")); \ if (n_rp >= n_rp_allocated) \ { \ (rp) = X2NREALLOC (rp, &n_rp_allocated); \ -- cgit v1.2.3-54-g00ecf