summaryrefslogtreecommitdiff
path: root/xkbcomp.c
diff options
context:
space:
mode:
Diffstat (limited to 'xkbcomp.c')
-rw-r--r--xkbcomp.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/xkbcomp.c b/xkbcomp.c
index d97220f..c5775fa 100644
--- a/xkbcomp.c
+++ b/xkbcomp.c
@@ -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))
{