Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/coreutils/src/src/tty.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | - | |||||||||||||
4 | enum | - | ||||||||||||
5 | { | - | ||||||||||||
6 | TTY_STDIN_NOTTY = 1, | - | ||||||||||||
7 | TTY_FAILURE = 2, | - | ||||||||||||
8 | TTY_WRITE_ERROR = 3 | - | ||||||||||||
9 | }; | - | ||||||||||||
10 | - | |||||||||||||
11 | - | |||||||||||||
12 | - | |||||||||||||
13 | - | |||||||||||||
14 | - | |||||||||||||
15 | - | |||||||||||||
16 | - | |||||||||||||
17 | static | - | ||||||||||||
18 | _Bool | - | ||||||||||||
19 | silent; | - | ||||||||||||
20 | - | |||||||||||||
21 | static struct option const longopts[] = | - | ||||||||||||
22 | { | - | ||||||||||||
23 | {"silent", | - | ||||||||||||
24 | 0 | - | ||||||||||||
25 | , | - | ||||||||||||
26 | ((void *)0) | - | ||||||||||||
27 | , 's'}, | - | ||||||||||||
28 | {"quiet", | - | ||||||||||||
29 | 0 | - | ||||||||||||
30 | , | - | ||||||||||||
31 | ((void *)0) | - | ||||||||||||
32 | , 's'}, | - | ||||||||||||
33 | {"help", | - | ||||||||||||
34 | 0 | - | ||||||||||||
35 | , | - | ||||||||||||
36 | ((void *)0) | - | ||||||||||||
37 | , GETOPT_HELP_CHAR}, | - | ||||||||||||
38 | {"version", | - | ||||||||||||
39 | 0 | - | ||||||||||||
40 | , | - | ||||||||||||
41 | ((void *)0) | - | ||||||||||||
42 | , GETOPT_VERSION_CHAR}, | - | ||||||||||||
43 | { | - | ||||||||||||
44 | ((void *)0) | - | ||||||||||||
45 | , 0, | - | ||||||||||||
46 | ((void *)0) | - | ||||||||||||
47 | , 0} | - | ||||||||||||
48 | }; | - | ||||||||||||
49 | - | |||||||||||||
50 | void | - | ||||||||||||
51 | usage (int status) | - | ||||||||||||
52 | { | - | ||||||||||||
53 | if (status !=
| 5-6 | ||||||||||||
54 | 0
| 5-6 | ||||||||||||
55 | ) | - | ||||||||||||
56 | do { fprintf ( | - | ||||||||||||
57 | stderr | - | ||||||||||||
58 | , | - | ||||||||||||
59 | dcgettext (((void *)0), | - | ||||||||||||
60 | "Try '%s --help' for more information.\n" | - | ||||||||||||
61 | , 5) | - | ||||||||||||
62 | , program_name); } executed 5 times by 1 test: while (0);end of block Executed by:
| 5 | ||||||||||||
63 | else | - | ||||||||||||
64 | { | - | ||||||||||||
65 | printf ( | - | ||||||||||||
66 | dcgettext (((void *)0), | - | ||||||||||||
67 | "Usage: %s [OPTION]...\n" | - | ||||||||||||
68 | , 5) | - | ||||||||||||
69 | , program_name); | - | ||||||||||||
70 | fputs_unlocked ( | - | ||||||||||||
71 | dcgettext (((void *)0), | - | ||||||||||||
72 | "Print the file name of the terminal connected to standard input.\n\n -s, --silent, --quiet print nothing, only return an exit status\n" | - | ||||||||||||
73 | , 5) | - | ||||||||||||
74 | , | - | ||||||||||||
75 | stdout | - | ||||||||||||
76 | ) | - | ||||||||||||
77 | - | |||||||||||||
78 | - | |||||||||||||
79 | - | |||||||||||||
80 | ; | - | ||||||||||||
81 | fputs_unlocked ( | - | ||||||||||||
82 | dcgettext (((void *)0), | - | ||||||||||||
83 | " --help display this help and exit\n" | - | ||||||||||||
84 | , 5) | - | ||||||||||||
85 | , | - | ||||||||||||
86 | stdout | - | ||||||||||||
87 | ); | - | ||||||||||||
88 | fputs_unlocked ( | - | ||||||||||||
89 | dcgettext (((void *)0), | - | ||||||||||||
90 | " --version output version information and exit\n" | - | ||||||||||||
91 | , 5) | - | ||||||||||||
92 | , | - | ||||||||||||
93 | stdout | - | ||||||||||||
94 | ); | - | ||||||||||||
95 | emit_ancillary_info ("tty"); | - | ||||||||||||
96 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||
97 | exit (status); executed 11 times by 1 test: exit (status); Executed by:
| 11 | ||||||||||||
98 | } | - | ||||||||||||
99 | - | |||||||||||||
100 | int | - | ||||||||||||
101 | main (int argc, char **argv) | - | ||||||||||||
102 | { | - | ||||||||||||
103 | int optc; | - | ||||||||||||
104 | - | |||||||||||||
105 | ; | - | ||||||||||||
106 | set_program_name (argv[0]); | - | ||||||||||||
107 | setlocale ( | - | ||||||||||||
108 | 6 | - | ||||||||||||
109 | , ""); | - | ||||||||||||
110 | bindtextdomain ("coreutils", "/usr/local/share/locale"); | - | ||||||||||||
111 | textdomain ("coreutils"); | - | ||||||||||||
112 | - | |||||||||||||
113 | initialize_exit_failure (TTY_WRITE_ERROR); | - | ||||||||||||
114 | atexit (close_stdout); | - | ||||||||||||
115 | - | |||||||||||||
116 | silent = | - | ||||||||||||
117 | 0 | - | ||||||||||||
118 | ; | - | ||||||||||||
119 | - | |||||||||||||
120 | while ((
| 11-24 | ||||||||||||
121 | ((void *)0)
| 11-24 | ||||||||||||
122 | )) != -1
| 11-24 | ||||||||||||
123 | { | - | ||||||||||||
124 | switch (optc) | - | ||||||||||||
125 | { | - | ||||||||||||
126 | case executed 11 times by 1 test: 's':case 's': Executed by:
executed 11 times by 1 test: case 's': Executed by:
| 11 | ||||||||||||
127 | silent = | - | ||||||||||||
128 | 1 | - | ||||||||||||
129 | ; | - | ||||||||||||
130 | break; executed 11 times by 1 test: break; Executed by:
| 11 | ||||||||||||
131 | - | |||||||||||||
132 | case executed 6 times by 1 test: GETOPT_HELP_CHAR:case GETOPT_HELP_CHAR: Executed by:
executed 6 times by 1 test: usage (case GETOPT_HELP_CHAR: Executed by:
| 6 | ||||||||||||
133 | 0 | - | ||||||||||||
134 | ); break; never executed: ;break; | 0 | ||||||||||||
135 | - | |||||||||||||
136 | case executed 4 times by 1 test: GETOPT_VERSION_CHAR:case GETOPT_VERSION_CHAR: Executed by:
executed 4 times by 1 test: version_etc (case GETOPT_VERSION_CHAR: Executed by:
| 4 | ||||||||||||
137 | stdout | - | ||||||||||||
138 | , "tty", "GNU coreutils", Version, ("David MacKenzie"), (char *) | - | ||||||||||||
139 | ((void *)0) | - | ||||||||||||
140 | ); exit ( executed 4 times by 1 test: exit ( 0 ); Executed by:
| 4 | ||||||||||||
141 | 0 executed 4 times by 1 test: exit ( 0 ); Executed by:
| 4 | ||||||||||||
142 | ); executed 4 times by 1 test: break;exit ( 0 ); Executed by:
never executed: ;break; | 0-4 | ||||||||||||
143 | - | |||||||||||||
144 | default executed 3 times by 1 test: :default: Executed by:
executed 3 times by 1 test: default: Executed by:
| 3 | ||||||||||||
145 | usage (TTY_FAILURE); | - | ||||||||||||
146 | } never executed: end of block | 0 | ||||||||||||
147 | } | - | ||||||||||||
148 | - | |||||||||||||
149 | if (optind < argc
| 2-9 | ||||||||||||
150 | { | - | ||||||||||||
151 | error (0, 0, | - | ||||||||||||
152 | dcgettext (((void *)0), | - | ||||||||||||
153 | "extra operand %s" | - | ||||||||||||
154 | , 5) | - | ||||||||||||
155 | , quote (argv[optind])); | - | ||||||||||||
156 | usage (TTY_FAILURE); | - | ||||||||||||
157 | } never executed: end of block | 0 | ||||||||||||
158 | - | |||||||||||||
159 | - | |||||||||||||
160 | (*__errno_location ()) | - | ||||||||||||
161 | = | - | ||||||||||||
162 | 2 | - | ||||||||||||
163 | ; | - | ||||||||||||
164 | - | |||||||||||||
165 | if (silent
| 2-7 | ||||||||||||
166 | return executed 7 times by 1 test: isatty (return isatty ( 0 ) ? 0 : TTY_STDIN_NOTTY; Executed by:
executed 7 times by 1 test: return isatty ( 0 ) ? 0 : TTY_STDIN_NOTTY; Executed by:
| 7 | ||||||||||||
167 | 0 executed 7 times by 1 test: return isatty ( 0 ) ? 0 : TTY_STDIN_NOTTY; Executed by:
| 7 | ||||||||||||
168 | ) ? executed 7 times by 1 test: return isatty ( 0 ) ? 0 : TTY_STDIN_NOTTY; Executed by:
| 7 | ||||||||||||
169 | 0 executed 7 times by 1 test: return isatty ( 0 ) ? 0 : TTY_STDIN_NOTTY; Executed by:
| 7 | ||||||||||||
170 | : TTY_STDIN_NOTTY; executed 7 times by 1 test: return isatty ( 0 ) ? 0 : TTY_STDIN_NOTTY; Executed by:
| 7 | ||||||||||||
171 | - | |||||||||||||
172 | int status = | - | ||||||||||||
173 | 0 | - | ||||||||||||
174 | ; | - | ||||||||||||
175 | char const *tty = ttyname ( | - | ||||||||||||
176 | 0 | - | ||||||||||||
177 | ); | - | ||||||||||||
178 | - | |||||||||||||
179 | if (! tty
| 0-2 | ||||||||||||
180 | { | - | ||||||||||||
181 | tty = | - | ||||||||||||
182 | dcgettext (((void *)0), | - | ||||||||||||
183 | "not a tty" | - | ||||||||||||
184 | , 5) | - | ||||||||||||
185 | ; | - | ||||||||||||
186 | status = TTY_STDIN_NOTTY; | - | ||||||||||||
187 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||
188 | - | |||||||||||||
189 | puts (tty); | - | ||||||||||||
190 | return executed 2 times by 1 test: status;return status; Executed by:
executed 2 times by 1 test: return status; Executed by:
| 2 | ||||||||||||
191 | } | - | ||||||||||||
Switch to Source code | Preprocessed file |