escape_ansi.c

filter: Statementstmt 93.7% 15 / 16 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 85.0% 17 / 20 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« escape_chars.c ↑ Summary
1 /*
2 * This file was generated automatically by ExtUtils::ParseXS version 3.63 from the
3 * contents of escape_ansi.xs. Do not edit this file, edit escape_ansi.xs instead.
4 *
5 * ANY CHANGES MADE HERE WILL BE LOST!
6 *
7 */
8  
9 #line 1 "escape_ansi.xs"
10 /*
11 * escape_ansi.xs
12 * --------------
13 * Functions for escaping non-printable characters.
14 *
15 *
16 * Copyright 2008, 2009 Sebastien Aperghis-Tramoni
17 *
18 * This program is free software; you can redistribute it
19 * and/or modify it under the same terms as Perl itself.
20 */
21  
22 /* Perl includes */
23 #include "EXTERN.h"
24 #include "perl.h"
25 #include "XSUB.h"
26  
27 /* escape_ansi */
28 #include "escape_chars.h"
29  
30  
31 #line 32 "escape_ansi.c"
32 #ifndef PERL_UNUSED_VAR
33 # define PERL_UNUSED_VAR(var) if (0) var = var
34 #endif
35  
36 #ifndef dVAR
37 # define dVAR dNOOP
38 #endif
39  
40  
41 /* This stuff is not part of the API! You have been warned. */
42 #ifndef PERL_VERSION_DECIMAL
43 # define PERL_VERSION_DECIMAL(r,v,s) (r*1000000 + v*1000 + s)
44 #endif
45 #ifndef PERL_DECIMAL_VERSION
46 # define PERL_DECIMAL_VERSION \
47 PERL_VERSION_DECIMAL(PERL_REVISION,PERL_VERSION,PERL_SUBVERSION)
48 #endif
49 #ifndef PERL_VERSION_GE
50 # define PERL_VERSION_GE(r,v,s) \
51 (PERL_DECIMAL_VERSION >= PERL_VERSION_DECIMAL(r,v,s))
52 #endif
53 #ifndef PERL_VERSION_LE
54 # define PERL_VERSION_LE(r,v,s) \
55 (PERL_DECIMAL_VERSION <= PERL_VERSION_DECIMAL(r,v,s))
56 #endif
57  
58 /* XS_INTERNAL is the explicit static-linkage variant of the default
59 * XS macro.
60 *
61 * XS_EXTERNAL is the same as XS_INTERNAL except it does not include
62 * "static", ie. it exports XSUB symbols. You probably don't want that
63 * for anything but the BOOT XSUB.
64 *
65 * See XSUB.h in core!
66 */
67  
68  
69 /* TODO: This might be compatible further back than 5.10.0. */
70 #if PERL_VERSION_GE(5, 10, 0) && PERL_VERSION_LE(5, 15, 1)
71 # undef XS_EXTERNAL
72 # undef XS_INTERNAL
73 # if defined(__CYGWIN__) && defined(USE_DYNAMIC_LOADING)
74 # define XS_EXTERNAL(name) __declspec(dllexport) XSPROTO(name)
75 # define XS_INTERNAL(name) static XSPROTO(name)
76 # endif
77 # if defined(__SYMBIAN32__)
78 # define XS_EXTERNAL(name) EXPORT_C XSPROTO(name)
79 # define XS_INTERNAL(name) EXPORT_C static XSPROTO(name)
80 # endif
81 # ifndef XS_EXTERNAL
82 # if defined(HASATTRIBUTE_UNUSED) && !defined(__cplusplus)
83 # define XS_EXTERNAL(name) void name(pTHX_ CV* cv __attribute__unused__)
84 # define XS_INTERNAL(name) static void name(pTHX_ CV* cv __attribute__unused__)
85 # else
86 # ifdef __cplusplus
87 # define XS_EXTERNAL(name) extern "C" XSPROTO(name)
88 # define XS_INTERNAL(name) static XSPROTO(name)
89 # else
90 # define XS_EXTERNAL(name) XSPROTO(name)
91 # define XS_INTERNAL(name) static XSPROTO(name)
92 # endif
93 # endif
94 # endif
95 #endif
96  
97 /* perl >= 5.10.0 && perl <= 5.15.1 */
98  
99  
100 /* The XS_EXTERNAL macro is used for functions that must not be static
101 * like the boot XSUB of a module. If perl didn't have an XS_EXTERNAL
102 * macro defined, the best we can do is assume XS is the same.
103 * Dito for XS_INTERNAL.
104 */
105 #ifndef XS_EXTERNAL
106 # define XS_EXTERNAL(name) XS(name)
107 #endif
108 #ifndef XS_INTERNAL
109 # define XS_INTERNAL(name) XS(name)
110 #endif
111  
112 /* Now, finally, after all this mess, we want an ExtUtils::ParseXS
113 * internal macro that we're free to redefine for varying linkage due
114 * to the EXPORT_XSUB_SYMBOLS XS keyword. This is internal, use
115 * XS_EXTERNAL(name) or XS_INTERNAL(name) in your code if you need to!
116 */
117  
118 #undef XS_EUPXS
119 #if defined(PERL_EUPXS_ALWAYS_EXPORT)
120 # define XS_EUPXS(name) XS_EXTERNAL(name)
121 #else
122 /* default to internal */
123 # define XS_EUPXS(name) XS_INTERNAL(name)
124 #endif
125  
126 #ifndef PERL_ARGS_ASSERT_CROAK_XS_USAGE
127 #define PERL_ARGS_ASSERT_CROAK_XS_USAGE assert(cv); assert(params)
128  
129 /* prototype to pass -Wmissing-prototypes */
130 static void
131 S_croak_xs_usage(const CV *const cv, const char *const params);
132  
133 static void
134 S_croak_xs_usage(const CV *const cv, const char *const params)
135 {
136 const GV *const gv = CvGV(cv);
137  
138 PERL_ARGS_ASSERT_CROAK_XS_USAGE;
139  
140 if (gv) {
141 const char *const gvname = GvNAME(gv);
142 const HV *const stash = GvSTASH(gv);
143 const char *const hvname = stash ? HvNAME(stash) : NULL;
144  
145 if (hvname)
146 Perl_croak_nocontext("Usage: %s::%s(%s)", hvname, gvname, params);
147 else
148 Perl_croak_nocontext("Usage: %s(%s)", gvname, params);
149 } else {
150 /* Pants. I don't think that it should be possible to get here. */
151 Perl_croak_nocontext("Usage: CODE(0x%" UVxf ")(%s)", PTR2UV(cv), params);
152 }
153 }
154 #undef PERL_ARGS_ASSERT_CROAK_XS_USAGE
155  
156 #define croak_xs_usage S_croak_xs_usage
157  
158 #endif
159  
160 /* NOTE: the prototype of newXSproto() is different in versions of perls,
161 * so we define a portable version of newXSproto()
162 */
163 #ifdef newXS_flags
164 #define newXSproto_portable(name, c_impl, file, proto) newXS_flags(name, c_impl, file, proto, 0)
165 #else
166 #define newXSproto_portable(name, c_impl, file, proto) (PL_Sv=(SV*)newXS(name, c_impl, file), sv_setpv(PL_Sv, proto), (CV*)PL_Sv)
167 #endif /* !defined(newXS_flags) */
168  
169 #if PERL_VERSION_LE(5, 21, 5)
170 # define newXS_deffile(a,b) Perl_newXS(aTHX_ a,b,file)
171 #else
172 # define newXS_deffile(a,b) Perl_newXS_deffile(aTHX_ a,b)
173 #endif
174  
175 /* simple backcompat versions of the TARGx() macros with no optimisation */
176 #ifndef TARGi
177 # define TARGi(iv, do_taint) sv_setiv_mg(TARG, iv)
178 # define TARGu(uv, do_taint) sv_setuv_mg(TARG, uv)
179 # define TARGn(nv, do_taint) sv_setnv_mg(TARG, nv)
180 #endif
181  
182 #line 183 "escape_ansi.c"
183  
184 XS_EUPXS(XS_PerlIO__via__escape_ansi_escape_non_printable_chars); /* prototype to pass -Wmissing-prototypes */
185 6 XS_EUPXS(XS_PerlIO__via__escape_ansi_escape_non_printable_chars)
186 {
187 6 dVAR; dXSARGS;
188 6 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 6 6
189 0 croak_xs_usage(cv, "input");
190 {
191 6 const char * input = (const char *)SvPV_nolen(ST(0))
192 ;
193 char * RETVAL;
194 6 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 6 0 6
195  
196 6 RETVAL = escape_non_printable_chars(input);
197 6 sv_setpv((SV*)TARG, RETVAL);
198 6 ST(0) = TARG;
199 }
200 6 XSRETURN(1);
201 }
202  
203 #ifdef __cplusplus
204 extern "C" {
205 #endif
206 XS_EXTERNAL(boot_PerlIO__via__escape_ansi); /* prototype to pass -Wmissing-prototypes */
207 3 XS_EXTERNAL(boot_PerlIO__via__escape_ansi)
208 {
209 #if PERL_VERSION_LE(5, 21, 5)
210 dVAR; dXSARGS;
211 #else
212 3 dVAR; dXSBOOTARGSXSAPIVERCHK;
213 #endif
214 #if PERL_VERSION_LE(5, 8, 999) /* PERL_VERSION_LT is 5.33+ */
215 char* file = __FILE__;
216 #else
217 3 const char* file = __FILE__;
218 #endif
219  
220 PERL_UNUSED_VAR(file);
221  
222 PERL_UNUSED_VAR(cv); /* -W */
223 PERL_UNUSED_VAR(items); /* -W */
224 #if PERL_VERSION_LE(5, 21, 5)
225 XS_VERSION_BOOTCHECK;
226 # ifdef XS_APIVERSION_BOOTCHECK
227 XS_APIVERSION_BOOTCHECK;
228 # endif
229 #endif
230  
231 3 (void)newXSproto_portable("PerlIO::via::escape_ansi::escape_non_printable_chars", XS_PerlIO__via__escape_ansi_escape_non_printable_chars, file, "$");
232 #if PERL_VERSION_LE(5, 21, 5)
233 # if PERL_VERSION_GE(5, 9, 0)
234 if (PL_unitcheckav)
235 call_list(PL_scopestack_ix, PL_unitcheckav);
236 # endif
237 XSRETURN_YES;
238 #else
239 3 Perl_xs_boot_epilog(aTHX_ ax);
240 #endif
241 3 }
242  
243 #ifdef __cplusplus
244 }
245 #endif
« escape_chars.c ↑ Summary