Prepare to load dictionary data set from an external file

This CL is a groundwork to enable mozc server to load dictionary data set from an external file at runtime.  No actual behavior change is intended right now though.

Major changes are:
- Add sentinel elements to arrays of POSMatcher to determine array size.
- Remove const qualifier from POSMatcher::Range so that it can be constructed by vector::push_back.

BUG=none
TEST=unittest

git-svn-id: https://mozc.googlecode.com/svn/trunk@450 a6090854-d499-a067-5803-1114d4e51264
diff --git a/src/data_manager/packed/gen_packed_data_light_main_template.cc b/src/data_manager/packed/gen_packed_data_light_main_template.cc
index e605c71..7ae7366 100644
--- a/src/data_manager/packed/gen_packed_data_light_main_template.cc
+++ b/src/data_manager/packed/gen_packed_data_light_main_template.cc
@@ -51,8 +51,11 @@
 bool OutputData(const string &file_path) {
   packed::SystemDictionaryDataPacker packer(Version::GetMozcVersion());
   packer.SetPosTokens(kPOSToken, arraysize(kPOSToken));
-  packer.SetPosMatcherData(kRuleIdTable, arraysize(kRuleIdTable),
-                           kRangeTables, arraysize(kRangeTables));
+  // The following two arrays contain sentinel elements but the packer doesn't
+  // expect them.  So, pass the shinked ranges of the arrays.  Note that
+  // sentinel elements are not necessary at runtime.
+  packer.SetPosMatcherData(kRuleIdTable, arraysize(kRuleIdTable) - 1,
+                           kRangeTables, arraysize(kRangeTables) - 1);
   return packer.Output(file_path, false);
 }
 
diff --git a/src/data_manager/packed/gen_packed_data_main_template.cc b/src/data_manager/packed/gen_packed_data_main_template.cc
index fbe1b4d..c09f10c 100644
--- a/src/data_manager/packed/gen_packed_data_main_template.cc
+++ b/src/data_manager/packed/gen_packed_data_main_template.cc
@@ -80,8 +80,11 @@
   }
   packed::SystemDictionaryDataPacker packer(dictionary_version);
   packer.SetPosTokens(kPOSToken, arraysize(kPOSToken));
-  packer.SetPosMatcherData(kRuleIdTable, arraysize(kRuleIdTable),
-                           kRangeTables, arraysize(kRangeTables));
+  // The following two arrays contain sentinel elements but the packer doesn't
+  // expect them.  So pass the shinked ranges of the arrays.  Note that sentinel
+  // elements are not required at runtime.
+  packer.SetPosMatcherData(kRuleIdTable, arraysize(kRuleIdTable) - 1,
+                           kRangeTables, arraysize(kRangeTables) - 1);
   packer.SetLidGroupData(kLidGroup, arraysize(kLidGroup));
   packer.SetBoundaryData(kBoundaryData, arraysize(kBoundaryData));
   packer.SetSuffixTokens(kSuffixTokens, arraysize(kSuffixTokens));
diff --git a/src/dictionary/gen_pos_matcher_code.py b/src/dictionary/gen_pos_matcher_code.py
index 96c5643..5bc5375 100644
--- a/src/dictionary/gen_pos_matcher_code.py
+++ b/src/dictionary/gen_pos_matcher_code.py
@@ -70,6 +70,7 @@
         % { 'id': pos_matcher.GetId(rule_name),
             'rule_name': rule_name,
             'original_pattern': pos_matcher.GetOriginalPattern(rule_name) })
+  output.write('  static_cast<uint16>(0xFFFF),\n')
   output.write('};\n')
 
   # Generate arrays of ranges each of which will be an element of kRangeTable[].
@@ -91,9 +92,10 @@
   # Generate kRangeTable[].
   output.write(
       'const ::mozc::POSMatcher::Range *const kRangeTables[%d] = {\n'
-      % len(pos_matcher.GetRuleNameList()))
+      % (len(pos_matcher.GetRuleNameList()) + 1))
   for rule_name in pos_matcher.GetRuleNameList():
     output.write('  kRangeTable_%s,\n' % rule_name)
+  output.write('  NULL,\n')
   output.write('};\n')
 
 
@@ -113,8 +115,8 @@
       'class POSMatcher {\n'
       ' public:\n'
       '  struct Range {\n'
-      '    const uint16 lower;\n'
-      '    const uint16 upper;\n'
+      '    uint16 lower;\n'
+      '    uint16 upper;\n'
       '  };\n')
 
   # Helper function to generate Get<RuleName>Id() method from rule name and its
diff --git a/src/mozc_version_template.txt b/src/mozc_version_template.txt
index db1324f..36ca1a1 100644
--- a/src/mozc_version_template.txt
+++ b/src/mozc_version_template.txt
@@ -1,6 +1,6 @@
 MAJOR=2
 MINOR=16
-BUILD=1989
+BUILD=1990
 REVISION=102
 # NACL_DICTIONARY_VERSION is the target version of the system dictionary to be
 # downloaded by NaCl Mozc.