]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(limfield): #ifdef-out a block of code that makes
authorJim Meyering <jim@meyering.net>
Fri, 31 May 1996 03:07:45 +0000 (03:07 +0000)
committerJim Meyering <jim@meyering.net>
Fri, 31 May 1996 03:07:45 +0000 (03:07 +0000)
GNU sort incompatible with Unix sort when a key-end spec refers
to the N'th character in a field that has fewer than N characters.
The POSIX spec doesn't appear to specify behavior for this case.
From Karl Heuer.

src/sort.c

index 9130190538872833f9b963eba9dfa7ee13ac0302..733df0adfaf5a774d2d3300e89d8686126d4adc2 100644 (file)
@@ -610,6 +610,36 @@ limfield (const struct line *line, const struct keyfield *key)
          ++ptr;
       }
 
+#ifdef POSIX_UNSPECIFIED
+  /* The following block of code makes GNU sort incompatible with
+     standard Unix sort, so it's ifdef'd out for now.
+     The POSIX spec isn't clear on how to interpret this.
+     FIXME: request clarification.
+
+     From: kwzh@gnu.ai.mit.edu (Karl Heuer)
+     Date: Thu, 30 May 96 12:20:41 -0400
+
+     [...]I believe I've found another bug in `sort'.
+
+     $ cat /tmp/sort.in
+     a b c 2 d
+     pq rs 1 t
+     $ textutils-1.15/src/sort +0.6 -0.7 </tmp/sort.in
+     a b c 2 d
+     pq rs 1 t
+     $ /bin/sort +0.6 -0.7 </tmp/sort.in
+     pq rs 1 t
+     a b c 2 d
+
+     Unix sort produced the answer I expected: sort on the single character
+     in column 6.  GNU sort produced different results, because it disagrees
+     on the interpretation of the key-end spec "-M.N".  Unix sort reads this
+     as "skip M fields, then N characters"; but GNU sort wants it to mean
+     "skip M fields, then either N characters or the rest of the current
+     field, whichever comes first".  This extra clause applies only to
+     key-ends, not key-starts.
+     */
+
   /* Make LIM point to the end of (one byte past) the current field.  */
   if (tab)
     {
@@ -628,6 +658,7 @@ limfield (const struct line *line, const struct keyfield *key)
        ++newlim;
       lim = newlim;
     }
+#endif
 
   /* If we're skipping leading blanks, don't start counting characters
      until after skipping past any leading blanks.  */