From 3f48829c2939e53c7e961a42d0749765dc076279 Mon Sep 17 00:00:00 2001 From: Pádraig Brady
Date: Mon, 27 Sep 2010 07:16:44 +0100 Subject: tr: fix various issues with case conversion This valid translation spec aborted: LC_ALL=en_US.iso-8859-1 tr '[:upper:]- ' '[:lower:]_' This invalid translation spec aborted: LC_ALL=en_US.iso-8859-1 tr '[:upper:] ' '[:lower:]' This was caused by commit 6efd1046, 05-01-2008, "Avoid tr case-conversion failure in some locales" This misaligned conversion spec was allowed: LC_ALL=C tr 'A-Y[:lower:]' 'a-z[:upper:]' This was caused by commit af5d0c36, 21-10-2007, "tr: do not reject an unmatched [:lower:] or [:upper:] in SET1" This misaligned spec was allowed by extending the class: LC_ALL=C tr '[:upper:] ' '[:lower:]' * src/tr.c (validate_case_classes): A new function to check alignment of case conversion classes. Also it adjusts the length of the sets so that locales with different numbers of upper and lower case characters, don't cause issues. (string2_extend): Disallow extending the case conversion class as in the above example. That is locale dependent and most likely not what the user wants. (validate): Do the simple test for "restricted" char classes earlier, so we don't redundantly do more expensive validation. (main): Remove the case class validation, and simplify. * tests/misc/tr-case-class: A new test to test the various alignment and locale issues, associated with case conversion. * tests/misc/tr: Move case conversion tests to new tr-case-class. * tests/Makefile.am: Reference the new test. * NEWS: Mention the fixes. --- tests/misc/tr | 26 -------------------------- 1 file changed, 26 deletions(-) (limited to 'tests/misc/tr') diff --git a/tests/misc/tr b/tests/misc/tr index ca7a960bb..00cd8e62c 100755 --- a/tests/misc/tr +++ b/tests/misc/tr @@ -155,34 +155,8 @@ my @Tests = # Up to coreutils-6.9, this would provoke a failed assertion. ['no-abort-1', qw(-c a '[b*256]'), {IN=>'abc'}, {OUT=>'abb'}], - - # Up to coreutils-6.9, tr rejected an unmatched [:lower:] or [:upper:] in SET1. - ['s1-lower', qw('[:lower:]' '[.*]'), - {IN=>'#$%123abcABC'}, {OUT=>'#$%123...ABC'}], - ['s1-upper', qw('[:upper:]' '[.*]'), - {IN=>'#$%123abcABC'}, {OUT=>'#$%123abc...'}], - - # Up to coreutils-6.9.91, this would fail with the diagnostic: - # tr: misaligned [:upper:] and/or [:lower:] construct - # with LC_CTYPE=en_US.ISO-8859-1. - ['tolower-F', qw('[:upper:]' '[:lower:]'), {IN=>'A'}, {OUT=>'a'}], - - # When doing a case-converting translation with something after the - # [:upper:] and [:lower:] elements, ensure that tr honors the following byte. - ['upcase-xtra', qw('[:lower:].' '[:upper:]x'), {IN=>'abc.'}, {OUT=>'ABCx'}], - ['dncase-xtra', qw('[:upper:].' '[:lower:]x'), {IN=>'ABC.'}, {OUT=>'abcx'}], ); -# Set LC_CTYPE=en_US.ISO-8859-1 in the environment of the tolower-F test. -foreach my $t (@Tests) - { - if ($t->[0] eq 'tolower-F') - { - push @$t, {ENV=>'LC_CTYPE=en_US.ISO-8859-1'}; - last; - } - } - @Tests = triple_test \@Tests; # tr takes its input only from stdin, not from a file argument, so -- cgit v1.2.3-70-g09d2