smparkes-johnson 1.1.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (1078) hide show
  1. data/.autotest +14 -0
  2. data/CHANGELOG.rdoc +21 -0
  3. data/Manifest.txt +1077 -0
  4. data/README.rdoc +51 -0
  5. data/Rakefile +140 -0
  6. data/bin/johnson +106 -0
  7. data/ext/spidermonkey/context.c +116 -0
  8. data/ext/spidermonkey/context.h +19 -0
  9. data/ext/spidermonkey/conversions.c +354 -0
  10. data/ext/spidermonkey/conversions.h +31 -0
  11. data/ext/spidermonkey/debugger.c +234 -0
  12. data/ext/spidermonkey/debugger.h +10 -0
  13. data/ext/spidermonkey/extconf.rb +32 -0
  14. data/ext/spidermonkey/extensions.c +37 -0
  15. data/ext/spidermonkey/extensions.h +12 -0
  16. data/ext/spidermonkey/global.c +40 -0
  17. data/ext/spidermonkey/global.h +11 -0
  18. data/ext/spidermonkey/idhash.c +16 -0
  19. data/ext/spidermonkey/idhash.h +8 -0
  20. data/ext/spidermonkey/immutable_node.c +1153 -0
  21. data/ext/spidermonkey/immutable_node.c.erb +523 -0
  22. data/ext/spidermonkey/immutable_node.h +22 -0
  23. data/ext/spidermonkey/jroot.h +197 -0
  24. data/ext/spidermonkey/js_land_proxy.c +610 -0
  25. data/ext/spidermonkey/js_land_proxy.h +20 -0
  26. data/ext/spidermonkey/ruby_land_proxy.c +611 -0
  27. data/ext/spidermonkey/ruby_land_proxy.h +38 -0
  28. data/ext/spidermonkey/runtime.c +396 -0
  29. data/ext/spidermonkey/runtime.h +27 -0
  30. data/ext/spidermonkey/spidermonkey.c +22 -0
  31. data/ext/spidermonkey/spidermonkey.h +29 -0
  32. data/ext/tracemonkey/context.cc +125 -0
  33. data/ext/tracemonkey/context.h +19 -0
  34. data/ext/tracemonkey/conversions.cc +355 -0
  35. data/ext/tracemonkey/conversions.h +32 -0
  36. data/ext/tracemonkey/debugger.cc +234 -0
  37. data/ext/tracemonkey/debugger.h +10 -0
  38. data/ext/tracemonkey/extconf.rb +37 -0
  39. data/ext/tracemonkey/extensions.cc +37 -0
  40. data/ext/tracemonkey/extensions.h +12 -0
  41. data/ext/tracemonkey/global.cc +40 -0
  42. data/ext/tracemonkey/global.h +11 -0
  43. data/ext/tracemonkey/idhash.cc +16 -0
  44. data/ext/tracemonkey/idhash.h +8 -0
  45. data/ext/tracemonkey/immutable_node.cc +1199 -0
  46. data/ext/tracemonkey/immutable_node.cc.erb +559 -0
  47. data/ext/tracemonkey/immutable_node.h +22 -0
  48. data/ext/tracemonkey/jroot.h +215 -0
  49. data/ext/tracemonkey/js_land_proxy.cc +610 -0
  50. data/ext/tracemonkey/js_land_proxy.h +20 -0
  51. data/ext/tracemonkey/ruby_land_proxy.cc +611 -0
  52. data/ext/tracemonkey/ruby_land_proxy.h +38 -0
  53. data/ext/tracemonkey/runtime.cc +454 -0
  54. data/ext/tracemonkey/runtime.h +27 -0
  55. data/ext/tracemonkey/split_global.cc +392 -0
  56. data/ext/tracemonkey/split_global.h +11 -0
  57. data/ext/tracemonkey/tracemonkey.cc +23 -0
  58. data/ext/tracemonkey/tracemonkey.h +32 -0
  59. data/lib/johnson/cli/options.rb +67 -0
  60. data/lib/johnson/cli.rb +8 -0
  61. data/lib/johnson/error.rb +4 -0
  62. data/lib/johnson/js/cli.js +30 -0
  63. data/lib/johnson/js/prelude.js +118 -0
  64. data/lib/johnson/nodes/binary_node.rb +65 -0
  65. data/lib/johnson/nodes/for.rb +14 -0
  66. data/lib/johnson/nodes/for_in.rb +12 -0
  67. data/lib/johnson/nodes/function.rb +13 -0
  68. data/lib/johnson/nodes/list.rb +28 -0
  69. data/lib/johnson/nodes/node.rb +68 -0
  70. data/lib/johnson/nodes/ternary_node.rb +20 -0
  71. data/lib/johnson/nodes.rb +7 -0
  72. data/lib/johnson/parser/syntax_error.rb +13 -0
  73. data/lib/johnson/parser.rb +22 -0
  74. data/lib/johnson/ruby_land_proxy.rb +81 -0
  75. data/lib/johnson/runtime.rb +141 -0
  76. data/lib/johnson/spidermonkey/context.rb +10 -0
  77. data/lib/johnson/spidermonkey/debugger.rb +67 -0
  78. data/lib/johnson/spidermonkey/immutable_node.rb +282 -0
  79. data/lib/johnson/spidermonkey/js_land_proxy.rb +64 -0
  80. data/lib/johnson/spidermonkey/mutable_tree_visitor.rb +242 -0
  81. data/lib/johnson/spidermonkey/ruby_land_proxy.rb +17 -0
  82. data/lib/johnson/spidermonkey/runtime.rb +92 -0
  83. data/lib/johnson/spidermonkey.rb +12 -0
  84. data/lib/johnson/tracemonkey/context.rb +10 -0
  85. data/lib/johnson/tracemonkey/debugger.rb +67 -0
  86. data/lib/johnson/tracemonkey/immutable_node.rb +282 -0
  87. data/lib/johnson/tracemonkey/js_land_proxy.rb +64 -0
  88. data/lib/johnson/tracemonkey/mutable_tree_visitor.rb +242 -0
  89. data/lib/johnson/tracemonkey/ruby_land_proxy.rb +17 -0
  90. data/lib/johnson/tracemonkey/runtime.rb +98 -0
  91. data/lib/johnson/tracemonkey.rb +13 -0
  92. data/lib/johnson/visitable.rb +16 -0
  93. data/lib/johnson/visitors/dot_visitor.rb +169 -0
  94. data/lib/johnson/visitors/ecma_visitor.rb +323 -0
  95. data/lib/johnson/visitors/enumerating_visitor.rb +15 -0
  96. data/lib/johnson/visitors/sexp_visitor.rb +174 -0
  97. data/lib/johnson/visitors/visitor.rb +91 -0
  98. data/lib/johnson/visitors.rb +5 -0
  99. data/lib/johnson.rb +53 -0
  100. data/test/generic/johnson_test.rb +16 -0
  101. data/test/generic/parser_test.rb +276 -0
  102. data/test/helper.rb +82 -0
  103. data/test/johnson/generic/browser_test.rb +43 -0
  104. data/test/johnson/generic/conversions/array_test.rb +70 -0
  105. data/test/johnson/generic/conversions/boolean_test.rb +17 -0
  106. data/test/johnson/generic/conversions/callable_test.rb +34 -0
  107. data/test/johnson/generic/conversions/file_test.rb +15 -0
  108. data/test/johnson/generic/conversions/helper.rb +1 -0
  109. data/test/johnson/generic/conversions/nil_test.rb +20 -0
  110. data/test/johnson/generic/conversions/number_test.rb +34 -0
  111. data/test/johnson/generic/conversions/regexp_test.rb +24 -0
  112. data/test/johnson/generic/conversions/string_test.rb +38 -0
  113. data/test/johnson/generic/conversions/struct_test.rb +15 -0
  114. data/test/johnson/generic/conversions/symbol_test.rb +19 -0
  115. data/test/johnson/generic/conversions/thread_test.rb +24 -0
  116. data/test/johnson/generic/default_test.rb +12 -0
  117. data/test/johnson/generic/error_test.rb +9 -0
  118. data/test/johnson/generic/extensions_test.rb +56 -0
  119. data/test/johnson/generic/helper.rb +1 -0
  120. data/test/johnson/generic/nodes/array_literal_test.rb +57 -0
  121. data/test/johnson/generic/nodes/array_node_test.rb +26 -0
  122. data/test/johnson/generic/nodes/binary_node_test.rb +61 -0
  123. data/test/johnson/generic/nodes/bracket_access_test.rb +16 -0
  124. data/test/johnson/generic/nodes/delete_test.rb +11 -0
  125. data/test/johnson/generic/nodes/do_while_test.rb +12 -0
  126. data/test/johnson/generic/nodes/dot_accessor_test.rb +15 -0
  127. data/test/johnson/generic/nodes/export_test.rb +11 -0
  128. data/test/johnson/generic/nodes/for_test.rb +54 -0
  129. data/test/johnson/generic/nodes/function_test.rb +71 -0
  130. data/test/johnson/generic/nodes/helper.rb +1 -0
  131. data/test/johnson/generic/nodes/if_test.rb +51 -0
  132. data/test/johnson/generic/nodes/import_test.rb +15 -0
  133. data/test/johnson/generic/nodes/label_test.rb +19 -0
  134. data/test/johnson/generic/nodes/let_test.rb +31 -0
  135. data/test/johnson/generic/nodes/object_literal_test.rb +110 -0
  136. data/test/johnson/generic/nodes/return_test.rb +16 -0
  137. data/test/johnson/generic/nodes/semi_test.rb +8 -0
  138. data/test/johnson/generic/nodes/switch_test.rb +55 -0
  139. data/test/johnson/generic/nodes/ternary_test.rb +25 -0
  140. data/test/johnson/generic/nodes/throw_test.rb +9 -0
  141. data/test/johnson/generic/nodes/try_node_test.rb +89 -0
  142. data/test/johnson/generic/nodes/typeof_test.rb +11 -0
  143. data/test/johnson/generic/nodes/unary_node_test.rb +23 -0
  144. data/test/johnson/generic/nodes/void_test.rb +11 -0
  145. data/test/johnson/generic/nodes/while_test.rb +26 -0
  146. data/test/johnson/generic/nodes/with_test.rb +10 -0
  147. data/test/johnson/generic/prelude_test.rb +79 -0
  148. data/test/johnson/generic/runtime_test.rb +140 -0
  149. data/test/johnson/generic/version_test.rb +13 -0
  150. data/test/johnson/generic/visitors/dot_visitor_test.rb +39 -0
  151. data/test/johnson/generic/visitors/enumerating_visitor_test.rb +12 -0
  152. data/test/johnson/generic/visitors/helper.rb +1 -0
  153. data/test/johnson/spidermonkey/context_test.rb +21 -0
  154. data/test/johnson/spidermonkey/immutable_node_test.rb +34 -0
  155. data/test/johnson/spidermonkey/js_land_proxy_test.rb +277 -0
  156. data/test/johnson/spidermonkey/ruby_land_proxy_test.rb +270 -0
  157. data/test/johnson/spidermonkey/runtime_test.rb +41 -0
  158. data/test/johnson/tracemonkey/context_test.rb +21 -0
  159. data/test/johnson/tracemonkey/immutable_node_test.rb +34 -0
  160. data/test/johnson/tracemonkey/js_land_proxy_test.rb +277 -0
  161. data/test/johnson/tracemonkey/ruby_land_proxy_test.rb +270 -0
  162. data/test/johnson/tracemonkey/runtime_test.rb +41 -0
  163. data/test/johnson/tracemonkey/split_global_test.rb +32 -0
  164. data/vendor/spidermonkey/.cvsignore +9 -0
  165. data/vendor/spidermonkey/Makefile.in +449 -0
  166. data/vendor/spidermonkey/Makefile.ref +365 -0
  167. data/vendor/spidermonkey/README.html +820 -0
  168. data/vendor/spidermonkey/SpiderMonkey.rsp +12 -0
  169. data/vendor/spidermonkey/Y.js +19 -0
  170. data/vendor/spidermonkey/build.mk +43 -0
  171. data/vendor/spidermonkey/config/AIX4.1.mk +65 -0
  172. data/vendor/spidermonkey/config/AIX4.2.mk +64 -0
  173. data/vendor/spidermonkey/config/AIX4.3.mk +65 -0
  174. data/vendor/spidermonkey/config/Darwin.mk +83 -0
  175. data/vendor/spidermonkey/config/Darwin1.3.mk +81 -0
  176. data/vendor/spidermonkey/config/Darwin1.4.mk +41 -0
  177. data/vendor/spidermonkey/config/Darwin5.2.mk +81 -0
  178. data/vendor/spidermonkey/config/Darwin5.3.mk +81 -0
  179. data/vendor/spidermonkey/config/HP-UXB.10.10.mk +77 -0
  180. data/vendor/spidermonkey/config/HP-UXB.10.20.mk +77 -0
  181. data/vendor/spidermonkey/config/HP-UXB.11.00.mk +80 -0
  182. data/vendor/spidermonkey/config/IRIX.mk +87 -0
  183. data/vendor/spidermonkey/config/IRIX5.3.mk +44 -0
  184. data/vendor/spidermonkey/config/IRIX6.1.mk +44 -0
  185. data/vendor/spidermonkey/config/IRIX6.2.mk +44 -0
  186. data/vendor/spidermonkey/config/IRIX6.3.mk +44 -0
  187. data/vendor/spidermonkey/config/IRIX6.5.mk +44 -0
  188. data/vendor/spidermonkey/config/Linux_All.mk +103 -0
  189. data/vendor/spidermonkey/config/Mac_OS10.0.mk +82 -0
  190. data/vendor/spidermonkey/config/OSF1V4.0.mk +72 -0
  191. data/vendor/spidermonkey/config/OSF1V5.0.mk +69 -0
  192. data/vendor/spidermonkey/config/SunOS4.1.4.mk +101 -0
  193. data/vendor/spidermonkey/config/SunOS5.10.mk +50 -0
  194. data/vendor/spidermonkey/config/SunOS5.3.mk +91 -0
  195. data/vendor/spidermonkey/config/SunOS5.4.mk +92 -0
  196. data/vendor/spidermonkey/config/SunOS5.5.1.mk +44 -0
  197. data/vendor/spidermonkey/config/SunOS5.5.mk +87 -0
  198. data/vendor/spidermonkey/config/SunOS5.6.mk +89 -0
  199. data/vendor/spidermonkey/config/SunOS5.7.mk +44 -0
  200. data/vendor/spidermonkey/config/SunOS5.8.mk +44 -0
  201. data/vendor/spidermonkey/config/SunOS5.9.mk +44 -0
  202. data/vendor/spidermonkey/config/WINNT4.0.mk +117 -0
  203. data/vendor/spidermonkey/config/WINNT5.0.mk +117 -0
  204. data/vendor/spidermonkey/config/WINNT5.1.mk +117 -0
  205. data/vendor/spidermonkey/config/WINNT5.2.mk +117 -0
  206. data/vendor/spidermonkey/config/WINNT6.0.mk +117 -0
  207. data/vendor/spidermonkey/config/dgux.mk +64 -0
  208. data/vendor/spidermonkey/config.mk +192 -0
  209. data/vendor/spidermonkey/editline/Makefile.ref +144 -0
  210. data/vendor/spidermonkey/editline/README +83 -0
  211. data/vendor/spidermonkey/editline/editline.3 +175 -0
  212. data/vendor/spidermonkey/editline/editline.c +1369 -0
  213. data/vendor/spidermonkey/editline/editline.h +135 -0
  214. data/vendor/spidermonkey/editline/sysunix.c +182 -0
  215. data/vendor/spidermonkey/editline/unix.h +82 -0
  216. data/vendor/spidermonkey/fdlibm/.cvsignore +7 -0
  217. data/vendor/spidermonkey/fdlibm/Makefile.in +127 -0
  218. data/vendor/spidermonkey/fdlibm/Makefile.ref +192 -0
  219. data/vendor/spidermonkey/fdlibm/e_acos.c +147 -0
  220. data/vendor/spidermonkey/fdlibm/e_acosh.c +105 -0
  221. data/vendor/spidermonkey/fdlibm/e_asin.c +156 -0
  222. data/vendor/spidermonkey/fdlibm/e_atan2.c +165 -0
  223. data/vendor/spidermonkey/fdlibm/e_atanh.c +110 -0
  224. data/vendor/spidermonkey/fdlibm/e_cosh.c +133 -0
  225. data/vendor/spidermonkey/fdlibm/e_exp.c +202 -0
  226. data/vendor/spidermonkey/fdlibm/e_fmod.c +184 -0
  227. data/vendor/spidermonkey/fdlibm/e_gamma.c +71 -0
  228. data/vendor/spidermonkey/fdlibm/e_gamma_r.c +70 -0
  229. data/vendor/spidermonkey/fdlibm/e_hypot.c +173 -0
  230. data/vendor/spidermonkey/fdlibm/e_j0.c +524 -0
  231. data/vendor/spidermonkey/fdlibm/e_j1.c +523 -0
  232. data/vendor/spidermonkey/fdlibm/e_jn.c +315 -0
  233. data/vendor/spidermonkey/fdlibm/e_lgamma.c +71 -0
  234. data/vendor/spidermonkey/fdlibm/e_lgamma_r.c +347 -0
  235. data/vendor/spidermonkey/fdlibm/e_log.c +184 -0
  236. data/vendor/spidermonkey/fdlibm/e_log10.c +134 -0
  237. data/vendor/spidermonkey/fdlibm/e_pow.c +386 -0
  238. data/vendor/spidermonkey/fdlibm/e_rem_pio2.c +222 -0
  239. data/vendor/spidermonkey/fdlibm/e_remainder.c +120 -0
  240. data/vendor/spidermonkey/fdlibm/e_scalb.c +89 -0
  241. data/vendor/spidermonkey/fdlibm/e_sinh.c +122 -0
  242. data/vendor/spidermonkey/fdlibm/e_sqrt.c +497 -0
  243. data/vendor/spidermonkey/fdlibm/fdlibm.h +273 -0
  244. data/vendor/spidermonkey/fdlibm/fdlibm.mak +1453 -0
  245. data/vendor/spidermonkey/fdlibm/fdlibm.mdp +0 -0
  246. data/vendor/spidermonkey/fdlibm/k_cos.c +135 -0
  247. data/vendor/spidermonkey/fdlibm/k_rem_pio2.c +354 -0
  248. data/vendor/spidermonkey/fdlibm/k_sin.c +114 -0
  249. data/vendor/spidermonkey/fdlibm/k_standard.c +785 -0
  250. data/vendor/spidermonkey/fdlibm/k_tan.c +170 -0
  251. data/vendor/spidermonkey/fdlibm/s_asinh.c +101 -0
  252. data/vendor/spidermonkey/fdlibm/s_atan.c +175 -0
  253. data/vendor/spidermonkey/fdlibm/s_cbrt.c +133 -0
  254. data/vendor/spidermonkey/fdlibm/s_ceil.c +120 -0
  255. data/vendor/spidermonkey/fdlibm/s_copysign.c +72 -0
  256. data/vendor/spidermonkey/fdlibm/s_cos.c +118 -0
  257. data/vendor/spidermonkey/fdlibm/s_erf.c +356 -0
  258. data/vendor/spidermonkey/fdlibm/s_expm1.c +267 -0
  259. data/vendor/spidermonkey/fdlibm/s_fabs.c +70 -0
  260. data/vendor/spidermonkey/fdlibm/s_finite.c +71 -0
  261. data/vendor/spidermonkey/fdlibm/s_floor.c +121 -0
  262. data/vendor/spidermonkey/fdlibm/s_frexp.c +99 -0
  263. data/vendor/spidermonkey/fdlibm/s_ilogb.c +85 -0
  264. data/vendor/spidermonkey/fdlibm/s_isnan.c +74 -0
  265. data/vendor/spidermonkey/fdlibm/s_ldexp.c +66 -0
  266. data/vendor/spidermonkey/fdlibm/s_lib_version.c +73 -0
  267. data/vendor/spidermonkey/fdlibm/s_log1p.c +211 -0
  268. data/vendor/spidermonkey/fdlibm/s_logb.c +79 -0
  269. data/vendor/spidermonkey/fdlibm/s_matherr.c +64 -0
  270. data/vendor/spidermonkey/fdlibm/s_modf.c +132 -0
  271. data/vendor/spidermonkey/fdlibm/s_nextafter.c +124 -0
  272. data/vendor/spidermonkey/fdlibm/s_rint.c +131 -0
  273. data/vendor/spidermonkey/fdlibm/s_scalbn.c +107 -0
  274. data/vendor/spidermonkey/fdlibm/s_signgam.c +40 -0
  275. data/vendor/spidermonkey/fdlibm/s_significand.c +68 -0
  276. data/vendor/spidermonkey/fdlibm/s_sin.c +118 -0
  277. data/vendor/spidermonkey/fdlibm/s_tan.c +112 -0
  278. data/vendor/spidermonkey/fdlibm/s_tanh.c +122 -0
  279. data/vendor/spidermonkey/fdlibm/w_acos.c +78 -0
  280. data/vendor/spidermonkey/fdlibm/w_acosh.c +78 -0
  281. data/vendor/spidermonkey/fdlibm/w_asin.c +80 -0
  282. data/vendor/spidermonkey/fdlibm/w_atan2.c +79 -0
  283. data/vendor/spidermonkey/fdlibm/w_atanh.c +81 -0
  284. data/vendor/spidermonkey/fdlibm/w_cosh.c +77 -0
  285. data/vendor/spidermonkey/fdlibm/w_exp.c +88 -0
  286. data/vendor/spidermonkey/fdlibm/w_fmod.c +78 -0
  287. data/vendor/spidermonkey/fdlibm/w_gamma.c +85 -0
  288. data/vendor/spidermonkey/fdlibm/w_gamma_r.c +81 -0
  289. data/vendor/spidermonkey/fdlibm/w_hypot.c +78 -0
  290. data/vendor/spidermonkey/fdlibm/w_j0.c +105 -0
  291. data/vendor/spidermonkey/fdlibm/w_j1.c +106 -0
  292. data/vendor/spidermonkey/fdlibm/w_jn.c +128 -0
  293. data/vendor/spidermonkey/fdlibm/w_lgamma.c +85 -0
  294. data/vendor/spidermonkey/fdlibm/w_lgamma_r.c +81 -0
  295. data/vendor/spidermonkey/fdlibm/w_log.c +78 -0
  296. data/vendor/spidermonkey/fdlibm/w_log10.c +81 -0
  297. data/vendor/spidermonkey/fdlibm/w_pow.c +99 -0
  298. data/vendor/spidermonkey/fdlibm/w_remainder.c +77 -0
  299. data/vendor/spidermonkey/fdlibm/w_scalb.c +95 -0
  300. data/vendor/spidermonkey/fdlibm/w_sinh.c +77 -0
  301. data/vendor/spidermonkey/fdlibm/w_sqrt.c +77 -0
  302. data/vendor/spidermonkey/javascript-trace.d +73 -0
  303. data/vendor/spidermonkey/js.c +3951 -0
  304. data/vendor/spidermonkey/js.mdp +0 -0
  305. data/vendor/spidermonkey/js.msg +308 -0
  306. data/vendor/spidermonkey/js.pkg +2 -0
  307. data/vendor/spidermonkey/js3240.rc +79 -0
  308. data/vendor/spidermonkey/jsOS240.def +654 -0
  309. data/vendor/spidermonkey/jsapi.c +5836 -0
  310. data/vendor/spidermonkey/jsapi.h +2624 -0
  311. data/vendor/spidermonkey/jsarena.c +450 -0
  312. data/vendor/spidermonkey/jsarena.h +318 -0
  313. data/vendor/spidermonkey/jsarray.c +2996 -0
  314. data/vendor/spidermonkey/jsarray.h +127 -0
  315. data/vendor/spidermonkey/jsatom.c +1045 -0
  316. data/vendor/spidermonkey/jsatom.h +442 -0
  317. data/vendor/spidermonkey/jsbit.h +253 -0
  318. data/vendor/spidermonkey/jsbool.c +176 -0
  319. data/vendor/spidermonkey/jsbool.h +73 -0
  320. data/vendor/spidermonkey/jsclist.h +139 -0
  321. data/vendor/spidermonkey/jscntxt.c +1348 -0
  322. data/vendor/spidermonkey/jscntxt.h +1120 -0
  323. data/vendor/spidermonkey/jscompat.h +57 -0
  324. data/vendor/spidermonkey/jsconfig.h +248 -0
  325. data/vendor/spidermonkey/jsconfig.mk +181 -0
  326. data/vendor/spidermonkey/jscpucfg.c +396 -0
  327. data/vendor/spidermonkey/jscpucfg.h +212 -0
  328. data/vendor/spidermonkey/jsdate.c +2390 -0
  329. data/vendor/spidermonkey/jsdate.h +124 -0
  330. data/vendor/spidermonkey/jsdbgapi.c +1802 -0
  331. data/vendor/spidermonkey/jsdbgapi.h +464 -0
  332. data/vendor/spidermonkey/jsdhash.c +868 -0
  333. data/vendor/spidermonkey/jsdhash.h +592 -0
  334. data/vendor/spidermonkey/jsdtoa.c +3167 -0
  335. data/vendor/spidermonkey/jsdtoa.h +130 -0
  336. data/vendor/spidermonkey/jsdtracef.c +317 -0
  337. data/vendor/spidermonkey/jsdtracef.h +77 -0
  338. data/vendor/spidermonkey/jsemit.c +6909 -0
  339. data/vendor/spidermonkey/jsemit.h +741 -0
  340. data/vendor/spidermonkey/jsexn.c +1371 -0
  341. data/vendor/spidermonkey/jsexn.h +96 -0
  342. data/vendor/spidermonkey/jsfile.c +2736 -0
  343. data/vendor/spidermonkey/jsfile.h +56 -0
  344. data/vendor/spidermonkey/jsfile.msg +90 -0
  345. data/vendor/spidermonkey/jsfun.c +2634 -0
  346. data/vendor/spidermonkey/jsfun.h +254 -0
  347. data/vendor/spidermonkey/jsgc.c +3562 -0
  348. data/vendor/spidermonkey/jsgc.h +403 -0
  349. data/vendor/spidermonkey/jshash.c +476 -0
  350. data/vendor/spidermonkey/jshash.h +151 -0
  351. data/vendor/spidermonkey/jsify.pl +485 -0
  352. data/vendor/spidermonkey/jsinterp.c +7007 -0
  353. data/vendor/spidermonkey/jsinterp.h +525 -0
  354. data/vendor/spidermonkey/jsinvoke.c +43 -0
  355. data/vendor/spidermonkey/jsiter.c +1067 -0
  356. data/vendor/spidermonkey/jsiter.h +122 -0
  357. data/vendor/spidermonkey/jskeyword.tbl +124 -0
  358. data/vendor/spidermonkey/jskwgen.c +460 -0
  359. data/vendor/spidermonkey/jslibmath.h +266 -0
  360. data/vendor/spidermonkey/jslock.c +1309 -0
  361. data/vendor/spidermonkey/jslock.h +313 -0
  362. data/vendor/spidermonkey/jslocko.asm +60 -0
  363. data/vendor/spidermonkey/jslog2.c +94 -0
  364. data/vendor/spidermonkey/jslong.c +264 -0
  365. data/vendor/spidermonkey/jslong.h +412 -0
  366. data/vendor/spidermonkey/jsmath.c +567 -0
  367. data/vendor/spidermonkey/jsmath.h +57 -0
  368. data/vendor/spidermonkey/jsnum.c +1239 -0
  369. data/vendor/spidermonkey/jsnum.h +283 -0
  370. data/vendor/spidermonkey/jsobj.c +5282 -0
  371. data/vendor/spidermonkey/jsobj.h +709 -0
  372. data/vendor/spidermonkey/jsopcode.c +5245 -0
  373. data/vendor/spidermonkey/jsopcode.h +394 -0
  374. data/vendor/spidermonkey/jsopcode.tbl +523 -0
  375. data/vendor/spidermonkey/jsotypes.h +202 -0
  376. data/vendor/spidermonkey/jsparse.c +6704 -0
  377. data/vendor/spidermonkey/jsparse.h +511 -0
  378. data/vendor/spidermonkey/jsprf.c +1264 -0
  379. data/vendor/spidermonkey/jsprf.h +150 -0
  380. data/vendor/spidermonkey/jsproto.tbl +128 -0
  381. data/vendor/spidermonkey/jsprvtd.h +267 -0
  382. data/vendor/spidermonkey/jspubtd.h +744 -0
  383. data/vendor/spidermonkey/jsregexp.c +4364 -0
  384. data/vendor/spidermonkey/jsregexp.h +183 -0
  385. data/vendor/spidermonkey/jsreops.tbl +145 -0
  386. data/vendor/spidermonkey/jsscan.c +2012 -0
  387. data/vendor/spidermonkey/jsscan.h +387 -0
  388. data/vendor/spidermonkey/jsscope.c +1957 -0
  389. data/vendor/spidermonkey/jsscope.h +418 -0
  390. data/vendor/spidermonkey/jsscript.c +1832 -0
  391. data/vendor/spidermonkey/jsscript.h +287 -0
  392. data/vendor/spidermonkey/jsshell.msg +50 -0
  393. data/vendor/spidermonkey/jsstddef.h +83 -0
  394. data/vendor/spidermonkey/jsstr.c +5005 -0
  395. data/vendor/spidermonkey/jsstr.h +641 -0
  396. data/vendor/spidermonkey/jstypes.h +475 -0
  397. data/vendor/spidermonkey/jsutil.c +345 -0
  398. data/vendor/spidermonkey/jsutil.h +157 -0
  399. data/vendor/spidermonkey/jsxdrapi.c +800 -0
  400. data/vendor/spidermonkey/jsxdrapi.h +218 -0
  401. data/vendor/spidermonkey/jsxml.c +8476 -0
  402. data/vendor/spidermonkey/jsxml.h +349 -0
  403. data/vendor/spidermonkey/lock_SunOS.s +119 -0
  404. data/vendor/spidermonkey/perfect.js +39 -0
  405. data/vendor/spidermonkey/plify_jsdhash.sed +36 -0
  406. data/vendor/spidermonkey/prmjtime.c +846 -0
  407. data/vendor/spidermonkey/prmjtime.h +103 -0
  408. data/vendor/spidermonkey/resource.h +15 -0
  409. data/vendor/spidermonkey/rules.mk +197 -0
  410. data/vendor/spidermonkey/win32.order +384 -0
  411. data/vendor/tracemonkey/Makefile.in +668 -0
  412. data/vendor/tracemonkey/Makefile.ref +483 -0
  413. data/vendor/tracemonkey/README.html +54 -0
  414. data/vendor/tracemonkey/SpiderMonkey.rsp +11 -0
  415. data/vendor/tracemonkey/Y.js +19 -0
  416. data/vendor/tracemonkey/aclocal.m4 +9 -0
  417. data/vendor/tracemonkey/bench.sh +5 -0
  418. data/vendor/tracemonkey/build/autoconf/acoutput-fast.pl +202 -0
  419. data/vendor/tracemonkey/build/autoconf/altoptions.m4 +154 -0
  420. data/vendor/tracemonkey/build/autoconf/config.guess +1537 -0
  421. data/vendor/tracemonkey/build/autoconf/config.sub +1595 -0
  422. data/vendor/tracemonkey/build/autoconf/install-sh +119 -0
  423. data/vendor/tracemonkey/build/autoconf/make-makefile +315 -0
  424. data/vendor/tracemonkey/build/autoconf/match-dir.sh +101 -0
  425. data/vendor/tracemonkey/build/autoconf/moznbytetype.m4 +136 -0
  426. data/vendor/tracemonkey/build/autoconf/nspr.m4 +82 -0
  427. data/vendor/tracemonkey/build/autoconf/pkg.m4 +59 -0
  428. data/vendor/tracemonkey/build/autoconf/update-makefile.sh +118 -0
  429. data/vendor/tracemonkey/build/cygwin-wrapper +75 -0
  430. data/vendor/tracemonkey/build/hcc +111 -0
  431. data/vendor/tracemonkey/build/hcpp +155 -0
  432. data/vendor/tracemonkey/build/unix/mddepend.pl +165 -0
  433. data/vendor/tracemonkey/build/unix/uniq.pl +63 -0
  434. data/vendor/tracemonkey/build/win32/pgomerge.py +40 -0
  435. data/vendor/tracemonkey/builtins.tbl +91 -0
  436. data/vendor/tracemonkey/call.js +13 -0
  437. data/vendor/tracemonkey/config/Makefile.in +106 -0
  438. data/vendor/tracemonkey/config/Moz/Milestone.pm +232 -0
  439. data/vendor/tracemonkey/config/autoconf.mk.in +362 -0
  440. data/vendor/tracemonkey/config/check-sync-dirs.py +103 -0
  441. data/vendor/tracemonkey/config/check-sync-exceptions +7 -0
  442. data/vendor/tracemonkey/config/config.mk +881 -0
  443. data/vendor/tracemonkey/config/fastcwd.pl +66 -0
  444. data/vendor/tracemonkey/config/gcc_hidden.h +2 -0
  445. data/vendor/tracemonkey/config/insure.mk +53 -0
  446. data/vendor/tracemonkey/config/make-system-wrappers.pl +59 -0
  447. data/vendor/tracemonkey/config/milestone.pl +112 -0
  448. data/vendor/tracemonkey/config/milestone.txt +13 -0
  449. data/vendor/tracemonkey/config/mkdepend/Makefile.in +84 -0
  450. data/vendor/tracemonkey/config/mkdepend/cppsetup.c +233 -0
  451. data/vendor/tracemonkey/config/mkdepend/def.h +184 -0
  452. data/vendor/tracemonkey/config/mkdepend/ifparser.c +551 -0
  453. data/vendor/tracemonkey/config/mkdepend/ifparser.h +83 -0
  454. data/vendor/tracemonkey/config/mkdepend/imakemdep.h +733 -0
  455. data/vendor/tracemonkey/config/mkdepend/include.c +337 -0
  456. data/vendor/tracemonkey/config/mkdepend/main.c +860 -0
  457. data/vendor/tracemonkey/config/mkdepend/mkdepend.man +382 -0
  458. data/vendor/tracemonkey/config/mkdepend/parse.c +686 -0
  459. data/vendor/tracemonkey/config/mkdepend/pr.c +124 -0
  460. data/vendor/tracemonkey/config/nfspwd.pl +50 -0
  461. data/vendor/tracemonkey/config/nsinstall.c +481 -0
  462. data/vendor/tracemonkey/config/nsinstall.py +155 -0
  463. data/vendor/tracemonkey/config/pathsub.c +247 -0
  464. data/vendor/tracemonkey/config/pathsub.h +74 -0
  465. data/vendor/tracemonkey/config/preprocessor.pl +671 -0
  466. data/vendor/tracemonkey/config/revdepth-nt.pl +48 -0
  467. data/vendor/tracemonkey/config/revdepth.pl +51 -0
  468. data/vendor/tracemonkey/config/rules.mk +2310 -0
  469. data/vendor/tracemonkey/config/static-checking-config.mk +21 -0
  470. data/vendor/tracemonkey/config/static-checking.js +92 -0
  471. data/vendor/tracemonkey/config/string-format.js +61 -0
  472. data/vendor/tracemonkey/config/system-headers +1035 -0
  473. data/vendor/tracemonkey/config/version.mk +85 -0
  474. data/vendor/tracemonkey/config/version_win.pl +442 -0
  475. data/vendor/tracemonkey/config.mk +206 -0
  476. data/vendor/tracemonkey/configure +14183 -0
  477. data/vendor/tracemonkey/configure.in +5363 -0
  478. data/vendor/tracemonkey/correct/check-3d-morph.js +55 -0
  479. data/vendor/tracemonkey/correct/check-3d-raytrace.js +445 -0
  480. data/vendor/tracemonkey/correct/check-access-binary-trees.js +52 -0
  481. data/vendor/tracemonkey/correct/check-access-fannkuch.js +66 -0
  482. data/vendor/tracemonkey/correct/check-access-nbody.js +171 -0
  483. data/vendor/tracemonkey/correct/check-access-nsieve.js +40 -0
  484. data/vendor/tracemonkey/correct/check-bitops-3bit-bits-in-byte.js +35 -0
  485. data/vendor/tracemonkey/correct/check-bitops-bits-in-byte.js +24 -0
  486. data/vendor/tracemonkey/correct/check-bitops-bitwise-and.js +29 -0
  487. data/vendor/tracemonkey/correct/check-bitops-nsieve-bits.js +40 -0
  488. data/vendor/tracemonkey/correct/check-controlflow-recursive.js +27 -0
  489. data/vendor/tracemonkey/correct/check-date-format-tofte.js +302 -0
  490. data/vendor/tracemonkey/correct/check-date-format-xparb.js +421 -0
  491. data/vendor/tracemonkey/correct/check-mont.js +119 -0
  492. data/vendor/tracemonkey/correct.sh +23 -0
  493. data/vendor/tracemonkey/dtoa.c +3335 -0
  494. data/vendor/tracemonkey/editline/Makefile.in +55 -0
  495. data/vendor/tracemonkey/editline/Makefile.ref +143 -0
  496. data/vendor/tracemonkey/editline/README +83 -0
  497. data/vendor/tracemonkey/editline/editline.3 +175 -0
  498. data/vendor/tracemonkey/editline/editline.c +1371 -0
  499. data/vendor/tracemonkey/editline/editline.h +135 -0
  500. data/vendor/tracemonkey/editline/sysunix.c +182 -0
  501. data/vendor/tracemonkey/editline/unix.h +82 -0
  502. data/vendor/tracemonkey/if.js +13 -0
  503. data/vendor/tracemonkey/imacro_asm.js.in +396 -0
  504. data/vendor/tracemonkey/imacros.c.out +1034 -0
  505. data/vendor/tracemonkey/imacros.jsasm +770 -0
  506. data/vendor/tracemonkey/javascript-trace.d +73 -0
  507. data/vendor/tracemonkey/jitstats.tbl +55 -0
  508. data/vendor/tracemonkey/js-config.h.in +82 -0
  509. data/vendor/tracemonkey/js-config.in +111 -0
  510. data/vendor/tracemonkey/js.mdp +0 -0
  511. data/vendor/tracemonkey/js.msg +312 -0
  512. data/vendor/tracemonkey/js3240.rc +79 -0
  513. data/vendor/tracemonkey/jsOS240.def +654 -0
  514. data/vendor/tracemonkey/jsapi.cpp +6005 -0
  515. data/vendor/tracemonkey/jsapi.h +2727 -0
  516. data/vendor/tracemonkey/jsarena.cpp +450 -0
  517. data/vendor/tracemonkey/jsarena.h +318 -0
  518. data/vendor/tracemonkey/jsarray.cpp +3664 -0
  519. data/vendor/tracemonkey/jsarray.h +238 -0
  520. data/vendor/tracemonkey/jsatom.cpp +1244 -0
  521. data/vendor/tracemonkey/jsatom.h +493 -0
  522. data/vendor/tracemonkey/jsbit.h +249 -0
  523. data/vendor/tracemonkey/jsbool.cpp +184 -0
  524. data/vendor/tracemonkey/jsbool.h +88 -0
  525. data/vendor/tracemonkey/jsbuiltins.cpp +415 -0
  526. data/vendor/tracemonkey/jsbuiltins.h +456 -0
  527. data/vendor/tracemonkey/jsclist.h +139 -0
  528. data/vendor/tracemonkey/jscntxt.cpp +1816 -0
  529. data/vendor/tracemonkey/jscntxt.h +1541 -0
  530. data/vendor/tracemonkey/jscompat.h +57 -0
  531. data/vendor/tracemonkey/jsconfig.mk +181 -0
  532. data/vendor/tracemonkey/jscpucfg.cpp +194 -0
  533. data/vendor/tracemonkey/jscpucfg.h +91 -0
  534. data/vendor/tracemonkey/jsdate.cpp +2465 -0
  535. data/vendor/tracemonkey/jsdate.h +129 -0
  536. data/vendor/tracemonkey/jsdbgapi.cpp +2017 -0
  537. data/vendor/tracemonkey/jsdbgapi.h +500 -0
  538. data/vendor/tracemonkey/jsdhash.cpp +876 -0
  539. data/vendor/tracemonkey/jsdhash.h +588 -0
  540. data/vendor/tracemonkey/jsdtoa.cpp +572 -0
  541. data/vendor/tracemonkey/jsdtoa.h +131 -0
  542. data/vendor/tracemonkey/jsdtracef.c +318 -0
  543. data/vendor/tracemonkey/jsdtracef.h +81 -0
  544. data/vendor/tracemonkey/jsemit.cpp +7292 -0
  545. data/vendor/tracemonkey/jsemit.h +802 -0
  546. data/vendor/tracemonkey/jsexn.cpp +1337 -0
  547. data/vendor/tracemonkey/jsexn.h +96 -0
  548. data/vendor/tracemonkey/jsfile.cpp +2747 -0
  549. data/vendor/tracemonkey/jsfile.h +56 -0
  550. data/vendor/tracemonkey/jsfile.msg +90 -0
  551. data/vendor/tracemonkey/jsfun.cpp +3089 -0
  552. data/vendor/tracemonkey/jsfun.h +366 -0
  553. data/vendor/tracemonkey/jsgc.cpp +3816 -0
  554. data/vendor/tracemonkey/jsgc.h +429 -0
  555. data/vendor/tracemonkey/jshash.cpp +477 -0
  556. data/vendor/tracemonkey/jshash.h +151 -0
  557. data/vendor/tracemonkey/jsify.pl +483 -0
  558. data/vendor/tracemonkey/jsinterp.cpp +7441 -0
  559. data/vendor/tracemonkey/jsinterp.h +666 -0
  560. data/vendor/tracemonkey/jsinvoke.cpp +42 -0
  561. data/vendor/tracemonkey/jsiter.cpp +1040 -0
  562. data/vendor/tracemonkey/jsiter.h +140 -0
  563. data/vendor/tracemonkey/jskeyword.tbl +124 -0
  564. data/vendor/tracemonkey/jskwgen.cpp +460 -0
  565. data/vendor/tracemonkey/jslibmath.h +69 -0
  566. data/vendor/tracemonkey/jslock.cpp +1512 -0
  567. data/vendor/tracemonkey/jslock.h +325 -0
  568. data/vendor/tracemonkey/jslocko.asm +60 -0
  569. data/vendor/tracemonkey/jslog2.cpp +111 -0
  570. data/vendor/tracemonkey/jslong.h +167 -0
  571. data/vendor/tracemonkey/jsmath.cpp +806 -0
  572. data/vendor/tracemonkey/jsmath.h +63 -0
  573. data/vendor/tracemonkey/jsnum.cpp +1374 -0
  574. data/vendor/tracemonkey/jsnum.h +280 -0
  575. data/vendor/tracemonkey/jsobj.cpp +6165 -0
  576. data/vendor/tracemonkey/jsobj.h +873 -0
  577. data/vendor/tracemonkey/json.cpp +1338 -0
  578. data/vendor/tracemonkey/json.h +108 -0
  579. data/vendor/tracemonkey/jsopcode.cpp +5484 -0
  580. data/vendor/tracemonkey/jsopcode.h +434 -0
  581. data/vendor/tracemonkey/jsopcode.tbl +591 -0
  582. data/vendor/tracemonkey/jsoplengen.cpp +121 -0
  583. data/vendor/tracemonkey/jsotypes.h +202 -0
  584. data/vendor/tracemonkey/jsparse.cpp +9272 -0
  585. data/vendor/tracemonkey/jsparse.h +900 -0
  586. data/vendor/tracemonkey/jsprf.cpp +1262 -0
  587. data/vendor/tracemonkey/jsprf.h +150 -0
  588. data/vendor/tracemonkey/jsproto.tbl +117 -0
  589. data/vendor/tracemonkey/jsprvtd.h +366 -0
  590. data/vendor/tracemonkey/jspubtd.h +585 -0
  591. data/vendor/tracemonkey/jsregexp.cpp +5051 -0
  592. data/vendor/tracemonkey/jsregexp.h +199 -0
  593. data/vendor/tracemonkey/jsreops.tbl +145 -0
  594. data/vendor/tracemonkey/jsscan.cpp +2040 -0
  595. data/vendor/tracemonkey/jsscan.h +467 -0
  596. data/vendor/tracemonkey/jsscope.cpp +1966 -0
  597. data/vendor/tracemonkey/jsscope.h +487 -0
  598. data/vendor/tracemonkey/jsscript.cpp +1932 -0
  599. data/vendor/tracemonkey/jsscript.h +345 -0
  600. data/vendor/tracemonkey/jsshell.msg +54 -0
  601. data/vendor/tracemonkey/jsstack.js +167 -0
  602. data/vendor/tracemonkey/jsstaticcheck.h +69 -0
  603. data/vendor/tracemonkey/jsstddef.h +87 -0
  604. data/vendor/tracemonkey/jsstdint.h +96 -0
  605. data/vendor/tracemonkey/jsstr.cpp +5277 -0
  606. data/vendor/tracemonkey/jsstr.h +702 -0
  607. data/vendor/tracemonkey/jstracer.cpp +10991 -0
  608. data/vendor/tracemonkey/jstracer.h +794 -0
  609. data/vendor/tracemonkey/jstypes.h +481 -0
  610. data/vendor/tracemonkey/jsutil.cpp +361 -0
  611. data/vendor/tracemonkey/jsutil.h +178 -0
  612. data/vendor/tracemonkey/jsversion.h +243 -0
  613. data/vendor/tracemonkey/jswince.asm +44 -0
  614. data/vendor/tracemonkey/jsxdrapi.cpp +800 -0
  615. data/vendor/tracemonkey/jsxdrapi.h +220 -0
  616. data/vendor/tracemonkey/jsxml.cpp +8327 -0
  617. data/vendor/tracemonkey/jsxml.h +305 -0
  618. data/vendor/tracemonkey/liveconnect/LiveConnect.dsp +157 -0
  619. data/vendor/tracemonkey/liveconnect/LiveConnectShell.dsp +120 -0
  620. data/vendor/tracemonkey/liveconnect/LiveConnectShell.dsw +44 -0
  621. data/vendor/tracemonkey/liveconnect/Makefile.in +105 -0
  622. data/vendor/tracemonkey/liveconnect/Makefile.ref +169 -0
  623. data/vendor/tracemonkey/liveconnect/README.html +712 -0
  624. data/vendor/tracemonkey/liveconnect/_jni/netscape_javascript_JSException.h +14 -0
  625. data/vendor/tracemonkey/liveconnect/_jni/netscape_javascript_JSObject.h +155 -0
  626. data/vendor/tracemonkey/liveconnect/classes/Makefile.in +89 -0
  627. data/vendor/tracemonkey/liveconnect/classes/Makefile.ref +57 -0
  628. data/vendor/tracemonkey/liveconnect/classes/netscape/Makefile.ref +47 -0
  629. data/vendor/tracemonkey/liveconnect/classes/netscape/javascript/JSException.java +140 -0
  630. data/vendor/tracemonkey/liveconnect/classes/netscape/javascript/JSObject.java +183 -0
  631. data/vendor/tracemonkey/liveconnect/classes/netscape/javascript/JSProxy.java +58 -0
  632. data/vendor/tracemonkey/liveconnect/classes/netscape/javascript/JSRunnable.java +70 -0
  633. data/vendor/tracemonkey/liveconnect/classes/netscape/javascript/JSUtil.java +59 -0
  634. data/vendor/tracemonkey/liveconnect/classes/netscape/javascript/Makefile.ref +53 -0
  635. data/vendor/tracemonkey/liveconnect/config/AIX4.1.mk +45 -0
  636. data/vendor/tracemonkey/liveconnect/config/AIX4.2.mk +45 -0
  637. data/vendor/tracemonkey/liveconnect/config/AIX4.3.mk +50 -0
  638. data/vendor/tracemonkey/liveconnect/config/HP-UXB.10.10.mk +43 -0
  639. data/vendor/tracemonkey/liveconnect/config/HP-UXB.10.20.mk +43 -0
  640. data/vendor/tracemonkey/liveconnect/config/HP-UXB.11.00.mk +43 -0
  641. data/vendor/tracemonkey/liveconnect/config/IRIX6.2.mk +43 -0
  642. data/vendor/tracemonkey/liveconnect/config/IRIX6.3.mk +43 -0
  643. data/vendor/tracemonkey/liveconnect/config/IRIX6.5.mk +43 -0
  644. data/vendor/tracemonkey/liveconnect/config/Linux_All.mk +73 -0
  645. data/vendor/tracemonkey/liveconnect/config/OSF1V4.0.mk +65 -0
  646. data/vendor/tracemonkey/liveconnect/config/OSF1V5.0.mk +62 -0
  647. data/vendor/tracemonkey/liveconnect/config/SunOS5.5.1.mk +55 -0
  648. data/vendor/tracemonkey/liveconnect/config/SunOS5.6.mk +39 -0
  649. data/vendor/tracemonkey/liveconnect/config/SunOS5.7.mk +39 -0
  650. data/vendor/tracemonkey/liveconnect/config/SunOS5.8.mk +39 -0
  651. data/vendor/tracemonkey/liveconnect/config/WINNT4.0.mk +53 -0
  652. data/vendor/tracemonkey/liveconnect/jsj.c +886 -0
  653. data/vendor/tracemonkey/liveconnect/jsj.msg +98 -0
  654. data/vendor/tracemonkey/liveconnect/jsj_JSObject.c +1377 -0
  655. data/vendor/tracemonkey/liveconnect/jsj_JavaArray.c +474 -0
  656. data/vendor/tracemonkey/liveconnect/jsj_JavaClass.c +737 -0
  657. data/vendor/tracemonkey/liveconnect/jsj_JavaMember.c +191 -0
  658. data/vendor/tracemonkey/liveconnect/jsj_JavaObject.c +1079 -0
  659. data/vendor/tracemonkey/liveconnect/jsj_JavaPackage.c +569 -0
  660. data/vendor/tracemonkey/liveconnect/jsj_array.c +207 -0
  661. data/vendor/tracemonkey/liveconnect/jsj_class.c +770 -0
  662. data/vendor/tracemonkey/liveconnect/jsj_convert.c +902 -0
  663. data/vendor/tracemonkey/liveconnect/jsj_field.c +421 -0
  664. data/vendor/tracemonkey/liveconnect/jsj_hash.c +488 -0
  665. data/vendor/tracemonkey/liveconnect/jsj_hash.h +161 -0
  666. data/vendor/tracemonkey/liveconnect/jsj_method.c +1825 -0
  667. data/vendor/tracemonkey/liveconnect/jsj_nodl.c +1 -0
  668. data/vendor/tracemonkey/liveconnect/jsj_private.h +677 -0
  669. data/vendor/tracemonkey/liveconnect/jsj_simpleapi.c +219 -0
  670. data/vendor/tracemonkey/liveconnect/jsj_utils.c +513 -0
  671. data/vendor/tracemonkey/liveconnect/jsjava.h +316 -0
  672. data/vendor/tracemonkey/liveconnect/netscape_javascript_JSObject.h +155 -0
  673. data/vendor/tracemonkey/liveconnect/nsCLiveconnect.cpp +785 -0
  674. data/vendor/tracemonkey/liveconnect/nsCLiveconnect.h +197 -0
  675. data/vendor/tracemonkey/liveconnect/nsCLiveconnectFactory.cpp +118 -0
  676. data/vendor/tracemonkey/liveconnect/nsCLiveconnectFactory.h +76 -0
  677. data/vendor/tracemonkey/liveconnect/nsILiveconnect.h +197 -0
  678. data/vendor/tracemonkey/liveconnect/nsISecureLiveconnect.h +94 -0
  679. data/vendor/tracemonkey/liveconnect/nsISecurityContext.h +136 -0
  680. data/vendor/tracemonkey/lock_SunOS.s +119 -0
  681. data/vendor/tracemonkey/mandelbrot-results.js +3 -0
  682. data/vendor/tracemonkey/math-partial-sums.js +32 -0
  683. data/vendor/tracemonkey/math-trace-tests.js +507 -0
  684. data/vendor/tracemonkey/md5.js +289 -0
  685. data/vendor/tracemonkey/nanojit/Assembler.cpp +1984 -0
  686. data/vendor/tracemonkey/nanojit/Assembler.h +375 -0
  687. data/vendor/tracemonkey/nanojit/Fragmento.cpp +651 -0
  688. data/vendor/tracemonkey/nanojit/Fragmento.h +237 -0
  689. data/vendor/tracemonkey/nanojit/LIR.cpp +2314 -0
  690. data/vendor/tracemonkey/nanojit/LIR.h +879 -0
  691. data/vendor/tracemonkey/nanojit/LIRopcode.tbl +252 -0
  692. data/vendor/tracemonkey/nanojit/Native.h +127 -0
  693. data/vendor/tracemonkey/nanojit/NativeARM.cpp +1742 -0
  694. data/vendor/tracemonkey/nanojit/NativeARM.h +844 -0
  695. data/vendor/tracemonkey/nanojit/NativeSparc.cpp +1130 -0
  696. data/vendor/tracemonkey/nanojit/NativeSparc.h +948 -0
  697. data/vendor/tracemonkey/nanojit/NativeThumb.cpp +1322 -0
  698. data/vendor/tracemonkey/nanojit/NativeThumb.h +525 -0
  699. data/vendor/tracemonkey/nanojit/Nativei386.cpp +1748 -0
  700. data/vendor/tracemonkey/nanojit/Nativei386.h +857 -0
  701. data/vendor/tracemonkey/nanojit/RegAlloc.cpp +183 -0
  702. data/vendor/tracemonkey/nanojit/RegAlloc.h +95 -0
  703. data/vendor/tracemonkey/nanojit/TraceTreeDrawer.cpp +306 -0
  704. data/vendor/tracemonkey/nanojit/TraceTreeDrawer.h +88 -0
  705. data/vendor/tracemonkey/nanojit/avmplus.cpp +56 -0
  706. data/vendor/tracemonkey/nanojit/avmplus.h +1016 -0
  707. data/vendor/tracemonkey/nanojit/nanojit.h +253 -0
  708. data/vendor/tracemonkey/perfect.js +39 -0
  709. data/vendor/tracemonkey/plify_jsdhash.sed +35 -0
  710. data/vendor/tracemonkey/prmjtime.cpp +869 -0
  711. data/vendor/tracemonkey/prmjtime.h +103 -0
  712. data/vendor/tracemonkey/ref-config/AIX4.1.mk +65 -0
  713. data/vendor/tracemonkey/ref-config/AIX4.2.mk +64 -0
  714. data/vendor/tracemonkey/ref-config/AIX4.3.mk +65 -0
  715. data/vendor/tracemonkey/ref-config/Darwin.mk +85 -0
  716. data/vendor/tracemonkey/ref-config/Darwin1.3.mk +81 -0
  717. data/vendor/tracemonkey/ref-config/Darwin1.4.mk +41 -0
  718. data/vendor/tracemonkey/ref-config/Darwin5.2.mk +81 -0
  719. data/vendor/tracemonkey/ref-config/Darwin5.3.mk +81 -0
  720. data/vendor/tracemonkey/ref-config/Darwin64.mk +72 -0
  721. data/vendor/tracemonkey/ref-config/HP-UXB.10.10.mk +77 -0
  722. data/vendor/tracemonkey/ref-config/HP-UXB.10.20.mk +77 -0
  723. data/vendor/tracemonkey/ref-config/HP-UXB.11.00.mk +80 -0
  724. data/vendor/tracemonkey/ref-config/IRIX.mk +87 -0
  725. data/vendor/tracemonkey/ref-config/IRIX5.3.mk +44 -0
  726. data/vendor/tracemonkey/ref-config/IRIX6.1.mk +44 -0
  727. data/vendor/tracemonkey/ref-config/IRIX6.2.mk +44 -0
  728. data/vendor/tracemonkey/ref-config/IRIX6.3.mk +44 -0
  729. data/vendor/tracemonkey/ref-config/IRIX6.5.mk +44 -0
  730. data/vendor/tracemonkey/ref-config/Linux_All.mk +105 -0
  731. data/vendor/tracemonkey/ref-config/Mac_OS10.0.mk +82 -0
  732. data/vendor/tracemonkey/ref-config/OSF1V4.0.mk +72 -0
  733. data/vendor/tracemonkey/ref-config/OSF1V5.0.mk +69 -0
  734. data/vendor/tracemonkey/ref-config/SunOS4.1.4.mk +101 -0
  735. data/vendor/tracemonkey/ref-config/SunOS5.10.mk +50 -0
  736. data/vendor/tracemonkey/ref-config/SunOS5.3.mk +91 -0
  737. data/vendor/tracemonkey/ref-config/SunOS5.4.mk +92 -0
  738. data/vendor/tracemonkey/ref-config/SunOS5.5.1.mk +44 -0
  739. data/vendor/tracemonkey/ref-config/SunOS5.5.mk +87 -0
  740. data/vendor/tracemonkey/ref-config/SunOS5.6.mk +89 -0
  741. data/vendor/tracemonkey/ref-config/SunOS5.7.mk +44 -0
  742. data/vendor/tracemonkey/ref-config/SunOS5.8.mk +44 -0
  743. data/vendor/tracemonkey/ref-config/SunOS5.9.mk +44 -0
  744. data/vendor/tracemonkey/ref-config/WINNT4.0.mk +118 -0
  745. data/vendor/tracemonkey/ref-config/WINNT5.0.mk +118 -0
  746. data/vendor/tracemonkey/ref-config/WINNT5.1.mk +118 -0
  747. data/vendor/tracemonkey/ref-config/WINNT5.2.mk +118 -0
  748. data/vendor/tracemonkey/ref-config/WINNT6.0.mk +118 -0
  749. data/vendor/tracemonkey/ref-config/dgux.mk +64 -0
  750. data/vendor/tracemonkey/resource.h +15 -0
  751. data/vendor/tracemonkey/rules.mk +206 -0
  752. data/vendor/tracemonkey/shell/Makefile.in +72 -0
  753. data/vendor/tracemonkey/shell/js.cpp +4719 -0
  754. data/vendor/tracemonkey/t/3d-cube.js +337 -0
  755. data/vendor/tracemonkey/t/3d-morph.js +54 -0
  756. data/vendor/tracemonkey/t/3d-raytrace.js +441 -0
  757. data/vendor/tracemonkey/t/access-binary-trees.js +50 -0
  758. data/vendor/tracemonkey/t/access-fannkuch.js +66 -0
  759. data/vendor/tracemonkey/t/access-nbody.js +169 -0
  760. data/vendor/tracemonkey/t/access-nsieve.js +38 -0
  761. data/vendor/tracemonkey/t/bitops-3bit-bits-in-byte.js +32 -0
  762. data/vendor/tracemonkey/t/bitops-bits-in-byte.js +21 -0
  763. data/vendor/tracemonkey/t/bitops-bitwise-and.js +28 -0
  764. data/vendor/tracemonkey/t/bitops-nsieve-bits.js +32 -0
  765. data/vendor/tracemonkey/t/controlflow-recursive.js +25 -0
  766. data/vendor/tracemonkey/t/crypto-aes.js +422 -0
  767. data/vendor/tracemonkey/t/crypto-md5.js +286 -0
  768. data/vendor/tracemonkey/t/crypto-sha1.js +224 -0
  769. data/vendor/tracemonkey/t/date-format-tofte.js +299 -0
  770. data/vendor/tracemonkey/t/date-format-xparb.js +417 -0
  771. data/vendor/tracemonkey/t/math-cordic.js +95 -0
  772. data/vendor/tracemonkey/t/math-partial-sums.js +33 -0
  773. data/vendor/tracemonkey/t/math-spectral-norm.js +51 -0
  774. data/vendor/tracemonkey/t/regexp-dna.js +1712 -0
  775. data/vendor/tracemonkey/t/string-base64.js +135 -0
  776. data/vendor/tracemonkey/t/string-fasta.js +85 -0
  777. data/vendor/tracemonkey/t/string-tagcloud.js +265 -0
  778. data/vendor/tracemonkey/t/string-unpack-code.js +68 -0
  779. data/vendor/tracemonkey/t/string-validate-input.js +89 -0
  780. data/vendor/tracemonkey/time.sh +13 -0
  781. data/vendor/tracemonkey/trace-test.js +5564 -0
  782. data/vendor/tracemonkey/v8/base.js +187 -0
  783. data/vendor/tracemonkey/v8/crypto.js +1689 -0
  784. data/vendor/tracemonkey/v8/deltablue.js +880 -0
  785. data/vendor/tracemonkey/v8/earley-boyer.js +4682 -0
  786. data/vendor/tracemonkey/v8/raytrace.js +3418 -0
  787. data/vendor/tracemonkey/v8/richards.js +539 -0
  788. data/vendor/tracemonkey/v8/run-crypto.js +44 -0
  789. data/vendor/tracemonkey/v8/run-deltablue.js +44 -0
  790. data/vendor/tracemonkey/v8/run-earley-boyer.js +44 -0
  791. data/vendor/tracemonkey/v8/run-raytrace.js +44 -0
  792. data/vendor/tracemonkey/v8/run-richards.js +44 -0
  793. data/vendor/tracemonkey/v8/run.js +49 -0
  794. data/vendor/tracemonkey/vprof/readme.txt +93 -0
  795. data/vendor/tracemonkey/vprof/vprof.cpp +360 -0
  796. data/vendor/tracemonkey/vprof/vprof.h +245 -0
  797. data/vendor/tracemonkey/xpconnect/Makefile.in +67 -0
  798. data/vendor/tracemonkey/xpconnect/crashtests/117307-1.html +20 -0
  799. data/vendor/tracemonkey/xpconnect/crashtests/193710.html +11 -0
  800. data/vendor/tracemonkey/xpconnect/crashtests/290162-1.html +5 -0
  801. data/vendor/tracemonkey/xpconnect/crashtests/326615-1.html +16 -0
  802. data/vendor/tracemonkey/xpconnect/crashtests/328553-1.html +13 -0
  803. data/vendor/tracemonkey/xpconnect/crashtests/346258-1.html +12 -0
  804. data/vendor/tracemonkey/xpconnect/crashtests/346512-1-frame1.xhtml +16 -0
  805. data/vendor/tracemonkey/xpconnect/crashtests/346512-1-frame2.xhtml +15 -0
  806. data/vendor/tracemonkey/xpconnect/crashtests/346512-1.xhtml +30 -0
  807. data/vendor/tracemonkey/xpconnect/crashtests/382133-1.html +3 -0
  808. data/vendor/tracemonkey/xpconnect/crashtests/386680-1.html +22 -0
  809. data/vendor/tracemonkey/xpconnect/crashtests/394810-1.html +4 -0
  810. data/vendor/tracemonkey/xpconnect/crashtests/400349-1.html +20 -0
  811. data/vendor/tracemonkey/xpconnect/crashtests/403356-1.html +13 -0
  812. data/vendor/tracemonkey/xpconnect/crashtests/418139-1.svg +22 -0
  813. data/vendor/tracemonkey/xpconnect/crashtests/420513-1.html +11 -0
  814. data/vendor/tracemonkey/xpconnect/crashtests/453935-1.html +37 -0
  815. data/vendor/tracemonkey/xpconnect/crashtests/462926.html +12 -0
  816. data/vendor/tracemonkey/xpconnect/crashtests/468552-1.html +18 -0
  817. data/vendor/tracemonkey/xpconnect/crashtests/471366-1.html +12 -0
  818. data/vendor/tracemonkey/xpconnect/crashtests/475185-1.html +13 -0
  819. data/vendor/tracemonkey/xpconnect/crashtests/475291-1.html +14 -0
  820. data/vendor/tracemonkey/xpconnect/crashtests/503286-1.html +23 -0
  821. data/vendor/tracemonkey/xpconnect/crashtests/crashtests.list +21 -0
  822. data/vendor/tracemonkey/xpconnect/idl/Makefile.in +78 -0
  823. data/vendor/tracemonkey/xpconnect/idl/XPCIDispatch.idl +51 -0
  824. data/vendor/tracemonkey/xpconnect/idl/mozIJSSubScriptLoader.idl +64 -0
  825. data/vendor/tracemonkey/xpconnect/idl/nsIActiveXSecurityPolicy.idl +67 -0
  826. data/vendor/tracemonkey/xpconnect/idl/nsIDispatchSupport.idl +119 -0
  827. data/vendor/tracemonkey/xpconnect/idl/nsIJSContextStack.idl +85 -0
  828. data/vendor/tracemonkey/xpconnect/idl/nsIJSRuntimeService.idl +51 -0
  829. data/vendor/tracemonkey/xpconnect/idl/nsIScriptError.idl +102 -0
  830. data/vendor/tracemonkey/xpconnect/idl/nsIScriptableInterfaces.idl +67 -0
  831. data/vendor/tracemonkey/xpconnect/idl/nsIXPCScriptNotify.idl +66 -0
  832. data/vendor/tracemonkey/xpconnect/idl/nsIXPCScriptable.idl +183 -0
  833. data/vendor/tracemonkey/xpconnect/idl/nsIXPCSecurityManager.idl +114 -0
  834. data/vendor/tracemonkey/xpconnect/idl/nsIXPConnect.idl +819 -0
  835. data/vendor/tracemonkey/xpconnect/idl/xpcIJSModuleLoader.idl +95 -0
  836. data/vendor/tracemonkey/xpconnect/idl/xpcIJSWeakReference.idl +49 -0
  837. data/vendor/tracemonkey/xpconnect/idl/xpccomponents.idl +254 -0
  838. data/vendor/tracemonkey/xpconnect/idl/xpcexception.idl +66 -0
  839. data/vendor/tracemonkey/xpconnect/idl/xpcjsid.idl +83 -0
  840. data/vendor/tracemonkey/xpconnect/loader/ISO8601DateUtils.jsm +176 -0
  841. data/vendor/tracemonkey/xpconnect/loader/Makefile.in +63 -0
  842. data/vendor/tracemonkey/xpconnect/loader/XPCOMUtils.jsm +267 -0
  843. data/vendor/tracemonkey/xpconnect/loader/mozJSComponentLoader.cpp +1717 -0
  844. data/vendor/tracemonkey/xpconnect/loader/mozJSComponentLoader.h +172 -0
  845. data/vendor/tracemonkey/xpconnect/loader/mozJSLoaderConstructors.h +101 -0
  846. data/vendor/tracemonkey/xpconnect/loader/mozJSSubScriptLoader.cpp +360 -0
  847. data/vendor/tracemonkey/xpconnect/loader/mozJSSubScriptLoader.h +66 -0
  848. data/vendor/tracemonkey/xpconnect/public/Makefile.in +54 -0
  849. data/vendor/tracemonkey/xpconnect/public/nsAXPCNativeCallContext.h +89 -0
  850. data/vendor/tracemonkey/xpconnect/public/nsAutoJSValHolder.h +168 -0
  851. data/vendor/tracemonkey/xpconnect/public/xpc_map_end.h +327 -0
  852. data/vendor/tracemonkey/xpconnect/sample/Makefile.in +71 -0
  853. data/vendor/tracemonkey/xpconnect/sample/README +39 -0
  854. data/vendor/tracemonkey/xpconnect/sample/xpcsample1.cpp +337 -0
  855. data/vendor/tracemonkey/xpconnect/sample/xpcsample1.idl +82 -0
  856. data/vendor/tracemonkey/xpconnect/sample/xpcsample1.js +21 -0
  857. data/vendor/tracemonkey/xpconnect/shell/Makefile.in +106 -0
  858. data/vendor/tracemonkey/xpconnect/shell/jsshell.msg +50 -0
  859. data/vendor/tracemonkey/xpconnect/shell/xpcshell.cpp +1817 -0
  860. data/vendor/tracemonkey/xpconnect/shell/xpcshellMacUtils.h +43 -0
  861. data/vendor/tracemonkey/xpconnect/shell/xpcshellMacUtils.mm +54 -0
  862. data/vendor/tracemonkey/xpconnect/src/Makefile.in +228 -0
  863. data/vendor/tracemonkey/xpconnect/src/README +3 -0
  864. data/vendor/tracemonkey/xpconnect/src/XPCCrossOriginWrapper.cpp +1186 -0
  865. data/vendor/tracemonkey/xpconnect/src/XPCDispConvert.cpp +593 -0
  866. data/vendor/tracemonkey/xpconnect/src/XPCDispInlines.h +667 -0
  867. data/vendor/tracemonkey/xpconnect/src/XPCDispInterface.cpp +383 -0
  868. data/vendor/tracemonkey/xpconnect/src/XPCDispObject.cpp +516 -0
  869. data/vendor/tracemonkey/xpconnect/src/XPCDispParamPropJSClass.cpp +223 -0
  870. data/vendor/tracemonkey/xpconnect/src/XPCDispParams.cpp +103 -0
  871. data/vendor/tracemonkey/xpconnect/src/XPCDispPrivate.h +1401 -0
  872. data/vendor/tracemonkey/xpconnect/src/XPCDispTearOff.cpp +547 -0
  873. data/vendor/tracemonkey/xpconnect/src/XPCDispTypeInfo.cpp +471 -0
  874. data/vendor/tracemonkey/xpconnect/src/XPCIDispatchClassInfo.cpp +139 -0
  875. data/vendor/tracemonkey/xpconnect/src/XPCIDispatchExtension.cpp +362 -0
  876. data/vendor/tracemonkey/xpconnect/src/XPCNativeWrapper.cpp +1350 -0
  877. data/vendor/tracemonkey/xpconnect/src/XPCNativeWrapper.h +88 -0
  878. data/vendor/tracemonkey/xpconnect/src/XPCSafeJSObjectWrapper.cpp +1148 -0
  879. data/vendor/tracemonkey/xpconnect/src/XPCSystemOnlyWrapper.cpp +718 -0
  880. data/vendor/tracemonkey/xpconnect/src/XPCWrapper.cpp +850 -0
  881. data/vendor/tracemonkey/xpconnect/src/XPCWrapper.h +394 -0
  882. data/vendor/tracemonkey/xpconnect/src/dom_quickstubs.qsconf +568 -0
  883. data/vendor/tracemonkey/xpconnect/src/nsDispatchSupport.cpp +348 -0
  884. data/vendor/tracemonkey/xpconnect/src/nsScriptError.cpp +201 -0
  885. data/vendor/tracemonkey/xpconnect/src/nsXPConnect.cpp +2609 -0
  886. data/vendor/tracemonkey/xpconnect/src/qsgen.py +1487 -0
  887. data/vendor/tracemonkey/xpconnect/src/xpc.msg +217 -0
  888. data/vendor/tracemonkey/xpconnect/src/xpcJSWeakReference.cpp +148 -0
  889. data/vendor/tracemonkey/xpconnect/src/xpcJSWeakReference.h +56 -0
  890. data/vendor/tracemonkey/xpconnect/src/xpccallcontext.cpp +579 -0
  891. data/vendor/tracemonkey/xpconnect/src/xpccomponents.cpp +4144 -0
  892. data/vendor/tracemonkey/xpconnect/src/xpccontext.cpp +115 -0
  893. data/vendor/tracemonkey/xpconnect/src/xpcconvert.cpp +2298 -0
  894. data/vendor/tracemonkey/xpconnect/src/xpcdebug.cpp +481 -0
  895. data/vendor/tracemonkey/xpconnect/src/xpcexception.cpp +502 -0
  896. data/vendor/tracemonkey/xpconnect/src/xpcforwards.h +114 -0
  897. data/vendor/tracemonkey/xpconnect/src/xpcinlines.h +772 -0
  898. data/vendor/tracemonkey/xpconnect/src/xpcjsid.cpp +1025 -0
  899. data/vendor/tracemonkey/xpconnect/src/xpcjsruntime.cpp +1342 -0
  900. data/vendor/tracemonkey/xpconnect/src/xpclog.cpp +128 -0
  901. data/vendor/tracemonkey/xpconnect/src/xpclog.h +101 -0
  902. data/vendor/tracemonkey/xpconnect/src/xpcmaps.cpp +761 -0
  903. data/vendor/tracemonkey/xpconnect/src/xpcmaps.h +713 -0
  904. data/vendor/tracemonkey/xpconnect/src/xpcmodule.cpp +136 -0
  905. data/vendor/tracemonkey/xpconnect/src/xpcprivate.h +4138 -0
  906. data/vendor/tracemonkey/xpconnect/src/xpcquickstubs.cpp +1128 -0
  907. data/vendor/tracemonkey/xpconnect/src/xpcquickstubs.h +480 -0
  908. data/vendor/tracemonkey/xpconnect/src/xpcruntimesvc.cpp +179 -0
  909. data/vendor/tracemonkey/xpconnect/src/xpcstack.cpp +342 -0
  910. data/vendor/tracemonkey/xpconnect/src/xpcstring.cpp +139 -0
  911. data/vendor/tracemonkey/xpconnect/src/xpcthreadcontext.cpp +599 -0
  912. data/vendor/tracemonkey/xpconnect/src/xpcthrower.cpp +399 -0
  913. data/vendor/tracemonkey/xpconnect/src/xpcvariant.cpp +850 -0
  914. data/vendor/tracemonkey/xpconnect/src/xpcwrappedjs.cpp +670 -0
  915. data/vendor/tracemonkey/xpconnect/src/xpcwrappedjsclass.cpp +2015 -0
  916. data/vendor/tracemonkey/xpconnect/src/xpcwrappednative.cpp +3482 -0
  917. data/vendor/tracemonkey/xpconnect/src/xpcwrappednativeinfo.cpp +945 -0
  918. data/vendor/tracemonkey/xpconnect/src/xpcwrappednativejsops.cpp +2003 -0
  919. data/vendor/tracemonkey/xpconnect/src/xpcwrappednativeproto.cpp +302 -0
  920. data/vendor/tracemonkey/xpconnect/src/xpcwrappednativescope.cpp +991 -0
  921. data/vendor/tracemonkey/xpconnect/tests/Makefile.in +75 -0
  922. data/vendor/tracemonkey/xpconnect/tests/TestXPC.cpp +785 -0
  923. data/vendor/tracemonkey/xpconnect/tests/chrome/Makefile.in +51 -0
  924. data/vendor/tracemonkey/xpconnect/tests/chrome/test_bug500931.xul +43 -0
  925. data/vendor/tracemonkey/xpconnect/tests/components/Makefile.in +85 -0
  926. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_array.cpp +388 -0
  927. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_attributes.cpp +305 -0
  928. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_calljs.cpp +135 -0
  929. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_child.cpp +225 -0
  930. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_const.cpp +76 -0
  931. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_domstring.cpp +118 -0
  932. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_echo.cpp +616 -0
  933. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_in.cpp +204 -0
  934. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_inout.cpp +171 -0
  935. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_module.cpp +77 -0
  936. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_multiple.cpp +554 -0
  937. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_noisy.cpp +154 -0
  938. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_out.cpp +335 -0
  939. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_overloaded.cpp +250 -0
  940. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_private.h +192 -0
  941. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_string.cpp +185 -0
  942. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_variant.cpp +355 -0
  943. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/StdAfx.cpp +12 -0
  944. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/StdAfx.h +28 -0
  945. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/XPCDispUtilities.h +28 -0
  946. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/XPCIDispatchTest.cpp +86 -0
  947. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/XPCIDispatchTest.def +9 -0
  948. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/XPCIDispatchTest.dsp +318 -0
  949. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/XPCIDispatchTest.dsw +29 -0
  950. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/XPCIDispatchTest.idl +454 -0
  951. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/XPCIDispatchTest.rc +145 -0
  952. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispSimple.cpp +44 -0
  953. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispSimple.h +56 -0
  954. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispSimple.rgs +23 -0
  955. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestArrays.cpp +221 -0
  956. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestArrays.h +53 -0
  957. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestArrays.rgs +23 -0
  958. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestMethods.cpp +699 -0
  959. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestMethods.h +138 -0
  960. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestMethods.rgs +23 -0
  961. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestNoIDispatch.cpp +23 -0
  962. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestNoIDispatch.h +41 -0
  963. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestNoIDispatch.rgs +23 -0
  964. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestProperties.cpp +256 -0
  965. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestProperties.h +88 -0
  966. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestProperties.rgs +23 -0
  967. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestScriptOff.cpp +23 -0
  968. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestScriptOff.h +43 -0
  969. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestScriptOff.rgs +23 -0
  970. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestScriptOn.cpp +29 -0
  971. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestScriptOn.h +45 -0
  972. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestScriptOn.rgs +23 -0
  973. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestWrappedJS.cpp +177 -0
  974. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestWrappedJS.h +50 -0
  975. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestWrappedJS.rgs +23 -0
  976. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/resource.h +36 -0
  977. data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/WrappedCOM/Arrays/XPCIDispatchArrayTests.js +54 -0
  978. data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/WrappedCOM/Attributes/XPCIDispatchAttributeTests.js +150 -0
  979. data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/WrappedCOM/General/XPCIDispatchInstantiations.js +122 -0
  980. data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/WrappedCOM/General/XPCStress.js +58 -0
  981. data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/WrappedCOM/Methods/XPCIDispatchMethodTests.js +376 -0
  982. data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/WrappedCOM/shell.js +377 -0
  983. data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/WrappedJS/General/XPCIDispatchTestWrappedJS.js +76 -0
  984. data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/WrappedJS/shell.js +377 -0
  985. data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/exectests.cmd +1 -0
  986. data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/jsDriver.pl +1288 -0
  987. data/vendor/tracemonkey/xpconnect/tests/idl/Makefile.in +61 -0
  988. data/vendor/tracemonkey/xpconnect/tests/idl/xpctest.idl +312 -0
  989. data/vendor/tracemonkey/xpconnect/tests/idl/xpctest2.idl +51 -0
  990. data/vendor/tracemonkey/xpconnect/tests/idl/xpctest_attributes.idl +67 -0
  991. data/vendor/tracemonkey/xpconnect/tests/idl/xpctest_calljs.idl +59 -0
  992. data/vendor/tracemonkey/xpconnect/tests/idl/xpctest_const.idl +61 -0
  993. data/vendor/tracemonkey/xpconnect/tests/idl/xpctest_domstring.idl +59 -0
  994. data/vendor/tracemonkey/xpconnect/tests/idl/xpctest_in.idl +88 -0
  995. data/vendor/tracemonkey/xpconnect/tests/idl/xpctest_inout.idl +86 -0
  996. data/vendor/tracemonkey/xpconnect/tests/idl/xpctest_multiple.idl +77 -0
  997. data/vendor/tracemonkey/xpconnect/tests/idl/xpctest_out.idl +142 -0
  998. data/vendor/tracemonkey/xpconnect/tests/js/checkid.js +82 -0
  999. data/vendor/tracemonkey/xpconnect/tests/js/evaluate.js +311 -0
  1000. data/vendor/tracemonkey/xpconnect/tests/js/exceptions-2.js +153 -0
  1001. data/vendor/tracemonkey/xpconnect/tests/js/exceptions-3.js +194 -0
  1002. data/vendor/tracemonkey/xpconnect/tests/js/exceptions-4.js +297 -0
  1003. data/vendor/tracemonkey/xpconnect/tests/js/exceptions-5.js +343 -0
  1004. data/vendor/tracemonkey/xpconnect/tests/js/exceptions.js +230 -0
  1005. data/vendor/tracemonkey/xpconnect/tests/js/javascript.js +96 -0
  1006. data/vendor/tracemonkey/xpconnect/tests/js/multiple-2.js +151 -0
  1007. data/vendor/tracemonkey/xpconnect/tests/js/multiple-3.js +148 -0
  1008. data/vendor/tracemonkey/xpconnect/tests/js/multiple-4.js +152 -0
  1009. data/vendor/tracemonkey/xpconnect/tests/js/multiple.js +137 -0
  1010. data/vendor/tracemonkey/xpconnect/tests/js/notscriptable.js +104 -0
  1011. data/vendor/tracemonkey/xpconnect/tests/js/old/simpletest.js +36 -0
  1012. data/vendor/tracemonkey/xpconnect/tests/js/old/speed.js +60 -0
  1013. data/vendor/tracemonkey/xpconnect/tests/js/old/testxpc.js +464 -0
  1014. data/vendor/tracemonkey/xpconnect/tests/js/old/threads.js +74 -0
  1015. data/vendor/tracemonkey/xpconnect/tests/js/old/try.js +27 -0
  1016. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_array.js +308 -0
  1017. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_callcontext.js +68 -0
  1018. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_echo.js +636 -0
  1019. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_enum_and_sort.js +28 -0
  1020. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_enum_constants.js +15 -0
  1021. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_enum_create.js +200 -0
  1022. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_exceptions.js +167 -0
  1023. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_ids.js +135 -0
  1024. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_observer.js +36 -0
  1025. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_overloaded.js +14 -0
  1026. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_primitives.js +141 -0
  1027. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_propertybag.js +36 -0
  1028. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_variant.js +339 -0
  1029. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_variant_array.js +30 -0
  1030. data/vendor/tracemonkey/xpconnect/tests/js/readonlyattributes.js +74 -0
  1031. data/vendor/tracemonkey/xpconnect/tests/js/readwriteattributes.js +101 -0
  1032. data/vendor/tracemonkey/xpconnect/tests/js/scriptable.js +120 -0
  1033. data/vendor/tracemonkey/xpconnect/tests/js/testin.js +203 -0
  1034. data/vendor/tracemonkey/xpconnect/tests/js/xpcfun.js +234 -0
  1035. data/vendor/tracemonkey/xpconnect/tests/js/xpctest_primitives.js +200 -0
  1036. data/vendor/tracemonkey/xpconnect/tests/mochitest/Makefile.in +66 -0
  1037. data/vendor/tracemonkey/xpconnect/tests/mochitest/bug500931_helper.html +7 -0
  1038. data/vendor/tracemonkey/xpconnect/tests/mochitest/inner.html +7 -0
  1039. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug361111.xul +29 -0
  1040. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug384632.html +32 -0
  1041. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug390488.html +65 -0
  1042. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug393269.html +46 -0
  1043. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug396851.html +43 -0
  1044. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug428021.html +41 -0
  1045. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug446584.html +49 -0
  1046. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug448587.html +31 -0
  1047. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug462428.html +42 -0
  1048. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug478438.html +66 -0
  1049. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug484107.html +100 -0
  1050. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug484459.html +36 -0
  1051. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug500691.html +28 -0
  1052. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_wrappers.html +116 -0
  1053. data/vendor/tracemonkey/xpconnect/tests/unit/bogus_element_type.jsm +1 -0
  1054. data/vendor/tracemonkey/xpconnect/tests/unit/bogus_exports_type.jsm +1 -0
  1055. data/vendor/tracemonkey/xpconnect/tests/unit/bug451678_subscript.js +2 -0
  1056. data/vendor/tracemonkey/xpconnect/tests/unit/component_import.js +144 -0
  1057. data/vendor/tracemonkey/xpconnect/tests/unit/recursive_importA.jsm +44 -0
  1058. data/vendor/tracemonkey/xpconnect/tests/unit/recursive_importB.jsm +45 -0
  1059. data/vendor/tracemonkey/xpconnect/tests/unit/syntax_error.jsm +1 -0
  1060. data/vendor/tracemonkey/xpconnect/tests/unit/test_bogus_files.js +88 -0
  1061. data/vendor/tracemonkey/xpconnect/tests/unit/test_bug408412.js +51 -0
  1062. data/vendor/tracemonkey/xpconnect/tests/unit/test_bug451678.js +52 -0
  1063. data/vendor/tracemonkey/xpconnect/tests/unit/test_bug_442086.js +68 -0
  1064. data/vendor/tracemonkey/xpconnect/tests/unit/test_import.js +127 -0
  1065. data/vendor/tracemonkey/xpconnect/tests/unit/test_js_weak_references.js +63 -0
  1066. data/vendor/tracemonkey/xpconnect/tests/unit/test_recursive_import.js +62 -0
  1067. data/vendor/tracemonkey/xpconnect/tools/Makefile.in +49 -0
  1068. data/vendor/tracemonkey/xpconnect/tools/idl/Makefile.in +53 -0
  1069. data/vendor/tracemonkey/xpconnect/tools/idl/nsIXPCToolsCompiler.idl +60 -0
  1070. data/vendor/tracemonkey/xpconnect/tools/idl/nsIXPCToolsProfiler.idl +57 -0
  1071. data/vendor/tracemonkey/xpconnect/tools/js/CompileJSFiles.js +28 -0
  1072. data/vendor/tracemonkey/xpconnect/tools/js/ListJSFiles.js +18 -0
  1073. data/vendor/tracemonkey/xpconnect/tools/src/Makefile.in +76 -0
  1074. data/vendor/tracemonkey/xpconnect/tools/src/nsXPCToolsCompiler.cpp +161 -0
  1075. data/vendor/tracemonkey/xpconnect/tools/src/nsXPCToolsModule.cpp +65 -0
  1076. data/vendor/tracemonkey/xpconnect/tools/src/nsXPCToolsProfiler.cpp +370 -0
  1077. data/vendor/tracemonkey/xpconnect/tools/src/xpctools_private.h +236 -0
  1078. metadata +1164 -0
