summaryrefslogtreecommitdiff
path: root/gnu/lib/libreadline/histfile.c
diff options
context:
space:
mode:
authorBob Beck <beck@cvs.openbsd.org>2003-05-10 21:40:01 +0000
committerBob Beck <beck@cvs.openbsd.org>2003-05-10 21:40:01 +0000
commite5ec5dcb85d7417669bf035105a45f538f146525 (patch)
treeaf34ea162aad1e34381c11da590e8a12b6d75a9c /gnu/lib/libreadline/histfile.c
parent6f41679e5b646ab8a07115715935afb174abffae (diff)
Back out libreadline changes, this breaks static build (I.E. vax).
changes are nontrivial to fix. Will return when static build works.
Diffstat (limited to 'gnu/lib/libreadline/histfile.c')
-rw-r--r--gnu/lib/libreadline/histfile.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/gnu/lib/libreadline/histfile.c b/gnu/lib/libreadline/histfile.c
index ad200d3051b..0b3135d2a6b 100644
--- a/gnu/lib/libreadline/histfile.c
+++ b/gnu/lib/libreadline/histfile.c
@@ -88,7 +88,6 @@ history_filename (filename)
{
char *return_val, *home;
int home_len;
- char dot;
return_val = filename ? savestring (filename) : (char *)NULL;
@@ -103,13 +102,15 @@ history_filename (filename)
}
home_len = strlen (home);
+ return_val = xmalloc (2 + home_len + 8); /* strlen(".history") == 8 */
+ strcpy (return_val, home);
+ return_val[home_len] = '/';
#if defined (__MSDOS__)
- dot = '_';
+ strcpy (return_val + home_len + 1, "_history");
#else
- dot = '.';
+ strcpy (return_val + home_len + 1, ".history");
#endif
- if (asprintf(&return_val, "%s/%c%s", home, dot, "history") == -1)
- memory_error_and_abort("asprintf");
+
return (return_val);
}
@@ -334,6 +335,7 @@ history_do_write (filename, nelements, overwrite)
Suggested by Peter Ho (peter@robosts.oxford.ac.uk). */
{
HIST_ENTRY **the_history; /* local */
+ register int j;
int buffer_size;
char *buffer;
@@ -344,12 +346,12 @@ history_do_write (filename, nelements, overwrite)
/* Allocate the buffer, and fill it. */
buffer = xmalloc (buffer_size);
- buffer[0] = '\0';
- for (i = history_length - nelements; i < history_length; i++)
+ for (j = 0, i = history_length - nelements; i < history_length; i++)
{
- strlcat (buffer, the_history[i]->line, buffer_size);
- strlcat (buffer, "\n", buffer_size);
+ strcpy (buffer + j, the_history[i]->line);
+ j += strlen (the_history[i]->line);
+ buffer[j++] = '\n';
}
write (file, buffer, buffer_size);