X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=flower%2Fwarn.cc;h=1c2f4ed134724bfb04c36fde2f380e7ce710cbf2;hb=b57b314fc28d142a342b7180827e63ee843e6644;hp=aef1f3833399f36c0ddc26b12d63517c34d4e243;hpb=8bcab38894d0ec3451045356146d875c1d4f08b9;p=lilypond.git diff --git a/flower/warn.cc b/flower/warn.cc index aef1f38333..1c2f4ed134 100644 --- a/flower/warn.cc +++ b/flower/warn.cc @@ -1,46 +1,89 @@ /* - warn.cc -- implement warnings + This file is part of LilyPond, the GNU music typesetter. - source file of the Flower Library + Copyright (C) 1997--2011 Han-Wen Nienhuys - (c) 1997--2000 Han-Wen Nienhuys -*/ + LilyPond is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + LilyPond is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -#include -#include + You should have received a copy of the GNU General Public License + along with LilyPond. If not, see . +*/ #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 +progress_indication (string s) +{ + /* 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 success message. Always starts on a new line. */ void -message (String s) +successful (string s) { - fputs (s.ch_C (), stderr); + message (_f ("success: %s", s.c_str ()) + "\n"); } +/* Display a warning message. Always starts on a new line. */ void -warning (String s) +warning (string s) { - message (_f ("warning: %s\n", s.ch_C ())); + message (_f ("warning: %s", s.c_str ()) + "\n"); } void -non_fatal_error (String s) +non_fatal_error (string s) { - message (_f ("error: %s\n", s.ch_C ())); + message (_f ("error: %s", s.c_str ()) + "\n"); } +/* Display an error message. Always starts on a new line. */ void -error (String s) +error (string s) { non_fatal_error (s); exit (1); } void -programming_error (String s) +programming_error (string s) { - message (_f ("programming error: %s (Continuing; cross thumbs)\n", - s.ch_C ())); + message (_f ("programming error: %s", s) + "\n"); + message (_ ("continuing, cross fingers") + "\n"); }