include/pq_tkr.h

filter: Statementstmt 100% 14 / 14 Branchbran 59.0% 13 / 22 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 75.0% 27 / 36 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« include/pq_sqlite.h ↑ Summary xs/queue.xs »
1 #ifndef PQ_TKR_H
2 #define PQ_TKR_H
3  
4 /* The Time::Keeper::Recurrence C ABI, resolved lazily and optionally.
5 *
6 * Time::Keeper::Recurrence is a SOFT dependency, as Hyperman is (pq_hm.h):
7 * the cron walk is complete without it for UTC, local and +HHMM. With it,
8 * a cron's tz may also be an IANA zone name (America/New_York), whose
9 * occurrences come from its cron_next: Punk::Queue's own grammar, walked
10 * through the zone database with the same DST answers as 'local' (a time
11 * in the spring-forward gap does not fire; in the doubled hour a pinned
12 * time fires once, at the first instance, and an every-minute spec every
13 * real minute). Vendored headers pinned at version 1, a `>=` gate.
14 *
15 * pq_tkr() returns NULL to degrade, never croaks. PUNK_QUEUE_NO_RECURRENCE=1
16 * forces NULL, which is the test seam for the path without it.
17 *
18 * Include after pq_compat.h and time_keeper_recurrence_abi.h. */
19  
20 static const time_keeper_recurrence_abi *PQ_TKR = NULL;
21 static int PQ_TKR_TRIED = 0;
22  
23 809 static const time_keeper_recurrence_abi *pq_tkr(pTHX) {
24 809 ▶ if (!PQ_TKR && !PQ_TKR_TRIED) {
Branch: 2 branches
BranchTrueFalseTotal
if (!PQ_TKR && !PQ_TKR_TRIED) { 4 805 809
if (!PQ_TKR && !PQ_TKR_TRIED) { 4 0 4
25 SV *sv;
26 4 PQ_TKR_TRIED = 1;
27 {
28 4 const char *no = PerlEnv_getenv("PUNK_QUEUE_NO_RECURRENCE");
29 4 ▶ if (no && *no && strNE(no, "0")) return NULL;
Branch: 3 branches
BranchTrueFalseTotal
if (no && *no && strNE(no, "0")) return NULL; 2 2 4
if (no && *no && strNE(no, "0")) return NULL; 2 0 2
if (no && *no && strNE(no, "0")) return NULL; 2 0 2
30 }
31 2 ENTER;
32 2 save_scalar(PL_errgv); /* the caller's $@ survives the require */
33 2 sv = eval_pv("require Time::Keeper::Recurrence; Time::Keeper::Recurrence::_abi_ptr()", FALSE);
34 2 ▶ if (!SvTRUE(ERRSV) && sv && SvOK(sv)) {
Branch: 4 branches
BranchTrueFalseTotal
if (!SvTRUE(ERRSV) && sv && SvOK(sv)) { 2 0 2
if (!SvTRUE(ERRSV) && sv && SvOK(sv)) { 2 0 2
if (!SvTRUE(ERRSV) && sv && SvOK(sv)) { 2 0 2
if (!SvTRUE(ERRSV) && sv && SvOK(sv)) { 2 0 2
35 2 UV p = SvUV(sv);
36 2 const time_keeper_recurrence_abi *a = INT2PTR(const time_keeper_recurrence_abi *, p);
37 2 ▶ if (TIME_KEEPER_RECURRENCE_ABI_OK(a)) PQ_TKR = a;
Branch: 2 branches
BranchTrueFalseTotal
if (TIME_KEEPER_RECURRENCE_ABI_OK(a)) PQ_TKR = a; 2 0 2
if (TIME_KEEPER_RECURRENCE_ABI_OK(a)) PQ_TKR = a; 2 0 2
38 }
39 2 LEAVE;
40 }
41 807 return PQ_TKR;
42 }
43  
44 #endif /* PQ_TKR_H */
« include/pq_sqlite.h ↑ Summary xs/queue.xs »