[svn-r26551] Description:

Remove the VSNPRINTF_WORKS macro, it's working around bugs in old SGI
& HP compilers.

Tested on:
    MacOSX/64 10.10.2 (amazon) w/serial & parallel
    (h5committest not required on this branch)
This commit is contained in:
Quincey Koziol 2015-03-23 17:16:28 -05:00
parent b424ce1b3f
commit 61b5fa8e2d
6 changed files with 5 additions and 110 deletions

View File

@ -640,10 +640,6 @@
/* Version number of package */
#define H5_VERSION "@HDF5_PACKAGE_VERSION_STRING@"
/* Define if vsnprintf() returns the correct value for formatted strings that
don't fit into size allowed */
#cmakedefine H5_VSNPRINTF_WORKS @H5_VSNPRINTF_WORKS@
/* Check exception handling functions during data conversions */
#cmakedefine H5_WANT_DCONV_EXCEPTION @H5_WANT_DCONV_EXCEPTION@

View File

@ -1727,59 +1727,7 @@ AC_CHECK_FUNCS([gethostname getpwuid getrusage gettimeofday])
AC_CHECK_FUNCS([lstat rand_r random setsysinfo])
AC_CHECK_FUNCS([signal longjmp setjmp siglongjmp sigsetjmp sigprocmask])
AC_CHECK_FUNCS([snprintf srandom strdup symlink system])
AC_CHECK_FUNCS([tmpfile asprintf vasprintf waitpid])
## Check for vsnprintf() separately, so we can detect situations where it
## doesn't return the correct size for formatted strings that are too large
## for the buffer provided
AC_CHECK_FUNCS([vsnprintf],
## Check if vsnprintf() returns correct size for strings that don't fit
## into the size allowed. If vsnprintf() works correctly on this platform,
## it should return a value of 42 for the test below
##
## Note that vsnprintf fails in two different ways:
## - In IRIX64, calls to vnsprintf() with a formatted string that
## is larger than the buffer size allowed incorrectly
## return the size of the buffer minus one.
## - In HP/UX, calls to vsnprintf() with a formatted string that
## is larger than the buffer size allowed incorrectly
## return (-1)
AC_MSG_CHECKING([if vsnprintf returns correct value])
AC_CACHE_VAL([hdf5_cv_vsnprintf_works],
AC_TRY_RUN([
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
int test_vsnprintf(const char *fmt,...)
{
va_list ap;
char *s = malloc(16);
int ret;
va_start(ap, fmt);
ret=vsnprintf(s,16,"%s",ap);
va_end(ap);
return(ret!=42 ? 1 : 0);
}
int main(void)
{
exit(test_vsnprintf("%s","A string that is longer than 16 characters"));
}
],[hdf5_cv_vsnprintf_works=yes],[hdf5_cv_vsnprintf_works=no],))
if test ${hdf5_cv_vsnprintf_works} = "yes"; then
AC_MSG_RESULT([yes])
AC_DEFINE([VSNPRINTF_WORKS], [1],
[Define if vsnprintf() returns the correct value for formatted strings that don't fit into size allowed])
else
AC_MSG_RESULT([no])
fi
,)
AC_CHECK_FUNCS([tmpfile asprintf vasprintf vsnprintf waitpid])
## ----------------------------------------------------------------------
## Check that a lone colon can be used as an argument

View File

@ -1397,17 +1397,7 @@ H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line,
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
/* If the description doesn't fit into the initial buffer size, allocate more space and try again */
while((desc_len = HDvsnprintf(tmp, (size_t)tmp_len, fmt, ap))
#ifdef H5_VSNPRINTF_WORKS
>
#else /* H5_VSNPRINTF_WORKS */
>=
#endif /* H5_VSNPRINTF_WORKS */
(tmp_len - 1)
#ifndef H5_VSNPRINTF_WORKS
|| (desc_len < 0)
#endif /* H5_VSNPRINTF_WORKS */
) {
while((desc_len = HDvsnprintf(tmp, (size_t)tmp_len, fmt, ap)) > (tmp_len - 1)) {
/* shutdown & restart the va_list */
va_end(ap);
va_start(ap, fmt);
@ -1416,11 +1406,7 @@ H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line,
H5MM_xfree(tmp);
/* Allocate a description of the appropriate length */
#ifdef H5_VSNPRINTF_WORKS
tmp_len = desc_len + 1;
#else /* H5_VSNPRINTF_WORKS */
tmp_len = 2 * tmp_len;
#endif /* H5_VSNPRINTF_WORKS */
if(NULL == (tmp = H5MM_malloc((size_t)tmp_len)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
} /* end while */

View File

@ -741,17 +741,7 @@ H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned lin
HGOTO_DONE(FAIL)
/* If the description doesn't fit into the initial buffer size, allocate more space and try again */
while((desc_len = HDvsnprintf(tmp, (size_t)tmp_len, fmt, ap))
#ifdef H5_VSNPRINTF_WORKS
>
#else /* H5_VSNPRINTF_WORKS */
>=
#endif /* H5_VSNPRINTF_WORKS */
(tmp_len - 1)
#ifndef H5_VSNPRINTF_WORKS
|| (desc_len < 0)
#endif /* H5_VSNPRINTF_WORKS */
) {
while((desc_len = HDvsnprintf(tmp, (size_t)tmp_len, fmt, ap)) > (tmp_len - 1)) {
/* shutdown & restart the va_list */
va_end(ap);
va_start(ap, fmt);
@ -760,11 +750,7 @@ H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned lin
H5MM_xfree(tmp);
/* Allocate a description of the appropriate length */
#ifdef H5_VSNPRINTF_WORKS
tmp_len = desc_len + 1;
#else /* H5_VSNPRINTF_WORKS */
tmp_len = 2 * tmp_len;
#endif /* H5_VSNPRINTF_WORKS */
if(NULL == (tmp = H5MM_malloc((size_t)tmp_len)))
HGOTO_DONE(FAIL)
} /* end while */

View File

@ -155,11 +155,7 @@ h5tools_str_append(h5tools_str_t *str/*in,out*/, const char *fmt, ...)
* to lack of buffer size, so try one more time after realloc more
* buffer size before return NULL.
*/
if (nchars < 0
#ifndef H5_VSNPRINTF_WORKS
&& (HDstrlen(str->s) < str->nalloc)
#endif
) {
if (nchars < 0) {
/* failure, such as bad format */
return NULL;
}

View File

@ -89,28 +89,11 @@ void parallel_print(const char* format, ...)
HDvprintf(format, ap);
else {
if(overflow_file == NULL) /*no overflow has occurred yet */ {
#if 0
printf("calling HDvsnprintf: OUTBUFF_SIZE=%ld, outBuffOffset=%ld, ", (long)OUTBUFF_SIZE, (long)outBuffOffset);
#endif
bytes_written = HDvsnprintf(outBuff+outBuffOffset, OUTBUFF_SIZE-outBuffOffset, format, ap);
#if 0
printf("bytes_written=%ld\n", (long)bytes_written);
#endif
HDva_end(ap);
HDva_start(ap, format);
#if 0
printf("Result: bytes_written=%ld, OUTBUFF_SIZE-outBuffOffset=%ld\n", (long)bytes_written, (long)OUTBUFF_SIZE-outBuffOffset);
#endif
if ((bytes_written < 0) ||
#ifdef H5_VSNPRINTF_WORKS
(bytes_written >= (OUTBUFF_SIZE-outBuffOffset))
#else
((bytes_written+1) == (OUTBUFF_SIZE-outBuffOffset))
#endif
)
{
if((bytes_written < 0) || (bytes_written >= (OUTBUFF_SIZE - outBuffOffset))) {
/* Terminate the outbuff at the end of the previous output */
outBuff[outBuffOffset] = '\0';