diff options
| author | Paul Eggert | 2014-09-10 17:29:54 -0700 |
|---|---|---|
| committer | Paul Eggert | 2014-09-10 17:29:54 -0700 |
| commit | fe252976a18bf7bb66009fa80c1c6f02b124404f (patch) | |
| tree | 3b89cb45b9b220b2c16d777f961b804e9a28b26a /src | |
| parent | c8b22035d67421b02c69a20d0809b732ab4c7f01 (diff) | |
| download | emacs-fe252976a18bf7bb66009fa80c1c6f02b124404f.tar.gz emacs-fe252976a18bf7bb66009fa80c1c6f02b124404f.zip | |
* charset.c (Fget_unused_iso_final_char): Fix subscript error.
Use check_iso_charset_parameter instead of doing the checks by hand.
(check_iso_charset_parameter): Move up. Check parameters a bit
more carefully, and return true for 96-char sets. All callers changed.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 7 | ||||
| -rw-r--r-- | src/charset.c | 77 |
2 files changed, 44 insertions, 40 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 50f5fb8ca1e..f6cf9938573 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2014-09-10 Paul Eggert <eggert@penguin.cs.ucla.edu> | ||
| 2 | |||
| 3 | * charset.c (Fget_unused_iso_final_char): Fix subscript error. | ||
| 4 | Use check_iso_charset_parameter instead of doing the checks by hand. | ||
| 5 | (check_iso_charset_parameter): Move up. Check parameters a bit | ||
| 6 | more carefully, and return true for 96-char sets. All callers changed. | ||
| 7 | |||
| 1 | 2014-09-10 Paul Eggert <eggert@cs.ucla.edu> | 8 | 2014-09-10 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 9 | ||
| 3 | Simplify lisp.h by removing the __COUNTER__ business. | 10 | Simplify lisp.h by removing the __COUNTER__ business. |
diff --git a/src/charset.c b/src/charset.c index 6964208137b..501075621cd 100644 --- a/src/charset.c +++ b/src/charset.c | |||
| @@ -1400,6 +1400,32 @@ Optional third argument DEUNIFY, if non-nil, means to de-unify CHARSET. */) | |||
| 1400 | return Qnil; | 1400 | return Qnil; |
| 1401 | } | 1401 | } |
| 1402 | 1402 | ||
| 1403 | /* Check that DIMENSION, CHARS, and FINAL_CHAR specify a valid ISO charset. | ||
| 1404 | Return true if it's a 96-character set, false if 94. */ | ||
| 1405 | |||
| 1406 | static bool | ||
| 1407 | check_iso_charset_parameter (Lisp_Object dimension, Lisp_Object chars, | ||
| 1408 | Lisp_Object final_char) | ||
| 1409 | { | ||
| 1410 | CHECK_NUMBER (dimension); | ||
| 1411 | CHECK_NUMBER (chars); | ||
| 1412 | CHECK_CHARACTER (final_char); | ||
| 1413 | |||
| 1414 | if (! (1 <= XINT (dimension) && XINT (dimension) <= 3)) | ||
| 1415 | error ("Invalid DIMENSION %"pI"d, it should be 1, 2, or 3", | ||
| 1416 | XINT (dimension)); | ||
| 1417 | |||
| 1418 | bool chars_flag = XINT (chars) == 96; | ||
| 1419 | if (! (chars_flag || XINT (chars) == 94)) | ||
| 1420 | error ("Invalid CHARS %"pI"d, it should be 94 or 96", XINT (chars)); | ||
| 1421 | |||
| 1422 | int final_ch = XFASTINT (final_char); | ||
| 1423 | if (! ('0' <= final_ch && final_ch <= '~')) | ||
| 1424 | error ("Invalid FINAL-CHAR '%c', it should be '0'..'~'", final_ch); | ||
| 1425 | |||
| 1426 | return chars_flag; | ||
| 1427 | } | ||
| 1428 | |||
| 1403 | DEFUN ("get-unused-iso-final-char", Fget_unused_iso_final_char, | 1429 | DEFUN ("get-unused-iso-final-char", Fget_unused_iso_final_char, |
| 1404 | Sget_unused_iso_final_char, 2, 2, 0, | 1430 | Sget_unused_iso_final_char, 2, 2, 0, |
| 1405 | doc: /* | 1431 | doc: /* |
| @@ -1412,35 +1438,12 @@ If there's no unused final char for the specified kind of charset, | |||
| 1412 | return nil. */) | 1438 | return nil. */) |
| 1413 | (Lisp_Object dimension, Lisp_Object chars) | 1439 | (Lisp_Object dimension, Lisp_Object chars) |
| 1414 | { | 1440 | { |
| 1415 | int final_char; | 1441 | bool chars_flag = check_iso_charset_parameter (dimension, chars, |
| 1416 | 1442 | make_number ('0')); | |
| 1417 | CHECK_NUMBER (dimension); | 1443 | for (int final_char = '0'; final_char <= '?'; final_char++) |
| 1418 | CHECK_NUMBER (chars); | 1444 | if (ISO_CHARSET_TABLE (XINT (dimension), chars_flag, final_char) < 0) |
| 1419 | if (XINT (dimension) != 1 && XINT (dimension) != 2 && XINT (dimension) != 3) | 1445 | return make_number (final_char); |
| 1420 | args_out_of_range_3 (dimension, make_number (1), make_number (3)); | 1446 | return Qnil; |
| 1421 | if (XINT (chars) != 94 && XINT (chars) != 96) | ||
| 1422 | args_out_of_range_3 (chars, make_number (94), make_number (96)); | ||
| 1423 | for (final_char = '0'; final_char <= '?'; final_char++) | ||
| 1424 | if (ISO_CHARSET_TABLE (XINT (dimension), XINT (chars), final_char) < 0) | ||
| 1425 | break; | ||
| 1426 | return (final_char <= '?' ? make_number (final_char) : Qnil); | ||
| 1427 | } | ||
| 1428 | |||
| 1429 | static void | ||
| 1430 | check_iso_charset_parameter (Lisp_Object dimension, Lisp_Object chars, Lisp_Object final_char) | ||
| 1431 | { | ||
| 1432 | CHECK_NATNUM (dimension); | ||
| 1433 | CHECK_NATNUM (chars); | ||
| 1434 | CHECK_CHARACTER (final_char); | ||
| 1435 | |||
| 1436 | if (XINT (dimension) > 3) | ||
| 1437 | error ("Invalid DIMENSION %"pI"d, it should be 1, 2, or 3", | ||
| 1438 | XINT (dimension)); | ||
| 1439 | if (XINT (chars) != 94 && XINT (chars) != 96) | ||
| 1440 | error ("Invalid CHARS %"pI"d, it should be 94 or 96", XINT (chars)); | ||
| 1441 | if (XINT (final_char) < '0' || XINT (final_char) > '~') | ||
| 1442 | error ("Invalid FINAL-CHAR %c, it should be `0'..`~'", | ||
| 1443 | (int)XINT (final_char)); | ||
| 1444 | } | 1447 | } |
| 1445 | 1448 | ||
| 1446 | 1449 | ||
| @@ -1454,12 +1457,10 @@ if CHARSET is designated instead. */) | |||
| 1454 | (Lisp_Object dimension, Lisp_Object chars, Lisp_Object final_char, Lisp_Object charset) | 1457 | (Lisp_Object dimension, Lisp_Object chars, Lisp_Object final_char, Lisp_Object charset) |
| 1455 | { | 1458 | { |
| 1456 | int id; | 1459 | int id; |
| 1457 | bool chars_flag; | ||
| 1458 | 1460 | ||
| 1459 | CHECK_CHARSET_GET_ID (charset, id); | 1461 | CHECK_CHARSET_GET_ID (charset, id); |
| 1460 | check_iso_charset_parameter (dimension, chars, final_char); | 1462 | bool chars_flag = check_iso_charset_parameter (dimension, chars, final_char); |
| 1461 | chars_flag = XINT (chars) == 96; | 1463 | ISO_CHARSET_TABLE (XINT (dimension), chars_flag, XFASTINT (final_char)) = id; |
| 1462 | ISO_CHARSET_TABLE (XINT (dimension), chars_flag, XINT (final_char)) = id; | ||
| 1463 | return Qnil; | 1464 | return Qnil; |
| 1464 | } | 1465 | } |
| 1465 | 1466 | ||
| @@ -2113,13 +2114,9 @@ See the documentation of the function `charset-info' for the meanings of | |||
| 2113 | DIMENSION, CHARS, and FINAL-CHAR. */) | 2114 | DIMENSION, CHARS, and FINAL-CHAR. */) |
| 2114 | (Lisp_Object dimension, Lisp_Object chars, Lisp_Object final_char) | 2115 | (Lisp_Object dimension, Lisp_Object chars, Lisp_Object final_char) |
| 2115 | { | 2116 | { |
| 2116 | int id; | 2117 | bool chars_flag = check_iso_charset_parameter (dimension, chars, final_char); |
| 2117 | bool chars_flag; | 2118 | int id = ISO_CHARSET_TABLE (XINT (dimension), chars_flag, |
| 2118 | 2119 | XFASTINT (final_char)); | |
| 2119 | check_iso_charset_parameter (dimension, chars, final_char); | ||
| 2120 | chars_flag = XFASTINT (chars) == 96; | ||
| 2121 | id = ISO_CHARSET_TABLE (XFASTINT (dimension), chars_flag, | ||
| 2122 | XFASTINT (final_char)); | ||
| 2123 | return (id >= 0 ? CHARSET_NAME (CHARSET_FROM_ID (id)) : Qnil); | 2120 | return (id >= 0 ? CHARSET_NAME (CHARSET_FROM_ID (id)) : Qnil); |
| 2124 | } | 2121 | } |
| 2125 | 2122 | ||