@port-labs/jq-node-bindings 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/binding.gyp +3 -3
- package/configure +8 -6
- package/deps/jq/.travis.yml +184 -35
- package/deps/jq/AUTHORS +31 -30
- package/deps/jq/COPYING +2 -2
- package/deps/jq/KEYS +8 -0
- package/deps/jq/Makefile.am +85 -70
- package/deps/jq/NEWS +5 -4
- package/deps/jq/README.md +18 -9
- package/deps/jq/appveyor.yml +53 -0
- package/deps/jq/compile-ios.sh +5 -5
- package/deps/jq/config/m4/check-math-func.m4 +7 -2
- package/deps/jq/configure.ac +130 -68
- package/deps/jq/docs/Rakefile +14 -135
- package/deps/jq/docs/Rakefile.manual +49 -0
- package/deps/jq/docs/Rakefile.website +76 -0
- package/deps/jq/docs/content/2.download/default.yml +115 -39
- package/deps/jq/docs/content/3.manual/manual.yml +641 -231
- package/deps/jq/docs/content/3.manual/v1.3/manual.yml +130 -130
- package/deps/jq/docs/content/3.manual/v1.4/manual.yml +160 -160
- package/deps/jq/docs/content/3.manual/v1.5/manual.yml +2878 -0
- package/deps/jq/docs/content/3.manual/v1.6/manual.yml +3287 -0
- package/deps/jq/docs/content/index/index.yml +28 -6
- package/deps/jq/docs/public/.htaccess +2 -2
- package/deps/jq/docs/public/css/base.scss +141 -59
- package/deps/jq/docs/public/js/manual-search.js +52 -0
- package/deps/jq/docs/site.yml +1 -10
- package/deps/jq/docs/templates/default.liquid +10 -10
- package/deps/jq/docs/templates/index.liquid +45 -32
- package/deps/jq/docs/templates/manual.liquid +67 -90
- package/deps/jq/docs/templates/shared/_footer.liquid +10 -5
- package/deps/jq/docs/templates/shared/_head.liquid +17 -12
- package/deps/jq/docs/templates/shared/_navbar.liquid +27 -0
- package/deps/jq/jq.1.prebuilt +523 -139
- package/deps/jq/modules/oniguruma/AUTHORS +1 -0
- package/deps/jq/modules/oniguruma/CMakeLists.txt +86 -0
- package/deps/jq/modules/oniguruma/COPYING +28 -0
- package/deps/jq/modules/oniguruma/ChangeLog +0 -0
- package/deps/jq/modules/oniguruma/HISTORY +2138 -0
- package/deps/jq/modules/oniguruma/Makefile.am +33 -0
- package/deps/jq/modules/oniguruma/NEWS +0 -0
- package/deps/jq/modules/oniguruma/README +189 -0
- package/deps/jq/modules/oniguruma/README.ja +195 -0
- package/deps/jq/modules/oniguruma/README.md +203 -0
- package/deps/jq/modules/oniguruma/cmake/dist.cmake +321 -0
- package/deps/jq/modules/oniguruma/compile +348 -0
- package/deps/jq/modules/oniguruma/config.guess +1754 -0
- package/deps/jq/modules/oniguruma/config.sub +1890 -0
- package/deps/jq/modules/oniguruma/configure.ac +87 -0
- package/deps/jq/modules/oniguruma/contributed/libfuzzer-onig.cpp +31 -0
- package/deps/jq/modules/oniguruma/depcomp +791 -0
- package/deps/jq/modules/oniguruma/dist.info +10 -0
- package/deps/jq/modules/oniguruma/doc/API +660 -0
- package/deps/jq/modules/oniguruma/doc/API.ja +667 -0
- package/deps/jq/modules/oniguruma/doc/FAQ +12 -0
- package/deps/jq/modules/oniguruma/doc/FAQ.ja +22 -0
- package/deps/jq/modules/oniguruma/doc/RE +436 -0
- package/deps/jq/modules/oniguruma/doc/RE.ja +448 -0
- package/deps/jq/modules/oniguruma/doc/UNICODE_PROPERTIES +698 -0
- package/deps/jq/modules/oniguruma/index.html +181 -0
- package/deps/jq/modules/oniguruma/index_ja.html +184 -0
- package/deps/jq/modules/oniguruma/install-sh +541 -0
- package/deps/jq/modules/oniguruma/m4/.whatever +0 -0
- package/deps/jq/modules/oniguruma/make_win32.bat +3 -0
- package/deps/jq/modules/oniguruma/make_win64.bat +3 -0
- package/deps/jq/modules/oniguruma/missing +215 -0
- package/deps/jq/modules/oniguruma/onig-config.in +78 -0
- package/deps/jq/modules/oniguruma/oniguruma.pc.cmake.in +13 -0
- package/deps/jq/modules/oniguruma/oniguruma.pc.in +14 -0
- package/deps/jq/modules/oniguruma/sample/CMakeLists.txt +28 -0
- package/deps/jq/modules/oniguruma/sample/Makefile.am +34 -0
- package/deps/jq/modules/oniguruma/sample/bug_fix.c +131 -0
- package/deps/jq/modules/oniguruma/sample/crnl.c +127 -0
- package/deps/jq/modules/oniguruma/sample/encode.c +308 -0
- package/deps/jq/modules/oniguruma/sample/listcap.c +110 -0
- package/deps/jq/modules/oniguruma/sample/names.c +75 -0
- package/deps/jq/modules/oniguruma/sample/posix.c +96 -0
- package/deps/jq/modules/oniguruma/sample/scan.c +88 -0
- package/deps/jq/modules/oniguruma/sample/simple.c +59 -0
- package/deps/jq/modules/oniguruma/sample/sql.c +76 -0
- package/deps/jq/modules/oniguruma/sample/syntax.c +76 -0
- package/deps/jq/modules/oniguruma/sample/user_property.c +87 -0
- package/deps/jq/modules/oniguruma/src/Makefile.am +58 -0
- package/deps/jq/modules/oniguruma/src/Makefile.windows +183 -0
- package/deps/jq/modules/oniguruma/src/ascii.c +61 -0
- package/deps/jq/modules/oniguruma/src/big5.c +190 -0
- package/deps/jq/modules/oniguruma/src/config.h.cmake.in +71 -0
- package/deps/jq/modules/oniguruma/src/config.h.win32 +84 -0
- package/deps/jq/modules/oniguruma/src/config.h.win64 +84 -0
- package/deps/jq/modules/oniguruma/src/cp1251.c +203 -0
- package/deps/jq/modules/oniguruma/src/euc_jp.c +310 -0
- package/deps/jq/modules/oniguruma/src/euc_jp_prop.c +158 -0
- package/deps/jq/modules/oniguruma/src/euc_jp_prop.gperf +27 -0
- package/deps/jq/modules/oniguruma/src/euc_kr.c +188 -0
- package/deps/jq/modules/oniguruma/src/euc_tw.c +171 -0
- package/deps/jq/modules/oniguruma/src/gb18030.c +538 -0
- package/deps/jq/modules/oniguruma/src/gperf_fold_key_conv.py +67 -0
- package/deps/jq/modules/oniguruma/src/gperf_unfold_key_conv.py +55 -0
- package/deps/jq/modules/oniguruma/src/iso8859_1.c +275 -0
- package/deps/jq/modules/oniguruma/src/iso8859_10.c +242 -0
- package/deps/jq/modules/oniguruma/src/iso8859_11.c +99 -0
- package/deps/jq/modules/oniguruma/src/iso8859_13.c +231 -0
- package/deps/jq/modules/oniguruma/src/iso8859_14.c +244 -0
- package/deps/jq/modules/oniguruma/src/iso8859_15.c +238 -0
- package/deps/jq/modules/oniguruma/src/iso8859_16.c +240 -0
- package/deps/jq/modules/oniguruma/src/iso8859_2.c +238 -0
- package/deps/jq/modules/oniguruma/src/iso8859_3.c +238 -0
- package/deps/jq/modules/oniguruma/src/iso8859_4.c +240 -0
- package/deps/jq/modules/oniguruma/src/iso8859_5.c +229 -0
- package/deps/jq/modules/oniguruma/src/iso8859_6.c +99 -0
- package/deps/jq/modules/oniguruma/src/iso8859_7.c +225 -0
- package/deps/jq/modules/oniguruma/src/iso8859_8.c +99 -0
- package/deps/jq/modules/oniguruma/src/iso8859_9.c +231 -0
- package/deps/jq/modules/oniguruma/src/koi8.c +253 -0
- package/deps/jq/modules/oniguruma/src/koi8_r.c +215 -0
- package/deps/jq/modules/oniguruma/src/make_unicode_fold.sh +22 -0
- package/deps/jq/modules/oniguruma/src/make_unicode_fold_data.py +306 -0
- package/deps/jq/modules/oniguruma/src/make_unicode_property.sh +18 -0
- package/deps/jq/modules/oniguruma/src/make_unicode_property_data.py +545 -0
- package/deps/jq/modules/oniguruma/src/mktable.c +1184 -0
- package/deps/jq/modules/oniguruma/src/onig_init.c +45 -0
- package/deps/jq/modules/oniguruma/src/oniggnu.h +85 -0
- package/deps/jq/modules/oniguruma/src/onigposix.h +169 -0
- package/deps/jq/modules/oniguruma/src/oniguruma.h +841 -0
- package/deps/jq/modules/oniguruma/src/regcomp.c +6300 -0
- package/deps/jq/modules/oniguruma/src/regenc.c +917 -0
- package/deps/jq/modules/oniguruma/src/regenc.h +243 -0
- package/deps/jq/modules/oniguruma/src/regerror.c +393 -0
- package/deps/jq/modules/oniguruma/src/regexec.c +3856 -0
- package/deps/jq/modules/oniguruma/src/regext.c +202 -0
- package/deps/jq/modules/oniguruma/src/reggnu.c +147 -0
- package/deps/jq/modules/oniguruma/src/regint.h +779 -0
- package/deps/jq/modules/oniguruma/src/regparse.c +5403 -0
- package/deps/jq/modules/oniguruma/src/regparse.h +351 -0
- package/deps/jq/modules/oniguruma/src/regposerr.c +105 -0
- package/deps/jq/modules/oniguruma/src/regposix.c +306 -0
- package/deps/jq/modules/oniguruma/src/regsyntax.c +315 -0
- package/deps/jq/modules/oniguruma/src/regtrav.c +76 -0
- package/deps/jq/modules/oniguruma/src/regversion.c +57 -0
- package/deps/jq/modules/oniguruma/src/sjis.c +341 -0
- package/deps/jq/modules/oniguruma/src/sjis_prop.c +158 -0
- package/deps/jq/modules/oniguruma/src/sjis_prop.gperf +27 -0
- package/deps/jq/modules/oniguruma/src/st.c +589 -0
- package/deps/jq/modules/oniguruma/src/st.h +68 -0
- package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_fold1_key.c +2250 -0
- package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_fold2_key.c +203 -0
- package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_fold3_key.c +113 -0
- package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_fold_data.c +1225 -0
- package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_property_data.c +24742 -0
- package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_property_data_posix.c +4846 -0
- package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_unfold_key.c +2571 -0
- package/deps/jq/modules/oniguruma/src/unicode.c +664 -0
- package/deps/jq/modules/oniguruma/src/unicode_fold1_key.c +2548 -0
- package/deps/jq/modules/oniguruma/src/unicode_fold2_key.c +203 -0
- package/deps/jq/modules/oniguruma/src/unicode_fold3_key.c +113 -0
- package/deps/jq/modules/oniguruma/src/unicode_fold_data.c +1366 -0
- package/deps/jq/modules/oniguruma/src/unicode_property_data.c +25306 -0
- package/deps/jq/modules/oniguruma/src/unicode_property_data_posix.c +4940 -0
- package/deps/jq/modules/oniguruma/src/unicode_unfold_key.c +2854 -0
- package/deps/jq/modules/oniguruma/src/utf16_be.c +235 -0
- package/deps/jq/modules/oniguruma/src/utf16_le.c +245 -0
- package/deps/jq/modules/oniguruma/src/utf32_be.c +194 -0
- package/deps/jq/modules/oniguruma/src/utf32_le.c +194 -0
- package/deps/jq/modules/oniguruma/src/utf8.c +335 -0
- package/deps/jq/modules/oniguruma/test/Makefile.am +28 -0
- package/deps/jq/modules/oniguruma/test/testc.c +874 -0
- package/deps/jq/modules/oniguruma/test/testu.c +916 -0
- package/deps/jq/modules/oniguruma/test-driver +153 -0
- package/deps/jq/modules/oniguruma/windows/testc.c +869 -0
- package/deps/jq/scripts/crosscompile +2 -1
- package/deps/jq/scripts/gen_utf8_tables.py +2 -3
- package/deps/jq/scripts/update-website +29 -0
- package/deps/jq/scripts/version +7 -2
- package/deps/jq/sig/jq-release.key +41 -0
- package/deps/jq/sig/v1.3/jq-linux-x86.asc +17 -0
- package/deps/jq/sig/v1.3/jq-linux-x86_64.asc +17 -0
- package/deps/jq/sig/v1.3/jq-osx-x86.asc +17 -0
- package/deps/jq/sig/v1.3/jq-osx-x86_64.asc +17 -0
- package/deps/jq/sig/v1.3/jq-win32.exe.asc +17 -0
- package/deps/jq/sig/v1.3/jq-win64.exe.asc +17 -0
- package/deps/jq/sig/v1.3/sha256sum.txt +6 -0
- package/deps/jq/sig/v1.4/jq-linux-x86.asc +17 -0
- package/deps/jq/sig/v1.4/jq-linux-x86_64.asc +17 -0
- package/deps/jq/sig/v1.4/jq-osx-x86.asc +17 -0
- package/deps/jq/sig/v1.4/jq-osx-x86_64.asc +17 -0
- package/deps/jq/sig/v1.4/jq-solaris11-32.asc +17 -0
- package/deps/jq/sig/v1.4/jq-solaris11-64.asc +17 -0
- package/deps/jq/sig/v1.4/jq-win32.exe.asc +17 -0
- package/deps/jq/sig/v1.4/jq-win64.exe.asc +17 -0
- package/deps/jq/sig/v1.4/sha256sum.txt +8 -0
- package/deps/jq/sig/v1.5/jq-linux32-no-oniguruma.asc +17 -0
- package/deps/jq/sig/v1.5/jq-linux32.asc +17 -0
- package/deps/jq/sig/v1.5/jq-linux64.asc +17 -0
- package/deps/jq/sig/v1.5/jq-osx-amd64.asc +17 -0
- package/deps/jq/sig/v1.5/jq-win32.exe.asc +17 -0
- package/deps/jq/sig/v1.5/jq-win64.exe.asc +17 -0
- package/deps/jq/sig/v1.5/sha256sum.txt +5 -0
- package/deps/jq/sig/v1.5rc1/jq-linux-x86_64-static.asc +17 -0
- package/deps/jq/sig/v1.5rc1/jq-win32.exe.asc +17 -0
- package/deps/jq/sig/v1.5rc1/jq-win64.exe.asc +17 -0
- package/deps/jq/sig/v1.5rc1/sha256sum.txt +3 -0
- package/deps/jq/sig/v1.5rc2/jq-linux-x86.asc +17 -0
- package/deps/jq/sig/v1.5rc2/jq-linux-x86_64.asc +17 -0
- package/deps/jq/sig/v1.5rc2/jq-osx-x86_64.asc +17 -0
- package/deps/jq/sig/v1.5rc2/jq-win32.exe.asc +17 -0
- package/deps/jq/sig/v1.5rc2/jq-win64.exe.asc +17 -0
- package/deps/jq/sig/v1.5rc2/sha256sum.txt +5 -0
- package/deps/jq/sig/v1.6/jq-linux32.asc +16 -0
- package/deps/jq/sig/v1.6/jq-linux64.asc +16 -0
- package/deps/jq/sig/v1.6/jq-osx-amd64.asc +16 -0
- package/deps/jq/sig/v1.6/jq-win32.exe.asc +16 -0
- package/deps/jq/sig/v1.6/jq-win64.exe.asc +16 -0
- package/deps/jq/sig/v1.6/sha256sum.txt +5 -0
- package/deps/jq/{builtin.c → src/builtin.c} +449 -344
- package/deps/jq/{builtin.h → src/builtin.h} +0 -0
- package/deps/jq/src/builtin.jq +311 -0
- package/deps/jq/{bytecode.c → src/bytecode.c} +0 -0
- package/deps/jq/{bytecode.h → src/bytecode.h} +0 -0
- package/deps/jq/{compile.c → src/compile.c} +213 -37
- package/deps/jq/{compile.h → src/compile.h} +7 -2
- package/deps/jq/{exec_stack.h → src/exec_stack.h} +0 -0
- package/deps/jq/{execute.c → src/execute.c} +127 -24
- package/deps/jq/{inject_errors.c → src/inject_errors.c} +0 -0
- package/deps/jq/{jq.h → src/jq.h} +13 -2
- package/deps/jq/{jq_parser.h → src/jq_parser.h} +0 -0
- package/deps/jq/{jq_test.c → src/jq_test.c} +1 -1
- package/deps/jq/{jv.c → src/jv.c} +24 -5
- package/deps/jq/{jv.h → src/jv.h} +46 -11
- package/deps/jq/{jv_alloc.c → src/jv_alloc.c} +0 -0
- package/deps/jq/{jv_alloc.h → src/jv_alloc.h} +0 -0
- package/deps/jq/{jv_aux.c → src/jv_aux.c} +38 -14
- package/deps/jq/{jv_dtoa.c → src/jv_dtoa.c} +4 -5
- package/deps/jq/{jv_dtoa.h → src/jv_dtoa.h} +0 -0
- package/deps/jq/src/jv_file.c +81 -0
- package/deps/jq/{jv_parse.c → src/jv_parse.c} +8 -2
- package/deps/jq/{jv_print.c → src/jv_print.c} +80 -27
- package/deps/jq/{jv_unicode.c → src/jv_unicode.c} +28 -4
- package/deps/jq/{jv_unicode.h → src/jv_unicode.h} +1 -0
- package/deps/jq/{jv_utf8_tables.h → src/jv_utf8_tables.h} +0 -0
- package/deps/jq/{lexer.c → src/lexer.c} +317 -292
- package/deps/jq/{lexer.h → src/lexer.h} +16 -12
- package/deps/jq/{lexer.l → src/lexer.l} +5 -4
- package/deps/jq/src/libm.h +291 -0
- package/deps/jq/{linker.c → src/linker.c} +5 -3
- package/deps/jq/{linker.h → src/linker.h} +0 -0
- package/deps/jq/{locfile.c → src/locfile.c} +1 -1
- package/deps/jq/{locfile.h → src/locfile.h} +0 -0
- package/deps/jq/{main.c → src/main.c} +202 -100
- package/deps/jq/{opcode_list.h → src/opcode_list.h} +4 -0
- package/deps/jq/{parser.c → src/parser.c} +1149 -1069
- package/deps/jq/{parser.h → src/parser.h} +28 -24
- package/deps/jq/{parser.y → src/parser.y} +108 -52
- package/deps/jq/{util.c → src/util.c} +12 -9
- package/deps/jq/{util.h → src/util.h} +0 -0
- package/deps/jq/tests/base64.test +35 -0
- package/deps/jq/tests/base64test +5 -0
- package/deps/jq/tests/jq-f-test.sh +4 -0
- package/deps/jq/tests/jq.test +305 -21
- package/deps/jq/tests/jqtest +1 -1
- package/deps/jq/tests/mantest +1 -1
- package/deps/jq/tests/onig.test +13 -0
- package/deps/jq/tests/onigtest +1 -1
- package/deps/jq/tests/optional.test +20 -0
- package/deps/jq/tests/optionaltest +5 -0
- package/deps/jq/tests/setup +7 -1
- package/deps/jq/tests/shtest +133 -29
- package/deps/jq/tests/utf8-truncate.jq +3 -0
- package/deps/jq/tests/utf8test +10 -0
- package/lib/index.js +7 -1
- package/package.json +3 -3
- package/test/santiy.test.js +24 -0
- package/deps/jq/docs/default_manpage.md +0 -22
- package/deps/jq/docs/public/bootstrap/css/bootstrap-responsive.css +0 -1058
- package/deps/jq/docs/public/bootstrap/css/bootstrap-responsive.min.css +0 -9
- package/deps/jq/docs/public/bootstrap/css/bootstrap.css +0 -5224
- package/deps/jq/docs/public/bootstrap/css/bootstrap.min.css +0 -9
- package/deps/jq/docs/public/bootstrap/img/glyphicons-halflings-white.png +0 -0
- package/deps/jq/docs/public/bootstrap/img/glyphicons-halflings.png +0 -0
- package/deps/jq/docs/public/bootstrap/js/bootstrap.js +0 -2027
- package/deps/jq/docs/public/bootstrap/js/bootstrap.min.js +0 -6
- package/deps/jq/docs/templates/shared/_header.liquid +0 -26
- package/deps/jq/jq.1.default +0 -39
- package/deps/jq/jv_file.c +0 -49
- package/deps/jq/libm.h +0 -160
- package/deps/jq/setup.sh +0 -33
- package/reports/jest-port-api.xml +0 -35
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**********************************************************************
|
|
2
|
+
euc_tw.c - Oniguruma (regular expression library)
|
|
3
|
+
**********************************************************************/
|
|
4
|
+
/*-
|
|
5
|
+
* Copyright (c) 2002-2016 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
|
|
6
|
+
* All rights reserved.
|
|
7
|
+
*
|
|
8
|
+
* Redistribution and use in source and binary forms, with or without
|
|
9
|
+
* modification, are permitted provided that the following conditions
|
|
10
|
+
* are met:
|
|
11
|
+
* 1. Redistributions of source code must retain the above copyright
|
|
12
|
+
* notice, this list of conditions and the following disclaimer.
|
|
13
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
|
14
|
+
* notice, this list of conditions and the following disclaimer in the
|
|
15
|
+
* documentation and/or other materials provided with the distribution.
|
|
16
|
+
*
|
|
17
|
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
18
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
19
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
20
|
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
21
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
22
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
23
|
+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
24
|
+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
25
|
+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
26
|
+
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
27
|
+
* SUCH DAMAGE.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
#include "regenc.h"
|
|
31
|
+
|
|
32
|
+
static const int EncLen_EUCTW[] = {
|
|
33
|
+
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
34
|
+
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
35
|
+
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
36
|
+
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
37
|
+
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
38
|
+
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
39
|
+
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
40
|
+
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
41
|
+
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 1,
|
|
42
|
+
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
43
|
+
1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
|
44
|
+
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
|
45
|
+
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
|
46
|
+
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
|
47
|
+
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
|
48
|
+
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
static int
|
|
52
|
+
euctw_mbc_enc_len(const UChar* p)
|
|
53
|
+
{
|
|
54
|
+
return EncLen_EUCTW[*p];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static int
|
|
58
|
+
is_valid_mbc_string(const UChar* p, const UChar* end)
|
|
59
|
+
{
|
|
60
|
+
while (p < end) {
|
|
61
|
+
if (*p < 0x80) {
|
|
62
|
+
p++;
|
|
63
|
+
}
|
|
64
|
+
else if (*p < 0xa1) {
|
|
65
|
+
if (*p == 0x8e) {
|
|
66
|
+
p++;
|
|
67
|
+
if (p >= end) return FALSE;
|
|
68
|
+
if (*p < 0xa1 || *p > 0xb0) return FALSE;
|
|
69
|
+
p++;
|
|
70
|
+
if (p >= end) return FALSE;
|
|
71
|
+
if (*p < 0xa1 || *p == 0xff)
|
|
72
|
+
return FALSE;
|
|
73
|
+
p++;
|
|
74
|
+
if (p >= end) return FALSE;
|
|
75
|
+
if (*p < 0xa1 || *p == 0xff)
|
|
76
|
+
return FALSE;
|
|
77
|
+
p++;
|
|
78
|
+
}
|
|
79
|
+
else
|
|
80
|
+
return FALSE;
|
|
81
|
+
}
|
|
82
|
+
else if (*p < 0xff) {
|
|
83
|
+
p++;
|
|
84
|
+
if (p >= end) return FALSE;
|
|
85
|
+
if (*p < 0xa1 || *p == 0xff)
|
|
86
|
+
return FALSE;
|
|
87
|
+
p++;
|
|
88
|
+
}
|
|
89
|
+
else
|
|
90
|
+
return FALSE;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return TRUE;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
static OnigCodePoint
|
|
97
|
+
euctw_mbc_to_code(const UChar* p, const UChar* end)
|
|
98
|
+
{
|
|
99
|
+
return onigenc_mbn_mbc_to_code(ONIG_ENCODING_EUC_TW, p, end);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
static int
|
|
103
|
+
euctw_code_to_mbc(OnigCodePoint code, UChar *buf)
|
|
104
|
+
{
|
|
105
|
+
return onigenc_mb4_code_to_mbc(ONIG_ENCODING_EUC_TW, code, buf);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
static int
|
|
109
|
+
euctw_mbc_case_fold(OnigCaseFoldType flag, const UChar** pp, const UChar* end,
|
|
110
|
+
UChar* lower)
|
|
111
|
+
{
|
|
112
|
+
return onigenc_mbn_mbc_case_fold(ONIG_ENCODING_EUC_TW, flag,
|
|
113
|
+
pp, end, lower);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
static int
|
|
117
|
+
euctw_is_code_ctype(OnigCodePoint code, unsigned int ctype)
|
|
118
|
+
{
|
|
119
|
+
return onigenc_mb4_is_code_ctype(ONIG_ENCODING_EUC_TW, code, ctype);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
#define euctw_islead(c) ((UChar )((c) - 0xa1) > 0xfe - 0xa1)
|
|
123
|
+
|
|
124
|
+
static UChar*
|
|
125
|
+
euctw_left_adjust_char_head(const UChar* start, const UChar* s)
|
|
126
|
+
{
|
|
127
|
+
/* Assumed in this encoding,
|
|
128
|
+
mb-trail bytes don't mix with single bytes.
|
|
129
|
+
*/
|
|
130
|
+
const UChar *p;
|
|
131
|
+
int len;
|
|
132
|
+
|
|
133
|
+
if (s <= start) return (UChar* )s;
|
|
134
|
+
p = s;
|
|
135
|
+
|
|
136
|
+
while (!euctw_islead(*p) && p > start) p--;
|
|
137
|
+
len = enclen(ONIG_ENCODING_EUC_TW, p);
|
|
138
|
+
if (p + len > s) return (UChar* )p;
|
|
139
|
+
p += len;
|
|
140
|
+
return (UChar* )(p + ((s - p) & ~1));
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
static int
|
|
144
|
+
euctw_is_allowed_reverse_match(const UChar* s, const UChar* end ARG_UNUSED)
|
|
145
|
+
{
|
|
146
|
+
const UChar c = *s;
|
|
147
|
+
if (c <= 0x7e) return TRUE;
|
|
148
|
+
else return FALSE;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
OnigEncodingType OnigEncodingEUC_TW = {
|
|
152
|
+
euctw_mbc_enc_len,
|
|
153
|
+
"EUC-TW", /* name */
|
|
154
|
+
4, /* max enc length */
|
|
155
|
+
1, /* min enc length */
|
|
156
|
+
onigenc_is_mbc_newline_0x0a,
|
|
157
|
+
euctw_mbc_to_code,
|
|
158
|
+
onigenc_mb4_code_to_mbclen,
|
|
159
|
+
euctw_code_to_mbc,
|
|
160
|
+
euctw_mbc_case_fold,
|
|
161
|
+
onigenc_ascii_apply_all_case_fold,
|
|
162
|
+
onigenc_ascii_get_case_fold_codes_by_str,
|
|
163
|
+
onigenc_minimum_property_name_to_ctype,
|
|
164
|
+
euctw_is_code_ctype,
|
|
165
|
+
onigenc_not_support_get_ctype_code_range,
|
|
166
|
+
euctw_left_adjust_char_head,
|
|
167
|
+
euctw_is_allowed_reverse_match,
|
|
168
|
+
NULL, /* init */
|
|
169
|
+
NULL, /* is_initialized */
|
|
170
|
+
is_valid_mbc_string
|
|
171
|
+
};
|
|
@@ -0,0 +1,538 @@
|
|
|
1
|
+
/**********************************************************************
|
|
2
|
+
gb18030.c - Oniguruma (regular expression library)
|
|
3
|
+
**********************************************************************/
|
|
4
|
+
/*-
|
|
5
|
+
* Copyright (c) 2005-2016 KUBO Takehiro <kubo AT jiubao DOT org>
|
|
6
|
+
* K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
|
|
7
|
+
* All rights reserved.
|
|
8
|
+
*
|
|
9
|
+
* Redistribution and use in source and binary forms, with or without
|
|
10
|
+
* modification, are permitted provided that the following conditions
|
|
11
|
+
* are met:
|
|
12
|
+
* 1. Redistributions of source code must retain the above copyright
|
|
13
|
+
* notice, this list of conditions and the following disclaimer.
|
|
14
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
|
15
|
+
* notice, this list of conditions and the following disclaimer in the
|
|
16
|
+
* documentation and/or other materials provided with the distribution.
|
|
17
|
+
*
|
|
18
|
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
19
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
20
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
21
|
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
22
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
23
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
24
|
+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
25
|
+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
26
|
+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
27
|
+
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
28
|
+
* SUCH DAMAGE.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
#include "regenc.h"
|
|
32
|
+
|
|
33
|
+
#if 1
|
|
34
|
+
#define DEBUG_GB18030(arg)
|
|
35
|
+
#else
|
|
36
|
+
#define DEBUG_GB18030(arg) printf arg
|
|
37
|
+
#endif
|
|
38
|
+
|
|
39
|
+
enum {
|
|
40
|
+
C1, /* one-byte char */
|
|
41
|
+
C2, /* one-byte or second of two-byte char */
|
|
42
|
+
C4, /* one-byte or second or fourth of four-byte char */
|
|
43
|
+
CM /* first of two- or four-byte char or second of two-byte char */
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
static const char GB18030_MAP[] = {
|
|
47
|
+
C1, C1, C1, C1, C1, C1, C1, C1, C1, C1, C1, C1, C1, C1, C1, C1,
|
|
48
|
+
C1, C1, C1, C1, C1, C1, C1, C1, C1, C1, C1, C1, C1, C1, C1, C1,
|
|
49
|
+
C1, C1, C1, C1, C1, C1, C1, C1, C1, C1, C1, C1, C1, C1, C1, C1,
|
|
50
|
+
C4, C4, C4, C4, C4, C4, C4, C4, C4, C4, C1, C1, C1, C1, C1, C1,
|
|
51
|
+
C2, C2, C2, C2, C2, C2, C2, C2, C2, C2, C2, C2, C2, C2, C2, C2,
|
|
52
|
+
C2, C2, C2, C2, C2, C2, C2, C2, C2, C2, C2, C2, C2, C2, C2, C2,
|
|
53
|
+
C2, C2, C2, C2, C2, C2, C2, C2, C2, C2, C2, C2, C2, C2, C2, C2,
|
|
54
|
+
C2, C2, C2, C2, C2, C2, C2, C2, C2, C2, C2, C2, C2, C2, C2, C1,
|
|
55
|
+
C2, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM,
|
|
56
|
+
CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM,
|
|
57
|
+
CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM,
|
|
58
|
+
CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM,
|
|
59
|
+
CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM,
|
|
60
|
+
CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM,
|
|
61
|
+
CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM,
|
|
62
|
+
CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, CM, C1
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
static int
|
|
66
|
+
gb18030_mbc_enc_len(const UChar* p)
|
|
67
|
+
{
|
|
68
|
+
if (GB18030_MAP[*p] != CM)
|
|
69
|
+
return 1;
|
|
70
|
+
p++;
|
|
71
|
+
if (GB18030_MAP[*p] == C4)
|
|
72
|
+
return 4;
|
|
73
|
+
if (GB18030_MAP[*p] == C1)
|
|
74
|
+
return 1; /* illegal sequence */
|
|
75
|
+
return 2;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
static int
|
|
79
|
+
is_valid_mbc_string(const UChar* p, const UChar* end)
|
|
80
|
+
{
|
|
81
|
+
while (p < end) {
|
|
82
|
+
if (*p < 0x80) {
|
|
83
|
+
p++;
|
|
84
|
+
}
|
|
85
|
+
else if (*p == 0x80 || *p == 0xff) {
|
|
86
|
+
return FALSE;
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
p++;
|
|
90
|
+
if (p >= end) return FALSE;
|
|
91
|
+
if (*p < 0x40) {
|
|
92
|
+
if (*p < 0x30 || *p > 0x39)
|
|
93
|
+
return FALSE;
|
|
94
|
+
|
|
95
|
+
p++;
|
|
96
|
+
if (p >= end) return FALSE;
|
|
97
|
+
if (*p < 0x81 || *p == 0xff) return FALSE;
|
|
98
|
+
|
|
99
|
+
p++;
|
|
100
|
+
if (p >= end) return FALSE;
|
|
101
|
+
if (*p < 0x30 || *p > 0x39)
|
|
102
|
+
return FALSE;
|
|
103
|
+
|
|
104
|
+
p++;
|
|
105
|
+
}
|
|
106
|
+
else if (*p == 0x7f || *p == 0xff) {
|
|
107
|
+
return FALSE;
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
p++;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return TRUE;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
static OnigCodePoint
|
|
119
|
+
gb18030_mbc_to_code(const UChar* p, const UChar* end)
|
|
120
|
+
{
|
|
121
|
+
return onigenc_mbn_mbc_to_code(ONIG_ENCODING_GB18030, p, end);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
static int
|
|
125
|
+
gb18030_code_to_mbc(OnigCodePoint code, UChar *buf)
|
|
126
|
+
{
|
|
127
|
+
return onigenc_mb4_code_to_mbc(ONIG_ENCODING_GB18030, code, buf);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
static int
|
|
131
|
+
gb18030_mbc_case_fold(OnigCaseFoldType flag, const UChar** pp, const UChar* end,
|
|
132
|
+
UChar* lower)
|
|
133
|
+
{
|
|
134
|
+
return onigenc_mbn_mbc_case_fold(ONIG_ENCODING_GB18030, flag,
|
|
135
|
+
pp, end, lower);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
#if 0
|
|
139
|
+
static int
|
|
140
|
+
gb18030_is_mbc_ambiguous(OnigCaseFoldType flag,
|
|
141
|
+
const UChar** pp, const UChar* end)
|
|
142
|
+
{
|
|
143
|
+
return onigenc_mbn_is_mbc_ambiguous(ONIG_ENCODING_GB18030, flag, pp, end);
|
|
144
|
+
}
|
|
145
|
+
#endif
|
|
146
|
+
|
|
147
|
+
static int
|
|
148
|
+
gb18030_is_code_ctype(OnigCodePoint code, unsigned int ctype)
|
|
149
|
+
{
|
|
150
|
+
return onigenc_mb4_is_code_ctype(ONIG_ENCODING_GB18030, code, ctype);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
enum state {
|
|
154
|
+
S_START,
|
|
155
|
+
S_one_C2,
|
|
156
|
+
S_one_C4,
|
|
157
|
+
S_one_CM,
|
|
158
|
+
|
|
159
|
+
S_odd_CM_one_CX,
|
|
160
|
+
S_even_CM_one_CX,
|
|
161
|
+
|
|
162
|
+
/* CMC4 : pair of "CM C4" */
|
|
163
|
+
S_one_CMC4,
|
|
164
|
+
S_odd_CMC4,
|
|
165
|
+
S_one_C4_odd_CMC4,
|
|
166
|
+
S_even_CMC4,
|
|
167
|
+
S_one_C4_even_CMC4,
|
|
168
|
+
|
|
169
|
+
S_odd_CM_odd_CMC4,
|
|
170
|
+
S_even_CM_odd_CMC4,
|
|
171
|
+
|
|
172
|
+
S_odd_CM_even_CMC4,
|
|
173
|
+
S_even_CM_even_CMC4,
|
|
174
|
+
|
|
175
|
+
/* C4CM : pair of "C4 CM" */
|
|
176
|
+
S_odd_C4CM,
|
|
177
|
+
S_one_CM_odd_C4CM,
|
|
178
|
+
S_even_C4CM,
|
|
179
|
+
S_one_CM_even_C4CM,
|
|
180
|
+
|
|
181
|
+
S_even_CM_odd_C4CM,
|
|
182
|
+
S_odd_CM_odd_C4CM,
|
|
183
|
+
S_even_CM_even_C4CM,
|
|
184
|
+
S_odd_CM_even_C4CM,
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
static UChar*
|
|
188
|
+
gb18030_left_adjust_char_head(const UChar* start, const UChar* s)
|
|
189
|
+
{
|
|
190
|
+
const UChar *p;
|
|
191
|
+
enum state state = S_START;
|
|
192
|
+
|
|
193
|
+
DEBUG_GB18030(("----------------\n"));
|
|
194
|
+
for (p = s; p >= start; p--) {
|
|
195
|
+
DEBUG_GB18030(("state %d --(%02x)-->\n", state, *p));
|
|
196
|
+
switch (state) {
|
|
197
|
+
case S_START:
|
|
198
|
+
switch (GB18030_MAP[*p]) {
|
|
199
|
+
case C1:
|
|
200
|
+
return (UChar *)s;
|
|
201
|
+
case C2:
|
|
202
|
+
state = S_one_C2; /* C2 */
|
|
203
|
+
break;
|
|
204
|
+
case C4:
|
|
205
|
+
state = S_one_C4; /* C4 */
|
|
206
|
+
break;
|
|
207
|
+
case CM:
|
|
208
|
+
state = S_one_CM; /* CM */
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
break;
|
|
212
|
+
case S_one_C2: /* C2 */
|
|
213
|
+
switch (GB18030_MAP[*p]) {
|
|
214
|
+
case C1:
|
|
215
|
+
case C2:
|
|
216
|
+
case C4:
|
|
217
|
+
return (UChar *)s;
|
|
218
|
+
case CM:
|
|
219
|
+
state = S_odd_CM_one_CX; /* CM C2 */
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
break;
|
|
223
|
+
case S_one_C4: /* C4 */
|
|
224
|
+
switch (GB18030_MAP[*p]) {
|
|
225
|
+
case C1:
|
|
226
|
+
case C2:
|
|
227
|
+
case C4:
|
|
228
|
+
return (UChar *)s;
|
|
229
|
+
case CM:
|
|
230
|
+
state = S_one_CMC4;
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
break;
|
|
234
|
+
case S_one_CM: /* CM */
|
|
235
|
+
switch (GB18030_MAP[*p]) {
|
|
236
|
+
case C1:
|
|
237
|
+
case C2:
|
|
238
|
+
return (UChar *)s;
|
|
239
|
+
case C4:
|
|
240
|
+
state = S_odd_C4CM;
|
|
241
|
+
break;
|
|
242
|
+
case CM:
|
|
243
|
+
state = S_odd_CM_one_CX; /* CM CM */
|
|
244
|
+
break;
|
|
245
|
+
}
|
|
246
|
+
break;
|
|
247
|
+
|
|
248
|
+
case S_odd_CM_one_CX: /* CM C2 */ /* CM CM */ /* CM CM CM C4 */
|
|
249
|
+
switch (GB18030_MAP[*p]) {
|
|
250
|
+
case C1:
|
|
251
|
+
case C2:
|
|
252
|
+
case C4:
|
|
253
|
+
return (UChar *)(s - 1);
|
|
254
|
+
case CM:
|
|
255
|
+
state = S_even_CM_one_CX;
|
|
256
|
+
break;
|
|
257
|
+
}
|
|
258
|
+
break;
|
|
259
|
+
case S_even_CM_one_CX: /* CM CM C2 */ /* CM CM CM */ /* CM CM C4 */
|
|
260
|
+
switch (GB18030_MAP[*p]) {
|
|
261
|
+
case C1:
|
|
262
|
+
case C2:
|
|
263
|
+
case C4:
|
|
264
|
+
return (UChar *)s;
|
|
265
|
+
case CM:
|
|
266
|
+
state = S_odd_CM_one_CX;
|
|
267
|
+
break;
|
|
268
|
+
}
|
|
269
|
+
break;
|
|
270
|
+
|
|
271
|
+
case S_one_CMC4: /* CM C4 */
|
|
272
|
+
switch (GB18030_MAP[*p]) {
|
|
273
|
+
case C1:
|
|
274
|
+
case C2:
|
|
275
|
+
return (UChar *)(s - 1);
|
|
276
|
+
case C4:
|
|
277
|
+
state = S_one_C4_odd_CMC4; /* C4 CM C4 */
|
|
278
|
+
break;
|
|
279
|
+
case CM:
|
|
280
|
+
state = S_even_CM_one_CX; /* CM CM C4 */
|
|
281
|
+
break;
|
|
282
|
+
}
|
|
283
|
+
break;
|
|
284
|
+
case S_odd_CMC4: /* CM C4 CM C4 CM C4 */
|
|
285
|
+
switch (GB18030_MAP[*p]) {
|
|
286
|
+
case C1:
|
|
287
|
+
case C2:
|
|
288
|
+
return (UChar *)(s - 1);
|
|
289
|
+
case C4:
|
|
290
|
+
state = S_one_C4_odd_CMC4;
|
|
291
|
+
break;
|
|
292
|
+
case CM:
|
|
293
|
+
state = S_odd_CM_odd_CMC4;
|
|
294
|
+
break;
|
|
295
|
+
}
|
|
296
|
+
break;
|
|
297
|
+
case S_one_C4_odd_CMC4: /* C4 CM C4 */
|
|
298
|
+
switch (GB18030_MAP[*p]) {
|
|
299
|
+
case C1:
|
|
300
|
+
case C2:
|
|
301
|
+
case C4:
|
|
302
|
+
return (UChar *)(s - 1);
|
|
303
|
+
case CM:
|
|
304
|
+
state = S_even_CMC4; /* CM C4 CM C4 */
|
|
305
|
+
break;
|
|
306
|
+
}
|
|
307
|
+
break;
|
|
308
|
+
case S_even_CMC4: /* CM C4 CM C4 */
|
|
309
|
+
switch (GB18030_MAP[*p]) {
|
|
310
|
+
case C1:
|
|
311
|
+
case C2:
|
|
312
|
+
return (UChar *)(s - 3);
|
|
313
|
+
case C4:
|
|
314
|
+
state = S_one_C4_even_CMC4;
|
|
315
|
+
break;
|
|
316
|
+
case CM:
|
|
317
|
+
state = S_odd_CM_even_CMC4;
|
|
318
|
+
break;
|
|
319
|
+
}
|
|
320
|
+
break;
|
|
321
|
+
case S_one_C4_even_CMC4: /* C4 CM C4 CM C4 */
|
|
322
|
+
switch (GB18030_MAP[*p]) {
|
|
323
|
+
case C1:
|
|
324
|
+
case C2:
|
|
325
|
+
case C4:
|
|
326
|
+
return (UChar *)(s - 3);
|
|
327
|
+
case CM:
|
|
328
|
+
state = S_odd_CMC4;
|
|
329
|
+
break;
|
|
330
|
+
}
|
|
331
|
+
break;
|
|
332
|
+
|
|
333
|
+
case S_odd_CM_odd_CMC4: /* CM CM C4 CM C4 CM C4 */
|
|
334
|
+
switch (GB18030_MAP[*p]) {
|
|
335
|
+
case C1:
|
|
336
|
+
case C2:
|
|
337
|
+
case C4:
|
|
338
|
+
return (UChar *)(s - 3);
|
|
339
|
+
case CM:
|
|
340
|
+
state = S_even_CM_odd_CMC4;
|
|
341
|
+
break;
|
|
342
|
+
}
|
|
343
|
+
break;
|
|
344
|
+
case S_even_CM_odd_CMC4: /* CM CM CM C4 CM C4 CM C4 */
|
|
345
|
+
switch (GB18030_MAP[*p]) {
|
|
346
|
+
case C1:
|
|
347
|
+
case C2:
|
|
348
|
+
case C4:
|
|
349
|
+
return (UChar *)(s - 1);
|
|
350
|
+
case CM:
|
|
351
|
+
state = S_odd_CM_odd_CMC4;
|
|
352
|
+
break;
|
|
353
|
+
}
|
|
354
|
+
break;
|
|
355
|
+
|
|
356
|
+
case S_odd_CM_even_CMC4: /* CM CM C4 CM C4 */
|
|
357
|
+
switch (GB18030_MAP[*p]) {
|
|
358
|
+
case C1:
|
|
359
|
+
case C2:
|
|
360
|
+
case C4:
|
|
361
|
+
return (UChar *)(s - 1);
|
|
362
|
+
case CM:
|
|
363
|
+
state = S_even_CM_even_CMC4;
|
|
364
|
+
break;
|
|
365
|
+
}
|
|
366
|
+
break;
|
|
367
|
+
case S_even_CM_even_CMC4: /* CM CM CM C4 CM C4 */
|
|
368
|
+
switch (GB18030_MAP[*p]) {
|
|
369
|
+
case C1:
|
|
370
|
+
case C2:
|
|
371
|
+
case C4:
|
|
372
|
+
return (UChar *)(s - 3);
|
|
373
|
+
case CM:
|
|
374
|
+
state = S_odd_CM_even_CMC4;
|
|
375
|
+
break;
|
|
376
|
+
}
|
|
377
|
+
break;
|
|
378
|
+
|
|
379
|
+
case S_odd_C4CM: /* C4 CM */ /* C4 CM C4 CM C4 CM*/
|
|
380
|
+
switch (GB18030_MAP[*p]) {
|
|
381
|
+
case C1:
|
|
382
|
+
case C2:
|
|
383
|
+
case C4:
|
|
384
|
+
return (UChar *)s;
|
|
385
|
+
case CM:
|
|
386
|
+
state = S_one_CM_odd_C4CM; /* CM C4 CM */
|
|
387
|
+
break;
|
|
388
|
+
}
|
|
389
|
+
break;
|
|
390
|
+
case S_one_CM_odd_C4CM: /* CM C4 CM */ /* CM C4 CM C4 CM C4 CM */
|
|
391
|
+
switch (GB18030_MAP[*p]) {
|
|
392
|
+
case C1:
|
|
393
|
+
case C2:
|
|
394
|
+
return (UChar *)(s - 2); /* |CM C4 CM */
|
|
395
|
+
case C4:
|
|
396
|
+
state = S_even_C4CM;
|
|
397
|
+
break;
|
|
398
|
+
case CM:
|
|
399
|
+
state = S_even_CM_odd_C4CM;
|
|
400
|
+
break;
|
|
401
|
+
}
|
|
402
|
+
break;
|
|
403
|
+
case S_even_C4CM: /* C4 CM C4 CM */
|
|
404
|
+
switch (GB18030_MAP[*p]) {
|
|
405
|
+
case C1:
|
|
406
|
+
case C2:
|
|
407
|
+
case C4:
|
|
408
|
+
return (UChar *)(s - 2); /* C4|CM C4 CM */
|
|
409
|
+
case CM:
|
|
410
|
+
state = S_one_CM_even_C4CM;
|
|
411
|
+
break;
|
|
412
|
+
}
|
|
413
|
+
break;
|
|
414
|
+
case S_one_CM_even_C4CM: /* CM C4 CM C4 CM */
|
|
415
|
+
switch (GB18030_MAP[*p]) {
|
|
416
|
+
case C1:
|
|
417
|
+
case C2:
|
|
418
|
+
return (UChar *)(s - 0); /*|CM C4 CM C4|CM */
|
|
419
|
+
case C4:
|
|
420
|
+
state = S_odd_C4CM;
|
|
421
|
+
break;
|
|
422
|
+
case CM:
|
|
423
|
+
state = S_even_CM_even_C4CM;
|
|
424
|
+
break;
|
|
425
|
+
}
|
|
426
|
+
break;
|
|
427
|
+
|
|
428
|
+
case S_even_CM_odd_C4CM: /* CM CM C4 CM */
|
|
429
|
+
switch (GB18030_MAP[*p]) {
|
|
430
|
+
case C1:
|
|
431
|
+
case C2:
|
|
432
|
+
case C4:
|
|
433
|
+
return (UChar *)(s - 0); /* |CM CM|C4|CM */
|
|
434
|
+
case CM:
|
|
435
|
+
state = S_odd_CM_odd_C4CM;
|
|
436
|
+
break;
|
|
437
|
+
}
|
|
438
|
+
break;
|
|
439
|
+
case S_odd_CM_odd_C4CM: /* CM CM CM C4 CM */
|
|
440
|
+
switch (GB18030_MAP[*p]) {
|
|
441
|
+
case C1:
|
|
442
|
+
case C2:
|
|
443
|
+
case C4:
|
|
444
|
+
return (UChar *)(s - 2); /* |CM CM|CM C4 CM */
|
|
445
|
+
case CM:
|
|
446
|
+
state = S_even_CM_odd_C4CM;
|
|
447
|
+
break;
|
|
448
|
+
}
|
|
449
|
+
break;
|
|
450
|
+
|
|
451
|
+
case S_even_CM_even_C4CM: /* CM CM C4 CM C4 CM */
|
|
452
|
+
switch (GB18030_MAP[*p]) {
|
|
453
|
+
case C1:
|
|
454
|
+
case C2:
|
|
455
|
+
case C4:
|
|
456
|
+
return (UChar *)(s - 2); /* |CM CM|C4|CM C4 CM */
|
|
457
|
+
case CM:
|
|
458
|
+
state = S_odd_CM_even_C4CM;
|
|
459
|
+
break;
|
|
460
|
+
}
|
|
461
|
+
break;
|
|
462
|
+
case S_odd_CM_even_C4CM: /* CM CM CM C4 CM C4 CM */
|
|
463
|
+
switch (GB18030_MAP[*p]) {
|
|
464
|
+
case C1:
|
|
465
|
+
case C2:
|
|
466
|
+
case C4:
|
|
467
|
+
return (UChar *)(s - 0); /* |CM CM|CM C4 CM C4|CM */
|
|
468
|
+
case CM:
|
|
469
|
+
state = S_even_CM_even_C4CM;
|
|
470
|
+
break;
|
|
471
|
+
}
|
|
472
|
+
break;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
DEBUG_GB18030(("state %d\n", state));
|
|
477
|
+
switch (state) {
|
|
478
|
+
case S_START: return (UChar *)(s - 0);
|
|
479
|
+
case S_one_C2: return (UChar *)(s - 0);
|
|
480
|
+
case S_one_C4: return (UChar *)(s - 0);
|
|
481
|
+
case S_one_CM: return (UChar *)(s - 0);
|
|
482
|
+
|
|
483
|
+
case S_odd_CM_one_CX: return (UChar *)(s - 1);
|
|
484
|
+
case S_even_CM_one_CX: return (UChar *)(s - 0);
|
|
485
|
+
|
|
486
|
+
case S_one_CMC4: return (UChar *)(s - 1);
|
|
487
|
+
case S_odd_CMC4: return (UChar *)(s - 1);
|
|
488
|
+
case S_one_C4_odd_CMC4: return (UChar *)(s - 1);
|
|
489
|
+
case S_even_CMC4: return (UChar *)(s - 3);
|
|
490
|
+
case S_one_C4_even_CMC4: return (UChar *)(s - 3);
|
|
491
|
+
|
|
492
|
+
case S_odd_CM_odd_CMC4: return (UChar *)(s - 3);
|
|
493
|
+
case S_even_CM_odd_CMC4: return (UChar *)(s - 1);
|
|
494
|
+
|
|
495
|
+
case S_odd_CM_even_CMC4: return (UChar *)(s - 1);
|
|
496
|
+
case S_even_CM_even_CMC4: return (UChar *)(s - 3);
|
|
497
|
+
|
|
498
|
+
case S_odd_C4CM: return (UChar *)(s - 0);
|
|
499
|
+
case S_one_CM_odd_C4CM: return (UChar *)(s - 2);
|
|
500
|
+
case S_even_C4CM: return (UChar *)(s - 2);
|
|
501
|
+
case S_one_CM_even_C4CM: return (UChar *)(s - 0);
|
|
502
|
+
|
|
503
|
+
case S_even_CM_odd_C4CM: return (UChar *)(s - 0);
|
|
504
|
+
case S_odd_CM_odd_C4CM: return (UChar *)(s - 2);
|
|
505
|
+
case S_even_CM_even_C4CM: return (UChar *)(s - 2);
|
|
506
|
+
case S_odd_CM_even_C4CM: return (UChar *)(s - 0);
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
return (UChar* )s; /* never come here. (escape warning) */
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
static int
|
|
513
|
+
gb18030_is_allowed_reverse_match(const UChar* s, const UChar* end ARG_UNUSED)
|
|
514
|
+
{
|
|
515
|
+
return GB18030_MAP[*s] == C1 ? TRUE : FALSE;
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
OnigEncodingType OnigEncodingGB18030 = {
|
|
519
|
+
gb18030_mbc_enc_len,
|
|
520
|
+
"GB18030", /* name */
|
|
521
|
+
4, /* max enc length */
|
|
522
|
+
1, /* min enc length */
|
|
523
|
+
onigenc_is_mbc_newline_0x0a,
|
|
524
|
+
gb18030_mbc_to_code,
|
|
525
|
+
onigenc_mb4_code_to_mbclen,
|
|
526
|
+
gb18030_code_to_mbc,
|
|
527
|
+
gb18030_mbc_case_fold,
|
|
528
|
+
onigenc_ascii_apply_all_case_fold,
|
|
529
|
+
onigenc_ascii_get_case_fold_codes_by_str,
|
|
530
|
+
onigenc_minimum_property_name_to_ctype,
|
|
531
|
+
gb18030_is_code_ctype,
|
|
532
|
+
onigenc_not_support_get_ctype_code_range,
|
|
533
|
+
gb18030_left_adjust_char_head,
|
|
534
|
+
gb18030_is_allowed_reverse_match,
|
|
535
|
+
NULL, /* init */
|
|
536
|
+
NULL, /* is_initialized */
|
|
537
|
+
is_valid_mbc_string
|
|
538
|
+
};
|