OpenCoverage

posixtm.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/coreutils/src/gnulib/lib/posixtm.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6static -
7 _Bool-
8-
9year (struct tm *tm, const int *digit_pair, size_t n, unsigned int syntax_bits)-
10{-
11 switch (n)-
12 {-
13 case
executed 1 time by 1 test: case 1:
Executed by:
  • touch
1:
executed 1 time by 1 test: case 1:
Executed by:
  • touch
1
14 tm->tm_year = *digit_pair;-
15-
16-
17-
18 if (digit_pair[0] <= 68
digit_pair[0] <= 68Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • touch
FALSEnever evaluated
)
0-1
19 {-
20 if (syntax_bits & 8
syntax_bits & 8Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • touch
FALSEnever evaluated
)
0-1
21 return
executed 1 time by 1 test: return 0 ;
Executed by:
  • touch
executed 1 time by 1 test: return 0 ;
Executed by:
  • touch
1
22 0
executed 1 time by 1 test: return 0 ;
Executed by:
  • touch
1
23 ;
executed 1 time by 1 test: return 0 ;
Executed by:
  • touch
1
24 tm->tm_year += 100;-
25 }
never executed: end of block
0
26 break;
never executed: break;
0
27-
28 case
executed 2 times by 1 test: case 2:
Executed by:
  • touch
2:
executed 2 times by 1 test: case 2:
Executed by:
  • touch
2
29 if (! (syntax_bits & 2)
! (syntax_bits & 2)Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • touch
)
0-2
30 return
never executed: return 0 ;
never executed: return 0 ;
0
31 0
never executed: return 0 ;
0
32 ;
never executed: return 0 ;
0
33 tm->tm_year = digit_pair[0] * 100 + digit_pair[1] - 1900;-
34 break;
executed 2 times by 1 test: break;
Executed by:
  • touch
2
35-
36 case
executed 4 times by 1 test: case 0:
Executed by:
  • touch
0:
executed 4 times by 1 test: case 0:
Executed by:
  • touch
4
37 {-
38 time_t now;-
39 struct tm *tmp;-
40-
41-
42 time (&now);-
43 tmp = localtime (&now);-
44 if (! tmp
! tmpDescription
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • touch
)
0-4
45 return
never executed: return 0 ;
never executed: return 0 ;
0
46 0
never executed: return 0 ;
0
47 ;
never executed: return 0 ;
0
48 tm->tm_year = tmp->tm_year;-
49 }-
50 break;
executed 4 times by 1 test: break;
Executed by:
  • touch
4
51-
52 default
never executed: default:
:
never executed: default:
0
53 abort ();
never executed: abort ();
0
54 }-
55-
56 return
executed 6 times by 1 test: return 1 ;
Executed by:
  • touch
executed 6 times by 1 test: return 1 ;
Executed by:
  • touch
6
57 1
executed 6 times by 1 test: return 1 ;
Executed by:
  • touch
6
58 ;
executed 6 times by 1 test: return 1 ;
Executed by:
  • touch
6
59}-
60-
61static -
62 _Bool-
63-
64posix_time_parse (struct tm *tm, const char *s, unsigned int syntax_bits)-
65{-
66 const char *dot = -
67 ((void *)0)-
68 ;-
69 int pair[6];-
70 int *p;-
71 size_t i;-
72-
73 size_t s_len = strlen (s);-
74 size_t len = s_len;-
75-
76 if (syntax_bits & 4
syntax_bits & 4Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • touch
FALSEevaluated 5 times by 1 test
Evaluated by:
  • touch
)
3-5
77 {-
78 dot = -
79 (__extension__ (__builtin_constant_p (
__builtin_constant_p ( '.' )Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • touch
FALSEnever evaluated
0-3
80 '.'
__builtin_constant_p ( '.' )Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • touch
FALSEnever evaluated
0-3
81 )
__builtin_constant_p ( '.' )Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • touch
FALSEnever evaluated
&& !__builtin_constant_p (
!__builtin_constant_p ( s )Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • touch
FALSEnever evaluated
0-3
82 s
!__builtin_constant_p ( s )Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • touch
FALSEnever evaluated
0-3
83 )
!__builtin_constant_p ( s )Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • touch
FALSEnever evaluated
&& (
( '.' ) == '\0'Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • touch
0-3
84 '.'
( '.' ) == '\0'Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • touch
0-3
85 ) == '\0'
( '.' ) == '\0'Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • touch
? (char *) __rawmemchr (
0-3
86 s-
87 , -
88 '.'-
89 ) : __builtin_strchr (-
90 s-
91 , -
92 '.'-
93 )))-
94 ;-
95 if (dot
dotDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • touch
FALSEevaluated 1 time by 1 test
Evaluated by:
  • touch
)
1-2
96 {-
97 len = dot - s;-
98 if (s_len - len != 3
s_len - len != 3Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • touch
)
0-2
99 return
never executed: return 0 ;
never executed: return 0 ;
0
100 0
never executed: return 0 ;
0
101 ;
never executed: return 0 ;
0
102 }
executed 2 times by 1 test: end of block
Executed by:
  • touch
2
103 }
executed 3 times by 1 test: end of block
Executed by:
  • touch
3
104-
105 if (! (8 <= len
8 <= lenDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • touch
FALSEevaluated 1 time by 1 test
Evaluated by:
  • touch
&& len <= 12
len <= 12Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • touch
FALSEnever evaluated
&& len % 2 == 0
len % 2 == 0Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • touch
FALSEnever evaluated
))
0-7
106 return
executed 1 time by 1 test: return 0 ;
Executed by:
  • touch
executed 1 time by 1 test: return 0 ;
Executed by:
  • touch
1
107 0
executed 1 time by 1 test: return 0 ;
Executed by:
  • touch
1
108 ;
executed 1 time by 1 test: return 0 ;
Executed by:
  • touch
1
109-
110 for (i = 0; i < len
i < lenDescription
TRUEevaluated 66 times by 1 test
Evaluated by:
  • touch
FALSEevaluated 7 times by 1 test
Evaluated by:
  • touch
; i++)
7-66
111 if (!((unsigned int) (s[i]) - '0' <= 9)
!((unsigned in...]) - '0' <= 9)Description
TRUEnever evaluated
FALSEevaluated 66 times by 1 test
Evaluated by:
  • touch
)
0-66
112 return
never executed: return 0 ;
never executed: return 0 ;
0
113 0
never executed: return 0 ;
0
114 ;
never executed: return 0 ;
0
115-
116 len /= 2;-
117 for (i = 0; i < len
i < lenDescription
TRUEevaluated 33 times by 1 test
Evaluated by:
  • touch
FALSEevaluated 7 times by 1 test
Evaluated by:
  • touch
; i++)
7-33
118 pair[i] = 10 * (s[2*i] - '0') + s[2*i + 1] - '0';
executed 33 times by 1 test: pair[i] = 10 * (s[2*i] - '0') + s[2*i + 1] - '0';
Executed by:
  • touch
