[Mesa-dev] [PATCH] xmlpool: fix script to write bytes instead of locale-formatted strings
Ilia Mirkin
imirkin at alum.mit.edu
Fri Aug 24 03:18:22 UTC 2018
Withdrawn. This doesn't actually work. Will follow up with something that does.
On Thu, Aug 23, 2018 at 11:08 PM, Ilia Mirkin <imirkin at alum.mit.edu> wrote:
> With LANG=C, print won't output any non-ascii characters. Since we're
> trying to get specific bytes onto stdout, we can just write these
> directly.
>
> Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
> ---
> src/util/xmlpool/gen_xmlpool.py | 16 +++++++++-------
> 1 file changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/src/util/xmlpool/gen_xmlpool.py b/src/util/xmlpool/gen_xmlpool.py
> index 56a67bcab55..640b1bc7d42 100644
> --- a/src/util/xmlpool/gen_xmlpool.py
> +++ b/src/util/xmlpool/gen_xmlpool.py
> @@ -144,7 +144,8 @@ def expandMatches (matches, translations, end=None):
> if sys.version_info.major == 2:
> text = text.encode('utf-8')
>
> - print(text)
> + sys.stdout.write(text)
> + sys.stdout.write('\n')
>
> # Expand any subsequent enum lines
> for match in matches[1:]:
> @@ -157,11 +158,12 @@ def expandMatches (matches, translations, end=None):
> if sys.version_info.major == 2:
> text = text.encode('utf-8')
>
> - print(text)
> + sys.stdout.write(text)
> + sys.stdout.write('\n')
>
> # Expand description end
> if end:
> - print(end, end='')
> + sys.stdout.write(end)
>
> # Compile a list of translation classes to all supported languages.
> # The first translation is always a NullTranslations.
> @@ -182,9 +184,9 @@ reENUM = re.compile (r'(\s*DRI_CONF_ENUM\s*\([^,]+,\s*)(gettext\s*\(\s*")(
> reDESC_END = re.compile (r'\s*DRI_CONF_DESC_END')
>
> # Print a header
> -print("/***********************************************************************\n" \
> +sys.stdout.write("/***********************************************************************\n" \
> " *** THIS FILE IS GENERATED AUTOMATICALLY. DON'T EDIT! ***\n" \
> -" ***********************************************************************/")
> +" ***********************************************************************/\n")
>
> # Process the options template and generate options.h with all
> # translations.
> @@ -206,7 +208,7 @@ for line in template:
> continue
> if reLibintl_h.search (line):
> # Ignore (comment out) #include <libintl.h>
> - print("/* %s * commented out by gen_xmlpool.py */" % line)
> + sys.stdout.write("/* %s * commented out by gen_xmlpool.py */\n" % line)
> continue
> matchDESC = reDESC .match (line)
> matchDESC_BEGIN = reDESC_BEGIN.match (line)
> @@ -222,7 +224,7 @@ for line in template:
> if sys.version_info.major == 2:
> line = line.encode('utf-8')
>
> - print(line, end='')
> + sys.stdout.write(line)
>
> template.close()
>
> --
> 2.16.4
>
More information about the mesa-dev
mailing list