Eshu.xs

filter: Statementstmt 82.4% 775 / 940 Branchbran 58.0% 693 / 1194 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 68.7% 1468 / 2134 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« include/eshu_hl.h ↑ Summary include/eshu_lua.h »
1 #define PERL_NO_GET_CONTEXT
2 #include "EXTERN.h"
3 #include "perl.h"
4 #include "XSUB.h"
5  
6 /*
7 * On Windows threaded Perl (MULTIPLICITY), perl.h redefines standard C
8 * functions (malloc, free, stat, opendir, etc.) as macros that require
9 * the interpreter context (my_perl). Our engine headers are pure C and
10 * must call the real libc functions, so undo those overrides here.
11 * This is safe: the XS code below uses Perl API directly and never
12 * relies on these macros.
13 */
14 #ifdef WIN32
15 # undef malloc
16 # undef realloc
17 # undef calloc
18 # undef free
19 # undef stat
20 # undef lstat
21 # undef fstat
22 # undef opendir
23 # undef readdir
24 # undef closedir
25 # undef rename
26 # undef open
27 # undef close
28 # undef read
29 # undef write
30 #endif
31  
32 #include "eshu.h"
33 #include "eshu_c.h"
34 #include "eshu_pod.h"
35 #include "eshu_pl.h"
36 #include "eshu_xs.h"
37 #include "eshu_js.h"
38 #include "eshu_xml.h"
39 #include "eshu_css.h"
40 #include "eshu_diff.h"
41 #include "eshu_bash.h"
42 #include "eshu_go.h"
43 #include "eshu_py.h"
44 #include "eshu_json.h"
45 #include "eshu_java.h"
46 #include "eshu_lua.h"
47 #include "eshu_rust.h"
48 #include "eshu_php.h"
49 #include "eshu_ruby.h"
50 #include "eshu_ts.h"
51 #include "eshu_sql.h"
52 #include "eshu_yaml.h"
53 #include "eshu_file.h"
54 #include "eshu_hl.h"
55  
56 MODULE = Eshu PACKAGE = Eshu
57  
58 PROTOTYPES: DISABLE
59  
60 SV *
61 detect_lang(class, filename_sv)
62 SV * class
63 SV * filename_sv
64 CODE:
65 {
66 const char *filename;
67 const char *dot;
68 STRLEN len;
69  
70 PERL_UNUSED_VAR(class);
71 103 RETVAL = &PL_sv_undef;
72  
73 103 ▶ if (SvOK(filename_sv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (SvOK(filename_sv)) { 103 0 103
74 103 filename = SvPV(filename_sv, len);
75 103 dot = NULL;
76 /* find last dot */
77 {
78 103 const char *p = filename + len;
79 412 ▶ while (p > filename) {
Branch: 1 branch
BranchTrueFalseTotal
while (p > filename) { 408 4 412
80 408 p--;
81 408 ▶ if (*p == '.') { dot = p + 1; break; }
Branch: 1 branch
BranchTrueFalseTotal
if (*p == '.') { dot = p + 1; break; } 99 309 408
82 }
83 }
84 103 ▶ if (dot) {
Branch: 1 branch
BranchTrueFalseTotal
if (dot) { 99 4 103
85 99 STRLEN ext_len = (filename + len) - dot;
86 99 ▶ if ((ext_len == 1 && (dot[0] == 'c' || dot[0] == 'C'))
Branch: 3 branches
BranchTrueFalseTotal
if ((ext_len == 1 && (dot[0] == 'c' || dot[0] == 'C')) 14 85 99
if ((ext_len == 1 && (dot[0] == 'c' || dot[0] == 'C')) 5 9 14
if ((ext_len == 1 && (dot[0] == 'c' || dot[0] == 'C')) 4 1 5
87 89 ▶ || (ext_len == 1 && (dot[0] == 'h' || dot[0] == 'H'))) {
Branch: 3 branches
BranchTrueFalseTotal
|| (ext_len == 1 && (dot[0] == 'h' || dot[0] == 'H'))) { 4 85 89
|| (ext_len == 1 && (dot[0] == 'h' || dot[0] == 'H'))) { 3 1 4
|| (ext_len == 1 && (dot[0] == 'h' || dot[0] == 'H'))) { 1 2 3
88 12 RETVAL = newSVpvs("c");
89 87 ▶ } else if (ext_len == 2
Branch: 1 branch
BranchTrueFalseTotal
} else if (ext_len == 2 23 64 87
90 23 ▶ && (dot[0] == 'x' || dot[0] == 'X')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 'x' || dot[0] == 'X') 21 2 23
&& (dot[0] == 'x' || dot[0] == 'X') 0 21 21
91 2 ▶ && (dot[1] == 's' || dot[1] == 'S')) {
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 's' || dot[1] == 'S')) { 0 2 2
&& (dot[1] == 's' || dot[1] == 'S')) { 0 0 0
92 2 RETVAL = newSVpvs("xs");
93 85 ▶ } else if ((ext_len == 2
Branch: 1 branch
BranchTrueFalseTotal
} else if ((ext_len == 2 21 64 85
94 21 ▶ && (dot[0] == 'p' || dot[0] == 'P')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 'p' || dot[0] == 'P') 15 6 21
&& (dot[0] == 'p' || dot[0] == 'P') 0 15 15
95 6 ▶ && (dot[1] == 'l' || dot[1] == 'L'))
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 'l' || dot[1] == 'L')) 4 2 6
&& (dot[1] == 'l' || dot[1] == 'L')) 4 0 4
96 83 ▶ || (ext_len == 2
Branch: 1 branch
BranchTrueFalseTotal
|| (ext_len == 2 19 64 83
97 19 ▶ && (dot[0] == 'p' || dot[0] == 'P')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 'p' || dot[0] == 'P') 15 4 19
&& (dot[0] == 'p' || dot[0] == 'P') 0 15 15
98 4 ▶ && (dot[1] == 'm' || dot[1] == 'M'))
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 'm' || dot[1] == 'M')) 1 3 4
&& (dot[1] == 'm' || dot[1] == 'M')) 1 0 1
99 80 ▶ || (ext_len == 1
Branch: 1 branch
BranchTrueFalseTotal
|| (ext_len == 1 2 78 80
100 2 ▶ && (dot[0] == 't' || dot[0] == 'T'))) {
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 't' || dot[0] == 'T'))) { 0 2 2
&& (dot[0] == 't' || dot[0] == 'T'))) { 0 0 0
101 7 RETVAL = newSVpvs("perl");
102 78 ▶ } else if ((ext_len == 3
Branch: 1 branch
BranchTrueFalseTotal
} else if ((ext_len == 3 36 42 78
103 36 ▶ && (dot[0] == 'x' || dot[0] == 'X')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 'x' || dot[0] == 'X') 32 4 36
&& (dot[0] == 'x' || dot[0] == 'X') 0 32 32
104 4 ▶ && (dot[1] == 'm' || dot[1] == 'M')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 'm' || dot[1] == 'M') 2 2 4
&& (dot[1] == 'm' || dot[1] == 'M') 0 2 2
105 2 ▶ && (dot[2] == 'l' || dot[2] == 'L'))
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[2] == 'l' || dot[2] == 'L')) 0 2 2
&& (dot[2] == 'l' || dot[2] == 'L')) 0 0 0
106 76 ▶ || (ext_len == 3
Branch: 1 branch
BranchTrueFalseTotal
|| (ext_len == 3 34 42 76
107 34 ▶ && (dot[0] == 'x' || dot[0] == 'X')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 'x' || dot[0] == 'X') 32 2 34
&& (dot[0] == 'x' || dot[0] == 'X') 0 32 32
108 2 ▶ && (dot[1] == 's' || dot[1] == 'S')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 's' || dot[1] == 'S') 0 2 2
&& (dot[1] == 's' || dot[1] == 'S') 0 0 0
109 2 ▶ && (dot[2] == 'l' || dot[2] == 'L'))
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[2] == 'l' || dot[2] == 'L')) 0 2 2
&& (dot[2] == 'l' || dot[2] == 'L')) 0 0 0
110 74 ▶ || (ext_len == 4
Branch: 1 branch
BranchTrueFalseTotal
|| (ext_len == 4 20 54 74
111 20 ▶ && (dot[0] == 'x' || dot[0] == 'X')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 'x' || dot[0] == 'X') 18 2 20
&& (dot[0] == 'x' || dot[0] == 'X') 0 18 18
112 2 ▶ && (dot[1] == 's' || dot[1] == 'S')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 's' || dot[1] == 'S') 0 2 2
&& (dot[1] == 's' || dot[1] == 'S') 0 0 0
113 2 ▶ && (dot[2] == 'l' || dot[2] == 'L')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[2] == 'l' || dot[2] == 'L') 0 2 2
&& (dot[2] == 'l' || dot[2] == 'L') 0 0 0
114 2 ▶ && (dot[3] == 't' || dot[3] == 'T'))
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[3] == 't' || dot[3] == 'T')) 0 2 2
&& (dot[3] == 't' || dot[3] == 'T')) 0 0 0
115 72 ▶ || (ext_len == 3
Branch: 1 branch
BranchTrueFalseTotal
|| (ext_len == 3 32 40 72
116 32 ▶ && (dot[0] == 's' || dot[0] == 'S')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 's' || dot[0] == 'S') 29 3 32
&& (dot[0] == 's' || dot[0] == 'S') 1 28 29
117 4 ▶ && (dot[1] == 'v' || dot[1] == 'V')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 'v' || dot[1] == 'V') 2 2 4
&& (dot[1] == 'v' || dot[1] == 'V') 0 2 2
118 2 ▶ && (dot[2] == 'g' || dot[2] == 'G'))
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[2] == 'g' || dot[2] == 'G')) 0 2 2
&& (dot[2] == 'g' || dot[2] == 'G')) 0 0 0
119 70 ▶ || (ext_len == 5
Branch: 1 branch
BranchTrueFalseTotal
|| (ext_len == 5 6 64 70
120 6 ▶ && (dot[0] == 'x' || dot[0] == 'X')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 'x' || dot[0] == 'X') 4 2 6
&& (dot[0] == 'x' || dot[0] == 'X') 0 4 4
121 2 ▶ && (dot[1] == 'h' || dot[1] == 'H')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 'h' || dot[1] == 'H') 0 2 2
&& (dot[1] == 'h' || dot[1] == 'H') 0 0 0
122 2 ▶ && (dot[2] == 't' || dot[2] == 'T')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[2] == 't' || dot[2] == 'T') 0 2 2
&& (dot[2] == 't' || dot[2] == 'T') 0 0 0
123 2 ▶ && (dot[3] == 'm' || dot[3] == 'M')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[3] == 'm' || dot[3] == 'M') 0 2 2
&& (dot[3] == 'm' || dot[3] == 'M') 0 0 0
124 2 ▶ && (dot[4] == 'l' || dot[4] == 'L'))) {
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[4] == 'l' || dot[4] == 'L'))) { 0 2 2
&& (dot[4] == 'l' || dot[4] == 'L'))) { 0 0 0
125 10 RETVAL = newSVpvs("xml");
126 68 ▶ } else if ((ext_len == 4
Branch: 1 branch
BranchTrueFalseTotal
} else if ((ext_len == 4 18 50 68
127 18 ▶ && (dot[0] == 'h' || dot[0] == 'H')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 'h' || dot[0] == 'H') 16 2 18
&& (dot[0] == 'h' || dot[0] == 'H') 0 16 16
128 2 ▶ && (dot[1] == 't' || dot[1] == 'T')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 't' || dot[1] == 'T') 0 2 2
&& (dot[1] == 't' || dot[1] == 'T') 0 0 0
129 2 ▶ && (dot[2] == 'm' || dot[2] == 'M')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[2] == 'm' || dot[2] == 'M') 0 2 2
&& (dot[2] == 'm' || dot[2] == 'M') 0 0 0
130 2 ▶ && (dot[3] == 'l' || dot[3] == 'L'))
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[3] == 'l' || dot[3] == 'L')) 0 2 2
&& (dot[3] == 'l' || dot[3] == 'L')) 0 0 0
131 66 ▶ || (ext_len == 3
Branch: 1 branch
BranchTrueFalseTotal
|| (ext_len == 3 30 36 66
132 30 ▶ && (dot[0] == 'h' || dot[0] == 'H')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 'h' || dot[0] == 'H') 28 2 30
&& (dot[0] == 'h' || dot[0] == 'H') 0 28 28
133 2 ▶ && (dot[1] == 't' || dot[1] == 'T')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 't' || dot[1] == 'T') 0 2 2
&& (dot[1] == 't' || dot[1] == 'T') 0 0 0
134 2 ▶ && (dot[2] == 'm' || dot[2] == 'M'))
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[2] == 'm' || dot[2] == 'M')) 0 2 2
&& (dot[2] == 'm' || dot[2] == 'M')) 0 0 0
135 64 ▶ || (ext_len == 4
Branch: 1 branch
BranchTrueFalseTotal
|| (ext_len == 4 16 48 64
136 16 ▶ && (dot[0] == 't' || dot[0] == 'T')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 't' || dot[0] == 'T') 14 2 16
&& (dot[0] == 't' || dot[0] == 'T') 0 14 14
137 2 ▶ && (dot[1] == 'm' || dot[1] == 'M')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 'm' || dot[1] == 'M') 0 2 2
&& (dot[1] == 'm' || dot[1] == 'M') 0 0 0
138 2 ▶ && (dot[2] == 'p' || dot[2] == 'P')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[2] == 'p' || dot[2] == 'P') 0 2 2
&& (dot[2] == 'p' || dot[2] == 'P') 0 0 0
139 2 ▶ && (dot[3] == 'l' || dot[3] == 'L'))
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[3] == 'l' || dot[3] == 'L')) 0 2 2
&& (dot[3] == 'l' || dot[3] == 'L')) 0 0 0
140 62 ▶ || (ext_len == 2
Branch: 1 branch
BranchTrueFalseTotal
|| (ext_len == 2 16 46 62
141 16 ▶ && (dot[0] == 't' || dot[0] == 'T')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 't' || dot[0] == 'T') 11 5 16
&& (dot[0] == 't' || dot[0] == 'T') 0 11 11
142 5 ▶ && (dot[1] == 't' || dot[1] == 'T'))
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 't' || dot[1] == 'T')) 3 2 5
&& (dot[1] == 't' || dot[1] == 'T')) 3 0 3
143 60 ▶ || (ext_len == 2
Branch: 1 branch
BranchTrueFalseTotal
|| (ext_len == 2 14 46 60
144 14 ▶ && (dot[0] == 'e' || dot[0] == 'E')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 'e' || dot[0] == 'E') 12 2 14
&& (dot[0] == 'e' || dot[0] == 'E') 0 12 12
145 2 ▶ && (dot[1] == 'p' || dot[1] == 'P'))) {
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 'p' || dot[1] == 'P'))) { 0 2 2
&& (dot[1] == 'p' || dot[1] == 'P'))) { 0 0 0
146 10 RETVAL = newSVpvs("html");
147 58 ▶ } else if ((ext_len == 3
Branch: 1 branch
BranchTrueFalseTotal
} else if ((ext_len == 3 28 30 58
148 28 ▶ && (dot[0] == 'c' || dot[0] == 'C')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 'c' || dot[0] == 'C') 24 4 28
&& (dot[0] == 'c' || dot[0] == 'C') 1 23 24
149 5 ▶ && (dot[1] == 's' || dot[1] == 'S')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 's' || dot[1] == 'S') 3 2 5
&& (dot[1] == 's' || dot[1] == 'S') 1 2 3
150 3 ▶ && (dot[2] == 's' || dot[2] == 'S'))
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[2] == 's' || dot[2] == 'S')) 1 2 3
&& (dot[2] == 's' || dot[2] == 'S')) 0 1 1
151 55 ▶ || (ext_len == 4
Branch: 1 branch
BranchTrueFalseTotal
|| (ext_len == 4 14 41 55
152 14 ▶ && (dot[0] == 's' || dot[0] == 'S')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 's' || dot[0] == 'S') 12 2 14
&& (dot[0] == 's' || dot[0] == 'S') 0 12 12
153 2 ▶ && (dot[1] == 'c' || dot[1] == 'C')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 'c' || dot[1] == 'C') 0 2 2
&& (dot[1] == 'c' || dot[1] == 'C') 0 0 0
154 2 ▶ && (dot[2] == 's' || dot[2] == 'S')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[2] == 's' || dot[2] == 'S') 0 2 2
&& (dot[2] == 's' || dot[2] == 'S') 0 0 0
155 2 ▶ && (dot[3] == 's' || dot[3] == 'S'))
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[3] == 's' || dot[3] == 'S')) 0 2 2
&& (dot[3] == 's' || dot[3] == 'S')) 0 0 0
156 53 ▶ || (ext_len == 4
Branch: 1 branch
BranchTrueFalseTotal
|| (ext_len == 4 12 41 53
157 12 ▶ && (dot[0] == 'l' || dot[0] == 'L')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 'l' || dot[0] == 'L') 10 2 12
&& (dot[0] == 'l' || dot[0] == 'L') 0 10 10
158 2 ▶ && (dot[1] == 'e' || dot[1] == 'E')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 'e' || dot[1] == 'E') 0 2 2
&& (dot[1] == 'e' || dot[1] == 'E') 0 0 0
159 2 ▶ && (dot[2] == 's' || dot[2] == 'S')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[2] == 's' || dot[2] == 'S') 0 2 2
&& (dot[2] == 's' || dot[2] == 'S') 0 0 0
160 2 ▶ && (dot[3] == 's' || dot[3] == 'S'))) {
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[3] == 's' || dot[3] == 'S'))) { 0 2 2
&& (dot[3] == 's' || dot[3] == 'S'))) { 0 0 0
161 7 RETVAL = newSVpvs("css");
162 51 ▶ } else if ((ext_len == 2
Branch: 1 branch
BranchTrueFalseTotal
} else if ((ext_len == 2 12 39 51
163 12 ▶ && (dot[0] == 'j' || dot[0] == 'J')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 'j' || dot[0] == 'J') 10 2 12
&& (dot[0] == 'j' || dot[0] == 'J') 0 10 10
164 2 ▶ && (dot[1] == 's' || dot[1] == 'S'))
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 's' || dot[1] == 'S')) 0 2 2
&& (dot[1] == 's' || dot[1] == 'S')) 0 0 0
165 49 ▶ || (ext_len == 3
Branch: 1 branch
BranchTrueFalseTotal
|| (ext_len == 3 25 24 49
166 25 ▶ && (dot[0] == 'j' || dot[0] == 'J')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 'j' || dot[0] == 'J') 23 2 25
&& (dot[0] == 'j' || dot[0] == 'J') 0 23 23
167 2 ▶ && (dot[1] == 's' || dot[1] == 'S')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 's' || dot[1] == 'S') 0 2 2
&& (dot[1] == 's' || dot[1] == 'S') 0 0 0
168 2 ▶ && (dot[2] == 'x' || dot[2] == 'X'))
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[2] == 'x' || dot[2] == 'X')) 0 2 2
&& (dot[2] == 'x' || dot[2] == 'X')) 0 0 0
169 47 ▶ || (ext_len == 3
Branch: 1 branch
BranchTrueFalseTotal
|| (ext_len == 3 23 24 47
170 23 ▶ && (dot[0] == 'm' || dot[0] == 'M')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 'm' || dot[0] == 'M') 18 5 23
&& (dot[0] == 'm' || dot[0] == 'M') 0 18 18
171 5 ▶ && (dot[1] == 'j' || dot[1] == 'J')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 'j' || dot[1] == 'J') 3 2 5
&& (dot[1] == 'j' || dot[1] == 'J') 0 3 3
172 2 ▶ && (dot[2] == 's' || dot[2] == 'S'))
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[2] == 's' || dot[2] == 'S')) 0 2 2
&& (dot[2] == 's' || dot[2] == 'S')) 0 0 0
173 45 ▶ || (ext_len == 3
Branch: 1 branch
BranchTrueFalseTotal
|| (ext_len == 3 21 24 45
174 21 ▶ && (dot[0] == 'c' || dot[0] == 'C')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 'c' || dot[0] == 'C') 19 2 21
&& (dot[0] == 'c' || dot[0] == 'C') 0 19 19
175 2 ▶ && (dot[1] == 'j' || dot[1] == 'J')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 'j' || dot[1] == 'J') 0 2 2
&& (dot[1] == 'j' || dot[1] == 'J') 0 0 0
176 2 ▶ && (dot[2] == 's' || dot[2] == 'S'))
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[2] == 's' || dot[2] == 'S')) 0 2 2
&& (dot[2] == 's' || dot[2] == 'S')) 0 0 0
177 ) {
178 8 RETVAL = newSVpvs("js");
179 43 ▶ } else if ((ext_len == 2
Branch: 1 branch
BranchTrueFalseTotal
} else if ((ext_len == 2 10 33 43
180 10 ▶ && (dot[0] == 't' || dot[0] == 'T')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 't' || dot[0] == 'T') 7 3 10
&& (dot[0] == 't' || dot[0] == 'T') 0 7 7
181 3 ▶ && (dot[1] == 's' || dot[1] == 'S'))
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 's' || dot[1] == 'S')) 0 3 3
&& (dot[1] == 's' || dot[1] == 'S')) 0 0 0
182 40 ▶ || (ext_len == 3
Branch: 1 branch
BranchTrueFalseTotal
|| (ext_len == 3 19 21 40
183 19 ▶ && (dot[0] == 't' || dot[0] == 'T')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 't' || dot[0] == 'T') 13 6 19
&& (dot[0] == 't' || dot[0] == 'T') 0 13 13
184 6 ▶ && (dot[1] == 's' || dot[1] == 'S')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 's' || dot[1] == 'S') 2 4 6
&& (dot[1] == 's' || dot[1] == 'S') 0 2 2
185 4 ▶ && (dot[2] == 'x' || dot[2] == 'X'))
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[2] == 'x' || dot[2] == 'X')) 0 4 4
&& (dot[2] == 'x' || dot[2] == 'X')) 0 0 0
186 36 ▶ || (ext_len == 3
Branch: 1 branch
BranchTrueFalseTotal
|| (ext_len == 3 15 21 36
187 15 ▶ && (dot[0] == 'm' || dot[0] == 'M')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 'm' || dot[0] == 'M') 12 3 15
&& (dot[0] == 'm' || dot[0] == 'M') 0 12 12
188 3 ▶ && (dot[1] == 't' || dot[1] == 'T')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 't' || dot[1] == 'T') 0 3 3
&& (dot[1] == 't' || dot[1] == 'T') 0 0 0
189 3 ▶ && (dot[2] == 's' || dot[2] == 'S'))) {
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[2] == 's' || dot[2] == 'S'))) { 0 3 3
&& (dot[2] == 's' || dot[2] == 'S'))) { 0 0 0
190 10 RETVAL = newSVpvs("ts");
191 33 ▶ } else if (ext_len == 3
Branch: 1 branch
BranchTrueFalseTotal
} else if (ext_len == 3 12 21 33
192 12 ▶ && (dot[0] == 'p' || dot[0] == 'P')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 'p' || dot[0] == 'P') 7 5 12
&& (dot[0] == 'p' || dot[0] == 'P') 2 5 7
193 7 ▶ && (dot[1] == 'o' || dot[1] == 'O')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 'o' || dot[1] == 'O') 5 2 7
&& (dot[1] == 'o' || dot[1] == 'O') 0 5 5
194 2 ▶ && (dot[2] == 'd' || dot[2] == 'D')) {
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[2] == 'd' || dot[2] == 'D')) { 0 2 2
&& (dot[2] == 'd' || dot[2] == 'D')) { 0 0 0
195 2 RETVAL = newSVpvs("pod");
196 31 ▶ } else if ((ext_len == 2
Branch: 1 branch
BranchTrueFalseTotal
} else if ((ext_len == 2 7 24 31
197 7 ▶ && (dot[0] == 'p' || dot[0] == 'P')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 'p' || dot[0] == 'P') 6 1 7
&& (dot[0] == 'p' || dot[0] == 'P') 0 6 6
198 1 ▶ && (dot[1] == 'y' || dot[1] == 'Y'))
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 'y' || dot[1] == 'Y')) 0 1 1
&& (dot[1] == 'y' || dot[1] == 'Y')) 0 0 0
199 30 ▶ || (ext_len == 3
Branch: 1 branch
BranchTrueFalseTotal
|| (ext_len == 3 10 20 30
200 10 ▶ && (dot[0] == 'p' || dot[0] == 'P')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 'p' || dot[0] == 'P') 7 3 10
&& (dot[0] == 'p' || dot[0] == 'P') 2 5 7
201 5 ▶ && (dot[1] == 'y' || dot[1] == 'Y')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 'y' || dot[1] == 'Y') 4 1 5
&& (dot[1] == 'y' || dot[1] == 'Y') 0 4 4
202 1 ▶ && (dot[2] == 'w' || dot[2] == 'W'))) {
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[2] == 'w' || dot[2] == 'W'))) { 0 1 1
&& (dot[2] == 'w' || dot[2] == 'W'))) { 0 0 0
203 2 RETVAL = newSVpvs("python");
204 29 ▶ } else if ((ext_len == 2
Branch: 1 branch
BranchTrueFalseTotal
} else if ((ext_len == 2 6 23 29
205 6 ▶ && (dot[0] == 's' || dot[0] == 'S')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 's' || dot[0] == 'S') 6 0 6
&& (dot[0] == 's' || dot[0] == 'S') 0 6 6
206 0 ▶ && (dot[1] == 'h' || dot[1] == 'H'))
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 'h' || dot[1] == 'H')) 0 0 0
&& (dot[1] == 'h' || dot[1] == 'H')) 0 0 0
207 29 ▶ || (ext_len == 4
Branch: 1 branch
BranchTrueFalseTotal
|| (ext_len == 4 10 19 29
208 10 ▶ && (dot[0] == 'b' || dot[0] == 'B')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 'b' || dot[0] == 'B') 10 0 10
&& (dot[0] == 'b' || dot[0] == 'B') 0 10 10
209 0 ▶ && (dot[1] == 'a' || dot[1] == 'A')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 'a' || dot[1] == 'A') 0 0 0
&& (dot[1] == 'a' || dot[1] == 'A') 0 0 0
210 0 ▶ && (dot[2] == 's' || dot[2] == 'S')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[2] == 's' || dot[2] == 'S') 0 0 0
&& (dot[2] == 's' || dot[2] == 'S') 0 0 0
211 0 ▶ && (dot[3] == 'h' || dot[3] == 'H'))
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[3] == 'h' || dot[3] == 'H')) 0 0 0
&& (dot[3] == 'h' || dot[3] == 'H')) 0 0 0
212 29 ▶ || (ext_len == 3
Branch: 1 branch
BranchTrueFalseTotal
|| (ext_len == 3 9 20 29
213 9 ▶ && (dot[0] == 'z' || dot[0] == 'Z')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 'z' || dot[0] == 'Z') 9 0 9
&& (dot[0] == 'z' || dot[0] == 'Z') 0 9 9
214 0 ▶ && (dot[1] == 's' || dot[1] == 'S')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 's' || dot[1] == 'S') 0 0 0
&& (dot[1] == 's' || dot[1] == 'S') 0 0 0
215 0 ▶ && (dot[2] == 'h' || dot[2] == 'H'))
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[2] == 'h' || dot[2] == 'H')) 0 0 0
&& (dot[2] == 'h' || dot[2] == 'H')) 0 0 0
216 29 ▶ || (ext_len == 3
Branch: 1 branch
BranchTrueFalseTotal
|| (ext_len == 3 9 20 29
217 9 ▶ && (dot[0] == 'k' || dot[0] == 'K')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 'k' || dot[0] == 'K') 9 0 9
&& (dot[0] == 'k' || dot[0] == 'K') 0 9 9
218 0 ▶ && (dot[1] == 's' || dot[1] == 'S')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 's' || dot[1] == 'S') 0 0 0
&& (dot[1] == 's' || dot[1] == 'S') 0 0 0
219 0 ▶ && (dot[2] == 'h' || dot[2] == 'H'))) {
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[2] == 'h' || dot[2] == 'H'))) { 0 0 0
&& (dot[2] == 'h' || dot[2] == 'H'))) { 0 0 0
220 0 RETVAL = newSVpvs("bash");
221 29 ▶ } else if (ext_len == 2
Branch: 1 branch
BranchTrueFalseTotal
} else if (ext_len == 2 6 23 29
222 6 ▶ && (dot[0] == 'g' || dot[0] == 'G')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 'g' || dot[0] == 'G') 6 0 6
&& (dot[0] == 'g' || dot[0] == 'G') 0 6 6
223 0 ▶ && (dot[1] == 'o' || dot[1] == 'O')) {
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 'o' || dot[1] == 'O')) { 0 0 0
&& (dot[1] == 'o' || dot[1] == 'O')) { 0 0 0
224 0 RETVAL = newSVpvs("go");
225 29 ▶ } else if (ext_len == 2
Branch: 1 branch
BranchTrueFalseTotal
} else if (ext_len == 2 6 23 29
226 6 ▶ && (dot[0] == 'r' || dot[0] == 'R')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 'r' || dot[0] == 'R') 3 3 6
&& (dot[0] == 'r' || dot[0] == 'R') 2 1 3
227 5 ▶ && (dot[1] == 's' || dot[1] == 'S')) {
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 's' || dot[1] == 'S')) { 3 2 5
&& (dot[1] == 's' || dot[1] == 'S')) { 1 2 3
228 3 RETVAL = newSVpvs("rust");
229 26 ▶ } else if (ext_len == 3
Branch: 1 branch
BranchTrueFalseTotal
} else if (ext_len == 3 9 17 26
230 9 ▶ && (dot[0] == 'l' || dot[0] == 'L')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 'l' || dot[0] == 'L') 9 0 9
&& (dot[0] == 'l' || dot[0] == 'L') 0 9 9
231 0 ▶ && (dot[1] == 'u' || dot[1] == 'U')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 'u' || dot[1] == 'U') 0 0 0
&& (dot[1] == 'u' || dot[1] == 'U') 0 0 0
232 0 ▶ && (dot[2] == 'a' || dot[2] == 'A')) {
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[2] == 'a' || dot[2] == 'A')) { 0 0 0
&& (dot[2] == 'a' || dot[2] == 'A')) { 0 0 0
233 0 RETVAL = newSVpvs("lua");
234 26 ▶ } else if ((ext_len == 4
Branch: 1 branch
BranchTrueFalseTotal
} else if ((ext_len == 4 10 16 26
235 10 ▶ && (dot[0] == 'j' || dot[0] == 'J')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 'j' || dot[0] == 'J') 7 3 10
&& (dot[0] == 'j' || dot[0] == 'J') 1 6 7
236 4 ▶ && (dot[1] == 's' || dot[1] == 'S')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 's' || dot[1] == 'S') 2 2 4
&& (dot[1] == 's' || dot[1] == 'S') 0 2 2
237 2 ▶ && (dot[2] == 'o' || dot[2] == 'O')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[2] == 'o' || dot[2] == 'O') 0 2 2
&& (dot[2] == 'o' || dot[2] == 'O') 0 0 0
238 2 ▶ && (dot[3] == 'n' || dot[3] == 'N'))
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[3] == 'n' || dot[3] == 'N')) 0 2 2
&& (dot[3] == 'n' || dot[3] == 'N')) 0 0 0
239 24 ▶ || (ext_len == 5
Branch: 1 branch
BranchTrueFalseTotal
|| (ext_len == 5 4 20 24
240 4 ▶ && (dot[0] == 'j' || dot[0] == 'J')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 'j' || dot[0] == 'J') 3 1 4
&& (dot[0] == 'j' || dot[0] == 'J') 1 2 3
241 2 ▶ && (dot[1] == 's' || dot[1] == 'S')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 's' || dot[1] == 'S') 1 1 2
&& (dot[1] == 's' || dot[1] == 'S') 1 0 1
242 2 ▶ && (dot[2] == 'o' || dot[2] == 'O')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[2] == 'o' || dot[2] == 'O') 1 1 2
&& (dot[2] == 'o' || dot[2] == 'O') 1 0 1
243 2 ▶ && (dot[3] == 'n' || dot[3] == 'N')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[3] == 'n' || dot[3] == 'N') 1 1 2
&& (dot[3] == 'n' || dot[3] == 'N') 1 0 1
244 2 ▶ && (dot[4] == 'c' || dot[4] == 'C'))) {
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[4] == 'c' || dot[4] == 'C'))) { 1 1 2
&& (dot[4] == 'c' || dot[4] == 'C'))) { 1 0 1
245 4 RETVAL = newSVpvs("json");
246 22 ▶ } else if (ext_len == 4
Branch: 1 branch
BranchTrueFalseTotal
} else if (ext_len == 4 8 14 22
247 8 ▶ && (dot[0] == 'j' || dot[0] == 'J')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 'j' || dot[0] == 'J') 7 1 8
&& (dot[0] == 'j' || dot[0] == 'J') 1 6 7
248 2 ▶ && (dot[1] == 'a' || dot[1] == 'A')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 'a' || dot[1] == 'A') 1 1 2
&& (dot[1] == 'a' || dot[1] == 'A') 1 0 1
249 2 ▶ && (dot[2] == 'v' || dot[2] == 'V')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[2] == 'v' || dot[2] == 'V') 1 1 2
&& (dot[2] == 'v' || dot[2] == 'V') 1 0 1
250 2 ▶ && (dot[3] == 'a' || dot[3] == 'A')) {
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[3] == 'a' || dot[3] == 'A')) { 1 1 2
&& (dot[3] == 'a' || dot[3] == 'A')) { 1 0 1
251 2 RETVAL = newSVpvs("java");
252 20 ▶ } else if ((ext_len == 3
Branch: 1 branch
BranchTrueFalseTotal
} else if ((ext_len == 3 9 11 20
253 9 ▶ && (dot[0] == 'p' || dot[0] == 'P')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 'p' || dot[0] == 'P') 7 2 9
&& (dot[0] == 'p' || dot[0] == 'P') 2 5 7
254 4 ▶ && (dot[1] == 'h' || dot[1] == 'H')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 'h' || dot[1] == 'H') 2 2 4
&& (dot[1] == 'h' || dot[1] == 'H') 2 0 2
255 4 ▶ && (dot[2] == 'p' || dot[2] == 'P'))
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[2] == 'p' || dot[2] == 'P')) 2 2 4
&& (dot[2] == 'p' || dot[2] == 'P')) 0 2 2
256 16 ▶ || (ext_len == 5
Branch: 1 branch
BranchTrueFalseTotal
|| (ext_len == 5 2 14 16
257 2 ▶ && (dot[0] == 'p' || dot[0] == 'P')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 'p' || dot[0] == 'P') 0 2 2
&& (dot[0] == 'p' || dot[0] == 'P') 0 0 0
258 2 ▶ && (dot[1] == 'h' || dot[1] == 'H')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 'h' || dot[1] == 'H') 0 2 2
&& (dot[1] == 'h' || dot[1] == 'H') 0 0 0
259 2 ▶ && (dot[2] == 't' || dot[2] == 'T')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[2] == 't' || dot[2] == 'T') 0 2 2
&& (dot[2] == 't' || dot[2] == 'T') 0 0 0
260 2 ▶ && (dot[3] == 'm' || dot[3] == 'M')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[3] == 'm' || dot[3] == 'M') 0 2 2
&& (dot[3] == 'm' || dot[3] == 'M') 0 0 0
261 2 ▶ && (dot[4] == 'l' || dot[4] == 'L'))
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[4] == 'l' || dot[4] == 'L')) 0 2 2
&& (dot[4] == 'l' || dot[4] == 'L')) 0 0 0
262 14 ▶ || (ext_len == 4
Branch: 1 branch
BranchTrueFalseTotal
|| (ext_len == 4 6 8 14
263 6 ▶ && (dot[0] == 'p' || dot[0] == 'P')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 'p' || dot[0] == 'P') 2 4 6
&& (dot[0] == 'p' || dot[0] == 'P') 0 2 2
264 4 ▶ && (dot[1] == 'h' || dot[1] == 'H')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 'h' || dot[1] == 'H') 1 3 4
&& (dot[1] == 'h' || dot[1] == 'H') 0 1 1
265 3 ▶ && (dot[2] == 'p' || dot[2] == 'P')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[2] == 'p' || dot[2] == 'P') 0 3 3
&& (dot[2] == 'p' || dot[2] == 'P') 0 0 0
266 3 ▶ && (dot[3] >= '3' && dot[3] <= '5'))) {
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[3] >= '3' && dot[3] <= '5'))) { 3 0 3
&& (dot[3] >= '3' && dot[3] <= '5'))) { 3 0 3
267 9 RETVAL = newSVpvs("php");
268 11 ▶ } else if ((ext_len == 2
Branch: 1 branch
BranchTrueFalseTotal
} else if ((ext_len == 2 3 8 11
269 3 ▶ && (dot[0] == 'r' || dot[0] == 'R')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 'r' || dot[0] == 'R') 2 1 3
&& (dot[0] == 'r' || dot[0] == 'R') 1 1 2
270 2 ▶ && (dot[1] == 'b' || dot[1] == 'B'))
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 'b' || dot[1] == 'B')) 1 1 2
&& (dot[1] == 'b' || dot[1] == 'B')) 0 1 1
271 9 ▶ || (ext_len == 4
Branch: 1 branch
BranchTrueFalseTotal
|| (ext_len == 4 3 6 9
272 3 ▶ && (dot[0] == 'r' || dot[0] == 'R')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 'r' || dot[0] == 'R') 2 1 3
&& (dot[0] == 'r' || dot[0] == 'R') 0 2 2
273 1 ▶ && (dot[1] == 'a' || dot[1] == 'A')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 'a' || dot[1] == 'A') 0 1 1
&& (dot[1] == 'a' || dot[1] == 'A') 0 0 0
274 1 ▶ && (dot[2] == 'k' || dot[2] == 'K')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[2] == 'k' || dot[2] == 'K') 0 1 1
&& (dot[2] == 'k' || dot[2] == 'K') 0 0 0
275 1 ▶ && (dot[3] == 'e' || dot[3] == 'E'))) {
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[3] == 'e' || dot[3] == 'E'))) { 0 1 1
&& (dot[3] == 'e' || dot[3] == 'E'))) { 0 0 0
276 3 RETVAL = newSVpvs("ruby");
277 8 ▶ } else if ((ext_len == 3
Branch: 1 branch
BranchTrueFalseTotal
} else if ((ext_len == 3 5 3 8
278 5 ▶ && (dot[0] == 's' || dot[0] == 'S')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 's' || dot[0] == 'S') 4 1 5
&& (dot[0] == 's' || dot[0] == 'S') 1 3 4
279 2 ▶ && (dot[1] == 'q' || dot[1] == 'Q')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 'q' || dot[1] == 'Q') 1 1 2
&& (dot[1] == 'q' || dot[1] == 'Q') 1 0 1
280 2 ▶ && (dot[2] == 'l' || dot[2] == 'L'))
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[2] == 'l' || dot[2] == 'L')) 1 1 2
&& (dot[2] == 'l' || dot[2] == 'L')) 0 1 1
281 6 ▶ || (ext_len == 4
Branch: 1 branch
BranchTrueFalseTotal
|| (ext_len == 4 2 4 6
282 2 ▶ && (dot[0] == 'p' || dot[0] == 'P')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 'p' || dot[0] == 'P') 1 1 2
&& (dot[0] == 'p' || dot[0] == 'P') 0 1 1
283 1 ▶ && (dot[1] == 's' || dot[1] == 'S')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 's' || dot[1] == 'S') 0 1 1
&& (dot[1] == 's' || dot[1] == 'S') 0 0 0
284 1 ▶ && (dot[2] == 'q' || dot[2] == 'Q')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[2] == 'q' || dot[2] == 'Q') 0 1 1
&& (dot[2] == 'q' || dot[2] == 'Q') 0 0 0
285 1 ▶ && (dot[3] == 'l' || dot[3] == 'L'))
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[3] == 'l' || dot[3] == 'L')) 0 1 1
&& (dot[3] == 'l' || dot[3] == 'L')) 0 0 0
286 5 ▶ || (ext_len == 3
Branch: 1 branch
BranchTrueFalseTotal
|| (ext_len == 3 3 2 5
287 3 ▶ && (dot[0] == 'd' || dot[0] == 'D')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 'd' || dot[0] == 'D') 2 1 3
&& (dot[0] == 'd' || dot[0] == 'D') 0 2 2
288 1 ▶ && (dot[1] == 'd' || dot[1] == 'D')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 'd' || dot[1] == 'D') 0 1 1
&& (dot[1] == 'd' || dot[1] == 'D') 0 0 0
289 1 ▶ && (dot[2] == 'l' || dot[2] == 'L'))) {
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[2] == 'l' || dot[2] == 'L'))) { 0 1 1
&& (dot[2] == 'l' || dot[2] == 'L'))) { 0 0 0
290 4 RETVAL = newSVpvs("sql");
291 }
292 /* yaml */
293 99 ▶ if (!RETVAL &&
Branch: 2 branches
BranchTrueFalseTotal
if (!RETVAL && 0 99 99
if (!RETVAL && 0 0 0
294 ((ext_len == 4
295 0 ▶ && (dot[0] == 'y' || dot[0] == 'Y')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 'y' || dot[0] == 'Y') 0 0 0
&& (dot[0] == 'y' || dot[0] == 'Y') 0 0 0
296 0 ▶ && (dot[1] == 'a' || dot[1] == 'A')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 'a' || dot[1] == 'A') 0 0 0
&& (dot[1] == 'a' || dot[1] == 'A') 0 0 0
297 0 ▶ && (dot[2] == 'm' || dot[2] == 'M')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[2] == 'm' || dot[2] == 'M') 0 0 0
&& (dot[2] == 'm' || dot[2] == 'M') 0 0 0
298 0 ▶ && (dot[3] == 'l' || dot[3] == 'L'))
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[3] == 'l' || dot[3] == 'L')) 0 0 0
&& (dot[3] == 'l' || dot[3] == 'L')) 0 0 0
299 0 ▶ || (ext_len == 3
Branch: 1 branch
BranchTrueFalseTotal
|| (ext_len == 3 0 0 0
300 0 ▶ && (dot[0] == 'y' || dot[0] == 'Y')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[0] == 'y' || dot[0] == 'Y') 0 0 0
&& (dot[0] == 'y' || dot[0] == 'Y') 0 0 0
301 0 ▶ && (dot[1] == 'm' || dot[1] == 'M')
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[1] == 'm' || dot[1] == 'M') 0 0 0
&& (dot[1] == 'm' || dot[1] == 'M') 0 0 0
302 0 ▶ && (dot[2] == 'l' || dot[2] == 'L')))) {
Branch: 2 branches
BranchTrueFalseTotal
&& (dot[2] == 'l' || dot[2] == 'L')))) { 0 0 0
&& (dot[2] == 'l' || dot[2] == 'L')))) { 0 0 0
303 0 RETVAL = newSVpvs("yaml");
304 }
305 } else {
306 /* no dot: check for special filenames */
307 4 const char *base = filename;
308 {
309 4 const char *q = filename + len;
310 35 ▶ while (q > filename && *(q-1) != '/' && *(q-1) != '\\') q--;
Branch: 3 branches
BranchTrueFalseTotal
while (q > filename && *(q-1) != '/' && *(q-1) != '\\') q--; 31 4 35
while (q > filename && *(q-1) != '/' && *(q-1) != '\\') q--; 31 0 31
while (q > filename && *(q-1) != '/' && *(q-1) != '\\') q--; 31 0 31
311 4 base = q;
312 }
313 4 ▶ if (strcmp(base, "Gemfile") == 0 ||
Branch: 1 branch
BranchTrueFalseTotal
if (strcmp(base, "Gemfile") == 0 || 3 1 4
314 3 ▶ strcmp(base, "Rakefile") == 0 ||
Branch: 1 branch
BranchTrueFalseTotal
strcmp(base, "Rakefile") == 0 || 2 1 3
315 2 ▶ strcmp(base, "Guardfile") == 0) {
Branch: 1 branch
BranchTrueFalseTotal
strcmp(base, "Guardfile") == 0) { 0 2 2
316 2 RETVAL = newSVpvs("ruby");
317 }
318 }
319 }
320 }
321 OUTPUT:
322 RETVAL
323  
324 SV *
325 indent_c(class, src_sv, ...)
326 SV * class
327 SV * src_sv
328 CODE:
329 {
330 const char *src;
331 STRLEN src_len;
332 eshu_config_t cfg;
333 char *result;
334 size_t out_len;
335 int i;
336  
337 PERL_UNUSED_VAR(class);
338 150 src = SvPV(src_sv, src_len);
339 150 cfg = eshu_default_config();
340  
341 157 ▶ for (i = 2; i + 1 < items; i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 2; i + 1 < items; i += 2) { 7 150 157
342 7 const char *key = SvPV_nolen(ST(i));
343 7 SV *val = ST(i + 1);
344 7 ▶ if (strEQ(key, "indent_char")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(key, "indent_char")) { 1 6 7
345 1 const char *ic = SvPV_nolen(val);
346 1 ▶ cfg.indent_char = (*ic == ' ') ? ' ' : '\t';
Branch: 1 branch
BranchTrueFalseTotal
cfg.indent_char = (*ic == ' ') ? ' ' : '\t'; 1 0 1
347 6 ▶ } else if (strEQ(key, "indent_width")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "indent_width")) { 1 5 6
348 1 cfg.indent_width = SvIV(val);
349 5 ▶ } else if (strEQ(key, "indent_pp")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "indent_pp")) { 1 4 5
350 1 cfg.indent_pp = SvTRUE(val) ? 1 : 0;
351 4 ▶ } else if (strEQ(key, "range_start")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "range_start")) { 2 2 4
352 2 cfg.range_start = SvIV(val);
353 2 ▶ } else if (strEQ(key, "range_end")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "range_end")) { 2 0 2
354 2 cfg.range_end = SvIV(val);
355 }
356 }
357  
358 150 result = eshu_indent_c(src, (size_t)src_len, &cfg, &out_len);
359 150 RETVAL = newSVpvn(result, out_len);
360 150 free(result);
361 }
362 OUTPUT:
363 RETVAL
364  
365 SV *
366 indent_pl(class, src_sv, ...)
367 SV * class
368 SV * src_sv
369 CODE:
370 {
371 const char *src;
372 STRLEN src_len;
373 eshu_config_t cfg;
374 char *result;
375 size_t out_len;
376 int i;
377  
378 PERL_UNUSED_VAR(class);
379 233 src = SvPV(src_sv, src_len);
380 233 cfg = eshu_default_config();
381 233 cfg.lang = ESHU_LANG_PERL;
382  
383 241 ▶ for (i = 2; i + 1 < items; i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 2; i + 1 < items; i += 2) { 8 233 241
384 8 const char *key = SvPV_nolen(ST(i));
385 8 SV *val = ST(i + 1);
386 8 ▶ if (strEQ(key, "indent_char")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(key, "indent_char")) { 3 5 8
387 3 const char *ic = SvPV_nolen(val);
388 3 ▶ cfg.indent_char = (*ic == ' ') ? ' ' : '\t';
Branch: 1 branch
BranchTrueFalseTotal
cfg.indent_char = (*ic == ' ') ? ' ' : '\t'; 3 0 3
389 5 ▶ } else if (strEQ(key, "indent_width")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "indent_width")) { 3 2 5
390 3 cfg.indent_width = SvIV(val);
391 2 ▶ } else if (strEQ(key, "range_start")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "range_start")) { 1 1 2
392 1 cfg.range_start = SvIV(val);
393 1 ▶ } else if (strEQ(key, "range_end")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "range_end")) { 1 0 1
394 1 cfg.range_end = SvIV(val);
395 }
396 }
397  
398 233 result = eshu_indent_pl(src, (size_t)src_len, &cfg, &out_len);
399 233 RETVAL = newSVpvn(result, out_len);
400 233 free(result);
401 }
402 OUTPUT:
403 RETVAL
404  
405 SV *
406 indent_xs(class, src_sv, ...)
407 SV * class
408 SV * src_sv
409 CODE:
410 {
411 const char *src;
412 STRLEN src_len;
413 eshu_config_t cfg;
414 char *result;
415 size_t out_len;
416 int i;
417  
418 PERL_UNUSED_VAR(class);
419 94 src = SvPV(src_sv, src_len);
420 94 cfg = eshu_default_config();
421 94 cfg.lang = ESHU_LANG_XS;
422  
423 97 ▶ for (i = 2; i + 1 < items; i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 2; i + 1 < items; i += 2) { 3 94 97
424 3 const char *key = SvPV_nolen(ST(i));
425 3 SV *val = ST(i + 1);
426 3 ▶ if (strEQ(key, "indent_char")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(key, "indent_char")) { 1 2 3
427 1 const char *ic = SvPV_nolen(val);
428 1 ▶ cfg.indent_char = (*ic == ' ') ? ' ' : '\t';
Branch: 1 branch
BranchTrueFalseTotal
cfg.indent_char = (*ic == ' ') ? ' ' : '\t'; 1 0 1
429 2 ▶ } else if (strEQ(key, "indent_width")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "indent_width")) { 1 1 2
430 1 cfg.indent_width = SvIV(val);
431 1 ▶ } else if (strEQ(key, "indent_pp")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "indent_pp")) { 1 0 1
432 1 cfg.indent_pp = SvTRUE(val) ? 1 : 0;
433 0 ▶ } else if (strEQ(key, "range_start")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "range_start")) { 0 0 0
434 0 cfg.range_start = SvIV(val);
435 0 ▶ } else if (strEQ(key, "range_end")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "range_end")) { 0 0 0
436 0 cfg.range_end = SvIV(val);
437 }
438 }
439  
440 94 result = eshu_indent_xs(src, (size_t)src_len, &cfg, &out_len);
441 94 RETVAL = newSVpvn(result, out_len);
442 94 free(result);
443 }
444 OUTPUT:
445 RETVAL
446  
447 SV *
448 indent_xml(class, src_sv, ...)
449 SV * class
450 SV * src_sv
451 CODE:
452 {
453 const char *src;
454 STRLEN src_len;
455 eshu_config_t cfg;
456 char *result;
457 size_t out_len;
458 int i;
459  
460 PERL_UNUSED_VAR(class);
461 111 src = SvPV(src_sv, src_len);
462 111 cfg = eshu_default_config();
463 111 cfg.lang = ESHU_LANG_XML;
464  
465 125 ▶ for (i = 2; i + 1 < items; i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 2; i + 1 < items; i += 2) { 14 111 125
466 14 const char *key = SvPV_nolen(ST(i));
467 14 SV *val = ST(i + 1);
468 14 ▶ if (strEQ(key, "indent_char")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(key, "indent_char")) { 2 12 14
469 2 const char *ic = SvPV_nolen(val);
470 2 ▶ cfg.indent_char = (*ic == ' ') ? ' ' : '\t';
Branch: 1 branch
BranchTrueFalseTotal
cfg.indent_char = (*ic == ' ') ? ' ' : '\t'; 2 0 2
471 12 ▶ } else if (strEQ(key, "indent_width")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "indent_width")) { 2 10 12
472 2 cfg.indent_width = SvIV(val);
473 10 ▶ } else if (strEQ(key, "lang")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "lang")) { 8 2 10
474 8 const char *l = SvPV_nolen(val);
475 8 ▶ if (strEQ(l, "html") || strEQ(l, "htm")) {
Branch: 2 branches
BranchTrueFalseTotal
if (strEQ(l, "html") || strEQ(l, "htm")) { 0 8 8
if (strEQ(l, "html") || strEQ(l, "htm")) { 0 0 0
476 8 cfg.lang = ESHU_LANG_HTML;
477 }
478 2 ▶ } else if (strEQ(key, "range_start")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "range_start")) { 1 1 2
479 1 cfg.range_start = SvIV(val);
480 1 ▶ } else if (strEQ(key, "range_end")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "range_end")) { 1 0 1
481 1 cfg.range_end = SvIV(val);
482 }
483 }
484  
485 111 result = eshu_indent_xml(src, (size_t)src_len, &cfg, &out_len);
486 111 RETVAL = newSVpvn(result, out_len);
487 111 free(result);
488 }
489 OUTPUT:
490 RETVAL
491  
492 SV *
493 indent_html(class, src_sv, ...)
494 SV * class
495 SV * src_sv
496 CODE:
497 {
498 const char *src;
499 STRLEN src_len;
500 eshu_config_t cfg;
501 char *result;
502 size_t out_len;
503 int i;
504  
505 PERL_UNUSED_VAR(class);
506 79 src = SvPV(src_sv, src_len);
507 79 cfg = eshu_default_config();
508 79 cfg.lang = ESHU_LANG_HTML;
509  
510 81 ▶ for (i = 2; i + 1 < items; i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 2; i + 1 < items; i += 2) { 2 79 81
511 2 const char *key = SvPV_nolen(ST(i));
512 2 SV *val = ST(i + 1);
513 2 ▶ if (strEQ(key, "indent_char")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(key, "indent_char")) { 1 1 2
514 1 const char *ic = SvPV_nolen(val);
515 1 ▶ cfg.indent_char = (*ic == ' ') ? ' ' : '\t';
Branch: 1 branch
BranchTrueFalseTotal
cfg.indent_char = (*ic == ' ') ? ' ' : '\t'; 1 0 1
516 1 ▶ } else if (strEQ(key, "indent_width")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "indent_width")) { 1 0 1
517 1 cfg.indent_width = SvIV(val);
518 0 ▶ } else if (strEQ(key, "range_start")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "range_start")) { 0 0 0
519 0 cfg.range_start = SvIV(val);
520 0 ▶ } else if (strEQ(key, "range_end")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "range_end")) { 0 0 0
521 0 cfg.range_end = SvIV(val);
522 }
523 }
524  
525 79 result = eshu_indent_xml(src, (size_t)src_len, &cfg, &out_len);
526 79 RETVAL = newSVpvn(result, out_len);
527 79 free(result);
528 }
529 OUTPUT:
530 RETVAL
531  
532 SV *
533 indent_css(class, src_sv, ...)
534 SV * class
535 SV * src_sv
536 CODE:
537 {
538 const char *src;
539 STRLEN src_len;
540 eshu_config_t cfg;
541 char *result;
542 size_t out_len;
543 int i;
544  
545 PERL_UNUSED_VAR(class);
546 116 src = SvPV(src_sv, src_len);
547 116 cfg = eshu_default_config();
548 116 cfg.lang = ESHU_LANG_CSS;
549  
550 122 ▶ for (i = 2; i + 1 < items; i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 2; i + 1 < items; i += 2) { 6 116 122
551 6 const char *key = SvPV_nolen(ST(i));
552 6 SV *val = ST(i + 1);
553 6 ▶ if (strEQ(key, "indent_char")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(key, "indent_char")) { 2 4 6
554 2 const char *ic = SvPV_nolen(val);
555 2 ▶ cfg.indent_char = (*ic == ' ') ? ' ' : '\t';
Branch: 1 branch
BranchTrueFalseTotal
cfg.indent_char = (*ic == ' ') ? ' ' : '\t'; 2 0 2
556 4 ▶ } else if (strEQ(key, "indent_width")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "indent_width")) { 2 2 4
557 2 cfg.indent_width = SvIV(val);
558 2 ▶ } else if (strEQ(key, "range_start")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "range_start")) { 1 1 2
559 1 cfg.range_start = SvIV(val);
560 1 ▶ } else if (strEQ(key, "range_end")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "range_end")) { 1 0 1
561 1 cfg.range_end = SvIV(val);
562 }
563 }
564  
565 116 result = eshu_indent_css(src, (size_t)src_len, &cfg, &out_len);
566 116 RETVAL = newSVpvn(result, out_len);
567 116 free(result);
568 }
569 OUTPUT:
570 RETVAL
571  
572 SV *
573 indent_js(class, src_sv, ...)
574 SV * class
575 SV * src_sv
576 CODE:
577 {
578 const char *src;
579 STRLEN src_len;
580 eshu_config_t cfg;
581 char *result;
582 size_t out_len;
583 int i;
584  
585 PERL_UNUSED_VAR(class);
586 136 src = SvPV(src_sv, src_len);
587 136 cfg = eshu_default_config();
588 136 cfg.lang = ESHU_LANG_JS;
589  
590 144 ▶ for (i = 2; i + 1 < items; i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 2; i + 1 < items; i += 2) { 8 136 144
591 8 const char *key = SvPV_nolen(ST(i));
592 8 SV *val = ST(i + 1);
593 8 ▶ if (strEQ(key, "indent_char")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(key, "indent_char")) { 2 6 8
594 2 const char *ic = SvPV_nolen(val);
595 2 ▶ cfg.indent_char = (*ic == ' ') ? ' ' : '\t';
Branch: 1 branch
BranchTrueFalseTotal
cfg.indent_char = (*ic == ' ') ? ' ' : '\t'; 2 0 2
596 6 ▶ } else if (strEQ(key, "indent_width")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "indent_width")) { 2 4 6
597 2 cfg.indent_width = SvIV(val);
598 4 ▶ } else if (strEQ(key, "range_start")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "range_start")) { 2 2 4
599 2 cfg.range_start = SvIV(val);
600 2 ▶ } else if (strEQ(key, "range_end")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "range_end")) { 2 0 2
601 2 cfg.range_end = SvIV(val);
602 }
603 }
604  
605 136 result = eshu_indent_js(src, (size_t)src_len, &cfg, &out_len);
606 136 RETVAL = newSVpvn(result, out_len);
607 136 free(result);
608 }
609 OUTPUT:
610 RETVAL
611  
612 SV *
613 indent_ts(class, src_sv, ...)
614 SV * class
615 SV * src_sv
616 CODE:
617 {
618 const char *src;
619 STRLEN src_len;
620 eshu_config_t cfg;
621 char *result;
622 size_t out_len;
623 int i;
624  
625 PERL_UNUSED_VAR(class);
626 67 src = SvPV(src_sv, src_len);
627 67 cfg = eshu_default_config();
628 67 cfg.lang = ESHU_LANG_TS;
629  
630 201 ▶ for (i = 2; i + 1 < items; i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 2; i + 1 < items; i += 2) { 134 67 201
631 134 const char *key = SvPV_nolen(ST(i));
632 134 SV *val = ST(i + 1);
633 134 ▶ if (strEQ(key, "indent_char")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(key, "indent_char")) { 67 67 134
634 67 const char *ic = SvPV_nolen(val);
635 67 ▶ cfg.indent_char = (*ic == ' ') ? ' ' : '\t';
Branch: 1 branch
BranchTrueFalseTotal
cfg.indent_char = (*ic == ' ') ? ' ' : '\t'; 67 0 67
636 67 ▶ } else if (strEQ(key, "indent_width")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "indent_width")) { 67 0 67
637 67 cfg.indent_width = SvIV(val);
638 0 ▶ } else if (strEQ(key, "range_start")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "range_start")) { 0 0 0
639 0 cfg.range_start = SvIV(val);
640 0 ▶ } else if (strEQ(key, "range_end")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "range_end")) { 0 0 0
641 0 cfg.range_end = SvIV(val);
642 }
643 }
644  
645 67 result = eshu_indent_ts(src, (size_t)src_len, &cfg, &out_len);
646 67 RETVAL = newSVpvn(result, out_len);
647 67 free(result);
648 }
649 OUTPUT:
650 RETVAL
651  
652 SV *
653 highlight_ts(class, src_sv)
654 SV * class
655 SV * src_sv
656 CODE:
657 {
658 const char *src;
659 STRLEN src_len;
660 size_t result_len;
661 char *result;
662  
663 PERL_UNUSED_VAR(class);
664 50 src = SvPV(src_sv, src_len);
665 50 result = eshu_highlight_ts(src, (size_t)src_len, &result_len);
666 50 RETVAL = newSVpvn(result, result_len);
667 50 SvUTF8_on(RETVAL);
668 50 free(result);
669 }
670 OUTPUT:
671 RETVAL
672  
673 SV *
674 indent_pod(class, src_sv, ...)
675 SV * class
676 SV * src_sv
677 CODE:
678 {
679 const char *src;
680 STRLEN src_len;
681 eshu_config_t cfg;
682 char *result;
683 size_t out_len;
684 int i;
685  
686 PERL_UNUSED_VAR(class);
687 76 src = SvPV(src_sv, src_len);
688 76 cfg = eshu_default_config();
689 76 cfg.lang = ESHU_LANG_POD;
690  
691 80 ▶ for (i = 2; i + 1 < items; i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 2; i + 1 < items; i += 2) { 4 76 80
692 4 const char *key = SvPV_nolen(ST(i));
693 4 SV *val = ST(i + 1);
694 4 ▶ if (strEQ(key, "indent_char")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(key, "indent_char")) { 1 3 4
695 1 const char *ic = SvPV_nolen(val);
696 1 ▶ cfg.indent_char = (*ic == ' ') ? ' ' : '\t';
Branch: 1 branch
BranchTrueFalseTotal
cfg.indent_char = (*ic == ' ') ? ' ' : '\t'; 1 0 1
697 3 ▶ } else if (strEQ(key, "indent_width")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "indent_width")) { 1 2 3
698 1 cfg.indent_width = SvIV(val);
699 2 ▶ } else if (strEQ(key, "range_start")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "range_start")) { 1 1 2
700 1 cfg.range_start = SvIV(val);
701 1 ▶ } else if (strEQ(key, "range_end")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "range_end")) { 1 0 1
702 1 cfg.range_end = SvIV(val);
703 }
704 }
705  
706 76 result = eshu_indent_pod(src, (size_t)src_len, &cfg, &out_len);
707 76 RETVAL = newSVpvn(result, out_len);
708 76 free(result);
709 }
710 OUTPUT:
711 RETVAL
712  
713 SV *
714 indent_python(class, src_sv, ...)
715 SV * class
716 SV * src_sv
717 CODE:
718 {
719 const char *src;
720 STRLEN src_len;
721 eshu_config_t cfg;
722 char *result;
723 size_t out_len;
724 int i;
725  
726 PERL_UNUSED_VAR(class);
727 135 src = SvPV(src_sv, src_len);
728 135 cfg = eshu_default_config();
729 135 cfg.lang = ESHU_LANG_PYTHON;
730 135 cfg.indent_char = ' ';
731 135 cfg.indent_width = 4;
732  
733 405 ▶ for (i = 2; i + 1 < items; i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 2; i + 1 < items; i += 2) { 270 135 405
734 270 const char *key = SvPV_nolen(ST(i));
735 270 SV *val = ST(i + 1);
736 270 ▶ if (strEQ(key, "indent_char")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(key, "indent_char")) { 135 135 270
737 135 const char *ic = SvPV_nolen(val);
738 135 ▶ cfg.indent_char = (*ic == '\t') ? '\t' : ' ';
Branch: 1 branch
BranchTrueFalseTotal
cfg.indent_char = (*ic == '\t') ? '\t' : ' '; 1 134 135
739 135 ▶ } else if (strEQ(key, "indent_width")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "indent_width")) { 135 0 135
740 135 cfg.indent_width = SvIV(val);
741 0 ▶ } else if (strEQ(key, "range_start")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "range_start")) { 0 0 0
742 0 cfg.range_start = SvIV(val);
743 0 ▶ } else if (strEQ(key, "range_end")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "range_end")) { 0 0 0
744 0 cfg.range_end = SvIV(val);
745 }
746 }
747  
748 135 result = eshu_indent_python(src, (size_t)src_len, &cfg, &out_len);
749 135 RETVAL = newSVpvn(result, out_len);
750 135 free(result);
751 }
752 OUTPUT:
753 RETVAL
754  
755 SV *
756 indent_bash(class, src_sv, ...)
757 SV * class
758 SV * src_sv
759 CODE:
760 {
761 const char *src;
762 STRLEN src_len;
763 eshu_config_t cfg;
764 char *result;
765 size_t out_len;
766 int i;
767  
768 PERL_UNUSED_VAR(class);
769 78 src = SvPV(src_sv, src_len);
770 78 cfg = eshu_default_config();
771 78 cfg.lang = ESHU_LANG_BASH;
772  
773 80 ▶ for (i = 2; i + 1 < items; i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 2; i + 1 < items; i += 2) { 2 78 80
774 2 const char *key = SvPV_nolen(ST(i));
775 2 SV *val = ST(i + 1);
776 2 ▶ if (strEQ(key, "indent_char")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(key, "indent_char")) { 1 1 2
777 1 const char *ic = SvPV_nolen(val);
778 1 ▶ cfg.indent_char = (*ic == ' ') ? ' ' : '\t';
Branch: 1 branch
BranchTrueFalseTotal
cfg.indent_char = (*ic == ' ') ? ' ' : '\t'; 1 0 1
779 1 ▶ } else if (strEQ(key, "indent_width")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "indent_width")) { 1 0 1
780 1 cfg.indent_width = SvIV(val);
781 0 ▶ } else if (strEQ(key, "range_start")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "range_start")) { 0 0 0
782 0 cfg.range_start = SvIV(val);
783 0 ▶ } else if (strEQ(key, "range_end")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "range_end")) { 0 0 0
784 0 cfg.range_end = SvIV(val);
785 }
786 }
787  
788 78 result = eshu_indent_bash(src, (size_t)src_len, &cfg, &out_len);
789 78 RETVAL = newSVpvn(result, out_len);
790 78 free(result);
791 }
792 OUTPUT:
793 RETVAL
794  
795 SV *
796 highlight_bash(class, src_sv)
797 SV * class
798 SV * src_sv
799 CODE:
800 {
801 const char *src;
802 STRLEN src_len;
803 char *result;
804 size_t result_len;
805  
806 PERL_UNUSED_VAR(class);
807 32 src = SvPV(src_sv, src_len);
808 32 result = eshu_highlight_bash(src, (size_t)src_len, &result_len);
809 32 RETVAL = newSVpvn(result, result_len);
810 32 free(result);
811 }
812 OUTPUT:
813 RETVAL
814  
815 SV *
816 indent_go(class, src_sv, ...)
817 SV * class
818 SV * src_sv
819 CODE:
820 {
821 const char *src;
822 STRLEN src_len;
823 eshu_config_t cfg;
824 char *result;
825 size_t out_len;
826 int i;
827  
828 PERL_UNUSED_VAR(class);
829 89 src = SvPV(src_sv, src_len);
830 89 cfg = eshu_default_config();
831 89 cfg.lang = ESHU_LANG_GO;
832  
833 91 ▶ for (i = 2; i + 1 < items; i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 2; i + 1 < items; i += 2) { 2 89 91
834 2 const char *key = SvPV_nolen(ST(i));
835 2 SV *val = ST(i + 1);
836 2 ▶ if (strEQ(key, "indent_char")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(key, "indent_char")) { 1 1 2
837 1 const char *ic = SvPV_nolen(val);
838 1 ▶ cfg.indent_char = (*ic == ' ') ? ' ' : '\t';
Branch: 1 branch
BranchTrueFalseTotal
cfg.indent_char = (*ic == ' ') ? ' ' : '\t'; 1 0 1
839 1 ▶ } else if (strEQ(key, "indent_width")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "indent_width")) { 1 0 1
840 1 cfg.indent_width = SvIV(val);
841 0 ▶ } else if (strEQ(key, "range_start")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "range_start")) { 0 0 0
842 0 cfg.range_start = SvIV(val);
843 0 ▶ } else if (strEQ(key, "range_end")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "range_end")) { 0 0 0
844 0 cfg.range_end = SvIV(val);
845 }
846 }
847  
848 89 result = eshu_indent_go(src, (size_t)src_len, &cfg, &out_len);
849 89 RETVAL = newSVpvn(result, out_len);
850 89 free(result);
851 }
852 OUTPUT:
853 RETVAL
854  
855 SV *
856 highlight_go(class, src_sv)
857 SV * class
858 SV * src_sv
859 CODE:
860 {
861 const char *src;
862 STRLEN src_len;
863 char *result;
864 size_t result_len;
865  
866 PERL_UNUSED_VAR(class);
867 37 src = SvPV(src_sv, src_len);
868 37 result = eshu_highlight_go(src, (size_t)src_len, &result_len);
869 37 RETVAL = newSVpvn(result, result_len);
870 37 free(result);
871 }
872 OUTPUT:
873 RETVAL
874  
875 SV *
876 indent_json(class, src_sv, ...)
877 SV * class
878 SV * src_sv
879 CODE:
880 {
881 const char *src;
882 STRLEN src_len;
883 eshu_config_t cfg;
884 char *result;
885 size_t out_len;
886 int i;
887  
888 PERL_UNUSED_VAR(class);
889 110 src = SvPV(src_sv, src_len);
890 110 cfg = eshu_default_config();
891 110 cfg.lang = ESHU_LANG_JSON;
892 110 cfg.indent_char = ' ';
893 110 cfg.indent_width = 2;
894  
895 327 ▶ for (i = 2; i + 1 < items; i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 2; i + 1 < items; i += 2) { 217 110 327
896 217 const char *key = SvPV_nolen(ST(i));
897 217 SV *val = ST(i + 1);
898 217 ▶ if (strEQ(key, "indent_char")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(key, "indent_char")) { 109 108 217
899 109 const char *ic = SvPV_nolen(val);
900 109 ▶ cfg.indent_char = (*ic == '\t') ? '\t' : ' ';
Branch: 1 branch
BranchTrueFalseTotal
cfg.indent_char = (*ic == '\t') ? '\t' : ' '; 2 107 109
901 108 ▶ } else if (strEQ(key, "indent_width")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "indent_width")) { 108 0 108
902 108 cfg.indent_width = SvIV(val);
903 }
904 }
905  
906 110 result = eshu_indent_json(src, (size_t)src_len, &cfg, &out_len);
907 110 RETVAL = newSVpvn(result, out_len);
908 110 free(result);
909 }
910 OUTPUT:
911 RETVAL
912  
913 SV *
914 highlight_json(class, src_sv)
915 SV * class
916 SV * src_sv
917 CODE:
918 {
919 const char *src;
920 STRLEN src_len;
921 char *result;
922 size_t result_len;
923  
924 PERL_UNUSED_VAR(class);
925 0 src = SvPV(src_sv, src_len);
926 0 result = eshu_highlight_json(src, (size_t)src_len, &result_len);
927 0 RETVAL = newSVpvn(result, result_len);
928 0 free(result);
929 }
930 OUTPUT:
931 RETVAL
932  
933 SV *
934 indent_java(class, src_sv, ...)
935 SV * class
936 SV * src_sv
937 CODE:
938 {
939 const char *src;
940 STRLEN src_len;
941 eshu_config_t cfg;
942 char *result;
943 size_t out_len;
944 int i;
945  
946 PERL_UNUSED_VAR(class);
947 89 src = SvPV(src_sv, src_len);
948 89 cfg = eshu_default_config();
949 89 cfg.lang = ESHU_LANG_JAVA;
950 89 cfg.indent_char = ' ';
951 89 cfg.indent_width = 4;
952  
953 265 ▶ for (i = 2; i + 1 < items; i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 2; i + 1 < items; i += 2) { 176 89 265
954 176 const char *key = SvPV_nolen(ST(i));
955 176 SV *val = ST(i + 1);
956 176 ▶ if (strEQ(key, "indent_char")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(key, "indent_char")) { 88 88 176
957 88 const char *ic = SvPV_nolen(val);
958 88 ▶ cfg.indent_char = (*ic == '\t') ? '\t' : ' ';
Branch: 1 branch
BranchTrueFalseTotal
cfg.indent_char = (*ic == '\t') ? '\t' : ' '; 0 88 88
959 88 ▶ } else if (strEQ(key, "indent_width")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "indent_width")) { 88 0 88
960 88 cfg.indent_width = SvIV(val);
961 0 ▶ } else if (strEQ(key, "range_start")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "range_start")) { 0 0 0
962 0 cfg.range_start = SvIV(val);
963 0 ▶ } else if (strEQ(key, "range_end")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "range_end")) { 0 0 0
964 0 cfg.range_end = SvIV(val);
965 }
966 }
967  
968 89 result = eshu_indent_java(src, (size_t)src_len, &cfg, &out_len);
969 89 RETVAL = newSVpvn(result, out_len);
970 89 free(result);
971 }
972 OUTPUT:
973 RETVAL
974  
975 SV *
976 highlight_java(class, src_sv)
977 SV * class
978 SV * src_sv
979 CODE:
980 {
981 const char *src;
982 STRLEN src_len;
983 char *result;
984 size_t result_len;
985  
986 PERL_UNUSED_VAR(class);
987 0 src = SvPV(src_sv, src_len);
988 0 result = eshu_highlight_java(src, (size_t)src_len, &result_len);
989 0 RETVAL = newSVpvn(result, result_len);
990 0 free(result);
991 }
992 OUTPUT:
993 RETVAL
994  
995 SV *
996 indent_lua(class, src_sv, ...)
997 SV * class
998 SV * src_sv
999 CODE:
1000 {
1001 const char *src;
1002 STRLEN src_len;
1003 eshu_config_t cfg;
1004 char *result;
1005 size_t out_len;
1006 int i;
1007  
1008 PERL_UNUSED_VAR(class);
1009 76 src = SvPV(src_sv, src_len);
1010 76 cfg = eshu_default_config();
1011 76 cfg.lang = ESHU_LANG_LUA;
1012  
1013 76 ▶ for (i = 2; i + 1 < items; i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 2; i + 1 < items; i += 2) { 0 76 76
1014 0 const char *key = SvPV_nolen(ST(i));
1015 0 SV *val = ST(i + 1);
1016 0 ▶ if (strEQ(key, "indent_char")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(key, "indent_char")) { 0 0 0
1017 0 const char *ic = SvPV_nolen(val);
1018 0 ▶ cfg.indent_char = (*ic == ' ') ? ' ' : '\t';
Branch: 1 branch
BranchTrueFalseTotal
cfg.indent_char = (*ic == ' ') ? ' ' : '\t'; 0 0 0
1019 0 ▶ } else if (strEQ(key, "indent_width")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "indent_width")) { 0 0 0
1020 0 cfg.indent_width = SvIV(val);
1021 0 ▶ } else if (strEQ(key, "range_start")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "range_start")) { 0 0 0
1022 0 cfg.range_start = SvIV(val);
1023 0 ▶ } else if (strEQ(key, "range_end")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "range_end")) { 0 0 0
1024 0 cfg.range_end = SvIV(val);
1025 }
1026 }
1027  
1028 76 result = eshu_indent_lua(src, (size_t)src_len, &cfg, &out_len);
1029 76 RETVAL = newSVpvn(result, out_len);
1030 76 free(result);
1031 }
1032 OUTPUT:
1033 RETVAL
1034  
1035 SV *
1036 highlight_lua(class, src_sv)
1037 SV * class
1038 SV * src_sv
1039 CODE:
1040 {
1041 const char *src;
1042 STRLEN src_len;
1043 char *result;
1044 size_t result_len;
1045  
1046 PERL_UNUSED_VAR(class);
1047 0 src = SvPV(src_sv, src_len);
1048 0 result = eshu_highlight_lua(src, (size_t)src_len, &result_len);
1049 0 RETVAL = newSVpvn(result, result_len);
1050 0 free(result);
1051 }
1052 OUTPUT:
1053 RETVAL
1054  
1055 SV *
1056 indent_rust(class, src_sv, ...)
1057 SV * class
1058 SV * src_sv
1059 CODE:
1060 {
1061 const char *src;
1062 STRLEN src_len;
1063 eshu_config_t cfg;
1064 char *result;
1065 size_t out_len;
1066 int i;
1067  
1068 PERL_UNUSED_VAR(class);
1069 79 src = SvPV(src_sv, src_len);
1070 79 cfg = eshu_default_config();
1071 79 cfg.lang = ESHU_LANG_RUST;
1072  
1073 79 ▶ for (i = 2; i + 1 < items; i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 2; i + 1 < items; i += 2) { 0 79 79
1074 0 const char *key = SvPV_nolen(ST(i));
1075 0 SV *val = ST(i + 1);
1076 0 ▶ if (strEQ(key, "indent_char")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(key, "indent_char")) { 0 0 0
1077 0 const char *ic = SvPV_nolen(val);
1078 0 ▶ cfg.indent_char = (*ic == ' ') ? ' ' : '\t';
Branch: 1 branch
BranchTrueFalseTotal
cfg.indent_char = (*ic == ' ') ? ' ' : '\t'; 0 0 0
1079 0 ▶ } else if (strEQ(key, "indent_width")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "indent_width")) { 0 0 0
1080 0 cfg.indent_width = SvIV(val);
1081 0 ▶ } else if (strEQ(key, "range_start")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "range_start")) { 0 0 0
1082 0 cfg.range_start = SvIV(val);
1083 0 ▶ } else if (strEQ(key, "range_end")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "range_end")) { 0 0 0
1084 0 cfg.range_end = SvIV(val);
1085 }
1086 }
1087  
1088 79 result = eshu_indent_rust(src, (size_t)src_len, &cfg, &out_len);
1089 79 RETVAL = newSVpvn(result, out_len);
1090 79 free(result);
1091 }
1092 OUTPUT:
1093 RETVAL
1094  
1095 SV *
1096 highlight_rust(class, src_sv)
1097 SV * class
1098 SV * src_sv
1099 CODE:
1100 {
1101 const char *src;
1102 STRLEN src_len;
1103 char *result;
1104 size_t result_len;
1105  
1106 PERL_UNUSED_VAR(class);
1107 53 src = SvPV(src_sv, src_len);
1108 53 result = eshu_highlight_rust(src, (size_t)src_len, &result_len);
1109 53 RETVAL = newSVpvn(result, result_len);
1110 53 free(result);
1111 }
1112 OUTPUT:
1113 RETVAL
1114  
1115 SV *
1116 indent_php(class, src_sv, ...)
1117 SV * class
1118 SV * src_sv
1119 CODE:
1120 {
1121 const char *src;
1122 STRLEN src_len;
1123 eshu_config_t cfg;
1124 char *result;
1125 size_t out_len;
1126 int i;
1127  
1128 PERL_UNUSED_VAR(class);
1129 81 src = SvPV(src_sv, src_len);
1130 81 cfg = eshu_default_config();
1131 81 cfg.lang = ESHU_LANG_PHP;
1132 81 cfg.indent_char = ' ';
1133 81 cfg.indent_width = 4;
1134  
1135 242 ▶ for (i = 2; i + 1 < items; i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 2; i + 1 < items; i += 2) { 161 81 242
1136 161 const char *key = SvPV_nolen(ST(i));
1137 161 SV *val = ST(i + 1);
1138 161 ▶ if (strEQ(key, "indent_char")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(key, "indent_char")) { 81 80 161
1139 81 const char *ic = SvPV_nolen(val);
1140 81 ▶ cfg.indent_char = (*ic == ' ') ? ' ' : '\t';
Branch: 1 branch
BranchTrueFalseTotal
cfg.indent_char = (*ic == ' ') ? ' ' : '\t'; 80 1 81
1141 80 ▶ } else if (strEQ(key, "indent_width")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "indent_width")) { 80 0 80
1142 80 cfg.indent_width = SvIV(val);
1143 0 ▶ } else if (strEQ(key, "range_start")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "range_start")) { 0 0 0
1144 0 cfg.range_start = SvIV(val);
1145 0 ▶ } else if (strEQ(key, "range_end")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "range_end")) { 0 0 0
1146 0 cfg.range_end = SvIV(val);
1147 }
1148 }
1149  
1150 81 result = eshu_indent_php(src, (size_t)src_len, &cfg, &out_len);
1151 81 RETVAL = newSVpvn(result, out_len);
1152 81 free(result);
1153 }
1154 OUTPUT:
1155 RETVAL
1156  
1157 SV *
1158 highlight_php(class, src_sv)
1159 SV * class
1160 SV * src_sv
1161 CODE:
1162 {
1163 const char *src;
1164 STRLEN src_len;
1165 char *result;
1166 size_t result_len;
1167  
1168 PERL_UNUSED_VAR(class);
1169 46 src = SvPV(src_sv, src_len);
1170 46 result = eshu_highlight_php(src, (size_t)src_len, &result_len);
1171 46 RETVAL = newSVpvn(result, result_len);
1172 46 free(result);
1173 }
1174 OUTPUT:
1175 RETVAL
1176  
1177 SV *
1178 indent_ruby(class, src_sv, ...)
1179 SV * class
1180 SV * src_sv
1181 CODE:
1182 {
1183 const char *src;
1184 STRLEN src_len;
1185 eshu_config_t cfg;
1186 char *result;
1187 size_t out_len;
1188 int i;
1189  
1190 PERL_UNUSED_VAR(class);
1191 82 src = SvPV(src_sv, src_len);
1192 82 cfg = eshu_default_config();
1193 82 cfg.lang = ESHU_LANG_RUBY;
1194 82 cfg.indent_char = ' ';
1195 82 cfg.indent_width = 2;
1196  
1197 246 ▶ for (i = 2; i + 1 < items; i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 2; i + 1 < items; i += 2) { 164 82 246
1198 164 const char *key = SvPV_nolen(ST(i));
1199 164 SV *val = ST(i + 1);
1200 164 ▶ if (strEQ(key, "indent_char")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(key, "indent_char")) { 82 82 164
1201 82 const char *ic = SvPV_nolen(val);
1202 82 ▶ cfg.indent_char = (*ic == ' ') ? ' ' : '\t';
Branch: 1 branch
BranchTrueFalseTotal
cfg.indent_char = (*ic == ' ') ? ' ' : '\t'; 82 0 82
1203 82 ▶ } else if (strEQ(key, "indent_width")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "indent_width")) { 82 0 82
1204 82 cfg.indent_width = SvIV(val);
1205 0 ▶ } else if (strEQ(key, "range_start")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "range_start")) { 0 0 0
1206 0 cfg.range_start = SvIV(val);
1207 0 ▶ } else if (strEQ(key, "range_end")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "range_end")) { 0 0 0
1208 0 cfg.range_end = SvIV(val);
1209 }
1210 }
1211  
1212 82 result = eshu_indent_ruby(src, (size_t)src_len, &cfg, &out_len);
1213 82 RETVAL = newSVpvn(result, out_len);
1214 82 free(result);
1215 }
1216 OUTPUT:
1217 RETVAL
1218  
1219 SV *
1220 highlight_ruby(class, src_sv)
1221 SV * class
1222 SV * src_sv
1223 CODE:
1224 {
1225 const char *src;
1226 STRLEN src_len;
1227 char *result;
1228 size_t result_len;
1229  
1230 PERL_UNUSED_VAR(class);
1231 47 src = SvPV(src_sv, src_len);
1232 47 result = eshu_highlight_ruby(src, (size_t)src_len, &result_len);
1233 47 RETVAL = newSVpvn(result, result_len);
1234 47 free(result);
1235 }
1236 OUTPUT:
1237 RETVAL
1238  
1239 SV *
1240 indent_sql(class, src_sv, ...)
1241 SV * class
1242 SV * src_sv
1243 CODE:
1244 {
1245 const char *src;
1246 STRLEN src_len;
1247 eshu_config_t cfg;
1248 char *result;
1249 size_t out_len;
1250 int i;
1251  
1252 PERL_UNUSED_VAR(class);
1253 69 src = SvPV(src_sv, src_len);
1254 69 cfg = eshu_default_config();
1255 69 cfg.lang = ESHU_LANG_SQL;
1256 69 cfg.indent_char = ' ';
1257 69 cfg.indent_width = 4;
1258  
1259 69 ▶ for (i = 2; i + 1 < items; i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 2; i + 1 < items; i += 2) { 0 69 69
1260 0 const char *key = SvPV_nolen(ST(i));
1261 0 SV *val = ST(i + 1);
1262 0 ▶ if (strEQ(key, "indent_char")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(key, "indent_char")) { 0 0 0
1263 0 const char *ic = SvPV_nolen(val);
1264 0 ▶ cfg.indent_char = (*ic == '\t') ? '\t' : ' ';
Branch: 1 branch
BranchTrueFalseTotal
cfg.indent_char = (*ic == '\t') ? '\t' : ' '; 0 0 0
1265 0 ▶ } else if (strEQ(key, "indent_width")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "indent_width")) { 0 0 0
1266 0 cfg.indent_width = SvIV(val);
1267 0 ▶ } else if (strEQ(key, "range_start")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "range_start")) { 0 0 0
1268 0 cfg.range_start = SvIV(val);
1269 0 ▶ } else if (strEQ(key, "range_end")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "range_end")) { 0 0 0
1270 0 cfg.range_end = SvIV(val);
1271 }
1272 }
1273  
1274 69 result = eshu_indent_sql(src, (size_t)src_len, &cfg, &out_len);
1275 69 RETVAL = newSVpvn(result, out_len);
1276 69 free(result);
1277 }
1278 OUTPUT:
1279 RETVAL
1280  
1281 SV *
1282 highlight_sql(class, src_sv)
1283 SV * class
1284 SV * src_sv
1285 CODE:
1286 {
1287 const char *src;
1288 STRLEN src_len;
1289 char *result;
1290 size_t result_len;
1291  
1292 PERL_UNUSED_VAR(class);
1293 42 src = SvPV(src_sv, src_len);
1294 42 result = eshu_highlight_sql(src, (size_t)src_len, &result_len);
1295 42 RETVAL = newSVpvn(result, result_len);
1296 42 free(result);
1297 }
1298 OUTPUT:
1299 RETVAL
1300  
1301 SV *
1302 indent_yaml(class, src_sv, ...)
1303 SV * class
1304 SV * src_sv
1305 CODE:
1306 {
1307 const char *src;
1308 STRLEN src_len;
1309 eshu_config_t cfg;
1310 char *result;
1311 size_t out_len;
1312 int i;
1313  
1314 PERL_UNUSED_VAR(class);
1315 81 src = SvPV(src_sv, src_len);
1316 81 cfg = eshu_default_config();
1317 81 cfg.lang = ESHU_LANG_YAML;
1318 81 cfg.indent_char = ' ';
1319 81 cfg.indent_width = 2;
1320  
1321 81 ▶ for (i = 2; i + 1 < items; i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 2; i + 1 < items; i += 2) { 0 81 81
1322 0 const char *key = SvPV_nolen(ST(i));
1323 0 SV *val = ST(i + 1);
1324 0 ▶ if (strEQ(key, "indent_char")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(key, "indent_char")) { 0 0 0
1325 0 const char *ic = SvPV_nolen(val);
1326 0 ▶ cfg.indent_char = (*ic == '\t') ? '\t' : ' ';
Branch: 1 branch
BranchTrueFalseTotal
cfg.indent_char = (*ic == '\t') ? '\t' : ' '; 0 0 0
1327 0 ▶ } else if (strEQ(key, "indent_width")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "indent_width")) { 0 0 0
1328 0 cfg.indent_width = SvIV(val);
1329 0 ▶ } else if (strEQ(key, "range_start")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "range_start")) { 0 0 0
1330 0 cfg.range_start = SvIV(val);
1331 0 ▶ } else if (strEQ(key, "range_end")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "range_end")) { 0 0 0
1332 0 cfg.range_end = SvIV(val);
1333 }
1334 }
1335  
1336 81 result = eshu_indent_yaml(src, (size_t)src_len, &cfg, &out_len);
1337 81 RETVAL = newSVpvn(result, out_len);
1338 81 free(result);
1339 }
1340 OUTPUT:
1341 RETVAL
1342  
1343 SV *
1344 highlight_yaml(class, src_sv)
1345 SV * class
1346 SV * src_sv
1347 CODE:
1348 {
1349 const char *src;
1350 STRLEN src_len;
1351 char *result;
1352 size_t result_len;
1353  
1354 PERL_UNUSED_VAR(class);
1355 35 src = SvPV(src_sv, src_len);
1356 35 result = eshu_highlight_yaml(src, (size_t)src_len, &result_len);
1357 35 RETVAL = newSVpvn(result, result_len);
1358 35 free(result);
1359 }
1360 OUTPUT:
1361 RETVAL
1362  
1363 SV *
1364 indent_string(class, src_sv, ...)
1365 SV * class
1366 SV * src_sv
1367 CODE:
1368 {
1369 const char *src;
1370 STRLEN src_len;
1371 eshu_config_t cfg;
1372 char *result;
1373 size_t out_len;
1374 51 const char *lang = "c";
1375 int i;
1376  
1377 PERL_UNUSED_VAR(class);
1378 51 src = SvPV(src_sv, src_len);
1379 51 cfg = eshu_default_config();
1380  
1381 112 ▶ for (i = 2; i + 1 < items; i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 2; i + 1 < items; i += 2) { 61 51 112
1382 61 const char *key = SvPV_nolen(ST(i));
1383 61 SV *val = ST(i + 1);
1384 61 ▶ if (strEQ(key, "lang")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(key, "lang")) { 51 10 61
1385 51 lang = SvPV_nolen(val);
1386 10 ▶ } else if (strEQ(key, "indent_char")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "indent_char")) { 5 5 10
1387 5 const char *ic = SvPV_nolen(val);
1388 5 ▶ cfg.indent_char = (*ic == ' ') ? ' ' : '\t';
Branch: 1 branch
BranchTrueFalseTotal
cfg.indent_char = (*ic == ' ') ? ' ' : '\t'; 4 1 5
1389 5 ▶ } else if (strEQ(key, "indent_width")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "indent_width")) { 5 0 5
1390 5 cfg.indent_width = SvIV(val);
1391 0 ▶ } else if (strEQ(key, "indent_pp")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "indent_pp")) { 0 0 0
1392 0 cfg.indent_pp = SvTRUE(val) ? 1 : 0;
1393 0 ▶ } else if (strEQ(key, "range_start")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "range_start")) { 0 0 0
1394 0 cfg.range_start = SvIV(val);
1395 0 ▶ } else if (strEQ(key, "range_end")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "range_end")) { 0 0 0
1396 0 cfg.range_end = SvIV(val);
1397 }
1398 }
1399  
1400 51 ▶ if (strEQ(lang, "c")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(lang, "c")) { 11 40 51
1401 11 result = eshu_indent_c(src, (size_t)src_len, &cfg, &out_len);
1402 40 ▶ } else if (strEQ(lang, "perl") || strEQ(lang, "pl")) {
Branch: 2 branches
BranchTrueFalseTotal
} else if (strEQ(lang, "perl") || strEQ(lang, "pl")) { 38 2 40
} else if (strEQ(lang, "perl") || strEQ(lang, "pl")) { 1 37 38
1403 3 cfg.lang = ESHU_LANG_PERL;
1404 3 result = eshu_indent_pl(src, (size_t)src_len, &cfg, &out_len);
1405 37 ▶ } else if (strEQ(lang, "xs")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(lang, "xs")) { 2 35 37
1406 2 cfg.lang = ESHU_LANG_XS;
1407 2 result = eshu_indent_xs(src, (size_t)src_len, &cfg, &out_len);
1408 35 ▶ } else if (strEQ(lang, "xml") || strEQ(lang, "svg")) {
Branch: 2 branches
BranchTrueFalseTotal
} else if (strEQ(lang, "xml") || strEQ(lang, "svg")) { 33 2 35
} else if (strEQ(lang, "xml") || strEQ(lang, "svg")) { 1 32 33
1409 3 cfg.lang = ESHU_LANG_XML;
1410 3 result = eshu_indent_xml(src, (size_t)src_len, &cfg, &out_len);
1411 32 ▶ } else if (strEQ(lang, "html") || strEQ(lang, "htm")) {
Branch: 2 branches
BranchTrueFalseTotal
} else if (strEQ(lang, "html") || strEQ(lang, "htm")) { 30 2 32
} else if (strEQ(lang, "html") || strEQ(lang, "htm")) { 1 29 30
1412 3 cfg.lang = ESHU_LANG_HTML;
1413 3 result = eshu_indent_xml(src, (size_t)src_len, &cfg, &out_len);
1414 29 ▶ } else if (strEQ(lang, "css") || strEQ(lang, "scss") || strEQ(lang, "less")) {
Branch: 3 branches
BranchTrueFalseTotal
} else if (strEQ(lang, "css") || strEQ(lang, "scss") || strEQ(lang, "less")) { 27 2 29
} else if (strEQ(lang, "css") || strEQ(lang, "scss") || strEQ(lang, "less")) { 26 1 27
} else if (strEQ(lang, "css") || strEQ(lang, "scss") || strEQ(lang, "less")) { 1 25 26
1415 4 cfg.lang = ESHU_LANG_CSS;
1416 4 result = eshu_indent_css(src, (size_t)src_len, &cfg, &out_len);
1417 25 ▶ } else if (strEQ(lang, "js") || strEQ(lang, "javascript") ||
Branch: 2 branches
BranchTrueFalseTotal
} else if (strEQ(lang, "js") || strEQ(lang, "javascript") || 23 2 25
} else if (strEQ(lang, "js") || strEQ(lang, "javascript") || 21 2 23
1418 21 ▶ strEQ(lang, "jsx") || strEQ(lang, "mjs") ||
Branch: 2 branches
BranchTrueFalseTotal
strEQ(lang, "jsx") || strEQ(lang, "mjs") || 20 1 21
strEQ(lang, "jsx") || strEQ(lang, "mjs") || 19 1 20
1419 19 ▶ strEQ(lang, "cjs")) {
Branch: 1 branch
BranchTrueFalseTotal
strEQ(lang, "cjs")) { 1 18 19
1420 7 cfg.lang = ESHU_LANG_JS;
1421 7 result = eshu_indent_js(src, (size_t)src_len, &cfg, &out_len);
1422 18 ▶ } else if (strEQ(lang, "ts") || strEQ(lang, "typescript") ||
Branch: 2 branches
BranchTrueFalseTotal
} else if (strEQ(lang, "ts") || strEQ(lang, "typescript") || 15 3 18
} else if (strEQ(lang, "ts") || strEQ(lang, "typescript") || 13 2 15
1423 13 ▶ strEQ(lang, "tsx") || strEQ(lang, "mts")) {
Branch: 2 branches
BranchTrueFalseTotal
strEQ(lang, "tsx") || strEQ(lang, "mts")) { 11 2 13
strEQ(lang, "tsx") || strEQ(lang, "mts")) { 1 10 11
1424 8 cfg.lang = ESHU_LANG_TS;
1425 8 result = eshu_indent_ts(src, (size_t)src_len, &cfg, &out_len);
1426 10 ▶ } else if (strEQ(lang, "pod")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(lang, "pod")) { 2 8 10
1427 2 cfg.lang = ESHU_LANG_POD;
1428 2 result = eshu_indent_pod(src, (size_t)src_len, &cfg, &out_len);
1429 8 ▶ } else if (strEQ(lang, "python") || strEQ(lang, "py")) {
Branch: 2 branches
BranchTrueFalseTotal
} else if (strEQ(lang, "python") || strEQ(lang, "py")) { 7 1 8
} else if (strEQ(lang, "python") || strEQ(lang, "py")) { 1 6 7
1430 2 cfg.lang = ESHU_LANG_PYTHON;
1431 2 cfg.indent_char = ' ';
1432 2 cfg.indent_width = 4;
1433 2 result = eshu_indent_python(src, (size_t)src_len, &cfg, &out_len);
1434 6 ▶ } else if (strEQ(lang, "bash") || strEQ(lang, "sh") ||
Branch: 2 branches
BranchTrueFalseTotal
} else if (strEQ(lang, "bash") || strEQ(lang, "sh") || 6 0 6
} else if (strEQ(lang, "bash") || strEQ(lang, "sh") || 6 0 6
1435 6 ▶ strEQ(lang, "shell") || strEQ(lang, "zsh") ||
Branch: 2 branches
BranchTrueFalseTotal
strEQ(lang, "shell") || strEQ(lang, "zsh") || 6 0 6
strEQ(lang, "shell") || strEQ(lang, "zsh") || 6 0 6
1436 6 ▶ strEQ(lang, "ksh")) {
Branch: 1 branch
BranchTrueFalseTotal
strEQ(lang, "ksh")) { 0 6 6
1437 0 cfg.lang = ESHU_LANG_BASH;
1438 0 result = eshu_indent_bash(src, (size_t)src_len, &cfg, &out_len);
1439 6 ▶ } else if (strEQ(lang, "go")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(lang, "go")) { 0 6 6
1440 0 cfg.lang = ESHU_LANG_GO;
1441 0 result = eshu_indent_go(src, (size_t)src_len, &cfg, &out_len);
1442 6 ▶ } else if (strEQ(lang, "rust") || strEQ(lang, "rs")) {
Branch: 2 branches
BranchTrueFalseTotal
} else if (strEQ(lang, "rust") || strEQ(lang, "rs")) { 6 0 6
} else if (strEQ(lang, "rust") || strEQ(lang, "rs")) { 0 6 6
1443 0 cfg.lang = ESHU_LANG_RUST;
1444 0 result = eshu_indent_rust(src, (size_t)src_len, &cfg, &out_len);
1445 6 ▶ } else if (strEQ(lang, "json") || strEQ(lang, "jsonc")) {
Branch: 2 branches
BranchTrueFalseTotal
} else if (strEQ(lang, "json") || strEQ(lang, "jsonc")) { 5 1 6
} else if (strEQ(lang, "json") || strEQ(lang, "jsonc")) { 0 5 5
1446 1 cfg.lang = ESHU_LANG_JSON;
1447 1 cfg.indent_char = ' ';
1448 1 cfg.indent_width = 2;
1449 1 result = eshu_indent_json(src, (size_t)src_len, &cfg, &out_len);
1450 5 ▶ } else if (strEQ(lang, "java")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(lang, "java")) { 1 4 5
1451 1 cfg.lang = ESHU_LANG_JAVA;
1452 1 cfg.indent_char = ' ';
1453 1 cfg.indent_width = 4;
1454 1 result = eshu_indent_java(src, (size_t)src_len, &cfg, &out_len);
1455 4 ▶ } else if (strEQ(lang, "lua")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(lang, "lua")) { 0 4 4
1456 0 cfg.lang = ESHU_LANG_LUA;
1457 0 result = eshu_indent_lua(src, (size_t)src_len, &cfg, &out_len);
1458 4 ▶ } else if (strEQ(lang, "php") || strEQ(lang, "phtml")) {
Branch: 2 branches
BranchTrueFalseTotal
} else if (strEQ(lang, "php") || strEQ(lang, "phtml")) { 3 1 4
} else if (strEQ(lang, "php") || strEQ(lang, "phtml")) { 0 3 3
1459 1 cfg.lang = ESHU_LANG_PHP;
1460 1 cfg.indent_char = ' ';
1461 1 cfg.indent_width = 4;
1462 1 result = eshu_indent_php(src, (size_t)src_len, &cfg, &out_len);
1463 3 ▶ } else if (strEQ(lang, "ruby") || strEQ(lang, "rb")) {
Branch: 2 branches
BranchTrueFalseTotal
} else if (strEQ(lang, "ruby") || strEQ(lang, "rb")) { 2 1 3
} else if (strEQ(lang, "ruby") || strEQ(lang, "rb")) { 1 1 2
1464 2 cfg.lang = ESHU_LANG_RUBY;
1465 2 cfg.indent_char = ' ';
1466 2 cfg.indent_width = 2;
1467 2 result = eshu_indent_ruby(src, (size_t)src_len, &cfg, &out_len);
1468 1 ▶ } else if (strEQ(lang, "sql") || strEQ(lang, "psql") || strEQ(lang, "ddl")) {
Branch: 3 branches
BranchTrueFalseTotal
} else if (strEQ(lang, "sql") || strEQ(lang, "psql") || strEQ(lang, "ddl")) { 1 0 1
} else if (strEQ(lang, "sql") || strEQ(lang, "psql") || strEQ(lang, "ddl")) { 1 0 1
} else if (strEQ(lang, "sql") || strEQ(lang, "psql") || strEQ(lang, "ddl")) { 0 1 1
1469 0 cfg.lang = ESHU_LANG_SQL;
1470 0 cfg.indent_char = ' ';
1471 0 cfg.indent_width = 4;
1472 0 result = eshu_indent_sql(src, (size_t)src_len, &cfg, &out_len);
1473 1 ▶ } else if (strEQ(lang, "yaml") || strEQ(lang, "yml")) {
Branch: 2 branches
BranchTrueFalseTotal
} else if (strEQ(lang, "yaml") || strEQ(lang, "yml")) { 1 0 1
} else if (strEQ(lang, "yaml") || strEQ(lang, "yml")) { 0 1 1
1474 0 cfg.lang = ESHU_LANG_YAML;
1475 0 cfg.indent_char = ' ';
1476 0 cfg.indent_width = 2;
1477 0 result = eshu_indent_yaml(src, (size_t)src_len, &cfg, &out_len);
1478 } else {
1479 1 croak("Eshu: unsupported language '%s'", lang);
1480 result = NULL; /* not reached */
1481 out_len = 0;
1482 }
1483  
1484 50 RETVAL = newSVpvn(result, out_len);
1485 50 free(result);
1486 }
1487 OUTPUT:
1488 RETVAL
1489  
1490 SV *
1491 indent_file(class, path_sv, ...)
1492 SV * class
1493 SV * path_sv
1494 CODE:
1495 {
1496 const char *path;
1497 STRLEN path_len;
1498 eshu_config_t cfg;
1499 8 const char *force_lang = NULL;
1500 8 int opts = 0;
1501 int i;
1502 eshu_file_result_t res;
1503 HV *hv;
1504  
1505 PERL_UNUSED_VAR(class);
1506 8 path = SvPV(path_sv, path_len);
1507 8 cfg = eshu_default_config();
1508  
1509 11 ▶ for (i = 2; i + 1 < items; i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 2; i + 1 < items; i += 2) { 3 8 11
1510 3 const char *key = SvPV_nolen(ST(i));
1511 3 SV *val = ST(i + 1);
1512 3 ▶ if (strEQ(key, "fix")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(key, "fix")) { 1 2 3
1513 1 ▶ if (SvTRUE(val)) opts |= ESHU_OPT_FIX;
Branch: 1 branch
BranchTrueFalseTotal
if (SvTRUE(val)) opts |= ESHU_OPT_FIX; 1 0 1
1514 2 ▶ } else if (strEQ(key, "diff")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "diff")) { 1 1 2
1515 1 ▶ if (SvTRUE(val)) opts |= ESHU_OPT_DIFF;
Branch: 1 branch
BranchTrueFalseTotal
if (SvTRUE(val)) opts |= ESHU_OPT_DIFF; 1 0 1
1516 1 ▶ } else if (strEQ(key, "lang")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "lang")) { 1 0 1
1517 1 force_lang = SvPV_nolen(val);
1518 0 ▶ } else if (strEQ(key, "indent_char")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "indent_char")) { 0 0 0
1519 0 const char *ic = SvPV_nolen(val);
1520 0 ▶ cfg.indent_char = (*ic == ' ') ? ' ' : '\t';
Branch: 1 branch
BranchTrueFalseTotal
cfg.indent_char = (*ic == ' ') ? ' ' : '\t'; 0 0 0
1521 0 ▶ } else if (strEQ(key, "indent_width")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "indent_width")) { 0 0 0
1522 0 cfg.indent_width = SvIV(val);
1523 0 ▶ } else if (strEQ(key, "indent_pp")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "indent_pp")) { 0 0 0
1524 0 cfg.indent_pp = SvTRUE(val) ? 1 : 0;
1525 0 ▶ } else if (strEQ(key, "range_start")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "range_start")) { 0 0 0
1526 0 cfg.range_start = SvIV(val);
1527 0 ▶ } else if (strEQ(key, "range_end")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "range_end")) { 0 0 0
1528 0 cfg.range_end = SvIV(val);
1529 }
1530 }
1531  
1532 8 eshu_indent_file(path, &cfg, force_lang, opts, &res);
1533  
1534 8 hv = newHV();
1535 8 hv_store(hv, "file", 4, newSVpv(res.file, 0), 0);
1536 8 switch (res.status) {
1537 1 case ESHU_STATUS_UNCHANGED:
1538 1 hv_store(hv, "status", 6, newSVpvs("unchanged"), 0); break;
1539 1 case ESHU_STATUS_CHANGED:
1540 1 hv_store(hv, "status", 6, newSVpvs("changed"), 0); break;
1541 3 case ESHU_STATUS_NEEDS_FIXING:
1542 3 hv_store(hv, "status", 6, newSVpvs("needs_fixing"), 0); break;
1543 2 case ESHU_STATUS_SKIPPED:
1544 2 hv_store(hv, "status", 6, newSVpvs("skipped"), 0); break;
1545 1 case ESHU_STATUS_ERROR:
1546 1 hv_store(hv, "status", 6, newSVpvs("error"), 0); break;
1547 }
1548 8 ▶ if (res.lang)
Branch: 1 branch
BranchTrueFalseTotal
if (res.lang) 5 3 8
1549 5 hv_store(hv, "lang", 4, newSVpv(res.lang, 0), 0);
1550 8 ▶ if (res.reason)
Branch: 1 branch
BranchTrueFalseTotal
if (res.reason) 2 6 8
1551 2 hv_store(hv, "reason", 6, newSVpv(res.reason, 0), 0);
1552 8 ▶ if (res.error)
Branch: 1 branch
BranchTrueFalseTotal
if (res.error) 1 7 8
1553 1 hv_store(hv, "error", 5, newSVpv(res.error, 0), 0);
1554 8 ▶ if (res.diff)
Branch: 1 branch
BranchTrueFalseTotal
if (res.diff) 1 7 8
1555 1 hv_store(hv, "diff", 4, newSVpvn(res.diff, res.diff_len), 0);
1556  
1557 8 eshu_file_result_free(&res);
1558 8 RETVAL = newRV_noinc((SV *)hv);
1559 }
1560 OUTPUT:
1561 RETVAL
1562  
1563 SV *
1564 indent_dir(class, path_sv, ...)
1565 SV * class
1566 SV * path_sv
1567 CODE:
1568 {
1569 const char *path;
1570 STRLEN path_len;
1571 eshu_config_t cfg;
1572 16 const char *force_lang = NULL;
1573 16 int file_opts = 0;
1574 16 int recursive = 1;
1575 int i;
1576 eshu_strlist_t files;
1577 eshu_dir_report_t report;
1578 HV *report_hv;
1579 AV *changes_av;
1580 size_t fi;
1581 16 AV *exclude_av = NULL;
1582 16 AV *include_av = NULL;
1583  
1584 PERL_UNUSED_VAR(class);
1585 16 path = SvPV(path_sv, path_len);
1586 16 cfg = eshu_default_config();
1587  
1588 28 ▶ for (i = 2; i + 1 < items; i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 2; i + 1 < items; i += 2) { 12 16 28
1589 12 const char *key = SvPV_nolen(ST(i));
1590 12 SV *val = ST(i + 1);
1591 12 ▶ if (strEQ(key, "fix")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(key, "fix")) { 5 7 12
1592 5 ▶ if (SvTRUE(val)) file_opts |= ESHU_OPT_FIX;
Branch: 1 branch
BranchTrueFalseTotal
if (SvTRUE(val)) file_opts |= ESHU_OPT_FIX; 5 0 5
1593 7 ▶ } else if (strEQ(key, "diff")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "diff")) { 1 6 7
1594 1 ▶ if (SvTRUE(val)) file_opts |= ESHU_OPT_DIFF;
Branch: 1 branch
BranchTrueFalseTotal
if (SvTRUE(val)) file_opts |= ESHU_OPT_DIFF; 1 0 1
1595 6 ▶ } else if (strEQ(key, "lang")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "lang")) { 0 6 6
1596 0 force_lang = SvPV_nolen(val);
1597 6 ▶ } else if (strEQ(key, "recursive")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "recursive")) { 1 5 6
1598 1 recursive = SvTRUE(val) ? 1 : 0;
1599 5 ▶ } else if (strEQ(key, "exclude")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "exclude")) { 3 2 5
1600 3 ▶ if (SvROK(val) && SvTYPE(SvRV(val)) == SVt_PVAV) {
Branch: 2 branches
BranchTrueFalseTotal
if (SvROK(val) && SvTYPE(SvRV(val)) == SVt_PVAV) { 3 0 3
if (SvROK(val) && SvTYPE(SvRV(val)) == SVt_PVAV) { 1 2 3
1601 1 exclude_av = (AV *)SvRV(val);
1602 } else {
1603 2 exclude_av = newAV();
1604 2 av_push(exclude_av, SvREFCNT_inc(val));
1605 2 sv_2mortal((SV *)exclude_av);
1606 }
1607 2 ▶ } else if (strEQ(key, "include")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "include")) { 2 0 2
1608 2 ▶ if (SvROK(val) && SvTYPE(SvRV(val)) == SVt_PVAV) {
Branch: 2 branches
BranchTrueFalseTotal
if (SvROK(val) && SvTYPE(SvRV(val)) == SVt_PVAV) { 2 0 2
if (SvROK(val) && SvTYPE(SvRV(val)) == SVt_PVAV) { 0 2 2
1609 0 include_av = (AV *)SvRV(val);
1610 } else {
1611 2 include_av = newAV();
1612 2 av_push(include_av, SvREFCNT_inc(val));
1613 2 sv_2mortal((SV *)include_av);
1614 }
1615 0 ▶ } else if (strEQ(key, "indent_char")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "indent_char")) { 0 0 0
1616 0 const char *ic = SvPV_nolen(val);
1617 0 ▶ cfg.indent_char = (*ic == ' ') ? ' ' : '\t';
Branch: 1 branch
BranchTrueFalseTotal
cfg.indent_char = (*ic == ' ') ? ' ' : '\t'; 0 0 0
1618 0 ▶ } else if (strEQ(key, "indent_width")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "indent_width")) { 0 0 0
1619 0 cfg.indent_width = SvIV(val);
1620 0 ▶ } else if (strEQ(key, "indent_pp")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "indent_pp")) { 0 0 0
1621 0 cfg.indent_pp = SvTRUE(val) ? 1 : 0;
1622 }
1623 }
1624  
1625 /* Collect files */
1626 16 eshu_strlist_init(&files);
1627 {
1628 struct stat st;
1629 16 ▶ if (stat(path, &st) == 0 && S_ISREG(st.st_mode)) {
Branch: 2 branches
BranchTrueFalseTotal
if (stat(path, &st) == 0 && S_ISREG(st.st_mode)) { 16 0 16
if (stat(path, &st) == 0 && S_ISREG(st.st_mode)) { 0 16 16
1630 0 eshu_strlist_push(&files, path);
1631 16 ▶ } else if (stat(path, &st) == 0 && S_ISDIR(st.st_mode)) {
Branch: 2 branches
BranchTrueFalseTotal
} else if (stat(path, &st) == 0 && S_ISDIR(st.st_mode)) { 16 0 16
} else if (stat(path, &st) == 0 && S_ISDIR(st.st_mode)) { 16 0 16
1632 16 eshu_walk_dir(path, &files, recursive);
1633 } else {
1634 0 eshu_strlist_free(&files);
1635 0 croak("Eshu: '%s' is not a file or directory", path);
1636 }
1637 }
1638 16 eshu_strlist_sort(&files);
1639  
1640 /* Process files */
1641 16 eshu_dir_report_init(&report);
1642 16 changes_av = newAV();
1643  
1644 62 ▶ for (fi = 0; fi < files.count; fi++) {
Branch: 1 branch
BranchTrueFalseTotal
for (fi = 0; fi < files.count; fi++) { 46 16 62
1645 46 const char *fpath = files.items[fi];
1646 46 int skip = 0;
1647  
1648 /* Exclude filter */
1649 46 ▶ if (exclude_av) {
Branch: 1 branch
BranchTrueFalseTotal
if (exclude_av) { 12 34 46
1650 12 SSize_t j, alen = av_len(exclude_av) + 1;
1651 23 ▶ for (j = 0; j < alen; j++) {
Branch: 1 branch
BranchTrueFalseTotal
for (j = 0; j < alen; j++) { 15 8 23
1652 15 SV **elem = av_fetch(exclude_av, j, 0);
1653 15 ▶ if (elem && SvOK(*elem)) {
Branch: 2 branches
BranchTrueFalseTotal
if (elem && SvOK(*elem)) { 15 0 15
if (elem && SvOK(*elem)) { 15 0 15
1654 15 REGEXP *rx = SvRX(*elem);
1655 15 ▶ if (rx) {
Branch: 1 branch
BranchTrueFalseTotal
if (rx) { 15 0 15
1656 15 SV *file_sv = sv_2mortal(newSVpv(fpath, 0));
1657 45 ▶ if (pregexec(rx, SvPV_nolen(file_sv), SvPV_nolen(file_sv) + strlen(fpath), SvPV_nolen(file_sv), 0, file_sv, 0)) {
Branch: 3 branches
BranchTrueFalseTotal
if (pregexec(rx, SvPV_nolen(file_sv), SvPV_nolen(file_sv) + strlen(fpath), SvPV_nolen(file_sv), 0, file_sv, 0)) { 15 0 15
if (pregexec(rx, SvPV_nolen(file_sv), SvPV_nolen(file_sv) + strlen(fpath), SvPV_nolen(file_sv), 0, file_sv, 0)) { 15 0 15
if (pregexec(rx, SvPV_nolen(file_sv), SvPV_nolen(file_sv) + strlen(fpath), SvPV_nolen(file_sv), 0, file_sv, 0)) { 4 11 15
1658 4 skip = 1; break;
1659 }
1660 }
1661 }
1662 }
1663 }
1664 46 ▶ if (skip) {
Branch: 1 branch
BranchTrueFalseTotal
if (skip) { 4 42 46
1665 4 HV *hv = newHV();
1666 4 hv_store(hv, "file", 4, newSVpv(fpath, 0), 0);
1667 4 hv_store(hv, "status", 6, newSVpvs("skipped"), 0);
1668 4 hv_store(hv, "reason", 6, newSVpvs("excluded"), 0);
1669 4 av_push(changes_av, newRV_noinc((SV *)hv));
1670 4 report.files_skipped++;
1671 4 continue;
1672 }
1673  
1674 /* Include filter */
1675 42 ▶ if (include_av) {
Branch: 1 branch
BranchTrueFalseTotal
if (include_av) { 7 35 42
1676 7 SSize_t j, alen = av_len(include_av) + 1;
1677 7 int matched = 0;
1678 10 ▶ for (j = 0; j < alen; j++) {
Branch: 1 branch
BranchTrueFalseTotal
for (j = 0; j < alen; j++) { 7 3 10
1679 7 SV **elem = av_fetch(include_av, j, 0);
1680 7 ▶ if (elem && SvOK(*elem)) {
Branch: 2 branches
BranchTrueFalseTotal
if (elem && SvOK(*elem)) { 7 0 7
if (elem && SvOK(*elem)) { 7 0 7
1681 7 REGEXP *rx = SvRX(*elem);
1682 7 ▶ if (rx) {
Branch: 1 branch
BranchTrueFalseTotal
if (rx) { 7 0 7
1683 7 SV *file_sv = sv_2mortal(newSVpv(fpath, 0));
1684 21 ▶ if (pregexec(rx, SvPV_nolen(file_sv), SvPV_nolen(file_sv) + strlen(fpath), SvPV_nolen(file_sv), 0, file_sv, 0)) {
Branch: 3 branches
BranchTrueFalseTotal
if (pregexec(rx, SvPV_nolen(file_sv), SvPV_nolen(file_sv) + strlen(fpath), SvPV_nolen(file_sv), 0, file_sv, 0)) { 7 0 7
if (pregexec(rx, SvPV_nolen(file_sv), SvPV_nolen(file_sv) + strlen(fpath), SvPV_nolen(file_sv), 0, file_sv, 0)) { 7 0 7
if (pregexec(rx, SvPV_nolen(file_sv), SvPV_nolen(file_sv) + strlen(fpath), SvPV_nolen(file_sv), 0, file_sv, 0)) { 4 3 7
1685 4 matched = 1; break;
1686 }
1687 }
1688 }
1689 }
1690 7 ▶ if (!matched) {
Branch: 1 branch
BranchTrueFalseTotal
if (!matched) { 3 4 7
1691 3 HV *hv = newHV();
1692 3 hv_store(hv, "file", 4, newSVpv(fpath, 0), 0);
1693 3 hv_store(hv, "status", 6, newSVpvs("skipped"), 0);
1694 3 hv_store(hv, "reason", 6, newSVpvs("not included"), 0);
1695 3 av_push(changes_av, newRV_noinc((SV *)hv));
1696 3 report.files_skipped++;
1697 3 continue;
1698 }
1699 }
1700  
1701 /* Process file */
1702 {
1703 eshu_file_result_t res;
1704 39 HV *hv = newHV();
1705  
1706 39 eshu_indent_file(fpath, &cfg, force_lang, file_opts, &res);
1707  
1708 39 hv_store(hv, "file", 4, newSVpv(res.file, 0), 0);
1709 39 switch (res.status) {
1710 2 case ESHU_STATUS_UNCHANGED:
1711 2 hv_store(hv, "status", 6, newSVpvs("unchanged"), 0); break;
1712 12 case ESHU_STATUS_CHANGED:
1713 12 hv_store(hv, "status", 6, newSVpvs("changed"), 0); break;
1714 22 case ESHU_STATUS_NEEDS_FIXING:
1715 22 hv_store(hv, "status", 6, newSVpvs("needs_fixing"), 0); break;
1716 3 case ESHU_STATUS_SKIPPED:
1717 3 hv_store(hv, "status", 6, newSVpvs("skipped"), 0); break;
1718 0 case ESHU_STATUS_ERROR:
1719 0 hv_store(hv, "status", 6, newSVpvs("error"), 0); break;
1720 }
1721 39 ▶ if (res.lang)
Branch: 1 branch
BranchTrueFalseTotal
if (res.lang) 36 3 39
1722 36 hv_store(hv, "lang", 4, newSVpv(res.lang, 0), 0);
1723 39 ▶ if (res.reason)
Branch: 1 branch
BranchTrueFalseTotal
if (res.reason) 3 36 39
1724 3 hv_store(hv, "reason", 6, newSVpv(res.reason, 0), 0);
1725 39 ▶ if (res.error)
Branch: 1 branch
BranchTrueFalseTotal
if (res.error) 0 39 39
1726 0 hv_store(hv, "error", 5, newSVpv(res.error, 0), 0);
1727 39 ▶ if (res.diff)
Branch: 1 branch
BranchTrueFalseTotal
if (res.diff) 1 38 39
1728 1 hv_store(hv, "diff", 4, newSVpvn(res.diff, res.diff_len), 0);
1729  
1730 39 ▶ if (res.status == ESHU_STATUS_CHANGED || res.status == ESHU_STATUS_NEEDS_FIXING) {
Branch: 2 branches
BranchTrueFalseTotal
if (res.status == ESHU_STATUS_CHANGED || res.status == ESHU_STATUS_NEEDS_FIXING) { 27 12 39
if (res.status == ESHU_STATUS_CHANGED || res.status == ESHU_STATUS_NEEDS_FIXING) { 22 5 27
1731 34 report.files_changed++;
1732 34 report.files_checked++;
1733 5 ▶ } else if (res.status == ESHU_STATUS_UNCHANGED) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (res.status == ESHU_STATUS_UNCHANGED) { 2 3 5
1734 2 report.files_checked++;
1735 3 ▶ } else if (res.status == ESHU_STATUS_SKIPPED) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (res.status == ESHU_STATUS_SKIPPED) { 3 0 3
1736 3 report.files_skipped++;
1737 0 ▶ } else if (res.status == ESHU_STATUS_ERROR) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (res.status == ESHU_STATUS_ERROR) { 0 0 0
1738 0 report.files_errored++;
1739 }
1740  
1741 39 eshu_file_result_free(&res);
1742 39 av_push(changes_av, newRV_noinc((SV *)hv));
1743 }
1744 }
1745  
1746 16 eshu_strlist_free(&files);
1747  
1748 16 report_hv = newHV();
1749 16 hv_store(report_hv, "files_checked", 13, newSViv(report.files_checked), 0);
1750 16 hv_store(report_hv, "files_changed", 13, newSViv(report.files_changed), 0);
1751 16 hv_store(report_hv, "files_skipped", 13, newSViv(report.files_skipped), 0);
1752 16 hv_store(report_hv, "files_errored", 13, newSViv(report.files_errored), 0);
1753 16 hv_store(report_hv, "changes", 7, newRV_noinc((SV *)changes_av), 0);
1754  
1755 16 free(report.changes);
1756  
1757 16 RETVAL = newRV_noinc((SV *)report_hv);
1758 }
1759 OUTPUT:
1760 RETVAL
1761  
1762 SV *
1763 highlight_string(class, src_sv, ...)
1764 SV * class
1765 SV * src_sv
1766 CODE:
1767 {
1768 const char *src;
1769 STRLEN src_len;
1770 498 const char *lang = "c";
1771 char *result;
1772 size_t result_len;
1773 int i;
1774  
1775 PERL_UNUSED_VAR(class);
1776 498 src = SvPV(src_sv, src_len);
1777 996 ▶ for (i = 2; i < items; i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 2; i < items; i += 2) { 498 498 996
1778 498 const char *key = SvPV_nolen(ST(i));
1779 498 ▶ if (strEQ(key, "lang") && i + 1 < items)
Branch: 2 branches
BranchTrueFalseTotal
if (strEQ(key, "lang") && i + 1 < items) 498 0 498
if (strEQ(key, "lang") && i + 1 < items) 498 0 498
1780 996 lang = SvPV_nolen(ST(i + 1));
1781 }
1782 498 result = eshu_highlight(src, (size_t)src_len, lang, &result_len);
1783 498 RETVAL = newSVpvn(result, result_len);
1784 498 free(result);
1785 }
1786 OUTPUT:
1787 RETVAL
« include/eshu_hl.h ↑ Summary include/eshu_lua.h »