- Rework the way literals are handled, these are now kept as strings until
[cparser] / diagnostic.c
index 3e83b0b..0b92ae5 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * This file is part of cparser.
- * Copyright (C) 2007-2008 Matthias Braun <matze@braunis.de>
+ * Copyright (C) 2007-2009 Matthias Braun <matze@braunis.de>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -34,15 +34,14 @@ unsigned diagnostic_count = 0;
 unsigned error_count      = 0;
 /** Number of occurred warnings. */
 unsigned warning_count    = 0;
-/** true if warnings should be inhibited */
-bool inhibit_all_warnings = false;
 
 static const source_position_t *curr_pos = NULL;
 
 /**
  * prints an additional source position
  */
-static void print_source_position(FILE *out, const source_position_t *pos) {
+static void print_source_position(FILE *out, const source_position_t *pos)
+{
        fprintf(out, "at line %u", pos->linenr);
        if (curr_pos == NULL || curr_pos->input_name != pos->input_name)
                fprintf(out, " of \"%s\"", pos->input_name);
@@ -68,12 +67,6 @@ static void diagnosticvf(const char *const fmt, va_list ap)
                                        fputc(*f, stderr);
                                        break;
 
-                               case 'C': {
-                                       const wint_t val = va_arg(ap, wint_t);
-                                       fputwc(val, stderr);
-                                       break;
-                               }
-
                                case 'c': {
                                        const unsigned char val = (unsigned char) va_arg(ap, int);
                                        fputc(val, stderr);
@@ -92,9 +85,26 @@ static void diagnosticvf(const char *const fmt, va_list ap)
                                        break;
                                }
 
+                               case 'S': {
+                                       const string_t *str = va_arg(ap, const string_t*);
+                                       for (size_t i = 0; i < str->size; ++i) {
+                                               fputc(str->begin[i], stderr);
+                                       }
+                                       break;
+                               }
+
+                               case 'u': {
+                                       const unsigned int val = va_arg(ap, unsigned int);
+                                       fprintf(stderr, "%u", val);
+                                       break;
+                               }
+
                                case 'Y': {
                                        const symbol_t *const symbol = va_arg(ap, const symbol_t*);
-                                       fputs(symbol->string, stderr);
+                                       if (symbol == NULL)
+                                               fputs("(null)", stderr);
+                                       else
+                                               fputs(symbol->string, stderr);
                                        break;
                                }
 
@@ -120,6 +130,12 @@ static void diagnosticvf(const char *const fmt, va_list ap)
                                        break;
                                }
 
+                               case 't': {
+                                       const token_t *const token = va_arg(ap, const token_t*);
+                                       print_pp_token(stderr, token);
+                                       break;
+                               }
+
                                case 'K': {
                                        const token_t* const token = va_arg(ap, const token_t*);
                                        print_token(stderr, token);
@@ -208,9 +224,6 @@ static void warningvf(const source_position_t *pos,
 
 void warningf(const source_position_t *pos, const char *const fmt, ...)
 {
-       if (inhibit_all_warnings)
-               return;
-
        va_list ap;
        va_start(ap, fmt);
        curr_pos = pos;