Abusing filename[0] as type is just too much of a hack. -- From 05364072042ff37904a7b0b14cdd85a1ea1ca11d
Showing the changes to tcc.c (1 of 4 files). Show all
Unified · Split
| @@ -307,23 +307,17 @@ int main(int argc, char **argv) · 306 unmodified lines | ||
| 307 | 307 | |
| 308 | 308 | /* compile or add each files or library */ |
| 309 | 309 | for(i = ret = 0; i < s->nb_files && ret == 0; i++) { |
| 310 | − int filetype = *(unsigned char *)s->files[i]; | |
| 311 | − const char *filename = s->files[i] + 1; | |
| 312 | − if (filename[0] == '-' && filename[1] == 'l') { | |
| 313 | − if (tcc_add_library(s, filename + 2) < 0) { | |
| 314 | − /* don't fail on -lm as it's harmless to skip math lib */ | |
| 315 | − if (strcmp(filename + 2, "m")) { | |
| 316 | − tcc_error_noabort("cannot find library 'lib%s'", filename + 2); | |
| 317 | − ret = 1; | |
| 318 | − } | |
| 319 | − } | |
| 310 | + struct filespec *f = s->files[i]; | |
| 311 | + if (f->type == 'l') { | |
| 312 | + if (tcc_add_library_err(s, f->name) < 0) | |
| 313 | + ret = 1; | |
| 320 | 314 | } else { |
| 321 | 315 | if (1 == s->verbose) |
| 322 | − printf("-> %s\n", filename); | |
| 323 | − if (tcc_add_file(s, filename, filetype) < 0) | |
| 316 | + printf("-> %s\n", f->name); | |
| 317 | + if (tcc_add_file(s, f->name, f->type) < 0) | |
| 324 | 318 | ret = 1; |
| 325 | 319 | if (!first_file) |
| 326 | − first_file = filename; | |
| 320 | + first_file = f->name; | |
| 327 | 321 | } |
| 328 | 322 | } |
| 329 | 323 | |