From 964a1c2ea7c3611e8c92911449119b0ad54d962c Mon Sep 17 00:00:00 2001 From: wollman Date: Tue, 21 Feb 1995 04:32:55 +0000 Subject: Use POSIX.2 regular expressions, kill libcompat. --- usr.bin/rdist/Makefile | 2 -- usr.bin/rdist/docmd.c | 17 +++++++++++++---- usr.bin/rdist/gram.y | 21 ++++++++++++++++----- usr.bin/rdist/rdist.1 | 5 +++-- 4 files changed, 32 insertions(+), 13 deletions(-) (limited to 'usr.bin') diff --git a/usr.bin/rdist/Makefile b/usr.bin/rdist/Makefile index 4b60c6b..853439c 100644 --- a/usr.bin/rdist/Makefile +++ b/usr.bin/rdist/Makefile @@ -7,8 +7,6 @@ OBJS+= gram.o BINOWN= root BINMODE=4555 INSTALLFLAGS=-fschg -DPADD= ${LIBCOMPAT} -LDADD= -lcompat CLEANFILES=y.tab.h .include diff --git a/usr.bin/rdist/docmd.c b/usr.bin/rdist/docmd.c index 0422a37..39a9d5d 100644 --- a/usr.bin/rdist/docmd.c +++ b/usr.bin/rdist/docmd.c @@ -32,12 +32,15 @@ */ #ifndef lint -static char sccsid[] = "@(#)docmd.c 8.1 (Berkeley) 6/9/93"; +/*static char sccsid[] = "From: @(#)docmd.c 8.1 (Berkeley) 6/9/93";*/ +static const char rcsid[] = + "$Id$"; #endif /* not lint */ #include "defs.h" #include #include +#include FILE *lfp; /* log file for recording files updated */ struct subcmd *subcmds; /* list of sub-commands for current cmd */ @@ -592,6 +595,8 @@ except(file) { register struct subcmd *sc; register struct namelist *nl; + regex_t rx; + int val; if (debug) printf("except(%s)\n", file); @@ -605,9 +610,13 @@ except(file) return(1); continue; } - re_comp(nl->n_name); - if (re_exec(file) > 0) - return(1); + val = regcomp(&rx, nl->n_name, + REG_EXTENDED | REG_NOSUB); + if (!regexec(&rx, file, 0, 0, 0)) { + regfree(&rx); + return 1; + } + regfree(&rx); } } return(0); diff --git a/usr.bin/rdist/gram.y b/usr.bin/rdist/gram.y index 7f40f87..6e54911 100644 --- a/usr.bin/rdist/gram.y +++ b/usr.bin/rdist/gram.y @@ -37,6 +37,9 @@ static char sccsid[] = "@(#)gram.y 8.1 (Berkeley) 6/9/93"; #endif /* not lint */ #include "defs.h" +#include +#include +#include struct cmd *cmds = NULL; struct cmd *last_cmd; @@ -163,11 +166,19 @@ cmd: INSTALL options opt_namelist SM = { } | PATTERN namelist SM = { struct namelist *nl; - char *cp, *re_comp(); - - for (nl = $2; nl != NULL; nl = nl->n_next) - if ((cp = re_comp(nl->n_name)) != NULL) - yyerror(cp); + regex_t rx; + int val; + char errbuf[_POSIX2_LINE_MAX]; + + for (nl = $2; nl != NULL; nl = nl->n_next) { + if (val = regcomp(&rx, nl->n_name, + REG_EXTENDED)) { + regerror(val, &rx, errbuf, + sizeof errbuf); + yyerror(errbuf); + } + regfree(&rx); + } $1->sc_args = expand($2, E_VARS); $$ = $1; } diff --git a/usr.bin/rdist/rdist.1 b/usr.bin/rdist/rdist.1 index 9ae17e9..00a3339 100644 --- a/usr.bin/rdist/rdist.1 +++ b/usr.bin/rdist/rdist.1 @@ -308,7 +308,7 @@ command except that .Ar pattern list is a list of regular expressions (see -.Xr ed 1 +.Xr re_format 7 for details). If one of the patterns matches some string within a file name, that file will be ignored. @@ -384,7 +384,8 @@ temporary file for update lists .Sh SEE ALSO .Xr sh 1 , .Xr csh 1 , -.Xr stat 2 +.Xr stat 2 , +.Xr re_format 7 .Sh HISTORY The .Nm rdist -- cgit v1.1