Mercurial > hg > xemacs-beta
annotate lisp/mule/general-late.el @ 5892:053ef01b71a8
Import the #'clear-string API from GNU, use it in tls.c
src/ChangeLog addition:
2015-04-18 Aidan Kehoe <kehoea@parhasard.net>
* sequence.c (Fclear_string): New, API from GNU. Zero a string's
contents, making sure the text is not kept around even when the
string's data is reallocated because of a changed character
length.
* sequence.c (syms_of_sequence): Make it available to Lisp.
* lisp.h: Make it available to C code.
* tls.c (nss_pk11_password): Use it.
* tls.c (gnutls_pk11_password): Use it.
* tls.c (openssl_password): Use it.
tests/ChangeLog addition:
2015-04-18 Aidan Kehoe <kehoea@parhasard.net>
* automated/lisp-tests.el:
Test #'clear-string, just added. Unfortunately there's no way to
be certain from Lisp that the old password data has been erased
after realloc; it may be worth adding a test to tests.c, but
*we'll be reading memory we shouldn't be*, so that gives me pause.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Sat, 18 Apr 2015 23:00:14 +0100 |
parents | 10f179710250 |
children |
rev | line source |
---|---|
3707 | 1 ;;; general-late.el --- General Mule code that needs to be run late when |
2 ;; dumping. | |
3 ;; Copyright (C) 2006 Free Software Foundation | |
4 | |
5 ;; Author: Aidan Kehoe | |
6 | |
7 ;; This file is part of XEmacs. | |
8 | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4690
diff
changeset
|
9 ;; XEmacs is free software: you can redistribute it and/or modify it |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4690
diff
changeset
|
10 ;; under the terms of the GNU General Public License as published by the |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4690
diff
changeset
|
11 ;; Free Software Foundation, either version 3 of the License, or (at your |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4690
diff
changeset
|
12 ;; option) any later version. |
3707 | 13 |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4690
diff
changeset
|
14 ;; XEmacs is distributed in the hope that it will be useful, but WITHOUT |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4690
diff
changeset
|
15 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4690
diff
changeset
|
16 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4690
diff
changeset
|
17 ;; for more details. |
3707 | 18 |
19 ;; You should have received a copy of the GNU General Public License | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4690
diff
changeset
|
20 ;; along with XEmacs. If not, see <http://www.gnu.org/licenses/>. |
3707 | 21 |
22 ;;; Commentary: | |
23 | |
24 ;;; Code: | |
25 | |
26 ;; The variable is declared in mule-cmds.el; it's initialised here, to give | |
27 ;; the language-specific code a chance to create its coding systems. | |
28 | |
29 (setq posix-charset-to-coding-system-hash | |
4145 | 30 (loop |
31 ;; We want both normal and internal coding systems in order | |
32 ;; to pick up coding system aliases. | |
33 for coding-system in (coding-system-list 'every) | |
34 with res = (make-hash-table :test #'equal) | |
35 do | |
36 (setq coding-system (symbol-name coding-system)) | |
37 (unless (or (string-match #r"\(-unix\|-mac\|-dos\)$" coding-system) | |
38 (string-match #r"^\(internal\|mswindows\)" coding-system)) | |
39 (puthash | |
40 (replace-in-string (downcase coding-system) "[^a-z0-9]" "") | |
41 (coding-system-name (intern coding-system)) res)) | |
42 finally return res) | |
3707 | 43 |
44 ;; In a thoughtless act of cultural imperialism, move English, German | |
45 ;; and Japanese to the front of language-info-alist to make start-up a | |
46 ;; fraction faster for those languages. | |
47 language-info-alist | |
48 (cons (assoc "Japanese" language-info-alist) | |
5583
10f179710250
Deprecate #'remassoc, #'remassq, #'remrassoc, #'remrassq.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
49 (delete* "Japanese" language-info-alist :test #'equal :key #'car)) |
3707 | 50 language-info-alist |
51 (cons (assoc "German" language-info-alist) | |
5583
10f179710250
Deprecate #'remassoc, #'remassq, #'remrassoc, #'remrassq.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
52 (delete* "German" language-info-alist :test #'equal :key #'car)) |
3707 | 53 language-info-alist |
54 (cons (assoc "English" language-info-alist) | |
5583
10f179710250
Deprecate #'remassoc, #'remassq, #'remrassoc, #'remrassq.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
55 (delete* "English" language-info-alist :test #'equal :key #'car)) |
4246 | 56 |
57 ;; Make Installation-string actually reflect the environment at | |
58 ;; byte-compile time. (We can't necessarily decode it when version.el | |
59 ;; is loaded, since not all the coding systems are available then.) | |
60 Installation-string (if-boundp 'Installation-file-coding-system | |
61 (decode-coding-string | |
62 Installation-string | |
63 Installation-file-coding-system) | |
4549
68d1ca56cffa
First part of interactive checks that coding systems encode regions.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4246
diff
changeset
|
64 Installation-string) |
68d1ca56cffa
First part of interactive checks that coding systems encode regions.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4246
diff
changeset
|
65 |
4690
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4596
diff
changeset
|
66 ;; This used to be here to convince the byte-compiler to encode the |
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4596
diff
changeset
|
67 ;; output file using escape-quoted. This is no longer necessary, but |
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4596
diff
changeset
|
68 ;; keeping it here avoids doing the eval-when-compile clause below |
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4596
diff
changeset
|
69 ;; twice, which is a significant improvement. |
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4596
diff
changeset
|
70 system-type (symbol-value (intern "\u0073ystem-type"))) |
4549
68d1ca56cffa
First part of interactive checks that coding systems encode regions.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4246
diff
changeset
|
71 |
4690
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4596
diff
changeset
|
72 ;; When this file is being compiled, all the charsets have been loaded, so |
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4596
diff
changeset
|
73 ;; we can construct the query-skip-chars-arg string correctly. |
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4596
diff
changeset
|
74 (set-unicode-query-skip-chars-args |
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4596
diff
changeset
|
75 (eval-when-compile |
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4596
diff
changeset
|
76 (when-fboundp 'map-charset-chars |
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4596
diff
changeset
|
77 (loop |
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4596
diff
changeset
|
78 for charset in (charset-list) |
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4596
diff
changeset
|
79 with skip-chars-string = "" |
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4596
diff
changeset
|
80 do |
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4596
diff
changeset
|
81 (block no-ucs-mapping |
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4596
diff
changeset
|
82 (map-charset-chars |
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4596
diff
changeset
|
83 #'(lambda (begin end) |
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4596
diff
changeset
|
84 (loop |
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4596
diff
changeset
|
85 while (and begin (>= end begin)) |
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4596
diff
changeset
|
86 do |
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4596
diff
changeset
|
87 (when (= -1 (char-to-unicode begin)) |
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4596
diff
changeset
|
88 (return-from no-ucs-mapping)) |
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4596
diff
changeset
|
89 (setq begin (int-to-char (1+ begin))))) |
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4596
diff
changeset
|
90 charset) |
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4596
diff
changeset
|
91 (setq skip-chars-string |
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4596
diff
changeset
|
92 (concat skip-chars-string |
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4596
diff
changeset
|
93 (charset-skip-chars-string charset)))) |
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4596
diff
changeset
|
94 finally return skip-chars-string))) |
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4596
diff
changeset
|
95 unicode-invalid-sequence-regexp-range |
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4596
diff
changeset
|
96 (eval-when-compile |
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4596
diff
changeset
|
97 (concat (loop |
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4596
diff
changeset
|
98 for i from #x80 to #xFF |
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4596
diff
changeset
|
99 collect (aref (decode-coding-string (int-char i) |
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4596
diff
changeset
|
100 'utf-8) 0))))) |
3707 | 101 |
3767 | 102 ;; At this point in the dump, all the charsets have been loaded. Now, load |
103 ;; their Unicode mappings. | |
104 (if load-unicode-tables-at-dump-time | |
105 (let ((data-directory (expand-file-name "etc" source-directory))) | |
106 (load-unicode-tables))) | |
107 | |
4246 | 108 ;;; general-late.el ends here |