html-template-pro 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (222) hide show
  1. data/.autotest +9 -0
  2. data/ARTISTIC +131 -0
  3. data/History.txt +4 -0
  4. data/LGPL +504 -0
  5. data/Manifest.txt +221 -0
  6. data/README.rdoc +52 -0
  7. data/Rakefile +18 -0
  8. data/benchmark.rb +136 -0
  9. data/config/website.yml +2 -0
  10. data/ext/html/template/internal/Pro.xs +679 -0
  11. data/ext/html/template/internal/builtin_findfile.inc +361 -0
  12. data/ext/html/template/internal/calc.h +26 -0
  13. data/ext/html/template/internal/calc.inc +120 -0
  14. data/ext/html/template/internal/callback_stubs.inc +63 -0
  15. data/ext/html/template/internal/expr.c +2267 -0
  16. data/ext/html/template/internal/expr.y +476 -0
  17. data/ext/html/template/internal/expr_iface.c +94 -0
  18. data/ext/html/template/internal/exprpstr.h +36 -0
  19. data/ext/html/template/internal/exprpstr.inc +144 -0
  20. data/ext/html/template/internal/exprtool.h +99 -0
  21. data/ext/html/template/internal/exprtool.inc +289 -0
  22. data/ext/html/template/internal/exprtype.h +62 -0
  23. data/ext/html/template/internal/exprval.h +30 -0
  24. data/ext/html/template/internal/extconf.rb +6 -0
  25. data/ext/html/template/internal/internal.c +449 -0
  26. data/ext/html/template/internal/loadfile.h +11 -0
  27. data/ext/html/template/internal/loadfile.inc +171 -0
  28. data/ext/html/template/internal/pabidecl.h +54 -0
  29. data/ext/html/template/internal/pabstract.h +426 -0
  30. data/ext/html/template/internal/parse_expr.h +15 -0
  31. data/ext/html/template/internal/pbuffer.c +76 -0
  32. data/ext/html/template/internal/pbuffer.h +31 -0
  33. data/ext/html/template/internal/pmiscdef.h +54 -0
  34. data/ext/html/template/internal/pparam.h +101 -0
  35. data/ext/html/template/internal/ppport.h +1098 -0
  36. data/ext/html/template/internal/procore.c +1189 -0
  37. data/ext/html/template/internal/procore.h +18 -0
  38. data/ext/html/template/internal/proparam.c +443 -0
  39. data/ext/html/template/internal/proparam.h +571 -0
  40. data/ext/html/template/internal/proscope.h +32 -0
  41. data/ext/html/template/internal/proscope.inc +107 -0
  42. data/ext/html/template/internal/prostate.h +49 -0
  43. data/ext/html/template/internal/prostate.inc +24 -0
  44. data/ext/html/template/internal/provalue.h +14 -0
  45. data/ext/html/template/internal/pstring.h +60 -0
  46. data/ext/html/template/internal/pstrutils.h +25 -0
  47. data/ext/html/template/internal/pstrutils.inc +150 -0
  48. data/ext/html/template/internal/tagstack.h +30 -0
  49. data/ext/html/template/internal/tagstack.inc +65 -0
  50. data/ext/html/template/internal/tmpllog.c +62 -0
  51. data/ext/html/template/internal/tmpllog.h +27 -0
  52. data/ext/html/template/internal/tmplpro.h +218 -0
  53. data/ext/html/template/internal/tmplpro_version.c +35 -0
  54. data/lib/html/template/pro.rb +225 -0
  55. data/script/console +10 -0
  56. data/script/destroy +14 -0
  57. data/script/generate +14 -0
  58. data/script/txt2html +71 -0
  59. data/tasks/extconf.rake +13 -0
  60. data/tasks/extconf/tmplpro.rake +43 -0
  61. data/templates-Pro/a.incl +1 -0
  62. data/templates-Pro/empty.incl +0 -0
  63. data/templates-Pro/include/1/a.incl +1 -0
  64. data/templates-Pro/include/2.out +3 -0
  65. data/templates-Pro/include/2.tmpl +1 -0
  66. data/templates-Pro/include/2/a.incl +1 -0
  67. data/templates-Pro/include/3.tmpl +1 -0
  68. data/templates-Pro/include/4.tmpl +1 -0
  69. data/templates-Pro/include/a.incl +1 -0
  70. data/templates-Pro/test_broken.tmpl +25 -0
  71. data/templates-Pro/test_broken1.out +1 -0
  72. data/templates-Pro/test_broken1.tmpl +1 -0
  73. data/templates-Pro/test_esc1.out +4 -0
  74. data/templates-Pro/test_esc1.tmpl +4 -0
  75. data/templates-Pro/test_esc2.out +5 -0
  76. data/templates-Pro/test_esc2.tmpl +6 -0
  77. data/templates-Pro/test_esc3.out +4 -0
  78. data/templates-Pro/test_esc3.tmpl +4 -0
  79. data/templates-Pro/test_esc4.out +3 -0
  80. data/templates-Pro/test_esc4.tmpl +4 -0
  81. data/templates-Pro/test_expr1.out +26 -0
  82. data/templates-Pro/test_expr1.tmpl +26 -0
  83. data/templates-Pro/test_expr2.out +34 -0
  84. data/templates-Pro/test_expr2.tmpl +34 -0
  85. data/templates-Pro/test_expr3.out +6 -0
  86. data/templates-Pro/test_expr3.tmpl +6 -0
  87. data/templates-Pro/test_expr4.out +4 -0
  88. data/templates-Pro/test_expr4.tmpl +4 -0
  89. data/templates-Pro/test_expr5.out +18 -0
  90. data/templates-Pro/test_expr5.tmpl +18 -0
  91. data/templates-Pro/test_expr6.out +18 -0
  92. data/templates-Pro/test_expr6.tmpl +18 -0
  93. data/templates-Pro/test_expr7.out +44 -0
  94. data/templates-Pro/test_expr7.tmpl +20 -0
  95. data/templates-Pro/test_expr8.out +15 -0
  96. data/templates-Pro/test_expr8.tmpl +15 -0
  97. data/templates-Pro/test_if1.out +25 -0
  98. data/templates-Pro/test_if1.tmpl +28 -0
  99. data/templates-Pro/test_if2.out +17 -0
  100. data/templates-Pro/test_if2.tmpl +25 -0
  101. data/templates-Pro/test_if3.out +12 -0
  102. data/templates-Pro/test_if3.tmpl +14 -0
  103. data/templates-Pro/test_if4.out +15 -0
  104. data/templates-Pro/test_if4.tmpl +31 -0
  105. data/templates-Pro/test_if5.out +16 -0
  106. data/templates-Pro/test_if5.tmpl +16 -0
  107. data/templates-Pro/test_if6.out +15 -0
  108. data/templates-Pro/test_if6.tmpl +31 -0
  109. data/templates-Pro/test_if7.out +14 -0
  110. data/templates-Pro/test_if7.tmpl +18 -0
  111. data/templates-Pro/test_include1.out +23 -0
  112. data/templates-Pro/test_include1.tmpl +7 -0
  113. data/templates-Pro/test_include2.out +120 -0
  114. data/templates-Pro/test_include2.tmpl +10 -0
  115. data/templates-Pro/test_include3.out +8 -0
  116. data/templates-Pro/test_include3.tmpl +8 -0
  117. data/templates-Pro/test_include4.out +7 -0
  118. data/templates-Pro/test_include4.tmpl +6 -0
  119. data/templates-Pro/test_include5.out +7 -0
  120. data/templates-Pro/test_include5.tmpl +6 -0
  121. data/templates-Pro/test_loop1.erb +17 -0
  122. data/templates-Pro/test_loop1.out +12 -0
  123. data/templates-Pro/test_loop1.tmpl +16 -0
  124. data/templates-Pro/test_loop2.erb +19 -0
  125. data/templates-Pro/test_loop2.out +40 -0
  126. data/templates-Pro/test_loop2.tmpl +19 -0
  127. data/templates-Pro/test_loop3.out +38 -0
  128. data/templates-Pro/test_loop3.tmpl +40 -0
  129. data/templates-Pro/test_loop4.out +44 -0
  130. data/templates-Pro/test_loop4.tmpl +20 -0
  131. data/templates-Pro/test_loop5.out +9 -0
  132. data/templates-Pro/test_loop5.tmpl +11 -0
  133. data/templates-Pro/test_loop6.out +33 -0
  134. data/templates-Pro/test_loop6.tmpl +15 -0
  135. data/templates-Pro/test_malloc.tmpl +1 -0
  136. data/templates-Pro/test_userfunc1.out +14 -0
  137. data/templates-Pro/test_userfunc1.tmpl +14 -0
  138. data/templates-Pro/test_userfunc2.out +35 -0
  139. data/templates-Pro/test_userfunc2.tmpl +5 -0
  140. data/templates-Pro/test_userfunc3.out +5 -0
  141. data/templates-Pro/test_userfunc3.tmpl +5 -0
  142. data/templates-Pro/test_userfunc4.out +10 -0
  143. data/templates-Pro/test_userfunc4.tmpl +10 -0
  144. data/templates-Pro/test_userfunc5.out +4 -0
  145. data/templates-Pro/test_userfunc5.tmpl +4 -0
  146. data/templates-Pro/test_userfunc6.out +4 -0
  147. data/templates-Pro/test_userfunc6.tmpl +4 -0
  148. data/templates-Pro/test_var1.erb +23 -0
  149. data/templates-Pro/test_var1.out +20 -0
  150. data/templates-Pro/test_var1.tmpl +23 -0
  151. data/templates-Pro/test_var2.erb +7 -0
  152. data/templates-Pro/test_var2.out +6 -0
  153. data/templates-Pro/test_var2.tmpl +7 -0
  154. data/templates-Pro/test_var3.out +14 -0
  155. data/templates-Pro/test_var3.tmpl +16 -0
  156. data/templates/case_loop.tmpl +3 -0
  157. data/templates/context.tmpl +3 -0
  158. data/templates/counter.tmpl +2 -0
  159. data/templates/default.tmpl +1 -0
  160. data/templates/default_escape.tmpl +4 -0
  161. data/templates/double_loop.tmpl +7 -0
  162. data/templates/escape.tmpl +5 -0
  163. data/templates/global-loops.tmpl +9 -0
  164. data/templates/globals.tmpl +11 -0
  165. data/templates/if.tmpl +7 -0
  166. data/templates/ifelse.tmpl +6 -0
  167. data/templates/include.tmpl +14 -0
  168. data/templates/include_path/a.tmpl +2 -0
  169. data/templates/include_path/b.tmpl +1 -0
  170. data/templates/include_path/inner.tmpl +1 -0
  171. data/templates/include_path/one.tmpl +2 -0
  172. data/templates/include_path2/inner.tmpl +1 -0
  173. data/templates/included.tmpl +4 -0
  174. data/templates/included2.tmpl +3 -0
  175. data/templates/js.tmpl +1 -0
  176. data/templates/long_loops.tmpl +307 -0
  177. data/templates/loop-context.tmpl +2 -0
  178. data/templates/loop-if.tmpl +9 -0
  179. data/templates/medium.tmpl +217 -0
  180. data/templates/multiline_tags.tmpl +7 -0
  181. data/templates/newline_test1.tmpl +1 -0
  182. data/templates/newline_test2.tmpl +1 -0
  183. data/templates/other-loop.tmpl +7 -0
  184. data/templates/outer.tmpl +3 -0
  185. data/templates/query-test.tmpl +21 -0
  186. data/templates/query-test2.tmpl +12 -0
  187. data/templates/recursive.tmpl +2 -0
  188. data/templates/searchpath/included.tmpl +4 -0
  189. data/templates/searchpath/three.tmpl +1 -0
  190. data/templates/searchpath/two.tmpl +2 -0
  191. data/templates/simple-loop-nonames.tmpl +13 -0
  192. data/templates/simple-loop.tmpl +12 -0
  193. data/templates/simple.tmpl +9 -0
  194. data/templates/unless.tmpl +5 -0
  195. data/templates/urlescape.tmpl +3 -0
  196. data/templates/vanguard1.tmpl +2 -0
  197. data/templates/vanguard2.tmpl +3 -0
  198. data/test/templates/complex.tmpl +24 -0
  199. data/test/templates/foo.tmpl +6 -0
  200. data/test/templates/func.tmpl +2 -0
  201. data/test/templates/loop.tmpl +14 -0
  202. data/test/templates/negative.tmpl +1 -0
  203. data/test/templates/numerics.tmpl +6 -0
  204. data/test/templates/register.tmpl +2 -0
  205. data/test/test_basic.rb +23 -0
  206. data/test/test_coderefs.rb +16 -0
  207. data/test/test_complex.rb +106 -0
  208. data/test/test_helper.rb +3 -0
  209. data/test/test_html_template.rb +583 -0
  210. data/test/test_html_template_internal_extn.rb +10 -0
  211. data/test/test_html_template_pro.rb +177 -0
  212. data/test/test_path_like_variable_scope.rb +59 -0
  213. data/test/test_random.rb +21 -0
  214. data/test/test_realloc.rb +16 -0
  215. data/test/test_register.rb +25 -0
  216. data/test/test_tmplpro.rb +9 -0
  217. data/test/tests.rb +9 -0
  218. data/website/index.txt +57 -0
  219. data/website/javascripts/rounded_corners_lite.inc.js +285 -0
  220. data/website/stylesheets/screen.css +159 -0
  221. data/website/template.html.erb +50 -0
  222. metadata +303 -0
