Mercurial > emacs
comparison lib-src/test-distrib.c @ 111548:ae7e9ce45a16
* lib-src/test-distrib.c: Remove include guards for config.h and fcntl.h.
(O_RDONLY): Do not define.
(cool_read): Fix type for variable "sofar".
author | Dan Nicolaescu <dann@ics.uci.edu> |
---|---|
date | Sun, 14 Nov 2010 22:42:21 -0800 |
parents | 5c1a707ab452 |
children | 417b1e4d63cd 7df2e30d72ec |
comparison
equal
deleted
inserted
replaced
111547:b678d49db641 | 111548:ae7e9ce45a16 |
---|---|
17 | 17 |
18 You should have received a copy of the GNU General Public License | 18 You should have received a copy of the GNU General Public License |
19 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | 19 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ |
20 | 20 |
21 | 21 |
22 #ifdef HAVE_CONFIG_H | |
23 #include <config.h> | 22 #include <config.h> |
24 #endif | |
25 | |
26 #include <stdio.h> | 23 #include <stdio.h> |
27 | |
28 #ifdef HAVE_FCNTL_H | |
29 #include <fcntl.h> | 24 #include <fcntl.h> |
30 #endif | |
31 | 25 |
32 #ifdef HAVE_UNISTD_H | 26 #ifdef HAVE_UNISTD_H |
33 #include <unistd.h> | 27 #include <unistd.h> |
34 #endif | |
35 | |
36 #ifndef O_RDONLY | |
37 #define O_RDONLY 0 | |
38 #endif | 28 #endif |
39 | 29 |
40 /* Break string in two parts to avoid buggy C compilers that ignore characters | 30 /* Break string in two parts to avoid buggy C compilers that ignore characters |
41 after nulls in strings. */ | 31 after nulls in strings. */ |
42 | 32 |
53 /* Like `read' but keeps trying until it gets SIZE bytes or reaches eof. */ | 43 /* Like `read' but keeps trying until it gets SIZE bytes or reaches eof. */ |
54 int | 44 int |
55 cool_read (int fd, char *buf, size_t size) | 45 cool_read (int fd, char *buf, size_t size) |
56 { | 46 { |
57 ssize_t num; | 47 ssize_t num; |
58 size_t sofar = 0; | 48 ssize_t sofar = 0; |
59 | 49 |
60 while (1) | 50 while (1) |
61 { | 51 { |
62 if ((num = read (fd, buf + sofar, size - sofar)) == 0) | 52 if ((num = read (fd, buf + sofar, size - sofar)) == 0) |
63 return sofar; | 53 return sofar; |