提交 57ca68ac 编写于 作者: P Pieter Noordhuis

moved argument parsing around

上级 e795c758
......@@ -125,25 +125,23 @@ long process(FILE *fp) {
}
int main(int argc, char **argv) {
/* expect the first argument to be the dump file */
if (argc <= 1) {
printf("Usage: %s [--fix] <file.aof>\n", argv[0]);
exit(0);
}
char *filename;
int fix = 0;
if (argc == 3) {
if (argc < 2) {
printf("Usage: %s [--fix] <file.aof>\n", argv[0]);
exit(1);
} else if (argc == 2) {
filename = argv[1];
} else if (argc == 3) {
if (strcmp(argv[1],"--fix") != 0) {
printf("Invalid argument: %s\n", argv[1]);
exit(1);
}
fix = 1;
filename = argv[2];
} else if (argc == 2) {
filename = argv[1];
fix = 1;
} else {
printf("Invalid argument");
printf("Invalid arguments\n");
exit(1);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册