rrichards Wed Oct 12 09:58:10 2005 EDT
Modified files: (Branch: PHP_5_1)
/php-src/ext/xml compat.c
Log:
MFH: use spprintf where appropriate
http://cvs.php.net/diff.php/php-src/ext/xml/compat.c?r1=1.44.2.1&r2=1.44.2.2&ty=u
Index: php-src/ext/xml/compat.c
diff -u php-src/ext/xml/compat.c:1.44.2.1 php-src/ext/xml/compat.c:1.44.2.2
--- php-src/ext/xml/compat.c:1.44.2.1 Tue Oct 11 23:21:05 2005
+++ php-src/ext/xml/compat.c Wed Oct 12 09:58:10 2005
@@ -59,12 +59,16 @@
qualified_name = xmlStrncatNew((xmlChar *)"<", name,
xmlStrlen(name));
if (attributes) {
while (attributes[attno] != NULL) {
- qualified_name =
xmlStrncat(qualified_name, (xmlChar *)" ", 1);
- qualified_name =
xmlStrcat(qualified_name, (xmlChar *)attributes[attno]);
- qualified_name =
xmlStrncat(qualified_name, (xmlChar *)"=\"", 2);
- qualified_name =
xmlStrcat(qualified_name, (xmlChar *)attributes[++attno]);
- qualified_name =
xmlStrncat(qualified_name, (xmlChar *)"\"", 1);
- attno++;
+ int att_len;
+ char *att_string, *att_name, *att_value;
+
+ att_name = (char *)attributes[attno++];
+ att_value = (char *)attributes[attno++];
+
+ att_len = spprintf(&att_string, 0, "
%s=\"%s\"", att_name, att_value);
+
+ qualified_name =
xmlStrncat(qualified_name, (xmlChar *)att_string, att_len);
+ efree(att_string);
}
}
@@ -151,10 +155,11 @@
if (parser->h_end_element == NULL) {
if (parser->h_default) {
- qualified_name = xmlStrncatNew((xmlChar *)"</", name,
xmlStrlen(name));
- qualified_name = xmlStrncat(qualified_name, (xmlChar
*)">", 1);
- parser->h_default(parser->user, (const XML_Char *)
qualified_name, xmlStrlen(qualified_name));
- xmlFree(qualified_name);
+ char *end_element;
+
+ spprintf(&end_element, 0, "</%s>", (char *)name);
+ parser->h_default(parser->user, (const XML_Char *)
end_element, strlen(end_element));
+ efree(end_element);
}
return;
}
@@ -205,14 +210,10 @@
if (parser->h_pi == NULL) {
if (parser->h_default) {
- xmlChar *full_pi;
-
- full_pi = xmlStrncatNew((xmlChar *)"<?", target,
xmlStrlen(target));
- full_pi = xmlStrncat(full_pi, (xmlChar *)" ", 1);
- full_pi = xmlStrcat(full_pi, data);
- full_pi = xmlStrncat(full_pi, (xmlChar *)"?>", 2);
+ char *full_pi;
+ spprintf(&full_pi, 0, "<?%s %s?>", (char *)target,
(char *)data);
parser->h_default(parser->user, (const XML_Char *)
full_pi, xmlStrlen(full_pi));
- xmlFree(full_pi);
+ efree(full_pi);
}
return;
}
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php