ngx_int_t
ngx_http_script_compile(ngx_http_script_compile_t *sc)
{
    u_char       ch;
    ngx_str_t    name;
    ngx_uint_t   i, bracket;
    if (ngx_http_script_init_arrays(sc) != NGX_OK) {
        return NGX_ERROR;
    }
    for (i = 0; i < sc->source->len;   ) {
        name.len = 0;
        if (sc->source->data[i] == '$') {
            if (++i == sc->source->len) {
                goto invalid_variable;
            }
#if (NGX_PCRE)
            {
            ngx_uint_t  n;
            if (sc->source->data[i] >= '1' && sc->source->data[i] <= '9') {
                n = sc->source->data[i] - '0';
                if (sc->captures_mask & (1 << n)) {
                    sc->dup_capture = 1;
                }
                sc->captures_mask |= 1 << n;
                if (ngx_http_script_add_capture_code(sc, n) != NGX_OK) {
                    return NGX_ERROR;
                }
                i++;
                continue;
            }
            }
#endif
            if (sc->source->data[i] == '{') {
                bracket = 1;
                if (++i == sc->source->len) {
                    goto invalid_variable;
                }
                name.data = &sc->source->data[i];
            } else {
                bracket = 0;
                name.data = &sc->source->data[i];
            }
            for (   ; i < sc->source->len; i++, name.len++) {
                ch = sc->source->data[i];
                if (ch == '}' && bracket) {
                    i++;
                    bracket = 0;
                    break;
                }
                if ((ch >= 'A' && ch <= 'Z')
                    || (ch >= 'a' && ch <= 'z')
                    || (ch >= '0' && ch <= '9')
                    || ch == '_')
                {
                    continue;
                }
                break;
            }
            if (bracket) {
                ngx_conf_log_error(NGX_LOG_EMERG, sc->cf, 0,
                                   "the closing bracket in \"%V\" "
                                   "variable is missing", &name);
                return NGX_ERROR;
            }
            if (name.len == 0) {
                goto invalid_variable;
            }
            sc->variables++;
            if (ngx_http_script_add_var_code(sc, &name) != NGX_OK) {
                return NGX_ERROR;
            }
            continue;
        }
        if (sc->source->data[i] == '?' && sc->compile_args) {
            sc->args = 1;
            sc->compile_args = 0;
            if (ngx_http_script_add_args_code(sc) != NGX_OK) {
                return NGX_ERROR;
            }
            i++;
            continue;
        }
        name.data = &sc->source->data[i];
        while (i < sc->source->len) {
            if (sc->source->data[i] == '$') {
                break;
            }
            if (sc->source->data[i] == '?') {
                sc->args = 1;
                if (sc->compile_args) {
                    break;
                }
            }
            i++;
            name.len++;
        }
        sc->size += name.len;
        if (ngx_http_script_add_copy_code(sc, &name, (i == sc->source->len))
            != NGX_OK)
        {
            return NGX_ERROR;
        }
    }
    return ngx_http_script_done(sc);
invalid_variable:
    ngx_conf_log_error(NGX_LOG_EMERG, sc->cf, 0, "invalid variable name");
    return NGX_ERROR;
}
['static char *\nngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)\n{\n    ngx_http_log_loc_conf_t *llcf = conf;\n    ssize_t                     buf;\n    ngx_uint_t                  i, n;\n    ngx_str_t                  *value, name;\n    ngx_http_log_t             *log;\n    ngx_http_log_fmt_t         *fmt;\n    ngx_http_log_main_conf_t   *lmcf;\n    ngx_http_script_compile_t   sc;\n    value = cf->args->elts;\n    if (ngx_strcmp(value[1].data, "off") == 0) {\n        llcf->off = 1;\n        return NGX_CONF_OK;\n    }\n    if (llcf->logs == NULL) {\n        llcf->logs = ngx_array_create(cf->pool, 2, sizeof(ngx_http_log_t));\n        if (llcf->logs == NULL) {\n            return NGX_CONF_ERROR;\n        }\n    }\n    lmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_log_module);\n    log = ngx_array_push(llcf->logs);\n    if (log == NULL) {\n        return NGX_CONF_ERROR;\n    }\n    ngx_memzero(log, sizeof(ngx_http_log_t));\n    n = ngx_http_script_variables_count(&value[1]);\n    if (n == 0) {\n        log->file = ngx_conf_open_file(cf->cycle, &value[1]);\n        if (log->file == NULL) {\n            return NGX_CONF_ERROR;\n        }\n    } else {\n        if (ngx_conf_full_name(cf->cycle, &value[1], 0) != NGX_OK) {\n            return NGX_CONF_ERROR;\n        }\n        log->script = ngx_pcalloc(cf->pool, sizeof(ngx_http_log_script_t));\n        if (log->script == NULL) {\n            return NGX_CONF_ERROR;\n        }\n        ngx_memzero(&sc, sizeof(ngx_http_script_compile_t));\n        sc.cf = cf;\n        sc.source = &value[1];\n        sc.lengths = &log->script->lengths;\n        sc.values = &log->script->values;\n        sc.variables = n;\n        sc.complete_lengths = 1;\n        sc.complete_values = 1;\n        if (ngx_http_script_compile(&sc) != NGX_OK) {\n            return NGX_CONF_ERROR;\n        }\n    }\n    if (cf->args->nelts >= 3) {\n        name = value[2];\n        if (ngx_strcmp(name.data, "combined") == 0) {\n            lmcf->combined_used = 1;\n        }\n    } else {\n        name.len = sizeof("combined") - 1;\n        name.data = (u_char *) "combined";\n        lmcf->combined_used = 1;\n    }\n    fmt = lmcf->formats.elts;\n    for (i = 0; i < lmcf->formats.nelts; i++) {\n        if (fmt[i].name.len == name.len\n            && ngx_strcasecmp(fmt[i].name.data, name.data) == 0)\n        {\n            log->format = &fmt[i];\n            goto buffer;\n        }\n    }\n    ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                       "unknown log format \\"%V\\"", &name);\n    return NGX_CONF_ERROR;\nbuffer:\n    if (cf->args->nelts == 4) {\n        if (ngx_strncmp(value[3].data, "buffer=", 7) != 0) {\n            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                               "invalid parameter \\"%V\\"", &value[3]);\n            return NGX_CONF_ERROR;\n        }\n        if (log->script) {\n            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                               "buffered logs can not have variables in name");\n            return NGX_CONF_ERROR;\n        }\n        name.len = value[3].len - 7;\n        name.data = value[3].data + 7;\n        buf = ngx_parse_size(&name);\n        if (buf == NGX_ERROR) {\n            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                               "invalid parameter \\"%V\\"", &value[3]);\n            return NGX_CONF_ERROR;\n        }\n        if (log->file->buffer && log->file->last - log->file->pos != buf) {\n            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                               "access_log \\"%V\\" already defined "\n                               "with different buffer size", &value[1]);\n            return NGX_CONF_ERROR;\n        }\n        log->file->buffer = ngx_palloc(cf->pool, buf);\n        if (log->file->buffer == NULL) {\n            return NGX_CONF_ERROR;\n        }\n        log->file->pos = log->file->buffer;\n        log->file->last = log->file->buffer + buf;\n    }\n    return NGX_CONF_OK;\n}', "ngx_int_t\nngx_conf_full_name(ngx_cycle_t *cycle, ngx_str_t *name, ngx_uint_t conf_prefix)\n{\n    size_t      len;\n    u_char     *p, *prefix;\n    ngx_str_t   old;\n    if (name->data[0] == '/') {\n        return NGX_OK;\n    }\n#if (NGX_WIN32)\n    if (name->len > 2\n        && name->data[1] == ':'\n        && ((name->data[0] >= 'a' && name->data[0] <= 'z')\n             || (name->data[0] >= 'A' && name->data[0] <= 'Z')))\n    {\n        return NGX_OK;\n    }\n#endif\n    old = *name;\n    if (conf_prefix) {\n        len = sizeof(NGX_CONF_PREFIX) - 1;\n        prefix = (u_char *) NGX_CONF_PREFIX;\n    } else {\n        len = cycle->root.len;\n        prefix = cycle->root.data;\n    }\n    name->len = len + old.len;\n    name->data = ngx_pnalloc(cycle->pool, name->len + 1);\n    if (name->data == NULL) {\n        return NGX_ERROR;\n    }\n    p = ngx_cpymem(name->data, prefix, len);\n    ngx_cpystrn(p, old.data, old.len + 1);\n    return NGX_OK;\n}", 'ngx_int_t\nngx_http_script_compile(ngx_http_script_compile_t *sc)\n{\n    u_char       ch;\n    ngx_str_t    name;\n    ngx_uint_t   i, bracket;\n    if (ngx_http_script_init_arrays(sc) != NGX_OK) {\n        return NGX_ERROR;\n    }\n    for (i = 0; i < sc->source->len;   ) {\n        name.len = 0;\n        if (sc->source->data[i] == \'$\') {\n            if (++i == sc->source->len) {\n                goto invalid_variable;\n            }\n#if (NGX_PCRE)\n            {\n            ngx_uint_t  n;\n            if (sc->source->data[i] >= \'1\' && sc->source->data[i] <= \'9\') {\n                n = sc->source->data[i] - \'0\';\n                if (sc->captures_mask & (1 << n)) {\n                    sc->dup_capture = 1;\n                }\n                sc->captures_mask |= 1 << n;\n                if (ngx_http_script_add_capture_code(sc, n) != NGX_OK) {\n                    return NGX_ERROR;\n                }\n                i++;\n                continue;\n            }\n            }\n#endif\n            if (sc->source->data[i] == \'{\') {\n                bracket = 1;\n                if (++i == sc->source->len) {\n                    goto invalid_variable;\n                }\n                name.data = &sc->source->data[i];\n            } else {\n                bracket = 0;\n                name.data = &sc->source->data[i];\n            }\n            for (   ; i < sc->source->len; i++, name.len++) {\n                ch = sc->source->data[i];\n                if (ch == \'}\' && bracket) {\n                    i++;\n                    bracket = 0;\n                    break;\n                }\n                if ((ch >= \'A\' && ch <= \'Z\')\n                    || (ch >= \'a\' && ch <= \'z\')\n                    || (ch >= \'0\' && ch <= \'9\')\n                    || ch == \'_\')\n                {\n                    continue;\n                }\n                break;\n            }\n            if (bracket) {\n                ngx_conf_log_error(NGX_LOG_EMERG, sc->cf, 0,\n                                   "the closing bracket in \\"%V\\" "\n                                   "variable is missing", &name);\n                return NGX_ERROR;\n            }\n            if (name.len == 0) {\n                goto invalid_variable;\n            }\n            sc->variables++;\n            if (ngx_http_script_add_var_code(sc, &name) != NGX_OK) {\n                return NGX_ERROR;\n            }\n            continue;\n        }\n        if (sc->source->data[i] == \'?\' && sc->compile_args) {\n            sc->args = 1;\n            sc->compile_args = 0;\n            if (ngx_http_script_add_args_code(sc) != NGX_OK) {\n                return NGX_ERROR;\n            }\n            i++;\n            continue;\n        }\n        name.data = &sc->source->data[i];\n        while (i < sc->source->len) {\n            if (sc->source->data[i] == \'$\') {\n                break;\n            }\n            if (sc->source->data[i] == \'?\') {\n                sc->args = 1;\n                if (sc->compile_args) {\n                    break;\n                }\n            }\n            i++;\n            name.len++;\n        }\n        sc->size += name.len;\n        if (ngx_http_script_add_copy_code(sc, &name, (i == sc->source->len))\n            != NGX_OK)\n        {\n            return NGX_ERROR;\n        }\n    }\n    return ngx_http_script_done(sc);\ninvalid_variable:\n    ngx_conf_log_error(NGX_LOG_EMERG, sc->cf, 0, "invalid variable name");\n    return NGX_ERROR;\n}']