From a0a25554a72020aad4df7d568a8686c358724d5f Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 7 May 2014 09:28:26 -0700 Subject: Manually implement strndup Mac and Windows don't appear to have that function, so just implement the poor man's version by hand. Signed-off-by: Dirk Hohndel --- save-xml.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/save-xml.c b/save-xml.c index a7a083ed6..196143286 100644 --- a/save-xml.c +++ b/save-xml.c @@ -75,6 +75,7 @@ static void show_utf8(struct membuffer *b, const char *text, const char *pre, co if (!text) return; + /* remove leading and trailing space */ while (isspace(*text)) text++; len = strlen(text); @@ -82,7 +83,9 @@ static void show_utf8(struct membuffer *b, const char *text, const char *pre, co return; while (len && isspace(text[len - 1])) len--; - cleaned = strndup(text, len); + /* strndup would be easier, but that doesn't appear to exist on Windows / Mac */ + cleaned = strdup(text); + cleaned[len] = '\0'; put_string(b, pre); quote(b, cleaned, is_attribute); put_string(b, post); -- cgit v1.2.3-70-g09d2