]> git.donarmstrong.com Git - lilypond.git/blob - flower/warn.cc
Merge branch 'lilypond/translation' of ssh://git.sv.gnu.org/srv/git/lilypond
[lilypond.git] / flower / warn.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 1997--2010 Han-Wen Nienhuys <hanwen@xs4all.nl>
5
6   LilyPond 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 3 of the License, or
9   (at your option) any later version.
10
11   LilyPond 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 LilyPond.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include "warn.hh"
21
22 #include <cstdlib>
23 #include <cstdio>
24
25 #include "international.hh"
26
27 using namespace std;
28
29 /* Is progress indication at NEWLINE?  */
30 static bool progress_newline = true;
31
32 /* Display user information that is not a full message.  */
33 void
34 progress_indication (string s)
35 {
36   /* Test if all silly progress_indication ("\n") can be dropped now.  */
37   if (s == "\n")
38     return;
39
40   fputs (s.c_str (), stderr);
41   fflush (stderr);
42   if (s.length ())
43     progress_newline = s[s.length () - 1] == '\n';
44 }
45
46 /* Display a single user message.  Always starts on a new line.  */
47 void
48 message (string s)
49 {
50   if (!progress_newline)
51     fputc ('\n', stderr);
52   progress_indication (s);
53 }
54
55 /* Display a warning message.  Always starts on a new line.  */
56 void
57 warning (string s)
58 {
59   message (_f ("warning: %s", s.c_str ()) + "\n");
60 }
61
62 void
63 non_fatal_error (string s)
64 {
65   message (_f ("error: %s", s.c_str ()) + "\n");
66 }
67
68 /* Display an error message.  Always starts on a new line.  */
69 void
70 error (string s)
71 {
72   non_fatal_error (s);
73   exit (1);
74 }
75
76 void
77 programming_error (string s)
78 {
79   message (_f ("programming error: %s", s) + "\n");
80   message (_ ("continuing, cross fingers") + "\n");
81 }
82