OpenCoverage

printenv.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/coreutils/src/src/printenv.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4enum { PRINTENV_FAILURE = 2 };-
5static struct option const longopts[] =-
6{-
7 {"null", -
8 0-
9 , -
10 ((void *)0)-
11 , '0'},-
12 {"help", -
13 0-
14 , -
15 ((void *)0)-
16 , GETOPT_HELP_CHAR},-
17 {"version", -
18 0-
19 , -
20 ((void *)0)-
21 , GETOPT_VERSION_CHAR},-
22 {-
23 ((void *)0)-
24 , 0, -
25 ((void *)0)-
26 , 0}-
27};-
28-
29void-
30usage (int status)-
31{-
32 if (status !=
status != 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • printenv
FALSEevaluated 5 times by 1 test
Evaluated by:
  • printenv
3-5
33 0
status != 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • printenv
FALSEevaluated 5 times by 1 test
Evaluated by:
  • printenv
3-5
34 )-
35 do { fprintf (-
36 stderr-
37 , -
38 dcgettext (((void *)0), -
39 "Try '%s --help' for more information.\n"-
40 , 5)-
41 , program_name); }
executed 3 times by 1 test: end of block
Executed by:
  • printenv
while (0);
3
42 else-
43 {-
44 printf (-
45 dcgettext (((void *)0), -
46 "Usage: %s [OPTION]... [VARIABLE]...\nPrint the values of the specified environment VARIABLE(s).\nIf no VARIABLE is specified, print name and value pairs for them all.\n\n"-
47 , 5)-
48-
49-
50-
51-
52 -
53 ,-
54 program_name);-
55 fputs_unlocked (-
56 dcgettext (((void *)0), -
57 " -0, --null end each output line with NUL, not newline\n"-
58 , 5)-
59 ,-
60 stdout-
61 )-
62-
63 ;-
64 fputs_unlocked (-
65 dcgettext (((void *)0), -
66 " --help display this help and exit\n"-
67 , 5)-
68 ,-
69 stdout-
70 );-
71 fputs_unlocked (-
72 dcgettext (((void *)0), -
73 " --version output version information and exit\n"-
74 , 5)-
75 ,-
76 stdout-
77 );-
78 printf (-
79 dcgettext (((void *)0), -
80 "\n" "NOTE: your shell may have its own version of %s, which usually supersedes\n" "the version described here. Please refer to your shell's documentation\n" "for details about the options it supports.\n"-
81 , 5)-
82 , "printenv");-
83 emit_ancillary_info ("printenv");-
84 }
executed 5 times by 1 test: end of block
Executed by:
  • printenv
5
85 exit (status);
executed 8 times by 1 test: exit (status);
Executed by:
  • printenv
8
86}-
87-
88int-
89main (int argc, char **argv)-
90{-
91 char **env;-
92 char *ep, *ap;-
93 int i;-
94 -
95 _Bool -
96 ok;-
97 int optc;-
98 -
99 _Bool -
100 opt_nul_terminate_output = -
101 0-
102 ;-
103-
104 ;-
105 set_program_name (argv[0]);-
106 setlocale (-
107 6-
108 , "");-
109 bindtextdomain ("coreutils", "/usr/local/share/locale");-
110 textdomain ("coreutils");-
111-
112 initialize_exit_failure (PRINTENV_FAILURE);-
113 atexit (close_stdout);-
114-
115 while ((
(optc = getopt... *)0) )) != -1Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • printenv
FALSEevaluated 16 times by 1 test
Evaluated by:
  • printenv
optc = getopt_long (argc, argv, "+iu:0", longopts,
(optc = getopt... *)0) )) != -1Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • printenv
FALSEevaluated 16 times by 1 test
Evaluated by:
  • printenv
16-20
116 ((void *)0)
(optc = getopt... *)0) )) != -1Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • printenv
FALSEevaluated 16 times by 1 test
Evaluated by:
  • printenv
