@@ -100,7 +100,7 @@ def GetGsCommand():
100
100
gs_cmd = os .getenv ('PDFSIZEOPT_GS' , None )
101
101
if gs_cmd is None :
102
102
if sys .platform .startswith ('win' ): # Windows: win32 or win64
103
- gs_cmd = FindOnPath (r 'pdfsizeopt_gswin\ gswin32c.exe' )
103
+ gs_cmd = FindOnPath (os . path . join ( 'pdfsizeopt_gswin' , ' gswin32c.exe') )
104
104
if gs_cmd is None :
105
105
data = None
106
106
else :
@@ -8017,7 +8017,14 @@ def main(argv):
8017
8017
used_script_dir = script_dir
8018
8018
else :
8019
8019
used_script_dir = os .path .dirname (os .path .abspath (main_file ))
8020
- libexec_dir = os .path .join (used_script_dir , 'pdfsizeopt_libexec' )
8020
+ libexec_dir = None
8021
+ if libexec_dir is None and sys .platform .startswith ('win' ):
8022
+ xdir = os .path .join (used_script_dir , 'pdfsizeopt_win32exec' )
8023
+ if os .path .isdir (xdir ):
8024
+ libexec_dir = xdir
8025
+ xdir = None
8026
+ if libexec_dir is None :
8027
+ libexec_dir = os .path .join (used_script_dir , 'pdfsizeopt_libexec' )
8021
8028
avian_pathname = None
8022
8029
if os .path .isdir (libexec_dir ):
8023
8030
extrapath_dir = libexec_dir
@@ -8027,9 +8034,13 @@ def main(argv):
8027
8034
else :
8028
8035
extrapath_dir = used_script_dir
8029
8036
if sys .platform .startswith ('win' ):
8030
- extrapath_dir = ShellQuote (extrapath_dir )
8037
+ # ShellQuote(...) doesn't work in wine-1.6.2, is it needed on normal
8038
+ # Windows (e.g. for running sam2p).
8039
+ # extrapath_dir = ShellQuote(extrapath_dir)
8040
+ pass
8031
8041
os .environ ['PATH' ] = '%s%s%s' % (
8032
8042
extrapath_dir , os .pathsep , os .getenv ('PATH' , '' ))
8043
+ #assert 0, os.environ['PATH']
8033
8044
if not argv :
8034
8045
argv = ['pdfsizeopt' ]
8035
8046
if len (argv ) == 1 :
@@ -8186,6 +8197,14 @@ def main(argv):
8186
8197
except getopt .GetoptError , exc :
8187
8198
print >> sys .stderr , 'error: in command line: %s' % exc
8188
8199
sys .exit (1 )
8200
+ if sys .platform .startswith ('win' ):
8201
+ # pngout doesn't work otherwise, because it treats / as flag.
8202
+ # This fix affects wine.
8203
+ if file_name .startswith ('/' ):
8204
+ file_name = file_name .replace ('/' , os .sep )
8205
+ if output_file_name .startswith ('/' ):
8206
+ output_file_name = output_file_name .replace ('/' , os .sep )
8207
+
8189
8208
if do_generate_object_stream and not do_generate_xref_stream :
8190
8209
print >> sys .stderr , ('error: --do-generate-object-stream=yes requires '
8191
8210
'--do-generate-xref-stream=yes' )
0 commit comments