1 /*
2 Copyright (C) 2011
3 R. Bernstein <rocky@gnu.org>
4 This file is part of GNU Make (remake variant).
5 
6 GNU Make is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10 
11 GNU Make is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with GNU Make; see the file COPYING.  If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.  */
20 
21 /* Debugger messages */
22 #include "msg.h"
23 
24 #if HAVE_VPRINTF || HAVE_DOPRNT
25 # define HAVE_STDVARARGS 1
26 # if __STDC__
27 #  include <stdarg.h>
28 #  define VA_START(args, lastarg) va_start(args, lastarg)
29 # else
30 #  include <varargs.h>
31 #  define VA_START(args, lastarg) va_start(args)
32 # endif
33 # if HAVE_VPRINTF
34 #  define VA_PRINTF(fp, lastarg, args) vfprintf((fp), (lastarg), (args))
35 # else
36 #  define VA_PRINTF(fp, lastarg, args) _doprnt((lastarg), (args), (fp))
37 # endif
38 # define VA_END(args) va_end(args)
39 #else
40 /* # undef HAVE_STDVARARGS */
41 # define va_alist a1, a2, a3, a4, a5, a6, a7, a8
42 # define va_dcl char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8;
43 # define VA_START(args, lastarg)
44 # define VA_PRINTF(fp, lastarg, args) fprintf((fp), (lastarg), va_alist)
45 # define VA_END(args)
46 #endif
47 
48 /* Print an error message on stdout.  */
49 void
50 #if __STDC__ && HAVE_STDVARARGS
dbg_errmsg(const char * fmt,...)51 dbg_errmsg(const char *fmt, ...)
52 #else
53 dbg_errmsg (const char *fmt, va_alist)
54 #endif
55 {
56 #if HAVE_STDVARARGS
57   va_list args;
58 #endif
59   fprintf(stdout, "** ");
60   VA_START (args, fmt);
61   VA_PRINTF (stdout, fmt, args);
62   VA_END (args);
63   fprintf (stdout, "\n");
64   fflush (stdout);
65 }
66 
67 /* Print a message on stdout.  */
68 void
69 #if __STDC__ && HAVE_STDVARARGS
dbg_msg(const char * fmt,...)70 dbg_msg(const char *fmt, ...)
71 #else
72 // dbg_msg (const char *fmt, va_alist)
73 dbg_msg (const char *fmt, va_alist)
74 #endif
75 {
76 #if HAVE_STDVARARGS
77   va_list args;
78 #endif
79   VA_START (args, fmt);
80   VA_PRINTF (stdout, fmt, args);
81   VA_END (args);
82   fprintf (stdout, "\n");
83   fflush (stdout);
84 }
85