You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stdcxx.apache.org by Martin Sebor <se...@roguewave.com> on 2006/09/01 00:17:05 UTC

Re: [PATCH] run_locale_utils.sh

Andrew Black wrote:
> Ok...
> 
> Attached are a pair of quick patches that revisit these regular 
> expressions.  Change log for each patch is below.  I suppose they could 
> be committed together if desired.
> 
> --Andrew Black
> 
> ansi_fix.diff change log:
>     * run_locale_utils.sh (test_locale()): Correct locale target name 
> conversion patterns to handle the ANSI_X3.4-1968 character map correctly.
> 
> pattern_sync.diff change log:
>     * GNUmakefile.bin ($(LOCALE_LIST), $(DEPENDDIR)/localedb.d): 
> Simplify and standardize sed patterns used to convert locale target 
> names into locale and character map parameters.

What was non-standard and what were the substantive changes to the
code?

The patches touches the whole rule so it's hard to tell at a glance
exactly what changed (although ignoring whitespace reveals that only
the regular expressions have).

Escaping the dot in the bracket expression shouldn't be necessary
(the dot has no special meaning there except when it comes first).
Ditto for the @ sign. Actually, according to POSIX, even the back
slash character is supposed to lose its usual meaning so I'm not
sure my understanding of the change is correct. Can you explain?

Thanks
Martin

> 
> Martin Sebor wrote:
> 
>> Andrew Black wrote:
>>
>>> Greetings Farid
>>>
>>> May I propose the patch below as an alternative solution?  While the 
>>> cost of running tr in addition to sed isn't too great in the grand 
>>> scheme of things, this removes the additional overhead of the second 
>>> function call.
>>
>>
>> I applied your patch until the names have been changed:
>>   http://svn.apache.org/viewvc?rev=438309&view=rev
>>
>>> It might be worthwhile to also look at the regular expressions used 
>>> in GNUmakefile.bin file, particularly the rules for $(LOCALE_LIST) 
>>> and $(DEPENDDIR)/localedb.d.  Each of these locations has logic that 
>>> makes similar translations.
>>
>>
>> Would you like to put together a patch? If not, could you please
>> open an issue so we don't forget? (A test case or something along
>> those lines demonstrating the problem you are pointing out would
>> be most helpful.)
>>
>>>
>>> A related issue I'm observing is that the en_US.ANSI_X3.4-1968 locale 
>>> fails as follows.
>>
>>
>> Same here (issue + patch please :)
>>
>> Thanks
>> Martin
>>
>>>
>>>  ./en_US.ANSI_X3.4-1968.sh -d
>>> RWSTD_SRC_ROOT=/build/ablack/stdcxx-test/etc/nls
>>> export RWSTD_SRC_ROOT
>>> RWSTD_LOCALE_ROOT=/tmp/locale.13281
>>> export RWSTD_LOCALE_ROOT
>>> ./localedef -w -c -f 
>>> /build/ablack/stdcxx-test/etc/nls/charmaps/ANSI_X3 -i 
>>> /build/ablack/stdcxx-test/etc/nls/src/en_US.4-1968 
>>> /tmp/locale.13281/en_US.ANSI_X3.4-1968 2>/dev/tty
>>> Error 500: /build/ablack/stdcxx-test/etc/nls/charmaps/ANSI_X3 could 
>>> not be opened for reading
>>>
>>>
> [...]
> 
> 
> ------------------------------------------------------------------------
> 
> Index: etc/config/run_locale_utils.sh
> ===================================================================
> --- etc/config/run_locale_utils.sh	(revision 438522)
> +++ etc/config/run_locale_utils.sh	(working copy)
> @@ -232,10 +232,9 @@
>  
>      # get locale's name and encoding
>      locale_src=`echo $3 | \
> -                sed -n "s:\([^\.]*\)\.\([^\.\@]*\)\(.*\):\1\3:;\
> -                        s:\@$::;y:@:.:;p"`;
> +                sed "s:\([^\.]*\)\.\([^\@]*\)\(.*\):\1\3:;y:@:.:"`;
>      locale_encoding=`echo $3 | \
> -                     sed -n "s:\([^\.]*\)\.\([^\.\@]*\)\(.*\):\2:p"`;
> +                     sed "s:\([^\.]*\)\.\([^\@]*\)\(.*\):\2:"`;
>  
>      ## generate the first locale database
>      generate_locale $1/charmaps/$locale_encoding     \
> 
> 
> ------------------------------------------------------------------------
> 
> Index: etc/config/GNUmakefile.bin
> ===================================================================
> --- etc/config/GNUmakefile.bin	(revision 438522)
> +++ etc/config/GNUmakefile.bin	(working copy)
> @@ -90,27 +90,27 @@
>  # the rule presents as dependencies the source files corresponding
>  # to that locale; it is run once for each entry in LOCALE_LIST
>  $(LOCALE_LIST):
> -	@(lname=`echo $@ |                                                   \
> -                 sed s:"\([^.]*\)\.\([^>@]*\)\(.*\)":"\1\3":g | tr "@" "."`; \
> -          cname=`echo $@ |                                                   \
> -                 sed s:"\([^.]*\)\.\([^>@]*\)\(.*\)":"\2":g | tr "@" "."`;   \
> -          echo "./localedef -w -c -f $(NLSDIR)/charmaps/$$cname"             \
> -               "-i $(NLSDIR)/src/$$lname $(LOCDIR)/$@";                      \
> -          ./localedef -w -c -f $(NLSDIR)/charmaps/$$cname                    \
> +	@(lname=`echo $@ |                                               \
> +                 sed "s:\([^\.]*\)\.\([^\@]*\)\(.*\):\1\3:;y:@:.:"`; \
> +          cname=`echo $@ |                                           \
> +                 sed "s:\([^\.]*\)\.\([^\@]*\)\(.*\):\2:"`;          \
> +          echo "./localedef -w -c -f $(NLSDIR)/charmaps/$$cname"     \
> +               "-i $(NLSDIR)/src/$$lname $(LOCDIR)/$@";              \
> +          ./localedef -w -c -f $(NLSDIR)/charmaps/$$cname            \
>                        -i $(NLSDIR)/src/$$lname $(LOCDIR)/$@)
>  
>  $(DEPENDDIR)/localedb.d:
> -	@(echo "# generated locale dependencies" > $@;                      \
> -          for f in $(LOCALE_LIST); do                                       \
> -              lname=`echo $$f |                                             \
> -                sed s:"\([^.]*\)\.\([^>@]*\)\(.*\)":"\1\3":g | tr "@" "."`; \
> -              cname=`echo $$f |                                             \
> -                sed s:"\([^.]*\)\.\([^>@]*\)\(.*\)":"\2":g`;                \
> -              f=$$f;                                                        \
> -              echo "generating dependencies for $$f";                       \
> -              printf "%-32s:%s %s\n" $$f                                    \
> -                     $(NLSDIR)/src/$$lname                                  \
> -                     $(NLSDIR)/charmaps/$$cname >> $@;                      \
> +	@(echo "# generated locale dependencies" > $@;                  \
> +          for f in $(LOCALE_LIST); do                               \
> +              lname=`echo $$f |                                     \
> +                sed "s:\([^\.]*\)\.\([^\@]*\)\(.*\):\1\3:;y:@:.:"`; \
> +              cname=`echo $$f |                                     \
> +                sed "s:\([^\.]*\)\.\([^\@]*\)\(.*\):\2:"`;        	\
> +              f=$$f;                                                \
> +              echo "generating dependencies for $$f";               \
> +              printf "%-32s:%s %s\n" $$f                            \
> +                     $(NLSDIR)/src/$$lname                          \
> +                     $(NLSDIR)/charmaps/$$cname >> $@;              \
>            done;)
>  
>  # include the generated dependencies file


Re: [PATCH] run_locale_utils.sh

Posted by Martin Sebor <se...@roguewave.com>.
Andrew Black wrote:
> Take two on the patches are attached (removing most of the whitespace 
> changes).
> 
> I've done a little more cleanup on the patterns (including removing the 
> unneeded escapes within the [] blocks), and I think the pattern is about 
> as simple as I can get it.  It would be possible to remove some of the 
> capture braces, but I decided against this, as it would remove some of 
> the similarities between the pairs of patterns that can provide a 
> measure of context to other developers working on the code.
> 
> I'm not certain if standardization would be the most accurate 
> description of what I did, but it is accurate enough.  The (basically) 
> same pair of patterns was used in 3 different locations, and I replaced 
> all these instances with a single pair of patterns.

I see. So by standardization you mean making semantically equivalent
expressions syntactically identical, and not avoiding non-standard
(as in non-portable) constructs.

I clarified your changelog to that effect and committed both patches
here: http://svn.apache.org/viewvc?rev=439399&view=rev.

Thanks
Martin

Re: [PATCH] run_locale_utils.sh

Posted by Andrew Black <ab...@roguewave.com>.
Take two on the patches are attached (removing most of the whitespace 
changes).

I've done a little more cleanup on the patterns (including removing the 
unneeded escapes within the [] blocks), and I think the pattern is about 
as simple as I can get it.  It would be possible to remove some of the 
capture braces, but I decided against this, as it would remove some of 
the similarities between the pairs of patterns that can provide a 
measure of context to other developers working on the code.

