X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=sbr%2Fseq_read.c;h=041f632786e66ce8e53ef7b4c97a4bbb54a58595;hp=e76bcc6a9dd2d7338f356286ada76afab6516430;hb=e917512db8efcbf3b5b5baeb64b6d345fd3686db;hpb=9cf6132a6ea29968131a000bc2fb6860affac45e diff --git a/sbr/seq_read.c b/sbr/seq_read.c index e76bcc6..041f632 100644 --- a/sbr/seq_read.c +++ b/sbr/seq_read.c @@ -55,9 +55,9 @@ seq_read(struct msgs *mp) static void seq_public(struct msgs *mp) { - int state; - char *cp, seqfile[PATH_MAX]; - char name[NAMESZ], field[BUFSIZ]; + enum state state; + struct field f = {{0}}; + char seqfile[PATH_MAX]; FILE *fp; /* @@ -74,37 +74,27 @@ seq_public(struct msgs *mp) return; /* Use m_getfld to scan sequence file */ - for (state = FLD;;) { - switch (state = m_getfld(state, name, field, sizeof(field), - fp)) { - case FLD: - case FLDPLUS: - if (state == FLDPLUS) { - cp = mh_xstrdup(field); - while (state == FLDPLUS) { - state = m_getfld(state, name, field, - sizeof(field), fp); - cp = add(field, cp); - } - seq_init(mp, mh_xstrdup(name), trimcpy(cp)); - mh_free0(&cp); - } else { - seq_init(mp, mh_xstrdup(name), trimcpy(field)); - } + for (state = FLD2;;) { + switch (state = m_getfld2(state, &f, fp)) { + case LENERR2: + state = FLD2; + /* FALL */ + case FLD2: + seq_init(mp, mh_xstrdup(f.name), trimcpy(f.value)); continue; - case BODY: + case BODY2: adios(EX_CONFIG, NULL, "no blank lines are permitted in %s", seqfile); - /* fall */ + /* FALL */ - case FILEEOF: + case FILEEOF2: break; default: adios(EX_CONFIG, NULL, "%s is poorly formatted", seqfile); } - break; /* break from for loop */ + break; } lkfclose(fp, seqfile);