From 458c8cff9dd2cab8460b9d8037bd37c180fc1010 Mon Sep 17 00:00:00 2001 From: "Y. Wang" Date: Mon, 18 Mar 2024 02:02:27 +0100 Subject: [PATCH] Fix inconsistent backslash escaping --- advtrains/poconvert.lua | 4 ++-- advtrains/spec/poconvert_spec.lua | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/advtrains/poconvert.lua b/advtrains/poconvert.lua index f44cbd1..3075282 100644 --- a/advtrains/poconvert.lua +++ b/advtrains/poconvert.lua @@ -13,12 +13,12 @@ do local function replace_single(pfx, c) local pl = #pfx if pl % 2 == 0 then - return pfx .. c + return pfx:sub(1, pl/2) .. c end return string.sub(pfx, 1, math.floor(pl/2)) .. (schartbl[c] or c) end unescape_string = function(str) - return (string.gsub(str, [[(\+)([abefnrtv'"?])]], replace_single):gsub([[\\]], [[\]])) + return string.gsub(str, [[(\+)([abefnrtv'"?])]], replace_single) end end diff --git a/advtrains/spec/poconvert_spec.lua b/advtrains/spec/poconvert_spec.lua index ef87619..7b2ceea 100644 --- a/advtrains/spec/poconvert_spec.lua +++ b/advtrains/spec/poconvert_spec.lua @@ -9,7 +9,7 @@ describe("PO file converter", function() # textdomain: foo foo=bar baz= -#@=wh\at\@n=@=w\as\@n +#@=wh\at\\@n=@=w\as\\@n multiline@nstrings= with context?=oder doch nicht]], poconvert.from_string("foo", [[ msgid "" @@ -22,8 +22,8 @@ msgid "baz" msgstr "" #, fuzzy -msgid "=wh\\at\\\n" -msgstr "=w\\as\\\n" +msgid "=wh\\at\\\\\n" +msgstr "=w\\as\\\\\n" msgid "multi" "line\n"