cvs: /php4/ext/standard html.c html.h
| From: | Andrei Zmievski | Date: | Tue, 29 Feb 2000 04:38:44 +0000 |
| Subject: | cvs: /php4/ext/standard html.c html.h | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-11170@lists.php.net to get a copy of this message | ||
andrei Mon Feb 28 20:38:44 2000 EDT
Modified files:
/php4/ext/standard html.c html.h
Log:
Made php_escape_html_entities() as a separate function for export.
Index: php4/ext/standard/html.c
diff -u php4/ext/standard/html.c:1.13 php4/ext/standard/html.c:1.14
--- php4/ext/standard/html.c:1.13 Sat Feb 19 15:41:21 2000
+++ php4/ext/standard/html.c Mon Feb 28 20:38:13 2000
@@ -43,27 +43,18 @@
"uuml","yacute","thorn","yuml"
};
-static void php_html_entities(INTERNAL_FUNCTION_PARAMETERS, int all)
+PHPAPI char *php_escape_html_entities(unsigned char *old, int oldlen, int *newlen, int all)
{
- pval **arg;
- int i, len, maxlen;
- unsigned char *old;
+ int i, maxlen, len;
char *new;
-
- if (ARG_COUNT(ht) != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string_ex(arg);
-
- maxlen = 2 * (*arg)->value.str.len;
+ maxlen = 2 * oldlen;
if (maxlen < 128)
maxlen = 128;
new = emalloc (maxlen);
len = 0;
- old = (unsigned char *)(*arg)->value.str.val;
- i = (*arg)->value.str.len;
+ i = oldlen;
while (i--) {
if (len + 9 > maxlen)
new = erealloc (new, maxlen += 128);
@@ -90,9 +81,25 @@
old++;
}
new [len] = '\0';
+ *newlen = len;
+
+ return new;
+}
+
+static void php_html_entities(INTERNAL_FUNCTION_PARAMETERS, int all)
+{
+ zval **arg;
+ int len;
+ char *new;
+
+ if (ARG_COUNT(ht) != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+
+ convert_to_string_ex(arg);
- RETVAL_STRINGL(new,len,1);
- efree(new);
+ new = php_escape_html_entities((*arg)->value.str.val, (*arg)->value.str.len, &len, all);
+ RETVAL_STRINGL(new,len,0);
}
#define HTML_SPECIALCHARS 0
Index: php4/ext/standard/html.h
diff -u php4/ext/standard/html.h:1.3 php4/ext/standard/html.h:1.4
--- php4/ext/standard/html.h:1.3 Sun Nov 21 05:25:04 1999
+++ php4/ext/standard/html.h Mon Feb 28 20:38:14 2000
@@ -27,7 +27,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: html.h,v 1.3 1999/11/21 13:25:04 thies Exp $ */
+/* $Id: html.h,v 1.4 2000/02/29 04:38:14 andrei Exp $ */
#ifndef _HTML_H
#define _HTML_H
@@ -37,5 +37,7 @@
PHP_FUNCTION(htmlspecialchars);
PHP_FUNCTION(htmlentities);
PHP_FUNCTION(get_html_translation_table);
+
+PHPAPI char *php_escape_html_entities(unsigned char *old, int oldlen, int *newlen, int all);
#endif /* _HTML_H */