mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-19 03:33:43 +03:00
tr: do not reject an unmatched [:lower:] or [:upper:] in SET1.
* NEWS: Mention this. * src/tr.c (get_next) [RE_CHAR_CLASS]: Don't skip the loop when processing [:lower:] and [:upper:]. (main): Require [:lower:] or [:upper:] in SET1 only when when one of those is specified in SET2. * tests/tr/Test.pm: Add tests for this fix. Reported by Per Starbäck. Signed-off-by: Jim Meyering <meyering@redhat.com>
This commit is contained in:
1 parent
c365bafa81
commit
af5d0c363a
5 files changed
+23
-18
No files matched your search
@@ -1,3 +1,14 @@
|
|||||||
|
2007-10-21 Jim Meyering <meyering@redhat.com>
|
||||||
|
|
||||||
|
tr: do not reject an unmatched [:lower:] or [:upper:] in SET1.
|
||||||
|
* NEWS: Mention this.
|
||||||
|
* src/tr.c (get_next) [RE_CHAR_CLASS]: Don't skip the loop when
|
||||||
|
processing [:lower:] and [:upper:].
|
||||||
|
(main): Require [:lower:] or [:upper:] in SET1 only when
|
||||||
|
when one of those is specified in SET2.
|
||||||
|
* tests/tr/Test.pm: Add tests for this fix.
|
||||||
|
Reported by Per Starbäck.
|
||||||
|
|
||||||
2007-10-20 Jim Meyering <meyering@redhat.com>
|
2007-10-20 Jim Meyering <meyering@redhat.com>
|
||||||
|
|
||||||
* tests/misc/help-version: Add a comment.
|
* tests/misc/help-version: Add a comment.
|
||||||
|
|||||||
@@ -148,6 +148,8 @@ GNU coreutils NEWS -*- outline -*-
|
|||||||
tr -c no longer aborts when translating with Set2 larger than the
|
tr -c no longer aborts when translating with Set2 larger than the
|
||||||
complement of Set1. [introduced with the original version, in 1992]
|
complement of Set1. [introduced with the original version, in 1992]
|
||||||
|
|
||||||
|
tr no longer rejects an unmatched [:lower:] or [:upper:] in SET1.
|
||||||
|
|
||||||
|
|
||||||
* Noteworthy changes in release 6.9 (2007-03-22) [stable]
|
* Noteworthy changes in release 6.9 (2007-03-22) [stable]
|
||||||
|
|
||||||
|
|||||||
@@ -407,6 +407,7 @@ Paul Worrall paul@basilisk.uklinux.net
|
|||||||
Pawel Prokop pablo@wizard.ae.krakow.pl
|
Pawel Prokop pablo@wizard.ae.krakow.pl
|
||||||
Per Cederqvist ceder@lysator.liu.se
|
Per Cederqvist ceder@lysator.liu.se
|
||||||
Per Kristian Hove perhov@math.ntnu.no
|
Per Kristian Hove perhov@math.ntnu.no
|
||||||
|
Per Starbäck starback@stp.lingfil.uu.se
|
||||||
Peter Breitenlohner peb@mppmu.mpg.de
|
Peter Breitenlohner peb@mppmu.mpg.de
|
||||||
Peter Dyballa peter_dyballa@web.de
|
Peter Dyballa peter_dyballa@web.de
|
||||||
Peter Eriksson peter@ifm.liu.se
|
Peter Eriksson peter@ifm.liu.se
|
||||||
|
|||||||
@@ -1077,27 +1077,15 @@ get_next (struct Spec_list *s, enum Upper_Lower_class *class)
|
|||||||
case RE_CHAR_CLASS:
|
case RE_CHAR_CLASS:
|
||||||
if (class)
|
if (class)
|
||||||
{
|
{
|
||||||
bool upper_or_lower;
|
|
||||||
switch (p->u.char_class)
|
switch (p->u.char_class)
|
||||||
{
|
{
|
||||||
case CC_LOWER:
|
case CC_LOWER:
|
||||||
*class = UL_LOWER;
|
*class = UL_LOWER;
|
||||||
upper_or_lower = true;
|
|
||||||
break;
|
break;
|
||||||
case CC_UPPER:
|
case CC_UPPER:
|
||||||
*class = UL_UPPER;
|
*class = UL_UPPER;
|
||||||
upper_or_lower = true;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
upper_or_lower = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (upper_or_lower)
|
|
||||||
{
|
|
||||||
s->tail = p->next;
|
|
||||||
s->state = NEW_ELEMENT;
|
|
||||||
return_val = 0;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1833,12 +1821,11 @@ main (int argc, char **argv)
|
|||||||
c1 = get_next (s1, &class_s1);
|
c1 = get_next (s1, &class_s1);
|
||||||
c2 = get_next (s2, &class_s2);
|
c2 = get_next (s2, &class_s2);
|
||||||
|
|
||||||
/* When constructing the translation array, either one of the
|
/* When translating and there is an [:upper:] or [:lower:]
|
||||||
values returned by paired calls to get_next must be from
|
class in SET2, then there must be a corresponding [:lower:]
|
||||||
[:upper:] and the other is [:lower:], or neither can be from
|
or [:upper:] class in SET1. */
|
||||||
upper or lower. */
|
if (class_s1 == UL_NONE
|
||||||
|
&& (class_s2 == UL_LOWER || class_s2 == UL_UPPER))
|
||||||
if ((class_s1 == UL_NONE) != (class_s2 == UL_NONE))
|
|
||||||
error (EXIT_FAILURE, 0,
|
error (EXIT_FAILURE, 0,
|
||||||
_("misaligned [:upper:] and/or [:lower:] construct"));
|
_("misaligned [:upper:] and/or [:lower:] construct"));
|
||||||
|
|
||||||
|
|||||||
@@ -135,6 +135,10 @@ my @tv = (
|
|||||||
|
|
||||||
# Prior to coreutils-6.10, this would provoke a failed assertion.
|
# Prior to coreutils-6.10, this would provoke a failed assertion.
|
||||||
['no-abort-1', '-c ' . q|a '[b*256]'|, 'abc', 'abb', 0],
|
['no-abort-1', '-c ' . q|a '[b*256]'|, 'abc', 'abb', 0],
|
||||||
|
|
||||||
|
# Up to coreutils-6.9, tr rejected an unmatched [:lower:] or [:upper:] in SET1.
|
||||||
|
['s1-lower', q|'[:lower:]' '[.*]'|, '#$%123abcABC', '#$%123...ABC', 0],
|
||||||
|
['s1-upper', q|'[:upper:]' '[.*]'|, '#$%123abcABC', '#$%123abc...', 0],
|
||||||
);
|
);
|
||||||
|
|
||||||
sub test_vector
|
sub test_vector
|
||||||
|
|||||||
Reference in new issue
Block a user