summaryrefslogtreecommitdiff
path: root/Src
diff options
context:
space:
mode:
authorAxel Beckert <abe@deuxchevaux.org>2022-05-08 05:47:08 +0200
committerAxel Beckert <abe@deuxchevaux.org>2022-05-08 05:47:08 +0200
commit9529af723604dfe1c8152db11e1d216621c898d5 (patch)
treea512727d6ea897041fca8a6b09f7d5ddd753d7f1 /Src
parentb09f4483416c54c1782824633dfabaf2ec0265b6 (diff)
parent32100208ecc26f8b70a0dbef6298bfd2b823d8d0 (diff)
downloadzsh-9529af723604dfe1c8152db11e1d216621c898d5.tar.gz
zsh-9529af723604dfe1c8152db11e1d216621c898d5.zip
New upstream version 5.8.1.3-test
Diffstat (limited to 'Src')
-rw-r--r--Src/Modules/stat.c12
-rw-r--r--Src/Modules/system.c4
-rw-r--r--Src/Zle/compcore.c2
-rw-r--r--Src/builtin.c3
-rw-r--r--Src/exec.c10
-rw-r--r--Src/hist.c4
-rw-r--r--Src/input.c24
-rw-r--r--Src/jobs.c17
-rw-r--r--Src/params.c20
-rw-r--r--Src/patchlevel.h.release2
-rw-r--r--Src/pattern.c10
-rw-r--r--Src/prompt.c2
12 files changed, 88 insertions, 22 deletions
diff --git a/Src/Modules/stat.c b/Src/Modules/stat.c
index 7c736072b..0df9b35b7 100644
--- a/Src/Modules/stat.c
+++ b/Src/Modules/stat.c
@@ -503,8 +503,10 @@ bin_stat(char *name, char **args, Options ops, UNUSED(int func))
if (OPT_ISSET(ops,'f'))
nargs = 1;
else
- for (aptr = args; *aptr; aptr++)
+ for (aptr = args; *aptr; aptr++) {
+ unmetafy(*aptr, NULL);
nargs++;
+ }
if (OPT_ISSET(ops,'g')) {
flags |= STF_GMT;
@@ -555,8 +557,8 @@ bin_stat(char *name, char **args, Options ops, UNUSED(int func))
for (; OPT_ISSET(ops,'f') || *args; args++) {
char outbuf[PATH_MAX + 9]; /* "link " + link name + NULL */
int rval = OPT_ISSET(ops,'f') ? fstat(fd, &statbuf) :
- OPT_ISSET(ops,'L') ? lstat(unmeta(*args), &statbuf) :
- stat(unmeta(*args), &statbuf);
+ OPT_ISSET(ops,'L') ? lstat(*args, &statbuf) :
+ stat(*args, &statbuf);
if (rval) {
if (OPT_ISSET(ops,'f'))
sprintf(outbuf, "%d", fd);
@@ -571,10 +573,10 @@ bin_stat(char *name, char **args, Options ops, UNUSED(int func))
if (flags & STF_FILE) {
if (arrnam)
- *arrptr++ = ztrdup(*args);
+ *arrptr++ = ztrdup_metafy(*args);
else if (hashnam) {
*hashptr++ = ztrdup(HNAMEKEY);
- *hashptr++ = ztrdup(*args);
+ *hashptr++ = ztrdup_metafy(*args);
} else
printf("%s%s", *args, (flags & STF_PICK) ? " " : ":\n");
}
diff --git a/Src/Modules/system.c b/Src/Modules/system.c
index 71745548f..ea11ef037 100644
--- a/Src/Modules/system.c
+++ b/Src/Modules/system.c
@@ -83,10 +83,6 @@ bin_sysread(char *nam, char **args, Options ops, UNUSED(int func))
/* -o: output file descriptor, else store in REPLY */
if (OPT_ISSET(ops, 'o')) {
- if (*args) {
- zwarnnam(nam, "no argument allowed with -o");
- return 1;
- }
outfd = getposint(OPT_ARG(ops, 'o'), nam);
if (outfd < 0)
return 1;
diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c
index fe3ea10fc..4ac5d089f 100644
--- a/Src/Zle/compcore.c
+++ b/Src/Zle/compcore.c
@@ -3314,7 +3314,7 @@ makearray(LinkList l, int type, int flags, int *np, int *nlp, int *llp)
if (del) {
int n_orig = n;
for (bp = rp, ap = rp; bp < rp + n_orig; ap++, bp++) {
- while (bp[0]->flags & CMF_DELETE) {
+ while (bp < rp + n_orig && (bp[0]->flags & CMF_DELETE)) {
bp++;
n--;
}
diff --git a/Src/builtin.c b/Src/builtin.c
index 8ef678b22..1cef7cce8 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -5720,6 +5720,8 @@ bin_break(char *name, char **argv, UNUSED(Options ops), int func)
* a bad job.
*/
if (stopmsg || (zexit(0, ZEXIT_DEFERRED), !stopmsg)) {
+ if (trap_state)
+ trap_state = TRAP_STATE_FORCE_RETURN;
retflag = 1;
breaks = loops;
exit_pending = 1;
@@ -5858,6 +5860,7 @@ zexit(int val, enum zexit_t from_where)
/* send SIGHUP to any jobs left running */
killrunjobs(from_where == ZEXIT_SIGNAL);
}
+ cleanfilelists();
if (isset(RCS) && interact) {
if (!nohistsave) {
int writeflags = HFILE_USE_OPTIONS;
diff --git a/Src/exec.c b/Src/exec.c
index 27d49e005..f2911807c 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -561,7 +561,7 @@ zexecve(char *pth, char **argv, char **newenvp)
isbinary = 1;
hasletter = 0;
for (ptr = execvebuf; ptr < ptr2; ptr++) {
- if (islower(*ptr) || *ptr == '$' || *ptr == '`')
+ if (islower(STOUC(*ptr)) || *ptr == '$' || *ptr == '`')
hasletter = 1;
if (hasletter && *ptr == '\n') {
isbinary = 0;
@@ -3898,6 +3898,10 @@ execcmd_exec(Estate state, Execcmd_params eparams,
for (i = 0; i < 10; i++)
if (save[i] != -2)
zclose(save[i]);
+ /*
+ * We're done with this job, no need to wait for it.
+ */
+ jobtab[thisjob].stat |= STAT_DONE;
goto done;
}
if (isset(XTRACE)) {
@@ -4879,13 +4883,9 @@ getoutputfile(char *cmd, char **eptr)
child_unblock();
return nam;
} else if (pid) {
- int os;
-
close(fd);
- os = jobtab[thisjob].stat;
waitforpid(pid, 0);
cmdoutval = 0;
- jobtab[thisjob].stat = os;
return nam;
}
diff --git a/Src/hist.c b/Src/hist.c
index f9440dba7..bff0abe61 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -2254,10 +2254,10 @@ casemodify(char *str, int how)
int c;
int mod = 0;
if (*str == Meta) {
- c = str[1] ^ 32;
+ c = STOUC(str[1] ^ 32);
str += 2;
} else
- c = *str++;
+ c = STOUC(*str++);
switch (how) {
case CASMOD_LOWER:
if (isupper(c)) {
diff --git a/Src/input.c b/Src/input.c
index c59232681..9898a7177 100644
--- a/Src/input.c
+++ b/Src/input.c
@@ -217,12 +217,34 @@ shinbufrestore(void)
static int
shingetchar(void)
{
- int nread;
+ int nread, rsize = isset(SHINSTDIN) ? 1 : SHINBUFSIZE;
if (shinbufptr < shinbufendptr)
return STOUC(*shinbufptr++);
shinbufreset();
+#ifdef USE_LSEEK
+ if (rsize == 1 && lseek(SHIN, 0, SEEK_CUR) != (off_t)-1)
+ rsize = SHINBUFSIZE;
+ if (rsize > 1) {
+ do {
+ errno = 0;
+ nread = read(SHIN, shinbuffer, rsize);
+ } while (nread < 0 && errno == EINTR);
+ if (nread <= 0)
+ return -1;
+ if (isset(SHINSTDIN) &&
+ (shinbufendptr = memchr(shinbuffer, '\n', nread))) {
+ shinbufendptr++;
+ rsize = (shinbufendptr - shinbuffer);
+ if (nread > rsize &&
+ lseek(SHIN, -(nread - rsize), SEEK_CUR) < 0)
+ zerr("lseek(%d, %d): %e", SHIN, -(nread - rsize), errno);
+ } else
+ shinbufendptr = shinbuffer + nread;
+ return STOUC(*shinbufptr++);
+ }
+#endif
for (;;) {
errno = 0;
nread = read(SHIN, shinbufendptr, 1);
diff --git a/Src/jobs.c b/Src/jobs.c
index af0a1233d..a91ef787f 100644
--- a/Src/jobs.c
+++ b/Src/jobs.c
@@ -1368,6 +1368,18 @@ deletefilelist(LinkList file_list, int disowning)
/**/
void
+cleanfilelists(void)
+{
+ int i;
+
+ DPUTS(shell_exiting >= 0, "BUG: cleanfilelists() before exit");
+
+ for (i = 1; i <= maxjob; i++)
+ deletefilelist(jobtab[i].filelist, 0);
+}
+
+/**/
+void
freejob(Job jn, int deleting)
{
struct process *pn, *nx;
@@ -1476,7 +1488,10 @@ addproc(pid_t pid, char *text, int aux, struct timeval *bgtime,
* set it for that, too.
*/
if (gleader != -1) {
- jobtab[thisjob].gleader = gleader;
+ if (jobtab[thisjob].stat & STAT_CURSH)
+ jobtab[thisjob].gleader = gleader;
+ else
+ jobtab[thisjob].gleader = pid;
if (list_pipe_job_used != -1)
jobtab[list_pipe_job_used].gleader = gleader;
/*
diff --git a/Src/params.c b/Src/params.c
index 970a207e4..27ea82298 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -4594,6 +4594,19 @@ static struct localename {
{NULL, 0}
};
+/* On some systems (at least on NetBSD-9), when LC_CTYPE changes,
+ * global variables (type mbstate_t) used by mbrtowc() etc. need be
+ * reset by clear_mbstate() */
+
+/**/
+static void
+clear_mbstate(void) {
+#ifdef MULTIBYTE_SUPPORT
+ mb_charinit(); /* utils.c */
+ clear_shiftstate(); /* pattern.c */
+#endif
+}
+
/**/
static void
setlang(char *x)
@@ -4616,6 +4629,7 @@ setlang(char *x)
* that case.
*/
setlocale(LC_ALL, x ? unmeta(x) : "");
+ clear_mbstate();
queue_signals();
for (ln = lc_names; ln->name; ln++)
if ((x = getsparam_u(ln->name)) && *x)
@@ -4641,8 +4655,10 @@ lc_allsetfn(Param pm, char *x)
unqueue_signals();
}
}
- else
+ else {
setlocale(LC_ALL, unmeta(x));
+ clear_mbstate();
+ }
}
/**/
@@ -4679,6 +4695,7 @@ lcsetfn(Param pm, char *x)
setlocale(ln->category, unmeta(x));
}
unqueue_signals();
+ clear_mbstate(); /* LC_CTYPE may have changed */
}
#endif /* USE_LOCALE */
@@ -5627,6 +5644,7 @@ endparamscope(void)
setlocale(ln->category, val);
}
}
+ clear_mbstate(); /* LC_CTYPE may have changed */
}
#endif /* USE_LOCALE */
unqueue_signals();
diff --git a/Src/patchlevel.h.release b/Src/patchlevel.h.release
index 05403a9e4..b95d69ac2 100644
--- a/Src/patchlevel.h.release
+++ b/Src/patchlevel.h.release
@@ -1 +1 @@
-#define ZSH_PATCHLEVEL "zsh-5.8.1.2-test-0-g6e55c92"
+#define ZSH_PATCHLEVEL "zsh-5.8.1.3-test-0-g3210020"
diff --git a/Src/pattern.c b/Src/pattern.c
index c0e31b78e..e947d1216 100644
--- a/Src/pattern.c
+++ b/Src/pattern.c
@@ -320,6 +320,14 @@ typedef wint_t patint_t;
*/
static mbstate_t shiftstate;
+/* See clear_mbstate() in params.c for the use of clear_shiftstate() */
+
+/**/
+mod_export void
+clear_shiftstate(void) {
+ memset(&shiftstate, 0, sizeof(shiftstate));
+}
+
/*
* Multibyte version: it's (almost) as easy to return the
* value as not, so do so since we sometimes need it..
@@ -1999,6 +2007,8 @@ charsub(char *x, char *y)
if (ret == MB_INVALID || ret == MB_INCOMPLETE) {
/* Error. Treat remainder as single characters */
+ /* Reset the shift state for next time. */
+ memset(&shiftstate, 0, sizeof(shiftstate));
return res + (y - x);
}
diff --git a/Src/prompt.c b/Src/prompt.c
index 738c7fc7a..092de63a4 100644
--- a/Src/prompt.c
+++ b/Src/prompt.c
@@ -1666,7 +1666,7 @@ match_colour(const char **teststrp, int is_fg, int colour)
tc = TCBGCOLOUR;
}
if (teststrp) {
- if (**teststrp == '#' && isxdigit((*teststrp)[1])) {
+ if (**teststrp == '#' && isxdigit(STOUC((*teststrp)[1]))) {
struct color_rgb color;
char *end;
zlong col = zstrtol(*teststrp+1, &end, 16);