summaryrefslogtreecommitdiff
path: root/src/pcre2_context.c
diff options
context:
space:
mode:
authorph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069>2014-06-24 09:51:58 +0000
committerph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069>2014-06-24 09:51:58 +0000
commit27f9bc29120e545b5f49791df1ea91d0f02c3a30 (patch)
tree8b073f4775bfe3f8897fb6e1f5093b24c9441879 /src/pcre2_context.c
parentaeab49e60fbe4fcc167f26fe6663e8f258835315 (diff)
downloadpcre2-27f9bc29120e545b5f49791df1ea91d0f02c3a30.tar.gz
Allow \R and newline handling to be specified at match time (as for PCRE1).
git-svn-id: svn://vcs.exim.org/pcre2/code/trunk@19 6239d852-aaf2-0410-a92c-79f79f948069
Diffstat (limited to 'src/pcre2_context.c')
-rw-r--r--src/pcre2_context.c67
1 files changed, 50 insertions, 17 deletions
diff --git a/src/pcre2_context.c b/src/pcre2_context.c
index 376a807..724a152 100644
--- a/src/pcre2_context.c
+++ b/src/pcre2_context.c
@@ -172,6 +172,8 @@ mcontext->stack_malloc = mcontext->malloc;
mcontext->stack_free = mcontext->free;
#endif
mcontext->callout = NULL;
+mcontext->newline_convention = 0;
+mcontext->bsr_convention = 0;
mcontext->match_limit = MATCH_LIMIT;
mcontext->recursion_limit = MATCH_LIMIT_RECURSION;
}
@@ -269,8 +271,19 @@ if (mcontext != NULL)
/* All these functions return 1 for success or 0 if invalid data is given. Only
some of the functions are able to test the validity of the data. */
+
+/* ------------ Compile contexts ------------ */
+
+PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
+pcre2_set_character_tables(pcre2_compile_context *ccontext,
+ const unsigned char *tables)
+{
+ccontext->tables = tables;
+return 1;
+}
+
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
-pcre2_set_bsr_convention(pcre2_compile_context *ccontext, uint32_t value)
+pcre2_set_bsr_compile(pcre2_compile_context *ccontext, uint32_t value)
{
switch(value)
{
@@ -284,18 +297,8 @@ switch(value)
}
}
-
-PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
-pcre2_set_character_tables(pcre2_compile_context *ccontext,
- const unsigned char *tables)
-{
-ccontext->tables = tables;
-return 1;
-}
-
-
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
-pcre2_set_newline_convention(pcre2_compile_context *ccontext, uint32_t newline)
+pcre2_set_newline_compile(pcre2_compile_context *ccontext, uint32_t newline)
{
switch(newline)
{
@@ -312,7 +315,6 @@ switch(newline)
}
}
-
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
pcre2_set_parens_nest_limit(pcre2_compile_context *ccontext, uint32_t limit)
{
@@ -320,7 +322,6 @@ ccontext->parens_nest_limit = limit;
return 1;
}
-
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
pcre2_set_compile_recursion_guard(pcre2_compile_context *ccontext,
int (*guard)(uint32_t))
@@ -330,6 +331,41 @@ return 1;
}
+/* ------------ Match contexts ------------ */
+
+PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
+pcre2_set_bsr_match(pcre2_match_context *mcontext, uint32_t value)
+{
+switch(value)
+ {
+ case PCRE2_BSR_ANYCRLF:
+ case PCRE2_BSR_UNICODE:
+ mcontext->bsr_convention = value;
+ return 1;
+
+ default:
+ return 0;
+ }
+}
+
+PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
+pcre2_set_newline_match(pcre2_match_context *mcontext, uint32_t newline)
+{
+switch(newline)
+ {
+ case PCRE2_NEWLINE_CR:
+ case PCRE2_NEWLINE_LF:
+ case PCRE2_NEWLINE_CRLF:
+ case PCRE2_NEWLINE_ANY:
+ case PCRE2_NEWLINE_ANYCRLF:
+ mcontext->newline_convention = newline;
+ return 1;
+
+ default:
+ return 0;
+ }
+}
+
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
pcre2_set_callout(pcre2_match_context *mcontext,
int (*callout)(pcre2_callout_block *, void *))
@@ -338,7 +374,6 @@ mcontext->callout = callout;
return 1;
}
-
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
pcre2_set_match_limit(pcre2_match_context *mcontext, uint32_t limit)
{
@@ -353,7 +388,6 @@ mcontext->recursion_limit = limit;
return 1;
}
-
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
pcre2_set_recursion_memory_management(pcre2_match_context *mcontext,
void *(*mymalloc)(size_t, void *),
@@ -370,5 +404,4 @@ mcontext->stack_free = myfree;
return 1;
}
-
/* End of pcre2_context.c */