mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-07-06 20:00:49 +02:00
size_t changes for multibyte characters; fix for running debug trap in asynchronous pipeline; remove support for precomputed cache files for cross-compiling; more size_t and ssize_t changes to avoid overflow
This commit is contained in:
@@ -1362,7 +1362,6 @@ compute_lcd_of_matches (char **match_list, int matches, const char *text)
|
||||
size_t si1, si2;
|
||||
size_t len1, len2;
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
int v;
|
||||
size_t v1, v2;
|
||||
mbstate_t ps1, ps2;
|
||||
WCHAR_T wc1, wc2;
|
||||
|
||||
@@ -1732,7 +1732,7 @@ update_line (char *old, char *old_face, char *new, char *new_face, int current_l
|
||||
{
|
||||
char *ofd, *ols, *oe, *nfd, *nls, *ne;
|
||||
char *ofdf, *nfdf, *olsf, *nlsf;
|
||||
int temp, lendiff, wsatend, od, nd, twidth, o_cpos;
|
||||
int temp, lendiff, wsatend, od, nd, o_cpos;
|
||||
int current_invis_chars;
|
||||
int col_lendiff, col_temp;
|
||||
int bytes_to_insert;
|
||||
@@ -1863,7 +1863,7 @@ update_line (char *old, char *old_face, char *new, char *new_face, int current_l
|
||||
_rl_output_some_chars below. */
|
||||
if (newwidth > 0)
|
||||
{
|
||||
int count, i, j;
|
||||
int i, j;
|
||||
char *optr;
|
||||
|
||||
puts_face (new, new_face, newbytes);
|
||||
|
||||
@@ -19,7 +19,7 @@ My example shows how, using the alternate interface, you can
|
||||
interactively change the prompt (which is very nice imo). Also, I
|
||||
point out that you must roll your own terminal setting when using the
|
||||
alternate interface because readline depreps (using your parlance) the
|
||||
terminal while in the user callback. I try to demostrate what I mean
|
||||
terminal while in the user callback. I try to demonstrate what I mean
|
||||
with an example. I've included the program below.
|
||||
|
||||
To compile, I just put the program in the examples directory and made
|
||||
@@ -72,7 +72,7 @@ Copyright (C) 1999 Jeff Solomon
|
||||
* alternate interface. The first is the ability to interactively change the
|
||||
* prompt, which can't be done using the regular interface since rl_prompt is
|
||||
* read-only.
|
||||
*
|
||||
*
|
||||
* The second feature really highlights a subtle point when using the alternate
|
||||
* interface. That is, readline will not alter the terminal when inside your
|
||||
* callback handler. So let's so, your callback executes a user command that
|
||||
|
||||
@@ -110,7 +110,7 @@ main (int argc, char **argv)
|
||||
int which;
|
||||
if ((sscanf (line + 6, "%d", &which)) == 1)
|
||||
{
|
||||
HIST_ENTRY *entry = remove_history (which);
|
||||
HIST_ENTRY *entry = remove_history (which - history_base);
|
||||
if (!entry)
|
||||
fprintf (stderr, "No such entry %d\n", which);
|
||||
else
|
||||
|
||||
@@ -94,16 +94,8 @@ invert_case_line (int count, int key)
|
||||
|
||||
start = rl_point;
|
||||
|
||||
if (count < 0)
|
||||
{
|
||||
direction = -1;
|
||||
count = -count;
|
||||
}
|
||||
else
|
||||
direction = 1;
|
||||
|
||||
/* Find the end of the range to modify. */
|
||||
end = start + (count * direction);
|
||||
end = start + count;
|
||||
|
||||
/* Force it to be within range. */
|
||||
if (end > rl_end)
|
||||
@@ -111,6 +103,14 @@ invert_case_line (int count, int key)
|
||||
else if (end < 0)
|
||||
end = -1;
|
||||
|
||||
if (start == end)
|
||||
return 0;
|
||||
|
||||
/* For positive arguments, put point after the last changed character. For
|
||||
negative arguments, put point before the last changed character. */
|
||||
rl_point = end;
|
||||
|
||||
/* Swap start and end if we are moving backwards */
|
||||
if (start > end)
|
||||
{
|
||||
int temp = start;
|
||||
@@ -118,14 +118,11 @@ invert_case_line (int count, int key)
|
||||
end = temp;
|
||||
}
|
||||
|
||||
if (start == end)
|
||||
return 0;
|
||||
|
||||
/* Tell readline that we are modifying the line, so save the undo
|
||||
information. */
|
||||
rl_modifying (start, end);
|
||||
|
||||
for (; start != end; start += direction)
|
||||
for (; start != end; start++)
|
||||
{
|
||||
if (_rl_uppercase_p (rl_line_buffer[start]))
|
||||
rl_line_buffer[start] = _rl_to_lower (rl_line_buffer[start]);
|
||||
@@ -133,7 +130,5 @@ invert_case_line (int count, int key)
|
||||
rl_line_buffer[start] = _rl_to_upper (rl_line_buffer[start]);
|
||||
}
|
||||
|
||||
/* Move point to on top of the last character changed. */
|
||||
rl_point = end - direction;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -265,6 +265,7 @@ rl_funmap_names (void)
|
||||
result[result_index + 1] = (char *)NULL;
|
||||
}
|
||||
|
||||
qsort (result, result_index, sizeof (char *), (QSFUNC *)_rl_qsort_string_compare);
|
||||
if (result)
|
||||
qsort (result, result_index, sizeof (char *), (QSFUNC *)_rl_qsort_string_compare);
|
||||
return (result);
|
||||
}
|
||||
|
||||
+2
-1
@@ -107,12 +107,13 @@ static int
|
||||
utf8locale (char *lspec)
|
||||
{
|
||||
char *cp;
|
||||
size_t len;
|
||||
|
||||
#if HAVE_LANGINFO_CODESET
|
||||
cp = nl_langinfo (CODESET);
|
||||
return (STREQ (cp, "UTF-8") || STREQ (cp, "utf8"));
|
||||
#else
|
||||
size_t len;
|
||||
|
||||
cp = find_codeset (lspec, &len);
|
||||
|
||||
if (cp == 0 || len < 4 || len > 5)
|
||||
|
||||
+4
-4
@@ -1453,8 +1453,7 @@ rl_change_case (int count, int op)
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
WCHAR_T wc, nwc;
|
||||
char mb[MB_LEN_MAX+1];
|
||||
int mlen;
|
||||
size_t m;
|
||||
size_t m, mlen;
|
||||
mbstate_t mps;
|
||||
#endif
|
||||
|
||||
@@ -1532,12 +1531,13 @@ change_singlebyte:
|
||||
|
||||
memset (&ts, 0, sizeof (mbstate_t));
|
||||
mlen = WCRTOMB (mb, nwc, &ts);
|
||||
if (mlen < 0)
|
||||
|
||||
if (MB_INVALIDCH (mlen))
|
||||
{
|
||||
nwc = wc;
|
||||
memset (&ts, 0, sizeof (mbstate_t));
|
||||
mlen = WCRTOMB (mb, nwc, &ts);
|
||||
if (mlen < 0) /* should not happen */
|
||||
if (MB_INVALIDCH (mlen)) /* should not happen */
|
||||
strncpy (mb, rl_line_buffer + start, mlen = m);
|
||||
}
|
||||
if (mlen > 0)
|
||||
|
||||
+4
-1
@@ -536,7 +536,10 @@ _rl_audit_tty (char *string)
|
||||
size = strlen (string) + 1;
|
||||
|
||||
if (NLMSG_SPACE (size) > MAX_AUDIT_MESSAGE_LENGTH)
|
||||
return;
|
||||
{
|
||||
close (fd);
|
||||
return;
|
||||
}
|
||||
|
||||
memset (&req, 0, sizeof(req));
|
||||
req.nlh.nlmsg_len = NLMSG_SPACE (size);
|
||||
|
||||
+4
-4
@@ -106,8 +106,7 @@ sh_modcase (const char *string, char *pat, int flags)
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
wchar_t nwc;
|
||||
char mb[MB_LEN_MAX+1];
|
||||
int mlen;
|
||||
size_t m;
|
||||
size_t m, mlen;
|
||||
mbstate_t state;
|
||||
#endif
|
||||
|
||||
@@ -249,8 +248,9 @@ singlebyte:
|
||||
else
|
||||
{
|
||||
mlen = wcrtomb (mb, nwc, &state);
|
||||
if (mlen > 0)
|
||||
mb[mlen] = '\0';
|
||||
if (MB_INVALIDCH (mlen))
|
||||
strncpy (mb, string + start, mlen = m);
|
||||
mb[mlen] = '\0';
|
||||
/* Don't assume the same width */
|
||||
strncpy (ret + retind, mb, mlen);
|
||||
retind += mlen;
|
||||
|
||||
+3
-1
@@ -38,7 +38,9 @@ extern int errno;
|
||||
int
|
||||
zwrite (int fd, char *buf, size_t nb)
|
||||
{
|
||||
int n, i, nt;
|
||||
int nt;
|
||||
size_t n;
|
||||
ssize_t i;
|
||||
|
||||
for (n = nb, nt = 0;;)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user