commit bash-20041202 snapshot

This commit is contained in:
Chet Ramey
2011-12-03 13:40:44 -05:00
parent 54cdd75ae4
commit 76a8d78dfd
9 changed files with 91 additions and 50 deletions
+12 -7
View File
@@ -1,6 +1,6 @@
/* xmbsrtowcs.c -- replacement function for mbsrtowcs */
/* Copyright (C) 2002 Free Software Foundation, Inc.
/* Copyright (C) 2002-2004 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -54,7 +54,7 @@ xmbsrtowcs (dest, src, len, pstate)
ps = &local_state;
}
n = strlen(*src);
n = strlen (*src);
if (dest == NULL)
{
@@ -62,19 +62,22 @@ xmbsrtowcs (dest, src, len, pstate)
const char *mbs;
mbstate_t psbuf;
/* It doesn't matter if malloc fails here, since mbsrtowcs should do
the right thing with a NULL first argument. */
wsbuf = (wchar_t *) malloc ((n + 1) * sizeof(wchar_t));
mbs = *src;
psbuf = *ps;
wclength = mbsrtowcs (wsbuf, &mbs, n, &psbuf);
free (wsbuf);
if (wsbuf)
free (wsbuf);
return wclength;
}
for (wclength = 0; wclength < len; wclength++, dest++)
{
if(mbsinit(ps))
if (mbsinit(ps))
{
if (**src == '\0')
{
@@ -166,10 +169,11 @@ xdupmbstowcs (destp, indicesp, src)
p = src;
wcnum = 0;
do {
do
{
size_t mblength; /* Byte length of one multibyte character. */
if(mbsinit (&state))
if (mbsinit (&state))
{
if (*p == '\0')
{
@@ -230,7 +234,8 @@ xdupmbstowcs (destp, indicesp, src)
wsbuf[wcnum - 1] = wc;
indices[wcnum - 1] = (char *)p;
p += mblength;
} while (MB_NULLWCH (wc) == 0);
}
while (MB_NULLWCH (wc) == 0);
/* Return the length of the wide character string, not including `\0'. */
*destp = wsbuf;
+6 -2
View File
@@ -225,8 +225,10 @@ _rl_free_history_entry (entry)
{
if (entry == 0)
return;
if (entry->line)
free (entry->line);
FREE (entry->line);
FREE (entry->timestamp);
free (entry);
}
@@ -242,6 +244,7 @@ rl_maybe_replace_line ()
{
temp = replace_history_entry (where_history (), rl_line_buffer, (histdata_t)rl_undo_list);
free (temp->line);
FREE (temp->timestamp);
free (temp);
}
return 0;
@@ -274,6 +277,7 @@ rl_maybe_save_line ()
{
_rl_saved_line_for_history = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY));
_rl_saved_line_for_history->line = savestring (rl_line_buffer);
_rl_saved_line_for_history->timestamp = (char *)NULL;
_rl_saved_line_for_history->data = (char *)rl_undo_list;
}