/** * Replaces placeholders from pattern returning a valid PCRE regular expression * * @param string pattern * @return string */ PHP_METHOD(Test_Router_Route, compilePattern) { zval *pattern = NULL, *idPattern, _0 = zval_used_for_init, *_1 = NULL, _2 = zval_used_for_init, *_3 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &pattern); ZEPHIR_SEPARATE_PARAM(pattern); if (zephir_memnstr_str(pattern, SL(":"), "test/router/route.zep", 57)) { ZEPHIR_INIT_VAR(idPattern); ZVAL_STRING(idPattern, "/([a-zA-Z0-9\\_\\-]+)", 1); if (zephir_memnstr_str(pattern, SL("/:module"), "test/router/route.zep", 63)) { ZEPHIR_SINIT_VAR(_0); ZVAL_STRING(&_0, "/:module", 0); ZEPHIR_INIT_VAR(_1); zephir_call_func_p3(_1, "str_replace", &_0, idPattern, pattern); ZEPHIR_CPY_WRT(pattern, _1); } if (zephir_memnstr_str(pattern, SL("/:controller"), "test/router/route.zep", 68)) { ZEPHIR_SINIT_NVAR(_0); ZVAL_STRING(&_0, "/:controller", 0); ZEPHIR_INIT_NVAR(_1); zephir_call_func_p3(_1, "str_replace", &_0, idPattern, pattern); ZEPHIR_CPY_WRT(pattern, _1); } if (zephir_memnstr_str(pattern, SL("/:namespace"), "test/router/route.zep", 73)) { ZEPHIR_SINIT_NVAR(_0); ZVAL_STRING(&_0, "/:namespace", 0); ZEPHIR_INIT_NVAR(_1); zephir_call_func_p3(_1, "str_replace", &_0, idPattern, pattern); ZEPHIR_CPY_WRT(pattern, _1); } if (zephir_memnstr_str(pattern, SL("/:action"), "test/router/route.zep", 78)) { ZEPHIR_SINIT_NVAR(_0); ZVAL_STRING(&_0, "/:action", 0); ZEPHIR_INIT_NVAR(_1); zephir_call_func_p3(_1, "str_replace", &_0, idPattern, pattern); ZEPHIR_CPY_WRT(pattern, _1); } if (zephir_memnstr_str(pattern, SL("/:params"), "test/router/route.zep", 83)) { ZEPHIR_SINIT_NVAR(_0); ZVAL_STRING(&_0, "/:params", 0); ZEPHIR_SINIT_VAR(_2); ZVAL_STRING(&_2, "(/.*)*", 0); ZEPHIR_INIT_NVAR(_1); zephir_call_func_p3(_1, "str_replace", &_0, &_2, pattern); ZEPHIR_CPY_WRT(pattern, _1); } if (zephir_memnstr_str(pattern, SL("/:int"), "test/router/route.zep", 88)) { ZEPHIR_SINIT_NVAR(_0); ZVAL_STRING(&_0, "/:int", 0); ZEPHIR_SINIT_NVAR(_2); ZVAL_STRING(&_2, "/([0-9]+)", 0); ZEPHIR_INIT_NVAR(_1); zephir_call_func_p3(_1, "str_replace", &_0, &_2, pattern); ZEPHIR_CPY_WRT(pattern, _1); } } if (zephir_memnstr_str(pattern, SL("("), "test/router/route.zep", 94)) { ZEPHIR_INIT_VAR(_3); ZEPHIR_CONCAT_SV(_3, "#^", pattern); ZEPHIR_CONCAT_VS(return_value, _3, "$#"); RETURN_MM(); } if (zephir_memnstr_str(pattern, SL("["), "test/router/route.zep", 99)) { ZEPHIR_INIT_LNVAR(_3); ZEPHIR_CONCAT_SV(_3, "#^", pattern); ZEPHIR_CONCAT_VS(return_value, _3, "$#"); RETURN_MM(); } RETURN_CCTOR(pattern); }
/** * Extracts parameters from a string * * @param string pattern */ PHP_METHOD(Test_Router_Route, extractNamedParams) { zend_bool notValid; int tmp, cursor, cursorVar, marker, bracketCount = 0, parenthesesCount = 0, foundPattern = 0, intermediate = 0, numberMatches = 0, _0, _5, _10; char ch; zval *pattern_param = NULL, *matches, _1 = zval_used_for_init, _2 = zval_used_for_init, *_3 = NULL, *_6 = NULL, *_8 = NULL; zval *pattern = NULL, *route, *item = NULL, *variable = NULL, *regexp = NULL, *_4 = NULL, *_7 = NULL, *_9 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &pattern_param); zephir_get_strval(pattern, pattern_param); if ((zephir_fast_strlen_ev(pattern) <= 0)) { RETURN_MM_BOOL(0); } ZEPHIR_INIT_VAR(matches); array_init(matches); ZEPHIR_INIT_VAR(route); ZVAL_EMPTY_STRING(route); for (_0 = 0; _0 < Z_STRLEN_P(pattern); _0++) { cursor = _0; ch = Z_STRVAL_P(pattern)[_0]; if ((parenthesesCount == 0)) { if ((ch == '{')) { if ((bracketCount == 0)) { marker = (cursor + 1); intermediate = 0; notValid = 0; } bracketCount++; } else { if ((ch == '}')) { bracketCount--; if ((intermediate > 0)) { if ((bracketCount == 0)) { numberMatches++; ZEPHIR_INIT_NVAR(variable); ZVAL_EMPTY_STRING(variable); ZEPHIR_INIT_NVAR(regexp); ZVAL_EMPTY_STRING(regexp); ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, marker); ZEPHIR_SINIT_NVAR(_2); ZVAL_LONG(&_2, (cursor - marker)); ZEPHIR_INIT_NVAR(_3); zephir_call_func_p3(_3, "substr", pattern, &_1, &_2); zephir_get_strval(_4, _3); ZEPHIR_CPY_WRT(item, _4); for (_5 = 0; _5 < Z_STRLEN_P(item); _5++) { cursorVar = _5; ch = Z_STRVAL_P(item)[_5]; if ((ch == '\0')) { break; } if (((cursorVar == 0) && !(((((ch >= 'a') && (ch <= 'z'))) || (((ch >= 'A') && (ch <= 'Z'))))))) { notValid = 1; break; } if (((((((((ch >= 'a') && (ch <= 'z'))) || (((ch >= 'A') && (ch <= 'Z')))) || (((ch >= '0') && (ch <= '9')))) || (ch == '-')) || (ch == '_')) || (ch == ':'))) { if ((ch == ':')) { ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, 0); ZEPHIR_SINIT_NVAR(_2); ZVAL_LONG(&_2, cursorVar); ZEPHIR_INIT_NVAR(_6); zephir_call_func_p3(_6, "substr", item, &_1, &_2); zephir_get_strval(_7, _6); ZEPHIR_CPY_WRT(variable, _7); ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, (cursorVar + 1)); ZEPHIR_INIT_NVAR(_8); zephir_call_func_p2(_8, "substr", item, &_1); zephir_get_strval(_9, _8); ZEPHIR_CPY_WRT(regexp, _9); break; } } else { notValid = 1; break; } } if (!(notValid)) { tmp = numberMatches; if ((variable && Z_STRLEN_P(variable)) && (regexp && Z_STRLEN_P(regexp))) { foundPattern = 0; for (_10 = 0; _10 < Z_STRLEN_P(regexp); _10++) { ch = Z_STRVAL_P(regexp)[_10]; if ((ch == '\0')) { break; } if (!(foundPattern)) { if ((ch == '(')) { foundPattern = 1; } } else { if ((ch == ')')) { foundPattern = 2; break; } } } if ((foundPattern != 2)) { zephir_concat_self_str(&route, "(", sizeof("(")-1 TSRMLS_CC); zephir_concat_self(&route, regexp TSRMLS_CC); zephir_concat_self_str(&route, ")", sizeof(")")-1 TSRMLS_CC); } else { zephir_concat_self(&route, regexp TSRMLS_CC); } ZEPHIR_INIT_NVAR(_6); ZVAL_LONG(_6, tmp); zephir_array_update_zval(&matches, variable, &_6, PH_COPY | PH_SEPARATE); } else { zephir_concat_self_str(&route, "([^/]*)", sizeof("([^/]*)")-1 TSRMLS_CC); ZEPHIR_INIT_NVAR(_8); ZVAL_LONG(_8, tmp); zephir_array_update_zval(&matches, item, &_8, PH_COPY | PH_SEPARATE); } } else { zephir_concat_self_str(&route, "{", sizeof("{")-1 TSRMLS_CC); zephir_concat_self(&route, item TSRMLS_CC); zephir_concat_self_str(&route, "}", sizeof("}")-1 TSRMLS_CC); } continue; } } } } } if ((bracketCount == 0)) { if ((ch == '(')) { parenthesesCount++; } else { if ((ch == ')')) { parenthesesCount--; if ((parenthesesCount == 0)) { numberMatches++; } } } } if ((bracketCount > 0)) { intermediate++; } else { zephir_concat_self_char(&route, ch TSRMLS_CC); } } array_init(return_value); zephir_array_fast_append(return_value, route); zephir_array_fast_append(return_value, matches); RETURN_MM(); }
/** * Extracts parameters from a string * * @param string pattern */ PHP_METHOD(Test_Router_Route, extractNamedParams) { zend_bool notValid; int tmp, cursor, cursorVar, marker, bracketCount = 0, parenthesesCount = 0, foundPattern = 0, intermediate = 0, numberMatches = 0, _1, _7, _12; char ch; zval *pattern_param = NULL, *matches, _0, _2 = zval_used_for_init, _3 = zval_used_for_init, _4 = zval_used_for_init, *_5 = NULL, *_8 = NULL, *_10 = NULL; zephir_str *pattern = NULL, *route = NULL, *item = NULL, *variable = NULL, *regexp = NULL, *_6 = NULL, *_9 = NULL, *_11 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &pattern_param); zephir_get_strval(pattern_param, &pattern); ZEPHIR_SINIT_VAR(_0); ZVAL_STRINGL(&_0, pattern->str, pattern->len, 0); if ((zephir_fast_strlen_ev(&_0) <= 0)) { RETURN_MM_BOOL(0); } ZEPHIR_INIT_VAR(matches); array_init(matches); for (_1 = 0; _1 < pattern->len; _1++) { cursor = _1; ch = pattern->str[_1]; if ((parenthesesCount == 0)) { if ((ch == '{')) { if ((bracketCount == 0)) { marker = (cursor + 1); intermediate = 0; notValid = 0; } bracketCount++; } else { if ((ch == '}')) { bracketCount--; if ((intermediate > 0)) { if ((bracketCount == 0)) { numberMatches++; zephir_str_assign(variable, "", sizeof("")-1); zephir_str_assign(regexp, "", sizeof("")-1); ZEPHIR_SINIT_NVAR(_2); ZVAL_STRINGL(&_2, pattern->str, pattern->len, 0); ZEPHIR_SINIT_NVAR(_3); ZVAL_LONG(&_3, marker); ZEPHIR_SINIT_NVAR(_4); ZVAL_LONG(&_4, (cursor - marker)); ZEPHIR_INIT_NVAR(_5); zephir_call_func_p3(_5, "substr", &_2, &_3, &_4); zephir_get_strval(_5, &_6); zephir_str_assign(item, _6->str, _6->len); for (_7 = 0; _7 < item->len; _7++) { cursorVar = _7; ch = item->str[_7]; if ((ch == '\0')) { break; } if (((cursorVar == 0) && !(((((ch >= 'a') && (ch <= 'z'))) || (((ch >= 'A') && (ch <= 'Z'))))))) { notValid = 1; break; } if (((((((((ch >= 'a') && (ch <= 'z'))) || (((ch >= 'A') && (ch <= 'Z')))) || (((ch >= '0') && (ch <= '9')))) || (ch == '-')) || (ch == '_')) || (ch == ':'))) { if ((ch == ':')) { ZEPHIR_SINIT_NVAR(_2); ZVAL_STRINGL(&_2, item->str, item->len, 0); ZEPHIR_SINIT_NVAR(_3); ZVAL_LONG(&_3, 0); ZEPHIR_SINIT_NVAR(_4); ZVAL_LONG(&_4, cursorVar); ZEPHIR_INIT_NVAR(_8); zephir_call_func_p3(_8, "substr", &_2, &_3, &_4); zephir_get_strval(_8, &_9); zephir_str_assign(variable, _9->str, _9->len); ZEPHIR_SINIT_NVAR(_2); ZVAL_STRINGL(&_2, item->str, item->len, 0); ZEPHIR_SINIT_NVAR(_3); ZVAL_LONG(&_3, (cursorVar + 1)); ZEPHIR_INIT_NVAR(_10); zephir_call_func_p2(_10, "substr", &_2, &_3); zephir_get_strval(_10, &_11); zephir_str_assign(regexp, _11->str, _11->len); break; } } else { notValid = 1; break; } } if (!(notValid)) { tmp = numberMatches; if ((variable && variable->len) && (regexp && regexp->len)) { foundPattern = 0; for (_12 = 0; _12 < regexp->len; _12++) { ch = regexp->str[_12]; if ((ch == '\0')) { break; } if (!(foundPattern)) { if ((ch == '(')) { foundPattern = 1; } } else { if ((ch == ')')) { foundPattern = 2; break; } } } if ((foundPattern != 2)) { zephir_str_append_char(route, '('); zephir_str_append(route, regexp->str, regexp->len); zephir_str_append_char(route, ')'); } else { zephir_str_append(route, regexp->str, regexp->len); } ZEPHIR_INIT_NVAR(_8); ZVAL_LONG(_8, tmp); zephir_array_update_string(&matches, variable->str, variable->len, &_8, PH_COPY | PH_SEPARATE); } else { zephir_str_append(route, "([^/]*)", sizeof("([^/]*)")-1); ZEPHIR_INIT_NVAR(_10); ZVAL_LONG(_10, tmp); zephir_array_update_string(&matches, item->str, item->len, &_10, PH_COPY | PH_SEPARATE); } } else { zephir_str_append_char(route, '{'); zephir_str_append(route, item->str, item->len); zephir_str_append_char(route, '}'); } continue; } } } } } if ((bracketCount == 0)) { if ((ch == '(')) { parenthesesCount++; } else { if ((ch == ')')) { parenthesesCount--; if ((parenthesesCount == 0)) { numberMatches++; } } } } if ((bracketCount > 0)) { intermediate++; } else { zephir_str_append_char(route, ch); } } array_init(return_value); ZEPHIR_INIT_NVAR(_5); ZVAL_STRINGL(_5, route->str, route->len, 1); zephir_array_append(&return_value, _5, 0); zephir_array_append(&return_value, matches, 0); RETURN_MM(); }
PHP_METHOD(Test_RegexDNA, process) { HashTable *_27; HashPosition _26; zval *path, *variants, *vIUB, *vIUBnew, *stuffToRemove, *contents = NULL, *initialLength, *regex = NULL, *codeLength, *discard, *_0, *_1, *_2, *_3, *_4, *_5, *_6, *_7, *_8, *_9, *_10, *_11, *_12, *_13, *_14, *_15, *_16, *_17, *_18, *_19, *_20, *_21, *_22, *_23, _24, *_25 = NULL, **_28, *_29 = NULL, *_30 = NULL, *_31; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &path); ZEPHIR_INIT_VAR(variants); array_init(variants); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "agggtaaa|tttaccct", 1); zephir_array_fast_append(variants, _0); ZEPHIR_INIT_BNVAR(_0); ZVAL_STRING(_0, "[cgt]gggtaaa|tttaccc[acg]", 1); zephir_array_fast_append(variants, _0); ZEPHIR_INIT_BNVAR(_0); ZVAL_STRING(_0, "a[act]ggtaaa|tttacc[agt]t", 1); zephir_array_fast_append(variants, _0); ZEPHIR_INIT_BNVAR(_0); ZVAL_STRING(_0, "ag[act]gtaaa|tttac[agt]ct", 1); zephir_array_fast_append(variants, _0); ZEPHIR_INIT_BNVAR(_0); ZVAL_STRING(_0, "agg[act]taaa|ttta[agt]cct", 1); zephir_array_fast_append(variants, _0); ZEPHIR_INIT_BNVAR(_0); ZVAL_STRING(_0, "aggg[acg]aaa|ttt[cgt]ccct", 1); zephir_array_fast_append(variants, _0); ZEPHIR_INIT_BNVAR(_0); ZVAL_STRING(_0, "agggt[cgt]aa|tt[acg]accct", 1); zephir_array_fast_append(variants, _0); ZEPHIR_INIT_BNVAR(_0); ZVAL_STRING(_0, "agggta[cgt]a|t[acg]taccct", 1); zephir_array_fast_append(variants, _0); ZEPHIR_INIT_BNVAR(_0); ZVAL_STRING(_0, "agggtaa[cgt]|[acg]ttaccct", 1); zephir_array_fast_append(variants, _0); ZEPHIR_INIT_VAR(vIUB); array_init(vIUB); ZEPHIR_INIT_VAR(vIUBnew); array_init(vIUBnew); ZEPHIR_INIT_BNVAR(_0); ZVAL_STRING(_0, "/B/S", 1); zephir_array_append(&vIUB, _0, PH_SEPARATE); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "(c|g|t)", 1); zephir_array_append(&vIUBnew, _1, PH_SEPARATE); ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "/D/S", 1); zephir_array_append(&vIUB, _2, PH_SEPARATE); ZEPHIR_INIT_VAR(_3); ZVAL_STRING(_3, "(a|g|t)", 1); zephir_array_append(&vIUBnew, _3, PH_SEPARATE); ZEPHIR_INIT_VAR(_4); ZVAL_STRING(_4, "/H/S", 1); zephir_array_append(&vIUB, _4, PH_SEPARATE); ZEPHIR_INIT_VAR(_5); ZVAL_STRING(_5, "(a|c|t)", 1); zephir_array_append(&vIUBnew, _5, PH_SEPARATE); ZEPHIR_INIT_VAR(_6); ZVAL_STRING(_6, "/K/S", 1); zephir_array_append(&vIUB, _6, PH_SEPARATE); ZEPHIR_INIT_VAR(_7); ZVAL_STRING(_7, "(g|t)", 1); zephir_array_append(&vIUBnew, _7, PH_SEPARATE); ZEPHIR_INIT_VAR(_8); ZVAL_STRING(_8, "/M/S", 1); zephir_array_append(&vIUB, _8, PH_SEPARATE); ZEPHIR_INIT_VAR(_9); ZVAL_STRING(_9, "(a|c)", 1); zephir_array_append(&vIUBnew, _9, PH_SEPARATE); ZEPHIR_INIT_VAR(_10); ZVAL_STRING(_10, "/N/S", 1); zephir_array_append(&vIUB, _10, PH_SEPARATE); ZEPHIR_INIT_VAR(_11); ZVAL_STRING(_11, "(a|c|g|t)", 1); zephir_array_append(&vIUBnew, _11, PH_SEPARATE); ZEPHIR_INIT_VAR(_12); ZVAL_STRING(_12, "/R/S", 1); zephir_array_append(&vIUB, _12, PH_SEPARATE); ZEPHIR_INIT_VAR(_13); ZVAL_STRING(_13, "(a|g)", 1); zephir_array_append(&vIUBnew, _13, PH_SEPARATE); ZEPHIR_INIT_VAR(_14); ZVAL_STRING(_14, "/S/S", 1); zephir_array_append(&vIUB, _14, PH_SEPARATE); ZEPHIR_INIT_VAR(_15); ZVAL_STRING(_15, "(c|g)", 1); zephir_array_append(&vIUBnew, _15, PH_SEPARATE); ZEPHIR_INIT_VAR(_16); ZVAL_STRING(_16, "/V/S", 1); zephir_array_append(&vIUB, _16, PH_SEPARATE); ZEPHIR_INIT_VAR(_17); ZVAL_STRING(_17, "(a|c|g)", 1); zephir_array_append(&vIUBnew, _17, PH_SEPARATE); ZEPHIR_INIT_VAR(_18); ZVAL_STRING(_18, "/W/S", 1); zephir_array_append(&vIUB, _18, PH_SEPARATE); ZEPHIR_INIT_VAR(_19); ZVAL_STRING(_19, "(a|t)", 1); zephir_array_append(&vIUBnew, _19, PH_SEPARATE); ZEPHIR_INIT_VAR(_20); ZVAL_STRING(_20, "/Y/S", 1); zephir_array_append(&vIUB, _20, PH_SEPARATE); ZEPHIR_INIT_VAR(_21); ZVAL_STRING(_21, "(c|t)", 1); zephir_array_append(&vIUBnew, _21, PH_SEPARATE); ZEPHIR_INIT_VAR(stuffToRemove); ZVAL_STRING(stuffToRemove, "^>.*$|\n", 1); ZEPHIR_INIT_VAR(discard); ZVAL_NULL(discard); ZEPHIR_INIT_VAR(contents); zephir_call_func_p1(contents, "file_get_contents", path); ZEPHIR_INIT_VAR(initialLength); ZVAL_LONG(initialLength, zephir_fast_strlen_ev(contents)); ZEPHIR_INIT_VAR(_22); ZEPHIR_CONCAT_SV(_22, "/", stuffToRemove); ZEPHIR_INIT_VAR(_23); ZEPHIR_CONCAT_VS(_23, _22, "/mS"); ZEPHIR_SINIT_VAR(_24); ZVAL_STRING(&_24, "", 0); ZEPHIR_INIT_VAR(_25); zephir_call_func_p3(_25, "preg_replace", _23, &_24, contents); ZEPHIR_CPY_WRT(contents, _25); ZEPHIR_INIT_VAR(codeLength); ZVAL_LONG(codeLength, zephir_fast_strlen_ev(contents)); zephir_is_iterable(variants, &_27, &_26, 0, 0); for ( ; zend_hash_get_current_data_ex(_27, (void**) &_28, &_26) == SUCCESS ; zend_hash_move_forward_ex(_27, &_26) ) { ZEPHIR_GET_HVALUE(regex, _28); zend_print_zval(regex, 0); php_printf(" "); ZEPHIR_INIT_LNVAR(_29); ZEPHIR_CONCAT_SV(_29, "/", regex); ZEPHIR_INIT_LNVAR(_30); ZEPHIR_CONCAT_VS(_30, _29, "/iS"); Z_SET_ISREF_P(discard); ZEPHIR_INIT_NVAR(_25); zephir_call_func_p3(_25, "preg_match_all", _30, contents, discard); zend_print_zval(_25, 0); php_printf("%c", '\n'); } ZEPHIR_INIT_VAR(_31); zephir_call_func_p3(_31, "preg_replace", vIUB, vIUBnew, contents); ZEPHIR_CPY_WRT(contents, _31); php_printf("%c", '\n'); zend_print_zval(initialLength, 0); php_printf("%c", '\n'); zend_print_zval(codeLength, 0); php_printf("%c", '\n'); php_printf("%d", zephir_fast_strlen_ev(contents)); php_printf("%c", '\n'); ZEPHIR_MM_RESTORE(); }
PHP_METHOD(Test_RegexDNA, process) { HashTable *_4; HashPosition _3; zval *path, *variants, *vIUB, *vIUBnew, *stuffToRemove, *contents = NULL, *initialLength, *regex = NULL, *codeLength, *discard, *_0 = NULL, *_1, _2, **_5, *_6 = NULL, *_7; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &path); ZEPHIR_INIT_VAR(variants); array_init_size(variants, 13); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "agggtaaa|tttaccct", 1); zephir_array_fast_append(variants, _0); ZEPHIR_INIT_BNVAR(_0); ZVAL_STRING(_0, "[cgt]gggtaaa|tttaccc[acg]", 1); zephir_array_fast_append(variants, _0); ZEPHIR_INIT_BNVAR(_0); ZVAL_STRING(_0, "a[act]ggtaaa|tttacc[agt]t", 1); zephir_array_fast_append(variants, _0); ZEPHIR_INIT_BNVAR(_0); ZVAL_STRING(_0, "ag[act]gtaaa|tttac[agt]ct", 1); zephir_array_fast_append(variants, _0); ZEPHIR_INIT_BNVAR(_0); ZVAL_STRING(_0, "agg[act]taaa|ttta[agt]cct", 1); zephir_array_fast_append(variants, _0); ZEPHIR_INIT_BNVAR(_0); ZVAL_STRING(_0, "aggg[acg]aaa|ttt[cgt]ccct", 1); zephir_array_fast_append(variants, _0); ZEPHIR_INIT_BNVAR(_0); ZVAL_STRING(_0, "agggt[cgt]aa|tt[acg]accct", 1); zephir_array_fast_append(variants, _0); ZEPHIR_INIT_BNVAR(_0); ZVAL_STRING(_0, "agggta[cgt]a|t[acg]taccct", 1); zephir_array_fast_append(variants, _0); ZEPHIR_INIT_BNVAR(_0); ZVAL_STRING(_0, "agggtaa[cgt]|[acg]ttaccct", 1); zephir_array_fast_append(variants, _0); ZEPHIR_INIT_VAR(vIUB); array_init(vIUB); ZEPHIR_INIT_VAR(vIUBnew); array_init(vIUBnew); ZEPHIR_INIT_BNVAR(_0); ZVAL_STRING(_0, "/B/S", 1); zephir_array_append(&vIUB, _0, PH_SEPARATE); ZEPHIR_INIT_BNVAR(_0); ZVAL_STRING(_0, "(c|g|t)", 1); zephir_array_append(&vIUBnew, _0, PH_SEPARATE); ZEPHIR_INIT_BNVAR(_0); ZVAL_STRING(_0, "/D/S", 1); zephir_array_append(&vIUB, _0, PH_SEPARATE); ZEPHIR_INIT_BNVAR(_0); ZVAL_STRING(_0, "(a|g|t)", 1); zephir_array_append(&vIUBnew, _0, PH_SEPARATE); ZEPHIR_INIT_BNVAR(_0); ZVAL_STRING(_0, "/H/S", 1); zephir_array_append(&vIUB, _0, PH_SEPARATE); ZEPHIR_INIT_BNVAR(_0); ZVAL_STRING(_0, "(a|c|t)", 1); zephir_array_append(&vIUBnew, _0, PH_SEPARATE); ZEPHIR_INIT_BNVAR(_0); ZVAL_STRING(_0, "/K/S", 1); zephir_array_append(&vIUB, _0, PH_SEPARATE); ZEPHIR_INIT_BNVAR(_0); ZVAL_STRING(_0, "(g|t)", 1); zephir_array_append(&vIUBnew, _0, PH_SEPARATE); ZEPHIR_INIT_BNVAR(_0); ZVAL_STRING(_0, "/M/S", 1); zephir_array_append(&vIUB, _0, PH_SEPARATE); ZEPHIR_INIT_BNVAR(_0); ZVAL_STRING(_0, "(a|c)", 1); zephir_array_append(&vIUBnew, _0, PH_SEPARATE); ZEPHIR_INIT_BNVAR(_0); ZVAL_STRING(_0, "/N/S", 1); zephir_array_append(&vIUB, _0, PH_SEPARATE); ZEPHIR_INIT_BNVAR(_0); ZVAL_STRING(_0, "(a|c|g|t)", 1); zephir_array_append(&vIUBnew, _0, PH_SEPARATE); ZEPHIR_INIT_BNVAR(_0); ZVAL_STRING(_0, "/R/S", 1); zephir_array_append(&vIUB, _0, PH_SEPARATE); ZEPHIR_INIT_BNVAR(_0); ZVAL_STRING(_0, "(a|g)", 1); zephir_array_append(&vIUBnew, _0, PH_SEPARATE); ZEPHIR_INIT_BNVAR(_0); ZVAL_STRING(_0, "/S/S", 1); zephir_array_append(&vIUB, _0, PH_SEPARATE); ZEPHIR_INIT_BNVAR(_0); ZVAL_STRING(_0, "(c|g)", 1); zephir_array_append(&vIUBnew, _0, PH_SEPARATE); ZEPHIR_INIT_BNVAR(_0); ZVAL_STRING(_0, "/V/S", 1); zephir_array_append(&vIUB, _0, PH_SEPARATE); ZEPHIR_INIT_BNVAR(_0); ZVAL_STRING(_0, "(a|c|g)", 1); zephir_array_append(&vIUBnew, _0, PH_SEPARATE); ZEPHIR_INIT_BNVAR(_0); ZVAL_STRING(_0, "/W/S", 1); zephir_array_append(&vIUB, _0, PH_SEPARATE); ZEPHIR_INIT_BNVAR(_0); ZVAL_STRING(_0, "(a|t)", 1); zephir_array_append(&vIUBnew, _0, PH_SEPARATE); ZEPHIR_INIT_BNVAR(_0); ZVAL_STRING(_0, "/Y/S", 1); zephir_array_append(&vIUB, _0, PH_SEPARATE); ZEPHIR_INIT_BNVAR(_0); ZVAL_STRING(_0, "(c|t)", 1); zephir_array_append(&vIUBnew, _0, PH_SEPARATE); ZEPHIR_INIT_VAR(stuffToRemove); ZVAL_STRING(stuffToRemove, "^>.*$|\n", 1); ZEPHIR_INIT_VAR(discard); ZVAL_NULL(discard); ZEPHIR_INIT_VAR(contents); zephir_file_get_contents(contents, path TSRMLS_CC); ZEPHIR_INIT_VAR(initialLength); ZVAL_LONG(initialLength, zephir_fast_strlen_ev(contents)); ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_SVS(_1, "/", stuffToRemove, "/mS"); ZEPHIR_SINIT_VAR(_2); ZVAL_STRING(&_2, "", 0); ZEPHIR_INIT_BNVAR(_0); zephir_call_func_p3(_0, "preg_replace", _1, &_2, contents); ZEPHIR_CPY_WRT(contents, _0); ZEPHIR_INIT_VAR(codeLength); ZVAL_LONG(codeLength, zephir_fast_strlen_ev(contents)); zephir_is_iterable(variants, &_4, &_3, 0, 0); for ( ; zend_hash_get_current_data_ex(_4, (void**) &_5, &_3) == SUCCESS ; zephir_hash_move_forward_ex(_4, &_3) ) { ZEPHIR_GET_HVALUE(regex, _5); zend_print_zval(regex, 0); php_printf(" "); ZEPHIR_INIT_NVAR(_0); ZEPHIR_INIT_LNVAR(_6); ZEPHIR_CONCAT_SVS(_6, "/", regex, "/iS"); zephir_preg_match(_0, &(_0), _6, contents, discard, 1, 0 , 0 TSRMLS_CC); zend_print_zval(_0, 0); php_printf("%c", '\n'); } ZEPHIR_INIT_VAR(_7); zephir_call_func_p3(_7, "preg_replace", vIUB, vIUBnew, contents); ZEPHIR_CPY_WRT(contents, _7); php_printf("%c", '\n'); zend_print_zval(initialLength, 0); php_printf("%c", '\n'); zend_print_zval(codeLength, 0); php_printf("%c", '\n'); php_printf("%d", zephir_fast_strlen_ev(contents)); php_printf("%c", '\n'); ZEPHIR_MM_RESTORE(); }