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

@ -2,6 +2,7 @@ Release ...
* The screen buffers for visual mode are now dynamically allocated, so * 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 vi usually does not return to ex mode with "screen too large" when the
terminal is resized on a large monitor anymore. terminal is resized on a large monitor anymore.
* ex (not vi) can now edit files with lines of arbitrary length.
Release 3/25/05 Release 3/25/05
* vi no longer dies with a segmentation fault if a line does not fit on the * vi no longer dies with a segmentation fault if a line does not fit on the

13
ex.c
View File

@ -77,7 +77,7 @@ char *copyright =
"@(#) Copyright (c) 1980 Regents of the University of California.\n\ "@(#) Copyright (c) 1980 Regents of the University of California.\n\
All rights reserved.\n"; All rights reserved.\n";
static char sccsid[] = "@(#)ex.c 1.36 (gritter) 2/13/05"; static char sccsid[] = "@(#)ex.c 1.37 (gritter) 8/4/05";
#endif /* DOSCCS */ #endif /* DOSCCS */
#endif /* !lint */ #endif /* !lint */
@ -294,6 +294,13 @@ main(register int ac, register char *av[])
poolsbrk(0); poolsbrk(0);
#endif #endif
/*
* Initialize the primary buffers which were originally static.
* NOTE: Most of this must be repeated in ex_recover.c.
*/
linebuf = calloc(LBSIZE = BUFSIZ<4096?4096:BUFSIZ, sizeof *linebuf);
genbuf = calloc(MAXBSIZE, sizeof *genbuf);
/* /*
* Immediately grab the tty modes so that we wont * Immediately grab the tty modes so that we wont
* get messed up if an interrupt comes in quickly. * get messed up if an interrupt comes in quickly.
@ -588,9 +595,9 @@ argend:
else { else {
globp = 0; globp = 0;
if ((cp = getenv("HOME")) != 0 && *cp) { if ((cp = getenv("HOME")) != 0 && *cp) {
safecat(safecp(genbuf, cp, sizeof genbuf, safecat(safecp(genbuf, cp, MAXBSIZE,
"$HOME too long"), "$HOME too long"),
"/.exrc", sizeof genbuf, "/.exrc", MAXBSIZE,
"$HOME too long"); "$HOME too long");
if (iownit(genbuf)) if (iownit(genbuf))
source(genbuf, 1); source(genbuf, 1);

12
ex.h
View File

@ -72,7 +72,7 @@
* *
* from ex.h 7.7.1.1 (Berkeley) 8/12/86 * from ex.h 7.7.1.1 (Berkeley) 8/12/86
* *
* Sccsid @(#)ex.h 1.54 (gritter) 8/4/05 * Sccsid @(#)ex.h 1.55 (gritter) 8/4/05
*/ */
/* /*
@ -276,9 +276,8 @@ typedef sigjmp_buf JMP_BUF;
#define SETJMP(a) sigsetjmp(a, 1) #define SETJMP(a) sigsetjmp(a, 1)
#define LONGJMP(a, b) siglongjmp(a, b) #define LONGJMP(a, b) siglongjmp(a, b)
#ifndef MAXBSIZE #undef MAXBSIZE
#define MAXBSIZE 8192 /* Same as in 4.2BSD */ #define MAXBSIZE (2*LBSIZE)
#endif
#include "ex_tune.h" #include "ex_tune.h"
#include "ex_vars.h" #include "ex_vars.h"
@ -387,7 +386,7 @@ var short erfile; /* Error message file unit */
var line *fendcore; /* First address in line pointer space */ var line *fendcore; /* First address in line pointer space */
var char file[FNSIZE]; /* Working file name */ var char file[FNSIZE]; /* Working file name */
var bool fixedzero; /* zero file size was fixed (for visual) */ var bool fixedzero; /* zero file size was fixed (for visual) */
var char genbuf[MAXBSIZE]; /* Working buffer when manipulating linebuf */ var char *genbuf; /* Working buffer when manipulating linebuf */
var bool hush; /* Command line option - was given, hush up! */ var bool hush; /* Command line option - was given, hush up! */
var char *globp; /* (Untyped) input string to command mode */ var char *globp; /* (Untyped) input string to command mode */
var bool holdcm; /* Don't cursor address */ var bool holdcm; /* Don't cursor address */
@ -403,7 +402,8 @@ var bool laste; /* Last command was an "e" (or "rec") */
var char lastmac; /* Last macro called for ** */ var char lastmac; /* Last macro called for ** */
var char lasttag[TAGSIZE]; /* Last argument to a tag command */ var char lasttag[TAGSIZE]; /* Last argument to a tag command */
var char *linebp; /* Used in substituting in \n */ var char *linebp; /* Used in substituting in \n */
var char linebuf[LBSIZE]; /* The primary line buffer */ var char *linebuf; /* The primary line buffer */
var int LBSIZE; /* Size of linebuf */
var bool listf; /* Command should run in list mode */ var bool listf; /* Command should run in list mode */
var line names['z'-'a'+2]; /* Mark registers a-z,' */ var line names['z'-'a'+2]; /* Mark registers a-z,' */
var int notecnt; /* Count for notify (to visual from cmd) */ var int notecnt; /* Count for notify (to visual from cmd) */

View File

@ -73,7 +73,7 @@
#ifndef lint #ifndef lint
#ifdef DOSCCS #ifdef DOSCCS
static char sccsid[] = "@(#)ex_addr.c 1.10 (gritter) 2/17/05"; static char sccsid[] = "@(#)ex_addr.c 1.11 (gritter) 8/4/05";
#endif #endif
#endif /* not lint */ #endif /* not lint */

View File

@ -73,7 +73,7 @@
#ifndef lint #ifndef lint
#ifdef DOSCCS #ifdef DOSCCS
static char sccsid[] = "@(#)ex_cmdsub.c 1.29 (gritter) 2/17/05"; static char sccsid[] = "@(#)ex_cmdsub.c 1.31 (gritter) 8/4/05";
#endif #endif
#endif #endif
@ -281,7 +281,7 @@ void
join(int c) join(int c)
{ {
register line *a1; register line *a1;
register char *cp, *cp1; char *cp, *cp1;
cp = genbuf; cp = genbuf;
*cp = 0; *cp = 0;
@ -301,8 +301,9 @@ join(int c)
} }
while (*cp++ = *cp1++) while (*cp++ = *cp1++)
if (cp > &genbuf[LBSIZE-2]) if (cp > &genbuf[LBSIZE-2])
error(catgets(catd, 1, 40, grow(
"Line overflow|Result line of join would be too long")); "Line overflow|Result line of join would be too long",
&cp1, NULL, &cp, NULL);
cp--; cp--;
} }
strcLIN(genbuf); strcLIN(genbuf);
@ -477,7 +478,7 @@ pragged(int kill)
getline(dol[1]); getline(dol[1]);
if (kill) if (kill)
strcLIN(pkill[0]); strcLIN(pkill[0]);
safecp(gp, linebuf, sizeof genbuf - (gp - genbuf), "Line too long"); safecp(gp, linebuf, MAXBSIZE - (gp - genbuf), "Line too long");
strcLIN(genbuf); strcLIN(genbuf);
putmark(dol+1); putmark(dol+1);
undkind = UNDCHANGE; undkind = UNDCHANGE;
@ -495,7 +496,7 @@ void
shift(int c, int cnt) shift(int c, int cnt)
{ {
register line *addr; register line *addr;
register char *cp = NULL; char *cp = NULL;
char *dp; char *dp;
register int i; register int i;
@ -534,8 +535,9 @@ shift(int c, int cnt)
#endif #endif
} }
if (cp + strlen(dp = vpastwh(linebuf)) >= &genbuf[LBSIZE - 2]) if (cp + strlen(dp = vpastwh(linebuf)) >= &genbuf[LBSIZE - 2])
error(catgets(catd, 1, 45, grow(
"Line too long|Result line after shift would be too long")); "Line too long|Result line after shift would be too long",
&dp, NULL, &cp, NULL);
CP(cp, dp); CP(cp, dp);
strcLIN(genbuf); strcLIN(genbuf);
putmark(addr); putmark(addr);
@ -562,9 +564,9 @@ tagfind(bool quick)
struct stat sbuf; struct stat sbuf;
char *savefirstpat = NULL; char *savefirstpat = NULL;
int ofailed; int ofailed;
char *ft_iofbuf = NULL;
#ifdef FASTTAG #ifdef FASTTAG
int ft_iof; int ft_iof;
char ft_iofbuf[MAXBSIZE];
off_t mid; /* assumed byte offset */ off_t mid; /* assumed byte offset */
off_t top, bot; /* length of tag file */ off_t top, bot; /* length of tag file */
#endif #endif
@ -600,6 +602,9 @@ badtag:
*/ */
safecp(tagfbuf, svalue(TAGS), sizeof tagfbuf, "Tag too long"); safecp(tagfbuf, svalue(TAGS), sizeof tagfbuf, "Tag too long");
fne = tagfbuf - 1; fne = tagfbuf - 1;
#ifdef FASTTAG
ft_iofbuf = smalloc(MAXBSIZE);
#endif
while (fne) { while (fne) {
fn = ++fne; fn = ++fne;
while (*fne && *fne != ' ') while (*fne && *fne != ' ')
@ -646,10 +651,10 @@ badtag:
tseek(ft_iof, mid); tseek(ft_iof, mid);
if (mid > 0) /* to get first tag in file to work */ if (mid > 0) /* to get first tag in file to work */
/* scan to next \n */ /* scan to next \n */
if(tgets(linebuf, sizeof linebuf, ft_iof)==0) if(tgets(linebuf, LBSIZE, ft_iof)==0)
goto goleft; goto goleft;
/* get the line itself */ /* get the line itself */
if(tgets(linebuf, sizeof linebuf, ft_iof)==0) if(tgets(linebuf, LBSIZE, ft_iof)==0)
goto goleft; goto goleft;
#ifdef TDEBUG #ifdef TDEBUG
printf("tag: %o %o %o %s\n", bot, mid, top, linebuf); printf("tag: %o %o %o %s\n", bot, mid, top, linebuf);
@ -687,6 +692,7 @@ goleft:
cp++; cp++;
if (!*cp) if (!*cp)
badtags: badtags:
free(ft_iofbuf);
serror(catgets(catd, 1, 48, serror(catgets(catd, 1, 48,
"%s: Bad tags file entry"), lasttag); "%s: Bad tags file entry"), lasttag);
lp = filebuf; lp = filebuf;
@ -720,9 +726,11 @@ badtags:
/* Different file. Do autowrite & get it. */ /* Different file. Do autowrite & get it. */
if (!quick) { if (!quick) {
ckaw(); ckaw();
if (chng && dol > zero) if (chng && dol > zero) {
free(ft_iofbuf);
error(catgets(catd, 1, 49, error(catgets(catd, 1, 49,
"No write@since last change (:tag! overrides)")); "No write@since last change (:tag! overrides)"));
}
} }
oglobp = globp; oglobp = globp;
strcpy(cmdbuf2, "e! "); strcpy(cmdbuf2, "e! ");
@ -767,6 +775,7 @@ badtags:
} else } else
tflag = 0; tflag = 0;
} }
free(ft_iofbuf);
return; return;
} /* end of "for each tag in file" */ } /* end of "for each tag in file" */
@ -779,6 +788,7 @@ badtags:
close(io); close(io);
#endif #endif
} /* end of "for each file in path" */ } /* end of "for each file in path" */
free(ft_iofbuf);
if (tfcount <= 0) if (tfcount <= 0)
error(catgets(catd, 1, 50, "No tags file")); error(catgets(catd, 1, 50, "No tags file"));
else else

