Skip to content

Commit

Permalink
Create output file name from input when output option is not specified
Browse files Browse the repository at this point in the history
  • Loading branch information
fcambus committed Jul 26, 2015
1 parent e8652b2 commit 775fe09
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/main.c
Expand Up @@ -121,7 +121,7 @@ int main(int argc, char *argv[])
char *font;
char *icecolors = NULL; // TODO : Re-enable icecolors

char *input, *output;
char *input, *output = NULL;
char *retinaout = NULL;

while ((getoptFlag = getopt(argc, argv, "b:c:ef:hi:o:rsv")) != -1) {
Expand Down Expand Up @@ -162,6 +162,13 @@ int main(int argc, char *argv[])
argc -= optind;
argv += optind;

// create output file name if output is not specified
if (!output) {
int outputLen = strlen(input) + 5;
output = malloc(outputLen);
snprintf(output, outputLen, "%s%s", input, ".png");
}

// get file extension
char *fext = strrchr(input, '.');
fext = fext ? strtolower(fext) : "none";
Expand Down

0 comments on commit 775fe09

Please sign in to comment.