summaryrefslogtreecommitdiff
path: root/Build/source/texk/mendexk/fwrite.c
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/texk/mendexk/fwrite.c
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/texk/mendexk/fwrite.c')
-rw-r--r--Build/source/texk/mendexk/fwrite.c9
1 files changed, 6 insertions, 3 deletions
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;