diff options
-rw-r--r-- | configure.ac | 3 | ||||
-rw-r--r-- | get_rload.c | 10 |
2 files changed, 13 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac index 43fdf0b..347249b 100644 --- a/configure.ac +++ b/configure.ac @@ -39,6 +39,9 @@ m4_ifndef([XORG_MACROS_VERSION], XORG_MACROS_VERSION(1.8) XORG_DEFAULT_OPTIONS +# Checks for library functions. +AC_CHECK_FUNCS([asprintf]) + # Internationalization & localization support AC_SEARCH_LIBS([gettext], [intl], [USE_GETTEXT="yes"], [USE_GETTEXT="no"]) AC_MSG_CHECKING([where to install localized messages]) diff --git a/get_rload.c b/get_rload.c index c3f9dfb..c17598f 100644 --- a/get_rload.c +++ b/get_rload.c @@ -1,3 +1,6 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif #include <stdio.h> #include <X11/Intrinsic.h> @@ -44,6 +47,12 @@ void GetRLoadPoint( *(double *)call_data = 0.0; /* to be on the safe side */ if (fname == NULL) { +#ifdef HAVE_ASPRINTF + if (asprintf(&fname, "%s/whod.%s", _PATH_RWHODIR, resources.remote) < 0) { + perror("GetRLoadPoint: asprintf() failed"); + exit(1); + } +#else if ((fname = malloc(strlen(_PATH_RWHODIR)+strlen("/whod.")+strlen(resources.remote)+1)) == NULL) { fprintf(stderr,"GetRLoadPoint: malloc() failed\n"); exit(1); @@ -51,6 +60,7 @@ void GetRLoadPoint( strcpy(fname,_PATH_RWHODIR); strcat(fname,"/whod."); strcat(fname,resources.remote); +#endif } if ((f = open(fname, O_RDONLY, 0)) < 0) return; |