From 12b0c5143a3d96d4a0a8077866a82910b86312e0 Mon Sep 17 00:00:00 2001 From: giraffedata Date: Mon, 25 Aug 2008 05:48:18 +0000 Subject: Use pm_openr() instead of fopen() git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@714 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- converter/ppm/picttoppm.c | 64 ++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 34 deletions(-) (limited to 'converter/ppm/picttoppm.c') diff --git a/converter/ppm/picttoppm.c b/converter/ppm/picttoppm.c index 02f2afec..6f34dae4 100644 --- a/converter/ppm/picttoppm.c +++ b/converter/ppm/picttoppm.c @@ -727,43 +727,39 @@ load_fontdir(const char * const dirfile) { Load the font directory from file named 'dirfile'. Add its contents to the global list of fonts 'fontlist'. -----------------------------------------------------------------------------*/ - int retval; - FILE * fp; + FILE * ifP; + unsigned int nFont; + char line[1024]; - fp = fopen(dirfile, "rb"); - if (!fp) - retval = -1; - else { - unsigned int nFont; - char line[1024]; - - nFont = 0; - while (fgets(line, 1024, fp) && nFont < INT_MAX) { - const char * token[10]; - unsigned int nToken; - - tokenize(line, token, ARRAY_SIZE(token), &nToken); - - if (nToken == 0) { - /* blank line - ignore */ - } else if (token[0][0] == '#') { - /* comment - ignore */ - } else if (nToken != 4) { - /* Unrecognized format - ignore */ - } else { - struct fontinfo * fontinfoP; - - parseFontLine(token, &fontinfoP); - - fontinfoP->next = 0; - *fontlist_ins = fontinfoP; - fontlist_ins = &fontinfoP->next; - ++nFont; - } + ifP = pm_openr(dirfile); + + nFont = 0; + while (fgets(line, 1024, ifP) && nFont < INT_MAX) { + const char * token[10]; + unsigned int nToken; + + tokenize(line, token, ARRAY_SIZE(token), &nToken); + + if (nToken == 0) { + /* blank line - ignore */ + } else if (token[0][0] == '#') { + /* comment - ignore */ + } else if (nToken != 4) { + /* Unrecognized format - ignore */ + } else { + struct fontinfo * fontinfoP; + + parseFontLine(token, &fontinfoP); + + fontinfoP->next = 0; + *fontlist_ins = fontinfoP; + fontlist_ins = &fontinfoP->next; + ++nFont; } - retval = nFont; } - return retval; + pm_close(ifP); + + return nFont; } -- cgit 1.4.1