View File

@ -73,7 +73,7 @@
#ifndef lint #ifndef lint
#ifdef DOSCCS #ifdef DOSCCS
static char sccsid[] = "@(#)ex_get.c 1.17 (gritter) 2/17/05"; static char sccsid[] = "@(#)ex_get.c 1.18 (gritter) 8/4/05";
#endif #endif
#endif #endif

10
ex_io.c
View File

@ -73,7 +73,7 @@
#ifndef lint #ifndef lint
#ifdef DOSCCS #ifdef DOSCCS
static char sccsid[] = "@(#)ex_io.c 1.40 (gritter) 2/17/05"; static char sccsid[] = "@(#)ex_io.c 1.41 (gritter) 8/4/05";
#endif #endif
#endif #endif
@ -839,7 +839,7 @@ int
getfile(void) getfile(void)
{ {
register short c; register short c;
register char *lp, *fp; char *lp, *fp;
lp = linebuf; lp = linebuf;
fp = nextip; fp = nextip;
@ -858,10 +858,8 @@ getfile(void)
fp = genbuf; fp = genbuf;
cntch += ninbuf+1; cntch += ninbuf+1;
} }
if (lp >= &linebuf[LBSIZE]) { if (lp >= &linebuf[LBSIZE])
synced(); grow(" Line too long", &lp, NULL, &fp, &nextip);
error(catgets(catd, 1, 118, " Line too long"));
}
c = *fp++; c = *fp++;
if (c == 0) { if (c == 0) {
cntnull++; cntnull++;

View File

@ -71,7 +71,7 @@
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* Sccsid @(#)ex_proto.h 1.29 (gritter) 8/4/05 * Sccsid @(#)ex_proto.h 1.31 (gritter) 8/4/05
*/ */
/* /*
@ -325,6 +325,8 @@ extern void onemt(int);
extern char *movestr(char *, const char *); extern char *movestr(char *, const char *);
extern char *safecp(char *, const char *, size_t, char *, ...); extern char *safecp(char *, const char *, size_t, char *, ...);
extern char *safecat(char *, const char *, size_t, char *, ...); extern char *safecat(char *, const char *, size_t, char *, ...);
extern void grow(char *, char **, char **, char **, char **);
extern void *smalloc(size_t);
/* ex_tagio.c */ /* ex_tagio.c */
extern int topen(char *, char *); extern int topen(char *, char *);
extern int tseek(int, off_t); extern int tseek(int, off_t);

17
ex_re.c
View File

@ -73,7 +73,7 @@
#ifndef lint #ifndef lint
#ifdef DOSCCS #ifdef DOSCCS
static char sccsid[] = "@(#)ex_re.c 1.56 (gritter) 3/25/05"; static char sccsid[] = "@(#)ex_re.c 1.58 (gritter) 8/4/05";
#endif #endif
#endif #endif
@ -359,7 +359,7 @@ substitute(int c)
* but we don't want to break other, reasonable cases. * but we don't want to break other, reasonable cases.
*/ */
while (*loc2) { while (*loc2) {
if (++hopcount > sizeof linebuf) if (++hopcount > LBSIZE)
error(catgets(catd, 1, 124, error(catgets(catd, 1, 124,
"substitution loop")); "substitution loop"));
if (dosubcon(1, addr) == 0) if (dosubcon(1, addr) == 0)
@ -416,10 +416,10 @@ compsub(int ch)
/* fall into ... */ /* fall into ... */
case '&': case '&':
redo: redo:
if (re.Patbuf[0] == 0) if (re.Patbuf == NULL || re.Patbuf[0] == 0)
error(catgets(catd, 1, 127, error(catgets(catd, 1, 127,
"No previous re|No previous regular expression")); "No previous re|No previous regular expression"));
if (subre.Patbuf[0] == 0) if (subre.Patbuf == NULL || subre.Patbuf[0] == 0)
error(catgets(catd, 1, 128, error(catgets(catd, 1, 128,
"No previous substitute re|No previous substitute to repeat")); "No previous substitute re|No previous substitute to repeat"));
break; break;
@ -867,7 +867,8 @@ snote(register int total, register int lines)
void void
cerror(char *s) cerror(char *s)
{ {
re.Patbuf[0] = '\0'; if (re.Patbuf != NULL)
re.Patbuf[0] = '\0';
error(s); error(s);
} }
@ -1020,13 +1021,17 @@ compile(int eof, int oknl)
{ {
int c, d, i, n = 0; int c, d, i, n = 0;
char mb[MB_LEN_MAX+1]; char mb[MB_LEN_MAX+1];
char *p = re.Patbuf, *end = re.Patbuf + sizeof re.Patbuf; char *p, *end;
int nomagic = value(MAGIC) ? 0 : 1, esc, rcnt = 0; int nomagic = value(MAGIC) ? 0 : 1, esc, rcnt = 0;
char *rhsp; char *rhsp;
#ifdef BIT8 #ifdef BIT8
char *rhsq; char *rhsq;
#endif #endif
free(re.Patbuf);
re.Patbuf = smalloc(2*LBSIZE + 1);
p = re.Patbuf;
end = re.Patbuf + sizeof re.Patbuf;
if (isalpha(eof) || isdigit(eof)) if (isalpha(eof) || isdigit(eof))
error(catgets(catd, 1, 133, error(catgets(catd, 1, 133,
"Regular expressions cannot be delimited by letters or digits")); "Regular expressions cannot be delimited by letters or digits"));

View File

@ -72,7 +72,7 @@
* *
* from ex_re.h 7.3 (Berkeley) 5/31/85 * from ex_re.h 7.3 (Berkeley) 5/31/85
* *
* Sccsid @(#)ex_re.h 1.23 (gritter) 8/4/05 * Sccsid @(#)ex_re.h 1.24 (gritter) 8/4/05
*/ */
/* /*
@ -85,7 +85,7 @@
* more and alternation.) * more and alternation.)
*/ */
struct regexp { struct regexp {
char Patbuf[2*LBSIZE + 1]; char *Patbuf;
long Re_ident; long Re_ident;
void *Expbuf; void *Expbuf;
bool Circfl; bool Circfl;

View File

@ -73,7 +73,7 @@
#ifndef lint #ifndef lint
#ifdef DOSCCS #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
#endif #endif
@ -1151,3 +1151,39 @@ safecat(char *s1, const char *s2, size_t max, char *msg, ...)
/*NOTREACHED*/ /*NOTREACHED*/
return NULL; 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;
}

View File

@ -81,7 +81,7 @@
#ifdef FASTTAG #ifdef FASTTAG
#ifndef lint #ifndef lint
#ifdef DOSCCS #ifdef DOSCCS
static char sccsid[] = "@(#)ex_tagio.c 1.11 (gritter) 11/27/04"; static char sccsid[] = "@(#)ex_tagio.c 1.12 (gritter) 8/4/05";
#endif #endif
#endif #endif
@ -92,7 +92,7 @@ static char sccsid[] = "@(#)ex_tagio.c 1.11 (gritter) 11/27/04";
static long offset = -1; static long offset = -1;
static long block = -1; static long block = -1;
static int bcnt = 0; static int bcnt = 0;
static int b_size = MAXBSIZE; static int b_size;
static char *ibuf; static char *ibuf;
int int
@ -101,6 +101,7 @@ topen(char *file, char *buf)
int fd; int fd;
struct stat statb; struct stat statb;
b_size = MAXBSIZE;
offset = -1; offset = -1;
block = -1; block = -1;
if ((fd = open(file, O_RDONLY, 0)) < 0) if ((fd = open(file, O_RDONLY, 0)) < 0)

View File

@ -73,7 +73,7 @@
#ifndef lint #ifndef lint
#ifdef DOSCCS #ifdef DOSCCS
static char sccsid[] = "@(#)ex_temp.c 1.24 (gritter) 11/24/04"; static char sccsid[] = "@(#)ex_temp.c 1.26 (gritter) 8/4/05";
#endif #endif
#endif #endif
@ -236,7 +236,7 @@ putline(void)
} }
} }
tl = tline; tl = tline;
tline += (((lp - linebuf) + BNDRY - 1) >> SHFT) & 077776; tline += (((lp - linebuf) + BNDRY - 1) >> SHFT) & TLNMSK;
return (tl); return (tl);
} }
@ -657,8 +657,9 @@ YANKreg(register int c)
{ {
register line *addr; register line *addr;
register struct strreg *sp; register struct strreg *sp;
char savelb[LBSIZE]; char *savelb;
savelb = smalloc(LBSIZE);
if (isdigit(c)) if (isdigit(c))
kshift(); kshift();
if (islower(c)) if (islower(c))
@ -688,6 +689,7 @@ YANKreg(register int c)
rbflush(); rbflush();
killed(); killed();
CP(linebuf,savelb); CP(linebuf,savelb);
free(savelb);
} }
void void

View File

@ -72,7 +72,7 @@
* *
* from ex_temp.h 7.4 (Berkeley) 5/31/85 * from ex_temp.h 7.4 (Berkeley) 5/31/85
* *
* Sccsid @(#)ex_temp.h 1.9 (gritter) 8/4/05 * Sccsid @(#)ex_temp.h 1.10 (gritter) 8/4/05
*/ */
/* /*
@ -111,7 +111,8 @@
#define OFFBTS 7 /* 6 */ #define OFFBTS 7 /* 6 */
#define OFFMSK 0177 /* 077 */ #define OFFMSK 0177 /* 077 */
#define SHFT 2 /* 3 */ #define SHFT 2 /* 3 */
#else #define TLNMSK 077776
#else /* VMUNIX */
#ifdef LARGEF #ifdef LARGEF
#define BLKMSK 017777777777 #define BLKMSK 017777777777
#else #else
@ -128,7 +129,8 @@
#define OFFBTS 10 #define OFFBTS 10
#define OFFMSK 01777 #define OFFMSK 01777
#define SHFT 0 #define SHFT 0
#endif #define TLNMSK 017777777776
#endif /* VMUNIX */
/* /*
* The editor uses three buffers into the temporary file (ed uses two * The editor uses three buffers into the temporary file (ed uses two

View File

@ -72,7 +72,7 @@
* *
* from ex_tune.h 7.8.1 (2.11BSD) 1996/10/23 * from ex_tune.h 7.8.1 (2.11BSD) 1996/10/23
* *
* Sccsid @(#)ex_tune.h 1.13 (gritter) 8/4/05 * Sccsid @(#)ex_tune.h 1.14 (gritter) 8/4/05
*/ */
/* /*
@ -111,8 +111,7 @@
/* /*
* Maximums * Maximums
* *
* The definition of LBSIZE should be the same as BUFSIZ (512 usually). * Most definitions are quite generous.
* Most other definitions are quite generous.
*/ */
/* FNSIZE is also defined in expreserve.c */ /* FNSIZE is also defined in expreserve.c */
#ifdef _POSIX_PATH_MAX #ifdef _POSIX_PATH_MAX
@ -121,20 +120,17 @@
#define FNSIZE 128 /* File name size */ #define FNSIZE 128 /* File name size */
#endif #endif
#ifdef VMUNIX #ifdef VMUNIX
#define LBSIZE BUFSIZ /* Line buffer size */
#ifndef ESIZE /* see config.h */ #ifndef ESIZE /* see config.h */
#define ESIZE 512 /* Regular expression buffer size */ #define ESIZE 512 /* Regular expression buffer size */
#endif #endif
#define CRSIZE BUFSIZ /* Crypt buffer size */ #define CRSIZE BUFSIZ /* Crypt buffer size */
#else /* !VMUNIX */ #else /* !VMUNIX */
#ifdef u370 #ifdef u370
#define LBSIZE 4096
#ifndef ESIZE /* see config.h */ #ifndef ESIZE /* see config.h */
#define ESIZE 512 #define ESIZE 512
#endif #endif
#define CRSIZE 4096 #define CRSIZE 4096
#else #else
#define LBSIZE 512 /* Line length */
#ifndef ESIZE /* see config.h */ #ifndef ESIZE /* see config.h */
#define ESIZE 128 /* Size of compiled re */ #define ESIZE 128 /* Size of compiled re */
#endif #endif
@ -186,7 +182,7 @@
#undef NCARGS #undef NCARGS
#ifndef VMUNIX #ifndef VMUNIX
#define NARGS 100 /* Maximum number of names in "next" */ #define NARGS 100 /* Maximum number of names in "next" */
#define NCARGS LBSIZE /* Maximum arglist chars in "next" */ #define NCARGS 512 /* Maximum arglist chars in "next" */
#else #else
#define NCARGS 5120 #define NCARGS 5120
#define NARGS (NCARGS/6) #define NARGS (NCARGS/6)

View File

@ -73,7 +73,7 @@
#ifndef lint #ifndef lint
#ifdef DOSCCS #ifdef DOSCCS
static char sccsid[] = "@(#)ex_unix.c 1.16 (gritter) 11/23/04"; static char sccsid[] = "@(#)ex_unix.c 1.17 (gritter) 8/4/05";
#endif #endif
#endif #endif

2
ex_v.c
View File

@ -73,7 +73,7 @@
#ifndef lint #ifndef lint
#ifdef DOSCCS #ifdef DOSCCS
static char sccsid[] = "@(#)ex_v.c 1.18 (gritter) 8/4/05"; static char sccsid[] = "@(#)ex_v.c 1.19 (gritter) 8/4/05";
#endif #endif
#endif #endif

View File

@ -73,7 +73,7 @@
#ifndef lint #ifndef lint
#ifdef DOSCCS #ifdef DOSCCS
static char sccsid[] = "@(#)ex_vadj.c 1.11 (gritter) 3/4/05"; static char sccsid[] = "@(#)ex_vadj.c 1.14 (gritter) 8/4/05";
#endif #endif
#endif #endif
@ -418,14 +418,14 @@ vopenup(int cnt, int could, int l)
void void
vadjAL(int p, int cnt) vadjAL(int p, int cnt)
{ {
cell *tlines[TUBELINES]; cell **tlines = smalloc(TUBELINES * sizeof *tlines);
register int from, to; register int from, to;
#ifdef ADEBUG #ifdef ADEBUG
if (trace) if (trace)
tfixnl(), fprintf(trace, "vadjal(%d, %d)\n", p, cnt); tfixnl(), fprintf(trace, "vadjal(%d, %d)\n", p, cnt);
#endif #endif
copy(tlines, vtube, sizeof vtube); /*SASSIGN*/ copy(tlines, vtube, TUBELINES * sizeof *tlines); /*SASSIGN*/
for (from = p, to = p + cnt; to <= WECHO; from++, to++) for (from = p, to = p + cnt; to <= WECHO; from++, to++)
vtube[to] = tlines[from]; vtube[to] = tlines[from];
for (to = p; from <= WECHO; from++, to++) { for (to = p; from <= WECHO; from++, to++) {
@ -437,6 +437,7 @@ vadjAL(int p, int cnt)
* necessarily consistent with the rest of the display. * necessarily consistent with the rest of the display.
*/ */
vclrech(0); vclrech(0);
free(tlines);
} }
/* /*
@ -509,7 +510,7 @@ void
vscroll(register int cnt) vscroll(register int cnt)
{ {
register int from, to; register int from, to;
cell *tlines[TUBELINES]; cell **tlines;
#ifdef ADEBUG #ifdef ADEBUG
if (trace) if (trace)
@ -519,7 +520,8 @@ vscroll(register int cnt)
error(catgets(catd, 1, 219, "Internal error: vscroll")); error(catgets(catd, 1, 219, "Internal error: vscroll"));
if (cnt == 0) if (cnt == 0)
return; return;
copy(tlines, vtube, sizeof vtube); tlines = smalloc(TUBELINES * sizeof *tlines);
copy(tlines, vtube, TUBELINES * sizeof *tlines);
for (to = ZERO, from = ZERO + cnt; to <= WECHO - cnt; to++, from++) for (to = ZERO, from = ZERO + cnt; to <= WECHO - cnt; to++, from++)
vtube[to] = tlines[from]; vtube[to] = tlines[from];
for (from = ZERO; to <= WECHO; to++, from++) { for (from = ZERO; to <= WECHO; to++, from++) {
@ -528,6 +530,7 @@ vscroll(register int cnt)
} }
for (from = 0; from <= vcnt; from++) for (from = 0; from <= vcnt; from++)
LINE(from) -= cnt; LINE(from) -= cnt;
free(tlines);
} }
/* /*
@ -680,7 +683,7 @@ vredraw(register int p)
{ {
register int l; register int l;
register line *tp; register line *tp;
char temp[LBSIZE]; char *temp;
bool anydl = 0; bool anydl = 0;
short oldhold = hold; short oldhold = hold;
@ -697,6 +700,7 @@ vredraw(register int p)
if (p < 0 /* || p > WECHO */) if (p < 0 /* || p > WECHO */)
error(catgets(catd, 1, 221, "Internal error: vredraw")); error(catgets(catd, 1, 221, "Internal error: vredraw"));
temp = smalloc(LBSIZE);
/* /*
* Trim the ragged edges (lines which are off the screen but * Trim the ragged edges (lines which are off the screen but
* not yet logically discarded), save the current line, and * not yet logically discarded), save the current line, and
@ -790,6 +794,7 @@ vredraw(register int p)
if (trace) if (trace)
tvliny(); tvliny();
#endif #endif
free(temp);
} }
/* /*
@ -845,7 +850,7 @@ vdellin(int p, int cnt, int l)
void void
vadjDL(int p, int cnt) vadjDL(int p, int cnt)
{ {
cell *tlines[TUBELINES]; cell **tlines = smalloc(TUBELINES * sizeof *tlines);
register int from, to; register int from, to;
#ifdef ADEBUG #ifdef ADEBUG
@ -857,13 +862,14 @@ vadjDL(int p, int cnt)
* v7 compiler (released with phototypesetter for v6) * v7 compiler (released with phototypesetter for v6)
* can't hack it. * can't hack it.
*/ */
copy(tlines, vtube, sizeof vtube); /*SASSIGN*/ copy(tlines, vtube, TUBELINES * sizeof *tlines); /*SASSIGN*/
for (from = p + cnt, to = p; from <= WECHO; from++, to++) for (from = p + cnt, to = p; from <= WECHO; from++, to++)
vtube[to] = tlines[from]; vtube[to] = tlines[from];
for (from = p; to <= WECHO; from++, to++) { for (from = p; to <= WECHO; from++, to++) {
vtube[to] = tlines[from]; vtube[to] = tlines[from];
vclrcell(vtube[to], WCOLS); vclrcell(vtube[to], WCOLS);
} }
free(tlines);
} }
/* /*
* Sync the screen, like redraw but more lazy and willing to leave * Sync the screen, like redraw but more lazy and willing to leave
@ -896,7 +902,7 @@ void
vsync1(register int p) vsync1(register int p)
{ {
register int l; register int l;
char temp[LBSIZE]; char *temp;
register struct vlinfo *vp = &vlinfo[0]; register struct vlinfo *vp = &vlinfo[0];
short oldhold = hold; short oldhold = hold;
@ -911,6 +917,7 @@ vsync1(register int p)
} }
if (state == HARDOPEN || splitw) if (state == HARDOPEN || splitw)
return; return;
temp = smalloc(LBSIZE);
vscrap(); vscrap();
CP(temp, linebuf); CP(temp, linebuf);
if (vcnt == 0) if (vcnt == 0)
@ -960,6 +967,7 @@ vsync1(register int p)
hold = oldhold; hold = oldhold;
if (heldech) if (heldech)
vclrech(0); vclrech(0);
free(temp);
} }
/* /*

View File

@ -70,7 +70,7 @@
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* Sccsid @(#)ex_version.c 1.136 (gritter) 8/4/05 * Sccsid @(#)ex_version.c 1.139 (gritter) 8/4/05
*/ */
#include "ex.h" #include "ex.h"
@ -90,43 +90,43 @@ printver(void)
} }
/* SLIST */ /* SLIST */
/* /*
ex.c:static char sccsid[] = "@(#)ex.c 1.36 (gritter) 2/13/05"; ex.c:static char sccsid[] = "@(#)ex.c 1.37 (gritter) 8/4/05";
ex.h: * Sccsid @(#)ex.h 1.54 (gritter) 8/4/05 ex.h: * Sccsid @(#)ex.h 1.55 (gritter) 8/4/05
ex_addr.c:static char sccsid[] = "@(#)ex_addr.c 1.10 (gritter) 2/17/05"; ex_addr.c:static char sccsid[] = "@(#)ex_addr.c 1.11 (gritter) 8/4/05";
ex_argv.h: * Sccsid @(#)ex_argv.h 1.9 (gritter) 8/4/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_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_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"; ex_cmdsub.c:static char sccsid[] = "@(#)ex_cmdsub.c 1.31 (gritter) 8/4/05";
ex_data.c:static char sccsid[] = "@(#)ex_data.c 1.14 (gritter) 11/23/04"; 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_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_get.c:static char sccsid[] = "@(#)ex_get.c 1.18 (gritter) 8/4/05";
ex_io.c:static char sccsid[] = "@(#)ex_io.c 1.40 (gritter) 2/17/05"; ex_io.c:static char sccsid[] = "@(#)ex_io.c 1.41 (gritter) 8/4/05";
ex_proto.h: * Sccsid @(#)ex_proto.h 1.29 (gritter) 8/4/05 ex_proto.h: * Sccsid @(#)ex_proto.h 1.31 (gritter) 8/4/05
ex_put.c:static char sccsid[] = "@(#)ex_put.c 1.32 (gritter) 2/17/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.c:static char sccsid[] = "@(#)ex_re.c 1.58 (gritter) 8/4/05";
ex_re.h: * Sccsid @(#)ex_re.h 1.23 (gritter) 8/4/05 ex_re.h: * Sccsid @(#)ex_re.h 1.24 (gritter) 8/4/05
ex_set.c:static char sccsid[] = "@(#)ex_set.c 1.11 (gritter) 11/24/04"; 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_subr.c:static char sccsid[] = "@(#)ex_subr.c 1.39 (gritter) 8/4/05";
ex_tagio.c:static char sccsid[] = "@(#)ex_tagio.c 1.11 (gritter) 11/27/04"; ex_tagio.c:static char sccsid[] = "@(#)ex_tagio.c 1.12 (gritter) 8/4/05";
ex_temp.c:static char sccsid[] = "@(#)ex_temp.c 1.24 (gritter) 11/24/04"; ex_temp.c:static char sccsid[] = "@(#)ex_temp.c 1.26 (gritter) 8/4/05";
ex_temp.h: * Sccsid @(#)ex_temp.h 1.9 (gritter) 8/4/05 ex_temp.h: * Sccsid @(#)ex_temp.h 1.10 (gritter) 8/4/05
ex_tty.c:static char sccsid[] = "@(#)ex_tty.c 1.30 (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_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_tune.h: * Sccsid @(#)ex_tune.h 1.14 (gritter) 8/4/05
ex_unix.c:static char sccsid[] = "@(#)ex_unix.c 1.16 (gritter) 11/23/04"; ex_unix.c:static char sccsid[] = "@(#)ex_unix.c 1.17 (gritter) 8/4/05";
ex_v.c:static char sccsid[] = "@(#)ex_v.c 1.18 (gritter) 8/4/05"; ex_v.c:static char sccsid[] = "@(#)ex_v.c 1.19 (gritter) 8/4/05";
ex_vadj.c:static char sccsid[] = "@(#)ex_vadj.c 1.11 (gritter) 3/4/05"; ex_vadj.c:static char sccsid[] = "@(#)ex_vadj.c 1.14 (gritter) 8/4/05";
ex_vget.c:static char sccsid[] = "@(#)ex_vget.c 1.29 (gritter) 2/15/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_vis.h: * Sccsid @(#)ex_vis.h 1.21 (gritter) 8/4/05
ex_vmain.c:static char sccsid[] = "@(#)ex_vmain.c 1.29 (gritter) 2/17/05"; ex_vmain.c:static char sccsid[] = "@(#)ex_vmain.c 1.31 (gritter) 8/4/05";
ex_voper.c:static char sccsid[] = "@(#)ex_voper.c 1.27 (gritter) 2/15/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"; ex_vops.c:static char sccsid[] = "@(#)ex_vops.c 1.28 (gritter) 8/4/05";
ex_vops2.c:static char sccsid[] = "@(#)ex_vops2.c 1.34 (gritter) 1/12/05"; ex_vops2.c:static char sccsid[] = "@(#)ex_vops2.c 1.35 (gritter) 8/4/05";
ex_vops3.c:static char sccsid[] = "@(#)ex_vops3.c 1.19 (gritter) 1/2/05"; ex_vops3.c:static char sccsid[] = "@(#)ex_vops3.c 1.21 (gritter) 8/4/05";
ex_vput.c:static char sccsid[] = "@(#)ex_vput.c 1.49 (gritter) 2/15/05"; ex_vput.c:static char sccsid[] = "@(#)ex_vput.c 1.50 (gritter) 8/4/05";
ex_vwind.c:static char sccsid[] = "@(#)ex_vwind.c 1.9 (gritter) 11/23/04"; ex_vwind.c:static char sccsid[] = "@(#)ex_vwind.c 1.9 (gritter) 11/23/04";
expreserve.c:static char sccsid[] UNUSED = "@(#)expreserve.c 1.23 (gritter) 11/27/04"; expreserve.c:static char sccsid[] UNUSED = "@(#)expreserve.c 1.23 (gritter) 11/27/04";
exrecover.c:static char sccsid[] UNUSED = "@(#)exrecover.c 1.21 (gritter) 11/27/04"; exrecover.c:static char sccsid[] UNUSED = "@(#)exrecover.c 1.22 (gritter) 8/4/05";
mapmalloc.c: * Sccsid @(#)mapmalloc.c 1.6 (gritter) 6/19/05 mapmalloc.c: * Sccsid @(#)mapmalloc.c 1.6 (gritter) 6/19/05
printf.c:static char sccsid[] = "@(#)printf.c 1.15 (gritter) 12/1/04"; printf.c:static char sccsid[] = "@(#)printf.c 1.15 (gritter) 12/1/04";
*/ */

View File

@ -72,7 +72,7 @@
* *
* from ex_vis.h 7.4 (Berkeley) 5/31/85 * from ex_vis.h 7.4 (Berkeley) 5/31/85
* *
* Sccsid @(#)ex_vis.h 1.20 (gritter) 8/4/05 * Sccsid @(#)ex_vis.h 1.21 (gritter) 8/4/05
*/ */
/* /*

View File

@ -73,7 +73,7 @@
#ifndef lint #ifndef lint
#ifdef DOSCCS #ifdef DOSCCS
static char sccsid[] = "@(#)ex_vmain.c 1.29 (gritter) 2/17/05"; static char sccsid[] = "@(#)ex_vmain.c 1.31 (gritter) 8/4/05";
#endif #endif
#endif #endif
@ -1264,7 +1264,7 @@ vremote(int cnt, void (*f)(int), int arg)
void void
vsave(void) vsave(void)
{ {
char temp[LBSIZE]; char *temp = smalloc(LBSIZE);
CP(temp, linebuf); CP(temp, linebuf);
if (FIXUNDO && vundkind == VCHNG || vundkind == VCAPU) { if (FIXUNDO && vundkind == VCHNG || vundkind == VCAPU) {
@ -1290,10 +1290,13 @@ vsave(void)
* almost always be in a read buffer so this may well avoid disk i/o. * almost always be in a read buffer so this may well avoid disk i/o.
*/ */
getDOT(); getDOT();
if (strcmp(linebuf, temp) == 0) if (strcmp(linebuf, temp) == 0) {
free(temp);
return; return;
}
strcLIN(temp); strcLIN(temp);
putmark(dot); putmark(dot);
free(temp);
} }
#undef forbid #undef forbid