16-20
117 )) != -1
(optc = getopt... *)0) )) != -1Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • printenv
FALSEevaluated 16 times by 1 test
Evaluated by:
  • printenv
)
16-20
118 {-
119 switch (optc)-
120 {-
121 case
executed 7 times by 1 test: case '0':
Executed by:
  • printenv
'0':
executed 7 times by 1 test: case '0':
Executed by:
  • printenv
7
122 opt_nul_terminate_output = -
123 1-
124 ;-
125 break;
executed 7 times by 1 test: break;
Executed by:
  • printenv
7
126 case
executed 5 times by 1 test: case GETOPT_HELP_CHAR:
Executed by:
  • printenv
GETOPT_HELP_CHAR:
executed 5 times by 1 test: case GETOPT_HELP_CHAR:
Executed by:
  • printenv
usage (
5
127 0-
128 ); break;
never executed: break;
;
0
129 case
executed 5 times by 1 test: case GETOPT_VERSION_CHAR:
Executed by:
  • printenv
GETOPT_VERSION_CHAR:
executed 5 times by 1 test: case GETOPT_VERSION_CHAR:
Executed by:
  • printenv
version_etc (
5
130 stdout-
131 , "printenv", "GNU coreutils", Version, ("David MacKenzie"), ("Richard Mlynarik"), (char *) -
132 ((void *)0)-
133 ); exit (
executed 5 times by 1 test: exit ( 0 );
Executed by:
  • printenv
5
134 0
executed 5 times by 1 test: exit ( 0 );
Executed by:
  • printenv
5
135 );
executed 5 times by 1 test: exit ( 0 );
Executed by:
  • printenv
break;
never executed: break;
;
0-5
136 default
executed 3 times by 1 test: default:
Executed by:
  • printenv
:
executed 3 times by 1 test: default:
Executed by:
  • printenv
3
137 usage (PRINTENV_FAILURE);-
138 }
never executed: end of block
0
139 }-
140-
141 if (optind >= argc
optind >= argcDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • printenv
FALSEevaluated 11 times by 1 test
Evaluated by:
  • printenv
)
5-11
142 {-
143 for (env = environ; *
*env != ((void *)0)Description
TRUEevaluated 185 times by 1 test
Evaluated by:
  • printenv
FALSEevaluated 5 times by 1 test
Evaluated by:
  • printenv
env !=
*env != ((void *)0)Description
TRUEevaluated 185 times by 1 test
Evaluated by:
  • printenv
FALSEevaluated 5 times by 1 test
Evaluated by:
  • printenv
5-185
144 ((void *)0)
*env != ((void *)0)Description
TRUEevaluated 185 times by 1 test
Evaluated by:
  • printenv
FALSEevaluated 5 times by 1 test
Evaluated by:
  • printenv
5-185
145 ; ++env)-
146 printf ("%s%c", *env, opt_nul_terminate_output ? '\0' : '\n');
executed 185 times by 1 test: printf ("%s%c", *env, opt_nul_terminate_output ? '\0' : '\n');
Executed by:
  • printenv
185
147 ok = -
148 1-
149 ;-
150 }
executed 5 times by 1 test: end of block
Executed by:
  • printenv
5
151 else-
152 {-
153 int matches = 0;-
154-
155 for (i = optind; i < argc
i < argcDescription
TRUEevaluated 17 times by 1 test
Evaluated by:
  • printenv
FALSEevaluated 11 times by 1 test
Evaluated by:
  • printenv
; ++i)
11-17
156 {-
157 -
158 _Bool -
159 matched = -
160 0-
161 ;-
162-
163-
164 if (-
165 (
(__extension__...v[i] , '=' )))Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • printenv
FALSEevaluated 16 times by 1 test
Evaluated by:
  • printenv
__extension__ (__builtin_constant_p (
__builtin_constant_p ( '=' )Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • printenv
FALSEnever evaluated
(__extension__...v[i] , '=' )))Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • printenv
FALSEevaluated 16 times by 1 test
Evaluated by:
  • printenv
0-17
166 '='
__builtin_constant_p ( '=' )Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • printenv
FALSEnever evaluated
(__extension__...v[i] , '=' )))Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • printenv
FALSEevaluated 16 times by 1 test
Evaluated by:
  • printenv
0-17
167 )
__builtin_constant_p ( '=' )Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • printenv
FALSEnever evaluated
&& !__builtin_constant_p (
!__builtin_con..._p ( argv[i] )Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • printenv
FALSEnever evaluated
(__extension__...v[i] , '=' )))Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • printenv
FALSEevaluated 16 times by 1 test
Evaluated by:
  • printenv
0-17
168 argv[i]
!__builtin_con..._p ( argv[i] )Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • printenv
FALSEnever evaluated
(__extension__...v[i] , '=' )))Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • printenv
FALSEevaluated 16 times by 1 test
Evaluated by:
  • printenv
0-17
169 )
!__builtin_con..._p ( argv[i] )Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • printenv
FALSEnever evaluated
&& (
( '=' ) == '\0'Description
TRUEnever evaluated
FALSEevaluated 17 times by 1 test
Evaluated by:
  • printenv
(__extension__...v[i] , '=' )))Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • printenv
FALSEevaluated 16 times by 1 test
Evaluated by:
  • printenv
0-17
170 '='
( '=' ) == '\0'Description
TRUEnever evaluated
FALSEevaluated 17 times by 1 test
Evaluated by:
  • printenv
(__extension__...v[i] , '=' )))Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • printenv
FALSEevaluated 16 times by 1 test
Evaluated by:
  • printenv
0-17
171 ) == '\0'
( '=' ) == '\0'Description
TRUEnever evaluated
FALSEevaluated 17 times by 1 test
Evaluated by:
  • printenv
? (char *) __rawmemchr (
(__extension__...v[i] , '=' )))Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • printenv
FALSEevaluated 16 times by 1 test
Evaluated by:
  • printenv
0-17
172 argv[i]
(__extension__...v[i] , '=' )))Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • printenv
FALSEevaluated 16 times by 1 test
Evaluated by:
  • printenv
