284 |
selected_diversion->file = tmpfile (); |
selected_diversion->file = tmpfile (); |
285 |
if (selected_diversion->file == NULL) |
if (selected_diversion->file == NULL) |
286 |
M4ERROR ((EXIT_FAILURE, errno, |
M4ERROR ((EXIT_FAILURE, errno, |
287 |
_("ERROR: Cannot create temporary file for diversion"))); |
_("cannot create temporary file for diversion"))); |
288 |
|
|
289 |
if (selected_diversion->used > 0) |
if (selected_diversion->used > 0) |
290 |
{ |
{ |
294 |
selected_diversion->file); |
selected_diversion->file); |
295 |
if (count != 1) |
if (count != 1) |
296 |
M4ERROR ((EXIT_FAILURE, errno, |
M4ERROR ((EXIT_FAILURE, errno, |
297 |
_("ERROR: Cannot flush diversion to temporary file"))); |
_("cannot flush diversion to temporary file"))); |
298 |
} |
} |
299 |
|
|
300 |
/* Reclaim the buffer space for other diversions. */ |
/* Reclaim the buffer space for other diversions. */ |
372 |
{ |
{ |
373 |
count = fwrite (text, length, 1, output_file); |
count = fwrite (text, length, 1, output_file); |
374 |
if (count != 1) |
if (count != 1) |
375 |
M4ERROR ((EXIT_FAILURE, errno, _("ERROR: Copying inserted file"))); |
M4ERROR ((EXIT_FAILURE, errno, _("copying inserted file"))); |
376 |
} |
} |
377 |
else |
else |
378 |
{ |
{ |
575 |
while (length = read (fileno (file), buffer, COPY_BUFFER_SIZE), |
while (length = read (fileno (file), buffer, COPY_BUFFER_SIZE), |
576 |
length != 0) |
length != 0) |
577 |
if (length == (size_t) -1) |
if (length == (size_t) -1) |
578 |
M4ERROR ((EXIT_FAILURE, errno, _("ERROR: Reading inserted file"))); |
M4ERROR ((EXIT_FAILURE, errno, _("reading inserted file"))); |
579 |
else |
else |
580 |
output_text (buffer, length); |
output_text (buffer, length); |
581 |
} |
} |
665 |
{ |
{ |
666 |
fflush (diversion->file); |
fflush (diversion->file); |
667 |
if (fstat (fileno (diversion->file), &file_stat) < 0) |
if (fstat (fileno (diversion->file), &file_stat) < 0) |
668 |
M4ERROR ((EXIT_FAILURE, errno, _("Cannot stat diversion"))); |
M4ERROR ((EXIT_FAILURE, errno, _("cannot stat diversion"))); |
669 |
if (file_stat.st_size < 0 |
if (file_stat.st_size < 0 |
670 |
|| file_stat.st_size != (unsigned long) file_stat.st_size) |
|| file_stat.st_size != (unsigned long) file_stat.st_size) |
671 |
M4ERROR ((EXIT_FAILURE, errno, _("Diversion too large"))); |
M4ERROR ((EXIT_FAILURE, errno, _("diversion too large"))); |
672 |
fprintf (file, "D%d,%lu", divnum, |
fprintf (file, "D%d,%lu", divnum, |
673 |
(unsigned long) file_stat.st_size); |
(unsigned long) file_stat.st_size); |
674 |
} |
} |