├── .github
└── workflows
│ └── ci.yml
├── .gitignore
├── .npmignore
├── .pairs
├── LICENSE.md
├── README.md
├── benchmark
├── benchmark.js
├── large.js
└── oneline.js
├── binding.gyp
├── deps
└── onig
│ ├── AUTHORS
│ ├── COPYING
│ ├── HISTORY
│ ├── INSTALL
│ ├── Makefile.am
│ ├── Makefile.in
│ ├── README
│ ├── README.ja
│ ├── aclocal.m4
│ ├── config.guess
│ ├── config.h
│ ├── config.h.in
│ ├── config.sub
│ ├── configure
│ ├── configure.in
│ ├── depcomp
│ ├── doc
│ ├── API
│ ├── API.ja
│ ├── FAQ
│ ├── FAQ.ja
│ ├── RE
│ └── RE.ja
│ ├── enc
│ ├── ascii.c
│ ├── big5.c
│ ├── cp1251.c
│ ├── euc_jp.c
│ ├── euc_kr.c
│ ├── euc_tw.c
│ ├── gb18030.c
│ ├── iso8859_1.c
│ ├── iso8859_10.c
│ ├── iso8859_11.c
│ ├── iso8859_13.c
│ ├── iso8859_14.c
│ ├── iso8859_15.c
│ ├── iso8859_16.c
│ ├── iso8859_2.c
│ ├── iso8859_3.c
│ ├── iso8859_4.c
│ ├── iso8859_5.c
│ ├── iso8859_6.c
│ ├── iso8859_7.c
│ ├── iso8859_8.c
│ ├── iso8859_9.c
│ ├── koi8.c
│ ├── koi8_r.c
│ ├── mktable.c
│ ├── sjis.c
│ ├── unicode.c
│ ├── utf16_be.c
│ ├── utf16_le.c
│ ├── utf32_be.c
│ ├── utf32_le.c
│ └── utf8.c
│ ├── index.html
│ ├── index_ja.html
│ ├── install-sh
│ ├── ltmain.sh
│ ├── m4
│ ├── libtool.m4
│ ├── ltoptions.m4
│ ├── ltsugar.m4
│ ├── ltversion.m4
│ └── lt~obsolete.m4
│ ├── missing
│ ├── onig-config
│ ├── onig-config.in
│ ├── oniggnu.h
│ ├── onigposix.h
│ ├── oniguruma.h
│ ├── oniguruma.pc.in
│ ├── regcomp.c
│ ├── regenc.c
│ ├── regenc.h
│ ├── regerror.c
│ ├── regexec.c
│ ├── regext.c
│ ├── reggnu.c
│ ├── regint.h
│ ├── regparse.c
│ ├── regparse.h
│ ├── regposerr.c
│ ├── regposix.c
│ ├── regsyntax.c
│ ├── regtrav.c
│ ├── regversion.c
│ ├── sample
│ ├── Makefile.am
│ ├── Makefile.in
│ ├── crnl.c
│ ├── encode.c
│ ├── listcap.c
│ ├── names.c
│ ├── posix.c
│ ├── simple.c
│ ├── sql.c
│ └── syntax.c
│ ├── st.c
│ ├── st.h
│ ├── stamp-h1
│ ├── testc.c
│ ├── testu.c
│ └── win32
│ ├── config.h
│ └── testc.c
├── package-lock.json
├── package.json
├── spec
├── onig-reg-exp-spec.js
├── onig-scanner-spec.js
└── onig-string-spec.js
└── src
├── onig-reg-exp.cc
├── onig-reg-exp.h
├── onig-result.cc
├── onig-result.h
├── onig-scanner-worker.cc
├── onig-scanner-worker.h
├── onig-scanner.cc
├── onig-scanner.h
├── onig-searcher.cc
├── onig-searcher.h
├── onig-string.cc
├── onig-string.h
└── oniguruma.js
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: CI
2 |
3 | on: [push]
4 |
5 | env:
6 | CI: true
7 |
8 | jobs:
9 | Test:
10 | strategy:
11 | matrix:
12 | os: [ubuntu-latest, macos-latest, windows-latest]
13 | channel: [stable, beta]
14 | runs-on: ${{ matrix.os }}
15 | steps:
16 | - uses: actions/checkout@v1
17 | - uses: actions/setup-node@v2
18 | with:
19 | node-version: '14'
20 | - name: Install windows-build-tools
21 | if: ${{ matrix.os == 'windows-latest' }}
22 | run: |
23 | npm config set msvs_version 2019
24 | - name: Install dependencies
25 | run: npm i
26 | - name: Run tests
27 | run: npm run test
28 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules
2 | /build
3 | /lib/*.js
4 | *.swp
5 | *.o
6 | *.lo
7 | *.la
8 | *.a
9 | .deps
10 | .libs
11 | Makefile
12 | *.log
13 | *.status
14 | deps/onig/libtool
15 | deps/onig/sample/crnl
16 | deps/onig/sample/encode
17 | deps/onig/sample/listcap
18 | deps/onig/sample/names
19 | deps/onig/sample/posix
20 | deps/onig/sample/simple
21 | deps/onig/sample/sql
22 | deps/onig/sample/syntax
23 | deps/onig/libtool
24 | *~
25 | .node-version
26 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | /build
2 | .pairs
3 | *.a
4 | *.o
5 | *.lo
6 | .deps
7 | .libs
8 | *.coffee
9 | Makefile
10 | *.log
11 | *.status
12 | deps/onig/sample/crnl
13 | deps/onig/sample/encode
14 | deps/onig/sample/listcap
15 | deps/onig/sample/names
16 | deps/onig/sample/posix
17 | deps/onig/sample/simple
18 | deps/onig/sample/sql
19 | deps/onig/sample/syntax
20 | .travis.yml
21 | *~
22 | .npmignore
23 | .node-version
24 | benchmark
25 |
--------------------------------------------------------------------------------
/.pairs:
--------------------------------------------------------------------------------
1 | pairs:
2 | ns: Nathan Sobo; nathan
3 | cj: Corey Johnson; cj
4 | ks: Kevin Sawicki; kevin
5 | email:
6 | domain: github.com
7 | #global: true
8 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | Copyright (c) 2013 GitHub Inc.
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining
4 | a copy of this software and associated documentation files (the
5 | "Software"), to deal in the Software without restriction, including
6 | without limitation the rights to use, copy, modify, merge, publish,
7 | distribute, sublicense, and/or sell copies of the Software, and to
8 | permit persons to whom the Software is furnished to do so, subject to
9 | the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be
12 | included in all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ##### Atom and all repositories under Atom will be archived on December 15, 2022. Learn more in our [official announcement](https://github.blog/2022-06-08-sunsetting-atom/)
2 | #### Atom and all repositories under Atom will be archived on December 15, 2022. Learn more in our [official announcement](https://github.blog/2022-06-08-sunsetting-atom/)
3 | # Oniguruma Node module
4 |
5 | [](https://travis-ci.org/atom/node-oniguruma)
6 | [](https://ci.appveyor.com/project/Atom/node-oniguruma/branch/master)
7 | [](https://david-dm.org/atom/node-oniguruma)
8 |
9 | Native Node bindings to the Oniguruma regular expressions library.
10 |
11 | Read all about Oniguruma regular expressions [here](https://github.com/kkos/oniguruma/blob/master/doc/RE).
12 |
13 | Version 2.0 of this library added an asynchronous API, the old synchronous
14 | methods have been renamed to have a `Sync` suffix.
15 |
16 | ## Installing
17 |
18 | ```sh
19 | npm install oniguruma
20 | ```
21 |
22 | ## Building
23 | * Clone the repository
24 | * Run `npm install`
25 | * Run `npm test` to run the specs
26 |
27 | ## Using
28 |
29 | ```coffeescript
30 | {OnigRegExp, OnigScanner} = require 'oniguruma'
31 | ```
32 |
33 | ### OnigScanner(patterns)
34 |
35 | Create a new scanner with the given patterns.
36 |
37 | `patterns` - An array of string patterns.
38 |
39 | ### OnigScanner::findNextMatch(string, startPosition, callback)
40 |
41 | Find the next match from a given position.
42 |
43 | `string` - The string to search.
44 |
45 | `startPosition` - The optional position to start at, defaults to `0`.
46 |
47 | `callback` - The `(error, match)` function to call when done, `match` will
48 | null when there is no match.
49 |
50 | #### Example
51 |
52 | ```coffeescript
53 | scanner = new OnigScanner(['c', 'a(b)?'])
54 | scanner.findNextMatch 'abc', (error, match) ->
55 | console.log match
56 | {
57 | index: 1, # Index of the best pattern match
58 | captureIndices: [
59 | {index: 0, start: 0, end: 2, length: 2}, # Entire match
60 | {index: 1, start: 1, end: 2, length: 1} # Match of first capture group
61 | ]
62 | }
63 | ```
64 |
65 | ### OnigScanner::findNextMatchSync(string, startPosition)
66 |
67 | Synchronously find the next match from a given position.
68 |
69 | `string` - The string to search.
70 |
71 | `startPosition` - The optional position to start at, defaults to `0`.
72 |
73 | Returns an object containing details about the match or `null` if no match.
74 |
75 | #### Example
76 |
77 | ```coffeescript
78 | scanner = new OnigScanner(['c', 'a(b)?'])
79 | match = scanner.findNextMatchSync('abc')
80 | console.log match
81 | {
82 | index: 1, # Index of the best pattern match
83 | captureIndices: [
84 | {index: 0, start: 0, end: 2, length: 2}, # Entire match
85 | {index: 1, start: 1, end: 2, length: 1} # Match of first capture group
86 | ]
87 | }
88 | ```
89 |
90 | ### OnigRegExp(pattern)
91 |
92 | Create a new regex with the given pattern.
93 |
94 | `pattern` - A string pattern.
95 |
96 | ### OnigRegExp::search(string, startPosition, callback)
97 |
98 | Search the string for a match starting at the given position.
99 |
100 | `string` - The string to search.
101 |
102 | `startPosition` - The optional position to start the search at, defaults to `0`.
103 |
104 | `callback` - The `(error, match)` function to call when done, `match` will be
105 | null if no matches were found. `match` will be an array of objects for each
106 | matched group on a successful search.
107 |
108 | #### Example
109 |
110 | ```coffeescript
111 | regex = new OnigRegExp('a([b-d])c')
112 | regex.search '!abcdef', (error, match) ->
113 | console.log match
114 | [
115 | {index: 0, start: 1, end: 4, match: 'abc', length: 3}, # Entire match
116 | {index: 1, start: 2, end: 3, match: 'b', length: 1} # Match of first capture group
117 | ]
118 | ```
119 |
120 | ### OnigRegExp::searchSync(string, startPosition)
121 |
122 | Synchronously search the string for a match starting at the given position.
123 |
124 | `string` - The string to search.
125 |
126 | `startPosition` - The optional position to start the search at, defaults to `0`.
127 |
128 | Returns an array of objects for each matched group or `null` if no match was
129 | found.
130 |
131 | #### Example
132 |
133 | ```coffeescript
134 | regex = new OnigRegExp('a([b-d])c')
135 | match = regex.searchSync('!abcdef')
136 | console.log match
137 | [
138 | {index: 0, start: 1, end: 4, match: 'abc', length: 3}, # Entire match
139 | {index: 1, start: 2, end: 3, match: 'b', length: 1} # Match of first capture group
140 | ]
141 | ```
142 |
143 | ### OnigRegExp::test(string, callback)
144 |
145 | Test if this regular expression matches the given string.
146 |
147 | `string` - The string to test against.
148 |
149 | `callback` - The `(error, matches)` function to call when done, `matches` will
150 | be `true` if at least one match is found, `false` otherwise.
151 |
152 | #### Example
153 |
154 | ```coffeescript
155 | regex = new OnigRegExp('a([b-d])c')
156 | regex.test 'abcdef', (error, matches) ->
157 | console.log matches # true
158 | ```
159 |
160 | ### OnigRegExp::testSync(string)
161 |
162 | Synchronously test if this regular expression matches the given string.
163 |
164 | `string` - The string to test against.
165 |
166 | Returns `true` if at least one match, `false` otherwise.
167 |
168 | #### Example
169 |
170 | ```coffeescript
171 | regex = new OnigRegExp('a([b-d])c')
172 | matches = regex.testSync('abcdef')
173 | console.log matches # true
174 | ```
175 |
--------------------------------------------------------------------------------
/benchmark/benchmark.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | const fs = require('fs')
4 | const path = require('path')
5 | const OnigScanner = require('..').OnigScanner
6 |
7 | function runBenchmarkSync (lines, scanner) {
8 | let startTime = Date.now()
9 | let matches = 0
10 |
11 | for (let row = 0, rowCount = lines.length; row < rowCount; row++) {
12 | const line = lines[row]
13 | for (let position = 0, length = line.length; position <= length; position++) {
14 | if (scanner.findNextMatchSync(line, position)) matches++
15 | }
16 | }
17 |
18 | console.log(`sync: ${matches} matches in ${Date.now() - startTime}ms`)
19 | }
20 |
21 | function runBenchmarkAsync (lines, scanner) {
22 | let matches = 0
23 | let callsInProgress = 0
24 |
25 | function callback (error, match) {
26 | if (match != null) { matches++ }
27 | if (--callsInProgress === 0) {
28 | console.log(`async: ${matches} matches in ${Date.now() - startTime}ms`)
29 | }
30 | };
31 |
32 | var startTime = Date.now()
33 | for (let row = 0, rowCount = lines.length; row < rowCount; row++) {
34 | const line = lines[row]
35 | for (let position = 0, length = line.length; position <= length; position++) {
36 | callsInProgress++
37 | scanner.findNextMatch(line, position, callback)
38 | }
39 | }
40 | }
41 |
42 | console.log('oneline.js')
43 | runBenchmarkSync(
44 | fs.readFileSync(path.join(__dirname, 'oneline.js'), 'utf8').split('\n'),
45 | new OnigScanner(['\\[', '\\]', '\\{', '\\}'])
46 | )
47 |
48 | console.log('large.js')
49 | runBenchmarkSync(
50 | fs.readFileSync(path.join(__dirname, 'large.js'), 'utf8').split('\n'),
51 | new OnigScanner(['this', 'var', 'selector', 'window'])
52 | )
53 |
54 | runBenchmarkAsync(
55 | fs.readFileSync(path.join(__dirname, 'large.js'), 'utf8').split('\n'),
56 | new OnigScanner(['this', 'var', 'selector', 'window'])
57 | )
58 |
--------------------------------------------------------------------------------
/binding.gyp:
--------------------------------------------------------------------------------
1 | {
2 | 'targets': [
3 | {
4 | 'target_name': 'oniguruma',
5 | 'type': 'static_library',
6 | 'conditions': [
7 | ['OS=="win"', {
8 | 'msvs_disabled_warnings': [
9 | 4244, # conversion from '__int64' to 'int', possible loss of data
10 | ],
11 | 'defines': [
12 | 'ONIG_EXTERN=extern',
13 | ],
14 | }],
15 | ['OS=="linux"', {
16 | 'cflags': [
17 | '-w',
18 | ],
19 | }],
20 | ],
21 | 'direct_dependent_settings': {
22 | 'include_dirs': [
23 | 'deps/onig'
24 | ],
25 | },
26 | 'include_dirs': [
27 | 'deps/onig',
28 | 'deps/onig/enc',
29 | ],
30 | 'sources': [
31 | 'deps/onig/oniggnu.h',
32 | 'deps/onig/onigposix.h',
33 | 'deps/onig/oniguruma.h',
34 | 'deps/onig/regcomp.c',
35 | 'deps/onig/regenc.c',
36 | 'deps/onig/regenc.h',
37 | 'deps/onig/regerror.c',
38 | 'deps/onig/regexec.c',
39 | 'deps/onig/regext.c',
40 | 'deps/onig/reggnu.c',
41 | 'deps/onig/regint.h',
42 | 'deps/onig/regparse.c',
43 | 'deps/onig/regparse.h',
44 | 'deps/onig/regposerr.c',
45 | 'deps/onig/regposix.c',
46 | 'deps/onig/regsyntax.c',
47 | 'deps/onig/regtrav.c',
48 | 'deps/onig/regversion.c',
49 | 'deps/onig/st.c',
50 | 'deps/onig/st.c',
51 | 'deps/onig/enc/ascii.c',
52 | 'deps/onig/enc/big5.c',
53 | 'deps/onig/enc/cp1251.c',
54 | 'deps/onig/enc/euc_jp.c',
55 | 'deps/onig/enc/euc_kr.c',
56 | 'deps/onig/enc/euc_tw.c',
57 | 'deps/onig/enc/gb18030.c',
58 | 'deps/onig/enc/iso8859_1.c',
59 | 'deps/onig/enc/iso8859_2.c',
60 | 'deps/onig/enc/iso8859_3.c',
61 | 'deps/onig/enc/iso8859_4.c',
62 | 'deps/onig/enc/iso8859_5.c',
63 | 'deps/onig/enc/iso8859_6.c',
64 | 'deps/onig/enc/iso8859_7.c',
65 | 'deps/onig/enc/iso8859_8.c',
66 | 'deps/onig/enc/iso8859_9.c',
67 | 'deps/onig/enc/iso8859_10.c',
68 | 'deps/onig/enc/iso8859_11.c',
69 | 'deps/onig/enc/iso8859_13.c',
70 | 'deps/onig/enc/iso8859_14.c',
71 | 'deps/onig/enc/iso8859_15.c',
72 | 'deps/onig/enc/iso8859_16.c',
73 | 'deps/onig/enc/koi8.c',
74 | 'deps/onig/enc/koi8_r.c',
75 | 'deps/onig/enc/mktable.c',
76 | 'deps/onig/enc/sjis.c',
77 | 'deps/onig/enc/unicode.c',
78 | 'deps/onig/enc/utf16_be.c',
79 | 'deps/onig/enc/utf16_le.c',
80 | 'deps/onig/enc/utf32_be.c',
81 | 'deps/onig/enc/utf32_le.c',
82 | 'deps/onig/enc/utf8.c',
83 | ],
84 | },
85 | {
86 | 'target_name': 'onig_scanner',
87 | 'dependencies': [
88 | 'oniguruma'
89 | ],
90 | 'include_dirs': [ '
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 |
--------------------------------------------------------------------------------
/deps/onig/Makefile.am:
--------------------------------------------------------------------------------
1 | ## Makefile.am for Oniguruma
2 | encdir = $(top_srcdir)/enc
3 | sampledir = $(top_srcdir)/sample
4 | libname = libonig.la
5 |
6 | ACLOCAL_AMFLAGS = -I m4
7 | #AM_CFLAGS = -DNOT_RUBY
8 | AM_CFLAGS =
9 | INCLUDES = -I$(top_srcdir) -I$(includedir)
10 |
11 | SUBDIRS = . sample
12 |
13 | include_HEADERS = oniguruma.h oniggnu.h onigposix.h
14 | lib_LTLIBRARIES = $(libname)
15 |
16 | libonig_la_SOURCES = regint.h regparse.h regenc.h st.h \
17 | regerror.c regparse.c regext.c regcomp.c regexec.c reggnu.c \
18 | regenc.c regsyntax.c regtrav.c regversion.c st.c \
19 | regposix.c regposerr.c \
20 | $(encdir)/unicode.c $(encdir)/ascii.c $(encdir)/utf8.c \
21 | $(encdir)/utf16_be.c $(encdir)/utf16_le.c \
22 | $(encdir)/utf32_be.c $(encdir)/utf32_le.c \
23 | $(encdir)/euc_jp.c $(encdir)/sjis.c $(encdir)/iso8859_1.c \
24 | $(encdir)/iso8859_2.c $(encdir)/iso8859_3.c \
25 | $(encdir)/iso8859_4.c $(encdir)/iso8859_5.c \
26 | $(encdir)/iso8859_6.c $(encdir)/iso8859_7.c \
27 | $(encdir)/iso8859_8.c $(encdir)/iso8859_9.c \
28 | $(encdir)/iso8859_10.c $(encdir)/iso8859_11.c \
29 | $(encdir)/iso8859_13.c $(encdir)/iso8859_14.c \
30 | $(encdir)/iso8859_15.c $(encdir)/iso8859_16.c \
31 | $(encdir)/euc_tw.c $(encdir)/euc_kr.c $(encdir)/big5.c \
32 | $(encdir)/gb18030.c $(encdir)/koi8_r.c $(encdir)/cp1251.c
33 |
34 | libonig_la_LDFLAGS = -version-info $(LTVERSION)
35 |
36 | EXTRA_DIST = oniguruma.pc.in HISTORY README.ja index.html index_ja.html \
37 | doc/API doc/API.ja doc/RE doc/RE.ja doc/FAQ doc/FAQ.ja \
38 | win32/Makefile win32/config.h win32/testc.c \
39 | $(encdir)/koi8.c $(encdir)/mktable.c \
40 | $(sampledir)/encode.c $(sampledir)/listcap.c $(sampledir)/names.c \
41 | $(sampledir)/posix.c $(sampledir)/simple.c $(sampledir)/sql.c \
42 | $(sampledir)/syntax.c
43 |
44 | bin_SCRIPTS = onig-config
45 |
46 | onig-config: onig-config.in
47 |
48 | do_subst = sed \
49 | -e 's,[@]datadir[@],$(datadir),g' \
50 | -e 's,[@]datarootdir[@],$(datarootdir),g' \
51 | -e 's,[@]PACKAGE_VERSION[@],$(PACKAGE_VERSION),g' \
52 | -e 's,[@]prefix[@],$(prefix),g' \
53 | -e 's,[@]exec_prefix[@],$(exec_prefix),g' \
54 | -e 's,[@]libdir[@],$(libdir),g' \
55 | -e 's,[@]includedir[@],$(includedir),g'
56 |
57 | oniguruma.pc: $(srcdir)/oniguruma.pc.in Makefile
58 | $(do_subst) < $(<) > $(@)
59 |
60 | pkgconfigdir = $(libdir)/pkgconfig
61 | pkgconfig_DATA = oniguruma.pc
62 |
63 | dll:
64 | $(CXX) -shared -Wl,--output-def,libonig.def -o libonig.dll *.o \
65 | $(LIBS)
66 | strip libonig.dll
67 |
68 | # Ruby TEST
69 | rtest:
70 | $(RUBYDIR)/ruby -w -Ke $(srcdir)/test.rb
71 |
72 | # character-types-table source generator
73 | mktable: $(encdir)/mktable.c $(srcdir)/regenc.h
74 | $(CC) -I$(top_srcdir) -o mktable $(encdir)/mktable.c
75 |
76 |
77 | # TEST
78 | TESTS = testc testp testcu
79 |
80 | check_PROGRAMS = testc testp testcu
81 |
82 | atest: testc testp testcu
83 | @echo "[Oniguruma API, ASCII/EUC-JP check]"
84 | @$(top_builddir)/testc | grep RESULT
85 | @echo "[POSIX API, ASCII/EUC-JP check]"
86 | @$(top_builddir)/testp | grep RESULT
87 | @echo "[Oniguruma API, UTF-16 check]"
88 | @$(top_builddir)/testcu | grep RESULT
89 |
90 | testc_SOURCES = testc.c
91 | testc_LDADD = libonig.la
92 |
93 | testp_SOURCES = testc.c
94 | testp_LDADD = libonig.la
95 | testp_CFLAGS = -DPOSIX_TEST
96 |
97 | testcu_SOURCES = testu.c
98 | testcu_LDADD = libonig.la
99 |
100 |
101 | #testc.c: $(srcdir)/test.rb $(srcdir)/testconv.rb
102 | # ruby -Ke $(srcdir)/testconv.rb < $(srcdir)/test.rb > $@
103 |
104 | #testu.c: $(srcdir)/test.rb $(srcdir)/testconvu.rb
105 | # ruby -Ke $(srcdir)/testconvu.rb $(srcdir)/test.rb > $@
106 |
107 | #win32/testc.c: $(srcdir)/test.rb $(srcdir)/testconv.rb
108 | # ruby -Ke $(srcdir)/testconv.rb -win < $(srcdir)/test.rb | nkf -cs > $@
109 |
110 | ## END OF FILE
111 |
--------------------------------------------------------------------------------
/deps/onig/README:
--------------------------------------------------------------------------------
1 | README 2007/05/31
2 |
3 | Oniguruma ---- (C) K.Kosako
4 |
5 | http://www.geocities.jp/kosako3/oniguruma/
6 |
7 | Oniguruma is a regular expressions library.
8 | The characteristics of this library is that different character encoding
9 | for every regular expression object can be specified.
10 |
11 | Supported character encodings:
12 |
13 | ASCII, UTF-8, UTF-16BE, UTF-16LE, UTF-32BE, UTF-32LE,
14 | EUC-JP, EUC-TW, EUC-KR, EUC-CN,
15 | Shift_JIS, Big5, GB18030, KOI8-R, CP1251,
16 | ISO-8859-1, ISO-8859-2, ISO-8859-3, ISO-8859-4, ISO-8859-5,
17 | ISO-8859-6, ISO-8859-7, ISO-8859-8, ISO-8859-9, ISO-8859-10,
18 | ISO-8859-11, ISO-8859-13, ISO-8859-14, ISO-8859-15, ISO-8859-16
19 |
20 | * GB18030: contributed by KUBO Takehiro
21 | * CP1251: contributed by Byte
22 | ------------------------------------------------------------
23 |
24 | License
25 |
26 | BSD license.
27 |
28 |
29 | Install
30 |
31 | Case 1: Unix and Cygwin platform
32 |
33 | 1. ./configure
34 | 2. make
35 | 3. make install
36 |
37 | * uninstall
38 |
39 | make uninstall
40 |
41 | * test (ASCII/EUC-JP)
42 |
43 | make atest
44 |
45 | * configuration check
46 |
47 | onig-config --cflags
48 | onig-config --libs
49 | onig-config --prefix
50 | onig-config --exec-prefix
51 |
52 |
53 |
54 | Case 2: Win32 platform (VC++)
55 |
56 | 1. copy win32\Makefile Makefile
57 | 2. copy win32\config.h config.h
58 | 3. nmake
59 |
60 | onig_s.lib: static link library
61 | onig.dll: dynamic link library
62 |
63 | * test (ASCII/Shift_JIS)
64 | 4. copy win32\testc.c testc.c
65 | 5. nmake ctest
66 |
67 |
68 |
69 | Regular Expressions
70 |
71 | See doc/RE (or doc/RE.ja for Japanese).
72 |
73 |
74 | Usage
75 |
76 | Include oniguruma.h in your program. (Oniguruma API)
77 | See doc/API for Oniguruma API.
78 |
79 | If you want to disable UChar type (== unsigned char) definition
80 | in oniguruma.h, define ONIG_ESCAPE_UCHAR_COLLISION and then
81 | include oniguruma.h.
82 |
83 | If you want to disable regex_t type definition in oniguruma.h,
84 | define ONIG_ESCAPE_REGEX_T_COLLISION and then include oniguruma.h.
85 |
86 | Example of the compiling/linking command line in Unix or Cygwin,
87 | (prefix == /usr/local case)
88 |
89 | cc sample.c -L/usr/local/lib -lonig
90 |
91 |
92 | If you want to use static link library(onig_s.lib) in Win32,
93 | add option -DONIG_EXTERN=extern to C compiler.
94 |
95 |
96 |
97 | Sample Programs
98 |
99 | sample/simple.c example of the minimum (Oniguruma API)
100 | sample/names.c example of the named group callback.
101 | sample/encode.c example of some encodings.
102 | sample/listcap.c example of the capture history.
103 | sample/posix.c POSIX API sample.
104 | sample/sql.c example of the variable meta characters.
105 | (SQL-like pattern matching)
106 |
107 | Test Programs
108 | sample/syntax.c Perl, Java and ASIS syntax test.
109 | sample/crnl.c --enable-crnl-as-line-terminator test
110 |
111 |
112 | Source Files
113 |
114 | oniguruma.h Oniguruma API header file. (public)
115 | onig-config.in configuration check program template.
116 |
117 | regenc.h character encodings framework header file.
118 | regint.h internal definitions
119 | regparse.h internal definitions for regparse.c and regcomp.c
120 | regcomp.c compiling and optimization functions
121 | regenc.c character encodings framework.
122 | regerror.c error message function
123 | regext.c extended API functions. (deluxe version API)
124 | regexec.c search and match functions
125 | regparse.c parsing functions.
126 | regsyntax.c pattern syntax functions and built-in syntax definitions.
127 | regtrav.c capture history tree data traverse functions.
128 | regversion.c version info function.
129 | st.h hash table functions header file
130 | st.c hash table functions
131 |
132 | oniggnu.h GNU regex API header file. (public)
133 | reggnu.c GNU regex API functions
134 |
135 | onigposix.h POSIX API header file. (public)
136 | regposerr.c POSIX error message function.
137 | regposix.c POSIX API functions.
138 |
139 | enc/mktable.c character type table generator.
140 | enc/ascii.c ASCII encoding.
141 | enc/euc_jp.c EUC-JP encoding.
142 | enc/euc_tw.c EUC-TW encoding.
143 | enc/euc_kr.c EUC-KR, EUC-CN encoding.
144 | enc/sjis.c Shift_JIS encoding.
145 | enc/big5.c Big5 encoding.
146 | enc/gb18030.c GB18030 encoding.
147 | enc/koi8.c KOI8 encoding.
148 | enc/koi8_r.c KOI8-R encoding.
149 | enc/cp1251.c CP1251 encoding.
150 | enc/iso8859_1.c ISO-8859-1 encoding. (Latin-1)
151 | enc/iso8859_2.c ISO-8859-2 encoding. (Latin-2)
152 | enc/iso8859_3.c ISO-8859-3 encoding. (Latin-3)
153 | enc/iso8859_4.c ISO-8859-4 encoding. (Latin-4)
154 | enc/iso8859_5.c ISO-8859-5 encoding. (Cyrillic)
155 | enc/iso8859_6.c ISO-8859-6 encoding. (Arabic)
156 | enc/iso8859_7.c ISO-8859-7 encoding. (Greek)
157 | enc/iso8859_8.c ISO-8859-8 encoding. (Hebrew)
158 | enc/iso8859_9.c ISO-8859-9 encoding. (Latin-5 or Turkish)
159 | enc/iso8859_10.c ISO-8859-10 encoding. (Latin-6 or Nordic)
160 | enc/iso8859_11.c ISO-8859-11 encoding. (Thai)
161 | enc/iso8859_13.c ISO-8859-13 encoding. (Latin-7 or Baltic Rim)
162 | enc/iso8859_14.c ISO-8859-14 encoding. (Latin-8 or Celtic)
163 | enc/iso8859_15.c ISO-8859-15 encoding. (Latin-9 or West European with Euro)
164 | enc/iso8859_16.c ISO-8859-16 encoding.
165 | (Latin-10 or South-Eastern European with Euro)
166 | enc/utf8.c UTF-8 encoding.
167 | enc/utf16_be.c UTF-16BE encoding.
168 | enc/utf16_le.c UTF-16LE encoding.
169 | enc/utf32_be.c UTF-32BE encoding.
170 | enc/utf32_le.c UTF-32LE encoding.
171 | enc/unicode.c Unicode information data.
172 |
173 | win32/Makefile Makefile for Win32 (VC++)
174 | win32/config.h config.h for Win32
175 |
176 |
177 |
178 | ToDo
179 |
180 | ? case fold flag: Katakana <-> Hiragana.
181 | ? add ONIG_OPTION_NOTBOS/NOTEOS. (\A, \z, \Z)
182 | ?? \X (== \PM\pM*)
183 | ?? implement syntax behavior ONIG_SYN_CONTEXT_INDEP_ANCHORS.
184 | ?? transmission stopper. (return ONIG_STOP from match_at())
185 |
186 | and I'm thankful to Akinori MUSHA.
187 |
188 |
189 | Mail Address: K.Kosako
190 |
--------------------------------------------------------------------------------
/deps/onig/README.ja:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/atom/node-oniguruma/0c6b95fc7d79ab7e60a7ed63df6d05677ace2642/deps/onig/README.ja
--------------------------------------------------------------------------------
/deps/onig/config.h:
--------------------------------------------------------------------------------
1 | /* config.h. Generated from config.h.in by configure. */
2 | /* config.h.in. Generated from configure.in by autoheader. */
3 |
4 | #ifdef _WIN32
5 | #include "win32/config.h"
6 | #else
7 |
8 | /* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
9 | systems. This function is required for `alloca.c' support on those systems.
10 | */
11 | /* #undef CRAY_STACKSEG_END */
12 |
13 | /* Define to 1 if using `alloca.c'. */
14 | /* #undef C_ALLOCA */
15 |
16 | /* Define to 1 if you have `alloca', as a function or macro. */
17 | #define HAVE_ALLOCA 1
18 |
19 | /* Define to 1 if you have and it should be used (not on Ultrix).
20 | */
21 | #define HAVE_ALLOCA_H 1
22 |
23 | /* Define to 1 if you have the header file. */
24 | #define HAVE_DLFCN_H 1
25 |
26 | /* Define to 1 if you have the header file. */
27 | #define HAVE_INTTYPES_H 1
28 |
29 | /* Define to 1 if you have the header file. */
30 | #define HAVE_MEMORY_H 1
31 |
32 | /* Define if compilerr supports prototypes */
33 | #define HAVE_PROTOTYPES 1
34 |
35 | /* Define if compiler supports stdarg prototypes */
36 | #define HAVE_STDARG_PROTOTYPES 1
37 |
38 | /* Define to 1 if you have the header file. */
39 | #define HAVE_STDINT_H 1
40 |
41 | /* Define to 1 if you have the header file. */
42 | #define HAVE_STDLIB_H 1
43 |
44 | /* Define to 1 if you have the header file. */
45 | #define HAVE_STRINGS_H 1
46 |
47 | /* Define to 1 if you have the header file. */
48 | #define HAVE_STRING_H 1
49 |
50 | /* Define to 1 if you have the header file. */
51 | #define HAVE_SYS_STAT_H 1
52 |
53 | /* Define to 1 if you have the header file. */
54 | #define HAVE_SYS_TIMES_H 1
55 |
56 | /* Define to 1 if you have the header file. */
57 | #define HAVE_SYS_TIME_H 1
58 |
59 | /* Define to 1 if you have the header file. */
60 | #define HAVE_SYS_TYPES_H 1
61 |
62 | /* Define to 1 if you have the header file. */
63 | #define HAVE_UNISTD_H 1
64 |
65 | /* Define to the sub-directory in which libtool stores uninstalled libraries.
66 | */
67 | #define LT_OBJDIR ".libs/"
68 |
69 | /* Name of package */
70 | #define PACKAGE "onig"
71 |
72 | /* Define to the address where bug reports for this package should be sent. */
73 | #define PACKAGE_BUGREPORT ""
74 |
75 | /* Define to the full name of this package. */
76 | #define PACKAGE_NAME "onig"
77 |
78 | /* Define to the full name and version of this package. */
79 | #define PACKAGE_STRING "onig 5.9.3"
80 |
81 | /* Define to the one symbol short name of this package. */
82 | #define PACKAGE_TARNAME "onig"
83 |
84 | /* Define to the home page for this package. */
85 | #define PACKAGE_URL ""
86 |
87 | /* Define to the version of this package. */
88 | #define PACKAGE_VERSION "5.9.3"
89 |
90 | /* The size of `int', as computed by sizeof. */
91 | #define SIZEOF_INT 4
92 |
93 | /* The size of `long', as computed by sizeof. */
94 | #define SIZEOF_LONG 8
95 |
96 | /* The size of `short', as computed by sizeof. */
97 | #define SIZEOF_SHORT 2
98 |
99 | /* If using the C implementation of alloca, define if you know the
100 | direction of stack growth for your system; otherwise it will be
101 | automatically deduced at runtime.
102 | STACK_DIRECTION > 0 => grows toward higher addresses
103 | STACK_DIRECTION < 0 => grows toward lower addresses
104 | STACK_DIRECTION = 0 => direction of growth unknown */
105 | /* #undef STACK_DIRECTION */
106 |
107 | /* Define to 1 if you have the ANSI C header files. */
108 | #define STDC_HEADERS 1
109 |
110 | /* Define to 1 if you can safely include both and . */
111 | #define TIME_WITH_SYS_TIME 1
112 |
113 | /* Define if combination explosion check */
114 | /* #undef USE_COMBINATION_EXPLOSION_CHECK */
115 |
116 | /* Define if enable CR+NL as line terminator */
117 | /* #undef USE_CRNL_AS_LINE_TERMINATOR */
118 |
119 | /* Version number of package */
120 | #define VERSION "5.9.3"
121 |
122 | /* Define to empty if `const' does not conform to ANSI C. */
123 | /* #undef const */
124 |
125 | #endif
126 |
--------------------------------------------------------------------------------
/deps/onig/config.h.in:
--------------------------------------------------------------------------------
1 | /* config.h.in. Generated from configure.in by autoheader. */
2 |
3 | /* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
4 | systems. This function is required for `alloca.c' support on those systems.
5 | */
6 | #undef CRAY_STACKSEG_END
7 |
8 | /* Define to 1 if using `alloca.c'. */
9 | #undef C_ALLOCA
10 |
11 | /* Define to 1 if you have `alloca', as a function or macro. */
12 | #undef HAVE_ALLOCA
13 |
14 | /* Define to 1 if you have and it should be used (not on Ultrix).
15 | */
16 | #undef HAVE_ALLOCA_H
17 |
18 | /* Define to 1 if you have the header file. */
19 | #undef HAVE_DLFCN_H
20 |
21 | /* Define to 1 if you have the header file. */
22 | #undef HAVE_INTTYPES_H
23 |
24 | /* Define to 1 if you have the header file. */
25 | #undef HAVE_MEMORY_H
26 |
27 | /* Define if compilerr supports prototypes */
28 | #undef HAVE_PROTOTYPES
29 |
30 | /* Define if compiler supports stdarg prototypes */
31 | #undef HAVE_STDARG_PROTOTYPES
32 |
33 | /* Define to 1 if you have the header file. */
34 | #undef HAVE_STDINT_H
35 |
36 | /* Define to 1 if you have the header file. */
37 | #undef HAVE_STDLIB_H
38 |
39 | /* Define to 1 if you have the header file. */
40 | #undef HAVE_STRINGS_H
41 |
42 | /* Define to 1 if you have the header file. */
43 | #undef HAVE_STRING_H
44 |
45 | /* Define to 1 if you have the header file. */
46 | #undef HAVE_SYS_STAT_H
47 |
48 | /* Define to 1 if you have the header file. */
49 | #undef HAVE_SYS_TIMES_H
50 |
51 | /* Define to 1 if you have the header file. */
52 | #undef HAVE_SYS_TIME_H
53 |
54 | /* Define to 1 if you have the header file. */
55 | #undef HAVE_SYS_TYPES_H
56 |
57 | /* Define to 1 if you have the header file. */
58 | #undef HAVE_UNISTD_H
59 |
60 | /* Define to the sub-directory in which libtool stores uninstalled libraries.
61 | */
62 | #undef LT_OBJDIR
63 |
64 | /* Name of package */
65 | #undef PACKAGE
66 |
67 | /* Define to the address where bug reports for this package should be sent. */
68 | #undef PACKAGE_BUGREPORT
69 |
70 | /* Define to the full name of this package. */
71 | #undef PACKAGE_NAME
72 |
73 | /* Define to the full name and version of this package. */
74 | #undef PACKAGE_STRING
75 |
76 | /* Define to the one symbol short name of this package. */
77 | #undef PACKAGE_TARNAME
78 |
79 | /* Define to the home page for this package. */
80 | #undef PACKAGE_URL
81 |
82 | /* Define to the version of this package. */
83 | #undef PACKAGE_VERSION
84 |
85 | /* The size of `int', as computed by sizeof. */
86 | #undef SIZEOF_INT
87 |
88 | /* The size of `long', as computed by sizeof. */
89 | #undef SIZEOF_LONG
90 |
91 | /* The size of `short', as computed by sizeof. */
92 | #undef SIZEOF_SHORT
93 |
94 | /* If using the C implementation of alloca, define if you know the
95 | direction of stack growth for your system; otherwise it will be
96 | automatically deduced at runtime.
97 | STACK_DIRECTION > 0 => grows toward higher addresses
98 | STACK_DIRECTION < 0 => grows toward lower addresses
99 | STACK_DIRECTION = 0 => direction of growth unknown */
100 | #undef STACK_DIRECTION
101 |
102 | /* Define to 1 if you have the ANSI C header files. */
103 | #undef STDC_HEADERS
104 |
105 | /* Define to 1 if you can safely include both and . */
106 | #undef TIME_WITH_SYS_TIME
107 |
108 | /* Define if combination explosion check */
109 | #undef USE_COMBINATION_EXPLOSION_CHECK
110 |
111 | /* Define if enable CR+NL as line terminator */
112 | #undef USE_CRNL_AS_LINE_TERMINATOR
113 |
114 | /* Version number of package */
115 | #undef VERSION
116 |
117 | /* Define to empty if `const' does not conform to ANSI C. */
118 | #undef const
119 |
120 | /* Define to `unsigned int' if does not define. */
121 | #undef size_t
122 |
--------------------------------------------------------------------------------
/deps/onig/configure.in:
--------------------------------------------------------------------------------
1 | dnl Process this file with autoconf to produce a configure script.
2 | AC_INIT(onig, 5.9.6)
3 |
4 | AC_CONFIG_MACRO_DIR([m4])
5 |
6 | AM_INIT_AUTOMAKE
7 | AC_CONFIG_HEADER(config.h)
8 |
9 |
10 | dnl default value for RUBYDIR
11 | RUBYDIR=".."
12 | AC_ARG_WITH(rubydir,
13 | [ --with-rubydir=RUBYDIR specify value for RUBYDIR (default ..)],
14 | [ RUBYDIR=$withval ])
15 | AC_SUBST(RUBYDIR)
16 |
17 | dnl default value for STATISTICS
18 | STATISTICS=""
19 | AC_ARG_WITH(statistics,
20 | [ --with-statistics take matching time statistical data],
21 | [ STATISTICS=-DONIG_DEBUG_STATISTICS ])
22 | AC_SUBST(STATISTICS)
23 |
24 | dnl check for COMBINATION_EXPLOSION
25 | AC_ARG_ENABLE(combination-explosion-check,
26 | [ --enable-combination-explosion-check enable combination explosion check],
27 | [comb_expl_check=$enableval])
28 | if test "${comb_expl_check}" = yes; then
29 | AC_DEFINE(USE_COMBINATION_EXPLOSION_CHECK,1,[Define if combination explosion check])
30 | fi
31 |
32 | dnl check for CRNL_AS_LINE_TERMINATOR
33 | AC_ARG_ENABLE(crnl-as-line-terminator,
34 | [ --enable-crnl-as-line-terminator enable CR+NL as line terminator],
35 | [crnl_as_line_terminator=$enableval])
36 | if test "${crnl_as_line_terminator}" = yes; then
37 | AC_DEFINE(USE_CRNL_AS_LINE_TERMINATOR,1,[Define if enable CR+NL as line terminator])
38 | fi
39 |
40 |
41 | dnl Checks for programs.
42 | AC_PROG_CC
43 | AM_PROG_LIBTOOL
44 | LTVERSION="2:0:0"
45 | AC_SUBST(LTVERSION)
46 |
47 | AC_PROG_INSTALL
48 | AC_PROG_MAKE_SET
49 |
50 | dnl Checks for libraries.
51 |
52 | dnl Checks for header files.
53 | AC_HEADER_STDC
54 | AC_CHECK_HEADERS(stdlib.h string.h strings.h sys/time.h unistd.h sys/times.h)
55 |
56 | dnl Checks for typedefs, structures, and compiler characteristics.
57 | AC_CHECK_SIZEOF(int, 4)
58 | AC_CHECK_SIZEOF(short, 2)
59 | AC_CHECK_SIZEOF(long, 4)
60 | AC_C_CONST
61 | AC_HEADER_TIME
62 |
63 | dnl Checks for library functions.
64 | AC_FUNC_ALLOCA
65 | AC_FUNC_MEMCMP
66 |
67 | AC_CACHE_CHECK(for prototypes, _cv_have_prototypes,
68 | [AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],
69 | _cv_have_prototypes=yes,
70 | _cv_have_prototypes=no)])
71 | if test "$_cv_have_prototypes" = yes; then
72 | AC_DEFINE(HAVE_PROTOTYPES,1,[Define if compilerr supports prototypes])
73 | fi
74 |
75 | AC_CACHE_CHECK(for variable length prototypes and stdarg.h, _cv_stdarg,
76 | [AC_TRY_COMPILE([
77 | #include
78 | int foo(int x, ...) {
79 | va_list va;
80 | va_start(va, x);
81 | va_arg(va, int);
82 | va_arg(va, char *);
83 | va_arg(va, double);
84 | return 0;
85 | }
86 | ], [return foo(10, "", 3.14);],
87 | _cv_stdarg=yes,
88 | _cv_stdarg=no)])
89 | if test "$_cv_stdarg" = yes; then
90 | AC_DEFINE(HAVE_STDARG_PROTOTYPES,1,[Define if compiler supports stdarg prototypes])
91 | fi
92 |
93 |
94 | AC_OUTPUT([Makefile onig-config sample/Makefile], [chmod +x onig-config])
95 |
--------------------------------------------------------------------------------
/deps/onig/doc/API.ja:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/atom/node-oniguruma/0c6b95fc7d79ab7e60a7ed63df6d05677ace2642/deps/onig/doc/API.ja
--------------------------------------------------------------------------------
/deps/onig/doc/FAQ:
--------------------------------------------------------------------------------
1 | FAQ 2006/11/14
2 |
3 | 1. Lognest match
4 |
5 | You can execute longest match by using ONIG_OPTION_FIND_LONGEST option
6 | in onig_new().
7 |
8 |
9 | 2. Thread safe
10 |
11 | In order to make thread safe, which of (A) or (B) must be done.
12 |
13 | (A) Oniguruma Layer
14 |
15 | Define the macro below in oniguruma/regint.h.
16 |
17 | USE_MULTI_THREAD_SYSTEM
18 | THREAD_ATOMIC_START
19 | THREAD_ATOMIC_END
20 | THREAD_PASS
21 |
22 | THREAD_SYSTEM_INIT
23 | THREAD_SYSTEM_END
24 |
25 |
26 | (B) Application Layer
27 |
28 | The plural threads should not do simultaneously that making
29 | new regexp objects or re-compiling objects or freeing objects,
30 | even if these objects are differ.
31 |
32 |
33 | 3. Mailing list
34 |
35 | There is no mailing list about Oniguruma.
36 |
37 | // END
38 |
--------------------------------------------------------------------------------
/deps/onig/doc/FAQ.ja:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/atom/node-oniguruma/0c6b95fc7d79ab7e60a7ed63df6d05677ace2642/deps/onig/doc/FAQ.ja
--------------------------------------------------------------------------------
/deps/onig/doc/RE.ja:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/atom/node-oniguruma/0c6b95fc7d79ab7e60a7ed63df6d05677ace2642/deps/onig/doc/RE.ja
--------------------------------------------------------------------------------
/deps/onig/enc/ascii.c:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | ascii.c - Oniguruma (regular expression library)
3 | **********************************************************************/
4 | /*-
5 | * Copyright (c) 2002-2006 K.Kosako
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 int
33 | ascii_is_code_ctype(OnigCodePoint code, unsigned int ctype)
34 | {
35 | if (code < 128)
36 | return ONIGENC_IS_ASCII_CODE_CTYPE(code, ctype);
37 | else
38 | return FALSE;
39 | }
40 |
41 | OnigEncodingType OnigEncodingASCII = {
42 | onigenc_single_byte_mbc_enc_len,
43 | "US-ASCII", /* name */
44 | 1, /* max byte length */
45 | 1, /* min byte length */
46 | onigenc_is_mbc_newline_0x0a,
47 | onigenc_single_byte_mbc_to_code,
48 | onigenc_single_byte_code_to_mbclen,
49 | onigenc_single_byte_code_to_mbc,
50 | onigenc_ascii_mbc_case_fold,
51 | onigenc_ascii_apply_all_case_fold,
52 | onigenc_ascii_get_case_fold_codes_by_str,
53 | onigenc_minimum_property_name_to_ctype,
54 | ascii_is_code_ctype,
55 | onigenc_not_support_get_ctype_code_range,
56 | onigenc_single_byte_left_adjust_char_head,
57 | onigenc_always_true_is_allowed_reverse_match
58 | };
59 |
--------------------------------------------------------------------------------
/deps/onig/enc/big5.c:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | big5.c - Oniguruma (regular expression library)
3 | **********************************************************************/
4 | /*-
5 | * Copyright (c) 2002-2007 K.Kosako
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_BIG5[] = {
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, 1, 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 | big5_mbc_enc_len(const UChar* p)
53 | {
54 | return EncLen_BIG5[*p];
55 | }
56 |
57 | static OnigCodePoint
58 | big5_mbc_to_code(const UChar* p, const UChar* end)
59 | {
60 | return onigenc_mbn_mbc_to_code(ONIG_ENCODING_BIG5, p, end);
61 | }
62 |
63 | static int
64 | big5_code_to_mbc(OnigCodePoint code, UChar *buf)
65 | {
66 | return onigenc_mb2_code_to_mbc(ONIG_ENCODING_BIG5, code, buf);
67 | }
68 |
69 | static int
70 | big5_mbc_case_fold(OnigCaseFoldType flag, const UChar** pp, const UChar* end,
71 | UChar* lower)
72 | {
73 | return onigenc_mbn_mbc_case_fold(ONIG_ENCODING_BIG5, flag,
74 | pp, end, lower);
75 | }
76 |
77 | #if 0
78 | static int
79 | big5_is_mbc_ambiguous(OnigCaseFoldType flag,
80 | const UChar** pp, const UChar* end)
81 | {
82 | return onigenc_mbn_is_mbc_ambiguous(ONIG_ENCODING_BIG5, flag, pp, end);
83 | }
84 | #endif
85 |
86 | static int
87 | big5_is_code_ctype(OnigCodePoint code, unsigned int ctype)
88 | {
89 | return onigenc_mb2_is_code_ctype(ONIG_ENCODING_BIG5, code, ctype);
90 | }
91 |
92 | static const char BIG5_CAN_BE_TRAIL_TABLE[256] = {
93 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
94 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
95 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
96 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
97 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
98 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
99 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
100 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
101 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
102 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
103 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
104 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
105 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
106 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
107 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
108 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0
109 | };
110 |
111 | #define BIG5_ISMB_FIRST(byte) (EncLen_BIG5[byte] > 1)
112 | #define BIG5_ISMB_TRAIL(byte) BIG5_CAN_BE_TRAIL_TABLE[(byte)]
113 |
114 | static UChar*
115 | big5_left_adjust_char_head(const UChar* start, const UChar* s)
116 | {
117 | const UChar *p;
118 | int len;
119 |
120 | if (s <= start) return (UChar* )s;
121 | p = s;
122 |
123 | if (BIG5_ISMB_TRAIL(*p)) {
124 | while (p > start) {
125 | if (! BIG5_ISMB_FIRST(*--p)) {
126 | p++;
127 | break;
128 | }
129 | }
130 | }
131 | len = enclen(ONIG_ENCODING_BIG5, p);
132 | if (p + len > s) return (UChar* )p;
133 | p += len;
134 | return (UChar* )(p + ((s - p) & ~1));
135 | }
136 |
137 | static int
138 | big5_is_allowed_reverse_match(const UChar* s, const UChar* end ARG_UNUSED)
139 | {
140 | const UChar c = *s;
141 |
142 | return (BIG5_ISMB_TRAIL(c) ? FALSE : TRUE);
143 | }
144 |
145 | OnigEncodingType OnigEncodingBIG5 = {
146 | big5_mbc_enc_len,
147 | "Big5", /* name */
148 | 2, /* max enc length */
149 | 1, /* min enc length */
150 | onigenc_is_mbc_newline_0x0a,
151 | big5_mbc_to_code,
152 | onigenc_mb2_code_to_mbclen,
153 | big5_code_to_mbc,
154 | big5_mbc_case_fold,
155 | onigenc_ascii_apply_all_case_fold,
156 | onigenc_ascii_get_case_fold_codes_by_str,
157 | onigenc_minimum_property_name_to_ctype,
158 | big5_is_code_ctype,
159 | onigenc_not_support_get_ctype_code_range,
160 | big5_left_adjust_char_head,
161 | big5_is_allowed_reverse_match
162 | };
163 |
--------------------------------------------------------------------------------
/deps/onig/enc/euc_jp.c:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | euc_jp.c - Oniguruma (regular expression library)
3 | **********************************************************************/
4 | /*-
5 | * Copyright (c) 2002-2008 K.Kosako
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 "regint.h"
31 |
32 | #define eucjp_islead(c) ((UChar )((c) - 0xa1) > 0xfe - 0xa1)
33 |
34 | static const int EncLen_EUCJP[] = {
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, 1, 1,
42 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
43 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
44 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
45 | 1, 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, 2,
49 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
50 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1
51 | };
52 |
53 | static int
54 | mbc_enc_len(const UChar* p)
55 | {
56 | return EncLen_EUCJP[*p];
57 | }
58 |
59 | static OnigCodePoint
60 | mbc_to_code(const UChar* p, const UChar* end)
61 | {
62 | int c, i, len;
63 | OnigCodePoint n;
64 |
65 | len = enclen(ONIG_ENCODING_EUC_JP, p);
66 | n = (OnigCodePoint )*p++;
67 | if (len == 1) return n;
68 |
69 | for (i = 1; i < len; i++) {
70 | if (p >= end) break;
71 | c = *p++;
72 | n <<= 8; n += c;
73 | }
74 | return n;
75 | }
76 |
77 | static int
78 | code_to_mbclen(OnigCodePoint code)
79 | {
80 | if (ONIGENC_IS_CODE_ASCII(code)) return 1;
81 | else if ((code & 0xff0000) != 0) return 3;
82 | else if ((code & 0xff00) != 0) return 2;
83 | else
84 | return ONIGERR_INVALID_CODE_POINT_VALUE;
85 | }
86 |
87 | #if 0
88 | static int
89 | code_to_mbc_first(OnigCodePoint code)
90 | {
91 | int first;
92 |
93 | if ((code & 0xff0000) != 0) {
94 | first = (code >> 16) & 0xff;
95 | }
96 | else if ((code & 0xff00) != 0) {
97 | first = (code >> 8) & 0xff;
98 | }
99 | else {
100 | return (int )code;
101 | }
102 | return first;
103 | }
104 | #endif
105 |
106 | static int
107 | code_to_mbc(OnigCodePoint code, UChar *buf)
108 | {
109 | UChar *p = buf;
110 |
111 | if ((code & 0xff0000) != 0) *p++ = (UChar )(((code >> 16) & 0xff));
112 | if ((code & 0xff00) != 0) *p++ = (UChar )(((code >> 8) & 0xff));
113 | *p++ = (UChar )(code & 0xff);
114 |
115 | #if 1
116 | if (enclen(ONIG_ENCODING_EUC_JP, buf) != (p - buf))
117 | return ONIGERR_INVALID_CODE_POINT_VALUE;
118 | #endif
119 | return p - buf;
120 | }
121 |
122 | static int
123 | mbc_case_fold(OnigCaseFoldType flag ARG_UNUSED,
124 | const UChar** pp, const UChar* end ARG_UNUSED, UChar* lower)
125 | {
126 | int len;
127 | const UChar* p = *pp;
128 |
129 | if (ONIGENC_IS_MBC_ASCII(p)) {
130 | *lower = ONIGENC_ASCII_CODE_TO_LOWER_CASE(*p);
131 | (*pp)++;
132 | return 1;
133 | }
134 | else {
135 | int i;
136 |
137 | len = enclen(ONIG_ENCODING_EUC_JP, p);
138 | for (i = 0; i < len; i++) {
139 | *lower++ = *p++;
140 | }
141 | (*pp) += len;
142 | return len; /* return byte length of converted char to lower */
143 | }
144 | }
145 |
146 | static UChar*
147 | left_adjust_char_head(const UChar* start, const UChar* s)
148 | {
149 | /* In this encoding
150 | mb-trail bytes doesn't mix with single bytes.
151 | */
152 | const UChar *p;
153 | int len;
154 |
155 | if (s <= start) return (UChar* )s;
156 | p = s;
157 |
158 | while (!eucjp_islead(*p) && p > start) p--;
159 | len = enclen(ONIG_ENCODING_EUC_JP, p);
160 | if (p + len > s) return (UChar* )p;
161 | p += len;
162 | return (UChar* )(p + ((s - p) & ~1));
163 | }
164 |
165 | static int
166 | is_allowed_reverse_match(const UChar* s, const UChar* end ARG_UNUSED)
167 | {
168 | const UChar c = *s;
169 | if (c <= 0x7e || c == 0x8e || c == 0x8f)
170 | return TRUE;
171 | else
172 | return FALSE;
173 | }
174 |
175 |
176 | static int PropertyInited = 0;
177 | static const OnigCodePoint** PropertyList;
178 | static int PropertyListNum;
179 | static int PropertyListSize;
180 | static hash_table_type* PropertyNameTable;
181 |
182 | static const OnigCodePoint CR_Hiragana[] = {
183 | 1,
184 | 0xa4a1, 0xa4f3
185 | }; /* CR_Hiragana */
186 |
187 | static const OnigCodePoint CR_Katakana[] = {
188 | 3,
189 | 0xa5a1, 0xa5f6,
190 | 0xaaa6, 0xaaaf,
191 | 0xaab1, 0xaadd
192 | }; /* CR_Katakana */
193 |
194 | static int
195 | init_property_list(void)
196 | {
197 | int r;
198 |
199 | PROPERTY_LIST_ADD_PROP("Hiragana", CR_Hiragana);
200 | PROPERTY_LIST_ADD_PROP("Katakana", CR_Katakana);
201 | PropertyInited = 1;
202 |
203 | end:
204 | return r;
205 | }
206 |
207 | static int
208 | property_name_to_ctype(OnigEncoding enc, UChar* p, UChar* end)
209 | {
210 | hash_data_type ctype;
211 |
212 | PROPERTY_LIST_INIT_CHECK;
213 |
214 | if (onig_st_lookup_strend(PropertyNameTable, p, end, &ctype) == 0) {
215 | return onigenc_minimum_property_name_to_ctype(enc, p, end);
216 | }
217 |
218 | return (int )ctype;
219 | }
220 |
221 | static int
222 | is_code_ctype(OnigCodePoint code, unsigned int ctype)
223 | {
224 | if (ctype <= ONIGENC_MAX_STD_CTYPE) {
225 | if (code < 128)
226 | return ONIGENC_IS_ASCII_CODE_CTYPE(code, ctype);
227 | else {
228 | if (CTYPE_IS_WORD_GRAPH_PRINT(ctype)) {
229 | return (code_to_mbclen(code) > 1 ? TRUE : FALSE);
230 | }
231 | }
232 | }
233 | else {
234 | PROPERTY_LIST_INIT_CHECK;
235 |
236 | ctype -= (ONIGENC_MAX_STD_CTYPE + 1);
237 | if (ctype >= (unsigned int )PropertyListNum)
238 | return ONIGERR_TYPE_BUG;
239 |
240 | return onig_is_in_code_range((UChar* )PropertyList[ctype], code);
241 | }
242 |
243 | return FALSE;
244 | }
245 |
246 | static int
247 | get_ctype_code_range(OnigCtype ctype, OnigCodePoint* sb_out,
248 | const OnigCodePoint* ranges[])
249 | {
250 | if (ctype <= ONIGENC_MAX_STD_CTYPE) {
251 | return ONIG_NO_SUPPORT_CONFIG;
252 | }
253 | else {
254 | *sb_out = 0x80;
255 |
256 | PROPERTY_LIST_INIT_CHECK;
257 |
258 | ctype -= (ONIGENC_MAX_STD_CTYPE + 1);
259 | if (ctype >= (OnigCtype )PropertyListNum)
260 | return ONIGERR_TYPE_BUG;
261 |
262 | *ranges = PropertyList[ctype];
263 | return 0;
264 | }
265 | }
266 |
267 |
268 | OnigEncodingType OnigEncodingEUC_JP = {
269 | mbc_enc_len,
270 | "EUC-JP", /* name */
271 | 3, /* max enc length */
272 | 1, /* min enc length */
273 | onigenc_is_mbc_newline_0x0a,
274 | mbc_to_code,
275 | code_to_mbclen,
276 | code_to_mbc,
277 | mbc_case_fold,
278 | onigenc_ascii_apply_all_case_fold,
279 | onigenc_ascii_get_case_fold_codes_by_str,
280 | property_name_to_ctype,
281 | is_code_ctype,
282 | get_ctype_code_range,
283 | left_adjust_char_head,
284 | is_allowed_reverse_match
285 | };
286 |
--------------------------------------------------------------------------------
/deps/onig/enc/euc_kr.c:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | euc_kr.c - Oniguruma (regular expression library)
3 | **********************************************************************/
4 | /*-
5 | * Copyright (c) 2002-2007 K.Kosako
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_EUCKR[] = {
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, 1, 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 | euckr_mbc_enc_len(const UChar* p)
53 | {
54 | return EncLen_EUCKR[*p];
55 | }
56 |
57 | static OnigCodePoint
58 | euckr_mbc_to_code(const UChar* p, const UChar* end)
59 | {
60 | return onigenc_mbn_mbc_to_code(ONIG_ENCODING_EUC_KR, p, end);
61 | }
62 |
63 | static int
64 | euckr_code_to_mbc(OnigCodePoint code, UChar *buf)
65 | {
66 | return onigenc_mb2_code_to_mbc(ONIG_ENCODING_EUC_KR, code, buf);
67 | }
68 |
69 | static int
70 | euckr_mbc_case_fold(OnigCaseFoldType flag, const UChar** pp, const UChar* end,
71 | UChar* lower)
72 | {
73 | return onigenc_mbn_mbc_case_fold(ONIG_ENCODING_EUC_KR, flag,
74 | pp, end, lower);
75 | }
76 |
77 | #if 0
78 | static int
79 | euckr_is_mbc_ambiguous(OnigCaseFoldType flag,
80 | const UChar** pp, const UChar* end)
81 | {
82 | return onigenc_mbn_is_mbc_ambiguous(ONIG_ENCODING_EUC_KR, flag, pp, end);
83 | }
84 | #endif
85 |
86 | static int
87 | euckr_is_code_ctype(OnigCodePoint code, unsigned int ctype)
88 | {
89 | return onigenc_mb2_is_code_ctype(ONIG_ENCODING_EUC_KR, code, ctype);
90 | }
91 |
92 | #define euckr_islead(c) ((c) < 0xa1 || (c) == 0xff)
93 |
94 | static UChar*
95 | euckr_left_adjust_char_head(const UChar* start, const UChar* s)
96 | {
97 | /* Assumed in this encoding,
98 | mb-trail bytes don't mix with single bytes.
99 | */
100 | const UChar *p;
101 | int len;
102 |
103 | if (s <= start) return (UChar* )s;
104 | p = s;
105 |
106 | while (!euckr_islead(*p) && p > start) p--;
107 | len = enclen(ONIG_ENCODING_EUC_KR, p);
108 | if (p + len > s) return (UChar* )p;
109 | p += len;
110 | return (UChar* )(p + ((s - p) & ~1));
111 | }
112 |
113 | static int
114 | euckr_is_allowed_reverse_match(const UChar* s, const UChar* end ARG_UNUSED)
115 | {
116 | const UChar c = *s;
117 | if (c <= 0x7e) return TRUE;
118 | else return FALSE;
119 | }
120 |
121 | OnigEncodingType OnigEncodingEUC_KR = {
122 | euckr_mbc_enc_len,
123 | "EUC-KR", /* name */
124 | 2, /* max enc length */
125 | 1, /* min enc length */
126 | onigenc_is_mbc_newline_0x0a,
127 | euckr_mbc_to_code,
128 | onigenc_mb2_code_to_mbclen,
129 | euckr_code_to_mbc,
130 | euckr_mbc_case_fold,
131 | onigenc_ascii_apply_all_case_fold,
132 | onigenc_ascii_get_case_fold_codes_by_str,
133 | onigenc_minimum_property_name_to_ctype,
134 | euckr_is_code_ctype,
135 | onigenc_not_support_get_ctype_code_range,
136 | euckr_left_adjust_char_head,
137 | euckr_is_allowed_reverse_match
138 | };
139 |
140 | /* Same with OnigEncodingEUC_KR except the name */
141 | OnigEncodingType OnigEncodingEUC_CN = {
142 | euckr_mbc_enc_len,
143 | "EUC-CN", /* name */
144 | 2, /* max enc length */
145 | 1, /* min enc length */
146 | onigenc_is_mbc_newline_0x0a,
147 | euckr_mbc_to_code,
148 | onigenc_mb2_code_to_mbclen,
149 | euckr_code_to_mbc,
150 | euckr_mbc_case_fold,
151 | onigenc_ascii_apply_all_case_fold,
152 | onigenc_ascii_get_case_fold_codes_by_str,
153 | onigenc_minimum_property_name_to_ctype,
154 | euckr_is_code_ctype,
155 | onigenc_not_support_get_ctype_code_range,
156 | euckr_left_adjust_char_head,
157 | euckr_is_allowed_reverse_match
158 | };
159 |
--------------------------------------------------------------------------------
/deps/onig/enc/euc_tw.c:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | euc_tw.c - Oniguruma (regular expression library)
3 | **********************************************************************/
4 | /*-
5 | * Copyright (c) 2002-2008 K.Kosako
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 OnigCodePoint
58 | euctw_mbc_to_code(const UChar* p, const UChar* end)
59 | {
60 | return onigenc_mbn_mbc_to_code(ONIG_ENCODING_EUC_TW, p, end);
61 | }
62 |
63 | static int
64 | euctw_code_to_mbc(OnigCodePoint code, UChar *buf)
65 | {
66 | return onigenc_mb4_code_to_mbc(ONIG_ENCODING_EUC_TW, code, buf);
67 | }
68 |
69 | static int
70 | euctw_mbc_case_fold(OnigCaseFoldType flag, const UChar** pp, const UChar* end,
71 | UChar* lower)
72 | {
73 | return onigenc_mbn_mbc_case_fold(ONIG_ENCODING_EUC_TW, flag,
74 | pp, end, lower);
75 | }
76 |
77 | static int
78 | euctw_is_code_ctype(OnigCodePoint code, unsigned int ctype)
79 | {
80 | return onigenc_mb4_is_code_ctype(ONIG_ENCODING_EUC_TW, code, ctype);
81 | }
82 |
83 | #define euctw_islead(c) ((UChar )((c) - 0xa1) > 0xfe - 0xa1)
84 |
85 | static UChar*
86 | euctw_left_adjust_char_head(const UChar* start, const UChar* s)
87 | {
88 | /* Assumed in this encoding,
89 | mb-trail bytes don't mix with single bytes.
90 | */
91 | const UChar *p;
92 | int len;
93 |
94 | if (s <= start) return (UChar* )s;
95 | p = s;
96 |
97 | while (!euctw_islead(*p) && p > start) p--;
98 | len = enclen(ONIG_ENCODING_EUC_TW, p);
99 | if (p + len > s) return (UChar* )p;
100 | p += len;
101 | return (UChar* )(p + ((s - p) & ~1));
102 | }
103 |
104 | static int
105 | euctw_is_allowed_reverse_match(const UChar* s, const UChar* end ARG_UNUSED)
106 | {
107 | const UChar c = *s;
108 | if (c <= 0x7e) return TRUE;
109 | else return FALSE;
110 | }
111 |
112 | OnigEncodingType OnigEncodingEUC_TW = {
113 | euctw_mbc_enc_len,
114 | "EUC-TW", /* name */
115 | 4, /* max enc length */
116 | 1, /* min enc length */
117 | onigenc_is_mbc_newline_0x0a,
118 | euctw_mbc_to_code,
119 | onigenc_mb4_code_to_mbclen,
120 | euctw_code_to_mbc,
121 | euctw_mbc_case_fold,
122 | onigenc_ascii_apply_all_case_fold,
123 | onigenc_ascii_get_case_fold_codes_by_str,
124 | onigenc_minimum_property_name_to_ctype,
125 | euctw_is_code_ctype,
126 | onigenc_not_support_get_ctype_code_range,
127 | euctw_left_adjust_char_head,
128 | euctw_is_allowed_reverse_match
129 | };
130 |
--------------------------------------------------------------------------------
/deps/onig/enc/iso8859_11.c:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | iso8859_11.c - Oniguruma (regular expression library)
3 | **********************************************************************/
4 | /*-
5 | * Copyright (c) 2002-2007 K.Kosako
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 | #define ENC_IS_ISO_8859_11_CTYPE(code,ctype) \
33 | ((EncISO_8859_11_CtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0)
34 |
35 | static const unsigned short EncISO_8859_11_CtypeTable[256] = {
36 | 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
37 | 0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008,
38 | 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
39 | 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
40 | 0x4284, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
41 | 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
42 | 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0,
43 | 0x78b0, 0x78b0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
44 | 0x41a0, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x74a2,
45 | 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
46 | 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
47 | 0x74a2, 0x74a2, 0x74a2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x51a0,
48 | 0x41a0, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x70e2,
49 | 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
50 | 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
51 | 0x70e2, 0x70e2, 0x70e2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x4008,
52 | 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
53 | 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
54 | 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
55 | 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
56 | 0x0284, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2,
57 | 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2,
58 | 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2,
59 | 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2,
60 | 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2,
61 | 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2,
62 | 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2,
63 | 0x30a2, 0x30a2, 0x30a2, 0x0000, 0x0000, 0x0000, 0x0000, 0x30a2,
64 | 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2,
65 | 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2,
66 | 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2,
67 | 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x0000, 0x0000, 0x0000, 0x0000
68 | };
69 |
70 | static int
71 | is_code_ctype(OnigCodePoint code, unsigned int ctype)
72 | {
73 | if (code < 256)
74 | return ENC_IS_ISO_8859_11_CTYPE(code, ctype);
75 | else
76 | return FALSE;
77 | }
78 |
79 | OnigEncodingType OnigEncodingISO_8859_11 = {
80 | onigenc_single_byte_mbc_enc_len,
81 | "ISO-8859-11", /* name */
82 | 1, /* max enc length */
83 | 1, /* min enc length */
84 | onigenc_is_mbc_newline_0x0a,
85 | onigenc_single_byte_mbc_to_code,
86 | onigenc_single_byte_code_to_mbclen,
87 | onigenc_single_byte_code_to_mbc,
88 | onigenc_ascii_mbc_case_fold,
89 | onigenc_ascii_apply_all_case_fold,
90 | onigenc_ascii_get_case_fold_codes_by_str,
91 | onigenc_minimum_property_name_to_ctype,
92 | is_code_ctype,
93 | onigenc_not_support_get_ctype_code_range,
94 | onigenc_single_byte_left_adjust_char_head,
95 | onigenc_always_true_is_allowed_reverse_match
96 | };
97 |
--------------------------------------------------------------------------------
/deps/onig/enc/iso8859_6.c:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | iso8859_6.c - Oniguruma (regular expression library)
3 | **********************************************************************/
4 | /*-
5 | * Copyright (c) 2002-2007 K.Kosako
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 | #define ENC_IS_ISO_8859_6_CTYPE(code,ctype) \
33 | ((EncISO_8859_6_CtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0)
34 |
35 | static const unsigned short EncISO_8859_6_CtypeTable[256] = {
36 | 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
37 | 0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008,
38 | 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
39 | 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
40 | 0x4284, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
41 | 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
42 | 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0,
43 | 0x78b0, 0x78b0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
44 | 0x41a0, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x74a2,
45 | 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
46 | 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
47 | 0x74a2, 0x74a2, 0x74a2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x51a0,
48 | 0x41a0, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x70e2,
49 | 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
50 | 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
51 | 0x70e2, 0x70e2, 0x70e2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x4008,
52 | 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
53 | 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
54 | 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
55 | 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
56 | 0x0284, 0x0000, 0x0000, 0x0000, 0x00a0, 0x0000, 0x0000, 0x0000,
57 | 0x0000, 0x0000, 0x0000, 0x0000, 0x01a0, 0x01a0, 0x0000, 0x0000,
58 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
59 | 0x0000, 0x0000, 0x0000, 0x01a0, 0x0000, 0x0000, 0x0000, 0x01a0,
60 | 0x0000, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2,
61 | 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2,
62 | 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2,
63 | 0x30a2, 0x30a2, 0x30a2, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
64 | 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2,
65 | 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2,
66 | 0x30a2, 0x30a2, 0x30a2, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
67 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
68 | };
69 |
70 | static int
71 | is_code_ctype(OnigCodePoint code, unsigned int ctype)
72 | {
73 | if (code < 256)
74 | return ENC_IS_ISO_8859_6_CTYPE(code, ctype);
75 | else
76 | return FALSE;
77 | }
78 |
79 | OnigEncodingType OnigEncodingISO_8859_6 = {
80 | onigenc_single_byte_mbc_enc_len,
81 | "ISO-8859-6", /* name */
82 | 1, /* max enc length */
83 | 1, /* min enc length */
84 | onigenc_is_mbc_newline_0x0a,
85 | onigenc_single_byte_mbc_to_code,
86 | onigenc_single_byte_code_to_mbclen,
87 | onigenc_single_byte_code_to_mbc,
88 | onigenc_ascii_mbc_case_fold,
89 | onigenc_ascii_apply_all_case_fold,
90 | onigenc_ascii_get_case_fold_codes_by_str,
91 | onigenc_minimum_property_name_to_ctype,
92 | is_code_ctype,
93 | onigenc_not_support_get_ctype_code_range,
94 | onigenc_single_byte_left_adjust_char_head,
95 | onigenc_always_true_is_allowed_reverse_match
96 | };
97 |
--------------------------------------------------------------------------------
/deps/onig/enc/iso8859_8.c:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | iso8859_8.c - Oniguruma (regular expression library)
3 | **********************************************************************/
4 | /*-
5 | * Copyright (c) 2002-2007 K.Kosako
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 | #define ENC_IS_ISO_8859_8_CTYPE(code,ctype) \
33 | ((EncISO_8859_8_CtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0)
34 |
35 | static const unsigned short EncISO_8859_8_CtypeTable[256] = {
36 | 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
37 | 0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008,
38 | 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
39 | 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
40 | 0x4284, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
41 | 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
42 | 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0,
43 | 0x78b0, 0x78b0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
44 | 0x41a0, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x74a2,
45 | 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
46 | 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
47 | 0x74a2, 0x74a2, 0x74a2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x51a0,
48 | 0x41a0, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x70e2,
49 | 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
50 | 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
51 | 0x70e2, 0x70e2, 0x70e2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x4008,
52 | 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
53 | 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
54 | 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
55 | 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
56 | 0x0284, 0x0000, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0,
57 | 0x00a0, 0x00a0, 0x00a0, 0x01a0, 0x00a0, 0x01a0, 0x00a0, 0x00a0,
58 | 0x00a0, 0x00a0, 0x10a0, 0x10a0, 0x00a0, 0x30e2, 0x00a0, 0x01a0,
59 | 0x00a0, 0x10a0, 0x00a0, 0x01a0, 0x10a0, 0x10a0, 0x10a0, 0x0000,
60 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
61 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
62 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
63 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x01a0,
64 | 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2,
65 | 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2,
66 | 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2,
67 | 0x30a2, 0x30a2, 0x30a2, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
68 | };
69 |
70 | static int
71 | is_code_ctype(OnigCodePoint code, unsigned int ctype)
72 | {
73 | if (code < 256)
74 | return ENC_IS_ISO_8859_8_CTYPE(code, ctype);
75 | else
76 | return FALSE;
77 | }
78 |
79 | OnigEncodingType OnigEncodingISO_8859_8 = {
80 | onigenc_single_byte_mbc_enc_len,
81 | "ISO-8859-8", /* name */
82 | 1, /* max enc length */
83 | 1, /* min enc length */
84 | onigenc_is_mbc_newline_0x0a,
85 | onigenc_single_byte_mbc_to_code,
86 | onigenc_single_byte_code_to_mbclen,
87 | onigenc_single_byte_code_to_mbc,
88 | onigenc_ascii_mbc_case_fold,
89 | onigenc_ascii_apply_all_case_fold,
90 | onigenc_ascii_get_case_fold_codes_by_str,
91 | onigenc_minimum_property_name_to_ctype,
92 | is_code_ctype,
93 | onigenc_not_support_get_ctype_code_range,
94 | onigenc_single_byte_left_adjust_char_head,
95 | onigenc_always_true_is_allowed_reverse_match
96 | };
97 |
--------------------------------------------------------------------------------
/deps/onig/enc/utf16_be.c:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | utf16_be.c - Oniguruma (regular expression library)
3 | **********************************************************************/
4 | /*-
5 | * Copyright (c) 2002-2008 K.Kosako
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_UTF16[] = {
33 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
34 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
35 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
36 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
37 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
38 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
39 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
40 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
41 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
42 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
43 | 2, 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, 4, 4, 4, 4, 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, 2
49 | };
50 |
51 | static int
52 | utf16be_mbc_enc_len(const UChar* p)
53 | {
54 | return EncLen_UTF16[*p];
55 | }
56 |
57 | static int
58 | utf16be_is_mbc_newline(const UChar* p, const UChar* end)
59 | {
60 | if (p + 1 < end) {
61 | if (*(p+1) == 0x0a && *p == 0x00)
62 | return 1;
63 | #ifdef USE_UNICODE_ALL_LINE_TERMINATORS
64 | if ((
65 | #ifndef USE_CRNL_AS_LINE_TERMINATOR
66 | *(p+1) == 0x0d ||
67 | #endif
68 | *(p+1) == 0x85) && *p == 0x00)
69 | return 1;
70 | if (*p == 0x20 && (*(p+1) == 0x29 || *(p+1) == 0x28))
71 | return 1;
72 | #endif
73 | }
74 | return 0;
75 | }
76 |
77 | static OnigCodePoint
78 | utf16be_mbc_to_code(const UChar* p, const UChar* end ARG_UNUSED)
79 | {
80 | OnigCodePoint code;
81 |
82 | if (UTF16_IS_SURROGATE_FIRST(*p)) {
83 | code = ((((p[0] - 0xd8) << 2) + ((p[1] & 0xc0) >> 6) + 1) << 16)
84 | + ((((p[1] & 0x3f) << 2) + (p[2] - 0xdc)) << 8)
85 | + p[3];
86 | }
87 | else {
88 | code = p[0] * 256 + p[1];
89 | }
90 | return code;
91 | }
92 |
93 | static int
94 | utf16be_code_to_mbclen(OnigCodePoint code)
95 | {
96 | return (code > 0xffff ? 4 : 2);
97 | }
98 |
99 | static int
100 | utf16be_code_to_mbc(OnigCodePoint code, UChar *buf)
101 | {
102 | UChar* p = buf;
103 |
104 | if (code > 0xffff) {
105 | unsigned int plane, high;
106 |
107 | plane = (code >> 16) - 1;
108 | *p++ = (plane >> 2) + 0xd8;
109 | high = (code & 0xff00) >> 8;
110 | *p++ = ((plane & 0x03) << 6) + (high >> 2);
111 | *p++ = (high & 0x03) + 0xdc;
112 | *p = (UChar )(code & 0xff);
113 | return 4;
114 | }
115 | else {
116 | *p++ = (UChar )((code & 0xff00) >> 8);
117 | *p++ = (UChar )(code & 0xff);
118 | return 2;
119 | }
120 | }
121 |
122 | static int
123 | utf16be_mbc_case_fold(OnigCaseFoldType flag,
124 | const UChar** pp, const UChar* end, UChar* fold)
125 | {
126 | const UChar* p = *pp;
127 |
128 | if (ONIGENC_IS_ASCII_CODE(*(p+1)) && *p == 0) {
129 | p++;
130 | #ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI
131 | if ((flag & ONIGENC_CASE_FOLD_TURKISH_AZERI) != 0) {
132 | if (*p == 0x49) {
133 | *fold++ = 0x01;
134 | *fold = 0x31;
135 | (*pp) += 2;
136 | return 2;
137 | }
138 | }
139 | #endif
140 |
141 | *fold++ = 0;
142 | *fold = ONIGENC_ASCII_CODE_TO_LOWER_CASE(*p);
143 | *pp += 2;
144 | return 2;
145 | }
146 | else
147 | return onigenc_unicode_mbc_case_fold(ONIG_ENCODING_UTF16_BE, flag,
148 | pp, end, fold);
149 | }
150 |
151 | #if 0
152 | static int
153 | utf16be_is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end)
154 | {
155 | const UChar* p = *pp;
156 |
157 | (*pp) += EncLen_UTF16[*p];
158 |
159 | if (*p == 0) {
160 | int c, v;
161 |
162 | p++;
163 | if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {
164 | return TRUE;
165 | }
166 |
167 | c = *p;
168 | v = ONIGENC_IS_UNICODE_ISO_8859_1_BIT_CTYPE(c,
169 | (BIT_CTYPE_UPPER | BIT_CTYPE_LOWER));
170 |
171 | if ((v | BIT_CTYPE_LOWER) != 0) {
172 | /* 0xaa, 0xb5, 0xba are lower case letter, but can't convert. */
173 | if (c >= 0xaa && c <= 0xba)
174 | return FALSE;
175 | else
176 | return TRUE;
177 | }
178 | return (v != 0 ? TRUE : FALSE);
179 | }
180 |
181 | return FALSE;
182 | }
183 | #endif
184 |
185 | static UChar*
186 | utf16be_left_adjust_char_head(const UChar* start, const UChar* s)
187 | {
188 | if (s <= start) return (UChar* )s;
189 |
190 | if ((s - start) % 2 == 1) {
191 | s--;
192 | }
193 |
194 | if (UTF16_IS_SURROGATE_SECOND(*s) && s > start + 1)
195 | s -= 2;
196 |
197 | return (UChar* )s;
198 | }
199 |
200 | static int
201 | utf16be_get_case_fold_codes_by_str(OnigCaseFoldType flag,
202 | const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[])
203 | {
204 | return onigenc_unicode_get_case_fold_codes_by_str(ONIG_ENCODING_UTF16_BE,
205 | flag, p, end, items);
206 | }
207 |
208 | OnigEncodingType OnigEncodingUTF16_BE = {
209 | utf16be_mbc_enc_len,
210 | "UTF-16BE", /* name */
211 | 4, /* max byte length */
212 | 2, /* min byte length */
213 | utf16be_is_mbc_newline,
214 | utf16be_mbc_to_code,
215 | utf16be_code_to_mbclen,
216 | utf16be_code_to_mbc,
217 | utf16be_mbc_case_fold,
218 | onigenc_unicode_apply_all_case_fold,
219 | utf16be_get_case_fold_codes_by_str,
220 | onigenc_unicode_property_name_to_ctype,
221 | onigenc_unicode_is_code_ctype,
222 | onigenc_utf16_32_get_ctype_code_range,
223 | utf16be_left_adjust_char_head,
224 | onigenc_always_false_is_allowed_reverse_match
225 | };
226 |
--------------------------------------------------------------------------------
/deps/onig/enc/utf16_le.c:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | utf16_le.c - Oniguruma (regular expression library)
3 | **********************************************************************/
4 | /*-
5 | * Copyright (c) 2002-2008 K.Kosako
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_UTF16[] = {
33 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
34 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
35 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
36 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
37 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
38 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
39 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
40 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
41 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
42 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
43 | 2, 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, 4, 4, 4, 4, 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, 2
49 | };
50 |
51 | static int
52 | utf16le_code_to_mbclen(OnigCodePoint code)
53 | {
54 | return (code > 0xffff ? 4 : 2);
55 | }
56 |
57 | static int
58 | utf16le_mbc_enc_len(const UChar* p)
59 | {
60 | return EncLen_UTF16[*(p+1)];
61 | }
62 |
63 | static int
64 | utf16le_is_mbc_newline(const UChar* p, const UChar* end)
65 | {
66 | if (p + 1 < end) {
67 | if (*p == 0x0a && *(p+1) == 0x00)
68 | return 1;
69 | #ifdef USE_UNICODE_ALL_LINE_TERMINATORS
70 | if ((
71 | #ifndef USE_CRNL_AS_LINE_TERMINATOR
72 | *p == 0x0d ||
73 | #endif
74 | *p == 0x85) && *(p+1) == 0x00)
75 | return 1;
76 | if (*(p+1) == 0x20 && (*p == 0x29 || *p == 0x28))
77 | return 1;
78 | #endif
79 | }
80 | return 0;
81 | }
82 |
83 | static OnigCodePoint
84 | utf16le_mbc_to_code(const UChar* p, const UChar* end ARG_UNUSED)
85 | {
86 | OnigCodePoint code;
87 | UChar c0 = *p;
88 | UChar c1 = *(p+1);
89 |
90 | if (UTF16_IS_SURROGATE_FIRST(c1)) {
91 | code = ((((c1 - 0xd8) << 2) + ((c0 & 0xc0) >> 6) + 1) << 16)
92 | + ((((c0 & 0x3f) << 2) + (p[3] - 0xdc)) << 8)
93 | + p[2];
94 | }
95 | else {
96 | code = c1 * 256 + p[0];
97 | }
98 | return code;
99 | }
100 |
101 | static int
102 | utf16le_code_to_mbc(OnigCodePoint code, UChar *buf)
103 | {
104 | UChar* p = buf;
105 |
106 | if (code > 0xffff) {
107 | unsigned int plane, high;
108 |
109 | plane = (code >> 16) - 1;
110 | high = (code & 0xff00) >> 8;
111 |
112 | *p++ = ((plane & 0x03) << 6) + (high >> 2);
113 | *p++ = (plane >> 2) + 0xd8;
114 | *p++ = (UChar )(code & 0xff);
115 | *p = (high & 0x03) + 0xdc;
116 | return 4;
117 | }
118 | else {
119 | *p++ = (UChar )(code & 0xff);
120 | *p++ = (UChar )((code & 0xff00) >> 8);
121 | return 2;
122 | }
123 | }
124 |
125 | static int
126 | utf16le_mbc_case_fold(OnigCaseFoldType flag,
127 | const UChar** pp, const UChar* end, UChar* fold)
128 | {
129 | const UChar* p = *pp;
130 |
131 | if (ONIGENC_IS_ASCII_CODE(*p) && *(p+1) == 0) {
132 | #ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI
133 | if ((flag & ONIGENC_CASE_FOLD_TURKISH_AZERI) != 0) {
134 | if (*p == 0x49) {
135 | *fold++ = 0x31;
136 | *fold = 0x01;
137 | (*pp) += 2;
138 | return 2;
139 | }
140 | }
141 | #endif
142 |
143 | *fold++ = ONIGENC_ASCII_CODE_TO_LOWER_CASE(*p);
144 | *fold = 0;
145 | *pp += 2;
146 | return 2;
147 | }
148 | else
149 | return onigenc_unicode_mbc_case_fold(ONIG_ENCODING_UTF16_LE, flag, pp, end,
150 | fold);
151 | }
152 |
153 | #if 0
154 | static int
155 | utf16le_is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp,
156 | const UChar* end)
157 | {
158 | const UChar* p = *pp;
159 |
160 | (*pp) += EncLen_UTF16[*(p+1)];
161 |
162 | if (*(p+1) == 0) {
163 | int c, v;
164 |
165 | if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {
166 | return TRUE;
167 | }
168 |
169 | c = *p;
170 | v = ONIGENC_IS_UNICODE_ISO_8859_1_BIT_CTYPE(c,
171 | (BIT_CTYPE_UPPER | BIT_CTYPE_LOWER));
172 | if ((v | BIT_CTYPE_LOWER) != 0) {
173 | /* 0xaa, 0xb5, 0xba are lower case letter, but can't convert. */
174 | if (c >= 0xaa && c <= 0xba)
175 | return FALSE;
176 | else
177 | return TRUE;
178 | }
179 | return (v != 0 ? TRUE : FALSE);
180 | }
181 |
182 | return FALSE;
183 | }
184 | #endif
185 |
186 | static UChar*
187 | utf16le_left_adjust_char_head(const UChar* start, const UChar* s)
188 | {
189 | if (s <= start) return (UChar* )s;
190 |
191 | if ((s - start) % 2 == 1) {
192 | s--;
193 | }
194 |
195 | if (UTF16_IS_SURROGATE_SECOND(*(s+1)) && s > start + 1)
196 | s -= 2;
197 |
198 | return (UChar* )s;
199 | }
200 |
201 | static int
202 | utf16le_get_case_fold_codes_by_str(OnigCaseFoldType flag,
203 | const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[])
204 | {
205 | return onigenc_unicode_get_case_fold_codes_by_str(ONIG_ENCODING_UTF16_LE,
206 | flag, p, end, items);
207 | }
208 |
209 | OnigEncodingType OnigEncodingUTF16_LE = {
210 | utf16le_mbc_enc_len,
211 | "UTF-16LE", /* name */
212 | 4, /* max byte length */
213 | 2, /* min byte length */
214 | utf16le_is_mbc_newline,
215 | utf16le_mbc_to_code,
216 | utf16le_code_to_mbclen,
217 | utf16le_code_to_mbc,
218 | utf16le_mbc_case_fold,
219 | onigenc_unicode_apply_all_case_fold,
220 | utf16le_get_case_fold_codes_by_str,
221 | onigenc_unicode_property_name_to_ctype,
222 | onigenc_unicode_is_code_ctype,
223 | onigenc_utf16_32_get_ctype_code_range,
224 | utf16le_left_adjust_char_head,
225 | onigenc_always_false_is_allowed_reverse_match
226 | };
227 |
--------------------------------------------------------------------------------
/deps/onig/enc/utf32_be.c:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | utf32_be.c - Oniguruma (regular expression library)
3 | **********************************************************************/
4 | /*-
5 | * Copyright (c) 2002-2007 K.Kosako
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 int
33 | utf32be_mbc_enc_len(const UChar* p ARG_UNUSED)
34 | {
35 | return 4;
36 | }
37 |
38 | static int
39 | utf32be_is_mbc_newline(const UChar* p, const UChar* end)
40 | {
41 | if (p + 3 < end) {
42 | if (*(p+3) == 0x0a && *(p+2) == 0 && *(p+1) == 0 && *p == 0)
43 | return 1;
44 | #ifdef USE_UNICODE_ALL_LINE_TERMINATORS
45 | if ((
46 | #ifndef USE_CRNL_AS_LINE_TERMINATOR
47 | *(p+3) == 0x0d ||
48 | #endif
49 | *(p+3) == 0x85)
50 | && *(p+2) == 0 && *(p+1) == 0 && *p == 0x00)
51 | return 1;
52 | if (*(p+2) == 0x20 && (*(p+3) == 0x29 || *(p+3) == 0x28)
53 | && *(p+1) == 0 && *p == 0)
54 | return 1;
55 | #endif
56 | }
57 | return 0;
58 | }
59 |
60 | static OnigCodePoint
61 | utf32be_mbc_to_code(const UChar* p, const UChar* end ARG_UNUSED)
62 | {
63 | return (OnigCodePoint )(((p[0] * 256 + p[1]) * 256 + p[2]) * 256 + p[3]);
64 | }
65 |
66 | static int
67 | utf32be_code_to_mbclen(OnigCodePoint code ARG_UNUSED)
68 | {
69 | return 4;
70 | }
71 |
72 | static int
73 | utf32be_code_to_mbc(OnigCodePoint code, UChar *buf)
74 | {
75 | UChar* p = buf;
76 |
77 | *p++ = (UChar )((code & 0xff000000) >>24);
78 | *p++ = (UChar )((code & 0xff0000) >>16);
79 | *p++ = (UChar )((code & 0xff00) >> 8);
80 | *p++ = (UChar ) (code & 0xff);
81 | return 4;
82 | }
83 |
84 | static int
85 | utf32be_mbc_case_fold(OnigCaseFoldType flag,
86 | const UChar** pp, const UChar* end, UChar* fold)
87 | {
88 | const UChar* p = *pp;
89 |
90 | if (ONIGENC_IS_ASCII_CODE(*(p+3)) && *(p+2) == 0 && *(p+1) == 0 && *p == 0) {
91 | *fold++ = 0;
92 | *fold++ = 0;
93 |
94 | #ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI
95 | if ((flag & ONIGENC_CASE_FOLD_TURKISH_AZERI) != 0) {
96 | if (*(p+3) == 0x49) {
97 | *fold++ = 0x01;
98 | *fold = 0x31;
99 | (*pp) += 4;
100 | return 4;
101 | }
102 | }
103 | #endif
104 |
105 | *fold++ = 0;
106 | *fold = ONIGENC_ASCII_CODE_TO_LOWER_CASE(*(p+3));
107 | *pp += 4;
108 | return 4;
109 | }
110 | else
111 | return onigenc_unicode_mbc_case_fold(ONIG_ENCODING_UTF32_BE, flag, pp, end,
112 | fold);
113 | }
114 |
115 | #if 0
116 | static int
117 | utf32be_is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end)
118 | {
119 | const UChar* p = *pp;
120 |
121 | (*pp) += 4;
122 |
123 | if (*(p+2) == 0 && *(p+1) == 0 && *p == 0) {
124 | int c, v;
125 |
126 | p += 3;
127 | if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {
128 | return TRUE;
129 | }
130 |
131 | c = *p;
132 | v = ONIGENC_IS_UNICODE_ISO_8859_1_BIT_CTYPE(c,
133 | (BIT_CTYPE_UPPER | BIT_CTYPE_LOWER));
134 | if ((v | BIT_CTYPE_LOWER) != 0) {
135 | /* 0xaa, 0xb5, 0xba are lower case letter, but can't convert. */
136 | if (c >= 0xaa && c <= 0xba)
137 | return FALSE;
138 | else
139 | return TRUE;
140 | }
141 | return (v != 0 ? TRUE : FALSE);
142 | }
143 |
144 | return FALSE;
145 | }
146 | #endif
147 |
148 | static UChar*
149 | utf32be_left_adjust_char_head(const UChar* start, const UChar* s)
150 | {
151 | int rem;
152 |
153 | if (s <= start) return (UChar* )s;
154 |
155 | rem = (s - start) % 4;
156 | return (UChar* )(s - rem);
157 | }
158 |
159 | static int
160 | utf32be_get_case_fold_codes_by_str(OnigCaseFoldType flag,
161 | const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[])
162 | {
163 | return onigenc_unicode_get_case_fold_codes_by_str(ONIG_ENCODING_UTF32_BE,
164 | flag, p, end, items);
165 | }
166 |
167 | OnigEncodingType OnigEncodingUTF32_BE = {
168 | utf32be_mbc_enc_len,
169 | "UTF-32BE", /* name */
170 | 4, /* max byte length */
171 | 4, /* min byte length */
172 | utf32be_is_mbc_newline,
173 | utf32be_mbc_to_code,
174 | utf32be_code_to_mbclen,
175 | utf32be_code_to_mbc,
176 | utf32be_mbc_case_fold,
177 | onigenc_unicode_apply_all_case_fold,
178 | utf32be_get_case_fold_codes_by_str,
179 | onigenc_unicode_property_name_to_ctype,
180 | onigenc_unicode_is_code_ctype,
181 | onigenc_utf16_32_get_ctype_code_range,
182 | utf32be_left_adjust_char_head,
183 | onigenc_always_false_is_allowed_reverse_match
184 | };
185 |
--------------------------------------------------------------------------------
/deps/onig/enc/utf32_le.c:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | utf32_le.c - Oniguruma (regular expression library)
3 | **********************************************************************/
4 | /*-
5 | * Copyright (c) 2002-2007 K.Kosako
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 int
33 | utf32le_mbc_enc_len(const UChar* p ARG_UNUSED)
34 | {
35 | return 4;
36 | }
37 |
38 | static int
39 | utf32le_is_mbc_newline(const UChar* p, const UChar* end)
40 | {
41 | if (p + 3 < end) {
42 | if (*p == 0x0a && *(p+1) == 0 && *(p+2) == 0 && *(p+3) == 0)
43 | return 1;
44 | #ifdef USE_UNICODE_ALL_LINE_TERMINATORS
45 | if ((
46 | #ifndef USE_CRNL_AS_LINE_TERMINATOR
47 | *p == 0x0d ||
48 | #endif
49 | *p == 0x85)
50 | && *(p+1) == 0x00 && (p+2) == 0x00 && *(p+3) == 0x00)
51 | return 1;
52 | if (*(p+1) == 0x20 && (*p == 0x29 || *p == 0x28)
53 | && *(p+2) == 0x00 && *(p+3) == 0x00)
54 | return 1;
55 | #endif
56 | }
57 | return 0;
58 | }
59 |
60 | static OnigCodePoint
61 | utf32le_mbc_to_code(const UChar* p, const UChar* end ARG_UNUSED)
62 | {
63 | return (OnigCodePoint )(((p[3] * 256 + p[2]) * 256 + p[1]) * 256 + p[0]);
64 | }
65 |
66 | static int
67 | utf32le_code_to_mbclen(OnigCodePoint code ARG_UNUSED)
68 | {
69 | return 4;
70 | }
71 |
72 | static int
73 | utf32le_code_to_mbc(OnigCodePoint code, UChar *buf)
74 | {
75 | UChar* p = buf;
76 |
77 | *p++ = (UChar ) (code & 0xff);
78 | *p++ = (UChar )((code & 0xff00) >> 8);
79 | *p++ = (UChar )((code & 0xff0000) >>16);
80 | *p++ = (UChar )((code & 0xff000000) >>24);
81 | return 4;
82 | }
83 |
84 | static int
85 | utf32le_mbc_case_fold(OnigCaseFoldType flag,
86 | const UChar** pp, const UChar* end, UChar* fold)
87 | {
88 | const UChar* p = *pp;
89 |
90 | if (ONIGENC_IS_ASCII_CODE(*p) && *(p+1) == 0 && *(p+2) == 0 && *(p+3) == 0) {
91 | #ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI
92 | if ((flag & ONIGENC_CASE_FOLD_TURKISH_AZERI) != 0) {
93 | if (*p == 0x49) {
94 | *fold++ = 0x31;
95 | *fold++ = 0x01;
96 | }
97 | }
98 | else {
99 | #endif
100 | *fold++ = ONIGENC_ASCII_CODE_TO_LOWER_CASE(*p);
101 | *fold++ = 0;
102 | #ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI
103 | }
104 | #endif
105 |
106 | *fold++ = 0;
107 | *fold = 0;
108 | *pp += 4;
109 | return 4;
110 | }
111 | else
112 | return onigenc_unicode_mbc_case_fold(ONIG_ENCODING_UTF32_LE, flag, pp, end,
113 | fold);
114 | }
115 |
116 | #if 0
117 | static int
118 | utf32le_is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end)
119 | {
120 | const UChar* p = *pp;
121 |
122 | (*pp) += 4;
123 |
124 | if (*(p+1) == 0 && *(p+2) == 0 && *(p+3) == 0) {
125 | int c, v;
126 |
127 | if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {
128 | return TRUE;
129 | }
130 |
131 | c = *p;
132 | v = ONIGENC_IS_UNICODE_ISO_8859_1_BIT_CTYPE(c,
133 | (BIT_CTYPE_UPPER | BIT_CTYPE_LOWER));
134 | if ((v | BIT_CTYPE_LOWER) != 0) {
135 | /* 0xaa, 0xb5, 0xba are lower case letter, but can't convert. */
136 | if (c >= 0xaa && c <= 0xba)
137 | return FALSE;
138 | else
139 | return TRUE;
140 | }
141 | return (v != 0 ? TRUE : FALSE);
142 | }
143 |
144 | return FALSE;
145 | }
146 | #endif
147 |
148 | static UChar*
149 | utf32le_left_adjust_char_head(const UChar* start, const UChar* s)
150 | {
151 | int rem;
152 |
153 | if (s <= start) return (UChar* )s;
154 |
155 | rem = (s - start) % 4;
156 | return (UChar* )(s - rem);
157 | }
158 |
159 | static int
160 | utf32le_get_case_fold_codes_by_str(OnigCaseFoldType flag,
161 | const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[])
162 | {
163 | return onigenc_unicode_get_case_fold_codes_by_str(ONIG_ENCODING_UTF32_LE,
164 | flag, p, end, items);
165 | }
166 |
167 | OnigEncodingType OnigEncodingUTF32_LE = {
168 | utf32le_mbc_enc_len,
169 | "UTF-32LE", /* name */
170 | 4, /* max byte length */
171 | 4, /* min byte length */
172 | utf32le_is_mbc_newline,
173 | utf32le_mbc_to_code,
174 | utf32le_code_to_mbclen,
175 | utf32le_code_to_mbc,
176 | utf32le_mbc_case_fold,
177 | onigenc_unicode_apply_all_case_fold,
178 | utf32le_get_case_fold_codes_by_str,
179 | onigenc_unicode_property_name_to_ctype,
180 | onigenc_unicode_is_code_ctype,
181 | onigenc_utf16_32_get_ctype_code_range,
182 | utf32le_left_adjust_char_head,
183 | onigenc_always_false_is_allowed_reverse_match
184 | };
185 |
--------------------------------------------------------------------------------
/deps/onig/index_ja.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 鬼車
5 |
6 |
7 |
8 | 鬼車
9 |
10 |
11 | (c) K.Kosako, 最終更新: 2014/12/12
12 |
13 |
14 |
15 |
16 | - 更新情報
17 |
18 |
19 | - 2014/12/12: Version 5.9.6 リリース
20 | - 2007/08/16: Version 4.7.1 リリース
21 | - 2007/06/20: Version 2.5.9 リリース
22 | - 2007/06/20: 2.xの保守担当者を変更
23 |
24 |
25 |
26 |
27 |
28 | 鬼車は正規表現ライブラリである。
29 | このライブラリの特徴は、それぞれの正規表現オブジェクトごとに異なる文字エンコーディングを
30 | 指定できること。
31 | (API: GNU regex, POSIX and Oniguruma native)
32 |
33 |
34 |
35 | - 対応している文字エンコーディング:
36 | ASCII, UTF-8, UTF-16BE, UTF-16LE, UTF-32BE, UTF-32LE,
37 | EUC-JP, EUC-TW, EUC-KR, EUC-CN,
38 | Shift_JIS, Big5, GB18030, KOI8-R, CP1251,
39 | ISO-8859-1, ISO-8859-2, ISO-8859-3, ISO-8859-4, ISO-8859-5,
40 | ISO-8859-6, ISO-8859-7, ISO-8859-8, ISO-8859-9, ISO-8859-10,
41 | ISO-8859-11, ISO-8859-13, ISO-8859-14, ISO-8859-15, ISO-8859-16
42 |
43 | (GB18030は、KUBO Takehiro氏提供)
44 | (CP1251は、Byte氏提供)
45 |
46 |
47 |
48 |
49 |
50 |
51 | ライセンス:BSDライセンス
52 |
53 |
54 | - プラットフォーム:
55 |
56 | - Unix (Mac OS Xを含む)
57 |
- Cygwin
58 |
- Win32
59 |
60 |
61 |
62 |
63 | - ダウンロード:
64 |
71 |
72 |
73 |
74 | 2.xの保守担当は、Hannes Wyss <hwyss AT ywesee.com>に交替しました。
75 | 2.xについては、彼に連絡してください。
76 |
77 | * 5.xはUnicode Property/Scriptを提供
78 | * 2.xはRuby1.6/1.8組込みライブラリとして動作する。 (2006年末で保守を終了)
79 |
80 |
81 | - ドキュメント: (version 5.9.6)
82 |
88 |
89 |
90 | - サンプルプログラム:
91 |
95 |
96 |
97 | - サイト:
98 |
102 |
103 |
104 | - リンク:
105 |
151 |
152 |
153 | - 参考資料:
154 |
164 |
165 |
166 |
167 |
168 | and I'm thankful to Akinori MUSHA.
169 |
170 |
171 |
172 |
173 | - 他のライブラリ:
174 |
189 |
190 |
191 |
192 | ホームにもどる
193 |
194 |
195 |
--------------------------------------------------------------------------------
/deps/onig/m4/ltsugar.m4:
--------------------------------------------------------------------------------
1 | # ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*-
2 | #
3 | # Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
4 | # Written by Gary V. Vaughan, 2004
5 | #
6 | # This file is free software; the Free Software Foundation gives
7 | # unlimited permission to copy and/or distribute it, with or without
8 | # modifications, as long as this notice is preserved.
9 |
10 | # serial 6 ltsugar.m4
11 |
12 | # This is to help aclocal find these macros, as it can't see m4_define.
13 | AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])])
14 |
15 |
16 | # lt_join(SEP, ARG1, [ARG2...])
17 | # -----------------------------
18 | # Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their
19 | # associated separator.
20 | # Needed until we can rely on m4_join from Autoconf 2.62, since all earlier
21 | # versions in m4sugar had bugs.
22 | m4_define([lt_join],
23 | [m4_if([$#], [1], [],
24 | [$#], [2], [[$2]],
25 | [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])])
26 | m4_define([_lt_join],
27 | [m4_if([$#$2], [2], [],
28 | [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])])
29 |
30 |
31 | # lt_car(LIST)
32 | # lt_cdr(LIST)
33 | # ------------
34 | # Manipulate m4 lists.
35 | # These macros are necessary as long as will still need to support
36 | # Autoconf-2.59 which quotes differently.
37 | m4_define([lt_car], [[$1]])
38 | m4_define([lt_cdr],
39 | [m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
40 | [$#], 1, [],
41 | [m4_dquote(m4_shift($@))])])
42 | m4_define([lt_unquote], $1)
43 |
44 |
45 | # lt_append(MACRO-NAME, STRING, [SEPARATOR])
46 | # ------------------------------------------
47 | # Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'.
48 | # Note that neither SEPARATOR nor STRING are expanded; they are appended
49 | # to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
50 | # No SEPARATOR is output if MACRO-NAME was previously undefined (different
51 | # than defined and empty).
52 | #
53 | # This macro is needed until we can rely on Autoconf 2.62, since earlier
54 | # versions of m4sugar mistakenly expanded SEPARATOR but not STRING.
55 | m4_define([lt_append],
56 | [m4_define([$1],
57 | m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])])
58 |
59 |
60 |
61 | # lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...])
62 | # ----------------------------------------------------------
63 | # Produce a SEP delimited list of all paired combinations of elements of
64 | # PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list
65 | # has the form PREFIXmINFIXSUFFIXn.
66 | # Needed until we can rely on m4_combine added in Autoconf 2.62.
67 | m4_define([lt_combine],
68 | [m4_if(m4_eval([$# > 3]), [1],
69 | [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl
70 | [[m4_foreach([_Lt_prefix], [$2],
71 | [m4_foreach([_Lt_suffix],
72 | ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[,
73 | [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])])
74 |
75 |
76 | # lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ])
77 | # -----------------------------------------------------------------------
78 | # Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited
79 | # by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ.
80 | m4_define([lt_if_append_uniq],
81 | [m4_ifdef([$1],
82 | [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1],
83 | [lt_append([$1], [$2], [$3])$4],
84 | [$5])],
85 | [lt_append([$1], [$2], [$3])$4])])
86 |
87 |
88 | # lt_dict_add(DICT, KEY, VALUE)
89 | # -----------------------------
90 | m4_define([lt_dict_add],
91 | [m4_define([$1($2)], [$3])])
92 |
93 |
94 | # lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE)
95 | # --------------------------------------------
96 | m4_define([lt_dict_add_subkey],
97 | [m4_define([$1($2:$3)], [$4])])
98 |
99 |
100 | # lt_dict_fetch(DICT, KEY, [SUBKEY])
101 | # ----------------------------------
102 | m4_define([lt_dict_fetch],
103 | [m4_ifval([$3],
104 | m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]),
105 | m4_ifdef([$1($2)], [m4_defn([$1($2)])]))])
106 |
107 |
108 | # lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE])
109 | # -----------------------------------------------------------------
110 | m4_define([lt_if_dict_fetch],
111 | [m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4],
112 | [$5],
113 | [$6])])
114 |
115 |
116 | # lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...])
117 | # --------------------------------------------------------------
118 | m4_define([lt_dict_filter],
119 | [m4_if([$5], [], [],
120 | [lt_join(m4_quote(m4_default([$4], [[, ]])),
121 | lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]),
122 | [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl
123 | ])
124 |
--------------------------------------------------------------------------------
/deps/onig/m4/ltversion.m4:
--------------------------------------------------------------------------------
1 | # ltversion.m4 -- version numbers -*- Autoconf -*-
2 | #
3 | # Copyright (C) 2004 Free Software Foundation, Inc.
4 | # Written by Scott James Remnant, 2004
5 | #
6 | # This file is free software; the Free Software Foundation gives
7 | # unlimited permission to copy and/or distribute it, with or without
8 | # modifications, as long as this notice is preserved.
9 |
10 | # @configure_input@
11 |
12 | # serial 3337 ltversion.m4
13 | # This file is part of GNU Libtool
14 |
15 | m4_define([LT_PACKAGE_VERSION], [2.4.2])
16 | m4_define([LT_PACKAGE_REVISION], [1.3337])
17 |
18 | AC_DEFUN([LTVERSION_VERSION],
19 | [macro_version='2.4.2'
20 | macro_revision='1.3337'
21 | _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
22 | _LT_DECL(, macro_revision, 0)
23 | ])
24 |
--------------------------------------------------------------------------------
/deps/onig/m4/lt~obsolete.m4:
--------------------------------------------------------------------------------
1 | # lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*-
2 | #
3 | # Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc.
4 | # Written by Scott James Remnant, 2004.
5 | #
6 | # This file is free software; the Free Software Foundation gives
7 | # unlimited permission to copy and/or distribute it, with or without
8 | # modifications, as long as this notice is preserved.
9 |
10 | # serial 5 lt~obsolete.m4
11 |
12 | # These exist entirely to fool aclocal when bootstrapping libtool.
13 | #
14 | # In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN)
15 | # which have later been changed to m4_define as they aren't part of the
16 | # exported API, or moved to Autoconf or Automake where they belong.
17 | #
18 | # The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN
19 | # in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us
20 | # using a macro with the same name in our local m4/libtool.m4 it'll
21 | # pull the old libtool.m4 in (it doesn't see our shiny new m4_define
22 | # and doesn't know about Autoconf macros at all.)
23 | #
24 | # So we provide this file, which has a silly filename so it's always
25 | # included after everything else. This provides aclocal with the
26 | # AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything
27 | # because those macros already exist, or will be overwritten later.
28 | # We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6.
29 | #
30 | # Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here.
31 | # Yes, that means every name once taken will need to remain here until
32 | # we give up compatibility with versions before 1.7, at which point
33 | # we need to keep only those names which we still refer to.
34 |
35 | # This is to help aclocal find these macros, as it can't see m4_define.
36 | AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])])
37 |
38 | m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])])
39 | m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])])
40 | m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])])
41 | m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])])
42 | m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])])
43 | m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])])
44 | m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])])
45 | m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])])
46 | m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])])
47 | m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])])
48 | m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])])
49 | m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])])
50 | m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])])
51 | m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])])
52 | m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])])
53 | m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])])
54 | m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])])
55 | m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])])
56 | m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])])
57 | m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])])
58 | m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])])
59 | m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])])
60 | m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])])
61 | m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])])
62 | m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])])
63 | m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])])
64 | m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])])
65 | m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])])
66 | m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])])
67 | m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])])
68 | m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])])
69 | m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])])
70 | m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])])
71 | m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])])
72 | m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])])
73 | m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])])
74 | m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])])
75 | m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])])
76 | m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])])
77 | m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])])
78 | m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])])
79 | m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])])
80 | m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])])
81 | m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])])
82 | m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])])
83 | m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])])
84 | m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])])
85 | m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])])
86 | m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])])
87 | m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])])
88 | m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])])
89 | m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])])
90 | m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])])
91 | m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])])
92 | m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])])
93 | m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])])
94 | m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])])
95 | m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])])
96 | m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])])
97 | m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])])
98 | m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])])
99 |
--------------------------------------------------------------------------------
/deps/onig/onig-config:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # Copyright (C) 2006 K.Kosako (sndgk393 AT ybb DOT ne DOT jp)
3 |
4 | ONIG_VERSION=5.9.3
5 |
6 | show_usage()
7 | {
8 | cat <
8 | * All rights reserved.
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions
12 | * are met:
13 | * 1. Redistributions of source code must retain the above copyright
14 | * notice, this list of conditions and the following disclaimer.
15 | * 2. Redistributions in binary form must reproduce the above copyright
16 | * notice, this list of conditions and the following disclaimer in the
17 | * documentation and/or other materials provided with the distribution.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 | * SUCH DAMAGE.
30 | */
31 |
32 | #include "oniguruma.h"
33 |
34 | #ifdef __cplusplus
35 | extern "C" {
36 | #endif
37 |
38 | #define RE_MBCTYPE_ASCII 0
39 | #define RE_MBCTYPE_EUC 1
40 | #define RE_MBCTYPE_SJIS 2
41 | #define RE_MBCTYPE_UTF8 3
42 |
43 | /* GNU regex options */
44 | #ifndef RE_NREGS
45 | #define RE_NREGS ONIG_NREGION
46 | #endif
47 |
48 | #define RE_OPTION_IGNORECASE ONIG_OPTION_IGNORECASE
49 | #define RE_OPTION_EXTENDED ONIG_OPTION_EXTEND
50 | #define RE_OPTION_MULTILINE ONIG_OPTION_MULTILINE
51 | #define RE_OPTION_SINGLELINE ONIG_OPTION_SINGLELINE
52 | #define RE_OPTION_LONGEST ONIG_OPTION_FIND_LONGEST
53 | #define RE_OPTION_POSIXLINE (RE_OPTION_MULTILINE|RE_OPTION_SINGLELINE)
54 | #define RE_OPTION_FIND_NOT_EMPTY ONIG_OPTION_FIND_NOT_EMPTY
55 | #define RE_OPTION_NEGATE_SINGLELINE ONIG_OPTION_NEGATE_SINGLELINE
56 | #define RE_OPTION_DONT_CAPTURE_GROUP ONIG_OPTION_DONT_CAPTURE_GROUP
57 | #define RE_OPTION_CAPTURE_GROUP ONIG_OPTION_CAPTURE_GROUP
58 |
59 |
60 | ONIG_EXTERN
61 | void re_mbcinit P_((int));
62 | ONIG_EXTERN
63 | int re_compile_pattern P_((const char*, int, struct re_pattern_buffer*, char* err_buf));
64 | ONIG_EXTERN
65 | int re_recompile_pattern P_((const char*, int, struct re_pattern_buffer*, char* err_buf));
66 | ONIG_EXTERN
67 | void re_free_pattern P_((struct re_pattern_buffer*));
68 | ONIG_EXTERN
69 | int re_adjust_startpos P_((struct re_pattern_buffer*, const char*, int, int, int));
70 | ONIG_EXTERN
71 | int re_search P_((struct re_pattern_buffer*, const char*, int, int, int, struct re_registers*));
72 | ONIG_EXTERN
73 | int re_match P_((struct re_pattern_buffer*, const char *, int, int, struct re_registers*));
74 | ONIG_EXTERN
75 | void re_set_casetable P_((const char*));
76 | ONIG_EXTERN
77 | void re_free_registers P_((struct re_registers*));
78 | ONIG_EXTERN
79 | int re_alloc_pattern P_((struct re_pattern_buffer**)); /* added */
80 |
81 | #ifdef __cplusplus
82 | }
83 | #endif
84 |
85 | #endif /* ONIGGNU_H */
86 |
--------------------------------------------------------------------------------
/deps/onig/onigposix.h:
--------------------------------------------------------------------------------
1 | #ifndef ONIGPOSIX_H
2 | #define ONIGPOSIX_H
3 | /**********************************************************************
4 | onigposix.h - Oniguruma (regular expression library)
5 | **********************************************************************/
6 | /*-
7 | * Copyright (c) 2002-2005 K.Kosako
8 | * All rights reserved.
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions
12 | * are met:
13 | * 1. Redistributions of source code must retain the above copyright
14 | * notice, this list of conditions and the following disclaimer.
15 | * 2. Redistributions in binary form must reproduce the above copyright
16 | * notice, this list of conditions and the following disclaimer in the
17 | * documentation and/or other materials provided with the distribution.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 | * SUCH DAMAGE.
30 | */
31 | #include
32 |
33 | #ifdef __cplusplus
34 | extern "C" {
35 | #endif
36 |
37 | /* options */
38 | #define REG_ICASE (1<<0)
39 | #define REG_NEWLINE (1<<1)
40 | #define REG_NOTBOL (1<<2)
41 | #define REG_NOTEOL (1<<3)
42 | #define REG_EXTENDED (1<<4) /* if not setted, Basic Onigular Expression */
43 | #define REG_NOSUB (1<<5)
44 |
45 | /* POSIX error codes */
46 | #define REG_NOMATCH 1
47 | #define REG_BADPAT 2
48 | #define REG_ECOLLATE 3
49 | #define REG_ECTYPE 4
50 | #define REG_EESCAPE 5
51 | #define REG_ESUBREG 6
52 | #define REG_EBRACK 7
53 | #define REG_EPAREN 8
54 | #define REG_EBRACE 9
55 | #define REG_BADBR 10
56 | #define REG_ERANGE 11
57 | #define REG_ESPACE 12
58 | #define REG_BADRPT 13
59 |
60 | /* extended error codes */
61 | #define REG_EONIG_INTERNAL 14
62 | #define REG_EONIG_BADWC 15
63 | #define REG_EONIG_BADARG 16
64 | #define REG_EONIG_THREAD 17
65 |
66 | /* character encodings (for reg_set_encoding()) */
67 | #define REG_POSIX_ENCODING_ASCII 0
68 | #define REG_POSIX_ENCODING_EUC_JP 1
69 | #define REG_POSIX_ENCODING_SJIS 2
70 | #define REG_POSIX_ENCODING_UTF8 3
71 | #define REG_POSIX_ENCODING_UTF16_BE 4
72 | #define REG_POSIX_ENCODING_UTF16_LE 5
73 |
74 |
75 | typedef int regoff_t;
76 |
77 | typedef struct {
78 | regoff_t rm_so;
79 | regoff_t rm_eo;
80 | } regmatch_t;
81 |
82 | /* POSIX regex_t */
83 | typedef struct {
84 | void* onig; /* Oniguruma regex_t* */
85 | size_t re_nsub;
86 | int comp_options;
87 | } regex_t;
88 |
89 |
90 | #ifndef P_
91 | #if defined(__STDC__) || defined(_WIN32)
92 | # define P_(args) args
93 | #else
94 | # define P_(args) ()
95 | #endif
96 | #endif
97 |
98 | #ifndef ONIG_EXTERN
99 | #if defined(_WIN32) && !defined(__GNUC__)
100 | #if defined(EXPORT)
101 | #define ONIG_EXTERN extern __declspec(dllexport)
102 | #else
103 | #define ONIG_EXTERN extern __declspec(dllimport)
104 | #endif
105 | #endif
106 | #endif
107 |
108 | #ifndef ONIG_EXTERN
109 | #define ONIG_EXTERN extern
110 | #endif
111 |
112 | #ifndef ONIGURUMA_H
113 | typedef unsigned int OnigOptionType;
114 |
115 | /* syntax */
116 | typedef struct {
117 | unsigned int op;
118 | unsigned int op2;
119 | unsigned int behavior;
120 | OnigOptionType options; /* default option */
121 | } OnigSyntaxType;
122 |
123 | ONIG_EXTERN OnigSyntaxType OnigSyntaxPosixBasic;
124 | ONIG_EXTERN OnigSyntaxType OnigSyntaxPosixExtended;
125 | ONIG_EXTERN OnigSyntaxType OnigSyntaxEmacs;
126 | ONIG_EXTERN OnigSyntaxType OnigSyntaxGrep;
127 | ONIG_EXTERN OnigSyntaxType OnigSyntaxGnuRegex;
128 | ONIG_EXTERN OnigSyntaxType OnigSyntaxJava;
129 | ONIG_EXTERN OnigSyntaxType OnigSyntaxPerl;
130 | ONIG_EXTERN OnigSyntaxType OnigSyntaxRuby;
131 |
132 | /* predefined syntaxes (see regsyntax.c) */
133 | #define ONIG_SYNTAX_POSIX_BASIC (&OnigSyntaxPosixBasic)
134 | #define ONIG_SYNTAX_POSIX_EXTENDED (&OnigSyntaxPosixExtended)
135 | #define ONIG_SYNTAX_EMACS (&OnigSyntaxEmacs)
136 | #define ONIG_SYNTAX_GREP (&OnigSyntaxGrep)
137 | #define ONIG_SYNTAX_GNU_REGEX (&OnigSyntaxGnuRegex)
138 | #define ONIG_SYNTAX_JAVA (&OnigSyntaxJava)
139 | #define ONIG_SYNTAX_PERL (&OnigSyntaxPerl)
140 | #define ONIG_SYNTAX_RUBY (&OnigSyntaxRuby)
141 | /* default syntax */
142 | #define ONIG_SYNTAX_DEFAULT OnigDefaultSyntax
143 |
144 | ONIG_EXTERN OnigSyntaxType* OnigDefaultSyntax;
145 |
146 | ONIG_EXTERN int onig_set_default_syntax P_((OnigSyntaxType* syntax));
147 | ONIG_EXTERN void onig_copy_syntax P_((OnigSyntaxType* to, OnigSyntaxType* from));
148 | ONIG_EXTERN const char* onig_version P_((void));
149 | ONIG_EXTERN const char* onig_copyright P_((void));
150 |
151 | #endif /* ONIGURUMA_H */
152 |
153 |
154 | ONIG_EXTERN int regcomp P_((regex_t* reg, const char* pat, int options));
155 | ONIG_EXTERN int regexec P_((regex_t* reg, const char* str, size_t nmatch, regmatch_t* matches, int options));
156 | ONIG_EXTERN void regfree P_((regex_t* reg));
157 | ONIG_EXTERN size_t regerror P_((int code, const regex_t* reg, char* buf, size_t size));
158 |
159 | /* extended API */
160 | ONIG_EXTERN void reg_set_encoding P_((int enc));
161 | ONIG_EXTERN int reg_name_to_group_numbers P_((regex_t* reg, const unsigned char* name, const unsigned char* name_end, int** nums));
162 | ONIG_EXTERN int reg_foreach_name P_((regex_t* reg, int (*func)(const unsigned char*, const unsigned char*,int,int*,regex_t*,void*), void* arg));
163 | ONIG_EXTERN int reg_number_of_names P_((regex_t* reg));
164 |
165 | #ifdef __cplusplus
166 | }
167 | #endif
168 |
169 | #endif /* ONIGPOSIX_H */
170 |
--------------------------------------------------------------------------------
/deps/onig/oniguruma.pc.in:
--------------------------------------------------------------------------------
1 | prefix=@prefix@
2 | exec_prefix=@exec_prefix@
3 | libdir=@libdir@
4 | includedir=@includedir@
5 | datarootdir=@datarootdir@
6 | datadir=@datadir@
7 |
8 | Name: oniguruma
9 | Description: Regular expression library
10 | Version: @PACKAGE_VERSION@
11 | Requires:
12 | Libs: -L${libdir} -lonig
13 | Cflags: -I${includedir}
14 |
15 |
--------------------------------------------------------------------------------
/deps/onig/regext.c:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | regext.c - Oniguruma (regular expression library)
3 | **********************************************************************/
4 | /*-
5 | * Copyright (c) 2002-2008 K.Kosako
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 "regint.h"
31 |
32 | static void
33 | conv_ext0be32(const UChar* s, const UChar* end, UChar* conv)
34 | {
35 | while (s < end) {
36 | *conv++ = '\0';
37 | *conv++ = '\0';
38 | *conv++ = '\0';
39 | *conv++ = *s++;
40 | }
41 | }
42 |
43 | static void
44 | conv_ext0le32(const UChar* s, const UChar* end, UChar* conv)
45 | {
46 | while (s < end) {
47 | *conv++ = *s++;
48 | *conv++ = '\0';
49 | *conv++ = '\0';
50 | *conv++ = '\0';
51 | }
52 | }
53 |
54 | static void
55 | conv_ext0be(const UChar* s, const UChar* end, UChar* conv)
56 | {
57 | while (s < end) {
58 | *conv++ = '\0';
59 | *conv++ = *s++;
60 | }
61 | }
62 |
63 | static void
64 | conv_ext0le(const UChar* s, const UChar* end, UChar* conv)
65 | {
66 | while (s < end) {
67 | *conv++ = *s++;
68 | *conv++ = '\0';
69 | }
70 | }
71 |
72 | static void
73 | conv_swap4bytes(const UChar* s, const UChar* end, UChar* conv)
74 | {
75 | while (s < end) {
76 | *conv++ = s[3];
77 | *conv++ = s[2];
78 | *conv++ = s[1];
79 | *conv++ = s[0];
80 | s += 4;
81 | }
82 | }
83 |
84 | static void
85 | conv_swap2bytes(const UChar* s, const UChar* end, UChar* conv)
86 | {
87 | while (s < end) {
88 | *conv++ = s[1];
89 | *conv++ = s[0];
90 | s += 2;
91 | }
92 | }
93 |
94 | static int
95 | conv_encoding(OnigEncoding from, OnigEncoding to, const UChar* s, const UChar* end,
96 | UChar** conv, UChar** conv_end)
97 | {
98 | int len = end - s;
99 |
100 | if (to == ONIG_ENCODING_UTF16_BE) {
101 | if (from == ONIG_ENCODING_ASCII || from == ONIG_ENCODING_ISO_8859_1) {
102 | *conv = (UChar* )xmalloc(len * 2);
103 | CHECK_NULL_RETURN_MEMERR(*conv);
104 | *conv_end = *conv + (len * 2);
105 | conv_ext0be(s, end, *conv);
106 | return 0;
107 | }
108 | else if (from == ONIG_ENCODING_UTF16_LE) {
109 | swap16:
110 | *conv = (UChar* )xmalloc(len);
111 | CHECK_NULL_RETURN_MEMERR(*conv);
112 | *conv_end = *conv + len;
113 | conv_swap2bytes(s, end, *conv);
114 | return 0;
115 | }
116 | }
117 | else if (to == ONIG_ENCODING_UTF16_LE) {
118 | if (from == ONIG_ENCODING_ASCII || from == ONIG_ENCODING_ISO_8859_1) {
119 | *conv = (UChar* )xmalloc(len * 2);
120 | CHECK_NULL_RETURN_MEMERR(*conv);
121 | *conv_end = *conv + (len * 2);
122 | conv_ext0le(s, end, *conv);
123 | return 0;
124 | }
125 | else if (from == ONIG_ENCODING_UTF16_BE) {
126 | goto swap16;
127 | }
128 | }
129 | if (to == ONIG_ENCODING_UTF32_BE) {
130 | if (from == ONIG_ENCODING_ASCII || from == ONIG_ENCODING_ISO_8859_1) {
131 | *conv = (UChar* )xmalloc(len * 4);
132 | CHECK_NULL_RETURN_MEMERR(*conv);
133 | *conv_end = *conv + (len * 4);
134 | conv_ext0be32(s, end, *conv);
135 | return 0;
136 | }
137 | else if (from == ONIG_ENCODING_UTF32_LE) {
138 | swap32:
139 | *conv = (UChar* )xmalloc(len);
140 | CHECK_NULL_RETURN_MEMERR(*conv);
141 | *conv_end = *conv + len;
142 | conv_swap4bytes(s, end, *conv);
143 | return 0;
144 | }
145 | }
146 | else if (to == ONIG_ENCODING_UTF32_LE) {
147 | if (from == ONIG_ENCODING_ASCII || from == ONIG_ENCODING_ISO_8859_1) {
148 | *conv = (UChar* )xmalloc(len * 4);
149 | CHECK_NULL_RETURN_MEMERR(*conv);
150 | *conv_end = *conv + (len * 4);
151 | conv_ext0le32(s, end, *conv);
152 | return 0;
153 | }
154 | else if (from == ONIG_ENCODING_UTF32_BE) {
155 | goto swap32;
156 | }
157 | }
158 |
159 | return ONIGERR_NOT_SUPPORTED_ENCODING_COMBINATION;
160 | }
161 |
162 | extern int
163 | onig_new_deluxe(regex_t** reg, const UChar* pattern, const UChar* pattern_end,
164 | OnigCompileInfo* ci, OnigErrorInfo* einfo)
165 | {
166 | int r;
167 | UChar *cpat, *cpat_end;
168 |
169 | if (IS_NOT_NULL(einfo)) einfo->par = (UChar* )NULL;
170 |
171 | if (ci->pattern_enc != ci->target_enc) {
172 | r = conv_encoding(ci->pattern_enc, ci->target_enc, pattern, pattern_end,
173 | &cpat, &cpat_end);
174 | if (r) return r;
175 | }
176 | else {
177 | cpat = (UChar* )pattern;
178 | cpat_end = (UChar* )pattern_end;
179 | }
180 |
181 | *reg = (regex_t* )xmalloc(sizeof(regex_t));
182 | if (IS_NULL(*reg)) {
183 | r = ONIGERR_MEMORY;
184 | goto err2;
185 | }
186 |
187 | r = onig_reg_init(*reg, ci->option, ci->case_fold_flag, ci->target_enc,
188 | ci->syntax);
189 | if (r) goto err;
190 |
191 | r = onig_compile(*reg, cpat, cpat_end, einfo);
192 | if (r) {
193 | err:
194 | onig_free(*reg);
195 | *reg = NULL;
196 | }
197 |
198 | err2:
199 | if (cpat != pattern) xfree(cpat);
200 |
201 | return r;
202 | }
203 |
204 | #ifdef USE_RECOMPILE_API
205 | extern int
206 | onig_recompile_deluxe(regex_t* reg, const UChar* pattern, const UChar* pattern_end,
207 | OnigCompileInfo* ci, OnigErrorInfo* einfo)
208 | {
209 | int r;
210 | regex_t *new_reg;
211 |
212 | r = onig_new_deluxe(&new_reg, pattern, pattern_end, ci, einfo);
213 | if (r) return r;
214 | if (ONIG_STATE(reg) == ONIG_STATE_NORMAL) {
215 | onig_transfer(reg, new_reg);
216 | }
217 | else {
218 | onig_chain_link_add(reg, new_reg);
219 | }
220 | return 0;
221 | }
222 | #endif
223 |
--------------------------------------------------------------------------------
/deps/onig/reggnu.c:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | reggnu.c - Oniguruma (regular expression library)
3 | **********************************************************************/
4 | /*-
5 | * Copyright (c) 2002-2008 K.Kosako
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 "regint.h"
31 |
32 | #ifndef ONIGGNU_H
33 | #include "oniggnu.h"
34 | #endif
35 |
36 | extern void
37 | re_free_registers(OnigRegion* r)
38 | {
39 | /* 0: don't free self */
40 | onig_region_free(r, 0);
41 | }
42 |
43 | extern int
44 | re_adjust_startpos(regex_t* reg, const char* string, int size,
45 | int startpos, int range)
46 | {
47 | if (startpos > 0 && ONIGENC_MBC_MAXLEN(reg->enc) != 1 && startpos < size) {
48 | UChar *p;
49 | UChar *s = (UChar* )string + startpos;
50 |
51 | if (range > 0) {
52 | p = onigenc_get_right_adjust_char_head(reg->enc, (UChar* )string, s);
53 | }
54 | else {
55 | p = ONIGENC_LEFT_ADJUST_CHAR_HEAD(reg->enc, (UChar* )string, s);
56 | }
57 | return p - (UChar* )string;
58 | }
59 |
60 | return startpos;
61 | }
62 |
63 | extern int
64 | re_match(regex_t* reg, const char* str, int size, int pos,
65 | struct re_registers* regs)
66 | {
67 | return onig_match(reg, (UChar* )str, (UChar* )(str + size),
68 | (UChar* )(str + pos), regs, ONIG_OPTION_NONE);
69 | }
70 |
71 | extern int
72 | re_search(regex_t* bufp, const char* string, int size, int startpos, int range,
73 | struct re_registers* regs)
74 | {
75 | return onig_search(bufp, (UChar* )string, (UChar* )(string + size),
76 | (UChar* )(string + startpos),
77 | (UChar* )(string + startpos + range),
78 | regs, ONIG_OPTION_NONE);
79 | }
80 |
81 | extern int
82 | re_compile_pattern(const char* pattern, int size, regex_t* reg, char* ebuf)
83 | {
84 | int r;
85 | OnigErrorInfo einfo;
86 |
87 | r = onig_compile(reg, (UChar* )pattern, (UChar* )(pattern + size), &einfo);
88 | if (r != ONIG_NORMAL) {
89 | if (IS_NOT_NULL(ebuf))
90 | (void )onig_error_code_to_str((UChar* )ebuf, r, &einfo);
91 | }
92 |
93 | return r;
94 | }
95 |
96 | #ifdef USE_RECOMPILE_API
97 | extern int
98 | re_recompile_pattern(const char* pattern, int size, regex_t* reg, char* ebuf)
99 | {
100 | int r;
101 | OnigErrorInfo einfo;
102 | OnigEncoding enc;
103 |
104 | /* I think encoding and options should be arguments of this function.
105 | But this is adapted to present re.c. (2002/11/29)
106 | */
107 | enc = OnigEncDefaultCharEncoding;
108 |
109 | r = onig_recompile(reg, (UChar* )pattern, (UChar* )(pattern + size),
110 | reg->options, enc, OnigDefaultSyntax, &einfo);
111 | if (r != ONIG_NORMAL) {
112 | if (IS_NOT_NULL(ebuf))
113 | (void )onig_error_code_to_str((UChar* )ebuf, r, &einfo);
114 | }
115 | return r;
116 | }
117 | #endif
118 |
119 | extern void
120 | re_free_pattern(regex_t* reg)
121 | {
122 | onig_free(reg);
123 | }
124 |
125 | extern int
126 | re_alloc_pattern(regex_t** reg)
127 | {
128 | *reg = (regex_t* )xmalloc(sizeof(regex_t));
129 | if (IS_NULL(*reg)) return ONIGERR_MEMORY;
130 |
131 | return onig_reg_init(*reg, ONIG_OPTION_DEFAULT,
132 | ONIGENC_CASE_FOLD_DEFAULT,
133 | OnigEncDefaultCharEncoding,
134 | OnigDefaultSyntax);
135 | }
136 |
137 | extern void
138 | re_set_casetable(const char* table)
139 | {
140 | onigenc_set_default_caseconv_table((UChar* )table);
141 | }
142 |
143 | extern void
144 | re_mbcinit(int mb_code)
145 | {
146 | OnigEncoding enc;
147 |
148 | switch (mb_code) {
149 | case RE_MBCTYPE_ASCII:
150 | enc = ONIG_ENCODING_ASCII;
151 | break;
152 | case RE_MBCTYPE_EUC:
153 | enc = ONIG_ENCODING_EUC_JP;
154 | break;
155 | case RE_MBCTYPE_SJIS:
156 | enc = ONIG_ENCODING_SJIS;
157 | break;
158 | case RE_MBCTYPE_UTF8:
159 | enc = ONIG_ENCODING_UTF8;
160 | break;
161 | default:
162 | return ;
163 | break;
164 | }
165 |
166 | onigenc_set_default_encoding(enc);
167 | }
168 |
--------------------------------------------------------------------------------
/deps/onig/regposerr.c:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | regposerr.c - Oniguruma (regular expression library)
3 | **********************************************************************/
4 | /*-
5 | * Copyright (c) 2002-2007 K.Kosako
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 "config.h"
31 | #include "onigposix.h"
32 |
33 | #ifdef HAVE_STRING_H
34 | # include
35 | #else
36 | # include
37 | #endif
38 |
39 | #if defined(__GNUC__)
40 | # define ARG_UNUSED __attribute__ ((unused))
41 | #else
42 | # define ARG_UNUSED
43 | #endif
44 |
45 | static char* ESTRING[] = {
46 | NULL,
47 | "failed to match", /* REG_NOMATCH */
48 | "Invalid regular expression", /* REG_BADPAT */
49 | "invalid collating element referenced", /* REG_ECOLLATE */
50 | "invalid character class type referenced", /* REG_ECTYPE */
51 | "bad backslash-escape sequence", /* REG_EESCAPE */
52 | "invalid back reference number", /* REG_ESUBREG */
53 | "imbalanced [ and ]", /* REG_EBRACK */
54 | "imbalanced ( and )", /* REG_EPAREN */
55 | "imbalanced { and }", /* REG_EBRACE */
56 | "invalid repeat range {n,m}", /* REG_BADBR */
57 | "invalid range", /* REG_ERANGE */
58 | "Out of memory", /* REG_ESPACE */
59 | "? * + not preceded by valid regular expression", /* REG_BADRPT */
60 |
61 | /* Extended errors */
62 | "internal error", /* REG_EONIG_INTERNAL */
63 | "invalid wide char value", /* REG_EONIG_BADWC */
64 | "invalid argument", /* REG_EONIG_BADARG */
65 | "multi-thread error" /* REG_EONIG_THREAD */
66 | };
67 |
68 | #include
69 |
70 |
71 | extern size_t
72 | regerror(int posix_ecode, const regex_t* reg ARG_UNUSED, char* buf,
73 | size_t size)
74 | {
75 | char* s;
76 | char tbuf[35];
77 | size_t len;
78 |
79 | if (posix_ecode > 0
80 | && posix_ecode < (int )(sizeof(ESTRING) / sizeof(ESTRING[0]))) {
81 | s = ESTRING[posix_ecode];
82 | }
83 | else if (posix_ecode == 0) {
84 | s = "";
85 | }
86 | else {
87 | sprintf(tbuf, "undefined error code (%d)", posix_ecode);
88 | s = tbuf;
89 | }
90 |
91 | len = strlen(s) + 1; /* use strlen() because s is ascii encoding. */
92 |
93 | if (buf != NULL && size > 0) {
94 | strncpy(buf, s, size - 1);
95 | buf[size - 1] = '\0';
96 | }
97 | return len;
98 | }
99 |
--------------------------------------------------------------------------------
/deps/onig/regtrav.c:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | regtrav.c - Oniguruma (regular expression library)
3 | **********************************************************************/
4 | /*-
5 | * Copyright (c) 2002-2004 K.Kosako
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 "regint.h"
31 |
32 | #ifdef USE_CAPTURE_HISTORY
33 |
34 | static int
35 | capture_tree_traverse(OnigCaptureTreeNode* node, int at,
36 | int(*callback_func)(int,int,int,int,int,void*),
37 | int level, void* arg)
38 | {
39 | int r, i;
40 |
41 | if (node == (OnigCaptureTreeNode* )0)
42 | return 0;
43 |
44 | if ((at & ONIG_TRAVERSE_CALLBACK_AT_FIRST) != 0) {
45 | r = (*callback_func)(node->group, node->beg, node->end,
46 | level, ONIG_TRAVERSE_CALLBACK_AT_FIRST, arg);
47 | if (r != 0) return r;
48 | }
49 |
50 | for (i = 0; i < node->num_childs; i++) {
51 | r = capture_tree_traverse(node->childs[i], at,
52 | callback_func, level + 1, arg);
53 | if (r != 0) return r;
54 | }
55 |
56 | if ((at & ONIG_TRAVERSE_CALLBACK_AT_LAST) != 0) {
57 | r = (*callback_func)(node->group, node->beg, node->end,
58 | level, ONIG_TRAVERSE_CALLBACK_AT_LAST, arg);
59 | if (r != 0) return r;
60 | }
61 |
62 | return 0;
63 | }
64 | #endif /* USE_CAPTURE_HISTORY */
65 |
66 | extern int
67 | onig_capture_tree_traverse(OnigRegion* region, int at,
68 | int(*callback_func)(int,int,int,int,int,void*), void* arg)
69 | {
70 | #ifdef USE_CAPTURE_HISTORY
71 | return capture_tree_traverse(region->history_root, at,
72 | callback_func, 0, arg);
73 | #else
74 | return ONIG_NO_SUPPORT_CONFIG;
75 | #endif
76 | }
77 |
--------------------------------------------------------------------------------
/deps/onig/regversion.c:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | regversion.c - Oniguruma (regular expression library)
3 | **********************************************************************/
4 | /*-
5 | * Copyright (c) 2002-2008 K.Kosako
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 "config.h"
31 | #include "oniguruma.h"
32 | #include
33 |
34 | extern const char*
35 | onig_version(void)
36 | {
37 | static char s[12];
38 |
39 | sprintf(s, "%d.%d.%d",
40 | ONIGURUMA_VERSION_MAJOR,
41 | ONIGURUMA_VERSION_MINOR,
42 | ONIGURUMA_VERSION_TEENY);
43 | return s;
44 | }
45 |
46 | extern const char*
47 | onig_copyright(void)
48 | {
49 | static char s[58];
50 |
51 | sprintf(s, "Oniguruma %d.%d.%d : Copyright (C) 2002-2008 K.Kosako",
52 | ONIGURUMA_VERSION_MAJOR,
53 | ONIGURUMA_VERSION_MINOR,
54 | ONIGURUMA_VERSION_TEENY);
55 | return s;
56 | }
57 |
--------------------------------------------------------------------------------
/deps/onig/sample/Makefile.am:
--------------------------------------------------------------------------------
1 | noinst_PROGRAMS = encode listcap names posix simple sql syntax crnl
2 |
3 | libname = $(top_builddir)/libonig.la
4 | LDADD = $(libname)
5 | INCLUDES = -I$(top_srcdir) -I$(includedir)
6 |
7 | encode_SOURCES = encode.c
8 | listcap_SOURCES = listcap.c
9 | names_SOURCES = names.c
10 | posix_SOURCES = posix.c
11 | simple_SOURCES = simple.c
12 | sql_SOURCES = sql.c
13 | syntax_SOURCES = syntax.c
14 |
15 |
16 | sampledir = $(top_builddir)/sample
17 |
18 | test: encode listcap names posix simple sql syntax
19 | @$(sampledir)/encode
20 | @$(sampledir)/listcap
21 | @$(sampledir)/names
22 | @$(sampledir)/posix
23 | @$(sampledir)/simple
24 | @$(sampledir)/sql
25 | @$(sampledir)/syntax
26 |
--------------------------------------------------------------------------------
/deps/onig/sample/crnl.c:
--------------------------------------------------------------------------------
1 | /*
2 | * crnl.c 2007/05/30 K.Kosako
3 | *
4 | * !!! You should enable USE_CRNL_AS_LINE_TERMINATOR. !!!
5 | *
6 | * USE_CRNL_AS_LINE_TERMINATOR config test program.
7 | */
8 | #include
9 | #include
10 | #include "oniguruma.h"
11 |
12 | static int nfail = 0;
13 |
14 | static void result(int no, int from, int to,
15 | int expected_from, int expected_to)
16 | {
17 | fprintf(stderr, "%3d: ", no);
18 | if (from == expected_from && to == expected_to) {
19 | fprintf(stderr, "Success\n");
20 | }
21 | else {
22 | fprintf(stderr, "Fail: expected: (%d-%d), result: (%d-%d)\n",
23 | expected_from, expected_to, from, to);
24 |
25 | nfail++;
26 | }
27 | }
28 |
29 | static int
30 | x(int no, char* pattern_arg, char* str_arg,
31 | int expected_from, int expected_to)
32 | {
33 | int r;
34 | unsigned char *start, *range, *end;
35 | regex_t* reg;
36 | OnigErrorInfo einfo;
37 | OnigRegion *region;
38 | UChar *pattern, *str;
39 |
40 | pattern = (UChar* )pattern_arg;
41 | str = (UChar* )str_arg;
42 |
43 | r = onig_new(®, pattern, pattern + strlen((char* )pattern),
44 | ONIG_OPTION_DEFAULT, ONIG_ENCODING_ASCII, ONIG_SYNTAX_DEFAULT, &einfo);
45 | if (r != ONIG_NORMAL) {
46 | char s[ONIG_MAX_ERROR_MESSAGE_LEN];
47 | onig_error_code_to_str(s, r, &einfo);
48 | fprintf(stderr, "ERROR: %s\n", s);
49 | return -1;
50 | }
51 |
52 | region = onig_region_new();
53 |
54 | end = str + strlen((char* )str);
55 | start = str;
56 | range = end;
57 | r = onig_search(reg, str, end, start, range, region, ONIG_OPTION_NONE);
58 | if (r >= 0 || r == ONIG_MISMATCH) {
59 | result(no, region->beg[0], region->end[0], expected_from, expected_to);
60 | }
61 | else if (r == ONIG_MISMATCH) {
62 | result(no, r, -1, expected_from, expected_to);
63 | }
64 | else { /* error */
65 | char s[ONIG_MAX_ERROR_MESSAGE_LEN];
66 | onig_error_code_to_str(s, r);
67 | fprintf(stderr, "ERROR: %s\n", s);
68 | return -1;
69 | }
70 |
71 | onig_region_free(region, 1 /* 1:free self, 0:free contents only */);
72 | onig_free(reg);
73 | return 0;
74 | }
75 |
76 | static int
77 | f(int no, char* pattern_arg, char* str_arg)
78 | {
79 | return x(no, pattern_arg, str_arg, -1, -1);
80 | }
81 |
82 | extern int main(int argc, char* argv[])
83 | {
84 | x( 1, "", "\r\n", 0, 0);
85 | x( 2, ".", "\r\n", 0, 1);
86 | f( 3, "..", "\r\n");
87 | x( 4, "^", "\r\n", 0, 0);
88 | x( 5, "\\n^", "\r\nf", 1, 2);
89 | x( 6, "\\n^a", "\r\na", 1, 3);
90 | x( 7, "$", "\r\n", 0, 0);
91 | x( 8, "T$", "T\r\n", 0, 1);
92 | x( 9, "T$", "T\raT\r\n", 3, 4);
93 | x(10, "\\z", "\r\n", 2, 2);
94 | f(11, "a\\z", "a\r\n");
95 | x(12, "\\Z", "\r\n", 0, 0);
96 | x(13, "\\Z", "\r\na", 3, 3);
97 | x(14, "\\Z", "\r\n\r\n\n", 4, 4);
98 | x(15, "\\Z", "\r\n\r\nX", 5, 5);
99 | x(16, "a\\Z", "a\r\n", 0, 1);
100 | x(17, "aaaaaaaaaaaaaaa\\Z", "aaaaaaaaaaaaaaa\r\n", 0, 15);
101 | x(18, "a|$", "b\r\n", 1, 1);
102 | x(19, "$|b", "\rb", 1, 2);
103 | x(20, "a$|ab$", "\r\nab\r\n", 2, 4);
104 |
105 | x(21, "a|\\Z", "b\r\n", 1, 1);
106 | x(22, "\\Z|b", "\rb", 1, 2);
107 | x(23, "a\\Z|ab\\Z", "\r\nab\r\n", 2, 4);
108 | x(24, "(?=a$).", "a\r\n", 0, 1);
109 | f(25, "(?=a$).", "a\r");
110 | x(26, "(?!a$)..", "a\r", 0, 2);
111 | x(27, "(?<=a$).\\n", "a\r\n", 1, 3);
112 | f(28, "(? 0) {
120 | fprintf(stderr, "\n");
121 | fprintf(stderr, "!!! You have to enable USE_CRNL_AS_LINE_TERMINATOR\n");
122 | fprintf(stderr, "!!! in regenc.h for this test program.\n");
123 | fprintf(stderr, "\n");
124 | }
125 |
126 | return 0;
127 | }
128 |
--------------------------------------------------------------------------------
/deps/onig/sample/listcap.c:
--------------------------------------------------------------------------------
1 | /*
2 | * listcap.c
3 | *
4 | * capture history (?@...) sample.
5 | */
6 | #include
7 | #include
8 | #include "oniguruma.h"
9 |
10 | static int
11 | node_callback(int group, int beg, int end, int level, int at, void* arg)
12 | {
13 | int i;
14 |
15 | if (at != ONIG_TRAVERSE_CALLBACK_AT_FIRST)
16 | return -1; /* error */
17 |
18 | /* indent */
19 | for (i = 0; i < level * 2; i++)
20 | fputc(' ', stderr);
21 |
22 | fprintf(stderr, "%d: (%d-%d)\n", group, beg, end);
23 | return 0;
24 | }
25 |
26 | extern int ex(unsigned char* str, unsigned char* pattern,
27 | OnigSyntaxType* syntax)
28 | {
29 | int r;
30 | unsigned char *start, *range, *end;
31 | regex_t* reg;
32 | OnigErrorInfo einfo;
33 | OnigRegion *region;
34 |
35 | r = onig_new(®, pattern, pattern + strlen((char* )pattern),
36 | ONIG_OPTION_DEFAULT, ONIG_ENCODING_ASCII, syntax, &einfo);
37 | if (r != ONIG_NORMAL) {
38 | char s[ONIG_MAX_ERROR_MESSAGE_LEN];
39 | onig_error_code_to_str(s, r, &einfo);
40 | fprintf(stderr, "ERROR: %s\n", s);
41 | return -1;
42 | }
43 |
44 | fprintf(stderr, "number of captures: %d\n", onig_number_of_captures(reg));
45 | fprintf(stderr, "number of capture histories: %d\n",
46 | onig_number_of_capture_histories(reg));
47 |
48 | region = onig_region_new();
49 |
50 | end = str + strlen((char* )str);
51 | start = str;
52 | range = end;
53 | r = onig_search(reg, str, end, start, range, region, ONIG_OPTION_NONE);
54 | if (r >= 0) {
55 | int i;
56 |
57 | fprintf(stderr, "match at %d\n", r);
58 | for (i = 0; i < region->num_regs; i++) {
59 | fprintf(stderr, "%d: (%d-%d)\n", i, region->beg[i], region->end[i]);
60 | }
61 | fprintf(stderr, "\n");
62 |
63 | r = onig_capture_tree_traverse(region, ONIG_TRAVERSE_CALLBACK_AT_FIRST,
64 | node_callback, (void* )0);
65 | }
66 | else if (r == ONIG_MISMATCH) {
67 | fprintf(stderr, "search fail\n");
68 | }
69 | else { /* error */
70 | char s[ONIG_MAX_ERROR_MESSAGE_LEN];
71 | onig_error_code_to_str(s, r);
72 | return -1;
73 | }
74 |
75 | onig_region_free(region, 1 /* 1:free self, 0:free contents only */);
76 | onig_free(reg);
77 | return 0;
78 | }
79 |
80 |
81 | extern int main(int argc, char* argv[])
82 | {
83 | int r;
84 | OnigSyntaxType syn;
85 |
86 | static UChar* str1 = (UChar* )"((())())";
87 | static UChar* pattern1
88 | = (UChar* )"\\g(?@
\\(\\g\\)){0}(?@(?:\\g
)*|){0}";
89 |
90 | static UChar* str2 = (UChar* )"x00x00x00";
91 | static UChar* pattern2 = (UChar* )"(?@x(?@\\d+))+";
92 |
93 | static UChar* str3 = (UChar* )"0123";
94 | static UChar* pattern3 = (UChar* )"(?@.)(?@.)(?@.)(?@.)";
95 |
96 | /* enable capture hostory */
97 | onig_copy_syntax(&syn, ONIG_SYNTAX_DEFAULT);
98 | onig_set_syntax_op2(&syn,
99 | onig_get_syntax_op2(&syn) | ONIG_SYN_OP2_ATMARK_CAPTURE_HISTORY);
100 |
101 | r = ex(str1, pattern1, &syn);
102 | r = ex(str2, pattern2, &syn);
103 | r = ex(str3, pattern3, &syn);
104 |
105 | onig_end();
106 | return r;
107 | }
108 |
--------------------------------------------------------------------------------
/deps/onig/sample/names.c:
--------------------------------------------------------------------------------
1 | /*
2 | * names.c -- example of group name callback.
3 | */
4 | #include
5 | #include
6 | #include "oniguruma.h"
7 |
8 | static int
9 | name_callback(const UChar* name, const UChar* name_end,
10 | int ngroup_num, int* group_nums,
11 | regex_t* reg, void* arg)
12 | {
13 | int i, gn, ref;
14 | char* s;
15 | OnigRegion *region = (OnigRegion* )arg;
16 |
17 | for (i = 0; i < ngroup_num; i++) {
18 | gn = group_nums[i];
19 | ref = onig_name_to_backref_number(reg, name, name_end, region);
20 | s = (ref == gn ? "*" : "");
21 | fprintf(stderr, "%s (%d): ", name, gn);
22 | fprintf(stderr, "(%d-%d) %s\n", region->beg[gn], region->end[gn], s);
23 | }
24 | return 0; /* 0: continue */
25 | }
26 |
27 | extern int main(int argc, char* argv[])
28 | {
29 | int r;
30 | unsigned char *start, *range, *end;
31 | regex_t* reg;
32 | OnigErrorInfo einfo;
33 | OnigRegion *region;
34 |
35 | static UChar* pattern = (UChar* )"(?a*)(?b*)(?c*)";
36 | static UChar* str = (UChar* )"aaabbbbcc";
37 |
38 | r = onig_new(®, pattern, pattern + strlen((char* )pattern),
39 | ONIG_OPTION_DEFAULT, ONIG_ENCODING_ASCII, ONIG_SYNTAX_DEFAULT, &einfo);
40 | if (r != ONIG_NORMAL) {
41 | char s[ONIG_MAX_ERROR_MESSAGE_LEN];
42 | onig_error_code_to_str(s, r, &einfo);
43 | fprintf(stderr, "ERROR: %s\n", s);
44 | return -1;
45 | }
46 |
47 | fprintf(stderr, "number of names: %d\n", onig_number_of_names(reg));
48 |
49 | region = onig_region_new();
50 |
51 | end = str + strlen((char* )str);
52 | start = str;
53 | range = end;
54 | r = onig_search(reg, str, end, start, range, region, ONIG_OPTION_NONE);
55 | if (r >= 0) {
56 | fprintf(stderr, "match at %d\n\n", r);
57 | r = onig_foreach_name(reg, name_callback, (void* )region);
58 | }
59 | else if (r == ONIG_MISMATCH) {
60 | fprintf(stderr, "search fail\n");
61 | }
62 | else { /* error */
63 | char s[ONIG_MAX_ERROR_MESSAGE_LEN];
64 | onig_error_code_to_str(s, r);
65 | return -1;
66 | }
67 |
68 | onig_region_free(region, 1 /* 1:free self, 0:free contents only */);
69 | onig_free(reg);
70 | onig_end();
71 | return 0;
72 | }
73 |
--------------------------------------------------------------------------------
/deps/onig/sample/posix.c:
--------------------------------------------------------------------------------
1 | /*
2 | * posix.c
3 | */
4 | #include
5 | #include "onigposix.h"
6 |
7 | typedef unsigned char UChar;
8 |
9 | static int x(regex_t* reg, unsigned char* pattern, unsigned char* str)
10 | {
11 | int r, i;
12 | char buf[200];
13 | regmatch_t pmatch[20];
14 |
15 | r = regexec(reg, (char* )str, reg->re_nsub + 1, pmatch, 0);
16 | if (r != 0 && r != REG_NOMATCH) {
17 | regerror(r, reg, buf, sizeof(buf));
18 | fprintf(stderr, "ERROR: %s\n", buf);
19 | return -1;
20 | }
21 |
22 | if (r == REG_NOMATCH) {
23 | fprintf(stderr, "FAIL: /%s/ '%s'\n", pattern, str);
24 | }
25 | else {
26 | fprintf(stderr, "OK: /%s/ '%s'\n", pattern, str);
27 | for (i = 0; i <= (int )reg->re_nsub; i++) {
28 | fprintf(stderr, "%d: %d-%d\n", i, pmatch[i].rm_so, pmatch[i].rm_eo);
29 | }
30 | }
31 | return 0;
32 | }
33 |
34 | extern int main(int argc, char* argv[])
35 | {
36 | int r;
37 | char buf[200];
38 | regex_t reg;
39 | UChar* pattern;
40 |
41 | /* default syntax (ONIG_SYNTAX_RUBY) */
42 | pattern = (UChar* )"^a+b{2,7}[c-f]?$|uuu";
43 | r = regcomp(®, (char* )pattern, REG_EXTENDED);
44 | if (r) {
45 | regerror(r, ®, buf, sizeof(buf));
46 | fprintf(stderr, "ERROR: %s\n", buf);
47 | return -1;
48 | }
49 | x(®, pattern, (UChar* )"aaabbbbd");
50 |
51 | /* POSIX Basic RE (REG_EXTENDED is not specified.) */
52 | pattern = (UChar* )"^a+b{2,7}[c-f]?|uuu";
53 | r = regcomp(®, (char* )pattern, 0);
54 | if (r) {
55 | regerror(r, ®, buf, sizeof(buf));
56 | fprintf(stderr, "ERROR: %s\n", buf);
57 | return -1;
58 | }
59 | x(®, pattern, (UChar* )"a+b{2,7}d?|uuu");
60 |
61 | /* POSIX Basic RE (REG_EXTENDED is not specified.) */
62 | pattern = (UChar* )"^a*b\\{2,7\\}\\([c-f]\\)$";
63 | r = regcomp(®, (char* )pattern, 0);
64 | if (r) {
65 | regerror(r, ®, buf, sizeof(buf));
66 | fprintf(stderr, "ERROR: %s\n", buf);
67 | return -1;
68 | }
69 | x(®, pattern, (UChar* )"aaaabbbbbbd");
70 |
71 | /* POSIX Extended RE */
72 | onig_set_default_syntax(ONIG_SYNTAX_POSIX_EXTENDED);
73 | pattern = (UChar* )"^a+b{2,7}[c-f]?)$|uuu";
74 | r = regcomp(®, (char* )pattern, REG_EXTENDED);
75 | if (r) {
76 | regerror(r, ®, buf, sizeof(buf));
77 | fprintf(stderr, "ERROR: %s\n", buf);
78 | return -1;
79 | }
80 | x(®, pattern, (UChar* )"aaabbbbd)");
81 |
82 | pattern = (UChar* )"^b.";
83 | r = regcomp(®, (char* )pattern, REG_EXTENDED | REG_NEWLINE);
84 | if (r) {
85 | regerror(r, ®, buf, sizeof(buf));
86 | fprintf(stderr, "ERROR: %s\n", buf);
87 | return -1;
88 | }
89 | x(®, pattern, (UChar* )"a\nb\n");
90 |
91 | regfree(®);
92 | return 0;
93 | }
94 |
--------------------------------------------------------------------------------
/deps/onig/sample/simple.c:
--------------------------------------------------------------------------------
1 | /*
2 | * simple.c
3 | */
4 | #include
5 | #include
6 | #include "oniguruma.h"
7 |
8 | extern int main(int argc, char* argv[])
9 | {
10 | int r;
11 | unsigned char *start, *range, *end;
12 | regex_t* reg;
13 | OnigErrorInfo einfo;
14 | OnigRegion *region;
15 |
16 | static UChar* pattern = (UChar* )"a(.*)b|[e-f]+";
17 | static UChar* str = (UChar* )"zzzzaffffffffb";
18 |
19 | r = onig_new(®, pattern, pattern + strlen((char* )pattern),
20 | ONIG_OPTION_DEFAULT, ONIG_ENCODING_ASCII, ONIG_SYNTAX_DEFAULT, &einfo);
21 | if (r != ONIG_NORMAL) {
22 | char s[ONIG_MAX_ERROR_MESSAGE_LEN];
23 | onig_error_code_to_str(s, r, &einfo);
24 | fprintf(stderr, "ERROR: %s\n", s);
25 | return -1;
26 | }
27 |
28 | region = onig_region_new();
29 |
30 | end = str + strlen((char* )str);
31 | start = str;
32 | range = end;
33 | r = onig_search(reg, str, end, start, range, region, ONIG_OPTION_NONE);
34 | if (r >= 0) {
35 | int i;
36 |
37 | fprintf(stderr, "match at %d\n", r);
38 | for (i = 0; i < region->num_regs; i++) {
39 | fprintf(stderr, "%d: (%d-%d)\n", i, region->beg[i], region->end[i]);
40 | }
41 | }
42 | else if (r == ONIG_MISMATCH) {
43 | fprintf(stderr, "search fail\n");
44 | }
45 | else { /* error */
46 | char s[ONIG_MAX_ERROR_MESSAGE_LEN];
47 | onig_error_code_to_str(s, r);
48 | fprintf(stderr, "ERROR: %s\n", s);
49 | return -1;
50 | }
51 |
52 | onig_region_free(region, 1 /* 1:free self, 0:free contents only */);
53 | onig_free(reg);
54 | onig_end();
55 | return 0;
56 | }
57 |
--------------------------------------------------------------------------------
/deps/onig/sample/sql.c:
--------------------------------------------------------------------------------
1 | /*
2 | * sql.c
3 | */
4 | #include
5 | #include
6 | #include "oniguruma.h"
7 |
8 | extern int main(int argc, char* argv[])
9 | {
10 | static OnigSyntaxType SQLSyntax;
11 |
12 | int r;
13 | unsigned char *start, *range, *end;
14 | regex_t* reg;
15 | OnigErrorInfo einfo;
16 | OnigRegion *region;
17 |
18 | static UChar* pattern = (UChar* )"\\_%\\\\__zz";
19 | static UChar* str = (UChar* )"a_abcabcabc\\ppzz";
20 |
21 | onig_set_syntax_op (&SQLSyntax, ONIG_SYN_OP_VARIABLE_META_CHARACTERS);
22 | onig_set_syntax_op2 (&SQLSyntax, 0);
23 | onig_set_syntax_behavior(&SQLSyntax, 0);
24 | onig_set_syntax_options (&SQLSyntax, ONIG_OPTION_MULTILINE);
25 | onig_set_meta_char(&SQLSyntax, ONIG_META_CHAR_ESCAPE, (OnigCodePoint )'\\');
26 | onig_set_meta_char(&SQLSyntax, ONIG_META_CHAR_ANYCHAR, (OnigCodePoint )'_');
27 | onig_set_meta_char(&SQLSyntax, ONIG_META_CHAR_ANYTIME,
28 | ONIG_INEFFECTIVE_META_CHAR);
29 | onig_set_meta_char(&SQLSyntax, ONIG_META_CHAR_ZERO_OR_ONE_TIME,
30 | ONIG_INEFFECTIVE_META_CHAR);
31 | onig_set_meta_char(&SQLSyntax, ONIG_META_CHAR_ONE_OR_MORE_TIME,
32 | ONIG_INEFFECTIVE_META_CHAR);
33 | onig_set_meta_char(&SQLSyntax, ONIG_META_CHAR_ANYCHAR_ANYTIME,
34 | (OnigCodePoint )'%');
35 |
36 | r = onig_new(®, pattern, pattern + strlen((char* )pattern),
37 | ONIG_OPTION_DEFAULT, ONIG_ENCODING_ASCII, &SQLSyntax, &einfo);
38 | if (r != ONIG_NORMAL) {
39 | char s[ONIG_MAX_ERROR_MESSAGE_LEN];
40 | onig_error_code_to_str(s, r, &einfo);
41 | fprintf(stderr, "ERROR: %s\n", s);
42 | return -1;
43 | }
44 |
45 | region = onig_region_new();
46 |
47 | end = str + strlen((char* )str);
48 | start = str;
49 | range = end;
50 | r = onig_search(reg, str, end, start, range, region, ONIG_OPTION_NONE);
51 | if (r >= 0) {
52 | int i;
53 |
54 | fprintf(stderr, "match at %d\n", r);
55 | for (i = 0; i < region->num_regs; i++) {
56 | fprintf(stderr, "%d: (%d-%d)\n", i, region->beg[i], region->end[i]);
57 | }
58 | }
59 | else if (r == ONIG_MISMATCH) {
60 | fprintf(stderr, "search fail\n");
61 | }
62 | else { /* error */
63 | char s[ONIG_MAX_ERROR_MESSAGE_LEN];
64 | onig_error_code_to_str(s, r);
65 | fprintf(stderr, "ERROR: %s\n", s);
66 | return -1;
67 | }
68 |
69 | onig_region_free(region, 1 /* 1:free self, 0:free contents only */);
70 | onig_free(reg);
71 | onig_end();
72 | return 0;
73 | }
74 |
--------------------------------------------------------------------------------
/deps/onig/sample/syntax.c:
--------------------------------------------------------------------------------
1 | /*
2 | * syntax.c
3 | */
4 | #include
5 | #include
6 | #include "oniguruma.h"
7 |
8 | extern int exec(OnigSyntaxType* syntax,
9 | char* apattern, char* astr)
10 | {
11 | int r;
12 | unsigned char *start, *range, *end;
13 | regex_t* reg;
14 | OnigErrorInfo einfo;
15 | OnigRegion *region;
16 | UChar* pattern = (UChar* )apattern;
17 | UChar* str = (UChar* )astr;
18 |
19 | r = onig_new(®, pattern, pattern + strlen((char* )pattern),
20 | ONIG_OPTION_DEFAULT, ONIG_ENCODING_ASCII, syntax, &einfo);
21 | if (r != ONIG_NORMAL) {
22 | char s[ONIG_MAX_ERROR_MESSAGE_LEN];
23 | onig_error_code_to_str(s, r, &einfo);
24 | fprintf(stderr, "ERROR: %s\n", s);
25 | return -1;
26 | }
27 |
28 | region = onig_region_new();
29 |
30 | end = str + strlen((char* )str);
31 | start = str;
32 | range = end;
33 | r = onig_search(reg, str, end, start, range, region, ONIG_OPTION_NONE);
34 | if (r >= 0) {
35 | int i;
36 |
37 | fprintf(stderr, "match at %d\n", r);
38 | for (i = 0; i < region->num_regs; i++) {
39 | fprintf(stderr, "%d: (%d-%d)\n", i, region->beg[i], region->end[i]);
40 | }
41 | }
42 | else if (r == ONIG_MISMATCH) {
43 | fprintf(stderr, "search fail\n");
44 | }
45 | else { /* error */
46 | char s[ONIG_MAX_ERROR_MESSAGE_LEN];
47 | onig_error_code_to_str(s, r);
48 | fprintf(stderr, "ERROR: %s\n", s);
49 | return -1;
50 | }
51 |
52 | onig_region_free(region, 1 /* 1:free self, 0:free contents only */);
53 | onig_free(reg);
54 | onig_end();
55 | return 0;
56 | }
57 |
58 | extern int main(int argc, char* argv[])
59 | {
60 | int r;
61 |
62 | r = exec(ONIG_SYNTAX_PERL,
63 | "\\p{XDigit}\\P{XDigit}\\p{^XDigit}\\P{^XDigit}\\p{XDigit}",
64 | "bgh3a");
65 |
66 | r = exec(ONIG_SYNTAX_JAVA,
67 | "\\p{XDigit}\\P{XDigit}[a-c&&b-g]", "bgc");
68 |
69 | r = exec(ONIG_SYNTAX_ASIS,
70 | "abc def* e+ g?ddd[a-rvvv] (vv){3,7}hv\\dvv(?:aczui ss)\\W\\w$",
71 | "abc def* e+ g?ddd[a-rvvv] (vv){3,7}hv\\dvv(?:aczui ss)\\W\\w$");
72 | onig_end();
73 | return r;
74 | }
75 |
--------------------------------------------------------------------------------
/deps/onig/st.h:
--------------------------------------------------------------------------------
1 | /* This is a public domain general purpose hash table package written by Peter Moore @ UCB. */
2 |
3 | /* @(#) st.h 5.1 89/12/14 */
4 |
5 | #ifndef ST_INCLUDED
6 |
7 | #define ST_INCLUDED
8 |
9 | #ifdef _WIN32
10 | # include
11 | typedef ULONG_PTR st_data_t;
12 | #else
13 | typedef unsigned long st_data_t;
14 | #endif
15 | #define ST_DATA_T_DEFINED
16 |
17 | typedef struct st_table st_table;
18 |
19 | struct st_hash_type {
20 | int (*compare)();
21 | int (*hash)();
22 | };
23 |
24 | struct st_table {
25 | struct st_hash_type *type;
26 | int num_bins;
27 | int num_entries;
28 | struct st_table_entry **bins;
29 | };
30 |
31 | #define st_is_member(table,key) st_lookup(table,key,(st_data_t *)0)
32 |
33 | enum st_retval {ST_CONTINUE, ST_STOP, ST_DELETE, ST_CHECK};
34 |
35 | #ifndef _
36 | # define _(args) args
37 | #endif
38 | #ifndef ANYARGS
39 | # ifdef __cplusplus
40 | # define ANYARGS ...
41 | # else
42 | # define ANYARGS
43 | # endif
44 | #endif
45 |
46 | st_table *st_init_table _((struct st_hash_type *));
47 | st_table *st_init_table_with_size _((struct st_hash_type *, int));
48 | st_table *st_init_numtable _((void));
49 | st_table *st_init_numtable_with_size _((int));
50 | st_table *st_init_strtable _((void));
51 | st_table *st_init_strtable_with_size _((int));
52 | int st_delete _((st_table *, st_data_t *, st_data_t *));
53 | int st_delete_safe _((st_table *, st_data_t *, st_data_t *, st_data_t));
54 | int st_insert _((st_table *, st_data_t, st_data_t));
55 | int st_lookup _((st_table *, st_data_t, st_data_t *));
56 | int st_foreach _((st_table *, int (*)(ANYARGS), st_data_t));
57 | void st_add_direct _((st_table *, st_data_t, st_data_t));
58 | void st_free_table _((st_table *));
59 | void st_cleanup_safe _((st_table *, st_data_t));
60 | st_table *st_copy _((st_table *));
61 |
62 | #define ST_NUMCMP ((int (*)()) 0)
63 | #define ST_NUMHASH ((int (*)()) -2)
64 |
65 | #define st_numcmp ST_NUMCMP
66 | #define st_numhash ST_NUMHASH
67 |
68 | #endif /* ST_INCLUDED */
69 |
--------------------------------------------------------------------------------
/deps/onig/stamp-h1:
--------------------------------------------------------------------------------
1 | timestamp for config.h
2 |
--------------------------------------------------------------------------------
/deps/onig/testc.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/atom/node-oniguruma/0c6b95fc7d79ab7e60a7ed63df6d05677ace2642/deps/onig/testc.c
--------------------------------------------------------------------------------
/deps/onig/win32/config.h:
--------------------------------------------------------------------------------
1 | #define STDC_HEADERS 1
2 | #define HAVE_SYS_TYPES_H 1
3 | #define HAVE_SYS_STAT_H 1
4 | #define HAVE_STDLIB_H 1
5 | #define HAVE_STRING_H 1
6 | #define HAVE_MEMORY_H 1
7 | #define HAVE_FLOAT_H 1
8 | #define HAVE_OFF_T 1
9 | #define SIZEOF_INT 4
10 | #define SIZEOF_SHORT 2
11 | #define SIZEOF_LONG 4
12 | #define SIZEOF_LONG_LONG 0
13 | #define SIZEOF___INT64 8
14 | #define SIZEOF_OFF_T 4
15 | #define SIZEOF_VOIDP 4
16 | #define SIZEOF_FLOAT 4
17 | #define SIZEOF_DOUBLE 8
18 | #define HAVE_PROTOTYPES 1
19 | #define TOKEN_PASTE(x,y) x##y
20 | #define HAVE_STDARG_PROTOTYPES 1
21 | #ifndef NORETURN
22 | #if _MSC_VER > 1100
23 | #define NORETURN(x) __declspec(noreturn) x
24 | #else
25 | #define NORETURN(x) x
26 | #endif
27 | #endif
28 | #define HAVE_DECL_SYS_NERR 1
29 | #define STDC_HEADERS 1
30 | #define HAVE_STDLIB_H 1
31 | #define HAVE_STRING_H 1
32 | #define HAVE_LIMITS_H 1
33 | #define HAVE_FCNTL_H 1
34 | #define HAVE_SYS_UTIME_H 1
35 | #define HAVE_MEMORY_H 1
36 | #define uid_t int
37 | #define gid_t int
38 | #define HAVE_STRUCT_STAT_ST_RDEV 1
39 | #define HAVE_ST_RDEV 1
40 | #define GETGROUPS_T int
41 | #define RETSIGTYPE void
42 | #define HAVE_ALLOCA 1
43 | #define HAVE_DUP2 1
44 | #define HAVE_MEMCMP 1
45 | #define HAVE_MEMMOVE 1
46 | #define HAVE_MKDIR 1
47 | #define HAVE_STRCASECMP 1
48 | #define HAVE_STRNCASECMP 1
49 | #define HAVE_STRERROR 1
50 | #define HAVE_STRFTIME 1
51 | #define HAVE_STRCHR 1
52 | #define HAVE_STRSTR 1
53 | #define HAVE_STRTOD 1
54 | #define HAVE_STRTOL 1
55 | #define HAVE_STRTOUL 1
56 | #define HAVE_FLOCK 1
57 | #define HAVE_VSNPRINTF 1
58 | #define HAVE_FINITE 1
59 | #define HAVE_FMOD 1
60 | #define HAVE_FREXP 1
61 | #define HAVE_HYPOT 1
62 | #define HAVE_MODF 1
63 | #define HAVE_WAITPID 1
64 | #define HAVE_CHSIZE 1
65 | #define HAVE_TIMES 1
66 | #define HAVE__SETJMP 1
67 | #define HAVE_TELLDIR 1
68 | #define HAVE_SEEKDIR 1
69 | #define HAVE_MKTIME 1
70 | #define HAVE_COSH 1
71 | #define HAVE_SINH 1
72 | #define HAVE_TANH 1
73 | #define HAVE_EXECVE 1
74 | #define HAVE_TZNAME 1
75 | #define HAVE_DAYLIGHT 1
76 | #define SETPGRP_VOID 1
77 | #define inline __inline
78 | #define NEED_IO_SEEK_BETWEEN_RW 1
79 | #define RSHIFT(x,y) ((x)>>(int)y)
80 | #define FILE_COUNT _cnt
81 | #define FILE_READPTR _ptr
82 | #define DEFAULT_KCODE KCODE_NONE
83 | #define DLEXT ".so"
84 | #define DLEXT2 ".dll"
85 |
--------------------------------------------------------------------------------
/deps/onig/win32/testc.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/atom/node-oniguruma/0c6b95fc7d79ab7e60a7ed63df6d05677ace2642/deps/onig/win32/testc.c
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "main": "./src/oniguruma.js",
3 | "name": "oniguruma",
4 | "description": "oniguruma regular expression library",
5 | "version": "7.2.3",
6 | "licenses": [
7 | {
8 | "type": "MIT",
9 | "url": "http://github.com/atom/node-oniguruma/raw/master/LICENSE.md"
10 | }
11 | ],
12 | "repository": {
13 | "type": "git",
14 | "url": "https://github.com/atom/node-oniguruma.git"
15 | },
16 | "bugs": {
17 | "url": "https://github.com/atom/node-oniguruma/issues"
18 | },
19 | "homepage": "http://atom.github.io/node-oniguruma",
20 | "keywords": [
21 | "regex",
22 | "regexp",
23 | "re",
24 | "regular expression",
25 | "async"
26 | ],
27 | "devDependencies": {
28 | "async": "~2.6.2",
29 | "jasmine-focused": "~1.0.7"
30 | },
31 | "dependencies": {
32 | "nan": "^2.14.0"
33 | },
34 | "scripts": {
35 | "test": "jasmine-focused --captureExceptions spec/",
36 | "benchmark": "benchmark/benchmark.coffee"
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/spec/onig-reg-exp-spec.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const OnigRegExp = require('..').OnigRegExp
4 |
5 | describe('OnigRegExp', () => {
6 | describe('::search(string, index, callback)', () => {
7 | it('returns an array of the match and all capture groups', () => {
8 | let regex = new OnigRegExp('\\w(\\d+)')
9 | let searchCallback = jasmine.createSpy('searchCallback')
10 | let result = regex.search('----a123----', searchCallback)
11 |
12 | waitsFor(() => searchCallback.callCount === 1)
13 |
14 | runs(() => {
15 | result = searchCallback.argsForCall[0][1]
16 | expect(result.length).toBe(2)
17 | expect(result[0].match).toBe('a123')
18 | expect(result[0].start).toBe(4)
19 | expect(result[0].end).toBe(8)
20 | expect(result[0].index).toBe(0)
21 | expect(result[0].length).toBe(4)
22 | expect(result[1].match).toBe('123')
23 | expect(result[1].start).toBe(5)
24 | expect(result[1].end).toBe(8)
25 | expect(result[1].index).toBe(1)
26 | expect(result[1].length).toBe(3)
27 | })
28 | })
29 |
30 | it('returns null if it does not match', () => {
31 | let regex = new OnigRegExp('\\w(\\d+)')
32 | let searchCallback = jasmine.createSpy('searchCallback')
33 | let result = regex.search('--------', searchCallback)
34 |
35 | waitsFor(() => searchCallback.callCount === 1)
36 |
37 | runs(() => {
38 | result = searchCallback.argsForCall[0][1]
39 | expect(result).toBeNull()
40 | })
41 | })
42 |
43 | describe('when the string being searched contains a unicode character', () =>
44 | it('returns correct indices and lengths', () => {
45 | let regex = new OnigRegExp('a')
46 | let searchCallback = jasmine.createSpy('searchCallback')
47 | regex.search('ç√Ωa', 0, searchCallback)
48 |
49 | waitsFor(() => searchCallback.callCount === 1)
50 |
51 | runs(() => {
52 | let firstMatch = searchCallback.argsForCall[0][1]
53 | expect(firstMatch[0].start).toBe(3)
54 | expect(firstMatch[0].match).toBe('a')
55 | regex.search('ç√Ωabcd≈ßåabcd', 5, searchCallback)
56 | })
57 |
58 | waitsFor(() => searchCallback.callCount === 2)
59 |
60 | runs(() => {
61 | let secondMatch = searchCallback.argsForCall[1][1]
62 | expect(secondMatch[0].start).toBe(10)
63 | expect(secondMatch[0].match).toBe('a')
64 | })
65 | })
66 | )
67 |
68 | describe('when the string being searched contains non-Basic Multilingual Plane characters', () =>
69 | it('returns correct indices and matches', () => {
70 | let regex = new OnigRegExp("'")
71 | let searchCallback = jasmine.createSpy('searchCallback')
72 | regex.search("'\uD835\uDF97'", 0, searchCallback)
73 |
74 | waitsFor(() => searchCallback.callCount === 1)
75 |
76 | runs(() => {
77 | let match = searchCallback.argsForCall[0][1]
78 | expect(match[0].start).toBe(0)
79 | expect(match[0].match).toBe("'")
80 | regex.search("'\uD835\uDF97'", 1, searchCallback)
81 | })
82 |
83 | waitsFor(() => searchCallback.callCount === 2)
84 |
85 | runs(() => {
86 | let match = searchCallback.argsForCall[1][1]
87 | expect(match[0].start).toBe(3)
88 | expect(match[0].match).toBe("'")
89 | regex.search("'\uD835\uDF97'", 2, searchCallback)
90 | })
91 |
92 | waitsFor(() => searchCallback.callCount === 3)
93 |
94 | runs(() => {
95 | let match = searchCallback.argsForCall[2][1]
96 | expect(match[0].start).toBe(3)
97 | expect(match[0].match).toBe("'")
98 | })
99 | })
100 | )
101 | })
102 |
103 | describe('::searchSync(string, index)', () => {
104 | it('returns an array of the match and all capture groups', () => {
105 | let regex = new OnigRegExp('\\w(\\d+)')
106 | let result = regex.searchSync('----a123----')
107 | expect(result.length).toBe(2)
108 | expect(result[0].match).toBe('a123')
109 | expect(result[0].start).toBe(4)
110 | expect(result[0].end).toBe(8)
111 | expect(result[0].index).toBe(0)
112 | expect(result[0].length).toBe(4)
113 | expect(result[1].match).toBe('123')
114 | expect(result[1].start).toBe(5)
115 | expect(result[1].end).toBe(8)
116 | expect(result[1].index).toBe(1)
117 | expect(result[1].length).toBe(3)
118 | })
119 |
120 | it('returns null if it does not match', () => {
121 | let regex = new OnigRegExp('\\w(\\d+)')
122 | let result = regex.searchSync('--------')
123 | expect(result).toBeNull()
124 | })
125 |
126 | describe('when the string being searched contains a unicode character', () =>
127 | it('returns correct indices and lengths', () => {
128 | let regex = new OnigRegExp('a')
129 |
130 | let firstMatch = regex.searchSync('ç√Ωa', 0)
131 | expect(firstMatch[0].start).toBe(3)
132 | expect(firstMatch[0].match).toBe('a')
133 |
134 | let secondMatch = regex.searchSync('ç√Ωabcd≈ßåabcd', 5)
135 | expect(secondMatch[0].start).toBe(10)
136 | expect(secondMatch[0].match).toBe('a')
137 | })
138 | )
139 |
140 | describe('when the string being searched contains non-Basic Multilingual Plane characters', () =>
141 | it('returns correct indices and matches', () => {
142 | let regex = new OnigRegExp("'")
143 |
144 | let match = regex.searchSync("'\uD835\uDF97'", 0)
145 | expect(match[0].start).toBe(0)
146 | expect(match[0].match).toBe("'")
147 |
148 | match = regex.searchSync("'\uD835\uDF97'", 1)
149 | expect(match[0].start).toBe(3)
150 | expect(match[0].match).toBe("'")
151 |
152 | match = regex.searchSync("'\uD835\uDF97'", 2)
153 | expect(match[0].start).toBe(3)
154 | expect(match[0].match).toBe("'")
155 |
156 | match = regex.searchSync("'\uD835\uDF97'", 3)
157 | expect(match[0].start).toBe(3)
158 | expect(match[0].match).toBe("'")
159 | })
160 | )
161 | })
162 |
163 | describe('::testSync(string)', () =>
164 | it('returns true if the string matches the pattern', () => {
165 | expect(new OnigRegExp('a[b-d]c').testSync('aec')).toBe(false)
166 | expect(new OnigRegExp('a[b-d]c').testSync('abc')).toBe(true)
167 | expect(new OnigRegExp(false).testSync(false)).toBe(true)
168 | expect(new OnigRegExp(false).testSync(true)).toBe(false)
169 | })
170 | )
171 |
172 | describe('::test(string, callback)', () =>
173 | it('calls back with true if the string matches the pattern', () => {
174 | let testCallback = jasmine.createSpy('testCallback')
175 |
176 | new OnigRegExp('a[b-d]c').test('aec', testCallback)
177 |
178 | waitsFor(() => testCallback.callCount === 1)
179 |
180 | runs(() => {
181 | expect(testCallback.argsForCall[0][0]).toBeNull()
182 | expect(testCallback.argsForCall[0][1]).toBe(false)
183 | new OnigRegExp('a[b-d]c').test('abc', testCallback)
184 | })
185 |
186 | waitsFor(() => testCallback.callCount === 2)
187 |
188 | runs(() => {
189 | expect(testCallback.argsForCall[1][0]).toBeNull()
190 | expect(testCallback.argsForCall[1][1]).toBe(true)
191 | })
192 | })
193 | )
194 | })
195 |
--------------------------------------------------------------------------------
/spec/onig-string-spec.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const OnigString = require('..').OnigString
4 |
5 | describe('OnigString', () => {
6 | it('has a length property', () => {
7 | expect(new OnigString('abc').length).toBe(3)
8 | })
9 |
10 | it('can be converted back into a string', () => {
11 | expect(new OnigString('abc').toString()).toBe('abc')
12 | })
13 |
14 | it('can retrieve substrings (for conveniently inspecting captured text)', () => {
15 | const string = 'abcdef'
16 | const onigString = new OnigString(string)
17 | expect(onigString.substring(2, 3)).toBe(string.substring(2, 3))
18 | expect(onigString.substring(2)).toBe(string.substring(2))
19 | expect(onigString.substring()).toBe(string.substring())
20 | expect(onigString.substring(-1)).toBe(string.substring(-1))
21 | expect(onigString.substring(-1, -2)).toBe(string.substring(-1, -2))
22 |
23 | onigString.substring({})
24 | onigString.substring(null, undefined)
25 | })
26 |
27 | it('handles invalid arguments', () => {
28 | expect(() => new OnigString(undefined)).toThrow('Argument must be a string')
29 | })
30 | })
31 |
--------------------------------------------------------------------------------
/src/onig-reg-exp.cc:
--------------------------------------------------------------------------------
1 | #include "onig-reg-exp.h"
2 |
3 | using ::v8::Exception;
4 | using ::v8::String;
5 |
6 | OnigRegExp::OnigRegExp(const string& source)
7 | : source_(source),
8 | regex_(NULL) {
9 | lastSearchStrUniqueId = -1;
10 | lastSearchPosition = -1;
11 | lastSearchResult = NULL;
12 |
13 | hasGAnchor = false;
14 | for (size_t pos = 0, len = source.size(); pos < len; pos++) {
15 | if (source[pos] == '\\' && pos + 1 < len) {
16 | if (source[pos + 1] == 'G') {
17 | hasGAnchor = true;
18 | break;
19 | }
20 | pos++;
21 | }
22 | }
23 |
24 | OnigErrorInfo error;
25 | const UChar* sourceData = (const UChar*)source.data();
26 | int status = onig_new(®ex_, sourceData, sourceData + source.length(),
27 | ONIG_OPTION_CAPTURE_GROUP, ONIG_ENCODING_UTF8,
28 | ONIG_SYNTAX_DEFAULT, &error);
29 |
30 | if (status != ONIG_NORMAL) {
31 | UChar errorString[ONIG_MAX_ERROR_MESSAGE_LEN];
32 | onig_error_code_to_str(errorString, status, &error);
33 | Nan::ThrowError(Exception::Error(Nan::New(reinterpret_cast(errorString)).ToLocalChecked()));
34 | }
35 | }
36 |
37 | OnigRegExp::~OnigRegExp() {
38 | if (regex_) onig_free(regex_);
39 | }
40 |
41 | shared_ptr OnigRegExp::Search(OnigString* str, int position) {
42 | if (hasGAnchor) {
43 | // Should not use caching, because the regular expression
44 | // targets the current search position (\G)
45 | return Search(str->utf8_value(), position, str->utf8_length());
46 | }
47 |
48 | if (lastSearchStrUniqueId == str->uniqueId() && lastSearchPosition <= position) {
49 | if (lastSearchResult == NULL || lastSearchResult->LocationAt(0) >= position) {
50 | return lastSearchResult;
51 | }
52 | }
53 |
54 | lastSearchStrUniqueId = str->uniqueId();
55 | lastSearchPosition = position;
56 | lastSearchResult = Search(str->utf8_value(), position, str->utf8_length());
57 | return lastSearchResult;
58 | }
59 |
60 | shared_ptr OnigRegExp::Search(const char* data,
61 | size_t position, size_t end) {
62 | if (!regex_) {
63 | Nan::ThrowError(Exception::Error(Nan::New("RegExp is not valid").ToLocalChecked()));
64 | return shared_ptr();
65 | }
66 |
67 | const UChar* searchData = reinterpret_cast(data);
68 | OnigRegion* region = onig_region_new();
69 | int status = onig_search(regex_, searchData, searchData + end,
70 | searchData + position, searchData + end, region,
71 | ONIG_OPTION_NONE);
72 |
73 | if (status != ONIG_MISMATCH) {
74 | return shared_ptr(new OnigResult(region, -1));
75 | } else {
76 | onig_region_free(region, 1);
77 | return shared_ptr();
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/src/onig-reg-exp.h:
--------------------------------------------------------------------------------
1 | #ifndef SRC_ONIG_REG_EXP_H_
2 | #define SRC_ONIG_REG_EXP_H_
3 |
4 | #include
5 | #include
6 |
7 | #include "onig-result.h"
8 | #include "onig-string.h"
9 |
10 | using ::std::shared_ptr;
11 | using ::std::string;
12 |
13 | class OnigRegExp {
14 | public:
15 | explicit OnigRegExp(const string& source);
16 | ~OnigRegExp();
17 |
18 | shared_ptr Search(OnigString* str, int position);
19 |
20 | private:
21 | OnigRegExp(const OnigRegExp&); // Disallow copying
22 | OnigRegExp &operator=(const OnigRegExp&); // Disallow copying
23 |
24 | shared_ptr Search(const char* data, size_t position, size_t end);
25 |
26 | string source_;
27 | regex_t* regex_;
28 |
29 | bool hasGAnchor;
30 | int lastSearchStrUniqueId;
31 | int lastSearchPosition;
32 | shared_ptr lastSearchResult;
33 | };
34 |
35 | #endif // SRC_ONIG_REG_EXP_H_
36 |
--------------------------------------------------------------------------------
/src/onig-result.cc:
--------------------------------------------------------------------------------
1 | #include "onig-result.h"
2 |
3 | OnigResult::OnigResult(OnigRegion* region, int indexInScanner)
4 | : region_(region), indexInScanner(indexInScanner) {}
5 |
6 | OnigResult::~OnigResult() {
7 | onig_region_free(region_, 1);
8 | }
9 |
10 | int OnigResult::Count() {
11 | return region_->num_regs;
12 | }
13 |
14 | int OnigResult::LocationAt(int index) {
15 | int bytes = *(region_->beg + index);
16 | if (bytes > 0)
17 | return bytes;
18 | else
19 | return 0;
20 | }
21 |
22 | int OnigResult::LengthAt(int index) {
23 | int bytes = *(region_->end + index) - *(region_->beg + index);
24 | if (bytes > 0)
25 | return bytes;
26 | else
27 | return 0;
28 | }
29 |
--------------------------------------------------------------------------------
/src/onig-result.h:
--------------------------------------------------------------------------------
1 | #ifndef SRC_ONIG_RESULT_H_
2 | #define SRC_ONIG_RESULT_H_
3 |
4 | #include "nan.h"
5 | #include "oniguruma.h"
6 |
7 | class OnigResult {
8 | public:
9 | explicit OnigResult(OnigRegion* region, int indexInScanner);
10 | ~OnigResult();
11 |
12 | int Count();
13 | int LocationAt(int index);
14 | int LengthAt(int index);
15 | int Index() { return indexInScanner; }
16 | void SetIndex(int newIndex) { indexInScanner = newIndex; }
17 |
18 | private:
19 | OnigResult(const OnigResult&); // Disallow copying
20 | OnigResult &operator=(const OnigResult&); // Disallow copying
21 |
22 | OnigRegion *region_;
23 | int indexInScanner;
24 | };
25 |
26 | #endif // SRC_ONIG_RESULT_H_
27 |
--------------------------------------------------------------------------------
/src/onig-scanner-worker.cc:
--------------------------------------------------------------------------------
1 | #include "onig-scanner-worker.h"
2 |
3 | using ::v8::Array;
4 | using ::v8::Number;
5 | using ::v8::Value;
6 |
7 | void OnigScannerWorker::Execute() {
8 | bestResult = searcher->Search(source, charOffset);
9 | }
10 |
11 | void OnigScannerWorker::HandleOKCallback() {
12 | Nan::HandleScope scope;
13 |
14 | if (bestResult != NULL) {
15 | Local