[BACK]Return to test-rewb-bsd.c CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / mandoc

File: [cvsweb.bsd.lv] / mandoc / test-rewb-bsd.c (download)

Revision 1.1, Fri Nov 6 21:19:09 2015 UTC (8 years, 5 months ago) by schwarze
Branch: MAIN

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

#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;
}