Unified · Split
| @@ -228,10 +228,18 @@ static int expand_args(char ***pargv, const char *str) · 227 unmodified lines | |||
| 228 | #define CHILD "x86_64" | 228 | #define CHILD "x86_64" |
| 229 | #endif | 229 | #endif |
| 230 | 230 | ||
| 231 | static const char *ssuffix(const char *name, const char sep) | 231 | static char *ssuffix(const char *oldname, const char sep) |
| 232 | { | 232 | { |
| 233 | char *p = strchr(name, sep); | 233 | char *p, *name = tcc_strdup(oldname); |
| 234 | return p?p+1:name; | 234 | p = strchr(name, sep); |
| 235 | if (p) | ||
| 236 | return p + 1; | ||
| 237 | /* prefix "win32-" when file extension is present */ | ||
| 238 | if (*tcc_fileextension(name)){ | ||
| 239 | name = tcc_realloc(name, strlen(oldname + 7)); | ||
| 240 | sprintf(name, "win32-%s", oldname); | ||
| 241 | } | ||
| 242 | return name; | ||
| 235 | } | 243 | } |
| 236 | 244 | ||
| 237 | static void exec_other_tcc(TCCState *s, int argc, | 245 | static void exec_other_tcc(TCCState *s, int argc, |
| @@ -249,7 +257,9 @@ static void exec_other_tcc(TCCState *s, int argc, · 11 unmodified lines | |||
| 249 | case ARG: | 257 | case ARG: |
| 250 | { | 258 | { |
| 251 | parent = tcc_basename(argv[0]); | 259 | parent = tcc_basename(argv[0]); |
| 252 | sprintf(child_name, CHILD "-%s", ssuffix(parent,'-')); | 260 | child_tcc = ssuffix(parent,'-'); |
| 261 | sprintf(child_name, CHILD "-%s", child_tcc); | ||
| 262 | tcc_free(child_tcc); | ||
| 253 | if (strcmp(parent, child_name)) { | 263 | if (strcmp(parent, child_name)) { |
| 254 | /* child_path = dirname */ | 264 | /* child_path = dirname */ |
| 255 | pstrcpy(child_path, parent - argv[0] + 1, argv[0]); | 265 | pstrcpy(child_path, parent - argv[0] + 1, argv[0]); |