@@ -0,0 +1,15 @@
1
+ /* -*- c -*-
2
+ * File: parse_expr.h
3
+ * Author: Igor Vlasenko <vlasenko@imath.kiev.ua>
4
+ * Created: Mon Jun 6 14:54:45 2005
5
+ */
6
+
7
+ #ifndef _PARSE_EXPR_H
8
+ #define _PARSE_EXPR_H 1
9
+
10
+ #include<pabidecl.h>
11
+
12
+ TMPLPRO_LOCAL
13
+ PSTRING parse_expr(PSTRING line, struct tmplpro_state* state);
14
+
15
+ #endif /* parse_expr.h */
@@ -0,0 +1,76 @@
1
+ #include "pbuffer.h"
2
+
3
+ /* reentrant pbuffer functions */
4
+
5
+ TMPLPRO_LOCAL
6
+ size_t pbuffer_size(pbuffer* pBuffer) {
7
+ return pBuffer->bufsize;
8
+ }
9
+ TMPLPRO_LOCAL
10
+ void pbuffer_preinit(pbuffer* pBuffer) {
11
+ pBuffer->bufsize=0;
12
+ pBuffer->buffer=NULL;
13
+ }
14
+ TMPLPRO_LOCAL
15
+ char* pbuffer_init(pbuffer* pBuffer) {
16
+ pBuffer->bufsize=256;
17
+ pBuffer->buffer=(char*) malloc (pBuffer->bufsize * sizeof(char));
18
+ return pBuffer->buffer;
19
+ }
20
+ TMPLPRO_LOCAL
21
+ char* pbuffer_init_as(pbuffer* pBuffer,size_t size) {
22
+ pBuffer->bufsize=PBUFFER_MULTIPLICATOR*size;
23
+ pBuffer->buffer=(char*) malloc (pBuffer->bufsize * sizeof(char));
24
+ return pBuffer->buffer;
25
+ }
26
+ TMPLPRO_LOCAL
27
+ char* pbuffer_string(pbuffer* pBuffer) {
28
+ return pBuffer->buffer;
29
+ }
30
+ TMPLPRO_LOCAL
31
+ char* pbuffer_resize(pbuffer* pBuffer, size_t size) {
32
+ if (pBuffer->bufsize==0) {
33
+ pbuffer_init_as(pBuffer, size);
34
+ } else if (pBuffer->bufsize< size) {
35
+ pBuffer->bufsize=PBUFFER_MULTIPLICATOR*size; /* aggresive memory allocation to prevent frequent requests*/
36
+ pBuffer->buffer=(char*) realloc (pBuffer->buffer,pBuffer->bufsize * sizeof(char));
37
+ }
38
+ return pBuffer->buffer;
39
+ }
40
+
41
+ TMPLPRO_LOCAL
42
+ void pbuffer_free(pbuffer* pBuffer) {
43
+ if (pBuffer->bufsize!=0) {
44
+ pBuffer->bufsize=0;
45
+ free(pBuffer->buffer);
46
+ pBuffer->buffer=NULL;
47
+ }
48
+ }
49
+ TMPLPRO_LOCAL
50
+ void pbuffer_fill_from_pstring(pbuffer* pBuffer, PSTRING pstr) {
51
+ size_t size = pstr.endnext - pstr.begin;
52
+ const char* from = pstr.begin;
53
+ char* dest;
54
+ if (pBuffer->bufsize==0) {
55
+ pbuffer_init_as(pBuffer, size+1);
56
+ } else if (pBuffer->bufsize<size) {
57
+ pbuffer_resize(pBuffer, size+1);
58
+ }
59
+ dest = pBuffer->buffer;
60
+ while (from<pstr.endnext) {
61
+ *(dest++)=*(from++);
62
+ }
63
+ *dest='\0';
64
+ }
65
+ TMPLPRO_LOCAL
66
+ void pbuffer_swap(pbuffer* buf1, pbuffer* buf2) {
67
+ pbuffer tmpbuf = *buf1;
68
+ *buf1 = *buf2;
69
+ *buf2 = tmpbuf;
70
+ }
71
+
72
+ /*
73
+ * Local Variables:
74
+ * mode: c
75
+ * End:
76
+ */
@@ -0,0 +1,31 @@
1
+ #ifndef _PBUFFER_H
2
+ #define _PBUFFER_H 1
3
+
4
+ #include<stdlib.h>
5
+ #include<pabidecl.h>
6
+ #include "pstring.h"
7
+
8
+ typedef struct pbuffer {
9
+ size_t bufsize;
10
+ char* buffer;
11
+ } pbuffer;
12
+
13
+ #define PBUFFER_MULTIPLICATOR 2
14
+
15
+ TMPLPRO_LOCAL size_t pbuffer_size(pbuffer*);
16
+ TMPLPRO_LOCAL void pbuffer_preinit(pbuffer* pBuffer);
17
+ TMPLPRO_LOCAL char* pbuffer_init(pbuffer*);
18
+ TMPLPRO_LOCAL char* pbuffer_init_as(pbuffer* pBuffer,size_t size);
19
+ TMPLPRO_LOCAL char* pbuffer_string(pbuffer*);
20
+ TMPLPRO_LOCAL char* pbuffer_resize(pbuffer*, size_t size);
21
+ TMPLPRO_LOCAL void pbuffer_free(pbuffer*);
22
+ TMPLPRO_LOCAL void pbuffer_fill_from_pstring(pbuffer* pBuffer, PSTRING pstr);
23
+ TMPLPRO_LOCAL void pbuffer_swap(pbuffer* buf1, pbuffer* buf2);
24
+
25
+ #endif /* pbuffer.h */
26
+
27
+ /*
28
+ * Local Variables:
29
+ * mode: c
30
+ * End:
31
+ */
@@ -0,0 +1,54 @@
1
+ #ifndef _PMISCDEF_H
2
+ #define _PMISCDEF_H 1
3
+
4
+ #include <string.h>
5
+
6
+ /* snprintf MS VC++ support;
7
+ * thanks to Viacheslav Sheveliov <slavash@aha.ru>
8
+ */
9
+ #ifdef _MSC_VER
10
+ # define snprintf _snprintf
11
+ #endif
12
+
13
+ /* printf ptrdiff_t format modifier */
14
+ #if __STDC_VERSION__ >= 199901L
15
+ # define TO_PTRDIFF_T(X) (X)
16
+ # define MOD_TD "%td"
17
+ #elif defined _MSC_VER
18
+ # define TO_PTRDIFF_T(X) (X)
19
+ # define MOD_TD "%Id"
20
+ #else
21
+ # define TO_PTRDIFF_T(X) ((long) (X))
22
+ # define MOD_TD "%ld"
23
+ #endif
24
+
25
+ #if ! HAVE_STRDUP && ! defined strdup
26
+ # if HAVE__STRDUP
27
+ # define strdup _strdup
28
+ # else
29
+ # define strdup(str) strcpy(malloc(strlen(str) + 1), str)
30
+ # endif
31
+ #endif
32
+
33
+ #define COMPILE_TIME_ASSERT(x) \
34
+ void __cta_proto__(int __cta_foo__[(x) ? 1 : -1])
35
+
36
+ #ifdef __GNUC__
37
+ #define FORMAT_PRINTF(X,Y) __attribute__ ((__format__ (__printf__, X, Y)))
38
+ #else
39
+ #define FORMAT_PRINTF(X,Y)
40
+ #endif
41
+
42
+ #if defined(__GNUC__) && !(defined(PEDANTIC))
43
+ #define INLINE inline
44
+ #else /* !__GNUC__ */
45
+ #define INLINE
46
+ #endif /* __GNUC__ */
47
+
48
+ #endif /* pmiscdef.h */
49
+
50
+ /*
51
+ * Local Variables:
52
+ * mode: c
53
+ * End:
54
+ */
@@ -0,0 +1,101 @@
1
+ /* -*- c -*-
2
+ * File: pparam.h
3
+ * Author: Igor Vlasenko <vlasenko@imath.kiev.ua>
4
+ * Created: Thu Jul 9 20:05:37 2009
5
+ */
6
+
7
+ #ifndef _PPARAM_H
8
+ #define _PPARAM_H 1
9
+
10
+ #include "proscope.h"
11
+ #include "pbuffer.h"
12
+ #include "exprval.h" /* TODO: remove together with buffer */
13
+
14
+ typedef int flag;
15
+
16
+ struct tmplpro_param {
17
+ int global_vars;
18
+ int max_includes;
19
+ int debug;
20
+ int tmpl_var_case;
21
+ flag no_includes;
22
+ flag loop_context_vars;
23
+ flag strict;
24
+ /* filters --- indicates whether to use
25
+ * external file loader hook specified as LoadFileFuncPtr.
26
+ * Set it to 1 if you want to preprocess file with filters
27
+ * before they'll be processed by exec_tmpl */
28
+ flag filters;
29
+ int default_escape; /* one of HTML_TEMPLATE_OPT_ESCAPE_* */
30
+ const char* filename; /* template file */
31
+ PSTRING scalarref; /* memory area */
32
+ flag path_like_variable_scope;
33
+ flag search_path_on_include;
34
+ char** path;
35
+ /* flag vanguard_compatibility_mode; */
36
+
37
+ /* hooks to perl or other container */
38
+ /* HTML::Template callback hooks */
39
+ writer_functype WriterFuncPtr;
40
+ get_ABSTRACT_VALUE_functype GetAbstractValFuncPtr;
41
+ ABSTRACT_VALUE2PSTRING_functype AbstractVal2pstringFuncPtr;
42
+ ABSTRACT_VALUE2ABSTRACT_ARRAY_functype AbstractVal2abstractArrayFuncPtr;
43
+ get_ABSTRACT_ARRAY_length_functype GetAbstractArrayLengthFuncPtr;
44
+ get_ABSTRACT_MAP_functype GetAbstractMapFuncPtr;
45
+ /* user-supplied --- optional; we use it for full emulation of perl quirks */
46
+ is_ABSTRACT_VALUE_true_functype IsAbstractValTrueFuncPtr;
47
+ find_file_functype FindFileFuncPtr;
48
+ load_file_functype LoadFileFuncPtr;
49
+ unload_file_functype UnloadFileFuncPtr;
50
+ exit_loop_scope_functype ExitLoopScopeFuncPtr;
51
+ /* external state references to be supplied to callbacks */
52
+ ABSTRACT_WRITER* ext_writer_state;
53
+ ABSTRACT_FILTER* ext_filter_state;
54
+ ABSTRACT_FINDFILE* ext_findfile_state;
55
+ ABSTRACT_DATASTATE* ext_data_state;
56
+ ABSTRACT_CALLER* ext_calluserfunc_state;
57
+ /* HTML::Template::Expr hooks */
58
+ init_expr_arglist_functype InitExprArglistFuncPtr;
59
+ free_expr_arglist_functype FreeExprArglistFuncPtr;
60
+ /**
61
+ important note:
62
+ PushExprArglistFuncPtr should always copy the supplied pstring arg
63
+ as it could point to a temporary location.
64
+ */
65
+ push_expr_arglist_functype PushExprArglistFuncPtr;
66
+ call_expr_userfnc_functype CallExprUserfncFuncPtr;
67
+ is_expr_userfnc_functype IsExprUserfncFuncPtr;
68
+ ABSTRACT_FUNCMAP* expr_func_map;
69
+
70
+ /* private */
71
+ /* flags to be declared */
72
+ /* TODO use in walk_through_nested_loops */
73
+ flag warn_unused;
74
+
75
+ /* private */
76
+
77
+ int cur_includes; /* internal counter of include depth */
78
+ const char* masterpath; /* file that has included this file, or NULL */
79
+
80
+ /* variable scope (nested loops) passed to include */
81
+ struct scope_stack var_scope_stack;
82
+ int param_map_count; /* internal counter of pushed scope roots */
83
+
84
+ /* private buffer of builtin_findfile */
85
+ pbuffer builtin_findfile_buffer;
86
+ /* private buffer of write_chars_to_pbuffer */
87
+ pbuffer builtin_writer_buffer;
88
+ /* private buffers of walk_through_nested_loops */
89
+ PSTRING lowercase_varname;
90
+ pbuffer lowercase_varname_buffer;
91
+ PSTRING uppercase_varname;
92
+ pbuffer uppercase_varname_buffer;
93
+ };
94
+
95
+ #endif /* _PPARAM_H */
96
+
97
+ /*
98
+ * Local Variables:
99
+ * mode: c
100
+ * End:
101
+ */
@@ -0,0 +1,1098 @@
1
+
2
+ /* ppport.h -- Perl/Pollution/Portability Version 2.011
3
+ *
4
+ * Automatically Created by Devel::PPPort on Thu Feb 24 17:20:58 2005
5
+ *
6
+ * Do NOT edit this file directly! -- Edit PPPort.pm instead.
7
+ *
8
+ * Version 2.x, Copyright (C) 2001, Paul Marquess.
9
+ * Version 1.x, Copyright (C) 1999, Kenneth Albanowski.
10
+ * This code may be used and distributed under the same license as any
11
+ * version of Perl.
12
+ *
13
+ * This version of ppport.h is designed to support operation with Perl
14
+ * installations back to 5.004, and has been tested up to 5.8.1.
15
+ *
16
+ * If this version of ppport.h is failing during the compilation of this
17
+ * module, please check if a newer version of Devel::PPPort is available
18
+ * on CPAN before sending a bug report.
19
+ *
20
+ * If you are using the latest version of Devel::PPPort and it is failing
21
+ * during compilation of this module, please send a report to perlbug@perl.com
22
+ *
23
+ * Include all following information:
24
+ *
25
+ * 1. The complete output from running "perl -V"
26
+ *
27
+ * 2. This file.
28
+ *
29
+ * 3. The name & version of the module you were trying to build.
30
+ *
31
+ * 4. A full log of the build that failed.
32
+ *
33
+ * 5. Any other information that you think could be relevant.
34
+ *
35
+ *
36
+ * For the latest version of this code, please retreive the Devel::PPPort
37
+ * module from CPAN.
38
+ *
39
+ */
40
+
41
+ /*
42
+ * In order for a Perl extension module to be as portable as possible
43
+ * across differing versions of Perl itself, certain steps need to be taken.
44
+ * Including this header is the first major one, then using dTHR is all the
45
+ * appropriate places and using a PL_ prefix to refer to global Perl
46
+ * variables is the second.
47
+ *
48
+ */
49
+
50
+
51
+ /* If you use one of a few functions that were not present in earlier
52
+ * versions of Perl, please add a define before the inclusion of ppport.h
53
+ * for a static include, or use the GLOBAL request in a single module to
54
+ * produce a global definition that can be referenced from the other
55
+ * modules.
56
+ *
57
+ * Function: Static define: Extern define:
58
+ * newCONSTSUB() NEED_newCONSTSUB NEED_newCONSTSUB_GLOBAL
59
+ *
60
+ */
61
+
62
+
63
+ /* To verify whether ppport.h is needed for your module, and whether any
64
+ * special defines should be used, ppport.h can be run through Perl to check
65
+ * your source code. Simply say:
66
+ *
67
+ * perl -x ppport.h *.c *.h *.xs foo/bar*.c [etc]
68
+ *
69
+ * The result will be a list of patches suggesting changes that should at
70
+ * least be acceptable, if not necessarily the most efficient solution, or a
71
+ * fix for all possible problems. It won't catch where dTHR is needed, and
72
+ * doesn't attempt to account for global macro or function definitions,
73
+ * nested includes, typemaps, etc.
74
+ *
75
+ * In order to test for the need of dTHR, please try your module under a
76
+ * recent version of Perl that has threading compiled-in.
77
+ *
78
+ */
79
+
80
+
81
+ /*
82
+ #!/usr/bin/perl
83
+ @ARGV = ("*.xs") if !@ARGV;
84
+ %badmacros = %funcs = %macros = (); $replace = 0;
85
+ foreach (<DATA>) {
86
+ $funcs{$1} = 1 if /Provide:\s+(\S+)/;
87
+ $macros{$1} = 1 if /^#\s*define\s+([a-zA-Z0-9_]+)/;
88
+ $replace = $1 if /Replace:\s+(\d+)/;
89
+ $badmacros{$2}=$1 if $replace and /^#\s*define\s+([a-zA-Z0-9_]+).*?\s+([a-zA-Z0-9_]+)/;
90
+ $badmacros{$1}=$2 if /Replace (\S+) with (\S+)/;
91
+ }
92
+ foreach $filename (map(glob($_),@ARGV)) {
93
+ unless (open(IN, "<$filename")) {
94
+ warn "Unable to read from $file: $!\n";
95
+ next;
96
+ }
97
+ print "Scanning $filename...\n";
98
+ $c = ""; while (<IN>) { $c .= $_; } close(IN);
99
+ $need_include = 0; %add_func = (); $changes = 0;
100
+ $has_include = ($c =~ /#.*include.*ppport/m);
101
+
102
+ foreach $func (keys %funcs) {
103
+ if ($c =~ /#.*define.*\bNEED_$func(_GLOBAL)?\b/m) {
104
+ if ($c !~ /\b$func\b/m) {
105
+ print "If $func isn't needed, you don't need to request it.\n" if
106
+ $changes += ($c =~ s/^.*#.*define.*\bNEED_$func\b.*\n//m);
107
+ } else {
108
+ print "Uses $func\n";
109
+ $need_include = 1;
110
+ }
111
+ } else {
112
+ if ($c =~ /\b$func\b/m) {
113
+ $add_func{$func} =1 ;
114
+ print "Uses $func\n";
115
+ $need_include = 1;
116
+ }
117
+ }
118
+ }
119
+
120
+ if (not $need_include) {
121
+ foreach $macro (keys %macros) {
122
+ if ($c =~ /\b$macro\b/m) {
123
+ print "Uses $macro\n";
124
+ $need_include = 1;
125
+ }
126
+ }
127
+ }
128
+
129
+ foreach $badmacro (keys %badmacros) {
130
+ if ($c =~ /\b$badmacro\b/m) {
131
+ $changes += ($c =~ s/\b$badmacro\b/$badmacros{$badmacro}/gm);
132
+ print "Uses $badmacros{$badmacro} (instead of $badmacro)\n";
133
+ $need_include = 1;
134
+ }
135
+ }
136
+
137
+ if (scalar(keys %add_func) or $need_include != $has_include) {
138
+ if (!$has_include) {
139
+ $inc = join('',map("#define NEED_$_\n", sort keys %add_func)).
140
+ "#include \"ppport.h\"\n";
141
+ $c = "$inc$c" unless $c =~ s/#.*include.*XSUB.*\n/$&$inc/m;
142
+ } elsif (keys %add_func) {
143
+ $inc = join('',map("#define NEED_$_\n", sort keys %add_func));
144
+ $c = "$inc$c" unless $c =~ s/^.*#.*include.*ppport.*$/$inc$&/m;
145
+ }
146
+ if (!$need_include) {
147
+ print "Doesn't seem to need ppport.h.\n";
148
+ $c =~ s/^.*#.*include.*ppport.*\n//m;
149
+ }
150
+ $changes++;
151
+ }
152
+
153
+ if ($changes) {
154
+ open(OUT,">/tmp/ppport.h.$$");
155
+ print OUT $c;
156
+ close(OUT);
157
+ open(DIFF, "diff -u $filename /tmp/ppport.h.$$|");
158
+ while (<DIFF>) { s!/tmp/ppport\.h\.$$!$filename.patched!; print STDOUT; }
159
+ close(DIFF);
160
+ unlink("/tmp/ppport.h.$$");
161
+ } else {
162
+ print "Looks OK\n";
163
+ }
164
+ }
165
+ __DATA__
166
+ */
167
+
168
+ #ifndef _P_P_PORTABILITY_H_
169
+ #define _P_P_PORTABILITY_H_
170
+
171
+ #ifndef PERL_REVISION
172
+ # ifndef __PATCHLEVEL_H_INCLUDED__
173
+ # define PERL_PATCHLEVEL_H_IMPLICIT
174
+ # include <patchlevel.h>
175
+ # endif
176
+ # if !(defined(PERL_VERSION) || (defined(SUBVERSION) && defined(PATCHLEVEL)))
177
+ # include <could_not_find_Perl_patchlevel.h>
178
+ # endif
179
+ # ifndef PERL_REVISION
180
+ # define PERL_REVISION (5)
181
+ /* Replace: 1 */
182
+ # define PERL_VERSION PATCHLEVEL
183
+ # define PERL_SUBVERSION SUBVERSION
184
+ /* Replace PERL_PATCHLEVEL with PERL_VERSION */
185
+ /* Replace: 0 */
186
+ # endif
187
+ #endif
188
+
189
+ #define PERL_BCDVERSION ((PERL_REVISION * 0x1000000L) + (PERL_VERSION * 0x1000L) + PERL_SUBVERSION)
190
+
191
+ /* It is very unlikely that anyone will try to use this with Perl 6
192
+ (or greater), but who knows.
193
+ */
194
+ #if PERL_REVISION != 5
195
+ # error ppport.h only works with Perl version 5
196
+ #endif /* PERL_REVISION != 5 */
197
+
198
+ #ifndef ERRSV
199
+ # define ERRSV perl_get_sv("@",FALSE)
200
+ #endif
201
+
202
+ #if (PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION <= 5))
203
+ /* Replace: 1 */
204
+ # define PL_Sv Sv
205
+ # define PL_compiling compiling
206
+ # define PL_copline copline
207
+ # define PL_curcop curcop
208
+ # define PL_curstash curstash
209
+ # define PL_defgv defgv
210
+ # define PL_dirty dirty
211
+ # define PL_dowarn dowarn
212
+ # define PL_hints hints
213
+ # define PL_na na
214
+ # define PL_perldb perldb
215
+ # define PL_rsfp_filters rsfp_filters
216
+ # define PL_rsfpv rsfp
217
+ # define PL_stdingv stdingv
218
+ # define PL_sv_no sv_no
219
+ # define PL_sv_undef sv_undef
220
+ # define PL_sv_yes sv_yes
221
+ /* Replace: 0 */
222
+ #endif
223
+
224
+ #ifndef PERL_UNUSED_DECL
225
+ # ifdef HASATTRIBUTE
226
+ # if (defined(__GNUC__) && defined(__cplusplus)) || defined(__INTEL_COMPILER)
227
+ # define PERL_UNUSED_DECL
228
+ # else
229
+ # define PERL_UNUSED_DECL __attribute__((unused))
230
+ # endif
231
+ # else
232
+ # define PERL_UNUSED_DECL
233
+ # endif
234
+ #endif
235
+
236
+ #ifndef dNOOP
237
+ # define NOOP (void)0
238
+ # define dNOOP extern int Perl___notused PERL_UNUSED_DECL
239
+ #endif
240
+
241
+ #ifndef dTHR
242
+ # define dTHR dNOOP
243
+ #endif
244
+
245
+ #ifndef dTHX
246
+ # define dTHX dNOOP
247
+ # define dTHXa(x) dNOOP
248
+ # define dTHXoa(x) dNOOP
249
+ #endif
250
+
251
+ #ifndef pTHX
252
+ # define pTHX void
253
+ # define pTHX_
254
+ # define aTHX
255
+ # define aTHX_
256
+ #endif
257
+
258
+ #ifndef dAX
259
+ # define dAX I32 ax = MARK - PL_stack_base + 1
260
+ #endif
261
+ #ifndef dITEMS
262
+ # define dITEMS I32 items = SP - MARK
263
+ #endif
264
+
265
+ /* IV could also be a quad (say, a long long), but Perls
266
+ * capable of those should have IVSIZE already. */
267
+ #if !defined(IVSIZE) && defined(LONGSIZE)
268
+ # define IVSIZE LONGSIZE
269
+ #endif
270
+ #ifndef IVSIZE
271
+ # define IVSIZE 4 /* A bold guess, but the best we can make. */
272
+ #endif
273
+
274
+ #ifndef UVSIZE
275
+ # define UVSIZE IVSIZE
276
+ #endif
277
+
278
+ #ifndef NVTYPE
279
+ # if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE)
280
+ # define NVTYPE long double
281
+ # else
282
+ # define NVTYPE double
283
+ # endif
284
+ typedef NVTYPE NV;
285
+ #endif
286
+
287
+ #ifndef INT2PTR
288
+
289
+ #if (IVSIZE == PTRSIZE) && (UVSIZE == PTRSIZE)
290
+ # define PTRV UV
291
+ # define INT2PTR(any,d) (any)(d)
292
+ #else
293
+ # if PTRSIZE == LONGSIZE
294
+ # define PTRV unsigned long
295
+ # else
296
+ # define PTRV unsigned
297
+ # endif
298
+ # define INT2PTR(any,d) (any)(PTRV)(d)
299
+ #endif
300
+ #define NUM2PTR(any,d) (any)(PTRV)(d)
301
+ #define PTR2IV(p) INT2PTR(IV,p)
302
+ #define PTR2UV(p) INT2PTR(UV,p)
303
+ #define PTR2NV(p) NUM2PTR(NV,p)
304
+ #if PTRSIZE == LONGSIZE
305
+ # define PTR2ul(p) (unsigned long)(p)
306
+ #else
307
+ # define PTR2ul(p) INT2PTR(unsigned long,p)
308
+ #endif
309
+
310
+ #endif /* !INT2PTR */
311
+
312
+ #ifndef boolSV
313
+ # define boolSV(b) ((b) ? &PL_sv_yes : &PL_sv_no)
314
+ #endif
315
+
316
+ #ifndef gv_stashpvn
317
+ # define gv_stashpvn(str,len,flags) gv_stashpv(str,flags)
318
+ #endif
319
+
320
+ #ifndef newSVpvn
321
+ # define newSVpvn(data,len) ((len) ? newSVpv ((data), (len)) : newSVpv ("", 0))
322
+ #endif
323
+
324
+ #ifndef newRV_inc
325
+ /* Replace: 1 */
326
+ # define newRV_inc(sv) newRV(sv)
327
+ /* Replace: 0 */
328
+ #endif
329
+
330
+ /* DEFSV appears first in 5.004_56 */
331
+ #ifndef DEFSV
332
+ # define DEFSV GvSV(PL_defgv)
333
+ #endif
334
+
335
+ #ifndef SAVE_DEFSV
336
+ # define SAVE_DEFSV SAVESPTR(GvSV(PL_defgv))
337
+ #endif
338
+
339
+ #ifndef newRV_noinc
340
+ # ifdef __GNUC__
341
+ # define newRV_noinc(sv) \
342
+ ({ \
343
+ SV *nsv = (SV*)newRV(sv); \
344
+ SvREFCNT_dec(sv); \
345
+ nsv; \
346
+ })
347
+ # else
348
+ # if defined(USE_THREADS)
349
+ static SV * newRV_noinc (SV * sv)
350
+ {
351
+ SV *nsv = (SV*)newRV(sv);
352
+ SvREFCNT_dec(sv);
353
+ return nsv;
354
+ }
355
+ # else
356
+ # define newRV_noinc(sv) \
357
+ (PL_Sv=(SV*)newRV(sv), SvREFCNT_dec(sv), (SV*)PL_Sv)
358
+ # endif
359
+ # endif
360
+ #endif
361
+
362
+ /* Provide: newCONSTSUB */
363
+
364
+ /* newCONSTSUB from IO.xs is in the core starting with 5.004_63 */
365
+ #if (PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION < 63))
366
+
367
+ #if defined(NEED_newCONSTSUB)
368
+ static
369
+ #else
370
+ extern void newCONSTSUB(HV * stash, char * name, SV *sv);
371
+ #endif
372
+
373
+ #if defined(NEED_newCONSTSUB) || defined(NEED_newCONSTSUB_GLOBAL)
374
+ void
375
+ newCONSTSUB(stash,name,sv)
376
+ HV *stash;
377
+ char *name;
378
+ SV *sv;
379
+ {
380
+ U32 oldhints = PL_hints;
381
+ HV *old_cop_stash = PL_curcop->cop_stash;
382
+ HV *old_curstash = PL_curstash;
383
+ line_t oldline = PL_curcop->cop_line;
384
+ PL_curcop->cop_line = PL_copline;
385
+
386
+ PL_hints &= ~HINT_BLOCK_SCOPE;
387
+ if (stash)
388
+ PL_curstash = PL_curcop->cop_stash = stash;
389
+
390
+ newSUB(
391
+
392
+ #if (PERL_VERSION < 3) || ((PERL_VERSION == 3) && (PERL_SUBVERSION < 22))
393
+ /* before 5.003_22 */
394
+ start_subparse(),
395
+ #else
396
+ # if (PERL_VERSION == 3) && (PERL_SUBVERSION == 22)
397
+ /* 5.003_22 */
398
+ start_subparse(0),
399
+ # else
400
+ /* 5.003_23 onwards */
401
+ start_subparse(FALSE, 0),
402
+ # endif
403
+ #endif
404
+
405
+ newSVOP(OP_CONST, 0, newSVpv(name,0)),
406
+ newSVOP(OP_CONST, 0, &PL_sv_no), /* SvPV(&PL_sv_no) == "" -- GMB */
407
+ newSTATEOP(0, Nullch, newSVOP(OP_CONST, 0, sv))
408
+ );
409
+
410
+ PL_hints = oldhints;
411
+ PL_curcop->cop_stash = old_cop_stash;
412
+ PL_curstash = old_curstash;
413
+ PL_curcop->cop_line = oldline;
414
+ }
415
+ #endif
416
+
417
+ #endif /* newCONSTSUB */
418
+
419
+ #ifndef START_MY_CXT
420
+
421
+ /*
422
+ * Boilerplate macros for initializing and accessing interpreter-local
423
+ * data from C. All statics in extensions should be reworked to use
424
+ * this, if you want to make the extension thread-safe. See ext/re/re.xs
425
+ * for an example of the use of these macros.
426
+ *
427
+ * Code that uses these macros is responsible for the following:
428
+ * 1. #define MY_CXT_KEY to a unique string, e.g. "DynaLoader_guts"
429
+ * 2. Declare a typedef named my_cxt_t that is a structure that contains
430
+ * all the data that needs to be interpreter-local.
431
+ * 3. Use the START_MY_CXT macro after the declaration of my_cxt_t.
432
+ * 4. Use the MY_CXT_INIT macro such that it is called exactly once
433
+ * (typically put in the BOOT: section).
434
+ * 5. Use the members of the my_cxt_t structure everywhere as
435
+ * MY_CXT.member.
436
+ * 6. Use the dMY_CXT macro (a declaration) in all the functions that
437
+ * access MY_CXT.
438
+ */
439
+
440
+ #if defined(MULTIPLICITY) || defined(PERL_OBJECT) || \
441
+ defined(PERL_CAPI) || defined(PERL_IMPLICIT_CONTEXT)
442
+
443
+ /* This must appear in all extensions that define a my_cxt_t structure,
444
+ * right after the definition (i.e. at file scope). The non-threads
445
+ * case below uses it to declare the data as static. */
446
+ #define START_MY_CXT
447
+
448
+ #if (PERL_VERSION < 4 || (PERL_VERSION == 4 && PERL_SUBVERSION < 68 ))
449
+ /* Fetches the SV that keeps the per-interpreter data. */
450
+ #define dMY_CXT_SV \
451
+ SV *my_cxt_sv = perl_get_sv(MY_CXT_KEY, FALSE)
452
+ #else /* >= perl5.004_68 */
453
+ #define dMY_CXT_SV \
454
+ SV *my_cxt_sv = *hv_fetch(PL_modglobal, MY_CXT_KEY, \
455
+ sizeof(MY_CXT_KEY)-1, TRUE)
456
+ #endif /* < perl5.004_68 */
457
+
458
+ /* This declaration should be used within all functions that use the
459
+ * interpreter-local data. */
460
+ #define dMY_CXT \
461
+ dMY_CXT_SV; \
462
+ my_cxt_t *my_cxtp = INT2PTR(my_cxt_t*,SvUV(my_cxt_sv))
463
+
464
+ /* Creates and zeroes the per-interpreter data.
465
+ * (We allocate my_cxtp in a Perl SV so that it will be released when
466
+ * the interpreter goes away.) */
467
+ #define MY_CXT_INIT \
468
+ dMY_CXT_SV; \
469
+ /* newSV() allocates one more than needed */ \
470
+ my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\
471
+ Zero(my_cxtp, 1, my_cxt_t); \
472
+ sv_setuv(my_cxt_sv, PTR2UV(my_cxtp))
473
+
474
+ /* This macro must be used to access members of the my_cxt_t structure.
475
+ * e.g. MYCXT.some_data */
476
+ #define MY_CXT (*my_cxtp)
477
+
478
+ /* Judicious use of these macros can reduce the number of times dMY_CXT
479
+ * is used. Use is similar to pTHX, aTHX etc. */
480
+ #define pMY_CXT my_cxt_t *my_cxtp
481
+ #define pMY_CXT_ pMY_CXT,
482
+ #define _pMY_CXT ,pMY_CXT
483
+ #define aMY_CXT my_cxtp
484
+ #define aMY_CXT_ aMY_CXT,
485
+ #define _aMY_CXT ,aMY_CXT
486
+
487
+ #else /* single interpreter */
488
+
489
+ #define START_MY_CXT static my_cxt_t my_cxt;
490
+ #define dMY_CXT_SV dNOOP
491
+ #define dMY_CXT dNOOP
492
+ #define MY_CXT_INIT NOOP
493
+ #define MY_CXT my_cxt
494
+
495
+ #define pMY_CXT void
496
+ #define pMY_CXT_
497
+ #define _pMY_CXT
498
+ #define aMY_CXT
499
+ #define aMY_CXT_
500
+ #define _aMY_CXT
501
+
502
+ #endif
503
+
504
+ #endif /* START_MY_CXT */
505
+
506
+ #ifndef IVdf
507
+ # if IVSIZE == LONGSIZE
508
+ # define IVdf "ld"
509
+ # define UVuf "lu"
510
+ # define UVof "lo"
511
+ # define UVxf "lx"
512
+ # define UVXf "lX"
513
+ # else
514
+ # if IVSIZE == INTSIZE
515
+ # define IVdf "d"
516
+ # define UVuf "u"
517
+ # define UVof "o"
518
+ # define UVxf "x"
519
+ # define UVXf "X"
520
+ # endif
521
+ # endif
522
+ #endif
523
+
524
+ #ifndef NVef
525
+ # if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE) && \
526
+ defined(PERL_PRIfldbl) /* Not very likely, but let's try anyway. */
527
+ # define NVef PERL_PRIeldbl
528
+ # define NVff PERL_PRIfldbl
529
+ # define NVgf PERL_PRIgldbl
530
+ # else
531
+ # define NVef "e"
532
+ # define NVff "f"
533
+ # define NVgf "g"
534
+ # endif
535
+ #endif
536
+
537
+ #ifndef AvFILLp /* Older perls (<=5.003) lack AvFILLp */
538
+ # define AvFILLp AvFILL
539
+ #endif
540
+
541
+ #ifdef SvPVbyte
542
+ # if PERL_REVISION == 5 && PERL_VERSION < 7
543
+ /* SvPVbyte does not work in perl-5.6.1, borrowed version for 5.7.3 */
544
+ # undef SvPVbyte
545
+ # define SvPVbyte(sv, lp) \
546
+ ((SvFLAGS(sv) & (SVf_POK|SVf_UTF8)) == (SVf_POK) \
547
+ ? ((lp = SvCUR(sv)), SvPVX(sv)) : my_sv_2pvbyte(aTHX_ sv, &lp))
548
+ static char *
549
+ my_sv_2pvbyte(pTHX_ register SV *sv, STRLEN *lp)
550
+ {
551
+ sv_utf8_downgrade(sv,0);
552
+ return SvPV(sv,*lp);
553
+ }
554
+ # endif
555
+ #else
556
+ # define SvPVbyte SvPV
557
+ #endif
558
+
559
+ #ifndef SvPV_nolen
560
+ # define SvPV_nolen(sv) \
561
+ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \
562
+ ? SvPVX(sv) : sv_2pv_nolen(sv))
563
+ static char *
564
+ sv_2pv_nolen(pTHX_ register SV *sv)
565
+ {
566
+ STRLEN n_a;
567
+ return sv_2pv(sv, &n_a);
568
+ }
569
+ #endif
570
+
571
+ #ifndef get_cv
572
+ # define get_cv(name,create) perl_get_cv(name,create)
573
+ #endif
574
+
575
+ #ifndef get_sv
576
+ # define get_sv(name,create) perl_get_sv(name,create)
577
+ #endif
578
+
579
+ #ifndef get_av
580
+ # define get_av(name,create) perl_get_av(name,create)
581
+ #endif
582
+
583
+ #ifndef get_hv
584
+ # define get_hv(name,create) perl_get_hv(name,create)
585
+ #endif
586
+
587
+ #ifndef call_argv
588
+ # define call_argv perl_call_argv
589
+ #endif
590
+
591
+ #ifndef call_method
592
+ # define call_method perl_call_method
593
+ #endif
594
+
595
+ #ifndef call_pv
596
+ # define call_pv perl_call_pv
597
+ #endif
598
+
599
+ #ifndef call_sv
600
+ # define call_sv perl_call_sv
601
+ #endif
602
+
603
+ #ifndef eval_pv
604
+ # define eval_pv perl_eval_pv
605
+ #endif
606
+
607
+ #ifndef eval_sv
608
+ # define eval_sv perl_eval_sv
609
+ #endif
610
+
611
+ #ifndef PERL_SCAN_GREATER_THAN_UV_MAX
612
+ # define PERL_SCAN_GREATER_THAN_UV_MAX 0x02
613
+ #endif
614
+
615
+ #ifndef PERL_SCAN_SILENT_ILLDIGIT
616
+ # define PERL_SCAN_SILENT_ILLDIGIT 0x04
617
+ #endif
618
+
619
+ #ifndef PERL_SCAN_ALLOW_UNDERSCORES
620
+ # define PERL_SCAN_ALLOW_UNDERSCORES 0x01
621
+ #endif
622
+
623
+ #ifndef PERL_SCAN_DISALLOW_PREFIX
624
+ # define PERL_SCAN_DISALLOW_PREFIX 0x02
625
+ #endif
626
+
627
+ #if (PERL_VERSION > 6) || ((PERL_VERSION == 6) && (PERL_SUBVERSION >= 1))
628
+ #define I32_CAST
629
+ #else
630
+ #define I32_CAST (I32*)
631
+ #endif
632
+
633
+ #ifndef grok_hex
634
+ static UV _grok_hex (char *string, STRLEN *len, I32 *flags, NV *result) {
635
+ NV r = scan_hex(string, *len, I32_CAST len);
636
+ if (r > UV_MAX) {
637
+ *flags |= PERL_SCAN_GREATER_THAN_UV_MAX;
638
+ if (result) *result = r;
639
+ return UV_MAX;
640
+ }
641
+ return (UV)r;
642
+ }
643
+
644
+ # define grok_hex(string, len, flags, result) \
645
+ _grok_hex((string), (len), (flags), (result))
646
+ #endif
647
+
648
+ #ifndef grok_oct
649
+ static UV _grok_oct (char *string, STRLEN *len, I32 *flags, NV *result) {
650
+ NV r = scan_oct(string, *len, I32_CAST len);
651
+ if (r > UV_MAX) {
652
+ *flags |= PERL_SCAN_GREATER_THAN_UV_MAX;
653
+ if (result) *result = r;
654
+ return UV_MAX;
655
+ }
656
+ return (UV)r;
657
+ }
658
+
659
+ # define grok_oct(string, len, flags, result) \
660
+ _grok_oct((string), (len), (flags), (result))
661
+ #endif
662
+
663
+ #if !defined(grok_bin) && defined(scan_bin)
664
+ static UV _grok_bin (char *string, STRLEN *len, I32 *flags, NV *result) {
665
+ NV r = scan_bin(string, *len, I32_CAST len);
666
+ if (r > UV_MAX) {
667
+ *flags |= PERL_SCAN_GREATER_THAN_UV_MAX;
668
+ if (result) *result = r;
669
+ return UV_MAX;
670
+ }
671
+ return (UV)r;
672
+ }
673
+
674
+ # define grok_bin(string, len, flags, result) \
675
+ _grok_bin((string), (len), (flags), (result))
676
+ #endif
677
+
678
+ #ifndef IN_LOCALE
679
+ # define IN_LOCALE \
680
+ (PL_curcop == &PL_compiling ? IN_LOCALE_COMPILETIME : IN_LOCALE_RUNTIME)
681
+ #endif
682
+
683
+ #ifndef IN_LOCALE_RUNTIME
684
+ # define IN_LOCALE_RUNTIME (PL_curcop->op_private & HINT_LOCALE)
685
+ #endif
686
+
687
+ #ifndef IN_LOCALE_COMPILETIME
688
+ # define IN_LOCALE_COMPILETIME (PL_hints & HINT_LOCALE)
689
+ #endif
690
+
691
+
692
+ #ifndef IS_NUMBER_IN_UV
693
+ # define IS_NUMBER_IN_UV 0x01
694
+ # define IS_NUMBER_GREATER_THAN_UV_MAX 0x02
695
+ # define IS_NUMBER_NOT_INT 0x04
696
+ # define IS_NUMBER_NEG 0x08
697
+ # define IS_NUMBER_INFINITY 0x10
698
+ # define IS_NUMBER_NAN 0x20
699
+ #endif
700
+
701
+ #ifndef grok_numeric_radix
702
+ # define GROK_NUMERIC_RADIX(sp, send) grok_numeric_radix(aTHX_ sp, send)
703
+
704
+ #define grok_numeric_radix Perl_grok_numeric_radix
705
+
706
+ bool
707
+ Perl_grok_numeric_radix(pTHX_ const char **sp, const char *send)
708
+ {
709
+ #ifdef USE_LOCALE_NUMERIC
710
+ #if (PERL_VERSION > 6) || ((PERL_VERSION == 6) && (PERL_SUBVERSION >= 1))
711
+ if (PL_numeric_radix_sv && IN_LOCALE) {
712
+ STRLEN len;
713
+ char* radix = SvPV(PL_numeric_radix_sv, len);
714
+ if (*sp + len <= send && memEQ(*sp, radix, len)) {
715
+ *sp += len;
716
+ return TRUE;
717
+ }
718
+ }
719
+ #else
720
+ /* pre5.6.0 perls don't have PL_numeric_radix_sv so the radix
721
+ * must manually be requested from locale.h */
722
+ #include <locale.h>
723
+ struct lconv *lc = localeconv();
724
+ char *radix = lc->decimal_point;
725
+ if (radix && IN_LOCALE) {
726
+ STRLEN len = strlen(radix);
727
+ if (*sp + len <= send && memEQ(*sp, radix, len)) {
728
+ *sp += len;
729
+ return TRUE;
730
+ }
731
+ }
732
+ #endif /* PERL_VERSION */
733
+ #endif /* USE_LOCALE_NUMERIC */
734
+ /* always try "." if numeric radix didn't match because
735
+ * we may have data from different locales mixed */
736
+ if (*sp < send && **sp == '.') {
737
+ ++*sp;
738
+ return TRUE;
739
+ }
740
+ return FALSE;
741
+ }
742
+ #endif /* grok_numeric_radix */
743
+
744
+ #ifndef grok_number
745
+
746
+ #define grok_number Perl_grok_number
747
+
748
+ int
749
+ Perl_grok_number(pTHX_ const char *pv, STRLEN len, UV *valuep)
750
+ {
751
+ const char *s = pv;
752
+ const char *send = pv + len;
753
+ const UV max_div_10 = UV_MAX / 10;
754
+ const char max_mod_10 = UV_MAX % 10;
755
+ int numtype = 0;
756
+ int sawinf = 0;
757
+ int sawnan = 0;
758
+
759
+ while (s < send && isSPACE(*s))
760
+ s++;
761
+ if (s == send) {
762
+ return 0;
763
+ } else if (*s == '-') {
764
+ s++;
765
+ numtype = IS_NUMBER_NEG;
766
+ }
767
+ else if (*s == '+')
768
+ s++;
769
+
770
+ if (s == send)
771
+ return 0;
772
+
773
+ /* next must be digit or the radix separator or beginning of infinity */
774
+ if (isDIGIT(*s)) {
775
+ /* UVs are at least 32 bits, so the first 9 decimal digits cannot
776
+ overflow. */
777
+ UV value = *s - '0';
778
+ /* This construction seems to be more optimiser friendly.
779
+ (without it gcc does the isDIGIT test and the *s - '0' separately)
780
+ With it gcc on arm is managing 6 instructions (6 cycles) per digit.
781
+ In theory the optimiser could deduce how far to unroll the loop
782
+ before checking for overflow. */
783
+ if (++s < send) {
784
+ int digit = *s - '0';
785
+ if (digit >= 0 && digit <= 9) {
786
+ value = value * 10 + digit;
787
+ if (++s < send) {
788
+ digit = *s - '0';
789
+ if (digit >= 0 && digit <= 9) {
790
+ value = value * 10 + digit;
791
+ if (++s < send) {
792
+ digit = *s - '0';
793
+ if (digit >= 0 && digit <= 9) {
794
+ value = value * 10 + digit;
795
+ if (++s < send) {
796
+ digit = *s - '0';
797
+ if (digit >= 0 && digit <= 9) {
798
+ value = value * 10 + digit;
799
+ if (++s < send) {
800
+ digit = *s - '0';
801
+ if (digit >= 0 && digit <= 9) {
802
+ value = value * 10 + digit;
803
+ if (++s < send) {
804
+ digit = *s - '0';
805
+ if (digit >= 0 && digit <= 9) {
806
+ value = value * 10 + digit;
807
+ if (++s < send) {
808
+ digit = *s - '0';
809
+ if (digit >= 0 && digit <= 9) {
810
+ value = value * 10 + digit;
811
+ if (++s < send) {
812
+ digit = *s - '0';
813
+ if (digit >= 0 && digit <= 9) {
814
+ value = value * 10 + digit;
815
+ if (++s < send) {
816
+ /* Now got 9 digits, so need to check
817
+ each time for overflow. */
818
+ digit = *s - '0';
819
+ while (digit >= 0 && digit <= 9
820
+ && (value < max_div_10
821
+ || (value == max_div_10
822
+ && digit <= max_mod_10))) {
823
+ value = value * 10 + digit;
824
+ if (++s < send)
825
+ digit = *s - '0';
826
+ else
827
+ break;
828
+ }
829
+ if (digit >= 0 && digit <= 9
830
+ && (s < send)) {
831
+ /* value overflowed.
832
+ skip the remaining digits, don't
833
+ worry about setting *valuep. */
834
+ do {
835
+ s++;
836
+ } while (s < send && isDIGIT(*s));
837
+ numtype |=
838
+ IS_NUMBER_GREATER_THAN_UV_MAX;
839
+ goto skip_value;
840
+ }
841
+ }
842
+ }
843
+ }
844
+ }
845
+ }
846
+ }
847
+ }
848
+ }
849
+ }
850
+ }
851
+ }
852
+ }
853
+ }
854
+ }
855
+ }
856
+ }
857
+ }
858
+ numtype |= IS_NUMBER_IN_UV;
859
+ if (valuep)
860
+ *valuep = value;
861
+
862
+ skip_value:
863
+ if (GROK_NUMERIC_RADIX(&s, send)) {
864
+ numtype |= IS_NUMBER_NOT_INT;
865
+ while (s < send && isDIGIT(*s)) /* optional digits after the radix */
866
+ s++;
867
+ }
868
+ }
869
+ else if (GROK_NUMERIC_RADIX(&s, send)) {
870
+ numtype |= IS_NUMBER_NOT_INT | IS_NUMBER_IN_UV; /* valuep assigned below */
871
+ /* no digits before the radix means we need digits after it */
872
+ if (s < send && isDIGIT(*s)) {
873
+ do {
874
+ s++;
875
+ } while (s < send && isDIGIT(*s));
876
+ if (valuep) {
877
+ /* integer approximation is valid - it's 0. */
878
+ *valuep = 0;
879
+ }
880
+ }
881
+ else
882
+ return 0;
883
+ } else if (*s == 'I' || *s == 'i') {
884
+ s++; if (s == send || (*s != 'N' && *s != 'n')) return 0;
885
+ s++; if (s == send || (*s != 'F' && *s != 'f')) return 0;
886
+ s++; if (s < send && (*s == 'I' || *s == 'i')) {
887
+ s++; if (s == send || (*s != 'N' && *s != 'n')) return 0;
888
+ s++; if (s == send || (*s != 'I' && *s != 'i')) return 0;
889
+ s++; if (s == send || (*s != 'T' && *s != 't')) return 0;
890
+ s++; if (s == send || (*s != 'Y' && *s != 'y')) return 0;
891
+ s++;
892
+ }
893
+ sawinf = 1;
894
+ } else if (*s == 'N' || *s == 'n') {
895
+ /* XXX TODO: There are signaling NaNs and quiet NaNs. */
896
+ s++; if (s == send || (*s != 'A' && *s != 'a')) return 0;
897
+ s++; if (s == send || (*s != 'N' && *s != 'n')) return 0;
898
+ s++;
899
+ sawnan = 1;
900
+ } else
901
+ return 0;
902
+
903
+ if (sawinf) {
904
+ numtype &= IS_NUMBER_NEG; /* Keep track of sign */
905
+ numtype |= IS_NUMBER_INFINITY | IS_NUMBER_NOT_INT;
906
+ } else if (sawnan) {
907
+ numtype &= IS_NUMBER_NEG; /* Keep track of sign */
908
+ numtype |= IS_NUMBER_NAN | IS_NUMBER_NOT_INT;
909
+ } else if (s < send) {
910
+ /* we can have an optional exponent part */
911
+ if (*s == 'e' || *s == 'E') {
912
+ /* The only flag we keep is sign. Blow away any "it's UV" */
913
+ numtype &= IS_NUMBER_NEG;
914
+ numtype |= IS_NUMBER_NOT_INT;
915
+ s++;
916
+ if (s < send && (*s == '-' || *s == '+'))
917
+ s++;
918
+ if (s < send && isDIGIT(*s)) {
919
+ do {
920
+ s++;
921
+ } while (s < send && isDIGIT(*s));
922
+ }
923
+ else
924
+ return 0;
925
+ }
926
+ }
927
+ while (s < send && isSPACE(*s))
928
+ s++;
929
+ if (s >= send)
930
+ return numtype;
931
+ if (len == 10 && memEQ(pv, "0 but true", 10)) {
932
+ if (valuep)
933
+ *valuep = 0;
934
+ return IS_NUMBER_IN_UV;
935
+ }
936
+ return 0;
937
+ }
938
+ #endif /* grok_number */
939
+
940
+ #ifndef PERL_MAGIC_sv
941
+ # define PERL_MAGIC_sv '\0'
942
+ #endif
943
+
944
+ #ifndef PERL_MAGIC_overload
945
+ # define PERL_MAGIC_overload 'A'
946
+ #endif
947
+
948
+ #ifndef PERL_MAGIC_overload_elem
949
+ # define PERL_MAGIC_overload_elem 'a'
950
+ #endif
951
+
952
+ #ifndef PERL_MAGIC_overload_table
953
+ # define PERL_MAGIC_overload_table 'c'
954
+ #endif
955
+
956
+ #ifndef PERL_MAGIC_bm
957
+ # define PERL_MAGIC_bm 'B'
958
+ #endif
959
+
960
+ #ifndef PERL_MAGIC_regdata
961
+ # define PERL_MAGIC_regdata 'D'
962
+ #endif
963
+
964
+ #ifndef PERL_MAGIC_regdatum
965
+ # define PERL_MAGIC_regdatum 'd'
966
+ #endif
967
+
968
+ #ifndef PERL_MAGIC_env
969
+ # define PERL_MAGIC_env 'E'
970
+ #endif
971
+
972
+ #ifndef PERL_MAGIC_envelem
973
+ # define PERL_MAGIC_envelem 'e'
974
+ #endif
975
+
976
+ #ifndef PERL_MAGIC_fm
977
+ # define PERL_MAGIC_fm 'f'
978
+ #endif
979
+
980
+ #ifndef PERL_MAGIC_regex_global
981
+ # define PERL_MAGIC_regex_global 'g'
982
+ #endif
983
+
984
+ #ifndef PERL_MAGIC_isa
985
+ # define PERL_MAGIC_isa 'I'
986
+ #endif
987
+
988
+ #ifndef PERL_MAGIC_isaelem
989
+ # define PERL_MAGIC_isaelem 'i'
990
+ #endif
991
+
992
+ #ifndef PERL_MAGIC_nkeys
993
+ # define PERL_MAGIC_nkeys 'k'
994
+ #endif
995
+
996
+ #ifndef PERL_MAGIC_dbfile
997
+ # define PERL_MAGIC_dbfile 'L'
998
+ #endif
999
+
1000
+ #ifndef PERL_MAGIC_dbline
1001
+ # define PERL_MAGIC_dbline 'l'
1002
+ #endif
1003
+
1004
+ #ifndef PERL_MAGIC_mutex
1005
+ # define PERL_MAGIC_mutex 'm'
1006
+ #endif
1007
+
1008
+ #ifndef PERL_MAGIC_shared
1009
+ # define PERL_MAGIC_shared 'N'
1010
+ #endif
1011
+
1012
+ #ifndef PERL_MAGIC_shared_scalar
1013
+ # define PERL_MAGIC_shared_scalar 'n'
1014
+ #endif
1015
+
1016
+ #ifndef PERL_MAGIC_collxfrm
1017
+ # define PERL_MAGIC_collxfrm 'o'
1018
+ #endif
1019
+
1020
+ #ifndef PERL_MAGIC_tied
1021
+ # define PERL_MAGIC_tied 'P'
1022
+ #endif
1023
+
1024
+ #ifndef PERL_MAGIC_tiedelem
1025
+ # define PERL_MAGIC_tiedelem 'p'
1026
+ #endif
1027
+
1028
+ #ifndef PERL_MAGIC_tiedscalar
1029
+ # define PERL_MAGIC_tiedscalar 'q'
1030
+ #endif
1031
+
1032
+ #ifndef PERL_MAGIC_qr
1033
+ # define PERL_MAGIC_qr 'r'
1034
+ #endif
1035
+
1036
+ #ifndef PERL_MAGIC_sig
1037
+ # define PERL_MAGIC_sig 'S'
1038
+ #endif
1039
+
1040
+ #ifndef PERL_MAGIC_sigelem
1041
+ # define PERL_MAGIC_sigelem 's'
1042
+ #endif
1043
+
1044
+ #ifndef PERL_MAGIC_taint
1045
+ # define PERL_MAGIC_taint 't'
1046
+ #endif
1047
+
1048
+ #ifndef PERL_MAGIC_uvar
1049
+ # define PERL_MAGIC_uvar 'U'
1050
+ #endif
1051
+
1052
+ #ifndef PERL_MAGIC_uvar_elem
1053
+ # define PERL_MAGIC_uvar_elem 'u'
1054
+ #endif
1055
+
1056
+ #ifndef PERL_MAGIC_vstring
1057
+ # define PERL_MAGIC_vstring 'V'
1058
+ #endif
1059
+
1060
+ #ifndef PERL_MAGIC_vec
1061
+ # define PERL_MAGIC_vec 'v'
1062
+ #endif
1063
+
1064
+ #ifndef PERL_MAGIC_utf8
1065
+ # define PERL_MAGIC_utf8 'w'
1066
+ #endif
1067
+
1068
+ #ifndef PERL_MAGIC_substr
1069
+ # define PERL_MAGIC_substr 'x'
1070
+ #endif
1071
+
1072
+ #ifndef PERL_MAGIC_defelem
1073
+ # define PERL_MAGIC_defelem 'y'
1074
+ #endif
1075
+
1076
+ #ifndef PERL_MAGIC_glob
1077
+ # define PERL_MAGIC_glob '*'
1078
+ #endif
1079
+
1080
+ #ifndef PERL_MAGIC_arylen
1081
+ # define PERL_MAGIC_arylen '#'
1082
+ #endif
1083
+
1084
+ #ifndef PERL_MAGIC_pos
1085
+ # define PERL_MAGIC_pos '.'
1086
+ #endif
1087
+
1088
+ #ifndef PERL_MAGIC_backref
1089
+ # define PERL_MAGIC_backref '<'
1090
+ #endif
1091
+
1092
+ #ifndef PERL_MAGIC_ext
1093
+ # define PERL_MAGIC_ext '~'
1094
+ #endif
1095
+
1096
+ #endif /* _P_P_PORTABILITY_H_ */
1097
+
1098
+ /* End of File ppport.h */