comparison files.c @ 24:daa801fe719e

fix some bugs
author David A. Holland
date Mon, 20 Dec 2010 04:30:02 -0500
parents f6177d3ed5c2
children 8a955e3dda2c
comparison
equal deleted inserted replaced
23:fb83c2df2268 24:daa801fe719e
305 const struct placefile *pf; 305 const struct placefile *pf;
306 int fd; 306 int fd;
307 307
308 assert(place != NULL); 308 assert(place != NULL);
309 309
310 fd = file_tryopen(name); 310 if (name == NULL) {
311 if (fd < 0) { 311 fd = STDIN_FILENO;
312 warn("%s", name); 312 pf = place_addfile(place, "<standard-input>", false);
313 die(); 313 } else {
314 } 314 fd = file_tryopen(name);
315 pf = place_addfile(place, name, false); 315 if (fd < 0) {
316 warn("%s", name);
317 die();
318 }
319 pf = place_addfile(place, name, false);
320 }
321
316 file_read(pf, fd, name); 322 file_read(pf, fd, name);
317 close(fd); 323
318 } 324 if (name != NULL) {
325 close(fd);
326 }
327 }