mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
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>
This commit is contained in:
parent
ba31a57857
commit
a0a25554a7
1 changed files with 4 additions and 1 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue