X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;ds=sidebyside;f=unicode.h;h=b6a16e37afe21466577bacc4ba5e27cb8a3c872e;hb=296ba6e16420b89723d1a5b1217d6ecfc2fb0c7d;hp=18b19d56d5ead4e7bee30316b3da447234fa6675;hpb=6025937d4911b04456148671a111c364556dcd10;p=cparser diff --git a/unicode.h b/unicode.h index 18b19d5..b6a16e3 100644 --- a/unicode.h +++ b/unicode.h @@ -45,22 +45,23 @@ static inline utf32 read_utf8_char(const char **p) return result; } -static inline void obstack_grow_symbol(struct obstack *obstack, utf32 const tc) +static inline void obstack_grow_utf8(struct obstack *const obst, utf32 const c) { - if (tc < 0x80U) { - obstack_1grow(obstack, tc); - } else if (tc < 0x800) { - obstack_1grow(obstack, 0xC0 | (tc >> 6)); - obstack_1grow(obstack, 0x80 | (tc & 0x3F)); - } else if (tc < 0x10000) { - obstack_1grow(obstack, 0xE0 | ( tc >> 12)); - obstack_1grow(obstack, 0x80 | ((tc >> 6) & 0x3F)); - obstack_1grow(obstack, 0x80 | ( tc & 0x3F)); + if (c < 0x80U) { + obstack_1grow(obst, c); + } else if (c < 0x800) { + obstack_1grow(obst, 0xC0 | (c >> 6)); + goto one_more; + } else if (c < 0x10000) { + obstack_1grow(obst, 0xE0 | (c >> 12)); + goto two_more; } else { - obstack_1grow(obstack, 0xF0 | ( tc >> 18)); - obstack_1grow(obstack, 0x80 | ((tc >> 12) & 0x3F)); - obstack_1grow(obstack, 0x80 | ((tc >> 6) & 0x3F)); - obstack_1grow(obstack, 0x80 | ( tc & 0x3F)); + obstack_1grow(obst, 0xF0 | (c >> 18)); + obstack_1grow(obst, 0x80 | ((c >> 12) & 0x3F)); +two_more: + obstack_1grow(obst, 0x80 | ((c >> 6) & 0x3F)); +one_more: + obstack_1grow(obst, 0x80 | ( c & 0x3F)); } }