mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-07-02 01:40:49 +02:00
next set of documentation updates (word splitting), rearrange a test in readline's tilde expansion to avoid touching uninitialized data
This commit is contained in:
@@ -1140,6 +1140,7 @@ internal_realloc (PTR_T mem, size_t n, const char *file, int line, int flags)
|
||||
if (n == 0)
|
||||
{
|
||||
internal_free (mem, file, line, MALLOC_INTERNAL);
|
||||
/* XXX - return internal_malloc (0, file, line MALLOC_INTERNAL) ? */
|
||||
return (NULL);
|
||||
}
|
||||
if ((p = (union mhead *) mem) == 0)
|
||||
|
||||
+14
-4
@@ -742,7 +742,8 @@ history_do_write (const char *filename, int nelements, int overwrite)
|
||||
int file, mode, rv, exists;
|
||||
struct stat finfo;
|
||||
#ifdef HISTORY_USE_MMAP
|
||||
size_t cursize;
|
||||
size_t cursize, newsize;
|
||||
off_t offset;
|
||||
|
||||
history_lines_written_to_file = 0;
|
||||
|
||||
@@ -798,7 +799,11 @@ history_do_write (const char *filename, int nelements, int overwrite)
|
||||
#ifdef HISTORY_USE_MMAP
|
||||
if (ftruncate (file, buffer_size+cursize) == -1)
|
||||
goto mmap_error;
|
||||
buffer = (char *)mmap (0, buffer_size, PROT_READ|PROT_WRITE, MAP_WFLAGS, file, cursize);
|
||||
/* for portability, ensure that we round cursize to a multiple of the
|
||||
page size. */
|
||||
offset = cursize & ~(getpagesize () - 1);
|
||||
newsize = buffer_size + cursize - offset;
|
||||
buffer = (char *)mmap (0, newsize, PROT_READ|PROT_WRITE, MAP_WFLAGS, file, offset);
|
||||
if ((void *)buffer == MAP_FAILED)
|
||||
{
|
||||
mmap_error:
|
||||
@@ -812,6 +817,7 @@ mmap_error:
|
||||
FREE (tempname);
|
||||
return rv;
|
||||
}
|
||||
j = cursize - offset;
|
||||
#else
|
||||
buffer = (char *)malloc (buffer_size);
|
||||
if (buffer == 0)
|
||||
@@ -826,9 +832,10 @@ mmap_error:
|
||||
FREE (tempname);
|
||||
return rv;
|
||||
}
|
||||
j = 0;
|
||||
#endif
|
||||
|
||||
for (j = 0, i = history_length - nelements; i < history_length; i++)
|
||||
for (i = history_length - nelements; i < history_length; i++)
|
||||
{
|
||||
if (history_write_timestamps && the_history[i]->timestamp && the_history[i]->timestamp[0])
|
||||
{
|
||||
@@ -842,7 +849,10 @@ mmap_error:
|
||||
}
|
||||
|
||||
#ifdef HISTORY_USE_MMAP
|
||||
if (msync (buffer, buffer_size, MS_ASYNC) != 0 || munmap (buffer, buffer_size) != 0)
|
||||
/* make sure we unmap the pages even if the sync fails */
|
||||
if (msync (buffer, newsize, MS_ASYNC) != 0)
|
||||
rv = errno;
|
||||
if (munmap (buffer, newsize) != 0 && rv == 0)
|
||||
rv = errno;
|
||||
#else
|
||||
if (write (file, buffer, buffer_size) < 0)
|
||||
|
||||
+2
-2
@@ -205,9 +205,9 @@ rl_tilde_expand (int ignore, int key)
|
||||
end = start;
|
||||
do
|
||||
end++;
|
||||
while (whitespace (rl_line_buffer[end]) == 0 && end < rl_end);
|
||||
while (end < rl_end && whitespace (rl_line_buffer[end]) == 0);
|
||||
|
||||
if (whitespace (rl_line_buffer[end]) || end >= rl_end)
|
||||
if (end >= rl_end || whitespace (rl_line_buffer[end]))
|
||||
end--;
|
||||
|
||||
/* If the first character of the current word is a tilde, perform
|
||||
|
||||
Reference in New Issue
Block a user