This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] [BZ 17588 13064] Update UTF-8 charmap and width to Unicode 7.0.0


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]