Commit 13818c30 authored by Stefan Monnier's avatar Stefan Monnier

* 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.
parent 8b8bf8e6
2008-02-12 Stefan Monnier <monnier@iro.umontreal.ca> 2008-02-12 Stefan Monnier <monnier@iro.umontreal.ca>
* 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.
* character.h (FETCH_STRING_CHAR_ADVANCE) * character.h (FETCH_STRING_CHAR_ADVANCE)
(FETCH_STRING_CHAR_AS_MULTIBYTE_ADVANCE) (FETCH_STRING_CHAR_AS_MULTIBYTE_ADVANCE)
(FETCH_STRING_CHAR_ADVANCE_NO_CHECK): Use SDATA and SREF. (FETCH_STRING_CHAR_ADVANCE_NO_CHECK): Use SDATA and SREF.
......
...@@ -568,10 +568,10 @@ The returned value is 0 for left-to-right and 1 for right-to-left. */) ...@@ -568,10 +568,10 @@ The returned value is 0 for left-to-right and 1 for right-to-left. */)
However, if the current buffer has enable-multibyte-characters = However, if the current buffer has enable-multibyte-characters =
nil, we treat each byte as a character. */ nil, we treat each byte as a character. */
int EMACS_INT
chars_in_text (ptr, nbytes) chars_in_text (ptr, nbytes)
const unsigned char *ptr; const unsigned char *ptr;
int nbytes; EMACS_INT nbytes;
{ {
/* current_buffer is null at early stages of Emacs initialization. */ /* current_buffer is null at early stages of Emacs initialization. */
if (current_buffer == 0 if (current_buffer == 0
...@@ -586,10 +586,10 @@ chars_in_text (ptr, nbytes) ...@@ -586,10 +586,10 @@ chars_in_text (ptr, nbytes)
sequences while assuming that there's no invalid sequence. It sequences while assuming that there's no invalid sequence. It
ignores enable-multibyte-characters. */ ignores enable-multibyte-characters. */
int EMACS_INT
multibyte_chars_in_text (ptr, nbytes) multibyte_chars_in_text (ptr, nbytes)
const unsigned char *ptr; const unsigned char *ptr;
int nbytes; EMACS_INT nbytes;
{ {
const unsigned char *endp = ptr + nbytes; const unsigned char *endp = ptr + nbytes;
int chars = 0; int chars = 0;
......
...@@ -999,7 +999,7 @@ coding_set_destination (coding) ...@@ -999,7 +999,7 @@ coding_set_destination (coding)
{ {
if (coding->src_pos < 0) if (coding->src_pos < 0)
{ {
coding->destination = BEG_ADDR + coding->dst_pos_byte - 1; coding->destination = BEG_ADDR + coding->dst_pos_byte - BEG_BYTE;
coding->dst_bytes = (GAP_END_ADDR coding->dst_bytes = (GAP_END_ADDR
- (coding->src_bytes - coding->consumed) - (coding->src_bytes - coding->consumed)
- coding->destination); - coding->destination);
...@@ -1009,7 +1009,7 @@ coding_set_destination (coding) ...@@ -1009,7 +1009,7 @@ coding_set_destination (coding)
/* We are sure that coding->dst_pos_byte is before the gap /* We are sure that coding->dst_pos_byte is before the gap
of the buffer. */ of the buffer. */
coding->destination = (BUF_BEG_ADDR (XBUFFER (coding->dst_object)) coding->destination = (BUF_BEG_ADDR (XBUFFER (coding->dst_object))
+ coding->dst_pos_byte - 1); + coding->dst_pos_byte - BEG_BYTE);
coding->dst_bytes = (BUF_GAP_END_ADDR (XBUFFER (coding->dst_object)) coding->dst_bytes = (BUF_GAP_END_ADDR (XBUFFER (coding->dst_object))
- coding->destination); - coding->destination);
} }
...@@ -7329,7 +7329,8 @@ Lisp_Object ...@@ -7329,7 +7329,8 @@ Lisp_Object
detect_coding_system (src, src_chars, src_bytes, highest, multibytep, detect_coding_system (src, src_chars, src_bytes, highest, multibytep,
coding_system) coding_system)
const unsigned char *src; const unsigned char *src;
int src_chars, src_bytes, highest; EMACS_INT src_chars, src_bytes;
int highest;
int multibytep; int multibytep;
Lisp_Object coding_system; Lisp_Object coding_system;
{ {
......
...@@ -4183,12 +4183,12 @@ variable `last-coding-system-used' to the coding system actually used. */) ...@@ -4183,12 +4183,12 @@ variable `last-coding-system-used' to the coding system actually used. */)
in a more optimized way. */ in a more optimized way. */
if (!NILP (replace) && ! replace_handled && BEGV < ZV) if (!NILP (replace) && ! replace_handled && BEGV < ZV)
{ {
int same_at_start = BEGV_BYTE; EMACS_INT same_at_start = BEGV_BYTE;
int same_at_end = ZV_BYTE; EMACS_INT same_at_end = ZV_BYTE;
int same_at_start_charpos; EMACS_INT same_at_start_charpos;
int inserted_chars; EMACS_INT inserted_chars;
int overlap; EMACS_INT overlap;
int bufpos; EMACS_INT bufpos;
unsigned char *decoded; unsigned char *decoded;
int temp; int temp;
int this_count = SPECPDL_INDEX (); int this_count = SPECPDL_INDEX ();
......
...@@ -786,8 +786,8 @@ concat (nargs, args, target_type, last_special) ...@@ -786,8 +786,8 @@ concat (nargs, args, target_type, last_special)
} }
static Lisp_Object string_char_byte_cache_string; static Lisp_Object string_char_byte_cache_string;
static int string_char_byte_cache_charpos; static EMACS_INT string_char_byte_cache_charpos;
static int string_char_byte_cache_bytepos; static EMACS_INT string_char_byte_cache_bytepos;
void void
clear_string_char_byte_cache () clear_string_char_byte_cache ()
...@@ -795,16 +795,16 @@ clear_string_char_byte_cache () ...@@ -795,16 +795,16 @@ clear_string_char_byte_cache ()
string_char_byte_cache_string = Qnil; string_char_byte_cache_string = Qnil;
} }
/* Return the character index corresponding to CHAR_INDEX in STRING. */ /* Return the byte index corresponding to CHAR_INDEX in STRING. */
int EMACS_INT
string_char_to_byte (string, char_index) string_char_to_byte (string, char_index)
Lisp_Object string; Lisp_Object string;
int char_index; EMACS_INT char_index;
{ {
int i_byte; EMACS_INT i_byte;
int best_below, best_below_byte; EMACS_INT best_below, best_below_byte;
int best_above, best_above_byte; EMACS_INT best_above, best_above_byte;
best_below = best_below_byte = 0; best_below = best_below_byte = 0;
best_above = SCHARS (string); best_above = SCHARS (string);
...@@ -859,14 +859,14 @@ string_char_to_byte (string, char_index) ...@@ -859,14 +859,14 @@ string_char_to_byte (string, char_index)
/* Return the character index corresponding to BYTE_INDEX in STRING. */ /* Return the character index corresponding to BYTE_INDEX in STRING. */
int EMACS_INT
string_byte_to_char (string, byte_index) string_byte_to_char (string, byte_index)
Lisp_Object string; Lisp_Object string;
int byte_index; EMACS_INT byte_index;
{ {
int i, i_byte; EMACS_INT i, i_byte;
int best_below, best_below_byte; EMACS_INT best_below, best_below_byte;
int best_above, best_above_byte; EMACS_INT best_above, best_above_byte;
best_below = best_below_byte = 0; best_below = best_below_byte = 0;
best_above = SCHARS (string); best_above = SCHARS (string);
...@@ -930,7 +930,7 @@ string_make_multibyte (string) ...@@ -930,7 +930,7 @@ string_make_multibyte (string)
Lisp_Object string; Lisp_Object string;
{ {
unsigned char *buf; unsigned char *buf;
int nbytes; EMACS_INT nbytes;
Lisp_Object ret; Lisp_Object ret;
USE_SAFE_ALLOCA; USE_SAFE_ALLOCA;
...@@ -964,7 +964,7 @@ string_to_multibyte (string) ...@@ -964,7 +964,7 @@ string_to_multibyte (string)
Lisp_Object string; Lisp_Object string;
{ {
unsigned char *buf; unsigned char *buf;
int nbytes; EMACS_INT nbytes;
Lisp_Object ret; Lisp_Object ret;
USE_SAFE_ALLOCA; USE_SAFE_ALLOCA;
......
...@@ -1172,7 +1172,7 @@ insert_from_string_1 (string, pos, pos_byte, nchars, nbytes, ...@@ -1172,7 +1172,7 @@ insert_from_string_1 (string, pos, pos_byte, nchars, nbytes,
void void
insert_from_gap (nchars, nbytes) insert_from_gap (nchars, nbytes)
register int nchars, nbytes; register EMACS_INT nchars, nbytes;
{ {
if (NILP (current_buffer->enable_multibyte_characters)) if (NILP (current_buffer->enable_multibyte_characters))
nchars = nbytes; nchars = nbytes;
......
...@@ -2281,8 +2281,8 @@ EXFUN (Ffind_operation_coding_system, MANY); ...@@ -2281,8 +2281,8 @@ EXFUN (Ffind_operation_coding_system, MANY);
EXFUN (Fupdate_coding_systems_internal, 0); EXFUN (Fupdate_coding_systems_internal, 0);
EXFUN (Fencode_coding_string, 4); EXFUN (Fencode_coding_string, 4);
EXFUN (Fdecode_coding_string, 4); EXFUN (Fdecode_coding_string, 4);
extern Lisp_Object detect_coding_system P_ ((const unsigned char *, int, extern Lisp_Object detect_coding_system P_ ((const unsigned char *, EMACS_INT,
int, int, int, Lisp_Object)); EMACS_INT, int, int, Lisp_Object));
extern void init_coding P_ ((void)); extern void init_coding P_ ((void));
extern void init_coding_once P_ ((void)); extern void init_coding_once P_ ((void));
extern void syms_of_coding P_ ((void)); extern void syms_of_coding P_ ((void));
...@@ -2296,8 +2296,8 @@ EXFUN (Funibyte_char_to_multibyte, 1); ...@@ -2296,8 +2296,8 @@ EXFUN (Funibyte_char_to_multibyte, 1);
EXFUN (Fchar_bytes, 1); EXFUN (Fchar_bytes, 1);
EXFUN (Fchar_width, 1); EXFUN (Fchar_width, 1);
EXFUN (Fstring, MANY); EXFUN (Fstring, MANY);
extern int chars_in_text P_ ((const unsigned char *, int)); extern EMACS_INT chars_in_text P_ ((const unsigned char *, EMACS_INT));
extern int multibyte_chars_in_text P_ ((const unsigned char *, int)); extern EMACS_INT multibyte_chars_in_text P_ ((const unsigned char *, EMACS_INT));
extern int multibyte_char_to_unibyte P_ ((int, Lisp_Object)); extern int multibyte_char_to_unibyte P_ ((int, Lisp_Object));
extern int multibyte_char_to_unibyte_safe P_ ((int)); extern int multibyte_char_to_unibyte_safe P_ ((int));
extern Lisp_Object Qcharset; extern Lisp_Object Qcharset;
...@@ -2403,8 +2403,8 @@ extern Lisp_Object nconc2 P_ ((Lisp_Object, Lisp_Object)); ...@@ -2403,8 +2403,8 @@ extern Lisp_Object nconc2 P_ ((Lisp_Object, Lisp_Object));
extern Lisp_Object assq_no_quit P_ ((Lisp_Object, Lisp_Object)); extern Lisp_Object assq_no_quit P_ ((Lisp_Object, Lisp_Object));
extern Lisp_Object assoc_no_quit P_ ((Lisp_Object, Lisp_Object)); extern Lisp_Object assoc_no_quit P_ ((Lisp_Object, Lisp_Object));
extern void clear_string_char_byte_cache P_ ((void)); extern void clear_string_char_byte_cache P_ ((void));
extern int string_char_to_byte P_ ((Lisp_Object, int)); extern EMACS_INT string_char_to_byte P_ ((Lisp_Object, EMACS_INT));
extern int string_byte_to_char P_ ((Lisp_Object, int)); extern EMACS_INT string_byte_to_char P_ ((Lisp_Object, EMACS_INT));
extern Lisp_Object string_make_multibyte P_ ((Lisp_Object)); extern Lisp_Object string_make_multibyte P_ ((Lisp_Object));
extern Lisp_Object string_to_multibyte P_ ((Lisp_Object)); extern Lisp_Object string_to_multibyte P_ ((Lisp_Object));
extern Lisp_Object string_make_unibyte P_ ((Lisp_Object)); extern Lisp_Object string_make_unibyte P_ ((Lisp_Object));
...@@ -2448,7 +2448,7 @@ extern void insert P_ ((const unsigned char *, int)); ...@@ -2448,7 +2448,7 @@ extern void insert P_ ((const unsigned char *, int));
extern void insert_and_inherit P_ ((const unsigned char *, int)); extern void insert_and_inherit P_ ((const unsigned char *, int));
extern void insert_1 P_ ((const unsigned char *, int, int, int, int)); extern void insert_1 P_ ((const unsigned char *, int, int, int, int));
extern void insert_1_both P_ ((const unsigned char *, int, int, int, int, int)); extern void insert_1_both P_ ((const unsigned char *, int, int, int, int, int));
extern void insert_from_gap P_ ((int, int)); extern void insert_from_gap P_ ((EMACS_INT, EMACS_INT));
extern void insert_from_string P_ ((Lisp_Object, int, int, int, int, int)); extern void insert_from_string P_ ((Lisp_Object, int, int, int, int, int));
extern void insert_from_buffer P_ ((struct buffer *, int, int, int)); extern void insert_from_buffer P_ ((struct buffer *, int, int, int));
extern void insert_char P_ ((int)); extern void insert_char P_ ((int));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment