rpms/coreutils/devel coreutils-7.1-sort-endoffields.patch, NONE, 1.1 coreutils.spec, 1.248, 1.249

Ondrej Vasik ovasik at fedoraproject.org
Wed Feb 25 15:36:49 UTC 2009


Author: ovasik

Update of /cvs/extras/rpms/coreutils/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv5723

Modified Files:
	coreutils.spec 
Added Files:
	coreutils-7.1-sort-endoffields.patch 
Log Message:
fix couple of bugs in sort with determining end of fields (upstream) - includes #485715 fix

coreutils-7.1-sort-endoffields.patch:

--- NEW FILE coreutils-7.1-sort-endoffields.patch ---
diff -urNp coreutils-7.1-orig/src/sort.c coreutils-7.1/src/sort.c
--- coreutils-7.1-orig/src/sort.c	2009-02-25 16:15:52.000000000 +0100
+++ coreutils-7.1/src/sort.c	2009-02-25 16:20:35.000000000 +0100
@@ -1598,6 +1598,9 @@ limfield_uni (const struct line *line, c
   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
      PTR pointing at the beginning of the field having zero-based index,
@@ -1673,19 +1676,22 @@ 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;
+        }
+
+      /* Advance PTR by ECHAR (if possible), but no further than LIM.  */
+      remaining_bytes = lim - ptr;
+      if (echar < remaining_bytes)
+        ptr += echar;
+      else
+        ptr = lim;
+    }
 
   return ptr;
 }
@@ -3736,12 +3742,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-7.1-orig/tests/misc/sort coreutils-7.1/tests/misc/sort
--- coreutils-7.1-orig/tests/misc/sort	2009-01-27 22:11:25.000000000 +0100
+++ coreutils-7.1/tests/misc/sort	2009-02-25 16:21:48.000000000 +0100
@@ -110,6 +110,8 @@ my @Tests =
 ["07b", '-k 2,3', {IN=>"a a b\nz a a\n"}, {OUT=>"z a a\na a b\n"}],
 ["07c", '-k 2,3', {IN=>"y k b\nz k a\n"}, {OUT=>"z k a\ny k b\n"}],
 ["07d", '+1 -3', {IN=>"y k b\nz k a\n"}, {OUT=>"z k a\ny k b\n"}],
+["07e", '-k 2,3.0', {IN=>"a a b\nz a a\n"}, {OUT=>"z a a\na a b\n"}],
+
 #
 # report an error for `.' without following char spec
 ["08a", '-k 2.,3', {EXIT=>2},
@@ -210,6 +212,10 @@ my @Tests =
 # key start and key end.
 ["18e", '-nb -k1.1,1.2', {IN=>" 901\n100\n"}, {OUT=>"100\n 901\n"}],
 
+# When ignoring leading blanks for end position, ensure blanks from
+# next field are not included in the sort. I.E. order should not change here.
+["18f", '-k1,1b', {IN=>"a  y\na z\n"}, {OUT=>"a  y\na z\n"}],
+
 # This looks odd, but works properly -- 2nd keyspec is never
 # used because all lines are different.
 ["19a", '+0 +1nr', {IN=>"b 2\nb 1\nb 3\n"}, {OUT=>"b 1\nb 2\nb 3\n"}],


Index: coreutils.spec
===================================================================
RCS file: /cvs/extras/rpms/coreutils/devel/coreutils.spec,v
retrieving revision 1.248
retrieving revision 1.249
diff -u -r1.248 -r1.249
--- coreutils.spec	25 Feb 2009 13:13:05 -0000	1.248
+++ coreutils.spec	25 Feb 2009 15:36:19 -0000	1.249
@@ -1,7 +1,7 @@
 Summary: A set of basic GNU tools commonly used in shell scripts
 Name:    coreutils
 Version: 7.1
-Release: 2%{?dist}
+Release: 3%{?dist}
 License: GPLv3+
 Group:   System Environment/Base
 Url:     http://www.gnu.org/software/coreutils/
@@ -19,6 +19,7 @@
 Source203:  coreutils-runuser-l.pamd
 
 # From upstream
+Patch1: coreutils-7.1-sort-endoffields.patch
 
 # Our patches
 Patch100: coreutils-6.10-configuration.patch
@@ -98,6 +99,7 @@
 %setup -q
 
 # From upstream
+%patch1 -p1 -b .endfield
 
 # Our patches
 %patch100 -p1 -b .configure
@@ -309,6 +311,10 @@
 /sbin/runuser
 
 %changelog
+* Wed Feb 25 2009 Ondrej Vasik <ovasik at redhat.com> 7.1-3
+- fix couple of bugs (including #485715) in sort with
+  determining end of fields(upstream)
+
 * Wed Feb 25 2009 Ondrej Vasik <ovasik at redhat.com> 7.1-2
 - workaround libcap issue with broken headers (#483548)
 - fix gnulib testsuite failure (4x77 (skip) is not




More information about the fedora-extras-commits mailing list