summaryrefslogtreecommitdiffstats
path: root/src/xml/quote.cpp
diff options
context:
space:
mode:
authorMartin Owens <doctormo@gmail.com>2014-03-27 01:33:44 +0000
committerMartin Owens <doctormo@gmail.com>2014-03-27 01:33:44 +0000
commit5a4fb2325f60d292b47330f540b26a3279341c90 (patch)
treed2aa7967be25450b83e625025366c618101ae49f /src/xml/quote.cpp
parentThe Polar Arrange Tab of the Arrange Dialog now hides the parametric (diff)
parentRemove Snap menu item and improve grid menu item text (diff)
downloadinkscape-5a4fb2325f60d292b47330f540b26a3279341c90.tar.gz
inkscape-5a4fb2325f60d292b47330f540b26a3279341c90.zip
Commit a merge to trunk, with probabal errors
(bzr r11073.1.36)
Diffstat (limited to 'src/xml/quote.cpp')
-rw-r--r--src/xml/quote.cpp29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/xml/quote.cpp b/src/xml/quote.cpp
index 51f9ffb97..02c12dfb0 100644
--- a/src/xml/quote.cpp
+++ b/src/xml/quote.cpp
@@ -13,22 +13,25 @@
#include <cstring>
#include <glib.h>
+#include "quote.h"
/** \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;
- for (; *val != '\0'; val++) {
- switch (*val) {
- case '"': ret += sizeof("&quot;") - 1; break;
- case '&': ret += sizeof("&amp;") - 1; break;
- case '<': ret += sizeof("&lt;") - 1; break;
- case '>': ret += sizeof("&gt;") - 1; break;
- default: ++ret; break;
+ if (val != NULL) {
+ for (; *val != '\0'; val++) {
+ switch (*val) {
+ case '"': ret += sizeof("&quot;") - 1; break;
+ case '&': ret += sizeof("&amp;") - 1; break;
+ case '<': ret += sizeof("&lt;") - 1; break;
+ case '>': ret += sizeof("&gt;") - 1; break;
+ default: ++ret; break;
+ }
}
}
return ret;
@@ -42,11 +45,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) {