mirror of
git://git.suckless.org/sbase
synced 2024-12-22 23:13:44 +00:00
csplit, grep: use eregcomp
This commit is contained in:
parent
3fb0e50668
commit
1822f70d12
3
csplit.c
3
csplit.c
@ -362,8 +362,7 @@ do_rexp(const char *expr)
|
|||||||
} else
|
} else
|
||||||
ofs = 0;
|
ofs = 0;
|
||||||
|
|
||||||
if (regcomp(&cre, re, REG_NOSUB) != 0)
|
eregcomp(&cre, re, REG_NOSUB);
|
||||||
eprintf("%s: bad regular expression'n", re);
|
|
||||||
|
|
||||||
if (*expr == '/')
|
if (*expr == '/')
|
||||||
/* /regexp/: Save results to a file. */
|
/* /regexp/: Save results to a file. */
|
||||||
|
8
grep.c
8
grep.c
@ -38,8 +38,7 @@ int
|
|||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
struct pattern *pnode, *tmp;
|
struct pattern *pnode, *tmp;
|
||||||
int i, n, m, flags = REG_NOSUB, match = NoMatch;
|
int i, m, flags = REG_NOSUB, match = NoMatch;
|
||||||
char buf[BUFSIZ];
|
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
TAILQ_INIT(&phead);
|
TAILQ_INIT(&phead);
|
||||||
@ -83,10 +82,7 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
/* Compile regex for all search patterns */
|
/* Compile regex for all search patterns */
|
||||||
TAILQ_FOREACH(pnode, &phead, entry) {
|
TAILQ_FOREACH(pnode, &phead, entry) {
|
||||||
if ((n = regcomp(&pnode->preg, pnode->pattern, flags)) != 0) {
|
enregcomp(Error, &pnode->preg, pnode->pattern, flags);
|
||||||
regerror(n, &pnode->preg, buf, sizeof buf);
|
|
||||||
enprintf(Error, "invalid pattern: %s\n", buf);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
many = (argc > 1);
|
many = (argc > 1);
|
||||||
if (argc == 0) {
|
if (argc == 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user