sfnt2fnt: Remove output file on failure.
This commit is contained in:
parent
c39a5f0dba
commit
ef4440ad1b
@ -55,6 +55,8 @@ typedef struct {
|
|||||||
|
|
||||||
#include "poppack.h"
|
#include "poppack.h"
|
||||||
|
|
||||||
|
static const char *output_name;
|
||||||
|
|
||||||
static void usage(char **argv)
|
static void usage(char **argv)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s foo.ttf ppem enc dpi def_char avg_width\n", argv[0]);
|
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)
|
#define __attribute__(X)
|
||||||
#endif
|
#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, ...) __attribute__((format (printf, 1, 2)));
|
||||||
|
|
||||||
static void error(const char *s, ...)
|
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);
|
sprintf(output, "%s-%d-%d-%d.fnt", name, enc, dpi, ppem);
|
||||||
|
|
||||||
|
atexit( cleanup );
|
||||||
fp = fopen(output, "w");
|
fp = fopen(output, "w");
|
||||||
|
output_name = output;
|
||||||
|
|
||||||
fill_fontinfo(face, enc, fp, dpi, def_char, avg_width);
|
fill_fontinfo(face, enc, fp, dpi, def_char, avg_width);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
output_name = NULL;
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user