Install some bug fixes from Brian Fox.

This commit is contained in:
John Gilmore 1992-03-25 01:07:32 +00:00
parent 4f301966c2
commit daf45683dc
2 changed files with 46 additions and 28 deletions

View File

@ -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)
* Makefile.in: remove FIXME's on info and install-info targets.

View File

@ -1,24 +1,23 @@
/* 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
routines for managing the text of previously typed lines.
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
the Free Software Foundation; either version 1, or (at your option)
any later version.
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
The Library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
The Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
675 Mass Ave, Cambridge, MA 02139, USA. */
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* The goal is to make the implementation transparent, so that you
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 <stdio.h>
#include <errno.h>
#include <sys/types.h>
#ifndef NO_SYS_FILE
#include <sys/file.h>
#endif
#include <sys/stat.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"
#ifndef savestring
@ -591,10 +585,9 @@ history_do_write (filename, nelements, overwrite)
int nelements, overwrite;
{
extern int errno;
register int i;
register int i, j;
char *output = history_filename (filename);
int file, mode;
char cr = '\n';
if (overwrite)
mode = O_WRONLY | O_CREAT | O_TRUNC;
@ -607,13 +600,30 @@ history_do_write (filename, nelements, overwrite)
if (nelements > history_length)
nelements = history_length;
for (i = history_length - nelements; i < history_length; i++)
{
if (write (file, the_history[i]->line, strlen (the_history[i]->line)) < 0)
break;
if (write (file, &cr, 1) < 0)
break;
}
/* 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++)
{
strcpy (buffer + j, the_history[i]->line);
j += strlen (the_history[i]->line);
buffer[j++] = '\n';
}
write (file, buffer, buffer_size);
free (buffer);
}
close (file);
return (0);