diff options
| author | Kenichi Handa | 2010-09-30 13:28:34 +0900 |
|---|---|---|
| committer | Kenichi Handa | 2010-09-30 13:28:34 +0900 |
| commit | fcaf88782ba68e7c0618a663db51cf4a26cb3926 (patch) | |
| tree | 589ae64ef6f2e2acc260726235d0c98b29150c0a /src/coding.c | |
| parent | 9fb7a510c91c6aad04d2d6ba8e8c0889d19e1d79 (diff) | |
| download | emacs-fcaf88782ba68e7c0618a663db51cf4a26cb3926.tar.gz emacs-fcaf88782ba68e7c0618a663db51cf4a26cb3926.zip | |
Complement a coding system for encoding arguments and input to a process.
Diffstat (limited to 'src/coding.c')
| -rw-r--r-- | src/coding.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/coding.c b/src/coding.c index 92b328091ff..cbebeff6310 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -6112,6 +6112,63 @@ coding_inherit_eol_type (coding_system, parent) | |||
| 6112 | return coding_system; | 6112 | return coding_system; |
| 6113 | } | 6113 | } |
| 6114 | 6114 | ||
| 6115 | |||
| 6116 | /* Check if text-conversion and eol-conversion of CODING_SYSTEM are | ||
| 6117 | decided for writing to a process. If not, complement them, and | ||
| 6118 | return a new coding system. */ | ||
| 6119 | |||
| 6120 | Lisp_Object | ||
| 6121 | complement_process_encoding_system (coding_system) | ||
| 6122 | Lisp_Object coding_system; | ||
| 6123 | { | ||
| 6124 | Lisp_Object spec, attrs, coding_type, eol_type; | ||
| 6125 | |||
| 6126 | if (NILP (coding_system)) | ||
| 6127 | coding_system = Qundecided; | ||
| 6128 | spec = CODING_SYSTEM_SPEC (coding_system); | ||
| 6129 | attrs = AREF (spec, 0); | ||
| 6130 | coding_type = CODING_ATTR_TYPE (attrs); | ||
| 6131 | eol_type = AREF (spec, 2); | ||
| 6132 | |||
| 6133 | if (EQ (coding_type, Qundecided)) | ||
| 6134 | { | ||
| 6135 | /* We must decide the text-conversion part. */ | ||
| 6136 | if (CONSP (Vdefault_process_coding_system)) | ||
| 6137 | { | ||
| 6138 | coding_system = XCDR (Vdefault_process_coding_system); | ||
| 6139 | if (! NILP (coding_system)) | ||
| 6140 | { | ||
| 6141 | spec = CODING_SYSTEM_SPEC (coding_system); | ||
| 6142 | attrs = AREF (spec, 0); | ||
| 6143 | coding_type = CODING_ATTR_TYPE (attrs); | ||
| 6144 | eol_type = AREF (spec, 2); | ||
| 6145 | } | ||
| 6146 | } | ||
| 6147 | if (EQ (coding_type, Qundecided)) | ||
| 6148 | { | ||
| 6149 | coding_system = preferred_coding_system (); | ||
| 6150 | spec = CODING_SYSTEM_SPEC (coding_system); | ||
| 6151 | attrs = AREF (spec, 0); | ||
| 6152 | coding_type = CODING_ATTR_TYPE (attrs); | ||
| 6153 | eol_type = AREF (spec, 2); | ||
| 6154 | } | ||
| 6155 | if (EQ (coding_type, Qundecided)) | ||
| 6156 | { | ||
| 6157 | coding_system = Qraw_text; | ||
| 6158 | coding_type = Qraw_text; | ||
| 6159 | eol_type = Qnil; | ||
| 6160 | } | ||
| 6161 | } | ||
| 6162 | if (NILP (eol_type) || VECTORP (eol_type)) | ||
| 6163 | { | ||
| 6164 | /* We must decide the eol-conversion part. */ | ||
| 6165 | coding_system = coding_inherit_eol_type (coding_system, Qnil); | ||
| 6166 | } | ||
| 6167 | |||
| 6168 | return coding_system; | ||
| 6169 | } | ||
| 6170 | |||
| 6171 | |||
| 6115 | /* Emacs has a mechanism to automatically detect a coding system if it | 6172 | /* Emacs has a mechanism to automatically detect a coding system if it |
| 6116 | is one of Emacs' internal format, ISO2022, SJIS, and BIG5. But, | 6173 | is one of Emacs' internal format, ISO2022, SJIS, and BIG5. But, |
| 6117 | it's impossible to distinguish some coding systems accurately | 6174 | it's impossible to distinguish some coding systems accurately |