From 988d1c233a893200d744af57e479c06328cacbec Mon Sep 17 00:00:00 2001 From: "Peter H. Ganten" Date: Tue, 13 Feb 2001 20:18:47 +0000 Subject: [PATCH] - only parse AFM-files, which start with "BeginFontMetrics" - use fgetc instead of fgets to cope with AFM-Files with Macintosh-Style line-breaks ('\r') in the parser. --- dlls/wineps/afm.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/dlls/wineps/afm.c b/dlls/wineps/afm.c index 7fc9a4c4760..c051e56a38d 100644 --- a/dlls/wineps/afm.c +++ b/dlls/wineps/afm.c @@ -130,6 +130,7 @@ static AFM *PSDRV_AFMParse(char const *file) char *value; AFM *afm; char *cp; + int afmfile = 0; TRACE("parsing '%s'\n", file); @@ -144,12 +145,32 @@ static AFM *PSDRV_AFMParse(char const *file) return NULL; } - while(fgets(buf, sizeof(buf), fp)) { - cp = buf + strlen(buf); - do { - *cp = '\0'; + cp = buf; + while ( ( *cp = fgetc ( fp ) ) != EOF ) { + if ( *cp == '\r' || *cp == '\n' || cp - buf == sizeof(buf)-1 ) { + if ( cp == buf ) + continue; + *(cp+1)='\0'; + } + else { + cp ++; + continue; + } + + cp = buf + strlen(buf); + do { + *cp = '\0'; cp--; } while(cp > buf && isspace(*cp)); + cp = buf; + + if ( afmfile == 0 && strncmp ( buf, "StartFontMetrics", 16 ) ) { + HeapFree ( PSDRV_Heap, 0, afm ); + return NULL; + } + else { + afmfile = 1; + } value = strchr(buf, ' '); if(value)