|
From: Sam S. <sd...@gn...> - 2005-05-27 19:01:43
|
Bruno,
we have a problem with get-charset-range:
on mingw during bootstrap people have been complaining of the error:
(ERROR_INVALID_HANDLE): The handle is invalid.
during load of subtypep.lisp.
this has been traced down to iconv_range().
this patch fixes the problem:
--- stream.d 19 May 2005 19:05:33 -0400 1.519
+++ stream.d 27 May 2005 14:26:56 -0400
@@ -4335,7 +4335,11 @@
var size_t res = iconv(cd,&inptr,&insize,&outptr,&outsize);
if (res == (size_t)(-1)) {
var int my_errno = OS_errno;
- if (my_errno == EILSEQ) { /* invalid input? */
+ if (my_errno == EILSEQ
+ #ifdef WIN32_NATIVE
+ || my_errno == ERROR_INVALID_HANDLE
+ #endif
+ ) { /* invalid input? */
end_system_call();
# ch not encodable -> finish the interval
if (have_i1_i2) {
(apparently that's what is set by iconv() on failure: I got it for
MULELAO-1 encoding, start=0=i1, i=161)
OTOH, the whole notion of precomputing these ranges is suspect.
the only way they are used is when you call (SUBTYPEP ENC1 ENC2) which
is an extremely rare operation anyway.
there appears to be no real reason to pre-compute the cache during
bootstrap:
con:
1. longer bootstrap
2. larger memory image (16K - 1%)
3. risk of error for no gain: most people do not need this cache.
thus I propose the additional patch:
--- subtypep.lisp 09 Feb 2005 09:39:53 -0500 1.12
+++ subtypep.lisp 27 May 2005 14:50:13 -0400
@@ -1170,9 +1170,6 @@
type)))
;; Conversion of an encoding to a list of intervals.
#+UNICODE
-(let ((table (make-hash-table :key-type '(or string symbol) :value-type 'simple-string
- :test 'stablehash-equal :warn-if-needs-rehash-after-gc t)))
- ;; cache: charset name -> list of intervals #(start1 end1 ... startm endm)
#| ; Now in C and much more efficient.
(defun charset-range (encoding start end)
(setq start (char-code start))
@@ -1192,19 +1189,16 @@
;; Return the definition range of a character set. If necessary, compute it
;; and store it in the cache.
(defun get-charset-range (charset &optional maxintervals)
+ (let ((table #.(make-hash-table :key-type '(or string symbol)
+ :value-type 'simple-string
+ :test 'stablehash-equal
+ :warn-if-needs-rehash-after-gc t)))
+ ;; cache: charset name -> list of intervals #(start1 end1 ... startm endm)
(or (gethash charset table)
(setf (gethash charset table)
(charset-range (make-encoding :charset charset)
(code-char 0) (code-char (1- char-code-limit))
- maxintervals))))
- ;; Fill the cache, but cache only the results with small lists of intervals.
- ;; Some iconv based encodings have large lists of intervals (up to 5844
- ;; intervals for ISO-2022-JP-2) which are rarely used and not worth caching.
- (do-external-symbols (sym (find-package "CHARSET"))
- (let* ((charset (encoding-charset (symbol-value sym)))
- (computed-range (get-charset-range charset 100))
- (intervals (/ (length computed-range) 2)))
- (when (>= intervals 100) (remhash charset table)))))
+ maxintervals)))))
#| ;; Older code for a special case.
;; Test whether all characters encodable in encoding1 are also encodable in
;; encoding2.
--
Sam Steingold (http://www.podval.org/~sds) running w2k
<http://pmw.org.il/> <http://www.iris.org.il> <http://www.camera.org>
<http://www.jihadwatch.org/> <http://www.palestinefacts.org/>
A slave dreams not of Freedom, but of owning his own slaves.
|