mirror of
https://github.com/tildeclub/ex-vi.git
synced 2026-06-21 19:39:24 +00:00
ex (not vi) can now edit files with lines of arbitrary length.
This commit is contained in:
38
ex_subr.c
38
ex_subr.c
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user