mirror of
https://github.com/holub/mame
synced 2025-10-05 08:41:31 +03:00
Bugfixes to msgfmt, charset parsing broken on Python 2.6 for inexplicable reasons but does not cause failure (nw)
This commit is contained in:
parent
ff0cd967ca
commit
1f6688b967
@ -140,10 +140,10 @@ def make(filename, outfile):
|
|||||||
section = None
|
section = None
|
||||||
fuzzy = 0
|
fuzzy = 0
|
||||||
empty = 0
|
empty = 0
|
||||||
|
header_attempted = False
|
||||||
|
|
||||||
# Start off assuming Latin-1, so everything decodes without failure,
|
# Start off assuming Latin-1, so everything decodes without failure,
|
||||||
# until we know the exact encoding
|
# until we know the exact encoding
|
||||||
charset = None
|
|
||||||
encoding = 'latin-1'
|
encoding = 'latin-1'
|
||||||
|
|
||||||
# Start off assuming Latin-1, so everything decodes without failure,
|
# Start off assuming Latin-1, so everything decodes without failure,
|
||||||
@ -207,11 +207,11 @@ def make(filename, outfile):
|
|||||||
if msgstr:
|
if msgstr:
|
||||||
msgstr += b'\0' # Separator of the various plural forms
|
msgstr += b'\0' # Separator of the various plural forms
|
||||||
else:
|
else:
|
||||||
if (l[6:].strip() == '""') and (empty == 1) and (not charset):
|
if (l[6:].strip() == '""') and (empty == 1) and (not header_attempted):
|
||||||
header = ""
|
header = ""
|
||||||
# parse up until next empty line = end of header
|
# parse up until next empty line = end of header
|
||||||
hdrno = lno
|
hdrno = lno
|
||||||
while(hdrno < len(lines)):
|
while(hdrno < len(lines)-1):
|
||||||
# This is a roundabout way to strip non-ASCII unicode characters from the header.
|
# This is a roundabout way to strip non-ASCII unicode characters from the header.
|
||||||
# As we are only parsing out the encoding, we don't need any unicode chars in it.
|
# As we are only parsing out the encoding, we don't need any unicode chars in it.
|
||||||
l = lines[hdrno+1].decode('unicode_escape').encode('ascii','ignore').decode(encoding)
|
l = lines[hdrno+1].decode('unicode_escape').encode('ascii','ignore').decode(encoding)
|
||||||
@ -221,10 +221,12 @@ def make(filename, outfile):
|
|||||||
break
|
break
|
||||||
hdrno += 1
|
hdrno += 1
|
||||||
# See whether there is an encoding declaration
|
# See whether there is an encoding declaration
|
||||||
p = HeaderParser()
|
if(hdrno > lno):
|
||||||
charset = p.parsestr(header).get_content_charset()
|
p = HeaderParser()
|
||||||
if charset:
|
charset = p.parsestr(header).get_content_charset()
|
||||||
encoding = charset
|
header_attempted = 1
|
||||||
|
if charset:
|
||||||
|
encoding = charset
|
||||||
if is_plural:
|
if is_plural:
|
||||||
print('indexed msgstr required for plural on %s:%d' % (infile, lno),
|
print('indexed msgstr required for plural on %s:%d' % (infile, lno),
|
||||||
file=sys.stderr)
|
file=sys.stderr)
|
||||||
|
Loading…
Reference in New Issue
Block a user