2005-06-09 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ * 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.
#include "open-type-font.hh"
#include "main.hh"
#include "warn.hh"
-
+
char *
pfb2pfa (Byte const *pfb, int length)
{
"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},
(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)
(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?))
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);
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;
}