The attached patch fixes
http://www.lyx.org/trac/ticket/7657
for me.

Could some pythionist please review this?

If this can go in I would be able to fix the same bug for other third-party programs.

thanks and regards
Uwe
diff --git 
"a/C:\\Users\\Usti\\AppData\\Local\\Temp\\TortoiseGit\\con1414.tmp\\configure-77ab301-left.py"
 "b/D:\\LyXGit\\Master\\lib\\configure.py"
index ba5d2a4..e36afca 100644
--- 
"a/C:\\Users\\Usti\\AppData\\Local\\Temp\\TortoiseGit\\con1414.tmp\\configure-77ab301-left.py"
+++ "b/D:\\LyXGit\\Master\\lib\\configure.py"
@@ -228,6 +228,8 @@ def checkProg(description, progs, rc_entry = [], path = [], 
not_found = ''):
         progs: check programs, for each prog, the first word is used
             for searching but the whole string is used to replace
             %% for a rc_entry. So, feel free to add '$$i' etc for programs.
+            Note that spaces in prog paths must be input as '\s'.
+            Note that quotes around prog paths must be input as '\\"'.
 
         path: additional pathes
 
@@ -255,6 +257,11 @@ def checkProg(description, progs, rc_entry = [], path = 
[], not_found = ''):
         # ac_prog may have options, ac_word is the command name
         ac_prog = progs[idx]
         ac_word = ac_prog.split(' ')[0]
+        # we need to replace the \s by a real space
+        ac_word = ac_word.replace('\s', ' ')
+        ac_prog = ac_prog.replace('\s', ' ')
+        # we allow to input quoted paths
+        ac_word = ac_word.replace('\\"', '')
         if (ac_word.endswith('.class') or ac_word.endswith('.jar')) and java 
== '':
             continue
         if ac_word.endswith('.pl') and perl == '':
@@ -467,6 +474,19 @@ def checkDTLtools():
     return dtl_tools
 
 
+def getInkscapeBinary():
+    if os.name == 'nt':
+        import _winreg
+        aReg = _winreg.ConnectRegistry(None, _winreg.HKEY_CLASSES_ROOT)
+        try:
+            aKey = _winreg.OpenKey(aReg, r"inkscape.svg\DefaultIcon")
+            val = _winreg.QueryValueEx(aKey, "")
+            return str(val[0])
+        except EnvironmentError:
+            return ''
+    return 'inkscape'
+
+
 def checkLatex(dtl_tools):
     ''' Check latex, return lyx_check_config '''
     path, LATEX = checkProg('a Latex2e program', ['latex $$i', 'latex2e $$i'])
@@ -581,7 +601,7 @@ def checkFormatEntries(dtl_tools):
     checkViewerEditor('a FEN viewer and editor', ['xboard -lpf $$i -mode 
EditPosition'],
         rc_entry = [r'\Format fen        fen     FEN                    "" 
"%%"        "%%"    ""      ""'])
     #
-    checkViewerEditor('a SVG viewer and editor', ['inkscape'],
+    checkViewerEditor('a SVG viewer and editor', [getInkscapeBinary()],
         rc_entry = [r'\Format svg        "svg, svgz" SVG                "" 
"%%" "%%"   "vector,zipped=native"  "image/svg+xml"'])
     #
     imageformats = r'''\Format bmp        bmp     BMP                    "" 
"%s"       "%s"    ""      "image/x-bmp"
@@ -959,13 +979,19 @@ def checkConverterEntries():
     checkProg('an OpenDocument -> EPS converter', ['libreoffice -headless 
-nologo -convert-to eps $$i', 'unoconv -f eps --stdout $$i > $$o'],
         rc_entry = [ r'\converter odg        eps2       "%%"   ""'])
     # Only define a converter to pdf6 for graphics
-    checkProg('a SVG -> PDF converter', ['rsvg-convert -f pdf -o $$o $$i', 
'inkscape --file=$$i --export-area-drawing --without-gui --export-pdf=$$o'],
+    inkscape = getInkscapeBinary()
+    # on Windows we we got a quoted path with spaces and backslashes
+    # therefore replace the backslashes, the spaces and the quotes
+    inkscape = inkscape.replace('\\', '/')
+    inkscape = inkscape.replace('"', '\\"')
+    inkscape = inkscape.replace(' ', '\s')
+    checkProg('a SVG -> PDF converter', ['rsvg-convert -f pdf -o $$o $$i', '%s 
--file=$$i --export-area-drawing --without-gui --export-pdf=$$o' % inkscape],
         rc_entry = [ r'\converter svg        pdf6       "%%"   ""'])
     #
-    checkProg('a SVG -> EPS converter', ['rsvg-convert -f ps -o $$o $$i', 
'inkscape --file=$$i --export-area-drawing --without-gui --export-eps=$$o'],
+    checkProg('a SVG -> EPS converter', ['rsvg-convert -f ps -o $$o $$i', '%s 
--file=$$i --export-area-drawing --without-gui --export-eps=$$o' % inkscape],
         rc_entry = [ r'\converter svg        eps        "%%"   ""'])
     #
-    checkProg('a SVG -> PNG converter', ['rsvg-convert -f png -o $$o $$i', 
'inkscape --without-gui --file=$$i --export-png=$$o'],
+    checkProg('a SVG -> PNG converter', ['rsvg-convert -f png -o $$o $$i', '%s 
--without-gui --file=$$i --export-png=$$o' % inkscape],
         rc_entry = [ r'\converter svg        png        "%%"   ""'])
 
     #

Reply via email to