[hackers] [sbase] csplit, grep: use eregcomp || Hiltjo Posthuma

From: <git_AT_suckless.org>
Date: Sun, 16 Nov 2014 15:37:14 +0100

commit 1822f70d12b85cf4be46c9cd7111a035394b0796
Author: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Sun Nov 16 15:17:46 2014 +0100

    csplit, grep: use eregcomp

diff --git a/csplit.c b/csplit.c
index cf9f902..bf61337 100644
--- a/csplit.c
+++ b/csplit.c
_AT_@ -362,8 +362,7 @@ do_rexp(const char *expr)
         } else
                 ofs = 0;
 
- if (regcomp(&cre, re, REG_NOSUB) != 0)
- eprintf("%s: bad regular expression'n", re);
+ eregcomp(&cre, re, REG_NOSUB);
 
         if (*expr == '/')
                 /* /regexp/: Save results to a file. */
diff --git a/grep.c b/grep.c
index ffa9b44..6c6215d 100644
--- a/grep.c
+++ b/grep.c
_AT_@ -38,8 +38,7 @@ int
 main(int argc, char *argv[])
 {
         struct pattern *pnode, *tmp;
- int i, n, m, flags = REG_NOSUB, match = NoMatch;
- char buf[BUFSIZ];
+ int i, m, flags = REG_NOSUB, match = NoMatch;
         FILE *fp;
 
         TAILQ_INIT(&phead);
_AT_@ -83,10 +82,7 @@ main(int argc, char *argv[])
 
         /* Compile regex for all search patterns */
         TAILQ_FOREACH(pnode, &phead, entry) {
- if ((n = regcomp(&pnode->preg, pnode->pattern, flags)) != 0) {
- regerror(n, &pnode->preg, buf, sizeof buf);
- enprintf(Error, "invalid pattern: %s\n", buf);
- }
+ enregcomp(Error, &pnode->preg, pnode->pattern, flags);
         }
         many = (argc > 1);
         if (argc == 0) {
Received on Sun Nov 16 2014 - 15:37:14 CET

This archive was generated by hypermail 2.3.0 : Sun Nov 16 2014 - 15:48:10 CET