From 5e4d56c57c1e638a99c9ef5725e5c89657a3d1f3 Mon Sep 17 00:00:00 2001 From: hanwen Date: Thu, 9 Jun 2005 17:16:46 +0000 Subject: [PATCH] * scm/backend-library.scm (postscript->pdf): use delete-intermediate-files iso. running-from-gui? * ttftool/util.c (surely_read): robustness. Allow read() to return less bytes than requested, as per posix standards. * lily/pfb.cc (LY_DEFINE): set ttf_verbosity from ttf-verbosity program option. * lily/program-option.cc: rename from scm-option.cc --- ChangeLog | 6 ++++++ lily/pfb.cc | 2 +- lily/program-option.cc | 2 ++ scm/backend-library.scm | 4 +++- scm/lily.scm | 3 ++- ttftool/parse.c | 3 +-- ttftool/util.c | 16 +++++++++++----- 7 files changed, 26 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1e8d5a8d9b..f6269944f8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2005-06-09 Han-Wen Nienhuys + * scm/backend-library.scm (postscript->pdf): use + delete-intermediate-files iso. running-from-gui? + + * ttftool/util.c (surely_read): robustness. Allow read() to return + less bytes than requested, as per posix standards. + * lily/pfb.cc (LY_DEFINE): set ttf_verbosity from ttf-verbosity program option. diff --git a/lily/pfb.cc b/lily/pfb.cc index 375429cdd5..cc93d4a23a 100644 --- a/lily/pfb.cc +++ b/lily/pfb.cc @@ -17,7 +17,7 @@ #include "open-type-font.hh" #include "main.hh" #include "warn.hh" - + char * pfb2pfa (Byte const *pfb, int length) { diff --git a/lily/program-option.cc b/lily/program-option.cc index c4b2d0c856..2887a02278 100644 --- a/lily/program-option.cc +++ b/lily/program-option.cc @@ -53,6 +53,8 @@ static Lilypond_option_init options[] = { "include book-titles in preview images."}, {"gs-font-load", "#f", "load fonts via Ghostscript."}, + {"delete-intermediate-files", "#f", + "delete unusable PostScript files"}, {"ttf-verbosity", "0", "how much verbosity for TTF font embedding?"}, {0,0,0}, diff --git a/scm/backend-library.scm b/scm/backend-library.scm index 7293b7be95..d7a2cef49e 100644 --- a/scm/backend-library.scm +++ b/scm/backend-library.scm @@ -67,7 +67,9 @@ (ly:message (_ "Converting to `~a'...") pdf-name) (ly:progress "\n") (ly:system cmd) - (if (running-from-gui?) (delete-file name)))) + + (if (ly:get-option 'delete-intermediate-files) + (delete-file name)))) (use-modules (scm ps-to-png)) (define-public (postscript->png resolution paper-size-name name) diff --git a/scm/lily.scm b/scm/lily.scm index 4b5f1311f4..4a3da324e5 100644 --- a/scm/lily.scm +++ b/scm/lily.scm @@ -344,7 +344,8 @@ The syntax is the same as `define*-public'." (not have-tty?))))) (define-public (gui-main files) - (if (null? files) (gui-no-files-handler)) + (if (null? files) + (gui-no-files-handler)) (let* ((base (basename (car files) ".ly")) (log-name (string-append base ".log"))) (if (not (running-from-gui?)) diff --git a/ttftool/parse.c b/ttftool/parse.c index a8e7e3326d..95a605ee43 100644 --- a/ttftool/parse.c +++ b/ttftool/parse.c @@ -17,13 +17,12 @@ readDirectory (int fd, struct OffsetTable *ot) int i; struct TableDirectoryEntry *td; - if (ttf_verbosity >= 3) - fprintf (stderr, ""); surely_read (fd, ot, sizeof (struct OffsetTable)); FIX_OffsetTable (*ot); if (ttf_verbosity >= 2) fprintf (stderr, "%d tables\n", ot->numTables); + n = sizeof (struct TableDirectoryEntry) * ot->numTables; td = mymalloc (n); surely_read (fd, td, n); diff --git a/ttftool/util.c b/ttftool/util.c index aedbd43a23..872431a340 100644 --- a/ttftool/util.c +++ b/ttftool/util.c @@ -78,13 +78,19 @@ surely_read (int fildes, void *buf, size_t nbyte) fprintf (stderr, "Reading %d bytes\n", nbyte); ssize_t n; - if ((n = read (fildes, buf, nbyte)) < nbyte) + void *bufptr = buf; + while (nbyte > 0 + && (n = read (fildes, bufptr, nbyte)) > 0) { - char s[100]; - sprintf (s, "read too little in surely_read(), expect %d got %d", nbyte, n); - sprintf (s, "trying again yields %d", read (fildes, buf, nbyte - n)); - syserror (s); + bufptr += n; + nbyte -= n; + } + + if (n < 0 || nbyte > 0) + { + syserror ("error during read()"); } + return n; } -- 2.39.5