Browse Source

[core] const char *op in data_config

(instead of (buffer *))
personal/stbuehler/ci-build
Glenn Strauss 2 years ago
parent
commit
a51278030e
  1. 2
      src/configfile.h
  2. 16
      src/configparser.y
  3. 6
      src/data_config.c
  4. 2
      src/mod_rewrite.c

2
src/configfile.h

@ -62,7 +62,7 @@ struct data_config {
comp_key_t comp;
config_cond_t cond;
buffer *op;
const char *op;
int context_ndx; /* more or less like an id */
vector_config_weak children;

16
src/configparser.y

@ -539,7 +539,8 @@ cond_else(A) ::= context_else LCURLY metalines RCURLY. {
context ::= DOLLAR SRVVARNAME(B) LBRACKET stringop(C) RBRACKET cond(E) expression(D). {
data_config *dc;
buffer *b = NULL, *rvalue, *op = NULL;
buffer *b = NULL, *rvalue;
const char *op = NULL;
if (ctx->ok && D->type != TYPE_STRING) {
fprintf(stderr, "rvalue must be string");
@ -549,16 +550,16 @@ context ::= DOLLAR SRVVARNAME(B) LBRACKET stringop(C) RBRACKET cond(E) expressio
if (ctx->ok) {
switch(E) {
case CONFIG_COND_NE:
op = buffer_init_string("!=");
op = "!=";
break;
case CONFIG_COND_EQ:
op = buffer_init_string("==");
op = "==";
break;
case CONFIG_COND_NOMATCH:
op = buffer_init_string("!~");
op = "!~";
break;
case CONFIG_COND_MATCH:
op = buffer_init_string("=~");
op = "=~";
break;
default:
force_assert(0);
@ -570,7 +571,7 @@ context ::= DOLLAR SRVVARNAME(B) LBRACKET stringop(C) RBRACKET cond(E) expressio
buffer_append_string_len(b, CONST_STR_LEN("/"));
buffer_append_string_buffer(b, B);
buffer_append_string_buffer(b, C);
buffer_append_string_buffer(b, op);
buffer_append_string_len(b, op, 2);
rvalue = &((data_string*)D)->value;
buffer_append_string_buffer(b, rvalue);
@ -603,7 +604,7 @@ context ::= DOLLAR SRVVARNAME(B) LBRACKET stringop(C) RBRACKET cond(E) expressio
dc = data_config_init();
buffer_copy_buffer(&dc->key, b);
buffer_copy_buffer(dc->op, op);
dc->op = op;
buffer_copy_buffer(dc->comp_tag, C);
buffer_copy_buffer(dc->comp_key, B);
buffer_append_string_len(dc->comp_key, CONST_STR_LEN("[\""));
@ -722,7 +723,6 @@ context ::= DOLLAR SRVVARNAME(B) LBRACKET stringop(C) RBRACKET cond(E) expressio
}
buffer_free(b);
buffer_free(op);
buffer_free(B);
B = NULL;
buffer_free(C);

6
src/data_config.c

@ -29,7 +29,6 @@ static void data_config_free(data_unset *d) {
data_config *ds = (data_config *)d;
free(ds->key.ptr);
buffer_free(ds->op);
buffer_free(ds->comp_tag);
buffer_free(ds->comp_key);
@ -67,7 +66,7 @@ static void data_config_print(const data_unset *d, int depth) {
else {
if (ds->cond != CONFIG_COND_ELSE) {
fprintf(stdout, "$%s %s \"%s\" {\n",
ds->comp_key->ptr, ds->op->ptr, ds->string->ptr);
ds->comp_key->ptr, ds->op, ds->string->ptr);
} else {
fprintf(stdout, "{\n");
}
@ -111,7 +110,7 @@ static void data_config_print(const data_unset *d, int depth) {
if (0 != ds->context_ndx) {
if (ds->cond != CONFIG_COND_ELSE) {
fprintf(stdout, " # end of $%s %s \"%s\"",
ds->comp_key->ptr, ds->op->ptr, ds->string->ptr);
ds->comp_key->ptr, ds->op, ds->string->ptr);
} else {
fprintf(stdout, " # end of else");
}
@ -136,7 +135,6 @@ data_config *data_config_init(void) {
ds = calloc(1, sizeof(*ds));
ds->op = buffer_init();
ds->comp_tag = buffer_init();
ds->comp_key = buffer_init();
ds->value = array_init();

2
src/mod_rewrite.c

@ -243,7 +243,7 @@ static handler_t process_rewrite_rules(server *srv, connection *con, plugin_data
"ENDLESS LOOP IN rewrite-rule DETECTED ... aborting request");
return HANDLER_ERROR;
}
log_error_write(srv, __FILE__, __LINE__, "SbbSBS",
log_error_write(srv, __FILE__, __LINE__, "SbsSBS",
"ENDLESS LOOP IN rewrite-rule DETECTED ... aborting request, perhaps you want to use url.rewrite-once instead of url.rewrite-repeat ($", dc->comp_key, dc->op, "\"", dc->string, "\")");
return HANDLER_ERROR;

Loading…
Cancel
Save