summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2009-09-11 23:28:46 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2009-09-11 23:28:46 +0000
commit62af644151b7c37e8c1b9debd43041c6be4a5fd0 (patch)
tree1fb2e5382d3649312f2fae49c5c03707fc5b4b84
parenta80d8f39e46361d4d73f05173a4de8bb86c4a607 (diff)
downloadmpfr-62af644151b7c37e8c1b9debd43041c6be4a5fd0.tar.gz
vasprintf.c: fixed problem reported on
https://sympa.inria.fr/sympa/arc/mpfr/2009-09/msg00012.html http://article.gmane.org/gmane.comp.lib.mpfr.general/409 for mingw32, which defines wint_t as an unsigned short (though this is here forbidden by the ISO C99 standard). [changeset 6415 from the trunk] git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/branches/2.4@6416 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r--vasprintf.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/vasprintf.c b/vasprintf.c
index 8fa7fb2e5..647bd8fe8 100644
--- a/vasprintf.c
+++ b/vasprintf.c
@@ -56,7 +56,7 @@ MA 02110-1301, USA. */
# include <inttypes.h> /* for intmax_t */
#else
# if HAVE_STDINT_H
-# include <stdint.h>
+# include <stdint.h> /* for WINT_MAX in particular */
# endif
#endif
@@ -387,8 +387,15 @@ parse_arg_type (const char *format, struct printf_spec *specinfo)
integer type : int, unsigned int, long or unsigned long (unfortunately,
this is implementation dependant).
We follow gmp which assumes in print/doprnt.c that wchar_t is converted
- to int. */
+ to int (because wchar_t <= int).
+ For wint_t, we assume that the case WINT_MAX < INT_MAX yields an
+ integer promotion. */
#ifdef HAVE_WCHAR_H
+#if defined(WINT_MAX) && WINT_MAX < INT_MAX
+typedef int mpfr_va_wint; /* integer promotion */
+#else
+typedef wint_t mpfr_va_wint;
+#endif
#define CASE_LONG_ARG(specinfo, ap) \
case LONG_ARG: \
if (((specinfo).spec == 'd') || ((specinfo).spec == 'i') \
@@ -396,7 +403,7 @@ parse_arg_type (const char *format, struct printf_spec *specinfo)
|| ((specinfo).spec == 'x') || ((specinfo).spec == 'X')) \
(void) va_arg ((ap), long); \
else if ((specinfo).spec == 'c') \
- (void) va_arg ((ap), wint_t); \
+ (void) va_arg ((ap), mpfr_va_wint); \
else if ((specinfo).spec == 's') \
(void) va_arg ((ap), int); /* we assume integer promotion */ \
break;