summaryrefslogtreecommitdiff
path: root/makeint.h
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2013-11-23 22:23:52 -0500
committerPaul Smith <psmith@gnu.org>2013-11-23 22:23:52 -0500
commit757849cd93a9bc361a5113e3aaafe516773aad44 (patch)
treed6acd1705fe25873b43fa7d16b736e44b6191ab7 /makeint.h
parent9d58570c77240fed53d1f88217877f8e778f4bb2 (diff)
downloadgunmake-757849cd93a9bc361a5113e3aaafe516773aad44.tar.gz
[SV 40361] Don't use vsnprintf(), which is an ISO C99 function.
* output.c (error, fatal, message): Take an extra argument specifying how many bytes are used by the formatted arguments. (get_buffer): New function that allocates the requested buffer size. Remove msc_vsnprintf(), vfmtconcat(), and fmtconcat() as unneeded. * makeint.h: Declare various helper macros for generating output. * *.c: Change all error(), fatal(), message() calls to use the macros, or pass the extra length argument directly.
Diffstat (limited to 'makeint.h')
-rw-r--r--makeint.h42
1 files changed, 26 insertions, 16 deletions
diff --git a/makeint.h b/makeint.h
index c591427..f3f0111 100644
--- a/makeint.h
+++ b/makeint.h
@@ -56,12 +56,6 @@ char *alloca ();
#endif
#include "gnumake.h"
-/* Force MinGW64 to use a replacement for MS broken vsnprintf
- implementation. */
-#ifdef __MINGW64_VERSION_MAJOR
-# define __USE_MINGW_ANSI_STDIO 1
-#endif
-
#ifdef CRAY
/* This must happen before #include <signal.h> so
that the declaration therein is changed. */
@@ -179,9 +173,6 @@ unsigned int get_path_max (void);
(! INTEGER_TYPE_SIGNED (t) ? (t) 0 : ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))
#define INTEGER_TYPE_MAXIMUM(t) (~ (t) 0 - INTEGER_TYPE_MINIMUM (t))
-/* The maximum number of digits needed to represent the largest integer. */
-#define INTEGER_LENGTH sizeof("18446744073709551616")
-
#ifndef CHAR_MAX
# define CHAR_MAX INTEGER_TYPE_MAXIMUM (char)
#endif
@@ -427,17 +418,36 @@ extern struct rlimit stack_limit;
#define NILF ((gmk_floc *)0)
-#define CSTRLEN(_s) (sizeof (_s)-1)
+#define CSTRLEN(_s) (sizeof (_s)-1)
#define STRING_SIZE_TUPLE(_s) (_s), CSTRLEN(_s)
+/* The number of bytes needed to represent the largest integer as a string. */
+#define INTSTR_LENGTH CSTRLEN ("18446744073709551616")
+
const char *concat (unsigned int, ...);
-void message (int prefix, const char *fmt, ...)
- __attribute__ ((__format__ (__printf__, 2, 3)));
-void error (const gmk_floc *flocp, const char *fmt, ...)
- __attribute__ ((__format__ (__printf__, 2, 3)));
-void fatal (const gmk_floc *flocp, const char *fmt, ...)
- __attribute__ ((noreturn, __format__ (__printf__, 2, 3)));
+void message (int prefix, size_t length, const char *fmt, ...)
+ __attribute__ ((__format__ (__printf__, 3, 4)));
+void error (const gmk_floc *flocp, size_t length, const char *fmt, ...)
+ __attribute__ ((__format__ (__printf__, 3, 4)));
+void fatal (const gmk_floc *flocp, size_t length, const char *fmt, ...)
+ __attribute__ ((noreturn, __format__ (__printf__, 3, 4)));
+
+#define O(_t,_a,_f) _t((_a), 0, (_f))
+#define OS(_t,_a,_f,_s) _t((_a), strlen (_s), (_f), (_s))
+#define OSS(_t,_a,_f,_s1,_s2) _t((_a), strlen (_s1) + strlen (_s2), \
+ (_f), (_s1), (_s2))
+#define OSSS(_t,_a,_f,_s1,_s2,_s3) _t((_a), strlen (_s1) + strlen (_s2) + strlen (_s3), \
+ (_f), (_s1), (_s2), (_s3))
+#define ON(_t,_a,_f,_n) _t((_a), INTSTR_LENGTH, (_f), (_n))
+#define ONN(_t,_a,_f,_n1,_n2) _t((_a), INTSTR_LENGTH*2, (_f), (_n1), (_n2))
+
+#define OSN(_t,_a,_f,_s,_n) _t((_a), strlen (_s) + INTSTR_LENGTH, \
+ (_f), (_s), (_n))
+#define ONS(_t,_a,_f,_n,_s) _t((_a), INTSTR_LENGTH + strlen (_s), \
+ (_f), (_n), (_s))
+
+#define OUT_OF_MEM() O (fatal, NILF, _("virtual memory exhausted"))
void die (int) __attribute__ ((noreturn));
void pfatal_with_name (const char *) __attribute__ ((noreturn));