comparison src/coding.c @ 25662:0a7261c1d487

Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
author Ken Raeburn <raeburn@raeburn.org>
date Mon, 13 Sep 1999 02:23:04 +0000
parents 20d8158841b0
children 1c730f145aa2
comparison
equal deleted inserted replaced
25661:a6e2ae7964fb 25662:0a7261c1d487
2972 else 2972 else
2973 { 2973 {
2974 bzero (coding->safe_charsets, MAX_CHARSET + 1); 2974 bzero (coding->safe_charsets, MAX_CHARSET + 1);
2975 while (CONSP (val)) 2975 while (CONSP (val))
2976 { 2976 {
2977 if ((i = get_charset_id (XCONS (val)->car)) >= 0) 2977 if ((i = get_charset_id (XCAR (val))) >= 0)
2978 coding->safe_charsets[i] = 1; 2978 coding->safe_charsets[i] = 1;
2979 val = XCONS (val)->cdr; 2979 val = XCDR (val);
2980 } 2980 }
2981 } 2981 }
2982 2982
2983 switch (XFASTINT (coding_type)) 2983 switch (XFASTINT (coding_type))
2984 { 2984 {
3040 for (charset = 0; charset <= MAX_CHARSET; charset++) 3040 for (charset = 0; charset <= MAX_CHARSET; charset++)
3041 CODING_SPEC_ISO_REVISION_NUMBER (coding, charset) = 255; 3041 CODING_SPEC_ISO_REVISION_NUMBER (coding, charset) = 255;
3042 val = Vcharset_revision_alist; 3042 val = Vcharset_revision_alist;
3043 while (CONSP (val)) 3043 while (CONSP (val))
3044 { 3044 {
3045 charset = get_charset_id (Fcar_safe (XCONS (val)->car)); 3045 charset = get_charset_id (Fcar_safe (XCAR (val)));
3046 if (charset >= 0 3046 if (charset >= 0
3047 && (temp = Fcdr_safe (XCONS (val)->car), INTEGERP (temp)) 3047 && (temp = Fcdr_safe (XCAR (val)), INTEGERP (temp))
3048 && (i = XINT (temp), (i >= 0 && (i + '@') < 128))) 3048 && (i = XINT (temp), (i >= 0 && (i + '@') < 128)))
3049 CODING_SPEC_ISO_REVISION_NUMBER (coding, charset) = i; 3049 CODING_SPEC_ISO_REVISION_NUMBER (coding, charset) = i;
3050 val = XCONS (val)->cdr; 3050 val = XCDR (val);
3051 } 3051 }
3052 3052
3053 /* Checks FLAGS[REG] (REG = 0, 1, 2 3) and decide designations. 3053 /* Checks FLAGS[REG] (REG = 0, 1, 2 3) and decide designations.
3054 FLAGS[REG] can be one of below: 3054 FLAGS[REG] can be one of below:
3055 integer CHARSET: CHARSET occupies register I, 3055 integer CHARSET: CHARSET occupies register I,
3082 { 3082 {
3083 Lisp_Object tail; 3083 Lisp_Object tail;
3084 tail = flags[i]; 3084 tail = flags[i];
3085 3085
3086 coding->flags |= CODING_FLAG_ISO_DESIGNATION; 3086 coding->flags |= CODING_FLAG_ISO_DESIGNATION;
3087 if (INTEGERP (XCONS (tail)->car) 3087 if (INTEGERP (XCAR (tail))
3088 && (charset = XINT (XCONS (tail)->car), 3088 && (charset = XINT (XCAR (tail)),
3089 CHARSET_VALID_P (charset)) 3089 CHARSET_VALID_P (charset))
3090 || (charset = get_charset_id (XCONS (tail)->car)) >= 0) 3090 || (charset = get_charset_id (XCAR (tail))) >= 0)
3091 { 3091 {
3092 CODING_SPEC_ISO_INITIAL_DESIGNATION (coding, i) = charset; 3092 CODING_SPEC_ISO_INITIAL_DESIGNATION (coding, i) = charset;
3093 CODING_SPEC_ISO_REQUESTED_DESIGNATION (coding, charset) =i; 3093 CODING_SPEC_ISO_REQUESTED_DESIGNATION (coding, charset) =i;
3094 } 3094 }
3095 else 3095 else
3096 CODING_SPEC_ISO_INITIAL_DESIGNATION (coding, i) = -1; 3096 CODING_SPEC_ISO_INITIAL_DESIGNATION (coding, i) = -1;
3097 tail = XCONS (tail)->cdr; 3097 tail = XCDR (tail);
3098 while (CONSP (tail)) 3098 while (CONSP (tail))
3099 { 3099 {
3100 if (INTEGERP (XCONS (tail)->car) 3100 if (INTEGERP (XCAR (tail))
3101 && (charset = XINT (XCONS (tail)->car), 3101 && (charset = XINT (XCAR (tail)),
3102 CHARSET_VALID_P (charset)) 3102 CHARSET_VALID_P (charset))
3103 || (charset = get_charset_id (XCONS (tail)->car)) >= 0) 3103 || (charset = get_charset_id (XCAR (tail))) >= 0)
3104 CODING_SPEC_ISO_REQUESTED_DESIGNATION (coding, charset) 3104 CODING_SPEC_ISO_REQUESTED_DESIGNATION (coding, charset)
3105 = i; 3105 = i;
3106 else if (EQ (XCONS (tail)->car, Qt)) 3106 else if (EQ (XCAR (tail), Qt))
3107 reg_bits |= 1 << i; 3107 reg_bits |= 1 << i;
3108 tail = XCONS (tail)->cdr; 3108 tail = XCDR (tail);
3109 } 3109 }
3110 } 3110 }
3111 else 3111 else
3112 CODING_SPEC_ISO_INITIAL_DESIGNATION (coding, i) = -1; 3112 CODING_SPEC_ISO_INITIAL_DESIGNATION (coding, i) = -1;
3113 3113
3166 |= CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK; 3166 |= CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK;
3167 { 3167 {
3168 val = XVECTOR (coding_spec)->contents[4]; 3168 val = XVECTOR (coding_spec)->contents[4];
3169 if (! CONSP (val) 3169 if (! CONSP (val)
3170 || setup_ccl_program (&(coding->spec.ccl.decoder), 3170 || setup_ccl_program (&(coding->spec.ccl.decoder),
3171 XCONS (val)->car) < 0 3171 XCAR (val)) < 0
3172 || setup_ccl_program (&(coding->spec.ccl.encoder), 3172 || setup_ccl_program (&(coding->spec.ccl.encoder),
3173 XCONS (val)->cdr) < 0) 3173 XCDR (val)) < 0)
3174 goto label_invalid_coding_system; 3174 goto label_invalid_coding_system;
3175 3175
3176 bzero (coding->spec.ccl.valid_codes, 256); 3176 bzero (coding->spec.ccl.valid_codes, 256);
3177 val = Fplist_get (plist, Qvalid_codes); 3177 val = Fplist_get (plist, Qvalid_codes);
3178 if (CONSP (val)) 3178 if (CONSP (val))
3179 { 3179 {
3180 Lisp_Object this; 3180 Lisp_Object this;
3181 3181
3182 for (; CONSP (val); val = XCONS (val)->cdr) 3182 for (; CONSP (val); val = XCDR (val))
3183 { 3183 {
3184 this = XCONS (val)->car; 3184 this = XCAR (val);
3185 if (INTEGERP (this) 3185 if (INTEGERP (this)
3186 && XINT (this) >= 0 && XINT (this) < 256) 3186 && XINT (this) >= 0 && XINT (this) < 256)
3187 coding->spec.ccl.valid_codes[XINT (this)] = 1; 3187 coding->spec.ccl.valid_codes[XINT (this)] = 1;
3188 else if (CONSP (this) 3188 else if (CONSP (this)
3189 && INTEGERP (XCONS (this)->car) 3189 && INTEGERP (XCAR (this))
3190 && INTEGERP (XCONS (this)->cdr)) 3190 && INTEGERP (XCDR (this)))
3191 { 3191 {
3192 int start = XINT (XCONS (this)->car); 3192 int start = XINT (XCAR (this));
3193 int end = XINT (XCONS (this)->cdr); 3193 int end = XINT (XCDR (this));
3194 3194
3195 if (start >= 0 && start <= end && end < 256) 3195 if (start >= 0 && start <= end && end < 256)
3196 while (start <= end) 3196 while (start <= end)
3197 coding->spec.ccl.valid_codes[start++] = 1; 3197 coding->spec.ccl.valid_codes[start++] = 1;
3198 } 3198 }
4874 return (highest ? val : Fcons (val, Qnil)); 4874 return (highest ? val : Fcons (val, Qnil));
4875 } 4875 }
4876 4876
4877 /* At first, gather possible coding systems in VAL. */ 4877 /* At first, gather possible coding systems in VAL. */
4878 val = Qnil; 4878 val = Qnil;
4879 for (tmp = Vcoding_category_list; !NILP (tmp); tmp = XCONS (tmp)->cdr) 4879 for (tmp = Vcoding_category_list; !NILP (tmp); tmp = XCDR (tmp))
4880 { 4880 {
4881 int idx 4881 int idx
4882 = XFASTINT (Fget (XCONS (tmp)->car, Qcoding_category_index)); 4882 = XFASTINT (Fget (XCAR (tmp), Qcoding_category_index));
4883 if (coding_mask & (1 << idx)) 4883 if (coding_mask & (1 << idx))
4884 { 4884 {
4885 val = Fcons (Fsymbol_value (XCONS (tmp)->car), val); 4885 val = Fcons (Fsymbol_value (XCAR (tmp)), val);
4886 if (highest) 4886 if (highest)
4887 break; 4887 break;
4888 } 4888 }
4889 } 4889 }
4890 if (!highest) 4890 if (!highest)
4891 val = Fnreverse (val); 4891 val = Fnreverse (val);
4892 4892
4893 /* Then, replace the elements with subsidiary coding systems. */ 4893 /* Then, replace the elements with subsidiary coding systems. */
4894 for (tmp = val; !NILP (tmp); tmp = XCONS (tmp)->cdr) 4894 for (tmp = val; !NILP (tmp); tmp = XCDR (tmp))
4895 { 4895 {
4896 if (eol_type != CODING_EOL_UNDECIDED 4896 if (eol_type != CODING_EOL_UNDECIDED
4897 && eol_type != CODING_EOL_INCONSISTENT) 4897 && eol_type != CODING_EOL_INCONSISTENT)
4898 { 4898 {
4899 Lisp_Object eol; 4899 Lisp_Object eol;
4900 eol = Fget (XCONS (tmp)->car, Qeol_type); 4900 eol = Fget (XCAR (tmp), Qeol_type);
4901 if (VECTORP (eol)) 4901 if (VECTORP (eol))
4902 XCONS (tmp)->car = XVECTOR (eol)->contents[eol_type]; 4902 XCAR (tmp) = XVECTOR (eol)->contents[eol_type];
4903 } 4903 }
4904 } 4904 }
4905 return (highest ? XCONS (val)->car : val); 4905 return (highest ? XCAR (val) : val);
4906 } 4906 }
4907 4907
4908 DEFUN ("detect-coding-region", Fdetect_coding_region, Sdetect_coding_region, 4908 DEFUN ("detect-coding-region", Fdetect_coding_region, Sdetect_coding_region,
4909 2, 3, 0, 4909 2, 3, 0,
4910 "Detect coding system of the text in the region between START and END.\n\ 4910 "Detect coding system of the text in the region between START and END.\n\
5322 ? Vnetwork_coding_system_alist 5322 ? Vnetwork_coding_system_alist
5323 : Vprocess_coding_system_alist)); 5323 : Vprocess_coding_system_alist));
5324 if (NILP (chain)) 5324 if (NILP (chain))
5325 return Qnil; 5325 return Qnil;
5326 5326
5327 for (; CONSP (chain); chain = XCONS (chain)->cdr) 5327 for (; CONSP (chain); chain = XCDR (chain))
5328 { 5328 {
5329 Lisp_Object elt; 5329 Lisp_Object elt;
5330 elt = XCONS (chain)->car; 5330 elt = XCAR (chain);
5331 5331
5332 if (CONSP (elt) 5332 if (CONSP (elt)
5333 && ((STRINGP (target) 5333 && ((STRINGP (target)
5334 && STRINGP (XCONS (elt)->car) 5334 && STRINGP (XCAR (elt))
5335 && fast_string_match (XCONS (elt)->car, target) >= 0) 5335 && fast_string_match (XCAR (elt), target) >= 0)
5336 || (INTEGERP (target) && EQ (target, XCONS (elt)->car)))) 5336 || (INTEGERP (target) && EQ (target, XCAR (elt)))))
5337 { 5337 {
5338 val = XCONS (elt)->cdr; 5338 val = XCDR (elt);
5339 /* Here, if VAL is both a valid coding system and a valid 5339 /* Here, if VAL is both a valid coding system and a valid
5340 function symbol, we return VAL as a coding system. */ 5340 function symbol, we return VAL as a coding system. */
5341 if (CONSP (val)) 5341 if (CONSP (val))
5342 return val; 5342 return val;
5343 if (! SYMBOLP (val)) 5343 if (! SYMBOLP (val))
5404 5404
5405 val = Vcoding_category_list; 5405 val = Vcoding_category_list;
5406 5406
5407 while (CONSP (val) && i < CODING_CATEGORY_IDX_MAX) 5407 while (CONSP (val) && i < CODING_CATEGORY_IDX_MAX)
5408 { 5408 {
5409 if (! SYMBOLP (XCONS (val)->car)) 5409 if (! SYMBOLP (XCAR (val)))
5410 break; 5410 break;
5411 idx = XFASTINT (Fget (XCONS (val)->car, Qcoding_category_index)); 5411 idx = XFASTINT (Fget (XCAR (val), Qcoding_category_index));
5412 if (idx >= CODING_CATEGORY_IDX_MAX) 5412 if (idx >= CODING_CATEGORY_IDX_MAX)
5413 break; 5413 break;
5414 coding_priorities[i++] = (1 << idx); 5414 coding_priorities[i++] = (1 << idx);
5415 val = XCONS (val)->cdr; 5415 val = XCDR (val);
5416 } 5416 }
5417 /* If coding-category-list is valid and contains all coding 5417 /* If coding-category-list is valid and contains all coding
5418 categories, `i' should be CODING_CATEGORY_IDX_MAX now. If not, 5418 categories, `i' should be CODING_CATEGORY_IDX_MAX now. If not,
5419 the following code saves Emacs from craching. */ 5419 the following code saves Emacs from craching. */
5420 while (i < CODING_CATEGORY_IDX_MAX) 5420 while (i < CODING_CATEGORY_IDX_MAX)