Commit a4244313 authored by Ken Raeburn's avatar Ken Raeburn

(encode_eol, detect_coding, detect_eol):

(decode_coding, encode_coding, detect_coding_system): Source
strings now treated as const.
(decode_coding_string, encode_coding_string): Use STRING_COPYIN to
modify Lisp string contents.
parent a9fb257e
...@@ -1061,7 +1061,7 @@ decode_coding_emacs_mule (coding, source, destination, src_bytes, dst_bytes) ...@@ -1061,7 +1061,7 @@ decode_coding_emacs_mule (coding, source, destination, src_bytes, dst_bytes)
} while (0) } while (0)
static void encode_eol P_ ((struct coding_system *, unsigned char *, static void encode_eol P_ ((struct coding_system *, const unsigned char *,
unsigned char *, int, int)); unsigned char *, int, int));
static void static void
...@@ -3236,12 +3236,13 @@ decode_eol (coding, source, destination, src_bytes, dst_bytes) ...@@ -3236,12 +3236,13 @@ decode_eol (coding, source, destination, src_bytes, dst_bytes)
static void static void
encode_eol (coding, source, destination, src_bytes, dst_bytes) encode_eol (coding, source, destination, src_bytes, dst_bytes)
struct coding_system *coding; struct coding_system *coding;
unsigned char *source, *destination; const unsigned char *source;
unsigned char *destination;
int src_bytes, dst_bytes; int src_bytes, dst_bytes;
{ {
unsigned char *src = source; const unsigned char *src = source;
unsigned char *dst = destination; unsigned char *dst = destination;
unsigned char *src_end = src + src_bytes; const unsigned char *src_end = src + src_bytes;
unsigned char *dst_end = dst + dst_bytes; unsigned char *dst_end = dst + dst_bytes;
Lisp_Object translation_table; Lisp_Object translation_table;
/* SRC_BASE remembers the start position in source in each loop. /* SRC_BASE remembers the start position in source in each loop.
...@@ -3249,7 +3250,8 @@ encode_eol (coding, source, destination, src_bytes, dst_bytes) ...@@ -3249,7 +3250,8 @@ encode_eol (coding, source, destination, src_bytes, dst_bytes)
analyze multi-byte codes (within macro ONE_MORE_CHAR), or when analyze multi-byte codes (within macro ONE_MORE_CHAR), or when
there's not enough destination area to produce encoded codes there's not enough destination area to produce encoded codes
(within macro EMIT_BYTES). */ (within macro EMIT_BYTES). */
unsigned char *src_base; const unsigned char *src_base;
unsigned char *tmp;
int c; int c;
int selective_display = coding->mode & CODING_MODE_SELECTIVE_DISPLAY; int selective_display = coding->mode & CODING_MODE_SELECTIVE_DISPLAY;
...@@ -3299,13 +3301,13 @@ encode_eol (coding, source, destination, src_bytes, dst_bytes) ...@@ -3299,13 +3301,13 @@ encode_eol (coding, source, destination, src_bytes, dst_bytes)
} }
if (coding->eol_type == CODING_EOL_CR) if (coding->eol_type == CODING_EOL_CR)
{ {
for (src = destination; src < dst; src++) for (tmp = destination; tmp < dst; tmp++)
if (*src == '\n') *src = '\r'; if (*tmp == '\n') *tmp = '\r';
} }
else if (selective_display) else if (selective_display)
{ {
for (src = destination; src < dst; src++) for (tmp = destination; tmp < dst; tmp++)
if (*src == '\r') *src = '\n'; if (*tmp == '\r') *tmp = '\n';
} }
} }
if (coding->src_multibyte) if (coding->src_multibyte)
...@@ -4094,7 +4096,7 @@ detect_coding_mask (source, src_bytes, priorities, skip, multibytep) ...@@ -4094,7 +4096,7 @@ detect_coding_mask (source, src_bytes, priorities, skip, multibytep)
void void
detect_coding (coding, src, src_bytes) detect_coding (coding, src, src_bytes)
struct coding_system *coding; struct coding_system *coding;
unsigned char *src; const unsigned char *src;
int src_bytes; int src_bytes;
{ {
unsigned int idx; unsigned int idx;
...@@ -4267,7 +4269,7 @@ detect_eol_type_in_2_octet_form (source, src_bytes, skip, big_endian_p) ...@@ -4267,7 +4269,7 @@ detect_eol_type_in_2_octet_form (source, src_bytes, skip, big_endian_p)
void void
detect_eol (coding, src, src_bytes) detect_eol (coding, src, src_bytes)
struct coding_system *coding; struct coding_system *coding;
unsigned char *src; const unsigned char *src;
int src_bytes; int src_bytes;
{ {
Lisp_Object val; Lisp_Object val;
...@@ -4685,7 +4687,8 @@ decode_eol_post_ccl (coding, ptr, bytes) ...@@ -4685,7 +4687,8 @@ decode_eol_post_ccl (coding, ptr, bytes)
int int
decode_coding (coding, source, destination, src_bytes, dst_bytes) decode_coding (coding, source, destination, src_bytes, dst_bytes)
struct coding_system *coding; struct coding_system *coding;
unsigned char *source, *destination; const unsigned char *source;
unsigned char *destination;
int src_bytes, dst_bytes; int src_bytes, dst_bytes;
{ {
int extra = 0; int extra = 0;
...@@ -4764,7 +4767,7 @@ decode_coding (coding, source, destination, src_bytes, dst_bytes) ...@@ -4764,7 +4767,7 @@ decode_coding (coding, source, destination, src_bytes, dst_bytes)
if (coding->mode & CODING_MODE_LAST_BLOCK if (coding->mode & CODING_MODE_LAST_BLOCK
&& coding->result == CODING_FINISH_INSUFFICIENT_SRC) && coding->result == CODING_FINISH_INSUFFICIENT_SRC)
{ {
unsigned char *src = source + coding->consumed; const unsigned char *src = source + coding->consumed;
unsigned char *dst = destination + coding->produced; unsigned char *dst = destination + coding->produced;
src_bytes -= coding->consumed; src_bytes -= coding->consumed;
...@@ -4798,7 +4801,8 @@ decode_coding (coding, source, destination, src_bytes, dst_bytes) ...@@ -4798,7 +4801,8 @@ decode_coding (coding, source, destination, src_bytes, dst_bytes)
int int
encode_coding (coding, source, destination, src_bytes, dst_bytes) encode_coding (coding, source, destination, src_bytes, dst_bytes)
struct coding_system *coding; struct coding_system *coding;
unsigned char *source, *destination; const unsigned char *source;
unsigned char *destination;
int src_bytes, dst_bytes; int src_bytes, dst_bytes;
{ {
coding->produced = coding->produced_char = 0; coding->produced = coding->produced_char = 0;
...@@ -4840,7 +4844,7 @@ encode_coding (coding, source, destination, src_bytes, dst_bytes) ...@@ -4840,7 +4844,7 @@ encode_coding (coding, source, destination, src_bytes, dst_bytes)
if (coding->mode & CODING_MODE_LAST_BLOCK if (coding->mode & CODING_MODE_LAST_BLOCK
&& coding->result == CODING_FINISH_INSUFFICIENT_SRC) && coding->result == CODING_FINISH_INSUFFICIENT_SRC)
{ {
unsigned char *src = source + coding->consumed; const unsigned char *src = source + coding->consumed;
unsigned char *dst = destination + coding->produced; unsigned char *dst = destination + coding->produced;
if (coding->type == coding_type_iso2022) if (coding->type == coding_type_iso2022)
...@@ -6014,12 +6018,12 @@ decode_coding_string (str, coding, nocopy) ...@@ -6014,12 +6018,12 @@ decode_coding_string (str, coding, nocopy)
else else
newstr = make_uninit_string (produced + shrinked_bytes); newstr = make_uninit_string (produced + shrinked_bytes);
if (from > 0) if (from > 0)
bcopy (SDATA (str), SDATA (newstr), from); STRING_COPYIN (newstr, 0, SDATA (str), from);
bcopy (buf.data, SDATA (newstr) + from, produced); STRING_COPYIN (newstr, from, buf.data, produced);
if (shrinked_bytes > from) if (shrinked_bytes > from)
bcopy (SDATA (str) + to_byte, STRING_COPYIN (newstr, from + produced,
SDATA (newstr) + from + produced, SDATA (str) + to_byte,
shrinked_bytes - from); shrinked_bytes - from);
free_conversion_buffer (&buf); free_conversion_buffer (&buf);
if (coding->cmp_data && coding->cmp_data->used) if (coding->cmp_data && coding->cmp_data->used)
...@@ -6114,12 +6118,12 @@ encode_coding_string (str, coding, nocopy) ...@@ -6114,12 +6118,12 @@ encode_coding_string (str, coding, nocopy)
newstr = make_uninit_string (produced + shrinked_bytes); newstr = make_uninit_string (produced + shrinked_bytes);
if (from > 0) if (from > 0)
bcopy (SDATA (str), SDATA (newstr), from); STRING_COPYIN (newstr, 0, SDATA (str), from);
bcopy (buf.data, SDATA (newstr) + from, produced); STRING_COPYIN (newstr, from, buf.data, produced);
if (shrinked_bytes > from) if (shrinked_bytes > from)
bcopy (SDATA (str) + to_byte, STRING_COPYIN (newstr, from + produced,
SDATA (newstr) + from + produced, SDATA (str) + to_byte,
shrinked_bytes - from); shrinked_bytes - from);
free_conversion_buffer (&buf); free_conversion_buffer (&buf);
coding_free_composition_data (coding); coding_free_composition_data (coding);
...@@ -6197,7 +6201,7 @@ The value of property should be a vector of length 5. */) ...@@ -6197,7 +6201,7 @@ The value of property should be a vector of length 5. */)
Lisp_Object Lisp_Object
detect_coding_system (src, src_bytes, highest, multibytep) detect_coding_system (src, src_bytes, highest, multibytep)
unsigned char *src; const unsigned char *src;
int src_bytes, highest; int src_bytes, highest;
int multibytep; int multibytep;
{ {
......
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