48#define TYPE_OPTIONS (PCRE2_CONVERT_GLOB| \
49 PCRE2_CONVERT_POSIX_BASIC|PCRE2_CONVERT_POSIX_EXTENDED)
51#define ALL_OPTIONS (PCRE2_CONVERT_UTF|PCRE2_CONVERT_NO_UTF_CHECK| \
52 PCRE2_CONVERT_GLOB_NO_WILD_SEPARATOR| \
53 PCRE2_CONVERT_GLOB_NO_STARSTAR| \
56#define DUMMY_BUFFER_SIZE 100
60#define STR_BACKSLASH_A STR_BACKSLASH STR_A
61#define STR_BACKSLASH_z STR_BACKSLASH STR_z
62#define STR_COLON_RIGHT_SQUARE_BRACKET STR_COLON STR_RIGHT_SQUARE_BRACKET
63#define STR_DOT_STAR_LOOKBEHIND STR_DOT STR_ASTERISK STR_LEFT_PARENTHESIS STR_QUESTION_MARK STR_LESS_THAN_SIGN STR_EQUALS_SIGN
64#define STR_LOOKAHEAD_NOT_DOT STR_LEFT_PARENTHESIS STR_QUESTION_MARK STR_EXCLAMATION_MARK STR_BACKSLASH STR_DOT STR_RIGHT_PARENTHESIS
65#define STR_QUERY_s STR_LEFT_PARENTHESIS STR_QUESTION_MARK STR_s STR_RIGHT_PARENTHESIS
66#define STR_STAR_NUL STR_LEFT_PARENTHESIS STR_ASTERISK STR_N STR_U STR_L STR_RIGHT_PARENTHESIS
75#define PUTCHARS(string) \
77 for (s = (char *)(string); *s != 0; s++) \
79 if (p >= endp) return PCRE2_ERROR_NOMEMORY; \
86static const char *pcre2_escaped_literals =
95static const char *posix_meta_escapes =
135uint32_t bracount = 0;
137uint32_t lastspecial = 0;
146*bufflenptr = plength;
160 convlength +=
p - pp;
161 if (dummyrun)
p = use_buffer;
166#ifndef SUPPORT_UNICODE
169 GETCHARLENTEST(c, posix, clength);
174 sc = nextisliteral? 0 : c;
175 nextisliteral =
FALSE;
194 if (c <= 127 && islower(c))
break;
279 if (extended) nextisliteral =
TRUE;
else
281 if (*posix < 127 &&
strchr(posix_meta_escapes, *posix) !=
NULL)
285 lastspecial = *
p++ = *posix++;
288 else nextisliteral =
TRUE;
293 if (!extended || bracount == 0)
goto ESCAPE_LITERAL;
306 if (!extended)
goto ESCAPE_LITERAL;
329 if (extended)
goto COPY_SPECIAL;
339 if (c < 128 &&
strchr(pcre2_escaped_literals, c) !=
NULL)
356*bufflenptr = convlength;
388if (
out->output <
out->output_end)
403uint8_t *out_str =
out->out_str;
412 if (output < output_end)
413 *output++ = *out_str++;
415while (--length != 0);
418out->output_size = output_size;
437convert_glob_write(
out, separator);
455convert_glob_write_str(
out, 2);
457convert_glob_print_separator(
out, separator, with_escape);
478static const char *posix_classes =
"alnum:alpha:ascii:blank:cntrl:digit:"
479 "graph:lower:print:punct:space:upper:word:xdigit:";
482const char *class_ptr;
488 if (pattern >= pattern_end)
return 0;
492 if (c < CHAR_a || c >
CHAR_z)
break;
495if (c !=
CHAR_COLON || pattern >= pattern_end ||
499class_ptr = posix_classes;
504 if (*class_ptr ==
CHAR_NUL)
return 0;
515 do convert_glob_write(
out, *
start++);
while (
start < pattern);
541convert_glob_char_in_class(
int class_index,
PCRE2_UCHAR c)
543#if PCRE2_CODE_UNIT_WIDTH != 8
553 case 1:
return isalnum(c);
554 case 2:
return isalpha(c);
557 case 5:
return iscntrl(c);
558 case 6:
return isdigit(c);
559 case 7:
return isgraph(c);
560 case 8:
return islower(c);
561 case 9:
return isprint(c);
562 case 10:
return ispunct(c);
563 case 11:
return isspace(c);
564 case 12:
return isupper(c);
566 default:
return isxdigit(c);
598if (pattern >= pattern_end)
609 if (pattern >= pattern_end)
628 out->out_str[
len] = (uint8_t) separator;
631 convert_glob_write_str(
out,
len + 1);
643 convert_glob_write_str(
out, 2);
649while (pattern < pattern_end)
651 char_start = pattern;
656 convert_glob_write(
out, c);
658 if (!is_negative && !no_wildsep && separator_seen)
664 convert_glob_write_str(
out, 4);
666 convert_glob_print_separator(
out, separator, with_escape);
674 if (pattern >= pattern_end)
break;
679 class_index = convert_glob_parse_class(from, pattern_end,
out);
681 if (class_index != 0)
689 convert_glob_char_in_class (class_index, separator))
690 separator_seen =
TRUE;
699 char_start = pattern;
702 if (pattern >= pattern_end)
break;
704 if (escape != 0 && c == escape)
706 char_start = pattern;
721 if (prev_c < separator && separator < c) separator_seen =
TRUE;
728 if (escape != 0 && c == escape)
730 char_start = pattern;
733 if (pattern >= pattern_end)
break;
744 if (c == separator) separator_seen =
TRUE;
746 do convert_glob_write(
out, *char_start++);
while (char_start < pattern);
771convert_glob_write_str(
out, 8);
809BOOL with_escape, is_start, after_separator;
814#ifdef SUPPORT_UNICODE
815if (utf && (separator >= 128 || escape >= 128))
823with_escape =
strchr(pcre2_escaped_literals, separator) !=
NULL;
826out.output = use_buffer;
827out.output_end = use_buffer + use_length;
834convert_glob_write_str(&
out, 4);
842 else if (!no_starstar && pattern + 1 < pattern_end &&
851 convert_glob_write_str(&
out, 2);
854while (pattern < pattern_end)
860 is_start = pattern == pattern_start + 1;
868 if (!no_starstar && pattern < pattern_end && *pattern ==
CHAR_ASTERISK)
870 after_separator = is_start || (pattern[-2] == separator);
872 do pattern++;
while (pattern < pattern_end &&
875 if (pattern >= pattern_end)
881 after_starstar =
TRUE;
883 if (after_separator && escape != 0 && *pattern == escape &&
884 pattern + 1 < pattern_end && pattern[1] == separator)
889 if (*pattern != separator)
continue;
897 convert_glob_write_str(&
out, 6);
899 convert_glob_print_separator(&
out, separator, with_escape);
906 convert_glob_print_commit(&
out);
908 if (!after_separator || *pattern != separator)
913 convert_glob_write_str(&
out, 3);
924 convert_glob_write_str(&
out, 6);
926 convert_glob_print_separator(&
out, separator, with_escape);
931 convert_glob_write_str(&
out, 3);
939 do pattern++;
while (pattern < pattern_end &&
945 if (pattern >= pattern_end)
952 if (is_start)
continue;
962 convert_glob_write_str(&
out, 3);
966 convert_glob_print_commit(&
out);
972 convert_glob_print_wildcard(&
out, separator, with_escape);
976 if (pattern >= pattern_end)
978 convert_glob_write_str(&
out, 2);
987 convert_glob_print_wildcard(&
out, separator, with_escape);
993 result = convert_glob_parse_range(&pattern, pattern_end,
994 &
out, utf, separator, with_escape, escape, no_wildsep);
999 if (escape != 0 && c == escape)
1001 if (pattern >= pattern_end)
1009 if (c < 128 &&
strchr(pcre2_escaped_literals, c) !=
NULL)
1012 convert_glob_write(&
out, c);
1021 convert_glob_write_str(&
out, 2);
1029 if (!dummyrun &&
out.output_size != (
PCRE2_SIZE) (
out.output - use_buffer))
1035 *bufflenptr = pattern - pattern_start;
1039*bufflenptr =
out.output_size - 1;
1078 (pattype & (~pattype+1)) != pattype ||
1086if (ccontext ==
NULL) ccontext =
1091#ifndef SUPPORT_UNICODE
1104 *bufflenptr = erroroffset;
1113if (buffptr !=
NULL && *buffptr !=
NULL)
1115 use_buffer = *buffptr;
1116 use_length = *bufflenptr;
1122for (i = 0; i < 2; i++)
1131 use_buffer, use_length, bufflenptr, dummyrun, ccontext);
1136 rc = convert_posix(pattype, pattern, plength, utf, use_buffer, use_length,
1137 bufflenptr, dummyrun, ccontext);
1154 (*bufflenptr + 1)*PCRE2_CODE_UNIT_WIDTH, (
pcre2_memctl *)ccontext);
1158 use_buffer = *buffptr;
1159 use_length = *bufflenptr + 1;
1181if (converted !=
NULL)
strchr(string $haystack, string $needle, bool $before_needle=false)
#define pcre2_convert_context
#define PCRE2_ZERO_TERMINATED
#define PCRE2_ERROR_BADOPTION
#define PCRE2_ERROR_INTERNAL
#define PCRE2_CONVERT_POSIX_BASIC
#define pcre2_converted_pattern_free
#define PCRE2_ERROR_UNICODE_NOT_SUPPORTED
#define PCRE2_CONVERT_POSIX_EXTENDED
#define PCRE2_CONVERT_GLOB_NO_STARSTAR
#define PCRE2_CONVERT_NO_UTF_CHECK
#define PCRE2_ERROR_CONVERT_SYNTAX
#define PCRE2_ERROR_END_BACKSLASH
#define PCRE2_CALL_CONVENTION
#define PCRE2_CONVERT_UTF
#define PCRE2_CONVERT_GLOB
#define PCRE2_CONVERT_GLOB_NO_WILD_SEPARATOR
#define PCRE2_ERROR_NOMEMORY
#define pcre2_pattern_convert
#define PCRE2_ERROR_MISSING_SQUARE_BRACKET
void *PRIV memctl_malloc(size_t size, pcre2_memctl *memctl)
@ POSIX_CLASS_NOT_STARTED
#define STR_COLON_RIGHT_SQUARE_BRACKET
#define DUMMY_BUFFER_SIZE
#define CHAR_LESS_THAN_SIGN
#define STR_RIGHT_PARENTHESIS
#define CHAR_VERTICAL_LINE
#define STR_LEFT_CURLY_BRACKET
#define CHAR_LEFT_SQUARE_BRACKET
#define CHAR_QUESTION_MARK
#define STR_QUESTION_MARK
#define STR_LEFT_SQUARE_BRACKET
#define CHAR_EXCLAMATION_MARK
#define STR_RIGHT_CURLY_BRACKET
#define CHAR_RIGHT_PARENTHESIS
#define STR_RIGHT_SQUARE_BRACKET
#define CHAR_RIGHT_SQUARE_BRACKET
#define CHAR_RIGHT_CURLY_BRACKET
#define CHAR_LEFT_PARENTHESIS
#define CHAR_CIRCUMFLEX_ACCENT
#define STR_CIRCUMFLEX_ACCENT
#define CHAR_LEFT_CURLY_BRACKET
#define STR_LEFT_PARENTHESIS
#define CHAR_GREATER_THAN_SIGN
#define STR_VERTICAL_LINE
#define GETCHARINCTEST(c, eptr)
int PRIV valid_utf(PCRE2_SPTR string, PCRE2_SIZE length, PCRE2_SIZE *erroroffset)
PHP_JSON_API size_t int options
void(* free)(void *, void *)
ZEND_API void(ZEND_FASTCALL *zend_touch_vm_stack_data)(void *vm_stack_data)