directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alan D. Cabrera" <...@toolazydogs.com>
Subject Re: [asn1] Mods do not compile anymore - Re: svn commit: r155335 - in incubator/directory/asn1/trunk/ber/src: java/org/apache/asn1/ber/Tag.java java/org/apache/asn1/ber/Tuple.java test/org/apache/asn1/ber/MultiByteTagTests.java test/org/apache/asn1/ber/TagTest.java test/org/apache/asn1/ber/TupleTest.java
Date Fri, 25 Feb 2005 17:36:02 GMT
Odd, it works for me.  Did you do a clean build?


Regards,
Alan

Alex Karasulu wrote:

> Alan,
>
> Looks like these mods don't even compile.  Could you please roll back 
> these mods until you have a better understanding of the effects of 
> these changes.
>
> Thanks,
> Alex
>
> Alex
>
> adc@apache.org wrote:
>
>> Author: adc
>> Date: Fri Feb 25 07:31:15 2005
>> New Revision: 155335
>>
>> URL: http://svn.apache.org/viewcvs?view=rev&rev=155335
>> Log:
>> Bad encoding of tags number above 127
>> http://issues.apache.org/jira/browse/DIRSNICKERS-103
>>
>> Modified:
>>    
>> incubator/directory/asn1/trunk/ber/src/java/org/apache/asn1/ber/Tag.java
>>    
>> incubator/directory/asn1/trunk/ber/src/java/org/apache/asn1/ber/Tuple.java 
>>
>>    
>> incubator/directory/asn1/trunk/ber/src/test/org/apache/asn1/ber/MultiByteTagTests.java

>>
>>    
>> incubator/directory/asn1/trunk/ber/src/test/org/apache/asn1/ber/TagTest.java 
>>
>>    
>> incubator/directory/asn1/trunk/ber/src/test/org/apache/asn1/ber/TupleTest.java 
>>
>>
>> Modified: 
>> incubator/directory/asn1/trunk/ber/src/java/org/apache/asn1/ber/Tag.java
>> URL: 
>> http://svn.apache.org/viewcvs/incubator/directory/asn1/trunk/ber/src/java/org/apache/asn1/ber/Tag.java?view=diff&r1=155334&r2=155335

>>
>> ============================================================================== 
>>
>> --- 
>> incubator/directory/asn1/trunk/ber/src/java/org/apache/asn1/ber/Tag.java 
>> (original)
>> +++ 
>> incubator/directory/asn1/trunk/ber/src/java/org/apache/asn1/ber/Tag.java 
>> Fri Feb 25 07:31:15 2005
>> @@ -318,8 +318,7 @@
>>         // calculate tag value w/ long tag format
>>         for( int ii = 1 ; ii < octets.length; ii++ )
>>         {
>> -            int shift = ( ii - 1 ) * 7 ;
>> -            id |= ( octets[ii] & LONG_MASK ) << shift ;
>> +            id = (id << 7) | (octets[ii] & LONG_MASK);
>>         }
>>
>>         return id ;
>> @@ -407,8 +406,7 @@
>>         // calculate tag value w/ long tag format
>>         for( int ii = 1 ; ii < octets.size(); ii++ )
>>         {    -            int shift = ( ii - 1 ) * 7 ;
>> -            id |= ( octets.get( ii ) & LONG_MASK ) << shift ;
>> +            id = (id << 7) | (octets.get(ii) & LONG_MASK);
>>         }
>>                 return id ;
>>
>> Modified: 
>> incubator/directory/asn1/trunk/ber/src/java/org/apache/asn1/ber/Tuple.java 
>>
>> URL: 
>> http://svn.apache.org/viewcvs/incubator/directory/asn1/trunk/ber/src/java/org/apache/asn1/ber/Tuple.java?view=diff&r1=155334&r2=155335

>>
>> ============================================================================== 
>>
>> --- 
>> incubator/directory/asn1/trunk/ber/src/java/org/apache/asn1/ber/Tuple.java 
>> (original)
>> +++ 
>> incubator/directory/asn1/trunk/ber/src/java/org/apache/asn1/ber/Tuple.java 
>> Fri Feb 25 07:31:15 2005
>> @@ -539,111 +539,60 @@
>>      */
>>     public void setTag( ByteBuffer octets, int tagLength )
>>     {
>> -        int ii = octets.position();
>> -        octets.put( ( byte ) typeClass.getValue() ) ;
>> -        -        if ( ! isPrimitive )
>> -        {
>> -            octets.put( ii, ( byte ) ( octets.get( ii ) | BIT_5 ) ) ;
>> -        }
>> -        -        if ( tagLength == 1 )
>> -        {
>> -            octets.put( ii, ( byte ) ( octets.get( ii ) | id ) ) ;
>> -            return ;
>> -        }
>> -        -        octets.put( ii, ( byte ) ( octets.get( ii ) | 
>> Tag.SHORT_MASK ) ) ;
>> -        -        if ( tagLength >= 2 )
>> -        {
>> -            ii++;
>> -            octets.put( ( byte ) ( ( int ) 0x7f & id ) ) ;
>> -            -            if ( tagLength > 2 )
>> -            {
>> -                octets.put( ii, ( byte ) ( octets.get( ii ) | BIT_7 
>> ) ) ;
>> -            }
>> -        }
>> -        else
>> -        {
>> -            return ;
>> -        }
>> -        -        /* -         * Take bits [8-14] (1 based bit 
>> indexing) inclusive in id and set the
>> -         * value for the second byte to this when shifted down 7 
>> positions so
>> -         * we need the following mask:
>> -         * -         * 0011 1111 1000 0000 => 0x3f80
>> -         * -         */
>> -        if ( tagLength >= 3 )
>> -        {
>> -            ii++;
>> -            octets.put( ( byte ) ( ( ( int ) 0x3f80 & id ) >> 7 ) ) ;
>> -            -            if ( tagLength > 3 )
>> -            {
>> -                octets.put( ii, ( byte ) ( octets.get( ii ) | BIT_7 
>> ) ) ;
>> -            }
>> -        }
>> -        else
>> -        {
>> -            return ;
>> -        }
>> -        -        /* -         * Take bits [15-21] (1 based bit 
>> indexing) inclusive in id and set the
>> -         * value for the second byte to this when shifted down 14 
>> positions so
>> -         * we need the following mask:
>> -         * -         * 0001 1111 1100 0000 0000 0000 => 0x1fc000
>> -         * -         */
>> -        if ( tagLength >= 4 )
>> -        {
>> -            ii++;
>> -            octets.put( ( byte ) ( ( ( int ) 0x1fc000 & id ) >> 14 ) 
>> ) ;
>> -            -            if ( tagLength > 4 )
>> -            {
>> -                octets.put( ii, ( byte ) ( octets.get( ii ) | BIT_7 
>> ) ) ;
>> -            }
>> -        }
>> -        else
>> -        {
>> -            return ;
>> -        }
>> -        -        /* -         * Take bits [22-28] (1 based bit 
>> indexing) inclusive in id and set the
>> -         * value for the second byte to this when shifted down 21 
>> positions so
>> -         * we need the following mask:
>> -         * -         * 0000 1111 1110 0000 0000 0000 0000 0000 => 
>> 0x0fe00000
>> -         * -         */
>> -        if ( tagLength >= 5 )
>> -        {
>> -            ii++;
>> -            octets.put( ( byte ) ( ( ( int ) 0x0fe00000 & id ) >> 21 
>> ) ) ;
>> -            -            if ( tagLength > 5 )
>> -            {
>> -                octets.put( ii, ( byte ) ( octets.get( ii ) | BIT_7 
>> ) ) ;
>> -            }
>> -        }
>> -        else
>> -        {
>> -            return ;
>> -        }
>> -                if ( tagLength >= 6 )
>>         {                throw new IllegalArgumentException( "cannot 
>> support id's as large "
>>                     + "as " + id + " unless we start using longs for 
>> the id" ) ;
>>         }
>> +
>> +        byte octet = ( byte ) typeClass.getValue() ;
>> +        int i = octets.position();
>> +        +        if ( ! isPrimitive )
>> +        {
>> +            octet |= BIT_5;
>> +        }
>> +        +        if ( id < 31 ) +        {
>> +            octets.put( ( byte ) ( octet | (id & Tag.SHORT_MASK ) ) ) ;
>> +            return;
>> +           
>> +        } +        else
>> +        {
>> +            octets.put( ( byte ) ( octet | Tag.SHORT_MASK ) ) ;
>> +            i++;
>> +        }
>> +
>> +        switch ( tagLength - 1) {
>> +            case 5 :
>> +                octets.put( ( byte ) ( ( ( id >> 21 ) & 
>> Tag.LONG_MASK ) | BIT_7 ) ) ;
>> +                i++;
>> +                // fallthrough
>> +
>> +            case 4:
>> +                octets.put( ( byte ) ( ( ( id >> 21 ) & 
>> Tag.LONG_MASK ) | BIT_7 ) ) ;
>> +                i++;
>> +                // fallthrough
>> +
>> +            case 3 :
>> +                octets.put( ( byte ) ( ( ( id >> 14 ) & 
>> Tag.LONG_MASK ) | BIT_7 ) ) ;
>> +                i++;
>> +                // fallthrough
>> +
>> +            case 2 :
>> +                octets.put( ( byte ) ( ( ( id >> 7 ) & Tag.LONG_MASK 
>> ) | BIT_7 ) ) ;
>> +                i++;
>> +                // fallthrough
>> +
>> +            case 1 :
>> +                octets.put( ( byte ) ( id  & Tag.LONG_MASK ) ) ;
>> +                break;
>> +        }
>> +
>> +        //octets.f
>> +        return ;
>>     }
>>
>>
>>
>> Modified: 
>> incubator/directory/asn1/trunk/ber/src/test/org/apache/asn1/ber/MultiByteTagTests.java

>>
>> URL: 
>> http://svn.apache.org/viewcvs/incubator/directory/asn1/trunk/ber/src/test/org/apache/asn1/ber/MultiByteTagTests.java?view=diff&r1=155334&r2=155335

>>
>> ============================================================================== 
>>
>> --- 
>> incubator/directory/asn1/trunk/ber/src/test/org/apache/asn1/ber/MultiByteTagTests.java

>> (original)
>> +++ 
>> incubator/directory/asn1/trunk/ber/src/test/org/apache/asn1/ber/MultiByteTagTests.java

>> Fri Feb 25 07:31:15 2005
>> @@ -111,7 +111,7 @@
>>         assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
>>
>>         tlv = decode( "00000001" ) ;
>> -        assertEquals( 128, tlv.id ) ;
>> +        assertEquals( 1, tlv.id ) ;
>>         assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
>>     }
>>
>> @@ -146,7 +146,7 @@
>>         assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
>>         assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
>>
>> -        tlv = decode( "10000000" ) ;
>> +        tlv = decode( "10000001" ) ;
>>         assertEquals( 0, tlv.id ) ;
>>         assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
>>
>> @@ -154,7 +154,7 @@
>>         assertEquals( 0, tlv.id ) ;
>>         assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
>>
>> -        tlv = decode( "00000001" ) ;
>> +        tlv = decode( "00000000" ) ;
>>         assertEquals( BIT_13, tlv.id ) ;
>>         assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
>>     }
>>
>> Modified: 
>> incubator/directory/asn1/trunk/ber/src/test/org/apache/asn1/ber/TagTest.java 
>>
>> URL: 
>> http://svn.apache.org/viewcvs/incubator/directory/asn1/trunk/ber/src/test/org/apache/asn1/ber/TagTest.java?view=diff&r1=155334&r2=155335

