@@ -3,25 +3,25 @@ function read_double_le(b/*:RawBytes|CFBlob*/, idx/*:number*/)/*:number*/ {
33 var e = ( ( b [ idx + 7 ] & 0x7f ) << 4 ) + ( ( b [ idx + 6 ] >>> 4 ) & 0x0f ) ;
44 var m = ( b [ idx + 6 ] & 0x0f ) ;
55 for ( var i = 5 ; i >= 0 ; -- i ) m = m * 256 + b [ idx + i ] ;
6- if ( e == 0x7ff ) return m == 0 ? s * Infinity : NaN ;
6+ if ( e == 0x7ff ) return m == 0 ? ( s * Infinity ) : NaN ;
77 if ( e == 0 ) e = - 1022 ;
88 else { e -= 1023 ; m += Math . pow ( 2 , 52 ) ; }
99 return s * Math . pow ( 2 , e - 52 ) * m ;
1010}
1111
1212function write_double_le ( b /*:RawBytes|CFBlob*/ , v /*:number*/ , idx /*:number*/ ) {
13- var bs = ( ( v < 0 || 1 / v == - Infinity ) ? 1 : 0 ) << 7 , e = 0 , m = 0 ;
14- var av = bs ? - v : v ;
13+ var bs = ( ( ( ( v < 0 ) || ( 1 / v == - Infinity ) ) ? 1 : 0 ) << 7 ) , e = 0 , m = 0 ;
14+ var av = bs ? ( - v ) : v ;
1515 if ( ! isFinite ( av ) ) { e = 0x7ff ; m = isNaN ( v ) ? 0x6969 : 0 ; }
1616 else if ( av == 0 ) e = m = 0 ;
1717 else {
1818 e = Math . floor ( Math . log ( av ) / Math . LN2 ) ;
1919 m = av * Math . pow ( 2 , 52 - e ) ;
20- if ( e <= - 1023 && ( ! isFinite ( m ) || m < Math . pow ( 2 , 52 ) ) ) { e = - 1022 ; }
20+ if ( ( e <= - 1023 ) && ( ! isFinite ( m ) || ( m < Math . pow ( 2 , 52 ) ) ) ) { e = - 1022 ; }
2121 else { m -= Math . pow ( 2 , 52 ) ; e += 1023 ; }
2222 }
2323 for ( var i = 0 ; i <= 5 ; ++ i , m /= 256 ) b [ idx + i ] = m & 0xff ;
24- b [ idx + 6 ] = ( ( e & 0x0f ) << 4 ) | m & 0xf ;
24+ b [ idx + 6 ] = ( ( e & 0x0f ) << 4 ) | ( m & 0xf ) ;
2525 b [ idx + 7 ] = ( e >> 4 ) | bs ;
2626}
2727
@@ -73,8 +73,8 @@ if(typeof cptable !== 'undefined') {
7373}
7474
7575var __readUInt8 = function ( b /*:RawBytes|CFBlob*/ , idx /*:number*/ ) /*:number*/ { return b [ idx ] ; } ;
76- var __readUInt16LE = function ( b /*:RawBytes|CFBlob*/ , idx /*:number*/ ) /*:number*/ { return b [ idx + 1 ] * ( 1 << 8 ) + b [ idx ] ; } ;
77- var __readInt16LE = function ( b /*:RawBytes|CFBlob*/ , idx /*:number*/ ) /*:number*/ { var u = b [ idx + 1 ] * ( 1 << 8 ) + b [ idx ] ; return ( u < 0x8000 ) ? u : ( 0xffff - u + 1 ) * - 1 ; } ;
76+ var __readUInt16LE = function ( b /*:RawBytes|CFBlob*/ , idx /*:number*/ ) /*:number*/ { return ( b [ idx + 1 ] * ( 1 << 8 ) ) + b [ idx ] ; } ;
77+ var __readInt16LE = function ( b /*:RawBytes|CFBlob*/ , idx /*:number*/ ) /*:number*/ { var u = ( b [ idx + 1 ] * ( 1 << 8 ) ) + b [ idx ] ; return ( u < 0x8000 ) ? u : ( ( 0xffff - u + 1 ) * - 1 ) ; } ;
7878var __readUInt32LE = function ( b /*:RawBytes|CFBlob*/ , idx /*:number*/ ) /*:number*/ { return b [ idx + 3 ] * ( 1 << 24 ) + ( b [ idx + 2 ] << 16 ) + ( b [ idx + 1 ] << 8 ) + b [ idx ] ; } ;
7979var __readInt32LE = function ( b /*:RawBytes|CFBlob*/ , idx /*:number*/ ) /*:number*/ { return ( b [ idx + 3 ] << 24 ) | ( b [ idx + 2 ] << 16 ) | ( b [ idx + 1 ] << 8 ) | b [ idx ] ; } ;
8080var __readInt32BE = function ( b /*:RawBytes|CFBlob*/ , idx /*:number*/ ) /*:number*/ { return ( b [ idx ] << 24 ) | ( b [ idx + 1 ] << 16 ) | ( b [ idx + 2 ] << 8 ) | b [ idx + 3 ] ; } ;
@@ -85,7 +85,7 @@ function ReadShift(size/*:number*/, t/*:?string*/)/*:number|string*/ {
8585 case 'dbcs' :
8686 loc = this . l ;
8787 if ( has_buf && Buffer . isBuffer ( this ) ) o = this . slice ( this . l , this . l + 2 * size ) . toString ( "utf16le" ) ;
88- else for ( i = 0 ; i != size ; ++ i ) { o += String . fromCharCode ( __readUInt16LE ( this , loc ) ) ; loc += 2 ; }
88+ else for ( i = 0 ; i < size ; ++ i ) { o += String . fromCharCode ( __readUInt16LE ( this , loc ) ) ; loc += 2 ; }
8989 size *= 2 ;
9090 break ;
9191
@@ -116,7 +116,7 @@ function ReadShift(size/*:number*/, t/*:?string*/)/*:number|string*/ {
116116
117117 /* sbcs and dbcs support continue records in the SST way TODO codepages */
118118 case 'dbcs-cont' : o = "" ; loc = this . l ;
119- for ( i = 0 ; i != size ; ++ i ) {
119+ for ( i = 0 ; i < size ; ++ i ) {
120120 if ( this . lens && this . lens . indexOf ( loc ) !== - 1 ) {
121121 w = __readUInt8 ( this , loc ) ;
122122 this . l = loc + 1 ;
@@ -150,7 +150,7 @@ function ReadShift(size/*:number*/, t/*:?string*/)/*:number|string*/ {
150150 case 1 : oI = __readUInt8 ( this , this . l ) ; this . l ++ ; return oI ;
151151 case 2 : oI = ( t === 'i' ? __readInt16LE : __readUInt16LE ) ( this , this . l ) ; this . l += 2 ; return oI ;
152152 case 4 : case - 4 :
153- if ( t === 'i' || ( this [ this . l + 3 ] & 0x80 ) === 0 ) { oI = ( size > 0 ? __readInt32LE : __readInt32BE ) ( this , this . l ) ; this . l += 4 ; return oI ; }
153+ if ( t === 'i' || ( ( this [ this . l + 3 ] & 0x80 ) === 0 ) ) { oI = ( ( size > 0 ) ? __readInt32LE : __readInt32BE ) ( this , this . l ) ; this . l += 4 ; return oI ; }
154154 else { oR = __readUInt32LE ( this , this . l ) ; this . l += 4 ; } return oR ;
155155 case 8 : case - 8 :
156156 if ( t === 'f' ) {
@@ -179,20 +179,20 @@ function WriteShift(t/*:number*/, val/*:string|number*/, f/*:?string*/)/*:any*/
179179 /*:: if(typeof val !== 'string') throw new Error("unreachable"); */
180180 val = val . replace ( / [ ^ \x00 - \x7F ] / g, "_" ) ;
181181 /*:: if(typeof val !== 'string') throw new Error("unreachable"); */
182- for ( i = 0 ; i != val . length ; ++ i ) this [ this . l + i ] = val . charCodeAt ( i ) & 0xFF ;
182+ for ( i = 0 ; i != val . length ; ++ i ) this [ this . l + i ] = ( val . charCodeAt ( i ) & 0xFF ) ;
183183 size = val . length ;
184184 } else if ( f === 'hex' ) {
185185 for ( ; i < t ; ++ i ) {
186186 /*:: if(typeof val !== "string") throw new Error("unreachable"); */
187- this [ this . l ++ ] = parseInt ( val . slice ( 2 * i , 2 * i + 2 ) , 16 ) || 0 ;
187+ this [ this . l ++ ] = ( parseInt ( val . slice ( 2 * i , 2 * i + 2 ) , 16 ) || 0 ) ;
188188 } return this ;
189189 } else if ( f === 'utf16le' ) {
190190 /*:: if(typeof val !== "string") throw new Error("unreachable"); */
191191 var end /*:number*/ = this . l + t ;
192192 for ( i = 0 ; i < Math . min ( val . length , t ) ; ++ i ) {
193193 var cc = val . charCodeAt ( i ) ;
194- this [ this . l ++ ] = cc & 0xff ;
195- this [ this . l ++ ] = cc >> 8 ;
194+ this [ this . l ++ ] = ( cc & 0xff ) ;
195+ this [ this . l ++ ] = ( cc >> 8 ) ;
196196 }
197197 while ( this . l < end ) this [ this . l ++ ] = 0 ;
198198 return this ;
0 commit comments