$LINENO in trap

2010-05-18 Thread Manuel Giraud
My first patch that solves this :
http://cvs.openbsd.org/cgi-bin/query-pr-wrapper?full=yesnumbers=6195

Comments?

Index: history.c
===
RCS file: /cvs/src/bin/ksh/history.c,v
retrieving revision 1.38
diff -u -p -r1.38 history.c
--- history.c   1 May 2010 21:09:23 -   1.38
+++ history.c   18 May 2010 13:42:38 -
@@ -226,7 +226,7 @@ c_fc(char **wp)
Source *sold = source;
int ret;
 
-   ret = command(editor ? editor : ${FCEDIT:-/bin/ed} $_);
+   ret = command(editor ? editor : ${FCEDIT:-/bin/ed} $_, 0);
source = sold;
if (ret)
return ret;
@@ -295,7 +295,7 @@ hist_execute(char *cmd)
 */
/* XXX: source should not get trashed by this.. */
sold = source;
-   ret = command(cmd);
+   ret = command(cmd, 0);
source = sold;
return ret;
 }
Index: main.c
===
RCS file: /cvs/src/bin/ksh/main.c,v
retrieving revision 1.45
diff -u -p -r1.45 main.c
--- main.c  29 Jan 2009 23:27:26 -  1.45
+++ main.c  18 May 2010 13:42:38 -
@@ -460,13 +460,18 @@ include(const char *name, int argc, char
return i  0xff;/*  0xff to ensure value not -1 */
 }
 
+/*
+ * spawn a command into a shell optionally keeping track of line
+ * number.
+ */
 int
-command(const char *comm)
+command(const char *comm, int line)
 {
Source *s;
 
s = pushs(SSTRING, ATEMP);
s-start = s-str = comm;
+   s-line = line;
return shell(s, false);
 }
 
Index: proto.h
===
RCS file: /cvs/src/bin/ksh/proto.h,v
retrieving revision 1.32
diff -u -p -r1.32 proto.h
--- proto.h 29 Jan 2009 23:27:26 -  1.32
+++ proto.h 18 May 2010 13:42:38 -
@@ -159,7 +159,7 @@ voidmbset(char *);
 void   mpset(char *);
 /* main.c */
 intinclude(const char *, int, char **, int);
-intcommand(const char *);
+intcommand(const char *, int);
 intshell(Source *volatile, int volatile);
 void   unwind(int) __attribute__((__noreturn__));
 void   newenv(int);
Index: trap.c
===
RCS file: /cvs/src/bin/ksh/trap.c,v
retrieving revision 1.22
diff -u -p -r1.22 trap.c
--- trap.c  30 Mar 2005 17:16:37 -  1.22
+++ trap.c  18 May 2010 13:42:38 -
@@ -235,7 +235,7 @@ runtrap(Trap *p)
/* Note: trapstr is fully parsed before anything is executed, thus
 * no problem with afree(p-trap) in settrap() while still in use.
 */
-   command(trapstr);
+   command(trapstr, current_lineno);
exstat = oexstat;
if (i == SIGEXIT_ || i == SIGERR_) {
if (p-flags  TF_CHANGED)

-- 
Manuel Giraud



Re: $LINENO in trap

2010-05-18 Thread Adam M. Dutko
 Comments?


...snip...

After a quick read, it looks good to me, but I've not built it and tested it
because I don't have access to my openbsd system at the moment.