>>
>> ============================================================================== 
>>
>> --- 
>> incubator/directory/asn1/trunk/ber/src/test/org/apache/asn1/ber/TagTest.java 
>> (original)
>> +++ 
>> incubator/directory/asn1/trunk/ber/src/test/org/apache/asn1/ber/TagTest.java 
>> Fri Feb 25 07:31:15 2005
>> @@ -205,8 +205,8 @@
>>
>>         for ( int ii = 128 ; ii < 20000; ii++ )
>>         {
>> -            octets[1] = ( byte ) ( ii & Tag.LONG_MASK ) ;
>> -            octets[2] = ( byte ) ( ( ii >> 7 ) & Tag.LONG_MASK ) ;
>> +            octets[1] = (byte)((ii >> 7) & Tag.LONG_MASK);
>> +            octets[2] = (byte)(ii & Tag.LONG_MASK);
>>
>>             if ( ii < 16384 )
>>             {
>> @@ -226,9 +226,9 @@
>>
>>         for ( int ii = 16384 ; ii < 2100000 ; ii++ )
>>         {
>> -            octets[1] = ( byte ) ( ii & Tag.LONG_MASK ) ;
>> -            octets[2] = ( byte ) ( ( ii >> 7 ) & Tag.LONG_MASK ) ;
>> -            octets[3] = ( byte ) ( ( ii >> 14 ) & Tag.LONG_MASK ) ;
>> +            octets[1] = (byte)((ii >> 14) & Tag.LONG_MASK);
>> +            octets[2] = (byte)((ii >> 7) & Tag.LONG_MASK);
>> +            octets[3] = (byte)(ii & Tag.LONG_MASK);
>>
>>             if ( ii < 2097152 )
>>             {
>>
>> Modified: 
>> incubator/directory/asn1/trunk/ber/src/test/org/apache/asn1/ber/TupleTest.java 
>>
>> URL: 
>> http://svn.apache.org/viewcvs/incubator/directory/asn1/trunk/ber/src/test/org/apache/asn1/ber/TupleTest.java?view=diff&r1=155334&r2=155335

>>
>> ============================================================================== 
>>
>> --- 
>> incubator/directory/asn1/trunk/ber/src/test/org/apache/asn1/ber/TupleTest.java 
>> (original)
>> +++ 
>> incubator/directory/asn1/trunk/ber/src/test/org/apache/asn1/ber/TupleTest.java 
>> Fri Feb 25 07:31:15 2005
>> @@ -403,8 +403,8 @@
>>         encoded = t.toEncodedBuffer( Collections.EMPTY_LIST ) ;
>>         assertEquals(
>>                 "00000000" +
>> -                "00000001" +
>> -                "10000000" +
>> +                "00000000" +
>> +                "10000001" +
>>                 "01111111"
>>                 , toAsciiString( encoded ) ) ;
>>
>> @@ -414,8 +414,8 @@
>>         encoded = t.toEncodedBuffer( list ) ;
>>         assertEquals(
>>                 "01111111" +
>> -                "00000001" +
>> -                "10000000" +
>> +                "00000000" +
>> +                "10000001" +
>>                 "01111111"
>>                 , toAsciiString( encoded ) ) ;
>>
>> @@ -426,8 +426,8 @@
>>         assertEquals(
>>                 "10000000" +
>>                 "10000001" +
>> -                "00000001" +
>> -                "10000000" +
>> +                "00000000" +
>> +                "10000001" +
>>                 "01111111"
>>                 , toAsciiString( encoded ) ) ;
>>
>> @@ -438,8 +438,8 @@
>>         assertEquals(
>>                 "11111111" +
>>                 "10000001" +
>> -                "00000001" +
>> -                "10000000" +
>> +                "00000000" +
>> +                "10000001" +
>>                 "01111111"
>>                 , toAsciiString( encoded ) ) ;
>>
>> @@ -451,8 +451,8 @@
>>                 "00000000" +
>>                 "00000001" +
>>                 "10000010" +
>> -                "00000001" +
>> -                "10000000" +
>> +                "00000000" +
>> +                "10000001" +
>>                 "01111111"
>>                 , toAsciiString( encoded ) ) ;
>>     }
>> @@ -496,8 +496,8 @@
>>         encoded = t.toEncodedBuffer( Collections.EMPTY_LIST ) ;
>>         assertEquals(
>>                 "00000000" +
>> -                "00000001" +
>> -                "10000000" +
>> +                "00000000" +
>> +                "10000001" +
>>                 "01011111"
>>                 , toAsciiString( encoded ) ) ;
>>
>> @@ -509,8 +509,8 @@
>>         assertEquals(
>>                 "00000000" +
>>                 "00000001" +
>> -                "00000001" +
>> -                "10000000" +
>> +                "00000000" +
>> +                "10000001" +
>>                 "01011111"
>>                 , toAsciiString( encoded ) ) ;
>>
>> @@ -521,8 +521,8 @@
>>         encoded = t.toEncodedBuffer( list ) ;
>>         assertEquals( BinaryCodec.toAsciiString( data ) +
>>                 "01111111" +
>> -                "00000001" +
>> -                "10000000" +
>> +                "00000000" +
>> +                "10000001" +
>>                 "01011111"
>>                 , toAsciiString( encoded ) ) ;
>>
>> @@ -534,8 +534,8 @@
>>         assertEquals( BinaryCodec.toAsciiString( data ) +
>>                 "10000000" +
>>                 "10000001" +
>> -                "00000001" +
>> -                "10000000" +
>> +                "00000000" +
>> +                "10000001" +
>>                 "01011111"
>>                 , toAsciiString( encoded ) ) ;
>>
>> @@ -547,8 +547,8 @@
>>         assertEquals( BinaryCodec.toAsciiString( data ) +
>>                 "11111111" +
>>                 "10000001" +
>> -                "00000001" +
>> -                "10000000" +
>> +                "00000000" +
>> +                "10000001" +
>>                 "01011111"
>>                 , toAsciiString( encoded ) ) ;
>>
>> @@ -561,8 +561,8 @@
>>                 "00000000" +
>>                 "00000001" +
>>                 "10000010" +
>> -                "00000001" +
>> -                "10000000" +
>> +                "00000000" +
>> +                "10000001" +
>>                 "01011111"
>>                 , toAsciiString( encoded ) ) ;
>>     }
>> @@ -611,7 +611,7 @@
>>         t = new Tuple( 128, 0 ) ;
>>         t.setTag( bites, 3 ) ;
>>         binary = toAsciiString( bites ) ;
>> -        assertEquals( "00000001" + "10000000" + "01111111", binary ) ;
>> +        assertEquals( "00000000" + "10000001" + "01111111", binary ) ;
>>
>>         bites = ByteBuffer.allocate( 3 ) ;
>>         t = new Tuple( BIT_13 - 1, 0 ) ;
>> @@ -625,9 +625,9 @@
>>         t = new Tuple( BIT_13, 0 ) ;
>>         t.setTag( bites, 4 ) ;
>>         binary = toAsciiString( bites ) ;
>> -        assertEquals( "00000001" +
>> +        assertEquals( "00000000" +
>>                       "10000000" +
>> -                      "10000000" + +                      "10000001" 
>> +                       "01111111", binary ) ;
>>
>>         bites = ByteBuffer.allocate( 4 ) ;
>> @@ -652,10 +652,10 @@
>>         t = new Tuple( BIT_20, 0 ) ;
>>         t.setTag( bites, 5 ) ;
>>         binary = toAsciiString( bites ) ;
>> -        assertEquals( "00000001" +
>> +        assertEquals( "00000000" +
>>                       "10000000" +
>>                       "10000000" +
>> -                      "10000000" + +                      "10000001" 
>> +                       "01111111", binary ) ;
>>
>>         bites = ByteBuffer.allocate( 5 ) ;
>> @@ -729,7 +729,7 @@
>>         t = new Tuple( 128, 0 ) ;
>>         t.setTag( bites, 3 ) ;
>>         binary = toAsciiString( bites ) ;
>> -        assertEquals( "00000001" + "10000000" + "01111111", binary ) ;
>> +        assertEquals( "00000000" + "10000001" + "01111111", binary ) ;
>>
>>         bites = ByteBuffer.allocate( 3 ) ;
>>         t = new Tuple( BIT_13 - 1, 0 ) ;
>> @@ -743,9 +743,9 @@
>>         t = new Tuple( BIT_13, 0 ) ;
>>         t.setTag( bites, 4 ) ;
>>         binary = toAsciiString( bites ) ;
>> -        assertEquals( "00000001" +
>> +        assertEquals( "00000000" +
>>                       "10000000" +
>> -                      "10000000" + +                      "10000001" 
>> +                       "01111111", binary ) ;
>>
>>         bites = ByteBuffer.allocate( 4 ) ;
>> @@ -770,10 +770,10 @@
>>         t = new Tuple( BIT_20, 0 ) ;
>>         t.setTag( bites, 5 ) ;
>>         binary = toAsciiString( bites ) ;
>> -        assertEquals( "00000001" +
>> +        assertEquals( "00000000" +
>>                       "10000000" +
>>                       "10000000" +
>> -                      "10000000" + +                      "10000001" 
>> +                       "01111111", binary ) ;
>>
>>         bites = ByteBuffer.allocate( 5 ) ;
>>
>>
>>
>>  
>>


Mime
View raw message