]> git.draconx.ca Git - gob-dx.git/blobdiff - src/util.c
Release 2.0.7
[gob-dx.git] / src / util.c
index 5d891a20e5200377d82efd6bf68666c86365f39d..38dd53547b3cdf70bd423b39501040e4dde4f304 100644 (file)
@@ -35,10 +35,13 @@ void
 error_print(int type, int line, const char *error)
 {
        const char *w = NULL;
+       const char *fname = NULL;
 
        switch(type) {
        case GOB_WARN:
                w = "Warning:";
+               if (exit_on_warn)
+                       got_error = TRUE;
                break;
        case GOB_ERROR:
                w = "Error:";
@@ -47,13 +50,14 @@ error_print(int type, int line, const char *error)
        default:
                g_assert_not_reached();
        }
-       if(line > 0)
-               fprintf(stderr, "%s:%d: %s %s\n", filename, line, w, error);
+       fname = filename;
+       if (fname == NULL)
+               fname = "gob2";
+       if (line > 0)
+               fprintf(stderr, "%s:%d: %s %s\n", fname, line, w, error);
        else
-               fprintf(stderr, "%s: %s %s\n", filename, w, error);
-       if(exit_on_error &&
-          (type == GOB_ERROR ||
-           (type == GOB_WARN && exit_on_warn)))
+               fprintf(stderr, "%s: %s %s\n", fname, w, error);
+       if (exit_on_error && got_error)
                exit(1);
 }
 
@@ -165,7 +169,7 @@ make_pre_macro(const char *base, const char *pre)
        else
                s = g_strconcat(pre, "_", name, NULL);
 
-       g_strup(s);
+       gob_strup (s);
        
        g_free(ns);
        g_free(name);
@@ -366,3 +370,23 @@ get_type (const Type *t, gboolean postfix_to_stars)
        return g_string_free (gs, FALSE);
 }
 
+char *
+gob_strup (char *str)
+{
+       char *s;
+       for (s = str; *s; s++)
+               *s = g_ascii_toupper (*s);
+
+       return str;
+}
+
+char *
+gob_strdown (char *str)
+{
+       char *s;
+       for (s = str; *s; s++)
+               *s = g_ascii_tolower (*s);
+
+       return str;
+}
+