Ar an seachtú lá déag de mí Lúnasa, scríobh Aidan Kehoe:
Ar an seachtú lá déag de mí Lúnasa, scríobh Stephen J. Turnbull:
> Yes. I couldn't remember whether `make-temp-name' was the sanctioned
> (robust and secure) way to do this, so I punted.
It is, AIUI. Though the Gnus people do check with #’file-already-exists
after they call it--see
http://tinyurl.com/2hm355 in Google code search.
I still think this, but now I investigate some more I learn that GNU now
have a #’make-temp-file, which does what a Unix mkstemp call does. For the
sake of compatibility we should merge that, and for the sake of paranoia we
should use it, here and elsewhere--it’s a better-designed API than
#’make-temp-name or mktemp(3).
> > (2) The actual unexpected errors: "Unsupported
Unicode code point"...
>
> If Aidan wants to work on this, he probably knows more about it than I
> do offhand. If he doesn't, I'll get to it.
The issue here is that I just changed the Lisp reader to error when it
sees a Unicode code point that the current XEmacs doesn’t support.
Portable code needs to be able to handle this case, because that’s what
GNU does too; and we support all valid UCS code points right now in Mule
XEmacs, so we don’t error illegitimately there. However, it happens *all
the time* under non-Mule XEmacs, which is kind of the point of non-Mule
XEmacs.
Okay, I’ve got a solution; call #’read at runtime on escaped versions of
the relevant strings. The tests aren’t executed on non-Mule, so the error
won’t happen, but the Unicode escape functionality will still be tested
in passing (while testing the coding-cookie-in-compiled-files
functionality). I’ll send a patch later today.
Heh, not quite “later today” but the patch is a bit more comprehensive.
> > (3) The fact that the summary does not report the
unexpected errors.
>
> This may be hard to do well. I'll take a look at it.
>
> > Unexpected error (error "Can't activate input method
> > `german-postfix'") while executing interpreted code.
>
> This is due to the fact that the Makefile suppresses adding packages
> to the load-path.
No, it was due to Mike Sperber changing the load path for packages and not
telling anyone.
> Probably the best thing to do is have a
package-dependent-tests.el,
> which is run as a separate command.
os-tests.el calls #’Skip-Test-Unless in a similar context (when components
required for a test are not available) so something similar might be the
least intrusive approach; I’m not certain what the right check would be,
though-- (assq 'leim packages-package-list) ? But leim doesn’t provide all
the input methods--egg and skk are exceptions, at least.
I’ve decided to use Skip-Test-Unless, with the not-particularly-robust
assumption that if input-method-alist is greater than one in length (the
first entry coming from canna, the #’register-input-method call for which is
dumped), then all the package input methods are available. This reveals that
the following input methods used in language environments are not available
in packages:
latin-8-prefix latin-10-prefix latin-5-prefix latin-4-prefix latin-4-prefix
latin-4-prefix latin-4-prefix latin-4-prefix belarusian bulgarian-bds
Using Known-Bug-Expect-Failure calls to say that we know this already is
awkward, and the actual problem itself can be fixed with less work than that
would involve. Hopefully I’ll get to that soon.
I have added a Known-Bug-Expect-Failure for a separate bug, and documented
what provokes it and what needs to be done to eliminate it.
APPROVE COMMIT
NOTE: This patch has been committed.
tests/ChangeLog addition:
2007-08-21 Aidan Kehoe <kehoea(a)parhasard.net>
* automated/mule-tests.el (test-chars):
There are now 2^21 possible characters under Mule, not 2^19.
* automated/mule-tests.el (test-file-name):
Call #'make-temp-name instead of writing the file needed for the
rever-buffer test to the user's home directory. Wrap the following
#'save-buffer in a Silence-Message call.
* automated/mule-tests.el:
In the language environment tests, check that a given input method
exists before trying to activate it. If there are installed input
methods, assert that every input method specified in any language
environment exists. If the native-coding-system of the language
environment is specified as a function, don't assert that it is a
coding system.
In the byte-compiler coding cookie tests, call #'read at runtime
on strings with non-Latin-1 Unicode escapes. This avoids errors
when make check is run under a non-Mule XEmacs, where unavailable
Unicode escapes throw an error in the Lisp reader.
Add a new Known-Bug-Expect-Failure call for a bug that occurred to
me yesterday; if non-Latin-1 is generated in an eval-when-compile
clause, that non-ASCII may be trashed and the compiled code
incorrectly saved as no-conversion if no other non-Latin-1 exists
in the input buffer. Add a comment giving more details of the bug
and how one might fix it.
lisp/ChangeLog addition:
2007-08-21 Aidan Kehoe <kehoea(a)parhasard.net>
* mule/vietnamese.el ("Vietnamese"): Remove vscii and viqr from
the coding-system slot of the language environment for Vietnamese;
they're no longer available as coding systems in XEmacs, and they
were never widely used.
XEmacs Trunk source patch:
Diff command: cvs -q diff -u
Files affected: lisp/mule/vietnamese.el
===================================================================
RCS tests/automated/mule-tests.el
===================================================================
RCS
Index: tests/automated/mule-tests.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/tests/automated/mule-tests.el,v
retrieving revision 1.19
diff -u -r1.19 mule-tests.el
--- tests/automated/mule-tests.el 2007/06/22 16:37:41 1.19
+++ tests/automated/mule-tests.el 2007/08/21 12:34:15
@@ -42,12 +42,12 @@
(defun test-chars (&optional for-test-harness)
"Insert all characters in a buffer, to see if XEmacs will crash.
This is done by creating a string with all the legal characters
-in [0, 2^19) range, inserting it into the buffer, and checking
+in [0, 2^21) range, inserting it into the buffer, and checking
that the buffer's contents are equivalent to the string.
If FOR-TEST-HARNESS is specified, a temporary buffer is used, and
the Assert macro checks for correctness."
- (let ((max (expt 2 (if (featurep 'mule) 19 8)))
+ (let ((max (expt 2 (if (featurep 'mule) 21 8)))
(list nil)
(i 0))
(while (< i max)
@@ -118,14 +118,27 @@
;; Fixed 2007-06-22 <18043.2793.611745.734215(a)parhasard.net>.
;;----------------------------------------------------------------
-;; #### need a temp file name but this will do for now
-(let ((test-file-name (expand-file-name "~/test-revert-buffer-resets-modiff"))
+(let ((test-file-name
+ ;; The Gnus people, when they call #'make-temp-name, then loop,
+ ;; checking if the corresponding file exists. Our #'make-temp-name
+ ;; already does this loop, and the Gnus approach doesn't bring
+ ;; anything; there remains a race condition if you can predict the
+ ;; path name. The path name in question depends on the process ID and
+ ;; a (weak) PRNG seeded with the seconds to the power of the
+ ;; milliseconds of some instant close to the startup time of this
+ ;; XEmacs; without being able to read the address space of this
+ ;; XEmacs, or monitor what stat() calls it does, it is not predictable.
+ ;;
+ ;; The really kosher way to do this is to merge GNU's make-temp-file
+ ;; and use that. It basically has the functionality of the Unix
+ ;; mkstemp.
+ (make-temp-name (expand-file-name "tXfXsKc" (temp-directory))))
revert-buffer-function
kill-buffer-hook) ; paranoia
(find-file test-file-name)
(erase-buffer)
(insert "a string\n")
- (save-buffer 0)
+ (Silence-Message (save-buffer 0))
(insert "more text\n")
(revert-buffer t t)
;; Just "find-file" with autodetect coding didn't fail for me, but it
does
@@ -491,7 +504,7 @@
;; The sort is to make the algorithm of charsets-in-region
;; irrelevant.
(sort (charsets-in-region (point-min) (point-max))
- 'string<)
+ #'string<)
'(arabic-1-column arabic-2-column ascii chinese-big5-1
chinese-gb2312 cyrillic-iso8859-5 ethiopic greek-iso8859-7
hebrew-iso8859-8 japanese-jisx0208 japanese-jisx0212
@@ -500,26 +513,54 @@
(Assert (equal
(sort (charsets-in-string (buffer-substring (point-min)
(point-max)))
- 'string<)
+ #'string<)
'(arabic-1-column arabic-2-column ascii chinese-big5-1
chinese-gb2312 cyrillic-iso8859-5 ethiopic greek-iso8859-7
hebrew-iso8859-8 japanese-jisx0208 japanese-jisx0212
katakana-jisx0201 korean-ksc5601 latin-iso8859-1
latin-iso8859-2 thai-xtis vietnamese-viscii-lower))))
- ;; Language environments.
- (dolist (language (mapcar 'car language-info-alist))
- (set-language-environment language)
+ ;;---------------------------------------------------------------
+ ;; Language environments, and whether the specified values are sane.
+ ;;---------------------------------------------------------------
+ (loop
+ for language in (mapcar #'car language-info-alist)
+ with language-input-method = nil
+ do
+ ;; s-l-e can call #'require, which says "Loading ..."
+ (Silence-Message (set-language-environment language))
(Assert (equal language current-language-environment))
- (set-input-method (get-language-info language 'input-method))
- (Assert (equal (get-language-info language 'input-method)
- current-input-method))
+
+ (setq language-input-method
+ (get-language-info language 'input-method))
+ (when (and language-input-method
+ ;; #### Not robust, if more input methods besides canna are
+ ;; in core. The intention of this is that if *any* of the
+ ;; packages' input methods are available, we check that *all*
+ ;; of the language environments' input methods actually
+ ;; exist, which goes against the spirit of non-monolithic
+ ;; packages. But I don't have a better approach to this.
+ (> (length input-method-alist) 1))
+ (Assert (assoc language-input-method input-method-alist))
+ (Skip-Test-Unless
+ (assoc language-input-method input-method-alist)
+ "input method unavailable"
+ (format "check that IM %s can be activated" language-input-method)
+ ;; s-i-m can load files.
+ (Silence-Message
+ (set-input-method language-input-method))
+ (Assert (equal language-input-method current-input-method))))
+
(dolist (charset (get-language-info language 'charset))
(Assert (charsetp (find-charset charset))))
(dolist (coding-system (get-language-info language 'coding-system))
(Assert (coding-system-p (find-coding-system coding-system))))
- (dolist (coding-system (get-language-info language 'coding-system))
- (Assert (coding-system-p (find-coding-system coding-system)))))
+ (dolist (coding-system (get-language-info language
+ 'native-coding-system))
+ ;; We don't have the appropriate POSIX locales to test with a
+ ;; native-coding-system that is a function.
+ (unless (functionp coding-system)
+ (Assert (coding-system-p (find-coding-system coding-system))))))
(with-temp-buffer
(flet
@@ -535,9 +576,9 @@
temporary-file-name
(current-buffer)
byte-compile-result)
- (Assert (string-match "^;;;###coding system: escape-quoted"
- (buffer-substring nil nil
- byte-compile-result))))))
+ (Assert (string-match
+ "^;;;###coding system: escape-quoted"
+ (buffer-substring nil nil byte-compile-result))))))
(Assert-elc-has-no-specified-encoding ()
"Assert the current buffer has no coding cookie if compiled."
(save-excursion
@@ -552,17 +593,21 @@
byte-compile-result)
(Assert (not (string-match
";;;###coding system:"
- (buffer-substring nil nil byte-compile-result))))))))
+ (buffer-substring nil nil
+ byte-compile-result))))))))
(insert
- ;; Create a buffer creating the Unicode escapes.
- #r" (defvar testing-mule-compilation-handling
- (string ?\u371E ;; kDefinition beautiful; pretty, used
+ ;; Create a buffer with Unicode escapes. The #'read call is at
+ ;; runtime, because this file may be compiled and read in a non-Mule
+ ;; XEmacs. (But it won't be run.)
+ (read
+ "#r\" (defvar testing-mule-compilation-handling
+ (string ?\\u371E ;; kDefinition beautiful; pretty, used
;; in girl's name
- ?\U0002A6A9 ;; kDefinition (Cant.) sound of shouting
- ?\U0002A65B ;; kDefinition (Cant.) decayed teeth;
+ ?\\U0002A6A9 ;; kDefinition (Cant.) sound of shouting
+ ?\\U0002A65B ;; kDefinition (Cant.) decayed teeth;
;; tongue-tied
- ?\U00010400 ;; DESERET CAPITAL LETTER LONG I
- ?\u3263)) ;; CIRCLED HANGUL RIEUL ")
+ ?\\U00010400 ;; DESERET CAPITAL LETTER LONG I
+ ?\\u3263)) ;; CIRCLED HANGUL RIEUL \""))
(Assert-elc-is-escape-quoted)
(delete-region (point-min) (point-max))
@@ -570,55 +615,83 @@
(insert
;; This time, the buffer will contain the actual characters, because of
;; u flag to the #r.
- #ru" (defvar testing-mule-compilation-handling
- (string ?\u371E ;; kDefinition beautiful; pretty, used
+ (read
+ "#ru\" (defvar testing-mule-compilation-handling
+ (string ?\\u371E ;; kDefinition beautiful; pretty, used
;; in girl's name
- ?\U0002A6A9 ;; kDefinition (Cant.) sound of shouting
- ?\U0002A65B ;; kDefinition (Cant.) decayed teeth;
+ ?\\U0002A6A9 ;; kDefinition (Cant.) sound of shouting
+ ?\\U0002A65B ;; kDefinition (Cant.) decayed teeth;
;; tongue-tied
- ?\U00010400 ;; DESERET CAPITAL LETTER LONG I
- ?\u3263)) ;; CIRCLED HANGUL RIEUL ")
+ ?\\U00010400 ;; DESERET CAPITAL LETTER LONG I
+ ?\\u3263)) ;; CIRCLED HANGUL RIEUL \""))
(Assert-elc-is-escape-quoted)
(delete-region (point-min) (point-max))
(insert
;; Just a single four character escape.
- #r" (defvar testing-mule-compilation-handling
- (string ?\u371E)) ;; kDefinition beautiful; pretty, used")
+ (read
+ "#r\" (defvar testing-mule-compilation-handling
+ (string ?\\u371E)) ;; kDefinition beautiful; pretty, used\""))
(Assert-elc-is-escape-quoted)
(delete-region (point-min) (point-max))
(insert
;; Just a single eight character escape.
- #r" (defvar testing-mule-compilation-handling
- (string ?\U0002A65B)) ;; kDefinition (Cant.) decayed teeth;")
+ (read
+ "#r\" (defvar testing-mule-compilation-handling
+ (string ?\\U0002A65B)) ;; kDefinition (Cant.) decayed
teeth;\""))
(Assert-elc-is-escape-quoted)
(delete-region (point-min) (point-max))
(insert
- ;; A single latin-1 hex digit escape
+ ;; A single latin-1 hex digit escape No run-time #'read call,
+ ;; non-Mule can handle this too.
#r" (defvar testing-mule-compilation-handling
- (string ?\xab)) ;; LEFT-POINTING DOUBLE ANGLE QUOTATION MARK")
+ (string ?\xab)) ;; LEFT-POINTING DOUBLE ANGLE QUOTATION MARK")
(Assert-elc-has-no-specified-encoding)
(delete-region (point-min) (point-max))
(insert
- ;; A single latin-1 character
+ ;; A single latin-1 character. No run-time #'read call.
#ru" (defvar testing-mule-compilation-handling
- (string ?\u00AB)) ;; LEFT-POINTING DOUBLE ANGLE QUOTATION MARK")
+ (string ?\u00AB)) ;; LEFT-POINTING DOUBLE ANGLE QUOTATION MARK\")")
(Assert-elc-has-no-specified-encoding)
(delete-region (point-min) (point-max))
(insert
- ;; Just ASCII.
+ ;; Just ASCII. No run-time #'read call
#r" (defvar testing-mule-compilation-handling
(string ?A)) ;; LATIN CAPITAL LETTER A")
(Assert-elc-has-no-specified-encoding)
+ (delete-region (point-min) (point-max))
+
+ ;; This bug exists because the coding-cookie insertion code looks at
+ ;; the input buffer, not the output buffer.
+ ;;
+ ;; It looks at the input buffer because byte-compile-dynamic and
+ ;; byte-compile-dynamic-docstrings currently need to be
+ ;; unconditionally turned off for Mule files, since dynamic
+ ;; compilation of function bodies and docstrings fails if you can't
+ ;; call (point) and trivially get the byte offset in the file.
+ ;;
+ ;; And to unconditionally turn those two features off, you need to
+ ;; know before byte-compilation whether the byte-compilation output
+ ;; file contains non-Latin-1 characters, or perhaps to check after
+ ;; compilation and redo; but we don't do the latter.
+ ;;
+ ;; To fix this bug, we need to add Mule support to
+ ;; byte-compile-dynamic and byte-compile-dynamic-docstrings. Or drop
+ ;; support for those features entirely.
+ (insert
+ "(defvar testing-mule-compilation-handling (eval-when-compile
+ (decode-char 'ucs #x371e))) ;; kDefinition beautiful; pretty, used\"")
+ (Known-Bug-Expect-Failure
+ (Assert-elc-is-escape-quoted))
(delete-region (point-min) (point-max))))
)
Index: lisp/mule/vietnamese.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/lisp/mule/vietnamese.el,v
retrieving revision 1.9
diff -u -r1.9 vietnamese.el
--- lisp/mule/vietnamese.el 2007/07/22 22:03:50 1.9
+++ lisp/mule/vietnamese.el 2007/08/21 12:34:15
@@ -205,7 +205,7 @@
(set-language-info-alist
"Vietnamese" '((charset vietnamese-viscii-lower vietnamese-viscii-upper)
- (coding-system viscii vscii viqr)
+ (coding-system viscii)
(coding-priority viscii)
(locale "vietnamese" "vi")
;; Not available in packages.
--
On the quay of the little Black Sea port, where the rescued pair came once
more into contact with civilization, Dobrinton was bitten by a dog which was
assumed to be mad, though it may only have been indiscriminating. (Saki)
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://calypso.tux.org/cgi-bin/mailman/listinfo/xemacs-patches