summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2003-05-06 00:23:04 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2003-05-06 00:23:04 +0000
commitad94b0a87e1222252af5c932b6d5ad9e60499fee (patch)
tree20103c16dd1e190aa304ad63f224f7462c078adc
parent6d2267a379b77fbb4f78c0567dd38a4f77451d33 (diff)
more(1) now uses POSIX regex, no more ned for -lcompat; deraadt@ OK
-rw-r--r--distrib/miniroot/makeconf.awk4
-rw-r--r--distrib/special/more/Makefile6
-rw-r--r--distrib/special/more/more.c26
3 files changed, 25 insertions, 11 deletions
diff --git a/distrib/miniroot/makeconf.awk b/distrib/miniroot/makeconf.awk
index 889244a4c7e..b04aa712035 100644
--- a/distrib/miniroot/makeconf.awk
+++ b/distrib/miniroot/makeconf.awk
@@ -1,4 +1,4 @@
-# $OpenBSD: makeconf.awk,v 1.10 2003/04/17 23:02:42 deraadt Exp $
+# $OpenBSD: makeconf.awk,v 1.11 2003/05/06 00:23:02 millert Exp $
# $NetBSD: makeconf.awk,v 1.3 1996/05/04 15:45:32 pk Exp $
#
@@ -7,7 +7,7 @@
BEGIN {
printf("#\n# This file is automatically generated by `makeconf'\n#\n\n");
- libs = "libs -lutil -lotermcap -ll -lm -lkrb -ldes -lcompat";
+ libs = "libs -lutil -lotermcap -ll -lm -lkrb -ldes";
}
$1 == "LIBS" {
diff --git a/distrib/special/more/Makefile b/distrib/special/more/Makefile
index c0f8866a52b..98ac18f3c58 100644
--- a/distrib/special/more/Makefile
+++ b/distrib/special/more/Makefile
@@ -1,9 +1,9 @@
-# $OpenBSD: Makefile,v 1.1 2003/04/17 22:53:12 millert Exp $
+# $OpenBSD: Makefile,v 1.2 2003/05/06 00:23:03 millert Exp $
PROG= more
MAN=
CFLAGS+=-D_USE_OLD_CURSES_
-DPADD= ${LIBOCURSES} ${LIBCOMPAT}
-LDADD= -locurses -lcompat
+DPADD= ${LIBOCURSES}
+LDADD= -locurses
.include <bsd.prog.mk>
diff --git a/distrib/special/more/more.c b/distrib/special/more/more.c
index 8a747d82fcb..3acb96c4bb2 100644
--- a/distrib/special/more/more.c
+++ b/distrib/special/more/more.c
@@ -59,6 +59,7 @@ static const char sccsid[] = "@(#)more.c 5.28 (Berkeley) 3/1/93";
#include <curses.h>
#include <errno.h>
#include <locale.h>
+#include <regex.h>
#include <setjmp.h>
#include <signal.h>
#include <stdarg.h>
@@ -1359,20 +1360,31 @@ search (char *buf, FILE *file, int n)
register long line3 = startline;
register int lncount;
int saveln, rv;
- char *s;
+ char ebuf[BUFSIZ];
+ static regex_t reg;
+ static int initialized;
context.line = saveln = Currline;
context.chrctr = startline;
lncount = 0;
- if ((s = re_comp (buf)) != 0)
- error (s);
+ if (buf != NULL && *buf != '\0') {
+ if ((rv = regcomp(&reg, buf, REG_NOSUB)) != 0) {
+ initialized = 0;
+ regerror(rv, &reg, ebuf, sizeof(ebuf));
+ regfree(&reg);
+ error(ebuf);
+ }
+ initialized = 1;
+ } else if (!initialized) {
+ error("No previous regular expression");
+ }
while (!feof (file)) {
line3 = line2;
line2 = line1;
line1 = Ftell (file);
rdline (file);
lncount++;
- if ((rv = re_exec (Line)) == 1) {
+ if ((rv = regexec(&reg, Line, 0, NULL, 0)) == 0) {
if (--n == 0) {
if (lncount > 3 || (lncount > 1 && no_intty))
{
@@ -1406,8 +1418,10 @@ search (char *buf, FILE *file, int n)
}
break;
}
- } else if (rv == -1)
- error ("Regular expression botch");
+ } else if (rv != REG_NOMATCH) {
+ regerror(rv, &reg, ebuf, sizeof(ebuf));
+ error(ebuf);
+ }
}
if (feof (file)) {
if (!no_intty) {