Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/coreutils/src/src/printenv.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||||||||||||||||||||
2 | - | |||||||||||||||||||||||||||||||||||||
3 | - | |||||||||||||||||||||||||||||||||||||
4 | enum { PRINTENV_FAILURE = 2 }; | - | ||||||||||||||||||||||||||||||||||||
5 | static 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 | - | |||||||||||||||||||||||||||||||||||||
29 | void | - | ||||||||||||||||||||||||||||||||||||
30 | usage (int status) | - | ||||||||||||||||||||||||||||||||||||
31 | { | - | ||||||||||||||||||||||||||||||||||||
32 | if (status !=
| 3-5 | ||||||||||||||||||||||||||||||||||||
33 | 0
| 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: while (0);end of block Executed by:
| 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:
| 5 | ||||||||||||||||||||||||||||||||||||
85 | exit (status); executed 8 times by 1 test: exit (status); Executed by:
| 8 | ||||||||||||||||||||||||||||||||||||
86 | } | - | ||||||||||||||||||||||||||||||||||||
87 | - | |||||||||||||||||||||||||||||||||||||
88 | int | - | ||||||||||||||||||||||||||||||||||||
89 | main (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 ((
| 16-20 | ||||||||||||||||||||||||||||||||||||
116 | ((void *)0)
| 16-20 | ||||||||||||||||||||||||||||||||||||
117 | )) != -1
| 16-20 | ||||||||||||||||||||||||||||||||||||
118 | { | - | ||||||||||||||||||||||||||||||||||||
119 | switch (optc) | - | ||||||||||||||||||||||||||||||||||||
120 | { | - | ||||||||||||||||||||||||||||||||||||
121 | case executed 7 times by 1 test: '0':case '0': Executed by:
executed 7 times by 1 test: case '0': Executed by:
| 7 | ||||||||||||||||||||||||||||||||||||
122 | opt_nul_terminate_output = | - | ||||||||||||||||||||||||||||||||||||
123 | 1 | - | ||||||||||||||||||||||||||||||||||||
124 | ; | - | ||||||||||||||||||||||||||||||||||||
125 | break; executed 7 times by 1 test: break; Executed by:
| 7 | ||||||||||||||||||||||||||||||||||||
126 | case executed 5 times by 1 test: GETOPT_HELP_CHAR:case GETOPT_HELP_CHAR: Executed by:
executed 5 times by 1 test: usage (case GETOPT_HELP_CHAR: Executed by:
| 5 | ||||||||||||||||||||||||||||||||||||
127 | 0 | - | ||||||||||||||||||||||||||||||||||||
128 | ); break; never executed: ;break; | 0 | ||||||||||||||||||||||||||||||||||||
129 | case executed 5 times by 1 test: GETOPT_VERSION_CHAR:case GETOPT_VERSION_CHAR: Executed by:
executed 5 times by 1 test: version_etc (case GETOPT_VERSION_CHAR: Executed by:
| 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:
| 5 | ||||||||||||||||||||||||||||||||||||
134 | 0 executed 5 times by 1 test: exit ( 0 ); Executed by:
| 5 | ||||||||||||||||||||||||||||||||||||
135 | ); executed 5 times by 1 test: break;exit ( 0 ); Executed by:
never executed: ;break; | 0-5 | ||||||||||||||||||||||||||||||||||||
136 | default executed 3 times by 1 test: :default: Executed by:
executed 3 times by 1 test: default: Executed by:
| 3 | ||||||||||||||||||||||||||||||||||||
137 | usage (PRINTENV_FAILURE); | - | ||||||||||||||||||||||||||||||||||||
138 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
139 | } | - | ||||||||||||||||||||||||||||||||||||
140 | - | |||||||||||||||||||||||||||||||||||||
141 | if (optind >= argc
| 5-11 | ||||||||||||||||||||||||||||||||||||
142 | { | - | ||||||||||||||||||||||||||||||||||||
143 | for (env = environ; *
| 5-185 | ||||||||||||||||||||||||||||||||||||
144 | ((void *)0)
| 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:
| 185 | ||||||||||||||||||||||||||||||||||||
147 | ok = | - | ||||||||||||||||||||||||||||||||||||
148 | 1 | - | ||||||||||||||||||||||||||||||||||||
149 | ; | - | ||||||||||||||||||||||||||||||||||||
150 | } executed 5 times by 1 test: end of block Executed by:
| 5 | ||||||||||||||||||||||||||||||||||||
151 | else | - | ||||||||||||||||||||||||||||||||||||
152 | { | - | ||||||||||||||||||||||||||||||||||||
153 | int matches = 0; | - | ||||||||||||||||||||||||||||||||||||
154 | - | |||||||||||||||||||||||||||||||||||||
155 | for (i = optind; i < argc
| 11-17 | ||||||||||||||||||||||||||||||||||||
156 | { | - | ||||||||||||||||||||||||||||||||||||
157 | - | |||||||||||||||||||||||||||||||||||||
158 | _Bool | - | ||||||||||||||||||||||||||||||||||||
159 | matched = | - | ||||||||||||||||||||||||||||||||||||
160 | 0 | - | ||||||||||||||||||||||||||||||||||||
161 | ; | - | ||||||||||||||||||||||||||||||||||||
162 | - | |||||||||||||||||||||||||||||||||||||
163 | - | |||||||||||||||||||||||||||||||||||||
164 | if ( | - | ||||||||||||||||||||||||||||||||||||
165 | (
| 0-17 | ||||||||||||||||||||||||||||||||||||
166 | '='
| 0-17 | ||||||||||||||||||||||||||||||||||||
167 | )
| 0-17 | ||||||||||||||||||||||||||||||||||||
168 | argv[i]
| 0-17 | ||||||||||||||||||||||||||||||||||||
169 | )
| 0-17 | ||||||||||||||||||||||||||||||||||||
170 | '='
| 0-17 | ||||||||||||||||||||||||||||||||||||
171 | ) == '\0'
| 0-17 | ||||||||||||||||||||||||||||||||||||
172 | argv[i]
| 1-16 | ||||||||||||||||||||||||||||||||||||
173 | ,
| 1-16 | ||||||||||||||||||||||||||||||||||||
174 | '='
| 1-16 | ||||||||||||||||||||||||||||||||||||
175 | ) : __builtin_strchr (
| 1-16 | ||||||||||||||||||||||||||||||||||||
176 | argv[i]
| 1-16 | ||||||||||||||||||||||||||||||||||||
177 | ,
| 1-16 | ||||||||||||||||||||||||||||||||||||
178 | '='
| 1-16 | ||||||||||||||||||||||||||||||||||||
179 | )))
| 1-16 | ||||||||||||||||||||||||||||||||||||
180 | ) | - | ||||||||||||||||||||||||||||||||||||
181 | continue; executed 1 time by 1 test: continue; Executed by:
| 1 | ||||||||||||||||||||||||||||||||||||
182 | - | |||||||||||||||||||||||||||||||||||||
183 | for (env = environ; *
| 16-995 | ||||||||||||||||||||||||||||||||||||
184 | { | - | ||||||||||||||||||||||||||||||||||||
185 | ep = *env; | - | ||||||||||||||||||||||||||||||||||||
186 | ap = argv[i]; | - | ||||||||||||||||||||||||||||||||||||
187 | while (*
| 0-1147 | ||||||||||||||||||||||||||||||||||||
188 | { | - | ||||||||||||||||||||||||||||||||||||
189 | if (*
| 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:
| 11 | ||||||||||||||||||||||||||||||||||||
197 | } | - | ||||||||||||||||||||||||||||||||||||
198 | } executed 152 times by 1 test: end of block Executed by:
| 152 | ||||||||||||||||||||||||||||||||||||
199 | } executed 995 times by 1 test: end of block Executed by:
| 995 | ||||||||||||||||||||||||||||||||||||
200 | - | |||||||||||||||||||||||||||||||||||||
201 | matches += matched; | - | ||||||||||||||||||||||||||||||||||||
202 | } executed 16 times by 1 test: end of block Executed by:
| 16 | ||||||||||||||||||||||||||||||||||||
203 | - | |||||||||||||||||||||||||||||||||||||
204 | ok = (matches == argc - optind); | - | ||||||||||||||||||||||||||||||||||||
205 | } executed 11 times by 1 test: end of block Executed by:
| 11 | ||||||||||||||||||||||||||||||||||||
206 | - | |||||||||||||||||||||||||||||||||||||
207 | return executed 16 times by 1 test: ok ? return ok ? 0 : 1 ; Executed by:
executed 16 times by 1 test: return ok ? 0 : 1 ; Executed by:
| 16 | ||||||||||||||||||||||||||||||||||||
208 | 0 executed 16 times by 1 test: return ok ? 0 : 1 ; Executed by:
| 16 | ||||||||||||||||||||||||||||||||||||
209 | : executed 16 times by 1 test: return ok ? 0 : 1 ; Executed by:
| 16 | ||||||||||||||||||||||||||||||||||||
210 | 1 executed 16 times by 1 test: return ok ? 0 : 1 ; Executed by:
| 16 | ||||||||||||||||||||||||||||||||||||
211 | ; executed 16 times by 1 test: return ok ? 0 : 1 ; Executed by:
| 16 | ||||||||||||||||||||||||||||||||||||
212 | } | - | ||||||||||||||||||||||||||||||||||||
Switch to Source code | Preprocessed file |