diff options
| author | Philipp Stephani | 2016-04-21 14:47:46 -0700 |
|---|---|---|
| committer | Paul Eggert | 2016-04-21 19:29:40 -0700 |
| commit | 753c875714f708c0257a2d352635c5616be66fdc (patch) | |
| tree | 54b59d5405bbed3da5e2fe6238d348aadea4ee64 /src | |
| parent | a58d4e3c0f513294b9aebacb539542ad1b87be19 (diff) | |
| download | emacs-753c875714f708c0257a2d352635c5616be66fdc.tar.gz emacs-753c875714f708c0257a2d352635c5616be66fdc.zip | |
Minor cleanups for character name escapes
* src/lread.c (init_character_names): Add missing 'void'.
Remove top-level 'const'.
(read_escape): Simplify loop a bit. Remove top-level 'const'.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lread.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/src/lread.c b/src/lread.c index 9fa46a875be..dbe51bb06c8 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -2158,20 +2158,20 @@ static ptrdiff_t max_character_name_length; | |||
| 2158 | 2158 | ||
| 2159 | /* Initializes `character_names' and `max_character_name_length'. | 2159 | /* Initializes `character_names' and `max_character_name_length'. |
| 2160 | Called by `read_escape'. */ | 2160 | Called by `read_escape'. */ |
| 2161 | void init_character_names () | 2161 | void init_character_names (void) |
| 2162 | { | 2162 | { |
| 2163 | character_names = CALLN (Fmake_hash_table, | 2163 | character_names = CALLN (Fmake_hash_table, |
| 2164 | QCtest, Qequal, | 2164 | QCtest, Qequal, |
| 2165 | /* Currently around 100,000 Unicode | 2165 | /* Currently around 100,000 Unicode |
| 2166 | characters are defined. */ | 2166 | characters are defined. */ |
| 2167 | QCsize, make_natnum (100000)); | 2167 | QCsize, make_natnum (100000)); |
| 2168 | const Lisp_Object get_property = | 2168 | Lisp_Object get_property = |
| 2169 | Fsymbol_function (intern_c_string ("get-char-code-property")); | 2169 | Fsymbol_function (intern_c_string ("get-char-code-property")); |
| 2170 | ptrdiff_t length = 0; | 2170 | ptrdiff_t length = 0; |
| 2171 | for (int i = 0; i <= MAX_UNICODE_CHAR; ++i) | 2171 | for (int i = 0; i <= MAX_UNICODE_CHAR; ++i) |
| 2172 | { | 2172 | { |
| 2173 | const Lisp_Object code = make_natnum (i); | 2173 | Lisp_Object code = make_natnum (i); |
| 2174 | const Lisp_Object name = call2 (get_property, code, Qname); | 2174 | Lisp_Object name = call2 (get_property, code, Qname); |
| 2175 | if (NILP (name)) continue; | 2175 | if (NILP (name)) continue; |
| 2176 | CHECK_STRING (name); | 2176 | CHECK_STRING (name); |
| 2177 | length = max (length, SBYTES (name)); | 2177 | length = max (length, SBYTES (name)); |
| @@ -2417,25 +2417,22 @@ read_escape (Lisp_Object readcharfun, bool stringp) | |||
| 2417 | character names in e.g. multi-line strings. */ | 2417 | character names in e.g. multi-line strings. */ |
| 2418 | if (c_isspace (c)) | 2418 | if (c_isspace (c)) |
| 2419 | { | 2419 | { |
| 2420 | if (! whitespace) | 2420 | if (whitespace) |
| 2421 | { | 2421 | continue; |
| 2422 | whitespace = true; | 2422 | c = ' '; |
| 2423 | name[length++] = ' '; | 2423 | whitespace = true; |
| 2424 | } | ||
| 2425 | } | 2424 | } |
| 2426 | else | 2425 | else |
| 2427 | { | 2426 | whitespace = false; |
| 2428 | whitespace = false; | 2427 | name[length++] = c; |
| 2429 | name[length++] = c; | ||
| 2430 | } | ||
| 2431 | if (length >= max_character_name_length) | 2428 | if (length >= max_character_name_length) |
| 2432 | invalid_syntax ("Character name too long"); | 2429 | invalid_syntax ("Character name too long"); |
| 2433 | } | 2430 | } |
| 2434 | if (length == 0) | 2431 | if (length == 0) |
| 2435 | invalid_syntax ("Empty character name"); | 2432 | invalid_syntax ("Empty character name"); |
| 2436 | name[length] = 0; | 2433 | name[length] = 0; |
| 2437 | const Lisp_Object lisp_name = make_unibyte_string (name, length); | 2434 | Lisp_Object lisp_name = make_unibyte_string (name, length); |
| 2438 | const Lisp_Object code = | 2435 | Lisp_Object code = |
| 2439 | (length >= 3 && length <= 10 && name[0] == 'U' && name[1] == '+') ? | 2436 | (length >= 3 && length <= 10 && name[0] == 'U' && name[1] == '+') ? |
| 2440 | /* Code point as U+N, where N is between 1 and 8 hexadecimal | 2437 | /* Code point as U+N, where N is between 1 and 8 hexadecimal |
| 2441 | digits. */ | 2438 | digits. */ |