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

17
ex_re.c
View File

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