Mercurial > hg > xemacs-beta
comparison src/lstream.c @ 16:0293115a14e9 r19-15b91
Import from CVS: tag r19-15b91
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:49:20 +0200 |
parents | 4b173ad71786 |
children | 441bb1e64a06 |
comparison
equal
deleted
inserted
replaced
15:ad457d5f7d04 | 16:0293115a14e9 |
---|---|
120 may well have freed some necessary storage structures, for | 120 may well have freed some necessary storage structures, for |
121 example. | 121 example. |
122 | 122 |
123 void Lstream_rewind (Lstream *stream) | 123 void Lstream_rewind (Lstream *stream) |
124 Rewind the stream to the beginning. | 124 Rewind the stream to the beginning. |
125 */ | 125 */ |
126 | |
127 #ifdef MULE | |
128 MAC_DEFINE (Emchar, MTlstream_emchar) | |
129 MAC_DEFINE (int, MTlstream_emcint) | |
130 #endif | |
126 | 131 |
127 MAC_DEFINE (struct lstream *, MTlstream_data) | 132 MAC_DEFINE (struct lstream *, MTlstream_data) |
128 | 133 |
129 static Lisp_Object mark_lstream (Lisp_Object, void (*) (Lisp_Object)); | 134 static Lisp_Object mark_lstream (Lisp_Object, void (*) (Lisp_Object)); |
130 static void print_lstream (Lisp_Object obj, Lisp_Object printcharfun, | 135 static void print_lstream (Lisp_Object obj, Lisp_Object printcharfun, |
885 Bufbyte eof_char; | 890 Bufbyte eof_char; |
886 int starting_pos; | 891 int starting_pos; |
887 int current_pos; | 892 int current_pos; |
888 int end_pos; | 893 int end_pos; |
889 int chars_sans_newline; | 894 int chars_sans_newline; |
890 int closing :1; | 895 unsigned int closing :1; |
891 int allow_quit :1; | 896 unsigned int allow_quit :1; |
892 int blocked_ok :1; | 897 unsigned int blocked_ok :1; |
893 int pty_flushing :1; | 898 unsigned int pty_flushing :1; |
894 int blocking_error_p :1; | 899 unsigned int blocking_error_p :1; |
895 }; | 900 }; |
896 | 901 |
897 #define FILEDESC_STREAM_DATA(stream) LSTREAM_TYPE_DATA (stream, filedesc) | 902 #define FILEDESC_STREAM_DATA(stream) LSTREAM_TYPE_DATA (stream, filedesc) |
898 | 903 |
899 DEFINE_LSTREAM_IMPLEMENTATION ("filedesc", lstream_filedesc, | 904 DEFINE_LSTREAM_IMPLEMENTATION ("filedesc", lstream_filedesc, |
1165 Lstream *lstr; | 1170 Lstream *lstr; |
1166 struct lisp_string_stream *str; | 1171 struct lisp_string_stream *str; |
1167 | 1172 |
1168 CHECK_STRING (string); | 1173 CHECK_STRING (string); |
1169 if (len < 0) | 1174 if (len < 0) |
1170 len = string_length (XSTRING (string)) - offset; | 1175 len = XSTRING_LENGTH (string) - offset; |
1171 assert (offset >= 0); | 1176 assert (offset >= 0); |
1172 assert (len >= 0); | 1177 assert (len >= 0); |
1173 assert (offset + len <= string_length (XSTRING (string))); | 1178 assert (offset + len <= XSTRING_LENGTH (string)); |
1174 | 1179 |
1175 lstr = Lstream_new (lstream_lisp_string, "r"); | 1180 lstr = Lstream_new (lstream_lisp_string, "r"); |
1176 str = LISP_STRING_STREAM_DATA (lstr); | 1181 str = LISP_STRING_STREAM_DATA (lstr); |
1177 str->offset = offset; | 1182 str->offset = offset; |
1178 str->end = offset + len; | 1183 str->end = offset + len; |
1185 static int | 1190 static int |
1186 lisp_string_reader (Lstream *stream, unsigned char *data, int size) | 1191 lisp_string_reader (Lstream *stream, unsigned char *data, int size) |
1187 { | 1192 { |
1188 struct lisp_string_stream *str = LISP_STRING_STREAM_DATA (stream); | 1193 struct lisp_string_stream *str = LISP_STRING_STREAM_DATA (stream); |
1189 /* Don't lose if the string shrank past us ... */ | 1194 /* Don't lose if the string shrank past us ... */ |
1190 Bytecount offset = min (str->offset, string_length (XSTRING (str->obj))); | 1195 Bytecount offset = min (str->offset, XSTRING_LENGTH (str->obj)); |
1191 Bufbyte *strstart = string_data (XSTRING (str->obj)); | 1196 Bufbyte *strstart = XSTRING_DATA (str->obj); |
1192 Bufbyte *start = strstart + offset; | 1197 Bufbyte *start = strstart + offset; |
1193 | 1198 |
1194 /* ... or if someone changed the string and we ended up in the | 1199 /* ... or if someone changed the string and we ended up in the |
1195 middle of a character. */ | 1200 middle of a character. */ |
1196 /* Being in the middle of a character is `normal' unless | 1201 /* Being in the middle of a character is `normal' unless |
1211 struct lisp_string_stream *str = LISP_STRING_STREAM_DATA (stream); | 1216 struct lisp_string_stream *str = LISP_STRING_STREAM_DATA (stream); |
1212 int pos = str->init_offset; | 1217 int pos = str->init_offset; |
1213 if (pos > str->end) | 1218 if (pos > str->end) |
1214 pos = str->end; | 1219 pos = str->end; |
1215 /* Don't lose if the string shrank past us ... */ | 1220 /* Don't lose if the string shrank past us ... */ |
1216 pos = min (pos, string_length (XSTRING (str->obj))); | 1221 pos = min (pos, XSTRING_LENGTH (str->obj)); |
1217 /* ... or if someone changed the string and we ended up in the | 1222 /* ... or if someone changed the string and we ended up in the |
1218 middle of a character. */ | 1223 middle of a character. */ |
1219 { | 1224 { |
1220 Bufbyte *strstart = string_data (XSTRING (str->obj)); | 1225 Bufbyte *strstart = XSTRING_DATA (str->obj); |
1221 Bufbyte *start = strstart + pos; | 1226 Bufbyte *start = strstart + pos; |
1222 VALIDATE_CHARPTR_BACKWARD (start); | 1227 VALIDATE_CHARPTR_BACKWARD (start); |
1223 pos = start - strstart; | 1228 pos = start - strstart; |
1224 } | 1229 } |
1225 str->offset = pos; | 1230 str->offset = pos; |