Sort.
[cparser] / main.c
diff --git a/main.c b/main.c
index fbee913..7d679f6 100644 (file)
--- a/main.c
+++ b/main.c
@@ -80,7 +80,7 @@
 #include "warning.h"
 
 #ifndef PREPROCESSOR
-#define PREPROCESSOR "cpp -std=c99 -U__WCHAR_TYPE__ -D__WCHAR_TYPE__=int -U__SIZE_TYPE__ -D__SIZE_TYPE__=__SIZE_TYPE__ -m32"
+#define PREPROCESSOR "cpp -std=c99 -U__WCHAR_TYPE__ -D__WCHAR_TYPE__=int -U__SIZE_TYPE__ -D__SIZE_TYPE__=__SIZE_TYPE__ -m32 -U__STRICT_ANSI__"
 #endif
 
 #ifndef LINKER
@@ -628,6 +628,7 @@ int main(int argc, char **argv)
                                                || strcmp(opt, "unroll-loops") == 0
                                                || strcmp(opt, "expensive-optimizations") == 0
                                                || strcmp(opt, "no-common") == 0
+                                               || strcmp(opt, "PIC") == 0
                                                || strncmp(opt, "align-loops=", sizeof("align-loops=")-1) == 0
                                                || strncmp(opt, "align-jumps=", sizeof("align-jumps=")-1) == 0
                                                || strncmp(opt, "align-functions=", sizeof("align-functions=")-1) == 0) {
@@ -658,7 +659,13 @@ int main(int argc, char **argv)
                                                strncpy(cpu_arch, opt, sizeof(cpu_arch));
                                }
                        } else if(option[0] == 'W') {
-                               set_warning_opt(&option[1]);
+                               if(strncmp(option + 1, "l,", 2) == 0)   // a gcc-style linker option
+                               {
+                                       const char *opt;
+                                       GET_ARG_AFTER(opt, "-Wl,");
+                                       add_flag(&ldflags_obst, "-Wl,%s", opt);
+                               }
+                               else set_warning_opt(&option[1]);
                        } else if(option[0] == 'm') {
                                /* -m options */
                                const char *opt;
@@ -732,7 +739,8 @@ int main(int argc, char **argv)
                        } else if(strcmp(option, "pg") == 0) {
                                set_be_option("gprof");
                                add_flag(&ldflags_obst, "-pg");
-                       } else if(strcmp(option, "pedantic") == 0) {
+                       } else if(strcmp(option, "pedantic") == 0
+                                       || strcmp(option, "ansi") == 0) {
                                fprintf(stderr, "warning: ignoring gcc option '%s'\n", arg);
                        } else if(strcmp(option, "shared") == 0) {
                                add_flag(&ldflags_obst, "-shared");
@@ -816,8 +824,14 @@ int main(int argc, char **argv)
                                        case 'h': type = FILETYPE_C; break;
                                        case 's': type = FILETYPE_PREPROCESSED_ASSEMBLER; break;
                                        case 'S': type = FILETYPE_ASSEMBLER; break;
+
+                                       case 'a':
                                        case 'o': type = FILETYPE_OBJECT; break;
                                        }
+                               } else if (len > 3 && arg[len-3] == '.') {
+                                       if(strcmp(arg + len - 2, "so") == 0) {
+                                               type = FILETYPE_OBJECT;
+                                       }
                                }
 
                                if (type == FILETYPE_AUTODETECT) {
@@ -980,7 +994,7 @@ int main(int argc, char **argv)
                        if (in == preprocessed_in) {
                                int pp_result = pclose(preprocessed_in);
                                if (pp_result != EXIT_SUCCESS) {
-                                       return pp_result;
+                                       exit(EXIT_FAILURE);
                                }
                        }
 
@@ -1056,6 +1070,9 @@ int main(int argc, char **argv)
                                        return pp_result;
                                }
                        }
+                       if(asm_out != out) {
+                               fclose(asm_out);
+                       }
                }
 
                if (mode == Compile)
@@ -1090,6 +1107,9 @@ int main(int argc, char **argv)
                file->type = filetype;
        }
 
+       if (result != EXIT_SUCCESS)
+               return result;
+
        /* link program file */
        if(mode == CompileAssembleLink) {
                obstack_1grow(&ldflags_obst, '\0');