cvs: php4 /ext/standard info.c /main main.c php_ini.c php_main.h

From: Date: Sun, 12 May 2002 14:48:23 +0000
Subject: cvs: php4 /ext/standard info.c /main main.c php_ini.c php_main.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-11863@lists.php.net to get a copy of this message
sas Sun May 12 10:48:23 2002 EDT Modified files: /php4/main php_main.h php_ini.c main.c /php4/ext/standard info.c Log: reenable php_html_puts Index: php4/main/php_main.h diff -u php4/main/php_main.h:1.20 php4/main/php_main.h:1.21 --- php4/main/php_main.h:1.20 Sat May 11 08:41:33 2002 +++ php4/main/php_main.h Sun May 12 10:48:20 2002 @@ -18,7 +18,7 @@ */ -/* $Id: php_main.h,v 1.20 2002/05/11 12:41:33 zeev Exp $ */ +/* $Id: php_main.h,v 1.21 2002/05/12 14:48:20 sas Exp $ */ #ifndef PHP_MAIN_H @@ -44,6 +44,8 @@ PHPAPI void php_handle_aborted_connection(void); PHPAPI int php_handle_auth_data(const char *auth TSRMLS_DC); + +PHPAPI void php_html_puts(const char *str, uint siz TSRMLS_DC); extern void php_call_shutdown_functions(void); Index: php4/main/php_ini.c diff -u php4/main/php_ini.c:1.93 php4/main/php_ini.c:1.94 --- php4/main/php_ini.c:1.93 Sat May 11 09:49:44 2002 +++ php4/main/php_ini.c Sun May 12 10:48:20 2002 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_ini.c,v 1.93 2002/05/11 13:49:44 zeev Exp $ */ +/* $Id: php_ini.c,v 1.94 2002/05/12 14:48:20 sas Exp $ */ /* Check CWD for php.ini */ #define INI_CHECK_CWD @@ -74,7 +74,7 @@ display_string_length = sizeof("<i>no value</i>")-1; } if(esc_html) { - zend_html_puts(display_string, display_string_length); + php_html_puts(display_string, display_string_length TSRMLS_CC); } else { PHPWRITE(display_string, display_string_length); } Index: php4/main/main.c diff -u php4/main/main.c:1.452 php4/main/main.c:1.453 --- php4/main/main.c:1.452 Sat May 11 08:41:32 2002 +++ php4/main/main.c Sun May 12 10:48:21 2002 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: main.c,v 1.452 2002/05/11 12:41:32 zeev Exp $ */ +/* $Id: main.c,v 1.453 2002/05/12 14:48:21 sas Exp $ */ /* {{{ includes */ @@ -377,12 +377,54 @@ } /* }}} */ - /* {{{ php_html_puts */ -/* wrapper for backwards compatibility */ +#include "ext/standard/php_smart_str.h" + PHPAPI void php_html_puts(const char *str, uint size TSRMLS_DC) { - zend_html_puts(str, size); + const char *end = str+size; + const char *p = str; + smart_str s = {0}; + + while (p < end) { + switch (*p) { + case '\n': + smart_str_appendl(&s, "<br />", sizeof("<br />")-1); + break; + case '<': + smart_str_appendl(&s, "&lt;", sizeof("&lt;")-1); + break; + case '>': + smart_str_appendl(&s, "&gt;", sizeof("&gt;")-1); + break; + case '&': + smart_str_appendl(&s, "&amp;", sizeof("&amp;")-1); + break; + case ' ': { + const char *nextchar = p+1, *prevchar = p-1; + + /* series of spaces should be converted to &nbsp;'s */ + if (((nextchar < end) && *nextchar==' ') + || ((prevchar >= str) && *prevchar==' ')) { + smart_str_appendl(&s, "&nbsp;", sizeof("&nbsp;")-1); + } else { + smart_str_appendc(&s, ' '); + } + } + break; + case '\t': + smart_str_appendl(&s, "&nbsp;&nbsp;&nbsp;&nbsp;", sizeof("&nbsp;&nbsp;&nbsp;&nbsp;")-1); + break; + default: + smart_str_appendc(&s, *p); + } + p++; + } + + if (s.c) { + PHPWRITE(s.c, s.len); + smart_str_free(&s); + } } /* }}} */ Index: php4/ext/standard/info.c diff -u php4/ext/standard/info.c:1.176 php4/ext/standard/info.c:1.177 --- php4/ext/standard/info.c:1.176 Sat May 11 08:41:32 2002 +++ php4/ext/standard/info.c Sun May 12 10:48:22 2002 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: info.c,v 1.176 2002/05/11 12:41:32 zeev Exp $ */ +/* $Id: info.c,v 1.177 2002/05/12 14:48:22 sas Exp $ */ #include "php.h" #include "php_ini.h" @@ -67,6 +67,7 @@ { zval **data, **tmp, tmp2; char *string_key; + uint string_len; ulong num_key; if (zend_hash_find(&EG(symbol_table), name, name_length+1, (void **) &data)!=FAILURE @@ -77,9 +78,9 @@ PUTS("<td bgcolor=\"" PHP_ENTRY_NAME_COLOR "\"><b>"); PUTS(name); PUTS("[\""); - switch (zend_hash_get_current_key(Z_ARRVAL_PP(data), &string_key, &num_key, 0)) { + switch (zend_hash_get_current_key_ex(Z_ARRVAL_PP(data), &string_key, &string_len, &num_key, 0, NULL)) { case HASH_KEY_IS_STRING: - zend_html_puts(string_key, strlen(string_key)); + php_html_puts(string_key, strlen(string_key) TSRMLS_CC); break; case HASH_KEY_IS_LONG: php_printf("%ld", num_key); @@ -94,10 +95,10 @@ tmp2 = **tmp; zval_copy_ctor(&tmp2); convert_to_string(&tmp2); - zend_html_puts(Z_STRVAL(tmp2), Z_STRLEN(tmp2)); + php_html_puts(Z_STRVAL(tmp2), Z_STRLEN(tmp2) TSRMLS_CC); zval_dtor(&tmp2); } else { - zend_html_puts(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp)); + php_html_puts(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp) TSRMLS_CC); } PUTS("&nbsp;</td></tr>\n"); zend_hash_move_forward(Z_ARRVAL_PP(data)); @@ -290,7 +291,7 @@ PUTS("?="ZEND_LOGO_GUID"\" border=\"0\" align=\"right\" alt=\"Zend logo\"></a>\n"); } php_printf("This program makes use of the Zend Scripting Language Engine:<br />"); - zend_html_puts(zend_version, strlen(zend_version)); + php_html_puts(zend_version, strlen(zend_version) TSRMLS_CC); php_info_print_box_end(); efree(php_uname); } @@ -482,7 +483,7 @@ if (!row_element || !*row_element) { php_printf("&nbsp;"); } else { - zend_html_puts(row_element, strlen(row_element)); + php_html_puts(row_element, strlen(row_element) TSRMLS_CC); } php_printf("%s</td>", (i==0?"</b>":""));

« previous php.cvs (#11863) next »