History

libtcc: cleanup -x<filetype> switch code

Abusing filename[0] as type is just too much of a hack. -- From 05364072042ff37904a7b0b14cdd85a1ea1ca11d

grischka committed 10 years ago

Commit 09a487e1 parent e6301134 files · +34 −39Browse files

Showing the changes to tcc.c (1 of 4 files). Show all

Unified · Split

tcc.c+7−13
@@ -307,23 +307,17 @@ int main(int argc, char **argv) · 306 unmodified lines
307307
308308 /* compile or add each files or library */
309309 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;
320314 } else {
321315 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)
324318 ret = 1;
325319 if (!first_file)
326− first_file = filename;
320+ first_file = f->name;
327321 }
328322 }
329323

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t