php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login

Patch apc_auto_hardlinks_for_php_5.3.5.diff for *General Issues Bug #45421

Patch version 2011-04-27 08:27 UTC

Return to Bug #45421 | Download this patch
Patch Revisions:

Developer: simpcl2008@gmail.com

diff -uprN php-5.3.5/Zend/zend_compile.c php-5.3.5-sae/Zend/zend_compile.c
--- php-5.3.5/Zend/zend_compile.c	2010-11-03 23:40:24.000000000 +0800
+++ php-5.3.5-sae/Zend/zend_compile.c	2011-04-27 14:10:30.000000000 +0800
@@ -5404,6 +5404,20 @@ ZEND_API size_t zend_dirname(char *path,
 }
 /* }}} */
 
+void zend_do_executed_filename(znode *result TSRMLS_DC) /* {{{ */
+{
+    zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
+
+    opline->result.op_type = IS_TMP_VAR;
+    opline->result.u.var = get_temporary_variable(CG(active_op_array));
+    opline->opcode = ZEND_EXECUTED_FILENAME;
+    SET_UNUSED(opline->op1);
+    SET_UNUSED(opline->op2);
+    *result = opline->result;
+}
+/* }}} */
+
+
 /*
  * Local variables:
  * tab-width: 4
diff -uprN php-5.3.5/Zend/zend_compile.h php-5.3.5-sae/Zend/zend_compile.h
--- php-5.3.5/Zend/zend_compile.h	2010-06-10 17:13:22.000000000 +0800
+++ php-5.3.5-sae/Zend/zend_compile.h	2011-04-27 14:10:20.000000000 +0800
@@ -548,6 +548,8 @@ void zend_do_goto(const znode *label TSR
 void zend_resolve_goto_label(zend_op_array *op_array, zend_op *opline, int pass2 TSRMLS_DC);
 void zend_release_labels(TSRMLS_D);
 
+void zend_do_executed_filename(znode *result TSRMLS_DC);
+
 ZEND_API void function_add_ref(zend_function *function);
 
 #define INITIAL_OP_ARRAY_SIZE 64
diff -uprN php-5.3.5/Zend/zend_language_parser.y php-5.3.5-sae/Zend/zend_language_parser.y
--- php-5.3.5/Zend/zend_language_parser.y	2010-01-06 04:40:23.000000000 +0800
+++ php-5.3.5-sae/Zend/zend_language_parser.y	2011-04-27 13:53:17.000000000 +0800
@@ -132,7 +132,7 @@
 %token T_METHOD_C
 %token T_FUNC_C
 %token T_LINE
-%token T_FILE
+%token T_FILE T_EXECUTED_FILENAME
 %token T_COMMENT
 %token T_DOC_COMMENT
 %token T_OPEN_TAG
@@ -765,6 +765,7 @@ common_scalar:
 	|	T_NS_C						{ $$ = $1; }
 	|	T_START_HEREDOC T_ENCAPSED_AND_WHITESPACE T_END_HEREDOC { $$ = $2; CG(heredoc) = Z_STRVAL($1.u.constant); CG(heredoc_len) = Z_STRLEN($1.u.constant); }
 	|	T_START_HEREDOC T_END_HEREDOC { ZVAL_EMPTY_STRING(&$$.u.constant); INIT_PZVAL(&$$.u.constant); $$.op_type = IS_CONST; CG(heredoc) = Z_STRVAL($1.u.constant); CG(heredoc_len) = Z_STRLEN($1.u.constant); }
+    |   T_EXECUTED_FILENAME         { zend_do_executed_filename(&$$ TSRMLS_CC); }
 ;
 
 
diff -uprN php-5.3.5/Zend/zend_language_scanner.l php-5.3.5-sae/Zend/zend_language_scanner.l
--- php-5.3.5/Zend/zend_language_scanner.l	2010-11-18 00:46:19.000000000 +0800
+++ php-5.3.5-sae/Zend/zend_language_scanner.l	2011-04-27 13:50:39.000000000 +0800
@@ -1459,6 +1459,10 @@ NEWLINE ("\r"|"\n"|"\r\n")
 	return T_FILE;
 }
 
+<ST_IN_SCRIPTING>"executed_filename" {
+    return T_EXECUTED_FILENAME;
+}
+
 <ST_IN_SCRIPTING>"__DIR__" {
 	char *filename = zend_get_compiled_filename(TSRMLS_C);
 	const size_t filename_len = strlen(filename);
diff -uprN php-5.3.5/Zend/zend_vm_def.h php-5.3.5-sae/Zend/zend_vm_def.h
--- php-5.3.5/Zend/zend_vm_def.h	2010-07-05 17:08:35.000000000 +0800
+++ php-5.3.5-sae/Zend/zend_vm_def.h	2011-04-27 14:11:14.000000000 +0800
@@ -4432,4 +4432,14 @@ ZEND_VM_HANDLER(153, ZEND_DECLARE_LAMBDA
 	ZEND_VM_NEXT_OPCODE();
 }
 
+ZEND_VM_HANDLER(154, ZEND_EXECUTED_FILENAME, ANY, ANY)
+{
+    zend_op *opline = EX(opline);
+
+    char* s = zend_get_executed_filename(TSRMLS_C);
+    ZVAL_STRING(&(EX_T(opline->result.u.var).tmp_var), s, 1);
+    
+    ZEND_VM_NEXT_OPCODE();
+}
+
 ZEND_VM_EXPORT_HELPER(zend_do_fcall, zend_do_fcall_common_helper)
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Fri Apr 18 00:01:21 2014 UTC