summaryrefslogtreecommitdiffstats
path: root/text-utils/more.c
diff options
context:
space:
mode:
authorJeremy Huntwork2012-05-13 19:28:32 +0200
committerJeremy Huntwork2012-05-13 19:28:32 +0200
commit596007ef6a37b708f44286932eed667b316e5f70 (patch)
tree4cc264725a1745224b0af273b8d8d8eab95caf39 /text-utils/more.c
parentRemove use of __P. Its intended usage was to support pre-ANSI C compilers, bu... (diff)
downloadkernel-qcow2-util-linux-596007ef6a37b708f44286932eed667b316e5f70.tar.gz
kernel-qcow2-util-linux-596007ef6a37b708f44286932eed667b316e5f70.tar.xz
kernel-qcow2-util-linux-596007ef6a37b708f44286932eed667b316e5f70.zip
Use POSIX regcomp and regexec over obsolete BSD re_comp and re_exec
Diffstat (limited to 'text-utils/more.c')
-rw-r--r--text-utils/more.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/text-utils/more.c b/text-utils/more.c
index 519679143..d7d93226f 100644
--- a/text-utils/more.c
+++ b/text-utils/more.c
@@ -63,9 +63,7 @@
#include "widechar.h"
#include "closestream.h"
-#define _REGEX_RE_COMP
#include <regex.h>
-#undef _REGEX_RE_COMP
#ifndef XTABS
#define XTABS TAB3
@@ -1584,21 +1582,24 @@ void search(char buf[], FILE *file, register int n)
register long line2 = startline;
register long line3 = startline;
register int lncount;
- int saveln, rv;
+ int saveln, rv, rc;
char *s;
+ regex_t re;
context.line = saveln = Currline;
context.chrctr = startline;
lncount = 0;
- if ((s = re_comp (buf)) != 0)
+ if (rc = regcomp (&re, buf, REG_NOSUB) != 0) {
+ regerror (rc, &re, s, sizeof s);
more_error (s);
+ }
while (!feof (file)) {
line3 = line2;
line2 = line1;
line1 = Ftell (file);
rdline (file);
lncount++;
- if ((rv = re_exec (Line)) == 1) {
+ if ((rv = regexec (&re, Line, 0, NULL, 0)) == 0) {
if (--n == 0) {
if (lncount > 3 || (lncount > 1 && no_intty))
{
@@ -1633,7 +1634,7 @@ void search(char buf[], FILE *file, register int n)
}
break;
}
- } else if (rv == -1)
+ } else if (rv != REG_NOMATCH)
more_error (_("Regular expression botch"));
}
if (feof (file)) {