Zone.xs

filter: Statementstmt 94.1% 16 / 17 Branchbran 75.0% 12 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 84.8% 28 / 33 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« include/tkz/tkz_local.h ↑ Summary include/tkz/tkz_dump.h »
1 #define PERL_NO_GET_CONTEXT
2 /* Under PERL_IMPLICIT_SYS (every Strawberry perl) XSUB.h rewrites plain
3 * fopen/fgets/fclose into PerlSIO_ macros that need an interpreter. The
4 * headers below are plain C with no interpreter to hand, so keep the
5 * names as the C library's. */
6 #define NO_XSLOCKS
7 #include "EXTERN.h"
8 #include "perl.h"
9 #include "XSUB.h"
10  
11 #ifndef G_LIST
12 # define G_LIST G_ARRAY
13 #endif
14 #ifndef mPUSHs
15 # define mPUSHs(s) PUSHs(sv_2mortal(s))
16 #endif
17 #ifndef mXPUSHs
18 # define mXPUSHs(s) XPUSHs(sv_2mortal(s))
19 #endif
20  
21 #include "time_keeper_zone_abi.h"
22 #include "tkz/tkz_types.h"
23 #include "tkz/tkz_data.h"
24 #include "tkz/tkz_engine.h"
25 #include "tkz/tkz_local.h"
26 #include "tkz/tkz_abi_impl.h"
27 #include "tkz/tkz_dump.h"
28  
29 /* A method's zone argument: its id, or a croak naming it. */
30 static int
31 44 tkz_sv_zone(pTHX_ SV *name)
32 {
33 STRLEN len;
34 const char *p;
35 int id;
36 44 ▶ if (!SvOK(name))
Branch: 1 branch
BranchTrueFalseTotal
if (!SvOK(name)) 0 44 44
37 0 croak("Time::Keeper::Zone: no zone name given");
38 44 p = SvPV(name, len);
39 44 id = tkz_lookup_name(p, len);
40 44 ▶ if (id < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (id < 0) 6 38 44
41 6 croak("Time::Keeper::Zone: unknown time zone '%" SVf "'", SVfARG(name));
42 38 return id;
43 }
44  
45 /* A method's epoch argument, floored to the second: a fraction belongs to
46 * the second it falls in. About three billion years either way. */
47 static int64_t
48 42 tkz_sv_epoch(pTHX_ SV *sv)
49 {
50 NV n;
51 42 ▶ if (SvIOK(sv) && !SvIsUV(sv))
Branch: 2 branches
BranchTrueFalseTotal
if (SvIOK(sv) && !SvIsUV(sv)) 40 2 42
if (SvIOK(sv) && !SvIsUV(sv)) 40 0 40
52 40 n = (NV)SvIV(sv);
53 else
54 2 n = SvNV(sv);
55 42 ▶ if (!(n >= -1e17 && n <= 1e17))
Branch: 2 branches
BranchTrueFalseTotal
if (!(n >= -1e17 && n <= 1e17)) 42 0 42
if (!(n >= -1e17 && n <= 1e17)) 1 41 42
56 1 croak("Time::Keeper::Zone: epoch %" NVgf " is out of range", n);
57 41 ▶ if (SvIOK(sv) && !SvIsUV(sv))
Branch: 2 branches
BranchTrueFalseTotal
if (SvIOK(sv) && !SvIsUV(sv)) 40 1 41
if (SvIOK(sv) && !SvIsUV(sv)) 40 0 40
58 40 return (int64_t)SvIV(sv);
59 1 return (int64_t)Perl_floor(n);
60 }
61  
62 MODULE = Time::Keeper::Zone PACKAGE = Time::Keeper::Zone
63  
64 PROTOTYPES: DISABLE
65  
66 INCLUDE: xs/zone.xs
67 INCLUDE: xs/abi.xs
68 INCLUDE: xs/data.xs
69 INCLUDE: xs/engine.xs
70 INCLUDE: xs/rules.xs
71 INCLUDE: xs/test.xs
« include/tkz/tkz_local.h ↑ Summary include/tkz/tkz_dump.h »