diff options
Diffstat (limited to 'xkbcomp.c')
-rw-r--r-- | xkbcomp.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -24,6 +24,7 @@ ********************************************************/ +#include "utils.h" #include <stdio.h> #include <ctype.h> #include <X11/keysym.h> @@ -759,15 +760,20 @@ parseArgs(int argc, char *argv[]) } else if ((!outputFile) && (inputFile) && (strcmp(inputFile, "-") == 0)) { - int len = strlen("stdin") + strlen(fileTypeExt[outputFormat]) + 2; +#ifdef HAVE_ASPRINTF + if (asprintf(&outputFile, "stdin.%s", fileTypeExt[outputFormat]) < 0) +#else + size_t len = strlen("stdin") + strlen(fileTypeExt[outputFormat]) + 2; outputFile = calloc(len, sizeof(char)); - if (outputFile == NULL) + if (outputFile != NULL) + snprintf(outputFile, len, "stdin.%s", fileTypeExt[outputFormat]); + else +#endif { WSGO("Cannot allocate space for output file name\n"); ACTION("Exiting\n"); exit(1); } - snprintf(outputFile, len, "stdin.%s", fileTypeExt[outputFormat]); } else if ((outputFile == NULL) && (inputFile != NULL)) { |