Merge branch 'm_getfld2-meillo' into master
[mmh] / sbr / readconfig.c
index 2fe2d7d..6975d72 100644 (file)
@@ -36,9 +36,8 @@ static struct node **opp = NULL;
 void
 readconfig(struct node **npp, FILE *ib, char *file, int ctx)
 {
-       int state;
-       char *cp;
-       char name[NAMESZ], field[BUFSIZ];
+       enum state state;
+       struct field f = {{0}};
        struct node *np;
        struct procstr *ps;
 
@@ -47,46 +46,34 @@ readconfig(struct node **npp, FILE *ib, char *file, int ctx)
                return;
        }
 
-       for (state = FLD;;) {
-               switch (state = m_getfld(state, name, field, sizeof(field),
-                               ib)) {
-               case FLD:
-               case FLDPLUS:
+       for (state = FLD2;;) {
+               switch (state = m_getfld2(state, &f, ib)) {
+               case FLD2:
                        np = mh_xcalloc(1, sizeof(*np));
                        *npp = np;
                        *(npp = &np->n_next) = NULL;
-                       np->n_name = mh_xstrdup(name);
-                       if (state == FLDPLUS) {
-                               cp = mh_xstrdup(field);
-                               while (state == FLDPLUS) {
-                                       state = m_getfld(state, name, field,
-                                                       sizeof(field), ib);
-                                       cp = add(field, cp);
-                               }
-                               np->n_field = trimcpy(cp);
-                               mh_free0(&cp);
-                       } else {
-                               np->n_field = trimcpy(field);
-                       }
+                       np->n_name = mh_xstrdup(f.name);
+                       np->n_field = trimcpy(f.value);
                        np->n_context = ctx;
 
                        /*
                        ** Now scan the list of `procs' and link in
                        ** the field value to the global variable.
                        */
-                       for (ps = procs; ps->procname; ps++)
+                       for (ps = procs; ps->procname; ps++) {
                                if (mh_strcasecmp(np->n_name,
                                                ps->procname) == 0) {
                                        *ps->procnaddr = np->n_field;
                                        break;
                                }
+                       }
                        continue;
 
-               case BODY:
+               case BODY2:
                        adios(EX_CONFIG, NULL, "no blank lines are permitted in %s",
                                        file);
 
-               case FILEEOF:
+               case FILEEOF2:
                        break;
 
                default: