ansilove

ANSI and ASCII art to PNG converter in C
Log | Files | Refs | README | LICENSE

commit 775fe09b2c870bc7ac4d72082fd7d2483afaff1a
parent e8652b27ce6b1fbc5c8e2f2919c71eed2d9f8ad6
Author: Frederic Cambus <fcambus@users.sourceforge.net>
Date:   Sun, 26 Jul 2015 17:26:51 +0200

Create output file name from input when output option is not specified

Diffstat:
Msrc/main.c | 9++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/main.c b/src/main.c @@ -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) { @@ -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";