X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lib%2Finput.cc;h=f2dc0a51b376f5d0a322081c9f059e20772fc515;hb=48f2b9351f93d0161c675cfb60e95bf919041df2;hp=de341811bffc26f94100972dec63e779a3056de4;hpb=1ca7a2c01e48a2585ab7b43aa18c9c276d4a05d0;p=lilypond.git diff --git a/lib/input.cc b/lib/input.cc index de341811bf..f2dc0a51b3 100644 --- a/lib/input.cc +++ b/lib/input.cc @@ -1,74 +1,108 @@ /* - input.cc -- implement Input + input.cc -- implement Input - source file of the LilyPond music typesetter + source file of the LilyPond music typesetter - (c) 1997 Han-Wen Nienhuys + (c) 1997--1999 Han-Wen Nienhuys */ +#include #include "proto.hh" #include "input.hh" #include "string.hh" #include "source.hh" #include "source-file.hh" -Input::Input(Source_file*s, char const *cl) +Input::Input (Source_file*s, char const *cl) { - source_file_l_=s; - defined_ch_C_=cl; + source_file_l_=s; + defined_ch_C_=cl; } -Input::Input() +Input::Input () { - source_file_l_ = 0; - defined_ch_C_ = 0; + source_file_l_ = 0; + defined_ch_C_ = 0; } -Input::Input(Input const &s) +Input +Input::spot () const { - source_file_l_ = s.source_file_l_; - defined_ch_C_ = s.defined_ch_C_; + return *this; } void -Input::set_spot(Input const &i) +Input::set_spot (Input const &i) { - *this = i; + *this = i; } +/* + Produce almost GNU-compliant error message. Lily used to be rather + GNU-compliant in this too, but correcting mudela is such a breeze if + you('re edidor) know(s) the error column too (there's no GNU standard + on columns, is there?). + + Format: + + [file:line:column:][warning:]message + + */ void -Input::message(String message_str)const +Input::message (String message_str) const { - String str = ""; - - if ( source_file_l_ ) { - str += source_file_l_->file_line_no_str(defined_ch_C_) + String(": "); - } - - str += message_str; - if ( source_file_l_ ) { - str += ":\n"; - str += source_file_l_->error_str( defined_ch_C_); - } - cerr << str << endl; + String str; + + /* + marked "Work in prgress" in GNU iostream + libg++ 2.7.2.8 + libstdc++ 2.8.1 + + why not just return always -1 (unknown), + iso breaking the interface? + + int col = cerr.rdbuf ()->column (); + + */ + + // well, we don't want to loose first warning... + int col = 1; + if (col > 0) + str += "\n"; + + if (source_file_l_) + str += location_str () + String (": "); + + str += message_str; + if (source_file_l_) + { + str += ":\n"; + str += source_file_l_->error_str (defined_ch_C_); + } + cerr << str << endl; } void -Input::warning( String message_str)const +Input::warning (String message_str) const { - message( "warning: " + message_str); + message (_ ("warning: ") + message_str); } void -Input::error(String s)const +Input::error (String s) const { - message("error: "+ s); - exit (1); + message (_ ("error: ")+ s); } +void +Input::non_fatal_error (String s) const +{ + message (_ ("Non fatal error: ") + s); +} String -Input::location_str()const +Input::location_str () const { - if (source_file_l_) - return source_file_l_->file_line_no_str(defined_ch_C_); - else - return "(location unknown)"; + if (source_file_l_) + return source_file_l_->file_line_column_str (defined_ch_C_); + else + return "(" + _ ("position unknown") + ")"; } +