X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=sbr%2Fseq_read.c;h=ff01c427a94f3cd4a5e41a39e1ab26e6a69f53ca;hp=1c231dd66b10f1b73a8767c17af72a6c58f6ceba;hb=cf1205b5cbea2f0cd6ea710ec16c637df85b647c;hpb=c20b4fa14515c7ab388ce35411d89a7a92300711 diff --git a/sbr/seq_read.c b/sbr/seq_read.c index 1c231dd..ff01c42 100644 --- a/sbr/seq_read.c +++ b/sbr/seq_read.c @@ -7,6 +7,7 @@ ** complete copyright information. */ +#include #include #include @@ -29,9 +30,9 @@ seq_read(struct msgs *mp) { /* ** Initialize the list of sequence names. Go ahead and - ** add the "cur" sequence to the list of sequences. + ** add the cur sequence to the list of sequences. */ - mp->msgattrs[0] = getcpy(current); + mp->msgattrs[0] = getcpy(seq_cur); mp->msgattrs[1] = NULL; make_all_public(mp); /* initially, make all public */ @@ -60,10 +61,8 @@ seq_public(struct msgs *mp) FILE *fp; /* - ** If mh_seq == NULL (such as if nmh been compiled with - ** NOPUBLICSEQ), or if *mh_seq == '\0' (the user has defined - ** the "mh-sequences" profile entry, but left it empty), - ** then just return, and do not initialize any public sequences. + ** If public sequences are disabled (e.g. the user has defined + ** an empty `Mh-Sequences' profile entry), then just return. */ if (mh_seq == NULL || *mh_seq == '\0') return; @@ -76,35 +75,38 @@ seq_public(struct msgs *mp) /* Use m_getfld to scan sequence file */ for (state = FLD;;) { - switch (state = m_getfld(state, name, field, sizeof(field), fp)) { - case FLD: - case FLDPLUS: - case FLDEOF: - if (state == FLDPLUS) { - cp = getcpy(field); - while (state == FLDPLUS) { - state = m_getfld(state, name, field, sizeof(field), fp); - cp = add(field, cp); - } - seq_init(mp, getcpy(name), trimcpy(cp)); - free(cp); - } else { - seq_init(mp, getcpy(name), trimcpy(field)); + switch (state = m_getfld(state, name, field, sizeof(field), + fp)) { + case FLD: + case FLDPLUS: + case FLDEOF: + if (state == FLDPLUS) { + cp = getcpy(field); + while (state == FLDPLUS) { + state = m_getfld(state, name, field, + sizeof(field), fp); + cp = add(field, cp); } - if (state == FLDEOF) - break; - continue; + seq_init(mp, getcpy(name), trimcpy(cp)); + free(cp); + } else { + seq_init(mp, getcpy(name), trimcpy(field)); + } + if (state == FLDEOF) + break; + continue; - case BODY: - case BODYEOF: - adios(NULL, "no blank lines are permitted in %s", seqfile); - /* fall */ + case BODY: + case BODYEOF: + adios(EX_CONFIG, NULL, "no blank lines are permitted in %s", + seqfile); + /* fall */ - case FILEEOF: - break; + case FILEEOF: + break; - default: - adios(NULL, "%s is poorly formatted", seqfile); + default: + adios(EX_CONFIG, NULL, "%s is poorly formatted", seqfile); } break; /* break from for loop */ } @@ -131,11 +133,10 @@ seq_private(struct msgs *mp) plen = strlen(mp->foldpath) + 1; for (np = m_defs; np; np = np->n_next) { - if (isprefix("atr-", np->n_name) - && (j = strlen(np->n_name) - plen) > alen - && *(np->n_name + j) == '-' - && strcmp(mp->foldpath, np->n_name + j + 1) - == 0) { + if (strncmp(np->n_name, "atr-", alen)==0 && + (j = strlen(np->n_name) - plen) > alen && + *(np->n_name + j) == '-' && + strcmp(mp->foldpath, np->n_name + j + 1)==0) { cp = getcpy(np->n_name + alen); *(cp + j - alen) = '\0'; if ((i = seq_init(mp, cp, getcpy(np->n_field))) != -1) @@ -158,14 +159,15 @@ seq_private(struct msgs *mp) static int seq_init(struct msgs *mp, char *name, char *field) { - int i, j, k, is_current; + unsigned int i; + int j, k, is_current; char *cp, **ap; /* - ** Check if this is "cur" sequence, + ** Check if this is the cur sequence, ** so we can do some special things. */ - is_current = !strcmp(current, name); + is_current = (strcmp(seq_cur, name)==0); /* ** Search for this sequence name to see if we've seen @@ -174,7 +176,7 @@ seq_init(struct msgs *mp, char *name, char *field) ** mesages in this folder. */ for (i = 0; mp->msgattrs[i]; i++) { - if (!strcmp(mp->msgattrs[i], name)) { + if (strcmp(mp->msgattrs[i], name)==0) { for (j = mp->lowmsg; j <= mp->hghmsg; j++) clear_sequence(mp, i, j); break; @@ -209,7 +211,7 @@ seq_init(struct msgs *mp, char *name, char *field) k = cp ? m_atoi(cp) : j; /* - ** Keep mp->curmsg and "cur" sequence in synch. Unlike + ** Keep mp->curmsg and cur sequence in sync. Unlike ** other sequences, this message doesn't need to exist. ** Think about the series of command (rmm; next) to ** understand why this can be the case. But if it does