diff options
| author | Ken Raeburn | 2002-07-15 00:01:34 +0000 |
|---|---|---|
| committer | Ken Raeburn | 2002-07-15 00:01:34 +0000 |
| commit | d5db40779d7505244d37476b4f046641f07eea2b (patch) | |
| tree | 5c8bf4dad41639287e722cb7cbdc0709e47a9e53 /src/coding.c | |
| parent | 491c2516d32fa8b9ba9422ec142c8925dd82af00 (diff) | |
| download | emacs-d5db40779d7505244d37476b4f046641f07eea2b.tar.gz emacs-d5db40779d7505244d37476b4f046641f07eea2b.zip | |
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
SCHARS, SBYTES, STRING_INTERVALS, SREF, SDATA; explicit size_byte references
left unchanged for now.
Diffstat (limited to 'src/coding.c')
| -rw-r--r-- | src/coding.c | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/src/coding.c b/src/coding.c index af23b636764..0afe0b3ac42 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -5224,7 +5224,7 @@ coding_save_composition (coding, from, to, obj) | |||
| 5224 | else if (VECTORP (val) || STRINGP (val)) | 5224 | else if (VECTORP (val) || STRINGP (val)) |
| 5225 | { | 5225 | { |
| 5226 | int len = (VECTORP (val) | 5226 | int len = (VECTORP (val) |
| 5227 | ? XVECTOR (val)->size : XSTRING (val)->size); | 5227 | ? XVECTOR (val)->size : SCHARS (val)); |
| 5228 | int i; | 5228 | int i; |
| 5229 | for (i = 0; i < len; i++) | 5229 | for (i = 0; i < len; i++) |
| 5230 | { | 5230 | { |
| @@ -5832,7 +5832,7 @@ run_pre_post_conversion_on_str (str, coding, encodep) | |||
| 5832 | buf->enable_multibyte_characters = multibyte ? Qt : Qnil; | 5832 | buf->enable_multibyte_characters = multibyte ? Qt : Qnil; |
| 5833 | 5833 | ||
| 5834 | insert_from_string (str, 0, 0, | 5834 | insert_from_string (str, 0, 0, |
| 5835 | XSTRING (str)->size, STRING_BYTES (XSTRING (str)), 0); | 5835 | SCHARS (str), SBYTES (str), 0); |
| 5836 | UNGCPRO; | 5836 | UNGCPRO; |
| 5837 | inhibit_pre_post_conversion = 1; | 5837 | inhibit_pre_post_conversion = 1; |
| 5838 | if (encodep) | 5838 | if (encodep) |
| @@ -5864,7 +5864,7 @@ decode_coding_string (str, coding, nocopy) | |||
| 5864 | int consumed, consumed_char, produced, produced_char; | 5864 | int consumed, consumed_char, produced, produced_char; |
| 5865 | 5865 | ||
| 5866 | from = 0; | 5866 | from = 0; |
| 5867 | to_byte = STRING_BYTES (XSTRING (str)); | 5867 | to_byte = SBYTES (str); |
| 5868 | 5868 | ||
| 5869 | saved_coding_symbol = coding->symbol; | 5869 | saved_coding_symbol = coding->symbol; |
| 5870 | coding->src_multibyte = STRING_MULTIBYTE (str); | 5870 | coding->src_multibyte = STRING_MULTIBYTE (str); |
| @@ -5874,7 +5874,7 @@ decode_coding_string (str, coding, nocopy) | |||
| 5874 | /* See the comments in code_convert_region. */ | 5874 | /* See the comments in code_convert_region. */ |
| 5875 | if (coding->type == coding_type_undecided) | 5875 | if (coding->type == coding_type_undecided) |
| 5876 | { | 5876 | { |
| 5877 | detect_coding (coding, XSTRING (str)->data, to_byte); | 5877 | detect_coding (coding, SDATA (str), to_byte); |
| 5878 | if (coding->type == coding_type_undecided) | 5878 | if (coding->type == coding_type_undecided) |
| 5879 | { | 5879 | { |
| 5880 | coding->type = coding_type_emacs_mule; | 5880 | coding->type = coding_type_emacs_mule; |
| @@ -5889,7 +5889,7 @@ decode_coding_string (str, coding, nocopy) | |||
| 5889 | && coding->type != coding_type_ccl) | 5889 | && coding->type != coding_type_ccl) |
| 5890 | { | 5890 | { |
| 5891 | saved_coding_symbol = coding->symbol; | 5891 | saved_coding_symbol = coding->symbol; |
| 5892 | detect_eol (coding, XSTRING (str)->data, to_byte); | 5892 | detect_eol (coding, SDATA (str), to_byte); |
| 5893 | if (coding->eol_type == CODING_EOL_UNDECIDED) | 5893 | if (coding->eol_type == CODING_EOL_UNDECIDED) |
| 5894 | coding->eol_type = CODING_EOL_LF; | 5894 | coding->eol_type = CODING_EOL_LF; |
| 5895 | /* We had better recover the original eol format if we | 5895 | /* We had better recover the original eol format if we |
| @@ -5908,7 +5908,7 @@ decode_coding_string (str, coding, nocopy) | |||
| 5908 | { | 5908 | { |
| 5909 | /* Decoding routines expect the source text to be unibyte. */ | 5909 | /* Decoding routines expect the source text to be unibyte. */ |
| 5910 | str = Fstring_as_unibyte (str); | 5910 | str = Fstring_as_unibyte (str); |
| 5911 | to_byte = STRING_BYTES (XSTRING (str)); | 5911 | to_byte = SBYTES (str); |
| 5912 | nocopy = 1; | 5912 | nocopy = 1; |
| 5913 | coding->src_multibyte = 0; | 5913 | coding->src_multibyte = 0; |
| 5914 | } | 5914 | } |
| @@ -5916,24 +5916,24 @@ decode_coding_string (str, coding, nocopy) | |||
| 5916 | /* Try to skip the heading and tailing ASCIIs. */ | 5916 | /* Try to skip the heading and tailing ASCIIs. */ |
| 5917 | if (require_decoding && coding->type != coding_type_ccl) | 5917 | if (require_decoding && coding->type != coding_type_ccl) |
| 5918 | { | 5918 | { |
| 5919 | SHRINK_CONVERSION_REGION (&from, &to_byte, coding, XSTRING (str)->data, | 5919 | SHRINK_CONVERSION_REGION (&from, &to_byte, coding, SDATA (str), |
| 5920 | 0); | 5920 | 0); |
| 5921 | if (from == to_byte) | 5921 | if (from == to_byte) |
| 5922 | require_decoding = 0; | 5922 | require_decoding = 0; |
| 5923 | shrinked_bytes = from + (STRING_BYTES (XSTRING (str)) - to_byte); | 5923 | shrinked_bytes = from + (SBYTES (str) - to_byte); |
| 5924 | } | 5924 | } |
| 5925 | 5925 | ||
| 5926 | if (!require_decoding) | 5926 | if (!require_decoding) |
| 5927 | { | 5927 | { |
| 5928 | coding->consumed = STRING_BYTES (XSTRING (str)); | 5928 | coding->consumed = SBYTES (str); |
| 5929 | coding->consumed_char = XSTRING (str)->size; | 5929 | coding->consumed_char = SCHARS (str); |
| 5930 | if (coding->dst_multibyte) | 5930 | if (coding->dst_multibyte) |
| 5931 | { | 5931 | { |
| 5932 | str = Fstring_as_multibyte (str); | 5932 | str = Fstring_as_multibyte (str); |
| 5933 | nocopy = 1; | 5933 | nocopy = 1; |
| 5934 | } | 5934 | } |
| 5935 | coding->produced = STRING_BYTES (XSTRING (str)); | 5935 | coding->produced = SBYTES (str); |
| 5936 | coding->produced_char = XSTRING (str)->size; | 5936 | coding->produced_char = SCHARS (str); |
| 5937 | return (nocopy ? str : Fcopy_sequence (str)); | 5937 | return (nocopy ? str : Fcopy_sequence (str)); |
| 5938 | } | 5938 | } |
| 5939 | 5939 | ||
| @@ -5945,7 +5945,7 @@ decode_coding_string (str, coding, nocopy) | |||
| 5945 | consumed = consumed_char = produced = produced_char = 0; | 5945 | consumed = consumed_char = produced = produced_char = 0; |
| 5946 | while (1) | 5946 | while (1) |
| 5947 | { | 5947 | { |
| 5948 | result = decode_coding (coding, XSTRING (str)->data + from + consumed, | 5948 | result = decode_coding (coding, SDATA (str) + from + consumed, |
| 5949 | buf.data + produced, to_byte - from - consumed, | 5949 | buf.data + produced, to_byte - from - consumed, |
| 5950 | buf.size - produced); | 5950 | buf.size - produced); |
| 5951 | consumed += coding->consumed; | 5951 | consumed += coding->consumed; |
| @@ -6014,11 +6014,11 @@ decode_coding_string (str, coding, nocopy) | |||
| 6014 | else | 6014 | else |
| 6015 | newstr = make_uninit_string (produced + shrinked_bytes); | 6015 | newstr = make_uninit_string (produced + shrinked_bytes); |
| 6016 | if (from > 0) | 6016 | if (from > 0) |
| 6017 | bcopy (XSTRING (str)->data, XSTRING (newstr)->data, from); | 6017 | bcopy (SDATA (str), SDATA (newstr), from); |
| 6018 | bcopy (buf.data, XSTRING (newstr)->data + from, produced); | 6018 | bcopy (buf.data, SDATA (newstr) + from, produced); |
| 6019 | if (shrinked_bytes > from) | 6019 | if (shrinked_bytes > from) |
| 6020 | bcopy (XSTRING (str)->data + to_byte, | 6020 | bcopy (SDATA (str) + to_byte, |
| 6021 | XSTRING (newstr)->data + from + produced, | 6021 | SDATA (newstr) + from + produced, |
| 6022 | shrinked_bytes - from); | 6022 | shrinked_bytes - from); |
| 6023 | free_conversion_buffer (&buf); | 6023 | free_conversion_buffer (&buf); |
| 6024 | 6024 | ||
| @@ -6052,8 +6052,8 @@ encode_coding_string (str, coding, nocopy) | |||
| 6052 | str = run_pre_post_conversion_on_str (str, coding, 1); | 6052 | str = run_pre_post_conversion_on_str (str, coding, 1); |
| 6053 | 6053 | ||
| 6054 | from = 0; | 6054 | from = 0; |
| 6055 | to = XSTRING (str)->size; | 6055 | to = SCHARS (str); |
| 6056 | to_byte = STRING_BYTES (XSTRING (str)); | 6056 | to_byte = SBYTES (str); |
| 6057 | 6057 | ||
| 6058 | /* Encoding routines determine the multibyteness of the source text | 6058 | /* Encoding routines determine the multibyteness of the source text |
| 6059 | by coding->src_multibyte. */ | 6059 | by coding->src_multibyte. */ |
| @@ -6061,15 +6061,15 @@ encode_coding_string (str, coding, nocopy) | |||
| 6061 | coding->dst_multibyte = 0; | 6061 | coding->dst_multibyte = 0; |
| 6062 | if (! CODING_REQUIRE_ENCODING (coding)) | 6062 | if (! CODING_REQUIRE_ENCODING (coding)) |
| 6063 | { | 6063 | { |
| 6064 | coding->consumed = STRING_BYTES (XSTRING (str)); | 6064 | coding->consumed = SBYTES (str); |
| 6065 | coding->consumed_char = XSTRING (str)->size; | 6065 | coding->consumed_char = SCHARS (str); |
| 6066 | if (STRING_MULTIBYTE (str)) | 6066 | if (STRING_MULTIBYTE (str)) |
| 6067 | { | 6067 | { |
| 6068 | str = Fstring_as_unibyte (str); | 6068 | str = Fstring_as_unibyte (str); |
| 6069 | nocopy = 1; | 6069 | nocopy = 1; |
| 6070 | } | 6070 | } |
| 6071 | coding->produced = STRING_BYTES (XSTRING (str)); | 6071 | coding->produced = SBYTES (str); |
| 6072 | coding->produced_char = XSTRING (str)->size; | 6072 | coding->produced_char = SCHARS (str); |
| 6073 | return (nocopy ? str : Fcopy_sequence (str)); | 6073 | return (nocopy ? str : Fcopy_sequence (str)); |
| 6074 | } | 6074 | } |
| 6075 | 6075 | ||
| @@ -6079,11 +6079,11 @@ encode_coding_string (str, coding, nocopy) | |||
| 6079 | /* Try to skip the heading and tailing ASCIIs. */ | 6079 | /* Try to skip the heading and tailing ASCIIs. */ |
| 6080 | if (coding->type != coding_type_ccl) | 6080 | if (coding->type != coding_type_ccl) |
| 6081 | { | 6081 | { |
| 6082 | SHRINK_CONVERSION_REGION (&from, &to_byte, coding, XSTRING (str)->data, | 6082 | SHRINK_CONVERSION_REGION (&from, &to_byte, coding, SDATA (str), |
| 6083 | 1); | 6083 | 1); |
| 6084 | if (from == to_byte) | 6084 | if (from == to_byte) |
| 6085 | return (nocopy ? str : Fcopy_sequence (str)); | 6085 | return (nocopy ? str : Fcopy_sequence (str)); |
| 6086 | shrinked_bytes = from + (STRING_BYTES (XSTRING (str)) - to_byte); | 6086 | shrinked_bytes = from + (SBYTES (str) - to_byte); |
| 6087 | } | 6087 | } |
| 6088 | 6088 | ||
| 6089 | len = encoding_buffer_size (coding, to_byte - from); | 6089 | len = encoding_buffer_size (coding, to_byte - from); |
| @@ -6092,7 +6092,7 @@ encode_coding_string (str, coding, nocopy) | |||
| 6092 | consumed = consumed_char = produced = produced_char = 0; | 6092 | consumed = consumed_char = produced = produced_char = 0; |
| 6093 | while (1) | 6093 | while (1) |
| 6094 | { | 6094 | { |
| 6095 | result = encode_coding (coding, XSTRING (str)->data + from + consumed, | 6095 | result = encode_coding (coding, SDATA (str) + from + consumed, |
| 6096 | buf.data + produced, to_byte - from - consumed, | 6096 | buf.data + produced, to_byte - from - consumed, |
| 6097 | buf.size - produced); | 6097 | buf.size - produced); |
| 6098 | consumed += coding->consumed; | 6098 | consumed += coding->consumed; |
| @@ -6114,11 +6114,11 @@ encode_coding_string (str, coding, nocopy) | |||
| 6114 | 6114 | ||
| 6115 | newstr = make_uninit_string (produced + shrinked_bytes); | 6115 | newstr = make_uninit_string (produced + shrinked_bytes); |
| 6116 | if (from > 0) | 6116 | if (from > 0) |
| 6117 | bcopy (XSTRING (str)->data, XSTRING (newstr)->data, from); | 6117 | bcopy (SDATA (str), SDATA (newstr), from); |
| 6118 | bcopy (buf.data, XSTRING (newstr)->data + from, produced); | 6118 | bcopy (buf.data, SDATA (newstr) + from, produced); |
| 6119 | if (shrinked_bytes > from) | 6119 | if (shrinked_bytes > from) |
| 6120 | bcopy (XSTRING (str)->data + to_byte, | 6120 | bcopy (SDATA (str) + to_byte, |
| 6121 | XSTRING (newstr)->data + from + produced, | 6121 | SDATA (newstr) + from + produced, |
| 6122 | shrinked_bytes - from); | 6122 | shrinked_bytes - from); |
| 6123 | 6123 | ||
| 6124 | free_conversion_buffer (&buf); | 6124 | free_conversion_buffer (&buf); |
| @@ -6160,7 +6160,7 @@ DEFUN ("read-non-nil-coding-system", Fread_non_nil_coding_system, | |||
| 6160 | val = Fcompleting_read (prompt, Vcoding_system_alist, Qnil, | 6160 | val = Fcompleting_read (prompt, Vcoding_system_alist, Qnil, |
| 6161 | Qt, Qnil, Qcoding_system_history, Qnil, Qnil); | 6161 | Qt, Qnil, Qcoding_system_history, Qnil, Qnil); |
| 6162 | } | 6162 | } |
| 6163 | while (XSTRING (val)->size == 0); | 6163 | while (SCHARS (val) == 0); |
| 6164 | return (Fintern (val, Qnil)); | 6164 | return (Fintern (val, Qnil)); |
| 6165 | } | 6165 | } |
| 6166 | 6166 | ||
| @@ -6176,7 +6176,7 @@ If the user enters null input, return second argument DEFAULT-CODING-SYSTEM. */ | |||
| 6176 | val = Fcompleting_read (prompt, Vcoding_system_alist, Qnil, | 6176 | val = Fcompleting_read (prompt, Vcoding_system_alist, Qnil, |
| 6177 | Qt, Qnil, Qcoding_system_history, | 6177 | Qt, Qnil, Qcoding_system_history, |
| 6178 | default_coding_system, Qnil); | 6178 | default_coding_system, Qnil); |
| 6179 | return (XSTRING (val)->size == 0 ? Qnil : Fintern (val, Qnil)); | 6179 | return (SCHARS (val) == 0 ? Qnil : Fintern (val, Qnil)); |
| 6180 | } | 6180 | } |
| 6181 | 6181 | ||
| 6182 | DEFUN ("check-coding-system", Fcheck_coding_system, Scheck_coding_system, | 6182 | DEFUN ("check-coding-system", Fcheck_coding_system, Scheck_coding_system, |
| @@ -6318,12 +6318,12 @@ highest priority. */) | |||
| 6318 | { | 6318 | { |
| 6319 | CHECK_STRING (string); | 6319 | CHECK_STRING (string); |
| 6320 | 6320 | ||
| 6321 | return detect_coding_system (XSTRING (string)->data, | 6321 | return detect_coding_system (SDATA (string), |
| 6322 | /* "+ 1" is to include the anchor byte | 6322 | /* "+ 1" is to include the anchor byte |
| 6323 | `\0'. With this, code detectors can | 6323 | `\0'. With this, code detectors can |
| 6324 | handle the tailing bytes more | 6324 | handle the tailing bytes more |
| 6325 | accurately. */ | 6325 | accurately. */ |
| 6326 | STRING_BYTES (XSTRING (string)) + 1, | 6326 | SBYTES (string) + 1, |
| 6327 | !NILP (highest), | 6327 | !NILP (highest), |
| 6328 | STRING_MULTIBYTE (string)); | 6328 | STRING_MULTIBYTE (string)); |
| 6329 | } | 6329 | } |
| @@ -6420,9 +6420,9 @@ DEFUN ("find-coding-systems-region-internal", | |||
| 6420 | { | 6420 | { |
| 6421 | if (!STRING_MULTIBYTE (start)) | 6421 | if (!STRING_MULTIBYTE (start)) |
| 6422 | return Qt; | 6422 | return Qt; |
| 6423 | p1 = XSTRING (start)->data, p1end = p1 + STRING_BYTES (XSTRING (start)); | 6423 | p1 = SDATA (start), p1end = p1 + SBYTES (start); |
| 6424 | p2 = p2end = p1end; | 6424 | p2 = p2end = p1end; |
| 6425 | if (XSTRING (start)->size != STRING_BYTES (XSTRING (start))) | 6425 | if (SCHARS (start) != SBYTES (start)) |
| 6426 | non_ascii_p = 1; | 6426 | non_ascii_p = 1; |
| 6427 | } | 6427 | } |
| 6428 | else | 6428 | else |
| @@ -6508,7 +6508,7 @@ code_convert_region1 (start, end, coding_system, encodep) | |||
| 6508 | return make_number (to - from); | 6508 | return make_number (to - from); |
| 6509 | 6509 | ||
| 6510 | if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0) | 6510 | if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0) |
| 6511 | error ("Invalid coding system: %s", XSTRING (SYMBOL_NAME (coding_system))->data); | 6511 | error ("Invalid coding system: %s", SDATA (SYMBOL_NAME (coding_system))); |
| 6512 | 6512 | ||
| 6513 | coding.mode |= CODING_MODE_LAST_BLOCK; | 6513 | coding.mode |= CODING_MODE_LAST_BLOCK; |
| 6514 | coding.src_multibyte = coding.dst_multibyte | 6514 | coding.src_multibyte = coding.dst_multibyte |
| @@ -6563,7 +6563,7 @@ code_convert_string1 (string, coding_system, nocopy, encodep) | |||
| 6563 | return (NILP (nocopy) ? Fcopy_sequence (string) : string); | 6563 | return (NILP (nocopy) ? Fcopy_sequence (string) : string); |
| 6564 | 6564 | ||
| 6565 | if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0) | 6565 | if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0) |
| 6566 | error ("Invalid coding system: %s", XSTRING (SYMBOL_NAME (coding_system))->data); | 6566 | error ("Invalid coding system: %s", SDATA (SYMBOL_NAME (coding_system))); |
| 6567 | 6567 | ||
| 6568 | coding.mode |= CODING_MODE_LAST_BLOCK; | 6568 | coding.mode |= CODING_MODE_LAST_BLOCK; |
| 6569 | string = (encodep | 6569 | string = (encodep |
| @@ -6622,7 +6622,7 @@ code_convert_string_norecord (string, coding_system, encodep) | |||
| 6622 | return string; | 6622 | return string; |
| 6623 | 6623 | ||
| 6624 | if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0) | 6624 | if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0) |
| 6625 | error ("Invalid coding system: %s", XSTRING (SYMBOL_NAME (coding_system))->data); | 6625 | error ("Invalid coding system: %s", SDATA (SYMBOL_NAME (coding_system))); |
| 6626 | 6626 | ||
| 6627 | coding.composing = COMPOSITION_DISABLED; | 6627 | coding.composing = COMPOSITION_DISABLED; |
| 6628 | coding.mode |= CODING_MODE_LAST_BLOCK; | 6628 | coding.mode |= CODING_MODE_LAST_BLOCK; |
| @@ -6867,7 +6867,7 @@ usage: (find-operation-coding-system OPERATION ARGUMENTS ...) */) | |||
| 6867 | error ("Invalid first argument"); | 6867 | error ("Invalid first argument"); |
| 6868 | if (nargs < 1 + XINT (target_idx)) | 6868 | if (nargs < 1 + XINT (target_idx)) |
| 6869 | error ("Too few arguments for operation: %s", | 6869 | error ("Too few arguments for operation: %s", |
| 6870 | XSTRING (SYMBOL_NAME (operation))->data); | 6870 | SDATA (SYMBOL_NAME (operation))); |
| 6871 | target = args[XINT (target_idx) + 1]; | 6871 | target = args[XINT (target_idx) + 1]; |
| 6872 | if (!(STRINGP (target) | 6872 | if (!(STRINGP (target) |
| 6873 | || (EQ (operation, Qopen_network_stream) && INTEGERP (target)))) | 6873 | || (EQ (operation, Qopen_network_stream) && INTEGERP (target)))) |
| @@ -7430,7 +7430,7 @@ emacs_strerror (error_number) | |||
| 7430 | Lisp_Object dec = code_convert_string_norecord (build_string (str), | 7430 | Lisp_Object dec = code_convert_string_norecord (build_string (str), |
| 7431 | Vlocale_coding_system, | 7431 | Vlocale_coding_system, |
| 7432 | 0); | 7432 | 0); |
| 7433 | str = (char *) XSTRING (dec)->data; | 7433 | str = (char *) SDATA (dec); |
| 7434 | } | 7434 | } |
| 7435 | 7435 | ||
| 7436 | return str; | 7436 | return str; |