From 864134765a33823e2040c012ec383bebd7dd5743 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 4 Oct 2012 11:47:32 +1000 Subject: code cleanup: make more functions static or include their own headers. (bzr r11736) --- src/xml/quote.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/xml/quote.cpp') diff --git a/src/xml/quote.cpp b/src/xml/quote.cpp index 51f9ffb97..030a6c764 100644 --- a/src/xml/quote.cpp +++ b/src/xml/quote.cpp @@ -13,6 +13,7 @@ #include #include +#include "quote.h" /** \return strlen(xml_quote_strdup(\a val)) (without doing the malloc). -- cgit v1.2.3 From 627ff49d6fb3a7e52bb1430c412eee62311b5a2c Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Fri, 20 Sep 2013 16:59:45 +0200 Subject: make check: Fix harder. Remove muldefs hack and modify quote-test.h so that the hack is not required any more. (bzr r12551) --- src/xml/quote.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/xml/quote.cpp') diff --git a/src/xml/quote.cpp b/src/xml/quote.cpp index 030a6c764..c9e001d05 100644 --- a/src/xml/quote.cpp +++ b/src/xml/quote.cpp @@ -19,7 +19,7 @@ /** \return strlen(xml_quote_strdup(\a val)) (without doing the malloc). * \pre val != NULL */ -static size_t +size_t xml_quoted_strlen(char const *val) { size_t ret = 0; @@ -43,11 +43,11 @@ xml_quoted_strlen(char const *val) static void xml_quote(char *dest, char const *src) { -#define COPY_LIT(_lit) do { \ - size_t cpylen = sizeof(_lit "") - 1; \ - memcpy(dest, _lit, cpylen); \ - dest += cpylen; \ - } while(0) +#define COPY_LIT(_lit) do { \ + size_t cpylen = sizeof(_lit "") - 1; \ + memcpy(dest, _lit, cpylen); \ + dest += cpylen; \ + } while(0) for (; *src != '\0'; ++src) { switch (*src) { -- cgit v1.2.3 From b751fd5b7f06580b4a242cdddf475e3f2c121501 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Fri, 20 Dec 2013 16:12:24 +0100 Subject: add null check (bzr r12854) --- src/xml/quote.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/xml/quote.cpp') diff --git a/src/xml/quote.cpp b/src/xml/quote.cpp index c9e001d05..02c12dfb0 100644 --- a/src/xml/quote.cpp +++ b/src/xml/quote.cpp @@ -23,13 +23,15 @@ size_t xml_quoted_strlen(char const *val) { size_t ret = 0; - for (; *val != '\0'; val++) { - switch (*val) { - case '"': ret += sizeof(""") - 1; break; - case '&': ret += sizeof("&") - 1; break; - case '<': ret += sizeof("<") - 1; break; - case '>': ret += sizeof(">") - 1; break; - default: ++ret; break; + if (val != NULL) { + for (; *val != '\0'; val++) { + switch (*val) { + case '"': ret += sizeof(""") - 1; break; + case '&': ret += sizeof("&") - 1; break; + case '<': ret += sizeof("<") - 1; break; + case '>': ret += sizeof(">") - 1; break; + default: ++ret; break; + } } } return ret; -- cgit v1.2.3