1-16
173 ,
(__extension__...v[i] , '=' )))Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • printenv
FALSEevaluated 16 times by 1 test
Evaluated by:
  • printenv
1-16
174 '='
(__extension__...v[i] , '=' )))Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • printenv
FALSEevaluated 16 times by 1 test
Evaluated by:
  • printenv
1-16
175 ) : __builtin_strchr (
(__extension__...v[i] , '=' )))Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • printenv
FALSEevaluated 16 times by 1 test
Evaluated by:
  • printenv
1-16
176 argv[i]
(__extension__...v[i] , '=' )))Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • printenv
FALSEevaluated 16 times by 1 test
Evaluated by:
  • printenv
1-16
177 ,
(__extension__...v[i] , '=' )))Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • printenv
FALSEevaluated 16 times by 1 test
Evaluated by:
  • printenv
1-16
178 '='
(__extension__...v[i] , '=' )))Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • printenv
FALSEevaluated 16 times by 1 test
Evaluated by:
  • printenv
1-16
179 )))
(__extension__...v[i] , '=' )))Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • printenv
FALSEevaluated 16 times by 1 test
Evaluated by:
  • printenv
1-16
180 )-
181 continue;
executed 1 time by 1 test: continue;
Executed by:
  • printenv
1
182-
183 for (env = environ; *
*envDescription
TRUEevaluated 995 times by 1 test
Evaluated by:
  • printenv
FALSEevaluated 16 times by 1 test
Evaluated by:
  • printenv
env
*envDescription
TRUEevaluated 995 times by 1 test
Evaluated by:
  • printenv
FALSEevaluated 16 times by 1 test
Evaluated by:
  • printenv
; ++env)
16-995
184 {-
185 ep = *env;-
186 ap = argv[i];-
187 while (*
*ep != '\0'Description
TRUEevaluated 1147 times by 1 test
Evaluated by:
  • printenv
FALSEnever evaluated
ep != '\0'
*ep != '\0'Description
TRUEevaluated 1147 times by 1 test
Evaluated by:
  • printenv
FALSEnever evaluated
&& *
*ap != '\0'Description
TRUEevaluated 1137 times by 1 test
Evaluated by:
  • printenv
FALSEevaluated 10 times by 1 test
Evaluated by:
  • printenv
ap != '\0'
*ap != '\0'Description
TRUEevaluated 1137 times by 1 test
Evaluated by:
  • printenv
FALSEevaluated 10 times by 1 test
Evaluated by:
  • printenv
&& *
*ep++ == *ap++Description
TRUEevaluated 163 times by 1 test
Evaluated by:
  • printenv
FALSEevaluated 974 times by 1 test
Evaluated by:
  • printenv
ep++ == *ap++
*ep++ == *ap++Description
TRUEevaluated 163 times by 1 test
Evaluated by:
  • printenv
FALSEevaluated 974 times by 1 test
Evaluated by:
  • printenv
)
0-1147
188 {-
189 if (*
*ep == '='Description
TRUEevaluated 11 times by 1 test
Evaluated by:
  • printenv
FALSEevaluated 152 times by 1 test
Evaluated by:
  • printenv
ep == '='
*ep == '='Description
TRUEevaluated 11 times by 1 test
Evaluated by:
  • printenv
FALSEevaluated 152 times by 1 test
Evaluated by:
  • printenv
&& *
*ap == '\0'Description
TRUEevaluated 11 times by 1 test
Evaluated by:
  • printenv
FALSEnever evaluated
ap == '\0'
*ap == '\0'Description
TRUEevaluated 11 times by 1 test
Evaluated by:
  • printenv
FALSEnever evaluated
)
0-152
190 {-
191 printf ("%s%c", ep + 1,-
192 opt_nul_terminate_output ? '\0' : '\n');-
193 matched = -
194 1-
195 ;-
196 break;
executed 11 times by 1 test: break;
Executed by:
  • printenv
11
197 }-
198 }
executed 152 times by 1 test: end of block
Executed by:
  • printenv
152
199 }
executed 995 times by 1 test: end of block
Executed by:
  • printenv
995
200-
201 matches += matched;-
202 }
executed 16 times by 1 test: end of block
Executed by:
  • printenv
16
203-
204 ok = (matches == argc - optind);-
205 }
executed 11 times by 1 test: end of block
Executed by:
  • printenv
11
206-
207 return
executed 16 times by 1 test: return ok ? 0 : 1 ;
Executed by:
  • printenv
ok ?
executed 16 times by 1 test: return ok ? 0 : 1 ;
Executed by:
  • printenv
16
208 0
executed 16 times by 1 test: return ok ? 0 : 1 ;
Executed by:
  • printenv
16
209 :
executed 16 times by 1 test: return ok ? 0 : 1 ;
Executed by:
  • printenv
16
210 1
executed 16 times by 1 test: return ok ? 0 : 1 ;
Executed by:
  • printenv
16
211 ;
executed 16 times by 1 test: return ok ? 0 : 1 ;
Executed by:
  • printenv
16
212}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.1.2