* "breaks" variable incorrectly reset in "doshfunc()"
@ 1997-01-27 17:14 Martin Ouwehand
1997-01-27 21:57 ` Zoltan Hidvegi
0 siblings, 1 reply; 2+ messages in thread
From: Martin Ouwehand @ 1997-01-27 17:14 UTC (permalink / raw)
To: zsh-workers
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2345 bytes --]
Hello,
here is a bug report and a patch for zsh-3.0.2. First the description
of the bug:
- run "zsh" (the bug happens even with with the "-f" flag and no
/etc/zshenv)
- define the "TRAPDEBUG()" function to be anything, eg:
TRAPDEBUG()
{
return 0
}
- enter (for this to be really useful, you would put
"set -o AUTO_PUSHD" and "export DIRSTACKSIZE=10" in eg ".zshrc")
select dir in `dirs`
do
eval cd $dir
break
done
- the bug is that the "break" in the above loop is not executed, so
that you have to exit the loop with a "^D", otherwise you remain
in the loop forever.
My analysis is that "doshfunc()" is called because TRAPDEBUG is set and
this function resets the "breaks" variable to 0 a bit too early. See below
for the patch I propose (I don't know if it will break something else.)
Martin
--
Martin Ouwehand Tél +41 21 693 22 29 ouwehand@sic.epfl.ch
Service Informatique Central Central Computing Service
Ecole Polytechnique Fédérale - Lausanne - Swiss Federal Institute of Technology
================== PGP public key: http://sehp1.epfl.ch:8001 ==================
*** zsh-3.0.2.orig/Src/exec.c Tue Dec 17 21:14:11 1996
--- zsh-3.0.2/Src/exec.c Mon Jan 27 17:14:16 1997
***************
*** 2484,2489 ****
--- 2484,2490 ----
char **tab, **x, *oargv0 = NULL;
int xexittr, oldzoptind, oldlastval;
LinkList olist;
+ int obreaks;
char *s, *ou;
void *xexitfn;
char saveopts[OPT_SIZE];
***************
*** 2533,2538 ****
--- 2534,2540 ----
}
PERMALLOC {
olist = locallist; /* save the old locallist since shell functions may be nested */
+ obreaks = breaks;
locallist = newlinklist(); /* make a new list of local variables that we have to destroy */
} LASTALLOC;
locallevel++;
***************
*** 2552,2558 ****
zfree(locallist, sizeof(struct linklist));
locallist = olist; /* restore the old list of local variables */
! breaks = retflag = 0;
freearray(pparams);
if (oargv0) {
zsfree(argzero);
--- 2554,2561 ----
zfree(locallist, sizeof(struct linklist));
locallist = olist; /* restore the old list of local variables */
! breaks = obreaks;
! retflag = 0;
freearray(pparams);
if (oargv0) {
zsfree(argzero);
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: "breaks" variable incorrectly reset in "doshfunc()"
1997-01-27 17:14 "breaks" variable incorrectly reset in "doshfunc()" Martin Ouwehand
@ 1997-01-27 21:57 ` Zoltan Hidvegi
0 siblings, 0 replies; 2+ messages in thread
From: Zoltan Hidvegi @ 1997-01-27 21:57 UTC (permalink / raw)
To: ouwehand; +Cc: zsh-workers
Martin Ouwehand wrote:
> My analysis is that "doshfunc()" is called because TRAPDEBUG is set and
> this function resets the "breaks" variable to 0 a bit too early. See below
> for the patch I propose (I don't know if it will break something else.)
I think this breaks = 0 assignment is unnecessary. But in signals.c this
has to be handled somehow.
Zoltan
*** Src/exec.c 1997/01/26 02:55:02 3.1.1.10
--- Src/exec.c 1997/01/27 20:56:46
***************
*** 2585,2591 ****
zfree(locallist, sizeof(struct linklist));
locallist = olist; /* restore the old list of local variables */
! breaks = retflag = 0;
freearray(pparams);
if (oargv0) {
zsfree(argzero);
--- 2585,2591 ----
zfree(locallist, sizeof(struct linklist));
locallist = olist; /* restore the old list of local variables */
! retflag = 0;
freearray(pparams);
if (oargv0) {
zsfree(argzero);
*** Src/signals.c 1997/01/26 02:54:35 3.1.1.2
--- Src/signals.c 1997/01/27 20:49:30
***************
*** 664,669 ****
--- 664,670 ----
LinkList args;
char *name, num[4];
int trapret = 0;
+ int obreaks = breaks;
/* if signal is being ignored or the trap function *
* is NULL, then return *
***************
*** 680,685 ****
--- 681,687 ----
lexsave();
execsave();
+ breaks = 0;
if (sigtrapped[sig] & ZSIG_FUNC) {
PERMALLOC {
args = newlinklist();
***************
*** 706,714 ****
if (trapret > 0) {
breaks = loops;
errflag = 1;
}
if (sigtrapped[sig] != ZSIG_IGNORED)
sigtrapped[sig] &= ~ZSIG_IGNORED;
}
-
--- 708,719 ----
if (trapret > 0) {
breaks = loops;
errflag = 1;
+ } else {
+ breaks += obreaks;
+ if (breaks > loops)
+ breaks = loops;
}
if (sigtrapped[sig] != ZSIG_IGNORED)
sigtrapped[sig] &= ~ZSIG_IGNORED;
}
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1997-01-27 22:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-01-27 17:14 "breaks" variable incorrectly reset in "doshfunc()" Martin Ouwehand
1997-01-27 21:57 ` Zoltan Hidvegi
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).