View File

@ -73,7 +73,7 @@
#ifndef lint #ifndef lint
#ifdef DOSCCS #ifdef DOSCCS
static char sccsid[] = "@(#)ex_vops.c 1.26 (gritter) 1/13/05"; static char sccsid[] = "@(#)ex_vops.c 1.28 (gritter) 8/4/05";
#endif #endif
#endif #endif
@ -143,7 +143,7 @@ vundo (
register int cnt; register int cnt;
register line *addr; register line *addr;
register char *cp; register char *cp;
char temp[LBSIZE]; char *temp = smalloc(LBSIZE);
bool savenote; bool savenote;
int (*OO)(int); int (*OO)(int);
short oldhold = hold; short oldhold = hold;
@ -246,6 +246,7 @@ vundo (
beep(); beep();
break; break;
} }
free(temp);
} }
/* /*
@ -259,7 +260,7 @@ vmacchng(int fromvis)
{ {
line *savedot, *savedol; line *savedot, *savedol;
char *savecursor; char *savecursor;
char savelb[LBSIZE]; char *savelb;
int nlines, more; int nlines, more;
/* register line *a1, *a2; */ /* register line *a1, *a2; */
/* char ch; */ /* DEBUG */ /* char ch; */ /* DEBUG */
@ -283,6 +284,7 @@ vmacchng(int fromvis)
vch_mac = VC_ONECHANGE; vch_mac = VC_ONECHANGE;
break; break;
case VC_ONECHANGE: case VC_ONECHANGE:
savelb = smalloc(LBSIZE);
/* Save current state somewhere */ /* Save current state somewhere */
#ifdef TRACE #ifdef TRACE
vudump("before vmacchng hairy case"); vudump("before vmacchng hairy case");
@ -330,6 +332,7 @@ vmacchng(int fromvis)
#ifdef TRACE #ifdef TRACE
vudump("after vmacchng"); vudump("after vmacchng");
#endif #endif
free(savelb);
break; break;
case VC_NOTINMAC: case VC_NOTINMAC:
case VC_MANYCHANGE: case VC_MANYCHANGE:

