]> git.donarmstrong.com Git - lilypond.git/blobdiff - flower/warn.cc
* The grand 2005-2006 replace.
[lilypond.git] / flower / warn.cc
index 1df7cda734ace777af149bb0cf9f8b48be95f857..24117d7ec4d9632270aa16b576066482cd16c8c8 100644 (file)
@@ -1,37 +1,68 @@
-#include <stream.h>
+/*
+  warn.cc -- implement warnings
+
+  source file of the Flower Library
+
+  (c) 1997--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
+*/
+
 #include "warn.hh"
 
+#include <cstdlib>
+#include <cstdio>
+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)
 {
-  cerr <<  _ ("error: ") << s << '\n';
+  /* Test if all silly progress_indication ("\n") can be dropped now.  */
+  if (s == "\n")
+    return;
 
-  exit (1);
+  fputs (s.to_str0 (), 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
-non_fatal_error (String s)
+message (String s)
 {
-  cerr <<  _ ("error: ") << s << '\n';
+  if (!progress_newline)
+    fputc ('\n', stderr);
+  progress_indication (s);
 }
 
+/* Display a warning message.  Always starts on a new line.  */
 void
-warning (String m)
+warning (String s)
 {
-  cerr << _ ("warning: ") <<m <<endl;
+  message (_f ("warning: %s", s.to_str0 ()) + "\n");
+}
 
+void
+non_fatal_error (String s)
+{
+  message (_f ("error: %s", s.to_str0 ()) + "\n");
 }
 
+/* Display an error message.  Always starts on a new line.  */
 void
-message (String m)
+error (String s)
 {
-  cerr << m<<endl;
+  non_fatal_error (s);
+  exit (1);
 }
 
 void
 programming_error (String s)
 {
-  cerr << _("programming error: ") << s << _(" (Continuing; cross thumbs)") << '\n';
+  message (_f ("programming error: %s", s) + "\n");
+  message (_ ("continuing, cross fingers") + "\n");
 }