Changeset 363:5f6d9bb33a53

Show
Ignore:
Timestamp:
04/04/09 15:38:37 (3 years ago)
Author:
Frank Benoit <benoit@tionex.de>
Parents:

362:5b585873fec2 361:4bffbf81e2d6

branch:
default
Message:

merge

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • dwt/dwthelper/InflaterInputStream.d

    r361 r363  
    1212    } 
    1313} 
    14 version(TANGOSVN){ 
    15     import tango.io.device.Conduit; 
    16 } else { 
    17     import tango.io.Conduit; 
    18 
     14import tango.io.device.Conduit; 
    1915 
    2016class InputStreamWrapper : tango.io.model.IConduit.InputStream { 
  • dwt/dwthelper/InflaterInputStream.d

    r362 r363  
    66public import dwt.dwthelper.InputStream; 
    77import dwt.dwthelper.utils; 
    8 import tango.io.Stdout; 
    98import tango.io.compress.ZlibStream; 
    109version(Windows){ 
     
    2726        return res; 
    2827    } 
    29     void[] load (void[] dst = null) { 
    30             return Conduit.load (this, dst); 
     28 
     29    IOStream flush () { 
     30            return this; 
     31    } 
     32 
     33    void[] load ( size_t max = -1 ) { 
     34            return Conduit.load (this, max); 
    3135    } 
    3236 
     
    3539    } 
    3640 
    37     long seek ( long offset, IOStream.Anchor anchor = IOStream.Anchor.Begin ) 
    38     { 
    39         throw new IOException(__FILE__ ~ "seek method not implemented"); 
    40     } 
    41      
    4241    tango.io.model.IConduit.IConduit conduit (){ 
    4342        return null; 
     
    4746        istr.close(); 
    4847    } 
    49      
    50     tango.io.model.IConduit.InputStream input() { 
    51         return this; //?? 
     48    tango.io.model.IConduit.InputStream input (){ 
     49        return null; 
     50    } 
     51    long seek (long offset, Anchor anchor = Anchor.Begin){ 
     52        return 0; 
    5253    } 
    5354} 
  • dwt/dwthelper/utils.d

    r361 r363  
    486486} 
    487487 
    488 alias tango.text.convert.Utf.toString16 toString16; 
    489 alias tango.text.convert.Utf.toString toString; 
     488//alias tango.text.convert.Utf.toString16 toString16; 
     489//alias tango.text.convert.Utf.toString toString; 
    490490 
    491491int toAbsoluteCodePointStartOffset( String str, int index ){ 
  • dwt/dwthelper/utils.d

    r362 r363  
    1111 
    1212import tango.io.Stdout; 
    13 version(TANGOSVN) { 
    14     import tango.io.stream.Format; 
    15     alias FormatOutput Print; 
    16 
    17 else 
    18     import tango.io.Print; 
    19  
     13import tango.io.stream.Format; 
    2014static import tango.stdc.stringz; 
    2115static import tango.text.Util; 
     
    2721import tango.stdc.stdlib : exit; 
    2822 
    29 import tango.util.log.Trace
     23import tango.util.log.Log
    3024import tango.text.UnicodeData; 
     25 
     26Logger getDwtLogger(){ 
     27    return Log.lookup( "dwt" ); 
     28} 
    3129 
    3230alias char[] String; 
     
    3634 
    3735void implMissing( String file, uint line ){ 
    38     Stderr.formatln( "implementation missing in file {} line {}", file, line ); 
    39     Stderr.formatln( "exiting ..." ); 
     36    getDwtLogger().fatal( "implementation missing in file {} line {}", file, line ); 
     37    getDwtLogger().fatal( "exiting ..." ); 
    4038    exit(1); 
    4139} 
     
    6058        return (typeid(T[])).getHash(&array); 
    6159    } 
    62     static if( is( T == char[] )){ 
     60    static if( is( T == char )){ 
    6361        public override char[] toString(){ 
    6462            return array; 
     
    455453    consumed = ate; 
    456454    if( ate is 0 || res.length is 0 ){ 
    457         Trace.formatln( "dwthelper.utils {}: str.length={} str={:X2}", __LINE__, str.length, cast(ubyte[])str ); 
     455        getDwtLogger().trace( "dwthelper.utils {}: str.length={} str={:X2}", __LINE__, str.length, cast(ubyte[])str ); 
    458456    } 
    459457    assert( ate > 0 ); 
     
    467465    consumed = ate; 
    468466    if( ate is 0 || res.length is 0 ){ 
    469         Trace.formatln( "dwthelper.utils {}: str.length={} str={:X2}", __LINE__, str.length, cast(ubyte[])str ); 
     467        getDwtLogger().trace( "dwthelper.utils {}: str.length={} str={:X2}", __LINE__, str.length, cast(ubyte[])str ); 
    470468    } 
    471469    assert( ate > 0 ); 
     
    491489//alias tango.text.convert.Utf.toString toString; 
    492490 
     491int toAbsoluteCodePointStartOffset( String str, int index ){ 
     492    //getDwtLogger().trace( "str={}, str.length={}, index={}", str, str.length, index ); 
     493    //Trace.memory( str ); 
     494    if( str.length is index ){ 
     495        return index; 
     496    } 
     497    if( ( str[index] & 0x80 ) is 0x00 ) { 
     498        return index; 
     499    } 
     500    else{ 
     501        int steps = 0; 
     502        while(( str[index] & 0xC0 ) is 0x80 ){ 
     503            index--; 
     504            steps++; 
     505            if( steps > 3 || index < 0 ){ 
     506                break; 
     507            } 
     508        } 
     509        if((( str[index] & 0xE0 ) is 0xC0) && ( steps <= 1 )){ 
     510            // ok 
     511        } 
     512        else if((( str[index] & 0xF0 ) is 0xE0) && ( steps <= 2 )){ 
     513            // ok 
     514        } 
     515        else if((( str[index] & 0xF8 ) is 0xF0) && ( steps <= 3 )){ 
     516            // ok 
     517        } 
     518        else{ 
     519            tango.text.convert.Utf.onUnicodeError( "invalid utf8 input to toAbsoluteCodePointStartOffset" ); 
     520        } 
     521        return index; 
     522    } 
     523} 
    493524int getRelativeCodePointOffset( String str, int startIndex, int searchRelCp ){ 
    494525    return getAbsoluteCodePointOffset( str, startIndex, searchRelCp ) - startIndex; 
    495526} 
    496527int getAbsoluteCodePointOffset( String str, int startIndex, int searchRelCp ){ 
     528 
     529    //getDwtLogger().trace( "str={}, str.length={}, startIndex={}, searchRelCp={}", str, str.length, startIndex, searchRelCp ); 
     530    //Trace.memory( str ); 
     531 
    497532    int ignore; 
    498533    int i = startIndex; 
     
    501536 
    502537            if( ( i < str.length ) 
    503                 && ( str[i] & 0x80 ) is 0x00
     538            && (( str[i] & 0x80 ) is 0x00 )
    504539            { 
    505540                i+=1; 
     
    527562            } 
    528563            else{ 
    529                 Trace.formatln( "invalid utf8 characters:  {:X2}", cast(ubyte[]) str ); 
     564                getDwtLogger().trace( "getAbsoluteCodePointOffset invalid utf8 characters:  {:X2}", cast(ubyte[]) str ); 
    530565                tango.text.convert.Utf.onUnicodeError( "invalid utf8 input", i ); 
    531566            } 
     
    539574                if( i < 0 ){ 
    540575                    return startIndex-1; 
    541                     //Trace.formatln( "dwthelper.utils getRelativeCodePointOffset {}: str={}, startIndex={}, searchRelCp={}", __LINE__, str, startIndex, searchRelCp ); 
    542                     //tango.text.convert.Utf.onUnicodeError( "invalid utf8 input", i ); 
    543576                } 
    544577            } while(( str[i] & 0xC0 ) is 0x80 ); 
     
    566599            } 
    567600            else{ 
    568                 Trace.formatln( "invalid utf8 characters:  {:X2}", cast(ubyte[]) str ); 
    569                 tango.text.convert.Utf.onUnicodeError( "invalid utf8 input", i ); 
     601                getDwtLogger().trace( "invalid utf16 characters:  {:X2}", cast(ubyte[]) str ); 
     602                tango.text.convert.Utf.onUnicodeError( "invalid utf16 input", i ); 
    570603            } 
    571604            searchRelCp--; 
     
    578611                if( i < 0 ){ 
    579612                    return startIndex-1; 
    580                     //Trace.formatln( "dwthelper.utils getRelativeCodePointOffset {}: str={}, startIndex={}, searchRelCp={}", __LINE__, str, startIndex, searchRelCp ); 
    581                     //tango.text.convert.Utf.onUnicodeError( "invalid utf8 input", i ); 
     613                    //getDwtLogger().trace( "dwthelper.utils getRelativeCodePointOffset {}: str={}, startIndex={}, searchRelCp={}", __LINE__, str, startIndex, searchRelCp ); 
     614                    //tango.text.convert.Utf.onUnicodeError( "invalid utf16 input", i ); 
    582615                } 
    583616            } while(( str[i] & 0xDC00 ) is 0xDC00 ); 
     
    628661        assert( tries-- > 0 ); 
    629662    } 
    630     Trace.formatln( "utf8OffsetDecr {}->{}", offset, res ); 
    631     Trace.memory( str ); 
     663    getDwtLogger().trace( "utf8OffsetDecr {}->{}", offset, res ); 
     664    //Trace.memory( str ); 
    632665    return res; 
    633666} 
     
    10461079    ExceptionPrintStackTrace( e, Stderr ); 
    10471080} 
    1048 void ExceptionPrintStackTrace( Exception e, Print!(char) print ){ 
     1081void ExceptionPrintStackTrace( Exception e, FormatOutput!(char) print ){ 
    10491082    Exception exception = e; 
    10501083    while( exception !is null ){ 
     
    12661299    foreach( msg; e.info ){ 
    12671300        if( idx >= start && idx < start+deepth ) { 
    1268             Trace.formatln( "{}: {}", prefix, msg ); 
     1301            getDwtLogger().trace( "{}: {}", prefix, msg ); 
    12691302        } 
    12701303        idx++;