comparison files.c @ 143:ed45f2d8d3bc

Don't use the <err.h> functions. There are still people out there using legacy systems that are missing them.
author David A. Holland
date Sat, 13 Jul 2013 12:47:20 -0400
parents 1cda505ddc78
children a2c2fe8dbea3 d6e6b3940780
comparison
equal deleted inserted replaced
142:26ee741196d1 143:ed45f2d8d3bc
32 #include <stdlib.h> 32 #include <stdlib.h>
33 #include <string.h> 33 #include <string.h>
34 #include <unistd.h> 34 #include <unistd.h>
35 #include <fcntl.h> 35 #include <fcntl.h>
36 #include <errno.h> 36 #include <errno.h>
37 #include <err.h>
38 37
39 #include "array.h" 38 #include "array.h"
40 #include "mode.h" 39 #include "mode.h"
41 #include "place.h" 40 #include "place.h"
42 #include "files.h" 41 #include "files.h"
212 result = read(fd, buf+bufend, bufmax - bufend); 211 result = read(fd, buf+bufend, bufmax - bufend);
213 } 212 }
214 213
215 if (result == -1) { 214 if (result == -1) {
216 /* read error */ 215 /* read error */
217 warn("%s", name); 216 complain(NULL, "%s: %s",
217 name, strerror(errno));
218 complain_fail(); 218 complain_fail();
219 } else if (result == 0 && bufend == linestart) { 219 } else if (result == 0 && bufend == linestart) {
220 /* eof */ 220 /* eof */
221 ateof = true; 221 ateof = true;
222 break; 222 break;
330 /* XXX check for non-regular files */ 330 /* XXX check for non-regular files */
331 331
332 fd = open(file, O_RDONLY); 332 fd = open(file, O_RDONLY);
333 if (fd < 0) { 333 if (fd < 0) {
334 if (errno != ENOENT && errno != ENOTDIR) { 334 if (errno != ENOENT && errno != ENOTDIR) {
335 warn("%s", file); 335 complain(NULL, "%s: %s", file, strerror(errno));
336 } 336 }
337 return -1; 337 return -1;
338 } 338 }
339 339
340 return fd; 340 return fd;
404 fd = STDIN_FILENO; 404 fd = STDIN_FILENO;
405 pf = place_addfile(place, "<standard-input>", false); 405 pf = place_addfile(place, "<standard-input>", false);
406 } else { 406 } else {
407 fd = file_tryopen(name); 407 fd = file_tryopen(name);
408 if (fd < 0) { 408 if (fd < 0) {
409 warn("%s", name); 409 complain(NULL, "%s: %s", name, strerror(errno));
410 die(); 410 die();
411 } 411 }
412 pf = place_addfile(place, name, false); 412 pf = place_addfile(place, name, false);
413 } 413 }
414 414