diff options
| author | Eli Zaretskii | 2011-04-10 23:43:08 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2011-04-10 23:43:08 +0300 |
| commit | 8a2cbd723c0b453b70dc1fcefe5b489f58605258 (patch) | |
| tree | a1268c68ffe5a72329d60fcf6280485f8ba2327e /src | |
| parent | 1ebfdcb6eff7ebe4cf5ef3426944513a2ecdfacf (diff) | |
| download | emacs-8a2cbd723c0b453b70dc1fcefe5b489f58605258.tar.gz emacs-8a2cbd723c0b453b70dc1fcefe5b489f58605258.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 14 | ||||
| -rw-r--r-- | src/fileio.c | 23 | ||||
| -rw-r--r-- | src/lisp.h | 4 | ||||
| -rw-r--r-- | src/sound.c | 2 | ||||
| -rw-r--r-- | src/sysdep.c | 12 |
5 files changed, 37 insertions, 18 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 3b5f00a542d..242752cd777 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,17 @@ | |||
| 1 | 2011-04-10 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | Fix write-region and its subroutines for buffers > 2GB. | ||
| 4 | * fileio.c (a_write, e_write): Modify declaration of arguments and | ||
| 5 | local variables to support buffers larger than 2GB. | ||
| 6 | (Fcopy_file): Use EMACS_INT for return value of emacs_read. | ||
| 7 | |||
| 8 | * sysdep.c (emacs_write, emacs_read): Use ssize_t for last | ||
| 9 | argument, local variables, and return value. | ||
| 10 | |||
| 11 | * lisp.h: Update prototypes of emacs_write and emacs_read. | ||
| 12 | |||
| 13 | * sound.c (vox_write): Use ssize_t for return value of emacs_write. | ||
| 14 | |||
| 1 | 2011-04-10 Paul Eggert <eggert@cs.ucla.edu> | 15 | 2011-04-10 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 16 | ||
| 3 | * xdisp.c (vmessage): Use memchr, not strnlen, which some hosts lack. | 17 | * xdisp.c (vmessage): Use memchr, not strnlen, which some hosts lack. |
diff --git a/src/fileio.c b/src/fileio.c index f9923c420a3..7e2d888b227 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -143,9 +143,10 @@ Lisp_Object Qfile_name_history; | |||
| 143 | 143 | ||
| 144 | Lisp_Object Qcar_less_than_car; | 144 | Lisp_Object Qcar_less_than_car; |
| 145 | 145 | ||
| 146 | static int a_write (int, Lisp_Object, int, int, | 146 | static int a_write (int, Lisp_Object, EMACS_INT, EMACS_INT, |
| 147 | Lisp_Object *, struct coding_system *); | 147 | Lisp_Object *, struct coding_system *); |
| 148 | static int e_write (int, Lisp_Object, int, int, struct coding_system *); | 148 | static int e_write (int, Lisp_Object, EMACS_INT, EMACS_INT, |
| 149 | struct coding_system *); | ||
| 149 | 150 | ||
| 150 | 151 | ||
| 151 | void | 152 | void |
| @@ -1805,7 +1806,8 @@ If PRESERVE-SELINUX-CONTEXT is non-nil and SELinux is enabled | |||
| 1805 | on the system, we copy the SELinux context of FILE to NEWNAME. */) | 1806 | on the system, we copy the SELinux context of FILE to NEWNAME. */) |
| 1806 | (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) | 1807 | (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) |
| 1807 | { | 1808 | { |
| 1808 | int ifd, ofd, n; | 1809 | int ifd, ofd; |
| 1810 | EMACS_INT n; | ||
| 1809 | char buf[16 * 1024]; | 1811 | char buf[16 * 1024]; |
| 1810 | struct stat st, out_st; | 1812 | struct stat st, out_st; |
| 1811 | Lisp_Object handler; | 1813 | Lisp_Object handler; |
| @@ -4792,11 +4794,13 @@ build_annotations (Lisp_Object start, Lisp_Object end) | |||
| 4792 | The return value is negative in case of system call failure. */ | 4794 | The return value is negative in case of system call failure. */ |
| 4793 | 4795 | ||
| 4794 | static int | 4796 | static int |
| 4795 | a_write (int desc, Lisp_Object string, int pos, register int nchars, Lisp_Object *annot, struct coding_system *coding) | 4797 | a_write (int desc, Lisp_Object string, EMACS_INT pos, |
| 4798 | register EMACS_INT nchars, Lisp_Object *annot, | ||
| 4799 | struct coding_system *coding) | ||
| 4796 | { | 4800 | { |
| 4797 | Lisp_Object tem; | 4801 | Lisp_Object tem; |
| 4798 | int nextpos; | 4802 | EMACS_INT nextpos; |
| 4799 | int lastpos = pos + nchars; | 4803 | EMACS_INT lastpos = pos + nchars; |
| 4800 | 4804 | ||
| 4801 | while (NILP (*annot) || CONSP (*annot)) | 4805 | while (NILP (*annot) || CONSP (*annot)) |
| 4802 | { | 4806 | { |
| @@ -4836,7 +4840,8 @@ a_write (int desc, Lisp_Object string, int pos, register int nchars, Lisp_Object | |||
| 4836 | are indexes to the string STRING. */ | 4840 | are indexes to the string STRING. */ |
| 4837 | 4841 | ||
| 4838 | static int | 4842 | static int |
| 4839 | e_write (int desc, Lisp_Object string, int start, int end, struct coding_system *coding) | 4843 | e_write (int desc, Lisp_Object string, EMACS_INT start, EMACS_INT end, |
| 4844 | struct coding_system *coding) | ||
| 4840 | { | 4845 | { |
| 4841 | if (STRINGP (string)) | 4846 | if (STRINGP (string)) |
| 4842 | { | 4847 | { |
| @@ -4867,8 +4872,8 @@ e_write (int desc, Lisp_Object string, int start, int end, struct coding_system | |||
| 4867 | } | 4872 | } |
| 4868 | else | 4873 | else |
| 4869 | { | 4874 | { |
| 4870 | int start_byte = CHAR_TO_BYTE (start); | 4875 | EMACS_INT start_byte = CHAR_TO_BYTE (start); |
| 4871 | int end_byte = CHAR_TO_BYTE (end); | 4876 | EMACS_INT end_byte = CHAR_TO_BYTE (end); |
| 4872 | 4877 | ||
| 4873 | coding->src_multibyte = (end - start) < (end_byte - start_byte); | 4878 | coding->src_multibyte = (end - start) < (end_byte - start_byte); |
| 4874 | if (CODING_REQUIRE_ENCODING (coding)) | 4879 | if (CODING_REQUIRE_ENCODING (coding)) |
diff --git a/src/lisp.h b/src/lisp.h index 4859862c88f..d3e43c1cf14 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -3346,8 +3346,8 @@ extern long get_random (void); | |||
| 3346 | extern void seed_random (long); | 3346 | extern void seed_random (long); |
| 3347 | extern int emacs_open (const char *, int, int); | 3347 | extern int emacs_open (const char *, int, int); |
| 3348 | extern int emacs_close (int); | 3348 | extern int emacs_close (int); |
| 3349 | extern int emacs_read (int, char *, unsigned int); | 3349 | extern ssize_t emacs_read (int, char *, ssize_t); |
| 3350 | extern int emacs_write (int, const char *, unsigned int); | 3350 | extern ssize_t emacs_write (int, const char *, ssize_t); |
| 3351 | enum { READLINK_BUFSIZE = 1024 }; | 3351 | enum { READLINK_BUFSIZE = 1024 }; |
| 3352 | extern char *emacs_readlink (const char *, char [READLINK_BUFSIZE]); | 3352 | extern char *emacs_readlink (const char *, char [READLINK_BUFSIZE]); |
| 3353 | #ifndef HAVE_MEMSET | 3353 | #ifndef HAVE_MEMSET |
diff --git a/src/sound.c b/src/sound.c index a972809e2c7..a9bd540aaa9 100644 --- a/src/sound.c +++ b/src/sound.c | |||
| @@ -897,7 +897,7 @@ vox_init (struct sound_device *sd) | |||
| 897 | static void | 897 | static void |
| 898 | vox_write (struct sound_device *sd, const char *buffer, int nbytes) | 898 | vox_write (struct sound_device *sd, const char *buffer, int nbytes) |
| 899 | { | 899 | { |
| 900 | int nwritten = emacs_write (sd->fd, buffer, nbytes); | 900 | ssize_t nwritten = emacs_write (sd->fd, buffer, nbytes); |
| 901 | if (nwritten < 0) | 901 | if (nwritten < 0) |
| 902 | sound_perror ("Error writing to sound device"); | 902 | sound_perror ("Error writing to sound device"); |
| 903 | } | 903 | } |
diff --git a/src/sysdep.c b/src/sysdep.c index f4f767dac3f..37c9f73dba9 100644 --- a/src/sysdep.c +++ b/src/sysdep.c | |||
| @@ -1825,10 +1825,10 @@ emacs_close (int fd) | |||
| 1825 | return rtnval; | 1825 | return rtnval; |
| 1826 | } | 1826 | } |
| 1827 | 1827 | ||
| 1828 | int | 1828 | ssize_t |
| 1829 | emacs_read (int fildes, char *buf, unsigned int nbyte) | 1829 | emacs_read (int fildes, char *buf, ssize_t nbyte) |
| 1830 | { | 1830 | { |
| 1831 | register int rtnval; | 1831 | register ssize_t rtnval; |
| 1832 | 1832 | ||
| 1833 | while ((rtnval = read (fildes, buf, nbyte)) == -1 | 1833 | while ((rtnval = read (fildes, buf, nbyte)) == -1 |
| 1834 | && (errno == EINTR)) | 1834 | && (errno == EINTR)) |
| @@ -1836,10 +1836,10 @@ emacs_read (int fildes, char *buf, unsigned int nbyte) | |||
| 1836 | return (rtnval); | 1836 | return (rtnval); |
| 1837 | } | 1837 | } |
| 1838 | 1838 | ||
| 1839 | int | 1839 | ssize_t |
| 1840 | emacs_write (int fildes, const char *buf, unsigned int nbyte) | 1840 | emacs_write (int fildes, const char *buf, ssize_t nbyte) |
| 1841 | { | 1841 | { |
| 1842 | register int rtnval, bytes_written; | 1842 | register ssize_t rtnval, bytes_written; |
| 1843 | 1843 | ||
| 1844 | bytes_written = 0; | 1844 | bytes_written = 0; |
| 1845 | 1845 | ||