static char * ScrubRetpath (char * const retpath) { char * sspath = (char *)retpath; // // Check for null path because Win32 doesn't like them. // I.E.: Path lists of c:/foo;;c:/bar need changed to // c:/foo;c:/bar. // // This need be executed only if we actually converted the path. // while (*sspath) { if (*sspath == ';' && sspath[1] == ';') for (char *i = sspath; *i; i++) *i = *(i + 1); else sspath++; } if (*(sspath - 1) == ';') *(sspath - 1) = '\0'; // // If we modified the path then convert all / to \ if we have a path list // else convert all \ to /. // if ((strchr (retpath, ';'))) { backslashify (retpath, retpath, 0); } else { slashify (retpath, retpath, 0); } debug_printf("returning: %s", retpath); return retpath; }
static void process_argv (int argc, char **argv) { int i; char *lastdot; for (i = 1; i < argc; i++) if (strcmp (argv[i], "-c") == 0) { compileonly++; strcat (cmdline, " -c"); } else if (strncmp (argv[i], "-D", 2) == 0) { strcat (cmdline, " "); strcat (cmdline, argv[i]); if (strlen (argv[i]) == 2) { i++; strcat (cmdline, argv[i]); } } else if (strcmp (argv[i], "-E") == 0) strcat (cmdline, " -E"); else if (strcmp (argv[i], "-g") == 0) debug++; else if (strncmp (argv[i], "-I", 2) == 0) { strcat (cmdline, " "); backslashify (argv[i]); strcat (cmdline, argv[i]); if (strlen (argv[i]) == 2) { i++; backslashify (argv[i]); strcat (cmdline, argv[i]); } } else if (strncmp (argv[i], "-l", 2) == 0) libraries[lib_ix++] = argv[i] + 2; else if (strncmp (argv[i], "-L", 2) == 0) { if (strlen (argv[i]) > 2) { backslashify (argv[i]); libdirs[libdir_ix++] = argv[i] + 2; } else { i++; backslashify (argv[i]); libdirs[libdir_ix++] = argv[i]; } } else if (strcmp (argv[i], "-o") == 0) { output++; i++; lastdot = strrchr (argv[i], '.'); if (lastdot != NULL && (stricmp (lastdot, ".exe") == 0 || stricmp (lastdot, ".dll") == 0)) { strcat (cmdline, " -Fe"); backslashify (argv[i]); strcat (cmdline, argv[i]); output_executable = argv[i]; executable_type = strrchr (output_executable, '.'); } else if (lastdot != NULL && (strcmp (lastdot, ".obj") == 0)) { strcat (cmdline, " -Fo"); strcat (cmdline, argv[i]); } else { strcat (cmdline, " -Fe"); strcat (cmdline, argv[i]); strcat (cmdline, ".exe"); } } else if (strcmp (argv[i], "-O") == 0) strcat (cmdline, " -O"); else if (strcmp (argv[i], "-v") == 0) verbose++; else if (argv[i][0] == '-') fprintf (stderr, "Ignored flag %s\n", argv[i]); else { lastdot = strrchr (argv[i], '.'); if (lastdot != NULL && (stricmp (lastdot, ".c") == 0 || stricmp (lastdot, ".cpp") == 0 || stricmp (lastdot, ".cc") == 0)) { nsources++; strcat (cmdline, " "); if (stricmp (lastdot, ".cc") == 0) strcat (cmdline, "-Tp"); strcat (cmdline, argv[i]); } else if (lastdot != NULL && stricmp (lastdot, ".obj") == 0) objects[object_ix++] = argv[i]; else fprintf (stderr, "Ignored argument: %s\n", argv[i]); } }