diff options
| author | Stefan Monnier | 2008-02-12 21:35:15 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2008-02-12 21:35:15 +0000 |
| commit | 13818c30785d1253412c4e08c61417eb81a98c5b (patch) | |
| tree | f5fa90cff90bb458801514d30546ba9538d3af0a /src | |
| parent | 8b8bf8e68f19cdbe07521fa2d3c563265b27bd94 (diff) | |
| download | emacs-13818c30785d1253412c4e08c61417eb81a98c5b.tar.gz emacs-13818c30785d1253412c4e08c61417eb81a98c5b.zip | |
* coding.c (coding_set_destination): Use BEG_BYTE rather than hardcoding 1.
(detect_coding_system):
* lisp.h (detect_coding_system, chars_in_text, multibyte_chars_in_text)
(string_char_to_byte, string_byte_to_char, insert_from_gap):
* insdel.c (insert_from_gap):
* fns.c (string_char_byte_cache_charpos, string_char_byte_cache_bytepos)
(string_char_to_byte, string_byte_to_char, string_make_multibyte)
(string_to_multibyte):
* character.c (chars_in_text, multibyte_chars_in_text):
* fileio.c (Finsert_file_contents): Use EMACS_INT for buffer positions.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 11 | ||||
| -rw-r--r-- | src/character.c | 8 | ||||
| -rw-r--r-- | src/coding.c | 7 | ||||
| -rw-r--r-- | src/fileio.c | 12 | ||||
| -rw-r--r-- | src/fns.c | 30 | ||||
| -rw-r--r-- | src/insdel.c | 2 | ||||
| -rw-r--r-- | src/lisp.h | 14 |
7 files changed, 48 insertions, 36 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index a79548bd31f..cef846aa7f9 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,16 @@ | |||
| 1 | 2008-02-12 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2008-02-12 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * coding.c (coding_set_destination): Use BEG_BYTE rather than hardcoding 1. | ||
| 4 | (detect_coding_system): | ||
| 5 | * lisp.h (detect_coding_system, chars_in_text, multibyte_chars_in_text) | ||
| 6 | (string_char_to_byte, string_byte_to_char, insert_from_gap): | ||
| 7 | * insdel.c (insert_from_gap): | ||
| 8 | * fns.c (string_char_byte_cache_charpos, string_char_byte_cache_bytepos) | ||
| 9 | (string_char_to_byte, string_byte_to_char, string_make_multibyte) | ||
| 10 | (string_to_multibyte): | ||
| 11 | * character.c (chars_in_text, multibyte_chars_in_text): | ||
| 12 | * fileio.c (Finsert_file_contents): Use EMACS_INT for buffer positions. | ||
| 13 | |||
| 3 | * character.h (FETCH_STRING_CHAR_ADVANCE) | 14 | * character.h (FETCH_STRING_CHAR_ADVANCE) |
| 4 | (FETCH_STRING_CHAR_AS_MULTIBYTE_ADVANCE) | 15 | (FETCH_STRING_CHAR_AS_MULTIBYTE_ADVANCE) |
| 5 | (FETCH_STRING_CHAR_ADVANCE_NO_CHECK): Use SDATA and SREF. | 16 | (FETCH_STRING_CHAR_ADVANCE_NO_CHECK): Use SDATA and SREF. |
diff --git a/src/character.c b/src/character.c index 98256c9f9e2..9fa4dffc11f 100644 --- a/src/character.c +++ b/src/character.c | |||
| @@ -568,10 +568,10 @@ The returned value is 0 for left-to-right and 1 for right-to-left. */) | |||
| 568 | However, if the current buffer has enable-multibyte-characters = | 568 | However, if the current buffer has enable-multibyte-characters = |
| 569 | nil, we treat each byte as a character. */ | 569 | nil, we treat each byte as a character. */ |
| 570 | 570 | ||
| 571 | int | 571 | EMACS_INT |
| 572 | chars_in_text (ptr, nbytes) | 572 | chars_in_text (ptr, nbytes) |
| 573 | const unsigned char *ptr; | 573 | const unsigned char *ptr; |
| 574 | int nbytes; | 574 | EMACS_INT nbytes; |
| 575 | { | 575 | { |
| 576 | /* current_buffer is null at early stages of Emacs initialization. */ | 576 | /* current_buffer is null at early stages of Emacs initialization. */ |
| 577 | if (current_buffer == 0 | 577 | if (current_buffer == 0 |
| @@ -586,10 +586,10 @@ chars_in_text (ptr, nbytes) | |||
| 586 | sequences while assuming that there's no invalid sequence. It | 586 | sequences while assuming that there's no invalid sequence. It |
| 587 | ignores enable-multibyte-characters. */ | 587 | ignores enable-multibyte-characters. */ |
| 588 | 588 | ||
| 589 | int | 589 | EMACS_INT |
| 590 | multibyte_chars_in_text (ptr, nbytes) | 590 | multibyte_chars_in_text (ptr, nbytes) |
| 591 | const unsigned char *ptr; | 591 | const unsigned char *ptr; |
| 592 | int nbytes; | 592 | EMACS_INT nbytes; |
| 593 | { | 593 | { |
| 594 | const unsigned char *endp = ptr + nbytes; | 594 | const unsigned char *endp = ptr + nbytes; |
| 595 | int chars = 0; | 595 | int chars = 0; |
diff --git a/src/coding.c b/src/coding.c index 93726169585..8bac5c5ae80 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -999,7 +999,7 @@ coding_set_destination (coding) | |||
| 999 | { | 999 | { |
| 1000 | if (coding->src_pos < 0) | 1000 | if (coding->src_pos < 0) |
| 1001 | { | 1001 | { |
| 1002 | coding->destination = BEG_ADDR + coding->dst_pos_byte - 1; | 1002 | coding->destination = BEG_ADDR + coding->dst_pos_byte - BEG_BYTE; |
| 1003 | coding->dst_bytes = (GAP_END_ADDR | 1003 | coding->dst_bytes = (GAP_END_ADDR |
| 1004 | - (coding->src_bytes - coding->consumed) | 1004 | - (coding->src_bytes - coding->consumed) |
| 1005 | - coding->destination); | 1005 | - coding->destination); |
| @@ -1009,7 +1009,7 @@ coding_set_destination (coding) | |||
| 1009 | /* We are sure that coding->dst_pos_byte is before the gap | 1009 | /* We are sure that coding->dst_pos_byte is before the gap |
| 1010 | of the buffer. */ | 1010 | of the buffer. */ |
| 1011 | coding->destination = (BUF_BEG_ADDR (XBUFFER (coding->dst_object)) | 1011 | coding->destination = (BUF_BEG_ADDR (XBUFFER (coding->dst_object)) |
| 1012 | + coding->dst_pos_byte - 1); | 1012 | + coding->dst_pos_byte - BEG_BYTE); |
| 1013 | coding->dst_bytes = (BUF_GAP_END_ADDR (XBUFFER (coding->dst_object)) | 1013 | coding->dst_bytes = (BUF_GAP_END_ADDR (XBUFFER (coding->dst_object)) |
| 1014 | - coding->destination); | 1014 | - coding->destination); |
| 1015 | } | 1015 | } |
| @@ -7329,7 +7329,8 @@ Lisp_Object | |||
| 7329 | detect_coding_system (src, src_chars, src_bytes, highest, multibytep, | 7329 | detect_coding_system (src, src_chars, src_bytes, highest, multibytep, |
| 7330 | coding_system) | 7330 | coding_system) |
| 7331 | const unsigned char *src; | 7331 | const unsigned char *src; |
| 7332 | int src_chars, src_bytes, highest; | 7332 | EMACS_INT src_chars, src_bytes; |
| 7333 | int highest; | ||
| 7333 | int multibytep; | 7334 | int multibytep; |
| 7334 | Lisp_Object coding_system; | 7335 | Lisp_Object coding_system; |
| 7335 | { | 7336 | { |
diff --git a/src/fileio.c b/src/fileio.c index 76d076f75b2..9095cc45878 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -4183,12 +4183,12 @@ variable `last-coding-system-used' to the coding system actually used. */) | |||
| 4183 | in a more optimized way. */ | 4183 | in a more optimized way. */ |
| 4184 | if (!NILP (replace) && ! replace_handled && BEGV < ZV) | 4184 | if (!NILP (replace) && ! replace_handled && BEGV < ZV) |
| 4185 | { | 4185 | { |
| 4186 | int same_at_start = BEGV_BYTE; | 4186 | EMACS_INT same_at_start = BEGV_BYTE; |
| 4187 | int same_at_end = ZV_BYTE; | 4187 | EMACS_INT same_at_end = ZV_BYTE; |
| 4188 | int same_at_start_charpos; | 4188 | EMACS_INT same_at_start_charpos; |
| 4189 | int inserted_chars; | 4189 | EMACS_INT inserted_chars; |
| 4190 | int overlap; | 4190 | EMACS_INT overlap; |
| 4191 | int bufpos; | 4191 | EMACS_INT bufpos; |
| 4192 | unsigned char *decoded; | 4192 | unsigned char *decoded; |
| 4193 | int temp; | 4193 | int temp; |
| 4194 | int this_count = SPECPDL_INDEX (); | 4194 | int this_count = SPECPDL_INDEX (); |
| @@ -786,8 +786,8 @@ concat (nargs, args, target_type, last_special) | |||
| 786 | } | 786 | } |
| 787 | 787 | ||
| 788 | static Lisp_Object string_char_byte_cache_string; | 788 | static Lisp_Object string_char_byte_cache_string; |
| 789 | static int string_char_byte_cache_charpos; | 789 | static EMACS_INT string_char_byte_cache_charpos; |
| 790 | static int string_char_byte_cache_bytepos; | 790 | static EMACS_INT string_char_byte_cache_bytepos; |
| 791 | 791 | ||
| 792 | void | 792 | void |
| 793 | clear_string_char_byte_cache () | 793 | clear_string_char_byte_cache () |
| @@ -795,16 +795,16 @@ clear_string_char_byte_cache () | |||
| 795 | string_char_byte_cache_string = Qnil; | 795 | string_char_byte_cache_string = Qnil; |
| 796 | } | 796 | } |
| 797 | 797 | ||
| 798 | /* Return the character index corresponding to CHAR_INDEX in STRING. */ | 798 | /* Return the byte index corresponding to CHAR_INDEX in STRING. */ |
| 799 | 799 | ||
| 800 | int | 800 | EMACS_INT |
| 801 | string_char_to_byte (string, char_index) | 801 | string_char_to_byte (string, char_index) |
| 802 | Lisp_Object string; | 802 | Lisp_Object string; |
| 803 | int char_index; | 803 | EMACS_INT char_index; |
| 804 | { | 804 | { |
| 805 | int i_byte; | 805 | EMACS_INT i_byte; |
| 806 | int best_below, best_below_byte; | 806 | EMACS_INT best_below, best_below_byte; |
| 807 | int best_above, best_above_byte; | 807 | EMACS_INT best_above, best_above_byte; |
| 808 | 808 | ||
| 809 | best_below = best_below_byte = 0; | 809 | best_below = best_below_byte = 0; |
| 810 | best_above = SCHARS (string); | 810 | best_above = SCHARS (string); |
| @@ -859,14 +859,14 @@ string_char_to_byte (string, char_index) | |||
| 859 | 859 | ||
| 860 | /* Return the character index corresponding to BYTE_INDEX in STRING. */ | 860 | /* Return the character index corresponding to BYTE_INDEX in STRING. */ |
| 861 | 861 | ||
| 862 | int | 862 | EMACS_INT |
| 863 | string_byte_to_char (string, byte_index) | 863 | string_byte_to_char (string, byte_index) |
| 864 | Lisp_Object string; | 864 | Lisp_Object string; |
| 865 | int byte_index; | 865 | EMACS_INT byte_index; |
| 866 | { | 866 | { |
| 867 | int i, i_byte; | 867 | EMACS_INT i, i_byte; |
| 868 | int best_below, best_below_byte; | 868 | EMACS_INT best_below, best_below_byte; |
| 869 | int best_above, best_above_byte; | 869 | EMACS_INT best_above, best_above_byte; |
| 870 | 870 | ||
| 871 | best_below = best_below_byte = 0; | 871 | best_below = best_below_byte = 0; |
| 872 | best_above = SCHARS (string); | 872 | best_above = SCHARS (string); |
| @@ -930,7 +930,7 @@ string_make_multibyte (string) | |||
| 930 | Lisp_Object string; | 930 | Lisp_Object string; |
| 931 | { | 931 | { |
| 932 | unsigned char *buf; | 932 | unsigned char *buf; |
| 933 | int nbytes; | 933 | EMACS_INT nbytes; |
| 934 | Lisp_Object ret; | 934 | Lisp_Object ret; |
| 935 | USE_SAFE_ALLOCA; | 935 | USE_SAFE_ALLOCA; |
| 936 | 936 | ||
| @@ -964,7 +964,7 @@ string_to_multibyte (string) | |||
| 964 | Lisp_Object string; | 964 | Lisp_Object string; |
| 965 | { | 965 | { |
| 966 | unsigned char *buf; | 966 | unsigned char *buf; |
| 967 | int nbytes; | 967 | EMACS_INT nbytes; |
| 968 | Lisp_Object ret; | 968 | Lisp_Object ret; |
| 969 | USE_SAFE_ALLOCA; | 969 | USE_SAFE_ALLOCA; |
| 970 | 970 | ||
diff --git a/src/insdel.c b/src/insdel.c index dfc6a5ad551..2919c183ab7 100644 --- a/src/insdel.c +++ b/src/insdel.c | |||
| @@ -1172,7 +1172,7 @@ insert_from_string_1 (string, pos, pos_byte, nchars, nbytes, | |||
| 1172 | 1172 | ||
| 1173 | void | 1173 | void |
| 1174 | insert_from_gap (nchars, nbytes) | 1174 | insert_from_gap (nchars, nbytes) |
| 1175 | register int nchars, nbytes; | 1175 | register EMACS_INT nchars, nbytes; |
| 1176 | { | 1176 | { |
| 1177 | if (NILP (current_buffer->enable_multibyte_characters)) | 1177 | if (NILP (current_buffer->enable_multibyte_characters)) |
| 1178 | nchars = nbytes; | 1178 | nchars = nbytes; |
diff --git a/src/lisp.h b/src/lisp.h index 30e28b9ebb4..8221a85c13e 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -2281,8 +2281,8 @@ EXFUN (Ffind_operation_coding_system, MANY); | |||
| 2281 | EXFUN (Fupdate_coding_systems_internal, 0); | 2281 | EXFUN (Fupdate_coding_systems_internal, 0); |
| 2282 | EXFUN (Fencode_coding_string, 4); | 2282 | EXFUN (Fencode_coding_string, 4); |
| 2283 | EXFUN (Fdecode_coding_string, 4); | 2283 | EXFUN (Fdecode_coding_string, 4); |
| 2284 | extern Lisp_Object detect_coding_system P_ ((const unsigned char *, int, | 2284 | extern Lisp_Object detect_coding_system P_ ((const unsigned char *, EMACS_INT, |
| 2285 | int, int, int, Lisp_Object)); | 2285 | EMACS_INT, int, int, Lisp_Object)); |
| 2286 | extern void init_coding P_ ((void)); | 2286 | extern void init_coding P_ ((void)); |
| 2287 | extern void init_coding_once P_ ((void)); | 2287 | extern void init_coding_once P_ ((void)); |
| 2288 | extern void syms_of_coding P_ ((void)); | 2288 | extern void syms_of_coding P_ ((void)); |
| @@ -2296,8 +2296,8 @@ EXFUN (Funibyte_char_to_multibyte, 1); | |||
| 2296 | EXFUN (Fchar_bytes, 1); | 2296 | EXFUN (Fchar_bytes, 1); |
| 2297 | EXFUN (Fchar_width, 1); | 2297 | EXFUN (Fchar_width, 1); |
| 2298 | EXFUN (Fstring, MANY); | 2298 | EXFUN (Fstring, MANY); |
| 2299 | extern int chars_in_text P_ ((const unsigned char *, int)); | 2299 | extern EMACS_INT chars_in_text P_ ((const unsigned char *, EMACS_INT)); |
| 2300 | extern int multibyte_chars_in_text P_ ((const unsigned char *, int)); | 2300 | extern EMACS_INT multibyte_chars_in_text P_ ((const unsigned char *, EMACS_INT)); |
| 2301 | extern int multibyte_char_to_unibyte P_ ((int, Lisp_Object)); | 2301 | extern int multibyte_char_to_unibyte P_ ((int, Lisp_Object)); |
| 2302 | extern int multibyte_char_to_unibyte_safe P_ ((int)); | 2302 | extern int multibyte_char_to_unibyte_safe P_ ((int)); |
| 2303 | extern Lisp_Object Qcharset; | 2303 | extern Lisp_Object Qcharset; |
| @@ -2403,8 +2403,8 @@ extern Lisp_Object nconc2 P_ ((Lisp_Object, Lisp_Object)); | |||
| 2403 | extern Lisp_Object assq_no_quit P_ ((Lisp_Object, Lisp_Object)); | 2403 | extern Lisp_Object assq_no_quit P_ ((Lisp_Object, Lisp_Object)); |
| 2404 | extern Lisp_Object assoc_no_quit P_ ((Lisp_Object, Lisp_Object)); | 2404 | extern Lisp_Object assoc_no_quit P_ ((Lisp_Object, Lisp_Object)); |
| 2405 | extern void clear_string_char_byte_cache P_ ((void)); | 2405 | extern void clear_string_char_byte_cache P_ ((void)); |
| 2406 | extern int string_char_to_byte P_ ((Lisp_Object, int)); | 2406 | extern EMACS_INT string_char_to_byte P_ ((Lisp_Object, EMACS_INT)); |
| 2407 | extern int string_byte_to_char P_ ((Lisp_Object, int)); | 2407 | extern EMACS_INT string_byte_to_char P_ ((Lisp_Object, EMACS_INT)); |
| 2408 | extern Lisp_Object string_make_multibyte P_ ((Lisp_Object)); | 2408 | extern Lisp_Object string_make_multibyte P_ ((Lisp_Object)); |
| 2409 | extern Lisp_Object string_to_multibyte P_ ((Lisp_Object)); | 2409 | extern Lisp_Object string_to_multibyte P_ ((Lisp_Object)); |
| 2410 | extern Lisp_Object string_make_unibyte P_ ((Lisp_Object)); | 2410 | extern Lisp_Object string_make_unibyte P_ ((Lisp_Object)); |
| @@ -2448,7 +2448,7 @@ extern void insert P_ ((const unsigned char *, int)); | |||
| 2448 | extern void insert_and_inherit P_ ((const unsigned char *, int)); | 2448 | extern void insert_and_inherit P_ ((const unsigned char *, int)); |
| 2449 | extern void insert_1 P_ ((const unsigned char *, int, int, int, int)); | 2449 | extern void insert_1 P_ ((const unsigned char *, int, int, int, int)); |
| 2450 | extern void insert_1_both P_ ((const unsigned char *, int, int, int, int, int)); | 2450 | extern void insert_1_both P_ ((const unsigned char *, int, int, int, int, int)); |
| 2451 | extern void insert_from_gap P_ ((int, int)); | 2451 | extern void insert_from_gap P_ ((EMACS_INT, EMACS_INT)); |
| 2452 | extern void insert_from_string P_ ((Lisp_Object, int, int, int, int, int)); | 2452 | extern void insert_from_string P_ ((Lisp_Object, int, int, int, int, int)); |
| 2453 | extern void insert_from_buffer P_ ((struct buffer *, int, int, int)); | 2453 | extern void insert_from_buffer P_ ((struct buffer *, int, int, int)); |
| 2454 | extern void insert_char P_ ((int)); | 2454 | extern void insert_char P_ ((int)); |