Re: [PATCH] Improved LINENO support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Nov 27, 2010 at 04:56:17PM +0000, Harald van Dijk wrote:
>
> Again, comments are welcome.

Thanks for working on this! Just a few minor problems to correct.
Oh and please add a changelog + sign-off.

> diff --git a/src/eval.c b/src/eval.c
> index b966749..d85f66f 100644
> --- a/src/eval.c
> +++ b/src/eval.c
> @@ -73,7 +73,7 @@
>  int evalskip;			/* set if we are skipping commands */
>  STATIC int skipcount;		/* number of levels to skip */
>  MKINIT int loopnest;		/* current loop nesting level */
> -static int funcnest;		/* depth of function calls */
> +STATIC int funcline;		/* starting line number of current function, or 0 if not in a function */

Please don't add any new uses of STATIC.  I'm fine with leaving
existing ones in place though.

> @@ -730,7 +749,7 @@ evalcommand(union node *cmd, int flags)
>  	*nargv = NULL;
>  
>  	lastarg = NULL;
> -	if (iflag && funcnest == 0 && argc > 0)
> +	if (iflag && funcline == 0 && argc > 0)
>  		lastarg = nargv[-1];

I like this bit :)

> diff --git a/src/exec.c b/src/exec.c
> index 42299ea..959b9f4 100644
> --- a/src/exec.c
> +++ b/src/exec.c
> @@ -688,14 +688,14 @@ addcmdentry(char *name, struct cmdentry *entry)
>   */
>  
>  void
> -defun(char *name, union node *func)
> +defun(union node *func)
>  {
>  	struct cmdentry entry;
>  
>  	INTOFF;
>  	entry.cmdtype = CMDFUNCTION;
>  	entry.u.func = copyfunc(func);
> -	addcmdentry(name, &entry);
> +	addcmdentry(func->ndefun.text, &entry);
>  	INTON;
>  }

Please separate out unrelated changes like this into distinct
patches.

> @@ -329,6 +333,9 @@ lookupvar(const char *name)
>  	struct var *v;
>  
>  	if ((v = *findvar(hashvar(name), name)) && !(v->flags & VUNSET)) {
> +		if (v == &vlineno && v->text == linenovar) {
> +			sprintf(linenoval(), "%d", lineno);
> +		}

Please use fmtstr instead of sprintf for consistency.

Cheers,
--
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux