X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=flower%2Fwarn.cc;h=74be7c2453ba6c22666639b7d7043d96e1ba8eaf;hb=5b4b0d6e9a197e8f9eb085b7c2ad78b8be3e5cfc;hp=4ad8e947d85a23f415a5b9ddf94c90ee3b5a1af9;hpb=aa384518d059d26ffd6c0da3068fbdc2a345ecc1;p=lilypond.git diff --git a/flower/warn.cc b/flower/warn.cc index 4ad8e947d8..74be7c2453 100644 --- a/flower/warn.cc +++ b/flower/warn.cc @@ -1,37 +1,71 @@ -#include -#include +/* + warn.cc -- implement warnings + + source file of the Flower Library + + (c) 1997--2008 Han-Wen Nienhuys +*/ #include "warn.hh" +#include +#include + +#include "international.hh" +using namespace std; + +/* Is progress indication at NEWLINE? */ +static bool progress_newline = true; + +/* Display user information that is not a full message. */ void -error (String s) +progress_indication (string s) { - fputs ( _f("error: %s\n", s.ch_C()).ch_C(), stderr); - exit (1); + /* Test if all silly progress_indication ("\n") can be dropped now. */ + if (s == "\n") + return; + + fputs (s.c_str (), stderr); + fflush (stderr); + if (s.length ()) + progress_newline = s[s.length () - 1] == '\n'; +} + +/* Display a single user message. Always starts on a new line. */ +void +message (string s) +{ + if (!progress_newline) + fputc ('\n', stderr); + progress_indication (s); } +/* Display a warning message. Always starts on a new line. */ void -non_fatal_error (String s) +warning (string s) { - fputs ( _f("error: %s\n", s.ch_C()).ch_C(), stderr); + message (_f ("warning: %s", s.c_str ()) + "\n"); } void -warning (String m) +non_fatal_error (string s) { - fputs ( _f("warning: %s\n", m.ch_C()).ch_C(), stderr); + message (_f ("error: %s", s.c_str ()) + "\n"); } +/* Display an error message. Always starts on a new line. */ void -message (String m) +error (string s) { - fprintf (stderr, "%s\n",m.ch_C()); + non_fatal_error (s); + exit (1); } void -programming_error (String s) +programming_error (string s) { - fputs ( _f("programming error: %s (Continuing; cross thumbs)\n", s.ch_C()).ch_C(), stderr); + message (_f ("programming error: %s", s) + "\n"); + message (_ ("continuing, cross fingers") + "\n"); }