From 442a6afd2aa35676c3e5e1eb30f8d6b41db981ab Mon Sep 17 00:00:00 2001 From: millert Date: Mon, 28 Apr 1997 20:44:55 +0000 Subject: - cast usages of *printf() to void since we don't check return val - move an assert to be *before* a strcpy() where it can do some good. - integrate NetBSD fixes for 64-bit machines (NetBSD PR #3450, Ross Harvey) - add lite2 tags --- lib/libc/regex/Makefile.inc | 3 ++- lib/libc/regex/WHATSNEW | 3 ++- lib/libc/regex/cclass.h | 4 +++- lib/libc/regex/cname.h | 4 +++- lib/libc/regex/engine.c | 26 +++++++++++++---------- lib/libc/regex/re_format.7 | 4 +++- lib/libc/regex/regcomp.c | 28 +++++++++++++++++++++++- lib/libc/regex/regerror.c | 26 ++++++++++++----------- lib/libc/regex/regex.3 | 4 +++- lib/libc/regex/regex2.h | 52 +++++++++++++++++++++++---------------------- lib/libc/regex/regexec.c | 36 +++++++++++++++++++------------ lib/libc/regex/regfree.c | 8 ++++++- lib/libc/regex/utils.h | 4 +++- 13 files changed, 131 insertions(+), 71 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/regex/Makefile.inc b/lib/libc/regex/Makefile.inc index 74adaf8264a..f4a8f687923 100644 --- a/lib/libc/regex/Makefile.inc +++ b/lib/libc/regex/Makefile.inc @@ -1,4 +1,5 @@ -# $OpenBSD: Makefile.inc,v 1.2 1996/08/19 08:31:01 tholo Exp $ +# $OpenBSD: Makefile.inc,v 1.3 1997/04/28 20:44:55 millert Exp $ +# @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 # regex sources .PATH: ${.CURDIR}/regex diff --git a/lib/libc/regex/WHATSNEW b/lib/libc/regex/WHATSNEW index a6641e9799c..95a80ed757d 100644 --- a/lib/libc/regex/WHATSNEW +++ b/lib/libc/regex/WHATSNEW @@ -1,4 +1,5 @@ -# $OpenBSD: WHATSNEW,v 1.2 1996/08/19 08:31:03 tholo Exp $ +# $OpenBSD: WHATSNEW,v 1.3 1997/04/28 20:44:56 millert Exp $ +# @(#)WHATSNEW 8.3 (Berkeley) 3/18/94 New in alpha3.4: The complex bug alluded to below has been fixed (in a slightly kludgey temporary way that may hurt efficiency a bit; this is diff --git a/lib/libc/regex/cclass.h b/lib/libc/regex/cclass.h index d10974c4169..25eb9274903 100644 --- a/lib/libc/regex/cclass.h +++ b/lib/libc/regex/cclass.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cclass.h,v 1.2 1996/08/19 08:31:04 tholo Exp $ */ +/* $OpenBSD: cclass.h,v 1.3 1997/04/28 20:44:56 millert Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 Henry Spencer. @@ -35,6 +35,8 @@ * 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. + * + * @(#)cclass.h 8.3 (Berkeley) 3/20/94 */ /* character-class table */ diff --git a/lib/libc/regex/cname.h b/lib/libc/regex/cname.h index fb357f1e46d..074b5f8ac6c 100644 --- a/lib/libc/regex/cname.h +++ b/lib/libc/regex/cname.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cname.h,v 1.2 1996/08/19 08:31:05 tholo Exp $ */ +/* $OpenBSD: cname.h,v 1.3 1997/04/28 20:44:57 millert Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 Henry Spencer. @@ -35,6 +35,8 @@ * 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. + * + * @(#)cname.h 8.3 (Berkeley) 3/20/94 */ /* character-name table */ diff --git a/lib/libc/regex/engine.c b/lib/libc/regex/engine.c index 969d530f6df..a815669ed66 100644 --- a/lib/libc/regex/engine.c +++ b/lib/libc/regex/engine.c @@ -1,3 +1,5 @@ +/* $OpenBSD: engine.c,v 1.4 1997/04/28 20:44:57 millert Exp $ */ + /*- * Copyright (c) 1992, 1993, 1994 Henry Spencer. * Copyright (c) 1992, 1993, 1994 @@ -33,10 +35,12 @@ * 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. + * + * @(#)engine.c 8.5 (Berkeley) 3/20/94 */ #if defined(SNAMES) && defined(LIBC_SCCS) && !defined(lint) -static char enginercsid[] = "$OpenBSD: engine.c,v 1.3 1997/04/12 18:22:22 millert Exp $"; +static char enginercsid[] = "$OpenBSD: engine.c,v 1.4 1997/04/28 20:44:57 millert Exp $"; #endif /* SNAMES and LIBC_SCCS and not lint */ /* @@ -125,7 +129,7 @@ static char *pchar __P((int ch)); #ifdef REDEBUG #define SP(t, s, c) print(m, t, s, c, stdout) #define AT(t, p1, p2, s1, s2) at(m, t, p1, p2, s1, s2) -#define NOTE(str) { if (m->eflags®_TRACE) printf("=%s\n", (str)); } +#define NOTE(str) { if (m->eflags®_TRACE) (void)printf("=%s\n", (str)); } #else #define SP(t, s, c) /* nothing */ #define AT(t, p1, p2, s1, s2) /* nothing */ @@ -1019,15 +1023,15 @@ FILE *d; if (!(m->eflags®_TRACE)) return; - fprintf(d, "%s", caption); + (void)fprintf(d, "%s", caption); if (ch != '\0') - fprintf(d, " %s", pchar(ch)); + (void)fprintf(d, " %s", pchar(ch)); for (i = 0; i < g->nstates; i++) if (ISSET(st, i)) { - fprintf(d, "%s%d", (first) ? "\t" : ", ", i); + (void)fprintf(d, "%s%d", (first) ? "\t" : ", ", i); first = 0; } - fprintf(d, "\n"); + (void)fprintf(d, "\n"); } /* @@ -1049,9 +1053,9 @@ sopno stopst; if (!(m->eflags®_TRACE)) return; - printf("%s %s-", title, pchar(*start)); - printf("%s ", pchar(*stop)); - printf("%d-%d\n", startst, stopst); + (void)printf("%s %s-", title, pchar(*start)); + (void)printf("%s ", pchar(*stop)); + (void)printf("%ld-%ld\n", (long)startst, (long)stopst); } #ifndef PCHARDONE @@ -1074,9 +1078,9 @@ int ch; static char pbuf[10]; if (isprint(ch) || ch == ' ') - sprintf(pbuf, "%c", ch); + (void)sprintf(pbuf, "%c", ch); else - sprintf(pbuf, "\\%o", ch); + (void)sprintf(pbuf, "\\%o", ch); return(pbuf); } #endif diff --git a/lib/libc/regex/re_format.7 b/lib/libc/regex/re_format.7 index 065a426b28a..f4271496780 100644 --- a/lib/libc/regex/re_format.7 +++ b/lib/libc/regex/re_format.7 @@ -1,4 +1,4 @@ -.\" $OpenBSD: re_format.7,v 1.2 1996/08/19 08:31:08 tholo Exp $ +.\" $OpenBSD: re_format.7,v 1.3 1997/04/28 20:44:58 millert Exp $ .\" .\" Copyright (c) 1992, 1993, 1994 Henry Spencer. .\" Copyright (c) 1992, 1993, 1994 @@ -35,6 +35,8 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" +.\" @(#)re_format.7 8.3 (Berkeley) 3/20/94 +.\" .TH RE_FORMAT 7 "March 20, 1994" .SH NAME re_format \- POSIX 1003.2 regular expressions diff --git a/lib/libc/regex/regcomp.c b/lib/libc/regex/regcomp.c index 283f66c40db..e1aad4f4b57 100644 --- a/lib/libc/regex/regcomp.c +++ b/lib/libc/regex/regcomp.c @@ -33,10 +33,16 @@ * 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. + * + * @(#)regcomp.c 8.5 (Berkeley) 3/20/94 */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: regcomp.c,v 1.3 1996/09/15 09:31:25 tholo Exp $"; +#if 0 +static char sccsid[] = "@(#)regcomp.c 8.5 (Berkeley) 3/20/94"; +#else +static char rcsid[] = "$OpenBSD: regcomp.c,v 1.4 1997/04/28 20:44:59 millert Exp $"; +#endif #endif /* LIBC_SCCS and not lint */ #include @@ -101,6 +107,7 @@ static int freezeset __P((struct parse *p, cset *cs)); static int firstch __P((struct parse *p, cset *cs)); static int nch __P((struct parse *p, cset *cs)); static void mcadd __P((struct parse *p, cset *cs, char *cp)); +static char *mcfind __P((cset *cs, char *cp)); static void mcinvert __P((struct parse *p, cset *cs)); static void mccase __P((struct parse *p, cset *cs)); static int isinsets __P((struct re_guts *g, int c)); @@ -1257,6 +1264,25 @@ register char *cp; cs->multis[cs->smultis - 1] = '\0'; } +/* + - mcfind - find a collating element in a cset + == static char *mcfind(register cset *cs, register char *cp); + */ +static char * +mcfind(cs, cp) +register cset *cs; +register char *cp; +{ + register char *p; + + if (cs->multis == NULL) + return(NULL); + for (p = cs->multis; *p != '\0'; p += strlen(p) + 1) + if (strcmp(cp, p) == 0) + return(p); + return(NULL); +} + /* - mcinvert - invert the list of collating elements in a cset == static void mcinvert(register struct parse *p, register cset *cs); diff --git a/lib/libc/regex/regerror.c b/lib/libc/regex/regerror.c index 3394ec3eb21..3adaa82f7df 100644 --- a/lib/libc/regex/regerror.c +++ b/lib/libc/regex/regerror.c @@ -33,10 +33,16 @@ * 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. + * + * @(#)regerror.c 8.4 (Berkeley) 3/20/94 */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: regerror.c,v 1.3 1996/09/15 09:31:26 tholo Exp $"; +#if 0 +static char sccsid[] = "@(#)regerror.c 8.4 (Berkeley) 3/20/94"; +#else +static char rcsid[] = "$OpenBSD: regerror.c,v 1.4 1997/04/28 20:44:59 millert Exp $"; +#endif #endif /* LIBC_SCCS and not lint */ #include @@ -131,11 +137,11 @@ size_t errbuf_size; break; if (errcode®_ITOA) { - if (r->code != 0) + if (r->code != 0) { + assert(strlen(r->name) < sizeof(convbuf)); (void) strcpy(convbuf, r->name); - else - sprintf(convbuf, "REG_0x%x", target); - assert(strlen(convbuf) < sizeof(convbuf)); + } else + (void)sprintf(convbuf, "REG_0x%x", target); s = convbuf; } else s = r->explain; @@ -143,12 +149,8 @@ size_t errbuf_size; len = strlen(s) + 1; if (errbuf_size > 0) { - if (errbuf_size > len) - (void) strcpy(errbuf, s); - else { - (void) strncpy(errbuf, s, errbuf_size-1); - errbuf[errbuf_size-1] = '\0'; - } + (void) strncpy(errbuf, s, errbuf_size-1); + errbuf[errbuf_size-1] = '\0'; } return(len); @@ -171,6 +173,6 @@ char *localbuf; if (r->code == 0) return("0"); - sprintf(localbuf, "%d", r->code); + (void)sprintf(localbuf, "%d", r->code); return(localbuf); } diff --git a/lib/libc/regex/regex.3 b/lib/libc/regex/regex.3 index 883c07c5e15..9e6d7830b9b 100644 --- a/lib/libc/regex/regex.3 +++ b/lib/libc/regex/regex.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: regex.3,v 1.2 1996/08/19 08:31:13 tholo Exp $ +.\" $OpenBSD: regex.3,v 1.3 1997/04/28 20:45:00 millert Exp $ .\" .\" Copyright (c) 1992, 1993, 1994 Henry Spencer. .\" Copyright (c) 1992, 1993, 1994 @@ -35,6 +35,8 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" +.\" @(#)regex.3 8.4 (Berkeley) 3/20/94 +.\" .TH REGEX 3 "March 20, 1994" .de ZR .\" one other place knows this name: the SEE ALSO section diff --git a/lib/libc/regex/regex2.h b/lib/libc/regex/regex2.h index 6e720e24088..d41cb97f720 100644 --- a/lib/libc/regex/regex2.h +++ b/lib/libc/regex/regex2.h @@ -1,4 +1,4 @@ -/* $OpenBSD: regex2.h,v 1.3 1997/04/12 18:22:24 millert Exp $ */ +/* $OpenBSD: regex2.h,v 1.4 1997/04/28 20:45:00 millert Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 Henry Spencer. @@ -35,6 +35,8 @@ * 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. + * + * @(#)regex2.h 8.4 (Berkeley) 3/20/94 */ /* @@ -75,36 +77,36 @@ * In state representations, an operator's bit is on to signify a state * immediately *preceding* "execution" of that operator. */ -typedef unsigned sop; /* strip operator */ -typedef int sopno; -#define OPRMASK 0xf8000000 -#define OPDMASK 0x07ffffff +typedef unsigned long sop; /* strip operator */ +typedef long sopno; +#define OPRMASK 0xf8000000L +#define OPDMASK 0x07ffffffL #define OPSHIFT ((unsigned)27) #define OP(n) ((n)&OPRMASK) #define OPND(n) ((n)&OPDMASK) #define SOP(op, opnd) ((op)|(opnd)) /* operators meaning operand */ /* (back, fwd are offsets) */ -#define OEND (1<> (n)) -#define ISSETBACK(v, n) (((v) & ((unsigned)here >> (n))) != 0) +#define FWD(dst, src, n) ((dst) |= ((unsigned long)(src)&(here)) << (n)) +#define BACK(dst, src, n) ((dst) |= ((unsigned long)(src)&(here)) >> (n)) +#define ISSETBACK(v, n) (((v) & ((unsigned long)here >> (n))) != 0) /* function names */ #define SNAMES /* engine.c looks after details */ @@ -113,13 +121,13 @@ static char rcsid[] = "$OpenBSD: regexec.c,v 1.5 1997/04/12 18:22:25 millert Exp #define ISSET(v, n) ((v)[n]) #define ASSIGN(d, s) memcpy(d, s, m->g->nstates) #define EQ(a, b) (memcmp(a, b, m->g->nstates) == 0) -#define STATEVARS int vn; char *space +#define STATEVARS long vn; char *space #define STATESETUP(m, nv) { (m)->space = malloc((nv)*(m)->g->nstates); \ if ((m)->space == NULL) return(REG_ESPACE); \ (m)->vn = 0; } #define STATETEARDOWN(m) { free((m)->space); } #define SETUP(v) ((v) = &m->space[m->vn++ * m->g->nstates]) -#define onestate int +#define onestate long #define INIT(o, n) ((o) = (n)) #define INC(o) ((o)++) #define ISSTATEIN(v, o) ((v)[o]) diff --git a/lib/libc/regex/regfree.c b/lib/libc/regex/regfree.c index 57471d675c5..e7a9edfc88d 100644 --- a/lib/libc/regex/regfree.c +++ b/lib/libc/regex/regfree.c @@ -33,10 +33,16 @@ * 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. + * + * @(#)regfree.c 8.3 (Berkeley) 3/20/94 */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: regfree.c,v 1.2 1996/08/19 08:31:16 tholo Exp $"; +#if 0 +static char sccsid[] = "@(#)regfree.c 8.3 (Berkeley) 3/20/94"; +#else +static char rcsid[] = "$OpenBSD: regfree.c,v 1.3 1997/04/28 20:45:01 millert Exp $"; +#endif #endif /* LIBC_SCCS and not lint */ #include diff --git a/lib/libc/regex/utils.h b/lib/libc/regex/utils.h index 165b166b441..52c28bbedef 100644 --- a/lib/libc/regex/utils.h +++ b/lib/libc/regex/utils.h @@ -1,4 +1,4 @@ -/* $OpenBSD: utils.h,v 1.2 1996/08/19 08:31:17 tholo Exp $ */ +/* $OpenBSD: utils.h,v 1.3 1997/04/28 20:45:02 millert Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 Henry Spencer. @@ -35,6 +35,8 @@ * 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. + * + * @(#)utils.h 8.3 (Berkeley) 3/20/94 */ /* utility definitions */ -- cgit v1.2.3-59-g8ed1b