X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=lib%2Freadline%2Fhistfile.c;h=30a618247f1ec8a7be1c9202ae84224c7e8d5d5e;hb=495aee441b75276e38c75694ccb455bb6463fdb9;hp=a75fc16bf9d6d7a5e7c22e0f6b994c8e06cad143;hpb=30d188c2932d6ef609d894fefeb7e7b03ccff463;p=platform%2Fupstream%2Fbash.git 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 }