Skip to content

Commit

Permalink
Merge branch 'refact/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
nickolasburr committed Jul 17, 2018
2 parents 4da52fb + 9049ae4 commit 49fff50
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
int main (int argc, char **argv) {
int index, zindex;
int count, start, end, opt_value, long_opt_index;
char *line, *range, *token;
size_t len;
ssize_t read;
char *line = NULL,
*range = NULL,
*token = NULL;
FILE *stream = NULL;

long_opt_index = 0;
Expand Down Expand Up @@ -58,7 +60,7 @@ int main (int argc, char **argv) {
for (index = 1; index < argc; index += 1) {
switch (index) {
case 1:
range = ALLOC(sizeof(argv[index]) + NULL_BYTE);
range = ALLOC(sizeof(char) * (length(argv[index]) + NULL_BYTE));
copy(range, argv[index]);

zindex = 0;
Expand All @@ -68,7 +70,7 @@ int main (int argc, char **argv) {
fprintf(stderr, "%s: '%s' is not a valid range.\n\n", PROGNAME, argv[index]);
usage();

exit(EXIT_FAILURE);
goto on_error;
}

switch (zindex) {
Expand All @@ -92,7 +94,7 @@ int main (int argc, char **argv) {
if (!is_file(argv[index])) {
fprintf(stderr, "%s: '%s' is not a valid filename.\n\n", PROGNAME, argv[index]);

exit(EXIT_FAILURE);
goto on_error;
}

stream = fopen(argv[index], "r");
Expand Down Expand Up @@ -121,4 +123,9 @@ int main (int argc, char **argv) {
}

return EXIT_SUCCESS;

on_error:
FREE(range);

return EXIT_FAILURE;
}

0 comments on commit 49fff50

Please sign in to comment.