This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] [BZ 17588 13064] Update UTF-8 charmap and width to Unicode 7.0.0
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: Pravin Satpute <psatpute at redhat dot com>, Mike FABIAN <mfabian at redhat dot com>
- Cc: libc-alpha at sourceware dot org
- Date: Thu, 04 Dec 2014 12:25:24 -0200
- Subject: Re: [PATCH] [BZ 17588 13064] Update UTF-8 charmap and width to Unicode 7.0.0
- Authentication-results: sourceware.org; auth=none
- References: <573624784 dot 8871393 dot 1416848051220 dot JavaMail dot zimbra at redhat dot com> <orzjb3o7yf dot fsf at free dot home>
On Dec 4, 2014, Alexandre Oliva <aoliva@redhat.com> wrote:
> On Nov 24, 2014, Pravin Satpute <psatpute@redhat.com> wrote:
>> 6. https://github.com/pravins/glibc-i18n
> I've reviewed the gen scripts in the git repo above.
I see there have been changes since I started the review.
The only one that caught my attention was in gen-unicode-ctype.py.
I think the single loop in read_input_file would be better split into
multiple loops, one for head, one to skip to tail, one for tail.
Also consider using line.startswith instead of regexps for the
end-of-head and beginning-of-tail markers, unless that risks matching
unintended lines.
Finally, consider returning a tuple instead of modifying the global
variable.
It could end up like this:
def read_input_file(filename):
head = tail = ''
with open(filename, mode='r') as file:
for line in file:
match = re.match(
r'^(?P<key>date\s+)(?P<value>"[0-9]{4}-[0-9]{2}-[0-9]{2}")',
line)
if match:
line = match.group('key') + '"{:s}"\n'.format(time.strftime('%Y-%m-%d'))
head = head + line
if (line.startswith('LC_CTYPE'))
break
for line in file:
if (line.startswith('translit_start'))
tail = line
break
for line in file:
tail = tail + line
return (head, tail)
...
(i18n_file_head, i18n_file_tail) = read_input_file(args.input_file)
--
Alexandre Oliva, freedom fighter http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/ FSF Latin America board member
Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer