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