OpenCoverage

tty.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/coreutils/src/src/tty.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4enum-
5 {-
6 TTY_STDIN_NOTTY = 1,-
7 TTY_FAILURE = 2,-
8 TTY_WRITE_ERROR = 3-
9 };-
10-
11-
12-
13-
14-
15-
16-
17static -
18 _Bool -
19 silent;-
20-
21static 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-
50void-
51usage (int status)-
52{-
53 if (status !=
status != 0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tty
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tty
5-6
54 0
status != 0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tty
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tty
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: end of block
Executed by:
  • tty
while (0);
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:
  • tty
6
97 exit (status);
executed 11 times by 1 test: exit (status);
Executed by:
  • tty
11
98}-
99-
100int-
101main (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 ((
(optc = getopt... *)0) )) != -1Description
TRUEevaluated 24 times by 1 test
Evaluated by:
  • tty
FALSEevaluated 11 times by 1 test
Evaluated by:
  • tty
optc = getopt_long (argc, argv, "s", longopts,
(optc = getopt... *)0) )) != -1Description
TRUEevaluated 24 times by 1 test
Evaluated by:
  • tty
FALSEevaluated 11 times by 1 test
Evaluated by:
  • tty
11-24
121 ((void *)0)
(optc = getopt... *)0) )) != -1Description
TRUEevaluated 24 times by 1 test
Evaluated by:
  • tty
FALSEevaluated 11 times by 1 test
Evaluated by:
  • tty
11-24
122 )) != -1
(optc = getopt... *)0) )) != -1Description
TRUEevaluated 24 times by 1 test
Evaluated by:
  • tty
FALSEevaluated 11 times by 1 test
Evaluated by:
  • tty
)
11-24
123 {-
124 switch (optc)-
125 {-
126 case
executed 11 times by 1 test: case 's':
Executed by:
  • tty
's':
executed 11 times by 1 test: case 's':
Executed by:
  • tty
11
127 silent = -
128 1-
129 ;-
130 break;
executed 11 times by 1 test: break;
Executed by:
  • tty
11
131-
132 case
executed 6 times by 1 test: case GETOPT_HELP_CHAR:
Executed by:
  • tty
GETOPT_HELP_CHAR:
executed 6 times by 1 test: case GETOPT_HELP_CHAR:
Executed by:
  • tty
usage (
6
133 0-
134 ); break;
never executed: break;
;
0
135-
136 case
executed 4 times by 1 test: case GETOPT_VERSION_CHAR:
Executed by:
  • tty
GETOPT_VERSION_CHAR:
executed 4 times by 1 test: case GETOPT_VERSION_CHAR:
Executed by:
  • tty
version_etc (
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:
  • tty
4
141 0
executed 4 times by 1 test: exit ( 0 );
Executed by:
  • tty
4
142 );
executed 4 times by 1 test: exit ( 0 );
Executed by:
  • tty
break;
never executed: break;
;
0-4
143-
144 default
executed 3 times by 1 test: default:
Executed by:
  • tty
:
executed 3 times by 1 test: default:
Executed by:
  • tty
3
145 usage (TTY_FAILURE);-
146 }
never executed: end of block
0
147 }-
148-
149 if (optind < argc
optind < argcDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tty
FALSEevaluated 9 times by 1 test
Evaluated by:
  • tty
)
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
silentDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • tty
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tty
)
2-7
166 return
executed 7 times by 1 test: return isatty ( 0 ) ? 0 : TTY_STDIN_NOTTY;
Executed by:
  • tty
isatty (
executed 7 times by 1 test: return isatty ( 0 ) ? 0 : TTY_STDIN_NOTTY;
Executed by:
  • tty
7
167 0
executed 7 times by 1 test: return isatty ( 0 ) ? 0 : TTY_STDIN_NOTTY;
Executed by:
  • tty
7
168 ) ?
executed 7 times by 1 test: return isatty ( 0 ) ? 0 : TTY_STDIN_NOTTY;
Executed by:
  • tty
7
169 0
executed 7 times by 1 test: return isatty ( 0 ) ? 0 : TTY_STDIN_NOTTY;
Executed by:
  • tty
7
170 : TTY_STDIN_NOTTY;
executed 7 times by 1 test: return isatty ( 0 ) ? 0 : TTY_STDIN_NOTTY;
Executed by:
  • tty
7
171-
172 int status = -
173 0-
174 ;-
175 char const *tty = ttyname (-
176 0-
177 );-
178-
179 if (! tty
! ttyDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tty
FALSEnever evaluated
)
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:
  • tty
2
188-
189 puts (tty);-
190 return
executed 2 times by 1 test: return status;
Executed by:
  • tty
status;
executed 2 times by 1 test: return status;
Executed by:
  • tty
2
191}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.1.2