Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1617)

Side by Side Diff: xz/src/common/tuklib_exit.c

Issue 2869016: Add an unpatched version of xz, XZ Utils, to /trunk/deps/third_party (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/
Patch Set: Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « xz/src/common/tuklib_exit.h ('k') | xz/src/common/tuklib_gettext.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 /// \file tuklib_exit.c
4 /// \brief Close stdout and stderr, and exit
5 //
6 // Author: Lasse Collin
7 //
8 // This file has been put into the public domain.
9 // You can do whatever you want with this file.
10 //
11 ///////////////////////////////////////////////////////////////////////////////
12
13 #include "tuklib_common.h"
14
15 #include <stdlib.h>
16 #include <stdio.h>
17
18 #include "tuklib_gettext.h"
19 #include "tuklib_progname.h"
20 #include "tuklib_exit.h"
21
22
23 extern void
24 tuklib_exit(int status, int err_status, int show_error)
25 {
26 if (status != err_status) {
27 // Close stdout. If something goes wrong,
28 // print an error message to stderr.
29 const int ferror_err = ferror(stdout);
30 const int fclose_err = fclose(stdout);
31 if (ferror_err || fclose_err) {
32 status = err_status;
33
34 // If it was fclose() that failed, we have the reason
35 // in errno. If only ferror() indicated an error,
36 // we have no idea what the reason was.
37 if (show_error)
38 fprintf(stderr, "%s: %s: %s\n", progname,
39 _("Writing to standard "
40 "output failed"),
41 fclose_err ? strerror(errno)
42 : _("Unknown error"));
43 }
44 }
45
46 if (status != err_status) {
47 // Close stderr. If something goes wrong, there's
48 // nothing where we could print an error message.
49 // Just set the exit status.
50 const int ferror_err = ferror(stderr);
51 const int fclose_err = fclose(stderr);
52 if (fclose_err || ferror_err)
53 status = err_status;
54 }
55
56 exit(status);
57 }
OLDNEW
« no previous file with comments | « xz/src/common/tuklib_exit.h ('k') | xz/src/common/tuklib_gettext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698