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
[...]
Index: etc/config/run_locale_utils.sh
===================================================================
--- etc/config/run_locale_utils.sh (revision 438522)
+++ etc/config/run_locale_utils.sh (working copy)
@@ -231,11 +231,8 @@
fi
# get locale's name and encoding
- locale_src=`echo $3 | \
- sed -n "s:\([^\.]*\)\.\([EMAIL PROTECTED])\(.*\):\1\3:;\
- s:[EMAIL PROTECTED]::;y:@:.:;p"`;
- locale_encoding=`echo $3 | \
- sed -n "s:\([^\.]*\)\.\([EMAIL PROTECTED])\(.*\):\2:p"`;
+ locale_src=`echo $3 | sed "s:\([^.]*\)\.\([EMAIL PROTECTED])\(.*\):\1\3:;y:@:.:"`;
+ locale_encoding=`echo $3 | 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,10 +90,8 @@
# 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 "@" "."`; \
+ @(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 \
@@ -103,9 +101,8 @@
@(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`; \
+ 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 \