diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2015-01-18 11:21:45 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2015-01-25 19:51:44 -0800 |
commit | ca04f74887d53c75e794f643f7e860ba588c3a57 (patch) | |
tree | b43c370c08e83ed32b0199c35a111fe3ae4ba175 /util | |
parent | fba83e45a8d5dc2ca920ec6c49446d2b54c2db5c (diff) | |
download | xorg-lib-libXt-ca04f74887d53c75e794f643f7e860ba588c3a57.tar.gz |
makestrs: Use asprintf() if available
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'util')
-rw-r--r-- | util/makestrs.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/util/makestrs.c b/util/makestrs.c index f872ec8..5764849 100644 --- a/util/makestrs.c +++ b/util/makestrs.c @@ -90,19 +90,26 @@ static int solaris_abi_names = FALSE; static char* includedir = NULL; static FILE *ifopen(const char *file, const char *mode) { +#ifndef HAVE_ASPRINTF size_t len; +#endif char *buffer; FILE *ret; if (includedir == NULL) return fopen(file, mode); +#ifdef HAVE_ASPRINTF + if (asprintf(&buffer, "%s/%s", includedir, file) == -1) + return NULL; +#else len = strlen(file) + strlen(includedir) + 1; buffer = (char*)malloc(len + 1); if (buffer == NULL) return NULL; snprintf(buffer, len + 1, "%s/%s", includedir, file); +#endif ret = fopen(buffer, mode); @@ -269,13 +276,23 @@ static void WriteHeader (char *tagline, File *phile, int abi) /* do the right thing for Motif, i.e. avoid _XmXmStrDefs_h_ */ if (strcmp (prefixstr, "Xm") == 0) { +#ifdef HAVE_ASPRINTF + if (asprintf (&fileprotstr, "_%s_", phile->name) == -1) + exit (1); +#else if ((fileprotstr = malloc (strlen (phile->name) + 3)) == NULL) exit (1); (void) sprintf (fileprotstr, "_%s_", phile->name); +#endif } else { +#ifdef HAVE_ASPRINTF + if (asprintf (&fileprotstr, "_%s%s_", prefixstr, phile->name) == -1) + exit (1); +#else if ((fileprotstr = malloc (strlen (phile->name) + strlen (prefixstr) + 3)) == NULL) exit (1); (void) sprintf (fileprotstr, "_%s%s_", prefixstr, phile->name); +#endif } for (tmp = fileprotstr; *tmp; tmp++) if (*tmp == '.') *tmp = '_'; |