summaryrefslogtreecommitdiff
path: root/libexslt/strings.c
diff options
context:
space:
mode:
authorMyoungJune Park <mj2004.park@samsung.com>2016-06-29 14:28:51 +0900
committerMyoungJune Park <mj2004.park@samsung.com>2016-06-29 14:29:13 +0900
commit8737843a4d457b79d3c6abbc17fbf97b81a8861e (patch)
tree6229a8587d64a3a76c297f63d3eead8ffb51a14d /libexslt/strings.c
parentc3bb6b2f10204be6970bfbaa50f9e96e184d505f (diff)
parentc582450a479ff157cf79aed26b6b08e867ff3832 (diff)
downloadlibxslt-8737843a4d457b79d3c6abbc17fbf97b81a8861e.tar.gz
libxslt-8737843a4d457b79d3c6abbc17fbf97b81a8861e.tar.bz2
libxslt-8737843a4d457b79d3c6abbc17fbf97b81a8861e.zip
Merge branch 'tizen_base' into tizen
Change-Id: I412621219c0ed82145d1a03b5bbe474646fcf0ef Signed-off-by: MyoungJune Park <mj2004.park@samsung.com>
Diffstat (limited to 'libexslt/strings.c')
-rw-r--r--libexslt/strings.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/libexslt/strings.c b/libexslt/strings.c
index 045cc14b..f5f2d3c5 100644
--- a/libexslt/strings.c
+++ b/libexslt/strings.c
@@ -351,8 +351,8 @@ exsltStrDecodeUriFunction (xmlXPathParserContextPtr ctxt, int nargs) {
*/
static void
exsltStrPaddingFunction (xmlXPathParserContextPtr ctxt, int nargs) {
- int number, str_len = 0;
- xmlChar *str = NULL, *ret = NULL, *tmp;
+ int number, str_len = 0, str_size = 0;
+ xmlChar *str = NULL, *ret = NULL;
if ((nargs < 1) || (nargs > 2)) {
xmlXPathSetArityError(ctxt);
@@ -362,11 +362,13 @@ exsltStrPaddingFunction (xmlXPathParserContextPtr ctxt, int nargs) {
if (nargs == 2) {
str = xmlXPathPopString(ctxt);
str_len = xmlUTF8Strlen(str);
+ str_size = xmlStrlen(str);
}
if (str_len == 0) {
if (str != NULL) xmlFree(str);
str = xmlStrdup((const xmlChar *) " ");
str_len = 1;
+ str_size = 1;
}
number = (int) xmlXPathPopNumber(ctxt);
@@ -378,13 +380,13 @@ exsltStrPaddingFunction (xmlXPathParserContextPtr ctxt, int nargs) {
}
while (number >= str_len) {
- ret = xmlStrncat(ret, str, str_len);
+ ret = xmlStrncat(ret, str, str_size);
number -= str_len;
}
- tmp = xmlUTF8Strndup (str, number);
- ret = xmlStrcat(ret, tmp);
- if (tmp != NULL)
- xmlFree (tmp);
+ if (number > 0) {
+ str_size = xmlUTF8Strsize(str, number);
+ ret = xmlStrncat(ret, str, str_size);
+ }
xmlXPathReturnString(ctxt, ret);
@@ -445,7 +447,7 @@ exsltStrAlignFunction (xmlXPathParserContextPtr ctxt, int nargs) {
} else {
int str_s;
- str_s = xmlStrlen (str);
+ str_s = xmlUTF8Strsize(padding, str_l);
ret = xmlStrdup (str);
ret = xmlStrcat (ret, padding + str_s);
}
@@ -838,11 +840,7 @@ exsltStrXpathCtxtRegister (xmlXPathContextPtr ctxt, const xmlChar *prefix)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "concat",
(const xmlChar *) EXSLT_STRINGS_NAMESPACE,
- exsltStrConcatFunction)
- && !xmlXPathRegisterFuncNS(ctxt,
- (const xmlChar *) "replace",
- (const xmlChar *) EXSLT_STRINGS_NAMESPACE,
- exsltStrReplaceFunction)) {
+ exsltStrConcatFunction)) {
return 0;
}
return -1;