diff options
author | zherczeg <zherczeg@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2011-11-22 21:46:22 +0000 |
---|---|---|
committer | zherczeg <zherczeg@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2011-11-22 21:46:22 +0000 |
commit | e999fd0968252b446d0c5f88282767cd5b6c208a (patch) | |
tree | 78eb4172abdcae4a1336c336bf924415950e3e1e | |
parent | 467f4e6a0feb3d8fa900c3ce20d4b96562d03193 (diff) | |
download | pcre-e999fd0968252b446d0c5f88282767cd5b6c208a.tar.gz |
string utilities added
git-svn-id: svn://vcs.exim.org/pcre/code/branches/pcre16@763 2f5784b3-3f2a-0410-8824-cb99058d5e15
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | pcre.h.in | 2 | ||||
-rw-r--r-- | pcre16_valid_utf16.c | 4 | ||||
-rw-r--r-- | pcre_compile.c | 46 | ||||
-rw-r--r-- | pcre_exec.c | 10 | ||||
-rw-r--r-- | pcre_internal.h | 64 | ||||
-rw-r--r-- | pcre_jit_compile.c | 8 | ||||
-rw-r--r-- | pcre_str_utils.c | 168 |
8 files changed, 267 insertions, 37 deletions
diff --git a/Makefile.am b/Makefile.am index 4651c6f..94cab77 100644 --- a/Makefile.am +++ b/Makefile.am @@ -189,6 +189,7 @@ libpcre_la_SOURCES = \ pcre_newline.c \ pcre_ord2utf8.c \ pcre_refcount.c \ + pcre_str_utils.c \ pcre_study.c \ pcre_tables.c \ pcre_try_flipped.c \ @@ -208,6 +209,7 @@ endif # WITH_PCRE8 if WITH_PCRE16 lib_LTLIBRARIES += libpcre16.la libpcre16_la_SOURCES = \ + pcre_str_utils.c \ pcre16_compile.c \ pcre16_convert_utf16.c \ pcre16_valid_utf16.c @@ -350,7 +350,7 @@ PCRE_EXP_DECL pcre *pcre16_compile(PCRE_SPTR16, int, const char **, int *, const unsigned char *); PCRE_EXP_DECL pcre *pcre_compile2(const char *, int, int *, const char **, int *, const unsigned char *); -PCRE_EXP_DECL pcre *pcre16_compile2(PCRE_SPTR16, int, int *, const short **, +PCRE_EXP_DECL pcre *pcre16_compile2(PCRE_SPTR16, int, int *, const char **, int *, const unsigned char *); PCRE_EXP_DECL int pcre_config(int, void *); PCRE_EXP_DECL int pcre_copy_named_substring(const pcre *, const char *, diff --git a/pcre16_valid_utf16.c b/pcre16_valid_utf16.c index 85c4e4d..04b2eb9 100644 --- a/pcre16_valid_utf16.c +++ b/pcre16_valid_utf16.c @@ -78,10 +78,10 @@ Returns: = 0 if the string is a valid UTF-16 string */ int -_pcre16_valid_utf16(USPTR string, int length, int *erroroffset) +_pcre16_valid_utf16(PCRE_PUCHAR string, int length, int *erroroffset) { #ifdef SUPPORT_UTF16 -register USPTR p; +register PCRE_PUCHAR p; register uschar c; if (length < 0) diff --git a/pcre_compile.c b/pcre_compile.c index edcc112..e11eca1 100644 --- a/pcre_compile.c +++ b/pcre_compile.c @@ -1072,7 +1072,7 @@ get_ucp(const pcre_uchar **ptrptr, BOOL *negptr, int *dptr, int *errorcodeptr) { int c, i, bot, top; const pcre_uchar *ptr = *ptrptr; -char name[32]; +pcre_uchar name[32]; c = *(++ptr); if (c == 0) goto ERROR_RETURN; @@ -1118,7 +1118,7 @@ top = _pcre_utt_size; while (bot < top) { i = (bot + top) >> 1; - c = strcmp(name, _pcre_utt_names + _pcre_utt[i].name_offset); + c = STRCMP_UC_C8(name, _pcre_utt_names + _pcre_utt[i].name_offset); if (c == 0) { *dptr = _pcre_utt[i].value; @@ -1324,7 +1324,7 @@ if (ptr[0] == CHAR_LEFT_PARENTHESIS) thisname = ptr; while (*ptr != term) ptr++; if (name != NULL && lorn == ptr - thisname && - strncmp((const char *)name, (const char *)thisname, lorn) == 0) + STRNCMP_UC_UC(name, thisname, lorn) == 0) return *count; term++; } @@ -1367,7 +1367,7 @@ for (; ptr < cd->end_pattern; ptr++) { if (ptr[2] == CHAR_E) ptr+= 2; - else if (strncmp((const char *)ptr+2, + else if (STRNCMP_UC_C8(ptr + 2, STR_Q STR_BACKSLASH STR_E, 3) == 0) ptr += 4; else @@ -2579,7 +2579,7 @@ register int yield = 0; while (posix_name_lengths[yield] != 0) { if (len == posix_name_lengths[yield] && - strncmp((const char *)ptr, pn, len) == 0) return yield; + STRNCMP_UC_C8(ptr, pn, len) == 0) return yield; pn += posix_name_lengths[yield] + 1; yield++; } @@ -2915,7 +2915,7 @@ if ((options & PCRE_EXTENDED) != 0) /* If the next thing is itself optional, we have to give up. */ if (*ptr == CHAR_ASTERISK || *ptr == CHAR_QUESTION_MARK || - strncmp((char *)ptr, STR_LEFT_CURLY_BRACKET STR_0 STR_COMMA, 3) == 0) + STRNCMP_UC_C8(ptr, STR_LEFT_CURLY_BRACKET STR_0 STR_COMMA, 3) == 0) return FALSE; /* Now compare the next item with the previous opcode. First, handle cases when @@ -3177,7 +3177,7 @@ switch(op_code) to the original \d etc. At this point, ptr will point to a zero byte. */ if (*ptr == CHAR_ASTERISK || *ptr == CHAR_QUESTION_MARK || - strncmp((char *)ptr, STR_LEFT_CURLY_BRACKET STR_0 STR_COMMA, 3) == 0) + STRNCMP_UC_C8(ptr, STR_LEFT_CURLY_BRACKET STR_0 STR_COMMA, 3) == 0) return FALSE; /* Do the property check. */ @@ -3617,7 +3617,7 @@ for (;; ptr++) { if (ptr[1] == CHAR_E) ptr++; - else if (strncmp((const char *)ptr+1, + else if (STRNCMP_UC_C8(ptr + 1, STR_Q STR_BACKSLASH STR_E, 3) == 0) ptr += 3; else @@ -5295,7 +5295,7 @@ for (;; ptr++) for (i = 0; i < verbcount; i++) { if (namelen == verbs[i].len && - strncmp((char *)name, vn, namelen) == 0) + STRNCMP_UC_C8(name, vn, namelen) == 0) { /* Check for open captures before ACCEPT and convert it to ASSERT_ACCEPT if in an assertion. */ @@ -5519,7 +5519,7 @@ for (;; ptr++) slot = cd->name_table; for (i = 0; i < cd->names_found; i++) { - if (strncmp((char *)name, (char *)slot+2, namelen) == 0) break; + if (STRNCMP_UC_UC(name, slot+IMM2_SIZE, namelen) == 0) break; slot += cd->name_entry_size; } @@ -5576,7 +5576,7 @@ for (;; ptr++) /* Similarly, check for the (?(DEFINE) "condition", which is always false. */ - else if (namelen == 6 && strncmp((char *)name, STRING_DEFINE, 6) == 0) + else if (namelen == 6 && STRNCMP_UC_C8(name, STRING_DEFINE, 6) == 0) { code[1+LINK_SIZE] = OP_DEF; skipbytes = 1; @@ -5894,7 +5894,7 @@ for (;; ptr++) slot = cd->name_table; for (i = 0; i < cd->names_found; i++) { - if (strncmp((char *)name, (char *)slot+2, namelen) == 0 && + if (STRNCMP_UC_UC(name, slot+IMM2_SIZE, namelen) == 0 && slot[2+namelen] == 0) break; slot += cd->name_entry_size; @@ -7348,27 +7348,27 @@ while (ptr[skipatstart] == CHAR_LEFT_PARENTHESIS && int newnl = 0; int newbsr = 0; - if (strncmp((char *)(ptr+skipatstart+2), STRING_UTF8_RIGHTPAR, 5) == 0) + if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_UTF8_RIGHTPAR, 5) == 0) { skipatstart += 7; options |= PCRE_UTF8; continue; } - else if (strncmp((char *)(ptr+skipatstart+2), STRING_UCP_RIGHTPAR, 4) == 0) + else if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_UCP_RIGHTPAR, 4) == 0) { skipatstart += 6; options |= PCRE_UCP; continue; } - else if (strncmp((char *)(ptr+skipatstart+2), STRING_NO_START_OPT_RIGHTPAR, 13) == 0) + else if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_NO_START_OPT_RIGHTPAR, 13) == 0) { skipatstart += 15; options |= PCRE_NO_START_OPTIMIZE; continue; } - if (strncmp((char *)(ptr+skipatstart+2), STRING_CR_RIGHTPAR, 3) == 0) + if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_CR_RIGHTPAR, 3) == 0) { skipatstart += 5; newnl = PCRE_NEWLINE_CR; } - else if (strncmp((char *)(ptr+skipatstart+2), STRING_LF_RIGHTPAR, 3) == 0) + else if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_LF_RIGHTPAR, 3) == 0) { skipatstart += 5; newnl = PCRE_NEWLINE_LF; } - else if (strncmp((char *)(ptr+skipatstart+2), STRING_CRLF_RIGHTPAR, 5) == 0) + else if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_CRLF_RIGHTPAR, 5) == 0) { skipatstart += 7; newnl = PCRE_NEWLINE_CR + PCRE_NEWLINE_LF; } - else if (strncmp((char *)(ptr+skipatstart+2), STRING_ANY_RIGHTPAR, 4) == 0) + else if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_ANY_RIGHTPAR, 4) == 0) { skipatstart += 6; newnl = PCRE_NEWLINE_ANY; } - else if (strncmp((char *)(ptr+skipatstart+2), STRING_ANYCRLF_RIGHTPAR, 8) == 0) + else if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_ANYCRLF_RIGHTPAR, 8) == 0) { skipatstart += 10; newnl = PCRE_NEWLINE_ANYCRLF; } - else if (strncmp((char *)(ptr+skipatstart+2), STRING_BSR_ANYCRLF_RIGHTPAR, 12) == 0) + else if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_BSR_ANYCRLF_RIGHTPAR, 12) == 0) { skipatstart += 14; newbsr = PCRE_BSR_ANYCRLF; } - else if (strncmp((char *)(ptr+skipatstart+2), STRING_BSR_UNICODE_RIGHTPAR, 12) == 0) + else if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_BSR_UNICODE_RIGHTPAR, 12) == 0) { skipatstart += 14; newbsr = PCRE_BSR_UNICODE; } if (newnl != 0) @@ -7486,7 +7486,7 @@ cd->start_workspace = cworkspace; cd->start_code = cworkspace; cd->hwm = cworkspace; cd->start_pattern = (const pcre_uchar *)pattern; -cd->end_pattern = (const pcre_uchar *)(pattern + strlen(pattern)); +cd->end_pattern = (const pcre_uchar *)(pattern + STRLEN_UC(pattern)); cd->req_varyopt = 0; cd->external_options = options; cd->external_flags = 0; diff --git a/pcre_exec.c b/pcre_exec.c index 60cc4d9..8fc8339 100644 --- a/pcre_exec.c +++ b/pcre_exec.c @@ -713,7 +713,7 @@ for (;;) unaltered. */ if (rrc == MATCH_SKIP_ARG && - strcmp((char *)markptr, (char *)(md->start_match_ptr)) == 0) + STRCMP_UC_UC(markptr, md->start_match_ptr) == 0) { md->start_match_ptr = eptr; RRETURN(MATCH_SKIP); @@ -1279,7 +1279,7 @@ for (;;) while (slotB > md->name_table) { slotB -= md->name_entry_size; - if (strcmp((char *)slotA + 2, (char *)slotB + 2) == 0) + if (STRCMP_UC_UC(slotA + IMM2_SIZE, slotB + IMM2_SIZE) == 0) { condition = GET2(slotB, 0) == md->recursive->group_num; if (condition) break; @@ -1295,7 +1295,7 @@ for (;;) for (i++; i < md->name_count; i++) { slotB += md->name_entry_size; - if (strcmp((char *)slotA + 2, (char *)slotB + 2) == 0) + if (STRCMP_UC_UC(slotA + IMM2_SIZE, slotB + IMM2_SIZE) == 0) { condition = GET2(slotB, 0) == md->recursive->group_num; if (condition) break; @@ -1343,7 +1343,7 @@ for (;;) while (slotB > md->name_table) { slotB -= md->name_entry_size; - if (strcmp((char *)slotA + 2, (char *)slotB + 2) == 0) + if (STRCMP_UC_UC(slotA + IMM2_SIZE, slotB + IMM2_SIZE) == 0) { offset = GET2(slotB, 0) << 1; condition = offset < offset_top && @@ -1361,7 +1361,7 @@ for (;;) for (i++; i < md->name_count; i++) { slotB += md->name_entry_size; - if (strcmp((char *)slotA + 2, (char *)slotB + 2) == 0) + if (STRCMP_UC_UC(slotA + IMM2_SIZE, slotB + IMM2_SIZE) == 0) { offset = GET2(slotB, 0) << 1; condition = offset < offset_top && diff --git a/pcre_internal.h b/pcre_internal.h index 110e940..bbea84f 100644 --- a/pcre_internal.h +++ b/pcre_internal.h @@ -51,6 +51,11 @@ functions whose names all begin with "_pcre_". */ #define PCRE_DEBUG #endif +/* PCRE is compiled as an 8 bit library if it is not requested otherwise. */ +#ifndef COMPILE_PCRE16 +#define COMPILE_PCRE8 +#endif + /* We do not support both EBCDIC and UTF-8/16 at the same time. The "configure" script prevents both being selected, but not everybody uses "configure". */ @@ -222,7 +227,7 @@ typedef unsigned char pcre_uchar; pcre.h(.in) and disable (comment out) this message. */ #error Warning: PCRE_SCHAR16 is not a 16 bit data type. #endif -typedef pcre_uint16 uschar; +typedef pcre_uint16 pcre_uchar; #endif /* This is an unsigned int value that no character can ever have. UTF-8 @@ -407,6 +412,10 @@ is automated on Unix systems via the "configure" command. */ offsets changes. There are used for repeat counts and for other things such as capturing parenthesis numbers in back references. */ +#ifdef COMPILE_PCRE8 + +#define IMM2_SIZE 2 + #define PUT2(a,n,d) \ a[n] = (d) >> 8; \ a[(n)+1] = (d) & 255 @@ -414,8 +423,22 @@ capturing parenthesis numbers in back references. */ #define GET2(a,n) \ (((a)[n] << 8) | (a)[(n)+1]) -#define PUT2INC(a,n,d) PUT2(a,n,d), a += 2 +#elif defined(COMPILE_PCRE16) + +#define IMM2_SIZE 1 + +#define PUT2(a,n,d) \ + a[n] = d + +#define GET2(a,n) \ + a[n] + +#else +#error Unsupported compiling mode +#endif /* COMPILE_PCRE8 */ + +#define PUT2INC(a,n,d) PUT2(a,n,d), a += IMM2_SIZE /* When UTF-8 encoding is being used, a character is no longer just a single byte. The macros for character handling generate simple sequences when used in @@ -1943,6 +1966,43 @@ extern const pcre_uint8 _pcre_OP_lengths[]; one of the exported public functions. They have to be "external" in the C sense, but are not part of the PCRE public API. */ +/* String comparison functions. */ +#ifdef COMPILE_PCRE8 + +#define STRCMP_UC_UC(str1, str2) \ + strcmp((char *)(str1), (char *)(str2)) +#define STRCMP_UC_C8(str1, str2) \ + strcmp((char *)(str1), (str2)) +#define STRNCMP_UC_UC(str1, str2, num) \ + strncmp((char *)(str1), (char *)(str2), (num)) +#define STRNCMP_UC_C8(str1, str2, num) \ + strncmp((char *)(str1), (str2), (num)) +#define STRLEN_UC(str) strlen(str) + +#else + +extern int _pcre_strcmp_uc_uc(const pcre_uchar *, + const pcre_uchar *); +extern int _pcre_strcmp_uc_c8(const pcre_uchar *, + const char *); +extern int _pcre_strncmp_uc_uc(const pcre_uchar *, + const pcre_uchar *, unsigned int num); +extern int _pcre_strncmp_uc_c8(const pcre_uchar *, + const char *, unsigned int num); +extern unsigned int _pcre_strlen_uc(const pcre_uchar *str); + +#define STRCMP_UC_UC(str1, str2) \ + _pcre_strcmp_uc_uc((str1), (str2)) +#define STRCMP_UC_C8(str1, str2) \ + _pcre_strcmp_uc_c8((str1), (str2)) +#define STRNCMP_UC_UC(str1, str2, num) \ + _pcre_strncmp_uc_uc((str1), (str2), (num)) +#define STRNCMP_UC_C8(str1, str2, num) \ + _pcre_strncmp_uc_c8((str1), (str2), (num)) +#define STRLEN_UC(str) _pcre_strlen_uc(str) + +#endif /* COMPILE_PCRE8 */ + extern const pcre_uchar *_pcre_find_bracket(const pcre_uchar *, BOOL, int); extern BOOL _pcre_is_newline(PCRE_PUCHAR, int, PCRE_PUCHAR, int *, BOOL); diff --git a/pcre_jit_compile.c b/pcre_jit_compile.c index 6e944df..998c709 100644 --- a/pcre_jit_compile.c +++ b/pcre_jit_compile.c @@ -3832,7 +3832,7 @@ if (i < name_count) while (slotB > name_table) { slotB -= name_entry_size; - if (strcmp((char *)slotA + 2, (char *)slotB + 2) == 0) + if (STRCMP_UC_UC(slotA + IMM2_SIZE, slotB + IMM2_SIZE) == 0) { condition = locals[GET2(slotB, 0) << 1] != no_capture; if (condition) break; @@ -3847,7 +3847,7 @@ if (i < name_count) for (i++; i < name_count; i++) { slotB += name_entry_size; - if (strcmp((char *)slotA + 2, (char *)slotB + 2) == 0) + if (STRCMP_UC_UC(slotA + IMM2_SIZE, slotB + IMM2_SIZE) == 0) { condition = locals[GET2(slotB, 0) << 1] != no_capture; if (condition) break; @@ -3885,7 +3885,7 @@ if (i < name_count) while (slotB > name_table) { slotB -= name_entry_size; - if (strcmp((char *)slotA + 2, (char *)slotB + 2) == 0) + if (STRCMP_UC_UC(slotA + IMM2_SIZE, slotB + IMM2_SIZE) == 0) { condition = GET2(slotB, 0) == group_num; if (condition) break; @@ -3900,7 +3900,7 @@ if (i < name_count) for (i++; i < name_count; i++) { slotB += name_entry_size; - if (strcmp((char *)slotA + 2, (char *)slotB + 2) == 0) + if (STRCMP_UC_UC(slotA + IMM2_SIZE, slotB + IMM2_SIZE) == 0) { condition = GET2(slotB, 0) == group_num; if (condition) break; diff --git a/pcre_str_utils.c b/pcre_str_utils.c new file mode 100644 index 0000000..9bd8002 --- /dev/null +++ b/pcre_str_utils.c @@ -0,0 +1,168 @@ +/************************************************* +* Perl-Compatible Regular Expressions * +*************************************************/ + +/* PCRE is a library of functions to support regular expressions whose syntax +and semantics are as close as possible to those of the Perl 5 language. + + Written by Philip Hazel + Copyright (c) 1997-2010 University of Cambridge + +----------------------------------------------------------------------------- +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + * Neither the name of the University of Cambridge nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +----------------------------------------------------------------------------- +*/ + + +/* This module contains an internal function that is used to match an extended +class. It is used by both pcre_exec() and pcre_def_exec(). */ + + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "pcre_internal.h" + +#ifndef COMPILE_PCRE8 + +/************************************************* +* Compare string utilities * +*************************************************/ + +/* The following two functions compares two strings. Basically an strcmp +for non 8 bit characters. + +Arguments: + str1 first string + str2 second string + +Returns: 0 if both string are equal (like strcmp), 1 otherwise +*/ + +int +_pcre_strcmp_uc_uc(const pcre_uchar *str1, const pcre_uchar *str2) +{ +pcre_uchar c1; +pcre_uchar c2; + +while (*str1 != '\0' || *str2 != '\0') + { + c1 = *str1++; + c2 = *str2++; + if (c1 != c2) + return ((c1 > c2) << 1) - 1; + } +/* Both length and characters must be equal. */ +return 0; +} + +int +_pcre_strcmp_uc_c8(const pcre_uchar *str1, const char *str2) +{ +const pcre_uint8 *ustr2 = (pcre_uint8 *)str2; +pcre_uchar c1; +pcre_uchar c2; + +while (*str1 != '\0' || *ustr2 != '\0') + { + c1 = *str1++; + c2 = (pcre_uchar)*ustr2++; + if (c1 != c2) + return ((c1 > c2) << 1) - 1; + } +/* Both length and characters must be equal. */ +return 0; +} + +/* The following two functions compares two, fixed length +strings. Basically an strncmp for non 8 bit characters. + +Arguments: + str1 first string + str2 second string + num size of the string + +Returns: 0 if both string are equal (like strcmp), 1 otherwise +*/ + +int +_pcre_strncmp_uc_uc(const pcre_uchar *str1, const pcre_uchar *str2, unsigned int num) +{ +pcre_uchar c1; +pcre_uchar c2; + +while (num-- > 0) + { + c1 = *str1++; + c2 = *str2++; + if (c1 != c2) + return ((c1 > c2) << 1) - 1; + } +/* Both length and characters must be equal. */ +return 0; +} + +int +_pcre_strncmp_uc_c8(const pcre_uchar *str1, const char *str2, unsigned int num) +{ +const pcre_uint8 *ustr2 = (pcre_uint8 *)str2; +pcre_uchar c1; +pcre_uchar c2; + +while (num-- > 0) + { + c1 = *str1++; + c2 = (pcre_uchar)*ustr2++; + if (c1 != c2) + return ((c1 > c2) << 1) - 1; + } +/* Both length and characters must be equal. */ +return 0; +} + +/* The following function returns with the length of +a zero terminated string. Basically an strlen for non 8 bit characters. + +Arguments: + str string + +Returns: length of the string +*/ + +unsigned int +_pcre_strlen_uc(const pcre_uchar *str) +{ +unsigned int len = 0; +while (*str++ != 0) + len++; +return len; +} + +#endif /* COMPILE_PCRE8 */ + +/* End of pcre_str_utils.c */ |