]> granicus.if.org Git - apache/commitdiff
We now report the correct line number for syntax errors in config
authorJeff Trawick <trawick@apache.org>
Tue, 30 May 2000 02:42:32 +0000 (02:42 +0000)
committerJeff Trawick <trawick@apache.org>
Tue, 30 May 2000 02:42:32 +0000 (02:42 +0000)
files.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@85348 13f79535-47bb-0310-9956-ffa450edef68

include/http_config.h
server/config.c

index 04210856e9a0e9661794fcc64dddf19d7835266c..c97681f1424562cad75b55e5fdb2c615a90f8b16 100644 (file)
@@ -188,6 +188,7 @@ typedef struct {
 
     void *context;             /* per_dir_config vector passed 
                                 * to handle_command */
+    const ap_directive_t *err_directive; /* directive with syntax error */
 } cmd_parms;
 
 /* This structure records the existence of handlers in a module... */
index 09942c9923b63519795ec577563bb5e44692f4cd..5df5653d445bf57115d56efb6045c776bf0719da 100644 (file)
@@ -984,6 +984,7 @@ static const char *ap_walk_config_sub(const ap_directive_t *current,
        const command_rec *cmd;
 
        if (!(cmd = ap_find_command_in_modules(current->directive, &mod))) {
+            parms->err_directive = current;
             return ap_pstrcat(parms->pool, "Invalid command '", 
                              current->directive,
                              "', perhaps mis-spelled or defined by a module "
@@ -995,8 +996,20 @@ static const char *ap_walk_config_sub(const ap_directive_t *current,
            const char *retval;
 
            retval = invoke_cmd(cmd, parms, mconfig, current->args);
-           if (retval == NULL || strcmp(retval, DECLINE_CMD) != 0)
+           if (retval == NULL) {
+                return NULL;
+            }
+            if (strcmp(retval, DECLINE_CMD) != 0) {
+                /* If the directive in error has already been set, don't
+                 * replace it.  Otherwise, an error inside a container 
+                 * will be reported as occuring on the first line of the
+                 * container.
+                 */
+                if (!parms->err_directive) {
+                    parms->err_directive = current;
+                }
                return retval;
+            }
 
            mod = mod->next;    /* Next time around, skip this one */
        }
@@ -1130,7 +1143,7 @@ API_EXPORT_NONSTD(const char *) ap_set_file_slot(cmd_parms *cmd, char *struct_pt
  */
 
 static cmd_parms default_parms =
-{NULL, 0, -1, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
+{NULL, 0, -1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
 
 API_EXPORT(const char *) ap_server_root_relative(ap_pool_t *p, const char *file)
 {
@@ -1300,10 +1313,10 @@ void ap_process_resource_config(server_rec *s, const char *fname, ap_pool_t *p,
        errmsg = ap_walk_config(conftree, &parms, s->lookup_defaults);
 
     if (errmsg != NULL) {
-       /* ### wrong line number. need to pull from ap_directive_t */
        ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
                      "Syntax error on line %d of %s:",
-                    cfp->line_number, cfp->name);
+                     parms.err_directive->line_num, 
+                     parms.err_directive->filename);
        ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
                      "%s", errmsg);
        exit(1);