From: Jan Nieuwenhuizen Date: Fri, 18 Mar 2005 15:19:12 +0000 (+0000) Subject: * scm/framework-tex.scm (convert-to-dvi): Barf if NAME contains X-Git-Tag: release/2.5.16~2 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=5fa21ad8e8ee90a8974e0b1f51d606a796048cfa;p=lilypond.git * scm/framework-tex.scm (convert-to-dvi): Barf if NAME contains whitespace. * python/lilylib.py (make_ps_images): * scm/backend-library.scm (postscript->pdf, postscript->png): Quote file name. Use format rather than string-append juggling. --- diff --git a/ChangeLog b/ChangeLog index bc6c210e11..1135fd7d1b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2005-03-18 Jan Nieuwenhuizen + + * scm/framework-tex.scm (convert-to-dvi): Barf if NAME contains + whitespace. + + * python/lilylib.py (make_ps_images): + * scm/backend-library.scm (postscript->pdf, postscript->png): + Quote file name. Use format rather than string-append juggling. + 2005-03-18 Han-Wen Nienhuys * lily/key-performer.cc (create_audio_elements): don't use diff --git a/python/lilylib.py b/python/lilylib.py index 67336b02da..99d6684fe7 100644 --- a/python/lilylib.py +++ b/python/lilylib.py @@ -504,19 +504,18 @@ def make_ps_images (ps_name, resolution = 90, papersize = "a4"): if y == 0: y = 1 - ###cmd = r'''gs -g%dx%d -sDEVICE=png16m -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -q -sOutputFile=%s -r%d -dNOPAUSE %s %s -c showpage -c quit ''' % \ - ### (x, y, output_file, resolution, trans_ps, ps_name) cmd = r'''gs\ -g%(x)d%(y)d\ - -sDEVICE=png16m\ - -dTextAlphaBits=4\ -dGraphicsAlphaBits=4\ - -q\ - -sOutputFile=%(output_file)s\ + -dNOPAUSE\ + -dTextAlphaBits=4\ + -sDEVICE=png16m\ + -sOutputFile='%(output_file)s'\ -sPAPERSIZE=%(papersize)s\ - -r%(resolution)d -dNOPAUSE\ + -q\ + -r%(resolution)d\ %(trans_ps)s\ - %(ps_name)s\ + '%(ps_name)s'\ -c showpage\ -c quit ''' % vars () @@ -529,18 +528,17 @@ def make_ps_images (ps_name, resolution = 90, papersize = "a4"): if os.path.isfile (rmfile): os.unlink (rmfile) - ###cmd = r'''gs -s -sDEVICE=png16m -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -q -sOutputFile=%s -dNOPAUSE -r%d %s -c quit''' % (output_file, - ### resolution, ps_name) cmd = r'''gs\ -s\ - -sDEVICE=png16m\ - -dTextAlphaBits=4\ -dGraphicsAlphaBits=4\ - -q\ - -sOutputFile=%(output_file)s\ + -dNOPAUSE\ + -dTextAlphaBits=4\ + -sDEVICE=png16m\ + -sOutputFile='%(output_file)s'\ -sPAPERSIZE=%(papersize)s\ - -dNOPAUSE -r%(resolution)d\ - %(ps_name)s\ + -q\ + -r%(resolution)d\ + '%(ps_name)s'\ -c quit''' % vars () status = system (cmd) diff --git a/scm/backend-library.scm b/scm/backend-library.scm index 9c10bcc851..59bfb2dbd9 100644 --- a/scm/backend-library.scm +++ b/scm/backend-library.scm @@ -34,12 +34,8 @@ "\"")) (define-public (postscript->pdf papersizename name) - (let* ((cmd (string-append "ps2pdf " - (string-append - " -sPAPERSIZE=" - (sanitize-command-option papersizename) - " " - name))) + (let* ((cmd (format #f "ps2pdf -sPAPERSIZE=~a '~a'" + (sanitize-command-option papersizename) name)) (pdf-name (string-append (basename name ".ps") ".pdf" ))) (if (access? pdf-name W_OK) @@ -48,16 +44,12 @@ (format (current-error-port) (_ "Converting to `~a'...") pdf-name) (ly:system cmd))) -(define-public (postscript->png resolution papersize name) - (let ((cmd (string-append - "ps2png --resolution=" - (if (number? resolution) - (number->string resolution) - "90 ") - " --papersize=" (if (string? papersize) papersize "a4") - (if (ly:get-option 'verbose) - " --verbose " - " ") +(define-public (postscript->png resolution papersizename name) + (let ((cmd (format #f + "ps2png --resolution=~S --papersize=~a~a '~a'" + resolution + (sanitize-command-option papersizename) + (if (ly:get-option 'verbose) " --verbose " "") name))) ;; Do not try to guess the name of the png file (format (current-error-port) (_ "Converting to `~a'...") "png") diff --git a/scm/framework-tex.scm b/scm/framework-tex.scm index 9661f3ec25..69bdf09afe 100644 --- a/scm/framework-tex.scm +++ b/scm/framework-tex.scm @@ -1,4 +1,4 @@ -;;;; framework-tex.scm -- +1;;;; framework-tex.scm -- ;;;; ;;;; source file of the GNU LilyPond music typesetter ;;;; @@ -14,6 +14,7 @@ (guile) (srfi srfi-1) (srfi srfi-13) + (srfi srfi-14) (lily)) (define (output-formats) @@ -348,8 +349,15 @@ (ly:kpathsea-expand-variable "$extra_mem_top") 'pre "" 'post))) (base (basename name ".tex")) - (cmd (string-append - "latex \\\\nonstopmode \\\\input " name))) + (cmd (format + #f "latex \\\\nonstopmode \\\\input '~a'" name))) + + ;; FIXME: latex 'foo bar' works, but \input 'foe bar' does not? + (if (string-index name (char-set #\space #\ht #\newline #\cr)) + (error (format + #f + (_"TeX file name must not contain whitespace: `~a'") name))) + (setenv "extra_mem_top" (number->string (max curr-extra-mem 1024000))) (let ((dvi-name (string-append base ".dvi"))) (if (access? dvi-name W_OK) @@ -360,7 +368,7 @@ (string-append base ".dvi")) (newline (current-error-port)))) - ;; fixme: set in environment? + ;; FIXME: set in environment? (if (ly:get-option 'safe) (set! cmd (string-append "openout_any=p " cmd)))