]> git.lyx.org Git - lyx.git/commitdiff
Fix bug #11214
authorEnrico Forestieri <forenr@lyx.org>
Sat, 28 Jul 2018 21:27:43 +0000 (23:27 +0200)
committerEnrico Forestieri <forenr@lyx.org>
Sat, 28 Jul 2018 21:27:43 +0000 (23:27 +0200)
The checkProg() function was separating a command from its parameters
by splitting at the first space. This was a problem if the command
was specified with a full path containing spaces. Now the checkProg()
function separates a command from the parameters by splitting at the
first non-quoted space. So, it suffices quoting a path to solve the
issue.

lib/configure.py
status.23x

index 627591298ae04634dccdafcea038e48e39af7f28..7bfac3d135b03c72d4b68d0a50372ae26f3b33f7 100644 (file)
@@ -25,6 +25,13 @@ console.setFormatter(formatter)
 logger = logging.getLogger('LyX')
 logger.addHandler(console)
 
+def quoteIfSpace(name):
+    " utility function: quote name if it contains spaces "
+    if ' ' in name:
+        return '"' + name + '"'
+    else:
+        return name
+
 def writeToFile(filename, lines, append = False):
     " utility function: write or append lines to filename "
     if append:
@@ -262,10 +269,11 @@ def checkProg(description, progs, rc_entry = [], path = [], not_found = ''):
     if "PATHEXT" in os.environ:
         extlist = extlist + os.environ["PATHEXT"].split(os.pathsep)
     global java, perl
+    unquoted_space = re.compile(r'''((?:[^ "']|"[^"]*"|'[^']*')+)''')
     for idx in range(len(progs)):
         # ac_prog may have options, ac_word is the command name
-        ac_prog = progs[idx]
-        ac_word = ac_prog.split(' ')[0]
+        ac_prog = progs[idx].replace('"', '\\"')
+        ac_word = unquoted_space.split(progs[idx])[1::2][0].strip('"')
         if (ac_word.endswith('.class') or ac_word.endswith('.jar')) and java == '':
             continue
         if ac_word.endswith('.pl') and perl == '':
@@ -789,7 +797,7 @@ def checkConverterEntries():
     in_binary_dir = os.path.join(lyx_binary_dir, 'tex2lyx')
     in_binary_dir = os.path.abspath(in_binary_dir).replace('\\', '/')
 
-    path, t2l = checkProg('a LaTeX/Noweb -> LyX converter', [in_binary_subdir, in_binary_subdir + version_suffix, in_binary_dir, in_binary_dir + version_suffix, 'tex2lyx' + version_suffix, 'tex2lyx'],
+    path, t2l = checkProg('a LaTeX/Noweb -> LyX converter', [quoteIfSpace(in_binary_subdir), quoteIfSpace(in_binary_subdir + version_suffix), quoteIfSpace(in_binary_dir), quoteIfSpace(in_binary_dir + version_suffix), 'tex2lyx' + version_suffix, 'tex2lyx'],
         rc_entry = [r'''\converter latex      lyx        "%% -f $$i $$o"       ""
 \converter latexclipboard lyx        "%% -fixedenc utf8 -f $$i $$o"    ""
 \converter literate   lyx        "%% -n -m noweb -f $$i $$o"   ""
index 4e70d977968c069458d8cac5d172c3777596879f..f3c13c5a2108f8584dcf58953e6710557721012e 100644 (file)
@@ -287,6 +287,9 @@ What's new
 
 - Fix language code of Austrian (old spelling).
 
+- When reconfiguring LyX, correctly detect commands specified with a
+  full path with spaces (bug 11214).
+
 
 * DOCUMENTATION AND LOCALIZATION