Move lastre to String type
This commit is contained in:
parent
35cf3c79f2
commit
7c2eec7bd1
13
ed.c
13
ed.c
|
@ -44,7 +44,7 @@ struct undo {
|
||||||
static char *prompt = "*";
|
static char *prompt = "*";
|
||||||
static regex_t *pattern;
|
static regex_t *pattern;
|
||||||
static regmatch_t matchs[10];
|
static regmatch_t matchs[10];
|
||||||
static char *lastre;
|
static String lastre;
|
||||||
|
|
||||||
static int optverbose, optprompt, exstatus, optdiag = 1;
|
static int optverbose, optprompt, exstatus, optdiag = 1;
|
||||||
static int marks['z' - 'a'];
|
static int marks['z' - 'a'];
|
||||||
|
@ -383,13 +383,12 @@ static void
|
||||||
compile(int delim)
|
compile(int delim)
|
||||||
{
|
{
|
||||||
int n, ret, c,bracket;
|
int n, ret, c,bracket;
|
||||||
static size_t siz, cap;
|
|
||||||
static char buf[BUFSIZ];
|
static char buf[BUFSIZ];
|
||||||
|
|
||||||
if (!isgraph(delim))
|
if (!isgraph(delim))
|
||||||
error("invalid pattern delimiter");
|
error("invalid pattern delimiter");
|
||||||
|
|
||||||
eol = bol = bracket = siz = 0;
|
eol = bol = bracket = lastre.siz = 0;
|
||||||
for (n = 0;; ++n) {
|
for (n = 0;; ++n) {
|
||||||
if ((c = input()) == delim && !bracket)
|
if ((c = input()) == delim && !bracket)
|
||||||
break;
|
break;
|
||||||
|
@ -403,27 +402,27 @@ compile(int delim)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c == '\\') {
|
if (c == '\\') {
|
||||||
lastre = addchar(c, lastre, &cap, &siz);
|
addchar_(c, &lastre);
|
||||||
c = input();
|
c = input();
|
||||||
} else if (c == '[') {
|
} else if (c == '[') {
|
||||||
bracket = 1;
|
bracket = 1;
|
||||||
} else if (c == ']') {
|
} else if (c == ']') {
|
||||||
bracket = 0;
|
bracket = 0;
|
||||||
}
|
}
|
||||||
lastre = addchar(c, lastre, &cap, &siz);
|
addchar_(c, &lastre);
|
||||||
}
|
}
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
if (!pattern)
|
if (!pattern)
|
||||||
error("no previous pattern");
|
error("no previous pattern");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lastre = addchar('\0', lastre, &cap, &siz);
|
addchar_('\0', &lastre);
|
||||||
|
|
||||||
if (pattern)
|
if (pattern)
|
||||||
regfree(pattern);
|
regfree(pattern);
|
||||||
if (!pattern && (!(pattern = malloc(sizeof(*pattern)))))
|
if (!pattern && (!(pattern = malloc(sizeof(*pattern)))))
|
||||||
error("out of memory");
|
error("out of memory");
|
||||||
if ((ret = regcomp(pattern, lastre, REG_NEWLINE))) {
|
if ((ret = regcomp(pattern, lastre.str, REG_NEWLINE))) {
|
||||||
regerror(ret, pattern, buf, sizeof(buf));
|
regerror(ret, pattern, buf, sizeof(buf));
|
||||||
error(buf);
|
error(buf);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user