X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/869b0d5dc814215b72b1899cf82073d13bb65a97..8664e81329d0811d0b0f35521a850b74ac276da3:/uip/sortm.c diff --git a/uip/sortm.c b/uip/sortm.c index 95c76b5f..b8df0d0b 100644 --- a/uip/sortm.c +++ b/uip/sortm.c @@ -365,23 +365,24 @@ get_fields (char *datesw, int msg, struct smsg *smsg) register struct tws *tw; register char *datecomp = NULL, *subjcomp = NULL; register FILE *in; + m_getfld_state_t gstate; if ((in = fopen (msgnam = m_name (msg), "r")) == NULL) { admonish (msgnam, "unable to read message"); return (0); } - for (compnum = 1, state = FLD;;) { + m_getfld_state_init (&gstate); + for (compnum = 1;;) { int bufsz = sizeof buf; - switch (state = m_getfld (state, nam, buf, &bufsz, in)) { + switch (state = m_getfld (gstate, nam, buf, &bufsz, in)) { case FLD: - case FLDEOF: case FLDPLUS: compnum++; if (!mh_strcasecmp (nam, datesw)) { datecomp = add (buf, datecomp); while (state == FLDPLUS) { bufsz = sizeof buf; - state = m_getfld (state, nam, buf, &bufsz, in); + state = m_getfld (gstate, nam, buf, &bufsz, in); datecomp = add (buf, datecomp); } if (!subjsort || subjcomp) @@ -390,7 +391,7 @@ get_fields (char *datesw, int msg, struct smsg *smsg) subjcomp = add (buf, subjcomp); while (state == FLDPLUS) { bufsz = sizeof buf; - state = m_getfld (state, nam, buf, &bufsz, in); + state = m_getfld (gstate, nam, buf, &bufsz, in); subjcomp = add (buf, subjcomp); } if (datecomp) @@ -399,13 +400,12 @@ get_fields (char *datesw, int msg, struct smsg *smsg) /* just flush this guy */ while (state == FLDPLUS) { bufsz = sizeof buf; - state = m_getfld (state, nam, buf, &bufsz, in); + state = m_getfld (gstate, nam, buf, &bufsz, in); } } continue; case BODY: - case BODYEOF: case FILEEOF: break; @@ -428,6 +428,7 @@ get_fields (char *datesw, int msg, struct smsg *smsg) } break; } + m_getfld_state_destroy (&gstate); /* * If no date component, then use the modification