about summary refs log tree commit diff
path: root/src/shared.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2003-07-24T08·53+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2003-07-24T08·53+0000
commit1a7468a57a11288a007c40d50ed28718d757a546 (patch)
tree175c3f3819298006548f4f7d00f4c98ce8135c6b /src/shared.cc
parentb75719b98457c61857689ab135559a17034dd8ec (diff)
* Debug levels. Use `--verbose / -v LEVEL' to display only messages
  up to the given verbosity levels.  These currently are:

    lvlError = 0, 
    lvlNormal = 5,
    lvlDebug = 10,
    lvlDebugMore = 15

  although only lvlError and lvlDebug are actually used right now.

Diffstat (limited to 'src/shared.cc')
-rw-r--r--src/shared.cc23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/shared.cc b/src/shared.cc
index bfd7498de16d..75145f6db2fa 100644
--- a/src/shared.cc
+++ b/src/shared.cc
@@ -1,4 +1,5 @@
 #include <iostream>
+#include <cctype>
 
 extern "C" {
 #include <aterm2.h>
@@ -32,7 +33,12 @@ static void initAndRun(int argc, char * * argv)
         string arg = *it;
         if (arg.length() > 2 && arg[0] == '-' && arg[1] != '-') {
             for (unsigned int i = 1; i < arg.length(); i++)
-                args.insert(it, (string) "-" + arg[i]);
+                if (isalpha(arg[i]))
+                    args.insert(it, (string) "-" + arg[i]);
+                else {
+                    args.insert(it, string(arg, i));
+                    break;
+                }
             it = args.erase(it);
         } else it++;
     }
@@ -50,18 +56,21 @@ int main(int argc, char * * argv)
     try {
         initAndRun(argc, argv);
     } catch (UsageError & e) {
-        cerr << format(
-            "error: %1%\n"
-            "Try `%2% --help' for more information.\n")
-            % e.what() % programId;
+        msg(lvlError, 
+            format(
+                "error: %1%\n"
+                "Try `%2% --help' for more information.")
+            % e.what() % programId);
         return 1;
     } catch (Error & e) {
-        cerr << format("error: %1%\n") % e.msg();
+        msg(lvlError, format("error: %1%") % e.msg());
         return 1;
     } catch (exception & e) {
-        cerr << format("error: %1%\n") % e.what();
+        msg(lvlError, format("error: %1%") % e.what());
         return 1;
     }
 
     return 0;
 }
+
+