Install some bug fixes from Brian Fox.
This commit is contained in:
parent
4f301966c2
commit
daf45683dc
2 changed files with 46 additions and 28 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
Mon Feb 10 01:41:35 1992 Brian Fox (bfox at gnuwest.fsf.org)
|
||||||
|
|
||||||
|
* history.c (history_do_write) Build a buffer of all of the lines
|
||||||
|
to write and write them in one fell swoop (lower overhead than
|
||||||
|
calling write () for each line). Suggested by Peter Ho.
|
||||||
|
|
||||||
|
* vi_mode.c (rl_vi_subst) Don't forget to end the undo group.
|
||||||
|
|
||||||
Sat Mar 7 00:15:36 1992 K. Richard Pixley (rich@rtl.cygnus.com)
|
Sat Mar 7 00:15:36 1992 K. Richard Pixley (rich@rtl.cygnus.com)
|
||||||
|
|
||||||
* Makefile.in: remove FIXME's on info and install-info targets.
|
* Makefile.in: remove FIXME's on info and install-info targets.
|
||||||
|
|
|
@ -1,24 +1,23 @@
|
||||||
/* History.c -- standalone history library */
|
/* History.c -- standalone history library */
|
||||||
|
|
||||||
/* Copyright (C) 1989 Free Software Foundation, Inc.
|
/* Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file contains the GNU History Library (the Library), a set of
|
This file contains the GNU History Library (the Library), a set of
|
||||||
routines for managing the text of previously typed lines.
|
routines for managing the text of previously typed lines.
|
||||||
|
|
||||||
The Library is free software; you can redistribute it and/or modify
|
The Library is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation; either version 1, or (at your option)
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
The Library is distributed in the hope that it will be useful, but
|
The Library is distributed in the hope that it will be useful,
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
The GNU General Public License is often shipped with GNU software, and
|
You should have received a copy of the GNU General Public License
|
||||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
along with this program; if not, write to the Free Software
|
||||||
have a copy of the license, write to the Free Software Foundation,
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||||
675 Mass Ave, Cambridge, MA 02139, USA. */
|
|
||||||
|
|
||||||
/* The goal is to make the implementation transparent, so that you
|
/* The goal is to make the implementation transparent, so that you
|
||||||
don't have to know what data types are used, just what functions
|
don't have to know what data types are used, just what functions
|
||||||
|
@ -33,19 +32,14 @@ static char *xmalloc (), *xrealloc ();
|
||||||
|
|
||||||
#include "sysdep.h"
|
#include "sysdep.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#ifndef NO_SYS_FILE
|
||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
|
#endif
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
#if defined (__GNUC__)
|
|
||||||
# define alloca __builtin_alloca
|
|
||||||
#else
|
|
||||||
# if defined (sparc) || defined (HAVE_ALLOCA_H)
|
|
||||||
# include <alloca.h>
|
|
||||||
# endif /* sparc || HAVE_ALLOCA_H */
|
|
||||||
#endif /* !__GNU_C__ */
|
|
||||||
|
|
||||||
#include "history.h"
|
#include "history.h"
|
||||||
|
|
||||||
#ifndef savestring
|
#ifndef savestring
|
||||||
|
@ -591,10 +585,9 @@ history_do_write (filename, nelements, overwrite)
|
||||||
int nelements, overwrite;
|
int nelements, overwrite;
|
||||||
{
|
{
|
||||||
extern int errno;
|
extern int errno;
|
||||||
register int i;
|
register int i, j;
|
||||||
char *output = history_filename (filename);
|
char *output = history_filename (filename);
|
||||||
int file, mode;
|
int file, mode;
|
||||||
char cr = '\n';
|
|
||||||
|
|
||||||
if (overwrite)
|
if (overwrite)
|
||||||
mode = O_WRONLY | O_CREAT | O_TRUNC;
|
mode = O_WRONLY | O_CREAT | O_TRUNC;
|
||||||
|
@ -607,12 +600,29 @@ history_do_write (filename, nelements, overwrite)
|
||||||
if (nelements > history_length)
|
if (nelements > history_length)
|
||||||
nelements = history_length;
|
nelements = history_length;
|
||||||
|
|
||||||
|
/* Build a buffer of all the lines to write, and write them in one syscall.
|
||||||
|
Suggested by Peter Ho (peter@robosts.oxford.ac.uk). */
|
||||||
|
{
|
||||||
|
register int j = 0;
|
||||||
|
int buffer_size = 0;
|
||||||
|
char *buffer;
|
||||||
|
|
||||||
|
/* Calculate the total number of bytes to write. */
|
||||||
|
for (i = history_length - nelements; i < history_length; i++)
|
||||||
|
buffer_size += 1 + strlen (the_history[i]->line);
|
||||||
|
|
||||||
|
/* Allocate the buffer, and fill it. */
|
||||||
|
buffer = (char *)xmalloc (buffer_size);
|
||||||
|
|
||||||
for (i = history_length - nelements; i < history_length; i++)
|
for (i = history_length - nelements; i < history_length; i++)
|
||||||
{
|
{
|
||||||
if (write (file, the_history[i]->line, strlen (the_history[i]->line)) < 0)
|
strcpy (buffer + j, the_history[i]->line);
|
||||||
break;
|
j += strlen (the_history[i]->line);
|
||||||
if (write (file, &cr, 1) < 0)
|
buffer[j++] = '\n';
|
||||||
break;
|
}
|
||||||
|
|
||||||
|
write (file, buffer, buffer_size);
|
||||||
|
free (buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
close (file);
|
close (file);
|
||||||
|
|
Loading…
Reference in a new issue