note 124305 deleted from language.operators.arithmetic by salathe
| From: | salathe@php.net | Date: | Mon, 21 Sep 2020 14:58:22 +0000 |
| Subject: | note 124305 deleted from language.operators.arithmetic by salathe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-215404@lists.php.net to get a copy of this message | ||
Note Submitter: vike2000 at gmail dot com
----
With % (modulo), it looks like php uses the C operator (apart from some sanity-checks), according to
following
awk command, getting the relevant lines of arbitrary commits (dbb462db5d and
04d5086578 for me) in github.com/php/php-src:
$ awk '!F[0]&&/expr '\''%'\'' expr/{p()}
!F[0]&&/case ZEND_MOD/{p();F[0]=1;F[1]="return"}
!F[0]&&/mod_function\(.*\)/{p();F[0]=2;F[1]="ZVAL_LONG"} '$(: function p for
printing and array F for finding in files follows: )'
F[0]&&match($0,F[1])&&1==F[0]--{p();delete F;nextfile}function p(){print
FILENAME":"FNR":\t"$0}' Zend/zend_{language_parser.y,{opcode,operators}.c}
Zend/zend_language_parser.y:939: | expr '%' expr { $$ =
zend_ast_create_binary_op(ZEND_MOD, $1, $3); }
Zend/zend_opcode.c:1042: case ZEND_MOD:
Zend/zend_opcode.c:1043: return (binary_op_type) mod_function;
Zend/zend_operators.c:1333: ZEND_API int ZEND_FASTCALL mod_function(zval *result, zval *op1, zval
*op2) /* {{{ */
Zend/zend_operators.c:1362: ZVAL_LONG(result, op1_lval % op2_lval);