Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
emacs
emacs
Commits
fcaf8878
Commit
fcaf8878
authored
Sep 30, 2010
by
Kenichi Handa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Complement a coding system for encoding arguments and input to a process.
parent
9fb7a510
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
108 additions
and
23 deletions
+108
-23
src/ChangeLog
src/ChangeLog
+16
-0
src/callproc.c
src/callproc.c
+6
-15
src/coding.c
src/coding.c
+57
-0
src/coding.h
src/coding.h
+1
-0
src/process.c
src/process.c
+28
-8
No files found.
src/ChangeLog
View file @
fcaf8878
2010-09-30 Kenichi Handa <handa@m17n.org>
* coding.c (complement_process_encoding_system): New function.
* coding.h (complement_process_encoding_system): Extern it.
* callproc.c (Fcall_process): Complement the coding system for
encoding arguments.
(Fcall_process_region): Complement the coding system for encoding
the input to the process.
* process.c (Fstart_process): Complement the coding system for
encoding arguments.
(send_process): Complement the coding system for encoding what
sent to the process.
2010-09-29 Kenichi Handa <handa@m17n.org>
* xfont.c (xfont_open): Fix setting of font->average_width from
...
...
src/callproc.c
View file @
fcaf8878
...
...
@@ -287,21 +287,16 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
if
(
!
NILP
(
Vcoding_system_for_write
))
val
=
Vcoding_system_for_write
;
else
if
(
!
must_encode
)
val
=
Q
nil
;
val
=
Q
raw_text
;
else
{
args2
=
(
Lisp_Object
*
)
alloca
((
nargs
+
1
)
*
sizeof
*
args2
);
args2
[
0
]
=
Qcall_process
;
for
(
i
=
0
;
i
<
nargs
;
i
++
)
args2
[
i
+
1
]
=
args
[
i
];
coding_systems
=
Ffind_operation_coding_system
(
nargs
+
1
,
args2
);
if
(
CONSP
(
coding_systems
))
val
=
XCDR
(
coding_systems
);
else
if
(
CONSP
(
Vdefault_process_coding_system
))
val
=
XCDR
(
Vdefault_process_coding_system
);
else
val
=
Qnil
;
val
=
CONSP
(
coding_systems
)
?
XCDR
(
coding_systems
)
:
Qnil
;
}
val
=
co
ding_inherit_eol_type
(
val
,
Qni
l
);
val
=
co
mplement_process_encoding_system
(
va
l
);
setup_coding_system
(
Fcheck_coding_system
(
val
),
&
argument_coding
);
coding_attrs
=
CODING_ID_ATTRS
(
argument_coding
.
id
);
if
(
NILP
(
CODING_ATTR_ASCII_COMPAT
(
coding_attrs
)))
...
...
@@ -954,20 +949,16 @@ usage: (call-process-region START END PROGRAM &optional DELETE BUFFER DISPLAY &r
if
(
!
NILP
(
Vcoding_system_for_write
))
val
=
Vcoding_system_for_write
;
else
if
(
NILP
(
current_buffer
->
enable_multibyte_characters
))
val
=
Q
nil
;
val
=
Q
raw_text
;
else
{
args2
=
(
Lisp_Object
*
)
alloca
((
nargs
+
1
)
*
sizeof
*
args2
);
args2
[
0
]
=
Qcall_process_region
;
for
(
i
=
0
;
i
<
nargs
;
i
++
)
args2
[
i
+
1
]
=
args
[
i
];
coding_systems
=
Ffind_operation_coding_system
(
nargs
+
1
,
args2
);
if
(
CONSP
(
coding_systems
))
val
=
XCDR
(
coding_systems
);
else
if
(
CONSP
(
Vdefault_process_coding_system
))
val
=
XCDR
(
Vdefault_process_coding_system
);
else
val
=
Qnil
;
val
=
CONSP
(
coding_systems
)
?
XCDR
(
coding_systems
)
:
Qnil
;
}
val
=
complement_process_encoding_system
(
val
);
{
int
count1
=
SPECPDL_INDEX
();
...
...
src/coding.c
View file @
fcaf8878
...
...
@@ -6112,6 +6112,63 @@ coding_inherit_eol_type (coding_system, parent)
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
...
...
src/coding.h
View file @
fcaf8878
...
...
@@ -707,6 +707,7 @@ extern Lisp_Object code_convert_string_norecord P_ ((Lisp_Object, Lisp_Object,
int
));
extern
Lisp_Object
raw_text_coding_system
P_
((
Lisp_Object
));
extern
Lisp_Object
coding_inherit_eol_type
P_
((
Lisp_Object
,
Lisp_Object
));
extern
Lisp_Object
complement_process_encoding_system
P_
((
Lisp_Object
));
extern
int
decode_coding_gap
P_
((
struct
coding_system
*
,
EMACS_INT
,
EMACS_INT
));
...
...
src/process.c
View file @
fcaf8878
...
...
@@ -1727,6 +1727,11 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */)
val
=
XCDR
(
Vdefault_process_coding_system
);
}
XPROCESS
(
proc
)
->
encode_coding_system
=
val
;
/* Note: At this momemnt, the above coding system may leave
text-conversion or eol-conversion unspecified. They will be
decided after we read output from the process and decode it by
some coding system, or just before we actually send a text to
the process. */
}
...
...
@@ -1769,6 +1774,7 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */)
tem
=
Fsubstring
(
tem
,
make_number
(
2
),
Qnil
);
{
Lisp_Object
arg_encoding
=
Qnil
;
struct
gcpro
gcpro1
;
GCPRO1
(
tem
);
...
...
@@ -1786,9 +1792,14 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */)
tem
=
Fcons
(
args
[
i
],
tem
);
CHECK_STRING
(
XCAR
(
tem
));
if
(
STRING_MULTIBYTE
(
XCAR
(
tem
)))
XSETCAR (tem,
code_convert_string_norecord
(XCAR (tem), XPROCESS (proc)->encode_coding_system, 1));
{
if
(
NILP
(
arg_encoding
))
arg_encoding
=
(
complement_process_encoding_system
(
XPROCESS
(
proc
)
->
encode_coding_system
));
XSETCAR
(
tem
,
code_convert_string_norecord
(
XCAR
(
tem
),
arg_encoding
,
1
));
}
}
UNGCPRO
;
...
...
@@ -5690,12 +5701,21 @@ send_process (proc, buf, len, object)
&&
!
NILP
(
XBUFFER
(
object
)
->
enable_multibyte_characters
))
||
EQ
(
object
,
Qt
))
{
p
->
encode_coding_system
=
complement_process_encoding_system
(
p
->
encode_coding_system
);
if
(
!
EQ
(
Vlast_coding_system_used
,
p
->
encode_coding_system
))
/* The coding system for encoding was changed to raw-text
because we sent a unibyte text previously. Now we are
sending a multibyte text, thus we must encode it by the
original coding system specified for the current process. */
setup_coding_system (p->encode_coding_system, coding);
{
/* The coding system for encoding was changed to raw-text
because we sent a unibyte text previously. Now we are
sending a multibyte text, thus we must encode it by the
original coding system specified for the current process.
Another reason we comming here is that the coding system
was just complemented and new one was returned by
complement_process_encoding_system. */
setup_coding_system
(
p
->
encode_coding_system
,
coding
);
Vlast_coding_system_used
=
p
->
encode_coding_system
;
}
coding
->
src_multibyte
=
1
;
}
else
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment