Mercurial > msvpvf
comparison src/main.c @ 8:9d862edfd3cc
fix fgetc() call
| author | Paper <37962225+mrpapersonic@users.noreply.github.com> |
|---|---|
| date | Wed, 26 Jan 2022 22:32:41 -0500 |
| parents | d1e5b8390cd3 |
| children | d2cd8c5672fa |
comparison
equal
deleted
inserted
replaced
| 7:bd392e82001c | 8:9d862edfd3cc |
|---|---|
| 90 break; | 90 break; |
| 91 case 'o': | 91 case 'o': |
| 92 strncpy(args.output, optarg, sizeof(args.input)-1); | 92 strncpy(args.output, optarg, sizeof(args.input)-1); |
| 93 break; | 93 break; |
| 94 case 'v': | 94 case 'v': |
| 95 args.version = abs(atoi(strcpy(optarg))); /* abs() for possible negative inputs */ | 95 args.version = abs(atoi(strdup(optarg))); /* abs() for possible negative inputs */ |
| 96 break; | 96 break; |
| 97 case 't': | 97 case 't': |
| 98 strncpy(args.type, optarg, sizeof(args.input)-1); | 98 strncpy(args.type, optarg, sizeof(args.input)-1); |
| 99 break; | 99 break; |
| 100 case 'h': | 100 case 'h': |
| 115 if (access(args.input, F_OK) != 0) { | 115 if (access(args.input, F_OK) != 0) { |
| 116 fprintf(stderr, "Input file \"%s\" doesn't exist! Exiting.", args.input); | 116 fprintf(stderr, "Input file \"%s\" doesn't exist! Exiting.", args.input); |
| 117 return 1; | 117 return 1; |
| 118 } | 118 } |
| 119 FILE* input_file = fopen(args.input, "r"); | 119 FILE* input_file = fopen(args.input, "r"); |
| 120 if (fgetc() == EOF) { | 120 if (fgetc(input_file) == EOF) { |
| 121 fprintf(stderr, "Input file \"%s\" is empty.", args.input); | 121 fprintf(stderr, "Input file \"%s\" is empty.", args.input); |
| 122 fclose(input_file); | 122 fclose(input_file); |
| 123 return 1; | 123 return 1; |
| 124 } | 124 } |
| 125 fseek(input_file, 0x46, SEEK_SET); | 125 fseek(input_file, 0x46, SEEK_SET); |
