webruby 0.2.2 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (245) hide show
  1. checksums.yaml +4 -4
  2. data/lib/webruby/config.rb +4 -9
  3. data/lib/webruby/rake/files.rake +2 -2
  4. data/modules/emscripten/AUTHORS +9 -1
  5. data/modules/emscripten/CONTRIBUTING.markdown +5 -0
  6. data/modules/emscripten/ChangeLog +435 -0
  7. data/modules/emscripten/cmake/Modules/FindOpenAL.cmake +26 -0
  8. data/modules/emscripten/cmake/Platform/Emscripten.cmake +9 -2
  9. data/modules/emscripten/em++ +0 -2
  10. data/modules/emscripten/emcc +92 -32
  11. data/modules/emscripten/emlink.py +16 -13
  12. data/modules/emscripten/emmake +1 -1
  13. data/modules/emscripten/emrun +918 -0
  14. data/modules/emscripten/emrun.bat +2 -0
  15. data/modules/emscripten/emscripten.py +545 -20
  16. data/modules/emscripten/src/analyzer.js +6 -1
  17. data/modules/emscripten/src/compiler.js +25 -16
  18. data/modules/emscripten/src/emrun_postjs.js +20 -0
  19. data/modules/emscripten/{tests → src}/hello_world.js +0 -0
  20. data/modules/emscripten/src/intertyper.js +45 -16
  21. data/modules/emscripten/src/jsifier.js +78 -48
  22. data/modules/emscripten/src/library.js +381 -96
  23. data/modules/emscripten/src/library_browser.js +50 -53
  24. data/modules/emscripten/src/library_egl.js +66 -24
  25. data/modules/emscripten/src/library_fs.js +122 -90
  26. data/modules/emscripten/src/library_gl.js +739 -353
  27. data/modules/emscripten/src/library_glfw.js +9 -3
  28. data/modules/emscripten/src/library_glut.js +10 -5
  29. data/modules/emscripten/src/library_idbfs.js +14 -14
  30. data/modules/emscripten/src/library_memfs.js +65 -41
  31. data/modules/emscripten/src/library_nodefs.js +61 -9
  32. data/modules/emscripten/src/library_openal.js +4 -4
  33. data/modules/emscripten/src/library_path.js +9 -13
  34. data/modules/emscripten/src/library_sdl.js +301 -64
  35. data/modules/emscripten/src/library_sockfs.js +7 -5
  36. data/modules/emscripten/src/modules.js +62 -22
  37. data/modules/emscripten/src/parseTools.js +135 -102
  38. data/modules/emscripten/src/postamble.js +3 -4
  39. data/modules/emscripten/src/preamble.js +49 -29
  40. data/modules/emscripten/src/proxyClient.js +1 -1
  41. data/modules/emscripten/src/proxyWorker.js +10 -10
  42. data/modules/emscripten/src/relooper/Relooper.cpp +15 -4
  43. data/modules/emscripten/src/runtime.js +32 -8
  44. data/modules/emscripten/src/settings.js +25 -8
  45. data/modules/emscripten/src/shell.html +6 -3
  46. data/modules/emscripten/src/shell.js +13 -11
  47. data/modules/emscripten/src/simd.js +602 -432
  48. data/modules/emscripten/src/struct_info.json +22 -2
  49. data/modules/emscripten/src/utility.js +32 -17
  50. data/modules/emscripten/system/include/SDL/SDL_events.h +1 -0
  51. data/modules/emscripten/system/include/compat/ctype.h +17 -0
  52. data/modules/emscripten/system/include/compat/wchar.h +23 -0
  53. data/modules/emscripten/system/include/compat/wctype.h +23 -0
  54. data/modules/emscripten/system/include/emscripten/emmintrin.h +87 -0
  55. data/modules/emscripten/system/include/emscripten/emscripten.h +30 -4
  56. data/modules/emscripten/system/include/emscripten/vector.h +29 -1
  57. data/modules/emscripten/system/include/emscripten/xmmintrin.h +131 -0
  58. data/modules/emscripten/system/include/libcxx/CREDITS.TXT +9 -1
  59. data/modules/emscripten/system/include/libcxx/__bit_reference +8 -8
  60. data/modules/emscripten/system/include/libcxx/__config +95 -17
  61. data/modules/emscripten/system/include/libcxx/__debug +25 -4
  62. data/modules/emscripten/system/include/libcxx/__functional_03 +7 -7
  63. data/modules/emscripten/system/include/libcxx/__functional_base +169 -9
  64. data/modules/emscripten/system/include/libcxx/__functional_base_03 +1 -1
  65. data/modules/emscripten/system/include/libcxx/__hash_table +25 -25
  66. data/modules/emscripten/system/include/libcxx/__locale +21 -19
  67. data/modules/emscripten/system/include/libcxx/__mutex_base +2 -33
  68. data/modules/emscripten/system/include/libcxx/__split_buffer +9 -9
  69. data/modules/emscripten/system/include/libcxx/__std_stream +14 -0
  70. data/modules/emscripten/system/include/libcxx/__tree +35 -26
  71. data/modules/emscripten/system/include/libcxx/__tuple +15 -15
  72. data/modules/emscripten/system/include/libcxx/__tuple_03 +2 -2
  73. data/modules/emscripten/system/include/libcxx/__undef_min_max +8 -0
  74. data/modules/emscripten/system/include/libcxx/algorithm +121 -110
  75. data/modules/emscripten/system/include/libcxx/array +15 -15
  76. data/modules/emscripten/system/include/libcxx/bitset +4 -4
  77. data/modules/emscripten/system/include/libcxx/chrono +51 -17
  78. data/modules/emscripten/system/include/libcxx/cmath +25 -23
  79. data/modules/emscripten/system/include/libcxx/codecvt +21 -18
  80. data/modules/emscripten/system/include/libcxx/complex +48 -7
  81. data/modules/emscripten/system/include/libcxx/cstddef +1 -1
  82. data/modules/emscripten/system/include/libcxx/cstdio +8 -1
  83. data/modules/emscripten/system/include/libcxx/cstdlib +1 -1
  84. data/modules/emscripten/system/include/libcxx/cwchar +1 -1
  85. data/modules/emscripten/system/include/libcxx/deque +26 -12
  86. data/modules/emscripten/system/include/libcxx/dynarray +311 -0
  87. data/modules/emscripten/system/include/libcxx/exception +4 -4
  88. data/modules/emscripten/system/include/libcxx/ext/__hash +3 -3
  89. data/modules/emscripten/system/include/libcxx/ext/hash_map +19 -15
  90. data/modules/emscripten/system/include/libcxx/ext/hash_set +7 -3
  91. data/modules/emscripten/system/include/libcxx/forward_list +33 -7
  92. data/modules/emscripten/system/include/libcxx/fstream +4 -4
  93. data/modules/emscripten/system/include/libcxx/functional +200 -170
  94. data/modules/emscripten/system/include/libcxx/future +83 -39
  95. data/modules/emscripten/system/include/libcxx/initializer_list +24 -11
  96. data/modules/emscripten/system/include/libcxx/iomanip +147 -0
  97. data/modules/emscripten/system/include/libcxx/ios +24 -16
  98. data/modules/emscripten/system/include/libcxx/iosfwd +19 -19
  99. data/modules/emscripten/system/include/libcxx/istream +13 -8
  100. data/modules/emscripten/system/include/libcxx/iterator +108 -417
  101. data/modules/emscripten/system/include/libcxx/limits +8 -4
  102. data/modules/emscripten/system/include/libcxx/list +28 -8
  103. data/modules/emscripten/system/include/libcxx/locale +153 -390
  104. data/modules/emscripten/system/include/libcxx/map +280 -100
  105. data/modules/emscripten/system/include/libcxx/memory +49 -97
  106. data/modules/emscripten/system/include/libcxx/mutex +2 -2
  107. data/modules/emscripten/system/include/libcxx/new +43 -14
  108. data/modules/emscripten/system/include/libcxx/numeric +2 -2
  109. data/modules/emscripten/system/include/libcxx/optional +697 -0
  110. data/modules/emscripten/system/include/libcxx/ostream +17 -8
  111. data/modules/emscripten/system/include/libcxx/queue +5 -5
  112. data/modules/emscripten/system/include/libcxx/random +53 -51
  113. data/modules/emscripten/system/include/libcxx/ratio +11 -11
  114. data/modules/emscripten/system/include/libcxx/readme.txt +1 -1
  115. data/modules/emscripten/system/include/libcxx/regex +23 -20
  116. data/modules/emscripten/system/include/libcxx/scoped_allocator +1 -1
  117. data/modules/emscripten/system/include/libcxx/set +166 -2
  118. data/modules/emscripten/system/include/libcxx/shared_mutex +419 -0
  119. data/modules/emscripten/system/include/libcxx/sstream +4 -4
  120. data/modules/emscripten/system/include/libcxx/stack +3 -3
  121. data/modules/emscripten/system/include/libcxx/streambuf +5 -5
  122. data/modules/emscripten/system/include/libcxx/string +372 -324
  123. data/modules/emscripten/system/include/libcxx/support/ibm/limits.h +99 -0
  124. data/modules/emscripten/system/include/libcxx/support/ibm/support.h +54 -0
  125. data/modules/emscripten/system/include/libcxx/support/ibm/xlocale.h +326 -0
  126. data/modules/emscripten/system/include/libcxx/support/win32/limits_win32.h +6 -6
  127. data/modules/emscripten/system/include/libcxx/support/win32/locale_win32.h +15 -15
  128. data/modules/emscripten/system/include/libcxx/support/win32/math_win32.h +2 -0
  129. data/modules/emscripten/system/include/libcxx/support/win32/support.h +6 -1
  130. data/modules/emscripten/system/include/libcxx/system_error +14 -8
  131. data/modules/emscripten/system/include/libcxx/thread +7 -8
  132. data/modules/emscripten/system/include/libcxx/tuple +29 -88
  133. data/modules/emscripten/system/include/libcxx/type_traits +253 -209
  134. data/modules/emscripten/system/include/libcxx/typeindex +3 -3
  135. data/modules/emscripten/system/include/libcxx/unordered_map +162 -101
  136. data/modules/emscripten/system/include/libcxx/unordered_set +79 -2
  137. data/modules/emscripten/system/include/libcxx/utility +20 -20
  138. data/modules/emscripten/system/include/libcxx/valarray +23 -23
  139. data/modules/emscripten/system/include/libcxx/vector +114 -91
  140. data/modules/emscripten/system/lib/libc/musl/src/regex/regcomp.c +3352 -0
  141. data/modules/emscripten/system/lib/libc/musl/src/regex/regerror.c +35 -0
  142. data/modules/emscripten/system/lib/libc/musl/src/regex/regexec.c +1011 -0
  143. data/modules/emscripten/system/lib/libc/musl/src/regex/tre-mem.c +158 -0
  144. data/modules/emscripten/system/lib/libc/musl/src/regex/tre.h +231 -0
  145. data/modules/emscripten/system/lib/libcextra.symbols +7 -0
  146. data/modules/emscripten/system/lib/libcxx/CREDITS.TXT +9 -1
  147. data/modules/emscripten/system/lib/libcxx/algorithm.cpp +1 -0
  148. data/modules/emscripten/system/lib/libcxx/debug.cpp +66 -42
  149. data/modules/emscripten/system/lib/libcxx/exception.cpp +88 -16
  150. data/modules/emscripten/system/lib/libcxx/future.cpp +6 -0
  151. data/modules/emscripten/system/lib/libcxx/ios.cpp +7 -2
  152. data/modules/emscripten/system/lib/libcxx/iostream.cpp +8 -8
  153. data/modules/emscripten/system/lib/libcxx/locale.cpp +38 -11
  154. data/modules/emscripten/system/lib/libcxx/mutex.cpp +3 -0
  155. data/modules/emscripten/system/lib/libcxx/new.cpp +44 -10
  156. data/modules/emscripten/system/lib/libcxx/optional.cpp +25 -0
  157. data/modules/emscripten/system/lib/libcxx/random.cpp +26 -0
  158. data/modules/emscripten/system/lib/libcxx/readme.txt +1 -1
  159. data/modules/emscripten/system/lib/libcxx/shared_mutex.cpp +101 -0
  160. data/modules/emscripten/system/lib/libcxx/stdexcept.cpp +11 -7
  161. data/modules/emscripten/system/lib/libcxx/string.cpp +3 -1
  162. data/modules/emscripten/system/lib/libcxx/strstream.cpp +7 -7
  163. data/modules/emscripten/system/lib/libcxx/support/win32/locale_win32.cpp +12 -13
  164. data/modules/emscripten/system/lib/libcxx/support/win32/support.cpp +33 -36
  165. data/modules/emscripten/system/lib/libcxx/symbols +187 -168
  166. data/modules/emscripten/system/lib/libcxx/system_error.cpp +1 -0
  167. data/modules/emscripten/system/lib/libcxx/thread.cpp +7 -3
  168. data/modules/emscripten/system/lib/libcxx/typeinfo.cpp +9 -6
  169. data/modules/emscripten/system/lib/libcxx/valarray.cpp +2 -0
  170. data/modules/emscripten/third_party/lzma.js/doit.bat +4 -0
  171. data/modules/emscripten/third_party/lzma.js/doit.sh +9 -2
  172. data/modules/emscripten/tools/cache.py +5 -7
  173. data/modules/emscripten/tools/cache.pyc +0 -0
  174. data/modules/emscripten/tools/eliminator/asm-eliminator-test-output.js +7 -0
  175. data/modules/emscripten/tools/eliminator/asm-eliminator-test.js +9 -1
  176. data/modules/emscripten/tools/eliminator/eliminator-test-output.js +3 -0
  177. data/modules/emscripten/tools/eliminator/eliminator-test.js +9 -1
  178. data/modules/emscripten/tools/file_packager.py +93 -50
  179. data/modules/emscripten/tools/js-optimizer.js +98 -48
  180. data/modules/emscripten/tools/js_optimizer.py +4 -4
  181. data/modules/emscripten/tools/js_optimizer.pyc +0 -0
  182. data/modules/emscripten/tools/jsrun.py +1 -1
  183. data/modules/emscripten/tools/jsrun.pyc +0 -0
  184. data/modules/emscripten/tools/response_file.py +6 -0
  185. data/modules/emscripten/tools/response_file.pyc +0 -0
  186. data/modules/emscripten/tools/settings_template_readonly.py +2 -0
  187. data/modules/emscripten/tools/shared.py +88 -34
  188. data/modules/emscripten/tools/shared.pyc +0 -0
  189. data/modules/emscripten/tools/split.py +21 -13
  190. data/modules/mruby/build_config.rb +7 -1
  191. data/modules/mruby/doc/compile/README.md +5 -9
  192. data/modules/mruby/include/mrbconf.h +5 -2
  193. data/modules/mruby/include/mruby/array.h +1 -0
  194. data/modules/mruby/include/mruby/compile.h +2 -4
  195. data/modules/mruby/include/mruby/dump.h +7 -16
  196. data/modules/mruby/include/mruby/hash.h +1 -1
  197. data/modules/mruby/include/mruby/irep.h +14 -2
  198. data/modules/mruby/include/mruby/khash.h +8 -7
  199. data/modules/mruby/include/mruby/string.h +1 -0
  200. data/modules/mruby/include/mruby/value.h +5 -2
  201. data/modules/mruby/include/mruby.h +12 -13
  202. data/modules/mruby/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c +16 -6
  203. data/modules/mruby/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c +18 -30
  204. data/modules/mruby/mrbgems/mruby-fiber/src/fiber.c +21 -0
  205. data/modules/mruby/mrbgems/mruby-math/src/math.c +1 -1
  206. data/modules/mruby/mrbgems/mruby-random/src/random.c +144 -47
  207. data/modules/mruby/mrbgems/mruby-random/test/random.rb +44 -0
  208. data/modules/mruby/mrbgems/mruby-struct/src/struct.c +5 -5
  209. data/modules/mruby/mrblib/numeric.rb +99 -33
  210. data/modules/mruby/src/array.c +11 -4
  211. data/modules/mruby/src/backtrace.c +2 -2
  212. data/modules/mruby/src/class.c +49 -30
  213. data/modules/mruby/src/codegen.c +131 -79
  214. data/modules/mruby/src/debug.c +1 -1
  215. data/modules/mruby/src/dump.c +213 -163
  216. data/modules/mruby/src/error.c +17 -17
  217. data/modules/mruby/src/error.h +1 -1
  218. data/modules/mruby/src/etc.c +10 -0
  219. data/modules/mruby/src/gc.c +35 -17
  220. data/modules/mruby/src/hash.c +5 -5
  221. data/modules/mruby/src/kernel.c +36 -14
  222. data/modules/mruby/src/load.c +238 -296
  223. data/modules/mruby/src/numeric.c +18 -98
  224. data/modules/mruby/src/object.c +3 -5
  225. data/modules/mruby/src/parse.y +63 -56
  226. data/modules/mruby/src/proc.c +8 -5
  227. data/modules/mruby/src/re.h +0 -1
  228. data/modules/mruby/src/state.c +65 -27
  229. data/modules/mruby/src/string.c +3 -31
  230. data/modules/mruby/src/symbol.c +3 -3
  231. data/modules/mruby/src/variable.c +12 -5
  232. data/modules/mruby/src/vm.c +90 -72
  233. data/modules/mruby/tasks/mruby_build.rake +10 -1
  234. data/modules/mruby/tasks/toolchains/gcc.rake +12 -2
  235. data/modules/mruby/tasks/toolchains/{vs2012.rake → visualcpp.rake} +1 -1
  236. data/modules/mruby/test/driver.c +3 -3
  237. data/modules/mruby/test/t/array.rb +5 -5
  238. data/modules/mruby/test/t/class.rb +14 -1
  239. data/modules/mruby/test/t/kernel.rb +4 -0
  240. data/modules/mruby/test/t/module.rb +4 -4
  241. data/modules/mruby/test/t/nameerror.rb +1 -1
  242. data/modules/mruby/tools/mrbc/mrbc.c +23 -17
  243. data/modules/mruby/travis_config.rb +10 -1
  244. metadata +28 -5
  245. data/modules/mruby/tasks/toolchains/vs2010.rake +0 -3
