Changeset 162 for trunk/thune/make.c

Show
Ignore:
Timestamp:
05/27/06 21:22:22 (3 years ago)
Author:
krobillard
Message:

Thune -

Opcode selector is now preserved by infuse & ur_toStr().
Added ur_makeBinaryFrom() & ur_encodingCharSize[].
Command line arguments now passed to script in 'args.
Switched order of 'iter arguments.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/thune/make.c

    r157 r162  
    128128    ur_arrayInit( ptr, sizeof(char), size ); 
    129129    return ur_binN( ptr ); 
     130} 
     131 
     132 
     133/* 
     134   Returns zero if cell can not be converted. 
     135*/ 
     136UIndex ur_makeBinaryFrom( const UCell* cell ) 
     137{ 
     138    char* cpA; 
     139    char* cpB; 
     140    UIndex binN = 0; 
     141 
     142    if( ur_stringSlice( cell, &cpA, &cpB ) ) 
     143    { 
     144        int count; 
     145        int size; 
     146        UBinary* bin; 
     147 
     148        count = cpB - cpA; 
     149        size =  count * ur_encCharSize( cell ); 
     150        binN = ur_makeBinary( size ); 
     151        if( size ) 
     152        { 
     153            bin = ur_binPtr( binN ); 
     154            memCpy( bin->ptr.b, cpA, size ); 
     155            bin->used = count; 
     156        } 
     157    } 
     158 
     159    return binN; 
    130160} 
    131161 
     
    200230  Returns non-zero if identical up to end of either string. 
    201231*/ 
    202 static int strEqual( const char* a, const char* b, int len ) 
     232int memEqual( const char* a, const char* b, int len ) 
    203233{ 
    204234    const char* end = a + len; 
     
    231261    else if( len == 3 ) 
    232262    { 
    233         if( strEqual( cp, "tab", 3 ) ) 
     263        if( memEqual( cp, "tab", 3 ) ) 
    234264            return '\t'; 
    235         if( strEqual( cp, "esc", 3 ) ) 
     265        if( memEqual( cp, "esc", 3 ) ) 
    236266            return 27; 
    237267    } 
    238268    else if( len == 4 ) 
    239269    { 
    240         if( strEqual( cp, "line", 4 ) ) 
     270        if( memEqual( cp, "line", 4 ) ) 
    241271            return '\n'; 
    242         if( strEqual( cp, "page", 4 ) ) 
     272        if( memEqual( cp, "page", 4 ) ) 
    243273            return '\f'; 
    244         if( strEqual( cp, "back", 4 ) ) 
     274        if( memEqual( cp, "back", 4 ) ) 
    245275            return '\b'; 
    246         if( strEqual( cp, "bell", 4 ) ) 
     276        if( memEqual( cp, "bell", 4 ) ) 
    247277            return '\a'; 
    248         if( strEqual( cp, "null", 4 ) ) 
     278        if( memEqual( cp, "null", 4 ) ) 
    249279            return '\0'; 
    250280    } 
     
    376406static void _setBitsetStr( uint8_t* bits, const UCell* from ) 
    377407{ 
    378     UChar* it; 
    379     UChar* end; 
     408    char* it; 
     409    char* end; 
    380410    UBinary* src = ur_bin(from); 
    381411 
     
    630660UR_CALL_PUB( uc_make ) 
    631661{ 
    632     UChar* spA; 
    633     UChar* spB; 
     662    char* spA; 
     663    char* spB; 
    634664    UCell* res; 
    635665    int argc = 1; 
     
    663693            { 
    664694                ur_setType( res, UT_OPCODE ); 
    665                 ur_opcode(res)     = ur_int(ur_s_next(res)); 
    666                 ur_opcodeAtom(res) = ur_atom(tos); 
     695                ur_opcode(res) = ur_int(ur_s_next(res)); 
     696                ur_atom(res)  = ur_atom(tos); 
    667697            } 
    668698            break;