diff options
author | Jim Meyering <meyering@redhat.com> | 2008-04-26 09:28:48 +0200 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2008-05-06 08:21:28 +0200 |
commit | 209850fd7e1e89cf8937310878bd22d70e3588a5 (patch) | |
tree | 4f124f7243ad25afb4ca6a2f2fab081a927a3016 /src | |
parent | 4d3bf408b9a308a4702ac93546446927c12cc101 (diff) | |
download | coreutils-209850fd7e1e89cf8937310878bd22d70e3588a5.tar.xz |
avoid problems with sign-extended "char" operand to is* functions
* src/cut.c (set_fields): Apply to_uchar to isblank operands.
* src/uniq.c (find_field): Likewise.
* src/seq.c (scan_arg): Likewise, for isspace.
* tests/misc/uniq: New file. Test for the above, but only
when isspace(0240).
* tests/Makefile.am (TESTS): Add misc/uniq.
* configure.ac: Use gt_LOCALE_FR.
* tests/check.mk (TESTS_ENVIRONMENT): Propagate LOCALE_FR to scripts.
* NEWS: Mention the bug fixes.
Before this patch, on FreeBSD 6:
$ printf 'x y z\nx \xa0 y z\n' > in
$ LC_ALL=fr_FR.UTF-8 uniq -f2 in|tr ' ' .
x.y.z
x. .y.z
With the patch:
$ LC_ALL=fr_FR.UTF-8 uniq -f2 in|tr ' ' .
x.y.z
This also affected many other locales:
for i in $(locale -a); do test $(LC_ALL=$i ./uniq -f1 in|wc -l)
= $(LC_ALL=$i uniq -f1 in|wc -l) || echo $i ; done
...
en_GB.ISO8859-1
en_GB.ISO8859-15
en_GB.UTF-8
en_IE.UTF-8
en_NZ.ISO8859-1
en_NZ.ISO8859-15
en_NZ.UTF-8
en_US.ISO8859-1
en_US.ISO8859-15
en_US.UTF-8
...
Diffstat (limited to 'src')
-rw-r--r-- | src/cut.c | 5 | ||||
-rw-r--r-- | src/seq.c | 2 | ||||
-rw-r--r-- | src/uniq.c | 6 |
3 files changed, 7 insertions, 6 deletions
@@ -1,5 +1,5 @@ /* cut - remove parts of lines of files - Copyright (C) 1997-2007 Free Software Foundation, Inc. + Copyright (C) 1997-2008 Free Software Foundation, Inc. Copyright (C) 1984 David M. Ihnat This program is free software: you can redistribute it and/or modify @@ -372,7 +372,8 @@ set_fields (const char *fieldstr) initial = (lhs_specified ? value : 1); value = 0; } - else if (*fieldstr == ',' || isblank (*fieldstr) || *fieldstr == '\0') + else if (*fieldstr == ',' || + isblank (to_uchar (*fieldstr)) || *fieldstr == '\0') { in_digits = false; /* Ending the string, or this field/byte sublist. */ @@ -145,7 +145,7 @@ scan_arg (const char *arg) } /* We don't output spaces or '+' so don't include in width */ - while (isspace (*arg) || *arg == '+') + while (isspace (to_uchar (*arg)) || *arg == '+') arg++; ret.width = strlen (arg); diff --git a/src/uniq.c b/src/uniq.c index 1a54055b3..b167bbb08 100644 --- a/src/uniq.c +++ b/src/uniq.c @@ -1,5 +1,5 @@ /* uniq -- remove duplicate lines from a sorted file - Copyright (C) 86, 91, 1995-2007 Free Software Foundation, Inc. + Copyright (C) 86, 91, 1995-2008 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 @@ -213,9 +213,9 @@ find_field (const struct linebuffer *line) for (count = 0; count < skip_fields && i < size; count++) { - while (i < size && isblank (lp[i])) + while (i < size && isblank (to_uchar (lp[i]))) i++; - while (i < size && !isblank (lp[i])) + while (i < size && !isblank (to_uchar (lp[i]))) i++; } |