]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(compare_files):
authorJim Meyering <jim@meyering.net>
Thu, 4 Nov 1999 23:11:03 +0000 (23:11 +0000)
committerJim Meyering <jim@meyering.net>
Thu, 4 Nov 1999 23:11:03 +0000 (23:11 +0000)
Do not consider newline to be part of a line when comparing lines
in `sort' and `comm'.  POSIX.2 requires that we consider newline,
but this is a bug in the spec and the bug will likely be fixed.

src/comm.c

index 2e069d6597fb562864955e213b5c226f608f6116..5020902850595117f94197ac98093e48565a9ac1 100644 (file)
@@ -177,13 +177,13 @@ compare_files (char **infiles)
        {
 #ifdef ENABLE_NLS
          if (hard_LC_COLLATE)
-           order = memcoll (thisline[0]->buffer, thisline[0]->length,
-                            thisline[1]->buffer, thisline[1]->length);
+           order = memcoll (thisline[0]->buffer, thisline[0]->length - 1,
+                            thisline[1]->buffer, thisline[1]->length - 1);
          else
 #endif
            {
-             order = memcmp (thisline[0]->buffer, thisline[1]->buffer,
-                             min (thisline[0]->length, thisline[1]->length));
+             size_t len = min (thisline[0]->length, thisline[1]->length) - 1;
+             order = memcmp (thisline[0]->buffer, thisline[1]->buffer, len);
              if (order == 0)
                order = thisline[0]->length - thisline[1]->length;
            }