@@ -0,0 +1,3335 @@
1
+ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2
+ /****************************************************************
3
+ *
4
+ * The author of this software is David M. Gay.
5
+ *
6
+ * Copyright (c) 1991, 2000, 2001 by Lucent Technologies.
7
+ *
8
+ * Permission to use, copy, modify, and distribute this software for any
9
+ * purpose without fee is hereby granted, provided that this entire notice
10
+ * is included in all copies of any software which is or includes a copy
11
+ * or modification of this software and in all copies of the supporting
12
+ * documentation for such software.
13
+ *
14
+ * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
15
+ * WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR LUCENT MAKES ANY
16
+ * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
17
+ * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
18
+ *
19
+ ***************************************************************/
20
+
21
+ /* Please send bug reports to David M. Gay (dmg at acm dot org,
22
+ * with " at " changed at "@" and " dot " changed to "."). */
23
+
24
+ /* On a machine with IEEE extended-precision registers, it is
25
+ * necessary to specify double-precision (53-bit) rounding precision
26
+ * before invoking strtod or dtoa. If the machine uses (the equivalent
27
+ * of) Intel 80x87 arithmetic, the call
28
+ * _control87(PC_53, MCW_PC);
29
+ * does this with many compilers. Whether this or another call is
30
+ * appropriate depends on the compiler; for this to work, it may be
31
+ * necessary to #include "float.h" or another system-dependent header
32
+ * file.
33
+ */
34
+
35
+ /* strtod for IEEE-, VAX-, and IBM-arithmetic machines.
36
+ *
37
+ * This strtod returns a nearest machine number to the input decimal
38
+ * string (or sets errno to ERANGE). With IEEE arithmetic, ties are
39
+ * broken by the IEEE round-even rule. Otherwise ties are broken by
40
+ * biased rounding (add half and chop).
41
+ *
42
+ * Inspired loosely by William D. Clinger's paper "How to Read Floating
43
+ * Point Numbers Accurately" [Proc. ACM SIGPLAN '90, pp. 92-101].
44
+ *
45
+ * Modifications:
46
+ *
47
+ * 1. We only require IEEE, IBM, or VAX double-precision
48
+ * arithmetic (not IEEE double-extended).
49
+ * 2. We get by with floating-point arithmetic in a case that
50
+ * Clinger missed -- when we're computing d * 10^n
51
+ * for a small integer d and the integer n is not too
52
+ * much larger than 22 (the maximum integer k for which
53
+ * we can represent 10^k exactly), we may be able to
54
+ * compute (d*10^k) * 10^(e-k) with just one roundoff.
55
+ * 3. Rather than a bit-at-a-time adjustment of the binary
56
+ * result in the hard case, we use floating-point
57
+ * arithmetic to determine the adjustment to within
58
+ * one bit; only in really hard cases do we need to
59
+ * compute a second residual.
60
+ * 4. Because of 3., we don't need a large table of powers of 10
61
+ * for ten-to-e (just some small tables, e.g. of 10^k
62
+ * for 0 <= k <= 22).
63
+ */
64
+
65
+ /*
66
+ * #define IEEE_8087 for IEEE-arithmetic machines where the least
67
+ * significant byte has the lowest address.
68
+ * #define IEEE_MC68k for IEEE-arithmetic machines where the most
69
+ * significant byte has the lowest address.
70
+ * #define Long int on machines with 32-bit ints and 64-bit longs.
71
+ * #define IBM for IBM mainframe-style floating-point arithmetic.
72
+ * #define VAX for VAX-style floating-point arithmetic (D_floating).
73
+ * #define No_leftright to omit left-right logic in fast floating-point
74
+ * computation of dtoa.
75
+ * #define Honor_FLT_ROUNDS if FLT_ROUNDS can assume the values 2 or 3
76
+ * and strtod and dtoa should round accordingly.
77
+ * #define Check_FLT_ROUNDS if FLT_ROUNDS can assume the values 2 or 3
78
+ * and Honor_FLT_ROUNDS is not #defined.
79
+ * #define RND_PRODQUOT to use rnd_prod and rnd_quot (assembly routines
80
+ * that use extended-precision instructions to compute rounded
81
+ * products and quotients) with IBM.
82
+ * #define ROUND_BIASED for IEEE-format with biased rounding.
83
+ * #define Inaccurate_Divide for IEEE-format with correctly rounded
84
+ * products but inaccurate quotients, e.g., for Intel i860.
85
+ * #define NO_LONG_LONG on machines that do not have a "long long"
86
+ * integer type (of >= 64 bits). On such machines, you can
87
+ * #define Just_16 to store 16 bits per 32-bit Long when doing
88
+ * high-precision integer arithmetic. Whether this speeds things
89
+ * up or slows things down depends on the machine and the number
90
+ * being converted. If long long is available and the name is
91
+ * something other than "long long", #define Llong to be the name,
92
+ * and if "unsigned Llong" does not work as an unsigned version of
93
+ * Llong, #define #ULLong to be the corresponding unsigned type.
94
+ * #define KR_headers for old-style C function headers.
95
+ * #define Bad_float_h if your system lacks a float.h or if it does not
96
+ * define some or all of DBL_DIG, DBL_MAX_10_EXP, DBL_MAX_EXP,
97
+ * FLT_RADIX, FLT_ROUNDS, and DBL_MAX.
98
+ * #define MALLOC your_malloc, where your_malloc(n) acts like malloc(n)
99
+ * if memory is available and otherwise does something you deem
100
+ * appropriate. If MALLOC is undefined, malloc will be invoked
101
+ * directly -- and assumed always to succeed. Similarly, if you
102
+ * want something other than the system's free() to be called to
103
+ * recycle memory acquired from MALLOC, #define FREE to be the
104
+ * name of the alternate routine. (FREE or free is only called in
105
+ * pathological cases, e.g., in a dtoa call after a dtoa return in
106
+ * mode 3 with thousands of digits requested.)
107
+ * #define Omit_Private_Memory to omit logic (added Jan. 1998) for making
108
+ * memory allocations from a private pool of memory when possible.
109
+ * When used, the private pool is PRIVATE_MEM bytes long: 2304 bytes,
110
+ * unless #defined to be a different length. This default length
111
+ * suffices to get rid of MALLOC calls except for unusual cases,
112
+ * such as decimal-to-binary conversion of a very long string of
113
+ * digits. The longest string dtoa can return is about 751 bytes
114
+ * long. For conversions by strtod of strings of 800 digits and
115
+ * all dtoa conversions in single-threaded executions with 8-byte
116
+ * pointers, PRIVATE_MEM >= 7400 appears to suffice; with 4-byte
117
+ * pointers, PRIVATE_MEM >= 7112 appears adequate.
118
+ * #define NO_INFNAN_CHECK if you do not wish to have INFNAN_CHECK
119
+ * #defined automatically on IEEE systems. On such systems,
120
+ * when INFNAN_CHECK is #defined, strtod checks
121
+ * for Infinity and NaN (case insensitively). On some systems
122
+ * (e.g., some HP systems), it may be necessary to #define NAN_WORD0
123
+ * appropriately -- to the most significant word of a quiet NaN.
124
+ * (On HP Series 700/800 machines, -DNAN_WORD0=0x7ff40000 works.)
125
+ * When INFNAN_CHECK is #defined and No_Hex_NaN is not #defined,
126
+ * strtod also accepts (case insensitively) strings of the form
127
+ * NaN(x), where x is a string of hexadecimal digits and spaces;
128
+ * if there is only one string of hexadecimal digits, it is taken
129
+ * for the 52 fraction bits of the resulting NaN; if there are two
130
+ * or more strings of hex digits, the first is for the high 20 bits,
131
+ * the second and subsequent for the low 32 bits, with intervening
132
+ * white space ignored; but if this results in none of the 52
133
+ * fraction bits being on (an IEEE Infinity symbol), then NAN_WORD0
134
+ * and NAN_WORD1 are used instead.
135
+ * #define MULTIPLE_THREADS if the system offers preemptively scheduled
136
+ * multiple threads. In this case, you must provide (or suitably
137
+ * #define) two locks, acquired by ACQUIRE_DTOA_LOCK(n) and freed
138
+ * by FREE_DTOA_LOCK(n) for n = 0 or 1. (The second lock, accessed
139
+ * in pow5mult, ensures lazy evaluation of only one copy of high
140
+ * powers of 5; omitting this lock would introduce a small
141
+ * probability of wasting memory, but would otherwise be harmless.)
142
+ * You must also invoke freedtoa(s) to free the value s returned by
143
+ * dtoa. You may do so whether or not MULTIPLE_THREADS is #defined.
144
+ * #define NO_IEEE_Scale to disable new (Feb. 1997) logic in strtod that
145
+ * avoids underflows on inputs whose result does not underflow.
146
+ * If you #define NO_IEEE_Scale on a machine that uses IEEE-format
147
+ * floating-point numbers and flushes underflows to zero rather
148
+ * than implementing gradual underflow, then you must also #define
149
+ * Sudden_Underflow.
150
+ * #define USE_LOCALE to use the current locale's decimal_point value.
151
+ * #define SET_INEXACT if IEEE arithmetic is being used and extra
152
+ * computation should be done to set the inexact flag when the
153
+ * result is inexact and avoid setting inexact when the result
154
+ * is exact. In this case, dtoa.c must be compiled in
155
+ * an environment, perhaps provided by #include "dtoa.c" in a
156
+ * suitable wrapper, that defines two functions,
157
+ * int get_inexact(void);
158
+ * void clear_inexact(void);
159
+ * such that get_inexact() returns a nonzero value if the
160
+ * inexact bit is already set, and clear_inexact() sets the
161
+ * inexact bit to 0. When SET_INEXACT is #defined, strtod
162
+ * also does extra computations to set the underflow and overflow
163
+ * flags when appropriate (i.e., when the result is tiny and
164
+ * inexact or when it is a numeric value rounded to +-infinity).
165
+ * #define NO_ERRNO if strtod should not assign errno = ERANGE when
166
+ * the result overflows to +-Infinity or underflows to 0.
167
+ */
168
+
169
+ #ifndef Long
170
+ #define Long long
171
+ #endif
172
+ #ifndef ULong
173
+ typedef unsigned Long ULong;
174
+ #endif
175
+
176
+ #ifdef DEBUG
177
+ #include "stdio.h"
178
+ #define Bug(x) {fprintf(stderr, "%s\n", x); exit(1);}
179
+ #endif
180
+
181
+ #include "stdlib.h"
182
+ #include "string.h"
183
+
184
+ #ifdef USE_LOCALE
185
+ #include "locale.h"
186
+ #endif
187
+
188
+ #ifdef MALLOC
189
+ #ifdef KR_headers
190
+ extern char *MALLOC();
191
+ #else
192
+ extern void *MALLOC(size_t);
193
+ #endif
194
+ #else
195
+ #define MALLOC malloc
196
+ #endif
197
+
198
+ #ifndef Omit_Private_Memory
199
+ #ifndef PRIVATE_MEM
200
+ #define PRIVATE_MEM 2304
201
+ #endif
202
+ #define PRIVATE_mem ((PRIVATE_MEM+sizeof(double)-1)/sizeof(double))
203
+ static double private_mem[PRIVATE_mem], *pmem_next = private_mem;
204
+ #endif
205
+
206
+ #undef IEEE_Arith
207
+ #undef Avoid_Underflow
208
+ #ifdef IEEE_MC68k
209
+ #define IEEE_Arith
210
+ #endif
211
+ #ifdef IEEE_8087
212
+ #define IEEE_Arith
213
+ #endif
214
+
215
+ #ifdef IEEE_Arith
216
+ #ifndef NO_INFNAN_CHECK
217
+ #undef INFNAN_CHECK
218
+ #define INFNAN_CHECK
219
+ #endif
220
+ #else
221
+ #undef INFNAN_CHECK
222
+ #endif
223
+
224
+ #include "errno.h"
225
+
226
+ #ifdef Bad_float_h
227
+
228
+ #ifdef IEEE_Arith
229
+ #define DBL_DIG 15
230
+ #define DBL_MAX_10_EXP 308
231
+ #define DBL_MAX_EXP 1024
232
+ #define FLT_RADIX 2
233
+ #endif /*IEEE_Arith*/
234
+
235
+ #ifdef IBM
236
+ #define DBL_DIG 16
237
+ #define DBL_MAX_10_EXP 75
238
+ #define DBL_MAX_EXP 63
239
+ #define FLT_RADIX 16
240
+ #define DBL_MAX 7.2370055773322621e+75
241
+ #endif
242
+
243
+ #ifdef VAX
244
+ #define DBL_DIG 16
245
+ #define DBL_MAX_10_EXP 38
246
+ #define DBL_MAX_EXP 127
247
+ #define FLT_RADIX 2
248
+ #define DBL_MAX 1.7014118346046923e+38
249
+ #endif
250
+
251
+ #ifndef LONG_MAX
252
+ #define LONG_MAX 2147483647
253
+ #endif
254
+
255
+ #else /* ifndef Bad_float_h */
256
+ #include "float.h"
257
+ #endif /* Bad_float_h */
258
+
259
+ #ifndef __MATH_H__
260
+ #include "math.h"
261
+ #endif
262
+
263
+ #ifdef __cplusplus
264
+ extern "C" {
265
+ #endif
266
+
267
+ #ifndef CONST
268
+ #ifdef KR_headers
269
+ #define CONST /* blank */
270
+ #else
271
+ #define CONST const
272
+ #endif
273
+ #endif
274
+
275
+ #if defined(IEEE_8087) + defined(IEEE_MC68k) + defined(VAX) + defined(IBM) != 1
276
+ Exactly one of IEEE_8087, IEEE_MC68k, VAX, or IBM should be defined.
277
+ #endif
278
+
279
+ typedef union { double d; ULong L[2]; } U;
280
+
281
+ #define dval(x) ((x).d)
282
+ #ifdef IEEE_8087
283
+ #define word0(x) ((x).L[1])
284
+ #define word1(x) ((x).L[0])
285
+ #else
286
+ #define word0(x) ((x).L[0])
287
+ #define word1(x) ((x).L[1])
288
+ #endif
289
+
290
+ /* The following definition of Storeinc is appropriate for MIPS processors.
291
+ * An alternative that might be better on some machines is
292
+ * #define Storeinc(a,b,c) (*a++ = b << 16 | c & 0xffff)
293
+ */
294
+ #if defined(IEEE_8087) + defined(VAX)
295
+ #define Storeinc(a,b,c) (((unsigned short *)a)[1] = (unsigned short)b, \
296
+ ((unsigned short *)a)[0] = (unsigned short)c, a++)
297
+ #else
298
+ #define Storeinc(a,b,c) (((unsigned short *)a)[0] = (unsigned short)b, \
299
+ ((unsigned short *)a)[1] = (unsigned short)c, a++)
300
+ #endif
301
+
302
+ /* #define P DBL_MANT_DIG */
303
+ /* Ten_pmax = floor(P*log(2)/log(5)) */
304
+ /* Bletch = (highest power of 2 < DBL_MAX_10_EXP) / 16 */
305
+ /* Quick_max = floor((P-1)*log(FLT_RADIX)/log(10) - 1) */
306
+ /* Int_max = floor(P*log(FLT_RADIX)/log(10) - 1) */
307
+
308
+ #ifdef IEEE_Arith
309
+ #define Exp_shift 20
310
+ #define Exp_shift1 20
311
+ #define Exp_msk1 0x100000
312
+ #define Exp_msk11 0x100000
313
+ #define Exp_mask 0x7ff00000
314
+ #define P 53
315
+ #define Bias 1023
316
+ #define Emin (-1022)
317
+ #define Exp_1 0x3ff00000
318
+ #define Exp_11 0x3ff00000
319
+ #define Ebits 11
320
+ #define Frac_mask 0xfffff
321
+ #define Frac_mask1 0xfffff
322
+ #define Ten_pmax 22
323
+ #define Bletch 0x10
324
+ #define Bndry_mask 0xfffff
325
+ #define Bndry_mask1 0xfffff
326
+ #define LSB 1
327
+ #define Sign_bit 0x80000000
328
+ #define Log2P 1
329
+ #define Tiny0 0
330
+ #define Tiny1 1
331
+ #define Quick_max 14
332
+ #define Int_max 14
333
+ #ifndef NO_IEEE_Scale
334
+ #define Avoid_Underflow
335
+ #ifdef Flush_Denorm /* debugging option */
336
+ #undef Sudden_Underflow
337
+ #endif
338
+ #endif
339
+
340
+ #ifndef Flt_Rounds
341
+ #ifdef FLT_ROUNDS
342
+ #define Flt_Rounds FLT_ROUNDS
343
+ #else
344
+ #define Flt_Rounds 1
345
+ #endif
346
+ #endif /*Flt_Rounds*/
347
+
348
+ #ifdef Honor_FLT_ROUNDS
349
+ #define Rounding rounding
350
+ #undef Check_FLT_ROUNDS
351
+ #define Check_FLT_ROUNDS
352
+ #else
353
+ #define Rounding Flt_Rounds
354
+ #endif
355
+
356
+ #else /* ifndef IEEE_Arith */
357
+ #undef Check_FLT_ROUNDS
358
+ #undef Honor_FLT_ROUNDS
359
+ #undef SET_INEXACT
360
+ #undef Sudden_Underflow
361
+ #define Sudden_Underflow
362
+ #ifdef IBM
363
+ #undef Flt_Rounds
364
+ #define Flt_Rounds 0
365
+ #define Exp_shift 24
366
+ #define Exp_shift1 24
367
+ #define Exp_msk1 0x1000000
368
+ #define Exp_msk11 0x1000000
369
+ #define Exp_mask 0x7f000000
370
+ #define P 14
371
+ #define Bias 65
372
+ #define Exp_1 0x41000000
373
+ #define Exp_11 0x41000000
374
+ #define Ebits 8 /* exponent has 7 bits, but 8 is the right value in b2d */
375
+ #define Frac_mask 0xffffff
376
+ #define Frac_mask1 0xffffff
377
+ #define Bletch 4
378
+ #define Ten_pmax 22
379
+ #define Bndry_mask 0xefffff
380
+ #define Bndry_mask1 0xffffff
381
+ #define LSB 1
382
+ #define Sign_bit 0x80000000
383
+ #define Log2P 4
384
+ #define Tiny0 0x100000
385
+ #define Tiny1 0
386
+ #define Quick_max 14
387
+ #define Int_max 15
388
+ #else /* VAX */
389
+ #undef Flt_Rounds
390
+ #define Flt_Rounds 1
391
+ #define Exp_shift 23
392
+ #define Exp_shift1 7
393
+ #define Exp_msk1 0x80
394
+ #define Exp_msk11 0x800000
395
+ #define Exp_mask 0x7f80
396
+ #define P 56
397
+ #define Bias 129
398
+ #define Exp_1 0x40800000
399
+ #define Exp_11 0x4080
400
+ #define Ebits 8
401
+ #define Frac_mask 0x7fffff
402
+ #define Frac_mask1 0xffff007f
403
+ #define Ten_pmax 24
404
+ #define Bletch 2
405
+ #define Bndry_mask 0xffff007f
406
+ #define Bndry_mask1 0xffff007f
407
+ #define LSB 0x10000
408
+ #define Sign_bit 0x8000
409
+ #define Log2P 1
410
+ #define Tiny0 0x80
411
+ #define Tiny1 0
412
+ #define Quick_max 15
413
+ #define Int_max 15
414
+ #endif /* IBM, VAX */
415
+ #endif /* IEEE_Arith */
416
+
417
+ #ifndef IEEE_Arith
418
+ #define ROUND_BIASED
419
+ #endif
420
+
421
+ #ifdef RND_PRODQUOT
422
+ #define rounded_product(a,b) a = rnd_prod(a, b)
423
+ #define rounded_quotient(a,b) a = rnd_quot(a, b)
424
+ #ifdef KR_headers
425
+ extern double rnd_prod(), rnd_quot();
426
+ #else
427
+ extern double rnd_prod(double, double), rnd_quot(double, double);
428
+ #endif
429
+ #else
430
+ #define rounded_product(a,b) a *= b
431
+ #define rounded_quotient(a,b) a /= b
432
+ #endif
433
+
434
+ #define Big0 (Frac_mask1 | Exp_msk1*(DBL_MAX_EXP+Bias-1))
435
+ #define Big1 0xffffffff
436
+
437
+ #ifndef Pack_32
438
+ #define Pack_32
439
+ #endif
440
+
441
+ #ifdef KR_headers
442
+ #define FFFFFFFF ((((unsigned long)0xffff)<<16)|(unsigned long)0xffff)
443
+ #else
444
+ #define FFFFFFFF 0xffffffffUL
445
+ #endif
446
+
447
+ #ifdef NO_LONG_LONG
448
+ #undef ULLong
449
+ #ifdef Just_16
450
+ #undef Pack_32
451
+ /* When Pack_32 is not defined, we store 16 bits per 32-bit Long.
452
+ * This makes some inner loops simpler and sometimes saves work
453
+ * during multiplications, but it often seems to make things slightly
454
+ * slower. Hence the default is now to store 32 bits per Long.
455
+ */
456
+ #endif
457
+ #else /* long long available */
458
+ #ifndef Llong
459
+ #define Llong long long
460
+ #endif
461
+ #ifndef ULLong
462
+ #define ULLong unsigned Llong
463
+ #endif
464
+ #endif /* NO_LONG_LONG */
465
+
466
+ #ifndef MULTIPLE_THREADS
467
+ #define ACQUIRE_DTOA_LOCK(n) /*nothing*/
468
+ #define FREE_DTOA_LOCK(n) /*nothing*/
469
+ #endif
470
+
471
+ #define Kmax 7
472
+
473
+ struct
474
+ Bigint {
475
+ struct Bigint *next;
476
+ int k, maxwds, sign, wds;
477
+ ULong x[1];
478
+ };
479
+
480
+ typedef struct Bigint Bigint;
481
+
482
+ static Bigint *freelist[Kmax+1];
483
+
484
+ static Bigint *
485
+ Balloc
486
+ #ifdef KR_headers
487
+ (k) int k;
488
+ #else
489
+ (int k)
490
+ #endif
491
+ {
492
+ int x;
493
+ Bigint *rv;
494
+ #ifndef Omit_Private_Memory
495
+ size_t len;
496
+ #endif
497
+
498
+ ACQUIRE_DTOA_LOCK(0);
499
+ /* The k > Kmax case does not need ACQUIRE_DTOA_LOCK(0), */
500
+ /* but this case seems very unlikely. */
501
+ if (k <= Kmax && (rv = freelist[k]))
502
+ freelist[k] = rv->next;
503
+ else {
504
+ x = 1 << k;
505
+ #ifdef Omit_Private_Memory
506
+ rv = (Bigint *)MALLOC(sizeof(Bigint) + (x-1)*sizeof(ULong));
507
+ #else
508
+ len = (sizeof(Bigint) + (x-1)*sizeof(ULong) + sizeof(double) - 1)
509
+ /sizeof(double);
510
+ if (k <= Kmax && pmem_next - private_mem + len <= PRIVATE_mem) {
511
+ rv = (Bigint*)pmem_next;
512
+ pmem_next += len;
513
+ }
514
+ else
515
+ rv = (Bigint*)MALLOC(len*sizeof(double));
516
+ #endif
517
+ rv->k = k;
518
+ rv->maxwds = x;
519
+ }
520
+ FREE_DTOA_LOCK(0);
521
+ rv->sign = rv->wds = 0;
522
+ return rv;
523
+ }
524
+
525
+ static void
526
+ Bfree
527
+ #ifdef KR_headers
528
+ (v) Bigint *v;
529
+ #else
530
+ (Bigint *v)
531
+ #endif
532
+ {
533
+ if (v) {
534
+ if (v->k > Kmax)
535
+ #ifdef FREE
536
+ FREE((void*)v);
537
+ #else
538
+ free((void*)v);
539
+ #endif
540
+ else {
541
+ ACQUIRE_DTOA_LOCK(0);
542
+ v->next = freelist[v->k];
543
+ freelist[v->k] = v;
544
+ FREE_DTOA_LOCK(0);
545
+ }
546
+ }
547
+ }
548
+
549
+ #define Bcopy(x,y) memcpy((char *)&x->sign, (char *)&y->sign, \
550
+ y->wds*sizeof(Long) + 2*sizeof(int))
551
+
552
+ static Bigint *
553
+ multadd
554
+ #ifdef KR_headers
555
+ (b, m, a) Bigint *b; int m, a;
556
+ #else
557
+ (Bigint *b, int m, int a) /* multiply by m and add a */
558
+ #endif
559
+ {
560
+ int i, wds;
561
+ #ifdef ULLong
562
+ ULong *x;
563
+ ULLong carry, y;
564
+ #else
565
+ ULong carry, *x, y;
566
+ #ifdef Pack_32
567
+ ULong xi, z;
568
+ #endif
569
+ #endif
570
+ Bigint *b1;
571
+
572
+ wds = b->wds;
573
+ x = b->x;
574
+ i = 0;
575
+ carry = a;
576
+ do {
577
+ #ifdef ULLong
578
+ y = *x * (ULLong)m + carry;
579
+ carry = y >> 32;
580
+ *x++ = (ULong) y & FFFFFFFF;
581
+ #else
582
+ #ifdef Pack_32
583
+ xi = *x;
584
+ y = (xi & 0xffff) * m + carry;
585
+ z = (xi >> 16) * m + (y >> 16);
586
+ carry = z >> 16;
587
+ *x++ = (z << 16) + (y & 0xffff);
588
+ #else
589
+ y = *x * m + carry;
590
+ carry = y >> 16;
591
+ *x++ = y & 0xffff;
592
+ #endif
593
+ #endif
594
+ }
595
+ while(++i < wds);
596
+ if (carry) {
597
+ if (wds >= b->maxwds) {
598
+ b1 = Balloc(b->k+1);
599
+ Bcopy(b1, b);
600
+ Bfree(b);
601
+ b = b1;
602
+ }
603
+ b->x[wds++] = (ULong) carry;
604
+ b->wds = wds;
605
+ }
606
+ return b;
607
+ }
608
+
609
+ static Bigint *
610
+ s2b
611
+ #ifdef KR_headers
612
+ (s, nd0, nd, y9) CONST char *s; int nd0, nd; ULong y9;
613
+ #else
614
+ (CONST char *s, int nd0, int nd, ULong y9)
615
+ #endif
616
+ {
617
+ Bigint *b;
618
+ int i, k;
619
+ Long x, y;
620
+
621
+ x = (nd + 8) / 9;
622
+ for(k = 0, y = 1; x > y; y <<= 1, k++) ;
623
+ #ifdef Pack_32
624
+ b = Balloc(k);
625
+ b->x[0] = y9;
626
+ b->wds = 1;
627
+ #else
628
+ b = Balloc(k+1);
629
+ b->x[0] = y9 & 0xffff;
630
+ b->wds = (b->x[1] = y9 >> 16) ? 2 : 1;
631
+ #endif
632
+
633
+ i = 9;
634
+ if (9 < nd0) {
635
+ s += 9;
636
+ do b = multadd(b, 10, *s++ - '0');
637
+ while(++i < nd0);
638
+ s++;
639
+ }
640
+ else
641
+ s += 10;
642
+ for(; i < nd; i++)
643
+ b = multadd(b, 10, *s++ - '0');
644
+ return b;
645
+ }
646
+
647
+ static int
648
+ hi0bits
649
+ #ifdef KR_headers
650
+ (x) register ULong x;
651
+ #else
652
+ (register ULong x)
653
+ #endif
654
+ {
655
+ register int k = 0;
656
+
657
+ if (!(x & 0xffff0000)) {
658
+ k = 16;
659
+ x <<= 16;
660
+ }
661
+ if (!(x & 0xff000000)) {
662
+ k += 8;
663
+ x <<= 8;
664
+ }
665
+ if (!(x & 0xf0000000)) {
666
+ k += 4;
667
+ x <<= 4;
668
+ }
669
+ if (!(x & 0xc0000000)) {
670
+ k += 2;
671
+ x <<= 2;
672
+ }
673
+ if (!(x & 0x80000000)) {
674
+ k++;
675
+ if (!(x & 0x40000000))
676
+ return 32;
677
+ }
678
+ return k;
679
+ }
680
+
681
+ static int
682
+ lo0bits
683
+ #ifdef KR_headers
684
+ (y) ULong *y;
685
+ #else
686
+ (ULong *y)
687
+ #endif
688
+ {
689
+ register int k;
690
+ register ULong x = *y;
691
+
692
+ if (x & 7) {
693
+ if (x & 1)
694
+ return 0;
695
+ if (x & 2) {
696
+ *y = x >> 1;
697
+ return 1;
698
+ }
699
+ *y = x >> 2;
700
+ return 2;
701
+ }
702
+ k = 0;
703
+ if (!(x & 0xffff)) {
704
+ k = 16;
705
+ x >>= 16;
706
+ }
707
+ if (!(x & 0xff)) {
708
+ k += 8;
709
+ x >>= 8;
710
+ }
711
+ if (!(x & 0xf)) {
712
+ k += 4;
713
+ x >>= 4;
714
+ }
715
+ if (!(x & 0x3)) {
716
+ k += 2;
717
+ x >>= 2;
718
+ }
719
+ if (!(x & 1)) {
720
+ k++;
721
+ x >>= 1;
722
+ if (!x)
723
+ return 32;
724
+ }
725
+ *y = x;
726
+ return k;
727
+ }
728
+
729
+ static Bigint *
730
+ i2b
731
+ #ifdef KR_headers
732
+ (i) int i;
733
+ #else
734
+ (int i)
735
+ #endif
736
+ {
737
+ Bigint *b;
738
+
739
+ b = Balloc(1);
740
+ b->x[0] = i;
741
+ b->wds = 1;
742
+ return b;
743
+ }
744
+
745
+ static Bigint *
746
+ mult
747
+ #ifdef KR_headers
748
+ (a, b) Bigint *a, *b;
749
+ #else
750
+ (Bigint *a, Bigint *b)
751
+ #endif
752
+ {
753
+ Bigint *c;
754
+ int k, wa, wb, wc;
755
+ ULong *x, *xa, *xae, *xb, *xbe, *xc, *xc0;
756
+ ULong y;
757
+ #ifdef ULLong
758
+ ULLong carry, z;
759
+ #else
760
+ ULong carry, z;
761
+ #ifdef Pack_32
762
+ ULong z2;
763
+ #endif
764
+ #endif
765
+
766
+ if (a->wds < b->wds) {
767
+ c = a;
768
+ a = b;
769
+ b = c;
770
+ }
771
+ k = a->k;
772
+ wa = a->wds;
773
+ wb = b->wds;
774
+ wc = wa + wb;
775
+ if (wc > a->maxwds)
776
+ k++;
777
+ c = Balloc(k);
778
+ for(x = c->x, xa = x + wc; x < xa; x++)
779
+ *x = 0;
780
+ xa = a->x;
781
+ xae = xa + wa;
782
+ xb = b->x;
783
+ xbe = xb + wb;
784
+ xc0 = c->x;
785
+ #ifdef ULLong
786
+ for(; xb < xbe; xc0++) {
787
+ if ((y = *xb++)) {
788
+ x = xa;
789
+ xc = xc0;
790
+ carry = 0;
791
+ do {
792
+ z = *x++ * (ULLong)y + *xc + carry;
793
+ carry = z >> 32;
794
+ *xc++ = (ULong) z & FFFFFFFF;
795
+ }
796
+ while(x < xae);
797
+ *xc = (ULong) carry;
798
+ }
799
+ }
800
+ #else
801
+ #ifdef Pack_32
802
+ for(; xb < xbe; xb++, xc0++) {
803
+ if (y = *xb & 0xffff) {
804
+ x = xa;
805
+ xc = xc0;
806
+ carry = 0;
807
+ do {
808
+ z = (*x & 0xffff) * y + (*xc & 0xffff) + carry;
809
+ carry = z >> 16;
810
+ z2 = (*x++ >> 16) * y + (*xc >> 16) + carry;
811
+ carry = z2 >> 16;
812
+ Storeinc(xc, z2, z);
813
+ }
814
+ while(x < xae);
815
+ *xc = carry;
816
+ }
817
+ if (y = *xb >> 16) {
818
+ x = xa;
819
+ xc = xc0;
820
+ carry = 0;
821
+ z2 = *xc;
822
+ do {
823
+ z = (*x & 0xffff) * y + (*xc >> 16) + carry;
824
+ carry = z >> 16;
825
+ Storeinc(xc, z, z2);
826
+ z2 = (*x++ >> 16) * y + (*xc & 0xffff) + carry;
827
+ carry = z2 >> 16;
828
+ }
829
+ while(x < xae);
830
+ *xc = z2;
831
+ }
832
+ }
833
+ #else
834
+ for(; xb < xbe; xc0++) {
835
+ if (y = *xb++) {
836
+ x = xa;
837
+ xc = xc0;
838
+ carry = 0;
839
+ do {
840
+ z = *x++ * y + *xc + carry;
841
+ carry = z >> 16;
842
+ *xc++ = z & 0xffff;
843
+ }
844
+ while(x < xae);
845
+ *xc = carry;
846
+ }
847
+ }
848
+ #endif
849
+ #endif
850
+ for(xc0 = c->x, xc = xc0 + wc; wc > 0 && !*--xc; --wc) ;
851
+ c->wds = wc;
852
+ return c;
853
+ }
854
+
855
+ static Bigint *p5s;
856
+
857
+ static Bigint *
858
+ pow5mult
859
+ #ifdef KR_headers
860
+ (b, k) Bigint *b; int k;
861
+ #else
862
+ (Bigint *b, int k)
863
+ #endif
864
+ {
865
+ Bigint *b1, *p5, *p51;
866
+ int i;
867
+ static int p05[3] = { 5, 25, 125 };
868
+
869
+ if ((i = k & 3))
870
+ b = multadd(b, p05[i-1], 0);
871
+
872
+ if (!(k >>= 2))
873
+ return b;
874
+ if (!(p5 = p5s)) {
875
+ /* first time */
876
+ #ifdef MULTIPLE_THREADS
877
+ ACQUIRE_DTOA_LOCK(1);
878
+ if (!(p5 = p5s)) {
879
+ p5 = p5s = i2b(625);
880
+ p5->next = 0;
881
+ }
882
+ FREE_DTOA_LOCK(1);
883
+ #else
884
+ p5 = p5s = i2b(625);
885
+ p5->next = 0;
886
+ #endif
887
+ }
888
+ for(;;) {
889
+ if (k & 1) {
890
+ b1 = mult(b, p5);
891
+ Bfree(b);
892
+ b = b1;
893
+ }
894
+ if (!(k >>= 1))
895
+ break;
896
+ if (!(p51 = p5->next)) {
897
+ #ifdef MULTIPLE_THREADS
898
+ ACQUIRE_DTOA_LOCK(1);
899
+ if (!(p51 = p5->next)) {
900
+ p51 = p5->next = mult(p5,p5);
901
+ p51->next = 0;
902
+ }
903
+ FREE_DTOA_LOCK(1);
904
+ #else
905
+ p51 = p5->next = mult(p5,p5);
906
+ p51->next = 0;
907
+ #endif
908
+ }
909
+ p5 = p51;
910
+ }
911
+ return b;
912
+ }
913
+
914
+ static Bigint *
915
+ lshift
916
+ #ifdef KR_headers
917
+ (b, k) Bigint *b; int k;
918
+ #else
919
+ (Bigint *b, int k)
920
+ #endif
921
+ {
922
+ int i, k1, n, n1;
923
+ Bigint *b1;
924
+ ULong *x, *x1, *xe, z;
925
+
926
+ #ifdef Pack_32
927
+ n = k >> 5;
928
+ #else
929
+ n = k >> 4;
930
+ #endif
931
+ k1 = b->k;
932
+ n1 = n + b->wds + 1;
933
+ for(i = b->maxwds; n1 > i; i <<= 1)
934
+ k1++;
935
+ b1 = Balloc(k1);
936
+ x1 = b1->x;
937
+ for(i = 0; i < n; i++)
938
+ *x1++ = 0;
939
+ x = b->x;
940
+ xe = x + b->wds;
941
+ #ifdef Pack_32
942
+ if (k &= 0x1f) {
943
+ k1 = 32 - k;
944
+ z = 0;
945
+ do {
946
+ *x1++ = *x << k | z;
947
+ z = *x++ >> k1;
948
+ }
949
+ while(x < xe);
950
+ if ((*x1 = z))
951
+ ++n1;
952
+ }
953
+ #else
954
+ if (k &= 0xf) {
955
+ k1 = 16 - k;
956
+ z = 0;
957
+ do {
958
+ *x1++ = *x << k & 0xffff | z;
959
+ z = *x++ >> k1;
960
+ }
961
+ while(x < xe);
962
+ if (*x1 = z)
963
+ ++n1;
964
+ }
965
+ #endif
966
+ else do
967
+ *x1++ = *x++;
968
+ while(x < xe);
969
+ b1->wds = n1 - 1;
970
+ Bfree(b);
971
+ return b1;
972
+ }
973
+
974
+ static int
975
+ cmp
976
+ #ifdef KR_headers
977
+ (a, b) Bigint *a, *b;
978
+ #else
979
+ (Bigint *a, Bigint *b)
980
+ #endif
981
+ {
982
+ ULong *xa, *xa0, *xb, *xb0;
983
+ int i, j;
984
+
985
+ i = a->wds;
986
+ j = b->wds;
987
+ #ifdef DEBUG
988
+ if (i > 1 && !a->x[i-1])
989
+ Bug("cmp called with a->x[a->wds-1] == 0");
990
+ if (j > 1 && !b->x[j-1])
991
+ Bug("cmp called with b->x[b->wds-1] == 0");
992
+ #endif
993
+ if (i -= j)
994
+ return i;
995
+ xa0 = a->x;
996
+ xa = xa0 + j;
997
+ xb0 = b->x;
998
+ xb = xb0 + j;
999
+ for(;;) {
1000
+ if (*--xa != *--xb)
1001
+ return *xa < *xb ? -1 : 1;
1002
+ if (xa <= xa0)
1003
+ break;
1004
+ }
1005
+ return 0;
1006
+ }
1007
+
1008
+ static Bigint *
1009
+ diff
1010
+ #ifdef KR_headers
1011
+ (a, b) Bigint *a, *b;
1012
+ #else
1013
+ (Bigint *a, Bigint *b)
1014
+ #endif
1015
+ {
1016
+ Bigint *c;
1017
+ int i, wa, wb;
1018
+ ULong *xa, *xae, *xb, *xbe, *xc;
1019
+ #ifdef ULLong
1020
+ ULLong borrow, y;
1021
+ #else
1022
+ ULong borrow, y;
1023
+ #ifdef Pack_32
1024
+ ULong z;
1025
+ #endif
1026
+ #endif
1027
+
1028
+ i = cmp(a,b);
1029
+ if (!i) {
1030
+ c = Balloc(0);
1031
+ c->wds = 1;
1032
+ c->x[0] = 0;
1033
+ return c;
1034
+ }
1035
+ if (i < 0) {
1036
+ c = a;
1037
+ a = b;
1038
+ b = c;
1039
+ i = 1;
1040
+ }
1041
+ else
1042
+ i = 0;
1043
+ c = Balloc(a->k);
1044
+ c->sign = i;
1045
+ wa = a->wds;
1046
+ xa = a->x;
1047
+ xae = xa + wa;
1048
+ wb = b->wds;
1049
+ xb = b->x;
1050
+ xbe = xb + wb;
1051
+ xc = c->x;
1052
+ borrow = 0;
1053
+ #ifdef ULLong
1054
+ do {
1055
+ y = (ULLong)*xa++ - *xb++ - borrow;
1056
+ borrow = y >> 32 & (ULong)1;
1057
+ *xc++ = (ULong) y & FFFFFFFF;
1058
+ }
1059
+ while(xb < xbe);
1060
+ while(xa < xae) {
1061
+ y = *xa++ - borrow;
1062
+ borrow = y >> 32 & (ULong)1;
1063
+ *xc++ = (ULong) y & FFFFFFFF;
1064
+ }
1065
+ #else
1066
+ #ifdef Pack_32
1067
+ do {
1068
+ y = (*xa & 0xffff) - (*xb & 0xffff) - borrow;
1069
+ borrow = (y & 0x10000) >> 16;
1070
+ z = (*xa++ >> 16) - (*xb++ >> 16) - borrow;
1071
+ borrow = (z & 0x10000) >> 16;
1072
+ Storeinc(xc, z, y);
1073
+ }
1074
+ while(xb < xbe);
1075
+ while(xa < xae) {
1076
+ y = (*xa & 0xffff) - borrow;
1077
+ borrow = (y & 0x10000) >> 16;
1078
+ z = (*xa++ >> 16) - borrow;
1079
+ borrow = (z & 0x10000) >> 16;
1080
+ Storeinc(xc, z, y);
1081
+ }
1082
+ #else
1083
+ do {
1084
+ y = *xa++ - *xb++ - borrow;
1085
+ borrow = (y & 0x10000) >> 16;
1086
+ *xc++ = y & 0xffff;
1087
+ }
1088
+ while(xb < xbe);
1089
+ while(xa < xae) {
1090
+ y = *xa++ - borrow;
1091
+ borrow = (y & 0x10000) >> 16;
1092
+ *xc++ = y & 0xffff;
1093
+ }
1094
+ #endif
1095
+ #endif
1096
+ while(!*--xc)
1097
+ wa--;
1098
+ c->wds = wa;
1099
+ return c;
1100
+ }
1101
+
1102
+ static double
1103
+ ulp
1104
+ #ifdef KR_headers
1105
+ (x) U x;
1106
+ #else
1107
+ (U x)
1108
+ #endif
1109
+ {
1110
+ register Long L;
1111
+ U a;
1112
+
1113
+ L = (word0(x) & Exp_mask) - (P-1)*Exp_msk1;
1114
+ #ifndef Avoid_Underflow
1115
+ #ifndef Sudden_Underflow
1116
+ if (L > 0) {
1117
+ #endif
1118
+ #endif
1119
+ #ifdef IBM
1120
+ L |= Exp_msk1 >> 4;
1121
+ #endif
1122
+ word0(a) = L;
1123
+ word1(a) = 0;
1124
+ #ifndef Avoid_Underflow
1125
+ #ifndef Sudden_Underflow
1126
+ }
1127
+ else {
1128
+ L = -L >> Exp_shift;
1129
+ if (L < Exp_shift) {
1130
+ word0(a) = 0x80000 >> L;
1131
+ word1(a) = 0;
1132
+ }
1133
+ else {
1134
+ word0(a) = 0;
1135
+ L -= Exp_shift;
1136
+ word1(a) = L >= 31 ? 1 : 1 << 31 - L;
1137
+ }
1138
+ }
1139
+ #endif
1140
+ #endif
1141
+ return dval(a);
1142
+ }
1143
+
1144
+ static double
1145
+ b2d
1146
+ #ifdef KR_headers
1147
+ (a, e) Bigint *a; int *e;
1148
+ #else
1149
+ (Bigint *a, int *e)
1150
+ #endif
1151
+ {
1152
+ ULong *xa, *xa0, w, y, z;
1153
+ int k;
1154
+ U d;
1155
+ #ifdef VAX
1156
+ ULong d0, d1;
1157
+ #else
1158
+ #define d0 word0(d)
1159
+ #define d1 word1(d)
1160
+ #endif
1161
+
1162
+ xa0 = a->x;
1163
+ xa = xa0 + a->wds;
1164
+ y = *--xa;
1165
+ #ifdef DEBUG
1166
+ if (!y) Bug("zero y in b2d");
1167
+ #endif
1168
+ k = hi0bits(y);
1169
+ *e = 32 - k;
1170
+ #ifdef Pack_32
1171
+ if (k < Ebits) {
1172
+ d0 = Exp_1 | y >> (Ebits - k);
1173
+ w = xa > xa0 ? *--xa : 0;
1174
+ d1 = y << ((32-Ebits) + k) | w >> (Ebits - k);
1175
+ goto ret_d;
1176
+ }
1177
+ z = xa > xa0 ? *--xa : 0;
1178
+ if (k -= Ebits) {
1179
+ d0 = Exp_1 | y << k | z >> (32 - k);
1180
+ y = xa > xa0 ? *--xa : 0;
1181
+ d1 = z << k | y >> (32 - k);
1182
+ }
1183
+ else {
1184
+ d0 = Exp_1 | y;
1185
+ d1 = z;
1186
+ }
1187
+ #else
1188
+ if (k < Ebits + 16) {
1189
+ z = xa > xa0 ? *--xa : 0;
1190
+ d0 = Exp_1 | y << k - Ebits | z >> Ebits + 16 - k;
1191
+ w = xa > xa0 ? *--xa : 0;
1192
+ y = xa > xa0 ? *--xa : 0;
1193
+ d1 = z << k + 16 - Ebits | w << k - Ebits | y >> 16 + Ebits - k;
1194
+ goto ret_d;
1195
+ }
1196
+ z = xa > xa0 ? *--xa : 0;
1197
+ w = xa > xa0 ? *--xa : 0;
1198
+ k -= Ebits + 16;
1199
+ d0 = Exp_1 | y << k + 16 | z << k | w >> 16 - k;
1200
+ y = xa > xa0 ? *--xa : 0;
1201
+ d1 = w << k + 16 | y << k;
1202
+ #endif
1203
+ ret_d:
1204
+ #ifdef VAX
1205
+ word0(d) = d0 >> 16 | d0 << 16;
1206
+ word1(d) = d1 >> 16 | d1 << 16;
1207
+ #else
1208
+ #undef d0
1209
+ #undef d1
1210
+ #endif
1211
+ return dval(d);
1212
+ }
1213
+
1214
+ static Bigint *
1215
+ d2b
1216
+ #ifdef KR_headers
1217
+ (d, e, bits) U d; int *e, *bits;
1218
+ #else
1219
+ (U d, int *e, int *bits)
1220
+ #endif
1221
+ {
1222
+ Bigint *b;
1223
+ int de, k;
1224
+ ULong *x, y, z;
1225
+ #ifndef Sudden_Underflow
1226
+ int i;
1227
+ #endif
1228
+ #ifdef VAX
1229
+ ULong d0, d1;
1230
+ d0 = word0(d) >> 16 | word0(d) << 16;
1231
+ d1 = word1(d) >> 16 | word1(d) << 16;
1232
+ #else
1233
+ #define d0 word0(d)
1234
+ #define d1 word1(d)
1235
+ #endif
1236
+
1237
+ #ifdef Pack_32
1238
+ b = Balloc(1);
1239
+ #else
1240
+ b = Balloc(2);
1241
+ #endif
1242
+ x = b->x;
1243
+
1244
+ z = d0 & Frac_mask;
1245
+ d0 &= 0x7fffffff; /* clear sign bit, which we ignore */
1246
+ #ifdef Sudden_Underflow
1247
+ de = (int)(d0 >> Exp_shift);
1248
+ #ifndef IBM
1249
+ z |= Exp_msk11;
1250
+ #endif
1251
+ #else
1252
+ if ((de = (int)(d0 >> Exp_shift)))
1253
+ z |= Exp_msk1;
1254
+ #endif
1255
+ #ifdef Pack_32
1256
+ if ((y = d1)) {
1257
+ if ((k = lo0bits(&y))) {
1258
+ x[0] = y | z << (32 - k);
1259
+ z >>= k;
1260
+ }
1261
+ else
1262
+ x[0] = y;
1263
+ #ifndef Sudden_Underflow
1264
+ i =
1265
+ #endif
1266
+ b->wds = (x[1] = z) ? 2 : 1;
1267
+ }
1268
+ else {
1269
+ #ifdef DEBUG
1270
+ if (!z)
1271
+ Bug("Zero passed to d2b");
1272
+ #endif
1273
+ k = lo0bits(&z);
1274
+ x[0] = z;
1275
+ #ifndef Sudden_Underflow
1276
+ i =
1277
+ #endif
1278
+ b->wds = 1;
1279
+ k += 32;
1280
+ }
1281
+ #else
1282
+ if (y = d1) {
1283
+ if (k = lo0bits(&y))
1284
+ if (k >= 16) {
1285
+ x[0] = y | z << 32 - k & 0xffff;
1286
+ x[1] = z >> k - 16 & 0xffff;
1287
+ x[2] = z >> k;
1288
+ i = 2;
1289
+ }
1290
+ else {
1291
+ x[0] = y & 0xffff;
1292
+ x[1] = y >> 16 | z << 16 - k & 0xffff;
1293
+ x[2] = z >> k & 0xffff;
1294
+ x[3] = z >> k+16;
1295
+ i = 3;
1296
+ }
1297
+ else {
1298
+ x[0] = y & 0xffff;
1299
+ x[1] = y >> 16;
1300
+ x[2] = z & 0xffff;
1301
+ x[3] = z >> 16;
1302
+ i = 3;
1303
+ }
1304
+ }
1305
+ else {
1306
+ #ifdef DEBUG
1307
+ if (!z)
1308
+ Bug("Zero passed to d2b");
1309
+ #endif
1310
+ k = lo0bits(&z);
1311
+ if (k >= 16) {
1312
+ x[0] = z;
1313
+ i = 0;
1314
+ }
1315
+ else {
1316
+ x[0] = z & 0xffff;
1317
+ x[1] = z >> 16;
1318
+ i = 1;
1319
+ }
1320
+ k += 32;
1321
+ }
1322
+ while(!x[i])
1323
+ --i;
1324
+ b->wds = i + 1;
1325
+ #endif
1326
+ #ifndef Sudden_Underflow
1327
+ if (de) {
1328
+ #endif
1329
+ #ifdef IBM
1330
+ *e = (de - Bias - (P-1) << 2) + k;
1331
+ *bits = 4*P + 8 - k - hi0bits(word0(d) & Frac_mask);
1332
+ #else
1333
+ *e = de - Bias - (P-1) + k;
1334
+ *bits = P - k;
1335
+ #endif
1336
+ #ifndef Sudden_Underflow
1337
+ }
1338
+ else {
1339
+ *e = de - Bias - (P-1) + 1 + k;
1340
+ #ifdef Pack_32
1341
+ *bits = 32*i - hi0bits(x[i-1]);
1342
+ #else
1343
+ *bits = (i+2)*16 - hi0bits(x[i]);
1344
+ #endif
1345
+ }
1346
+ #endif
1347
+ return b;
1348
+ }
1349
+ #undef d0
1350
+ #undef d1
1351
+
1352
+ static double
1353
+ ratio
1354
+ #ifdef KR_headers
1355
+ (a, b) Bigint *a, *b;
1356
+ #else
1357
+ (Bigint *a, Bigint *b)
1358
+ #endif
1359
+ {
1360
+ U da, db;
1361
+ int k, ka, kb;
1362
+
1363
+ dval(da) = b2d(a, &ka);
1364
+ dval(db) = b2d(b, &kb);
1365
+ #ifdef Pack_32
1366
+ k = ka - kb + 32*(a->wds - b->wds);
1367
+ #else
1368
+ k = ka - kb + 16*(a->wds - b->wds);
1369
+ #endif
1370
+ #ifdef IBM
1371
+ if (k > 0) {
1372
+ word0(da) += (k >> 2)*Exp_msk1;
1373
+ if (k &= 3)
1374
+ dval(da) *= 1 << k;
1375
+ }
1376
+ else {
1377
+ k = -k;
1378
+ word0(db) += (k >> 2)*Exp_msk1;
1379
+ if (k &= 3)
1380
+ dval(db) *= 1 << k;
1381
+ }
1382
+ #else
1383
+ if (k > 0)
1384
+ word0(da) += k*Exp_msk1;
1385
+ else {
1386
+ k = -k;
1387
+ word0(db) += k*Exp_msk1;
1388
+ }
1389
+ #endif
1390
+ return dval(da) / dval(db);
1391
+ }
1392
+
1393
+ static CONST double
1394
+ tens[] = {
1395
+ 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9,
1396
+ 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19,
1397
+ 1e20, 1e21, 1e22
1398
+ #ifdef VAX
1399
+ , 1e23, 1e24
1400
+ #endif
1401
+ };
1402
+
1403
+ static CONST double
1404
+ #ifdef IEEE_Arith
1405
+ bigtens[] = { 1e16, 1e32, 1e64, 1e128, 1e256 };
1406
+ static CONST double tinytens[] = { 1e-16, 1e-32, 1e-64, 1e-128,
1407
+ #ifdef Avoid_Underflow
1408
+ 9007199254740992.*9007199254740992.e-256
1409
+ /* = 2^106 * 1e-53 */
1410
+ #else
1411
+ 1e-256
1412
+ #endif
1413
+ };
1414
+ /* The factor of 2^53 in tinytens[4] helps us avoid setting the underflow */
1415
+ /* flag unnecessarily. It leads to a song and dance at the end of strtod. */
1416
+ #define Scale_Bit 0x10
1417
+ #define n_bigtens 5
1418
+ #else
1419
+ #ifdef IBM
1420
+ bigtens[] = { 1e16, 1e32, 1e64 };
1421
+ static CONST double tinytens[] = { 1e-16, 1e-32, 1e-64 };
1422
+ #define n_bigtens 3
1423
+ #else
1424
+ bigtens[] = { 1e16, 1e32 };
1425
+ static CONST double tinytens[] = { 1e-16, 1e-32 };
1426
+ #define n_bigtens 2
1427
+ #endif
1428
+ #endif
1429
+
1430
+ #ifdef INFNAN_CHECK
1431
+
1432
+ #ifndef NAN_WORD0
1433
+ #define NAN_WORD0 0x7ff80000
1434
+ #endif
1435
+
1436
+ #ifndef NAN_WORD1
1437
+ #define NAN_WORD1 0
1438
+ #endif
1439
+
1440
+ static int
1441
+ match
1442
+ #ifdef KR_headers
1443
+ (sp, t) char **sp, *t;
1444
+ #else
1445
+ (CONST char **sp, CONST char *t)
1446
+ #endif
1447
+ {
1448
+ int c, d;
1449
+ CONST char *s = *sp;
1450
+
1451
+ while((d = *t++)) {
1452
+ if ((c = *++s) >= 'A' && c <= 'Z')
1453
+ c += 'a' - 'A';
1454
+ if (c != d)
1455
+ return 0;
1456
+ }
1457
+ *sp = s + 1;
1458
+ return 1;
1459
+ }
1460
+
1461
+ #ifndef No_Hex_NaN
1462
+ static void
1463
+ hexnan
1464
+ #ifdef KR_headers
1465
+ (rvp, sp) U *rvp; CONST char **sp;
1466
+ #else
1467
+ (U *rvp, CONST char **sp)
1468
+ #endif
1469
+ {
1470
+ ULong c, x[2];
1471
+ CONST char *s;
1472
+ int havedig, udx0, xshift;
1473
+
1474
+ x[0] = x[1] = 0;
1475
+ havedig = xshift = 0;
1476
+ udx0 = 1;
1477
+ s = *sp;
1478
+ /* allow optional initial 0x or 0X */
1479
+ while((c = *(CONST unsigned char*)(s+1)) && c <= ' ')
1480
+ ++s;
1481
+ if (s[1] == '0' && (s[2] == 'x' || s[2] == 'X'))
1482
+ s += 2;
1483
+ while((c = *(CONST unsigned char*)++s)) {
1484
+ if (c >= '0' && c <= '9')
1485
+ c -= '0';
1486
+ else if (c >= 'a' && c <= 'f')
1487
+ c += 10 - 'a';
1488
+ else if (c >= 'A' && c <= 'F')
1489
+ c += 10 - 'A';
1490
+ else if (c <= ' ') {
1491
+ if (udx0 && havedig) {
1492
+ udx0 = 0;
1493
+ xshift = 1;
1494
+ }
1495
+ continue;
1496
+ }
1497
+ #ifdef GDTOA_NON_PEDANTIC_NANCHECK
1498
+ else if (/*(*/ c == ')' && havedig) {
1499
+ *sp = s + 1;
1500
+ break;
1501
+ }
1502
+ else
1503
+ return; /* invalid form: don't change *sp */
1504
+ #else
1505
+ else {
1506
+ do {
1507
+ if (/*(*/ c == ')') {
1508
+ *sp = s + 1;
1509
+ break;
1510
+ }
1511
+ } while((c = *++s));
1512
+ break;
1513
+ }
1514
+ #endif
1515
+ havedig = 1;
1516
+ if (xshift) {
1517
+ xshift = 0;
1518
+ x[0] = x[1];
1519
+ x[1] = 0;
1520
+ }
1521
+ if (udx0)
1522
+ x[0] = (x[0] << 4) | (x[1] >> 28);
1523
+ x[1] = (x[1] << 4) | c;
1524
+ }
1525
+ if ((x[0] &= 0xfffff) || x[1]) {
1526
+ word0(*rvp) = Exp_mask | x[0];
1527
+ word1(*rvp) = x[1];
1528
+ }
1529
+ }
1530
+ #endif /*No_Hex_NaN*/
1531
+ #endif /* INFNAN_CHECK */
1532
+
1533
+ static double
1534
+ _strtod
1535
+ #ifdef KR_headers
1536
+ (s00, se) CONST char *s00; char **se;
1537
+ #else
1538
+ (CONST char *s00, char **se)
1539
+ #endif
1540
+ {
1541
+ #ifdef Avoid_Underflow
1542
+ int scale;
1543
+ #endif
1544
+ int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, dsign,
1545
+ e, e1, esign, i, j, k, nd, nd0, nf, nz, nz0, sign;
1546
+ CONST char *s, *s0, *s1;
1547
+ double aadj, adj;
1548
+ U aadj1, rv, rv0;
1549
+ Long L;
1550
+ ULong y, z;
1551
+ Bigint *bb, *bb1, *bd, *bd0, *bs, *delta;
1552
+ #ifdef SET_INEXACT
1553
+ int inexact, oldinexact;
1554
+ #endif
1555
+ #ifdef Honor_FLT_ROUNDS
1556
+ int rounding;
1557
+ #endif
1558
+ #ifdef USE_LOCALE
1559
+ CONST char *s2;
1560
+ #endif
1561
+
1562
+ #ifdef __GNUC__
1563
+ delta = bb = bd = bs = 0;
1564
+ #endif
1565
+
1566
+ sign = nz0 = nz = 0;
1567
+ dval(rv) = 0.;
1568
+ for(s = s00;;s++) switch(*s) {
1569
+ case '-':
1570
+ sign = 1;
1571
+ /* no break */
1572
+ case '+':
1573
+ if (*++s)
1574
+ goto break2;
1575
+ /* no break */
1576
+ case 0:
1577
+ goto ret0;
1578
+ case '\t':
1579
+ case '\n':
1580
+ case '\v':
1581
+ case '\f':
1582
+ case '\r':
1583
+ case ' ':
1584
+ continue;
1585
+ default:
1586
+ goto break2;
1587
+ }
1588
+ break2:
1589
+ if (*s == '0') {
1590
+ nz0 = 1;
1591
+ while(*++s == '0') ;
1592
+ if (!*s)
1593
+ goto ret;
1594
+ }
1595
+ s0 = s;
1596
+ y = z = 0;
1597
+ for(nd = nf = 0; (c = *s) >= '0' && c <= '9'; nd++, s++)
1598
+ if (nd < 9)
1599
+ y = 10*y + c - '0';
1600
+ else if (nd < 16)
1601
+ z = 10*z + c - '0';
1602
+ nd0 = nd;
1603
+ #ifdef USE_LOCALE
1604
+ s1 = localeconv()->decimal_point;
1605
+ if (c == *s1) {
1606
+ c = '.';
1607
+ if (*++s1) {
1608
+ s2 = s;
1609
+ for(;;) {
1610
+ if (*++s2 != *s1) {
1611
+ c = 0;
1612
+ break;
1613
+ }
1614
+ if (!*++s1) {
1615
+ s = s2;
1616
+ break;
1617
+ }
1618
+ }
1619
+ }
1620
+ }
1621
+ #endif
1622
+ if (c == '.') {
1623
+ c = *++s;
1624
+ if (!nd) {
1625
+ for(; c == '0'; c = *++s)
1626
+ nz++;
1627
+ if (c > '0' && c <= '9') {
1628
+ s0 = s;
1629
+ nf += nz;
1630
+ nz = 0;
1631
+ goto have_dig;
1632
+ }
1633
+ goto dig_done;
1634
+ }
1635
+ for(; c >= '0' && c <= '9'; c = *++s) {
1636
+ have_dig:
1637
+ nz++;
1638
+ if (c -= '0') {
1639
+ nf += nz;
1640
+ for(i = 1; i < nz; i++)
1641
+ if (nd++ < 9)
1642
+ y *= 10;
1643
+ else if (nd <= DBL_DIG + 1)
1644
+ z *= 10;
1645
+ if (nd++ < 9)
1646
+ y = 10*y + c;
1647
+ else if (nd <= DBL_DIG + 1)
1648
+ z = 10*z + c;
1649
+ nz = 0;
1650
+ }
1651
+ }
1652
+ }
1653
+ dig_done:
1654
+ e = 0;
1655
+ if (c == 'e' || c == 'E') {
1656
+ if (!nd && !nz && !nz0) {
1657
+ goto ret0;
1658
+ }
1659
+ s00 = s;
1660
+ esign = 0;
1661
+ switch(c = *++s) {
1662
+ case '-':
1663
+ esign = 1;
1664
+ case '+':
1665
+ c = *++s;
1666
+ }
1667
+ if (c >= '0' && c <= '9') {
1668
+ while(c == '0')
1669
+ c = *++s;
1670
+ if (c > '0' && c <= '9') {
1671
+ L = c - '0';
1672
+ s1 = s;
1673
+ while((c = *++s) >= '0' && c <= '9')
1674
+ L = 10*L + c - '0';
1675
+ if (s - s1 > 8 || L > 19999)
1676
+ /* Avoid confusion from exponents
1677
+ * so large that e might overflow.
1678
+ */
1679
+ e = 19999; /* safe for 16 bit ints */
1680
+ else
1681
+ e = (int)L;
1682
+ if (esign)
1683
+ e = -e;
1684
+ }
1685
+ else
1686
+ e = 0;
1687
+ }
1688
+ else
1689
+ s = s00;
1690
+ }
1691
+ if (!nd) {
1692
+ if (!nz && !nz0) {
1693
+ #ifdef INFNAN_CHECK
1694
+ /* Check for Nan and Infinity */
1695
+ switch(c) {
1696
+ case 'i':
1697
+ case 'I':
1698
+ if (match(&s,"nf")) {
1699
+ --s;
1700
+ if (!match(&s,"inity"))
1701
+ ++s;
1702
+ word0(rv) = 0x7ff00000;
1703
+ word1(rv) = 0;
1704
+ goto ret;
1705
+ }
1706
+ break;
1707
+ case 'n':
1708
+ case 'N':
1709
+ if (match(&s, "an")) {
1710
+ word0(rv) = NAN_WORD0;
1711
+ word1(rv) = NAN_WORD1;
1712
+ #ifndef No_Hex_NaN
1713
+ if (*s == '(') /*)*/
1714
+ hexnan(&rv, &s);
1715
+ #endif
1716
+ goto ret;
1717
+ }
1718
+ }
1719
+ #endif /* INFNAN_CHECK */
1720
+ ret0:
1721
+ s = s00;
1722
+ sign = 0;
1723
+ }
1724
+ goto ret;
1725
+ }
1726
+ e1 = e -= nf;
1727
+
1728
+ /* Now we have nd0 digits, starting at s0, followed by a
1729
+ * decimal point, followed by nd-nd0 digits. The number we're
1730
+ * after is the integer represented by those digits times
1731
+ * 10**e */
1732
+
1733
+ if (!nd0)
1734
+ nd0 = nd;
1735
+ k = nd < DBL_DIG + 1 ? nd : DBL_DIG + 1;
1736
+ dval(rv) = y;
1737
+ if (k > 9) {
1738
+ #ifdef SET_INEXACT
1739
+ if (k > DBL_DIG)
1740
+ oldinexact = get_inexact();
1741
+ #endif
1742
+ dval(rv) = tens[k - 9] * dval(rv) + z;
1743
+ }
1744
+ bd0 = 0;
1745
+ if (nd <= DBL_DIG
1746
+ #ifndef RND_PRODQUOT
1747
+ #ifndef Honor_FLT_ROUNDS
1748
+ && Flt_Rounds == 1
1749
+ #endif
1750
+ #endif
1751
+ ) {
1752
+ if (!e)
1753
+ goto ret;
1754
+ if (e > 0) {
1755
+ if (e <= Ten_pmax) {
1756
+ #ifdef VAX
1757
+ goto vax_ovfl_check;
1758
+ #else
1759
+ #ifdef Honor_FLT_ROUNDS
1760
+ /* round correctly FLT_ROUNDS = 2 or 3 */
1761
+ if (sign) {
1762
+ rv = -rv;
1763
+ sign = 0;
1764
+ }
1765
+ #endif
1766
+ /* rv = */ rounded_product(dval(rv), tens[e]);
1767
+ goto ret;
1768
+ #endif
1769
+ }
1770
+ i = DBL_DIG - nd;
1771
+ if (e <= Ten_pmax + i) {
1772
+ /* A fancier test would sometimes let us do
1773
+ * this for larger i values.
1774
+ */
1775
+ #ifdef Honor_FLT_ROUNDS
1776
+ /* round correctly FLT_ROUNDS = 2 or 3 */
1777
+ if (sign) {
1778
+ rv = -rv;
1779
+ sign = 0;
1780
+ }
1781
+ #endif
1782
+ e -= i;
1783
+ dval(rv) *= tens[i];
1784
+ #ifdef VAX
1785
+ /* VAX exponent range is so narrow we must
1786
+ * worry about overflow here...
1787
+ */
1788
+ vax_ovfl_check:
1789
+ word0(rv) -= P*Exp_msk1;
1790
+ /* rv = */ rounded_product(dval(rv), tens[e]);
1791
+ if ((word0(rv) & Exp_mask)
1792
+ > Exp_msk1*(DBL_MAX_EXP+Bias-1-P))
1793
+ goto ovfl;
1794
+ word0(rv) += P*Exp_msk1;
1795
+ #else
1796
+ /* rv = */ rounded_product(dval(rv), tens[e]);
1797
+ #endif
1798
+ goto ret;
1799
+ }
1800
+ }
1801
+ #ifndef Inaccurate_Divide
1802
+ else if (e >= -Ten_pmax) {
1803
+ #ifdef Honor_FLT_ROUNDS
1804
+ /* round correctly FLT_ROUNDS = 2 or 3 */
1805
+ if (sign) {
1806
+ rv = -rv;
1807
+ sign = 0;
1808
+ }
1809
+ #endif
1810
+ /* rv = */ rounded_quotient(dval(rv), tens[-e]);
1811
+ goto ret;
1812
+ }
1813
+ #endif
1814
+ }
1815
+ e1 += nd - k;
1816
+
1817
+ #ifdef IEEE_Arith
1818
+ #ifdef SET_INEXACT
1819
+ inexact = 1;
1820
+ if (k <= DBL_DIG)
1821
+ oldinexact = get_inexact();
1822
+ #endif
1823
+ #ifdef Avoid_Underflow
1824
+ scale = 0;
1825
+ #endif
1826
+ #ifdef Honor_FLT_ROUNDS
1827
+ if ((rounding = Flt_Rounds) >= 2) {
1828
+ if (sign)
1829
+ rounding = rounding == 2 ? 0 : 2;
1830
+ else
1831
+ if (rounding != 2)
1832
+ rounding = 0;
1833
+ }
1834
+ #endif
1835
+ #endif /*IEEE_Arith*/
1836
+
1837
+ /* Get starting approximation = rv * 10**e1 */
1838
+
1839
+ if (e1 > 0) {
1840
+ if ((i = e1 & 15))
1841
+ dval(rv) *= tens[i];
1842
+ if (e1 &= ~15) {
1843
+ if (e1 > DBL_MAX_10_EXP) {
1844
+ ovfl:
1845
+ #ifndef NO_ERRNO
1846
+ errno = ERANGE;
1847
+ #endif
1848
+ /* Can't trust HUGE_VAL */
1849
+ #ifdef IEEE_Arith
1850
+ #ifdef Honor_FLT_ROUNDS
1851
+ switch(rounding) {
1852
+ case 0: /* toward 0 */
1853
+ case 3: /* toward -infinity */
1854
+ word0(rv) = Big0;
1855
+ word1(rv) = Big1;
1856
+ break;
1857
+ default:
1858
+ word0(rv) = Exp_mask;
1859
+ word1(rv) = 0;
1860
+ }
1861
+ #else /*Honor_FLT_ROUNDS*/
1862
+ word0(rv) = Exp_mask;
1863
+ word1(rv) = 0;
1864
+ #endif /*Honor_FLT_ROUNDS*/
1865
+ #ifdef SET_INEXACT
1866
+ /* set overflow bit */
1867
+ dval(rv0) = 1e300;
1868
+ dval(rv0) *= dval(rv0);
1869
+ #endif
1870
+ #else /*IEEE_Arith*/
1871
+ word0(rv) = Big0;
1872
+ word1(rv) = Big1;
1873
+ #endif /*IEEE_Arith*/
1874
+ if (bd0)
1875
+ goto retfree;
1876
+ goto ret;
1877
+ }
1878
+ e1 >>= 4;
1879
+ for(j = 0; e1 > 1; j++, e1 >>= 1)
1880
+ if (e1 & 1)
1881
+ dval(rv) *= bigtens[j];
1882
+ /* The last multiplication could overflow. */
1883
+ word0(rv) -= P*Exp_msk1;
1884
+ dval(rv) *= bigtens[j];
1885
+ if ((z = word0(rv) & Exp_mask)
1886
+ > Exp_msk1*(DBL_MAX_EXP+Bias-P))
1887
+ goto ovfl;
1888
+ if (z > Exp_msk1*(DBL_MAX_EXP+Bias-1-P)) {
1889
+ /* set to largest number */
1890
+ /* (Can't trust DBL_MAX) */
1891
+ word0(rv) = Big0;
1892
+ word1(rv) = Big1;
1893
+ }
1894
+ else
1895
+ word0(rv) += P*Exp_msk1;
1896
+ }
1897
+ }
1898
+ else if (e1 < 0) {
1899
+ e1 = -e1;
1900
+ if ((i = e1 & 15))
1901
+ dval(rv) /= tens[i];
1902
+ if (e1 >>= 4) {
1903
+ if (e1 >= 1 << n_bigtens)
1904
+ goto undfl;
1905
+ #ifdef Avoid_Underflow
1906
+ if (e1 & Scale_Bit)
1907
+ scale = 2*P;
1908
+ for(j = 0; e1 > 0; j++, e1 >>= 1)
1909
+ if (e1 & 1)
1910
+ dval(rv) *= tinytens[j];
1911
+ if (scale && (j = 2*P + 1 - ((word0(rv) & Exp_mask)
1912
+ >> Exp_shift)) > 0) {
1913
+ /* scaled rv is denormal; zap j low bits */
1914
+ if (j >= 32) {
1915
+ word1(rv) = 0;
1916
+ if (j >= 53)
1917
+ word0(rv) = (P+2)*Exp_msk1;
1918
+ else
1919
+ word0(rv) &= 0xffffffff << (j-32);
1920
+ }
1921
+ else
1922
+ word1(rv) &= 0xffffffff << j;
1923
+ }
1924
+ #else
1925
+ for(j = 0; e1 > 1; j++, e1 >>= 1)
1926
+ if (e1 & 1)
1927
+ dval(rv) *= tinytens[j];
1928
+ /* The last multiplication could underflow. */
1929
+ dval(rv0) = dval(rv);
1930
+ dval(rv) *= tinytens[j];
1931
+ if (!dval(rv)) {
1932
+ dval(rv) = 2.*dval(rv0);
1933
+ dval(rv) *= tinytens[j];
1934
+ #endif
1935
+ if (!dval(rv)) {
1936
+ undfl:
1937
+ dval(rv) = 0.;
1938
+ #ifndef NO_ERRNO
1939
+ errno = ERANGE;
1940
+ #endif
1941
+ if (bd0)
1942
+ goto retfree;
1943
+ goto ret;
1944
+ }
1945
+ #ifndef Avoid_Underflow
1946
+ word0(rv) = Tiny0;
1947
+ word1(rv) = Tiny1;
1948
+ /* The refinement below will clean
1949
+ * this approximation up.
1950
+ */
1951
+ }
1952
+ #endif
1953
+ }
1954
+ }
1955
+
1956
+ /* Now the hard part -- adjusting rv to the correct value.*/
1957
+
1958
+ /* Put digits into bd: true value = bd * 10^e */
1959
+
1960
+ bd0 = s2b(s0, nd0, nd, y);
1961
+
1962
+ for(;;) {
1963
+ bd = Balloc(bd0->k);
1964
+ Bcopy(bd, bd0);
1965
+ bb = d2b(rv, &bbe, &bbbits); /* rv = bb * 2^bbe */
1966
+ bs = i2b(1);
1967
+
1968
+ if (e >= 0) {
1969
+ bb2 = bb5 = 0;
1970
+ bd2 = bd5 = e;
1971
+ }
1972
+ else {
1973
+ bb2 = bb5 = -e;
1974
+ bd2 = bd5 = 0;
1975
+ }
1976
+ if (bbe >= 0)
1977
+ bb2 += bbe;
1978
+ else
1979
+ bd2 -= bbe;
1980
+ bs2 = bb2;
1981
+ #ifdef Honor_FLT_ROUNDS
1982
+ if (rounding != 1)
1983
+ bs2++;
1984
+ #endif
1985
+ #ifdef Avoid_Underflow
1986
+ j = bbe - scale;
1987
+ i = j + bbbits - 1; /* logb(rv) */
1988
+ if (i < Emin) /* denormal */
1989
+ j += P - Emin;
1990
+ else
1991
+ j = P + 1 - bbbits;
1992
+ #else /*Avoid_Underflow*/
1993
+ #ifdef Sudden_Underflow
1994
+ #ifdef IBM
1995
+ j = 1 + 4*P - 3 - bbbits + ((bbe + bbbits - 1) & 3);
1996
+ #else
1997
+ j = P + 1 - bbbits;
1998
+ #endif
1999
+ #else /*Sudden_Underflow*/
2000
+ j = bbe;
2001
+ i = j + bbbits - 1; /* logb(rv) */
2002
+ if (i < Emin) /* denormal */
2003
+ j += P - Emin;
2004
+ else
2005
+ j = P + 1 - bbbits;
2006
+ #endif /*Sudden_Underflow*/
2007
+ #endif /*Avoid_Underflow*/
2008
+ bb2 += j;
2009
+ bd2 += j;
2010
+ #ifdef Avoid_Underflow
2011
+ bd2 += scale;
2012
+ #endif
2013
+ i = bb2 < bd2 ? bb2 : bd2;
2014
+ if (i > bs2)
2015
+ i = bs2;
2016
+ if (i > 0) {
2017
+ bb2 -= i;
2018
+ bd2 -= i;
2019
+ bs2 -= i;
2020
+ }
2021
+ if (bb5 > 0) {
2022
+ bs = pow5mult(bs, bb5);
2023
+ bb1 = mult(bs, bb);
2024
+ Bfree(bb);
2025
+ bb = bb1;
2026
+ }
2027
+ if (bb2 > 0)
2028
+ bb = lshift(bb, bb2);
2029
+ if (bd5 > 0)
2030
+ bd = pow5mult(bd, bd5);
2031
+ if (bd2 > 0)
2032
+ bd = lshift(bd, bd2);
2033
+ if (bs2 > 0)
2034
+ bs = lshift(bs, bs2);
2035
+ delta = diff(bb, bd);
2036
+ dsign = delta->sign;
2037
+ delta->sign = 0;
2038
+ i = cmp(delta, bs);
2039
+ #ifdef Honor_FLT_ROUNDS
2040
+ if (rounding != 1) {
2041
+ if (i < 0) {
2042
+ /* Error is less than an ulp */
2043
+ if (!delta->x[0] && delta->wds <= 1) {
2044
+ /* exact */
2045
+ #ifdef SET_INEXACT
2046
+ inexact = 0;
2047
+ #endif
2048
+ break;
2049
+ }
2050
+ if (rounding) {
2051
+ if (dsign) {
2052
+ adj = 1.;
2053
+ goto apply_adj;
2054
+ }
2055
+ }
2056
+ else if (!dsign) {
2057
+ adj = -1.;
2058
+ if (!word1(rv)
2059
+ && !(word0(rv) & Frac_mask)) {
2060
+ y = word0(rv) & Exp_mask;
2061
+ #ifdef Avoid_Underflow
2062
+ if (!scale || y > 2*P*Exp_msk1)
2063
+ #else
2064
+ if (y)
2065
+ #endif
2066
+ {
2067
+ delta = lshift(delta,Log2P);
2068
+ if (cmp(delta, bs) <= 0)
2069
+ adj = -0.5;
2070
+ }
2071
+ }
2072
+ apply_adj:
2073
+ #ifdef Avoid_Underflow
2074
+ if (scale && (y = word0(rv) & Exp_mask)
2075
+ <= 2*P*Exp_msk1)
2076
+ word0(adj) += (2*P+1)*Exp_msk1 - y;
2077
+ #else
2078
+ #ifdef Sudden_Underflow
2079
+ if ((word0(rv) & Exp_mask) <=
2080
+ P*Exp_msk1) {
2081
+ word0(rv) += P*Exp_msk1;
2082
+ dval(rv) += adj*ulp(rv);
2083
+ word0(rv) -= P*Exp_msk1;
2084
+ }
2085
+ else
2086
+ #endif /*Sudden_Underflow*/
2087
+ #endif /*Avoid_Underflow*/
2088
+ dval(rv) += adj*ulp(rv);
2089
+ }
2090
+ break;
2091
+ }
2092
+ adj = ratio(delta, bs);
2093
+ if (adj < 1.)
2094
+ adj = 1.;
2095
+ if (adj <= 0x7ffffffe) {
2096
+ /* adj = rounding ? ceil(adj) : floor(adj); */
2097
+ y = adj;
2098
+ if (y != adj) {
2099
+ if (!((rounding>>1) ^ dsign))
2100
+ y++;
2101
+ adj = y;
2102
+ }
2103
+ }
2104
+ #ifdef Avoid_Underflow
2105
+ if (scale && (y = word0(rv) & Exp_mask) <= 2*P*Exp_msk1)
2106
+ word0(adj) += (2*P+1)*Exp_msk1 - y;
2107
+ #else
2108
+ #ifdef Sudden_Underflow
2109
+ if ((word0(rv) & Exp_mask) <= P*Exp_msk1) {
2110
+ word0(rv) += P*Exp_msk1;
2111
+ adj *= ulp(rv);
2112
+ if (dsign)
2113
+ dval(rv) += adj;
2114
+ else
2115
+ dval(rv) -= adj;
2116
+ word0(rv) -= P*Exp_msk1;
2117
+ goto cont;
2118
+ }
2119
+ #endif /*Sudden_Underflow*/
2120
+ #endif /*Avoid_Underflow*/
2121
+ adj *= ulp(rv);
2122
+ if (dsign)
2123
+ dval(rv) += adj;
2124
+ else
2125
+ dval(rv) -= adj;
2126
+ goto cont;
2127
+ }
2128
+ #endif /*Honor_FLT_ROUNDS*/
2129
+
2130
+ if (i < 0) {
2131
+ /* Error is less than half an ulp -- check for
2132
+ * special case of mantissa a power of two.
2133
+ */
2134
+ if (dsign || word1(rv) || word0(rv) & Bndry_mask
2135
+ #ifdef IEEE_Arith
2136
+ #ifdef Avoid_Underflow
2137
+ || (word0(rv) & Exp_mask) <= (2*P+1)*Exp_msk1
2138
+ #else
2139
+ || (word0(rv) & Exp_mask) <= Exp_msk1
2140
+ #endif
2141
+ #endif
2142
+ ) {
2143
+ #ifdef SET_INEXACT
2144
+ if (!delta->x[0] && delta->wds <= 1)
2145
+ inexact = 0;
2146
+ #endif
2147
+ break;
2148
+ }
2149
+ if (!delta->x[0] && delta->wds <= 1) {
2150
+ /* exact result */
2151
+ #ifdef SET_INEXACT
2152
+ inexact = 0;
2153
+ #endif
2154
+ break;
2155
+ }
2156
+ delta = lshift(delta,Log2P);
2157
+ if (cmp(delta, bs) > 0)
2158
+ goto drop_down;
2159
+ break;
2160
+ }
2161
+ if (i == 0) {
2162
+ /* exactly half-way between */
2163
+ if (dsign) {
2164
+ if ((word0(rv) & Bndry_mask1) == Bndry_mask1
2165
+ && word1(rv) == (
2166
+ #ifdef Avoid_Underflow
2167
+ (scale && (y = word0(rv) & Exp_mask) <= 2*P*Exp_msk1)
2168
+ ? (0xffffffff & (0xffffffff << (2*P+1-(y>>Exp_shift)))) :
2169
+ #endif
2170
+ 0xffffffff)) {
2171
+ /*boundary case -- increment exponent*/
2172
+ word0(rv) = (word0(rv) & Exp_mask)
2173
+ + Exp_msk1
2174
+ #ifdef IBM
2175
+ | Exp_msk1 >> 4
2176
+ #endif
2177
+ ;
2178
+ word1(rv) = 0;
2179
+ #ifdef Avoid_Underflow
2180
+ dsign = 0;
2181
+ #endif
2182
+ break;
2183
+ }
2184
+ }
2185
+ else if (!(word0(rv) & Bndry_mask) && !word1(rv)) {
2186
+ drop_down:
2187
+ /* boundary case -- decrement exponent */
2188
+ #ifdef Sudden_Underflow /*{{*/
2189
+ L = word0(rv) & Exp_mask;
2190
+ #ifdef IBM
2191
+ if (L < Exp_msk1)
2192
+ #else
2193
+ #ifdef Avoid_Underflow
2194
+ if (L <= (scale ? (2*P+1)*Exp_msk1 : Exp_msk1))
2195
+ #else
2196
+ if (L <= Exp_msk1)
2197
+ #endif /*Avoid_Underflow*/
2198
+ #endif /*IBM*/
2199
+ goto undfl;
2200
+ L -= Exp_msk1;
2201
+ #else /*Sudden_Underflow}{*/
2202
+ #ifdef Avoid_Underflow
2203
+ if (scale) {
2204
+ L = word0(rv) & Exp_mask;
2205
+ if (L <= (2*P+1)*Exp_msk1) {
2206
+ if (L > (P+2)*Exp_msk1)
2207
+ /* round even ==> */
2208
+ /* accept rv */
2209
+ break;
2210
+ /* rv = smallest denormal */
2211
+ goto undfl;
2212
+ }
2213
+ }
2214
+ #endif /*Avoid_Underflow*/
2215
+ L = (word0(rv) & Exp_mask) - Exp_msk1;
2216
+ #endif /*Sudden_Underflow}}*/
2217
+ word0(rv) = L | Bndry_mask1;
2218
+ word1(rv) = 0xffffffff;
2219
+ #ifdef IBM
2220
+ goto cont;
2221
+ #else
2222
+ break;
2223
+ #endif
2224
+ }
2225
+ #ifndef ROUND_BIASED
2226
+ if (!(word1(rv) & LSB))
2227
+ break;
2228
+ #endif
2229
+ if (dsign)
2230
+ dval(rv) += ulp(rv);
2231
+ #ifndef ROUND_BIASED
2232
+ else {
2233
+ dval(rv) -= ulp(rv);
2234
+ #ifndef Sudden_Underflow
2235
+ if (!dval(rv))
2236
+ goto undfl;
2237
+ #endif
2238
+ }
2239
+ #ifdef Avoid_Underflow
2240
+ dsign = 1 - dsign;
2241
+ #endif
2242
+ #endif
2243
+ break;
2244
+ }
2245
+ if ((aadj = ratio(delta, bs)) <= 2.) {
2246
+ if (dsign)
2247
+ aadj = dval(aadj1) = 1.;
2248
+ else if (word1(rv) || word0(rv) & Bndry_mask) {
2249
+ #ifndef Sudden_Underflow
2250
+ if (word1(rv) == Tiny1 && !word0(rv))
2251
+ goto undfl;
2252
+ #endif
2253
+ aadj = 1.;
2254
+ dval(aadj1) = -1.;
2255
+ }
2256
+ else {
2257
+ /* special case -- power of FLT_RADIX to be */
2258
+ /* rounded down... */
2259
+
2260
+ if (aadj < 2./FLT_RADIX)
2261
+ aadj = 1./FLT_RADIX;
2262
+ else
2263
+ aadj *= 0.5;
2264
+ dval(aadj1) = -aadj;
2265
+ }
2266
+ }
2267
+ else {
2268
+ aadj *= 0.5;
2269
+ dval(aadj1) = dsign ? aadj : -aadj;
2270
+ #ifdef Check_FLT_ROUNDS
2271
+ switch(Rounding) {
2272
+ case 2: /* towards +infinity */
2273
+ dval(aadj1) -= 0.5;
2274
+ break;
2275
+ case 0: /* towards 0 */
2276
+ case 3: /* towards -infinity */
2277
+ dval(aadj1) += 0.5;
2278
+ }
2279
+ #else
2280
+ if (Flt_Rounds == 0)
2281
+ dval(aadj1) += 0.5;
2282
+ #endif /*Check_FLT_ROUNDS*/
2283
+ }
2284
+ y = word0(rv) & Exp_mask;
2285
+
2286
+ /* Check for overflow */
2287
+
2288
+ if (y == Exp_msk1*(DBL_MAX_EXP+Bias-1)) {
2289
+ dval(rv0) = dval(rv);
2290
+ word0(rv) -= P*Exp_msk1;
2291
+ adj = dval(aadj1) * ulp(rv);
2292
+ dval(rv) += adj;
2293
+ if ((word0(rv) & Exp_mask) >=
2294
+ Exp_msk1*(DBL_MAX_EXP+Bias-P)) {
2295
+ if (word0(rv0) == Big0 && word1(rv0) == Big1)
2296
+ goto ovfl;
2297
+ word0(rv) = Big0;
2298
+ word1(rv) = Big1;
2299
+ goto cont;
2300
+ }
2301
+ else
2302
+ word0(rv) += P*Exp_msk1;
2303
+ }
2304
+ else {
2305
+ #ifdef Avoid_Underflow
2306
+ if (scale && y <= 2*P*Exp_msk1) {
2307
+ if (aadj <= 0x7fffffff) {
2308
+ if ((z = (ULong) aadj) <= 0)
2309
+ z = 1;
2310
+ aadj = z;
2311
+ dval(aadj1) = dsign ? aadj : -aadj;
2312
+ }
2313
+ word0(aadj1) += (2*P+1)*Exp_msk1 - y;
2314
+ }
2315
+ adj = dval(aadj1) * ulp(rv);
2316
+ dval(rv) += adj;
2317
+ #else
2318
+ #ifdef Sudden_Underflow
2319
+ if ((word0(rv) & Exp_mask) <= P*Exp_msk1) {
2320
+ dval(rv0) = dval(rv);
2321
+ word0(rv) += P*Exp_msk1;
2322
+ adj = dval(aadj1) * ulp(rv);
2323
+ dval(rv) += adj;
2324
+ #ifdef IBM
2325
+ if ((word0(rv) & Exp_mask) < P*Exp_msk1)
2326
+ #else
2327
+ if ((word0(rv) & Exp_mask) <= P*Exp_msk1)
2328
+ #endif
2329
+ {
2330
+ if (word0(rv0) == Tiny0
2331
+ && word1(rv0) == Tiny1)
2332
+ goto undfl;
2333
+ word0(rv) = Tiny0;
2334
+ word1(rv) = Tiny1;
2335
+ goto cont;
2336
+ }
2337
+ else
2338
+ word0(rv) -= P*Exp_msk1;
2339
+ }
2340
+ else {
2341
+ adj = dval(aadj1) * ulp(rv);
2342
+ dval(rv) += adj;
2343
+ }
2344
+ #else /*Sudden_Underflow*/
2345
+ /* Compute adj so that the IEEE rounding rules will
2346
+ * correctly round rv + adj in some half-way cases.
2347
+ * If rv * ulp(rv) is denormalized (i.e.,
2348
+ * y <= (P-1)*Exp_msk1), we must adjust aadj to avoid
2349
+ * trouble from bits lost to denormalization;
2350
+ * example: 1.2e-307 .
2351
+ */
2352
+ if (y <= (P-1)*Exp_msk1 && aadj > 1.) {
2353
+ dval(aadj1) = (double)(int)(aadj + 0.5);
2354
+ if (!dsign)
2355
+ dval(aadj1) = -dval(aadj1);
2356
+ }
2357
+ adj = dval(aadj1) * ulp(rv);
2358
+ dval(rv) += adj;
2359
+ #endif /*Sudden_Underflow*/
2360
+ #endif /*Avoid_Underflow*/
2361
+ }
2362
+ z = word0(rv) & Exp_mask;
2363
+ #ifndef SET_INEXACT
2364
+ #ifdef Avoid_Underflow
2365
+ if (!scale)
2366
+ #endif
2367
+ if (y == z) {
2368
+ /* Can we stop now? */
2369
+ L = (Long)aadj;
2370
+ aadj -= L;
2371
+ /* The tolerances below are conservative. */
2372
+ if (dsign || word1(rv) || word0(rv) & Bndry_mask) {
2373
+ if (aadj < .4999999 || aadj > .5000001)
2374
+ break;
2375
+ }
2376
+ else if (aadj < .4999999/FLT_RADIX)
2377
+ break;
2378
+ }
2379
+ #endif
2380
+ cont:
2381
+ Bfree(bb);
2382
+ Bfree(bd);
2383
+ Bfree(bs);
2384
+ Bfree(delta);
2385
+ }
2386
+ #ifdef SET_INEXACT
2387
+ if (inexact) {
2388
+ if (!oldinexact) {
2389
+ word0(rv0) = Exp_1 + (70 << Exp_shift);
2390
+ word1(rv0) = 0;
2391
+ dval(rv0) += 1.;
2392
+ }
2393
+ }
2394
+ else if (!oldinexact)
2395
+ clear_inexact();
2396
+ #endif
2397
+ #ifdef Avoid_Underflow
2398
+ if (scale) {
2399
+ word0(rv0) = Exp_1 - 2*P*Exp_msk1;
2400
+ word1(rv0) = 0;
2401
+ dval(rv) *= dval(rv0);
2402
+ #ifndef NO_ERRNO
2403
+ /* try to avoid the bug of testing an 8087 register value */
2404
+ if (word0(rv) == 0 && word1(rv) == 0)
2405
+ errno = ERANGE;
2406
+ #endif
2407
+ }
2408
+ #endif /* Avoid_Underflow */
2409
+ #ifdef SET_INEXACT
2410
+ if (inexact && !(word0(rv) & Exp_mask)) {
2411
+ /* set underflow bit */
2412
+ dval(rv0) = 1e-300;
2413
+ dval(rv0) *= dval(rv0);
2414
+ }
2415
+ #endif
2416
+ retfree:
2417
+ Bfree(bb);
2418
+ Bfree(bd);
2419
+ Bfree(bs);
2420
+ Bfree(bd0);
2421
+ Bfree(delta);
2422
+ ret:
2423
+ if (se)
2424
+ *se = (char *)s;
2425
+ return sign ? -dval(rv) : dval(rv);
2426
+ }
2427
+
2428
+ static int
2429
+ quorem
2430
+ #ifdef KR_headers
2431
+ (b, S) Bigint *b, *S;
2432
+ #else
2433
+ (Bigint *b, Bigint *S)
2434
+ #endif
2435
+ {
2436
+ int n;
2437
+ ULong *bx, *bxe, q, *sx, *sxe;
2438
+ #ifdef ULLong
2439
+ ULLong borrow, carry, y, ys;
2440
+ #else
2441
+ ULong borrow, carry, y, ys;
2442
+ #ifdef Pack_32
2443
+ ULong si, z, zs;
2444
+ #endif
2445
+ #endif
2446
+
2447
+ n = S->wds;
2448
+ #ifdef DEBUG
2449
+ /*debug*/ if (b->wds > n)
2450
+ /*debug*/ Bug("oversize b in quorem");
2451
+ #endif
2452
+ if (b->wds < n)
2453
+ return 0;
2454
+ sx = S->x;
2455
+ sxe = sx + --n;
2456
+ bx = b->x;
2457
+ bxe = bx + n;
2458
+ q = *bxe / (*sxe + 1); /* ensure q <= true quotient */
2459
+ #ifdef DEBUG
2460
+ /*debug*/ if (q > 9)
2461
+ /*debug*/ Bug("oversized quotient in quorem");
2462
+ #endif
2463
+ if (q) {
2464
+ borrow = 0;
2465
+ carry = 0;
2466
+ do {
2467
+ #ifdef ULLong
2468
+ ys = *sx++ * (ULLong)q + carry;
2469
+ carry = ys >> 32;
2470
+ y = *bx - (ys & FFFFFFFF) - borrow;
2471
+ borrow = y >> 32 & (ULong)1;
2472
+ *bx++ = (ULong) y & FFFFFFFF;
2473
+ #else
2474
+ #ifdef Pack_32
2475
+ si = *sx++;
2476
+ ys = (si & 0xffff) * q + carry;
2477
+ zs = (si >> 16) * q + (ys >> 16);
2478
+ carry = zs >> 16;
2479
+ y = (*bx & 0xffff) - (ys & 0xffff) - borrow;
2480
+ borrow = (y & 0x10000) >> 16;
2481
+ z = (*bx >> 16) - (zs & 0xffff) - borrow;
2482
+ borrow = (z & 0x10000) >> 16;
2483
+ Storeinc(bx, z, y);
2484
+ #else
2485
+ ys = *sx++ * q + carry;
2486
+ carry = ys >> 16;
2487
+ y = *bx - (ys & 0xffff) - borrow;
2488
+ borrow = (y & 0x10000) >> 16;
2489
+ *bx++ = y & 0xffff;
2490
+ #endif
2491
+ #endif
2492
+ }
2493
+ while(sx <= sxe);
2494
+ if (!*bxe) {
2495
+ bx = b->x;
2496
+ while(--bxe > bx && !*bxe)
2497
+ --n;
2498
+ b->wds = n;
2499
+ }
2500
+ }
2501
+ if (cmp(b, S) >= 0) {
2502
+ q++;
2503
+ borrow = 0;
2504
+ carry = 0;
2505
+ bx = b->x;
2506
+ sx = S->x;
2507
+ do {
2508
+ #ifdef ULLong
2509
+ ys = *sx++ + carry;
2510
+ carry = ys >> 32;
2511
+ y = *bx - (ys & FFFFFFFF) - borrow;
2512
+ borrow = y >> 32 & (ULong)1;
2513
+ *bx++ = (ULong) y & FFFFFFFF;
2514
+ #else
2515
+ #ifdef Pack_32
2516
+ si = *sx++;
2517
+ ys = (si & 0xffff) + carry;
2518
+ zs = (si >> 16) + (ys >> 16);
2519
+ carry = zs >> 16;
2520
+ y = (*bx & 0xffff) - (ys & 0xffff) - borrow;
2521
+ borrow = (y & 0x10000) >> 16;
2522
+ z = (*bx >> 16) - (zs & 0xffff) - borrow;
2523
+ borrow = (z & 0x10000) >> 16;
2524
+ Storeinc(bx, z, y);
2525
+ #else
2526
+ ys = *sx++ + carry;
2527
+ carry = ys >> 16;
2528
+ y = *bx - (ys & 0xffff) - borrow;
2529
+ borrow = (y & 0x10000) >> 16;
2530
+ *bx++ = y & 0xffff;
2531
+ #endif
2532
+ #endif
2533
+ }
2534
+ while(sx <= sxe);
2535
+ bx = b->x;
2536
+ bxe = bx + n;
2537
+ if (!*bxe) {
2538
+ while(--bxe > bx && !*bxe)
2539
+ --n;
2540
+ b->wds = n;
2541
+ }
2542
+ }
2543
+ return q;
2544
+ }
2545
+
2546
+ #ifndef MULTIPLE_THREADS
2547
+ static char *dtoa_result;
2548
+ #endif
2549
+
2550
+ static char *
2551
+ #ifdef KR_headers
2552
+ rv_alloc(i) int i;
2553
+ #else
2554
+ rv_alloc(int i)
2555
+ #endif
2556
+ {
2557
+ int j, k, *r;
2558
+
2559
+ j = sizeof(ULong);
2560
+ for(k = 0;
2561
+ sizeof(Bigint) - sizeof(ULong) - sizeof(int) + j <= (unsigned) i;
2562
+ j <<= 1)
2563
+ k++;
2564
+ r = (int*)Balloc(k);
2565
+ *r = k;
2566
+ return
2567
+ #ifndef MULTIPLE_THREADS
2568
+ dtoa_result =
2569
+ #endif
2570
+ (char *)(r+1);
2571
+ }
2572
+
2573
+ static char *
2574
+ #ifdef KR_headers
2575
+ nrv_alloc(s, rve, n) char *s, **rve; int n;
2576
+ #else
2577
+ nrv_alloc(CONST char *s, char **rve, int n)
2578
+ #endif
2579
+ {
2580
+ char *rv, *t;
2581
+
2582
+ t = rv = rv_alloc(n);
2583
+ while((*t = *s++)) t++;
2584
+ if (rve)
2585
+ *rve = t;
2586
+ return rv;
2587
+ }
2588
+
2589
+ /* freedtoa(s) must be used to free values s returned by dtoa
2590
+ * when MULTIPLE_THREADS is #defined. It should be used in all cases,
2591
+ * but for consistency with earlier versions of dtoa, it is optional
2592
+ * when MULTIPLE_THREADS is not defined.
2593
+ */
2594
+
2595
+ void
2596
+ #ifdef KR_headers
2597
+ freedtoa(s) char *s;
2598
+ #else
2599
+ freedtoa(char *s)
2600
+ #endif
2601
+ {
2602
+ Bigint *b = (Bigint *)((int *)s - 1);
2603
+ b->maxwds = 1 << (b->k = *(int*)b);
2604
+ Bfree(b);
2605
+ #ifndef MULTIPLE_THREADS
2606
+ if (s == dtoa_result)
2607
+ dtoa_result = 0;
2608
+ #endif
2609
+ }
2610
+
2611
+ /* dtoa for IEEE arithmetic (dmg): convert double to ASCII string.
2612
+ *
2613
+ * Inspired by "How to Print Floating-Point Numbers Accurately" by
2614
+ * Guy L. Steele, Jr. and Jon L. White [Proc. ACM SIGPLAN '90, pp. 112-126].
2615
+ *
2616
+ * Modifications:
2617
+ * 1. Rather than iterating, we use a simple numeric overestimate
2618
+ * to determine k = floor(log10(d)). We scale relevant
2619
+ * quantities using O(log2(k)) rather than O(k) multiplications.
2620
+ * 2. For some modes > 2 (corresponding to ecvt and fcvt), we don't
2621
+ * try to generate digits strictly left to right. Instead, we
2622
+ * compute with fewer bits and propagate the carry if necessary
2623
+ * when rounding the final digit up. This is often faster.
2624
+ * 3. Under the assumption that input will be rounded nearest,
2625
+ * mode 0 renders 1e23 as 1e23 rather than 9.999999999999999e22.
2626
+ * That is, we allow equality in stopping tests when the
2627
+ * round-nearest rule will give the same floating-point value
2628
+ * as would satisfaction of the stopping test with strict
2629
+ * inequality.
2630
+ * 4. We remove common factors of powers of 2 from relevant
2631
+ * quantities.
2632
+ * 5. When converting floating-point integers less than 1e16,
2633
+ * we use floating-point arithmetic rather than resorting
2634
+ * to multiple-precision integers.
2635
+ * 6. When asked to produce fewer than 15 digits, we first try
2636
+ * to get by with floating-point arithmetic; we resort to
2637
+ * multiple-precision integer arithmetic only if we cannot
2638
+ * guarantee that the floating-point calculation has given
2639
+ * the correctly rounded result. For k requested digits and
2640
+ * "uniformly" distributed input, the probability is
2641
+ * something like 10^(k-15) that we must resort to the Long
2642
+ * calculation.
2643
+ */
2644
+
2645
+ static char *
2646
+ dtoa
2647
+ #ifdef KR_headers
2648
+ (d, mode, ndigits, decpt, sign, rve)
2649
+ U d; int mode, ndigits, *decpt, *sign; char **rve;
2650
+ #else
2651
+ (U d, int mode, int ndigits, int *decpt, int *sign, char **rve)
2652
+ #endif
2653
+ {
2654
+ /* Arguments ndigits, decpt, sign are similar to those
2655
+ of ecvt and fcvt; trailing zeros are suppressed from
2656
+ the returned string. If not null, *rve is set to point
2657
+ to the end of the return value. If d is +-Infinity or NaN,
2658
+ then *decpt is set to 9999.
2659
+
2660
+ mode:
2661
+ 0 ==> shortest string that yields d when read in
2662
+ and rounded to nearest.
2663
+ 1 ==> like 0, but with Steele & White stopping rule;
2664
+ e.g. with IEEE P754 arithmetic , mode 0 gives
2665
+ 1e23 whereas mode 1 gives 9.999999999999999e22.
2666
+ 2 ==> max(1,ndigits) significant digits. This gives a
2667
+ return value similar to that of ecvt, except
2668
+ that trailing zeros are suppressed.
2669
+ 3 ==> through ndigits past the decimal point. This
2670
+ gives a return value similar to that from fcvt,
2671
+ except that trailing zeros are suppressed, and
2672
+ ndigits can be negative.
2673
+ 4,5 ==> similar to 2 and 3, respectively, but (in
2674
+ round-nearest mode) with the tests of mode 0 to
2675
+ possibly return a shorter string that rounds to d.
2676
+ With IEEE arithmetic and compilation with
2677
+ -DHonor_FLT_ROUNDS, modes 4 and 5 behave the same
2678
+ as modes 2 and 3 when FLT_ROUNDS != 1.
2679
+ 6-9 ==> Debugging modes similar to mode - 4: don't try
2680
+ fast floating-point estimate (if applicable).
2681
+
2682
+ Values of mode other than 0-9 are treated as mode 0.
2683
+
2684
+ Sufficient space is allocated to the return value
2685
+ to hold the suppressed trailing zeros.
2686
+ */
2687
+
2688
+ int bbits, b2, b5, be, dig, i, ieps, ilim, ilim0, ilim1,
2689
+ j, j1, k, k0, k_check, leftright, m2, m5, s2, s5,
2690
+ spec_case, try_quick;
2691
+ Long L;
2692
+ #ifndef Sudden_Underflow
2693
+ int denorm;
2694
+ ULong x;
2695
+ #endif
2696
+ Bigint *b, *b1, *delta, *mlo, *mhi, *S;
2697
+ U d2, eps;
2698
+ double ds;
2699
+ char *s, *s0;
2700
+ #ifdef Honor_FLT_ROUNDS
2701
+ int rounding;
2702
+ #endif
2703
+ #ifdef SET_INEXACT
2704
+ int inexact, oldinexact;
2705
+ #endif
2706
+
2707
+ #ifdef __GNUC__
2708
+ ilim = ilim1 = 0;
2709
+ mlo = NULL;
2710
+ #endif
2711
+
2712
+ #ifndef MULTIPLE_THREADS
2713
+ if (dtoa_result) {
2714
+ freedtoa(dtoa_result);
2715
+ dtoa_result = 0;
2716
+ }
2717
+ #endif
2718
+
2719
+ if (word0(d) & Sign_bit) {
2720
+ /* set sign for everything, including 0's and NaNs */
2721
+ *sign = 1;
2722
+ word0(d) &= ~Sign_bit; /* clear sign bit */
2723
+ }
2724
+ else
2725
+ *sign = 0;
2726
+
2727
+ #if defined(IEEE_Arith) + defined(VAX)
2728
+ #ifdef IEEE_Arith
2729
+ if ((word0(d) & Exp_mask) == Exp_mask)
2730
+ #else
2731
+ if (word0(d) == 0x8000)
2732
+ #endif
2733
+ {
2734
+ /* Infinity or NaN */
2735
+ *decpt = 9999;
2736
+ #ifdef IEEE_Arith
2737
+ if (!word1(d) && !(word0(d) & 0xfffff))
2738
+ return nrv_alloc("Infinity", rve, 8);
2739
+ #endif
2740
+ return nrv_alloc("NaN", rve, 3);
2741
+ }
2742
+ #endif
2743
+ #ifdef IBM
2744
+ dval(d) += 0; /* normalize */
2745
+ #endif
2746
+ if (!dval(d)) {
2747
+ *decpt = 1;
2748
+ return nrv_alloc("0", rve, 1);
2749
+ }
2750
+
2751
+ #ifdef SET_INEXACT
2752
+ try_quick = oldinexact = get_inexact();
2753
+ inexact = 1;
2754
+ #endif
2755
+ #ifdef Honor_FLT_ROUNDS
2756
+ if ((rounding = Flt_Rounds) >= 2) {
2757
+ if (*sign)
2758
+ rounding = rounding == 2 ? 0 : 2;
2759
+ else
2760
+ if (rounding != 2)
2761
+ rounding = 0;
2762
+ }
2763
+ #endif
2764
+
2765
+ b = d2b(d, &be, &bbits);
2766
+ #ifdef Sudden_Underflow
2767
+ i = (int)(word0(d) >> Exp_shift1 & (Exp_mask>>Exp_shift1));
2768
+ #else
2769
+ if ((i = (int)(word0(d) >> Exp_shift1 & (Exp_mask>>Exp_shift1)))) {
2770
+ #endif
2771
+ dval(d2) = dval(d);
2772
+ word0(d2) &= Frac_mask1;
2773
+ word0(d2) |= Exp_11;
2774
+ #ifdef IBM
2775
+ if (j = 11 - hi0bits(word0(d2) & Frac_mask))
2776
+ dval(d2) /= 1 << j;
2777
+ #endif
2778
+
2779
+ /* log(x) ~=~ log(1.5) + (x-1.5)/1.5
2780
+ * log10(x) = log(x) / log(10)
2781
+ * ~=~ log(1.5)/log(10) + (x-1.5)/(1.5*log(10))
2782
+ * log10(d) = (i-Bias)*log(2)/log(10) + log10(d2)
2783
+ *
2784
+ * This suggests computing an approximation k to log10(d) by
2785
+ *
2786
+ * k = (i - Bias)*0.301029995663981
2787
+ * + ( (d2-1.5)*0.289529654602168 + 0.176091259055681 );
2788
+ *
2789
+ * We want k to be too large rather than too small.
2790
+ * The error in the first-order Taylor series approximation
2791
+ * is in our favor, so we just round up the constant enough
2792
+ * to compensate for any error in the multiplication of
2793
+ * (i - Bias) by 0.301029995663981; since |i - Bias| <= 1077,
2794
+ * and 1077 * 0.30103 * 2^-52 ~=~ 7.2e-14,
2795
+ * adding 1e-13 to the constant term more than suffices.
2796
+ * Hence we adjust the constant term to 0.1760912590558.
2797
+ * (We could get a more accurate k by invoking log10,
2798
+ * but this is probably not worthwhile.)
2799
+ */
2800
+
2801
+ i -= Bias;
2802
+ #ifdef IBM
2803
+ i <<= 2;
2804
+ i += j;
2805
+ #endif
2806
+ #ifndef Sudden_Underflow
2807
+ denorm = 0;
2808
+ }
2809
+ else {
2810
+ /* d is denormalized */
2811
+
2812
+ i = bbits + be + (Bias + (P-1) - 1);
2813
+ x = i > 32 ? word0(d) << (64 - i) | word1(d) >> (i - 32)
2814
+ : word1(d) << (32 - i);
2815
+ dval(d2) = x;
2816
+ word0(d2) -= 31*Exp_msk1; /* adjust exponent */
2817
+ i -= (Bias + (P-1) - 1) + 1;
2818
+ denorm = 1;
2819
+ }
2820
+ #endif
2821
+ ds = (dval(d2)-1.5)*0.289529654602168 + 0.1760912590558 + i*0.301029995663981;
2822
+ k = (int)ds;
2823
+ if (ds < 0. && ds != k)
2824
+ k--; /* want k = floor(ds) */
2825
+ k_check = 1;
2826
+ if (k >= 0 && k <= Ten_pmax) {
2827
+ if (dval(d) < tens[k])
2828
+ k--;
2829
+ k_check = 0;
2830
+ }
2831
+ j = bbits - i - 1;
2832
+ if (j >= 0) {
2833
+ b2 = 0;
2834
+ s2 = j;
2835
+ }
2836
+ else {
2837
+ b2 = -j;
2838
+ s2 = 0;
2839
+ }
2840
+ if (k >= 0) {
2841
+ b5 = 0;
2842
+ s5 = k;
2843
+ s2 += k;
2844
+ }
2845
+ else {
2846
+ b2 -= k;
2847
+ b5 = -k;
2848
+ s5 = 0;
2849
+ }
2850
+ if (mode < 0 || mode > 9)
2851
+ mode = 0;
2852
+
2853
+ #ifndef SET_INEXACT
2854
+ #ifdef Check_FLT_ROUNDS
2855
+ try_quick = Rounding == 1;
2856
+ #else
2857
+ try_quick = 1;
2858
+ #endif
2859
+ #endif /*SET_INEXACT*/
2860
+
2861
+ if (mode > 5) {
2862
+ mode -= 4;
2863
+ try_quick = 0;
2864
+ }
2865
+ leftright = 1;
2866
+ switch(mode) {
2867
+ case 0:
2868
+ case 1:
2869
+ ilim = ilim1 = -1;
2870
+ i = 18;
2871
+ ndigits = 0;
2872
+ break;
2873
+ case 2:
2874
+ leftright = 0;
2875
+ /* no break */
2876
+ case 4:
2877
+ if (ndigits <= 0)
2878
+ ndigits = 1;
2879
+ ilim = ilim1 = i = ndigits;
2880
+ break;
2881
+ case 3:
2882
+ leftright = 0;
2883
+ /* no break */
2884
+ case 5:
2885
+ i = ndigits + k + 1;
2886
+ ilim = i;
2887
+ ilim1 = i - 1;
2888
+ if (i <= 0)
2889
+ i = 1;
2890
+ }
2891
+ s = s0 = rv_alloc(i);
2892
+
2893
+ #ifdef Honor_FLT_ROUNDS
2894
+ if (mode > 1 && rounding != 1)
2895
+ leftright = 0;
2896
+ #endif
2897
+
2898
+ if (ilim >= 0 && ilim <= Quick_max && try_quick) {
2899
+
2900
+ /* Try to get by with floating-point arithmetic. */
2901
+
2902
+ i = 0;
2903
+ dval(d2) = dval(d);
2904
+ k0 = k;
2905
+ ilim0 = ilim;
2906
+ ieps = 2; /* conservative */
2907
+ if (k > 0) {
2908
+ ds = tens[k&0xf];
2909
+ j = k >> 4;
2910
+ if (j & Bletch) {
2911
+ /* prevent overflows */
2912
+ j &= Bletch - 1;
2913
+ dval(d) /= bigtens[n_bigtens-1];
2914
+ ieps++;
2915
+ }
2916
+ for(; j; j >>= 1, i++)
2917
+ if (j & 1) {
2918
+ ieps++;
2919
+ ds *= bigtens[i];
2920
+ }
2921
+ dval(d) /= ds;
2922
+ }
2923
+ else if ((j1 = -k)) {
2924
+ dval(d) *= tens[j1 & 0xf];
2925
+ for(j = j1 >> 4; j; j >>= 1, i++)
2926
+ if (j & 1) {
2927
+ ieps++;
2928
+ dval(d) *= bigtens[i];
2929
+ }
2930
+ }
2931
+ if (k_check && dval(d) < 1. && ilim > 0) {
2932
+ if (ilim1 <= 0)
2933
+ goto fast_failed;
2934
+ ilim = ilim1;
2935
+ k--;
2936
+ dval(d) *= 10.;
2937
+ ieps++;
2938
+ }
2939
+ dval(eps) = ieps*dval(d) + 7.;
2940
+ word0(eps) -= (P-1)*Exp_msk1;
2941
+ if (ilim == 0) {
2942
+ S = mhi = 0;
2943
+ dval(d) -= 5.;
2944
+ if (dval(d) > dval(eps))
2945
+ goto one_digit;
2946
+ if (dval(d) < -dval(eps))
2947
+ goto no_digits;
2948
+ goto fast_failed;
2949
+ }
2950
+ #ifndef No_leftright
2951
+ if (leftright) {
2952
+ /* Use Steele & White method of only
2953
+ * generating digits needed.
2954
+ */
2955
+ dval(eps) = 0.5/tens[ilim-1] - dval(eps);
2956
+ for(i = 0;;) {
2957
+ L = (ULong) dval(d);
2958
+ dval(d) -= L;
2959
+ *s++ = '0' + (int)L;
2960
+ if (dval(d) < dval(eps))
2961
+ goto ret1;
2962
+ if (1. - dval(d) < dval(eps))
2963
+ goto bump_up;
2964
+ if (++i >= ilim)
2965
+ break;
2966
+ dval(eps) *= 10.;
2967
+ dval(d) *= 10.;
2968
+ }
2969
+ }
2970
+ else {
2971
+ #endif
2972
+ /* Generate ilim digits, then fix them up. */
2973
+ dval(eps) *= tens[ilim-1];
2974
+ for(i = 1;; i++, dval(d) *= 10.) {
2975
+ L = (Long)(dval(d));
2976
+ if (!(dval(d) -= L))
2977
+ ilim = i;
2978
+ *s++ = '0' + (int)L;
2979
+ if (i == ilim) {
2980
+ if (dval(d) > 0.5 + dval(eps))
2981
+ goto bump_up;
2982
+ else if (dval(d) < 0.5 - dval(eps)) {
2983
+ while(*--s == '0');
2984
+ s++;
2985
+ goto ret1;
2986
+ }
2987
+ break;
2988
+ }
2989
+ }
2990
+ #ifndef No_leftright
2991
+ }
2992
+ #endif
2993
+ fast_failed:
2994
+ s = s0;
2995
+ dval(d) = dval(d2);
2996
+ k = k0;
2997
+ ilim = ilim0;
2998
+ }
2999
+
3000
+ /* Do we have a "small" integer? */
3001
+
3002
+ if (be >= 0 && k <= Int_max) {
3003
+ /* Yes. */
3004
+ ds = tens[k];
3005
+ if (ndigits < 0 && ilim <= 0) {
3006
+ S = mhi = 0;
3007
+ if (ilim < 0 || dval(d) < 5*ds)
3008
+ goto no_digits;
3009
+ goto one_digit;
3010
+ }
3011
+ for(i = 1;; i++, dval(d) *= 10.) {
3012
+ L = (Long)(dval(d) / ds);
3013
+ dval(d) -= L*ds;
3014
+ #ifdef Check_FLT_ROUNDS
3015
+ /* If FLT_ROUNDS == 2, L will usually be high by 1 */
3016
+ if (dval(d) < 0) {
3017
+ L--;
3018
+ dval(d) += ds;
3019
+ }
3020
+ #endif
3021
+ *s++ = '0' + (int)L;
3022
+ if (!dval(d)) {
3023
+ #ifdef SET_INEXACT
3024
+ inexact = 0;
3025
+ #endif
3026
+ break;
3027
+ }
3028
+ if (i == ilim) {
3029
+ #ifdef Honor_FLT_ROUNDS
3030
+ if (mode > 1)
3031
+ switch(rounding) {
3032
+ case 0: goto ret1;
3033
+ case 2: goto bump_up;
3034
+ }
3035
+ #endif
3036
+ dval(d) += dval(d);
3037
+ if (dval(d) > ds || (dval(d) == ds && L & 1)) {
3038
+ bump_up:
3039
+ while(*--s == '9')
3040
+ if (s == s0) {
3041
+ k++;
3042
+ *s = '0';
3043
+ break;
3044
+ }
3045
+ ++*s++;
3046
+ }
3047
+ break;
3048
+ }
3049
+ }
3050
+ goto ret1;
3051
+ }
3052
+
3053
+ m2 = b2;
3054
+ m5 = b5;
3055
+ mhi = mlo = 0;
3056
+ if (leftright) {
3057
+ i =
3058
+ #ifndef Sudden_Underflow
3059
+ denorm ? be + (Bias + (P-1) - 1 + 1) :
3060
+ #endif
3061
+ #ifdef IBM
3062
+ 1 + 4*P - 3 - bbits + ((bbits + be - 1) & 3);
3063
+ #else
3064
+ 1 + P - bbits;
3065
+ #endif
3066
+ b2 += i;
3067
+ s2 += i;
3068
+ mhi = i2b(1);
3069
+ }
3070
+ if (m2 > 0 && s2 > 0) {
3071
+ i = m2 < s2 ? m2 : s2;
3072
+ b2 -= i;
3073
+ m2 -= i;
3074
+ s2 -= i;
3075
+ }
3076
+ if (b5 > 0) {
3077
+ if (leftright) {
3078
+ if (m5 > 0) {
3079
+ mhi = pow5mult(mhi, m5);
3080
+ b1 = mult(mhi, b);
3081
+ Bfree(b);
3082
+ b = b1;
3083
+ }
3084
+ if ((j = b5 - m5))
3085
+ b = pow5mult(b, j);
3086
+ }
3087
+ else
3088
+ b = pow5mult(b, b5);
3089
+ }
3090
+ S = i2b(1);
3091
+ if (s5 > 0)
3092
+ S = pow5mult(S, s5);
3093
+
3094
+ /* Check for special case that d is a normalized power of 2. */
3095
+
3096
+ spec_case = 0;
3097
+ if ((mode < 2 || leftright)
3098
+ #ifdef Honor_FLT_ROUNDS
3099
+ && rounding == 1
3100
+ #endif
3101
+ ) {
3102
+ if (!word1(d) && !(word0(d) & Bndry_mask)
3103
+ #ifndef Sudden_Underflow
3104
+ && word0(d) & (Exp_mask & ~Exp_msk1)
3105
+ #endif
3106
+ ) {
3107
+ /* The special case */
3108
+ b2 += Log2P;
3109
+ s2 += Log2P;
3110
+ spec_case = 1;
3111
+ }
3112
+ }
3113
+
3114
+ /* Arrange for convenient computation of quotients:
3115
+ * shift left if necessary so divisor has 4 leading 0 bits.
3116
+ *
3117
+ * Perhaps we should just compute leading 28 bits of S once
3118
+ * and for all and pass them and a shift to quorem, so it
3119
+ * can do shifts and ors to compute the numerator for q.
3120
+ */
3121
+ #ifdef Pack_32
3122
+ if ((i = ((s5 ? 32 - hi0bits(S->x[S->wds-1]) : 1) + s2) & 0x1f))
3123
+ i = 32 - i;
3124
+ #else
3125
+ if (i = ((s5 ? 32 - hi0bits(S->x[S->wds-1]) : 1) + s2) & 0xf)
3126
+ i = 16 - i;
3127
+ #endif
3128
+ if (i > 4) {
3129
+ i -= 4;
3130
+ b2 += i;
3131
+ m2 += i;
3132
+ s2 += i;
3133
+ }
3134
+ else if (i < 4) {
3135
+ i += 28;
3136
+ b2 += i;
3137
+ m2 += i;
3138
+ s2 += i;
3139
+ }
3140
+ if (b2 > 0)
3141
+ b = lshift(b, b2);
3142
+ if (s2 > 0)
3143
+ S = lshift(S, s2);
3144
+ if (k_check) {
3145
+ if (cmp(b,S) < 0) {
3146
+ k--;
3147
+ b = multadd(b, 10, 0); /* we botched the k estimate */
3148
+ if (leftright)
3149
+ mhi = multadd(mhi, 10, 0);
3150
+ ilim = ilim1;
3151
+ }
3152
+ }
3153
+ if (ilim <= 0 && (mode == 3 || mode == 5)) {
3154
+ if (ilim < 0 || cmp(b,S = multadd(S,5,0)) < 0) {
3155
+ /* no digits, fcvt style */
3156
+ no_digits:
3157
+ /* MOZILLA CHANGE: Always return a non-empty string. */
3158
+ *s++ = '0';
3159
+ k = 0;
3160
+ goto ret;
3161
+ }
3162
+ one_digit:
3163
+ *s++ = '1';
3164
+ k++;
3165
+ goto ret;
3166
+ }
3167
+ if (leftright) {
3168
+ if (m2 > 0)
3169
+ mhi = lshift(mhi, m2);
3170
+
3171
+ /* Compute mlo -- check for special case
3172
+ * that d is a normalized power of 2.
3173
+ */
3174
+
3175
+ mlo = mhi;
3176
+ if (spec_case) {
3177
+ mhi = Balloc(mhi->k);
3178
+ Bcopy(mhi, mlo);
3179
+ mhi = lshift(mhi, Log2P);
3180
+ }
3181
+
3182
+ for(i = 1;;i++) {
3183
+ dig = quorem(b,S) + '0';
3184
+ /* Do we yet have the shortest decimal string
3185
+ * that will round to d?
3186
+ */
3187
+ j = cmp(b, mlo);
3188
+ delta = diff(S, mhi);
3189
+ j1 = delta->sign ? 1 : cmp(b, delta);
3190
+ Bfree(delta);
3191
+ #ifndef ROUND_BIASED
3192
+ if (j1 == 0 && mode != 1 && !(word1(d) & 1)
3193
+ #ifdef Honor_FLT_ROUNDS
3194
+ && rounding >= 1
3195
+ #endif
3196
+ ) {
3197
+ if (dig == '9')
3198
+ goto round_9_up;
3199
+ if (j > 0)
3200
+ dig++;
3201
+ #ifdef SET_INEXACT
3202
+ else if (!b->x[0] && b->wds <= 1)
3203
+ inexact = 0;
3204
+ #endif
3205
+ *s++ = dig;
3206
+ goto ret;
3207
+ }
3208
+ #endif
3209
+ if (j < 0 || (j == 0 && mode != 1
3210
+ #ifndef ROUND_BIASED
3211
+ && !(word1(d) & 1)
3212
+ #endif
3213
+ )) {
3214
+ if (!b->x[0] && b->wds <= 1) {
3215
+ #ifdef SET_INEXACT
3216
+ inexact = 0;
3217
+ #endif
3218
+ goto accept_dig;
3219
+ }
3220
+ #ifdef Honor_FLT_ROUNDS
3221
+ if (mode > 1)
3222
+ switch(rounding) {
3223
+ case 0: goto accept_dig;
3224
+ case 2: goto keep_dig;
3225
+ }
3226
+ #endif /*Honor_FLT_ROUNDS*/
3227
+ if (j1 > 0) {
3228
+ b = lshift(b, 1);
3229
+ j1 = cmp(b, S);
3230
+ if ((j1 > 0 || (j1 == 0 && dig & 1))
3231
+ && dig++ == '9')
3232
+ goto round_9_up;
3233
+ }
3234
+ accept_dig:
3235
+ *s++ = dig;
3236
+ goto ret;
3237
+ }
3238
+ if (j1 > 0) {
3239
+ #ifdef Honor_FLT_ROUNDS
3240
+ if (!rounding)
3241
+ goto accept_dig;
3242
+ #endif
3243
+ if (dig == '9') { /* possible if i == 1 */
3244
+ round_9_up:
3245
+ *s++ = '9';
3246
+ goto roundoff;
3247
+ }
3248
+ *s++ = dig + 1;
3249
+ goto ret;
3250
+ }
3251
+ #ifdef Honor_FLT_ROUNDS
3252
+ keep_dig:
3253
+ #endif
3254
+ *s++ = dig;
3255
+ if (i == ilim)
3256
+ break;
3257
+ b = multadd(b, 10, 0);
3258
+ if (mlo == mhi)
3259
+ mlo = mhi = multadd(mhi, 10, 0);
3260
+ else {
3261
+ mlo = multadd(mlo, 10, 0);
3262
+ mhi = multadd(mhi, 10, 0);
3263
+ }
3264
+ }
3265
+ }
3266
+ else
3267
+ for(i = 1;; i++) {
3268
+ *s++ = dig = quorem(b,S) + '0';
3269
+ if (!b->x[0] && b->wds <= 1) {
3270
+ #ifdef SET_INEXACT
3271
+ inexact = 0;
3272
+ #endif
3273
+ goto ret;
3274
+ }
3275
+ if (i >= ilim)
3276
+ break;
3277
+ b = multadd(b, 10, 0);
3278
+ }
3279
+
3280
+ /* Round off last digit */
3281
+
3282
+ #ifdef Honor_FLT_ROUNDS
3283
+ switch(rounding) {
3284
+ case 0: goto trimzeros;
3285
+ case 2: goto roundoff;
3286
+ }
3287
+ #endif
3288
+ b = lshift(b, 1);
3289
+ j = cmp(b, S);
3290
+ if (j >= 0) { /* ECMA compatible rounding needed by Spidermonkey */
3291
+ roundoff:
3292
+ while(*--s == '9')
3293
+ if (s == s0) {
3294
+ k++;
3295
+ *s++ = '1';
3296
+ goto ret;
3297
+ }
3298
+ ++*s++;
3299
+ }
3300
+ else {
3301
+ #ifdef Honor_FLT_ROUNDS
3302
+ trimzeros:
3303
+ #endif
3304
+ while(*--s == '0');
3305
+ s++;
3306
+ }
3307
+ ret:
3308
+ Bfree(S);
3309
+ if (mhi) {
3310
+ if (mlo && mlo != mhi)
3311
+ Bfree(mlo);
3312
+ Bfree(mhi);
3313
+ }
3314
+ ret1:
3315
+ #ifdef SET_INEXACT
3316
+ if (inexact) {
3317
+ if (!oldinexact) {
3318
+ word0(d) = Exp_1 + (70 << Exp_shift);
3319
+ word1(d) = 0;
3320
+ dval(d) += 1.;
3321
+ }
3322
+ }
3323
+ else if (!oldinexact)
3324
+ clear_inexact();
3325
+ #endif
3326
+ Bfree(b);
3327
+ *s = 0;
3328
+ *decpt = k + 1;
3329
+ if (rve)
3330
+ *rve = s;
3331
+ return s0;
3332
+ }
3333
+ #ifdef __cplusplus
3334
+ }
3335
+ #endif