sfnt2fnt: Remove output file on failure.

oldstable
Alexandre Julliard 2006-03-21 16:18:45 +01:00
parent c39a5f0dba
commit ef4440ad1b
1 changed files with 11 additions and 0 deletions

View File

@ -55,6 +55,8 @@ typedef struct {
#include "poppack.h"
static const char *output_name;
static void usage(char **argv)
{
fprintf(stderr, "%s foo.ttf ppem enc dpi def_char avg_width\n", argv[0]);
@ -65,6 +67,12 @@ static void usage(char **argv)
#define __attribute__(X)
#endif
/* atexit handler to cleanup files */
static void cleanup(void)
{
if (output_name) unlink( output_name );
}
static void error(const char *s, ...) __attribute__((format (printf, 1, 2)));
static void error(const char *s, ...)
@ -377,10 +385,13 @@ int main(int argc, char **argv)
sprintf(output, "%s-%d-%d-%d.fnt", name, enc, dpi, ppem);
atexit( cleanup );
fp = fopen(output, "w");
output_name = output;
fill_fontinfo(face, enc, fp, dpi, def_char, avg_width);
fclose(fp);
output_name = NULL;
exit(0);
}