From 5bb39bb1995cb12d8da76b1d482df9be1acc2eb4 Mon Sep 17 00:00:00 2001 From: Harald van Dijk Date: Tue, 15 Mar 2011 15:52:05 +0800 Subject: [SHELL] Improve LINENO support This patch improves LINENO support by storing line numbers in the parse tree, for commands as well as for function definitions. It makes LINENO behaves properly when calling functions, and has the added benefit of improved line numbers in error messages when the last-parsed command is not the last-executed one. It removes the earlier LINENO support, and instead sets LINENO from evaltree when a command is executed Signed-off-by: Harald van Dijk Signed-off-by: Herbert Xu --- src/var.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/var.h') diff --git a/src/var.h b/src/var.h index 35dd099..54f7b2d 100644 --- a/src/var.h +++ b/src/var.h @@ -88,8 +88,9 @@ extern struct var varinit[]; #define vps2 (&vps1)[1] #define vps4 (&vps2)[1] #define voptind (&vps4)[1] +#define vlineno (&voptind)[1] #ifndef SMALL -#define vterm (&voptind)[1] +#define vterm (&vlineno)[1] #define vhistsize (&vterm)[1] #endif @@ -102,6 +103,9 @@ extern const char defifs[]; extern const char defpathvar[]; #define defpath (defpathvar + 5) +extern int lineno; +extern char linenovar[]; + /* * The following macros access the values of the above variables. * They have to skip over the name. They return the null string @@ -117,6 +121,7 @@ extern const char defpathvar[]; #define ps2val() (vps2.text + 4) #define ps4val() (vps4.text + 4) #define optindval() (voptind.text + 7) +#define linenoval() (vlineno.text + 7) #ifndef SMALL #define histsizeval() (vhistsize.text + 9) #define termval() (vterm.text + 5) -- cgit 1.4.1