From: tomo Date: Tue, 15 Jun 1999 02:07:40 +0000 (+0000) Subject: (non_ascii_set_charptr_emchar): Don't define local variables `lb', X-Git-Tag: r21-2-15-buf-utf8-1~8 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=2d8e6927bb8f6eb194418903d2b9dd76713fb0b2;p=chise%2Fxemacs-chise.git- (non_ascii_set_charptr_emchar): Don't define local variables `lb', `c1', `c2' and `charset' in UTF2000; encode as UTF-8 in UTF2000. (non_ascii_charptr_emchar): Decode as UTF-8 in UTF2000. (non_ascii_valid_char_p): Don't define in UTF2000. (non_ascii_charptr_copy_char): Add case 5 and 6 in UTF2000. (Lstream_get_emchar_1): Likewise. (utf-2000-version): New variable in UTF2000. --- diff --git a/src/mule-charset.c b/src/mule-charset.c index ef19c6b..79d1319 100644 --- a/src/mule-charset.c +++ b/src/mule-charset.c @@ -194,11 +194,54 @@ Bytecount non_ascii_set_charptr_emchar (Bufbyte *str, Emchar c) { Bufbyte *p; +#ifndef UTF2000 Bufbyte lb; int c1, c2; Lisp_Object charset; +#endif p = str; +#ifdef UTF2000 + if ( c <= 0x7f ) + { + *p++ = c; + } + else if ( c <= 0x7ff ) + { + *p++ = (c >> 6) | 0xc0; + *p++ = (c & 0x3f) | 0x80; + } + else if ( c <= 0xffff ) + { + *p++ = (c >> 12) | 0xe0; + *p++ = ((c >> 6) & 0x3f) | 0x80; + *p++ = (c & 0x3f) | 0x80; + } + else if ( c <= 0x1fffff ) + { + *p++ = (c >> 18) | 0xf0; + *p++ = ((c >> 12) & 0x3f) | 0x80; + *p++ = ((c >> 6) & 0x3f) | 0x80; + *p++ = (c & 0x3f) | 0x80; + } + else if ( c <= 0x3ffffff ) + { + *p++ = (c >> 24) | 0xf8; + *p++ = ((c >> 18) & 0x3f) | 0x80; + *p++ = ((c >> 12) & 0x3f) | 0x80; + *p++ = ((c >> 6) & 0x3f) | 0x80; + *p++ = (c & 0x3f) | 0x80; + } + else + { + *p++ = (c >> 30) | 0xfc; + *p++ = ((c >> 24) & 0x3f) | 0x80; + *p++ = ((c >> 18) & 0x3f) | 0x80; + *p++ = ((c >> 12) & 0x3f) | 0x80; + *p++ = ((c >> 6) & 0x3f) | 0x80; + *p++ = (c & 0x3f) | 0x80; + } +#else BREAKUP_CHAR (c, charset, c1, c2); lb = CHAR_LEADING_BYTE (c); if (LEADING_BYTE_PRIVATE_P (lb)) @@ -209,7 +252,7 @@ non_ascii_set_charptr_emchar (Bufbyte *str, Emchar c) *p++ = c1 | 0x80; if (c2) *p++ = c2 | 0x80; - +#endif return (p - str); } @@ -220,6 +263,49 @@ non_ascii_set_charptr_emchar (Bufbyte *str, Emchar c) Emchar non_ascii_charptr_emchar (CONST Bufbyte *str) { +#ifdef UTF2000 + Bufbyte b; + Emchar ch; + int len; + + b = *str++; + if ( b >= 0xfc ) + { + ch = (b & 0x01); + len = 5; + } + else if ( b >= 0xf8 ) + { + ch = b & 0x03; + len = 4; + } + else if ( b >= 0xf0 ) + { + ch = b & 0x07; + len = 3; + } + else if ( b >= 0xe0 ) + { + ch = b & 0x0f; + len = 2; + } + else if ( b >= 0xc0 ) + { + ch = b & 0x1f; + len = 1; + } + else + { + ch = b; + len = 0; + } + for( ; len > 0; len-- ) + { + b = *str++; + ch = ( ch << 6 ) | ( b & 0x3f ); + } + return ch; +#else Bufbyte i0 = *str, i1, i2 = 0; Lisp_Object charset; @@ -236,11 +322,13 @@ non_ascii_charptr_emchar (CONST Bufbyte *str) i2 = *++str & 0x7F; return MAKE_CHAR (charset, i1, i2); +#endif } /* Return whether CH is a valid Emchar, assuming it's non-ASCII. Do not call this directly. Use the macro valid_char_p() instead. */ +#ifndef UTF2000 int non_ascii_valid_char_p (Emchar ch) { @@ -311,6 +399,7 @@ non_ascii_valid_char_p (Emchar ch) return (XCHARSET_CHARS (charset) == 96); } } +#endif /************************************************************************/ @@ -329,6 +418,10 @@ non_ascii_charptr_copy_char (CONST Bufbyte *ptr, Bufbyte *str) switch (REP_BYTES_BY_FIRST_BYTE (*strptr)) { /* Notice fallthrough. */ +#ifdef UTF2000 + case 6: *++strptr = *ptr++; + case 5: *++strptr = *ptr++; +#endif case 4: *++strptr = *ptr++; case 3: *++strptr = *ptr++; case 2: *++strptr = *ptr; @@ -358,6 +451,16 @@ Lstream_get_emchar_1 (Lstream *stream, int ch) switch (REP_BYTES_BY_FIRST_BYTE (ch)) { /* Notice fallthrough. */ +#ifdef UTF2000 + case 6: + ch = Lstream_getc (stream); + assert (ch >= 0); + *++strptr = (Bufbyte) ch; + case 5: + ch = Lstream_getc (stream); + assert (ch >= 0); + *++strptr = (Bufbyte) ch; +#endif case 4: ch = Lstream_getc (stream); assert (ch >= 0); @@ -1282,10 +1385,12 @@ syms_of_mule_charset (void) defsymbol (&Qcomposite, "composite"); - Vutf_2000_version = build_string("0.1"); +#ifdef UTF2000 + Vutf_2000_version = build_string("0.2"); DEFVAR_LISP ("utf-2000-version", &Vutf_2000_version /* Version number of UTF-2000. */ ); +#endif leading_code_private_11 = PRE_LEADING_BYTE_PRIVATE_1; DEFVAR_INT ("leading-code-private-11", &leading_code_private_11 /*