adapt to latest libfirm
[cparser] / printer.c
index 71d48f8..7e6e8f5 100644 (file)
--- a/printer.c
+++ b/printer.c
 
 static FILE* out;
 
+static void print_char_file(const char c)
+{
+       fputc(c, out);
+}
+
 static void print_string_file(const char *str)
 {
        fputs(str, out);
@@ -36,26 +41,6 @@ static void print_vformat_file(const char *format, va_list ap)
        vfprintf(out, format, ap);
 }
 
-static void print_char_file(wchar_rep_t c)
-{
-       const unsigned tc = (unsigned) c;
-       if (tc < 0x80) {
-               fputc(tc, out);
-       } else if (tc < 0x800) {
-               fputc(0xC0 | (tc >> 6),   out);
-               fputc(0x80 | (tc & 0x3F), out);
-       } else if (tc < 0x10000) {
-               fputc(0xE0 | ( tc >> 12),         out);
-               fputc(0x80 | ((tc >>  6) & 0x3F), out);
-               fputc(0x80 | ( tc        & 0x3F), out);
-       } else {
-               fputc(0xF0 | ( tc >> 18),         out);
-               fputc(0x80 | ((tc >> 12) & 0x3F), out);
-               fputc(0x80 | ((tc >>  6) & 0x3F), out);
-               fputc(0x80 | ( tc        & 0x3F), out);
-       }
-}
-
 void print_to_file(FILE *new_out)
 {
        out = new_out;
@@ -68,6 +53,11 @@ void print_to_file(FILE *new_out)
 
 static struct obstack *obst;
 
+static void print_char_obstack(const char c)
+{
+       obstack_1grow(obst, c);
+}
+
 static void print_string_obstack(const char *str)
 {
        size_t len = strlen(str);
@@ -79,26 +69,6 @@ static void print_vformat_obstack(const char *format, va_list ap)
        obstack_vprintf(obst, format, ap);
 }
 
-static void print_char_obstack(wchar_rep_t c)
-{
-       const unsigned tc = (unsigned) c;
-       if (tc < 0x80) {
-               obstack_1grow(obst, tc);
-       } else if (tc < 0x800) {
-               obstack_1grow(obst, 0xC0 | (tc >> 6));
-               obstack_1grow(obst, 0x80 | (tc & 0x3F));
-       } else if (tc < 0x10000) {
-               obstack_1grow(obst, 0xE0 | ( tc >> 12));
-               obstack_1grow(obst, 0x80 | ((tc >>  6) & 0x3F));
-               obstack_1grow(obst, 0x80 | ( tc        & 0x3F));
-       } else {
-               obstack_1grow(obst, 0xF0 | ( tc >> 18));
-               obstack_1grow(obst, 0x80 | ((tc >> 12) & 0x3F));
-               obstack_1grow(obst, 0x80 | ((tc >>  6) & 0x3F));
-               obstack_1grow(obst, 0x80 | ( tc        & 0x3F));
-       }
-}
-
 void print_to_obstack(struct obstack *new_obst)
 {
        obst = new_obst;
@@ -112,7 +82,7 @@ void print_to_obstack(struct obstack *new_obst)
 static char *buffer_pos;
 static char *buffer_end;
 
-static inline void buffer_add_char(int c)
+static void print_char_buffer(const char c)
 {
        if (buffer_pos == buffer_end)
                return;
@@ -122,7 +92,7 @@ static inline void buffer_add_char(int c)
 static void print_string_buffer(const char *str)
 {
        for (const char *c = str; *c != '\0'; ++c) {
-               buffer_add_char(*c);
+               print_char_buffer(*c);
        }
 }
 
@@ -133,26 +103,6 @@ static void print_vformat_buffer(const char *format, va_list ap)
        buffer_pos    += written < size ? written : size;
 }
 
-static void print_char_buffer(wchar_rep_t c)
-{
-       const unsigned tc = (unsigned) c;
-       if (tc < 0x80) {
-               buffer_add_char(tc);
-       } else if (tc < 0x800) {
-               buffer_add_char(0xC0 | (tc >> 6));
-               buffer_add_char(0x80 | (tc & 0x3F));
-       } else if (tc < 0x10000) {
-               buffer_add_char(0xE0 | ( tc >> 12));
-               buffer_add_char(0x80 | ((tc >>  6) & 0x3F));
-               buffer_add_char(0x80 | ( tc        & 0x3F));
-       } else {
-               buffer_add_char(0xF0 | ( tc >> 18));
-               buffer_add_char(0x80 | ((tc >> 12) & 0x3F));
-               buffer_add_char(0x80 | ((tc >>  6) & 0x3F));
-               buffer_add_char(0x80 | ( tc        & 0x3F));
-       }
-}
-
 void print_to_buffer(char *buffer, size_t buffer_size)
 {
        buffer_pos = buffer;
@@ -173,7 +123,7 @@ void finish_print_to_buffer(void)
 
 void (*print_string)(const char *str) = print_string_file;
 void (*print_vformat)(const char *format, va_list ap) = print_vformat_file;
-void (*print_char)(wchar_rep_t c) = print_char_file;
+void (*print_char)(const char c) = print_char_file;
 
 void printer_push(void)
 {