1 /*
2 * This file was generated automatically by ExtUtils::ParseXS version 3.34 from the
3 * contents of MiscXS.xs. Do not edit this file, edit MiscXS.xs instead.
4 *
5 * ANY CHANGES MADE HERE WILL BE LOST!
6 *
7 */
8
9 #line 1 "MiscXS.xs"
10 #ifdef HAVE_CONFIG_H
11 #include <config.h>
12 #endif
13
14 #define PERL_NO_GET_CONTEXT
15 #include "EXTERN.h"
16 #include "perl.h"
17 #include "XSUB.h"
18
19 #include "ppport.h"
20
21 #include "miscxs.h"
22
23 #line 24 "MiscXS.c"
24 #ifndef PERL_UNUSED_VAR
25 # define PERL_UNUSED_VAR(var) if (0) var = var
26 #endif
27
28 #ifndef dVAR
29 # define dVAR dNOOP
30 #endif
31
32
33 /* This stuff is not part of the API! You have been warned. */
34 #ifndef PERL_VERSION_DECIMAL
35 # define PERL_VERSION_DECIMAL(r,v,s) (r*1000000 + v*1000 + s)
36 #endif
37 #ifndef PERL_DECIMAL_VERSION
38 # define PERL_DECIMAL_VERSION \
39 PERL_VERSION_DECIMAL(PERL_REVISION,PERL_VERSION,PERL_SUBVERSION)
40 #endif
41 #ifndef PERL_VERSION_GE
42 # define PERL_VERSION_GE(r,v,s) \
43 (PERL_DECIMAL_VERSION >= PERL_VERSION_DECIMAL(r,v,s))
44 #endif
45 #ifndef PERL_VERSION_LE
46 # define PERL_VERSION_LE(r,v,s) \
47 (PERL_DECIMAL_VERSION <= PERL_VERSION_DECIMAL(r,v,s))
48 #endif
49
50 /* XS_INTERNAL is the explicit static-linkage variant of the default
51 * XS macro.
52 *
53 * XS_EXTERNAL is the same as XS_INTERNAL except it does not include
54 * "STATIC", ie. it exports XSUB symbols. You probably don't want that
55 * for anything but the BOOT XSUB.
56 *
57 * See XSUB.h in core!
58 */
59
60
61 /* TODO: This might be compatible further back than 5.10.0. */
62 #if PERL_VERSION_GE(5, 10, 0) && PERL_VERSION_LE(5, 15, 1)
63 # undef XS_EXTERNAL
64 # undef XS_INTERNAL
65 # if defined(__CYGWIN__) && defined(USE_DYNAMIC_LOADING)
66 # define XS_EXTERNAL(name) __declspec(dllexport) XSPROTO(name)
67 # define XS_INTERNAL(name) STATIC XSPROTO(name)
68 # endif
69 # if defined(__SYMBIAN32__)
70 # define XS_EXTERNAL(name) EXPORT_C XSPROTO(name)
71 # define XS_INTERNAL(name) EXPORT_C STATIC XSPROTO(name)
72 # endif
73 # ifndef XS_EXTERNAL
74 # if defined(HASATTRIBUTE_UNUSED) && !defined(__cplusplus)
75 # define XS_EXTERNAL(name) void name(pTHX_ CV* cv __attribute__unused__)
76 # define XS_INTERNAL(name) STATIC void name(pTHX_ CV* cv __attribute__unused__)
77 # else
78 # ifdef __cplusplus
79 # define XS_EXTERNAL(name) extern "C" XSPROTO(name)
80 # define XS_INTERNAL(name) static XSPROTO(name)
81 # else
82 # define XS_EXTERNAL(name) XSPROTO(name)
83 # define XS_INTERNAL(name) STATIC XSPROTO(name)
84 # endif
85 # endif
86 # endif
87 #endif
88
89 /* perl >= 5.10.0 && perl <= 5.15.1 */
90
91
92 /* The XS_EXTERNAL macro is used for functions that must not be static
93 * like the boot XSUB of a module. If perl didn't have an XS_EXTERNAL
94 * macro defined, the best we can do is assume XS is the same.
95 * Dito for XS_INTERNAL.
96 */
97 #ifndef XS_EXTERNAL
98 # define XS_EXTERNAL(name) XS(name)
99 #endif
100 #ifndef XS_INTERNAL
101 # define XS_INTERNAL(name) XS(name)
102 #endif
103
104 /* Now, finally, after all this mess, we want an ExtUtils::ParseXS
105 * internal macro that we're free to redefine for varying linkage due
106 * to the EXPORT_XSUB_SYMBOLS XS keyword. This is internal, use
107 * XS_EXTERNAL(name) or XS_INTERNAL(name) in your code if you need to!
108 */
109
110 #undef XS_EUPXS
111 #if defined(PERL_EUPXS_ALWAYS_EXPORT)
112 # define XS_EUPXS(name) XS_EXTERNAL(name)
113 #else
114 /* default to internal */
115 # define XS_EUPXS(name) XS_INTERNAL(name)
116 #endif
117
118 #ifndef PERL_ARGS_ASSERT_CROAK_XS_USAGE
119 #define PERL_ARGS_ASSERT_CROAK_XS_USAGE assert(cv); assert(params)
120
121 /* prototype to pass -Wmissing-prototypes */
122 STATIC void
123 S_croak_xs_usage(const CV *const cv, const char *const params);
124
125 STATIC void
S_croak_xs_usage(const CV * const cv,const char * const params)126 S_croak_xs_usage(const CV *const cv, const char *const params)
127 {
128 const GV *const gv = CvGV(cv);
129
130 PERL_ARGS_ASSERT_CROAK_XS_USAGE;
131
132 if (gv) {
133 const char *const gvname = GvNAME(gv);
134 const HV *const stash = GvSTASH(gv);
135 const char *const hvname = stash ? HvNAME(stash) : NULL;
136
137 if (hvname)
138 Perl_croak_nocontext("Usage: %s::%s(%s)", hvname, gvname, params);
139 else
140 Perl_croak_nocontext("Usage: %s(%s)", gvname, params);
141 } else {
142 /* Pants. I don't think that it should be possible to get here. */
143 Perl_croak_nocontext("Usage: CODE(0x%" UVxf ")(%s)", PTR2UV(cv), params);
144 }
145 }
146 #undef PERL_ARGS_ASSERT_CROAK_XS_USAGE
147
148 #define croak_xs_usage S_croak_xs_usage
149
150 #endif
151
152 /* NOTE: the prototype of newXSproto() is different in versions of perls,
153 * so we define a portable version of newXSproto()
154 */
155 #ifdef newXS_flags
156 #define newXSproto_portable(name, c_impl, file, proto) newXS_flags(name, c_impl, file, proto, 0)
157 #else
158 #define newXSproto_portable(name, c_impl, file, proto) (PL_Sv=(SV*)newXS(name, c_impl, file), sv_setpv(PL_Sv, proto), (CV*)PL_Sv)
159 #endif /* !defined(newXS_flags) */
160
161 #if PERL_VERSION_LE(5, 21, 5)
162 # define newXS_deffile(a,b) Perl_newXS(aTHX_ a,b,file)
163 #else
164 # define newXS_deffile(a,b) Perl_newXS_deffile(aTHX_ a,b)
165 #endif
166
167 #line 168 "MiscXS.c"
168
169 XS_EUPXS(XS_Texinfo__MiscXS_abort_empty_line); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Texinfo__MiscXS_abort_empty_line)170 XS_EUPXS(XS_Texinfo__MiscXS_abort_empty_line)
171 {
172 dVAR; dXSARGS;
173 if (items < 2)
174 croak_xs_usage(cv, "self, current, ...");
175 {
176 HV * self;
177 HV * current;
178 #line 38 "MiscXS.xs"
179 SV *additional_text = 0;
180 #line 181 "MiscXS.c"
181 int RETVAL;
182 dXSTARG;
183
184 STMT_START {
185 SV* const xsub_tmp_sv = ST(0);
186 SvGETMAGIC(xsub_tmp_sv);
187 if (SvROK(xsub_tmp_sv) && SvTYPE(SvRV(xsub_tmp_sv)) == SVt_PVHV){
188 self = (HV*)SvRV(xsub_tmp_sv);
189 }
190 else{
191 Perl_croak_nocontext("%s: %s is not a HASH reference",
192 "Texinfo::MiscXS::abort_empty_line",
193 "self");
194 }
195 } STMT_END
196 ;
197
198 STMT_START {
199 SV* const xsub_tmp_sv = ST(1);
200 SvGETMAGIC(xsub_tmp_sv);
201 if (SvROK(xsub_tmp_sv) && SvTYPE(SvRV(xsub_tmp_sv)) == SVt_PVHV){
202 current = (HV*)SvRV(xsub_tmp_sv);
203 }
204 else{
205 Perl_croak_nocontext("%s: %s is not a HASH reference",
206 "Texinfo::MiscXS::abort_empty_line",
207 "current");
208 }
209 } STMT_END
210 ;
211 #line 40 "MiscXS.xs"
212 items -= 2;
213 if (items > 0 && SvOK(ST(2)))
214 {
215 additional_text = ST(2);
216 }
217 RETVAL = xs_abort_empty_line (self, current, additional_text);
218 #line 219 "MiscXS.c"
219 XSprePUSH; PUSHi((IV)RETVAL);
220 }
221 XSRETURN(1);
222 }
223
224
225 XS_EUPXS(XS_Texinfo__MiscXS_merge_text); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Texinfo__MiscXS_merge_text)226 XS_EUPXS(XS_Texinfo__MiscXS_merge_text)
227 {
228 dVAR; dXSARGS;
229 if (items != 3)
230 croak_xs_usage(cv, "self, current, text_in");
231 {
232 HV * self;
233 HV * current;
234 SV * text_in = ST(2)
235 ;
236 HV * RETVAL;
237
238 STMT_START {
239 SV* const xsub_tmp_sv = ST(0);
240 SvGETMAGIC(xsub_tmp_sv);
241 if (SvROK(xsub_tmp_sv) && SvTYPE(SvRV(xsub_tmp_sv)) == SVt_PVHV){
242 self = (HV*)SvRV(xsub_tmp_sv);
243 }
244 else{
245 Perl_croak_nocontext("%s: %s is not a HASH reference",
246 "Texinfo::MiscXS::merge_text",
247 "self");
248 }
249 } STMT_END
250 ;
251
252 STMT_START {
253 SV* const xsub_tmp_sv = ST(1);
254 SvGETMAGIC(xsub_tmp_sv);
255 if (SvROK(xsub_tmp_sv) && SvTYPE(SvRV(xsub_tmp_sv)) == SVt_PVHV){
256 current = (HV*)SvRV(xsub_tmp_sv);
257 }
258 else{
259 Perl_croak_nocontext("%s: %s is not a HASH reference",
260 "Texinfo::MiscXS::merge_text",
261 "current");
262 }
263 } STMT_END
264 ;
265
266 RETVAL = xs_merge_text(self, current, text_in);
267 {
268 SV * RETVALSV;
269 RETVALSV = newRV((SV*)RETVAL);
270 RETVALSV = sv_2mortal(RETVALSV);
271 ST(0) = RETVALSV;
272 }
273 }
274 XSRETURN(1);
275 }
276
277
278 XS_EUPXS(XS_Texinfo__MiscXS_process_text); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Texinfo__MiscXS_process_text)279 XS_EUPXS(XS_Texinfo__MiscXS_process_text)
280 {
281 dVAR; dXSARGS;
282 if (items != 1)
283 croak_xs_usage(cv, "text_in");
284 {
285 SV * text_in = ST(0)
286 ;
287 #line 59 "MiscXS.xs"
288 char *text;
289 char *retval;
290 #line 291 "MiscXS.c"
291 SV * RETVAL;
292 #line 62 "MiscXS.xs"
293 /* Make sure the input is in UTF8. */
294 if (!SvUTF8 (text_in))
295 sv_utf8_upgrade (text_in);
296
297 text = SvPV_nolen (text_in);
298
299 retval = xs_process_text (text);
300
301 RETVAL = newSVpv (retval, 0);
302 SvUTF8_on (RETVAL);
303 #line 304 "MiscXS.c"
304 RETVAL = sv_2mortal(RETVAL);
305 ST(0) = RETVAL;
306 }
307 XSRETURN(1);
308 }
309
310
311 XS_EUPXS(XS_Texinfo__MiscXS_unicode_text); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Texinfo__MiscXS_unicode_text)312 XS_EUPXS(XS_Texinfo__MiscXS_unicode_text)
313 {
314 dVAR; dXSARGS;
315 if (items < 1)
316 croak_xs_usage(cv, "text_in, ...");
317 {
318 SV * text_in = ST(0)
319 ;
320 #line 79 "MiscXS.xs"
321 int in_code = 0;
322 char *text;
323 char *retval;
324 #line 325 "MiscXS.c"
325 SV * RETVAL;
326 #line 83 "MiscXS.xs"
327 items--;
328 if (items > 0)
329 {
330 if (SvOK(ST(1)))
331 in_code = (int) SvIV(ST(1));
332 }
333 /* Make sure the input is in UTF8. */
334 if (!SvUTF8 (text_in))
335 sv_utf8_upgrade (text_in);
336
337 text = SvPV_nolen (text_in);
338
339 retval = xs_unicode_text (text, in_code);
340
341 RETVAL = newSVpv (retval, 0);
342 SvUTF8_on (RETVAL);
343
344 #line 345 "MiscXS.c"
345 RETVAL = sv_2mortal(RETVAL);
346 ST(0) = RETVAL;
347 }
348 XSRETURN(1);
349 }
350
351
352 XS_EUPXS(XS_Texinfo__MiscXS_parse_texi_regex); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Texinfo__MiscXS_parse_texi_regex)353 XS_EUPXS(XS_Texinfo__MiscXS_parse_texi_regex)
354 {
355 dVAR; dXSARGS;
356 if (items != 1)
357 croak_xs_usage(cv, "text");
358 PERL_UNUSED_VAR(ax); /* -Wall */
359 SP -= items;
360 {
361 SV * text = ST(0)
362 ;
363 #line 107 "MiscXS.xs"
364 char *at_command;
365 char *open_brace;
366 char *asterisk;
367 char *single_letter_command;
368 char *separator_match;
369 char *new_text;
370 #line 371 "MiscXS.c"
371 #line 114 "MiscXS.xs"
372 xs_parse_texi_regex(text, &at_command, &open_brace, &asterisk,
373 &single_letter_command, &separator_match, &new_text);
374 EXTEND(SP,6);
375 PUSHs(sv_newmortal());
376 sv_setpv((SV*)ST(0), at_command);
377 SvUTF8_on(ST(0));
378 PUSHs(sv_newmortal());
379 sv_setpv((SV*)ST(1), open_brace);
380 SvUTF8_on(ST(1));
381 PUSHs(sv_newmortal());
382 sv_setpv((SV*)ST(2), asterisk);
383 SvUTF8_on(ST(2));
384 PUSHs(sv_newmortal());
385 sv_setpv((SV*)ST(3), single_letter_command);
386 SvUTF8_on(ST(3));
387 PUSHs(sv_newmortal());
388 sv_setpv((SV*)ST(4), separator_match);
389 SvUTF8_on(ST(4));
390 PUSHs(sv_newmortal());
391 sv_setpv((SV*)ST(5), new_text);
392 SvUTF8_on(ST(5));
393 #line 394 "MiscXS.c"
394 PUTBACK;
395 return;
396 }
397 }
398
399 #ifdef __cplusplus
400 extern "C"
401 #endif
402 XS_EXTERNAL(boot_Texinfo__MiscXS); /* prototype to pass -Wmissing-prototypes */
XS_EXTERNAL(boot_Texinfo__MiscXS)403 XS_EXTERNAL(boot_Texinfo__MiscXS)
404 {
405 #if PERL_VERSION_LE(5, 21, 5)
406 dVAR; dXSARGS;
407 #else
408 dVAR; dXSBOOTARGSXSAPIVERCHK;
409 #endif
410 #if (PERL_REVISION == 5 && PERL_VERSION < 9)
411 char* file = __FILE__;
412 #else
413 const char* file = __FILE__;
414 #endif
415
416 PERL_UNUSED_VAR(file);
417
418 PERL_UNUSED_VAR(cv); /* -W */
419 PERL_UNUSED_VAR(items); /* -W */
420 #if PERL_VERSION_LE(5, 21, 5)
421 XS_VERSION_BOOTCHECK;
422 # ifdef XS_APIVERSION_BOOTCHECK
423 XS_APIVERSION_BOOTCHECK;
424 # endif
425 #endif
426
427 newXS_deffile("Texinfo::MiscXS::abort_empty_line", XS_Texinfo__MiscXS_abort_empty_line);
428 newXS_deffile("Texinfo::MiscXS::merge_text", XS_Texinfo__MiscXS_merge_text);
429 newXS_deffile("Texinfo::MiscXS::process_text", XS_Texinfo__MiscXS_process_text);
430 newXS_deffile("Texinfo::MiscXS::unicode_text", XS_Texinfo__MiscXS_unicode_text);
431 newXS_deffile("Texinfo::MiscXS::parse_texi_regex", XS_Texinfo__MiscXS_parse_texi_regex);
432 #if PERL_VERSION_LE(5, 21, 5)
433 # if PERL_VERSION_GE(5, 9, 0)
434 if (PL_unitcheckav)
435 call_list(PL_scopestack_ix, PL_unitcheckav);
436 # endif
437 XSRETURN_YES;
438 #else
439 Perl_xs_boot_epilog(aTHX_ ax);
440 #endif
441 }
442
443