httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@covalent.net
Subject Re: [PATCH] improving line number reporting for config file syntax errors
Date Mon, 29 May 2000 21:37:01 GMT

Here is a real quick update to my last patch for this problem that solves
syntax errors in the global context.  The patch I originally posted had
only been tested with errors inside a context and that error had to be an
unrecognized command.  This one has caught and correctly reported the line
number for:

PidFile 1 2 3 4 5 6 7

And

<Directory Foo>
silly
</Directory>

I like this patch because it is relatively clean with regard to how much
it changes things.  The basic idea to this patch, is that we pass around
the configfile_t variable that we use when reporting the error.  At the
time that we actually receive an error while reading the config file, we
just replace the line number in the configfile_t with the line number that
caused the error.

Ryan

Index: CHANGES
===================================================================
RCS file: /home/cvs/apache-2.0/src/CHANGES,v
retrieving revision 1.125
diff -u -d -b -w -u -r1.125 CHANGES
--- CHANGES	2000/05/29 08:57:19	1.125
+++ CHANGES	2000/05/29 21:31:09
@@ -1,5 +1,9 @@
 Changes with Apache 2.0a4
 
+  *) We now report the correct line number for Syntax errors from config
+     files.
+     [Ryan Bloom]
+
   *) Brought mod_auth_digest up to synch with 1.3, fixed ap_time_t-
      related bugs, and changed shmem/locking to use apr API. Shared-mem
      is currently disabled, however, because of problems with graceful
Index: main/http_config.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/main/http_config.c,v
retrieving revision 1.54
diff -u -d -b -w -u -r1.54 http_config.c
--- main/http_config.c	2000/05/28 03:52:41	1.54
+++ main/http_config.c	2000/05/29 21:31:16
@@ -984,6 +984,7 @@
 	const command_rec *cmd;
 
 	if (!(cmd = ap_find_command_in_modules(current->directive, &mod))) {
+	    parms->config_file->line_number = current->line_num;
             return ap_pstrcat(parms->pool, "Invalid command '", 
 			      current->directive,
 			      "', perhaps mis-spelled or defined by a module "
@@ -994,6 +995,7 @@
 	    void *mconfig = ap_set_config_vectors(parms,config, mod);
 	    const char *retval;
 
+	    parms->config_file->line_number = current->line_num;
 	    retval = invoke_cmd(cmd, parms, mconfig, current->args);
 	    if (retval == NULL || strcmp(retval, DECLINE_CMD) != 0)
 		return retval;

_______________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
406 29th St.
San Francisco, CA 94131
-------------------------------------------------------------------------------



Mime
View raw message