I'm not certain if standardization would be the most accurate 
description of what I did, but it is accurate enough.  The (basically) 
same pair of patterns was used in 3 different locations, and I replaced 
all these instances with a single pair of patterns.

--Andrew Black

Martin Sebor wrote:
> Andrew Black wrote:
>> Ok...
>>
>> Attached are a pair of quick patches that revisit these regular 
>> expressions.  Change log for each patch is below.  I suppose they 
>> could be committed together if desired.
>>
>> --Andrew Black
>>
>> ansi_fix.diff change log:
>>     * run_locale_utils.sh (test_locale()): Correct locale target name 
>> conversion patterns to handle the ANSI_X3.4-1968 character map correctly.
>>
>> pattern_sync.diff change log:
>>     * GNUmakefile.bin ($(LOCALE_LIST), $(DEPENDDIR)/localedb.d): 
>> Simplify and standardize sed patterns used to convert locale target 
>> names into locale and character map parameters.
> 
> What was non-standard and what were the substantive changes to the
> code?
> 
> The patches touches the whole rule so it's hard to tell at a glance
> exactly what changed (although ignoring whitespace reveals that only
> the regular expressions have).
> 
> Escaping the dot in the bracket expression shouldn't be necessary
> (the dot has no special meaning there except when it comes first).
> Ditto for the @ sign. Actually, according to POSIX, even the back
> slash character is supposed to lose its usual meaning so I'm not
> sure my understanding of the change is correct. Can you explain?
> 
> Thanks
> Martin
> 
[...]