X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Flstream.h;h=877f66ca21d71d0d1702b4117c50e1359ec10c01;hb=aa982acf01b4e35675a624d78c9e5ee109c1203e;hp=110804575bee7896d154eab87d96dccf2e110e71;hpb=afa9772e3fcbb4e80e3e4cfd1a40b4fccc6d08b8;p=chise%2Fxemacs-chise.git diff --git a/src/lstream.h b/src/lstream.h index 1108045..877f66c 100644 --- a/src/lstream.h +++ b/src/lstream.h @@ -23,8 +23,8 @@ Boston, MA 02111-1307, USA. */ /* Written by Ben Wing. */ -#ifndef _XEMACS_LSTREAM_H_ -#define _XEMACS_LSTREAM_H_ +#ifndef INCLUDED_lstream_h_ +#define INCLUDED_lstream_h_ /************************************************************************/ /* definition of Lstream object */ @@ -74,7 +74,7 @@ typedef enum lstream_buffering typedef struct lstream_implementation { - CONST char *name; + const char *name; size_t size; /* Number of additional bytes to be allocated with this stream. Access this data using Lstream_data(). */ /* Read some data from the stream's end and store it into DATA, which @@ -92,7 +92,7 @@ typedef struct lstream_implementation the caller calls Lstream_read() with a very small size. This function can be NULL if the stream is output-only. */ - /* The omniscient mly, blinded by the irresistable thrall of Common + /* The omniscient mly, blinded by the irresistible thrall of Common Lisp, thinks that it is bogus that the types and implementations of input and output streams are the same. */ ssize_t (*reader) (Lstream *stream, unsigned char *data, size_t size); @@ -106,7 +106,7 @@ typedef struct lstream_implementation data. (This is useful, e.g., of you're dealing with a non-blocking file descriptor and are getting EWOULDBLOCK errors.) This function can be NULL if the stream is input-only. */ - ssize_t (*writer) (Lstream *stream, CONST unsigned char *data, size_t size); + ssize_t (*writer) (Lstream *stream, const unsigned char *data, size_t size); /* Return non-zero if the last write operation on the stream resulted in an attempt to block (EWOULDBLOCK). If this method does not exists, the implementation returns 0 */ @@ -145,7 +145,7 @@ typedef struct lstream_implementation struct lstream { struct lcrecord_header header; - CONST Lstream_implementation *imp; /* methods for this stream */ + const Lstream_implementation *imp; /* methods for this stream */ Lstream_buffering buffering; /* type of buffering in use */ size_t buffering_size; /* number of bytes buffered */ @@ -167,20 +167,20 @@ struct lstream size_t unget_buffer_ind; /* pointer to next buffer spot to write a character */ size_t byte_count; - long flags; /* Align pointer for 64 bit machines (kny) */ - char data[1]; + int flags; + max_align_t data[1]; }; #define LSTREAM_TYPE_P(lstr, type) \ ((lstr)->imp == lstream_##type) #ifdef ERROR_CHECK_TYPECHECK -INLINE struct lstream * +INLINE_HEADER struct lstream * error_check_lstream_type (struct lstream *stream, - CONST Lstream_implementation *imp); -INLINE struct lstream * + const Lstream_implementation *imp); +INLINE_HEADER struct lstream * error_check_lstream_type (struct lstream *stream, - CONST Lstream_implementation *imp) + const Lstream_implementation *imp) { assert (stream->imp == imp); return stream; @@ -199,8 +199,8 @@ error_check_lstream_type (struct lstream *stream, (lstream_##type->m = type##_##m) -Lstream *Lstream_new (CONST Lstream_implementation *imp, - CONST char *mode); +Lstream *Lstream_new (const Lstream_implementation *imp, + const char *mode); void Lstream_reopen (Lstream *lstr); void Lstream_set_buffering (Lstream *lstr, Lstream_buffering buffering, int buffering_size); @@ -210,9 +210,9 @@ int Lstream_fputc (Lstream *lstr, int c); int Lstream_fgetc (Lstream *lstr); void Lstream_fungetc (Lstream *lstr, int c); ssize_t Lstream_read (Lstream *lstr, void *data, size_t size); -ssize_t Lstream_write (Lstream *lstr, CONST void *data, size_t size); +ssize_t Lstream_write (Lstream *lstr, const void *data, size_t size); int Lstream_was_blocked_p (Lstream *lstr); -void Lstream_unread (Lstream *lstr, CONST void *data, size_t size); +void Lstream_unread (Lstream *lstr, const void *data, size_t size); int Lstream_rewind (Lstream *lstr); int Lstream_seekable_p (Lstream *lstr); int Lstream_close (Lstream *lstr); @@ -265,20 +265,25 @@ void Lstream_set_character_mode (Lstream *str); #ifdef MULE #ifndef BYTE_ASCII_P -#include "mule-charset.h" +#include "multibyte.h" #endif -INLINE Emchar Lstream_get_emchar (Lstream *stream); -INLINE Emchar +#ifndef CHAR_ASCII_P +#include "character.h" +#endif + +INLINE_HEADER Emchar Lstream_get_emchar (Lstream *stream); +INLINE_HEADER Emchar Lstream_get_emchar (Lstream *stream) { int c = Lstream_getc (stream); - return BYTE_ASCII_P (c) ? (Emchar) c : - Lstream_get_emchar_1 (stream, c); + return (c < 0x80 /* c == EOF || BYTE_ASCII_P (c) */ + ? (Emchar) c + : Lstream_get_emchar_1 (stream, c)); } -INLINE int Lstream_put_emchar (Lstream *stream, Emchar ch); -INLINE int +INLINE_HEADER int Lstream_put_emchar (Lstream *stream, Emchar ch); +INLINE_HEADER int Lstream_put_emchar (Lstream *stream, Emchar ch) { return CHAR_ASCII_P (ch) ? @@ -286,8 +291,8 @@ Lstream_put_emchar (Lstream *stream, Emchar ch) Lstream_fput_emchar (stream, ch); } -INLINE void Lstream_unget_emchar (Lstream *stream, Emchar ch); -INLINE void +INLINE_HEADER void Lstream_unget_emchar (Lstream *stream, Emchar ch); +INLINE_HEADER void Lstream_unget_emchar (Lstream *stream, Emchar ch) { if (CHAR_ASCII_P (ch)) @@ -339,11 +344,9 @@ int filedesc_stream_fd (Lstream *stream); Lisp_Object make_lisp_string_input_stream (Lisp_Object string, Bytecount offset, Bytecount len); -Lisp_Object make_fixed_buffer_input_stream (CONST unsigned char *buf, - size_t size); -Lisp_Object make_fixed_buffer_output_stream (unsigned char *buf, - size_t size); -CONST unsigned char *fixed_buffer_input_stream_ptr (Lstream *stream); +Lisp_Object make_fixed_buffer_input_stream (const void *buf, size_t size); +Lisp_Object make_fixed_buffer_output_stream (void *buf, size_t size); +const unsigned char *fixed_buffer_input_stream_ptr (Lstream *stream); unsigned char *fixed_buffer_output_stream_ptr (Lstream *stream); Lisp_Object make_resizing_buffer_output_stream (void); unsigned char *resizing_buffer_stream_ptr (Lstream *stream); @@ -356,4 +359,4 @@ Lisp_Object make_lisp_buffer_output_stream (struct buffer *buf, Bufpos pos, int flags); Bufpos lisp_buffer_stream_startpos (Lstream *stream); -#endif /* _XEMACS_LSTREAM_H_ */ +#endif /* INCLUDED_lstream_h_ */