summaryrefslogtreecommitdiff
path: root/Src/loop.c
diff options
context:
space:
mode:
authorJoe Rayhawk <jrayhawk@fairlystable.org>2025-04-30 02:07:56 -0700
committerJoe Rayhawk <jrayhawk@fairlystable.org>2025-04-30 02:07:56 -0700
commit26e09889646be3ea65b4a3dfeda26213e4bb6a27 (patch)
tree4f3c73a9416bf47ad7e125383d23cf42879e38d7 /Src/loop.c
parent841bce705a58b04220b1f257abcc00ae71cbdbdc (diff)
parent001cba48ce3b964cf01fb3e2af54b20eacbc9bf5 (diff)
downloadzsh-26e09889646be3ea65b4a3dfeda26213e4bb6a27.tar.gz
zsh-26e09889646be3ea65b4a3dfeda26213e4bb6a27.zip
Merge branch 'upstream' into debian
Diffstat (limited to 'Src/loop.c')
-rw-r--r--Src/loop.c44
1 files changed, 24 insertions, 20 deletions
diff --git a/Src/loop.c b/Src/loop.c
index db5b3e097..979285abc 100644
--- a/Src/loop.c
+++ b/Src/loop.c
@@ -53,7 +53,7 @@ execfor(Estate state, int do_exec)
wordcode code = state->pc[-1];
int iscond = (WC_FOR_TYPE(code) == WC_FOR_COND), ctok = 0, atok = 0;
int last = 0;
- char *name, *str, *cond = NULL, *advance = NULL;
+ char *str, *cond = NULL, *advance = NULL;
zlong val = 0;
LinkList vars = NULL, args = NULL;
int old_simple_pline = simple_pline;
@@ -151,7 +151,7 @@ execfor(Estate state, int do_exec)
int count = 0;
for (node = firstnode(vars); node; incnode(node))
{
- name = (char *)getdata(node);
+ char *name = (char *)getdata(node);
if (!args || !(str = (char *) ugetnode(args)))
{
if (count) {
@@ -165,7 +165,7 @@ execfor(Estate state, int do_exec)
fprintf(xtrerr, "%s=%s\n", name, str);
fflush(xtrerr);
}
- setsparam(name, ztrdup(str));
+ setloopvar(name, str);
count++;
}
if (!count)
@@ -282,7 +282,7 @@ execselect(Estate state, UNUSED(int do_exec))
/* Keep any user interrupt error status */
errflag = oef | (errflag & ERRFLAG_INT);
} else {
- str = promptexpand(prompt3, 0, NULL, NULL, NULL);
+ str = promptexpand(prompt3, 0, NULL, NULL);
zputs(str, stderr);
free(str);
fflush(stderr);
@@ -351,9 +351,16 @@ selectlist(LinkList l, size_t start)
zleentry(ZLE_CMD_TRASH);
arr = hlinklist2array(l, 0);
- for (ap = arr; *ap; ap++)
- if (strlen(*ap) > longest)
- longest = strlen(*ap);
+ for (ap = arr; *ap; ap++) {
+#ifdef MB_METASTRWIDTH
+ int aplen = MB_METASTRWIDTH(*ap);
+#else
+ int aplen = 0;
+ (void) unmetafy(*ap, &aplen);
+#endif
+ if (aplen > longest)
+ longest = aplen;
+ }
t0 = ct = ap - arr;
longest++;
while (t0)
@@ -368,7 +375,12 @@ selectlist(LinkList l, size_t start)
for (t1 = start; t1 != colsz && t1 - start < zterm_lines - 2; t1++) {
ap = arr + t1;
do {
+#ifdef MB_METASTRWIDTH
+ size_t t2 = MB_METASTRWIDTH(*ap) + 2;
+ (void) unmetafy(*ap, NULL);
+#else
size_t t2 = strlen(*ap) + 2;
+#endif
int t3;
fprintf(stderr, "%d) %s", t3 = ap - arr + 1, *ap);
@@ -428,7 +440,7 @@ execwhile(Estate state, UNUSED(int do_exec))
} else {
for (;;) {
state->pc = loop;
- noerrexit = NOERREXIT_EXIT | NOERREXIT_RETURN;
+ noerrexit |= NOERREXIT_EXIT | NOERREXIT_RETURN;
/* In case the test condition is a functional no-op,
* make sure signal handlers recognize ^C to end the loop. */
@@ -569,23 +581,14 @@ execif(Estate state, int do_exec)
s = 1;
state->pc = next;
}
+ noerrexit = olderrexit;
if (run) {
- /* we need to ignore lastval until we reach execcmd() */
- if (olderrexit || run == 2)
- noerrexit = olderrexit;
- else if (lastval)
- noerrexit |= NOERREXIT_EXIT | NOERREXIT_RETURN | NOERREXIT_UNTIL_EXEC;
- else
- noerrexit &= ~ (NOERREXIT_EXIT | NOERREXIT_RETURN);
cmdpush(run == 2 ? CS_ELSE : (s ? CS_ELIFTHEN : CS_IFTHEN));
execlist(state, 1, do_exec);
cmdpop();
- } else {
- noerrexit = olderrexit;
- if (!retflag && !errflag)
- lastval = 0;
- }
+ } else if (!retflag && !errflag)
+ lastval = 0;
state->pc = end;
this_noerrexit = 1;
@@ -793,6 +796,7 @@ exectry(Estate state, int do_exec)
cmdpop();
popheap();
state->pc = end;
+ this_noerrexit = 1;
return endval;
}