Changeset 446
- Timestamp:
- 08/08/07 03:54:30 (14 months ago)
- Files:
-
- 1 modified
-
branches/thune/thread_safe/series.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/thune/thread_safe/series.c
r431 r446 1628 1628 { 1629 1629 UBinary* bin = ur_bin(tos); 1630 if( (bin->used - tos->series.it) < 1 ) 1630 int n = bin->used; 1631 if( (n - tos->series.it) < 1 ) 1631 1632 break; 1633 --n; 1634 if( ur_encoding(tos) == UR_ENC_UTF16 ) 1635 ur_int(tos) = bin->ptr.u16[ n ]; 1636 else 1637 ur_int(tos) = bin->ptr.c[ n ]; 1632 1638 ur_initType( tos, UT_CHAR ); 1633 ur_int(tos) = bin->ptr.c[ bin->used - 1 ];1634 1639 } 1635 1640 return; … … 1648 1653 /* 1649 1654 case UT_COORD: 1650 orResult( UT_INTEGER, tos->coord[ tos->argc ] ); 1655 ur_int(tos) = tos->coord.elem[ tos->coord.len - 1 ]; 1656 ur_initType( tos, UT_INT ); 1651 1657 return; 1652 1658 … … 1654 1660 break; 1655 1661 */ 1662 1663 case UT_SLICE: 1664 switch( ur_sliceDT(tos) ) 1665 { 1666 case UT_STRING: 1667 { 1668 UBinary* bin = ur_bin(tos); 1669 UIndex n = ur_sliceEnd( tos, bin ); 1670 if( (n - tos->series.it) < 1 ) 1671 break; 1672 --n; 1673 if( ur_encoding(tos) == UR_ENC_UTF16 ) 1674 ur_int(tos) = bin->ptr.u16[ n ]; 1675 else 1676 ur_int(tos) = bin->ptr.c[ n ]; 1677 ur_initType( tos, UT_CHAR ); 1678 } 1679 return; 1680 1681 case UT_BINARY: 1682 { 1683 UBinary* bin = ur_bin(tos); 1684 UIndex n = ur_sliceEnd( tos, bin ); 1685 if( (n - tos->series.it) < 1 ) 1686 break; 1687 ur_initType( tos, UT_INT ); 1688 ur_int(tos) = bin->ptr.b[ n - 1 ]; 1689 } 1690 return; 1691 1692 default: 1693 ur_throwErr( UR_ERR_DATATYPE, 1694 "FIXME: last not implemented for %s slice", 1695 ur_typeName( ur_sliceDT(tos) ) ); 1696 return; 1697 } 1698 break; 1656 1699 1657 1700 case UT_VECTOR: … … 2941 2984 2942 2985 2986 /** 2987 Returns sit where match is complete or zero if string starting with sit 2988 does not match all of pattern pit to pend. 2989 */ 2990 static const char* ur_match1( const char* sit, const char* send, 2991 const char* pit, const char* pend ) 2992 { 2993 while( pit != pend ) 2994 { 2995 if( sit == send ) 2996 return 0; 2997 if( *sit != *pit ) 2998 return 0; 2999 ++sit; 3000 ++pit; 3001 } 3002 return sit; 3003 } 3004 3005 2943 3006 /* 2944 3007 (series value -- series) … … 2956 3019 case UT_STRING: 2957 3020 { 2958 int found;2959 UString* s1 = ur_bin(res);2960 2961 3021 if( ur_is(tos, UT_CHAR) ) 2962 3022 { … … 2973 3033 else if( ur_is(tos, UT_STRING) || ur_is(tos, UT_BINARY) ) 2974 3034 { 2975 UString* s2 = ur_bin(tos); 2976 if( s2->used ) 2977 { 2978 found = ur_matchString( s1, res->series.it, 2979 s2, tos->series.it ); 2980 if( found ) 2981 { 2982 res->series.it = found; 2983 return; 2984 } 2985 } 3035 goto match_bytes; 3036 } 3037 else if( ur_is(tos, UT_SLICE) && 3038 ((ur_sliceDT(res) == UT_STRING) || 3039 (ur_sliceDT(res) == UT_BINARY)) ) 3040 { 3041 goto match_bytes; 2986 3042 } 2987 3043 } … … 3004 3060 } 3005 3061 goto ret_none; 3062 3063 case UT_SLICE: 3064 if( ((ur_sliceDT(res) == UT_STRING) || 3065 (ur_sliceDT(res) == UT_BINARY)) && 3066 (ur_is(tos, UT_STRING) || ur_is(tos, UT_BINARY)) ) 3067 goto match_bytes; 3068 goto ret_none; 3006 3069 } 3007 3070 … … 3013 3076 ur_initType(res, UT_NONE); 3014 3077 return; 3078 3079 match_bytes: 3080 { 3081 const char* eom; 3082 char* pA; 3083 char* pB; 3084 char* sA; 3085 char* sB; 3086 3087 ur_seriesMem( ut, res, &sA, &sB ); 3088 ur_seriesMem( ut, tos, &pA, &pB ); 3089 3090 eom = ur_match1( sA, sB, pA, pB ); 3091 if( eom ) 3092 { 3093 res->series.it += eom - sA; 3094 return; 3095 } 3096 } 3097 goto ret_none; 3015 3098 } 3016 3099
