(coded-charset-entity-reference-alist): Add setting for
[chise/xemacs-chise.git.1] / src / lstream.c
index d413800..8151bc7 100644 (file)
@@ -95,17 +95,19 @@ int Lstream_fgetc (Lstream *stream)
 void Lstream_fungetc (Lstream *stream, int c)
        Function equivalents of the above macros.
 
 void Lstream_fungetc (Lstream *stream, int c)
        Function equivalents of the above macros.
 
-ssize_t Lstream_read (Lstream *stream, void *data, size_t size)
+Lstream_data_count Lstream_read (Lstream *stream, void *data,
+                                 Lstream_data_count size)
        Read SIZE bytes of DATA from the stream.  Return the number of
        bytes read.  0 means EOF. -1 means an error occurred and no
        bytes were read.
 
        Read SIZE bytes of DATA from the stream.  Return the number of
        bytes read.  0 means EOF. -1 means an error occurred and no
        bytes were read.
 
-ssize_t Lstream_write (Lstream *stream, void *data, size_t size)
+Lstream_data_count Lstream_write (Lstream *stream, void *data,
+                                  Lstream_data_count size)
        Write SIZE bytes of DATA to the stream.  Return the number of
        bytes written.  -1 means an error occurred and no bytes were
        written.
 
        Write SIZE bytes of DATA to the stream.  Return the number of
        bytes written.  -1 means an error occurred and no bytes were
        written.
 
-void Lstream_unread (Lstream *stream, void *data, size_t size)
+void Lstream_unread (Lstream *stream, void *data, Lstream_data_count size)
        Push back SIZE bytes of DATA onto the input queue.  The
        next call to Lstream_read() with the same size will read the
        same bytes back.  Note that this will be the case even if
        Push back SIZE bytes of DATA onto the input queue.  The
        next call to Lstream_read() with the same size will read the
        same bytes back.  Note that this will be the case even if
@@ -282,7 +284,7 @@ Lstream_delete (Lstream *lstr)
        }
     }
 
        }
     }
 
-  abort ();
+  ABORT ();
 }
 
 #define Lstream_internal_error(reason, lstr) \
 }
 
 #define Lstream_internal_error(reason, lstr) \
