1. Patrick Mézard
  2. libphonenumber-csharp

Commits

phil...@gmail.com@ee073f10-1060-11df-b6a4-87a95322a99c  committed 8561e0a

CPP: Fix geocoding data parser.

Patch contributed by pmezard.

The "end" iterator must stay on the trailing LF, for it is not included in the
line characters sequence. Also fix the test which should have failed.

  • Participants
  • Parent commits b9fa7f6
  • Branches default

Comments (0)

Files changed (2)

File cpp/test/phonenumbers/geocoding/geocoding_data_test.cc

View file
   ASSERT_EQ(2, desc_1_de->prefixes_size);
   const int32 expected_prefixes[] = {1201, 1650};
   const char* expected_descriptions[] = {
-    "New Jerse",
-    "Kalifornie",
+    "New Jersey",
+    "Kalifornien",
   };
   for (int i = 0; i < desc_1_de->prefixes_size; ++i) {
     EXPECT_EQ(expected_prefixes[i], desc_1_de->prefixes[i]);

File tools/cpp/src/cpp-build/generate_geocoding_data.cc

View file
       continue;
     }
     --end;
-    if (*end != '\n') {
-      if (!feof(input)) {
-        // A line without LF can only happen at the end of file.
-        return false;
-      }
-    } else {
-      // Consume the LF.
-      --end;
+    if (*end != '\n' && !feof(input)) {
+      // A line without LF can only happen at the end of file.
+      return false;
     }
 
     // Trim and check for comments.