diff options
author | Dmitry Mikhirev | 2015-02-15 15:10:15 +0300 |
---|---|---|
committer | Dmitry Mikhirev | 2015-02-15 15:10:15 +0300 |
commit | e6f7aee8c27d87047857b9daf0075e90062b4ac2 (patch) | |
tree | 0c2876dce16c20a7ae938a7314dfa8c0e1d3dbfe | |
parent | 15f22648cd99f392ac5cab6afeec2a0e97b85c6d (diff) | |
download | make_pcre-e6f7aee8c27d87047857b9daf0075e90062b4ac2.tar.gz make_pcre-e6f7aee8c27d87047857b9daf0075e90062b4ac2.tar.bz2 make_pcre-e6f7aee8c27d87047857b9daf0075e90062b4ac2.tar.xz make_pcre-e6f7aee8c27d87047857b9daf0075e90062b4ac2.zip |
added php-like options `A' and `D'
-rw-r--r-- | README.md | 4 | ||||
-rw-r--r-- | pcre.c | 4 | ||||
-rw-r--r-- | tests.mk | 14 |
3 files changed, 21 insertions, 1 deletions
@@ -104,6 +104,10 @@ of one ore more characters, each of which enables some option: The following options are implemented: +- `A` makes expression anchored, i. e. constrained to match only at the first + matching point in the string. The same as in PHP; +- `D` forces a `$` metacharacter to match only before a newline at the end + of the string, not before any other newlines. The same as in PHP; - `E` enables expansion of pattern before compilation. Note that you will need to use `$$` instead `$` for matching end of line in this case; - `g` enables global search, like in Perl. `pcre_find` will return space @@ -202,6 +202,10 @@ static int parse_comp_opt(const char flag, const char *func) int b; /* PCRE configuration option value */ switch (flag) { + case 'A': /* anchored regexp */ + return PCRE_ANCHORED; + case 'D': /* $ matches at the and of string only */ + return PCRE_DOLLAR_ENDONLY; case 'i': /* ignore case */ return PCRE_CASELESS; case 'm': /* multi-line */ @@ -2,7 +2,7 @@ ifneq ($(findstring 4.,$(MAKE_VERSION)),4.) $(error you need GNU make 4.x to run tests) endif -NUMTESTS = 32 +NUMTESTS = 34 tests := $(foreach num,$(shell seq -f%03g $(NUMTESTS)),test$(num)) load pcre.so @@ -117,6 +117,18 @@ test030 = -z "$(m test.test,$(subj029))" -a \ test031 = "$(m x?,aaa,g)" = "" test032 = "$(s x?,!,abcd,g)" = "!a!b!c!d!" +# test `A' option +test033 = -z "$(m test,atest,A)" -a "$(m test,test,A)" = "test" + +# test `D' option +define subj034 +line1 +line2 + +endef +test034 = "$(m line\d$,$(subj034))" = "line2" -a -z "$(m line\d$,$(subj034),D)" -a \ + "$(m test$,test,D)" = "test" + ### END OF TEST EXPRESSIONS ### test%: |