]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
comm: fix a bug in its new --check-order option
authorBruno Haible <bruno@clisp.org>
Sun, 8 Mar 2009 17:25:29 +0000 (18:25 +0100)
committerJim Meyering <meyering@redhat.com>
Sun, 8 Mar 2009 20:34:08 +0000 (21:34 +0100)
* src/comm.c: Include memcmp2.h.
(check_order): Use memcmp2 instead of memcmp.
* bootstrap.conf (gnulib_modules): Add memcmp2.

bootstrap.conf
src/comm.c

index e61e241011ade18adfa07fa4c5caf5861fb88ba2..0747bb8583a6ddea59d91a516215763593d40526 100644 (file)
@@ -71,7 +71,7 @@ gnulib_modules="
        manywarnings
        mbrtowc
        mbswidth
-       memcasecmp mempcpy
+       memcasecmp memcmp2 mempcpy
        memrchr mgetgroups
        mkancesdirs mkdir mkdir-p mkstemp mktime modechange
        mountlist mpsort obstack pathmax perl physmem
index 4ec7e4a07cb31a734217c5ddf58912205d293e1e..c60936f4b4f38a8ca8af610a0adb440d5423bfb0 100644 (file)
@@ -1,5 +1,5 @@
 /* comm -- compare two sorted files line by line.
-   Copyright (C) 86, 90, 91, 1995-2005, 2008 Free Software Foundation, Inc.
+   Copyright (C) 86, 90, 91, 1995-2005, 2008-2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -25,6 +25,7 @@
 #include "error.h"
 #include "quote.h"
 #include "stdio--.h"
+#include "memcmp2.h"
 #include "xmemcoll.h"
 
 /* The official name of this program (e.g., no `g' prefix).  */
@@ -199,10 +200,8 @@ check_order (struct linebuffer const *prev,
            order = xmemcoll (prev->buffer, prev->length - 1,
                              current->buffer, current->length - 1);
          else
-           {
-             size_t len = min (prev->length, current->length) - 1;
-             order = memcmp (prev->buffer, current->buffer, len);
-           }
+           order = memcmp2 (prev->buffer, prev->length - 1,
+                            current->buffer, current->length - 1);
 
          if (0 < order)
            {