Changeset 3192 for trunk/src/kmk/output.c
- Timestamp:
- Mar 26, 2018, 10:25:56 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/output.c
r3191 r3192 373 373 374 374 /* write/fwrite like function, binary mode. */ 375 void 375 ssize_t 376 376 output_write_bin (struct output *out, int is_err, const char *src, size_t len) 377 377 { 378 size_t ret = len; 378 379 if (!out || !out->syncout) 379 380 { 380 381 FILE *f = is_err ? stderr : stdout; 381 382 # ifdef KBUILD_OS_WINDOWS 382 /* On windows we need to disable \n -> \r\n conver s that is common on383 /* On windows we need to disable \n -> \r\n converts that is common on 383 384 standard output/error. Also optimize for console output. */ 385 int saved_errno; 384 386 int fd = fileno (f); 385 387 int prev_mode = _setmode (fd, _O_BINARY); 386 388 maybe_con_fwrite (src, len, 1, f); 387 fflush (f); 389 if (fflush (f) == EOF) 390 ret = -1; 391 saved_errno = errno; 388 392 _setmode (fd, prev_mode); 393 errno = saved_errno; 389 394 # else 390 395 fwrite (src, len, 1, f); 391 fflush (f); 396 if (fflush (f) == EOF) 397 ret = -1; 392 398 # endif 393 399 } … … 410 416 } 411 417 } 418 return ret; 412 419 } 413 420 414 421 /* write/fwrite like function, text mode. */ 415 void 422 ssize_t 416 423 output_write_text (struct output *out, int is_err, const char *src, size_t len) 417 424 { 418 425 # if defined (KBUILD_OS_WINDOWS) || defined (KBUILD_OS_OS2) || defined (KBUILD_OS_DOS) 419 if (out && out->syncout) 426 ssize_t ret = len; 427 if (!out || !out->syncout) 420 428 { 421 429 /* ASSUME fwrite does the desired conversion. */ 422 430 FILE *f = is_err ? stderr : stdout; 423 431 # ifdef KBUILD_OS_WINDOWS 424 maybe_con_fwrite (src, len, 1, f); 432 if (maybe_con_fwrite (src, len, 1, f) < 0) 433 ret = -1; 425 434 # else 426 435 fwrite (src, len, 1, f); 427 436 # endif 428 fflush (f); 437 if (fflush (f) == EOF) 438 ret = -1; 429 439 } 430 440 else … … 443 453 } 444 454 } 455 return len; 445 456 # else 446 output_write_bin (out, is_err, src, len);457 return output_write_bin (out, is_err, src, len); 447 458 # endif 448 459 }
Note:
See TracChangeset
for help on using the changeset viewer.