Mercurial > emacs
comparison src/coding.c @ 110855:bec49af30c2f
Merge changes from emacs-23 branch.
| author | Juanma Barranquero <lekktu@gmail.com> |
|---|---|
| date | Fri, 08 Oct 2010 12:14:47 +0200 |
| parents | 41bf9b6f3b91 c234b2db847c |
| children | b8fde5ef9e14 |
comparison
equal
deleted
inserted
replaced
| 110820:e60b0b3ed516 | 110855:bec49af30c2f |
|---|---|
| 6014 : EQ (eol_type, Qdos) ? AREF (raw_text_eol_type, 1) | 6014 : EQ (eol_type, Qdos) ? AREF (raw_text_eol_type, 1) |
| 6015 : AREF (raw_text_eol_type, 2)); | 6015 : AREF (raw_text_eol_type, 2)); |
| 6016 } | 6016 } |
| 6017 | 6017 |
| 6018 | 6018 |
| 6019 /* If CODING_SYSTEM doesn't specify end-of-line format but PARENT | 6019 /* If CODING_SYSTEM doesn't specify end-of-line format, return one of |
| 6020 does, return one of the subsidiary that has the same eol-spec as | 6020 the subsidiary that has the same eol-spec as PARENT (if it is not |
| 6021 PARENT. Otherwise, return CODING_SYSTEM. If PARENT is nil, | 6021 nil and specifies end-of-line format) or the system's setting |
| 6022 inherit end-of-line format from the system's setting | |
| 6023 (system_eol_type). */ | 6022 (system_eol_type). */ |
| 6024 | 6023 |
| 6025 Lisp_Object | 6024 Lisp_Object |
| 6026 coding_inherit_eol_type (Lisp_Object coding_system, Lisp_Object parent) | 6025 coding_inherit_eol_type (Lisp_Object coding_system, Lisp_Object parent) |
| 6027 { | 6026 { |
| 6039 { | 6038 { |
| 6040 Lisp_Object parent_spec; | 6039 Lisp_Object parent_spec; |
| 6041 | 6040 |
| 6042 parent_spec = CODING_SYSTEM_SPEC (parent); | 6041 parent_spec = CODING_SYSTEM_SPEC (parent); |
| 6043 parent_eol_type = AREF (parent_spec, 2); | 6042 parent_eol_type = AREF (parent_spec, 2); |
| 6043 if (VECTORP (parent_eol_type)) | |
| 6044 parent_eol_type = system_eol_type; | |
| 6044 } | 6045 } |
| 6045 else | 6046 else |
| 6046 parent_eol_type = system_eol_type; | 6047 parent_eol_type = system_eol_type; |
| 6047 if (EQ (parent_eol_type, Qunix)) | 6048 if (EQ (parent_eol_type, Qunix)) |
| 6048 coding_system = AREF (eol_type, 0); | 6049 coding_system = AREF (eol_type, 0); |
| 6051 else if (EQ (parent_eol_type, Qmac)) | 6052 else if (EQ (parent_eol_type, Qmac)) |
| 6052 coding_system = AREF (eol_type, 2); | 6053 coding_system = AREF (eol_type, 2); |
| 6053 } | 6054 } |
| 6054 return coding_system; | 6055 return coding_system; |
| 6055 } | 6056 } |
| 6057 | |
| 6058 | |
| 6059 /* Check if text-conversion and eol-conversion of CODING_SYSTEM are | |
| 6060 decided for writing to a process. If not, complement them, and | |
| 6061 return a new coding system. */ | |
| 6062 | |
| 6063 Lisp_Object | |
| 6064 complement_process_encoding_system (Lisp_Object coding_system) | |
| 6065 { | |
| 6066 Lisp_Object coding_base = Qnil, eol_base = Qnil; | |
| 6067 Lisp_Object spec, attrs; | |
| 6068 int i; | |
| 6069 | |
| 6070 for (i = 0; i < 3; i++) | |
| 6071 { | |
| 6072 if (i == 1) | |
| 6073 coding_system = CDR_SAFE (Vdefault_process_coding_system); | |
| 6074 else if (i == 2) | |
| 6075 coding_system = preferred_coding_system (); | |
| 6076 spec = CODING_SYSTEM_SPEC (coding_system); | |
| 6077 if (NILP (spec)) | |
| 6078 continue; | |
| 6079 attrs = AREF (spec, 0); | |
| 6080 if (NILP (coding_base) && ! EQ (CODING_ATTR_TYPE (attrs), Qundecided)) | |
| 6081 coding_base = CODING_ATTR_BASE_NAME (attrs); | |
| 6082 if (NILP (eol_base) && ! VECTORP (AREF (spec, 2))) | |
| 6083 eol_base = coding_system; | |
| 6084 if (! NILP (coding_base) && ! NILP (eol_base)) | |
| 6085 break; | |
| 6086 } | |
| 6087 | |
| 6088 if (i > 0) | |
| 6089 /* The original CODING_SYSTEM didn't specify text-conversion or | |
| 6090 eol-conversion. Be sure that we return a fully complemented | |
| 6091 coding system. */ | |
| 6092 coding_system = coding_inherit_eol_type (coding_base, eol_base); | |
| 6093 return coding_system; | |
| 6094 } | |
| 6095 | |
| 6056 | 6096 |
| 6057 /* Emacs has a mechanism to automatically detect a coding system if it | 6097 /* Emacs has a mechanism to automatically detect a coding system if it |
| 6058 is one of Emacs' internal format, ISO2022, SJIS, and BIG5. But, | 6098 is one of Emacs' internal format, ISO2022, SJIS, and BIG5. But, |
| 6059 it's impossible to distinguish some coding systems accurately | 6099 it's impossible to distinguish some coding systems accurately |
| 6060 because they use the same range of codes. So, at first, coding | 6100 because they use the same range of codes. So, at first, coding |