@@ -0,0 +1,158 @@
1
+ /*
2
+ tre-mem.c - TRE memory allocator
3
+
4
+ Copyright (c) 2001-2009 Ville Laurikari <vl@iki.fi>
5
+ All rights reserved.
6
+
7
+ Redistribution and use in source and binary forms, with or without
8
+ modification, are permitted provided that the following conditions
9
+ are met:
10
+
11
+ 1. Redistributions of source code must retain the above copyright
12
+ notice, this list of conditions and the following disclaimer.
13
+
14
+ 2. Redistributions in binary form must reproduce the above copyright
15
+ notice, this list of conditions and the following disclaimer in the
16
+ documentation and/or other materials provided with the distribution.
17
+
18
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS
19
+ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
+ HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
+
30
+ */
31
+
32
+ /*
33
+ This memory allocator is for allocating small memory blocks efficiently
34
+ in terms of memory overhead and execution speed. The allocated blocks
35
+ cannot be freed individually, only all at once. There can be multiple
36
+ allocators, though.
37
+ */
38
+
39
+ #include <stdlib.h>
40
+ #include <string.h>
41
+
42
+ #include "tre.h"
43
+
44
+ /*
45
+ This memory allocator is for allocating small memory blocks efficiently
46
+ in terms of memory overhead and execution speed. The allocated blocks
47
+ cannot be freed individually, only all at once. There can be multiple
48
+ allocators, though.
49
+ */
50
+
51
+ /* Returns a new memory allocator or NULL if out of memory. */
52
+ tre_mem_t
53
+ tre_mem_new_impl(int provided, void *provided_block)
54
+ {
55
+ tre_mem_t mem;
56
+ if (provided)
57
+ {
58
+ mem = provided_block;
59
+ memset(mem, 0, sizeof(*mem));
60
+ }
61
+ else
62
+ mem = xcalloc(1, sizeof(*mem));
63
+ if (mem == NULL)
64
+ return NULL;
65
+ return mem;
66
+ }
67
+
68
+
69
+ /* Frees the memory allocator and all memory allocated with it. */
70
+ void
71
+ tre_mem_destroy(tre_mem_t mem)
72
+ {
73
+ tre_list_t *tmp, *l = mem->blocks;
74
+
75
+ while (l != NULL)
76
+ {
77
+ xfree(l->data);
78
+ tmp = l->next;
79
+ xfree(l);
80
+ l = tmp;
81
+ }
82
+ xfree(mem);
83
+ }
84
+
85
+
86
+ /* Allocates a block of `size' bytes from `mem'. Returns a pointer to the
87
+ allocated block or NULL if an underlying malloc() failed. */
88
+ void *
89
+ tre_mem_alloc_impl(tre_mem_t mem, int provided, void *provided_block,
90
+ int zero, size_t size)
91
+ {
92
+ void *ptr;
93
+
94
+ if (mem->failed)
95
+ {
96
+ return NULL;
97
+ }
98
+
99
+ if (mem->n < size)
100
+ {
101
+ /* We need more memory than is available in the current block.
102
+ Allocate a new block. */
103
+ tre_list_t *l;
104
+ if (provided)
105
+ {
106
+ if (provided_block == NULL)
107
+ {
108
+ mem->failed = 1;
109
+ return NULL;
110
+ }
111
+ mem->ptr = provided_block;
112
+ mem->n = TRE_MEM_BLOCK_SIZE;
113
+ }
114
+ else
115
+ {
116
+ int block_size;
117
+ if (size * 8 > TRE_MEM_BLOCK_SIZE)
118
+ block_size = size * 8;
119
+ else
120
+ block_size = TRE_MEM_BLOCK_SIZE;
121
+ l = xmalloc(sizeof(*l));
122
+ if (l == NULL)
123
+ {
124
+ mem->failed = 1;
125
+ return NULL;
126
+ }
127
+ l->data = xmalloc(block_size);
128
+ if (l->data == NULL)
129
+ {
130
+ xfree(l);
131
+ mem->failed = 1;
132
+ return NULL;
133
+ }
134
+ l->next = NULL;
135
+ if (mem->current != NULL)
136
+ mem->current->next = l;
137
+ if (mem->blocks == NULL)
138
+ mem->blocks = l;
139
+ mem->current = l;
140
+ mem->ptr = l->data;
141
+ mem->n = block_size;
142
+ }
143
+ }
144
+
145
+ /* Make sure the next pointer will be aligned. */
146
+ size += ALIGN(mem->ptr + size, long);
147
+
148
+ /* Allocate from current block. */
149
+ ptr = mem->ptr;
150
+ mem->ptr += size;
151
+ mem->n -= size;
152
+
153
+ /* Set to zero if needed. */
154
+ if (zero)
155
+ memset(ptr, 0, size);
156
+
157
+ return ptr;
158
+ }
@@ -0,0 +1,231 @@
1
+ /*
2
+ tre-internal.h - TRE internal definitions
3
+
4
+ Copyright (c) 2001-2009 Ville Laurikari <vl@iki.fi>
5
+ All rights reserved.
6
+
7
+ Redistribution and use in source and binary forms, with or without
8
+ modification, are permitted provided that the following conditions
9
+ are met:
10
+
11
+ 1. Redistributions of source code must retain the above copyright
12
+ notice, this list of conditions and the following disclaimer.
13
+
14
+ 2. Redistributions in binary form must reproduce the above copyright
15
+ notice, this list of conditions and the following disclaimer in the
16
+ documentation and/or other materials provided with the distribution.
17
+
18
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS
19
+ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
+ HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
+
30
+ */
31
+
32
+ #include <regex.h>
33
+ #include <wchar.h>
34
+ #include <wctype.h>
35
+
36
+ #undef TRE_MBSTATE
37
+
38
+ #define NDEBUG
39
+
40
+ #define TRE_REGEX_T_FIELD __opaque
41
+ typedef int reg_errcode_t;
42
+
43
+ typedef wchar_t tre_char_t;
44
+
45
+ #define DPRINT(msg) do { } while(0)
46
+
47
+ #define elementsof(x) ( sizeof(x) / sizeof(x[0]) )
48
+
49
+ #define tre_mbrtowc(pwc, s, n, ps) (mbtowc((pwc), (s), (n)))
50
+
51
+ /* Wide characters. */
52
+ typedef wint_t tre_cint_t;
53
+ #define TRE_CHAR_MAX 0x10ffff
54
+
55
+ #define tre_isalnum iswalnum
56
+ #define tre_isalpha iswalpha
57
+ #define tre_isblank iswblank
58
+ #define tre_iscntrl iswcntrl
59
+ #define tre_isdigit iswdigit
60
+ #define tre_isgraph iswgraph
61
+ #define tre_islower iswlower
62
+ #define tre_isprint iswprint
63
+ #define tre_ispunct iswpunct
64
+ #define tre_isspace iswspace
65
+ #define tre_isupper iswupper
66
+ #define tre_isxdigit iswxdigit
67
+
68
+ #define tre_tolower towlower
69
+ #define tre_toupper towupper
70
+ #define tre_strlen wcslen
71
+
72
+ /* Use system provided iswctype() and wctype(). */
73
+ typedef wctype_t tre_ctype_t;
74
+ #define tre_isctype iswctype
75
+ #define tre_ctype wctype
76
+
77
+ /* Returns number of bytes to add to (char *)ptr to make it
78
+ properly aligned for the type. */
79
+ #define ALIGN(ptr, type) \
80
+ ((((long)ptr) % sizeof(type)) \
81
+ ? (sizeof(type) - (((long)ptr) % sizeof(type))) \
82
+ : 0)
83
+
84
+ #undef MAX
85
+ #undef MIN
86
+ #define MAX(a, b) (((a) >= (b)) ? (a) : (b))
87
+ #define MIN(a, b) (((a) <= (b)) ? (a) : (b))
88
+
89
+ /* TNFA transition type. A TNFA state is an array of transitions,
90
+ the terminator is a transition with NULL `state'. */
91
+ typedef struct tnfa_transition tre_tnfa_transition_t;
92
+
93
+ struct tnfa_transition {
94
+ /* Range of accepted characters. */
95
+ tre_cint_t code_min;
96
+ tre_cint_t code_max;
97
+ /* Pointer to the destination state. */
98
+ tre_tnfa_transition_t *state;
99
+ /* ID number of the destination state. */
100
+ int state_id;
101
+ /* -1 terminated array of tags (or NULL). */
102
+ int *tags;
103
+ /* Assertion bitmap. */
104
+ int assertions;
105
+ /* Assertion parameters. */
106
+ union {
107
+ /* Character class assertion. */
108
+ tre_ctype_t class;
109
+ /* Back reference assertion. */
110
+ int backref;
111
+ } u;
112
+ /* Negative character class assertions. */
113
+ tre_ctype_t *neg_classes;
114
+ };
115
+
116
+
117
+ /* Assertions. */
118
+ #define ASSERT_AT_BOL 1 /* Beginning of line. */
119
+ #define ASSERT_AT_EOL 2 /* End of line. */
120
+ #define ASSERT_CHAR_CLASS 4 /* Character class in `class'. */
121
+ #define ASSERT_CHAR_CLASS_NEG 8 /* Character classes in `neg_classes'. */
122
+ #define ASSERT_AT_BOW 16 /* Beginning of word. */
123
+ #define ASSERT_AT_EOW 32 /* End of word. */
124
+ #define ASSERT_AT_WB 64 /* Word boundary. */
125
+ #define ASSERT_AT_WB_NEG 128 /* Not a word boundary. */
126
+ #define ASSERT_BACKREF 256 /* A back reference in `backref'. */
127
+ #define ASSERT_LAST 256
128
+
129
+ /* Tag directions. */
130
+ typedef enum {
131
+ TRE_TAG_MINIMIZE = 0,
132
+ TRE_TAG_MAXIMIZE = 1
133
+ } tre_tag_direction_t;
134
+
135
+ /* Instructions to compute submatch register values from tag values
136
+ after a successful match. */
137
+ struct tre_submatch_data {
138
+ /* Tag that gives the value for rm_so (submatch start offset). */
139
+ int so_tag;
140
+ /* Tag that gives the value for rm_eo (submatch end offset). */
141
+ int eo_tag;
142
+ /* List of submatches this submatch is contained in. */
143
+ int *parents;
144
+ };
145
+
146
+ typedef struct tre_submatch_data tre_submatch_data_t;
147
+
148
+
149
+ /* TNFA definition. */
150
+ typedef struct tnfa tre_tnfa_t;
151
+
152
+ struct tnfa {
153
+ tre_tnfa_transition_t *transitions;
154
+ unsigned int num_transitions;
155
+ tre_tnfa_transition_t *initial;
156
+ tre_tnfa_transition_t *final;
157
+ tre_submatch_data_t *submatch_data;
158
+ char *firstpos_chars;
159
+ int first_char;
160
+ unsigned int num_submatches;
161
+ tre_tag_direction_t *tag_directions;
162
+ int *minimal_tags;
163
+ int num_tags;
164
+ int num_minimals;
165
+ int end_tag;
166
+ int num_states;
167
+ int cflags;
168
+ int have_backrefs;
169
+ int have_approx;
170
+ };
171
+
172
+ /* from tre-mem.h: */
173
+
174
+ #define TRE_MEM_BLOCK_SIZE 1024
175
+
176
+ typedef struct tre_list {
177
+ void *data;
178
+ struct tre_list *next;
179
+ } tre_list_t;
180
+
181
+ typedef struct tre_mem_struct {
182
+ tre_list_t *blocks;
183
+ tre_list_t *current;
184
+ char *ptr;
185
+ size_t n;
186
+ int failed;
187
+ void **provided;
188
+ } *tre_mem_t;
189
+
190
+ #define tre_mem_new_impl __tre_mem_new_impl
191
+ #define tre_mem_alloc_impl __tre_mem_alloc_impl
192
+ #define tre_mem_destroy __tre_mem_destroy
193
+
194
+ tre_mem_t tre_mem_new_impl(int provided, void *provided_block);
195
+ void *tre_mem_alloc_impl(tre_mem_t mem, int provided, void *provided_block,
196
+ int zero, size_t size);
197
+
198
+ /* Returns a new memory allocator or NULL if out of memory. */
199
+ #define tre_mem_new() tre_mem_new_impl(0, NULL)
200
+
201
+ /* Allocates a block of `size' bytes from `mem'. Returns a pointer to the
202
+ allocated block or NULL if an underlying malloc() failed. */
203
+ #define tre_mem_alloc(mem, size) tre_mem_alloc_impl(mem, 0, NULL, 0, size)
204
+
205
+ /* Allocates a block of `size' bytes from `mem'. Returns a pointer to the
206
+ allocated block or NULL if an underlying malloc() failed. The memory
207
+ is set to zero. */
208
+ #define tre_mem_calloc(mem, size) tre_mem_alloc_impl(mem, 0, NULL, 1, size)
209
+
210
+ #ifdef TRE_USE_ALLOCA
211
+ /* alloca() versions. Like above, but memory is allocated with alloca()
212
+ instead of malloc(). */
213
+
214
+ #define tre_mem_newa() \
215
+ tre_mem_new_impl(1, alloca(sizeof(struct tre_mem_struct)))
216
+
217
+ #define tre_mem_alloca(mem, size) \
218
+ ((mem)->n >= (size) \
219
+ ? tre_mem_alloc_impl((mem), 1, NULL, 0, (size)) \
220
+ : tre_mem_alloc_impl((mem), 1, alloca(TRE_MEM_BLOCK_SIZE), 0, (size)))
221
+ #endif /* TRE_USE_ALLOCA */
222
+
223
+
224
+ /* Frees the memory allocator and all memory allocated with it. */
225
+ void tre_mem_destroy(tre_mem_t mem);
226
+
227
+ #define xmalloc malloc
228
+ #define xcalloc calloc
229
+ #define xfree free
230
+ #define xrealloc realloc
231
+
@@ -2,6 +2,9 @@
2
2
  T __strxfrm_l
