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.
This commit is contained in:
Enrico Forestieri 2018-07-28 23:07:17 +02:00
parent 3e92efd118
commit 0056867be8

View File

@ -25,6 +25,13 @@ console.setFormatter(formatter)
logger = logging.getLogger('LyX') logger = logging.getLogger('LyX')
logger.addHandler(console) 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): def writeToFile(filename, lines, append = False):
" utility function: write or append lines to filename " " utility function: write or append lines to filename "
if append: if append:
@ -267,10 +274,11 @@ def checkProg(description, progs, rc_entry = [], path = [], not_found = ''):
if "PATHEXT" in os.environ: if "PATHEXT" in os.environ:
extlist = extlist + os.environ["PATHEXT"].split(os.pathsep) extlist = extlist + os.environ["PATHEXT"].split(os.pathsep)
global java, perl global java, perl
unquoted_space = re.compile(r'''((?:[^ "']|"[^"]*"|'[^']*')+)''')
for idx in range(len(progs)): for idx in range(len(progs)):
# ac_prog may have options, ac_word is the command name # ac_prog may have options, ac_word is the command name
ac_prog = progs[idx] ac_prog = progs[idx].replace('"', '\\"')
ac_word = ac_prog.split(' ')[0] ac_word = unquoted_space.split(progs[idx])[1::2][0].strip('"')
if (ac_word.endswith('.class') or ac_word.endswith('.jar')) and java == '': if (ac_word.endswith('.class') or ac_word.endswith('.jar')) and java == '':
continue continue
if ac_word.endswith('.pl') and perl == '': if ac_word.endswith('.pl') and perl == '':
@ -793,7 +801,7 @@ def checkConverterEntries():
in_binary_dir = os.path.join(lyx_binary_dir, 'tex2lyx') in_binary_dir = os.path.join(lyx_binary_dir, 'tex2lyx')
in_binary_dir = os.path.abspath(in_binary_dir).replace('\\', '/') 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" "" rc_entry = [r'''\converter latex lyx "%% -f $$i $$o" ""
\converter latexclipboard lyx "%% -fixedenc utf8 -f $$i $$o" "" \converter latexclipboard lyx "%% -fixedenc utf8 -f $$i $$o" ""
\converter literate lyx "%% -n -m noweb -f $$i $$o" "" \converter literate lyx "%% -n -m noweb -f $$i $$o" ""