ref: ddd7fdac011efda5478748a0cd3cee8431db460e
parent: e5ac9c2cd83dd23d7fe15a60eab09f81c6f4ba45
author: anthony <[email protected]>
date: Tue Dec 29 19:16:56 EST 2009
finish fixing segfault (probably caused by argv[] craziness) this diff brought to you by lmod
--- a/src/fix/main.c
+++ b/src/fix/main.c
@@ -129,39 +129,44 @@
ulOptions = 0;
- if ((--argc) == 0)
+ if (argc == 1)
PrintUsage();
- while (*argv[argn] == '-') {
- argc -= 1;
- switch (argv[argn++][1]) {
- case '?':
- case 'h':
- PrintUsage();
- break;
- case 'd':
- ulOptions |= OPTF_DEBUG;
- break;
- case 'p':
- ulOptions |= OPTF_PAD;
- break;
- case 'r':
- ulOptions |= OPTF_TRUNCATE;
- break;
- case 'v':
- ulOptions |= OPTF_VALIDATE;
- break;
- case 't':
- strncpy(cartname, argv[argn - 1] + 2, 16);
- ulOptions |= OPTF_TITLE;
- break;
- case 'q':
- ulOptions|=OPTF_QUIET;
- break;
+ while (argn < argc) {
+ if(argv[argn][0] == '-') {
+ switch (argv[argn][1]) {
+ case '?':
+ case 'h':
+ PrintUsage();
+ break;
+ case 'd':
+ ulOptions |= OPTF_DEBUG;
+ break;
+ case 'p':
+ ulOptions |= OPTF_PAD;
+ break;
+ case 'r':
+ ulOptions |= OPTF_TRUNCATE;
+ break;
+ case 'v':
+ ulOptions |= OPTF_VALIDATE;
+ break;
+ case 't':
+ strncpy(cartname, argv[argn] + 2, 16);
+ ulOptions |= OPTF_TITLE;
+ break;
+ case 'q':
+ ulOptions|=OPTF_QUIET;
+ break;
+ }
}
+ argn++;
}
- strcpy(filename, argv[argn++]);
+ if(argv[argc - 1][0] == '-')
+ PrintUsage();
+
+ strcpy(filename, argv[argc - 1]);
if (!FileExists(filename))
strcat(filename, ".gb");