3
3
  W __towlower_l
4
4
  W __towupper_l
5
+ T __tre_mem_alloc_impl
6
+ T __tre_mem_destroy
7
+ T __tre_mem_new_impl
5
8
  T __wcscoll_l
6
9
  T __wcsxfrm_l
7
10
  W __wctype_l
@@ -47,6 +50,10 @@
47
50
  T mbsrtowcs
48
51
  T mbstowcs
49
52
  T mbtowc
53
+ T regcomp
54
+ T regerror
55
+ T regexec
56
+ T regfree
50
57
  T strfmon
51
58
  T strfmon_l
52
59
  T strxfrm
@@ -31,7 +31,7 @@ D: FreeBSD and Solaris ports, libcxxrt support, some atomics work.
31
31
  N: Marshall Clow
32
32
  E: mclow.lists@gmail.com
33
33
  E: marshall@idio.com
34
- D: Minor patches and bug fixes.
34
+ D: C++14 support, patches and bug fixes.
35
35
 
36
36
  N: Bill Fisher
37
37
  E: william.w.fisher@gmail.com
@@ -76,6 +76,10 @@ N: Bjorn Reese
76
76
  E: breese@users.sourceforge.net
77
77
  D: Initial regex prototype
78
78
 
79
+ N: Nico Rieck
80
+ E: nico.rieck@gmail.com
81
+ D: Windows fixes
82
+
79
83
  N: Jonathan Sauer
