]> diplodocus.org Git - nmh/commitdiff
Here's a better fix to m_Eom() in m_getfld.c than commit
authorDavid Levine <levinedl@acm.org>
Mon, 4 Aug 2014 02:05:03 +0000 (21:05 -0500)
committerDavid Levine <levinedl@acm.org>
Mon, 4 Aug 2014 02:05:03 +0000 (21:05 -0500)
d2520ac7054ad75d60342606bf13c821305d958c.  The comparison
of the return value of Getc() with EOF must be as an
integer, not a char.

sbr/m_getfld.c

index c4bc15fdadce951e48bbad40a960860f04d69125..7e92f9e3ef8cd150a2fb429d3b12dfec4989ec3a 100644 (file)
@@ -788,8 +788,11 @@ m_unknown(m_getfld_state_t *gstate, FILE *iob)
     s->msg_style = MS_UNKNOWN;
 
     for (i = 0, cp = text; i < sizeof text; ++i, ++cp) {
     s->msg_style = MS_UNKNOWN;
 
     for (i = 0, cp = text; i < sizeof text; ++i, ++cp) {
-       if ((signed char) (*cp = Getc (s)) == EOF) {
+       if ((c = Getc (s)) == EOF) {
+           *cp = '\0';
            break;
            break;
+       } else {
+           *cp = c;
        }
     }
 
        }
     }
 
@@ -851,8 +854,13 @@ m_Eom (m_getfld_state_t s, int c)
     char *cp;
 
     for (i = 0, cp = text; i < s->edelimlen; ++i, ++cp) {
     char *cp;
 
     for (i = 0, cp = text; i < s->edelimlen; ++i, ++cp) {
-       if ((signed char) (*cp = Getc (s)) == EOF) {
+       int c2;
+
+       if ((c2 = Getc (s)) == EOF) {
+           *cp = '\0';
            break;
            break;
+       } else {
+           *cp = c2;
        }
     }
 
        }
     }