33
119-
120 p = pair;-
121 if (! (syntax_bits & 1)
! (syntax_bits & 1)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • touch
FALSEevaluated 5 times by 1 test
Evaluated by:
  • touch
)
2-5
122 {-
123 if (! year (tm, p, len - 4, syntax_bits)
! year (tm, p,..., syntax_bits)Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • touch
)
0-2
124 return
never executed: return 0 ;
never executed: return 0 ;
0
125 0
never executed: return 0 ;
0
126 ;
never executed: return 0 ;
0
127 p += len - 4;-
128 len = 4;-
129 }
executed 2 times by 1 test: end of block
Executed by:
  • touch
2
130-
131-
132 tm->tm_mon = *p++ - 1;-
133 tm->tm_mday = *p++;-
134 tm->tm_hour = *p++;-
135 tm->tm_min = *p++;-
136 len -= 4;-
137-
138-
139 if (syntax_bits & 1
syntax_bits & 1Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • touch
FALSEevaluated 2 times by 1 test
Evaluated by:
  • touch
)
2-5
140 {-
141 if (! year (tm, p, len, syntax_bits)
! year (tm, p,..., syntax_bits)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • touch
FALSEevaluated 4 times by 1 test
Evaluated by:
  • touch
)
1-4
142 return
executed 1 time by 1 test: return 0 ;
Executed by:
  • touch
executed 1 time by 1 test: return 0 ;
Executed by:
  • touch
1
143 0
executed 1 time by 1 test: return 0 ;
Executed by:
  • touch
1
144 ;
executed 1 time by 1 test: return 0 ;
Executed by:
  • touch
1
145 }
executed 4 times by 1 test: end of block
Executed by:
  • touch
4
146-
147-
148 if (!dot
!dotDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • touch
FALSEevaluated 2 times by 1 test
Evaluated by:
  • touch
)
2-4
149 tm->tm_sec = 0;
executed 4 times by 1 test: tm->tm_sec = 0;
Executed by:
  • touch
4
150 else if (((
((unsigned int...]) - '0' <= 9)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • touch
FALSEnever evaluated
unsigned int) (dot[1]) - '0' <= 9)
((unsigned int...]) - '0' <= 9)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • touch
FALSEnever evaluated
&& ((
((unsigned int...]) - '0' <= 9)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • touch
FALSEnever evaluated
unsigned int) (dot[2]) - '0' <= 9)
((unsigned int...]) - '0' <= 9)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • touch
FALSEnever evaluated
)
0-2
151 tm->tm_sec = 10 * (dot[1] - '0') + dot[2] - '0';
executed 2 times by 1 test: tm->tm_sec = 10 * (dot[1] - '0') + dot[2] - '0';
Executed by:
  • touch
2
152 else-
153 return
never executed: return 0 ;
never executed: return 0 ;
0
154 0
never executed: return 0 ;
0
155 ;
never executed: return 0 ;
0
156-
157 return
executed 6 times by 1 test: return 1 ;
Executed by:
  • touch
