Browse Source

Fixed bug #26456 (Wrong results from Reflection-API getDocComment() when called via STDIN)

PHP-5.1
Dmitry Stogov 21 years ago
parent
commit
58a0ee09c3
  1. 15
      Zend/zend_compile.c
  2. 11
      Zend/zend_compile.h
  3. 3
      Zend/zend_language_scanner.l

15
Zend/zend_compile.c

@ -1155,9 +1155,10 @@ void zend_do_begin_function_declaration(znode *function_token, znode *function_n
}
if (CG(doc_comment)) {
CG(active_op_array)->doc_comment = estrndup(CG(doc_comment), CG(doc_comment_len));
CG(active_op_array)->doc_comment = CG(doc_comment);
CG(active_op_array)->doc_comment_len = CG(doc_comment_len);
RESET_DOC_COMMENT();
CG(doc_comment) = NULL;
CG(doc_comment_len) = 0;
}
}
@ -2611,9 +2612,10 @@ void zend_do_begin_class_declaration(znode *class_token, znode *class_name, znod
CG(implementing_class) = opline->result;
if (CG(doc_comment)) {
CG(active_class_entry)->doc_comment = estrndup(CG(doc_comment), CG(doc_comment_len));
CG(active_class_entry)->doc_comment = CG(doc_comment);
CG(active_class_entry)->doc_comment_len = CG(doc_comment_len);
RESET_DOC_COMMENT();
CG(doc_comment) = NULL;
CG(doc_comment_len) = 0;
}
}
@ -2745,9 +2747,10 @@ void zend_do_declare_property(znode *var_name, znode *value, zend_uint access_ty
}
if (CG(doc_comment)) {
comment = estrndup(CG(doc_comment), CG(doc_comment_len));
comment = CG(doc_comment);
comment_len = CG(doc_comment_len);
RESET_DOC_COMMENT();
CG(doc_comment) = NULL;
CG(doc_comment_len) = 0;
}
zend_declare_property_ex(CG(active_class_entry), var_name->u.constant.value.str.val, var_name->u.constant.value.str.len, property, access_type, comment, comment_len TSRMLS_CC);

11
Zend/zend_compile.h

@ -40,10 +40,13 @@
#define DEC_BPC(op_array) if (CG(interactive)) { ((op_array)->backpatch_count--); }
#define HANDLE_INTERACTIVE() if (CG(interactive)) { execute_new_code(TSRMLS_C); }
#define RESET_DOC_COMMENT() \
{ \
CG(doc_comment) = NULL; \
CG(doc_comment_len) = 0; \
#define RESET_DOC_COMMENT() \
{ \
if (CG(doc_comment)) { \
efree(CG(doc_comment)); \
CG(doc_comment) = NULL; \
} \
CG(doc_comment_len) = 0; \
}
typedef struct _zend_op_array zend_op_array;

3
Zend/zend_language_scanner.l

@ -1485,6 +1485,7 @@ NEWLINE ("\r"|"\n"|"\r\n")
<ST_IN_SCRIPTING>"/**"{WHITESPACE} {
CG(comment_start_line) = CG(zend_lineno);
RESET_DOC_COMMENT();
BEGIN(ST_DOC_COMMENT);
yymore();
}
@ -1501,7 +1502,7 @@ NEWLINE ("\r"|"\n"|"\r\n")
}
<ST_DOC_COMMENT>"*/" {
CG(doc_comment) = yytext; /* no copying - intentional */
CG(doc_comment) = estrndup(yytext, yyleng);
CG(doc_comment_len) = yyleng;
HANDLE_NEWLINES(yytext, yyleng);
BEGIN(ST_IN_SCRIPTING);

Loading…
Cancel
Save