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