mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
- Centralize html_puts() again
- Revolutionize phpinfo()'s speed
This commit is contained in:
parent
4f77354ce0
commit
2260e1742d
2 changed files with 4 additions and 38 deletions
|
@ -532,7 +532,10 @@ PHP_FUNCTION(phpinfo)
|
|||
flag = PHP_INFO_ALL;
|
||||
}
|
||||
|
||||
/* Andale! Andale! Yee-Hah! */
|
||||
php_start_ob_buffer(NULL, 4096, 0 TSRMLS_CC);
|
||||
php_print_info(flag TSRMLS_CC);
|
||||
php_end_ob_buffer(1, 0 TSRMLS_CC);
|
||||
|
||||
RETURN_TRUE;
|
||||
}
|
||||
|
|
39
main/main.c
39
main/main.c
|
@ -378,46 +378,9 @@ PHPAPI int php_printf(const char *format, ...)
|
|||
/* }}} */
|
||||
|
||||
/* {{{ php_html_puts */
|
||||
#include "ext/standard/php_smart_str.h"
|
||||
|
||||
PHPAPI void php_html_puts(const char *str, uint size TSRMLS_DC)
|
||||
{
|
||||
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, "<", sizeof("<")-1);
|
||||
break;
|
||||
case '>':
|
||||
smart_str_appendl(&s, ">", sizeof(">")-1);
|
||||
break;
|
||||
case '&':
|
||||
smart_str_appendl(&s, "&", sizeof("&")-1);
|
||||
break;
|
||||
case ' ':
|
||||
while (++p < end && *p == ' ');
|
||||
|
||||
smart_str_appends(&s, " ");
|
||||
continue;
|
||||
case '\t':
|
||||
smart_str_appendl(&s, " ", sizeof(" ")-1);
|
||||
break;
|
||||
default:
|
||||
smart_str_appendc(&s, *p);
|
||||
}
|
||||
p++;
|
||||
}
|
||||
|
||||
if (s.c) {
|
||||
PHPWRITE(s.c, s.len);
|
||||
smart_str_free(&s);
|
||||
}
|
||||
zend_html_puts(str, size);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue