PECL/phpdoc minor changes

From: Date: Sat, 12 Jan 2002 04:13:18 +0000
Subject: PECL/phpdoc minor changes
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-3911@lists.php.net to get a copy of this message
Hi all :) Here some minors modifications on PECL/phpdoc : - no more need to comment static statement on zend_language_scanner.c (did'nt succes to right use the Andrei last commit on this point). And to be honnest, i did'nt *really* understood all that i did, but it seems work quite fine for me... (tested with php 4.1.0 on a linux box) - Remove the function test : confirm_phpdoc_compiled - Proposition in poor english to an INSTALL file And i've seen last year a post who talk about future link between PECL/phpdoc and phpdoc, is there any news on this point ? :) -- old_phpdoc.c Sat Jan 12 04:19:24 2002 +++ phpdoc.c Sat Jan 12 04:19:53 2002 @@ -28,6 +28,7 @@ ** perhaps this a LICENSE CONFLICT, don't know. */ + typedef struct yy_buffer_state *YY_BUFFER_STATE; typedef unsigned int yy_size_t; struct yy_buffer_state @@ -87,6 +88,9 @@ #define YY_BUFFER_EOF_PENDING 2 }; +#define yy_current_buffer SCNG(current_buffer) +#define YY_CURRENT_BUFFER yy_current_buffer + #include "zend.h" #include "zend_language_scanner.h" #include "zend_language_parser.h" @@ -94,6 +98,63 @@ #define zendtext LANG_SCNG(yy_text) #define zendleng LANG_SCNG(yy_leng) +#define yy_switch_to_buffer zend_switch_to_buffer +#define yy_delete_buffer zend_delete_buffer +#define yy_scan_buffer zend_scan_buffer +#define SCNG LANG_SCNG +#define yy_start SCNG(start) +#define YY_START ((yy_start - 1) / 2) +#define YYSTATE YY_START +#define BEGIN yy_start = 1 + 2 * + + + +static inline void save_lexical_state(zend_lex_state *lex_state TSRMLS_DC) +{ + memcpy(&lex_state->buffer_state, &YY_CURRENT_BUFFER, sizeof(YY_BUFFER_STATE)); + lex_state->in = SCNG(yy_in); + lex_state->state = YYSTATE; + lex_state->filename = zend_get_compiled_filename(TSRMLS_C); + lex_state->lineno = CG(zend_lineno); +} + + +static inline void restore_lexical_state(zend_lex_state *lex_state TSRMLS_DC) +{ + YY_BUFFER_STATE original_buffer_state = YY_CURRENT_BUFFER; + + if (lex_state->buffer_state) { + yy_switch_to_buffer(lex_state->buffer_state TSRMLS_CC); + } else { + YY_CURRENT_BUFFER = NULL; + } + + yy_delete_buffer(original_buffer_state TSRMLS_CC); + SCNG(yy_in) = lex_state->in; + BEGIN(lex_state->state); + CG(zend_lineno) = lex_state->lineno; + zend_restore_compiled_filename(lex_state->filename TSRMLS_CC); +} + + +static inline int prepare_string_for_scanning(zval *str, char *filename TSRMLS_DC) +{ + /* enforce two trailing NULLs for flex... */ + STR_REALLOC(str->value.str.val, str->value.str.len+2); + + str->value.str.val[str->value.str.len+1]=0; + + SCNG(yy_in)=NULL; + yy_scan_buffer(str->value.str.val, str->value.str.len+2 TSRMLS_CC); + + zend_set_compiled_filename(filename TSRMLS_CC); + CG(zend_lineno) = 1; + CG(increment_lineno) = 0; + return SUCCESS; +} + + + /* ** --> */ @@ -113,7 +174,6 @@ /* Every user visible function must have an entry in phpdoc_functions[]. */ function_entry phpdoc_functions[] = { - PHP_FE(confirm_phpdoc_compiled, NULL) /* For testing, remove later. */ PHP_FE(phpdoc_xml_from_string, NULL) {NULL, NULL, NULL} /* Must be the last line in phpdoc_functions[] */ }; @@ -184,32 +244,6 @@ */ } -/* Every user-visible function in PHP should document itself in the source */ -/* {{{ proto string confirm_phpdoc_compiled(string arg) - Return a string to confirm that the module is compiled in */ - -PHP_FUNCTION(confirm_phpdoc_compiled) -{ - zval **arg; - int len; - char string[256]; - - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) { - WRONG_PARAM_COUNT; - } - - convert_to_string_ex(arg); - - len = sprintf(string, "Congratulations, you have successfully modified ext/phpdoc/config.m4, module %s is compiled into PHP", Z_STRVAL_PP(arg)); - RETURN_STRINGL(string, len, 1); -} -/* }}} */ - - - - - - int find_something(int *stack, int stack_pos) { #if 0 @@ -660,12 +694,12 @@ convert_to_string_ex(arg); - zend_save_lexical_state(&original_lex_state CLS_CC); + save_lexical_state(&original_lex_state CLS_CC); #ifndef ZTS - if (zend_prepare_string_for_scanning(*arg, "dummy.php")==FAILURE) { + if (prepare_string_for_scanning(*arg, "dummy.php")==FAILURE) { #else - if (zend_prepare_string_for_scanning(*arg, &input_stream, "dummy.php" CLS_CC)==FAILURE) { + if (prepare_string_for_scanning(*arg, &input_stream, "dummy.php" CLS_CC)==FAILURE) { #endif RETURN_EMPTY_STRING(); } @@ -675,7 +709,7 @@ MAKE_STD_ZVAL(return_value); ZVAL_EMPTY_STRING(return_value); #endif - zend_restore_lexical_state(&original_lex_state CLS_CC); + restore_lexical_state(&original_lex_state CLS_CC); #ifdef ZTS delete input_stream; #endif --- old_php_phpdoc.h Sat Jan 12 04:19:42 2002 +++ php_phpdoc.h Sat Jan 12 04:22:50 2002 @@ -40,7 +40,6 @@ PHP_RSHUTDOWN_FUNCTION(phpdoc); PHP_MINFO_FUNCTION(phpdoc); -PHP_FUNCTION(confirm_phpdoc_compiled); /* For testing, remove later. */ PHP_FUNCTION(phpdoc_xml_from_string); /* INSTALL -- To install PECL/phpdoc : First : - Download and untar a recent php source (php >= 4.1.0) - Copy the whole directory phpdoc in ext/ And then at top from php source tree do : $ ./buildconf $ ./configure [all your classical options] --enable-phpdoc $ make # make install Enjoy... ;) -- HTH :) -- Olivier

« previous php.pear.dev (#3911) next »