diff options
author | Daisuke Miyakawa <dmiyakawa@google.com> | 2009-09-19 19:19:53 -0700 |
---|---|---|
committer | Daisuke Miyakawa <dmiyakawa@google.com> | 2009-09-20 13:32:06 -0700 |
commit | 948a119c94f8b69760437c7d1e784b498cd9b766 (patch) | |
tree | fd7d49dbfa47e5017ffed31867a35e747a59c925 /android/sqlite3_android.cpp | |
parent | b3b8a9dac508afdbac8de93a31a752c60e34e254 (diff) |
Revert the default phone number comparation algorithm.
Now developers have to explicitly set the third argument of PHONE_NUMBERS_COMPARE() into 1,
when they want to use "strict" phone number comparation algorithm, which was used in Donut.
In default, PHONE_NUMBER_COMPARE() now uses "loose" phone number comparation algorithm,
which had been used in Cupcake.
Internal issue id: 1892808
Diffstat (limited to 'android/sqlite3_android.cpp')
-rw-r--r-- | android/sqlite3_android.cpp | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/android/sqlite3_android.cpp b/android/sqlite3_android.cpp index 252a0c5..2d4c3e6 100644 --- a/android/sqlite3_android.cpp +++ b/android/sqlite3_android.cpp @@ -111,7 +111,7 @@ static void get_normalized_string( static void phone_numbers_equal(sqlite3_context * context, int argc, sqlite3_value ** argv) { - if (argc != 2) { + if (argc != 2 && argc != 3) { sqlite3_result_int(context, 0); return; } @@ -119,12 +119,20 @@ static void phone_numbers_equal(sqlite3_context * context, int argc, sqlite3_val char const * num1 = (char const *)sqlite3_value_text(argv[0]); char const * num2 = (char const *)sqlite3_value_text(argv[1]); + bool use_strict = false; + if (argc == 3) { + use_strict = (sqlite3_value_int(argv[2]) != 0); + } + if (num1 == NULL || num2 == NULL) { sqlite3_result_null(context); return; } - bool equal = android::phone_number_compare(num1, num2); + bool equal = + (use_strict ? + android::phone_number_compare_strict(num1, num2) : + android::phone_number_compare_loose(num1, num2)); if (equal) { sqlite3_result_int(context, 1); @@ -479,11 +487,21 @@ extern "C" int register_android_functions(sqlite3 * handle, int utf16Storage) } // Register the PHONE_NUM_EQUALS function - err = sqlite3_create_function(handle, "PHONE_NUMBERS_EQUAL", 2, SQLITE_UTF8, NULL, phone_numbers_equal, NULL, NULL); + err = sqlite3_create_function( + handle, "PHONE_NUMBERS_EQUAL", 2, + SQLITE_UTF8, NULL, phone_numbers_equal, NULL, NULL); if (err != SQLITE_OK) { return err; } - + + // Register the PHONE_NUM_EQUALS function with an additional argument "use_strict" + err = sqlite3_create_function( + handle, "PHONE_NUMBERS_EQUAL", 3, + SQLITE_UTF8, NULL, phone_numbers_equal, NULL, NULL); + if (err != SQLITE_OK) { + return err; + } + // Register the _DELETE_FILE function err = sqlite3_create_function(handle, "_DELETE_FILE", 1, SQLITE_UTF8, NULL, delete_file, NULL, NULL); if (err != SQLITE_OK) { |