* The screen buffers for visual mode are now dynamically allocated, so

vi usually does not return to ex mode with "screen too large" when the
  terminal is resized on a large monitor anymore.
This commit is contained in:
Gunnar Ritter 2005-08-04 12:09:59 +00:00
parent c69b1ee369
commit 2b70d8e5eb
15 changed files with 72 additions and 57 deletions

View File

@ -1,3 +1,8 @@
Release ...
* The screen buffers for visual mode are now dynamically allocated, so
vi usually does not return to ex mode with "screen too large" when the
terminal is resized on a large monitor anymore.
Release 3/25/05
* vi no longer dies with a segmentation fault if a line does not fit on the
screen after an insertion.

8
README
View File

@ -23,9 +23,7 @@ How to build
First look at the Makefile and change the settings there to match your
build environment. Explanations are provided directly in this file.
You can tune the sizes of some internal buffers by editing config.h. In
particular, you will have to raise the size of the 'TUBE' constants if
you wish to use really large-sized terminals.
You can tune the sizes of some internal buffers by editing config.h.
Then type 'make' and 'make install'.
@ -139,7 +137,7 @@ the erase key once after entering a multibyte character will result in an
incomplete byte sequence.
Gunnar Ritter 2/20/05
Gunnar Ritter 8/4/05
Freiburg i. Br.
Germany
<Gunnar.Ritter@pluto.uni-freiburg.de>
<gunnarr@acm.org>

View File