80
84
  D: Minor patches, mostly related to constexpr
81
85
 
@@ -105,6 +109,10 @@ N: Zhang Xiongpang
105
109
  E: zhangxiongpang@gmail.com
106
110
  D: Minor patches and bug fixes.
107
111
 
112
+ N: Xing Xue
113
+ E: xingxue@ca.ibm.com
114
+ D: AIX port
115
+
108
116
  N: Zhihao Yuan
109
117
  E: lichray@gmail.com
110
118
  D: Standard compatibility fixes.
@@ -7,6 +7,7 @@
7
7
  //
8
8
  //===----------------------------------------------------------------------===//
9
9
 
10
+ #define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
10
11
  #include "algorithm"
11
12
  #include "random"
12
13
  #include "mutex"
@@ -7,7 +7,7 @@
7
7
  //
8
8
  //===----------------------------------------------------------------------===//
9
9
 
10
- #define _LIBCPP_DEBUG2 1
10
+ #define _LIBCPP_DEBUG 1
11
11
  #include "__config"
12
12
  #include "__debug"
13
13
  #include "functional"
@@ -118,20 +118,19 @@ void
118
118
  __libcpp_db::__insert_ic(void* __i, const void* __c)
119
119
  {
120
120
  WLock _(mut());
121
- __i_node* i = __insert_iterator(__i);
122
- const char* errmsg =
123
- "Container constructed in a translation unit with debug mode disabled."
124
- " But it is being used in a translation unit with debug mode enabled."
125
- " Enable it in the other translation unit with #define _LIBCPP_DEBUG2 1";
126
- _LIBCPP_ASSERT(__cbeg_ != __cend_, errmsg);
121
+ if (__cbeg_ == __cend_)
122
+ return;
127
123
  size_t hc = hash<const void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_);
