Diff for /gforth/utf-8.fs between versions 1.26 and 1.29

version 1.26, 2007/05/05 17:26:02 version 1.29, 2007/09/15 20:11:44
Line 71  $80 Value max-single-byte Line 71  $80 Value max-single-byte
   
 \ utf key and emit  \ utf key and emit
   
   Defer check-xy  ' noop IS check-xy
   
 : u8key ( -- u )  : u8key ( -- u )
     defers key dup max-single-byte u< ?EXIT  \ special case ASCII      defers key dup max-single-byte u< ?EXIT  \ special case ASCII
       dup $FF = ?EXIT  \ special resize character
     dup $C2 u< IF  UTF-8-err throw  THEN  \ malformed character      dup $C2 u< IF  UTF-8-err throw  THEN  \ malformed character
     $7F and  $40 >r      $7F and  $40 >r
     BEGIN  dup r@ and  WHILE  r@ xor      BEGIN  dup r@ and  WHILE  r@ xor
Line 91  $80 Value max-single-byte Line 94  $80 Value max-single-byte
   
 \ utf-8 stuff for xchars  \ utf-8 stuff for xchars
   
 : u8string+ ( xcaddr u -- xcaddr u' )  : +u8/string ( xc-addr1 u1 -- xc-addr2 u2 )
     over + u8>> over - ;  
 : u8string- ( xcaddr u -- xcaddr u' )  
     over + u8<< over - ;  
   
 : +u8string ( xc-addr1 u1 -- xc-addr2 u2 )  
     over dup u8>> swap - /string ;      over dup u8>> swap - /string ;
 : -u8string ( xc-addr1 u1 -- xc-addr2 u2 )  : u8\string- ( xcaddr u -- xcaddr u' )
     over dup u8<< swap - /string ;      over + u8<< over - ;
   
 : u8@ ( c-addr -- u )  : u8@ ( c-addr -- u )
     u8@+ nip ;      u8@+ nip ;
Line 112  $80 Value max-single-byte Line 110  $80 Value max-single-byte
         >r u8!+ r> r> swap - true          >r u8!+ r> r> swap - true
     then ;      then ;
   
 : u8addrlen ( u8-addr -- u )  : u8addrlen ( u8-addr u -- u )  drop
     \ length of UTF-8 char starting at u8-addr (accesses only u8-addr)      \ length of UTF-8 char starting at u8-addr (accesses only u8-addr)
     c@      c@
     dup $80 u< if drop 1 exit endif      dup $80 u< if drop 1 exit endif
Line 126  $80 Value max-single-byte Line 124  $80 Value max-single-byte
   
 : -u8trailing-garbage ( addr u1 -- addr u2 )  : -u8trailing-garbage ( addr u1 -- addr u2 )
     2dup + dup u8<< ( addr u1 end1 end2 )      2dup + dup u8<< ( addr u1 end1 end2 )
     2dup dup u8addrlen + = if \ last character ok      2dup dup over over - u8addrlen + = if \ last character ok
         2drop          2drop
     else      else
         nip nip over -          nip nip over -
Line 292  here wc-table - Constant #wc-table Line 290  here wc-table - Constant #wc-table
     ['] u8>> is xchar+      ['] u8>> is xchar+
     ['] u8<< is xchar-      ['] u8<< is xchar-
 [ [IFDEF] xstring+ ]  [ [IFDEF] xstring+ ]
     ['] u8string+ is xstring+      ['] u8\string- is xstring-
     ['] u8string- is xstring-      ['] +u8/string is +xstring
     ['] +u8string is +xstring  [ [THEN] ]
     ['] -u8string is -xstring  [ [IFDEF] x/string+ ]
       ['] u8\string- is x\string-
       ['] +u8/string is +x/string
 [ [THEN] ]  [ [THEN] ]
     ['] u8@ is xc@      ['] u8@ is xc@
     ['] u8!+? is xc!+?      ['] u8!+? is xc!+?
Line 304  here wc-table - Constant #wc-table Line 304  here wc-table - Constant #wc-table
 [ [IFDEF] x-width ]  [ [IFDEF] x-width ]
     ['] u8width is x-width      ['] u8width is x-width
 [ [THEN] ]  [ [THEN] ]
   [ [IFDEF] x-size ]
       ['] u8addrlen is x-size
   [ [THEN] ]
     ['] -u8trailing-garbage is -trailing-garbage      ['] -u8trailing-garbage is -trailing-garbage
 ;  ;
   

Removed from v.1.26  
changed lines
  Added in v.1.29


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>