diff options
author | ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069> | 2014-04-18 15:37:56 +0000 |
---|---|---|
committer | ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069> | 2014-04-18 15:37:56 +0000 |
commit | 8a7e1b1a832eb25fa9bf3ba8eeb7e2cfaad7839f (patch) | |
tree | 3e1c7f920800670516b46c59ae481a71ee0b2574 /src/pcre2_substring.c | |
parent | c1380a97c8830a473b48e815569d4a6b0d48acb8 (diff) | |
download | pcre2-8a7e1b1a832eb25fa9bf3ba8eeb7e2cfaad7839f.tar.gz |
Refactor the framework for revised API.
git-svn-id: svn://vcs.exim.org/pcre2/code/trunk@6 6239d852-aaf2-0410-a92c-79f79f948069
Diffstat (limited to 'src/pcre2_substring.c')
-rw-r--r-- | src/pcre2_substring.c | 135 |
1 files changed, 68 insertions, 67 deletions
diff --git a/src/pcre2_substring.c b/src/pcre2_substring.c index eec27d7..6b0ac7a 100644 --- a/src/pcre2_substring.c +++ b/src/pcre2_substring.c @@ -72,7 +72,7 @@ Returns: if successful: */ PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION -pcre2_copy_named_substring(pcre2_match_data *match_data, PCRE2_SPTR stringname, +pcre2_substring_copy_byname(pcre2_match_data *match_data, PCRE2_SPTR stringname, PCRE2_UCHAR *buffer, size_t size) { match_data=match_data;stringname=stringname;buffer=buffer;size=size; @@ -103,7 +103,7 @@ Returns: if successful: */ PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION -pcre2_copy_substring(pcre2_match_data *match_data, int stringnumber, +pcre2_substring_copy_bynumber(pcre2_match_data *match_data, int stringnumber, PCRE2_UCHAR *buffer, size_t size) { match_data=match_data;stringnumber=stringnumber;buffer=buffer;size=size; @@ -127,9 +127,9 @@ Returns: nothing */ PCRE2_EXP_DEFN void PCRE2_CALL_CONVENTION -pcre2_free_substring(pcre2_context *context, PCRE2_UCHAR *string) +pcre2_substring_free(PCRE2_UCHAR *string) { -context->free(string, context->user_data); +string=string; return; } @@ -151,9 +151,9 @@ Returns: nothing PCRE2_EXP_DEFN void PCRE2_CALL_CONVENTION -pcre2_free_substring_list(pcre2_context *context, PCRE2_SPTR *list) +pcre2_substring_list_free(PCRE2_SPTR *list) { -context->free(list, context->user_data); +list=list; return; } @@ -182,94 +182,67 @@ Returns: if successful: */ PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION -pcre2_get_named_substring(pcre2_context *context, pcre2_match_data *match_data, +pcre2_substring_get_byname(pcre2_match_data *match_data, PCRE2_SPTR stringname, PCRE2_UCHAR **stringptr) { -context=context;match_data=match_data;stringname=stringname;stringptr=stringptr; +match_data=match_data;stringname=stringname;stringptr=stringptr; return PCRE2_ERROR_NOSUBSTRING; } /************************************************* -* Get length of a named substring * -*************************************************/ - -/* This function returns the length of a named captured substring. If the regex -permits duplicate names, the first substring that is set is chosen. - -Arguments: - match_data pointer to match data - stringname the name of the required substring - -Returns: a non-negative length if successful - a negative error code otherwise -*/ - -PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION -pcre2_get_named_substring_length(pcre2_match_data *match_data, - PCRE2_SPTR stringname) -{ -match_data=match_data;stringname=stringname; -return PCRE2_ERROR_NOSUBSTRING; -} - - - -/************************************************* -* Find (multiple) entries for named string * +* Extract captured string to new memory * *************************************************/ -/* This is used by the local get_first_set() function, as well as being -generally available. It is used when duplicated names are permitted. +/* This function copies a single captured substring into a piece of new +memory. Arguments: - code the compiled regex - stringname the name whose entries required - firstptr where to put the pointer to the first entry - lastptr where to put the pointer to the last entry + context points to a PCRE2 context + match_data points to match data + stringnumber the number of the required substring + stringptr where to put a pointer to the substring -Returns: the length of each entry, or a negative number - (PCRE2_ERROR_NOSUBSTRING) if not found +Returns: if successful: + the length of the string, not including the zero that + is put on the end; can be zero + if not successful a negative error code: + PCRE2_ERROR_NOMEMORY: failed to get memory + PCRE2_ERROR_NOSUBSTRING: substring not present */ PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION -pcre2_get_stringtable_entries(const pcre2_code *code, PCRE2_SPTR stringname, - PCRE2_UCHAR **firstptr, PCRE2_UCHAR **lastptr) +pcre2_substring_get_bynumber(pcre2_match_data *match_data, int stringnumber, + PCRE2_UCHAR **stringptr) { -code=code;stringname=stringname;firstptr=firstptr;lastptr=lastptr; +match_data=match_data;stringnumber=stringnumber; +stringptr=stringptr; return PCRE2_ERROR_NOSUBSTRING; } /************************************************* -* Extract captured string to new memory * +* Get length of a named substring * *************************************************/ -/* This function copies a single captured substring into a piece of new -memory. +/* This function returns the length of a named captured substring. If the regex +permits duplicate names, the first substring that is set is chosen. Arguments: - context points to a PCRE2 context - match_data points to match data - stringnumber the number of the required substring - stringptr where to put a pointer to the substring + match_data pointer to match data + stringname the name of the required substring -Returns: if successful: - the length of the string, not including the zero that - is put on the end; can be zero - if not successful a negative error code: - PCRE2_ERROR_NOMEMORY: failed to get memory - PCRE2_ERROR_NOSUBSTRING: substring not present +Returns: a non-negative length if successful + a negative error code otherwise */ PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION -pcre2_get_substring(pcre2_context *context, pcre2_match_data *match_data, - int stringnumber, PCRE2_UCHAR **stringptr) +pcre2_substring_length_byname(pcre2_match_data *match_data, + PCRE2_SPTR stringname) { -context=context;match_data=match_data;stringnumber=stringnumber; -stringptr=stringptr; +match_data=match_data;stringname=stringname; return PCRE2_ERROR_NOSUBSTRING; } @@ -290,7 +263,7 @@ Returns: a non-negative length if successful */ PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION -pcre2_get_substring_length(pcre2_match_data *match_data, +pcre2_substring_length_bynumber(pcre2_match_data *match_data, int stringnumber) { match_data=match_data;stringnumber=stringnumber; @@ -317,10 +290,10 @@ Returns: if successful: 0 */ PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION -pcre2_get_substring_list(pcre2_context *context, pcre2_match_data *match_data, - PCRE2_UCHAR ***listptr) +pcre2_substring_list_get(pcre2_match_data *match_data, PCRE2_UCHAR ***listptr, + size_t **lengthsptr) { -context=context;match_data=match_data;listptr=listptr; +match_data=match_data;listptr=listptr;lengthsptr=lengthsptr; return PCRE2_ERROR_NOMEMORY; } @@ -342,11 +315,39 @@ Returns: the number of the named parentheses, or a negative number */ PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION - pcre2_get_substring_number(const pcre2_code *code, PCRE2_SPTR stringname) +pcre2_substring_number_from_name(const pcre2_code *code, + PCRE2_SPTR stringname) { code=code;stringname=stringname; return PCRE2_ERROR_NOSUBSTRING; } + +/************************************************* +* Find (multiple) entries for named string * +*************************************************/ + +/* This is used by the local get_first_set() function, as well as being +generally available. It is used when duplicated names are permitted. + +Arguments: + code the compiled regex + stringname the name whose entries required + firstptr where to put the pointer to the first entry + lastptr where to put the pointer to the last entry + +Returns: the length of each entry, or a negative number + (PCRE2_ERROR_NOSUBSTRING) if not found +*/ + +PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION +pcre2_substring_nametable_scan(const pcre2_code *code, PCRE2_SPTR stringname, + PCRE2_UCHAR **firstptr, PCRE2_UCHAR **lastptr) +{ +code=code;stringname=stringname;firstptr=firstptr;lastptr=lastptr; +return PCRE2_ERROR_NOSUBSTRING; +} + + /* End of pcre2_substring.c */ |