From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from localhost (fantadrom.bsd.lv [local]) by fantadrom.bsd.lv (OpenSMTPD) with ESMTPA id ad5b48d5 for ; Fri, 6 Nov 2015 16:19:39 -0500 (EST) Date: Fri, 6 Nov 2015 16:19:39 -0500 (EST) Message-Id: <5112392462336475182.enqueue@fantadrom.bsd.lv> X-Mailinglist: mdocml-source Reply-To: source@mdocml.bsd.lv MIME-Version: 1.0 From: schwarze@mdocml.bsd.lv To: source@mdocml.bsd.lv Subject: mdocml: In ./configure, select a RE syntax for word boundaries supported X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 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 +#include + +int +main(void) +{ + regex_t re; + + if (regcomp(&re, "\\", 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 +#include + +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