void
ngx_strlow(u_char *dst, u_char *src, size_t n)
{
    while (n--) {
        *dst = ngx_tolower(*src);
        dst++;
        src++;
    }
}
['static char *\nngx_http_core_root(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)\n{\n    ngx_http_core_loc_conf_t *lcf = conf;\n    ngx_str_t                  *value;\n    ngx_uint_t                  alias, n;\n    ngx_http_script_compile_t   sc;\n    alias = (cmd->name.len == sizeof("alias") - 1) ? 1 : 0;\n    if (lcf->root.data) {\n        if ((ngx_uint_t) lcf->alias == alias) {\n            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                               "\\"%V\\" directive is duplicate",\n                               &cmd->name);\n        } else {\n            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                               "\\"%V\\" directive is duplicate, "\n                               "\\"%s\\" directive is specified before",\n                               &cmd->name, lcf->alias ? "alias" : "root");\n        }\n        return NGX_CONF_ERROR;\n    }\n    if (lcf->named && alias) {\n        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                           "the \\"alias\\" directive may not be used "\n                           "inside named location");\n        return NGX_CONF_ERROR;\n    }\n    value = cf->args->elts;\n    if (ngx_strstr(value[1].data, "$document_root")\n        || ngx_strstr(value[1].data, "${document_root}"))\n    {\n        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                           "the $document_root variable may not be used "\n                           "in the \\"%V\\" directive",\n                           &cmd->name);\n        return NGX_CONF_ERROR;\n    }\n    if (ngx_strstr(value[1].data, "$realpath_root")\n        || ngx_strstr(value[1].data, "${realpath_root}"))\n    {\n        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                           "the $realpath_root variable may not be used "\n                           "in the \\"%V\\" directive",\n                           &cmd->name);\n        return NGX_CONF_ERROR;\n    }\n    lcf->alias = alias;\n    lcf->root = value[1];\n    if (!alias && lcf->root.data[lcf->root.len - 1] == \'/\') {\n        lcf->root.len--;\n    }\n    if (lcf->root.data[0] != \'$\') {\n        if (ngx_conf_full_name(cf->cycle, &lcf->root, 0) != NGX_OK) {\n            return NGX_CONF_ERROR;\n        }\n    }\n    n = ngx_http_script_variables_count(&lcf->root);\n    ngx_memzero(&sc, sizeof(ngx_http_script_compile_t));\n    if (n) {\n        sc.cf = cf;\n        sc.source = &lcf->root;\n        sc.lengths = &lcf->root_lengths;\n        sc.values = &lcf->root_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 (NGX_PCRE)\n    if (alias && lcf->regex\n        && (ngx_regex_capture_count(lcf->regex) <= 0 || sc.ncaptures == 0))\n    {\n        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                           "the \\"alias\\" directive must use captures "\n                           "inside location given by regular expression");\n        return NGX_CONF_ERROR;\n    }\n#endif\n    return NGX_CONF_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}', 'static ngx_int_t\nngx_http_script_add_var_code(ngx_http_script_compile_t *sc, ngx_str_t *name)\n{\n    ngx_int_t                    index, *p;\n    ngx_http_script_var_code_t  *code;\n    index = ngx_http_get_variable_index(sc->cf, name);\n    if (index == NGX_ERROR) {\n        return NGX_ERROR;\n    }\n    if (sc->flushes) {\n        p = ngx_array_push(*sc->flushes);\n        if (p == NULL) {\n            return NGX_ERROR;\n        }\n        *p = index;\n    }\n    code = ngx_http_script_add_code(*sc->lengths,\n                                    sizeof(ngx_http_script_var_code_t), NULL);\n    if (code == NULL) {\n        return NGX_ERROR;\n    }\n    code->code = (ngx_http_script_code_pt) ngx_http_script_copy_var_len_code;\n    code->index = (uintptr_t) index;\n    code = ngx_http_script_add_code(*sc->values,\n                                    sizeof(ngx_http_script_var_code_t),\n                                    &sc->main);\n    if (code == NULL) {\n        return NGX_ERROR;\n    }\n    code->code = ngx_http_script_copy_var_code;\n    code->index = (uintptr_t) index;\n    return NGX_OK;\n}', 'ngx_int_t\nngx_http_get_variable_index(ngx_conf_t *cf, ngx_str_t *name)\n{\n    ngx_uint_t                  i;\n    ngx_http_variable_t        *v;\n    ngx_http_core_main_conf_t  *cmcf;\n    cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);\n    v = cmcf->variables.elts;\n    if (v == NULL) {\n        if (ngx_array_init(&cmcf->variables, cf->pool, 4,\n                           sizeof(ngx_http_variable_t))\n            != NGX_OK)\n        {\n            return NGX_ERROR;\n        }\n    } else {\n        for (i = 0; i < cmcf->variables.nelts; i++) {\n            if (name->len != v[i].name.len\n                || ngx_strncasecmp(name->data, v[i].name.data, name->len) != 0)\n            {\n                continue;\n            }\n            return i;\n        }\n    }\n    v = ngx_array_push(&cmcf->variables);\n    if (v == NULL) {\n        return NGX_ERROR;\n    }\n    v->name.len = name->len;\n    v->name.data = ngx_pnalloc(cf->pool, name->len);\n    if (v->name.data == NULL) {\n        return NGX_ERROR;\n    }\n    ngx_strlow(v->name.data, name->data, name->len);\n    v->set_handler = NULL;\n    v->get_handler = NULL;\n    v->data = 0;\n    v->flags = 0;\n    v->index = cmcf->variables.nelts - 1;\n    return cmcf->variables.nelts - 1;\n}', 'void\nngx_strlow(u_char *dst, u_char *src, size_t n)\n{\n    while (n--) {\n        *dst = ngx_tolower(*src);\n        dst++;\n        src++;\n    }\n}']