summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/H5.c41
-rw-r--r--src/H5Tconv.c18
-rw-r--r--src/H5config.h.in3
-rw-r--r--src/H5private.h9
4 files changed, 61 insertions, 10 deletions
diff --git a/src/H5.c b/src/H5.c
index f97409d..09f3c85 100644
--- a/src/H5.c
+++ b/src/H5.c
@@ -438,6 +438,47 @@ H5close (void)
/*-------------------------------------------------------------------------
+ * Function: HDsnprintf
+ *
+ * Purpose: Writes output to the string BUF under control of the format
+ * FMT that specifies how subsequent arguments are converted for
+ * output. It is similar to sprintf except that SIZE specifies
+ * the maximum number of characters to produce. The trailing
+ * null character is counted towards this limit, so you should
+ * allocated at least SIZE characters for the string BUF.
+ *
+ * Note: This function is for compatibility on systems that don't have
+ * snprintf(3). It doesn't actually check for overflow like the
+ * real snprintf() would.
+ *
+ * Return: Success: Number of characters stored, not including
+ * the terminating null. If this value equals
+ * SIZE then there was not enough space in BUF
+ * for all the output.
+ *
+ * Failure: -1
+ *
+ * Programmer: Robb Matzke
+ * Tuesday, November 24, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+HDsnprintf(char *buf, size_t __unused__ size, const char *fmt, ...)
+{
+ int n;
+ va_list ap;
+
+ va_start(ap, fmt);
+ n = vsprintf(buf, fmt, ap);
+ va_end(ap);
+ return n;
+}
+
+
+/*-------------------------------------------------------------------------
* Function: HDfprintf
*
* Purpose: Prints the optional arguments under the control of the format
diff --git a/src/H5Tconv.c b/src/H5Tconv.c
index 481437e..914c255 100644
--- a/src/H5Tconv.c
+++ b/src/H5Tconv.c
@@ -2023,7 +2023,7 @@ H5T_conv_uchar_char(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
{
FUNC_ENTER(H5T_conv_char_short, FAIL);
H5T_CONV_us(cdata, src_id, dst_id, buf, nelmts,
- unsigned char, signed char, CHAR_MAX);
+ unsigned char, signed char, SCHAR_MAX);
FUNC_LEAVE(SUCCEED);
}
@@ -2481,7 +2481,7 @@ H5T_conv_short_char(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
{
FUNC_ENTER(H5T_conv_short_char, FAIL);
H5T_CONV_Ss(cdata, src_id, dst_id, buf, nelmts,
- short, signed char, CHAR_MIN, CHAR_MAX);
+ short, signed char, SCHAR_MIN, SCHAR_MAX);
FUNC_LEAVE(SUCCEED);
}
@@ -2535,7 +2535,7 @@ H5T_conv_ushort_char(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
{
FUNC_ENTER(H5T_conv_ushort_char, FAIL);
H5T_CONV_Us(cdata, src_id, dst_id, buf, nelmts,
- unsigned short, signed char, CHAR_MAX);
+ unsigned short, signed char, SCHAR_MAX);
FUNC_LEAVE(SUCCEED);
}
@@ -2965,7 +2965,7 @@ H5T_conv_int_char(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
{
FUNC_ENTER(H5T_conv_int_char, FAIL);
H5T_CONV_Ss(cdata, src_id, dst_id, buf, nelmts,
- int, signed char, CHAR_MIN, CHAR_MAX);
+ int, signed char, SCHAR_MIN, SCHAR_MAX);
FUNC_LEAVE(SUCCEED);
}
@@ -3019,7 +3019,7 @@ H5T_conv_uint_char(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
{
FUNC_ENTER(H5T_conv_uint_char, FAIL);
H5T_CONV_Us(cdata, src_id, dst_id, buf, nelmts,
- unsigned, signed char, CHAR_MAX);
+ unsigned, signed char, SCHAR_MAX);
FUNC_LEAVE(SUCCEED);
}
@@ -3450,7 +3450,7 @@ H5T_conv_long_char(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
{
FUNC_ENTER(H5T_conv_long_char, FAIL);
H5T_CONV_Ss(cdata, src_id, dst_id, buf, nelmts,
- long, signed char, CHAR_MIN, CHAR_MAX);
+ long, signed char, SCHAR_MIN, SCHAR_MAX);
FUNC_LEAVE(SUCCEED);
}
@@ -3504,7 +3504,7 @@ H5T_conv_ulong_char(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
{
FUNC_ENTER(H5T_conv_ulong_char, FAIL);
H5T_CONV_Us(cdata, src_id, dst_id, buf, nelmts,
- unsigned long, signed char, CHAR_MAX);
+ unsigned long, signed char, SCHAR_MAX);
FUNC_LEAVE(SUCCEED);
}
@@ -3936,7 +3936,7 @@ H5T_conv_llong_char(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
{
FUNC_ENTER(H5T_conv_llong_char, FAIL);
H5T_CONV_Ss(cdata, src_id, dst_id, buf, nelmts,
- long_long, signed char, CHAR_MIN, CHAR_MAX);
+ long_long, signed char, SCHAR_MIN, SCHAR_MAX);
FUNC_LEAVE(SUCCEED);
}
@@ -3990,7 +3990,7 @@ H5T_conv_ullong_char(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
{
FUNC_ENTER(H5T_conv_ullong_char, FAIL);
H5T_CONV_Us(cdata, src_id, dst_id, buf, nelmts,
- unsigned long_long, signed char, CHAR_MAX);
+ unsigned long_long, signed char, SCHAR_MAX);
FUNC_LEAVE(SUCCEED);
}
diff --git a/src/H5config.h.in b/src/H5config.h.in
index 11a538a..95e70c1 100644
--- a/src/H5config.h.in
+++ b/src/H5config.h.in
@@ -173,6 +173,9 @@
/* Define if you have the sigaction function. */
#undef HAVE_SIGACTION
+/* Define if you have the snprintf function. */
+#undef HAVE_SNPRINTF
+
/* Define if you have the system function. */
#undef HAVE_SYSTEM
diff --git a/src/H5private.h b/src/H5private.h
index abd104a..13fdcb2 100644
--- a/src/H5private.h
+++ b/src/H5private.h
@@ -595,6 +595,9 @@ int HDfprintf (FILE *stream, const char *fmt, ...);
#define HDsin(X) sin(X)
#define HDsinh(X) sinh(X)
#define HDsleep(N) sleep(N)
+#ifdef HAVE_SNPRINTF
+# define HDsnprintf snprintf /*varargs*/
+#endif
/* sprintf() variable arguments */
#define HDsqrt(X) sqrt(X)
#define HDsrand(N) srand(N)
@@ -662,9 +665,13 @@ int64_t HDstrtoll (const char *s, const char **rest, int base);
/*
* And now for a couple non-Posix functions...
*/
-extern char *strdup(const char *s);
+char *strdup(const char *s);
#define HDstrdup(S) strdup(S)
+#ifndef HAVE_SNPRINTF
+int HDsnprintf(char *buf, size_t size, const char *fmt, ...);
+#endif
+
/*
* These macros check whether debugging has been requested for a certain
* package at run-time. Code for debugging is conditionally compiled by