aboutsummaryrefslogtreecommitdiff
path: root/portable
diff options
context:
space:
mode:
authorRuss Allbery <eagle@eyrie.org>2016-01-17 14:30:53 -0800
committerRuss Allbery <eagle@eyrie.org>2016-01-17 14:30:53 -0800
commit57a5a0095c3fe0f22dcbb9d99a82cc94f2b608c7 (patch)
treed7ab6169e2c5af79d97711964c34fbc1f5bbab13 /portable
parent884297fc439a4c3eba2365cdb810214dfc4f5799 (diff)
Update to rra-c-util 5.10 and C TAP Harness 3.4
Update to rra-c-util 5.10: * Add missing va_end to xasprintf implementation. * Fix Perl test suite framework for new Automake relative paths. * Improve portability to Kerberos included in Solaris 10. * Use appropriate warning flags with Clang (currently not warning clean). Update to C TAP Harness 3.4: * Fix segfault in runtests with an empty test list. * Display verbose test results with -v or C_TAP_VERBOSE. * Test infrastructure builds cleanly with Clang warnings. * Support comments and blank lines in test lists.
Diffstat (limited to 'portable')
-rw-r--r--portable/asprintf.c6
-rw-r--r--portable/krb5-extra.c3
-rw-r--r--portable/krb5.h4
-rw-r--r--portable/macros.h3
-rw-r--r--portable/mkstemp.c5
-rw-r--r--portable/reallocarray.c8
-rw-r--r--portable/setenv.c24
-rw-r--r--portable/snprintf.c2
-rw-r--r--portable/strlcat.c1
-rw-r--r--portable/strlcpy.c1
-rw-r--r--portable/system.h4
11 files changed, 36 insertions, 25 deletions
diff --git a/portable/asprintf.c b/portable/asprintf.c
index eb2b713..9693842 100644
--- a/portable/asprintf.c
+++ b/portable/asprintf.c
@@ -19,6 +19,7 @@
*/
#include <config.h>
+#include <portable/macros.h>
#include <portable/system.h>
#include <errno.h>
@@ -28,11 +29,14 @@
* with the system versions.
*/
#if TESTING
+# undef asprintf
+# undef vasprintf
# define asprintf test_asprintf
# define vasprintf test_vasprintf
int test_asprintf(char **, const char *, ...)
__attribute__((__format__(printf, 2, 3)));
-int test_vasprintf(char **, const char *, va_list);
+int test_vasprintf(char **, const char *, va_list)
+ __attribute__((__format__(printf, 2, 0)));
#endif
diff --git a/portable/krb5-extra.c b/portable/krb5-extra.c
index b1c8b8d..c8309a4 100644
--- a/portable/krb5-extra.c
+++ b/portable/krb5-extra.c
@@ -22,6 +22,7 @@
#include <config.h>
#include <portable/krb5.h>
+#include <portable/macros.h>
#include <portable/system.h>
#include <errno.h>
@@ -33,6 +34,8 @@
# include <ibm_svc/krb5_svc.h>
# elif defined(HAVE_ET_COM_ERR_H)
# include <et/com_err.h>
+# elif defined(HAVE_KERBEROSV5_COM_ERR_H)
+# include <kerberosv5/com_err.h>
# else
# include <com_err.h>
# endif
diff --git a/portable/krb5.h b/portable/krb5.h
index 6dfffd5..34f960e 100644
--- a/portable/krb5.h
+++ b/portable/krb5.h
@@ -42,8 +42,10 @@
#endif
#include <portable/macros.h>
-#ifdef HAVE_KRB5_H
+#if defined(HAVE_KRB5_H)
# include <krb5.h>
+#elif defined(HAVE_KERBEROSV5_KRB5_H)
+# include <kerberosv5/krb5.h>
#else
# include <krb5/krb5.h>
#endif
diff --git a/portable/macros.h b/portable/macros.h
index b5093f5..d4cc2cc 100644
--- a/portable/macros.h
+++ b/portable/macros.h
@@ -37,7 +37,8 @@
* variadic macro support.
*/
#if !defined(__attribute__) && !defined(__alloc_size__)
-# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3)
+# if (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3)) \
+ && !defined(__clang__)
# define __alloc_size__(spec, args...) /* empty */
# endif
#endif
diff --git a/portable/mkstemp.c b/portable/mkstemp.c
index 2cbfe08..7c733a4 100644
--- a/portable/mkstemp.c
+++ b/portable/mkstemp.c
@@ -23,7 +23,10 @@
#include <errno.h>
#include <fcntl.h>
-#include <sys/time.h>
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
+#include <time.h>
/*
* If we're running the test suite, rename mkstemp to avoid conflicts with the
diff --git a/portable/reallocarray.c b/portable/reallocarray.c
index 7d40a7a..e9404e9 100644
--- a/portable/reallocarray.c
+++ b/portable/reallocarray.c
@@ -1,10 +1,10 @@
/*
* Replacement for a missing reallocarray.
*
- * Provides the same functionality as the OpenBSD library function reallocrray
- * for those systems that don't have it. This function is the same as
- * realloc, but takes the size arguments in the same form as calloc and checks
- * for overflow so that the caller doesn't need to.
+ * Provides the same functionality as the OpenBSD library function
+ * reallocarray for those systems that don't have it. This function is the
+ * same as realloc, but takes the size arguments in the same form as calloc
+ * and checks for overflow so that the caller doesn't need to.
*
* The canonical version of this file is maintained in the rra-c-util package,
* which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
diff --git a/portable/setenv.c b/portable/setenv.c
index 472282a..f1f6db4 100644
--- a/portable/setenv.c
+++ b/portable/setenv.c
@@ -26,6 +26,7 @@
* the system version.
*/
#if TESTING
+# undef setenv
# define setenv test_setenv
int test_setenv(const char *, const char *, int);
#endif
@@ -34,29 +35,22 @@ int
setenv(const char *name, const char *value, int overwrite)
{
char *envstring;
- size_t size;
+ /* Do nothing if not overwriting and the variable is already set. */
if (!overwrite && getenv(name) != NULL)
return 0;
/*
- * Allocate memory for the environment string. We intentionally don't use
- * the xmalloc family of allocation routines here, since the intention is
- * to provide a replacement for the standard library function that sets
- * errno and returns in the event of a memory allocation failure.
- */
- size = strlen(name) + 1 + strlen(value) + 1;
- envstring = malloc(size);
- if (envstring == NULL)
- return -1;
-
- /*
* Build the environment string and add it to the environment using
* putenv. Systems without putenv lose, but XPG4 requires it.
+ *
+ * We intentionally don't use the xmalloc family of allocation routines
+ * here, since the intention is to provide a replacement for the standard
+ * library function that sets errno and returns in the event of a memory
+ * allocation failure.
*/
- strlcpy(envstring, name, size);
- strlcat(envstring, "=", size);
- strlcat(envstring, value, size);
+ if (asprintf(&envstring, "%s=%s", name, value) < 0)
+ return -1;
return putenv(envstring);
/*
diff --git a/portable/snprintf.c b/portable/snprintf.c
index c35ad80..9818acd 100644
--- a/portable/snprintf.c
+++ b/portable/snprintf.c
@@ -19,6 +19,8 @@
* conflicts with the system version.
*/
#if TESTING
+# undef snprintf
+# undef vsnprintf
# define snprintf test_snprintf
# define vsnprintf test_vsnprintf
#endif
diff --git a/portable/strlcat.c b/portable/strlcat.c
index 9c8686d..613d3f2 100644
--- a/portable/strlcat.c
+++ b/portable/strlcat.c
@@ -31,6 +31,7 @@
* the system version.
*/
#if TESTING
+# undef strlcat
# define strlcat test_strlcat
size_t test_strlcat(char *, const char *, size_t);
#endif
diff --git a/portable/strlcpy.c b/portable/strlcpy.c
index 592e3ee..60fdab3 100644
--- a/portable/strlcpy.c
+++ b/portable/strlcpy.c
@@ -30,6 +30,7 @@
* the system version.
*/
#if TESTING
+# undef strlcpy
# define strlcpy test_strlcpy
size_t test_strlcpy(char *, const char *, size_t);
#endif
diff --git a/portable/system.h b/portable/system.h
index 544b2de..581e46c 100644
--- a/portable/system.h
+++ b/portable/system.h
@@ -136,10 +136,10 @@ extern void *reallocarray(void *, size_t, size_t);
#if !HAVE_SETENV
extern int setenv(const char *, const char *, int);
#endif
-#if !HAVE_STRLCAT
+#if !HAVE_DECL_STRLCAT
extern size_t strlcat(char *, const char *, size_t);
#endif
-#if !HAVE_STRLCPY
+#if !HAVE_DECL_STRLCPY
extern size_t strlcpy(char *, const char *, size_t);
#endif