computation for it as well, fix couple of bugs (including #485715) in sort with determining end of fields (upstream), do not mistakenly display -g and -G runuser option in su --help output, some sed cleanup in spec
155 lines
5.6 KiB
Diff
155 lines
5.6 KiB
Diff
diff -urNp coreutils-6.10-orig/src/sort.c coreutils-6.10/src/sort.c
|
|
--- coreutils-6.10-orig/src/sort.c 2008-01-22 00:33:25.000000000 +0100
|
|
+++ coreutils-6.10/src/sort.c 2009-02-27 11:19:35.000000000 +0100
|
|
@@ -1390,7 +1390,6 @@ begfield_uni (const struct line *line, c
|
|
char *ptr = line->text, *lim = ptr + line->length - 1;
|
|
size_t sword = key->sword;
|
|
size_t schar = key->schar;
|
|
- size_t remaining_bytes;
|
|
|
|
/* The leading field separator itself is included in a field when -t
|
|
is absent. */
|
|
@@ -1416,12 +1415,7 @@ begfield_uni (const struct line *line, c
|
|
while (ptr < lim && blanks[to_uchar (*ptr)])
|
|
++ptr;
|
|
|
|
- /* Advance PTR by SCHAR (if possible), but no further than LIM. */
|
|
- remaining_bytes = lim - ptr;
|
|
- if (schar < remaining_bytes)
|
|
- ptr += schar;
|
|
- else
|
|
- ptr = lim;
|
|
+ ptr = MIN (lim, ptr + schar);
|
|
|
|
return ptr;
|
|
}
|
|
@@ -1493,7 +1487,9 @@ limfield_uni (const struct line *line, c
|
|
{
|
|
char *ptr = line->text, *lim = ptr + line->length - 1;
|
|
size_t eword = key->eword, echar = key->echar;
|
|
- size_t remaining_bytes;
|
|
+
|
|
+ if (echar == 0)
|
|
+ eword++; /* Skip all of end field. */
|
|
|
|
/* Move PTR past EWORD fields or to one past the last byte on LINE,
|
|
whichever comes first. If there are more than EWORD fields, leave
|
|
@@ -1566,19 +1566,13 @@ limfield_uni (const struct line *line, c
|
|
}
|
|
#endif
|
|
|
|
- /* If we're ignoring leading blanks when computing the End
|
|
- of the field, don't start counting bytes until after skipping
|
|
- past any leading blanks. */
|
|
- if (key->skipeblanks)
|
|
- while (ptr < lim && blanks[to_uchar (*ptr)])
|
|
- ++ptr;
|
|
-
|
|
- /* Advance PTR by ECHAR (if possible), but no further than LIM. */
|
|
- remaining_bytes = lim - ptr;
|
|
- if (echar < remaining_bytes)
|
|
- ptr += echar;
|
|
- else
|
|
- ptr = lim;
|
|
+ if (echar != 0) /* We need to skip over a portion of the end field. */
|
|
+ {
|
|
+ if (key->skipeblanks) /* blanks not counted in echar. */
|
|
+ while (ptr < lim && blanks[to_uchar (*ptr)])
|
|
+ ++ptr;
|
|
+ ptr = MIN (lim, ptr + echar);
|
|
+ }
|
|
|
|
return ptr;
|
|
}
|
|
@@ -3582,12 +3579,9 @@ main (int argc, char **argv)
|
|
badfieldspec (optarg, N_("field number is zero"));
|
|
}
|
|
if (*s == '.')
|
|
- s = parse_field_count (s + 1, &key->echar,
|
|
- N_("invalid number after `.'"));
|
|
- else
|
|
{
|
|
- /* `-k 2,3' is equivalent to `+1 -3'. */
|
|
- key->eword++;
|
|
+ s = parse_field_count (s + 1, &key->echar,
|
|
+ N_("invalid number after `.'"));
|
|
}
|
|
s = set_ordering (s, key, bl_end);
|
|
}
|
|
diff -urNp coreutils-6.10-orig/tests/sort/sort-tests coreutils-6.10/tests/sort/sort-tests
|
|
--- coreutils-6.10-orig/tests/sort/sort-tests 2008-01-22 00:33:25.000000000 +0100
|
|
+++ coreutils-6.10/tests/sort/sort-tests 2009-02-27 11:19:35.000000000 +0100
|
|
@@ -1008,6 +1008,24 @@ else
|
|
esac
|
|
fi
|
|
test -s 07d.E || rm -f 07d.E
|
|
+_POSIX2_VERSION=199209 $xx -k 2,3.0 $srcdir/07e.I > 07e.O 2> 07e.E
|
|
+code=$?
|
|
+if test $code != 0; then
|
|
+ $echo "Test 07e(_POSIX2_VERSION=199209) failed: $xx return code $code differs from expected value 0" 1>&2
|
|
+ errors=`expr $errors + 1`
|
|
+else
|
|
+ cmp 07e.O $srcdir/07e.X > /dev/null 2>&1
|
|
+ case $? in
|
|
+ 0) if test "$VERBOSE"; then $echo "passed 07d(_POSIX2_VERSION=199209)"; fi;;
|
|
+ 1) $echo "Test 07e(_POSIX2_VERSION=199209) failed: files 07e.O and $srcdir/07e.X differ" 1>&2
|
|
+ (diff -c 07e.O $srcdir/07e.X) 2> /dev/null
|
|
+ errors=`expr $errors + 1`;;
|
|
+ 2) $echo "Test 07e(_POSIX2_VERSION=199209) may have failed." 1>&2
|
|
+ $echo The command "cmp 07e.O $srcdir/07e.X" failed. 1>&2
|
|
+ errors=`expr $errors + 1`;;
|
|
+ esac
|
|
+fi
|
|
+test -s 07e.E || rm -f 07e.E
|
|
_POSIX2_VERSION=199209 $xx -k 2.,3 $srcdir/08a.I > 08a.O 2> 08a.E
|
|
code=$?
|
|
if test $code != 2; then
|
|
@@ -1728,6 +1746,24 @@ else
|
|
esac
|
|
fi
|
|
test -s 18e.E || rm -f 18e.E
|
|
+_POSIX2_VERSION=199209 $xx -k1,1b $srcdir/18f.I > 18f.O 2> 18f.E
|
|
+code=$?
|
|
+if test $code != 0; then
|
|
+ $echo "Test 18f(_POSIX2_VERSION=199209) failed: $xx return code $code differs from expected value 0" 1>&2
|
|
+ errors=`expr $errors + 1`
|
|
+else
|
|
+ cmp 18f.O $srcdir/18f.X > /dev/null 2>&1
|
|
+ case $? in
|
|
+ 0) if test "$VERBOSE"; then $echo "passed 18f(_POSIX2_VERSION=199209)"; fi;;
|
|
+ 1) $echo "Test 18f(_POSIX2_VERSION=199209) failed: files 18f.O and $srcdir/18f.X differ" 1>&2
|
|
+ (diff -c 18f.O $srcdir/18f.X) 2> /dev/null
|
|
+ errors=`expr $errors + 1`;;
|
|
+ 2) $echo "Test 18f(_POSIX2_VERSION=199209) may have failed." 1>&2
|
|
+ $echo The command "cmp 18f.O $srcdir/18f.X" failed. 1>&2
|
|
+ errors=`expr $errors + 1`;;
|
|
+ esac
|
|
+fi
|
|
+test -s 18f.E || rm -f 18f.E
|
|
_POSIX2_VERSION=199209 $xx +0 +1nr $srcdir/19a.I > 19a.O 2> 19a.E
|
|
code=$?
|
|
if test $code != 0; then
|
|
diff -urNp coreutils-6.10-orig/tests/sort/07e.I coreutils-6.10/tests/sort/07e.I
|
|
--- coreutils-6.10-orig/tests/sort/07e.I 1970-01-01 01:00:00.000000000 +0100
|
|
+++ coreutils-6.10/tests/sort/07e.I 2009-02-27 11:21:24.000000000 +0100
|
|
@@ -0,0 +1,2 @@
|
|
+a a b
|
|
+z a a
|
|
diff -urNp coreutils-6.10-orig/tests/sort/07e.X coreutils-6.10/tests/sort/07e.X
|
|
--- coreutils-6.10-orig/tests/sort/07e.X 1970-01-01 01:00:00.000000000 +0100
|
|
+++ coreutils-6.10/tests/sort/07e.X 2009-02-27 11:21:10.000000000 +0100
|
|
@@ -0,0 +1,2 @@
|
|
+z a a
|
|
+a a b
|
|
diff -urNp coreutils-6.10-orig/tests/sort/18f.I coreutils-6.10/tests/sort/18f.I
|
|
--- coreutils-6.10-orig/tests/sort/18f.I 1970-01-01 01:00:00.000000000 +0100
|
|
+++ coreutils-6.10/tests/sort/18f.I 2009-02-27 11:14:41.000000000 +0100
|
|
@@ -0,0 +1,2 @@
|
|
+a y
|
|
+a z
|
|
diff -urNp coreutils-6.10-orig/tests/sort/18f.X coreutils-6.10/tests/sort/18f.X
|
|
--- coreutils-6.10-orig/tests/sort/18f.X 1970-01-01 01:00:00.000000000 +0100
|
|
+++ coreutils-6.10/tests/sort/18f.X 2009-02-27 11:15:07.000000000 +0100
|
|
@@ -0,0 +1,2 @@
|
|
+a y
|
|
+a z
|