1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-29 06:51:03 +02:00

26957: Fix some memory problems with read builtin

unposted: fix a WARN_CREATE_GLOBAL warning
This commit is contained in:
Peter Stephenson 2009-05-12 11:11:14 +00:00
parent c18b6c2c99
commit d1abd3e7cf
3 changed files with 22 additions and 9 deletions

View file

@ -1,3 +1,10 @@
2009-05-12 Peter Stephenson <pws@csr.com>
* unposted: Functions/Prompts/prompt_bart_setup: fix a warning
with WARN_CREATE_GLOBAL.
* Src/builtin.c: fix some memory usage issues.
2009-05-11 Peter Stephenson <pws@csr.com>
* 26956: Etc/zsh-development-guide, Src/Zle/zle_refresh:
@ -11691,5 +11698,5 @@
*****************************************************
* This is used by the shell to define $ZSH_PATCHLEVEL
* $Revision: 1.4683 $
* $Revision: 1.4684 $
*****************************************************

View file

@ -78,6 +78,7 @@ prompt_bart_precmd () {
psvar[8]='' # No padding until we compute it
psvar[9]=()
typeset -g PSCOL
# Reset the truncation widths for upcoming computations
((PSCOL == 1)) || { PSCOL=1 ; prompt_bart_ps1 }
if [[ -o promptcr ]]

View file

@ -5085,16 +5085,16 @@ bin_read(char *name, char **args, Options ops, UNUSED(int func))
if (OPT_ISSET(ops,'d')) {
char *delimstr = OPT_ARG(ops,'d');
#ifdef MULTIBYTE_SUPPORT
wint_t wc;
wint_t wi;
if (isset(MULTIBYTE)) {
mb_metacharinit();
(void)mb_metacharlenconv(delimstr, &wc);
(void)mb_metacharlenconv(delimstr, &wi);
}
else
wc = WEOF;
if (wc != WEOF)
delim = (wchar_t)wc;
wi = WEOF;
if (wi != WEOF)
delim = (wchar_t)wi;
else
delim = (wchar_t)((delimstr[0] == Meta) ?
delimstr[1] ^ 32 : delimstr[0]);
@ -5358,8 +5358,12 @@ bin_read(char *name, char **args, Options ops, UNUSED(int func))
wc = (wchar_t)c;
}
if (ret != MB_INCOMPLETE) {
if (ret == MB_INVALID)
if (ret == MB_INVALID) {
memset(&mbs, 0, sizeof(mbs));
/* Treat this as a single character */
wc = (wchar_t)c;
laststart = bptr;
}
if (bslash && wc == delim) {
bslash = 0;
continue;
@ -5450,9 +5454,10 @@ bin_read(char *name, char **args, Options ops, UNUSED(int func))
}
signal_setmask(s);
#ifdef MULTIBYTE_SUPPORT
if (c == EOF)
if (c == EOF) {
gotnl = 1;
if (ret == MB_INCOMPLETE) {
*bptr = '\0'; /* see below */
} else if (ret == MB_INCOMPLETE) {
/*
* We can only get here if there is an EOF in the
* middle of a character... safest to keep the debris,