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:\([^\.]*\)\.\([EMAIL PROTECTED])\(.*\):\1\3:;\
-                        s:[EMAIL PROTECTED]::;y:@:.:;p"`;
+                sed "s:\([^\.]*\)\.\([EMAIL PROTECTED])\(.*\):\1\3:;y:@:.:"`;
     locale_encoding=`echo $3 | \
-                     sed -n "s:\([^\.]*\)\.\([EMAIL PROTECTED])\(.*\):\2:p"`;
+                     sed "s:\([^\.]*\)\.\([EMAIL PROTECTED])\(.*\):\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:\([^\.]*\)\.\([EMAIL PROTECTED])\(.*\):\1\3:;y:@:.:"`; 
\
+          cname=`echo $@ |                                           \
+                 sed "s:\([^\.]*\)\.\([EMAIL PROTECTED])\(.*\):\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:\([^\.]*\)\.\([EMAIL PROTECTED])\(.*\):\1\3:;y:@:.:"`; \
+              cname=`echo $$f |                                     \
+                sed "s:\([^\.]*\)\.\([EMAIL PROTECTED])\(.*\):\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

Reply via email to