source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: In ./configure, select a RE syntax for word boundaries supported
@ 2015-11-06 21:19 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2015-11-06 21:19 UTC (permalink / raw)
  To: source

Log Message:
-----------
In ./configure, select a RE syntax for word boundaries supported by libc;
issue reported by Svyatoslav Mishyn, Peter Bray, and Daniel Levai.

Modified Files:
--------------
    mdocml:
        TODO
        configure
        mansearch.c

Added Files:
-----------
    mdocml:
        test-rewb-bsd.c
        test-rewb-sysv.c

Revision Data
-------------
Index: configure
===================================================================
RCS file: /home/cvs/mdocml/mdocml/configure,v
retrieving revision 1.30
retrieving revision 1.31
diff -Lconfigure -Lconfigure -u -p -r1.30 -r1.31
--- configure
+++ configure
@@ -53,6 +53,8 @@ HAVE_MMAP=
 HAVE_PLEDGE=
 HAVE_PROGNAME=
 HAVE_REALLOCARRAY=
+HAVE_REWB_BSD=
+HAVE_REWB_SYSV=
 HAVE_STRCASESTR=
 HAVE_STRINGLIST=
 HAVE_STRLCAT=
@@ -184,6 +186,8 @@ runtest mmap		MMAP		|| true
 runtest pledge		PLEDGE		|| true
 runtest progname	PROGNAME	|| true
 runtest reallocarray	REALLOCARRAY	|| true
+runtest rewb-bsd	REWB_BSD	|| true
+runtest rewb-sysv	REWB_SYSV	|| true
 runtest strcasestr	STRCASESTR	|| true
 runtest stringlist	STRINGLIST	|| true
 runtest strlcat		STRLCAT		|| true
@@ -306,6 +310,8 @@ cat << __HEREDOC__
 #define HAVE_PLEDGE ${HAVE_PLEDGE}
 #define HAVE_PROGNAME ${HAVE_PROGNAME}
 #define HAVE_REALLOCARRAY ${HAVE_REALLOCARRAY}
+#define HAVE_REWB_BSD ${HAVE_REWB_BSD}
+#define HAVE_REWB_SYSV ${HAVE_REWB_SYSV}
 #define HAVE_STRCASESTR ${HAVE_STRCASESTR}
 #define HAVE_STRINGLIST ${HAVE_STRINGLIST}
 #define HAVE_STRLCAT ${HAVE_STRLCAT}
--- /dev/null
+++ test-rewb-sysv.c
@@ -0,0 +1,26 @@
+#include <sys/types.h>
+#include <regex.h>
+
+int
+main(void)
+{
+	regex_t	 re;
+
+	if (regcomp(&re, "\\<word\\>", REG_EXTENDED | REG_NOSUB))
+		return 1;
+	if (regexec(&re, "the word is here", 0, NULL, 0))
+		return 2;
+	if (regexec(&re, "same word", 0, NULL, 0))
+		return 3;
+	if (regexec(&re, "word again", 0, NULL, 0))
+		return 4;
+	if (regexec(&re, "word", 0, NULL, 0))
+		return 5;
+	if (regexec(&re, "wordy", 0, NULL, 0) != REG_NOMATCH)
+		return 6;
+	if (regexec(&re, "sword", 0, NULL, 0) != REG_NOMATCH)
+		return 7;
+	if (regexec(&re, "reworded", 0, NULL, 0) != REG_NOMATCH)
+		return 8;
+	return 0;
+}
--- /dev/null
+++ test-rewb-bsd.c
@@ -0,0 +1,26 @@
+#include <sys/types.h>
+#include <regex.h>
+
+int
+main(void)
+{
+	regex_t	 re;
+
+	if (regcomp(&re, "[[:<:]]word[[:>:]]", REG_EXTENDED | REG_NOSUB))
+		return 1;
+	if (regexec(&re, "the word is here", 0, NULL, 0))
+		return 2;
+	if (regexec(&re, "same word", 0, NULL, 0))
+		return 3;
+	if (regexec(&re, "word again", 0, NULL, 0))
+		return 4;
+	if (regexec(&re, "word", 0, NULL, 0))
+		return 5;
+	if (regexec(&re, "wordy", 0, NULL, 0) != REG_NOMATCH)
+		return 6;
+	if (regexec(&re, "sword", 0, NULL, 0) != REG_NOMATCH)
+		return 7;
+	if (regexec(&re, "reworded", 0, NULL, 0) != REG_NOMATCH)
+		return 8;
+	return 0;
+}
Index: TODO
===================================================================
RCS file: /home/cvs/mdocml/mdocml/TODO,v
retrieving revision 1.214
retrieving revision 1.215
diff -LTODO -LTODO -u -p -r1.214 -r1.215
--- TODO
+++ TODO
@@ -527,12 +527,6 @@ are mere guesses, and some may be wrong.
 * portability
 ************************************************************************
 
-- word boundaries in regular expressions for whatis(1)
-  set up config tests to use [[:<:]], \<, or nothing
-  Svyatoslav Mishyn  Wed, 17 Dec 2014 11:07:10 +0200
-  reminded by Peter Bray Fri, 03 Apr 2015 23:02:16 +1100
-  loc *  exist *  algo *  size *  imp *
-
 - systems having UTF-8 but not en_US.UTF-8
   call locale(1) from ./configure, select a UTF-8-locale,
   and use that for test-wchar.c and term_ascii.c
Index: mansearch.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mansearch.c,v
retrieving revision 1.60
retrieving revision 1.61
diff -Lmansearch.c -Lmansearch.c -u -p -r1.60 -r1.61
--- mansearch.c
+++ mansearch.c
@@ -766,7 +766,14 @@ exprterm(const struct mansearch *search,
 	if (search->argmode == ARG_WORD) {
 		e->bits = TYPE_Nm;
 		e->substr = NULL;
+#if HAVE_REWB_BSD
 		mandoc_asprintf(&val, "[[:<:]]%s[[:>:]]", buf);
+#elif HAVE_REWB_SYSV
+		mandoc_asprintf(&val, "\\<%s\\>", buf);
+#else
+		mandoc_asprintf(&val,
+		    "(^|[^a-zA-Z01-9_])%s([^a-zA-Z01-9_]|$)", buf);
+#endif
 		cs = 0;
 	} else if ((val = strpbrk(buf, "=~")) == NULL) {
 		e->bits = TYPE_Nm | TYPE_Nd;
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-11-06 21:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-06 21:19 mdocml: In ./configure, select a RE syntax for word boundaries supported schwarze

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).