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