diff --git a/hphp/idl/string.idl.php b/hphp/idl/string.idl.php index c00381431..6cc6f71c5 100644 --- a/hphp/idl/string.idl.php +++ b/hphp/idl/string.idl.php @@ -1790,8 +1790,9 @@ DefineFunction( 'desc' => "This function is similar to strcmp(), with the difference that you can specify the (upper limit of the) number of characters from each string to be used in the comparison.\n\nNote that this comparison is case sensitive.", 'flags' => HasDocComment | FunctionIsFoldable, 'return' => array( - 'type' => Int64, - 'desc' => "Returns < 0 if str1 is less than str2; > 0 if str1 is greater than str2, and 0 if they are equal.", + 'type' => Variant, + 'desc' => "Returns < 0 if str1 is less than str2; > 0 if str1 is greater than str2, and 0 if they are equal.", + 'predicted_type' => Int64, ), 'args' => array( array( @@ -1867,8 +1868,9 @@ DefineFunction( 'desc' => "This function is similar to strcasecmp(), with the difference that you can specify the (upper limit of the) number of characters from each string to be used in the comparison.", 'flags' => HasDocComment | FunctionIsFoldable, 'return' => array( - 'type' => Int64, - 'desc' => "Returns < 0 if str1 is less than str2; > 0 if str1 is greater than str2, and 0 if they are equal.", + 'type' => Variant, + 'desc' => "Returns < 0 if str1 is less than str2; > 0 if str1 is greater than str2, and 0 if they are equal.", + 'predicted_type' => Int64, ), 'args' => array( array( @@ -2355,7 +2357,7 @@ DefineFunction( ), 'args' => array( array( - 'name' => "str", + 'name' => "vstr", 'type' => Variant, 'desc' => "The string being measured for length.", ), diff --git a/hphp/runtime/ext/ext_string.cpp b/hphp/runtime/ext/ext_string.cpp index 6525d7c51..b4f468638 100644 --- a/hphp/runtime/ext/ext_string.cpp +++ b/hphp/runtime/ext/ext_string.cpp @@ -435,7 +435,11 @@ String f_number_format(double number, int decimals /* = 0 */, int64_t f_strcmp(CStrRef str1, CStrRef str2) { return string_strcmp(str1.data(), str1.size(), str2.data(), str2.size()); } -int64_t f_strncmp(CStrRef str1, CStrRef str2, int len) { +Variant f_strncmp(CStrRef str1, CStrRef str2, int len) { + if (len < 0) { + raise_warning("Length must be greater than or equal to 0"); + return false; + } return string_strncmp(str1.data(), str1.size(), str2.data(), str2.size(), len); } @@ -446,7 +450,11 @@ int64_t f_strnatcmp(CStrRef str1, CStrRef str2) { int64_t f_strcasecmp(CStrRef str1, CStrRef str2) { return bstrcasecmp(str1.data(), str1.size(), str2.data(), str2.size()); } -int64_t f_strncasecmp(CStrRef str1, CStrRef str2, int len) { +Variant f_strncasecmp(CStrRef str1, CStrRef str2, int len) { + if (len < 0) { + raise_warning("Length must be greater than or equal to 0"); + return false; + } return string_strncasecmp(str1.data(), str1.size(), str2.data(), str2.size(), len); } @@ -1091,7 +1099,7 @@ static const HtmlBasicEntity basic_entities[] = { { 0, NULL, 0, 0 } }; -Array f_get_html_translation_table(int table, int quote_style) { +Array f_get_html_translation_table(int table /* = 0 */, int quote_style /* = k_ENT_COMPAT */) { static entity_charset charset = determine_charset(nullptr); // get default one char ind[2]; ind[1] = 0; diff --git a/hphp/runtime/ext/ext_string.ext_hhvm.cpp b/hphp/runtime/ext/ext_string.ext_hhvm.cpp index 904664a12..9e658d3d6 100644 --- a/hphp/runtime/ext/ext_string.ext_hhvm.cpp +++ b/hphp/runtime/ext/ext_string.ext_hhvm.cpp @@ -3789,21 +3789,21 @@ TypedValue* fg_strcmp(HPHP::VM::ActRec *ar) { /* -long HPHP::f_strncmp(HPHP::String const&, HPHP::String const&, int) +HPHP::Variant HPHP::f_strncmp(HPHP::String const&, HPHP::String const&, int) _ZN4HPHP9f_strncmpERKNS_6StringES2_i (return value) => rax -str1 => rdi -str2 => rsi -len => rdx +_rv => rdi +str1 => rsi +str2 => rdx +len => rcx */ -long fh_strncmp(Value* str1, Value* str2, int len) asm("_ZN4HPHP9f_strncmpERKNS_6StringES2_i"); +TypedValue* fh_strncmp(TypedValue* _rv, Value* str1, Value* str2, int len) asm("_ZN4HPHP9f_strncmpERKNS_6StringES2_i"); TypedValue * fg1_strncmp(TypedValue* rv, HPHP::VM::ActRec* ar, int64_t count) __attribute__((noinline,cold)); TypedValue * fg1_strncmp(TypedValue* rv, HPHP::VM::ActRec* ar, int64_t count) { TypedValue* args UNUSED = ((TypedValue*)ar) - 1; - rv->m_type = KindOfInt64; if ((args-2)->m_type != KindOfInt64) { tvCastToInt64InPlace(args-2); } @@ -3813,7 +3813,8 @@ TypedValue * fg1_strncmp(TypedValue* rv, HPHP::VM::ActRec* ar, int64_t count) { if (!IS_STRING_TYPE((args-0)->m_type)) { tvCastToStringInPlace(args-0); } - rv->m_data.num = (int64_t)fh_strncmp(&args[-0].m_data, &args[-1].m_data, (int)(args[-2].m_data.num)); + fh_strncmp((rv), &args[-0].m_data, &args[-1].m_data, (int)(args[-2].m_data.num)); + if (rv->m_type == KindOfUninit) rv->m_type = KindOfNull; return rv; } @@ -3823,8 +3824,8 @@ TypedValue* fg_strncmp(HPHP::VM::ActRec *ar) { TypedValue* args UNUSED = ((TypedValue*)ar) - 1; if (count == 3LL) { if ((args-2)->m_type == KindOfInt64 && IS_STRING_TYPE((args-1)->m_type) && IS_STRING_TYPE((args-0)->m_type)) { - rv.m_type = KindOfInt64; - rv.m_data.num = (int64_t)fh_strncmp(&args[-0].m_data, &args[-1].m_data, (int)(args[-2].m_data.num)); + fh_strncmp((&(rv)), &args[-0].m_data, &args[-1].m_data, (int)(args[-2].m_data.num)); + if (rv.m_type == KindOfUninit) rv.m_type = KindOfNull; frame_free_locals_no_this_inl(ar, 3); memcpy(&ar->m_r, &rv, sizeof(TypedValue)); return &ar->m_r; @@ -3958,21 +3959,21 @@ TypedValue* fg_strcasecmp(HPHP::VM::ActRec *ar) { /* -long HPHP::f_strncasecmp(HPHP::String const&, HPHP::String const&, int) +HPHP::Variant HPHP::f_strncasecmp(HPHP::String const&, HPHP::String const&, int) _ZN4HPHP13f_strncasecmpERKNS_6StringES2_i (return value) => rax -str1 => rdi -str2 => rsi -len => rdx +_rv => rdi +str1 => rsi +str2 => rdx +len => rcx */ -long fh_strncasecmp(Value* str1, Value* str2, int len) asm("_ZN4HPHP13f_strncasecmpERKNS_6StringES2_i"); +TypedValue* fh_strncasecmp(TypedValue* _rv, Value* str1, Value* str2, int len) asm("_ZN4HPHP13f_strncasecmpERKNS_6StringES2_i"); TypedValue * fg1_strncasecmp(TypedValue* rv, HPHP::VM::ActRec* ar, int64_t count) __attribute__((noinline,cold)); TypedValue * fg1_strncasecmp(TypedValue* rv, HPHP::VM::ActRec* ar, int64_t count) { TypedValue* args UNUSED = ((TypedValue*)ar) - 1; - rv->m_type = KindOfInt64; if ((args-2)->m_type != KindOfInt64) { tvCastToInt64InPlace(args-2); } @@ -3982,7 +3983,8 @@ TypedValue * fg1_strncasecmp(TypedValue* rv, HPHP::VM::ActRec* ar, int64_t count if (!IS_STRING_TYPE((args-0)->m_type)) { tvCastToStringInPlace(args-0); } - rv->m_data.num = (int64_t)fh_strncasecmp(&args[-0].m_data, &args[-1].m_data, (int)(args[-2].m_data.num)); + fh_strncasecmp((rv), &args[-0].m_data, &args[-1].m_data, (int)(args[-2].m_data.num)); + if (rv->m_type == KindOfUninit) rv->m_type = KindOfNull; return rv; } @@ -3992,8 +3994,8 @@ TypedValue* fg_strncasecmp(HPHP::VM::ActRec *ar) { TypedValue* args UNUSED = ((TypedValue*)ar) - 1; if (count == 3LL) { if ((args-2)->m_type == KindOfInt64 && IS_STRING_TYPE((args-1)->m_type) && IS_STRING_TYPE((args-0)->m_type)) { - rv.m_type = KindOfInt64; - rv.m_data.num = (int64_t)fh_strncasecmp(&args[-0].m_data, &args[-1].m_data, (int)(args[-2].m_data.num)); + fh_strncasecmp((&(rv)), &args[-0].m_data, &args[-1].m_data, (int)(args[-2].m_data.num)); + if (rv.m_type == KindOfUninit) rv.m_type = KindOfNull; frame_free_locals_no_this_inl(ar, 3); memcpy(&ar->m_r, &rv, sizeof(TypedValue)); return &ar->m_r; @@ -4935,10 +4937,10 @@ _ZN4HPHP8f_strlenERKNS_7VariantE (return value) => rax _rv => rdi -str => rsi +vstr => rsi */ -TypedValue* fh_strlen(TypedValue* _rv, TypedValue* str) asm("_ZN4HPHP8f_strlenERKNS_7VariantE"); +TypedValue* fh_strlen(TypedValue* _rv, TypedValue* vstr) asm("_ZN4HPHP8f_strlenERKNS_7VariantE"); TypedValue* fg_strlen(HPHP::VM::ActRec *ar) { TypedValue rv; diff --git a/hphp/runtime/ext/ext_string.ext_hhvm.h b/hphp/runtime/ext/ext_string.ext_hhvm.h index 7adb5b380..b72a8111f 100644 --- a/hphp/runtime/ext/ext_string.ext_hhvm.h +++ b/hphp/runtime/ext/ext_string.ext_hhvm.h @@ -799,16 +799,17 @@ str2 => rsi long fh_strcmp(Value* str1, Value* str2) asm("_ZN4HPHP8f_strcmpERKNS_6StringES2_"); /* -long HPHP::f_strncmp(HPHP::String const&, HPHP::String const&, int) +HPHP::Variant HPHP::f_strncmp(HPHP::String const&, HPHP::String const&, int) _ZN4HPHP9f_strncmpERKNS_6StringES2_i (return value) => rax -str1 => rdi -str2 => rsi -len => rdx +_rv => rdi +str1 => rsi +str2 => rdx +len => rcx */ -long fh_strncmp(Value* str1, Value* str2, int len) asm("_ZN4HPHP9f_strncmpERKNS_6StringES2_i"); +TypedValue* fh_strncmp(TypedValue* _rv, Value* str1, Value* str2, int len) asm("_ZN4HPHP9f_strncmpERKNS_6StringES2_i"); /* long HPHP::f_strnatcmp(HPHP::String const&, HPHP::String const&) @@ -833,16 +834,17 @@ str2 => rsi long fh_strcasecmp(Value* str1, Value* str2) asm("_ZN4HPHP12f_strcasecmpERKNS_6StringES2_"); /* -long HPHP::f_strncasecmp(HPHP::String const&, HPHP::String const&, int) +HPHP::Variant HPHP::f_strncasecmp(HPHP::String const&, HPHP::String const&, int) _ZN4HPHP13f_strncasecmpERKNS_6StringES2_i (return value) => rax -str1 => rdi -str2 => rsi -len => rdx +_rv => rdi +str1 => rsi +str2 => rdx +len => rcx */ -long fh_strncasecmp(Value* str1, Value* str2, int len) asm("_ZN4HPHP13f_strncasecmpERKNS_6StringES2_i"); +TypedValue* fh_strncasecmp(TypedValue* _rv, Value* str1, Value* str2, int len) asm("_ZN4HPHP13f_strncasecmpERKNS_6StringES2_i"); /* long HPHP::f_strnatcasecmp(HPHP::String const&, HPHP::String const&) @@ -1042,10 +1044,10 @@ _ZN4HPHP8f_strlenERKNS_7VariantE (return value) => rax _rv => rdi -str => rsi +vstr => rsi */ -TypedValue* fh_strlen(TypedValue* _rv, TypedValue* str) asm("_ZN4HPHP8f_strlenERKNS_7VariantE"); +TypedValue* fh_strlen(TypedValue* _rv, TypedValue* vstr) asm("_ZN4HPHP8f_strlenERKNS_7VariantE"); /* HPHP::Variant HPHP::f_count_chars(HPHP::String const&, long) diff --git a/hphp/runtime/ext/ext_string.h b/hphp/runtime/ext/ext_string.h index e892ddb1d..f71ba383a 100644 --- a/hphp/runtime/ext/ext_string.h +++ b/hphp/runtime/ext/ext_string.h @@ -136,10 +136,10 @@ String f_number_format(double number, int decimals = 0, CStrRef dec_point = ".", // analysis int64_t f_strcmp(CStrRef str1, CStrRef str2); -int64_t f_strncmp(CStrRef str1, CStrRef str2, int len); +Variant f_strncmp(CStrRef str1, CStrRef str2, int len); int64_t f_strnatcmp(CStrRef str1, CStrRef str2); int64_t f_strcasecmp(CStrRef str1, CStrRef str2); -int64_t f_strncasecmp(CStrRef str1, CStrRef str2, int len); +Variant f_strncasecmp(CStrRef str1, CStrRef str2, int len); int64_t f_strnatcasecmp(CStrRef str1, CStrRef str2); int64_t f_strcoll(CStrRef str1, CStrRef str2); diff --git a/hphp/system/class_map.cpp b/hphp/system/class_map.cpp index c74f5a16e..b290aa6d5 100644 --- a/hphp/system/class_map.cpp +++ b/hphp/system/class_map.cpp @@ -8812,8 +8812,8 @@ const char *g_class_map[] = { NULL, NULL, (const char *)0x10106040, "strncmp", "", (const char*)0, (const char*)0, - "/**\n * ( excerpt from http://php.net/manual/en/function.strncmp.php )\n *\n * This function is similar to strcmp(), with the difference that you can\n * specify the (upper limit of the) number of characters from each string\n * to be used in the comparison.\n *\n * Note that this comparison is case sensitive.\n *\n * @str1 string The first string.\n * @str2 string The second string.\n * @len int Number of characters to use in the comparison.\n *\n * @return int Returns < 0 if str1 is less than str2; > 0 if str1\n * is greater than str2, and 0 if they are equal.\n */", - (const char *)0xa, (const char *)0x2000, "str1", "", (const char *)0x14, "", "", NULL, + "/**\n * ( excerpt from http://php.net/manual/en/function.strncmp.php )\n *\n * This function is similar to strcmp(), with the difference that you can\n * specify the (upper limit of the) number of characters from each string\n * to be used in the comparison.\n *\n * Note that this comparison is case sensitive.\n *\n * @str1 string The first string.\n * @str2 string The second string.\n * @len int Number of characters to use in the comparison.\n *\n * @return mixed Returns < 0 if str1 is less than str2; > 0 if str1\n * is greater than str2, and 0 if they are equal.\n */", + (const char *)0xffffffff, (const char *)0x2000, "str1", "", (const char *)0x14, "", "", NULL, (const char *)0x2000, "str2", "", (const char *)0x14, "", "", NULL, (const char *)0x2000, "len", "", (const char *)0xa, "", "", NULL, NULL, @@ -8834,8 +8834,8 @@ const char *g_class_map[] = { NULL, NULL, (const char *)0x10106040, "strncasecmp", "", (const char*)0, (const char*)0, - "/**\n * ( excerpt from http://php.net/manual/en/function.strncasecmp.php )\n *\n * This function is similar to strcasecmp(), with the difference that you\n * can specify the (upper limit of the) number of characters from each\n * string to be used in the comparison.\n *\n * @str1 string The first string.\n * @str2 string The second string.\n * @len int The length of strings to be used in the comparison.\n *\n * @return int Returns < 0 if str1 is less than str2; > 0 if str1\n * is greater than str2, and 0 if they are equal.\n */", - (const char *)0xa, (const char *)0x2000, "str1", "", (const char *)0x14, "", "", NULL, + "/**\n * ( excerpt from http://php.net/manual/en/function.strncasecmp.php )\n *\n * This function is similar to strcasecmp(), with the difference that you\n * can specify the (upper limit of the) number of characters from each\n * string to be used in the comparison.\n *\n * @str1 string The first string.\n * @str2 string The second string.\n * @len int The length of strings to be used in the comparison.\n *\n * @return mixed Returns < 0 if str1 is less than str2; > 0 if str1\n * is greater than str2, and 0 if they are equal.\n */", + (const char *)0xffffffff, (const char *)0x2000, "str1", "", (const char *)0x14, "", "", NULL, (const char *)0x2000, "str2", "", (const char *)0x14, "", "", NULL, (const char *)0x2000, "len", "", (const char *)0xa, "", "", NULL, NULL, @@ -8961,8 +8961,8 @@ const char *g_class_map[] = { NULL, NULL, (const char *)0x10106040, "strlen", "", (const char*)0, (const char*)0, - "/**\n * ( excerpt from http://php.net/manual/en/function.strlen.php )\n *\n * Returns the length of the given string.\n *\n * @str mixed The string being measured for length.\n *\n * @return mixed The length of the string on success, and 0 if the\n * string is empty.\n */", - (const char *)0xffffffff, (const char *)0x2000, "str", "", (const char *)0xffffffff, "", "", NULL, + "/**\n * ( excerpt from http://php.net/manual/en/function.strlen.php )\n *\n * Returns the length of the given string.\n *\n * @vstr mixed The string being measured for length.\n *\n * @return mixed The length of the string on success, and 0 if the\n * string is empty.\n */", + (const char *)0xffffffff, (const char *)0x2000, "vstr", "", (const char *)0xffffffff, "", "", NULL, NULL, NULL, NULL, diff --git a/hphp/system/string.inc b/hphp/system/string.inc index 88efcdb0b..3abe3bbfc 100644 --- a/hphp/system/string.inc +++ b/hphp/system/string.inc @@ -66,10 +66,10 @@ "money_format", T(Variant), S(0), "format", T(String), NULL, S(0), NULL, S(0), "number", T(Double), NULL, S(0), NULL, S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/function.money-format.php )\n *\n * money_format() returns a formatted version of number. This function\n * wraps the C library function strfmon(), with the difference that this\n * implementation converts only one number at a time.\n *\n * @format string The format specification consists of the following\n * sequence: % character Flags\n *\n * One or more of the optional flags below can be\n * used: =f\n *\n * The character = followed by a (single byte)\n * character f to be used as the numeric fill\n * character. The default fill character is space.\n * @number float Disable the use of grouping characters (as defined\n * by the current locale).\n *\n * @return mixed Returns the formatted string. Characters before and\n * after the formatting string will be returned\n * unchanged. Non-numeric number causes returning NULL\n * and emitting E_WARNING.\n */", "number_format", T(String), S(0), "number", T(Double), NULL, S(0), NULL, S(0), "decimals", T(Int32), "i:0;", S(4), "0", S(0), "dec_point", T(String), "s:1:\".\";", S(8), "\".\"", S(0), "thousands_sep", T(String), "s:1:\",\";", S(8), "\",\"", S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/function.number-format.php )\n *\n * This function accepts either one, two, or four parameters (not three):\n *\n * If only one parameter is given, number will be formatted without\n * decimals, but with a comma (\",\") between every group of thousands.\n *\n * If two parameters are given, number will be formatted with decimals\n * decimals with a dot (\".\") in front, and a comma (\",\") between every\n * group of thousands.\n *\n * If all four parameters are given, number will be formatted with\n * decimals decimals, dec_point instead of a dot (\".\") before the decimals\n * and thousands_sep instead of a comma (\",\") between every group of\n * thousands.\n *\n * @number float The number being formatted.\n * @decimals int Sets the number of decimal points.\n * @dec_point string Sets the separator for the decimal point.\n * @thousands_sep\n * string Sets the thousands separator.\n *\n * Only the first character of thousands_sep is used.\n * For example, if you use bar as thousands_sep on the\n * number 1000, number_format() will return 1b000.\n *\n * @return string A formatted version of number.\n */", "strcmp", T(Int64), S(0), "str1", T(String), NULL, S(0), NULL, S(0), "str2", T(String), NULL, S(0), NULL, S(0), NULL, S(1064960), "/**\n * ( excerpt from http://php.net/manual/en/function.strcmp.php )\n *\n *\n * @str1 string The first string.\n * @str2 string The second string.\n *\n * @return int Returns < 0 if str1 is less than str2; > 0 if str1\n * is greater than str2, and 0 if they are equal.\n */", -"strncmp", T(Int64), S(0), "str1", T(String), NULL, S(0), NULL, S(0), "str2", T(String), NULL, S(0), NULL, S(0), "len", T(Int32), NULL, S(0), NULL, S(0), NULL, S(1064960), "/**\n * ( excerpt from http://php.net/manual/en/function.strncmp.php )\n *\n * This function is similar to strcmp(), with the difference that you can\n * specify the (upper limit of the) number of characters from each string\n * to be used in the comparison.\n *\n * Note that this comparison is case sensitive.\n *\n * @str1 string The first string.\n * @str2 string The second string.\n * @len int Number of characters to use in the comparison.\n *\n * @return int Returns < 0 if str1 is less than str2; > 0 if str1\n * is greater than str2, and 0 if they are equal.\n */", +"strncmp", T(Variant), S(0), "str1", T(String), NULL, S(0), NULL, S(0), "str2", T(String), NULL, S(0), NULL, S(0), "len", T(Int32), NULL, S(0), NULL, S(0), NULL, S(1064960), "/**\n * ( excerpt from http://php.net/manual/en/function.strncmp.php )\n *\n * This function is similar to strcmp(), with the difference that you can\n * specify the (upper limit of the) number of characters from each string\n * to be used in the comparison.\n *\n * Note that this comparison is case sensitive.\n *\n * @str1 string The first string.\n * @str2 string The second string.\n * @len int Number of characters to use in the comparison.\n *\n * @return mixed Returns < 0 if str1 is less than str2; > 0 if str1\n * is greater than str2, and 0 if they are equal.\n */", "strnatcmp", T(Int64), S(0), "str1", T(String), NULL, S(0), NULL, S(0), "str2", T(String), NULL, S(0), NULL, S(0), NULL, S(1064960), "/**\n * ( excerpt from http://php.net/manual/en/function.strnatcmp.php )\n *\n * This function implements a comparison algorithm that orders\n * alphanumeric strings in the way a human being would, this is described\n * as a \"natural ordering\". Note that this comparison is case sensitive.\n *\n * @str1 string The first string.\n * @str2 string The second string.\n *\n * @return int Similar to other string comparison functions, this\n * one returns < 0 if str1 is less than str2; > 0 if\n * str1 is greater than str2, and 0 if they are equal.\n */", "strcasecmp", T(Int64), S(0), "str1", T(String), NULL, S(0), NULL, S(0), "str2", T(String), NULL, S(0), NULL, S(0), NULL, S(1064960), "/**\n * ( excerpt from http://php.net/manual/en/function.strcasecmp.php )\n *\n * Binary safe case-insensitive string comparison.\n *\n * @str1 string The first string\n * @str2 string The second string\n *\n * @return int Returns < 0 if str1 is less than str2; > 0 if str1\n * is greater than str2, and 0 if they are equal.\n */", -"strncasecmp", T(Int64), S(0), "str1", T(String), NULL, S(0), NULL, S(0), "str2", T(String), NULL, S(0), NULL, S(0), "len", T(Int32), NULL, S(0), NULL, S(0), NULL, S(1064960), "/**\n * ( excerpt from http://php.net/manual/en/function.strncasecmp.php )\n *\n * This function is similar to strcasecmp(), with the difference that you\n * can specify the (upper limit of the) number of characters from each\n * string to be used in the comparison.\n *\n * @str1 string The first string.\n * @str2 string The second string.\n * @len int The length of strings to be used in the comparison.\n *\n * @return int Returns < 0 if str1 is less than str2; > 0 if str1\n * is greater than str2, and 0 if they are equal.\n */", +"strncasecmp", T(Variant), S(0), "str1", T(String), NULL, S(0), NULL, S(0), "str2", T(String), NULL, S(0), NULL, S(0), "len", T(Int32), NULL, S(0), NULL, S(0), NULL, S(1064960), "/**\n * ( excerpt from http://php.net/manual/en/function.strncasecmp.php )\n *\n * This function is similar to strcasecmp(), with the difference that you\n * can specify the (upper limit of the) number of characters from each\n * string to be used in the comparison.\n *\n * @str1 string The first string.\n * @str2 string The second string.\n * @len int The length of strings to be used in the comparison.\n *\n * @return mixed Returns < 0 if str1 is less than str2; > 0 if str1\n * is greater than str2, and 0 if they are equal.\n */", "strnatcasecmp", T(Int64), S(0), "str1", T(String), NULL, S(0), NULL, S(0), "str2", T(String), NULL, S(0), NULL, S(0), NULL, S(1064960), "/**\n * ( excerpt from http://php.net/manual/en/function.strnatcasecmp.php )\n *\n * This function implements a comparison algorithm that orders\n * alphanumeric strings in the way a human being would. The behaviour of\n * this function is similar to strnatcmp(), except that the comparison is\n * not case sensitive. For more information see: Martin Pool's Natural\n * Order String Comparison page.\n *\n * @str1 string The first string.\n * @str2 string The second string.\n *\n * @return int Similar to other string comparison functions, this\n * one returns < 0 if str1 is less than str2 > 0 if\n * str1 is greater than str2, and 0 if they are equal.\n */", "strcoll", T(Int64), S(0), "str1", T(String), NULL, S(0), NULL, S(0), "str2", T(String), NULL, S(0), NULL, S(0), NULL, S(1064960), "/**\n * ( excerpt from http://php.net/manual/en/function.strcoll.php )\n *\n * Note that this comparison is case sensitive, and unlike strcmp() this\n * function is not binary safe.\n *\n * strcoll() uses the current locale for doing the comparisons. If the\n * current locale is C or POSIX, this function is equivalent to strcmp().\n *\n * @str1 string The first string.\n * @str2 string The second string.\n *\n * @return int Returns < 0 if str1 is less than str2; > 0 if str1\n * is greater than str2, and 0 if they are equal.\n */", "substr_compare", T(Variant), S(0), "main_str", T(String), NULL, S(0), NULL, S(0), "str", T(String), NULL, S(0), NULL, S(0), "offset", T(Int32), NULL, S(0), NULL, S(0), "length", T(Int32), "i:2147483647;", S(13), "INT_MAX", S(0), "case_insensitivity", T(Boolean), "b:0;", S(4), "false", S(0), NULL, S(1064960), "/**\n * ( excerpt from http://php.net/manual/en/function.substr-compare.php )\n *\n * substr_compare() compares main_str from position offset with str up to\n * length characters.\n *\n * @main_str string The main string being compared.\n * @str string The secondary string being compared.\n * @offset int The start position for the comparison. If negative,\n * it starts counting from the end of the string.\n * @length int The length of the comparison. The default value is\n * the largest of the length of the str compared to the\n * length of main_str less the offset.\n * @case_insensitivity\n * bool If case_insensitivity is TRUE, comparison is case\n * insensitive.\n *\n * @return mixed Returns < 0 if main_str from position offset is less\n * than str, > 0 if it is greater than str, and 0 if\n * they are equal. If offset is equal to or greater\n * than the length of main_str or length is set and is\n * less than 1, substr_compare() prints a warning and\n * returns FALSE.\n */", @@ -85,7 +85,7 @@ "substr_count", T(Variant), S(0), "haystack", T(String), NULL, S(0), NULL, S(0), "needle", T(String), NULL, S(0), NULL, S(0), "offset", T(Int32), "i:0;", S(4), "0", S(0), "length", T(Int32), "i:2147483647;", S(13), "0x7FFFFFFF", S(0), NULL, S(1064960), "/**\n * ( excerpt from http://php.net/manual/en/function.substr-count.php )\n *\n * substr_count() returns the number of times the needle substring occurs\n * in the haystack string. Please note that needle is case sensitive.\n *\n * This function doesn't count overlapped substrings. See the example\n * below!\n *\n * @haystack string The string to search in\n * @needle string The substring to search for\n * @offset int The offset where to start counting\n * @length int The maximum length after the specified offset to\n * search for the substring. It outputs a warning if\n * the offset plus the length is greater than the\n * haystack length.\n *\n * @return mixed This functions returns an integer.\n */", "strspn", T(Variant), S(0), "str1", T(String), NULL, S(0), NULL, S(0), "str2", T(String), NULL, S(0), NULL, S(0), "start", T(Int32), "i:0;", S(4), "0", S(0), "length", T(Int32), "i:2147483647;", S(13), "0x7FFFFFFF", S(0), NULL, S(1064960), "/**\n * ( excerpt from http://php.net/manual/en/function.strspn.php )\n *\n * Returns the length of the first group of consecutive characters from\n * mask found in subject.\n *\n * If start and length are omitted, then all of subject will be examined.\n * If they are included, then the effect will be the same as calling\n * strspn(substr($subject, $start, $length), $mask) (see substr for more\n * information).\n *\n * The line of code:\n *\n * will assign 2 to $var, because the string \"42\" is the first segment\n * from subject to consist only of characters contained within\n * \"1234567890\".\n *\n * @str1 string The string to examine.\n * @str2 string The list of allowable characters to include in\n * counted segments.\n * @start int The position in subject to start searching.\n *\n * If start is given and is non-negative, then\n * strspn() will begin examining subject at the\n * start'th position. For instance, in the string\n * 'abcdef', the character at position 0 is 'a', the\n * character at position 2 is 'c', and so forth.\n *\n * If start is given and is negative, then strspn()\n * will begin examining subject at the start'th\n * position from the end of subject.\n * @length int The length of the segment from subject to examine.\n *\n * If length is given and is non-negative, then\n * subject will be examined for length characters after\n * the starting position.\n *\n * If lengthis given and is negative, then subject\n * will be examined from the starting position up to\n * length characters from the end of subject.\n *\n * @return mixed Returns the length of the initial segment of str1\n * which consists entirely of characters in str2.\n */", "strcspn", T(Variant), S(0), "str1", T(String), NULL, S(0), NULL, S(0), "str2", T(String), NULL, S(0), NULL, S(0), "start", T(Int32), "i:0;", S(4), "0", S(0), "length", T(Int32), "i:2147483647;", S(13), "0x7FFFFFFF", S(0), NULL, S(1064960), "/**\n * ( excerpt from http://php.net/manual/en/function.strcspn.php )\n *\n * Returns the length of the initial segment of str1 which does not\n * contain any of the characters in str2.\n *\n * @str1 string The first string.\n * @str2 string The second string.\n * @start int The start position of the string to examine.\n * @length int The length of the string to examine.\n *\n * @return mixed Returns the length of the segment as an integer.\n */", -"strlen", T(Variant), S(0), "str", T(Variant), NULL, S(0), NULL, S(0), NULL, S(1064960), "/**\n * ( excerpt from http://php.net/manual/en/function.strlen.php )\n *\n * Returns the length of the given string.\n *\n * @str mixed The string being measured for length.\n *\n * @return mixed The length of the string on success, and 0 if the\n * string is empty.\n */", +"strlen", T(Variant), S(0), "vstr", T(Variant), NULL, S(0), NULL, S(0), NULL, S(1064960), "/**\n * ( excerpt from http://php.net/manual/en/function.strlen.php )\n *\n * Returns the length of the given string.\n *\n * @vstr mixed The string being measured for length.\n *\n * @return mixed The length of the string on success, and 0 if the\n * string is empty.\n */", "count_chars", T(Variant), S(0), "str", T(String), NULL, S(0), NULL, S(0), "mode", T(Int64), "i:0;", S(4), "0", S(0), NULL, S(1064960), "/**\n * ( excerpt from http://php.net/manual/en/function.count-chars.php )\n *\n * Counts the number of occurrences of every byte-value (0..255) in string\n * and returns it in various ways.\n *\n * @str string The examined string.\n * @mode int See return values.\n *\n * @return mixed Depending on mode count_chars() returns one of the\n * following: 0 - an array with the byte-value as key\n * and the frequency of every byte as value. 1 - same\n * as 0 but only byte-values with a frequency greater\n * than zero are listed. 2 - same as 0 but only\n * byte-values with a frequency equal to zero are\n * listed. 3 - a string containing all unique\n * characters is returned. 4 - a string containing all\n * not used characters is returned.\n */", "str_word_count", T(Variant), S(0), "str", T(String), NULL, S(0), NULL, S(0), "format", T(Int64), "i:0;", S(4), "0", S(0), "charlist", T(String), "s:0:\"\";", S(7), "\"\"", S(0), NULL, S(1064960), "/**\n * ( excerpt from http://php.net/manual/en/function.str-word-count.php )\n *\n * Counts the number of words inside string. If the optional format is not\n * specified, then the return value will be an integer representing the\n * number of words found. In the event the format is specified, the return\n * value will be an array, content of which is dependent on the format. The\n * possible value for the format and the resultant outputs are listed\n * below.\n *\n * For the purpose of this function, 'word' is defined as a locale\n * dependent string containing alphabetic characters, which also may\n * contain, but not start with \"'\" and \"-\" characters.\n *\n * @str string The string\n * @format int Specify the return value of this function. The\n * current supported values are: 0 - returns the number\n * of words found 1 - returns an array containing all\n * the words found inside the string 2 - returns an\n * associative array, where the key is the numeric\n * position of the word inside the string and the value\n * is the actual word itself\n * @charlist string A list of additional characters which will be\n * considered as 'word'\n *\n * @return mixed Returns an array or an integer, depending on the\n * format chosen.\n */", "levenshtein", T(Int64), S(0), "str1", T(String), NULL, S(0), NULL, S(0), "str2", T(String), NULL, S(0), NULL, S(0), "cost_ins", T(Int32), "i:1;", S(4), "1", S(0), "cost_rep", T(Int32), "i:1;", S(4), "1", S(0), "cost_del", T(Int32), "i:1;", S(4), "1", S(0), NULL, S(1064960), "/**\n * ( excerpt from http://php.net/manual/en/function.levenshtein.php )\n *\n * The Levenshtein distance is defined as the minimal number of characters\n * you have to replace, insert or delete to transform str1 into str2. The\n * complexity of the algorithm is O(m*n), where n and m are the length of\n * str1 and str2 (rather good when compared to similar_text(), which is\n * O(max(n,m)**3), but still expensive).\n *\n * In its simplest form the function will take only the two strings as\n * parameter and will calculate just the number of insert, replace and\n * delete operations needed to transform str1 into str2.\n *\n * A second variant will take three additional parameters that define the\n * cost of insert, replace and delete operations. This is more general and\n * adaptive than variant one, but not as efficient.\n *\n * @str1 string One of the strings being evaluated for Levenshtein\n * distance.\n * @str2 string One of the strings being evaluated for Levenshtein\n * distance.\n * @cost_ins int Defines the cost of insertion.\n * @cost_rep int Defines the cost of replacement.\n * @cost_del int Defines the cost of deletion.\n *\n * @return int This function returns the Levenshtein-Distance\n * between the two argument strings or -1, if one of\n * the argument strings is longer than the limit of 255\n * characters.\n */", diff --git a/hphp/test/test_code_run.cpp b/hphp/test/test_code_run.cpp index d93518355..38703ac68 100644 --- a/hphp/test/test_code_run.cpp +++ b/hphp/test/test_code_run.cpp @@ -1794,15 +1794,11 @@ bool TestCodeRun::TestString() { "}" "foo();"); - MVCRO("