extensions/universalchardet/src/base/nsEscSM.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 #include "nsCodingStateMachine.h"
     7 static const uint32_t HZ_cls[ 256 / 8 ] = {
     8 PCK4BITS(1,0,0,0,0,0,0,0),  // 00 - 07 
     9 PCK4BITS(0,0,0,0,0,0,0,0),  // 08 - 0f 
    10 PCK4BITS(0,0,0,0,0,0,0,0),  // 10 - 17 
    11 PCK4BITS(0,0,0,1,0,0,0,0),  // 18 - 1f 
    12 PCK4BITS(0,0,0,0,0,0,0,0),  // 20 - 27 
    13 PCK4BITS(0,0,0,0,0,0,0,0),  // 28 - 2f 
    14 PCK4BITS(0,0,0,0,0,0,0,0),  // 30 - 37 
    15 PCK4BITS(0,0,0,0,0,0,0,0),  // 38 - 3f 
    16 PCK4BITS(0,0,0,0,0,0,0,0),  // 40 - 47 
    17 PCK4BITS(0,0,0,0,0,0,0,0),  // 48 - 4f 
    18 PCK4BITS(0,0,0,0,0,0,0,0),  // 50 - 57 
    19 PCK4BITS(0,0,0,0,0,0,0,0),  // 58 - 5f 
    20 PCK4BITS(0,0,0,0,0,0,0,0),  // 60 - 67 
    21 PCK4BITS(0,0,0,0,0,0,0,0),  // 68 - 6f 
    22 PCK4BITS(0,0,0,0,0,0,0,0),  // 70 - 77 
    23 PCK4BITS(0,0,0,4,0,5,2,0),  // 78 - 7f 
    24 PCK4BITS(1,1,1,1,1,1,1,1),  // 80 - 87 
    25 PCK4BITS(1,1,1,1,1,1,1,1),  // 88 - 8f 
    26 PCK4BITS(1,1,1,1,1,1,1,1),  // 90 - 97 
    27 PCK4BITS(1,1,1,1,1,1,1,1),  // 98 - 9f 
    28 PCK4BITS(1,1,1,1,1,1,1,1),  // a0 - a7 
    29 PCK4BITS(1,1,1,1,1,1,1,1),  // a8 - af 
    30 PCK4BITS(1,1,1,1,1,1,1,1),  // b0 - b7 
    31 PCK4BITS(1,1,1,1,1,1,1,1),  // b8 - bf 
    32 PCK4BITS(1,1,1,1,1,1,1,1),  // c0 - c7 
    33 PCK4BITS(1,1,1,1,1,1,1,1),  // c8 - cf 
    34 PCK4BITS(1,1,1,1,1,1,1,1),  // d0 - d7 
    35 PCK4BITS(1,1,1,1,1,1,1,1),  // d8 - df 
    36 PCK4BITS(1,1,1,1,1,1,1,1),  // e0 - e7 
    37 PCK4BITS(1,1,1,1,1,1,1,1),  // e8 - ef 
    38 PCK4BITS(1,1,1,1,1,1,1,1),  // f0 - f7 
    39 PCK4BITS(1,1,1,1,1,1,1,1)   // f8 - ff 
    40 };
    43 static const uint32_t HZ_st [ 6] = {
    44 PCK4BITS(eStart,eError,     3,eStart,eStart,eStart,eError,eError),//00-07 
    45 PCK4BITS(eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe),//08-0f 
    46 PCK4BITS(eItsMe,eItsMe,eError,eError,eStart,eStart,     4,eError),//10-17 
    47 PCK4BITS(     5,eError,     6,eError,     5,     5,     4,eError),//18-1f 
    48 PCK4BITS(     4,eError,     4,     4,     4,eError,     4,eError),//20-27 
    49 PCK4BITS(     4,eItsMe,eStart,eStart,eStart,eStart,eStart,eStart) //28-2f 
    50 };
    52 static const uint32_t HZCharLenTable[] = {0, 0, 0, 0, 0, 0};
    54 const SMModel HZSMModel = {
    55   {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, HZ_cls },
    56    6,
    57   {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, HZ_st },
    58   CHAR_LEN_TABLE(HZCharLenTable),
    59   "HZ-GB-2312",
    60 };
    63 static const uint32_t ISO2022CN_cls [ 256 / 8 ] = {
    64 PCK4BITS(2,0,0,0,0,0,0,0),  // 00 - 07 
    65 PCK4BITS(0,0,0,0,0,0,0,0),  // 08 - 0f 
    66 PCK4BITS(0,0,0,0,0,0,0,0),  // 10 - 17 
    67 PCK4BITS(0,0,0,1,0,0,0,0),  // 18 - 1f 
    68 PCK4BITS(0,0,0,0,0,0,0,0),  // 20 - 27 
    69 PCK4BITS(0,3,0,0,0,0,0,0),  // 28 - 2f 
    70 PCK4BITS(0,0,0,0,0,0,0,0),  // 30 - 37 
    71 PCK4BITS(0,0,0,0,0,0,0,0),  // 38 - 3f 
    72 PCK4BITS(0,0,0,4,0,0,0,0),  // 40 - 47 
    73 PCK4BITS(0,0,0,0,0,0,0,0),  // 48 - 4f 
    74 PCK4BITS(0,0,0,0,0,0,0,0),  // 50 - 57 
    75 PCK4BITS(0,0,0,0,0,0,0,0),  // 58 - 5f 
    76 PCK4BITS(0,0,0,0,0,0,0,0),  // 60 - 67 
    77 PCK4BITS(0,0,0,0,0,0,0,0),  // 68 - 6f 
    78 PCK4BITS(0,0,0,0,0,0,0,0),  // 70 - 77 
    79 PCK4BITS(0,0,0,0,0,0,0,0),  // 78 - 7f 
    80 PCK4BITS(2,2,2,2,2,2,2,2),  // 80 - 87 
    81 PCK4BITS(2,2,2,2,2,2,2,2),  // 88 - 8f 
    82 PCK4BITS(2,2,2,2,2,2,2,2),  // 90 - 97 
    83 PCK4BITS(2,2,2,2,2,2,2,2),  // 98 - 9f 
    84 PCK4BITS(2,2,2,2,2,2,2,2),  // a0 - a7 
    85 PCK4BITS(2,2,2,2,2,2,2,2),  // a8 - af 
    86 PCK4BITS(2,2,2,2,2,2,2,2),  // b0 - b7 
    87 PCK4BITS(2,2,2,2,2,2,2,2),  // b8 - bf 
    88 PCK4BITS(2,2,2,2,2,2,2,2),  // c0 - c7 
    89 PCK4BITS(2,2,2,2,2,2,2,2),  // c8 - cf 
    90 PCK4BITS(2,2,2,2,2,2,2,2),  // d0 - d7 
    91 PCK4BITS(2,2,2,2,2,2,2,2),  // d8 - df 
    92 PCK4BITS(2,2,2,2,2,2,2,2),  // e0 - e7 
    93 PCK4BITS(2,2,2,2,2,2,2,2),  // e8 - ef 
    94 PCK4BITS(2,2,2,2,2,2,2,2),  // f0 - f7 
    95 PCK4BITS(2,2,2,2,2,2,2,2)   // f8 - ff 
    96 };
    99 static const uint32_t ISO2022CN_st [ 8] = {
   100 PCK4BITS(eStart,     3,eError,eStart,eStart,eStart,eStart,eStart),//00-07 
   101 PCK4BITS(eStart,eError,eError,eError,eError,eError,eError,eError),//08-0f 
   102 PCK4BITS(eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe),//10-17 
   103 PCK4BITS(eItsMe,eItsMe,eItsMe,eError,eError,eError,     4,eError),//18-1f 
   104 PCK4BITS(eError,eError,eError,eItsMe,eError,eError,eError,eError),//20-27 
   105 PCK4BITS(     5,     6,eError,eError,eError,eError,eError,eError),//28-2f 
   106 PCK4BITS(eError,eError,eError,eItsMe,eError,eError,eError,eError),//30-37 
   107 PCK4BITS(eError,eError,eError,eError,eError,eItsMe,eError,eStart) //38-3f 
   108 };
   110 static const uint32_t ISO2022CNCharLenTable[] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
   112 const SMModel ISO2022CNSMModel = {
   113   {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, ISO2022CN_cls },
   114   9,
   115   {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, ISO2022CN_st },
   116   CHAR_LEN_TABLE(ISO2022CNCharLenTable),
   117   "ISO-2022-CN",
   118 };
   120 static const uint32_t ISO2022JP_cls [ 256 / 8 ] = {
   121 PCK4BITS(2,0,0,0,0,0,0,0),  // 00 - 07 
   122 PCK4BITS(0,0,0,0,0,0,2,2),  // 08 - 0f 
   123 PCK4BITS(0,0,0,0,0,0,0,0),  // 10 - 17 
   124 PCK4BITS(0,0,0,1,0,0,0,0),  // 18 - 1f 
   125 PCK4BITS(0,0,0,0,7,0,0,0),  // 20 - 27 
   126 PCK4BITS(3,0,0,0,0,0,0,0),  // 28 - 2f 
   127 PCK4BITS(0,0,0,0,0,0,0,0),  // 30 - 37 
   128 PCK4BITS(0,0,0,0,0,0,0,0),  // 38 - 3f 
   129 PCK4BITS(6,0,4,0,8,0,0,0),  // 40 - 47 
   130 PCK4BITS(0,9,5,0,0,0,0,0),  // 48 - 4f 
   131 PCK4BITS(0,0,0,0,0,0,0,0),  // 50 - 57 
   132 PCK4BITS(0,0,0,0,0,0,0,0),  // 58 - 5f 
   133 PCK4BITS(0,0,0,0,0,0,0,0),  // 60 - 67 
   134 PCK4BITS(0,0,0,0,0,0,0,0),  // 68 - 6f 
   135 PCK4BITS(0,0,0,0,0,0,0,0),  // 70 - 77 
   136 PCK4BITS(0,0,0,0,0,0,0,0),  // 78 - 7f 
   137 PCK4BITS(2,2,2,2,2,2,2,2),  // 80 - 87 
   138 PCK4BITS(2,2,2,2,2,2,2,2),  // 88 - 8f 
   139 PCK4BITS(2,2,2,2,2,2,2,2),  // 90 - 97 
   140 PCK4BITS(2,2,2,2,2,2,2,2),  // 98 - 9f 
   141 PCK4BITS(2,2,2,2,2,2,2,2),  // a0 - a7 
   142 PCK4BITS(2,2,2,2,2,2,2,2),  // a8 - af 
   143 PCK4BITS(2,2,2,2,2,2,2,2),  // b0 - b7 
   144 PCK4BITS(2,2,2,2,2,2,2,2),  // b8 - bf 
   145 PCK4BITS(2,2,2,2,2,2,2,2),  // c0 - c7 
   146 PCK4BITS(2,2,2,2,2,2,2,2),  // c8 - cf 
   147 PCK4BITS(2,2,2,2,2,2,2,2),  // d0 - d7 
   148 PCK4BITS(2,2,2,2,2,2,2,2),  // d8 - df 
   149 PCK4BITS(2,2,2,2,2,2,2,2),  // e0 - e7 
   150 PCK4BITS(2,2,2,2,2,2,2,2),  // e8 - ef 
   151 PCK4BITS(2,2,2,2,2,2,2,2),  // f0 - f7 
   152 PCK4BITS(2,2,2,2,2,2,2,2)   // f8 - ff 
   153 };
   156 static const uint32_t ISO2022JP_st [ 9] = {
   157 PCK4BITS(eStart,     3,eError,eStart,eStart,eStart,eStart,eStart),//00-07 
   158 PCK4BITS(eStart,eStart,eError,eError,eError,eError,eError,eError),//08-0f 
   159 PCK4BITS(eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe),//10-17 
   160 PCK4BITS(eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eError,eError),//18-1f 
   161 PCK4BITS(eError,     5,eError,eError,eError,     4,eError,eError),//20-27 
   162 PCK4BITS(eError,eError,eError,     6,eItsMe,eError,eItsMe,eError),//28-2f 
   163 PCK4BITS(eError,eError,eError,eError,eError,eError,eItsMe,eItsMe),//30-37 
   164 PCK4BITS(eError,eError,eError,eItsMe,eError,eError,eError,eError),//38-3f 
   165 PCK4BITS(eError,eError,eError,eError,eItsMe,eError,eStart,eStart) //40-47 
   166 };
   168 static const uint32_t ISO2022JPCharLenTable[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
   170 const SMModel ISO2022JPSMModel = {
   171   {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, ISO2022JP_cls },
   172   10,
   173   {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, ISO2022JP_st },
   174   CHAR_LEN_TABLE(ISO2022JPCharLenTable),
   175   "ISO-2022-JP",
   176 };
   178 static const uint32_t ISO2022KR_cls [ 256 / 8 ] = {
   179 PCK4BITS(2,0,0,0,0,0,0,0),  // 00 - 07 
   180 PCK4BITS(0,0,0,0,0,0,0,0),  // 08 - 0f 
   181 PCK4BITS(0,0,0,0,0,0,0,0),  // 10 - 17 
   182 PCK4BITS(0,0,0,1,0,0,0,0),  // 18 - 1f 
   183 PCK4BITS(0,0,0,0,3,0,0,0),  // 20 - 27 
   184 PCK4BITS(0,4,0,0,0,0,0,0),  // 28 - 2f 
   185 PCK4BITS(0,0,0,0,0,0,0,0),  // 30 - 37 
   186 PCK4BITS(0,0,0,0,0,0,0,0),  // 38 - 3f 
   187 PCK4BITS(0,0,0,5,0,0,0,0),  // 40 - 47 
   188 PCK4BITS(0,0,0,0,0,0,0,0),  // 48 - 4f 
   189 PCK4BITS(0,0,0,0,0,0,0,0),  // 50 - 57 
   190 PCK4BITS(0,0,0,0,0,0,0,0),  // 58 - 5f 
   191 PCK4BITS(0,0,0,0,0,0,0,0),  // 60 - 67 
   192 PCK4BITS(0,0,0,0,0,0,0,0),  // 68 - 6f 
   193 PCK4BITS(0,0,0,0,0,0,0,0),  // 70 - 77 
   194 PCK4BITS(0,0,0,0,0,0,0,0),  // 78 - 7f 
   195 PCK4BITS(2,2,2,2,2,2,2,2),  // 80 - 87 
   196 PCK4BITS(2,2,2,2,2,2,2,2),  // 88 - 8f 
   197 PCK4BITS(2,2,2,2,2,2,2,2),  // 90 - 97 
   198 PCK4BITS(2,2,2,2,2,2,2,2),  // 98 - 9f 
   199 PCK4BITS(2,2,2,2,2,2,2,2),  // a0 - a7 
   200 PCK4BITS(2,2,2,2,2,2,2,2),  // a8 - af 
   201 PCK4BITS(2,2,2,2,2,2,2,2),  // b0 - b7 
   202 PCK4BITS(2,2,2,2,2,2,2,2),  // b8 - bf 
   203 PCK4BITS(2,2,2,2,2,2,2,2),  // c0 - c7 
   204 PCK4BITS(2,2,2,2,2,2,2,2),  // c8 - cf 
   205 PCK4BITS(2,2,2,2,2,2,2,2),  // d0 - d7 
   206 PCK4BITS(2,2,2,2,2,2,2,2),  // d8 - df 
   207 PCK4BITS(2,2,2,2,2,2,2,2),  // e0 - e7 
   208 PCK4BITS(2,2,2,2,2,2,2,2),  // e8 - ef 
   209 PCK4BITS(2,2,2,2,2,2,2,2),  // f0 - f7 
   210 PCK4BITS(2,2,2,2,2,2,2,2)   // f8 - ff 
   211 };
   214 static const uint32_t ISO2022KR_st [ 5] = {
   215 PCK4BITS(eStart,     3,eError,eStart,eStart,eStart,eError,eError),//00-07 
   216 PCK4BITS(eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe),//08-0f 
   217 PCK4BITS(eItsMe,eItsMe,eError,eError,eError,     4,eError,eError),//10-17 
   218 PCK4BITS(eError,eError,eError,eError,     5,eError,eError,eError),//18-1f 
   219 PCK4BITS(eError,eError,eError,eItsMe,eStart,eStart,eStart,eStart) //20-27 
   220 };
   222 static const uint32_t ISO2022KRCharLenTable[] = {0, 0, 0, 0, 0, 0};
   224 const SMModel ISO2022KRSMModel = {
   225   {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, ISO2022KR_cls },
   226    6,
   227   {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, ISO2022KR_st },
   228   CHAR_LEN_TABLE(ISO2022KRCharLenTable),
   229   "ISO-2022-KR",
   230 };

mercurial