View File

@ -73,7 +73,7 @@
#ifndef lint #ifndef lint
#ifdef DOSCCS #ifdef DOSCCS
static char sccsid[] = "@(#)ex_vops2.c 1.34 (gritter) 1/12/05"; static char sccsid[] = "@(#)ex_vops2.c 1.35 (gritter) 8/4/05";
#endif #endif
#endif #endif

View File

@ -73,7 +73,7 @@
#ifndef lint #ifndef lint
#ifdef DOSCCS #ifdef DOSCCS
static char sccsid[] = "@(#)ex_vops3.c 1.19 (gritter) 1/2/05"; static char sccsid[] = "@(#)ex_vops3.c 1.21 (gritter) 8/4/05";
#endif #endif
#endif #endif
@ -118,7 +118,7 @@ llfind(bool pastatom, int cnt, void (*f)(int), line *limit)
register int c; register int c;
#endif #endif
register int rc = 0; register int rc = 0;
char save[LBSIZE]; char *save = smalloc(LBSIZE);
/* /*
* Initialize, saving the current line buffer state * Initialize, saving the current line buffer state
@ -284,6 +284,7 @@ begin:
#endif #endif
ret: ret:
strcLIN(save); strcLIN(save);
free(save);
return (rc); return (rc);
} }
@ -424,7 +425,7 @@ lmatchp(line *addr)
void void
lsmatch(char *cp) lsmatch(char *cp)
{ {
char save[LBSIZE]; char *save = smalloc(LBSIZE);
register char *sp = save; register char *sp = save;
register char *scurs = cursor; register char *scurs = cursor;
@ -457,6 +458,7 @@ lsmatch(char *cp)
wdot = 0; wdot = 0;
wcursor = 0; wcursor = 0;
cursor = scurs; cursor = scurs;
free(save);
} }
int int
@ -674,7 +676,7 @@ vswitch(int cnt)
mbuf[1+n1] = '\0'; mbuf[1+n1] = '\0';
macpush(mbuf, 1); macpush(mbuf, 1);
} else { /* cnt > 1 */ } else { /* cnt > 1 */
char *mbuf = malloc(MAXDIGS + cnt*(mb_cur_max+1) + 5); char *mbuf = smalloc(MAXDIGS + cnt*(mb_cur_max+1) + 5);
register char *p = &mbuf[MAXDIGS + 1]; register char *p = &mbuf[MAXDIGS + 1];
int num, n0, n1, m; int num, n0, n1, m;

View File

@ -73,7 +73,7 @@
#ifndef lint #ifndef lint
#ifdef DOSCCS #ifdef DOSCCS
static char sccsid[] = "@(#)ex_vput.c 1.49 (gritter) 2/15/05"; static char sccsid[] = "@(#)ex_vput.c 1.50 (gritter) 8/4/05";
#endif #endif
#endif #endif
@ -223,7 +223,7 @@ vclrech(bool didphys)
splitw = 0; splitw = 0;
didphys = 1; didphys = 1;
} }
if (didphys) if (didphys && vtube)
vclrcell(vtube[WECHO], WCOLS); vclrcell(vtube[WECHO], WCOLS);
heldech = 0; heldech = 0;
} }

