Mercurial > hg > xemacs-beta
changeset 5863:15041705c196
Provide `char-code-limit', implement the GNU equivalent in terms of it.
src/ChangeLog addition:
2015-03-15 Aidan Kehoe <kehoea@parhasard.net>
* text.h: Make CHAR_CODE_LIMIT available as a #define.
* text.h (valid_ichar_p): Use it.
* text.c: Make a fixnum Vchar_code_limit available here.
* text.c (non_ascii_valid_ichar_p): Use CHAR_CODE_LIMIT.
* text.c (vars_of_text): Make `char-code-limit' available to
Lisp.
tests/ChangeLog addition:
2015-03-15 Aidan Kehoe <kehoea@parhasard.net>
* automated/mule-tests.el (test-chars):
Use char-code-limit explicitly here, instead of hardcoding the
corresponding values.
lisp/ChangeLog addition:
2015-03-16 Aidan Kehoe <kehoea@parhasard.net>
* obsolete.el (max-char):
Make this available for compatiblity with GNU, implement it in
terms of char-code-limit.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Mon, 16 Mar 2015 00:09:46 +0000 |
parents | 5b799fa6d75e |
children | 5ea790936de9 |
files | lisp/ChangeLog lisp/obsolete.el man/ChangeLog man/lispref/strings.texi src/ChangeLog src/text.c src/text.h tests/ChangeLog tests/automated/mule-tests.el |
diffstat | 9 files changed, 66 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/ChangeLog Sun Mar 15 21:13:23 2015 +0000 +++ b/lisp/ChangeLog Mon Mar 16 00:09:46 2015 +0000 @@ -1,3 +1,9 @@ +2015-03-16 Aidan Kehoe <kehoea@parhasard.net> + + * obsolete.el (max-char): + Make this available for compatiblity with GNU, implement it in + terms of char-code-limit. + 2015-03-15 Aidan Kehoe <kehoea@parhasard.net> * tty-init.el (make-frame-after-init-entry-point):
--- a/lisp/obsolete.el Sun Mar 15 21:13:23 2015 +0000 +++ b/lisp/obsolete.el Mon Mar 16 00:09:46 2015 +0000 @@ -485,5 +485,15 @@ (make-obsolete 'remrassoc "use delete* with :test #'equal, :key #'cdr") (make-obsolete 'remrassq "use delete* with :test #'eq, :key #'cdr") +(defun max-char () + "Return a fixnum one less than `char-code-limit'. + +In contrast with GNU Emacs, this is not necessarily a valid character, but it +is an inclusive upper bound on the possible values returned by `char-int'." + (1- char-code-limit)) +(make-compatible + 'max-char + "consider `char-code-limit', which gives an exclusive upper bound") + (provide 'obsolete) ;;; obsolete.el ends here
--- a/man/ChangeLog Sun Mar 15 21:13:23 2015 +0000 +++ b/man/ChangeLog Mon Mar 16 00:09:46 2015 +0000 @@ -1,3 +1,8 @@ +2015-03-15 Aidan Kehoe <kehoea@parhasard.net> + + * lispref/strings.texi (Character Codes): + Document `char-code-limit' here too. + 2015-03-14 Aidan Kehoe <kehoea@parhasard.net> * lispref/help.texi (Help Functions):
--- a/man/lispref/strings.texi Sun Mar 15 21:13:23 2015 +0000 +++ b/man/lispref/strings.texi Mon Mar 16 00:09:46 2015 +0000 @@ -330,6 +330,17 @@ @code{nil} is returned. @end defun +@defvar char-code-limit +This is a constant integer describing an exclusive upper bound on the +results return by @code{char-int} and that set of integers (fixnums) for +which @code{int-char} will give non-nil. Without @sc{mule} +(internationalization) support this will be @code{#x100}, as described +under @code{char-int}, but with @sc{mule} support the range of values is +much bigger, at least 21 bits' worth. If an integer is less than +@var{char-code-limit}, it may still not have an associated character, it +is still necessary to check with the next function, @code{char-int-p}. +@end defvar + @defun char-int-p object This function returns @code{t} if @var{object} is an integer that can be converted into a character.
--- a/src/ChangeLog Sun Mar 15 21:13:23 2015 +0000 +++ b/src/ChangeLog Mon Mar 16 00:09:46 2015 +0000 @@ -1,3 +1,12 @@ +2015-03-15 Aidan Kehoe <kehoea@parhasard.net> + + * text.h: Make CHAR_CODE_LIMIT available as a #define. + * text.h (valid_ichar_p): Use it. + * text.c: Make a fixnum Vchar_code_limit available here. + * text.c (non_ascii_valid_ichar_p): Use CHAR_CODE_LIMIT. + * text.c (vars_of_text): Make `char-code-limit' available to + Lisp. + 2015-03-14 Aidan Kehoe <kehoea@parhasard.net> * general-slots.h (Qno_character_typed): New error symbol.
--- a/src/text.c Sun Mar 15 21:13:23 2015 +0000 +++ b/src/text.c Mon Mar 16 00:09:46 2015 +0000 @@ -1322,6 +1322,7 @@ Lisp_Object QSin_char_byte_conversion; Lisp_Object QSin_internal_external_conversion; +Fixnum Vchar_code_limit; /************************************************************************/ /* qxestr***() functions */ @@ -4677,7 +4678,7 @@ int f1, f2, f3; /* Must have only lowest 21 bits set */ - if (ch & ~0x1FFFFF) + if (ch & ~(CHAR_CODE_LIMIT - 1)) return 0; f1 = ichar_field1 (ch); @@ -5143,6 +5144,14 @@ build_defer_string ("(in internal-external conversion)"); staticpro (&QSin_internal_external_conversion); + DEFVAR_CONST_INT ("char-code-limit", &Vchar_code_limit /* +Exclusive upper bound on the values return by `char-int'. + +Note that not every fixnum with a value below `char-code-limit' has an +associated character; check with `char-int-p' if necessary. +*/); + Vchar_code_limit = CHAR_CODE_LIMIT; + #ifdef ENABLE_COMPOSITE_CHARS /* #### not dumped properly */ composite_char_row_next = 32;
--- a/src/text.h Sun Mar 15 21:13:23 2015 +0000 +++ b/src/text.h Mon Mar 16 00:09:46 2015 +0000 @@ -121,6 +121,8 @@ #define rep_bytes_by_first_byte(fb) 1 #define byte_ascii_p(byte) 1 #define MAX_ICHAR_LEN 1 +/* Exclusive upper bound on character codes. */ +#define CHAR_CODE_LIMIT 0x100 #else /* MULE */ @@ -212,12 +214,12 @@ #define ichar_ascii_p(c) (!ichar_multibyte_p (c)) -/* Maximum number of bytes per Emacs character when represented as text, in - any format. - */ - +/* Maximum number of bytes per Ichar when represented as text. */ #define MAX_ICHAR_LEN 4 +/* Exclusive upper bound on char codes. */ +#define CHAR_CODE_LIMIT 0x200000 + #endif /* not MULE */ #ifdef MULE @@ -239,7 +241,7 @@ /* This works when CH is negative, and correctly returns non-zero only when CH is in the range [0, 255], inclusive. */ -#define valid_ichar_p(ch) (! (ch & ~0xFF)) +#define valid_ichar_p(ch) (! (ch & ~(CHAR_CODE_LIMIT - 1))) #endif /* not MULE */
--- a/tests/ChangeLog Sun Mar 15 21:13:23 2015 +0000 +++ b/tests/ChangeLog Mon Mar 16 00:09:46 2015 +0000 @@ -1,3 +1,9 @@ +2015-03-15 Aidan Kehoe <kehoea@parhasard.net> + + * automated/mule-tests.el (test-chars): + Use char-code-limit explicitly here, instead of hardcoding the + corresponding values. + 2015-03-04 Aidan Kehoe <kehoea@parhasard.net> * automated/lisp-tests.el:
--- a/tests/automated/mule-tests.el Sun Mar 15 21:13:23 2015 +0000 +++ b/tests/automated/mule-tests.el Mon Mar 16 00:09:46 2015 +0000 @@ -46,10 +46,9 @@ 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) 21 8))) - (list nil) + (let ((list nil) (i 0)) - (while (< i max) + (while (< i char-code-limit) (and (not for-test-harness) (zerop (% i 1000)) (message "%d" i))