From: Peter Stephenson <pws@ibmth.df.unipi.it>
To: zsh-workers@sunsite.auc.dk (Zsh hackers list)
Subject: PATCH: pws-N: function line numbers
Date: Thu, 24 Jun 1999 12:02:07 +0200 [thread overview]
Message-ID: <9906241002.AA16000@ibmth.df.unipi.it> (raw)
Now line numbers work properly in functions, we can use them for printing
error messages. To get the name of the function right, I hijacked
scriptname. That neatly solves the problem of deciding whether the nearest
enclosing object is a sourced script or a function.
It would be sort of nice to fix this stuff in 3.0.6 too, but that means
adapting both Sven's and my previous fixes, which is a rather deathly task.
--- Src/exec.c.fnln Thu Jun 24 10:46:29 1999
+++ Src/exec.c Thu Jun 24 11:40:38 1999
@@ -2879,7 +2879,7 @@
{
char **tab, **x, *oargv0 = NULL;
int oldzoptind, oldlastval;
- char saveopts[OPT_SIZE];
+ char saveopts[OPT_SIZE], *oldscriptname;
int obreaks = breaks;
HEAPALLOC {
@@ -2891,6 +2891,8 @@
starttrapscope();
tab = pparams;
+ oldscriptname = scriptname;
+ scriptname = name;
oldzoptind = zoptind;
zoptind = 1;
@@ -2933,6 +2935,7 @@
argzero = oargv0;
}
zoptind = oldzoptind;
+ scriptname = oldscriptname;
pparams = tab;
if (isset(LOCALOPTIONS)) {
--- Src/utils.c.fnln Wed Jun 23 17:35:29 1999
+++ Src/utils.c Thu Jun 24 11:42:42 1999
@@ -62,9 +62,10 @@
/*
* scriptname is set when sourcing scripts, so that we get the
* correct name instead of the generic name of whatever
- * program/script is running.
+ * program/script is running. It's also set in shell functions,
+ * so test locallevel, too.
*/
- nicezputs(isset(SHINSTDIN) ? "zsh" :
+ nicezputs((isset(SHINSTDIN) && !locallevel) ? "zsh" :
scriptname ? scriptname : argzero, stderr);
fputs(": ", stderr);
zerrnam(NULL, fmt, str, num);
@@ -79,7 +80,7 @@
return;
errflag = 1;
trashzle();
- if(unset(SHINSTDIN)) {
+ if (unset(SHINSTDIN) || locallevel) {
nicezputs(scriptname ? scriptname : argzero, stderr);
fputs(": ", stderr);
}
@@ -133,7 +134,7 @@
putc(*fmt == Meta ? *++fmt ^ 32 : *fmt, stderr);
fmt++;
}
- if (unset(SHINSTDIN) && lineno)
+ if ((unset(SHINSTDIN) || locallevel) && lineno)
fprintf(stderr, " [%ld]\n", (long)lineno);
else
putc('\n', stderr);
--
Peter Stephenson <pws@ibmth.df.unipi.it> Tel: +39 050 844536
WWW: http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy
next reply other threads:[~1999-06-24 10:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-06-24 10:02 Peter Stephenson [this message]
1999-06-24 16:16 ` Bart Schaefer
1999-06-25 6:58 Sven Wischnowsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9906241002.AA16000@ibmth.df.unipi.it \
--to=pws@ibmth.df.unipi.it \
--cc=zsh-workers@sunsite.auc.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).