From 50c16a55c585fa4646a8409b2c4dc65286d40eab Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Thu, 16 Jul 2015 07:35:55 +0200 Subject: [PATCH] unibdf2hex: drop redundant null equations in code --- src/unibdf2hex.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/unibdf2hex.c b/src/unibdf2hex.c index b421f6a..bec8495 100644 --- a/src/unibdf2hex.c +++ b/src/unibdf2hex.c @@ -44,19 +44,21 @@ main() int startrow; /* row to start glyph */ unsigned rowout; - while (fgets (inbuf, MAXBUF - 1, stdin) != NULL) { - if (strncmp (inbuf, "ENCODING ", 9) != 0) continue; + while (fgets (inbuf, MAXBUF - 1, stdin)) { + if (strncmp (inbuf, "ENCODING ", 9)) continue; sscanf (&inbuf[9], "%d", &thispoint); /* get code point */ - /* - If we want this code point, get the BBX (bounding box) and - BITMAP information. - */ - while (fgets (inbuf, MAXBUF - 1, stdin) != NULL && - strncmp (inbuf, "BBX ", 4) != 0); /* find bounding box */ + /* Read bounding box values from BBX line */ + while (fgets (inbuf, MAXBUF - 1, stdin)) { + if (!strncmp (inbuf, "BBX ", 4)) break; + } sscanf (&inbuf[4], "%d %d %d %d", &bbxx, &bbxy, &bbxxoff, &bbxyoff); - while (fgets (inbuf, MAXBUF - 1, stdin) != NULL && - strncmp (inbuf, "BITMAP", 6) != 0); /* find bitmap start */ + + /* Find BITMAP start */ + while (fgets (inbuf, MAXBUF - 1, stdin)) { + if (!strncmp (inbuf, "BITMAP", 6)) break; + } + fprintf (stdout, "%04X:", thispoint); digitsout = 0; /* Print initial blank rows */ @@ -67,8 +69,9 @@ main() fprintf (stdout,"0000"); digitsout += 4; } - while (fgets (inbuf, MAXBUF - 1, stdin) != NULL && - strncmp (inbuf, "END", 3) != 0) { /* copy bitmap until END */ + /* Copy bitmap until END */ + while (fgets (inbuf, MAXBUF - 1, stdin)) { + if (!strncmp (inbuf, "END", 3)) break; sscanf (inbuf, "%X", &rowout); /* Now force glyph to a 16x16 grid even if they'd fit in 8x16 */ if (bbxx <= 8) rowout <<= 8; /* shift left for 16x16 glyph */ -- 2.30.0