View File

@ -83,7 +83,7 @@ char *copyright =
"@(#) Copyright (c) 1980 Regents of the University of California.\n\ "@(#) Copyright (c) 1980 Regents of the University of California.\n\
All rights reserved.\n"; All rights reserved.\n";
#endif #endif
static char sccsid[] UNUSED = "@(#)exrecover.c 1.21 (gritter) 11/27/04"; static char sccsid[] UNUSED = "@(#)exrecover.c 1.22 (gritter) 8/4/05";
#endif #endif
/* from exrecover.c 7.9.2 (2.11BSD) 1996/10/26 */ /* from exrecover.c 7.9.2 (2.11BSD) 1996/10/26 */
@ -210,6 +210,8 @@ main(int argc, char *argv[])
#ifdef VMUNIX #ifdef VMUNIX
poolsbrk(0); poolsbrk(0);
#endif #endif
linebuf = calloc(LBSIZE = BUFSIZ<4096?4096:BUFSIZ, sizeof *linebuf);
genbuf = calloc(MAXBSIZE, sizeof *genbuf);
#ifdef LANGMSG #ifdef LANGMSG
setlocale(LC_MESSAGES, ""); setlocale(LC_MESSAGES, "");
catd = catopen(CATNAME, NL_CAT_LOCALE); catd = catopen(CATNAME, NL_CAT_LOCALE);