From 251d90301c2bbaaf2c46362986a321fc70712ecc Mon Sep 17 00:00:00 2001 From: Tharo <17233964+Thar0@users.noreply.github.com> Date: Mon, 14 Feb 2022 23:26:03 +0000 Subject: [PATCH] Make text headers encoding more robust (#1145) * Improve encoding stage of text headers * Fix r string * Remove another unnecessary backslash --- Makefile | 3 ++- tools/msgenc.py | 46 ++++++++++++++++++++++++++++------------------ 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index 1fcd8a66e5..86285c9659 100644 --- a/Makefile +++ b/Makefile @@ -246,7 +246,8 @@ build/data/%.o: data/%.s $(AS) $(ASFLAGS) $< -o $@ build/assets/text/%.enc.h: assets/text/%.h assets/text/charmap.txt - python3 tools/msgenc.py assets/text/charmap.txt $< $@ + $(CPP) -P -dD -fpreprocessed $< > $(@:.enc.h=.h) + python3 tools/msgenc.py assets/text/charmap.txt $(@:.enc.h=.h) $@ build/assets/text/fra_message_data_static.o: build/assets/text/message_data.enc.h build/assets/text/ger_message_data_static.o: build/assets/text/message_data.enc.h diff --git a/tools/msgenc.py b/tools/msgenc.py index 80cdd653c0..b2b9cab168 100644 --- a/tools/msgenc.py +++ b/tools/msgenc.py @@ -5,41 +5,51 @@ import argparse, ast, re -charmap = {} - -string_regex = re.compile(r"([\"'`])(?:[\s\S])*?(?:(?