Mercurial > emacs
diff src/coding.c @ 110829:4d672e9d91bf
Complement a coding system for encoding arguments and input to a process.
| author | Kenichi Handa <handa@m17n.org> |
|---|---|
| date | Thu, 30 Sep 2010 13:28:34 +0900 |
| parents | 3ffb3b102dae |
| children | b997f43af473 |
line wrap: on
line diff
--- a/src/coding.c Wed Sep 29 09:55:58 2010 +0900 +++ b/src/coding.c Thu Sep 30 13:28:34 2010 +0900 @@ -6112,6 +6112,63 @@ return coding_system; } + +/* Check if text-conversion and eol-conversion of CODING_SYSTEM are + decided for writing to a process. If not, complement them, and + return a new coding system. */ + +Lisp_Object +complement_process_encoding_system (coding_system) + Lisp_Object coding_system; +{ + Lisp_Object spec, attrs, coding_type, eol_type; + + if (NILP (coding_system)) + coding_system = Qundecided; + spec = CODING_SYSTEM_SPEC (coding_system); + attrs = AREF (spec, 0); + coding_type = CODING_ATTR_TYPE (attrs); + eol_type = AREF (spec, 2); + + if (EQ (coding_type, Qundecided)) + { + /* We must decide the text-conversion part. */ + if (CONSP (Vdefault_process_coding_system)) + { + coding_system = XCDR (Vdefault_process_coding_system); + if (! NILP (coding_system)) + { + spec = CODING_SYSTEM_SPEC (coding_system); + attrs = AREF (spec, 0); + coding_type = CODING_ATTR_TYPE (attrs); + eol_type = AREF (spec, 2); + } + } + if (EQ (coding_type, Qundecided)) + { + coding_system = preferred_coding_system (); + spec = CODING_SYSTEM_SPEC (coding_system); + attrs = AREF (spec, 0); + coding_type = CODING_ATTR_TYPE (attrs); + eol_type = AREF (spec, 2); + } + if (EQ (coding_type, Qundecided)) + { + coding_system = Qraw_text; + coding_type = Qraw_text; + eol_type = Qnil; + } + } + if (NILP (eol_type) || VECTORP (eol_type)) + { + /* We must decide the eol-conversion part. */ + coding_system = coding_inherit_eol_type (coding_system, Qnil); + } + + return coding_system; +} + + /* Emacs has a mechanism to automatically detect a coding system if it is one of Emacs' internal format, ISO2022, SJIS, and BIG5. But, it's impossible to distinguish some coding systems accurately
