diff options
author | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2007-06-04 10:49:21 +0000 |
---|---|---|
committer | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2007-06-04 10:49:21 +0000 |
commit | 756fe1f5dfc297c4420809b85f636f7fdcfce7ff (patch) | |
tree | 5609f92de79d42934bc5f5b443a9b40c0bd290f2 | |
parent | a66e7e0c24877a1f878fe3bc29078143d018f888 (diff) | |
download | pcre-756fe1f5dfc297c4420809b85f636f7fdcfce7ff.tar.gz |
Add PCRE_INFO_OKPARTIAL and PCRE_INFO_JCHANGED.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@169 2f5784b3-3f2a-0410-8824-cb99058d5e15
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | doc/pcreapi.3 | 18 | ||||
-rw-r--r-- | doc/pcrepartial.3 | 4 | ||||
-rw-r--r-- | pcre.h.in | 2 | ||||
-rw-r--r-- | pcre_fullinfo.c | 8 | ||||
-rw-r--r-- | pcretest.c | 19 | ||||
-rw-r--r-- | testdata/testoutput2 | 1 |
7 files changed, 42 insertions, 13 deletions
@@ -35,6 +35,9 @@ Version 7.2 01-May-07 (d) \K resets the start of the current match so that everything before is not part of it. + + 7. Added two new calls to pcre_fullinfo(): PCRE_INFO_OKPARTIAL and + PCRE_INFO_JCHANGED. Version 7.1 24-Apr-07 diff --git a/doc/pcreapi.3 b/doc/pcreapi.3 index 0e33761..94684df 100644 --- a/doc/pcreapi.3 +++ b/doc/pcreapi.3 @@ -871,6 +871,12 @@ table indicating a fixed set of bytes for the first byte in any matching string, a pointer to the table is returned. Otherwise NULL is returned. The fourth argument should point to an \fBunsigned char *\fP variable. .sp + PCRE_INFO_JCHANGED +.sp +Return 1 if the (?J) option setting is used in the pattern, otherwise 0. The +fourth argument should point to an \fBint\fP variable. The (?J) internal option +setting changes the local PCRE_DUPNAMES value. +.sp PCRE_INFO_LASTLITERAL .sp Return the value of the rightmost literal byte that must exist in any matched @@ -923,6 +929,16 @@ When writing code to extract data from named subpatterns using the name-to-number map, remember that the length of the entries is likely to be different for each compiled pattern. .sp + PCRE_INFO_OKPARTIAL +.sp +Return 1 if the pattern can be used for partial matching, otherwise 0. The +fourth argument should point to an \fBint\fP variable. The +.\" HREF +\fBpcrepartial\fP +.\" +documentation lists the restrictions that apply to patterns when partial +matching is used. +.sp PCRE_INFO_OPTIONS .sp Return a copy of the options with which the pattern was compiled. The fourth @@ -1851,6 +1867,6 @@ Cambridge CB2 3QH, England. .rs .sp .nf -Last updated: 24 April 2007 +Last updated: 04 June 2007 Copyright (c) 1997-2007 University of Cambridge. .fi diff --git a/doc/pcrepartial.3 b/doc/pcrepartial.3 index 21008c1..6b88b7f 100644 --- a/doc/pcrepartial.3 +++ b/doc/pcrepartial.3 @@ -71,6 +71,8 @@ envisaged for this facility, this is not felt to be a major restriction. .P If PCRE_PARTIAL is set for a pattern that does not conform to the restrictions, \fBpcre_exec()\fP returns the error code PCRE_ERROR_BADPARTIAL (-13). +You can use the PCRE_INFO_OKPARTIAL call to \fBpcre_fullinfo()\fP to find out +if a compiled pattern can be used for partial matching. . . .SH "EXAMPLE OF PARTIAL MATCHING USING PCRETEST" @@ -212,6 +214,6 @@ Cambridge CB2 3QH, England. .rs .sp .nf -Last updated: 06 March 2007 +Last updated: 04 June 2007 Copyright (c) 1997-2007 University of Cambridge. .fi @@ -150,6 +150,8 @@ extern "C" { #define PCRE_INFO_NAMETABLE 9 #define PCRE_INFO_STUDYSIZE 10 #define PCRE_INFO_DEFAULT_TABLES 11 +#define PCRE_INFO_OKPARTIAL 12 +#define PCRE_INFO_JCHANGED 13 /* Request types for pcre_config(). Do not re-arrange, in order to remain compatible. */ diff --git a/pcre_fullinfo.c b/pcre_fullinfo.c index 8c0e54d..7682435 100644 --- a/pcre_fullinfo.c +++ b/pcre_fullinfo.c @@ -139,6 +139,14 @@ switch (what) case PCRE_INFO_DEFAULT_TABLES: *((const uschar **)where) = (const uschar *)(_pcre_default_tables); break; + + case PCRE_INFO_OKPARTIAL: + *((int *)where) = (re->options & PCRE_NOPARTIAL) == 0; + break; + + case PCRE_INFO_JCHANGED: + *((int *)where) = (re->options & PCRE_JCHANGED) != 0; + break; default: return PCRE_ERROR_BADOPTION; } @@ -1352,7 +1352,7 @@ while (!done) #if !defined NOINFOCHECK int old_first_char, old_options, old_count; #endif - int count, backrefmax, first_char, need_char; + int count, backrefmax, first_char, need_char, okpartial, jchanged; int nameentrysize, namecount; const uschar *nametable; @@ -1365,6 +1365,8 @@ while (!done) new_info(re, NULL, PCRE_INFO_NAMEENTRYSIZE, &nameentrysize); new_info(re, NULL, PCRE_INFO_NAMECOUNT, &namecount); new_info(re, NULL, PCRE_INFO_NAMETABLE, (void *)&nametable); + new_info(re, NULL, PCRE_INFO_OKPARTIAL, &okpartial); + new_info(re, NULL, PCRE_INFO_JCHANGED, &jchanged); #if !defined NOINFOCHECK old_count = pcre_info(re, &old_options, &old_first_char); @@ -1405,18 +1407,11 @@ while (!done) nametable += nameentrysize; } } - - /* The NOPARTIAL bit is a private bit in the options, so we have - to fish it out via out back door */ + + if (!okpartial) fprintf(outfile, "Partial matching not supported\n"); all_options = ((real_pcre *)re)->options; - if (do_flip) - { - all_options = byteflip(all_options, sizeof(all_options)); - } - - if ((all_options & PCRE_NOPARTIAL) != 0) - fprintf(outfile, "Partial matching not supported\n"); + if (do_flip) all_options = byteflip(all_options, sizeof(all_options)); if (get_options == 0) fprintf(outfile, "No options\n"); else fprintf(outfile, "Options:%s%s%s%s%s%s%s%s%s%s%s%s%s\n", @@ -1433,6 +1428,8 @@ while (!done) ((get_options & PCRE_UTF8) != 0)? " utf8" : "", ((get_options & PCRE_NO_UTF8_CHECK) != 0)? " no_utf8_check" : "", ((get_options & PCRE_DUPNAMES) != 0)? " dupnames" : ""); + + if (jchanged) fprintf(outfile, "Duplicate name status changes\n"); switch (get_options & PCRE_NEWLINE_BITS) { diff --git a/testdata/testoutput2 b/testdata/testoutput2 index 7fefbe4..8cda6a2 100644 --- a/testdata/testoutput2 +++ b/testdata/testoutput2 @@ -6193,6 +6193,7 @@ Named capturing subpatterns: B 3 C 4 Options: anchored +Duplicate name status changes No first char No need char a bc d\CA\CB\CC |