summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/common/escape.cc13
-rw-r--r--src/common/escape.h6
2 files changed, 9 insertions, 10 deletions
diff --git a/src/common/escape.cc b/src/common/escape.cc
index 78659b0bfb2..4e6b7f7f66a 100644
--- a/src/common/escape.cc
+++ b/src/common/escape.cc
@@ -32,10 +32,10 @@
#define SGL_QUOTE_XESCAPE "'"
#define DBL_QUOTE_XESCAPE """
-int escape_xml_attr_len(const char *buf)
+size_t escape_xml_attr_len(const char *buf)
{
const char *b;
- int ret = 0;
+ size_t ret = 0;
for (b = buf; *b; ++b) {
unsigned char c = *b;
switch (c) {
@@ -173,11 +173,10 @@ std::ostream& operator<<(std::ostream& out, const xml_stream_escaper& e)
#define TAB_JESCAPE "\\t"
#define NEWLINE_JESCAPE "\\n"
-int escape_json_attr_len(const char *buf, int src_len)
+size_t escape_json_attr_len(const char *buf, size_t src_len)
{
const char *b;
- int ret = 0;
- int i;
+ size_t i, ret = 0;
for (i = 0, b = buf; i < src_len; ++i, ++b) {
unsigned char c = *b;
switch (c) {
@@ -208,11 +207,11 @@ int escape_json_attr_len(const char *buf, int src_len)
return ret;
}
-void escape_json_attr(const char *buf, int src_len, char *out)
+void escape_json_attr(const char *buf, size_t src_len, char *out)
{
char *o = out;
const char *b;
- int i;
+ size_t i;
for (i = 0, b = buf; i < src_len; ++i, ++b) {
unsigned char c = *b;
switch (c) {
diff --git a/src/common/escape.h b/src/common/escape.h
index 277a208174c..22da777212a 100644
--- a/src/common/escape.h
+++ b/src/common/escape.h
@@ -21,7 +21,7 @@
/* Returns the length of a buffer that would be needed to escape 'buf'
* as an XML attrribute
*/
-int escape_xml_attr_len(const char *buf);
+size_t escape_xml_attr_len(const char *buf);
/* Escapes 'buf' as an XML attribute. Assumes that 'out' is at least long
* enough to fit the output. You can find out the required length by calling
@@ -32,13 +32,13 @@ void escape_xml_attr(const char *buf, char *out);
/* Returns the length of a buffer that would be needed to escape 'buf'
* as an JSON attrribute
*/
-int escape_json_attr_len(const char *buf, int src_len);
+size_t escape_json_attr_len(const char *buf, size_t src_len);
/* Escapes 'buf' as an JSON attribute. Assumes that 'out' is at least long
* enough to fit the output. You can find out the required length by calling
* escape_json_attr_len first.
*/
-void escape_json_attr(const char *buf, int src_len, char *out);
+void escape_json_attr(const char *buf, size_t src_len, char *out);
/* Note: we escape control characters. Although the XML spec doesn't actually
* require this, Amazon does it in their XML responses.