]> git.donarmstrong.com Git - lilypond.git/blob - flower/warn.cc
* The grand 2005-2006 replace.
[lilypond.git] / flower / warn.cc
1 /*
2   warn.cc -- implement warnings
3
4   source file of the Flower Library
5
6   (c) 1997--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #include "warn.hh"
10
11 #include <cstdlib>
12 #include <cstdio>
13 using namespace std;
14
15 /* Is progress indication at NEWLINE?  */
16 static bool progress_newline = true;
17
18 /* Display user information that is not a full message.  */
19 void
20 progress_indication (String s)
21 {
22   /* Test if all silly progress_indication ("\n") can be dropped now.  */
23   if (s == "\n")
24     return;
25
26   fputs (s.to_str0 (), stderr);
27   fflush (stderr);
28   if (s.length ())
29     progress_newline = s[s.length () - 1] == '\n';
30 }
31
32 /* Display a single user message.  Always starts on a new line.  */
33 void
34 message (String s)
35 {
36   if (!progress_newline)
37     fputc ('\n', stderr);
38   progress_indication (s);
39 }
40
41 /* Display a warning message.  Always starts on a new line.  */
42 void
43 warning (String s)
44 {
45   message (_f ("warning: %s", s.to_str0 ()) + "\n");
46 }
47
48 void
49 non_fatal_error (String s)
50 {
51   message (_f ("error: %s", s.to_str0 ()) + "\n");
52 }
53
54 /* Display an error message.  Always starts on a new line.  */
55 void
56 error (String s)
57 {
58   non_fatal_error (s);
59   exit (1);
60 }
61
62 void
63 programming_error (String s)
64 {
65   message (_f ("programming error: %s", s) + "\n");
66   message (_ ("continuing, cross fingers") + "\n");
67 }
68