Mercurial > hg > xemacs-beta
comparison src/file-coding.c @ 802:19dfb459d51a
[xemacs-hg @ 2002-04-03 10:47:37 by ben]
fix tty problem et al
internals/internals.texi: Add section on correctly merging a branch back into the trunk.
console-tty.c, eval.c, event-unixoid.c, file-coding.c, file-coding.h, lisp.h, print.c, sysdep.c: Fix data corruption error in print.c from print_depth becoming
negative. Borrow primitives internal_bind_int,
internal_bind_lisp_object from my stderr-proc ws, soon to be
integrated; use them to properly bind print_depth et al.
First fix for TTY problem. The basic problem is I switched things
so that the TTY I/O is filtered through a coding system, for the
support of kterm and such, that speak JIS or similar
encodings. (#### I ***swear*** I had this working way back in
19.12.) Anyway, this introduced buffering issues, in which instead
of one char being read, it tried to read 1024 chars. I tried
setting the stdin descriptor non-blocking, but it doesn't appear
to work on Cygwin. (#### Andy, do you know anything about this?)
So I fixed it elsewhere. If you get weirdness on the TTY, look in
console-tty.c and see how it gets the coding system; maybe there's
a way to change it (and if not, there should be!).
Also fix warning in sysdep.c.
author | ben |
---|---|
date | Wed, 03 Apr 2002 10:47:52 +0000 |
parents | 2b676dc88c66 |
children | a634e3b7acc8 |
comparison
equal
deleted
inserted
replaced
801:2b676dc88c66 | 802:19dfb459d51a |
---|---|
2035 Bytecount rejected = Dynarr_length (str->convert_from); | 2035 Bytecount rejected = Dynarr_length (str->convert_from); |
2036 /* #### 1024 is arbitrary; we really need to separate 0 from EOF, | 2036 /* #### 1024 is arbitrary; we really need to separate 0 from EOF, |
2037 and when we get 0, keep taking more data until we don't get 0 -- | 2037 and when we get 0, keep taking more data until we don't get 0 -- |
2038 we don't know how much data the conversion routine might need | 2038 we don't know how much data the conversion routine might need |
2039 before it can generate any data of its own */ | 2039 before it can generate any data of its own */ |
2040 Bytecount readmore = max (size, 1024); | 2040 Bytecount readmore = max (size, str->one_byte_at_a_time ? 1 : 1024); |
2041 | 2041 |
2042 Dynarr_add_many (str->convert_from, 0, readmore); | 2042 Dynarr_add_many (str->convert_from, 0, readmore); |
2043 read_size = Lstream_read (str->other_end, | 2043 read_size = Lstream_read (str->other_end, |
2044 Dynarr_atp (str->convert_from, rejected), | 2044 Dynarr_atp (str->convert_from, rejected), |
2045 readmore); | 2045 readmore); |
2303 a non-seekable input stream. */ | 2303 a non-seekable input stream. */ |
2304 | 2304 |
2305 static Lisp_Object | 2305 static Lisp_Object |
2306 make_coding_stream_1 (Lstream *stream, Lisp_Object codesys, | 2306 make_coding_stream_1 (Lstream *stream, Lisp_Object codesys, |
2307 const char *mode, enum encode_decode direction, | 2307 const char *mode, enum encode_decode direction, |
2308 int no_close_other) | 2308 int flags) |
2309 { | 2309 { |
2310 Lstream *lstr = Lstream_new (lstream_coding, mode); | 2310 Lstream *lstr = Lstream_new (lstream_coding, mode); |
2311 struct coding_stream *str = CODING_STREAM_DATA (lstr); | 2311 struct coding_stream *str = CODING_STREAM_DATA (lstr); |
2312 | 2312 |
2313 codesys = Fget_coding_system (codesys); | 2313 codesys = Fget_coding_system (codesys); |
2317 str->us = lstr; | 2317 str->us = lstr; |
2318 str->other_end = stream; | 2318 str->other_end = stream; |
2319 str->convert_to = Dynarr_new (unsigned_char); | 2319 str->convert_to = Dynarr_new (unsigned_char); |
2320 str->convert_from = Dynarr_new (unsigned_char); | 2320 str->convert_from = Dynarr_new (unsigned_char); |
2321 str->direction = direction; | 2321 str->direction = direction; |
2322 str->no_close_other = no_close_other; | 2322 if (flags & CODE_FL_NO_CLOSE_OTHER) |
2323 str->no_close_other = 1; | |
2324 else if (flags & CODE_FL_READ_ONE_BYTE_AT_A_TIME) | |
2325 str->one_byte_at_a_time = 1; | |
2326 | |
2323 set_coding_stream_coding_system (lstr, codesys); | 2327 set_coding_stream_coding_system (lstr, codesys); |
2324 return wrap_lstream (lstr); | 2328 return wrap_lstream (lstr); |
2325 } | 2329 } |
2326 | 2330 |
2327 /* If NO_CLOSE_OTHER is non-zero, don't close STREAM (the stream at the | 2331 /* FLAGS -- #### document me. If NO_CLOSE_OTHER is non-zero, don't close |
2328 other end) when this stream is closed. */ | 2332 STREAM (the stream at the other end) when this stream is closed. */ |
2329 Lisp_Object | 2333 Lisp_Object |
2330 make_coding_input_stream (Lstream *stream, Lisp_Object codesys, | 2334 make_coding_input_stream (Lstream *stream, Lisp_Object codesys, |
2331 enum encode_decode direction, int no_close_other) | 2335 enum encode_decode direction, int flags) |
2332 { | 2336 { |
2333 return make_coding_stream_1 (stream, codesys, "r", direction, | 2337 return make_coding_stream_1 (stream, codesys, "r", direction, |
2334 no_close_other); | 2338 flags); |
2335 } | 2339 } |
2336 | 2340 |
2337 /* If NO_CLOSE_OTHER is non-zero, don't close STREAM (the stream at the | 2341 /* FLAGS -- #### document me. If NO_CLOSE_OTHER is non-zero, don't close |
2338 other end) when this stream is closed. */ | 2342 STREAM (the stream at the other end) when this stream is closed. */ |
2339 Lisp_Object | 2343 Lisp_Object |
2340 make_coding_output_stream (Lstream *stream, Lisp_Object codesys, | 2344 make_coding_output_stream (Lstream *stream, Lisp_Object codesys, |
2341 enum encode_decode direction, int no_close_other) | 2345 enum encode_decode direction, int flags) |
2342 { | 2346 { |
2343 return make_coding_stream_1 (stream, codesys, "w", direction, | 2347 return make_coding_stream_1 (stream, codesys, "w", direction, |
2344 no_close_other); | 2348 flags); |
2345 } | 2349 } |
2346 | 2350 |
2347 static Lisp_Object | 2351 static Lisp_Object |
2348 encode_decode_coding_region (Lisp_Object start, Lisp_Object end, | 2352 encode_decode_coding_region (Lisp_Object start, Lisp_Object end, |
2349 Lisp_Object coding_system, Lisp_Object buffer, | 2353 Lisp_Object coding_system, Lisp_Object buffer, |
4145 struct gcpro gcpro1, gcpro2, gcpro3; | 4149 struct gcpro gcpro1, gcpro2, gcpro3; |
4146 UExtbyte random_buffer[65536]; | 4150 UExtbyte random_buffer[65536]; |
4147 Lisp_Object binary_instream = | 4151 Lisp_Object binary_instream = |
4148 make_coding_input_stream | 4152 make_coding_input_stream |
4149 (XLSTREAM (stream), Qbinary, | 4153 (XLSTREAM (stream), Qbinary, |
4150 CODING_ENCODE, 1); | 4154 CODING_ENCODE, CODE_FL_NO_CLOSE_OTHER); |
4151 Lisp_Object decstream = | 4155 Lisp_Object decstream = |
4152 make_coding_input_stream | 4156 make_coding_input_stream |
4153 (XLSTREAM (binary_instream), | 4157 (XLSTREAM (binary_instream), |
4154 Qundecided, CODING_DECODE, 0); | 4158 Qundecided, CODING_DECODE, 0); |
4155 Lstream *decstr = XLSTREAM (decstream); | 4159 Lstream *decstr = XLSTREAM (decstream); |