[Libreoffice-commits] core.git: librelogo/source sw/qa

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Oct 26 13:52:24 UTC 2018


 librelogo/source/LibreLogo/LibreLogo.py |    7 ++++---
 sw/qa/uitest/librelogo/compile.py       |    4 ++++
 2 files changed, 8 insertions(+), 3 deletions(-)

New commits:
commit 5590c70b47c029006edec41be70c34a0a07fd6fd
Author:     László Németh <nemeth at numbertext.org>
AuthorDate: Fri Oct 26 10:58:47 2018 +0200
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Fri Oct 26 15:51:58 2018 +0200

    LibreLogo: support backslash escape sequence for apostrophes
    
    (ASCII and typographical) and for enclosing quotes of string literals.
    
    Change-Id: I3caf3b707afa1fb41ba3afe9ff12ebce7ce63847
    Reviewed-on: https://gerrit.libreoffice.org/62384
    Tested-by: Jenkins
    Reviewed-by: László Németh <nemeth at numbertext.org>

diff --git a/librelogo/source/LibreLogo/LibreLogo.py b/librelogo/source/LibreLogo/LibreLogo.py
index 8834baf8e640..626c5d210f09 100644
--- a/librelogo/source/LibreLogo/LibreLogo.py
+++ b/librelogo/source/LibreLogo/LibreLogo.py
@@ -417,7 +417,7 @@ def __translate__(arg = None):
     __strings__ = []
 
     text = re.sub(r"^(([ \t]*[;#][^\n]*))", __encodecomment__, text)
-    text = re.sub("(?u)([%s])([^\n%s]*)(?<!\\\\)[%s]" % (lq, rq, rq), __encodestring__, selection.getString())
+    text = re.sub("(?u)([%s])((?:[^\n%s]|\\\\[%s])*)(?<!\\\\)[%s]" % (lq, rq, rq, rq), __encodestring__, selection.getString())
     text = re.sub('(?u)(?<![0-9])(")(~?\w*)', __encodestring__, text)
     text = re.sub(r";(([^\n]*))", __encodecomment__, text)
 
@@ -521,7 +521,8 @@ def __is_alive__():
     return __thread__ != None
 
 def __encodestring__(m):
-    __strings__.append(re.sub("\\[^\\]", "", m.group(2)))
+    __strings__.append(re.sub("(\\[^\\]|\\\\(?=[‘’“”»」』]))", "", m.group(2)))
+    # replace the string with the numbered identifier _s_0___, _s_1___, ...
     return __ENCODED_STRING__ % (len(__strings__) - 1)
 
 def __encodecomment__(m):
@@ -1767,7 +1768,7 @@ def __compil__(s):
     lq = '\'' + __l12n__(_.lng)['LEFTSTRING'].replace("|", "")
     rq = '\'' + __l12n__(_.lng)['RIGHTSTRING'].replace("|", "")
     __strings__ = []
-    s = re.sub("(?u)([%s])([^\n%s]*)(?<!\\\\)[%s]" % (lq, rq, rq), __encodestring__, s)
+    s = re.sub("(?u)([%s])((?:[^\n%s]|\\\\[%s])*)(?<!\\\\)[%s]" % (lq, rq, rq, rq), __encodestring__, s)
     s = re.sub('(?u)(?<![0-9])(")(~?\w*)', __encodestring__, s)
 
     # remove extra spaces
diff --git a/sw/qa/uitest/librelogo/compile.py b/sw/qa/uitest/librelogo/compile.py
index 59d5586e74be..b6eaa6407ce4 100644
--- a/sw/qa/uitest/librelogo/compile.py
+++ b/sw/qa/uitest/librelogo/compile.py
@@ -87,6 +87,10 @@ class LibreLogoCompileTest(UITestCase):
                 ("LABEL \"label", "label(u'label')"),
                 ("LABEL “label”", "label(u'label')"),
                 ("LABEL 'label'", "label(u'label')"),
+                ("LABEL ‘label’", "label(u'label')"),
+                ("LABEL “label\’s”", "label(u'label’s')"),
+                ("LABEL ““It\’s quote\’s...\””", "label(u'“It’s quote’s...”')"),
+                ("LABEL ““It\\'s quote\\'s...\””", "label(u'“It\\'s quote\\'s...”')"),
                 ):
             compiled = xCompile.invoke((test[0],), (), ())[0]
             self.assertEqual(test[1], re.sub(r'(\n| +\n)+', '\n', re.sub(r'\( ', '(', compiled)).strip())


More information about the Libreoffice-commits mailing list