summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Build/source/texk/mendexk/ChangeLog5
-rw-r--r--Build/source/texk/mendexk/fwrite.c9
2 files changed, 11 insertions, 3 deletions
diff --git a/Build/source/texk/mendexk/ChangeLog b/Build/source/texk/mendexk/ChangeLog
index 6f1b0506a67..c9084d0356a 100644
--- a/Build/source/texk/mendexk/ChangeLog
+++ b/Build/source/texk/mendexk/ChangeLog
@@ -1,3 +1,8 @@
+2015-01-09 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ * fwrite.c: Some compilers mishandle the use of sizeof(buf)
+ inside C99 variadic macros, so we replace it by BUFFERLEN.
+
2014-07-05 TANAKA Takuji <KXD02663@nifty.ne.jp>
* convert.c: Better timing for xstrdup.
diff --git a/Build/source/texk/mendexk/fwrite.c b/Build/source/texk/mendexk/fwrite.c
index 81030e7e94a..66dd1fcfba0 100644
--- a/Build/source/texk/mendexk/fwrite.c
+++ b/Build/source/texk/mendexk/fwrite.c
@@ -17,16 +17,19 @@ static int range_check(struct index ind, int count, char *lbuff);
static void linecheck(char *lbuff, char *tmpbuff);
static void crcheck(char *lbuff, FILE *fp);
+/* All buffers have size BUFFERLEN. */
#define BUFFERLEN 4096
#ifdef HAVE___VA_ARGS__
/* Use C99 variadic macros if they are supported. */
+/* We would like to use sizeof(buf) instead of BUFFERLEN but that fails
+ for, e.g., gcc-4.8.3 on Cygwin and gcc-4.5.3 on NetBSD. */
#define SPRINTF(buf, ...) \
- snprintf(buf, sizeof(buf), __VA_ARGS__)
+ snprintf(buf, BUFFERLEN, __VA_ARGS__)
#define SAPPENDF(buf, ...) \
- snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), __VA_ARGS__)
+ snprintf(buf + strlen(buf), BUFFERLEN - strlen(buf), __VA_ARGS__)
#else
-/* Alternatively use static inline functions (all buffers have size BUFFERLEN). */
+/* Alternatively use static inline functions. */
static inline int SPRINTF(char *buf, const char *format, ...)
{
va_list argptr;