]> git.ipfire.org Git - thirdparty/libbsd.git/commitdiff
Use getexecname() if available for getprogname()
authorGuillem Jover <guillem@hadrons.org>
Tue, 5 Jul 2011 21:27:31 +0000 (23:27 +0200)
committerGuillem Jover <guillem@hadrons.org>
Tue, 29 May 2012 02:36:23 +0000 (04:36 +0200)
This function is present on Solaris.

configure.ac
src/progname.c

index 06a02b7a12aad3a73414abe1b6b15ce62e53ca61..c9cf0a46003ee30945e7d5b3b9b1661fe82a8e3c 100644 (file)
@@ -37,6 +37,7 @@ AC_TYPE_SIZE_T
 AC_TYPE_SSIZE_T
 
 # Checks for library functions.
+AC_CHECK_FUNCS([getexecname])
 
 AC_CONFIG_FILES([
        Makefile
index f24071ae7c47d4706c24d430279d14e79f72bd4d..b5132d8ec0c13db88f5efd9c03c48653ba226af9 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2006 Robert Millan
- * Copyright © 2010-2011 Guillem Jover
+ * Copyright © 2010-2012 Guillem Jover <guillem@hadrons.org>
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -41,6 +41,10 @@ getprogname(void)
 #ifdef __GLIBC__
        if (__progname == NULL)
                __progname = program_invocation_short_name;
+#elif defined(HAVE_GETEXECNAME)
+       /* getexecname(3) returns an absolute pathname, normalize it. */
+       if (__progname == NULL)
+               setprogname(getexecname());
 #endif
 
        return __progname;