128
124
  __c_node* c = __cbeg_[hc];
129
- _LIBCPP_ASSERT(c != nullptr, errmsg);
125
+ if (c == nullptr)
126
+ return;
130
127
  while (c->__c_ != __c)
131
128
  {
132
129
  c = c->__next_;
133
- _LIBCPP_ASSERT(c != nullptr, errmsg);
130
+ if (c == nullptr)
131
+ return;
134
132
  }
133
+ __i_node* i = __insert_iterator(__i);
135
134
  c->__add(i);
136
135
  i->__c_ = c;
137
136
  }
@@ -217,18 +216,23 @@ void
217
216
  __libcpp_db::__invalidate_all(void* __c)
218
217
  {
219
218
  WLock _(mut());
220
- size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_);
221
- __c_node* p = __cbeg_[hc];
222
- _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __invalidate_all A");
223
- while (p->__c_ != __c)
224
- {
225
- p = p->__next_;
226
- _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __invalidate_all B");
227
- }
228
- while (p->end_ != p->beg_)
219
+ if (__cend_ != __cbeg_)
229
220
  {
230
- --p->end_;
231
- (*p->end_)->__c_ = nullptr;
221
+ size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_);
222
+ __c_node* p = __cbeg_[hc];
223
+ if (p == nullptr)
224
+ return;
225
+ while (p->__c_ != __c)
226
+ {
227
+ p = p->__next_;
228
+ if (p == nullptr)
229
+ return;
230
+ }
231
+ while (p->end_ != p->beg_)
232
+ {
233
+ --p->end_;
234
+ (*p->end_)->__c_ = nullptr;
235
+ }
232
236
  }
