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 Tue, 30 May 2000 02:11:03 GMT

+1.  I would like to get rid of the ap_assert and fix the indenting, but I
am +1 for this patch on it's technical merits.

Ryan

> > Index: src/include/http_config.h
> > ===================================================================
> > RCS file: /cvs/apache/apache-2.0/src/include/http_config.h,v
> > retrieving revision 1.26
> > diff -u -r1.26 http_config.h
> > --- http_config.h	2000/05/28 03:52:36	1.26
> > +++ http_config.h	2000/05/30 01:37:25
> > @@ -188,6 +188,7 @@
> >  
> >      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: src/main/http_config.c
> > ===================================================================
> > RCS file: /cvs/apache/apache-2.0/src/main/http_config.c,v
> > retrieving revision 1.54
> > diff -u -r1.54 http_config.c
> > --- http_config.c	2000/05/28 03:52:41	1.54
> > +++ http_config.c	2000/05/30 01:37:29
> > @@ -984,6 +984,7 @@
> >  	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 @@
> >  	    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 @@
> >   */
> >  
> >  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,11 @@
> >  	errmsg = ap_walk_config(conftree, &parms, s->lookup_defaults);
> >  
> >      if (errmsg != NULL) {
> > -	/* ### wrong line number. need to pull from ap_directive_t */
> > +        ap_assert(parms.err_directive);
> >  	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);
> > 
> > -- 
> > Jeff Trawick | trawick@ibm.net | PGP public key at web site:
> >      http://www.geocities.com/SiliconValley/Park/9289/
> >           Born in Roswell... married an alien...
> > 
> 
> -- 
> Greg Stein, http://www.lyra.org/
> 


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


Mime
View raw message