[common] options: fix build on windows (no strndup)

This commit is contained in:
Geoffrey McRae 2023-05-02 12:32:59 +10:00
parent 07bcc54732
commit 9d66a68403

View File

@ -357,7 +357,9 @@ bool option_parse(int argc, char * argv[])
while (valueLen > 1 && isspace(v[valueLen-1])) while (valueLen > 1 && isspace(v[valueLen-1]))
--valueLen; --valueLen;
value = strndup(v, valueLen); value = malloc(valueLen + 1);
memcpy(value, v, valueLen);
value[valueLen] = '\0';
} }
break; break;
} }
@ -389,7 +391,10 @@ bool option_parse(int argc, char * argv[])
while (valueLen > 1 && isspace(value[valueLen-1])) while (valueLen > 1 && isspace(value[valueLen-1]))
--valueLen; --valueLen;
value = strndup(value, valueLen); char * v = malloc(valueLen + 1);
memcpy(v, value, valueLen);
v[valueLen] = '\0';
value = v;
} }
free(arg); free(arg);