@@ -308,11 +310,11 @@ Lstream_reopen (Lstream *lstr)
 int
 Lstream_flush_out (Lstream *lstr)
 {
 int
 Lstream_flush_out (Lstream *lstr)
 {
-  ssize_t num_written;
+  Lstream_data_count num_written;
 
   while (lstr->out_buffer_ind > 0)
     {
 
   while (lstr->out_buffer_ind > 0)
     {
-      size_t size = lstr->out_buffer_ind;
+      Lstream_data_count size = lstr->out_buffer_ind;
       if (! (lstr->flags & LSTREAM_FL_IS_OPEN))
        Lstream_internal_error ("lstream not open", lstr);
       if (! (lstr->flags & LSTREAM_FL_WRITE))
       if (! (lstr->flags & LSTREAM_FL_IS_OPEN))
        Lstream_internal_error ("lstream not open", lstr);
       if (! (lstr->flags & LSTREAM_FL_WRITE))
@@ -395,10 +397,10 @@ Lstream_flush (Lstream *lstr)
    if it's getting EWOULDBLOCK errors.   We have to keep stocking them
    up until they can be written, so as to avoid losing data. */
 
    if it's getting EWOULDBLOCK errors.   We have to keep stocking them
    up until they can be written, so as to avoid losing data. */
 
-static size_t
-Lstream_adding (Lstream *lstr, size_t num, int force)
+static Lstream_data_count
+Lstream_adding (Lstream *lstr, Lstream_data_count num, int force)
 {
 {
-  size_t size = num + lstr->out_buffer_ind;
+  Lstream_data_count size = num + lstr->out_buffer_ind;
 
   if (size <= lstr->out_buffer_size)
     return num;
 
   if (size <= lstr->out_buffer_size)
     return num;
@@ -420,11 +422,11 @@ Lstream_adding (Lstream *lstr, size_t num, int force)
 
 /* Like Lstream_write(), but does not handle line-buffering correctly. */
 
 
 /* Like Lstream_write(), but does not handle line-buffering correctly. */
 
-static ssize_t
-Lstream_write_1 (Lstream *lstr, const void *data, size_t size)
+static Lstream_data_count
+Lstream_write_1 (Lstream *lstr, const void *data, Lstream_data_count size)
 {
   const unsigned char *p = (const unsigned char *) data;
 {
   const unsigned char *p = (const unsigned char *) data;
-  ssize_t off = 0;
+  Lstream_data_count off = 0;
   if (! (lstr->flags & LSTREAM_FL_IS_OPEN))
     Lstream_internal_error ("lstream not open", lstr);
   if (! (lstr->flags & LSTREAM_FL_WRITE))
   if (! (lstr->flags & LSTREAM_FL_IS_OPEN))
     Lstream_internal_error ("lstream not open", lstr);
   if (! (lstr->flags & LSTREAM_FL_WRITE))
@@ -435,7 +437,7 @@ Lstream_write_1 (Lstream *lstr, const void *data, size_t size)
     while (1)
       {
        /* Figure out how much we can add to the buffer */
     while (1)
       {
        /* Figure out how much we can add to the buffer */
-       size_t chunk = Lstream_adding (lstr, size, 0);
+       Lstream_data_count chunk = Lstream_adding (lstr, size, 0);
        if (chunk == 0)
          {
            if (couldnt_write_last_time)
        if (chunk == 0)
          {
            if (couldnt_write_last_time)
@@ -480,10 +482,10 @@ Lstream_write_1 (Lstream *lstr, const void *data, size_t size)
    repeatedly call Lstream_putc(), which knows how to handle
    line buffering.  Returns number of bytes written. */
 
    repeatedly call Lstream_putc(), which knows how to handle
    line buffering.  Returns number of bytes written. */
 
-ssize_t
-Lstream_write (Lstream *lstr, const void *data, size_t size)
+Lstream_data_count
+Lstream_write (Lstream *lstr, const void *data, Lstream_data_count size)
 {
 {
-  size_t i;
+  Lstream_data_count i;
   const unsigned char *p = (const unsigned char *) data;
 
   if (size == 0)
   const unsigned char *p = (const unsigned char *) data;
 
   if (size == 0)
@@ -495,7 +497,7 @@ Lstream_write (Lstream *lstr, const void *data, size_t size)
       if (Lstream_putc (lstr, p[i]) < 0)
        break;
     }
       if (Lstream_putc (lstr, p[i]) < 0)
        break;
     }
-  return i == 0 ? -1 : (ssize_t) i;
+  return i == 0 ? -1 : i;
 }
 
 int
 }
 
 int
@@ -504,8 +506,9 @@ Lstream_was_blocked_p (Lstream *lstr)
   return lstr->imp->was_blocked_p ? lstr->imp->was_blocked_p (lstr) : 0;
 }
 
   return lstr->imp->was_blocked_p ? lstr->imp->was_blocked_p (lstr) : 0;
 }
 
-static ssize_t
-Lstream_raw_read (Lstream *lstr, unsigned char *buffer, size_t size)
+static Lstream_data_count
+Lstream_raw_read (Lstream *lstr, unsigned char *buffer,
+                 Lstream_data_count size)
 {
   if (! (lstr->flags & LSTREAM_FL_IS_OPEN))
     Lstream_internal_error ("lstream not open", lstr);
 {
   if (! (lstr->flags & LSTREAM_FL_IS_OPEN))
     Lstream_internal_error ("lstream not open", lstr);
@@ -519,16 +522,18 @@ Lstream_raw_read (Lstream *lstr, unsigned char *buffer, size_t size)
 
 /* Assuming the buffer is empty, fill it up again. */
 
 
 /* Assuming the buffer is empty, fill it up again. */
 
-static ssize_t
+static Lstream_data_count
 Lstream_read_more (Lstream *lstr)
 {
 #if 0
 Lstream_read_more (Lstream *lstr)
 {
 #if 0
-  ssize_t size_needed = max (1, min (MAX_READ_SIZE, lstr->buffering_size));
+  Lstream_data_count size_needed 
+    = max (1, min (MAX_READ_SIZE, lstr->buffering_size));
 #else
   /* If someone requested a larger buffer size, so be it! */
 #else
   /* If someone requested a larger buffer size, so be it! */
-  ssize_t size_needed = max (1, lstr->buffering_size);
+  Lstream_data_count size_needed =
+    max (1, lstr->buffering_size);
 #endif
 #endif
-  ssize_t size_gotten;
+  Lstream_data_count size_gotten;
 
   DO_REALLOC (lstr->in_buffer, lstr->in_buffer_size,
              size_needed, unsigned char);
 
   DO_REALLOC (lstr->in_buffer, lstr->in_buffer_size,
              size_needed, unsigned char);
@@ -538,12 +543,12 @@ Lstream_read_more (Lstream *lstr)
   return size_gotten < 0 ? -1 : size_gotten;
 }
 
   return size_gotten < 0 ? -1 : size_gotten;
 }
 
-ssize_t
-Lstream_read (Lstream *lstr, void *data, size_t size)
+Lstream_data_count
+Lstream_read (Lstream *lstr, void *data, Lstream_data_count size)
 {
   unsigned char *p = (unsigned char *) data;
 {
   unsigned char *p = (unsigned char *) data;
-  size_t off = 0;
-  size_t chunk;
+  Lstream_data_count off = 0;
+  Lstream_data_count chunk;
   int error_occurred = 0;
 
   if (size == 0)
   int error_occurred = 0;
 
   if (size == 0)
@@ -576,7 +581,7 @@ Lstream_read (Lstream *lstr, void *data, size_t size)
       /* If we need some more, try to get some more from the stream's end */
       if (size > 0)
        {
       /* If we need some more, try to get some more from the stream's end */
       if (size > 0)
        {
-         ssize_t retval = Lstream_read_more (lstr);
+         Lstream_data_count retval = Lstream_read_more (lstr);
          if (retval < 0)
            error_occurred = 1;
          if (retval <= 0)
          if (retval < 0)
            error_occurred = 1;
          if (retval <= 0)
@@ -600,7 +605,7 @@ Lstream_read (Lstream *lstr, void *data, size_t size)
          VALIDATE_CHARPTR_BACKWARD (dataend);
          if (dataend + REP_BYTES_BY_FIRST_BYTE (*dataend) != p + off)
            {
          VALIDATE_CHARPTR_BACKWARD (dataend);
          if (dataend + REP_BYTES_BY_FIRST_BYTE (*dataend) != p + off)
            {
-             size_t newoff = dataend - p;
+             Lstream_data_count newoff = dataend - p;
              /* If not, chop the size down to ignore the last char
                 and stash it away for next time. */
              Lstream_unread (lstr, dataend, off - newoff);
              /* If not, chop the size down to ignore the last char
                 and stash it away for next time. */
              Lstream_unread (lstr, dataend, off - newoff);
@@ -609,11 +614,11 @@ Lstream_read (Lstream *lstr, void *data, size_t size)
        }
     }
 
        }
     }
 
-  return off == 0 && error_occurred ? -1 : (ssize_t) off;
+  return off == 0 && error_occurred ? -1 : off;
 }
 
 void
 }
 
 void
-Lstream_unread (Lstream *lstr, const void *data, size_t size)
+Lstream_unread (Lstream *lstr, const void *data, Lstream_data_count size)
 {
   const unsigned char *p = (const unsigned char *) data;
 
 {
   const unsigned char *p = (const unsigned char *) data;
 
@@ -653,7 +658,7 @@ Lstream_seekable_p (Lstream *lstr)
 static int
 Lstream_pseudo_close (Lstream *lstr)
 {
 static int
 Lstream_pseudo_close (Lstream *lstr)
 {
-  if (!lstr->flags & LSTREAM_FL_IS_OPEN)
+  if (! (lstr->flags & LSTREAM_FL_IS_OPEN))
     Lstream_internal_error ("lstream is not open", lstr);
 
   /* don't check errors here -- best not to risk file descriptor loss */
     Lstream_internal_error ("lstream is not open", lstr);
 
   /* don't check errors here -- best not to risk file descriptor loss */
@@ -732,7 +737,7 @@ int
 Lstream_fputc (Lstream *lstr, int c)
 {
   unsigned char ch = (unsigned char) c;
 Lstream_fputc (Lstream *lstr, int c)
 {
   unsigned char ch = (unsigned char) c;
-  ssize_t retval = Lstream_write_1 (lstr, &ch, 1);
+  Lstream_data_count retval = Lstream_write_1 (lstr, &ch, 1);
   if (retval >= 0 && lstr->buffering == LSTREAM_LINE_BUFFERED && ch == '\n')
     return Lstream_flush_out (lstr);
   return retval < 0 ? -1 : 0;
   if (retval >= 0 && lstr->buffering == LSTREAM_LINE_BUFFERED && ch == '\n')
     return Lstream_flush_out (lstr);
   return retval < 0 ? -1 : 0;
@@ -813,21 +818,22 @@ make_stdio_output_stream (FILE *stream, int flags)
    code (it could even be argued that the error might have fixed
    itself, so we should do the fread() again.  */
 
    code (it could even be argued that the error might have fixed
    itself, so we should do the fread() again.  */
 
-static ssize_t
-stdio_reader (Lstream *stream, unsigned char *data, size_t size)
+static Lstream_data_count
+stdio_reader (Lstream *stream, unsigned char *data, Lstream_data_count size)
 {
   struct stdio_stream *str = STDIO_STREAM_DATA (stream);
 {
   struct stdio_stream *str = STDIO_STREAM_DATA (stream);
-  size_t val = fread (data, 1, size, str->file);
+  Lstream_data_count val = fread (data, 1, size, str->file);
   if (!val && ferror (str->file))
     return -1;
   return val;
 }
 
   if (!val && ferror (str->file))
     return -1;
   return val;
 }
 
-static ssize_t
-stdio_writer (Lstream *stream, const unsigned char *data, size_t size)
+static Lstream_data_count
+stdio_writer (Lstream *stream, const unsigned char *data,
+             Lstream_data_count size)
 {
   struct stdio_stream *str = STDIO_STREAM_DATA (stream);
 {
   struct stdio_stream *str = STDIO_STREAM_DATA (stream);
-  size_t val = fwrite (data, 1, size, str->file);
+  Lstream_data_count val = fwrite (data, 1, size, str->file);
   if (!val && ferror (str->file))
     return -1;
   return val;
   if (!val && ferror (str->file))
     return -1;
   return val;
@@ -938,13 +944,13 @@ make_filedesc_output_stream (int filedesc, int offset, int count, int flags)
   return make_filedesc_stream_1 (filedesc, offset, count, flags, "w");
 }
 
   return make_filedesc_stream_1 (filedesc, offset, count, flags, "w");
 }
 
-static ssize_t
-filedesc_reader (Lstream *stream, unsigned char *data, size_t size)
+static Lstream_data_count
+filedesc_reader (Lstream *stream, unsigned char *data, Lstream_data_count size)
 {
 {
-  ssize_t nread;
+  Lstream_data_count nread;
   struct filedesc_stream *str = FILEDESC_STREAM_DATA (stream);
   if (str->end_pos >= 0)
   struct filedesc_stream *str = FILEDESC_STREAM_DATA (stream);
   if (str->end_pos >= 0)
-    size = min (size, (size_t) (str->end_pos - str->current_pos));
+    size = min (size, (Lstream_data_count) (str->end_pos - str->current_pos));
   nread = str->allow_quit ?
     read_allowing_quit (str->fd, data, size) :
     read (str->fd, data, size);
   nread = str->allow_quit ?
     read_allowing_quit (str->fd, data, size) :
     read (str->fd, data, size);
@@ -967,11 +973,12 @@ errno_would_block_p (int val)
   return 0;
 }
 
   return 0;
 }
 
-static ssize_t
-filedesc_writer (Lstream *stream, const unsigned char *data, size_t size)
+static Lstream_data_count
+filedesc_writer (Lstream *stream, const unsigned char *data,
+                Lstream_data_count size)
 {
   struct filedesc_stream *str = FILEDESC_STREAM_DATA (stream);
 {
   struct filedesc_stream *str = FILEDESC_STREAM_DATA (stream);
-  ssize_t retval;
+  Lstream_data_count retval;
   int need_newline = 0;
 
   /* This function would be simple if it were not for the blasted
   int need_newline = 0;
 
   /* This function would be simple if it were not for the blasted
@@ -1025,7 +1032,7 @@ filedesc_writer (Lstream *stream, const unsigned char *data, size_t size)
         out for EWOULDBLOCK. */
       if (str->chars_sans_newline >= str->pty_max_bytes)
        {
         out for EWOULDBLOCK. */
       if (str->chars_sans_newline >= str->pty_max_bytes)
        {
-         ssize_t retval2 = str->allow_quit ?
+         Lstream_data_count retval2 = str->allow_quit ?
            write_allowing_quit (str->fd, &str->eof_char, 1) :
            write (str->fd, &str->eof_char, 1);
 
            write_allowing_quit (str->fd, &str->eof_char, 1) :
            write (str->fd, &str->eof_char, 1);
 
@@ -1058,7 +1065,7 @@ filedesc_writer (Lstream *stream, const unsigned char *data, size_t size)
   if (need_newline)
     {
       Bufbyte nl = '\n';
   if (need_newline)
     {
       Bufbyte nl = '\n';
-      ssize_t retval2 = str->allow_quit ?
+      Lstream_data_count retval2 = str->allow_quit ?
        write_allowing_quit (str->fd, &nl, 1) :
        write (str->fd, &nl, 1);
 
        write_allowing_quit (str->fd, &nl, 1) :
        write (str->fd, &nl, 1);
 
@@ -1194,8 +1201,9 @@ make_lisp_string_input_stream (Lisp_Object string, Bytecount offset,
   return obj;
 }
 
   return obj;
 }
 
-static ssize_t
-lisp_string_reader (Lstream *stream, unsigned char *data, size_t size)
+static Lstream_data_count
+lisp_string_reader (Lstream *stream, unsigned char *data,
+                   Lstream_data_count size)
 {
   struct lisp_string_stream *str = LISP_STRING_STREAM_DATA (stream);
   /* Don't lose if the string shrank past us ... */
 {
   struct lisp_string_stream *str = LISP_STRING_STREAM_DATA (stream);
   /* Don't lose if the string shrank past us ... */
@@ -1210,7 +1218,7 @@ lisp_string_reader (Lstream *stream, unsigned char *data, size_t size)
   if (stream->flags & LSTREAM_FL_NO_PARTIAL_CHARS)
     VALIDATE_CHARPTR_BACKWARD (start);
   offset = start - strstart;
   if (stream->flags & LSTREAM_FL_NO_PARTIAL_CHARS)
     VALIDATE_CHARPTR_BACKWARD (start);
   offset = start - strstart;
-  size = min (size, (size_t) (str->end - offset));
+  size = min (size, (Lstream_data_count) (str->end - offset));
   memcpy (data, start, size);
   str->offset = offset + size;
   return size;
   memcpy (data, start, size);
   str->offset = offset + size;
   return size;
@@ -1253,15 +1261,15 @@ struct fixed_buffer_stream
 {
   const unsigned char *inbuf;
   unsigned char *outbuf;
 {
   const unsigned char *inbuf;
   unsigned char *outbuf;
-  size_t size;
-  size_t offset;
+  Lstream_data_count size;
+  Lstream_data_count offset;
 };
 
 DEFINE_LSTREAM_IMPLEMENTATION ("fixed-buffer", lstream_fixed_buffer,
                               sizeof (struct fixed_buffer_stream));
 
 Lisp_Object
 };
 
 DEFINE_LSTREAM_IMPLEMENTATION ("fixed-buffer", lstream_fixed_buffer,
                               sizeof (struct fixed_buffer_stream));
 
 Lisp_Object
-make_fixed_buffer_input_stream (const void *buf, size_t size)
+make_fixed_buffer_input_stream (const void *buf, Lstream_data_count size)
 {
   Lisp_Object obj;
   Lstream *lstr = Lstream_new (lstream_fixed_buffer, "r");
 {
   Lisp_Object obj;
   Lstream *lstr = Lstream_new (lstream_fixed_buffer, "r");
@@ -1273,7 +1281,7 @@ make_fixed_buffer_input_stream (const void *buf, size_t size)
 }
 
 Lisp_Object
 }
 
 Lisp_Object
-make_fixed_buffer_output_stream (void *buf, size_t size)
+make_fixed_buffer_output_stream (void *buf, Lstream_data_count size)
 {
   Lisp_Object obj;
   Lstream *lstr = Lstream_new (lstream_fixed_buffer, "w");
 {
   Lisp_Object obj;
   Lstream *lstr = Lstream_new (lstream_fixed_buffer, "w");
@@ -1284,8 +1292,9 @@ make_fixed_buffer_output_stream (void *buf, size_t size)
   return obj;
 }
 
   return obj;
 }
 
-static ssize_t
-fixed_buffer_reader (Lstream *stream, unsigned char *data, size_t size)
+static Lstream_data_count
+fixed_buffer_reader (Lstream *stream, unsigned char *data,
+                    Lstream_data_count size)
 {
   struct fixed_buffer_stream *str = FIXED_BUFFER_STREAM_DATA (stream);
   size = min (size, str->size - str->offset);
 {
   struct fixed_buffer_stream *str = FIXED_BUFFER_STREAM_DATA (stream);
   size = min (size, str->size - str->offset);
@@ -1294,8 +1303,9 @@ fixed_buffer_reader (Lstream *stream, unsigned char *data, size_t size)
   return size;
 }
 
   return size;
 }
 
-static ssize_t
-fixed_buffer_writer (Lstream *stream, const unsigned char *data, size_t size)
+static Lstream_data_count
+fixed_buffer_writer (Lstream *stream, const unsigned char *data,
+                    Lstream_data_count size)
 {
   struct fixed_buffer_stream *str = FIXED_BUFFER_STREAM_DATA (stream);
   if (str->offset == str->size)
 {
   struct fixed_buffer_stream *str = FIXED_BUFFER_STREAM_DATA (stream);
   if (str->offset == str->size)
@@ -1340,7 +1350,7 @@ fixed_buffer_output_stream_ptr (Lstream *stream)
 struct resizing_buffer_stream
 {
   unsigned char *buf;
 struct resizing_buffer_stream
 {
   unsigned char *buf;
-  size_t allocked;
+  Lstream_data_count allocked;
   int max_stored;
   int stored;
 };
   int max_stored;
   int stored;
 };
@@ -1356,8 +1366,9 @@ make_resizing_buffer_output_stream (void)
   return obj;
 }
 
   return obj;
 }
 
-static ssize_t
-resizing_buffer_writer (Lstream *stream, const unsigned char *data, size_t size)
+static Lstream_data_count
+resizing_buffer_writer (Lstream *stream, const unsigned char *data,
+                       Lstream_data_count size)
 {
   struct resizing_buffer_stream *str = RESIZING_BUFFER_STREAM_DATA (stream);
   DO_REALLOC (str->buf, str->allocked, str->stored + size, unsigned char);
 {
   struct resizing_buffer_stream *str = RESIZING_BUFFER_STREAM_DATA (stream);
   DO_REALLOC (str->buf, str->allocked, str->stored + size, unsigned char);
@@ -1418,8 +1429,9 @@ make_dynarr_output_stream (unsigned_char_dynarr *dyn)
   return obj;
 }
 
   return obj;
 }
 
-static ssize_t
-dynarr_writer (Lstream *stream, const unsigned char *data, size_t size)
+static Lstream_data_count
+dynarr_writer (Lstream *stream, const unsigned char *data,
+              Lstream_data_count size)
 {
   struct dynarr_stream *str = DYNARR_STREAM_DATA (stream);
   Dynarr_add_many (str->dyn, data, size);
 {
   struct dynarr_stream *str = DYNARR_STREAM_DATA (stream);
   Dynarr_add_many (str->dyn, data, size);
@@ -1472,7 +1484,7 @@ make_lisp_buffer_stream_1 (struct buffer *buf, Bufpos start, Bufpos end,
 
   /* Make sure the luser didn't pass "w" in. */
   if (!strcmp (mode, "w"))
 
   /* Make sure the luser didn't pass "w" in. */
   if (!strcmp (mode, "w"))
-    abort ();
+    ABORT ();
 
   if (flags & LSTR_IGNORE_ACCESSIBLE)
     {
 
   if (flags & LSTR_IGNORE_ACCESSIBLE)
     {
@@ -1542,8 +1554,9 @@ make_lisp_buffer_output_stream (struct buffer *buf, Bufpos pos, int flags)
   return lstr;
 }
 
   return lstr;
 }
 
-static ssize_t
-lisp_buffer_reader (Lstream *stream, unsigned char *data, size_t size)
+static Lstream_data_count
+lisp_buffer_reader (Lstream *stream, unsigned char *data,
+                   Lstream_data_count size)
 {
   struct lisp_buffer_stream *str = LISP_BUFFER_STREAM_DATA (stream);
   unsigned char *orig_data = data;
 {
   struct lisp_buffer_stream *str = LISP_BUFFER_STREAM_DATA (stream);
   unsigned char *orig_data = data;
@@ -1567,7 +1580,7 @@ lisp_buffer_reader (Lstream *stream, unsigned char *data, size_t size)
                                   BI_BUF_ZV (buf));
     }
 
                                   BI_BUF_ZV (buf));
     }
 
-  size = min (size, (size_t) (end - start));
+  size = min (size, (Lstream_data_count) (end - start));
   end = start + size;
   /* We cannot return a partial character. */
   VALIDATE_BYTIND_BACKWARD (buf, end);
   end = start + size;
   /* We cannot return a partial character. */
   VALIDATE_BYTIND_BACKWARD (buf, end);
@@ -1600,8 +1613,9 @@ lisp_buffer_reader (Lstream *stream, unsigned char *data, size_t size)
   return data - orig_data;
 }
 
   return data - orig_data;
 }
 
-static ssize_t
-lisp_buffer_writer (Lstream *stream, const unsigned char *data, size_t size)
+static Lstream_data_count
+lisp_buffer_writer (Lstream *stream, const unsigned char *data,
+                   Lstream_data_count size)
 {
   struct lisp_buffer_stream *str = LISP_BUFFER_STREAM_DATA (stream);
   Bufpos pos;
 {
   struct lisp_buffer_stream *str = LISP_BUFFER_STREAM_DATA (stream);
   Bufpos pos;