diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-05-07 09:28:26 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-05-07 09:28:26 -0700 |
commit | a0a25554a72020aad4df7d568a8686c358724d5f (patch) | |
tree | 581637e6099b1185f3b1907a8ad1ea07145a1103 /save-xml.c | |
parent | ba31a578570018223d68235d9614040c1ca1b925 (diff) | |
download | subsurface-a0a25554a72020aad4df7d568a8686c358724d5f.tar.gz |
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 <dirk@hohndel.org>
Diffstat (limited to 'save-xml.c')
-rw-r--r-- | save-xml.c | 5 |
1 files changed, 4 insertions, 1 deletions
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); |