summaryrefslogtreecommitdiff
path: root/Build/source
diff options
context:
space:
mode:
authorPeter Breitenlohner <peb@mppmu.mpg.de>2015-01-09 10:01:54 +0000
committerPeter Breitenlohner <peb@mppmu.mpg.de>2015-01-09 10:01:54 +0000
commit6b58058e700ac61db7d20b1f06dcbe1b0d2c7db4 (patch)
tree70fea0d5cbe40dd73fcbb8d00b4c67bb2b004581 /Build/source
parent514dbda2e91392430159283a73e5488b50257844 (diff)
texk/mendexk: Build fix for Cygwin and NetBSD, they mishandle sizeof(buf) inside variadic macros
git-svn-id: svn://tug.org/texlive/trunk@36004 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source')
-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;