diff options
| author | Juanma Barranquero | 2010-10-08 12:14:47 +0200 |
|---|---|---|
| committer | Juanma Barranquero | 2010-10-08 12:14:47 +0200 |
| commit | 4628bef1eea0f60e846fe6b6591725aa92952de9 (patch) | |
| tree | 9d137b8e0964c0b1ebc4afb4e743e35b807d048d /src/coding.c | |
| parent | 24ac444fbe5d76a7cf09a62b741b9e956ab90d3e (diff) | |
| parent | 2b7c934285417d2eac7a3c603231d22ce7e212d8 (diff) | |
| download | emacs-4628bef1eea0f60e846fe6b6591725aa92952de9.tar.gz emacs-4628bef1eea0f60e846fe6b6591725aa92952de9.zip | |
Merge changes from emacs-23 branch.
Diffstat (limited to 'src/coding.c')
| -rw-r--r-- | src/coding.c | 48 |
1 files changed, 44 insertions, 4 deletions
diff --git a/src/coding.c b/src/coding.c index d6285ed9245..2cf32360096 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -6016,10 +6016,9 @@ raw_text_coding_system (Lisp_Object coding_system) | |||
| 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 |
| @@ -6041,6 +6040,8 @@ coding_inherit_eol_type (Lisp_Object coding_system, Lisp_Object parent) | |||
| 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; |
| @@ -6054,6 +6055,45 @@ coding_inherit_eol_type (Lisp_Object coding_system, Lisp_Object parent) | |||
| 6054 | return coding_system; | 6055 | return coding_system; |
| 6055 | } | 6056 | } |
| 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 | |||
| 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 |