Use POSIX.2 regular expressions, kill libcompat.

This commit is contained in:
Garrett Wollman 1995-02-21 04:32:55 +00:00
parent a34565af65
commit 94ea865c39
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=6593
4 changed files with 31 additions and 12 deletions

View file

@ -7,8 +7,6 @@ OBJS+= gram.o
BINOWN= root
BINMODE=4555
INSTALLFLAGS=-fschg
DPADD= ${LIBCOMPAT}
LDADD= -lcompat
CLEANFILES=y.tab.h
.include <bsd.prog.mk>

View file

@ -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 <setjmp.h>
#include <netdb.h>
#include <regex.h>
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);

View file

@ -37,6 +37,9 @@ static char sccsid[] = "@(#)gram.y 8.1 (Berkeley) 6/9/93";
#endif /* not lint */
#include "defs.h"
#include <sys/types.h>
#include <regex.h>
#include <limits.h>
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();
regex_t rx;
int val;
char errbuf[_POSIX2_LINE_MAX];
for (nl = $2; nl != NULL; nl = nl->n_next)
if ((cp = re_comp(nl->n_name)) != NULL)
yyerror(cp);
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;
}

View file

@ -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