Bug 1315986 - Update line-break class mapping in nsJISx4051LineBreaker to handle new classes in ICU58/Unicode 9, and add assertions to detect any future additions that will require further updates. r=masayuki
authorJonathan Kew <jkew@mozilla.com>
Wed, 09 Nov 2016 15:07:54 +0000
changeset 348598 c17531742f635bcb7bac22ba9e80c23afd7d49b5
parent 348597 41e192bec53699a83c3002bb374c13909f6d6135
child 348599 310ae43d23b7392aad985af26c9907a598360b36
push id10298
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:33:03 +0000
treeherdermozilla-aurora@7e29173b1641 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1315986
milestone52.0a1
Bug 1315986 - Update line-break class mapping in nsJISx4051LineBreaker to handle new classes in ICU58/Unicode 9, and add assertions to detect any future additions that will require further updates. r=masayuki
intl/lwbrk/nsJISx4051LineBreaker.cpp
--- a/intl/lwbrk/nsJISx4051LineBreaker.cpp
+++ b/intl/lwbrk/nsJISx4051LineBreaker.cpp
@@ -542,20 +542,28 @@ GetClass(uint32_t u)
     /* H2 = 31,                           [H2] */ CLASS_BREAKABLE,
     /* H3 = 32,                           [H3] */ CLASS_BREAKABLE,
     /* JL = 33,                           [JL] */ CLASS_CHARACTER,
     /* JT = 34,                           [JT] */ CLASS_CHARACTER,
     /* JV = 35,                           [JV] */ CLASS_CHARACTER,
     /* CLOSE_PARENTHESIS = 36,            [CP] */ CLASS_CLOSE_LIKE_CHARACTER,
     /* CONDITIONAL_JAPANESE_STARTER = 37, [CJ] */ CLASS_CLOSE,
     /* HEBREW_LETTER = 38,                [HL] */ CLASS_CHARACTER,
-    /* REGIONAL_INDICATOR = 39,           [RI] */ CLASS_CHARACTER
+    /* REGIONAL_INDICATOR = 39,           [RI] */ CLASS_CHARACTER,
+    /* E_BASE = 40,                       [EB] */ CLASS_BREAKABLE,
+    /* E_MODIFIER = 41,                   [EM] */ CLASS_CHARACTER,
+    /* ZWJ = 42,                          [ZWJ]*/ CLASS_CHARACTER
   };
 
-  return sUnicodeLineBreakToClass[mozilla::unicode::GetLineBreakClass(u)];
+  static_assert(U_LB_COUNT == mozilla::ArrayLength(sUnicodeLineBreakToClass),
+                "Gecko vs ICU LineBreak class mismatch");
+
+  auto cls = mozilla::unicode::GetLineBreakClass(u);
+  MOZ_ASSERT(cls < mozilla::ArrayLength(sUnicodeLineBreakToClass));
+  return sUnicodeLineBreakToClass[cls];
 }
 
 static bool
 GetPair(int8_t c1, int8_t c2)
 {
   NS_ASSERTION(c1 < MAX_CLASSES ,"illegal classes 1");
   NS_ASSERTION(c2 < MAX_CLASSES ,"illegal classes 2");