fixed a big in string->utf16 and string->utf32 that I introduced in
the last commit.
This commit is contained in:
		
							parent
							
								
									0da61d51cb
								
							
						
					
					
						commit
						c0978044a5
					
				|  | @ -140,7 +140,8 @@ | |||
|      fxior fxand fxsra fxsll | ||||
|      integer->char char->integer | ||||
|      string-ref string-set! string-length | ||||
|      bytevector-u8-ref bytevector-u8-set!) | ||||
|      bytevector-u8-ref bytevector-u8-set! | ||||
|      bytevector-u16-ref) | ||||
|     (import  | ||||
|       (rename (ikarus system $strings) | ||||
|         ($string-length string-length) | ||||
|  | @ -163,7 +164,16 @@ | |||
|         ($fx>      fx>) | ||||
|         ($fx>=     fx>=) | ||||
|         ($fx<=     fx<=) | ||||
|         ($fx=      fx=)))) | ||||
|         ($fx=      fx=))) | ||||
|     (define (bytevector-u16-ref x i endianness) | ||||
|       (case endianness | ||||
|         [(little)  | ||||
|          (fxlogor (bytevector-u8-ref x i) | ||||
|                   (fxsll (bytevector-u8-ref x (fx+ i 1)) 8))] | ||||
|         [else | ||||
|          (fxlogor (bytevector-u8-ref x (fx+ i 1)) | ||||
|                   (fxsll (bytevector-u8-ref x i) 8))]))) | ||||
| 
 | ||||
| 
 | ||||
|   (define (port? x) | ||||
|     (import (only (ikarus) port?)) | ||||
|  |  | |||
|  | @ -410,7 +410,7 @@ | |||
|         [(str)  | ||||
|          (unless (string? str) | ||||
|            (die 'string->utf16 "not a string" str)) | ||||
|          ($string->utf16 str (native-endianness))] | ||||
|          ($string->utf16 str 'big)] | ||||
|         [(str endianness) | ||||
|          (unless (string? str) | ||||
|            (die 'string->utf16 "not a string" str)) | ||||
|  | @ -431,20 +431,20 @@ | |||
|            (cond | ||||
|              [(or (fx< w1 #xD800) (fx> w1 #xDFFF)) | ||||
|               (count-size bv endianness (+ i 2) len (+ n 1))] | ||||
|              [(not (fx<= #xD800 w1 #xDBFF)) ;;; die sequence | ||||
|              [(not (fx<= #xD800 w1 #xDBFF)) ;;; error sequence | ||||
|               (count-size bv endianness (+ i 2) len (+ n 1))] | ||||
|              [(<= (+ i 4) (bytevector-length bv)) | ||||
|               (let ([w2 (bytevector-u16-ref bv (+ i 2) endianness)]) | ||||
|                 (cond | ||||
|                   [(not (<= #xDC00 w2 #xDFFF))  | ||||
|                    ;;; do we skip w2 also? | ||||
|                    ;;; I won't.  Just w1 is an die | ||||
|                    ;;; I won't.  Just w1 is an error | ||||
|                    (count-size bv endianness (+ i 2) len (+ n 1))] | ||||
|                   [else  | ||||
|                    ;;; 4-byte sequence is ok | ||||
|                    (count-size bv endianness (+ i 4) len (+ n 1))]))] | ||||
|              [else  | ||||
|               ;;; die again | ||||
|               ;;; error again | ||||
|               (count-size bv endianness (+ i 2) len (+ n 1))]))])) | ||||
|     (define (fill bv endianness str i len n) | ||||
|       (cond | ||||
|  | @ -531,7 +531,7 @@ | |||
|         [(str)  | ||||
|          (unless (string? str) | ||||
|            (die who "not a string" str)) | ||||
|          ($string->utf32 str (native-endianness))] | ||||
|          ($string->utf32 str 'big)] | ||||
|         [(str endianness) | ||||
|          (unless (string? str) | ||||
|            (die who "not a string" str)) | ||||
|  |  | |||
|  | @ -1 +1 @@ | |||
| 1637 | ||||
| 1638 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 Abdulaziz Ghuloum
						Abdulaziz Ghuloum