Author: forenr
Date: Thu Jun 2 00:22:58 2011
New Revision: 38921
URL: http://www.lyx.org/trac/changeset/38921
Log:
On Windows, improve detection of the TeX engine by avoiding spaces in
filenames passed to latex (through the short form of the path) and also
by taking into account that a short form may not always be available.
Such detection may still fail if the file system does not support short
names and the TeX engine doesn't allow spaces in filenames, but this is
a highly improbable condition, hopefully.
Modified:
lyx-devel/branches/BRANCH_2_0_X/lib/configure.py
lyx-devel/branches/BRANCH_2_0_X/status.20x
Modified: lyx-devel/branches/BRANCH_2_0_X/lib/configure.py
==============================================================================
--- lyx-devel/branches/BRANCH_2_0_X/lib/configure.py Wed Jun 1 21:24:57
2011 (r38920)
+++ lyx-devel/branches/BRANCH_2_0_X/lib/configure.py Thu Jun 2 00:22:58
2011 (r38921)
@@ -102,7 +102,15 @@
from tempfile import mkstemp
fd, tmpfname = mkstemp(suffix='.ltx')
if os.name == 'nt':
- inpname = tmpfname.replace('\\', '/')
+ from ctypes import windll, create_unicode_buffer
+ GetShortPathName = windll.kernel32.GetShortPathNameW
+ longname = unicode(tmpfname)
+ shortlen = GetShortPathName(longname, 0, 0)
+ shortname = create_unicode_buffer(shortlen)
+ if GetShortPathName(longname, shortname, shortlen):
+ inpname = shortname.value.replace('\\', '/')
+ else:
+ inpname = tmpfname.replace('\\', '/')
else:
inpname = cmdOutput('cygpath -m ' + tmpfname)
logname = os.path.basename(inpname.replace('.ltx', '.log'))
@@ -111,6 +119,8 @@
os.close(fd)
latex_out = cmdOutput(r'latex "\nonstopmode\input{%s}"' % inpname)
if 'Error' in latex_out:
+ latex_out = cmdOutput(r'latex "\nonstopmode\input{\"%s\"}"' %
inpname)
+ if 'Error' in latex_out:
logger.warning("configure: TeX engine needs posix-style paths in
latex files")
windows_style_tex_paths = 'false'
else:
@@ -1293,7 +1303,7 @@
msg = "Checking whether TeX allows spaces in file names... "
writeToFile('a b.tex', r'\message{working^^J}' )
if LATEX != '':
- if os.name == 'nt':
+ if os.name == 'nt' or sys.platform == 'cygwin':
latex_out = cmdOutput(LATEX + r""" "\nonstopmode\input{\"a
b\"}" """)
else:
latex_out = cmdOutput(LATEX + r""" '\nonstopmode\input{"a b"}'
""")
Modified: lyx-devel/branches/BRANCH_2_0_X/status.20x
==============================================================================
--- lyx-devel/branches/BRANCH_2_0_X/status.20x Wed Jun 1 21:24:57 2011
(r38920)
+++ lyx-devel/branches/BRANCH_2_0_X/status.20x Thu Jun 2 00:22:58 2011
(r38921)
@@ -91,6 +91,9 @@
- Calculate relative pathnames to master documents when master is in a
directory above the child (bug #7540).
+- On Windows, improve detection of the TeX engine when the file system does
+ not support short names and the temp directory contains spaces.
+
* USER INTERFACE