summaryrefslogtreecommitdiffstats
path: root/fortune/fortune
diff options
context:
space:
mode:
authoraymeric <aymeric@NetBSD.org>2001-06-04 20:56:56 +0000
committeraymeric <aymeric@NetBSD.org>2001-06-04 20:56:56 +0000
commit027e644f7220209643890079bfe9a2c9b35b9998 (patch)
tree3d56c3857d82e836c87a374d7b422a10114e3200 /fortune/fortune
parentf47771ea66c0cafa6abdf85d6e629fbf84aaa3fe (diff)
downloadbsdgames-darwin-027e644f7220209643890079bfe9a2c9b35b9998.tar.gz
bsdgames-darwin-027e644f7220209643890079bfe9a2c9b35b9998.tar.zst
bsdgames-darwin-027e644f7220209643890079bfe9a2c9b35b9998.zip
Bail out when regex pattern is invalid if using regcomp or regcmp.
Remove trailing \n's also. Addresses PR#13109
Diffstat (limited to 'fortune/fortune')
-rw-r--r--fortune/fortune/fortune.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/fortune/fortune/fortune.c b/fortune/fortune/fortune.c
index 0593b0c7..5bef1ede 100644
--- a/fortune/fortune/fortune.c
+++ b/fortune/fortune/fortune.c
@@ -1,4 +1,4 @@
-/* $NetBSD: fortune.c,v 1.27 2001/02/19 22:41:45 cgd Exp $ */
+/* $NetBSD: fortune.c,v 1.28 2001/06/04 20:56:56 aymeric Exp $ */
/*-
* Copyright (c) 1986, 1993
@@ -46,7 +46,7 @@ __COPYRIGHT("@(#) Copyright (c) 1986, 1993\n\
#if 0
static char sccsid[] = "@(#)fortune.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: fortune.c,v 1.27 2001/02/19 22:41:45 cgd Exp $");
+__RCSID("$NetBSD: fortune.c,v 1.28 2001/06/04 20:56:56 aymeric Exp $");
#endif
#endif /* not lint */
@@ -391,11 +391,11 @@ getargs(argc, argv)
pat = conv_pat(pat);
RE_INIT();
if (BAD_COMP(RE_COMP(pat))) {
-#ifdef HAVE_REGCMP
- warnx("bad pattern: %s\n", pat);
-#else /* !HAVE_REGCMP */
- warnx("%s\n", pat);
-#endif /* !HAVE_REGCMP */
+#if defined(HAVE_REGCMP) || defined(HAVE_REGCOMP)
+ errx(1, "bad pattern: %s", pat);
+#else /* !HAVE_REGCMP && !HAVE_REGCOMP */
+ warnx("%s", pat);
+#endif /* !HAVE_REGCMP && !HAVE_REGCOMP */
RE_FREE();
}
}