瀏覽代碼

Initialize ICU as (meanwhile) needed

Stefan Siegl 8 年之前
父節點
當前提交
c957be8b2a
共有 3 個文件被更改,包括 26 次插入1 次删除
  1. 3 1
      config.m4
  2. 18 0
      tests/issue_306_basic.phpt
  3. 5 0
      v8js_v8.cc

+ 3 - 1
config.m4

@@ -3,7 +3,7 @@ PHP_ARG_WITH(v8js, for V8 Javascript Engine,
 
 if test "$PHP_V8JS" != "no"; then
   SEARCH_PATH="/usr/local /usr"
-  SEARCH_FOR="include/v8.h"
+  SEARCH_FOR="$PHP_LIBDIR/libv8.$SHLIB_DL_SUFFIX_NAME"
   
   if test -r $PHP_V8JS/$SEARCH_FOR; then
     case $host_os in
@@ -25,6 +25,8 @@ if test "$PHP_V8JS" != "no"; then
     done
   fi
 
+  AC_DEFINE_UNQUOTED([PHP_V8_EXEC_PATH], "$V8_DIR/$SEARCH_FOR", [Full path to libv8 library file])
+
   if test -z "$V8_DIR"; then
     AC_MSG_RESULT([not found])
     AC_MSG_ERROR([Please reinstall the v8 distribution])

+ 18 - 0
tests/issue_306_basic.phpt

@@ -0,0 +1,18 @@
+--TEST--
+Test V8::executeString() : Issue #306 V8 crashing on toLocaleString()
+--SKIPIF--
+<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
+--FILE--
+<?php
+
+$v8 = new V8Js();
+
+$v8 = new V8Js;
+$expr = 'new Date("10/11/2009").toLocaleString("en-us", { month: "long" });';
+var_dump( $v8->executeString($expr, null, V8Js::FLAG_FORCE_ARRAY) );
+
+?>
+===EOF===
+--EXPECT--
+string(7) "October"
+===EOF===

+ 5 - 0
v8js_v8.cc

@@ -76,6 +76,11 @@ void v8js_v8_init() /* {{{ */
 		}
 	}
 
+#ifdef PHP_V8_EXEC_PATH
+    /* Initialize ICU */
+	v8::V8::InitializeICUDefaultLocation(PHP_V8_EXEC_PATH, nullptr);
+#endif
+
 	/* Initialize V8 */
 	v8::V8::Initialize();