comparison src/coding.c @ 21244:50929073a0ba

Use STRING_BYTES and SET_STRING_BYTES.
author Richard M. Stallman <rms@gnu.org>
date Sat, 21 Mar 1998 07:06:14 +0000
parents d704dd953837
children 606fe1bb94e6
comparison
equal deleted inserted replaced
21243:e82a4a4fa12a 21244:50929073a0ba
4281 struct coding_system *coding; 4281 struct coding_system *coding;
4282 int encodep, nocopy; 4282 int encodep, nocopy;
4283 { 4283 {
4284 int len; 4284 int len;
4285 char *buf; 4285 char *buf;
4286 int from = 0, to = XSTRING (str)->size, to_byte = XSTRING (str)->size_byte; 4286 int from = 0, to = XSTRING (str)->size;
4287 int to_byte = STRING_BYTES (XSTRING (str));
4287 struct gcpro gcpro1; 4288 struct gcpro gcpro1;
4288 Lisp_Object saved_coding_symbol = Qnil; 4289 Lisp_Object saved_coding_symbol = Qnil;
4289 int result; 4290 int result;
4290 4291
4291 if (encodep && !NILP (coding->pre_write_conversion) 4292 if (encodep && !NILP (coding->pre_write_conversion)
4357 4358
4358 if (encodep) 4359 if (encodep)
4359 len = encoding_buffer_size (coding, to_byte - from); 4360 len = encoding_buffer_size (coding, to_byte - from);
4360 else 4361 else
4361 len = decoding_buffer_size (coding, to_byte - from); 4362 len = decoding_buffer_size (coding, to_byte - from);
4362 len += from + XSTRING (str)->size_byte - to_byte; 4363 len += from + STRING_BYTES (XSTRING (str)) - to_byte;
4363 GCPRO1 (str); 4364 GCPRO1 (str);
4364 buf = get_conversion_buffer (len); 4365 buf = get_conversion_buffer (len);
4365 UNGCPRO; 4366 UNGCPRO;
4366 4367
4367 if (from > 0) 4368 if (from > 0)
4379 coding->symbol = saved_coding_symbol; 4380 coding->symbol = saved_coding_symbol;
4380 return code_convert_string (str, coding, encodep, nocopy); 4381 return code_convert_string (str, coding, encodep, nocopy);
4381 } 4382 }
4382 4383
4383 bcopy (XSTRING (str)->data + to_byte, buf + from + coding->produced, 4384 bcopy (XSTRING (str)->data + to_byte, buf + from + coding->produced,
4384 XSTRING (str)->size_byte - to_byte); 4385 STRING_BYTES (XSTRING (str)) - to_byte);
4385 4386
4386 len = from + XSTRING (str)->size_byte - to_byte; 4387 len = from + STRING_BYTES (XSTRING (str)) - to_byte;
4387 if (encodep) 4388 if (encodep)
4388 str = make_unibyte_string (buf, len + coding->produced); 4389 str = make_unibyte_string (buf, len + coding->produced);
4389 else 4390 else
4390 str = make_multibyte_string (buf, len + coding->produced_char, 4391 str = make_multibyte_string (buf, len + coding->produced_char,
4391 len + coding->produced); 4392 len + coding->produced);
4563 Lisp_Object string, highest; 4564 Lisp_Object string, highest;
4564 { 4565 {
4565 CHECK_STRING (string, 0); 4566 CHECK_STRING (string, 0);
4566 4567
4567 return detect_coding_system (XSTRING (string)->data, 4568 return detect_coding_system (XSTRING (string)->data,
4568 XSTRING (string)->size_byte, 4569 STRING_BYTES (XSTRING (string)),
4569 !NILP (highest)); 4570 !NILP (highest));
4570 } 4571 }
4571 4572
4572 Lisp_Object 4573 Lisp_Object
4573 code_convert_region1 (start, end, coding_system, encodep) 4574 code_convert_region1 (start, end, coding_system, encodep)