/* 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.
if (home == 0)
{
+#if 0
home = ".";
home_len = 1;
+#else
+ return (NULL);
+#endif
}
else
home_len = strlen (home);
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;
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. */
FREE (buffer);
- free (filename);
+ xfree (filename);
return rv;
}
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);
#else
if (write (file, buffer, buffer_size) < 0)
rv = errno;
- free (buffer);
+ xfree (buffer);
#endif
}