Changeset 12902
- Timestamp:
- 08/28/10 11:09:13 (13 years ago)
- Location:
- trunk/abcl
- Files:
-
- 3 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/abcl.asd
r12899 r12902 46 46 (:file "math-tests") 47 47 (:file "misc-tests") 48 (:file "latin1-tests") 48 49 (:file "bugs" :depends-on ("file-system-tests")) 49 50 (:file "pathname-tests"))))) -
trunk/abcl/src/org/armedbear/lisp/util/DecodingReader.java
r12759 r12902 46 46 import java.nio.charset.CharsetEncoder; 47 47 import java.nio.charset.CoderResult; 48 import java.nio.charset.CodingErrorAction; 48 49 49 50 import org.armedbear.lisp.Debug; … … 80 81 this.stream = new PushbackInputStream(stream, size); 81 82 this.cd = cs.newDecoder(); 83 this.cd.onUnmappableCharacter(CodingErrorAction.REPLACE); 84 this.cd.onMalformedInput(CodingErrorAction.REPLACE); 82 85 this.ce = cs.newEncoder(); 83 86 bbuf = ByteBuffer.allocate(size); … … 90 93 public final void setCharset(Charset cs) { 91 94 this.cd = cs.newDecoder(); 95 this.cd.onUnmappableCharacter(CodingErrorAction.REPLACE); 96 this.cd.onMalformedInput(CodingErrorAction.REPLACE); 92 97 this.ce = cs.newEncoder(); 93 98 } … … 258 263 259 264 while (cb.remaining() > 0 && notEof) { 265 int oldRemaining = cb.remaining(); 260 266 notEof = ensureBbuf(forceRead); 261 267 CoderResult r = cd.decode(bbuf, cb, ! notEof); 268 if (oldRemaining == cb.remaining() 269 && CoderResult.OVERFLOW == r) { 270 // if this happens, the decoding failed 271 // but the bufs didn't advance. Advance 272 // them manually and do manual replacing, 273 // otherwise we loop endlessly. This occurs 274 // at least when parsing latin1 files with 275 // lowercase o-umlauts in them. 276 // Note that this is at the moment copy-paste 277 // with RandomAccessCharacterFile.read() 278 cb.put('?'); 279 bbuf.get(); 280 } 262 281 forceRead = (CoderResult.UNDERFLOW == r); 263 264 if (r.isMalformed()) {265 throw new RACFMalformedInputException(bbuf.position(),266 (char)bbuf.get(bbuf.position()),267 cd.charset().name());268 } else if (r.isUnmappable()) {269 // a situation exactly like this is in DecodingReader too270 Debug.assertTrue(false);271 }272 282 } 273 283 if (cb.remaining() == len) -
trunk/abcl/src/org/armedbear/lisp/util/RandomAccessCharacterFile.java
r12513 r12902 371 371 boolean atEof = false; 372 372 while ((cbuf.remaining() > 0) && ! atEof) { 373 373 int oldRemaining = cbuf.remaining(); 374 374 atEof = ! ensureReadBbuf(decodeWasUnderflow); 375 375 CoderResult r = cdec.decode(bbuf, cbuf, atEof ); 376 if (oldRemaining == cbuf.remaining() 377 && CoderResult.OVERFLOW == r) { 378 // if this happens, the decoding failed 379 // but the bufs didn't advance. Advance 380 // them manually and do manual replacing, 381 // otherwise we loop endlessly. This occurs 382 // at least when parsing latin1 files with 383 // lowercase o-umlauts in them 384 // Note that this is at the moment copy-paste 385 // with DecodingReader.read() 386 cbuf.put('?'); 387 bbuf.get(); 388 } 376 389 decodeWasUnderflow = (CoderResult.UNDERFLOW == r); 377 if (r.isMalformed())378 // When reading encoded Unicode, we'd expect to require379 // catching MalformedInput380 throw new RACFMalformedInputException(bbuf.position(),381 (char)bbuf.get(bbuf.position()),382 cset.name());383 if (r.isUnmappable())384 // Since we're mapping TO unicode, we'd expect to be able385 // to map all characters386 Debug.assertTrue(false);387 // OVERFLOW is a normal condition:388 // it's equal to cbuf.remaining() == 0389 // ### EHU: really??? EXACTLY equal??390 390 } 391 391 if (cbuf.remaining() == len) {
Note: See TracChangeset
for help on using the changeset viewer.