diff options
Diffstat (limited to 'lib/libcompat/regexp')
-rw-r--r-- | lib/libcompat/regexp/regerror.c | 17 | ||||
-rw-r--r-- | lib/libcompat/regexp/regexp.c | 22 | ||||
-rw-r--r-- | lib/libcompat/regexp/regexp.h | 71 | ||||
-rw-r--r-- | lib/libcompat/regexp/regmagic.h | 3 | ||||
-rw-r--r-- | lib/libcompat/regexp/regsub.c | 12 |
5 files changed, 90 insertions, 35 deletions
diff --git a/lib/libcompat/regexp/regerror.c b/lib/libcompat/regexp/regerror.c index 1b28f0c5f8a..1063b9722d2 100644 --- a/lib/libcompat/regexp/regerror.c +++ b/lib/libcompat/regexp/regerror.c @@ -1,22 +1,15 @@ +/* $OpenBSD: regerror.c,v 1.2 1996/07/24 05:39:11 downsj Exp $ */ #ifndef lint -static char *rcsid = "$Id: regerror.c,v 1.1.1.1 1995/10/18 08:42:35 deraadt Exp $"; +static char *rcsid = "$OpenBSD: regerror.c,v 1.2 1996/07/24 05:39:11 downsj Exp $"; #endif /* not lint */ #include <regexp.h> #include <stdio.h> void -regerror(s) +v8_regerror(s) const char *s; { -#ifdef ERRAVAIL - error("regexp: %s", s); -#else -/* - fprintf(stderr, "regexp(3): %s\n", s); - exit(1); -*/ - return; /* let std. egrep handle errors */ -#endif - /* NOTREACHED */ + warnx(s); + return; } diff --git a/lib/libcompat/regexp/regexp.c b/lib/libcompat/regexp/regexp.c index 8c013648cdb..2b2abe42f5f 100644 --- a/lib/libcompat/regexp/regexp.c +++ b/lib/libcompat/regexp/regexp.c @@ -1,3 +1,5 @@ +/* $OpenBSD: regexp.c,v 1.2 1996/07/24 05:39:11 downsj Exp $ */ + /* * regcomp and regexec -- regsub and regerror are elsewhere * @@ -34,7 +36,7 @@ */ #ifndef lint -static char *rcsid = "$Id: regexp.c,v 1.1.1.1 1995/10/18 08:42:35 deraadt Exp $"; +static char *rcsid = "$OpenBSD: regexp.c,v 1.2 1996/07/24 05:39:11 downsj Exp $"; #endif /* not lint */ #include <regexp.h> @@ -149,7 +151,7 @@ static char *rcsid = "$Id: regexp.c,v 1.1.1.1 1995/10/18 08:42:35 deraadt Exp $" #define UCHARAT(p) ((int)*(p)&CHARBITS) #endif -#define FAIL(m) { regerror(m); return(NULL); } +#define FAIL(m) { v8_regerror(m); return(NULL); } #define ISMULT(c) ((c) == '*' || (c) == '+' || (c) == '?') /* @@ -205,7 +207,7 @@ STATIC int strcspn __P((char *, char *)); * of the structure of the compiled regexp. */ regexp * -regcomp(exp) +v8_regcomp(exp) const char *exp; { register regexp *r; @@ -789,7 +791,7 @@ STATIC char *regprop __P((char *)); - regexec - match a regexp against a string */ int -regexec(prog, string) +v8_regexec(prog, string) register const regexp *prog; register const char *string; { @@ -797,13 +799,13 @@ register const char *string; /* Be paranoid... */ if (prog == NULL || string == NULL) { - regerror("NULL parameter"); + v8_regerror("NULL parameter"); return(0); } /* Check validity of program. */ if (UCHARAT(prog->program) != MAGIC) { - regerror("corrupted program"); + v8_regerror("corrupted program"); return(0); } @@ -1069,7 +1071,7 @@ char *prog; return(1); /* Success! */ break; default: - regerror("memory corruption"); + v8_regerror("memory corruption"); return(0); break; } @@ -1081,7 +1083,7 @@ char *prog; * We get here only if there's trouble -- normally "case END" is * the terminating point. */ - regerror("corrupted pointers"); + v8_regerror("corrupted pointers"); return(0); } @@ -1122,7 +1124,7 @@ char *p; } break; default: /* Oh dear. Called inappropriately. */ - regerror("internal foulup"); + v8_regerror("internal foulup"); count = 0; /* Best compromise. */ break; } @@ -1279,7 +1281,7 @@ char *op; p = "WORDZ"; break; default: - regerror("corrupted opcode"); + v8_regerror("corrupted opcode"); break; } if (p != NULL) diff --git a/lib/libcompat/regexp/regexp.h b/lib/libcompat/regexp/regexp.h index 60b950be953..e4bf5d8a367 100644 --- a/lib/libcompat/regexp/regexp.h +++ b/lib/libcompat/regexp/regexp.h @@ -1,12 +1,54 @@ +/* $OpenBSD: regexp.h,v 1.2 1996/07/24 05:39:12 downsj Exp $ */ +/* $NetBSD: regexp.h,v 1.3 1994/10/26 00:56:15 cgd Exp $ */ + +/* + * Copyright (c) 1986 by University of Toronto. + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley + * by Henry Spencer. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)regexp.h 5.2 (Berkeley) 4/3/91 + */ + +#ifndef _REGEXP_H_ +#define _REGEXP_H_ + /* * Definitions etc. for regexp(3) routines. * * Caveat: this is V8 regexp(3) [actually, a reimplementation thereof], * not the System V one. - * - * $Id: regexp.h,v 1.1.1.1 1995/10/18 08:42:35 deraadt Exp $ */ - #define NSUBEXP 10 typedef struct regexp { char *startp[NSUBEXP]; @@ -18,7 +60,22 @@ typedef struct regexp { char program[1]; /* Unwarranted chumminess with compiler. */ } regexp; -extern regexp *regcomp(); -extern int regexec(); -extern void regsub(); -extern void regerror(); +/* + * Redefine these to prevent conflicts with the POSIX routines. + */ + +#define regcomp(_exp) v8_regcomp(_exp) +#define regexec(_prg, _str) v8_regexec(_prg, _str) +#define regsub(_prg, _src, _dst) v8_regsub(_prg, _src, _dst) +#define regerror(_msg) v8_regerror(_msg) + +#include <sys/cdefs.h> + +__BEGIN_DECLS +regexp *v8_regcomp __P((const char *)); +int v8_regexec __P((const regexp *, const char *)); +void v8_regsub __P((const regexp *, const char *, char *)); +void v8_regerror __P((const char *)); +__END_DECLS + +#endif /* !_REGEXP_H_ */ diff --git a/lib/libcompat/regexp/regmagic.h b/lib/libcompat/regexp/regmagic.h index a6278263ed7..a40dfecbdf5 100644 --- a/lib/libcompat/regexp/regmagic.h +++ b/lib/libcompat/regexp/regmagic.h @@ -1,4 +1,5 @@ -/* $Id: regmagic.h,v 1.1.1.1 1995/10/18 08:42:35 deraadt Exp $ */ +/* $OpenBSD: regmagic.h,v 1.2 1996/07/24 05:39:12 downsj Exp $ */ +/* $Id: regmagic.h,v 1.2 1996/07/24 05:39:12 downsj Exp $ */ /* * The first byte of the regexp internal "program" is actually this magic diff --git a/lib/libcompat/regexp/regsub.c b/lib/libcompat/regexp/regsub.c index 0769d8801b5..9bd32b00f7f 100644 --- a/lib/libcompat/regexp/regsub.c +++ b/lib/libcompat/regexp/regsub.c @@ -1,3 +1,5 @@ +/* $OpenBSD: regsub.c,v 1.2 1996/07/24 05:39:12 downsj Exp $ */ + /* * regsub * @@ -20,7 +22,7 @@ */ #ifndef lint -static char *rcsid = "$Id: regsub.c,v 1.1.1.1 1995/10/18 08:42:35 deraadt Exp $"; +static char *rcsid = "$OpenBSD: regsub.c,v 1.2 1996/07/24 05:39:12 downsj Exp $"; #endif /* not lint */ #include <regexp.h> @@ -38,7 +40,7 @@ static char *rcsid = "$Id: regsub.c,v 1.1.1.1 1995/10/18 08:42:35 deraadt Exp $" - regsub - perform substitutions after a regexp match */ void -regsub(prog, source, dest) +v8_regsub(prog, source, dest) const regexp *prog; const char *source; char *dest; @@ -50,11 +52,11 @@ char *dest; register int len; if (prog == NULL || source == NULL || dest == NULL) { - regerror("NULL parm to regsub"); + v8_regerror("NULL parm to regsub"); return; } if (UCHARAT(prog->program) != MAGIC) { - regerror("damaged regexp fed to regsub"); + v8_regerror("damaged regexp fed to regsub"); return; } @@ -76,7 +78,7 @@ char *dest; (void) strncpy(dst, prog->startp[no], len); dst += len; if (len != 0 && *(dst-1) == '\0') { /* strncpy hit NUL. */ - regerror("damaged match string"); + v8_regerror("damaged match string"); return; } } |