mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +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)
|
if (!text)
|
||||||
return;
|
return;
|
||||||
|
/* remove leading and trailing space */
|
||||||
while (isspace(*text))
|
while (isspace(*text))
|
||||||
text++;
|
text++;
|
||||||
len = strlen(text);
|
len = strlen(text);
|
||||||
|
@ -82,7 +83,9 @@ static void show_utf8(struct membuffer *b, const char *text, const char *pre, co
|
||||||
return;
|
return;
|
||||||
while (len && isspace(text[len - 1]))
|
while (len && isspace(text[len - 1]))
|
||||||
len--;
|
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);
|
put_string(b, pre);
|
||||||
quote(b, cleaned, is_attribute);
|
quote(b, cleaned, is_attribute);
|
||||||
put_string(b, post);
|
put_string(b, post);
|
||||||
|
|
Loading…
Add table
Reference in a new issue