From 15c226ad30a2dc1b6758830ac7fcfc57a2b2a3ed Mon Sep 17 00:00:00 2001 From: Andy Staudacher Date: Wed, 18 Feb 2015 12:34:59 +0100 Subject: [PATCH] Add comment Follow up from change 49c2427, copying the comment from the Java implementation to the C++ impl. --- cpp/src/phonenumbers/asyoutypeformatter.cc | 2 ++ javascript/i18n/phonenumbers/asyoutypeformatter.js | 2 ++ 2 files changed, 4 insertions(+) diff --git a/cpp/src/phonenumbers/asyoutypeformatter.cc b/cpp/src/phonenumbers/asyoutypeformatter.cc index 422d568..0a5d958 100644 --- a/cpp/src/phonenumbers/asyoutypeformatter.cc +++ b/cpp/src/phonenumbers/asyoutypeformatter.cc @@ -738,6 +738,8 @@ char AsYouTypeFormatter::NormalizeAndAccrueDigitsAndPlusSign( void AsYouTypeFormatter::InputDigitHelper(char next_char, string* number) { DCHECK(number); number->clear(); + // Note that formattingTemplate is not guaranteed to have a value, it could be + // empty, e.g. when the next digit is entered after extracting an IDD or NDD. const char32 placeholder_codepoint = UnicodeString(kDigitPlaceholder)[0]; int placeholder_pos = formatting_template_ .tempSubString(last_match_position_).indexOf(placeholder_codepoint); diff --git a/javascript/i18n/phonenumbers/asyoutypeformatter.js b/javascript/i18n/phonenumbers/asyoutypeformatter.js index d4d4dd2..53ee5a3 100644 --- a/javascript/i18n/phonenumbers/asyoutypeformatter.js +++ b/javascript/i18n/phonenumbers/asyoutypeformatter.js @@ -1086,6 +1086,8 @@ i18n.phonenumbers.AsYouTypeFormatter.prototype. i18n.phonenumbers.AsYouTypeFormatter.prototype.inputDigitHelper_ = function(nextChar) { + // Note that formattingTemplate is not guaranteed to have a value, it could be + // empty, e.g. when the next digit is entered after extracting an IDD or NDD. /** @type {string} */ var formattingTemplate = this.formattingTemplate_.toString(); if (formattingTemplate.substring(this.lastMatchPosition_) -- 2.7.4