Mercurial > msvpvf
changeset 42:d873a04165f9
use basename() on cli version
really stupid bug lol
author | Paper <37962225+mrpapersonic@users.noreply.github.com> |
---|---|
date | Fri, 13 May 2022 00:48:11 -0400 |
parents | 02e46804c923 |
children | 9b309701420e |
files | src/main.c |
diffstat | 1 files changed, 5 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main.c Fri Apr 22 02:24:44 2022 -0400 +++ b/src/main.c Fri May 13 00:48:11 2022 -0400 @@ -5,6 +5,7 @@ #include <string.h> #include <unistd.h> #include <getopt.h> +#include <libgen.h> #ifdef _MSC_VER #define strdup(p) _strdup(p) #endif @@ -148,13 +149,13 @@ } fflush(stdout); if (strcmp(args.output, " ") == 0) { /* string manipulation hell */ - char temp[256] = {'V'}; + char temp[256] = (char*)malloc(sizeof(char)*256); char str_version[16] = {}; - sprintf(str_version, "%d", args.version); + sprintf(str_version, "V%d", args.version); strncat(temp, str_version, 2); strncat(temp, "_", 1); - strncat(temp, args.input, 248); - strcpy(temp, strremove(temp, strrchr(args.input, ('.')))); /* remove file extension */ + strncat(temp, basename(args.input), 248); + strcpy(temp, strremove(temp, strrchr(basename(args.input), ('.')))); /* remove file extension */ strncat(temp, ".", 1); strncat(temp, args.type, 3); strncpy(args.output, temp, 255);