emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r103883: Fix write-region and its sub


From: Eli Zaretskii
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r103883: Fix write-region and its subroutines for buffers > 2GB.
Date: Sun, 10 Apr 2011 23:43:08 +0300
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 103883
committer: Eli Zaretskii <address@hidden>
branch nick: trunk
timestamp: Sun 2011-04-10 23:43:08 +0300
message:
  Fix write-region and its subroutines for buffers > 2GB.
  
   src/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.
   src/sysdep.c (emacs_write, emacs_read): Use ssize_t for last
   argument, local variables, and return value.
   src/lisp.h: Update prototypes of emacs_write and emacs_read.
   src/sound.c (vox_write): Use ssize_t for return value of emacs_write.
modified:
  src/ChangeLog
  src/fileio.c
  src/lisp.h
  src/sound.c
  src/sysdep.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2011-04-10 19:47:49 +0000
+++ b/src/ChangeLog     2011-04-10 20:43:08 +0000
@@ -1,3 +1,17 @@
+2011-04-10  Eli Zaretskii  <address@hidden>
+
+       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  <address@hidden>
 
        * xdisp.c (vmessage): Use memchr, not strnlen, which some hosts lack.

=== modified file 'src/fileio.c'
--- a/src/fileio.c      2011-04-09 16:35:19 +0000
+++ b/src/fileio.c      2011-04-10 20:43:08 +0000
@@ -143,9 +143,10 @@
 
 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 *);
 
 
 void
@@ -1805,7 +1806,8 @@
 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;
@@ -4792,11 +4794,13 @@
    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))
     {
@@ -4836,7 +4840,8 @@
    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))
     {
@@ -4867,8 +4872,8 @@
        }
       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))

=== modified file 'src/lisp.h'
--- a/src/lisp.h        2011-04-09 18:42:31 +0000
+++ b/src/lisp.h        2011-04-10 20:43:08 +0000
@@ -3346,8 +3346,8 @@
 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

=== modified file 'src/sound.c'
--- a/src/sound.c       2011-04-05 20:08:03 +0000
+++ b/src/sound.c       2011-04-10 20:43:08 +0000
@@ -897,7 +897,7 @@
 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");
 }

=== modified file 'src/sysdep.c'
--- a/src/sysdep.c      2011-04-07 03:34:05 +0000
+++ b/src/sysdep.c      2011-04-10 20:43:08 +0000
@@ -1825,10 +1825,10 @@
   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))
@@ -1836,10 +1836,10 @@
   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;
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]