Add path test windows and escape in double quote.

This commit is contained in:
Christoffer Lerno
2024-08-21 10:37:50 +02:00
parent 33ce8e8a75
commit b46463563e
4 changed files with 27 additions and 5 deletions

View File

@@ -8,6 +8,8 @@
"linux-x64" : {
"cflags": "-fPIE"
},
"windows-x64" : { }
"windows-x64" : {
"c-include-dirs": ["C:\\"]
}
}
}

View File

@@ -704,7 +704,7 @@ static char *assemble_linker_command(const char **args, bool extra_quote)
if (arg == quote_arg)
{
scratch_buffer_append_char('"');
scratch_buffer_append(args[++i]);
scratch_buffer_append_in_quote(args[++i]);
scratch_buffer_append_char('"');
continue;
}
@@ -717,8 +717,8 @@ static char *assemble_linker_command(const char **args, bool extra_quote)
if (arg == quote_concat_arg)
{
scratch_buffer_append_char('"');
scratch_buffer_append(args[++i]);
scratch_buffer_append(args[++i]);
scratch_buffer_append_in_quote(args[++i]);
scratch_buffer_append_in_quote(args[++i]);
scratch_buffer_append_char('"');
continue;
}
@@ -726,7 +726,7 @@ static char *assemble_linker_command(const char **args, bool extra_quote)
{
scratch_buffer_append(args[++i]);
scratch_buffer_append_char('"');
scratch_buffer_append(args[++i]);
scratch_buffer_append_in_quote(args[++i]);
scratch_buffer_append_char('"');
continue;
}

View File

@@ -156,6 +156,7 @@ void scratch_buffer_clear(void);
void scratch_buffer_append(const char *string);
void scratch_buffer_append_len(const char *string, size_t len);
void scratch_buffer_append_char(char c);
void scratch_buffer_append_in_quote(const char *string);
void scratch_buffer_append_char_repeat(char c, size_t count);
void scratch_buffer_append_signed_int(int64_t i);
void scratch_buffer_append_double(double d);

View File

@@ -384,6 +384,25 @@ void scratch_buffer_printf(const char *format, ...)
scratch_buffer.len += len_needed;
}
void scratch_buffer_append_in_quote(const char *string)
{
size_t len = strlen(string);
for (size_t i = 0; i < len; )
{
char c = string[i++];
switch (c)
{
case '"':
scratch_buffer_append("\\\"");
continue;
case '\\':
scratch_buffer_append("\\\\");
continue;
}
scratch_buffer_append_char(c);
}
}
void scratch_buffer_append_char(char c)
{
if (scratch_buffer.len + 1 > MAX_STRING_BUFFER - 1)