+2011-04-10 Eli Zaretskii <eliz@gnu.org>
+
+ Fix write-region and its subroutines for buffers > 2GB.
+ * fileio.c (a_write, e_write): Modify declaration of arguments and
+ local variables to support buffers larger than 2GB.
+ (Fcopy_file): Use EMACS_INT for return value of emacs_read.
+
+ * sysdep.c (emacs_write, emacs_read): Use ssize_t for last
+ argument, local variables, and return value.
+
+ * lisp.h: Update prototypes of emacs_write and emacs_read.
+
+ * sound.c (vox_write): Use ssize_t for return value of emacs_write.
+
2011-04-10 Paul Eggert <eggert@cs.ucla.edu>
* xdisp.c (vmessage): Use memchr, not strnlen, which some hosts lack.
Lisp_Object Qcar_less_than_car;
-static int a_write (int, Lisp_Object, int, int,
+static int a_write (int, Lisp_Object, EMACS_INT, EMACS_INT,
Lisp_Object *, struct coding_system *);
-static int e_write (int, Lisp_Object, int, int, struct coding_system *);
+static int e_write (int, Lisp_Object, EMACS_INT, EMACS_INT,
+ struct coding_system *);
\f
void
on the system, we copy the SELinux context of FILE to NEWNAME. */)
(Lisp_Object file, Lisp_Object newname, Lisp_Object ok_if_already_exists, Lisp_Object keep_time, Lisp_Object preserve_uid_gid, Lisp_Object preserve_selinux_context)
{
- int ifd, ofd, n;
+ int ifd, ofd;
+ EMACS_INT n;
char buf[16 * 1024];
struct stat st, out_st;
Lisp_Object handler;
The return value is negative in case of system call failure. */
static int
-a_write (int desc, Lisp_Object string, int pos, register int nchars, Lisp_Object *annot, struct coding_system *coding)
+a_write (int desc, Lisp_Object string, EMACS_INT pos,
+ register EMACS_INT nchars, Lisp_Object *annot,
+ struct coding_system *coding)
{
Lisp_Object tem;
- int nextpos;
- int lastpos = pos + nchars;
+ EMACS_INT nextpos;
+ EMACS_INT lastpos = pos + nchars;
while (NILP (*annot) || CONSP (*annot))
{
are indexes to the string STRING. */
static int
-e_write (int desc, Lisp_Object string, int start, int end, struct coding_system *coding)
+e_write (int desc, Lisp_Object string, EMACS_INT start, EMACS_INT end,
+ struct coding_system *coding)
{
if (STRINGP (string))
{
}
else
{
- int start_byte = CHAR_TO_BYTE (start);
- int end_byte = CHAR_TO_BYTE (end);
+ EMACS_INT start_byte = CHAR_TO_BYTE (start);
+ EMACS_INT end_byte = CHAR_TO_BYTE (end);
coding->src_multibyte = (end - start) < (end_byte - start_byte);
if (CODING_REQUIRE_ENCODING (coding))
extern void seed_random (long);
extern int emacs_open (const char *, int, int);
extern int emacs_close (int);
-extern int emacs_read (int, char *, unsigned int);
-extern int emacs_write (int, const char *, unsigned int);
+extern ssize_t emacs_read (int, char *, ssize_t);
+extern ssize_t emacs_write (int, const char *, ssize_t);
enum { READLINK_BUFSIZE = 1024 };
extern char *emacs_readlink (const char *, char [READLINK_BUFSIZE]);
#ifndef HAVE_MEMSET
static void
vox_write (struct sound_device *sd, const char *buffer, int nbytes)
{
- int nwritten = emacs_write (sd->fd, buffer, nbytes);
+ ssize_t nwritten = emacs_write (sd->fd, buffer, nbytes);
if (nwritten < 0)
sound_perror ("Error writing to sound device");
}
return rtnval;
}
-int
-emacs_read (int fildes, char *buf, unsigned int nbyte)
+ssize_t
+emacs_read (int fildes, char *buf, ssize_t nbyte)
{
- register int rtnval;
+ register ssize_t rtnval;
while ((rtnval = read (fildes, buf, nbyte)) == -1
&& (errno == EINTR))
return (rtnval);
}
-int
-emacs_write (int fildes, const char *buf, unsigned int nbyte)
+ssize_t
+emacs_write (int fildes, const char *buf, ssize_t nbyte)
{
- register int rtnval, bytes_written;
+ register ssize_t rtnval, bytes_written;
bytes_written = 0;