diff options
author | Andrey A. Chernov <ache@FreeBSD.org> | 1997-06-07 12:17:44 +0000 |
---|---|---|
committer | Andrey A. Chernov <ache@FreeBSD.org> | 1997-06-07 12:17:44 +0000 |
commit | 933f368172458b72e1a1e36f6cab3d618e9595f4 (patch) | |
tree | 273a40857d601fa83d190bfbfb6ae23041a7743d /contrib/libreadline/histfile.c | |
parent | b29a08bf10533847eec8595efaffc02857b5b353 (diff) | |
download | src-933f368172458b72e1a1e36f6cab3d618e9595f4.tar.gz src-933f368172458b72e1a1e36f6cab3d618e9595f4.zip |
Virgin import of readline-2.1, unneded docs deleted
Notes
Notes:
svn path=/vendor/libreadline/dist/; revision=26497
Diffstat (limited to 'contrib/libreadline/histfile.c')
-rw-r--r-- | contrib/libreadline/histfile.c | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/contrib/libreadline/histfile.c b/contrib/libreadline/histfile.c index 355d46ea50f7..c3de134a9694 100644 --- a/contrib/libreadline/histfile.c +++ b/contrib/libreadline/histfile.c @@ -52,6 +52,16 @@ # include <strings.h> #endif /* !HAVE_STRING_H */ +#if defined (__EMX__) +# ifndef O_BINARY +# define O_BINARY 0 +# endif +#else /* !__EMX__ */ + /* If we're not compiling for __EMX__, we don't want this at all. Ever. */ +# undef O_BINARY +# define O_BINARY 0 +#endif /* !__EMX__ */ + #include <errno.h> #if !defined (errno) extern int errno; @@ -60,6 +70,9 @@ extern int errno; #include "history.h" #include "histlib.h" +/* Functions imported from shell.c */ +extern char *get_env_value (); + extern char *xmalloc (), *xrealloc (); /* Return the string that should be used in the place of this @@ -77,7 +90,7 @@ history_filename (filename) if (return_val) return (return_val); - home = getenv ("HOME"); + home = get_env_value ("HOME"); if (home == 0) { @@ -121,7 +134,7 @@ read_history_range (filename, from, to) struct stat finfo; input = history_filename (filename); - file = open (input, O_RDONLY, 0666); + file = open (input, O_RDONLY|O_BINARY, 0666); if ((file < 0) || (fstat (file, &finfo) == -1)) goto error_and_exit; @@ -194,11 +207,12 @@ history_truncate_file (fname, lines) { register int i; int file, chars_read; - char *buffer = (char *)NULL, *filename; + char *buffer, *filename; struct stat finfo; + buffer = (char *)NULL; filename = history_filename (fname); - file = open (filename, O_RDONLY, 0666); + file = open (filename, O_RDONLY|O_BINARY, 0666); if (file == -1 || fstat (file, &finfo) == -1) goto truncate_exit; @@ -232,7 +246,7 @@ history_truncate_file (fname, lines) /* Write only if there are more lines in the file than we want to truncate to. */ - if (i && ((file = open (filename, O_WRONLY|O_TRUNC, 0666)) != -1)) + if (i && ((file = open (filename, O_WRONLY|O_TRUNC|O_BINARY, 0666)) != -1)) { write (file, buffer + i, finfo.st_size - i); close (file); @@ -255,10 +269,11 @@ history_do_write (filename, nelements, overwrite) int nelements, overwrite; { register int i; - char *output = history_filename (filename); + char *output; int file, mode; - mode = overwrite ? O_WRONLY | O_CREAT | O_TRUNC : O_WRONLY | O_APPEND; + mode = overwrite ? O_WRONLY|O_CREAT|O_TRUNC|O_BINARY : O_WRONLY|O_APPEND|O_BINARY; + output = history_filename (filename); if ((file = open (output, mode, 0666)) == -1) { |