aboutsummaryrefslogtreecommitdiffstats
path: root/lib/readline/histfile.c
diff options
context:
space:
mode:
authorSebastian Schmidt <yath@yath.de>2012-04-17 11:23:35 +0200
committerSebastian Schmidt <yath@yath.de>2012-04-17 11:24:20 +0200
commitf4b417c62a4f272c4cf9a074d0f7a3a97201f9db (patch)
treee2196f3b6361e2377c43ab47a3abf17d8f6afd77 /lib/readline/histfile.c
parent791237e44695d2ee123c8a6f665ef074f5fadfbb (diff)
downloadexternal_bash-f4b417c62a4f272c4cf9a074d0f7a3a97201f9db.zip
external_bash-f4b417c62a4f272c4cf9a074d0f7a3a97201f9db.tar.gz
external_bash-f4b417c62a4f272c4cf9a074d0f7a3a97201f9db.tar.bz2
Update to upstream bash 4.2
This upgrades bash to from 4.1-rc to 4.2-release. See CWRU/changelog for changes. Change-Id: I926269c300cf44fa25964b5b375a148fcf11c4b7
Diffstat (limited to 'lib/readline/histfile.c')
-rw-r--r--lib/readline/histfile.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/readline/histfile.c b/lib/readline/histfile.c
index a75fc16..30a6182 100644
--- a/lib/readline/histfile.c
+++ b/lib/readline/histfile.c
@@ -1,6 +1,6 @@
/* histfile.c - functions to manipulate the history file. */
-/* Copyright (C) 1989-2009 Free Software Foundation, Inc.
+/* Copyright (C) 1989-2010 Free Software Foundation, Inc.
This file contains the GNU History Library (History), a set of
routines for managing the text of previously typed lines.
@@ -126,8 +126,12 @@ history_filename (filename)
if (home == 0)
{
+#if 0
home = ".";
home_len = 1;
+#else
+ return (NULL);
+#endif
}
else
home_len = strlen (home);
@@ -179,7 +183,7 @@ read_history_range (filename, from, to)
buffer = last_ts = (char *)NULL;
input = history_filename (filename);
- file = open (input, O_RDONLY|O_BINARY, 0666);
+ file = input ? open (input, O_RDONLY|O_BINARY, 0666) : -1;
if ((file < 0) || (fstat (file, &finfo) == -1))
goto error_and_exit;
@@ -314,7 +318,7 @@ history_truncate_file (fname, lines)
buffer = (char *)NULL;
filename = history_filename (fname);
- file = open (filename, O_RDONLY|O_BINARY, 0666);
+ file = filename ? open (filename, O_RDONLY|O_BINARY, 0666) : -1;
rv = 0;
/* Don't try to truncate non-regular files. */
@@ -413,7 +417,7 @@ history_truncate_file (fname, lines)
FREE (buffer);
- free (filename);
+ xfree (filename);
return rv;
}
@@ -436,9 +440,10 @@ history_do_write (filename, nelements, overwrite)
mode = overwrite ? O_WRONLY|O_CREAT|O_TRUNC|O_BINARY : O_WRONLY|O_APPEND|O_BINARY;
#endif
output = history_filename (filename);
+ file = output ? open (output, mode, 0600) : -1;
rv = 0;
- if ((file = open (output, mode, 0600)) == -1)
+ if (file == -1)
{
FREE (output);
return (errno);
@@ -515,7 +520,7 @@ mmap_error:
#else
if (write (file, buffer, buffer_size) < 0)
rv = errno;
- free (buffer);
+ xfree (buffer);
#endif
}