233
237
  }
234
238
 
@@ -236,13 +240,26 @@ __c_node*
236
240
  __libcpp_db::__find_c_and_lock(void* __c) const
237
241
  {
238
242
  mut().lock();
243
+ if (__cend_ == __cbeg_)
244
+ {
245
+ mut().unlock();
246
+ return nullptr;
247
+ }
239
248
  size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_);
240
249
  __c_node* p = __cbeg_[hc];
241
- _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __find_c_and_lock A");
250
+ if (p == nullptr)
251
+ {
252
+ mut().unlock();
253
+ return nullptr;
254
+ }
242
255
  while (p->__c_ != __c)
243
256
  {
244
257
  p = p->__next_;
245
- _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __find_c_and_lock B");
258
+ if (p == nullptr)
259
+ {
260
+ mut().unlock();
261
+ return nullptr;
262
+ }
246
263
  }
247
264
  return p;
248
265
  }
@@ -271,28 +288,35 @@ void
271
288
  __libcpp_db::__erase_c(void* __c)
272
289
  {
273
290
  WLock _(mut());
274
- size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_);
275
- __c_node* p = __cbeg_[hc];
276
- __c_node* q = nullptr;
277
- _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __erase_c A");
278
- while (p->__c_ != __c)
291
+ if (__cend_ != __cbeg_)
279
292
  {
280
- q = p;
281
- p = p->__next_;
282
- _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __erase_c B");
283
- }
284
- if (q == nullptr)
285
- __cbeg_[hc] = p->__next_;
286
- else
287
- q->__next_ = p->__next_;
288
- while (p->end_ != p->beg_)
289
- {
290
- --p->end_;
291
- (*p->end_)->__c_ = nullptr;
293
+ size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_);
294
+ __c_node* p = __cbeg_[hc];
295
+ if (p == nullptr)
296
+ return;
297
+ __c_node* q = nullptr;
298
+ _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __erase_c A");
299
+ while (p->__c_ != __c)
300
+ {
301
+ q = p;
302
+ p = p->__next_;
303
+ if (p == nullptr)
304
+ return;
305
+ _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __erase_c B");
306
+ }
307
+ if (q == nullptr)
308
+ __cbeg_[hc] = p->__next_;
309
+ else
310
+ q->__next_ = p->__next_;
311
+ while (p->end_ != p->beg_)
312
+ {
313
+ --p->end_;
314
+ (*p->end_)->__c_ = nullptr;
315
+ }
316
+ free(p->beg_);
317
+ free(p);
318
+ --__csz_;
292
319
  }
293
- free(p->beg_);
294
- free(p);
295
- --__csz_;
296
320
  }
297
321
 
298
322
  void