diff options
Diffstat (limited to 'listing.c')
-rw-r--r-- | listing.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -70,6 +70,7 @@ SOFTWARE. ******************************************************************/ +#include "utils.h" #include <stdio.h> #include <ctype.h> #include <sys/types.h> @@ -303,19 +304,24 @@ AddDirectory(char *head, char *ptrn, char *rest, char *map) { char *tmp, *filename; struct stat sbuf; - size_t tmpsize; filename = FileName(file); if (!filename || filename[0] == '.') continue; if (ptrn && (!XkbNameMatchesPattern(filename, ptrn))) continue; - tmpsize = (head ? strlen(head) : 0) + strlen(filename) + 2; +#ifdef HAVE_ASPRINTF + if (asprintf(&tmp, "%s%s%s", + (head ? head : ""), (head ? "/" : ""), filename) < 0) + continue; +#else + size_t tmpsize = (head ? strlen(head) : 0) + strlen(filename) + 2; tmp = malloc(tmpsize); if (!tmp) continue; snprintf(tmp, tmpsize, "%s%s%s", (head ? head : ""), (head ? "/" : ""), filename); +#endif if (stat(tmp, &sbuf) < 0) { free(tmp); |