X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/a616a7953d87c3c51afcc8e693c48c37ec000edf..f087de9a3279289fb273c099bac54b67ca4c5c99:/uip/sortm.c diff --git a/uip/sortm.c b/uip/sortm.c index b4e6d56e..b8df0d0b 100644 --- a/uip/sortm.c +++ b/uip/sortm.c @@ -365,14 +365,16 @@ 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 FLDPLUS: compnum++; @@ -380,7 +382,7 @@ get_fields (char *datesw, int msg, struct smsg *smsg) 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) @@ -389,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) @@ -398,7 +400,7 @@ 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; @@ -426,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