executed 6 times by 1 test: return 1 ;
Executed by:
  • touch
6
158 1
executed 6 times by 1 test: return 1 ;
Executed by:
  • touch
6
159 ;
executed 6 times by 1 test: return 1 ;
Executed by:
  • touch
6
160}-
161-
162-
163-
164-
165_Bool-
166-
167posixtime (time_t *p, const char *s, unsigned int syntax_bits)-
168{-
169 struct tm tm0;-
170 struct tm tm1;-
171 struct tm const *tm;-
172 time_t t;-
173-
174 if (! posix_time_parse (&tm0, s, syntax_bits)
! posix_time_p..., syntax_bits)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • touch
FALSEevaluated 6 times by 1 test
Evaluated by:
  • touch
)
2-6
175 return
executed 2 times by 1 test: return 0 ;
Executed by:
  • touch
executed 2 times by 1 test: return 0 ;
Executed by:
  • touch
2
176 0
executed 2 times by 1 test: return 0 ;
Executed by:
  • touch
2
177 ;
executed 2 times by 1 test: return 0 ;
Executed by:
  • touch
2
178-
179 tm1.tm_sec = tm0.tm_sec;-
180 tm1.tm_min = tm0.tm_min;-
181 tm1.tm_hour = tm0.tm_hour;-
182 tm1.tm_mday = tm0.tm_mday;-
183 tm1.tm_mon = tm0.tm_mon;-
184 tm1.tm_year = tm0.tm_year;-
185 tm1.tm_isdst = -1;-
186 t = mktime (&tm1);-
187-
188 if (t != (time_t) -1
t != (time_t) -1Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • touch
FALSEnever evaluated
)
0-6
189 tm = &tm1;
executed 6 times by 1 test: tm = &tm1;
Executed by:
  • touch
6
190 else-
191 {-
192-
193-
194 tm = localtime (&t);-
195 if (! tm
! tmDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
196 return
never executed: return 0 ;
never executed: return 0 ;
0
197 0
never executed: return 0 ;
0
198 ;
never executed: return 0 ;
0
199 }
never executed: end of block
0
200-
201-
202-
203-
204-
205 if ((
(tm0.tm_year ^... ^ tm->tm_sec)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • touch
FALSEevaluated 5 times by 1 test
Evaluated by:
  • touch
tm0.tm_year ^ tm->tm_year)
(tm0.tm_year ^... ^ tm->tm_sec)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • touch
FALSEevaluated 5 times by 1 test
Evaluated by:
  • touch
1-5
206 | (tm0.tm_mon ^ tm->tm_mon)
(tm0.tm_year ^... ^ tm->tm_sec)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • touch
FALSEevaluated 5 times by 1 test
Evaluated by:
  • touch
1-5
207 | (tm0.tm_mday ^ tm->tm_mday)
(tm0.tm_year ^... ^ tm->tm_sec)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • touch
FALSEevaluated 5 times by 1 test
Evaluated by:
  • touch
1-5
208 | (tm0.tm_hour ^ tm->tm_hour)
(tm0.tm_year ^... ^ tm->tm_sec)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • touch
FALSEevaluated 5 times by 1 test
Evaluated by:
  • touch
1-5
209 | (tm0.tm_min ^ tm->tm_min)
(tm0.tm_year ^... ^ tm->tm_sec)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • touch
FALSEevaluated 5 times by 1 test
Evaluated by:
  • touch
1-5
210 | (tm0.tm_sec ^ tm->tm_sec)
(tm0.tm_year ^... ^ tm->tm_sec)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • touch
FALSEevaluated 5 times by 1 test
Evaluated by:
  • touch
)
1-5
211 {-
212-
213 if (tm0.tm_sec != 60
tm0.tm_sec != 60Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • touch
)
0-1
214 return
never executed: return 0 ;
never executed: return 0 ;
0
215 0
never executed: return 0 ;
0
216 ;
never executed: return 0 ;
0
217-
218 {-
219-
220 time_t dummy;-
221 char buf[16];-
222 char *b = stpcpy (buf, s);-
223 strcpy (b - 2, "59");-
224 if (!posixtime (&dummy, buf, syntax_bits)
!posixtime (&d..., syntax_bits)Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • touch
)
0-1
225 return
never executed: return 0 ;
never executed: return 0 ;
0
226 0
never executed: return 0 ;
0
227 ;
never executed: return 0 ;
0
228 }-
229 }
executed 1 time by 1 test: end of block
Executed by:
  • touch
1
230-
231 *p = t;-
232 return
executed 6 times by 1 test: return 1 ;
Executed by:
  • touch
executed 6 times by 1 test: return 1 ;
Executed by:
  • touch
6
233 1
executed 6 times by 1 test: return 1 ;
Executed by:
  • touch
6
234 ;
executed 6 times by 1 test: return 1 ;
Executed by:
  • touch
6
235}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.1.2