diff options
author | Axel Beckert <abe@deuxchevaux.org> | 2020-02-14 01:58:20 +0100 |
---|---|---|
committer | Axel Beckert <abe@deuxchevaux.org> | 2020-02-14 01:58:20 +0100 |
commit | bfc5d42735c1660263904ec5254cccf539a0a458 (patch) | |
tree | 9bbb81b4a53941427e6f9e65ae55027d9108df8c /Src/utils.c | |
parent | 74561cc51b8867e43cb2937ab2edfb36e2a829bf (diff) | |
parent | 643de931640e01aa246723d2038328ef33737965 (diff) | |
download | zsh-bfc5d42735c1660263904ec5254cccf539a0a458.tar.gz zsh-bfc5d42735c1660263904ec5254cccf539a0a458.zip |
Merge tag 'zsh-5.7.1-test-3' into debian
Test release: 5.7.1-test-3
Diffstat (limited to 'Src/utils.c')
-rw-r--r-- | Src/utils.c | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/Src/utils.c b/Src/utils.c index 32f600858..f5667f389 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -287,9 +287,7 @@ zerrmsg(FILE *file, const char *fmt, va_list ap) { const char *str; int num; -#ifdef DEBUG long lnum; -#endif #ifdef HAVE_STRERROR_R #define ERRBUFSIZE (80) int olderrno; @@ -325,12 +323,10 @@ zerrmsg(FILE *file, const char *fmt, va_list ap) nicezputs(s, file); break; } -#ifdef DEBUG case 'L': lnum = va_arg(ap, long); fprintf(file, "%ld", lnum); break; -#endif case 'd': num = va_arg(ap, int); fprintf(file, "%d", num); @@ -2201,6 +2197,31 @@ gettempname(const char *prefix, int use_heap) #ifdef HAVE__MKTEMP /* Zsh uses mktemp() safely, so silence the warnings */ ret = (char *) _mktemp(ret); +#elif HAVE_MKSTEMP && defined(DEBUG) + { + /* zsh uses mktemp() safely (all callers use O_EXCL, and one of them + * uses mkfifo()/mknod(), as opposed to open()), but some compilers + * warn about this anyway and give no way to disable the warning. To + * appease them, use mkstemp() and then close the fd and unlink the + * filename, to match callers' expectations. + * + * But do this in debug builds only, because we don't want to suffer + * x3 the disk access (touch, unlink, touch again) in production. + */ + int fd; + errno = 0; + fd = mkstemp(ret); + if (fd < 0) + zwarn("can't get a temporary filename: %e", errno); + else { + close(fd); + ret = ztrdup(ret); + + errno = 0; + if (unlink(ret) < 0) + zwarn("unlinking a temporary filename failed: %e", errno); + } + } #else ret = (char *) mktemp(ret); #endif @@ -3159,6 +3180,8 @@ spckword(char **s, int hist, int cmd, int ask) scanhashtable(cmdnamtab, 1, 0, 0, spscan, 0); if (autocd) { char **pp; + if (cd_able_vars(unmeta(guess))) + return; for (pp = cdpath; *pp; pp++) { char bestcd[PATH_MAX + 1]; int thisdist; @@ -3336,7 +3359,7 @@ morefmt: case '.': { long fnsec = nsec; - if (digs > 9) + if (digs < 0 || digs > 9) digs = 9; if (ztrftimebuf(&bufsize, digs)) return -1; |