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