diff options
| author | Eli Zaretskii | 2010-09-23 08:09:12 -0400 |
|---|---|---|
| committer | Eli Zaretskii | 2010-09-23 08:09:12 -0400 |
| commit | 141624691330c7622d9a31d53ec919dee8e97473 (patch) | |
| tree | c8f2a43e69346342552c6a72a307555ae26a739f /src | |
| parent | 7228f056909af1ffe9d8f611b959638bc9544d2f (diff) | |
| download | emacs-141624691330c7622d9a31d53ec919dee8e97473.tar.gz emacs-141624691330c7622d9a31d53ec919dee8e97473.zip | |
Fix some more uses of int instead of EMACS_INT.
font.c (font_intern_prop): Use EMACS_INT for string length
variables.
character.c (parse_str_as_multibyte, str_as_multibyte)
(parse_str_to_multibyte, str_to_multibyte, str_as_unibyte)
(string_count_byte8, string_escape_byte8): Use EMACS_INT for
string length arguments, variables, and return values.
character.h (parse_str_as_multibyte, str_as_multibyte)
(parse_str_to_multibyte, str_to_multibyte, str_as_unibyte): Adjust
prototypes.
fns.c (Fstring_as_multibyte): Use EMACS_INT for string length
variables.
alloc.c <total_string_size>: Declare as EMACS_INT, not int.
(Fmake_string): Protect against too large strings.
(live_string_p, live_cons_p, live_symbol_p, live_float_p)
(live_misc_p): Use ptrdiff_t instead of int for pointer
differences.
(string_bytes, check_sblock, check_string_free_list)
(allocate_string_data, compact_small_strings, Fmake_string)
(Fmake_bool_vector, make_string, make_unibyte_string)
(make_multibyte_string, make_string_from_bytes)
(make_specified_string_string, Fmake_list, Fmake_vector): Use
EMACS_INT for string length variables and arguments.
(find_string_data_in_pure, make_pure_string, make_pure_c_string)
(Fpurecopy): Use EMACS_INT for string size.
(mark_vectorlike, mark_char_table, mark_object): Use EMACS_UINT
for vector size.
lisp.h (make_string, make_unibyte_string, make_multibyte_string)
(make_string_from_bytes, make_specified_string_string)
(make_pure_string, string_bytes): Adjust prototypes.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 37 | ||||
| -rw-r--r-- | src/alloc.c | 85 | ||||
| -rw-r--r-- | src/character.c | 58 | ||||
| -rw-r--r-- | src/character.h | 13 | ||||
| -rw-r--r-- | src/fns.c | 2 | ||||
| -rw-r--r-- | src/font.c | 2 | ||||
| -rw-r--r-- | src/lisp.h | 15 |
7 files changed, 137 insertions, 75 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 7036c7cc661..04f35d36ecf 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,40 @@ | |||
| 1 | 2010-09-23 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * font.c (font_intern_prop): Use EMACS_INT for string length | ||
| 4 | variables. | ||
| 5 | |||
| 6 | * character.c (parse_str_as_multibyte, str_as_multibyte) | ||
| 7 | (parse_str_to_multibyte, str_to_multibyte, str_as_unibyte) | ||
| 8 | (string_count_byte8, string_escape_byte8): Use EMACS_INT for | ||
| 9 | string length arguments, variables, and return values. | ||
| 10 | |||
| 11 | * character.h (parse_str_as_multibyte, str_as_multibyte) | ||
| 12 | (parse_str_to_multibyte, str_to_multibyte, str_as_unibyte): Adjust | ||
| 13 | prototypes. | ||
| 14 | |||
| 15 | * fns.c (Fstring_as_multibyte): Use EMACS_INT for string length | ||
| 16 | variables. | ||
| 17 | |||
| 18 | * alloc.c <total_string_size>: Declare as EMACS_INT, not int. | ||
| 19 | (Fmake_string): Protect against too large strings. | ||
| 20 | (live_string_p, live_cons_p, live_symbol_p, live_float_p) | ||
| 21 | (live_misc_p): Use ptrdiff_t instead of int for pointer | ||
| 22 | differences. | ||
| 23 | (string_bytes, check_sblock, check_string_free_list) | ||
| 24 | (allocate_string_data, compact_small_strings, Fmake_string) | ||
| 25 | (Fmake_bool_vector, make_string, make_unibyte_string) | ||
| 26 | (make_multibyte_string, make_string_from_bytes) | ||
| 27 | (make_specified_string_string, Fmake_list, Fmake_vector): Use | ||
| 28 | EMACS_INT for string length variables and arguments. | ||
| 29 | (find_string_data_in_pure, make_pure_string, make_pure_c_string) | ||
| 30 | (Fpurecopy): Use EMACS_INT for string size. | ||
| 31 | (mark_vectorlike, mark_char_table, mark_object): Use EMACS_UINT | ||
| 32 | for vector size. | ||
| 33 | |||
| 34 | * lisp.h (make_string, make_unibyte_string, make_multibyte_string) | ||
| 35 | (make_string_from_bytes, make_specified_string_string) | ||
| 36 | (make_pure_string, string_bytes): Adjust prototypes. | ||
| 37 | |||
| 1 | 2010-09-22 Eli Zaretskii <eliz@gnu.org> | 38 | 2010-09-22 Eli Zaretskii <eliz@gnu.org> |
| 2 | 39 | ||
| 3 | * editfns.c (Fsubst_char_in_region, Ftranslate_region_internal) | 40 | * editfns.c (Fsubst_char_in_region, Ftranslate_region_internal) |
diff --git a/src/alloc.c b/src/alloc.c index 60b8016fb88..5cbc7cfe411 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -1644,7 +1644,7 @@ static int total_strings, total_free_strings; | |||
| 1644 | 1644 | ||
| 1645 | /* Number of bytes used by live strings. */ | 1645 | /* Number of bytes used by live strings. */ |
| 1646 | 1646 | ||
| 1647 | static int total_string_size; | 1647 | static EMACS_INT total_string_size; |
| 1648 | 1648 | ||
| 1649 | /* Given a pointer to a Lisp_String S which is on the free-list | 1649 | /* Given a pointer to a Lisp_String S which is on the free-list |
| 1650 | string_free_list, return a pointer to its successor in the | 1650 | string_free_list, return a pointer to its successor in the |
| @@ -1739,11 +1739,12 @@ static void check_sblock (struct sblock *); | |||
| 1739 | 1739 | ||
| 1740 | /* Like GC_STRING_BYTES, but with debugging check. */ | 1740 | /* Like GC_STRING_BYTES, but with debugging check. */ |
| 1741 | 1741 | ||
| 1742 | int | 1742 | EMACS_INT |
| 1743 | string_bytes (s) | 1743 | string_bytes (struct Lisp_String *s) |
| 1744 | struct Lisp_String *s; | ||
| 1745 | { | 1744 | { |
| 1746 | int nbytes = (s->size_byte < 0 ? s->size & ~ARRAY_MARK_FLAG : s->size_byte); | 1745 | EMACS_INT nbytes = |
| 1746 | (s->size_byte < 0 ? s->size & ~ARRAY_MARK_FLAG : s->size_byte); | ||
| 1747 | |||
| 1747 | if (!PURE_POINTER_P (s) | 1748 | if (!PURE_POINTER_P (s) |
| 1748 | && s->data | 1749 | && s->data |
| 1749 | && nbytes != SDATA_NBYTES (SDATA_OF_STRING (s))) | 1750 | && nbytes != SDATA_NBYTES (SDATA_OF_STRING (s))) |
| @@ -1765,7 +1766,7 @@ check_sblock (b) | |||
| 1765 | { | 1766 | { |
| 1766 | /* Compute the next FROM here because copying below may | 1767 | /* Compute the next FROM here because copying below may |
| 1767 | overwrite data we need to compute it. */ | 1768 | overwrite data we need to compute it. */ |
| 1768 | int nbytes; | 1769 | EMACS_INT nbytes; |
| 1769 | 1770 | ||
| 1770 | /* Check that the string size recorded in the string is the | 1771 | /* Check that the string size recorded in the string is the |
| 1771 | same as the one recorded in the sdata structure. */ | 1772 | same as the one recorded in the sdata structure. */ |
| @@ -1825,7 +1826,7 @@ check_string_free_list () | |||
| 1825 | s = string_free_list; | 1826 | s = string_free_list; |
| 1826 | while (s != NULL) | 1827 | while (s != NULL) |
| 1827 | { | 1828 | { |
| 1828 | if ((unsigned)s < 1024) | 1829 | if ((unsigned long)s < 1024) |
| 1829 | abort(); | 1830 | abort(); |
| 1830 | s = NEXT_FREE_LISP_STRING (s); | 1831 | s = NEXT_FREE_LISP_STRING (s); |
| 1831 | } | 1832 | } |
| @@ -1913,7 +1914,7 @@ allocate_string_data (struct Lisp_String *s, | |||
| 1913 | { | 1914 | { |
| 1914 | struct sdata *data, *old_data; | 1915 | struct sdata *data, *old_data; |
| 1915 | struct sblock *b; | 1916 | struct sblock *b; |
| 1916 | int needed, old_nbytes; | 1917 | EMACS_INT needed, old_nbytes; |
| 1917 | 1918 | ||
| 1918 | /* Determine the number of bytes needed to store NBYTES bytes | 1919 | /* Determine the number of bytes needed to store NBYTES bytes |
| 1919 | of string data. */ | 1920 | of string data. */ |
| @@ -2155,7 +2156,7 @@ compact_small_strings (void) | |||
| 2155 | { | 2156 | { |
| 2156 | /* Compute the next FROM here because copying below may | 2157 | /* Compute the next FROM here because copying below may |
| 2157 | overwrite data we need to compute it. */ | 2158 | overwrite data we need to compute it. */ |
| 2158 | int nbytes; | 2159 | EMACS_INT nbytes; |
| 2159 | 2160 | ||
| 2160 | #ifdef GC_CHECK_STRING_BYTES | 2161 | #ifdef GC_CHECK_STRING_BYTES |
| 2161 | /* Check that the string size recorded in the string is the | 2162 | /* Check that the string size recorded in the string is the |
| @@ -2233,7 +2234,8 @@ INIT must be an integer that represents a character. */) | |||
| 2233 | { | 2234 | { |
| 2234 | register Lisp_Object val; | 2235 | register Lisp_Object val; |
| 2235 | register unsigned char *p, *end; | 2236 | register unsigned char *p, *end; |
| 2236 | int c, nbytes; | 2237 | int c; |
| 2238 | EMACS_INT nbytes; | ||
| 2237 | 2239 | ||
| 2238 | CHECK_NATNUM (length); | 2240 | CHECK_NATNUM (length); |
| 2239 | CHECK_NUMBER (init); | 2241 | CHECK_NUMBER (init); |
| @@ -2252,9 +2254,12 @@ INIT must be an integer that represents a character. */) | |||
| 2252 | { | 2254 | { |
| 2253 | unsigned char str[MAX_MULTIBYTE_LENGTH]; | 2255 | unsigned char str[MAX_MULTIBYTE_LENGTH]; |
| 2254 | int len = CHAR_STRING (c, str); | 2256 | int len = CHAR_STRING (c, str); |
| 2257 | EMACS_INT string_len = XINT (length); | ||
| 2255 | 2258 | ||
| 2256 | nbytes = len * XINT (length); | 2259 | if (string_len > MOST_POSITIVE_FIXNUM / len) |
| 2257 | val = make_uninit_multibyte_string (XINT (length), nbytes); | 2260 | error ("Maximum string size exceeded"); |
| 2261 | nbytes = len * string_len; | ||
| 2262 | val = make_uninit_multibyte_string (string_len, nbytes); | ||
| 2258 | p = SDATA (val); | 2263 | p = SDATA (val); |
| 2259 | end = p + nbytes; | 2264 | end = p + nbytes; |
| 2260 | while (p != end) | 2265 | while (p != end) |
| @@ -2277,7 +2282,8 @@ LENGTH must be a number. INIT matters only in whether it is t or nil. */) | |||
| 2277 | register Lisp_Object val; | 2282 | register Lisp_Object val; |
| 2278 | struct Lisp_Bool_Vector *p; | 2283 | struct Lisp_Bool_Vector *p; |
| 2279 | int real_init, i; | 2284 | int real_init, i; |
| 2280 | int length_in_chars, length_in_elts, bits_per_value; | 2285 | EMACS_INT length_in_chars, length_in_elts; |
| 2286 | int bits_per_value; | ||
| 2281 | 2287 | ||
| 2282 | CHECK_NATNUM (length); | 2288 | CHECK_NATNUM (length); |
| 2283 | 2289 | ||
| @@ -2317,10 +2323,10 @@ LENGTH must be a number. INIT matters only in whether it is t or nil. */) | |||
| 2317 | multibyte, depending on the contents. */ | 2323 | multibyte, depending on the contents. */ |
| 2318 | 2324 | ||
| 2319 | Lisp_Object | 2325 | Lisp_Object |
| 2320 | make_string (const char *contents, int nbytes) | 2326 | make_string (const char *contents, EMACS_INT nbytes) |
| 2321 | { | 2327 | { |
| 2322 | register Lisp_Object val; | 2328 | register Lisp_Object val; |
| 2323 | int nchars, multibyte_nbytes; | 2329 | EMACS_INT nchars, multibyte_nbytes; |
| 2324 | 2330 | ||
| 2325 | parse_str_as_multibyte (contents, nbytes, &nchars, &multibyte_nbytes); | 2331 | parse_str_as_multibyte (contents, nbytes, &nchars, &multibyte_nbytes); |
| 2326 | if (nbytes == nchars || nbytes != multibyte_nbytes) | 2332 | if (nbytes == nchars || nbytes != multibyte_nbytes) |
| @@ -2336,7 +2342,7 @@ make_string (const char *contents, int nbytes) | |||
| 2336 | /* Make an unibyte string from LENGTH bytes at CONTENTS. */ | 2342 | /* Make an unibyte string from LENGTH bytes at CONTENTS. */ |
| 2337 | 2343 | ||
| 2338 | Lisp_Object | 2344 | Lisp_Object |
| 2339 | make_unibyte_string (const char *contents, int length) | 2345 | make_unibyte_string (const char *contents, EMACS_INT length) |
| 2340 | { | 2346 | { |
| 2341 | register Lisp_Object val; | 2347 | register Lisp_Object val; |
| 2342 | val = make_uninit_string (length); | 2348 | val = make_uninit_string (length); |
| @@ -2350,7 +2356,8 @@ make_unibyte_string (const char *contents, int length) | |||
| 2350 | bytes at CONTENTS. */ | 2356 | bytes at CONTENTS. */ |
| 2351 | 2357 | ||
| 2352 | Lisp_Object | 2358 | Lisp_Object |
| 2353 | make_multibyte_string (const char *contents, int nchars, int nbytes) | 2359 | make_multibyte_string (const char *contents, |
| 2360 | EMACS_INT nchars, EMACS_INT nbytes) | ||
| 2354 | { | 2361 | { |
| 2355 | register Lisp_Object val; | 2362 | register Lisp_Object val; |
| 2356 | val = make_uninit_multibyte_string (nchars, nbytes); | 2363 | val = make_uninit_multibyte_string (nchars, nbytes); |
| @@ -2363,7 +2370,8 @@ make_multibyte_string (const char *contents, int nchars, int nbytes) | |||
| 2363 | CONTENTS. It is a multibyte string if NBYTES != NCHARS. */ | 2370 | CONTENTS. It is a multibyte string if NBYTES != NCHARS. */ |
| 2364 | 2371 | ||
| 2365 | Lisp_Object | 2372 | Lisp_Object |
| 2366 | make_string_from_bytes (const char *contents, int nchars, int nbytes) | 2373 | make_string_from_bytes (const char *contents, |
| 2374 | EMACS_INT nchars, EMACS_INT nbytes) | ||
| 2367 | { | 2375 | { |
| 2368 | register Lisp_Object val; | 2376 | register Lisp_Object val; |
| 2369 | val = make_uninit_multibyte_string (nchars, nbytes); | 2377 | val = make_uninit_multibyte_string (nchars, nbytes); |
| @@ -2380,7 +2388,8 @@ make_string_from_bytes (const char *contents, int nchars, int nbytes) | |||
| 2380 | characters by itself. */ | 2388 | characters by itself. */ |
| 2381 | 2389 | ||
| 2382 | Lisp_Object | 2390 | Lisp_Object |
| 2383 | make_specified_string (const char *contents, int nchars, int nbytes, int multibyte) | 2391 | make_specified_string (const char *contents, |
| 2392 | EMACS_INT nchars, EMACS_INT nbytes, int multibyte) | ||
| 2384 | { | 2393 | { |
| 2385 | register Lisp_Object val; | 2394 | register Lisp_Object val; |
| 2386 | 2395 | ||
| @@ -2768,7 +2777,7 @@ DEFUN ("make-list", Fmake_list, Smake_list, 2, 2, 0, | |||
| 2768 | (register Lisp_Object length, Lisp_Object init) | 2777 | (register Lisp_Object length, Lisp_Object init) |
| 2769 | { | 2778 | { |
| 2770 | register Lisp_Object val; | 2779 | register Lisp_Object val; |
| 2771 | register int size; | 2780 | register EMACS_INT size; |
| 2772 | 2781 | ||
| 2773 | CHECK_NATNUM (length); | 2782 | CHECK_NATNUM (length); |
| 2774 | size = XFASTINT (length); | 2783 | size = XFASTINT (length); |
| @@ -2946,7 +2955,7 @@ See also the function `vector'. */) | |||
| 2946 | { | 2955 | { |
| 2947 | Lisp_Object vector; | 2956 | Lisp_Object vector; |
| 2948 | register EMACS_INT sizei; | 2957 | register EMACS_INT sizei; |
| 2949 | register int index; | 2958 | register EMACS_INT index; |
| 2950 | register struct Lisp_Vector *p; | 2959 | register struct Lisp_Vector *p; |
| 2951 | 2960 | ||
| 2952 | CHECK_NATNUM (length); | 2961 | CHECK_NATNUM (length); |
| @@ -3786,7 +3795,7 @@ live_string_p (struct mem_node *m, void *p) | |||
| 3786 | if (m->type == MEM_TYPE_STRING) | 3795 | if (m->type == MEM_TYPE_STRING) |
| 3787 | { | 3796 | { |
| 3788 | struct string_block *b = (struct string_block *) m->start; | 3797 | struct string_block *b = (struct string_block *) m->start; |
| 3789 | int offset = (char *) p - (char *) &b->strings[0]; | 3798 | ptrdiff_t offset = (char *) p - (char *) &b->strings[0]; |
| 3790 | 3799 | ||
| 3791 | /* P must point to the start of a Lisp_String structure, and it | 3800 | /* P must point to the start of a Lisp_String structure, and it |
| 3792 | must not be on the free-list. */ | 3801 | must not be on the free-list. */ |
| @@ -3809,7 +3818,7 @@ live_cons_p (struct mem_node *m, void *p) | |||
| 3809 | if (m->type == MEM_TYPE_CONS) | 3818 | if (m->type == MEM_TYPE_CONS) |
| 3810 | { | 3819 | { |
| 3811 | struct cons_block *b = (struct cons_block *) m->start; | 3820 | struct cons_block *b = (struct cons_block *) m->start; |
| 3812 | int offset = (char *) p - (char *) &b->conses[0]; | 3821 | ptrdiff_t offset = (char *) p - (char *) &b->conses[0]; |
| 3813 | 3822 | ||
| 3814 | /* P must point to the start of a Lisp_Cons, not be | 3823 | /* P must point to the start of a Lisp_Cons, not be |
| 3815 | one of the unused cells in the current cons block, | 3824 | one of the unused cells in the current cons block, |
| @@ -3835,7 +3844,7 @@ live_symbol_p (struct mem_node *m, void *p) | |||
| 3835 | if (m->type == MEM_TYPE_SYMBOL) | 3844 | if (m->type == MEM_TYPE_SYMBOL) |
| 3836 | { | 3845 | { |
| 3837 | struct symbol_block *b = (struct symbol_block *) m->start; | 3846 | struct symbol_block *b = (struct symbol_block *) m->start; |
| 3838 | int offset = (char *) p - (char *) &b->symbols[0]; | 3847 | ptrdiff_t offset = (char *) p - (char *) &b->symbols[0]; |
| 3839 | 3848 | ||
| 3840 | /* P must point to the start of a Lisp_Symbol, not be | 3849 | /* P must point to the start of a Lisp_Symbol, not be |
| 3841 | one of the unused cells in the current symbol block, | 3850 | one of the unused cells in the current symbol block, |
| @@ -3861,7 +3870,7 @@ live_float_p (struct mem_node *m, void *p) | |||
| 3861 | if (m->type == MEM_TYPE_FLOAT) | 3870 | if (m->type == MEM_TYPE_FLOAT) |
| 3862 | { | 3871 | { |
| 3863 | struct float_block *b = (struct float_block *) m->start; | 3872 | struct float_block *b = (struct float_block *) m->start; |
| 3864 | int offset = (char *) p - (char *) &b->floats[0]; | 3873 | ptrdiff_t offset = (char *) p - (char *) &b->floats[0]; |
| 3865 | 3874 | ||
| 3866 | /* P must point to the start of a Lisp_Float and not be | 3875 | /* P must point to the start of a Lisp_Float and not be |
| 3867 | one of the unused cells in the current float block. */ | 3876 | one of the unused cells in the current float block. */ |
| @@ -3885,7 +3894,7 @@ live_misc_p (struct mem_node *m, void *p) | |||
| 3885 | if (m->type == MEM_TYPE_MISC) | 3894 | if (m->type == MEM_TYPE_MISC) |
| 3886 | { | 3895 | { |
| 3887 | struct marker_block *b = (struct marker_block *) m->start; | 3896 | struct marker_block *b = (struct marker_block *) m->start; |
| 3888 | int offset = (char *) p - (char *) &b->markers[0]; | 3897 | ptrdiff_t offset = (char *) p - (char *) &b->markers[0]; |
| 3889 | 3898 | ||
| 3890 | /* P must point to the start of a Lisp_Misc, not be | 3899 | /* P must point to the start of a Lisp_Misc, not be |
| 3891 | one of the unused cells in the current misc block, | 3900 | one of the unused cells in the current misc block, |
| @@ -4592,9 +4601,10 @@ check_pure_size (void) | |||
| 4592 | address. Return NULL if not found. */ | 4601 | address. Return NULL if not found. */ |
| 4593 | 4602 | ||
| 4594 | static char * | 4603 | static char * |
| 4595 | find_string_data_in_pure (const char *data, int nbytes) | 4604 | find_string_data_in_pure (const char *data, EMACS_INT nbytes) |
| 4596 | { | 4605 | { |
| 4597 | int i, skip, bm_skip[256], last_char_skip, infinity, start, start_max; | 4606 | int i; |
| 4607 | EMACS_INT skip, bm_skip[256], last_char_skip, infinity, start, start_max; | ||
| 4598 | const unsigned char *p; | 4608 | const unsigned char *p; |
| 4599 | char *non_lisp_beg; | 4609 | char *non_lisp_beg; |
| 4600 | 4610 | ||
| @@ -4661,7 +4671,8 @@ find_string_data_in_pure (const char *data, int nbytes) | |||
| 4661 | string; then the string is not protected from gc. */ | 4671 | string; then the string is not protected from gc. */ |
| 4662 | 4672 | ||
| 4663 | Lisp_Object | 4673 | Lisp_Object |
| 4664 | make_pure_string (const char *data, int nchars, int nbytes, int multibyte) | 4674 | make_pure_string (const char *data, |
| 4675 | EMACS_INT nchars, EMACS_INT nbytes, int multibyte) | ||
| 4665 | { | 4676 | { |
| 4666 | Lisp_Object string; | 4677 | Lisp_Object string; |
| 4667 | struct Lisp_String *s; | 4678 | struct Lisp_String *s; |
| @@ -4689,7 +4700,7 @@ make_pure_c_string (const char *data) | |||
| 4689 | { | 4700 | { |
| 4690 | Lisp_Object string; | 4701 | Lisp_Object string; |
| 4691 | struct Lisp_String *s; | 4702 | struct Lisp_String *s; |
| 4692 | int nchars = strlen (data); | 4703 | EMACS_INT nchars = strlen (data); |
| 4693 | 4704 | ||
| 4694 | s = (struct Lisp_String *) pure_alloc (sizeof *s, Lisp_String); | 4705 | s = (struct Lisp_String *) pure_alloc (sizeof *s, Lisp_String); |
| 4695 | s->size = nchars; | 4706 | s->size = nchars; |
| @@ -4779,7 +4790,7 @@ Does not copy symbols. Copies strings without text properties. */) | |||
| 4779 | else if (COMPILEDP (obj) || VECTORP (obj)) | 4790 | else if (COMPILEDP (obj) || VECTORP (obj)) |
| 4780 | { | 4791 | { |
| 4781 | register struct Lisp_Vector *vec; | 4792 | register struct Lisp_Vector *vec; |
| 4782 | register int i; | 4793 | register EMACS_INT i; |
| 4783 | EMACS_INT size; | 4794 | EMACS_INT size; |
| 4784 | 4795 | ||
| 4785 | size = XVECTOR (obj)->size; | 4796 | size = XVECTOR (obj)->size; |
| @@ -5228,8 +5239,8 @@ static int mark_object_loop_halt; | |||
| 5228 | static void | 5239 | static void |
| 5229 | mark_vectorlike (struct Lisp_Vector *ptr) | 5240 | mark_vectorlike (struct Lisp_Vector *ptr) |
| 5230 | { | 5241 | { |
| 5231 | register EMACS_INT size = ptr->size; | 5242 | register EMACS_UINT size = ptr->size; |
| 5232 | register int i; | 5243 | register EMACS_UINT i; |
| 5233 | 5244 | ||
| 5234 | eassert (!VECTOR_MARKED_P (ptr)); | 5245 | eassert (!VECTOR_MARKED_P (ptr)); |
| 5235 | VECTOR_MARK (ptr); /* Else mark it */ | 5246 | VECTOR_MARK (ptr); /* Else mark it */ |
| @@ -5251,8 +5262,8 @@ mark_vectorlike (struct Lisp_Vector *ptr) | |||
| 5251 | static void | 5262 | static void |
| 5252 | mark_char_table (struct Lisp_Vector *ptr) | 5263 | mark_char_table (struct Lisp_Vector *ptr) |
| 5253 | { | 5264 | { |
| 5254 | register EMACS_INT size = ptr->size & PSEUDOVECTOR_SIZE_MASK; | 5265 | register EMACS_UINT size = ptr->size & PSEUDOVECTOR_SIZE_MASK; |
| 5255 | register int i; | 5266 | register EMACS_UINT i; |
| 5256 | 5267 | ||
| 5257 | eassert (!VECTOR_MARKED_P (ptr)); | 5268 | eassert (!VECTOR_MARKED_P (ptr)); |
| 5258 | VECTOR_MARK (ptr); | 5269 | VECTOR_MARK (ptr); |
| @@ -5381,8 +5392,8 @@ mark_object (Lisp_Object arg) | |||
| 5381 | recursion there. */ | 5392 | recursion there. */ |
| 5382 | { | 5393 | { |
| 5383 | register struct Lisp_Vector *ptr = XVECTOR (obj); | 5394 | register struct Lisp_Vector *ptr = XVECTOR (obj); |
| 5384 | register EMACS_INT size = ptr->size; | 5395 | register EMACS_UINT size = ptr->size; |
| 5385 | register int i; | 5396 | register EMACS_UINT i; |
| 5386 | 5397 | ||
| 5387 | CHECK_LIVE (live_vector_p); | 5398 | CHECK_LIVE (live_vector_p); |
| 5388 | VECTOR_MARK (ptr); /* Else mark it */ | 5399 | VECTOR_MARK (ptr); /* Else mark it */ |
diff --git a/src/character.c b/src/character.c index c4a3a008bcd..90f6be10067 100644 --- a/src/character.c +++ b/src/character.c | |||
| @@ -592,10 +592,11 @@ multibyte_chars_in_text (const unsigned char *ptr, EMACS_INT nbytes) | |||
| 592 | represented by 2-byte in a multibyte text. */ | 592 | represented by 2-byte in a multibyte text. */ |
| 593 | 593 | ||
| 594 | void | 594 | void |
| 595 | parse_str_as_multibyte (const unsigned char *str, int len, int *nchars, int *nbytes) | 595 | parse_str_as_multibyte (const unsigned char *str, EMACS_INT len, |
| 596 | EMACS_INT *nchars, EMACS_INT *nbytes) | ||
| 596 | { | 597 | { |
| 597 | const unsigned char *endp = str + len; | 598 | const unsigned char *endp = str + len; |
| 598 | int n, chars = 0, bytes = 0; | 599 | EMACS_INT n, chars = 0, bytes = 0; |
| 599 | 600 | ||
| 600 | if (len >= MAX_MULTIBYTE_LENGTH) | 601 | if (len >= MAX_MULTIBYTE_LENGTH) |
| 601 | { | 602 | { |
| @@ -633,12 +634,13 @@ parse_str_as_multibyte (const unsigned char *str, int len, int *nchars, int *nby | |||
| 633 | area and that is enough. Return the number of bytes of the | 634 | area and that is enough. Return the number of bytes of the |
| 634 | resulting text. */ | 635 | resulting text. */ |
| 635 | 636 | ||
| 636 | int | 637 | EMACS_INT |
| 637 | str_as_multibyte (unsigned char *str, int len, int nbytes, int *nchars) | 638 | str_as_multibyte (unsigned char *str, EMACS_INT len, EMACS_INT nbytes, |
| 639 | EMACS_INT *nchars) | ||
| 638 | { | 640 | { |
| 639 | unsigned char *p = str, *endp = str + nbytes; | 641 | unsigned char *p = str, *endp = str + nbytes; |
| 640 | unsigned char *to; | 642 | unsigned char *to; |
| 641 | int chars = 0; | 643 | EMACS_INT chars = 0; |
| 642 | int n; | 644 | int n; |
| 643 | 645 | ||
| 644 | if (nbytes >= MAX_MULTIBYTE_LENGTH) | 646 | if (nbytes >= MAX_MULTIBYTE_LENGTH) |
| @@ -709,11 +711,11 @@ str_as_multibyte (unsigned char *str, int len, int nbytes, int *nchars) | |||
| 709 | bytes it may ocupy when converted to multibyte string by | 711 | bytes it may ocupy when converted to multibyte string by |
| 710 | `str_to_multibyte'. */ | 712 | `str_to_multibyte'. */ |
| 711 | 713 | ||
| 712 | int | 714 | EMACS_INT |
| 713 | parse_str_to_multibyte (const unsigned char *str, int len) | 715 | parse_str_to_multibyte (const unsigned char *str, EMACS_INT len) |
| 714 | { | 716 | { |
| 715 | const unsigned char *endp = str + len; | 717 | const unsigned char *endp = str + len; |
| 716 | int bytes; | 718 | EMACS_INT bytes; |
| 717 | 719 | ||
| 718 | for (bytes = 0; str < endp; str++) | 720 | for (bytes = 0; str < endp; str++) |
| 719 | bytes += (*str < 0x80) ? 1 : 2; | 721 | bytes += (*str < 0x80) ? 1 : 2; |
| @@ -727,8 +729,8 @@ parse_str_to_multibyte (const unsigned char *str, int len) | |||
| 727 | that we can use LEN bytes at STR as a work area and that is | 729 | that we can use LEN bytes at STR as a work area and that is |
| 728 | enough. */ | 730 | enough. */ |
| 729 | 731 | ||
| 730 | int | 732 | EMACS_INT |
| 731 | str_to_multibyte (unsigned char *str, int len, int bytes) | 733 | str_to_multibyte (unsigned char *str, EMACS_INT len, EMACS_INT bytes) |
| 732 | { | 734 | { |
| 733 | unsigned char *p = str, *endp = str + bytes; | 735 | unsigned char *p = str, *endp = str + bytes; |
| 734 | unsigned char *to; | 736 | unsigned char *to; |
| @@ -756,8 +758,8 @@ str_to_multibyte (unsigned char *str, int len, int bytes) | |||
| 756 | actually converts characters in the range 0x80..0xFF to | 758 | actually converts characters in the range 0x80..0xFF to |
| 757 | unibyte. */ | 759 | unibyte. */ |
| 758 | 760 | ||
| 759 | int | 761 | EMACS_INT |
| 760 | str_as_unibyte (unsigned char *str, int bytes) | 762 | str_as_unibyte (unsigned char *str, EMACS_INT bytes) |
| 761 | { | 763 | { |
| 762 | const unsigned char *p = str, *endp = str + bytes; | 764 | const unsigned char *p = str, *endp = str + bytes; |
| 763 | unsigned char *to; | 765 | unsigned char *to; |
| @@ -818,14 +820,14 @@ str_to_unibyte (const unsigned char *src, unsigned char *dst, EMACS_INT chars, i | |||
| 818 | } | 820 | } |
| 819 | 821 | ||
| 820 | 822 | ||
| 821 | int | 823 | EMACS_INT |
| 822 | string_count_byte8 (Lisp_Object string) | 824 | string_count_byte8 (Lisp_Object string) |
| 823 | { | 825 | { |
| 824 | int multibyte = STRING_MULTIBYTE (string); | 826 | int multibyte = STRING_MULTIBYTE (string); |
| 825 | int nbytes = SBYTES (string); | 827 | EMACS_INT nbytes = SBYTES (string); |
| 826 | unsigned char *p = SDATA (string); | 828 | unsigned char *p = SDATA (string); |
| 827 | unsigned char *pend = p + nbytes; | 829 | unsigned char *pend = p + nbytes; |
| 828 | int count = 0; | 830 | EMACS_INT count = 0; |
| 829 | int c, len; | 831 | int c, len; |
| 830 | 832 | ||
| 831 | if (multibyte) | 833 | if (multibyte) |
| @@ -851,10 +853,10 @@ string_count_byte8 (Lisp_Object string) | |||
| 851 | Lisp_Object | 853 | Lisp_Object |
| 852 | string_escape_byte8 (Lisp_Object string) | 854 | string_escape_byte8 (Lisp_Object string) |
| 853 | { | 855 | { |
| 854 | int nchars = SCHARS (string); | 856 | EMACS_INT nchars = SCHARS (string); |
| 855 | int nbytes = SBYTES (string); | 857 | EMACS_INT nbytes = SBYTES (string); |
| 856 | int multibyte = STRING_MULTIBYTE (string); | 858 | int multibyte = STRING_MULTIBYTE (string); |
| 857 | int byte8_count; | 859 | EMACS_INT byte8_count; |
| 858 | const unsigned char *src, *src_end; | 860 | const unsigned char *src, *src_end; |
| 859 | unsigned char *dst; | 861 | unsigned char *dst; |
| 860 | Lisp_Object val; | 862 | Lisp_Object val; |
| @@ -869,12 +871,22 @@ string_escape_byte8 (Lisp_Object string) | |||
| 869 | return string; | 871 | return string; |
| 870 | 872 | ||
| 871 | if (multibyte) | 873 | if (multibyte) |
| 872 | /* Convert 2-byte sequence of byte8 chars to 4-byte octal. */ | 874 | { |
| 873 | val = make_uninit_multibyte_string (nchars + byte8_count * 3, | 875 | if ((MOST_POSITIVE_FIXNUM - nchars) / 3 < byte8_count |
| 874 | nbytes + byte8_count * 2); | 876 | || (MOST_POSITIVE_FIXNUM - nbytes) / 2 < byte8_count) |
| 877 | error ("Maximum string size exceeded"); | ||
| 878 | |||
| 879 | /* Convert 2-byte sequence of byte8 chars to 4-byte octal. */ | ||
| 880 | val = make_uninit_multibyte_string (nchars + byte8_count * 3, | ||
| 881 | nbytes + byte8_count * 2); | ||
| 882 | } | ||
| 875 | else | 883 | else |
| 876 | /* Convert 1-byte sequence of byte8 chars to 4-byte octal. */ | 884 | { |
| 877 | val = make_uninit_string (nbytes + byte8_count * 3); | 885 | if ((MOST_POSITIVE_FIXNUM - nchars) / 3 < byte8_count) |
| 886 | error ("Maximum string size exceeded"); | ||
| 887 | /* Convert 1-byte sequence of byte8 chars to 4-byte octal. */ | ||
| 888 | val = make_uninit_string (nbytes + byte8_count * 3); | ||
| 889 | } | ||
| 878 | 890 | ||
| 879 | src = SDATA (string); | 891 | src = SDATA (string); |
| 880 | src_end = src + nbytes; | 892 | src_end = src + nbytes; |
diff --git a/src/character.h b/src/character.h index 8726b2ae1d6..cbc4d6b3121 100644 --- a/src/character.h +++ b/src/character.h | |||
| @@ -603,12 +603,13 @@ extern int string_char (const unsigned char *, | |||
| 603 | 603 | ||
| 604 | extern int translate_char (Lisp_Object, int c); | 604 | extern int translate_char (Lisp_Object, int c); |
| 605 | extern int char_printable_p (int c); | 605 | extern int char_printable_p (int c); |
| 606 | extern void parse_str_as_multibyte (const unsigned char *, int, int *, | 606 | extern void parse_str_as_multibyte (const unsigned char *, |
| 607 | int *); | 607 | EMACS_INT, EMACS_INT *, EMACS_INT *); |
| 608 | extern int parse_str_to_multibyte (const unsigned char *, int); | 608 | extern EMACS_INT parse_str_to_multibyte (const unsigned char *, EMACS_INT); |
| 609 | extern int str_as_multibyte (unsigned char *, int, int, int *); | 609 | extern EMACS_INT str_as_multibyte (unsigned char *, EMACS_INT, EMACS_INT, |
| 610 | extern int str_to_multibyte (unsigned char *, int, int); | 610 | EMACS_INT *); |
| 611 | extern int str_as_unibyte (unsigned char *, int); | 611 | extern EMACS_INT str_to_multibyte (unsigned char *, EMACS_INT, EMACS_INT); |
| 612 | extern EMACS_INT str_as_unibyte (unsigned char *, EMACS_INT); | ||
| 612 | extern EMACS_INT str_to_unibyte (const unsigned char *, unsigned char *, | 613 | extern EMACS_INT str_to_unibyte (const unsigned char *, unsigned char *, |
| 613 | EMACS_INT, int); | 614 | EMACS_INT, int); |
| 614 | extern int strwidth (const unsigned char *, int); | 615 | extern int strwidth (const unsigned char *, int); |
| @@ -1036,7 +1036,7 @@ If you're not sure, whether to use `string-as-multibyte' or | |||
| 1036 | if (! STRING_MULTIBYTE (string)) | 1036 | if (! STRING_MULTIBYTE (string)) |
| 1037 | { | 1037 | { |
| 1038 | Lisp_Object new_string; | 1038 | Lisp_Object new_string; |
| 1039 | int nchars, nbytes; | 1039 | EMACS_INT nchars, nbytes; |
| 1040 | 1040 | ||
| 1041 | parse_str_as_multibyte (SDATA (string), | 1041 | parse_str_as_multibyte (SDATA (string), |
| 1042 | SBYTES (string), | 1042 | SBYTES (string), |
diff --git a/src/font.c b/src/font.c index ae7211e92fe..dee55d1e976 100644 --- a/src/font.c +++ b/src/font.c | |||
| @@ -237,7 +237,7 @@ font_intern_prop (const char *str, int len, int force_symbol) | |||
| 237 | int i; | 237 | int i; |
| 238 | Lisp_Object tem; | 238 | Lisp_Object tem; |
| 239 | Lisp_Object obarray; | 239 | Lisp_Object obarray; |
| 240 | int nbytes, nchars; | 240 | EMACS_INT nbytes, nchars; |
| 241 | 241 | ||
| 242 | if (len == 1 && *str == '*') | 242 | if (len == 1 && *str == '*') |
| 243 | return Qnil; | 243 | return Qnil; |
diff --git a/src/lisp.h b/src/lisp.h index a1f146e45ad..f36d1836110 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -739,7 +739,7 @@ struct Lisp_Cons | |||
| 739 | #ifdef GC_CHECK_STRING_BYTES | 739 | #ifdef GC_CHECK_STRING_BYTES |
| 740 | 740 | ||
| 741 | struct Lisp_String; | 741 | struct Lisp_String; |
| 742 | extern int string_bytes (struct Lisp_String *); | 742 | extern EMACS_INT string_bytes (struct Lisp_String *); |
| 743 | #define STRING_BYTES(S) string_bytes ((S)) | 743 | #define STRING_BYTES(S) string_bytes ((S)) |
| 744 | 744 | ||
| 745 | #else /* not GC_CHECK_STRING_BYTES */ | 745 | #else /* not GC_CHECK_STRING_BYTES */ |
| @@ -2718,16 +2718,17 @@ EXFUN (Fmake_symbol, 1); | |||
| 2718 | EXFUN (Fmake_marker, 0); | 2718 | EXFUN (Fmake_marker, 0); |
| 2719 | EXFUN (Fmake_string, 2); | 2719 | EXFUN (Fmake_string, 2); |
| 2720 | extern Lisp_Object build_string (const char *); | 2720 | extern Lisp_Object build_string (const char *); |
| 2721 | extern Lisp_Object make_string (const char *, int); | 2721 | extern Lisp_Object make_string (const char *, EMACS_INT); |
| 2722 | extern Lisp_Object make_unibyte_string (const char *, int); | 2722 | extern Lisp_Object make_unibyte_string (const char *, EMACS_INT); |
| 2723 | extern Lisp_Object make_multibyte_string (const char *, int, int); | 2723 | extern Lisp_Object make_multibyte_string (const char *, EMACS_INT, EMACS_INT); |
| 2724 | extern Lisp_Object make_event_array (int, Lisp_Object *); | 2724 | extern Lisp_Object make_event_array (int, Lisp_Object *); |
| 2725 | extern Lisp_Object make_uninit_string (EMACS_INT); | 2725 | extern Lisp_Object make_uninit_string (EMACS_INT); |
| 2726 | extern Lisp_Object make_uninit_multibyte_string (EMACS_INT, EMACS_INT); | 2726 | extern Lisp_Object make_uninit_multibyte_string (EMACS_INT, EMACS_INT); |
| 2727 | extern Lisp_Object make_string_from_bytes (const char *, int, int); | 2727 | extern Lisp_Object make_string_from_bytes (const char *, EMACS_INT, EMACS_INT); |
| 2728 | extern Lisp_Object make_specified_string (const char *, int, int, int); | 2728 | extern Lisp_Object make_specified_string (const char *, |
| 2729 | EMACS_INT, EMACS_INT, int); | ||
| 2729 | EXFUN (Fpurecopy, 1); | 2730 | EXFUN (Fpurecopy, 1); |
| 2730 | extern Lisp_Object make_pure_string (const char *, int, int, int); | 2731 | extern Lisp_Object make_pure_string (const char *, EMACS_INT, EMACS_INT, int); |
| 2731 | extern Lisp_Object make_pure_c_string (const char *data); | 2732 | extern Lisp_Object make_pure_c_string (const char *data); |
| 2732 | extern Lisp_Object pure_cons (Lisp_Object, Lisp_Object); | 2733 | extern Lisp_Object pure_cons (Lisp_Object, Lisp_Object); |
| 2733 | extern Lisp_Object make_pure_vector (EMACS_INT); | 2734 | extern Lisp_Object make_pure_vector (EMACS_INT); |