ben 98/01/31 07:34:51
Modified: src/modules/standard mod_setenvif.c Log: Now that I've looked at it, I can't leave it like it was. Eliminate duplicate code, move invariants out of the loop. Revision Changes Path 1.15 +28 -39 apache-1.3/src/modules/standard/mod_setenvif.c Index: mod_setenvif.c =================================================================== RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_setenvif.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- mod_setenvif.c 1998/01/31 14:38:23 1.14 +++ mod_setenvif.c 1998/01/31 15:34:50 1.15 @@ -176,49 +176,40 @@ cmd->cmd->name, NULL); return error; } + + /* + * First, try to merge into an existing entry + */ + + for (i = 0; i < sconf->conditionals->nelts; ++i) { + new = &entries[i]; + if (!strcmp(new->name, fname) && !strcmp(new->regex, regex)) + goto gotit; + } + + /* + * If none was found, create a new entry + */ + + new = push_array(sconf->conditionals); + new->name = fname; + new->regex = regex; + new->preg = pregcomp(cmd->pool, regex, + (REG_EXTENDED | REG_NOSUB | cflags)); + if (new->preg == NULL) { + error = pstrcat(cmd->pool, cmd->cmd->name, + " regex could not be compiled.", NULL); + return error; + } + new->features = make_table(cmd->pool, 5); + +gotit: for( ; ; ) { feature = getword_conf(cmd->pool, &cmdline); if(!*feature) break; beenhere++; - /* - * First, try to merge into an existing entry - */ - - for (i = 0; i < sconf->conditionals->nelts; ++i) { - sei_entry *b = &entries[i]; - if (!strcmp(b->name, fname) && !strcmp(b->regex, regex)) { - var = getword(cmd->pool, &feature, '='); - if (*feature) { - table_set(b->features, var, feature); - } - else if (*var == '!') { - table_set(b->features, var + 1, "!"); - } - else { - table_set(b->features, var, "1"); - } - goto next; - } - } - - /* - * If none was found, create a new entry - */ - - new = push_array(sconf->conditionals); - new->name = fname; - new->regex = regex; - new->preg = pregcomp(cmd->pool, regex, - (REG_EXTENDED | REG_NOSUB | cflags)); - if (new->preg == NULL) { - error = pstrcat(cmd->pool, cmd->cmd->name, - " regex could not be compiled.", NULL); - return error; - } - new->features = make_table(cmd->pool, 5); - var = getword(cmd->pool, &feature, '='); if (*feature) { table_set(new->features, var, feature); @@ -229,8 +220,6 @@ else { table_set(new->features, var, "1"); } - next: - continue; } if (!beenhere) {