ex (not vi) can now edit files with lines of arbitrary length.

This commit is contained in:
Gunnar Ritter
2005-08-04 15:23:39 +00:00
parent 2b70d8e5eb
commit b0ff1d6b3e
26 changed files with 183 additions and 105 deletions

View File

@@ -73,7 +73,7 @@
#ifndef lint
#ifdef DOSCCS
static char sccsid[] = "@(#)ex_subr.c 1.37 (gritter) 2/15/05";
static char sccsid[] = "@(#)ex_subr.c 1.39 (gritter) 8/4/05";
#endif
#endif
@@ -1151,3 +1151,39 @@ safecat(char *s1, const char *s2, size_t max, char *msg, ...)
/*NOTREACHED*/
return NULL;
}
/*
* Grow the line and generic buffers.
*/
void
grow(char *msg, char **tolb0, char **tolb1, char **togb0, char **togb1)
{
char *nlb, *ngb = NULL;
if ((nlb = realloc(linebuf, LBSIZE + 4096)) == NULL ||
(ngb = realloc(genbuf, 2 * (LBSIZE + 4096))) == NULL) {
synced();
error(msg);
}
if (tolb0)
*tolb0 += nlb - linebuf;
if (tolb1)
*tolb1 += nlb - linebuf;
if (togb0)
*togb0 += ngb - genbuf;
if (togb1)
*togb1 += ngb - genbuf;
linebuf = nlb;
genbuf = ngb;
LBSIZE += 4096;
}
void *
smalloc(size_t size)
{
void *vp;
if ((vp = malloc(size)) == NULL)
error("no space");
return vp;
}