From: schwarze@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: In ./configure, select a RE syntax for word boundaries supported
Date: Fri, 6 Nov 2015 16:19:39 -0500 (EST) [thread overview]
Message-ID: <5112392462336475182.enqueue@fantadrom.bsd.lv> (raw)
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
reply other threads:[~2015-11-06 21:19 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5112392462336475182.enqueue@fantadrom.bsd.lv \
--to=schwarze@mdocml.bsd.lv \
--cc=source@mdocml.bsd.lv \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).