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);
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;
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);
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;
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;
static void print_string_buffer(const char *str)
{
for (const char *c = str; *c != '\0'; ++c) {
- buffer_add_char(*c);
+ print_char_buffer(*c);
}
}
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;
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)
{