Commit 8cfa78f5 authored by Sathya Gunasekaran's avatar Sathya Gunasekaran Committed by Commit Bot

[Intl] Use strcmp to be spec compatible

Tests will be added in a follow on CL.

Bug: v8:5751
Change-Id: Ie327239a0ad1526f06c2a71fdc821f57e3aa41df
Reviewed-on: https://chromium-review.googlesource.com/1176283Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Commit-Queue: Sathya Gunasekaran <gsathya@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55140}
parent 4d474c51
...@@ -223,9 +223,9 @@ void SetCaseFirstOption(icu::Collator* icu_collator, const char* value) { ...@@ -223,9 +223,9 @@ void SetCaseFirstOption(icu::Collator* icu_collator, const char* value) {
CHECK_NOT_NULL(icu_collator); CHECK_NOT_NULL(icu_collator);
CHECK_NOT_NULL(value); CHECK_NOT_NULL(value);
UErrorCode status = U_ZERO_ERROR; UErrorCode status = U_ZERO_ERROR;
if (strncmp(value, "upper", 5) == 0) { if (strcmp(value, "upper") == 0) {
icu_collator->setAttribute(UCOL_CASE_FIRST, UCOL_UPPER_FIRST, status); icu_collator->setAttribute(UCOL_CASE_FIRST, UCOL_UPPER_FIRST, status);
} else if (strncmp(value, "lower", 5) == 0) { } else if (strcmp(value, "lower") == 0) {
icu_collator->setAttribute(UCOL_CASE_FIRST, UCOL_LOWER_FIRST, status); icu_collator->setAttribute(UCOL_CASE_FIRST, UCOL_LOWER_FIRST, status);
} else { } else {
icu_collator->setAttribute(UCOL_CASE_FIRST, UCOL_OFF, status); icu_collator->setAttribute(UCOL_CASE_FIRST, UCOL_OFF, status);
...@@ -271,7 +271,7 @@ MaybeHandle<JSCollator> JSCollator::InitializeCollator( ...@@ -271,7 +271,7 @@ MaybeHandle<JSCollator> JSCollator::InitializeCollator(
if (found_usage.FromJust()) { if (found_usage.FromJust()) {
DCHECK_NOT_NULL(usage_str.get()); DCHECK_NOT_NULL(usage_str.get());
if (strncmp(usage_str.get(), "search", 6) == 0) { if (strcmp(usage_str.get(), "search") == 0) {
usage = JSCollator::Usage::SEARCH; usage = JSCollator::Usage::SEARCH;
} }
} }
...@@ -383,8 +383,7 @@ MaybeHandle<JSCollator> JSCollator::InitializeCollator( ...@@ -383,8 +383,7 @@ MaybeHandle<JSCollator> JSCollator::InitializeCollator(
// [[SearchLocaleData]][locale].co list. // [[SearchLocaleData]][locale].co list.
if (extensions.find("co") != extensions.end()) { if (extensions.find("co") != extensions.end()) {
const char* value = extensions.at("co"); const char* value = extensions.at("co");
if (strncmp(value, "search", 6) == 0 || if (strcmp(value, "search") == 0 || strcmp(value, "standard") == 0) {
strncmp(value, "standard", 8) == 0) {
UErrorCode status = U_ZERO_ERROR; UErrorCode status = U_ZERO_ERROR;
icu_locale.setKeywordValue("co", NULL, status); icu_locale.setKeywordValue("co", NULL, status);
CHECK(U_SUCCESS(status)); CHECK(U_SUCCESS(status));
...@@ -429,7 +428,7 @@ MaybeHandle<JSCollator> JSCollator::InitializeCollator( ...@@ -429,7 +428,7 @@ MaybeHandle<JSCollator> JSCollator::InitializeCollator(
} else if (extensions.find("kn") != extensions.end()) { } else if (extensions.find("kn") != extensions.end()) {
const char* value = extensions.at("kn"); const char* value = extensions.at("kn");
numeric = (strncmp(value, "true", 4) == 0); numeric = (strcmp(value, "true") == 0);
icu_collator->setAttribute(UCOL_NUMERIC_COLLATION, icu_collator->setAttribute(UCOL_NUMERIC_COLLATION,
numeric ? UCOL_ON : UCOL_OFF, status); numeric ? UCOL_ON : UCOL_OFF, status);
...@@ -480,17 +479,17 @@ MaybeHandle<JSCollator> JSCollator::InitializeCollator( ...@@ -480,17 +479,17 @@ MaybeHandle<JSCollator> JSCollator::InitializeCollator(
DCHECK_NOT_NULL(sensitivity_cstr); DCHECK_NOT_NULL(sensitivity_cstr);
// 26. Set collator.[[Sensitivity]] to sensitivity. // 26. Set collator.[[Sensitivity]] to sensitivity.
if (strncmp(sensitivity_cstr, "base", 4) == 0) { if (strcmp(sensitivity_cstr, "base") == 0) {
icu_collator->setStrength(icu::Collator::PRIMARY); icu_collator->setStrength(icu::Collator::PRIMARY);
} else if (strncmp(sensitivity_cstr, "accent", 6) == 0) { } else if (strcmp(sensitivity_cstr, "accent") == 0) {
icu_collator->setStrength(icu::Collator::SECONDARY); icu_collator->setStrength(icu::Collator::SECONDARY);
} else if (strncmp(sensitivity_cstr, "case", 4) == 0) { } else if (strcmp(sensitivity_cstr, "case") == 0) {
icu_collator->setStrength(icu::Collator::PRIMARY); icu_collator->setStrength(icu::Collator::PRIMARY);
status = U_ZERO_ERROR; status = U_ZERO_ERROR;
icu_collator->setAttribute(UCOL_CASE_LEVEL, UCOL_ON, status); icu_collator->setAttribute(UCOL_CASE_LEVEL, UCOL_ON, status);
CHECK(U_SUCCESS(status)); CHECK(U_SUCCESS(status));
} else { } else {
DCHECK_EQ(0, strncmp(sensitivity_cstr, "variant", 7)); DCHECK_EQ(0, strcmp(sensitivity_cstr, "variant"));
icu_collator->setStrength(icu::Collator::TERTIARY); icu_collator->setStrength(icu::Collator::TERTIARY);
} }
} }
......
...@@ -140,17 +140,17 @@ bool PopulateLocaleWithUnicodeTags(Isolate* isolate, const char* icu_locale, ...@@ -140,17 +140,17 @@ bool PopulateLocaleWithUnicodeTags(Isolate* isolate, const char* icu_locale,
if (bcp47_value) { if (bcp47_value) {
Handle<String> bcp47_handle = Handle<String> bcp47_handle =
factory->NewStringFromAsciiChecked(bcp47_value); factory->NewStringFromAsciiChecked(bcp47_value);
if (strncmp(bcp47_key, "kn", 2) == 0) { if (strcmp(bcp47_key, "kn") == 0) {
locale_holder->set_numeric(*bcp47_handle); locale_holder->set_numeric(*bcp47_handle);
} else if (strncmp(bcp47_key, "ca", 2) == 0) { } else if (strcmp(bcp47_key, "ca") == 0) {
locale_holder->set_calendar(*bcp47_handle); locale_holder->set_calendar(*bcp47_handle);
} else if (strncmp(bcp47_key, "kf", 2) == 0) { } else if (strcmp(bcp47_key, "kf") == 0) {
locale_holder->set_case_first(*bcp47_handle); locale_holder->set_case_first(*bcp47_handle);
} else if (strncmp(bcp47_key, "co", 2) == 0) { } else if (strcmp(bcp47_key, "co") == 0) {
locale_holder->set_collation(*bcp47_handle); locale_holder->set_collation(*bcp47_handle);
} else if (strncmp(bcp47_key, "hc", 2) == 0) { } else if (strcmp(bcp47_key, "hc") == 0) {
locale_holder->set_hour_cycle(*bcp47_handle); locale_holder->set_hour_cycle(*bcp47_handle);
} else if (strncmp(bcp47_key, "nu", 2) == 0) { } else if (strcmp(bcp47_key, "nu") == 0) {
locale_holder->set_numbering_system(*bcp47_handle); locale_holder->set_numbering_system(*bcp47_handle);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment