Fixed regex bug: a character class of the form [IC[],

where IC is of the form [::] , [..], or [==], would incorrectly
report an error.
Fixed input mode bug: a literal ^J(i.e., ^V^J) would discard text
following it.  Now, a literal ^J is treated as an ordinary ^J - i.e, it
splits a line in two.
This commit is contained in:
alm 1993-05-12 08:22:03 +00:00
parent 8db326f5d7
commit fc782b3ff5
2 changed files with 33 additions and 21 deletions

View File

@ -1205,6 +1205,7 @@ append(n, glob)
{
int l;
char *lp = ibuf;
char *eot;
undo_t *up = NULL;
for (curln = n;;) {
@ -1218,27 +1219,33 @@ append(n, glob)
lp = ibuf;
} else if (*(lp = ibufp) == '\0')
return 0;
else
else {
while (*ibufp++ != '\n')
;
if (lp[0] == '.' && lp[1] == '\n') {
l = ibufp - lp;
}
if (l == 2 && lp[0] == '.' && lp[1] == '\n') {
return 0;
}
eot = lp + l;
spl1();
if (puttxt(lp) == NULL) {
spl0();
return ERR;
} else if (up)
up->t = getlp(curln);
else if ((up = upush(UADD, curln, curln)) == NULL) {
spl0();
return ERR;
}
do {
if ((lp = puttxt(lp)) == NULL) {
spl0();
return ERR;
} else if (up)
up->t = getlp(curln);
else if ((up = upush(UADD, curln, curln)) == NULL) {
spl0();
return ERR;
}
} while (lp != eot);
spl0();
modified = 1;
}
}
#ifdef sun
/* subst: change all text matching a pattern in a range of lines according to
a substitution template; return status */

View File

@ -136,16 +136,21 @@ getlhs(delim)
}
/* ccl: expand a character class */
/* ccl: expand a POSIX character class */
char *
ccl(src)
char *src;
ccl(s)
char *s;
{
if (*src == '^')
src++;
if (*src == ']')
src++;
while (*src != ']' && *src != '\n')
src++;
return (*src == ']') ? src : NULL;
int c, d;
if (*s == '^')
s++;
if (*s == ']')
s++;
for (; *s != ']' && *s != '\n'; s++)
if (*s == '[' && ((d = *(s+1)) == '.' || d == ':' || d == '='))
for (s++, c = *++s; *s != ']' || c != d; s++)
if ((c = *s) == '\n')
return NULL;
return (*s == ']') ? s : NULL;
}