@ -70,35 +70,13 @@
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @(#)config.h 1.12 (gritter) 2/19/05
* @(#)config.h 1.13 (gritter) 8/4/05
*/
/*
* Configurable settings for the ex editor.
*/
/*
* Maximum screen size in visual mode.
*
* Because the routine "alloca" is not portable, TUBESIZE
* bytes are allocated on the stack each time you go into visual
* and then never freed by the system. Thus if you have no terminals
* which are larger than 24 * 80 you may well want to make TUBESIZE
* smaller. TUBECOLS should stay at 160 at least since this defines
* the maximum length of opening on hardcopies and allows two lines
* of open on terminals like adm3's (glass tty's) where it switches
* to pseudo hardcopy mode when a line gets longer than 80 characters.
*/
#ifndef VMUNIX
#define TUBELINES 70 /* Number of screen lines for visual */
#define TUBECOLS 160 /* Number of screen columns for visual */
#define TUBESIZE 6000 /* Maximum screen size for visual */
#else /* VMUNIX */
#define TUBELINES 100
#define TUBECOLS 160
#define TUBESIZE 16000
#endif /* VMUNIX */
/*
* Various buffer sizes.
*/

2
ex.h
View File

@ -72,7 +72,7 @@
*
* from ex.h 7.7.1.1 (Berkeley) 8/12/86
*
* @(#)ex.h 1.53 (gritter) 2/17/05
* Sccsid @(#)ex.h 1.54 (gritter) 8/4/05
*/
/*

View File

@ -1,5 +1,5 @@
#
# Sccsid @(#)ex.spec 1.7 (gritter) 1/22/05
# Sccsid @(#)ex.spec 1.8 (gritter) 7/12/05
#
Summary: A port of the traditional ex/vi editors
Name: ex
@ -8,7 +8,7 @@ Release: 1
License: BSD
Source: %{name}-%{version}.tar.bz2
Group: System Environment/Base
Vendor: Gunnar Ritter <Gunnar.Ritter@pluto.uni-freiburg.de>
Vendor: Gunnar Ritter <gunnarr@acm.org>
URL: <http://ex-vi.sourceforge.net>
BuildRoot: %{_tmppath}/%{name}-root

View File

@ -72,7 +72,7 @@
*
* from ex_argv.h 7.3 (Berkeley) 5/31/85
*
* @(#)ex_argv.h 1.8 (gritter) 11/23/04
* Sccsid @(#)ex_argv.h 1.9 (gritter) 8/4/05
*/
/*

View File

@ -70,7 +70,8 @@
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* @(#)ex_proto.h 1.28 (gritter) 2/19/05
*
* Sccsid @(#)ex_proto.h 1.29 (gritter) 8/4/05
*/
/*

View File

@ -72,7 +72,7 @@
*
* from ex_re.h 7.3 (Berkeley) 5/31/85
*
* @(#)ex_re.h 1.22 (gritter) 2/19/05
* Sccsid @(#)ex_re.h 1.23 (gritter) 8/4/05
*/
/*

View File

@ -72,7 +72,7 @@
*
* from ex_temp.h 7.4 (Berkeley) 5/31/85
*
* @(#)ex_temp.h 1.8 (gritter) 1/26/02
* Sccsid @(#)ex_temp.h 1.9 (gritter) 8/4/05
*/
/*

View File

@ -73,7 +73,7 @@
#ifndef lint
#ifdef DOSCCS
static char sccsid[] = "@(#)ex_tty.c 1.29 (gritter) 2/17/05";
static char sccsid[] = "@(#)ex_tty.c 1.30 (gritter) 8/4/05";
#endif
#endif
@ -300,8 +300,6 @@ setsize(void)
i = TLINES;
if (TLINES <= 5)
TLINES = 24;
if (TLINES > TUBELINES)
TLINES = TUBELINES;
l = TLINES;
if (ospeed < B1200)
l = 9; /* including the message line at the bottom */

View File

@ -72,7 +72,7 @@
*
* from ex_tty.h 7.5.1 (2.11BSD GTE) 12/9/94
*
* @(#)ex_tty.h 1.13 (gritter) 12/1/04
* Sccsid @(#)ex_tty.h 1.14 (gritter) 8/4/05
*/
#include "libterm/libterm.h"

View File

@ -72,7 +72,7 @@
*
* from ex_tune.h 7.8.1 (2.11BSD) 1996/10/23
*
* @(#)ex_tune.h 1.12 (gritter) 12/1/04
* Sccsid @(#)ex_tune.h 1.13 (gritter) 8/4/05
*/
/*

40
ex_v.c
View File

@ -73,7 +73,7 @@
#ifndef lint
#ifdef DOSCCS
static char sccsid[] = "@(#)ex_v.c 1.17 (gritter) 11/27/04";
static char sccsid[] = "@(#)ex_v.c 1.18 (gritter) 8/4/05";
#endif
#endif
@ -126,20 +126,41 @@ static char sccsid[] = "@(#)ex_v.c 1.17 (gritter) 11/27/04";
*/
JMP_BUF venv;
static cell *atube;
/*
* Determine and set the size for visual mode buffers.
*/
static void
tubesizes(void)
{
TUBELINES = TLINES;
/*
* TUBECOLS should stay at 160 at least since this defines the
* maximum length of opening on hardcopies and allows two lines
* of open on terminals like adm3's (glass tty's) where it
* switches to pseudo hardcopy mode when a line gets longer
* than 80 characters.
*/
TUBECOLS = TCOLUMNS < 160 ? 160 : TCOLUMNS;
TUBESIZE = TLINES * TCOLUMNS;
free(vlinfo);
free(vtube);
free(atube);
vlinfo = malloc((TUBELINES+2) * sizeof *vlinfo);
vtube = malloc(TUBELINES * sizeof *vtube);
atube = malloc((TUBESIZE + LBSIZE) * sizeof *atube);
if (vlinfo == NULL || vtube == NULL || atube == NULL)
error("Screen too large");
}
/*
* Enter open mode
*/
#ifdef u370
cell atube[TUBESIZE+LBSIZE];
#endif
void
oop(void)
{
register char *ic;
#ifndef u370
cell atube[TUBESIZE + LBSIZE];
#endif
struct termios f; /* mjm: was register */
int resize;
@ -150,6 +171,7 @@ oop(void)
inopen = 0;
addr1 = addr2 = dot;
}
tubesizes();
#ifdef SIGWINCH
signal(SIGWINCH, onwinch);
#endif
@ -258,9 +280,6 @@ void
vop(void)
{
register int c;
#ifndef u370
cell atube[TUBESIZE + LBSIZE];
#endif
struct termios f; /* mjm: was register */
int resize;
@ -299,6 +318,7 @@ toopen:
inopen = 0;
addr1 = addr2 = dot;
}
tubesizes();
#ifdef SIGWINCH
signal(SIGWINCH, onwinch);
#endif

View File

@ -70,12 +70,12 @@
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Sccsid @(#)ex_version.c 1.134 (gritter) 6/26/05
* Sccsid @(#)ex_version.c 1.136 (gritter) 8/4/05
*/
#include "ex.h"
static char *versionstring = "@(#)Version 4.0 (gritter) 6/26/05";
static char *versionstring = "@(#)Version 4.0 (gritter) 8/4/05";
void
printver(void)
@ -91,7 +91,9 @@ printver(void)
/* SLIST */
/*
ex.c:static char sccsid[] = "@(#)ex.c 1.36 (gritter) 2/13/05";
ex.h: * Sccsid @(#)ex.h 1.54 (gritter) 8/4/05
ex_addr.c:static char sccsid[] = "@(#)ex_addr.c 1.10 (gritter) 2/17/05";
ex_argv.h: * Sccsid @(#)ex_argv.h 1.9 (gritter) 8/4/05
ex_cmds.c:static char sccsid[] = "@(#)ex_cmds.c 1.22 (gritter) 2/18/05";
ex_cmds2.c:static char sccsid[] = "@(#)ex_cmds2.c 1.18 (gritter) 2/17/05";
ex_cmdsub.c:static char sccsid[] = "@(#)ex_cmdsub.c 1.29 (gritter) 2/17/05";
@ -99,17 +101,23 @@ ex_data.c:static char sccsid[] = "@(#)ex_data.c 1.14 (gritter) 11/23/04";
ex_extern.c:static char sccsid[] = "@(#)ex_extern.c 1.6 (gritter) 11/23/04";
ex_get.c:static char sccsid[] = "@(#)ex_get.c 1.17 (gritter) 2/17/05";
ex_io.c:static char sccsid[] = "@(#)ex_io.c 1.40 (gritter) 2/17/05";
ex_proto.h: * Sccsid @(#)ex_proto.h 1.29 (gritter) 8/4/05
ex_put.c:static char sccsid[] = "@(#)ex_put.c 1.32 (gritter) 2/17/05";
ex_re.c:static char sccsid[] = "@(#)ex_re.c 1.56 (gritter) 3/25/05";
ex_re.h: * Sccsid @(#)ex_re.h 1.23 (gritter) 8/4/05
ex_set.c:static char sccsid[] = "@(#)ex_set.c 1.11 (gritter) 11/24/04";
ex_subr.c:static char sccsid[] = "@(#)ex_subr.c 1.37 (gritter) 2/15/05";
ex_tagio.c:static char sccsid[] = "@(#)ex_tagio.c 1.11 (gritter) 11/27/04";
ex_temp.c:static char sccsid[] = "@(#)ex_temp.c 1.24 (gritter) 11/24/04";
ex_tty.c:static char sccsid[] = "@(#)ex_tty.c 1.29 (gritter) 2/17/05";
ex_temp.h: * Sccsid @(#)ex_temp.h 1.9 (gritter) 8/4/05
ex_tty.c:static char sccsid[] = "@(#)ex_tty.c 1.30 (gritter) 8/4/05";
ex_tty.h: * Sccsid @(#)ex_tty.h 1.14 (gritter) 8/4/05
ex_tune.h: * Sccsid @(#)ex_tune.h 1.13 (gritter) 8/4/05
ex_unix.c:static char sccsid[] = "@(#)ex_unix.c 1.16 (gritter) 11/23/04";
ex_v.c:static char sccsid[] = "@(#)ex_v.c 1.17 (gritter) 11/27/04";
ex_v.c:static char sccsid[] = "@(#)ex_v.c 1.18 (gritter) 8/4/05";
ex_vadj.c:static char sccsid[] = "@(#)ex_vadj.c 1.11 (gritter) 3/4/05";
ex_vget.c:static char sccsid[] = "@(#)ex_vget.c 1.29 (gritter) 2/15/05";
ex_vis.h: * Sccsid @(#)ex_vis.h 1.20 (gritter) 8/4/05
ex_vmain.c:static char sccsid[] = "@(#)ex_vmain.c 1.29 (gritter) 2/17/05";
ex_voper.c:static char sccsid[] = "@(#)ex_voper.c 1.27 (gritter) 2/15/05";
ex_vops.c:static char sccsid[] = "@(#)ex_vops.c 1.26 (gritter) 1/13/05";

View File

@ -72,7 +72,7 @@
*
* from ex_vis.h 7.4 (Berkeley) 5/31/85
*
* @(#)ex_vis.h 1.18 (gritter) 3/24/05
* Sccsid @(#)ex_vis.h 1.20 (gritter) 8/4/05
*/
/*
@ -99,6 +99,13 @@ var enum {
HARDOPEN = 3
} bastate, state;
/*
* Maximum screen size in visual mode, dynamically set as needed.
*/
var short TUBELINES;
var short TUBECOLS;
var short TUBESIZE;
/*
* The screen in visual and crtopen is of varying size; the basic
* window has top basWTOP and basWLINES lines are thereby implied.
@ -140,7 +147,7 @@ struct vlinfo {
short vdepth; /* Depth of displayed line */ /*mjm: was char */
short vflags; /* Is line potentially dirty ? */
};
var struct vlinfo vlinfo[TUBELINES + 2];
var struct vlinfo *vlinfo;
#define DEPTH(c) (vlinfo[c].vdepth)
#define LINE(c) (vlinfo[c].vliny)
@ -170,7 +177,7 @@ var short vcnt;
* data itself. It is also rearranged during insert mode across line
* boundaries to make incore work easier.
*/
var cell *vtube[TUBELINES];
var cell **vtube;
var cell *vtube0;
/*