Skip to content

Commit

Permalink
chore(ze2): Finally remove support for PHP5.3 and deprecate 5.4, #475
Browse files Browse the repository at this point in the history
  • Loading branch information
steffengy committed Dec 4, 2015
1 parent 7bcf46f commit 2efc33c
Show file tree
Hide file tree
Showing 18 changed files with 11 additions and 694 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ env:
secure: lRYAjibgHrvbte19lJCP2AhoGCR1asJlSNeF+QAn/ZYdd+J+StqK7DybaBbgk6cs7uodJ34OuGlOsAmE3B/EG4Qb/r+nbjEt7cA0+6+YyUs0sBpHoQ3XeFbZSSRsYvY0jKVn5/yl24GTobTTejc6MOW5N1/KErJynmylyW6q+Z4=

php:
- 5.3
- 5.4
- 5.5
- 5.6
Expand Down
63 changes: 1 addition & 62 deletions Library/Backends/ZendEngine2/StringsManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,68 +191,7 @@ public function genConcatCode()
$code .= "}" . PHP_EOL . PHP_EOL;
}

$code .= <<<EOF
void zephir_concat_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */
{
#if PHP_VERSION_ID < 50400
zval op1_copy, op2_copy;
int use_copy1 = 0, use_copy2 = 0;
if (Z_TYPE_P(op1) != IS_STRING) {
zend_make_printable_zval(op1, &op1_copy, &use_copy1);
}
if (Z_TYPE_P(op2) != IS_STRING) {
zend_make_printable_zval(op2, &op2_copy, &use_copy2);
}
if (use_copy1) {
/* We have created a converted copy of op1. Therefore, op1 won't become the result so
* we have to free it.
*/
if (result == op1) {
zval_dtor(op1);
}
op1 = &op1_copy;
}
if (use_copy2) {
op2 = &op2_copy;
}
if (result == op1 && !IS_INTERNED(Z_STRVAL_P(op1))) { /* special case, perform operations on result */
uint res_len = Z_STRLEN_P(op1) + Z_STRLEN_P(op2);
if (Z_STRLEN_P(result) < 0 || (int) (Z_STRLEN_P(op1) + Z_STRLEN_P(op2)) < 0) {
str_efree(Z_STRVAL_P(result));
ZVAL_EMPTY_STRING(result);
zend_error(E_ERROR, "String size overflow");
}
Z_STRVAL_P(result) = str_erealloc(Z_STRVAL_P(result), res_len+1);
memcpy(Z_STRVAL_P(result) + Z_STRLEN_P(result), Z_STRVAL_P(op2), Z_STRLEN_P(op2));
Z_STRVAL_P(result)[res_len] = 0;
Z_STRLEN_P(result) = res_len;
} else {
int length = Z_STRLEN_P(op1) + Z_STRLEN_P(op2);
char *buf = (char *) emalloc(length + 1);
memcpy(buf, Z_STRVAL_P(op1), Z_STRLEN_P(op1));
memcpy(buf + Z_STRLEN_P(op1), Z_STRVAL_P(op2), Z_STRLEN_P(op2));
buf[length] = 0;
ZVAL_STRINGL(result, buf, length, 0);
}
if (use_copy1) {
zval_dtor(op1);
}
if (use_copy2) {
zval_dtor(op2);
}
#else
concat_function(result, op1, op2 TSRMLS_CC);
#endif
}
EOF;

$codeh .= "void zephir_concat_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
$codeh .= "#define zephir_concat_function(result, op1, op2) concat_function(result, op1, op2 TSRMLS_CC)
#endif /* ZEPHIR_KERNEL_CONCAT_H */
Expand Down
2 changes: 1 addition & 1 deletion Library/Operators/Other/ConcatOperator.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public function compile($expression, CompilationContext $compilationContext)
}

if ($left->getType() == 'variable' && $right->getType() == 'variable') {
$compilationContext->codePrinter->output('zephir_concat_function(' . $expectedCode . ', ' . $variableLeft . ', ' . $variableRight . ' TSRMLS_CC);');
$compilationContext->codePrinter->output('zephir_concat_function(' . $expectedCode . ', ' . $variableLeft . ', ' . $variableRight . ');');
}

$expected->setDynamicTypes('string');
Expand Down
2 changes: 1 addition & 1 deletion Library/Statements/Let/StaticProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public function assignStatic($className, $property, CompiledExpression $resolved
$expression->compile($compilationContext);
$variableVariableCode = $compilationContext->backend->getVariableCode($variableVariable);
$tempVariableCode = $compilationContext->backend->getVariableCode($tempVariable);
$compilationContext->codePrinter->output('zephir_concat_function(' . $variableVariableCode . ', ' . $tempVariableCode . ', ' . $variableVariableCode .' TSRMLS_CC);');
$compilationContext->codePrinter->output('zephir_concat_function(' . $variableVariableCode . ', ' . $tempVariableCode . ', ' . $variableVariableCode .');');
//continue

case 'assign':
Expand Down
Loading

0 comments on commit 2efc33c

Please sign in to comment.