summaryrefslogtreecommitdiffstatshomepage
path: root/scripts/build/msgfmt.py
diff options
context:
space:
mode:
author balr0g <balrog032@gmail.com>2016-03-26 09:01:37 -0400
committer balr0g <balrog032@gmail.com>2016-03-26 09:01:45 -0400
commit1f6688b967aaac0a674a1c33512db1455ea6e712 (patch)
tree5fea51118c59464384388c0b2d5b34b63f6b883b /scripts/build/msgfmt.py
parentff0cd967caec0a726bf168b7bcbf64b171a5037f (diff)
Bugfixes to msgfmt, charset parsing broken on Python 2.6 for inexplicable reasons but does not cause failure (nw)
Diffstat (limited to 'scripts/build/msgfmt.py')
-rw-r--r--scripts/build/msgfmt.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/scripts/build/msgfmt.py b/scripts/build/msgfmt.py
index 5b58bde0dd4..7b804504f05 100644
--- a/scripts/build/msgfmt.py
+++ b/scripts/build/msgfmt.py
@@ -140,10 +140,10 @@ def make(filename, outfile):
section = None
fuzzy = 0
empty = 0
+ header_attempted = False
# Start off assuming Latin-1, so everything decodes without failure,
# until we know the exact encoding
- charset = None
encoding = 'latin-1'
# Start off assuming Latin-1, so everything decodes without failure,
@@ -207,11 +207,11 @@ def make(filename, outfile):
if msgstr:
msgstr += b'\0' # Separator of the various plural forms
else:
- if (l[6:].strip() == '""') and (empty == 1) and (not charset):
+ if (l[6:].strip() == '""') and (empty == 1) and (not header_attempted):
header = ""
# parse up until next empty line = end of header
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.
# 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)
@@ -221,10 +221,12 @@ def make(filename, outfile):
break
hdrno += 1
# See whether there is an encoding declaration
- p = HeaderParser()
- charset = p.parsestr(header).get_content_charset()
- if charset:
- encoding = charset
+ if(hdrno > lno):
+ p = HeaderParser()
+ charset = p.parsestr(header).get_content_charset()
+ header_attempted = 1
+ if charset:
+ encoding = charset
if is_plural:
print('indexed msgstr required for plural on %s:%d' % (infile, lno),
file=sys.stderr)