diff --git a/BUILDING.md b/BUILDING.md index 14206976e48a12..b63901297b1a40 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -69,14 +69,11 @@ There are three support tiers: * **Tier 1**: These platforms represent the majority of Node.js users. The Node.js Build Working Group maintains infrastructure for full test coverage. - All commits to the Node.js repository are tested on these platforms. Test - failures on tier 1 platforms will block releases. + Test failures on tier 1 platforms will block releases. * **Tier 2**: These platforms represent smaller segments of the Node.js user base. The Node.js Build Working Group maintains infrastructure for full test - coverage. All commits to the Node.js repository are tested on these platforms. - Test failures on tier 2 platforms will block releases. Delays in release of - binaries for these platforms are acceptable where necessary due to - infrastructure concerns. + coverage. Test failures on tier 2 platforms will block releases. + Infrastructure issues may delay the release of binaries for these platforms. * **Experimental**: May not compile or test suite may not pass. The core team does not create releases for these platforms. Test failures on experimental platforms do not block releases. Contributions to improve support for these @@ -87,12 +84,10 @@ will be updated to reflect those changes. ### Platform list -Compiling and running Node.js is supported for a limited set of operating -systems, architectures and libc versions. The table below lists the -combinations that the core team has committed to supporting and the nature of -that support as per the support tiers above. A list of -[supported compile toolchains](#supported-toolchains) is also supplied for -tier 1 platforms. +Node.js compilation/execution support depends on operating system, architecture, +and libc version. The table below lists the support tier for each supported +combination. A list of [supported compile toolchains](#supported-toolchains) is +also supplied for tier 1 platforms. **For production applications, run Node.js on supported platforms only.** @@ -227,18 +222,10 @@ Consult previous versions of this document for older versions of Node.js: ### Note about Python 2 and Python 3 -The Node.js project uses Python as part of its build process and has -historically only been Python 2 compatible. - -Python 2 will reach its _end-of-life_ at the end of 2019 at which point the -interpreter will cease receiving updates. See https://python3statement.org/ -for more information. - -The Node.js project is in the process of transitioning its Python code to -Python 3 compatibility. Installing both versions of Python while building -and testing Node.js allows developers and end users to test, benchmark, -and debug Node.js running on both versions to ensure a smooth and complete -transition before the year-end deadline. +The Node.js project supports both Python 3 and Python 2 for building. +If both are installed Python 3 will be used. If only Python 2 is available +it will be used instead. When possible we recommend that you build and +test with Python 3. ### Unix and macOS @@ -248,7 +235,7 @@ transition before the year-end deadline. * GNU Make 3.81 or newer * Python (see note above) * Python 2.7 - * Python 3.5, 3.6, 3.7, and 3.8 are experimental. + * Python 3.5, 3.6, 3.7, and 3.8. Installation via Linux package manager can be achieved with: @@ -264,7 +251,7 @@ FreeBSD and OpenBSD users may also need to install `libexecinfo`. * Xcode Command Line Tools >= 10 for macOS * Python (see note above) * Python 2.7 - * Python 3.5, 3.6, 3.7, and 3.8 are experimental. + * Python 3.5, 3.6, 3.7, and 3.8. macOS users can install the `Xcode Command Line Tools` by running `xcode-select --install`. Alternatively, if you already have the full Xcode diff --git a/CHANGELOG.md b/CHANGELOG.md index 39c3d092a4ba98..166336dcb8e7b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,7 +30,8 @@ release. -13.3.0
+13.4.0
+13.3.0
13.2.0
13.1.0
13.0.1
diff --git a/SECURITY.md b/SECURITY.md index 7e984b7ba36872..3196055ccb78e5 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -23,8 +23,8 @@ the HackerOne platform. See for further details. ## Reporting a Bug in a third party module Security bugs in third party modules should be reported to their respective -maintainers and should also be coordinated through the Node Ecosystem Security -Team via [HackerOne](https://hackerone.com/nodejs-ecosystem). +maintainers and should also be coordinated through the Node.js Ecosystem +Security Team via [HackerOne](https://hackerone.com/nodejs-ecosystem). Details regarding this process can be found in the [Security Working Group repository](https://github.com/nodejs/security-wg/blob/master/processes/third_party_vuln_process.md). diff --git a/benchmark/README.md b/benchmark/README.md index 45256670fdd2aa..7e027c6e76f7b8 100644 --- a/benchmark/README.md +++ b/benchmark/README.md @@ -5,7 +5,7 @@ of different Node.js implementations and different ways of writing JavaScript run by the built-in JavaScript engine. For a detailed guide on how to write and run benchmarks in this -directory, see [the guide on benchmarks](../doc/guides/writing-and-running-benchmarks.md). +directory, see [the guide on benchmarks](writing-and-running-benchmarks.md). ## Table of Contents @@ -76,17 +76,17 @@ writing benchmarks. ### createBenchmark(fn, configs\[, options\]) -See [the guide on writing benchmarks](../doc/guides/writing-and-running-benchmarks.md#basics-of-a-benchmark). +See [the guide on writing benchmarks](writing-and-running-benchmarks.md#basics-of-a-benchmark). ### default\_http\_benchmarker The default benchmarker used to run HTTP benchmarks. -See [the guide on writing HTTP benchmarks](../doc/guides/writing-and-running-benchmarks.md#creating-an-http-benchmark). +See [the guide on writing HTTP benchmarks](writing-and-running-benchmarks.md#creating-an-http-benchmark). ### PORT The default port used to run HTTP benchmarks. -See [the guide on writing HTTP benchmarks](../doc/guides/writing-and-running-benchmarks.md#creating-an-http-benchmark). +See [the guide on writing HTTP benchmarks](writing-and-running-benchmarks.md#creating-an-http-benchmark). ### sendResult(data) diff --git a/benchmark/_cli.js b/benchmark/_cli.js index 8b9f22d0fb4b57..771cc72bff1964 100644 --- a/benchmark/_cli.js +++ b/benchmark/_cli.js @@ -34,7 +34,7 @@ function CLI(usage, settings) { if (arg === '--') { // Only items can follow -- mode = 'item'; - } else if (['both', 'option'].includes(mode) && arg[0] === '-') { + } else if ('both' === mode && arg[0] === '-') { // Optional arguments declaration if (arg[1] === '-') { @@ -82,13 +82,12 @@ CLI.prototype.abort = function(msg) { CLI.prototype.benchmarks = function() { const paths = []; - const filter = this.optional.filter || false; for (const category of this.items) { if (benchmarks[category] === undefined) continue; for (const scripts of benchmarks[category]) { - if (filter && scripts.lastIndexOf(filter) === -1) continue; + if (this.shouldSkip(scripts)) continue; paths.push(path.join(category, scripts)); } @@ -96,3 +95,23 @@ CLI.prototype.benchmarks = function() { return paths; }; + +CLI.prototype.shouldSkip = function(scripts) { + const filters = this.optional.filter || []; + const excludes = this.optional.exclude || []; + let skip = filters.length > 0; + + for (const filter of filters) { + if (scripts.lastIndexOf(filter) !== -1) { + skip = false; + } + } + + for (const exclude of excludes) { + if (scripts.lastIndexOf(exclude) !== -1) { + skip = true; + } + } + + return skip; +}; diff --git a/benchmark/_http-benchmarkers.js b/benchmark/_http-benchmarkers.js index a4d623003947eb..7dd06be2655744 100644 --- a/benchmark/_http-benchmarkers.js +++ b/benchmark/_http-benchmarkers.js @@ -5,7 +5,7 @@ const path = require('path'); const fs = require('fs'); const requirementsURL = - 'https://github.com/nodejs/node/blob/master/doc/guides/writing-and-running-benchmarks.md#http-benchmark-requirements'; + 'https://github.com/nodejs/node/blob/master/benchmark/writing-and-running-benchmarks.md#http-benchmark-requirements'; // The port used by servers and wrk exports.PORT = Number(process.env.PORT) || 12346; diff --git a/benchmark/compare.js b/benchmark/compare.js index bd7c4a95cbb617..53f82bb4b9f1b9 100644 --- a/benchmark/compare.js +++ b/benchmark/compare.js @@ -18,10 +18,13 @@ const cli = CLI(`usage: ./node compare.js [options] [--] ... --new ./new-node-binary new node binary (required) --old ./old-node-binary old node binary (required) --runs 30 number of samples - --filter pattern string to filter benchmark scripts + --filter pattern includes only benchmark scripts matching + (can be repeated) + --exclude pattern excludes scripts matching (can be + repeated) --set variable=value set benchmark variable (can be repeated) --no-progress don't show benchmark progress indicator -`, { arrayArgs: ['set'], boolArgs: ['no-progress'] }); +`, { arrayArgs: ['set', 'filter', 'exclude'], boolArgs: ['no-progress'] }); if (!cli.optional.new || !cli.optional.old) { cli.abort(cli.usage); diff --git a/benchmark/run.js b/benchmark/run.js index 2eb1ab1a4b0905..8e81a2c5e16ab7 100644 --- a/benchmark/run.js +++ b/benchmark/run.js @@ -8,10 +8,13 @@ const cli = CLI(`usage: ./node run.js [options] [--] ... Run each benchmark in the directory a single time, more than one directory can be specified. - --filter pattern string to filter benchmark scripts + --filter pattern includes only benchmark scripts matching + (can be repeated) + --exclude pattern excludes scripts matching (can be + repeated) --set variable=value set benchmark variable (can be repeated) --format [simple|csv] optional value that specifies the output format -`, { arrayArgs: ['set'] }); +`, { arrayArgs: ['set', 'filter', 'exclude'] }); const benchmarks = cli.benchmarks(); if (benchmarks.length === 0) { diff --git a/benchmark/util/format.js b/benchmark/util/format.js index 44e950a6ca6522..976e0f4e655486 100644 --- a/benchmark/util/format.js +++ b/benchmark/util/format.js @@ -13,6 +13,8 @@ const inputs = { 'no-replace-2': ['foobar', 'yeah', 'mensch', 5], 'only-objects': [{ msg: 'This is an error' }, { msg: 'This is an error' }], 'many-%': ['replace%%%%s%%%%many%s%s%s', 'percent'], + 'object-to-string': ['foo %s bar', { toString() { return 'bla'; } }], + 'object-%s': ['foo %s bar', { a: true, b: false }], }; const bench = common.createBenchmark(main, { diff --git a/benchmark/util/inspect-proxy.js b/benchmark/util/inspect-proxy.js index dde86941ff42a3..02379cdc770f3b 100644 --- a/benchmark/util/inspect-proxy.js +++ b/benchmark/util/inspect-proxy.js @@ -3,13 +3,21 @@ const util = require('util'); const common = require('../common.js'); -const bench = common.createBenchmark(main, { n: [2e4] }); +const bench = common.createBenchmark(main, { + n: [1e5], + showProxy: [0, 1], + isProxy: [0, 1] +}); -function main({ n }) { - const proxyA = new Proxy({}, { get: () => {} }); - const proxyB = new Proxy(() => {}, {}); +function main({ n, showProxy, isProxy }) { + let proxyA = {}; + let proxyB = () => {}; + if (isProxy) { + proxyA = new Proxy(proxyA, { get: () => {} }); + proxyB = new Proxy(proxyB, {}); + } bench.start(); for (let i = 0; i < n; i += 1) - util.inspect({ a: proxyA, b: proxyB }, { showProxy: true }); + util.inspect({ a: proxyA, b: proxyB }, { showProxy }); bench.end(n); } diff --git a/doc/guides/writing-and-running-benchmarks.md b/benchmark/writing-and-running-benchmarks.md similarity index 83% rename from doc/guides/writing-and-running-benchmarks.md rename to benchmark/writing-and-running-benchmarks.md index 6097830aeeba1f..1db72d22de5324 100644 --- a/doc/guides/writing-and-running-benchmarks.md +++ b/benchmark/writing-and-running-benchmarks.md @@ -8,6 +8,7 @@ * [Running benchmarks](#running-benchmarks) * [Running individual benchmarks](#running-individual-benchmarks) * [Running all benchmarks](#running-all-benchmarks) + * [Filtering benchmarks](#filtering-benchmarks) * [Comparing Node.js versions](#comparing-nodejs-versions) * [Comparing parameters](#comparing-parameters) * [Running Benchmarks on the CI](#running-benchmarks-on-the-ci) @@ -149,6 +150,87 @@ It is possible to execute more groups by adding extra process arguments. $ node benchmark/run.js assert async_hooks ``` +#### Filtering benchmarks + +`benchmark/run.js` and `benchmark/compare.js` have `--filter pattern` and +`--exclude pattern` options, which can be used to run a subset of benchmarks or +to exclude specific benchmarks from the execution, respectively. + +```console +$ node benchmark/run.js --filter "deepequal-b" assert + +assert/deepequal-buffer.js +assert/deepequal-buffer.js method="deepEqual" strict=0 len=100 n=20000: 773,200.4995493788 +assert/deepequal-buffer.js method="notDeepEqual" strict=0 len=100 n=20000: 964,411.712953848 + +$ node benchmark/run.js --exclude "deepequal-b" assert + +assert/deepequal-map.js +assert/deepequal-map.js method="deepEqual_primitiveOnly" strict=0 len=500 n=500: 20,445.06368453332 +assert/deepequal-map.js method="deepEqual_objectOnly" strict=0 len=500 n=500: 1,393.3481642240833 +... + +assert/deepequal-object.js +assert/deepequal-object.js method="deepEqual" strict=0 size=100 n=5000: 1,053.1950937538475 +assert/deepequal-object.js method="notDeepEqual" strict=0 size=100 n=5000: 9,734.193251965213 +... +``` + +`--filter` and `--exclude` can be repeated to provide multiple patterns. + +```console +$ node benchmark/run.js --filter "deepequal-b" --filter "deepequal-m" assert + +assert/deepequal-buffer.js +assert/deepequal-buffer.js method="deepEqual" strict=0 len=100 n=20000: 773,200.4995493788 +assert/deepequal-buffer.js method="notDeepEqual" strict=0 len=100 n=20000: 964,411.712953848 + +assert/deepequal-map.js +assert/deepequal-map.js method="deepEqual_primitiveOnly" strict=0 len=500 n=500: 20,445.06368453332 +assert/deepequal-map.js method="deepEqual_objectOnly" strict=0 len=500 n=500: 1,393.3481642240833 + +$ node benchmark/run.js --exclude "deepequal-b" --exclude "deepequal-m" assert + +assert/deepequal-object.js +assert/deepequal-object.js method="deepEqual" strict=0 size=100 n=5000: 1,053.1950937538475 +assert/deepequal-object.js method="notDeepEqual" strict=0 size=100 n=5000: 9,734.193251965213 +... + +assert/deepequal-prims-and-objs-big-array-set.js +assert/deepequal-prims-and-objs-big-array-set.js method="deepEqual_Array" strict=0 len=20000 n=25 primitive="string": 865.2977195251661 +assert/deepequal-prims-and-objs-big-array-set.js method="notDeepEqual_Array" strict=0 len=20000 n=25 primitive="string": 827.8297281403861 +assert/deepequal-prims-and-objs-big-array-set.js method="deepEqual_Set" strict=0 len=20000 n=25 primitive="string": 28,826.618268696366 +... +``` + +If `--filter` and `--exclude` are used together, `--filter` is applied first, +and `--exclude` is applied on the result of `--filter`: + +```console +$ node benchmark/run.js --filter "bench-" process + +process/bench-env.js +process/bench-env.js operation="get" n=1000000: 2,356,946.0770617095 +process/bench-env.js operation="set" n=1000000: 1,295,176.3266261867 +process/bench-env.js operation="enumerate" n=1000000: 24,592.32231990992 +process/bench-env.js operation="query" n=1000000: 3,625,787.2150573144 +process/bench-env.js operation="delete" n=1000000: 1,521,131.5742806569 + +process/bench-hrtime.js +process/bench-hrtime.js type="raw" n=1000000: 13,178,002.113936031 +process/bench-hrtime.js type="diff" n=1000000: 11,585,435.712423025 +process/bench-hrtime.js type="bigint" n=1000000: 13,342,884.703919787 + +$ node benchmark/run.js --filter "bench-" --exclude "hrtime" process + +process/bench-env.js +process/bench-env.js operation="get" n=1000000: 2,356,946.0770617095 +process/bench-env.js operation="set" n=1000000: 1,295,176.3266261867 +process/bench-env.js operation="enumerate" n=1000000: 24,592.32231990992 +process/bench-env.js operation="query" n=1000000: 3,625,787.2150573144 +process/bench-env.js operation="delete" n=1000000: 1,521,131.5742806569 +``` + ### Comparing Node.js versions To compare the effect of a new Node.js version use the `compare.js` tool. This diff --git a/common.gypi b/common.gypi index 54a8d930c4c062..210e86eeb260d5 100644 --- a/common.gypi +++ b/common.gypi @@ -73,9 +73,6 @@ # TODO(refack): make v8-perfetto happen 'v8_use_perfetto': 0, - 'v8_enable_pointer_compression': 0, - 'v8_enable_31bit_smis_on_64bit_arch': 0, - ##### end V8 defaults ##### 'conditions': [ @@ -130,8 +127,8 @@ 'ldflags': [ '-Wl,-bbigtoc' ], }], ['OS == "android"', { - 'cflags': [ '-fPIE' ], - 'ldflags': [ '-fPIE', '-pie' ] + 'cflags': [ '-fPIC' ], + 'ldflags': [ '-fPIC' ] }], ], 'msvs_settings': { @@ -190,8 +187,8 @@ ], },], ['OS == "android"', { - 'cflags': [ '-fPIE' ], - 'ldflags': [ '-fPIE', '-pie' ] + 'cflags': [ '-fPIC' ], + 'ldflags': [ '-fPIC' ] }], ], 'msvs_settings': { diff --git a/configure.py b/configure.py index 48624aba92bf19..fb6a316118a9cb 100755 --- a/configure.py +++ b/configure.py @@ -346,6 +346,11 @@ dest='trace_maps', help='Enable the --trace-maps flag in V8 (use at your own risk)') +parser.add_option('--experimental-enable-pointer-compression', + action='store_true', + dest='enable_pointer_compression', + help='[Experimental] Enable V8 pointer compression (limits max heap to 4GB and breaks ABI compatibility)') + parser.add_option('--v8-options', action='store', dest='v8_options', @@ -1117,14 +1122,17 @@ def configure_node(o): o['variables']['node_shared'] = b(options.shared) node_module_version = getmoduleversion.get_version() - if sys.platform == 'darwin': + if options.dest_os == 'android': + shlib_suffix = 'so' + elif sys.platform == 'darwin': shlib_suffix = '%s.dylib' elif sys.platform.startswith('aix'): shlib_suffix = '%s.a' else: shlib_suffix = 'so.%s' + if '%s' in shlib_suffix: + shlib_suffix %= node_module_version - shlib_suffix %= node_module_version o['variables']['node_module_version'] = int(node_module_version) o['variables']['shlib_suffix'] = shlib_suffix @@ -1192,6 +1200,8 @@ def configure_v8(o): o['variables']['v8_random_seed'] = 0 # Use a random seed for hash tables. o['variables']['v8_promise_internal_field_count'] = 1 # Add internal field to promises for async hooks. o['variables']['v8_use_siphash'] = 0 if options.without_siphash else 1 + o['variables']['v8_enable_pointer_compression'] = 1 if options.enable_pointer_compression else 0 + o['variables']['v8_enable_31bit_smis_on_64bit_arch'] = 1 if options.enable_pointer_compression else 0 o['variables']['v8_trace_maps'] = 1 if options.trace_maps else 0 o['variables']['node_use_v8_platform'] = b(not options.without_v8_platform) o['variables']['node_use_bundled_v8'] = b(not options.without_bundled_v8) diff --git a/deps/icu-small/README-FULL-ICU.txt b/deps/icu-small/README-FULL-ICU.txt index d954e58a5fa0e3..99a75bed1defdd 100644 --- a/deps/icu-small/README-FULL-ICU.txt +++ b/deps/icu-small/README-FULL-ICU.txt @@ -1,8 +1,8 @@ ICU sources - auto generated by shrink-icu-src.py This directory contains the ICU subset used by --with-intl=full-icu -It is a strict subset of ICU 64 source files with the following exception(s): -* deps/icu-small/source/data/in/icudt64l.dat.bz2 : compressed data file +It is a strict subset of ICU 65 source files with the following exception(s): +* deps/icu-small/source/data/in/icudt65l.dat.bz2 : compressed data file To rebuild this directory, see ../../tools/icu/README.md diff --git a/deps/icu-small/source/common/brkeng.cpp b/deps/icu-small/source/common/brkeng.cpp index 42771b3617747d..68c74f2359c4a1 100644 --- a/deps/icu-small/source/common/brkeng.cpp +++ b/deps/icu-small/source/common/brkeng.cpp @@ -129,7 +129,7 @@ ICULanguageBreakFactory::getEngineFor(UChar32 c) { const LanguageBreakEngine *lbe = NULL; UErrorCode status = U_ZERO_ERROR; - static UMutex gBreakEngineMutex = U_MUTEX_INITIALIZER; + static UMutex gBreakEngineMutex; Mutex m(&gBreakEngineMutex); if (fEngines == NULL) { diff --git a/deps/icu-small/source/common/brkiter.cpp b/deps/icu-small/source/common/brkiter.cpp index 23e0cc3c153392..2fc4c345c7a038 100644 --- a/deps/icu-small/source/common/brkiter.cpp +++ b/deps/icu-small/source/common/brkiter.cpp @@ -277,7 +277,7 @@ ICUBreakIteratorService::~ICUBreakIteratorService() {} // defined in ucln_cmn.h U_NAMESPACE_END -static icu::UInitOnce gInitOnceBrkiter; +static icu::UInitOnce gInitOnceBrkiter = U_INITONCE_INITIALIZER; static icu::ICULocaleService* gService = NULL; diff --git a/deps/icu-small/source/common/bytesinkutil.h b/deps/icu-small/source/common/bytesinkutil.h index 69e4cbcd263932..6808fbe6777837 100644 --- a/deps/icu-small/source/common/bytesinkutil.h +++ b/deps/icu-small/source/common/bytesinkutil.h @@ -59,7 +59,7 @@ class U_COMMON_API ByteSinkUtil { ByteSink &sink, uint32_t options, Edits *edits); }; -class CharStringByteSink : public ByteSink { +class U_COMMON_API CharStringByteSink : public ByteSink { public: CharStringByteSink(CharString* dest); ~CharStringByteSink() override; diff --git a/deps/icu-small/source/common/characterproperties.cpp b/deps/icu-small/source/common/characterproperties.cpp index 5a57364375b372..7b50a4e2051b97 100644 --- a/deps/icu-small/source/common/characterproperties.cpp +++ b/deps/icu-small/source/common/characterproperties.cpp @@ -38,8 +38,8 @@ UBool U_CALLCONV characterproperties_cleanup(); constexpr int32_t NUM_INCLUSIONS = UPROPS_SRC_COUNT + UCHAR_INT_LIMIT - UCHAR_INT_START; struct Inclusion { - UnicodeSet *fSet; - UInitOnce fInitOnce; + UnicodeSet *fSet = nullptr; + UInitOnce fInitOnce = U_INITONCE_INITIALIZER; }; Inclusion gInclusions[NUM_INCLUSIONS]; // cached getInclusions() @@ -47,10 +47,7 @@ UnicodeSet *sets[UCHAR_BINARY_LIMIT] = {}; UCPMap *maps[UCHAR_INT_LIMIT - UCHAR_INT_START] = {}; -icu::UMutex *cpMutex() { - static icu::UMutex m = U_MUTEX_INITIALIZER; - return &m; -} +icu::UMutex cpMutex; //---------------------------------------------------------------- // Inclusions list @@ -361,7 +358,7 @@ u_getBinaryPropertySet(UProperty property, UErrorCode *pErrorCode) { *pErrorCode = U_ILLEGAL_ARGUMENT_ERROR; return nullptr; } - Mutex m(cpMutex()); + Mutex m(&cpMutex); UnicodeSet *set = sets[property]; if (set == nullptr) { sets[property] = set = makeSet(property, *pErrorCode); @@ -377,7 +374,7 @@ u_getIntPropertyMap(UProperty property, UErrorCode *pErrorCode) { *pErrorCode = U_ILLEGAL_ARGUMENT_ERROR; return nullptr; } - Mutex m(cpMutex()); + Mutex m(&cpMutex); UCPMap *map = maps[property - UCHAR_INT_START]; if (map == nullptr) { maps[property - UCHAR_INT_START] = map = makeMap(property, *pErrorCode); diff --git a/deps/icu-small/source/common/charstr.cpp b/deps/icu-small/source/common/charstr.cpp index 852cc539457760..dda29dac63273c 100644 --- a/deps/icu-small/source/common/charstr.cpp +++ b/deps/icu-small/source/common/charstr.cpp @@ -35,6 +35,17 @@ CharString& CharString::operator=(CharString&& src) U_NOEXCEPT { return *this; } +char *CharString::cloneData(UErrorCode &errorCode) const { + if (U_FAILURE(errorCode)) { return nullptr; } + char *p = static_cast(uprv_malloc(len + 1)); + if (p == nullptr) { + errorCode = U_MEMORY_ALLOCATION_ERROR; + return nullptr; + } + uprv_memcpy(p, buffer.getAlias(), len + 1); + return p; +} + CharString &CharString::copyFrom(const CharString &s, UErrorCode &errorCode) { if(U_SUCCESS(errorCode) && this!=&s && ensureCapacity(s.len+1, 0, errorCode)) { len=s.len; @@ -52,6 +63,18 @@ int32_t CharString::lastIndexOf(char c) const { return -1; } +bool CharString::contains(StringPiece s) const { + if (s.empty()) { return false; } + const char *p = buffer.getAlias(); + int32_t lastStart = len - s.length(); + for (int32_t i = 0; i <= lastStart; ++i) { + if (uprv_memcmp(p + i, s.data(), s.length()) == 0) { + return true; + } + } + return false; +} + CharString &CharString::truncate(int32_t newLength) { if(newLength<0) { newLength=0; diff --git a/deps/icu-small/source/common/charstr.h b/deps/icu-small/source/common/charstr.h index 1a97e01988f991..23b950ed6ecc76 100644 --- a/deps/icu-small/source/common/charstr.h +++ b/deps/icu-small/source/common/charstr.h @@ -82,10 +82,24 @@ class U_COMMON_API CharString : public UMemory { const char *data() const { return buffer.getAlias(); } char *data() { return buffer.getAlias(); } + /** + * Allocates length()+1 chars and copies the NUL-terminated data(). + * The caller must uprv_free() the result. + */ + char *cloneData(UErrorCode &errorCode) const; + + bool operator==(StringPiece other) const { + return len == other.length() && (len == 0 || uprv_memcmp(data(), other.data(), len) == 0); + } + bool operator!=(StringPiece other) const { + return !operator==(other); + } /** @return last index of c, or -1 if c is not in this string */ int32_t lastIndexOf(char c) const; + bool contains(StringPiece s) const; + CharString &clear() { len=0; buffer[0]=0; return *this; } CharString &truncate(int32_t newLength); diff --git a/deps/icu-small/source/common/cmemory.h b/deps/icu-small/source/common/cmemory.h index f501b20a14ca13..b24bd0ead2761c 100644 --- a/deps/icu-small/source/common/cmemory.h +++ b/deps/icu-small/source/common/cmemory.h @@ -64,38 +64,37 @@ uprv_free(void *mem); U_CAPI void * U_EXPORT2 uprv_calloc(size_t num, size_t size) U_MALLOC_ATTR U_ALLOC_SIZE_ATTR2(1,2); -/** - * This should align the memory properly on any machine. - * This is very useful for the safeClone functions. - */ -typedef union { - long t1; - double t2; - void *t3; -} UAlignedMemory; - /** * Get the least significant bits of a pointer (a memory address). * For example, with a mask of 3, the macro gets the 2 least significant bits, * which will be 0 if the pointer is 32-bit (4-byte) aligned. * - * ptrdiff_t is the most appropriate integer type to cast to. - * size_t should work too, since on most (or all?) platforms it has the same - * width as ptrdiff_t. + * uintptr_t is the most appropriate integer type to cast to. */ -#define U_POINTER_MASK_LSB(ptr, mask) (((ptrdiff_t)(char *)(ptr)) & (mask)) +#define U_POINTER_MASK_LSB(ptr, mask) ((uintptr_t)(ptr) & (mask)) /** - * Get the amount of bytes that a pointer is off by from - * the previous UAlignedMemory-aligned pointer. - */ -#define U_ALIGNMENT_OFFSET(ptr) U_POINTER_MASK_LSB(ptr, sizeof(UAlignedMemory) - 1) - -/** - * Get the amount of bytes to add to a pointer - * in order to get the next UAlignedMemory-aligned address. + * Create & return an instance of "type" in statically allocated storage. + * e.g. + * static std::mutex *myMutex = STATIC_NEW(std::mutex); + * To destroy an object created in this way, invoke the destructor explicitly, e.g. + * myMutex->~mutex(); + * DO NOT use delete. + * DO NOT use with class UMutex, which has specific support for static instances. + * + * STATIC_NEW is intended for use when + * - We want a static (or global) object. + * - We don't want it to ever be destructed, or to explicitly control destruction, + * to avoid use-after-destruction problems. + * - We want to avoid an ordinary heap allocated object, + * to avoid the possibility of memory allocation failures, and + * to avoid memory leak reports, from valgrind, for example. + * This is defined as a macro rather than a template function because each invocation + * must define distinct static storage for the object being returned. */ -#define U_ALIGNMENT_OFFSET_UP(ptr) (sizeof(UAlignedMemory) - U_ALIGNMENT_OFFSET(ptr)) +#define STATIC_NEW(type) [] () { \ + alignas(type) static char storage[sizeof(type)]; \ + return new(storage) type();} () /** * Heap clean up function, called from u_cleanup() diff --git a/deps/icu-small/source/common/edits.cpp b/deps/icu-small/source/common/edits.cpp index 00a8d601a1cc80..95f0c19a728cf4 100644 --- a/deps/icu-small/source/common/edits.cpp +++ b/deps/icu-small/source/common/edits.cpp @@ -243,7 +243,7 @@ UBool Edits::growArray() { return TRUE; } -UBool Edits::copyErrorTo(UErrorCode &outErrorCode) { +UBool Edits::copyErrorTo(UErrorCode &outErrorCode) const { if (U_FAILURE(outErrorCode)) { return TRUE; } if (U_SUCCESS(errorCode_)) { return FALSE; } outErrorCode = errorCode_; diff --git a/deps/icu-small/source/common/filteredbrk.cpp b/deps/icu-small/source/common/filteredbrk.cpp index 162b38de5d6fa2..ae7cf5270aeabf 100644 --- a/deps/icu-small/source/common/filteredbrk.cpp +++ b/deps/icu-small/source/common/filteredbrk.cpp @@ -173,7 +173,7 @@ class SimpleFilteredSentenceBreakIterator : public BreakIterator { status = U_SAFECLONE_ALLOCATED_WARNING; return clone(); } - virtual BreakIterator* clone(void) const { return new SimpleFilteredSentenceBreakIterator(*this); } + virtual SimpleFilteredSentenceBreakIterator* clone() const { return new SimpleFilteredSentenceBreakIterator(*this); } virtual UClassID getDynamicClassID(void) const { return NULL; } virtual UBool operator==(const BreakIterator& o) const { if(this==&o) return true; return false; } diff --git a/deps/icu-small/source/common/localebuilder.cpp b/deps/icu-small/source/common/localebuilder.cpp index fe931fcf759dfd..1dd8131e5895a5 100644 --- a/deps/icu-small/source/common/localebuilder.cpp +++ b/deps/icu-small/source/common/localebuilder.cpp @@ -157,13 +157,18 @@ _isKeywordValue(const char* key, const char* value, int32_t value_len) } static void -_copyExtensions(const Locale& from, Locale* to, bool validate, UErrorCode& errorCode) +_copyExtensions(const Locale& from, icu::StringEnumeration *keywords, + Locale& to, bool validate, UErrorCode& errorCode) { if (U_FAILURE(errorCode)) { return; } - LocalPointer iter(from.createKeywords(errorCode)); - if (U_FAILURE(errorCode) || iter.isNull()) { return; } + LocalPointer ownedKeywords; + if (keywords == nullptr) { + ownedKeywords.adoptInstead(from.createKeywords(errorCode)); + if (U_FAILURE(errorCode) || ownedKeywords.isNull()) { return; } + keywords = ownedKeywords.getAlias(); + } const char* key; - while ((key = iter->next(nullptr, errorCode)) != nullptr) { + while ((key = keywords->next(nullptr, errorCode)) != nullptr) { CharString value; CharStringByteSink sink(&value); from.getKeywordValue(key, sink, errorCode); @@ -176,34 +181,34 @@ _copyExtensions(const Locale& from, Locale* to, bool validate, UErrorCode& error errorCode = U_ILLEGAL_ARGUMENT_ERROR; return; } - to->setKeywordValue(key, value.data(), errorCode); + to.setKeywordValue(key, value.data(), errorCode); if (U_FAILURE(errorCode)) { return; } } } void static -_clearUAttributesAndKeyType(Locale* locale, UErrorCode& errorCode) +_clearUAttributesAndKeyType(Locale& locale, UErrorCode& errorCode) { // Clear Unicode attributes - locale->setKeywordValue(kAttributeKey, "", errorCode); + locale.setKeywordValue(kAttributeKey, "", errorCode); // Clear all Unicode keyword values - LocalPointer iter(locale->createUnicodeKeywords(errorCode)); + LocalPointer iter(locale.createUnicodeKeywords(errorCode)); if (U_FAILURE(errorCode) || iter.isNull()) { return; } const char* key; while ((key = iter->next(nullptr, errorCode)) != nullptr) { - locale->setUnicodeKeywordValue(key, nullptr, errorCode); + locale.setUnicodeKeywordValue(key, nullptr, errorCode); } } static void -_setUnicodeExtensions(Locale* locale, const CharString& value, UErrorCode& errorCode) +_setUnicodeExtensions(Locale& locale, const CharString& value, UErrorCode& errorCode) { // Add the unicode extensions to extensions_ CharString locale_str("und-u-", errorCode); locale_str.append(value, errorCode); _copyExtensions( - Locale::forLanguageTag(locale_str.data(), errorCode), + Locale::forLanguageTag(locale_str.data(), errorCode), nullptr, locale, false, errorCode); } @@ -235,10 +240,10 @@ LocaleBuilder& LocaleBuilder::setExtension(char key, StringPiece value) status_); return *this; } - _clearUAttributesAndKeyType(extensions_, status_); + _clearUAttributesAndKeyType(*extensions_, status_); if (U_FAILURE(status_)) { return *this; } if (!value.empty()) { - _setUnicodeExtensions(extensions_, value_str, status_); + _setUnicodeExtensions(*extensions_, value_str, status_); } return *this; } @@ -401,6 +406,24 @@ Locale makeBogusLocale() { return bogus; } +void LocaleBuilder::copyExtensionsFrom(const Locale& src, UErrorCode& errorCode) +{ + if (U_FAILURE(errorCode)) { return; } + LocalPointer keywords(src.createKeywords(errorCode)); + if (U_FAILURE(errorCode) || keywords.isNull() || keywords->count(errorCode) == 0) { + // Error, or no extensions to copy. + return; + } + if (extensions_ == nullptr) { + extensions_ = new Locale(); + if (extensions_ == nullptr) { + status_ = U_MEMORY_ALLOCATION_ERROR; + return; + } + } + _copyExtensions(src, keywords.getAlias(), *extensions_, false, errorCode); +} + Locale LocaleBuilder::build(UErrorCode& errorCode) { if (U_FAILURE(errorCode)) { @@ -425,7 +448,7 @@ Locale LocaleBuilder::build(UErrorCode& errorCode) } Locale product(locale_str.data()); if (extensions_ != nullptr) { - _copyExtensions(*extensions_, &product, true, errorCode); + _copyExtensions(*extensions_, nullptr, product, true, errorCode); } if (U_FAILURE(errorCode)) { return makeBogusLocale(); @@ -433,4 +456,13 @@ Locale LocaleBuilder::build(UErrorCode& errorCode) return product; } +UBool LocaleBuilder::copyErrorTo(UErrorCode &outErrorCode) const { + if (U_FAILURE(outErrorCode)) { + // Do not overwrite the older error code + return TRUE; + } + outErrorCode = status_; + return U_FAILURE(outErrorCode); +} + U_NAMESPACE_END diff --git a/deps/icu-small/source/common/localematcher.cpp b/deps/icu-small/source/common/localematcher.cpp new file mode 100644 index 00000000000000..d975fe759b4ce1 --- /dev/null +++ b/deps/icu-small/source/common/localematcher.cpp @@ -0,0 +1,720 @@ +// © 2019 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html#License + +// localematcher.cpp +// created: 2019may08 Markus W. Scherer + +#ifndef __LOCMATCHER_H__ +#define __LOCMATCHER_H__ + +#include "unicode/utypes.h" +#include "unicode/localebuilder.h" +#include "unicode/localematcher.h" +#include "unicode/locid.h" +#include "unicode/stringpiece.h" +#include "unicode/uobject.h" +#include "cstring.h" +#include "localeprioritylist.h" +#include "loclikelysubtags.h" +#include "locdistance.h" +#include "lsr.h" +#include "uassert.h" +#include "uhash.h" +#include "uvector.h" + +#define UND_LSR LSR("und", "", "") + +/** + * Indicator for the lifetime of desired-locale objects passed into the LocaleMatcher. + * + * @draft ICU 65 + */ +enum ULocMatchLifetime { + /** + * Locale objects are temporary. + * The matcher will make a copy of a locale that will be used beyond one function call. + * + * @draft ICU 65 + */ + ULOCMATCH_TEMPORARY_LOCALES, + /** + * Locale objects are stored at least as long as the matcher is used. + * The matcher will keep only a pointer to a locale that will be used beyond one function call, + * avoiding a copy. + * + * @draft ICU 65 + */ + ULOCMATCH_STORED_LOCALES // TODO: permanent? cached? clone? +}; +#ifndef U_IN_DOXYGEN +typedef enum ULocMatchLifetime ULocMatchLifetime; +#endif + +U_NAMESPACE_BEGIN + +LocaleMatcher::Result::Result(LocaleMatcher::Result &&src) U_NOEXCEPT : + desiredLocale(src.desiredLocale), + supportedLocale(src.supportedLocale), + desiredIndex(src.desiredIndex), + supportedIndex(src.supportedIndex), + desiredIsOwned(src.desiredIsOwned) { + if (desiredIsOwned) { + src.desiredLocale = nullptr; + src.desiredIndex = -1; + src.desiredIsOwned = FALSE; + } +} + +LocaleMatcher::Result::~Result() { + if (desiredIsOwned) { + delete desiredLocale; + } +} + +LocaleMatcher::Result &LocaleMatcher::Result::operator=(LocaleMatcher::Result &&src) U_NOEXCEPT { + this->~Result(); + + desiredLocale = src.desiredLocale; + supportedLocale = src.supportedLocale; + desiredIndex = src.desiredIndex; + supportedIndex = src.supportedIndex; + desiredIsOwned = src.desiredIsOwned; + + if (desiredIsOwned) { + src.desiredLocale = nullptr; + src.desiredIndex = -1; + src.desiredIsOwned = FALSE; + } + return *this; +} + +Locale LocaleMatcher::Result::makeResolvedLocale(UErrorCode &errorCode) const { + if (U_FAILURE(errorCode) || supportedLocale == nullptr) { + return Locale::getRoot(); + } + const Locale *bestDesired = getDesiredLocale(); + if (bestDesired == nullptr || *supportedLocale == *bestDesired) { + return *supportedLocale; + } + LocaleBuilder b; + b.setLocale(*supportedLocale); + + // Copy the region from bestDesired, if there is one. + const char *region = bestDesired->getCountry(); + if (*region != 0) { + b.setRegion(region); + } + + // Copy the variants from bestDesired, if there are any. + // Note that this will override any supportedLocale variants. + // For example, "sco-ulster-fonipa" + "...-fonupa" => "sco-fonupa" (replacing ulster). + const char *variants = bestDesired->getVariant(); + if (*variants != 0) { + b.setVariant(variants); + } + + // Copy the extensions from bestDesired, if there are any. + // C++ note: The following note, copied from Java, may not be true, + // as long as C++ copies by legacy ICU keyword, not by extension singleton. + // Note that this will override any supportedLocale extensions. + // For example, "th-u-nu-latn-ca-buddhist" + "...-u-nu-native" => "th-u-nu-native" + // (replacing calendar). + b.copyExtensionsFrom(*bestDesired, errorCode); + return b.build(errorCode); +} + +LocaleMatcher::Builder::Builder(LocaleMatcher::Builder &&src) U_NOEXCEPT : + errorCode_(src.errorCode_), + supportedLocales_(src.supportedLocales_), + thresholdDistance_(src.thresholdDistance_), + demotion_(src.demotion_), + defaultLocale_(src.defaultLocale_), + favor_(src.favor_) { + src.supportedLocales_ = nullptr; + src.defaultLocale_ = nullptr; +} + +LocaleMatcher::Builder::~Builder() { + delete supportedLocales_; + delete defaultLocale_; +} + +LocaleMatcher::Builder &LocaleMatcher::Builder::operator=(LocaleMatcher::Builder &&src) U_NOEXCEPT { + this->~Builder(); + + errorCode_ = src.errorCode_; + supportedLocales_ = src.supportedLocales_; + thresholdDistance_ = src.thresholdDistance_; + demotion_ = src.demotion_; + defaultLocale_ = src.defaultLocale_; + favor_ = src.favor_; + + src.supportedLocales_ = nullptr; + src.defaultLocale_ = nullptr; + return *this; +} + +void LocaleMatcher::Builder::clearSupportedLocales() { + if (supportedLocales_ != nullptr) { + supportedLocales_->removeAllElements(); + } +} + +bool LocaleMatcher::Builder::ensureSupportedLocaleVector() { + if (U_FAILURE(errorCode_)) { return false; } + if (supportedLocales_ != nullptr) { return true; } + supportedLocales_ = new UVector(uprv_deleteUObject, nullptr, errorCode_); + if (U_FAILURE(errorCode_)) { return false; } + if (supportedLocales_ == nullptr) { + errorCode_ = U_MEMORY_ALLOCATION_ERROR; + return false; + } + return true; +} + +LocaleMatcher::Builder &LocaleMatcher::Builder::setSupportedLocalesFromListString( + StringPiece locales) { + LocalePriorityList list(locales, errorCode_); + if (U_FAILURE(errorCode_)) { return *this; } + clearSupportedLocales(); + if (!ensureSupportedLocaleVector()) { return *this; } + int32_t length = list.getLengthIncludingRemoved(); + for (int32_t i = 0; i < length; ++i) { + Locale *locale = list.orphanLocaleAt(i); + if (locale == nullptr) { continue; } + supportedLocales_->addElement(locale, errorCode_); + if (U_FAILURE(errorCode_)) { + delete locale; + break; + } + } + return *this; +} + +LocaleMatcher::Builder &LocaleMatcher::Builder::setSupportedLocales(Locale::Iterator &locales) { + if (U_FAILURE(errorCode_)) { return *this; } + clearSupportedLocales(); + if (!ensureSupportedLocaleVector()) { return *this; } + while (locales.hasNext()) { + const Locale &locale = locales.next(); + Locale *clone = locale.clone(); + if (clone == nullptr) { + errorCode_ = U_MEMORY_ALLOCATION_ERROR; + break; + } + supportedLocales_->addElement(clone, errorCode_); + if (U_FAILURE(errorCode_)) { + delete clone; + break; + } + } + return *this; +} + +LocaleMatcher::Builder &LocaleMatcher::Builder::addSupportedLocale(const Locale &locale) { + if (!ensureSupportedLocaleVector()) { return *this; } + Locale *clone = locale.clone(); + if (clone == nullptr) { + errorCode_ = U_MEMORY_ALLOCATION_ERROR; + return *this; + } + supportedLocales_->addElement(clone, errorCode_); + if (U_FAILURE(errorCode_)) { + delete clone; + } + return *this; +} + +LocaleMatcher::Builder &LocaleMatcher::Builder::setDefaultLocale(const Locale *defaultLocale) { + if (U_FAILURE(errorCode_)) { return *this; } + Locale *clone = nullptr; + if (defaultLocale != nullptr) { + clone = defaultLocale->clone(); + if (clone == nullptr) { + errorCode_ = U_MEMORY_ALLOCATION_ERROR; + return *this; + } + } + delete defaultLocale_; + defaultLocale_ = clone; + return *this; +} + +LocaleMatcher::Builder &LocaleMatcher::Builder::setFavorSubtag(ULocMatchFavorSubtag subtag) { + if (U_FAILURE(errorCode_)) { return *this; } + favor_ = subtag; + return *this; +} + +LocaleMatcher::Builder &LocaleMatcher::Builder::setDemotionPerDesiredLocale(ULocMatchDemotion demotion) { + if (U_FAILURE(errorCode_)) { return *this; } + demotion_ = demotion; + return *this; +} + +#if 0 +/** + * Internal only! + * + * @param thresholdDistance the thresholdDistance to set, with -1 = default + * @return this Builder object + * @internal + * @deprecated This API is ICU internal only. + */ +@Deprecated +LocaleMatcher::Builder &LocaleMatcher::Builder::internalSetThresholdDistance(int32_t thresholdDistance) { + if (U_FAILURE(errorCode_)) { return *this; } + if (thresholdDistance > 100) { + thresholdDistance = 100; + } + thresholdDistance_ = thresholdDistance; + return *this; +} +#endif + +UBool LocaleMatcher::Builder::copyErrorTo(UErrorCode &outErrorCode) const { + if (U_FAILURE(outErrorCode)) { return TRUE; } + if (U_SUCCESS(errorCode_)) { return FALSE; } + outErrorCode = errorCode_; + return TRUE; +} + +LocaleMatcher LocaleMatcher::Builder::build(UErrorCode &errorCode) const { + if (U_SUCCESS(errorCode) && U_FAILURE(errorCode_)) { + errorCode = errorCode_; + } + return LocaleMatcher(*this, errorCode); +} + +namespace { + +LSR getMaximalLsrOrUnd(const XLikelySubtags &likelySubtags, const Locale &locale, + UErrorCode &errorCode) { + if (U_FAILURE(errorCode) || locale.isBogus() || *locale.getName() == 0 /* "und" */) { + return UND_LSR; + } else { + return likelySubtags.makeMaximizedLsrFrom(locale, errorCode); + } +} + +int32_t hashLSR(const UHashTok token) { + const LSR *lsr = static_cast(token.pointer); + return lsr->hashCode; +} + +UBool compareLSRs(const UHashTok t1, const UHashTok t2) { + const LSR *lsr1 = static_cast(t1.pointer); + const LSR *lsr2 = static_cast(t2.pointer); + return *lsr1 == *lsr2; +} + +bool putIfAbsent(UHashtable *lsrToIndex, const LSR &lsr, int32_t i, UErrorCode &errorCode) { + if (U_FAILURE(errorCode)) { return false; } + U_ASSERT(i > 0); + int32_t index = uhash_geti(lsrToIndex, &lsr); + if (index != 0) { + return false; + } else { + uhash_puti(lsrToIndex, const_cast(&lsr), i, &errorCode); + return U_SUCCESS(errorCode); + } +} + +} // namespace + +LocaleMatcher::LocaleMatcher(const Builder &builder, UErrorCode &errorCode) : + likelySubtags(*XLikelySubtags::getSingleton(errorCode)), + localeDistance(*LocaleDistance::getSingleton(errorCode)), + thresholdDistance(builder.thresholdDistance_), + demotionPerDesiredLocale(0), + favorSubtag(builder.favor_), + supportedLocales(nullptr), lsrs(nullptr), supportedLocalesLength(0), + supportedLsrToIndex(nullptr), + supportedLSRs(nullptr), supportedIndexes(nullptr), supportedLSRsLength(0), + ownedDefaultLocale(nullptr), defaultLocale(nullptr), defaultLocaleIndex(-1) { + if (U_FAILURE(errorCode)) { return; } + if (thresholdDistance < 0) { + thresholdDistance = localeDistance.getDefaultScriptDistance(); + } + supportedLocalesLength = builder.supportedLocales_ != nullptr ? + builder.supportedLocales_->size() : 0; + const Locale *def = builder.defaultLocale_; + int32_t idef = -1; + if (supportedLocalesLength > 0) { + // Store the supported locales in input order, + // so that when different types are used (e.g., language tag strings) + // we can return those by parallel index. + supportedLocales = static_cast( + uprv_malloc(supportedLocalesLength * sizeof(const Locale *))); + // Supported LRSs in input order. + // In C++, we store these permanently to simplify ownership management + // in the hash tables. Duplicate LSRs (if any) are unused overhead. + lsrs = new LSR[supportedLocalesLength]; + if (supportedLocales == nullptr || lsrs == nullptr) { + errorCode = U_MEMORY_ALLOCATION_ERROR; + return; + } + // If the constructor fails partway, we need null pointers for destructibility. + uprv_memset(supportedLocales, 0, supportedLocalesLength * sizeof(const Locale *)); + // Also find the first supported locale whose LSR is + // the same as that for the default locale. + LSR builderDefaultLSR; + const LSR *defLSR = nullptr; + if (def != nullptr) { + builderDefaultLSR = getMaximalLsrOrUnd(likelySubtags, *def, errorCode); + if (U_FAILURE(errorCode)) { return; } + defLSR = &builderDefaultLSR; + } + for (int32_t i = 0; i < supportedLocalesLength; ++i) { + const Locale &locale = *static_cast(builder.supportedLocales_->elementAt(i)); + supportedLocales[i] = locale.clone(); + if (supportedLocales[i] == nullptr) { + errorCode = U_MEMORY_ALLOCATION_ERROR; + return; + } + const Locale &supportedLocale = *supportedLocales[i]; + LSR &lsr = lsrs[i] = getMaximalLsrOrUnd(likelySubtags, supportedLocale, errorCode); + lsr.setHashCode(); + if (U_FAILURE(errorCode)) { return; } + if (idef < 0 && defLSR != nullptr && lsr == *defLSR) { + idef = i; + defLSR = &lsr; // owned pointer to put into supportedLsrToIndex + if (*def == supportedLocale) { + def = &supportedLocale; // owned pointer to keep + } + } + } + + // We need an unordered map from LSR to first supported locale with that LSR, + // and an ordered list of (LSR, supported index). + // We insert the supported locales in the following order: + // 1. Default locale, if it is supported. + // 2. Priority locales (aka "paradigm locales") in builder order. + // 3. Remaining locales in builder order. + // In Java, we use a LinkedHashMap for both map & ordered lists. + // In C++, we use separate structures. + // We over-allocate arrays of LSRs and indexes for simplicity. + // We reserve slots at the array starts for the default and paradigm locales, + // plus enough for all supported locales. + // If there are few paradigm locales and few duplicate supported LSRs, + // then the amount of wasted space is small. + supportedLsrToIndex = uhash_openSize(hashLSR, compareLSRs, uhash_compareLong, + supportedLocalesLength, &errorCode); + if (U_FAILURE(errorCode)) { return; } + int32_t paradigmLimit = 1 + localeDistance.getParadigmLSRsLength(); + int32_t suppLSRsCapacity = paradigmLimit + supportedLocalesLength; + supportedLSRs = static_cast( + uprv_malloc(suppLSRsCapacity * sizeof(const LSR *))); + supportedIndexes = static_cast( + uprv_malloc(suppLSRsCapacity * sizeof(int32_t))); + if (supportedLSRs == nullptr || supportedIndexes == nullptr) { + errorCode = U_MEMORY_ALLOCATION_ERROR; + return; + } + int32_t paradigmIndex = 0; + int32_t otherIndex = paradigmLimit; + if (idef >= 0) { + uhash_puti(supportedLsrToIndex, const_cast(defLSR), idef + 1, &errorCode); + supportedLSRs[0] = defLSR; + supportedIndexes[0] = idef; + paradigmIndex = 1; + } + for (int32_t i = 0; i < supportedLocalesLength; ++i) { + if (i == idef) { continue; } + const Locale &locale = *supportedLocales[i]; + const LSR &lsr = lsrs[i]; + if (defLSR == nullptr) { + U_ASSERT(i == 0); + def = &locale; + defLSR = &lsr; + idef = 0; + uhash_puti(supportedLsrToIndex, const_cast(&lsr), 0 + 1, &errorCode); + supportedLSRs[0] = &lsr; + supportedIndexes[0] = 0; + paradigmIndex = 1; + } else if (idef >= 0 && lsr == *defLSR) { + // lsr == *defLSR means that this supported locale is + // a duplicate of the default locale. + // Either an explicit default locale is supported, and we added it before the loop, + // or there is no explicit default locale, and this is + // a duplicate of the first supported locale. + // In both cases, idef >= 0 now, so otherwise we can skip the comparison. + // For a duplicate, putIfAbsent() is a no-op, so nothing to do. + } else { + if (putIfAbsent(supportedLsrToIndex, lsr, i + 1, errorCode)) { + if (localeDistance.isParadigmLSR(lsr)) { + supportedLSRs[paradigmIndex] = &lsr; + supportedIndexes[paradigmIndex++] = i; + } else { + supportedLSRs[otherIndex] = &lsr; + supportedIndexes[otherIndex++] = i; + } + } + } + if (U_FAILURE(errorCode)) { return; } + } + // Squeeze out unused array slots. + if (paradigmIndex < paradigmLimit && paradigmLimit < otherIndex) { + uprv_memmove(supportedLSRs + paradigmIndex, supportedLSRs + paradigmLimit, + (otherIndex - paradigmLimit) * sizeof(const LSR *)); + uprv_memmove(supportedIndexes + paradigmIndex, supportedIndexes + paradigmLimit, + (otherIndex - paradigmLimit) * sizeof(int32_t)); + } + supportedLSRsLength = otherIndex - (paradigmLimit - paradigmIndex); + } + + if (def != nullptr && (idef < 0 || def != supportedLocales[idef])) { + ownedDefaultLocale = def->clone(); + if (ownedDefaultLocale == nullptr) { + errorCode = U_MEMORY_ALLOCATION_ERROR; + return; + } + def = ownedDefaultLocale; + } + defaultLocale = def; + defaultLocaleIndex = idef; + + if (builder.demotion_ == ULOCMATCH_DEMOTION_REGION) { + demotionPerDesiredLocale = localeDistance.getDefaultDemotionPerDesiredLocale(); + } +} + +LocaleMatcher::LocaleMatcher(LocaleMatcher &&src) U_NOEXCEPT : + likelySubtags(src.likelySubtags), + localeDistance(src.localeDistance), + thresholdDistance(src.thresholdDistance), + demotionPerDesiredLocale(src.demotionPerDesiredLocale), + favorSubtag(src.favorSubtag), + supportedLocales(src.supportedLocales), lsrs(src.lsrs), + supportedLocalesLength(src.supportedLocalesLength), + supportedLsrToIndex(src.supportedLsrToIndex), + supportedLSRs(src.supportedLSRs), + supportedIndexes(src.supportedIndexes), + supportedLSRsLength(src.supportedLSRsLength), + ownedDefaultLocale(src.ownedDefaultLocale), defaultLocale(src.defaultLocale), + defaultLocaleIndex(src.defaultLocaleIndex) { + src.supportedLocales = nullptr; + src.lsrs = nullptr; + src.supportedLocalesLength = 0; + src.supportedLsrToIndex = nullptr; + src.supportedLSRs = nullptr; + src.supportedIndexes = nullptr; + src.supportedLSRsLength = 0; + src.ownedDefaultLocale = nullptr; + src.defaultLocale = nullptr; + src.defaultLocaleIndex = -1; +} + +LocaleMatcher::~LocaleMatcher() { + for (int32_t i = 0; i < supportedLocalesLength; ++i) { + delete supportedLocales[i]; + } + uprv_free(supportedLocales); + delete[] lsrs; + uhash_close(supportedLsrToIndex); + uprv_free(supportedLSRs); + uprv_free(supportedIndexes); + delete ownedDefaultLocale; +} + +LocaleMatcher &LocaleMatcher::operator=(LocaleMatcher &&src) U_NOEXCEPT { + this->~LocaleMatcher(); + + thresholdDistance = src.thresholdDistance; + demotionPerDesiredLocale = src.demotionPerDesiredLocale; + favorSubtag = src.favorSubtag; + supportedLocales = src.supportedLocales; + lsrs = src.lsrs; + supportedLocalesLength = src.supportedLocalesLength; + supportedLsrToIndex = src.supportedLsrToIndex; + supportedLSRs = src.supportedLSRs; + supportedIndexes = src.supportedIndexes; + supportedLSRsLength = src.supportedLSRsLength; + ownedDefaultLocale = src.ownedDefaultLocale; + defaultLocale = src.defaultLocale; + defaultLocaleIndex = src.defaultLocaleIndex; + + src.supportedLocales = nullptr; + src.lsrs = nullptr; + src.supportedLocalesLength = 0; + src.supportedLsrToIndex = nullptr; + src.supportedLSRs = nullptr; + src.supportedIndexes = nullptr; + src.supportedLSRsLength = 0; + src.ownedDefaultLocale = nullptr; + src.defaultLocale = nullptr; + src.defaultLocaleIndex = -1; + return *this; +} + +class LocaleLsrIterator { +public: + LocaleLsrIterator(const XLikelySubtags &likelySubtags, Locale::Iterator &locales, + ULocMatchLifetime lifetime) : + likelySubtags(likelySubtags), locales(locales), lifetime(lifetime) {} + + ~LocaleLsrIterator() { + if (lifetime == ULOCMATCH_TEMPORARY_LOCALES) { + delete remembered; + } + } + + bool hasNext() const { + return locales.hasNext(); + } + + LSR next(UErrorCode &errorCode) { + current = &locales.next(); + return getMaximalLsrOrUnd(likelySubtags, *current, errorCode); + } + + void rememberCurrent(int32_t desiredIndex, UErrorCode &errorCode) { + if (U_FAILURE(errorCode)) { return; } + bestDesiredIndex = desiredIndex; + if (lifetime == ULOCMATCH_STORED_LOCALES) { + remembered = current; + } else { + // ULOCMATCH_TEMPORARY_LOCALES + delete remembered; + remembered = new Locale(*current); + if (remembered == nullptr) { + errorCode = U_MEMORY_ALLOCATION_ERROR; + } + } + } + + const Locale *orphanRemembered() { + const Locale *rem = remembered; + remembered = nullptr; + return rem; + } + + int32_t getBestDesiredIndex() const { + return bestDesiredIndex; + } + +private: + const XLikelySubtags &likelySubtags; + Locale::Iterator &locales; + ULocMatchLifetime lifetime; + const Locale *current = nullptr, *remembered = nullptr; + int32_t bestDesiredIndex = -1; +}; + +const Locale *LocaleMatcher::getBestMatch(const Locale &desiredLocale, UErrorCode &errorCode) const { + if (U_FAILURE(errorCode)) { return nullptr; } + int32_t suppIndex = getBestSuppIndex( + getMaximalLsrOrUnd(likelySubtags, desiredLocale, errorCode), + nullptr, errorCode); + return U_SUCCESS(errorCode) && suppIndex >= 0 ? supportedLocales[suppIndex] : defaultLocale; +} + +const Locale *LocaleMatcher::getBestMatch(Locale::Iterator &desiredLocales, + UErrorCode &errorCode) const { + if (U_FAILURE(errorCode)) { return nullptr; } + if (!desiredLocales.hasNext()) { + return defaultLocale; + } + LocaleLsrIterator lsrIter(likelySubtags, desiredLocales, ULOCMATCH_TEMPORARY_LOCALES); + int32_t suppIndex = getBestSuppIndex(lsrIter.next(errorCode), &lsrIter, errorCode); + return U_SUCCESS(errorCode) && suppIndex >= 0 ? supportedLocales[suppIndex] : defaultLocale; +} + +const Locale *LocaleMatcher::getBestMatchForListString( + StringPiece desiredLocaleList, UErrorCode &errorCode) const { + LocalePriorityList list(desiredLocaleList, errorCode); + LocalePriorityList::Iterator iter = list.iterator(); + return getBestMatch(iter, errorCode); +} + +LocaleMatcher::Result LocaleMatcher::getBestMatchResult( + const Locale &desiredLocale, UErrorCode &errorCode) const { + if (U_FAILURE(errorCode)) { + return Result(nullptr, defaultLocale, -1, defaultLocaleIndex, FALSE); + } + int32_t suppIndex = getBestSuppIndex( + getMaximalLsrOrUnd(likelySubtags, desiredLocale, errorCode), + nullptr, errorCode); + if (U_FAILURE(errorCode) || suppIndex < 0) { + return Result(nullptr, defaultLocale, -1, defaultLocaleIndex, FALSE); + } else { + return Result(&desiredLocale, supportedLocales[suppIndex], 0, suppIndex, FALSE); + } +} + +LocaleMatcher::Result LocaleMatcher::getBestMatchResult( + Locale::Iterator &desiredLocales, UErrorCode &errorCode) const { + if (U_FAILURE(errorCode) || !desiredLocales.hasNext()) { + return Result(nullptr, defaultLocale, -1, defaultLocaleIndex, FALSE); + } + LocaleLsrIterator lsrIter(likelySubtags, desiredLocales, ULOCMATCH_TEMPORARY_LOCALES); + int32_t suppIndex = getBestSuppIndex(lsrIter.next(errorCode), &lsrIter, errorCode); + if (U_FAILURE(errorCode) || suppIndex < 0) { + return Result(nullptr, defaultLocale, -1, defaultLocaleIndex, FALSE); + } else { + return Result(lsrIter.orphanRemembered(), supportedLocales[suppIndex], + lsrIter.getBestDesiredIndex(), suppIndex, TRUE); + } +} + +int32_t LocaleMatcher::getBestSuppIndex(LSR desiredLSR, LocaleLsrIterator *remainingIter, + UErrorCode &errorCode) const { + if (U_FAILURE(errorCode)) { return -1; } + int32_t desiredIndex = 0; + int32_t bestSupportedLsrIndex = -1; + for (int32_t bestDistance = thresholdDistance;;) { + // Quick check for exact maximized LSR. + // Returns suppIndex+1 where 0 means not found. + if (supportedLsrToIndex != nullptr) { + desiredLSR.setHashCode(); + int32_t index = uhash_geti(supportedLsrToIndex, &desiredLSR); + if (index != 0) { + int32_t suppIndex = index - 1; + if (remainingIter != nullptr) { + remainingIter->rememberCurrent(desiredIndex, errorCode); + } + return suppIndex; + } + } + int32_t bestIndexAndDistance = localeDistance.getBestIndexAndDistance( + desiredLSR, supportedLSRs, supportedLSRsLength, bestDistance, favorSubtag); + if (bestIndexAndDistance >= 0) { + bestDistance = bestIndexAndDistance & 0xff; + if (remainingIter != nullptr) { + remainingIter->rememberCurrent(desiredIndex, errorCode); + if (U_FAILURE(errorCode)) { return -1; } + } + bestSupportedLsrIndex = bestIndexAndDistance >= 0 ? bestIndexAndDistance >> 8 : -1; + } + if ((bestDistance -= demotionPerDesiredLocale) <= 0) { + break; + } + if (remainingIter == nullptr || !remainingIter->hasNext()) { + break; + } + desiredLSR = remainingIter->next(errorCode); + if (U_FAILURE(errorCode)) { return -1; } + ++desiredIndex; + } + if (bestSupportedLsrIndex < 0) { + // no good match + return -1; + } + return supportedIndexes[bestSupportedLsrIndex]; +} + +double LocaleMatcher::internalMatch(const Locale &desired, const Locale &supported, UErrorCode &errorCode) const { + // Returns the inverse of the distance: That is, 1-distance(desired, supported). + LSR suppLSR = getMaximalLsrOrUnd(likelySubtags, supported, errorCode); + if (U_FAILURE(errorCode)) { return 0; } + const LSR *pSuppLSR = &suppLSR; + int32_t distance = localeDistance.getBestIndexAndDistance( + getMaximalLsrOrUnd(likelySubtags, desired, errorCode), + &pSuppLSR, 1, + thresholdDistance, favorSubtag) & 0xff; + return (100 - distance) / 100.0; +} + +U_NAMESPACE_END + +#endif // __LOCMATCHER_H__ diff --git a/deps/icu-small/source/common/localeprioritylist.cpp b/deps/icu-small/source/common/localeprioritylist.cpp new file mode 100644 index 00000000000000..06442fb46a83ad --- /dev/null +++ b/deps/icu-small/source/common/localeprioritylist.cpp @@ -0,0 +1,239 @@ +// © 2019 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html#License + +// localeprioritylist.cpp +// created: 2019jul11 Markus W. Scherer + +#include "unicode/utypes.h" +#include "unicode/localpointer.h" +#include "unicode/locid.h" +#include "unicode/stringpiece.h" +#include "unicode/uobject.h" +#include "charstr.h" +#include "cmemory.h" +#include "localeprioritylist.h" +#include "uarrsort.h" +#include "uassert.h" +#include "uhash.h" + +U_NAMESPACE_BEGIN + +namespace { + +int32_t hashLocale(const UHashTok token) { + auto *locale = static_cast(token.pointer); + return locale->hashCode(); +} + +UBool compareLocales(const UHashTok t1, const UHashTok t2) { + auto *l1 = static_cast(t1.pointer); + auto *l2 = static_cast(t2.pointer); + return *l1 == *l2; +} + +constexpr int32_t WEIGHT_ONE = 1000; + +struct LocaleAndWeight { + Locale *locale; + int32_t weight; // 0..1000 = 0.0..1.0 + int32_t index; // force stable sort + + int32_t compare(const LocaleAndWeight &other) const { + int32_t diff = other.weight - weight; // descending: other-this + if (diff != 0) { return diff; } + return index - other.index; + } +}; + +int32_t U_CALLCONV +compareLocaleAndWeight(const void * /*context*/, const void *left, const void *right) { + return static_cast(left)-> + compare(*static_cast(right)); +} + +const char *skipSpaces(const char *p, const char *limit) { + while (p < limit && *p == ' ') { ++p; } + return p; +} + +int32_t findTagLength(const char *p, const char *limit) { + // Look for accept-language delimiters. + // Leave other validation up to the Locale constructor. + const char *q; + for (q = p; q < limit; ++q) { + char c = *q; + if (c == ' ' || c == ',' || c == ';') { break; } + } + return static_cast(q - p); +} + +/** + * Parses and returns a qvalue weight in millis. + * Advances p to after the parsed substring. + * Returns a negative value if parsing fails. + */ +int32_t parseWeight(const char *&p, const char *limit) { + p = skipSpaces(p, limit); + char c; + if (p == limit || ((c = *p) != '0' && c != '1')) { return -1; } + int32_t weight = (c - '0') * 1000; + if (++p == limit || *p != '.') { return weight; } + int32_t multiplier = 100; + while (++p != limit && '0' <= (c = *p) && c <= '9') { + c -= '0'; + if (multiplier > 0) { + weight += c * multiplier; + multiplier /= 10; + } else if (multiplier == 0) { + // round up + if (c >= 5) { ++weight; } + multiplier = -1; + } // else ignore further fraction digits + } + return weight <= WEIGHT_ONE ? weight : -1; // bad if > 1.0 +} + +} // namespace + +/** + * Nothing but a wrapper over a MaybeStackArray of LocaleAndWeight. + * + * This wrapper exists (and is not in an anonymous namespace) + * so that we can forward-declare it in the header file and + * don't have to expose the MaybeStackArray specialization and + * the LocaleAndWeight to code (like the test) that #includes localeprioritylist.h. + * Also, otherwise we would have to do a platform-specific + * template export declaration of some kind for the MaybeStackArray specialization + * to be properly exported from the common DLL. + */ +struct LocaleAndWeightArray : public UMemory { + MaybeStackArray array; +}; + +LocalePriorityList::LocalePriorityList(StringPiece s, UErrorCode &errorCode) { + if (U_FAILURE(errorCode)) { return; } + list = new LocaleAndWeightArray(); + if (list == nullptr) { + errorCode = U_MEMORY_ALLOCATION_ERROR; + return; + } + const char *p = s.data(); + const char *limit = p + s.length(); + while ((p = skipSpaces(p, limit)) != limit) { + if (*p == ',') { // empty range field + ++p; + continue; + } + int32_t tagLength = findTagLength(p, limit); + if (tagLength == 0) { + errorCode = U_ILLEGAL_ARGUMENT_ERROR; + return; + } + CharString tag(p, tagLength, errorCode); + if (U_FAILURE(errorCode)) { return; } + Locale locale = Locale(tag.data()); + if (locale.isBogus()) { + errorCode = U_MEMORY_ALLOCATION_ERROR; + return; + } + int32_t weight = WEIGHT_ONE; + if ((p = skipSpaces(p + tagLength, limit)) != limit && *p == ';') { + if ((p = skipSpaces(p + 1, limit)) == limit || *p != 'q' || + (p = skipSpaces(p + 1, limit)) == limit || *p != '=' || + (++p, (weight = parseWeight(p, limit)) < 0)) { + errorCode = U_ILLEGAL_ARGUMENT_ERROR; + return; + } + p = skipSpaces(p, limit); + } + if (p != limit && *p != ',') { // trailing junk + errorCode = U_ILLEGAL_ARGUMENT_ERROR; + return; + } + add(locale, weight, errorCode); + if (p == limit) { break; } + ++p; + } + sort(errorCode); +} + +LocalePriorityList::~LocalePriorityList() { + if (list != nullptr) { + for (int32_t i = 0; i < listLength; ++i) { + delete list->array[i].locale; + } + delete list; + } + uhash_close(map); +} + +const Locale *LocalePriorityList::localeAt(int32_t i) const { + return list->array[i].locale; +} + +Locale *LocalePriorityList::orphanLocaleAt(int32_t i) { + if (list == nullptr) { return nullptr; } + LocaleAndWeight &lw = list->array[i]; + Locale *l = lw.locale; + lw.locale = nullptr; + return l; +} + +bool LocalePriorityList::add(const Locale &locale, int32_t weight, UErrorCode &errorCode) { + if (U_FAILURE(errorCode)) { return false; } + if (map == nullptr) { + if (weight <= 0) { return true; } // do not add q=0 + map = uhash_open(hashLocale, compareLocales, uhash_compareLong, &errorCode); + if (U_FAILURE(errorCode)) { return false; } + } + LocalPointer clone; + int32_t index = uhash_geti(map, &locale); + if (index != 0) { + // Duplicate: Remove the old item and append it anew. + LocaleAndWeight &lw = list->array[index - 1]; + clone.adoptInstead(lw.locale); + lw.locale = nullptr; + lw.weight = 0; + ++numRemoved; + } + if (weight <= 0) { // do not add q=0 + if (index != 0) { + // Not strictly necessary but cleaner. + uhash_removei(map, &locale); + } + return true; + } + if (clone.isNull()) { + clone.adoptInstead(locale.clone()); + if (clone.isNull() || (clone->isBogus() && !locale.isBogus())) { + errorCode = U_MEMORY_ALLOCATION_ERROR; + return false; + } + } + if (listLength == list->array.getCapacity()) { + int32_t newCapacity = listLength < 50 ? 100 : 4 * listLength; + if (list->array.resize(newCapacity, listLength) == nullptr) { + errorCode = U_MEMORY_ALLOCATION_ERROR; + return false; + } + } + uhash_puti(map, clone.getAlias(), listLength + 1, &errorCode); + if (U_FAILURE(errorCode)) { return false; } + LocaleAndWeight &lw = list->array[listLength]; + lw.locale = clone.orphan(); + lw.weight = weight; + lw.index = listLength++; + if (weight < WEIGHT_ONE) { hasWeights = true; } + U_ASSERT(uhash_count(map) == getLength()); + return true; +} + +void LocalePriorityList::sort(UErrorCode &errorCode) { + // Sort by descending weights if there is a mix of weights. + // The comparator forces a stable sort via the item index. + if (U_FAILURE(errorCode) || getLength() <= 1 || !hasWeights) { return; } + uprv_sortArray(list->array.getAlias(), listLength, sizeof(LocaleAndWeight), + compareLocaleAndWeight, nullptr, FALSE, &errorCode); +} + +U_NAMESPACE_END diff --git a/deps/icu-small/source/common/localeprioritylist.h b/deps/icu-small/source/common/localeprioritylist.h new file mode 100644 index 00000000000000..80ca38a7b52892 --- /dev/null +++ b/deps/icu-small/source/common/localeprioritylist.h @@ -0,0 +1,115 @@ +// © 2019 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html#License + +// localeprioritylist.h +// created: 2019jul11 Markus W. Scherer + +#ifndef __LOCALEPRIORITYLIST_H__ +#define __LOCALEPRIORITYLIST_H__ + +#include "unicode/utypes.h" +#include "unicode/locid.h" +#include "unicode/stringpiece.h" +#include "unicode/uobject.h" + +struct UHashtable; + +U_NAMESPACE_BEGIN + +struct LocaleAndWeightArray; + +/** + * Parses a list of locales from an accept-language string. + * We are a bit more lenient than the spec: + * We accept extra whitespace in more places, empty range fields, + * and any number of qvalue fraction digits. + * + * https://tools.ietf.org/html/rfc2616#section-14.4 + * 14.4 Accept-Language + * + * Accept-Language = "Accept-Language" ":" + * 1#( language-range [ ";" "q" "=" qvalue ] ) + * language-range = ( ( 1*8ALPHA *( "-" 1*8ALPHA ) ) | "*" ) + * + * Each language-range MAY be given an associated quality value which + * represents an estimate of the user's preference for the languages + * specified by that range. The quality value defaults to "q=1". For + * example, + * + * Accept-Language: da, en-gb;q=0.8, en;q=0.7 + * + * https://tools.ietf.org/html/rfc2616#section-3.9 + * 3.9 Quality Values + * + * HTTP content negotiation (section 12) uses short "floating point" + * numbers to indicate the relative importance ("weight") of various + * negotiable parameters. A weight is normalized to a real number in + * the range 0 through 1, where 0 is the minimum and 1 the maximum + * value. If a parameter has a quality value of 0, then content with + * this parameter is `not acceptable' for the client. HTTP/1.1 + * applications MUST NOT generate more than three digits after the + * decimal point. User configuration of these values SHOULD also be + * limited in this fashion. + * + * qvalue = ( "0" [ "." 0*3DIGIT ] ) + * | ( "1" [ "." 0*3("0") ] ) + */ +class U_COMMON_API LocalePriorityList : public UMemory { +public: + class Iterator : public Locale::Iterator { + public: + UBool hasNext() const override { return count < length; } + + const Locale &next() override { + for(;;) { + const Locale *locale = list.localeAt(index++); + if (locale != nullptr) { + ++count; + return *locale; + } + } + } + + private: + friend class LocalePriorityList; + + Iterator(const LocalePriorityList &list) : list(list), length(list.getLength()) {} + + const LocalePriorityList &list; + int32_t index = 0; + int32_t count = 0; + const int32_t length; + }; + + LocalePriorityList(StringPiece s, UErrorCode &errorCode); + + ~LocalePriorityList(); + + int32_t getLength() const { return listLength - numRemoved; } + + int32_t getLengthIncludingRemoved() const { return listLength; } + + Iterator iterator() const { return Iterator(*this); } + + const Locale *localeAt(int32_t i) const; + + Locale *orphanLocaleAt(int32_t i); + +private: + LocalePriorityList(const LocalePriorityList &) = delete; + LocalePriorityList &operator=(const LocalePriorityList &) = delete; + + bool add(const Locale &locale, int32_t weight, UErrorCode &errorCode); + + void sort(UErrorCode &errorCode); + + LocaleAndWeightArray *list = nullptr; + int32_t listLength = 0; + int32_t numRemoved = 0; + bool hasWeights = false; // other than 1.0 + UHashtable *map = nullptr; +}; + +U_NAMESPACE_END + +#endif // __LOCALEPRIORITYLIST_H__ diff --git a/deps/icu-small/source/common/locavailable.cpp b/deps/icu-small/source/common/locavailable.cpp index 1e608ffb9e1c84..ad9d2ca8c7bb53 100644 --- a/deps/icu-small/source/common/locavailable.cpp +++ b/deps/icu-small/source/common/locavailable.cpp @@ -19,11 +19,13 @@ * that then do not depend on resource bundle code and res_index bundles. */ +#include "unicode/errorcode.h" #include "unicode/utypes.h" #include "unicode/locid.h" #include "unicode/uloc.h" #include "unicode/ures.h" #include "cmemory.h" +#include "cstring.h" #include "ucln_cmn.h" #include "uassert.h" #include "umutex.h" @@ -95,84 +97,174 @@ U_NAMESPACE_USE /* ### Constants **************************************************/ -/* These strings describe the resources we attempt to load from - the locale ResourceBundle data file.*/ -static const char _kIndexLocaleName[] = "res_index"; -static const char _kIndexTag[] = "InstalledLocales"; +namespace { -static char** _installedLocales = NULL; -static int32_t _installedLocalesCount = 0; -static icu::UInitOnce _installedLocalesInitOnce; +// Enough capacity for the two lists in the res_index.res file +const char** gAvailableLocaleNames[2] = {}; +int32_t gAvailableLocaleCounts[2] = {}; +icu::UInitOnce ginstalledLocalesInitOnce = U_INITONCE_INITIALIZER; -/* ### Get available **************************************************/ +class AvailableLocalesSink : public ResourceSink { + public: + void put(const char *key, ResourceValue &value, UBool /*noFallback*/, UErrorCode &status) U_OVERRIDE { + ResourceTable resIndexTable = value.getTable(status); + if (U_FAILURE(status)) { + return; + } + for (int32_t i = 0; resIndexTable.getKeyAndValue(i, key, value); ++i) { + ULocAvailableType type; + if (uprv_strcmp(key, "InstalledLocales") == 0) { + type = ULOC_AVAILABLE_DEFAULT; + } else if (uprv_strcmp(key, "AliasLocales") == 0) { + type = ULOC_AVAILABLE_ONLY_LEGACY_ALIASES; + } else { + // CLDRVersion, etc. + continue; + } + ResourceTable availableLocalesTable = value.getTable(status); + if (U_FAILURE(status)) { + return; + } + gAvailableLocaleCounts[type] = availableLocalesTable.getSize(); + gAvailableLocaleNames[type] = static_cast( + uprv_malloc(gAvailableLocaleCounts[type] * sizeof(const char*))); + if (gAvailableLocaleNames[type] == nullptr) { + status = U_MEMORY_ALLOCATION_ERROR; + return; + } + for (int32_t j = 0; availableLocalesTable.getKeyAndValue(j, key, value); ++j) { + gAvailableLocaleNames[type][j] = key; + } + } + } +}; -static UBool U_CALLCONV uloc_cleanup(void) { - char ** temp; +class AvailableLocalesStringEnumeration : public StringEnumeration { + public: + AvailableLocalesStringEnumeration(ULocAvailableType type) : fType(type) { + } + + const char* next(int32_t *resultLength, UErrorCode&) override { + ULocAvailableType actualType = fType; + int32_t actualIndex = fIndex++; + + // If the "combined" list was requested, resolve that now + if (fType == ULOC_AVAILABLE_WITH_LEGACY_ALIASES) { + int32_t defaultLocalesCount = gAvailableLocaleCounts[ULOC_AVAILABLE_DEFAULT]; + if (actualIndex < defaultLocalesCount) { + actualType = ULOC_AVAILABLE_DEFAULT; + } else { + actualIndex -= defaultLocalesCount; + actualType = ULOC_AVAILABLE_ONLY_LEGACY_ALIASES; + } + } + + // Return the requested string + int32_t count = gAvailableLocaleCounts[actualType]; + const char* result; + if (actualIndex < count) { + result = gAvailableLocaleNames[actualType][actualIndex]; + if (resultLength != nullptr) { + *resultLength = static_cast(uprv_strlen(result)); + } + } else { + result = nullptr; + if (resultLength != nullptr) { + *resultLength = 0; + } + } + return result; + } + + void reset(UErrorCode&) override { + fIndex = 0; + } + + int32_t count(UErrorCode&) const override { + if (fType == ULOC_AVAILABLE_WITH_LEGACY_ALIASES) { + return gAvailableLocaleCounts[ULOC_AVAILABLE_DEFAULT] + + gAvailableLocaleCounts[ULOC_AVAILABLE_ONLY_LEGACY_ALIASES]; + } else { + return gAvailableLocaleCounts[fType]; + } + } - if (_installedLocales) { - temp = _installedLocales; - _installedLocales = NULL; + private: + ULocAvailableType fType; + int32_t fIndex = 0; +}; - _installedLocalesCount = 0; - _installedLocalesInitOnce.reset(); +/* ### Get available **************************************************/ - uprv_free(temp); +static UBool U_CALLCONV uloc_cleanup(void) { + for (int32_t i = 0; i < UPRV_LENGTHOF(gAvailableLocaleNames); i++) { + uprv_free(gAvailableLocaleNames[i]); + gAvailableLocaleNames[i] = nullptr; + gAvailableLocaleCounts[i] = 0; } + ginstalledLocalesInitOnce.reset(); return TRUE; } // Load Installed Locales. This function will be called exactly once // via the initOnce mechanism. -static void U_CALLCONV loadInstalledLocales() { - UErrorCode status = U_ZERO_ERROR; - int32_t i = 0; - int32_t localeCount; - - U_ASSERT(_installedLocales == NULL); - U_ASSERT(_installedLocalesCount == 0); +static void U_CALLCONV loadInstalledLocales(UErrorCode& status) { + ucln_common_registerCleanup(UCLN_COMMON_ULOC, uloc_cleanup); - _installedLocalesCount = 0; + icu::LocalUResourceBundlePointer rb(ures_openDirect(NULL, "res_index", &status)); + AvailableLocalesSink sink; + ures_getAllItemsWithFallback(rb.getAlias(), "", sink, status); +} - icu::LocalUResourceBundlePointer indexLocale(ures_openDirect(NULL, _kIndexLocaleName, &status)); - icu::StackUResourceBundle installed; +void _load_installedLocales(UErrorCode& status) { + umtx_initOnce(ginstalledLocalesInitOnce, &loadInstalledLocales, status); +} - ures_getByKey(indexLocale.getAlias(), _kIndexTag, installed.getAlias(), &status); +} // namespace - if(U_SUCCESS(status)) { - localeCount = ures_getSize(installed.getAlias()); - _installedLocales = (char **) uprv_malloc(sizeof(char*) * (localeCount+1)); - if (_installedLocales != NULL) { - ures_resetIterator(installed.getAlias()); - while(ures_hasNext(installed.getAlias())) { - ures_getNextString(installed.getAlias(), NULL, (const char **)&_installedLocales[i++], &status); - } - _installedLocales[i] = NULL; - _installedLocalesCount = localeCount; - ucln_common_registerCleanup(UCLN_COMMON_ULOC, uloc_cleanup); - } +U_CAPI const char* U_EXPORT2 +uloc_getAvailable(int32_t offset) { + icu::ErrorCode status; + _load_installedLocales(status); + if (status.isFailure()) { + return nullptr; + } + if (offset > gAvailableLocaleCounts[0]) { + // *status = U_ILLEGAL_ARGUMENT_ERROR; + return nullptr; } + return gAvailableLocaleNames[0][offset]; } -static void _load_installedLocales() -{ - umtx_initOnce(_installedLocalesInitOnce, &loadInstalledLocales); +U_CAPI int32_t U_EXPORT2 +uloc_countAvailable() { + icu::ErrorCode status; + _load_installedLocales(status); + if (status.isFailure()) { + return 0; + } + return gAvailableLocaleCounts[0]; } -U_CAPI const char* U_EXPORT2 -uloc_getAvailable(int32_t offset) -{ - - _load_installedLocales(); - - if (offset > _installedLocalesCount) - return NULL; - return _installedLocales[offset]; +U_CAPI UEnumeration* U_EXPORT2 +uloc_openAvailableByType(ULocAvailableType type, UErrorCode* status) { + if (U_FAILURE(*status)) { + return nullptr; + } + if (type < 0 || type >= ULOC_AVAILABLE_COUNT) { + *status = U_ILLEGAL_ARGUMENT_ERROR; + return nullptr; + } + _load_installedLocales(*status); + if (U_FAILURE(*status)) { + return nullptr; + } + LocalPointer result( + new AvailableLocalesStringEnumeration(type), *status); + if (U_FAILURE(*status)) { + return nullptr; + } + return uenum_openFromStringEnumeration(result.orphan(), status); } -U_CAPI int32_t U_EXPORT2 -uloc_countAvailable() -{ - _load_installedLocales(); - return _installedLocalesCount; -} diff --git a/deps/icu-small/source/common/locbased.h b/deps/icu-small/source/common/locbased.h index 6db6a41dc416df..9163bd11cfe65f 100644 --- a/deps/icu-small/source/common/locbased.h +++ b/deps/icu-small/source/common/locbased.h @@ -22,7 +22,7 @@ * `actualLocale' of size ULOC_FULLNAME_CAPACITY */ #define U_LOCALE_BASED(varname, objname) \ - LocaleBased varname((objname).validLocale, (objname).actualLocale); + LocaleBased varname((objname).validLocale, (objname).actualLocale) U_NAMESPACE_BEGIN diff --git a/deps/icu-small/source/common/locdistance.cpp b/deps/icu-small/source/common/locdistance.cpp new file mode 100644 index 00000000000000..800d0eacf2b605 --- /dev/null +++ b/deps/icu-small/source/common/locdistance.cpp @@ -0,0 +1,364 @@ +// © 2019 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html#License + +// locdistance.cpp +// created: 2019may08 Markus W. Scherer + +#include "unicode/utypes.h" +#include "unicode/bytestrie.h" +#include "unicode/localematcher.h" +#include "unicode/locid.h" +#include "unicode/uobject.h" +#include "unicode/ures.h" +#include "cstring.h" +#include "locdistance.h" +#include "loclikelysubtags.h" +#include "uassert.h" +#include "ucln_cmn.h" +#include "uinvchar.h" +#include "umutex.h" + +U_NAMESPACE_BEGIN + +namespace { + +/** + * Bit flag used on the last character of a subtag in the trie. + * Must be set consistently by the builder and the lookup code. + */ +constexpr int32_t END_OF_SUBTAG = 0x80; +/** Distance value bit flag, set by the builder. */ +constexpr int32_t DISTANCE_SKIP_SCRIPT = 0x80; +/** Distance value bit flag, set by trieNext(). */ +constexpr int32_t DISTANCE_IS_FINAL = 0x100; +constexpr int32_t DISTANCE_IS_FINAL_OR_SKIP_SCRIPT = DISTANCE_IS_FINAL | DISTANCE_SKIP_SCRIPT; + +constexpr int32_t ABOVE_THRESHOLD = 100; + +// Indexes into array of distances. +enum { + IX_DEF_LANG_DISTANCE, + IX_DEF_SCRIPT_DISTANCE, + IX_DEF_REGION_DISTANCE, + IX_MIN_REGION_DISTANCE, + IX_LIMIT +}; + +LocaleDistance *gLocaleDistance = nullptr; +UInitOnce gInitOnce = U_INITONCE_INITIALIZER; + +UBool U_CALLCONV cleanup() { + delete gLocaleDistance; + gLocaleDistance = nullptr; + gInitOnce.reset(); + return TRUE; +} + +} // namespace + +void U_CALLCONV LocaleDistance::initLocaleDistance(UErrorCode &errorCode) { + // This function is invoked only via umtx_initOnce(). + U_ASSERT(gLocaleDistance == nullptr); + const XLikelySubtags &likely = *XLikelySubtags::getSingleton(errorCode); + if (U_FAILURE(errorCode)) { return; } + const LocaleDistanceData &data = likely.getDistanceData(); + if (data.distanceTrieBytes == nullptr || + data.regionToPartitions == nullptr || data.partitions == nullptr || + // ok if no paradigms + data.distances == nullptr) { + errorCode = U_MISSING_RESOURCE_ERROR; + return; + } + gLocaleDistance = new LocaleDistance(data); + if (gLocaleDistance == nullptr) { + errorCode = U_MEMORY_ALLOCATION_ERROR; + return; + } + ucln_common_registerCleanup(UCLN_COMMON_LOCALE_DISTANCE, cleanup); +} + +const LocaleDistance *LocaleDistance::getSingleton(UErrorCode &errorCode) { + if (U_FAILURE(errorCode)) { return nullptr; } + umtx_initOnce(gInitOnce, &LocaleDistance::initLocaleDistance, errorCode); + return gLocaleDistance; +} + +LocaleDistance::LocaleDistance(const LocaleDistanceData &data) : + trie(data.distanceTrieBytes), + regionToPartitionsIndex(data.regionToPartitions), partitionArrays(data.partitions), + paradigmLSRs(data.paradigms), paradigmLSRsLength(data.paradigmsLength), + defaultLanguageDistance(data.distances[IX_DEF_LANG_DISTANCE]), + defaultScriptDistance(data.distances[IX_DEF_SCRIPT_DISTANCE]), + defaultRegionDistance(data.distances[IX_DEF_REGION_DISTANCE]), + minRegionDistance(data.distances[IX_MIN_REGION_DISTANCE]) { + // For the default demotion value, use the + // default region distance between unrelated Englishes. + // Thus, unless demotion is turned off, + // a mere region difference for one desired locale + // is as good as a perfect match for the next following desired locale. + // As of CLDR 36, we have . + LSR en("en", "Latn", "US"); + LSR enGB("en", "Latn", "GB"); + const LSR *p_enGB = &enGB; + defaultDemotionPerDesiredLocale = getBestIndexAndDistance(en, &p_enGB, 1, + 50, ULOCMATCH_FAVOR_LANGUAGE) & 0xff; +} + +int32_t LocaleDistance::getBestIndexAndDistance( + const LSR &desired, + const LSR **supportedLSRs, int32_t supportedLSRsLength, + int32_t threshold, ULocMatchFavorSubtag favorSubtag) const { + BytesTrie iter(trie); + // Look up the desired language only once for all supported LSRs. + // Its "distance" is either a match point value of 0, or a non-match negative value. + // Note: The data builder verifies that there are no <*, supported> or rules. + int32_t desLangDistance = trieNext(iter, desired.language, false); + uint64_t desLangState = desLangDistance >= 0 && supportedLSRsLength > 1 ? iter.getState64() : 0; + // Index of the supported LSR with the lowest distance. + int32_t bestIndex = -1; + for (int32_t slIndex = 0; slIndex < supportedLSRsLength; ++slIndex) { + const LSR &supported = *supportedLSRs[slIndex]; + bool star = false; + int32_t distance = desLangDistance; + if (distance >= 0) { + U_ASSERT((distance & DISTANCE_IS_FINAL) == 0); + if (slIndex != 0) { + iter.resetToState64(desLangState); + } + distance = trieNext(iter, supported.language, true); + } + // Note: The data builder verifies that there are no rules with "any" (*) language and + // real (non *) script or region subtags. + // This means that if the lookup for either language fails we can use + // the default distances without further lookups. + int32_t flags; + if (distance >= 0) { + flags = distance & DISTANCE_IS_FINAL_OR_SKIP_SCRIPT; + distance &= ~DISTANCE_IS_FINAL_OR_SKIP_SCRIPT; + } else { // <*, *> + if (uprv_strcmp(desired.language, supported.language) == 0) { + distance = 0; + } else { + distance = defaultLanguageDistance; + } + flags = 0; + star = true; + } + U_ASSERT(0 <= distance && distance <= 100); + // We implement "favor subtag" by reducing the language subtag distance + // (unscientifically reducing it to a quarter of the normal value), + // so that the script distance is relatively more important. + // For example, given a default language distance of 80, we reduce it to 20, + // which is below the default threshold of 50, which is the default script distance. + if (favorSubtag == ULOCMATCH_FAVOR_SCRIPT) { + distance >>= 2; + } + if (distance >= threshold) { + continue; + } + + int32_t scriptDistance; + if (star || flags != 0) { + if (uprv_strcmp(desired.script, supported.script) == 0) { + scriptDistance = 0; + } else { + scriptDistance = defaultScriptDistance; + } + } else { + scriptDistance = getDesSuppScriptDistance(iter, iter.getState64(), + desired.script, supported.script); + flags = scriptDistance & DISTANCE_IS_FINAL; + scriptDistance &= ~DISTANCE_IS_FINAL; + } + distance += scriptDistance; + if (distance >= threshold) { + continue; + } + + if (uprv_strcmp(desired.region, supported.region) == 0) { + // regionDistance = 0 + } else if (star || (flags & DISTANCE_IS_FINAL) != 0) { + distance += defaultRegionDistance; + } else { + int32_t remainingThreshold = threshold - distance; + if (minRegionDistance >= remainingThreshold) { + continue; + } + + // From here on we know the regions are not equal. + // Map each region to zero or more partitions. (zero = one non-matching string) + // (Each array of single-character partition strings is encoded as one string.) + // If either side has more than one, then we find the maximum distance. + // This could be optimized by adding some more structure, but probably not worth it. + distance += getRegionPartitionsDistance( + iter, iter.getState64(), + partitionsForRegion(desired), + partitionsForRegion(supported), + remainingThreshold); + } + if (distance < threshold) { + if (distance == 0) { + return slIndex << 8; + } + bestIndex = slIndex; + threshold = distance; + } + } + return bestIndex >= 0 ? (bestIndex << 8) | threshold : 0xffffff00 | ABOVE_THRESHOLD; +} + +int32_t LocaleDistance::getDesSuppScriptDistance( + BytesTrie &iter, uint64_t startState, const char *desired, const char *supported) { + // Note: The data builder verifies that there are no <*, supported> or rules. + int32_t distance = trieNext(iter, desired, false); + if (distance >= 0) { + distance = trieNext(iter, supported, true); + } + if (distance < 0) { + UStringTrieResult result = iter.resetToState64(startState).next(u'*'); // <*, *> + U_ASSERT(USTRINGTRIE_HAS_VALUE(result)); + if (uprv_strcmp(desired, supported) == 0) { + distance = 0; // same script + } else { + distance = iter.getValue(); + U_ASSERT(distance >= 0); + } + if (result == USTRINGTRIE_FINAL_VALUE) { + distance |= DISTANCE_IS_FINAL; + } + } + return distance; +} + +int32_t LocaleDistance::getRegionPartitionsDistance( + BytesTrie &iter, uint64_t startState, + const char *desiredPartitions, const char *supportedPartitions, int32_t threshold) { + char desired = *desiredPartitions++; + char supported = *supportedPartitions++; + U_ASSERT(desired != 0 && supported != 0); + // See if we have single desired/supported partitions, from NUL-terminated + // partition strings without explicit length. + bool suppLengthGt1 = *supportedPartitions != 0; // gt1: more than 1 character + // equivalent to: if (desLength == 1 && suppLength == 1) + if (*desiredPartitions == 0 && !suppLengthGt1) { + // Fastpath for single desired/supported partitions. + UStringTrieResult result = iter.next(uprv_invCharToAscii(desired) | END_OF_SUBTAG); + if (USTRINGTRIE_HAS_NEXT(result)) { + result = iter.next(uprv_invCharToAscii(supported) | END_OF_SUBTAG); + if (USTRINGTRIE_HAS_VALUE(result)) { + return iter.getValue(); + } + } + return getFallbackRegionDistance(iter, startState); + } + + const char *supportedStart = supportedPartitions - 1; // for restart of inner loop + int32_t regionDistance = 0; + // Fall back to * only once, not for each pair of partition strings. + bool star = false; + for (;;) { + // Look up each desired-partition string only once, + // not for each (desired, supported) pair. + UStringTrieResult result = iter.next(uprv_invCharToAscii(desired) | END_OF_SUBTAG); + if (USTRINGTRIE_HAS_NEXT(result)) { + uint64_t desState = suppLengthGt1 ? iter.getState64() : 0; + for (;;) { + result = iter.next(uprv_invCharToAscii(supported) | END_OF_SUBTAG); + int32_t d; + if (USTRINGTRIE_HAS_VALUE(result)) { + d = iter.getValue(); + } else if (star) { + d = 0; + } else { + d = getFallbackRegionDistance(iter, startState); + star = true; + } + if (d >= threshold) { + return d; + } else if (regionDistance < d) { + regionDistance = d; + } + if ((supported = *supportedPartitions++) != 0) { + iter.resetToState64(desState); + } else { + break; + } + } + } else if (!star) { + int32_t d = getFallbackRegionDistance(iter, startState); + if (d >= threshold) { + return d; + } else if (regionDistance < d) { + regionDistance = d; + } + star = true; + } + if ((desired = *desiredPartitions++) != 0) { + iter.resetToState64(startState); + supportedPartitions = supportedStart; + supported = *supportedPartitions++; + } else { + break; + } + } + return regionDistance; +} + +int32_t LocaleDistance::getFallbackRegionDistance(BytesTrie &iter, uint64_t startState) { +#if U_DEBUG + UStringTrieResult result = +#endif + iter.resetToState64(startState).next(u'*'); // <*, *> + U_ASSERT(USTRINGTRIE_HAS_VALUE(result)); + int32_t distance = iter.getValue(); + U_ASSERT(distance >= 0); + return distance; +} + +int32_t LocaleDistance::trieNext(BytesTrie &iter, const char *s, bool wantValue) { + uint8_t c; + if ((c = *s) == 0) { + return -1; // no empty subtags in the distance data + } + for (;;) { + c = uprv_invCharToAscii(c); + // EBCDIC: If *s is not an invariant character, + // then c is now 0 and will simply not match anything, which is harmless. + uint8_t next = *++s; + if (next != 0) { + if (!USTRINGTRIE_HAS_NEXT(iter.next(c))) { + return -1; + } + } else { + // last character of this subtag + UStringTrieResult result = iter.next(c | END_OF_SUBTAG); + if (wantValue) { + if (USTRINGTRIE_HAS_VALUE(result)) { + int32_t value = iter.getValue(); + if (result == USTRINGTRIE_FINAL_VALUE) { + value |= DISTANCE_IS_FINAL; + } + return value; + } + } else { + if (USTRINGTRIE_HAS_NEXT(result)) { + return 0; + } + } + return -1; + } + c = next; + } +} + +UBool LocaleDistance::isParadigmLSR(const LSR &lsr) const { + // Linear search for a very short list (length 6 as of 2019). + // If there are many paradigm LSRs we should use a hash set. + U_ASSERT(paradigmLSRsLength <= 15); + for (int32_t i = 0; i < paradigmLSRsLength; ++i) { + if (lsr == paradigmLSRs[i]) { return true; } + } + return false; +} + +U_NAMESPACE_END diff --git a/deps/icu-small/source/common/locdistance.h b/deps/icu-small/source/common/locdistance.h new file mode 100644 index 00000000000000..7439f51c56bf8c --- /dev/null +++ b/deps/icu-small/source/common/locdistance.h @@ -0,0 +1,109 @@ +// © 2019 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html#License + +// locdistance.h +// created: 2019may08 Markus W. Scherer + +#ifndef __LOCDISTANCE_H__ +#define __LOCDISTANCE_H__ + +#include "unicode/utypes.h" +#include "unicode/bytestrie.h" +#include "unicode/localematcher.h" +#include "unicode/locid.h" +#include "unicode/uobject.h" +#include "lsr.h" + +U_NAMESPACE_BEGIN + +struct LocaleDistanceData; + +/** + * Offline-built data for LocaleMatcher. + * Mostly but not only the data for mapping locales to their maximized forms. + */ +class LocaleDistance final : public UMemory { +public: + static const LocaleDistance *getSingleton(UErrorCode &errorCode); + + /** + * Finds the supported LSR with the smallest distance from the desired one. + * Equivalent LSR subtags must be normalized into a canonical form. + * + *

Returns the index of the lowest-distance supported LSR in bits 31..8 + * (negative if none has a distance below the threshold), + * and its distance (0..ABOVE_THRESHOLD) in bits 7..0. + */ + int32_t getBestIndexAndDistance(const LSR &desired, + const LSR **supportedLSRs, int32_t supportedLSRsLength, + int32_t threshold, ULocMatchFavorSubtag favorSubtag) const; + + int32_t getParadigmLSRsLength() const { return paradigmLSRsLength; } + + UBool isParadigmLSR(const LSR &lsr) const; + + int32_t getDefaultScriptDistance() const { + return defaultScriptDistance; + } + + int32_t getDefaultDemotionPerDesiredLocale() const { + return defaultDemotionPerDesiredLocale; + } + +private: + LocaleDistance(const LocaleDistanceData &data); + LocaleDistance(const LocaleDistance &other) = delete; + LocaleDistance &operator=(const LocaleDistance &other) = delete; + + static void initLocaleDistance(UErrorCode &errorCode); + + static int32_t getDesSuppScriptDistance(BytesTrie &iter, uint64_t startState, + const char *desired, const char *supported); + + static int32_t getRegionPartitionsDistance( + BytesTrie &iter, uint64_t startState, + const char *desiredPartitions, const char *supportedPartitions, + int32_t threshold); + + static int32_t getFallbackRegionDistance(BytesTrie &iter, uint64_t startState); + + static int32_t trieNext(BytesTrie &iter, const char *s, bool wantValue); + + const char *partitionsForRegion(const LSR &lsr) const { + // ill-formed region -> one non-matching string + int32_t pIndex = regionToPartitionsIndex[lsr.regionIndex]; + return partitionArrays[pIndex]; + } + + int32_t getDefaultRegionDistance() const { + return defaultRegionDistance; + } + + // The trie maps each dlang+slang+dscript+sscript+dregion+sregion + // (encoded in ASCII with bit 7 set on the last character of each subtag) to a distance. + // There is also a trie value for each subsequence of whole subtags. + // One '*' is used for a (desired, supported) pair of "und", "Zzzz"/"", or "ZZ"/"". + BytesTrie trie; + + /** + * Maps each region to zero or more single-character partitions. + */ + const uint8_t *regionToPartitionsIndex; + const char **partitionArrays; + + /** + * Used to get the paradigm region for a cluster, if there is one. + */ + const LSR *paradigmLSRs; + int32_t paradigmLSRsLength; + + int32_t defaultLanguageDistance; + int32_t defaultScriptDistance; + int32_t defaultRegionDistance; + int32_t minRegionDistance; + int32_t defaultDemotionPerDesiredLocale; +}; + +U_NAMESPACE_END + +#endif // __LOCDISTANCE_H__ diff --git a/deps/icu-small/source/common/locdspnm.cpp b/deps/icu-small/source/common/locdspnm.cpp index da35be9e766e50..43334f51964622 100644 --- a/deps/icu-small/source/common/locdspnm.cpp +++ b/deps/icu-small/source/common/locdspnm.cpp @@ -291,6 +291,7 @@ class LocaleDisplayNamesImpl : public LocaleDisplayNames { UnicodeString formatCloseParen; UnicodeString formatReplaceCloseParen; UDisplayContext nameLength; + UDisplayContext substitute; // Constants for capitalization context usage types. enum CapContextUsage { @@ -337,7 +338,7 @@ class LocaleDisplayNamesImpl : public LocaleDisplayNames { UnicodeString& result) const; private: UnicodeString& localeIdName(const char* localeId, - UnicodeString& result) const; + UnicodeString& result, bool substitute) const; UnicodeString& appendWithSep(UnicodeString& buffer, const UnicodeString& src) const; UnicodeString& adjustForUsageAndContext(CapContextUsage usage, UnicodeString& result) const; UnicodeString& scriptDisplayName(const char* script, UnicodeString& result, UBool skipAdjust) const; @@ -359,6 +360,7 @@ LocaleDisplayNamesImpl::LocaleDisplayNamesImpl(const Locale& locale, , capitalizationContext(UDISPCTX_CAPITALIZATION_NONE) , capitalizationBrkIter(NULL) , nameLength(UDISPCTX_LENGTH_FULL) + , substitute(UDISPCTX_SUBSTITUTE) { initialize(); } @@ -371,6 +373,7 @@ LocaleDisplayNamesImpl::LocaleDisplayNamesImpl(const Locale& locale, , capitalizationContext(UDISPCTX_CAPITALIZATION_NONE) , capitalizationBrkIter(NULL) , nameLength(UDISPCTX_LENGTH_FULL) + , substitute(UDISPCTX_SUBSTITUTE) { while (length-- > 0) { UDisplayContext value = *contexts++; @@ -385,6 +388,9 @@ LocaleDisplayNamesImpl::LocaleDisplayNamesImpl(const Locale& locale, case UDISPCTX_TYPE_DISPLAY_LENGTH: nameLength = value; break; + case UDISPCTX_TYPE_SUBSTITUTE_HANDLING: + substitute = value; + break; default: break; } @@ -535,6 +541,8 @@ LocaleDisplayNamesImpl::getContext(UDisplayContextType type) const { return capitalizationContext; case UDISPCTX_TYPE_DISPLAY_LENGTH: return nameLength; + case UDISPCTX_TYPE_SUBSTITUTE_HANDLING: + return substitute; default: break; } @@ -549,7 +557,7 @@ LocaleDisplayNamesImpl::adjustForUsageAndContext(CapContextUsage usage, if ( result.length() > 0 && u_islower(result.char32At(0)) && capitalizationBrkIter!= NULL && ( capitalizationContext==UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE || fCapitalization[usage] ) ) { // note fCapitalization[usage] won't be set unless capitalizationContext is UI_LIST_OR_MENU or STANDALONE - static UMutex capitalizationBrkIterLock = U_MUTEX_INITIALIZER; + static UMutex capitalizationBrkIterLock; Mutex lock(&capitalizationBrkIterLock); result.toTitle(capitalizationBrkIter, locale, U_TITLECASE_NO_LOWERCASE | U_TITLECASE_NO_BREAK_ADJUSTMENT); } @@ -583,7 +591,7 @@ LocaleDisplayNamesImpl::localeDisplayName(const Locale& loc, do { // loop construct is so we can break early out of search if (hasScript && hasCountry) { ncat(buffer, ULOC_FULLNAME_CAPACITY, lang, "_", script, "_", country, (char *)0); - localeIdName(buffer, resultName); + localeIdName(buffer, resultName, false); if (!resultName.isBogus()) { hasScript = FALSE; hasCountry = FALSE; @@ -592,7 +600,7 @@ LocaleDisplayNamesImpl::localeDisplayName(const Locale& loc, } if (hasScript) { ncat(buffer, ULOC_FULLNAME_CAPACITY, lang, "_", script, (char *)0); - localeIdName(buffer, resultName); + localeIdName(buffer, resultName, false); if (!resultName.isBogus()) { hasScript = FALSE; break; @@ -600,7 +608,7 @@ LocaleDisplayNamesImpl::localeDisplayName(const Locale& loc, } if (hasCountry) { ncat(buffer, ULOC_FULLNAME_CAPACITY, lang, "_", country, (char*)0); - localeIdName(buffer, resultName); + localeIdName(buffer, resultName, false); if (!resultName.isBogus()) { hasCountry = FALSE; break; @@ -609,7 +617,11 @@ LocaleDisplayNamesImpl::localeDisplayName(const Locale& loc, } while (FALSE); } if (resultName.isBogus() || resultName.isEmpty()) { - localeIdName(lang, resultName); + localeIdName(lang, resultName, substitute == UDISPCTX_SUBSTITUTE); + if (resultName.isBogus()) { + result.setToBogus(); + return result; + } } UnicodeString resultRemainder; @@ -617,13 +629,28 @@ LocaleDisplayNamesImpl::localeDisplayName(const Locale& loc, UErrorCode status = U_ZERO_ERROR; if (hasScript) { - resultRemainder.append(scriptDisplayName(script, temp, TRUE)); + UnicodeString script_str = scriptDisplayName(script, temp, TRUE); + if (script_str.isBogus()) { + result.setToBogus(); + return result; + } + resultRemainder.append(script_str); } if (hasCountry) { - appendWithSep(resultRemainder, regionDisplayName(country, temp, TRUE)); + UnicodeString region_str = regionDisplayName(country, temp, TRUE); + if (region_str.isBogus()) { + result.setToBogus(); + return result; + } + appendWithSep(resultRemainder, region_str); } if (hasVariant) { - appendWithSep(resultRemainder, variantDisplayName(variant, temp, TRUE)); + UnicodeString variant_str = variantDisplayName(variant, temp, TRUE); + if (variant_str.isBogus()) { + result.setToBogus(); + return result; + } + appendWithSep(resultRemainder, variant_str); } resultRemainder.findAndReplace(formatOpenParen, formatReplaceOpenParen); resultRemainder.findAndReplace(formatCloseParen, formatReplaceCloseParen); @@ -689,14 +716,18 @@ LocaleDisplayNamesImpl::localeDisplayName(const char* localeId, // private UnicodeString& LocaleDisplayNamesImpl::localeIdName(const char* localeId, - UnicodeString& result) const { + UnicodeString& result, bool substitute) const { if (nameLength == UDISPCTX_LENGTH_SHORT) { langData.getNoFallback("Languages%short", localeId, result); if (!result.isBogus()) { return result; } } - return langData.getNoFallback("Languages", localeId, result); + if (substitute) { + return langData.get("Languages", localeId, result); + } else { + return langData.getNoFallback("Languages", localeId, result); + } } UnicodeString& @@ -706,12 +737,16 @@ LocaleDisplayNamesImpl::languageDisplayName(const char* lang, return result = UnicodeString(lang, -1, US_INV); } if (nameLength == UDISPCTX_LENGTH_SHORT) { - langData.get("Languages%short", lang, result); + langData.getNoFallback("Languages%short", lang, result); if (!result.isBogus()) { return adjustForUsageAndContext(kCapContextUsageLanguage, result); } } - langData.get("Languages", lang, result); + if (substitute == UDISPCTX_SUBSTITUTE) { + langData.get("Languages", lang, result); + } else { + langData.getNoFallback("Languages", lang, result); + } return adjustForUsageAndContext(kCapContextUsageLanguage, result); } @@ -720,12 +755,16 @@ LocaleDisplayNamesImpl::scriptDisplayName(const char* script, UnicodeString& result, UBool skipAdjust) const { if (nameLength == UDISPCTX_LENGTH_SHORT) { - langData.get("Scripts%short", script, result); + langData.getNoFallback("Scripts%short", script, result); if (!result.isBogus()) { return skipAdjust? result: adjustForUsageAndContext(kCapContextUsageScript, result); } } - langData.get("Scripts", script, result); + if (substitute == UDISPCTX_SUBSTITUTE) { + langData.get("Scripts", script, result); + } else { + langData.getNoFallback("Scripts", script, result); + } return skipAdjust? result: adjustForUsageAndContext(kCapContextUsageScript, result); } @@ -746,12 +785,16 @@ LocaleDisplayNamesImpl::regionDisplayName(const char* region, UnicodeString& result, UBool skipAdjust) const { if (nameLength == UDISPCTX_LENGTH_SHORT) { - regionData.get("Countries%short", region, result); + regionData.getNoFallback("Countries%short", region, result); if (!result.isBogus()) { return skipAdjust? result: adjustForUsageAndContext(kCapContextUsageTerritory, result); } } - regionData.get("Countries", region, result); + if (substitute == UDISPCTX_SUBSTITUTE) { + regionData.get("Countries", region, result); + } else { + regionData.getNoFallback("Countries", region, result); + } return skipAdjust? result: adjustForUsageAndContext(kCapContextUsageTerritory, result); } @@ -767,7 +810,11 @@ LocaleDisplayNamesImpl::variantDisplayName(const char* variant, UnicodeString& result, UBool skipAdjust) const { // don't have a resource for short variant names - langData.get("Variants", variant, result); + if (substitute == UDISPCTX_SUBSTITUTE) { + langData.get("Variants", variant, result); + } else { + langData.getNoFallback("Variants", variant, result); + } return skipAdjust? result: adjustForUsageAndContext(kCapContextUsageVariant, result); } @@ -782,7 +829,11 @@ LocaleDisplayNamesImpl::keyDisplayName(const char* key, UnicodeString& result, UBool skipAdjust) const { // don't have a resource for short key names - langData.get("Keys", key, result); + if (substitute == UDISPCTX_SUBSTITUTE) { + langData.get("Keys", key, result); + } else { + langData.getNoFallback("Keys", key, result); + } return skipAdjust? result: adjustForUsageAndContext(kCapContextUsageKey, result); } @@ -802,9 +853,8 @@ LocaleDisplayNamesImpl::keyValueDisplayName(const char* key, UErrorCode sts = U_ZERO_ERROR; UnicodeString ustrValue(value, -1, US_INV); int32_t len; - UBool isChoice = FALSE; const UChar *currencyName = ucurr_getName(ustrValue.getTerminatedBuffer(), - locale.getBaseName(), UCURR_LONG_NAME, &isChoice, &len, &sts); + locale.getBaseName(), UCURR_LONG_NAME, nullptr /* isChoiceFormat */, &len, &sts); if (U_FAILURE(sts)) { // Return the value as is on failure result = ustrValue; @@ -815,12 +865,16 @@ LocaleDisplayNamesImpl::keyValueDisplayName(const char* key, } if (nameLength == UDISPCTX_LENGTH_SHORT) { - langData.get("Types%short", key, value, result); + langData.getNoFallback("Types%short", key, value, result); if (!result.isBogus()) { return skipAdjust? result: adjustForUsageAndContext(kCapContextUsageKeyValue, result); } } - langData.get("Types", key, value, result); + if (substitute == UDISPCTX_SUBSTITUTE) { + langData.get("Types", key, value, result); + } else { + langData.getNoFallback("Types", key, value, result); + } return skipAdjust? result: adjustForUsageAndContext(kCapContextUsageKeyValue, result); } diff --git a/deps/icu-small/source/common/locid.cpp b/deps/icu-small/source/common/locid.cpp index 06986b636adc31..c6d3f88fc3be07 100644 --- a/deps/icu-small/source/common/locid.cpp +++ b/deps/icu-small/source/common/locid.cpp @@ -38,19 +38,19 @@ #include "unicode/strenum.h" #include "unicode/stringpiece.h" #include "unicode/uloc.h" -#include "putilimp.h" -#include "mutex.h" -#include "umutex.h" -#include "uassert.h" + +#include "bytesinkutil.h" +#include "charstr.h" #include "cmemory.h" #include "cstring.h" +#include "mutex.h" +#include "putilimp.h" #include "uassert.h" +#include "ucln_cmn.h" #include "uhash.h" #include "ulocimp.h" -#include "ucln_cmn.h" +#include "umutex.h" #include "ustr_imp.h" -#include "charstr.h" -#include "bytesinkutil.h" U_CDECL_BEGIN static UBool U_CALLCONV locale_cleanup(void); @@ -62,10 +62,7 @@ static Locale *gLocaleCache = NULL; static UInitOnce gLocaleCacheInitOnce = U_INITONCE_INITIALIZER; // gDefaultLocaleMutex protects all access to gDefaultLocalesHashT and gDefaultLocale. -static UMutex *gDefaultLocaleMutex() { - static UMutex m = U_MUTEX_INITIALIZER; - return &m; -} +static UMutex gDefaultLocaleMutex; static UHashtable *gDefaultLocalesHashT = NULL; static Locale *gDefaultLocale = NULL; @@ -174,7 +171,7 @@ U_NAMESPACE_BEGIN Locale *locale_set_default_internal(const char *id, UErrorCode& status) { // Synchronize this entire function. - Mutex lock(gDefaultLocaleMutex()); + Mutex lock(&gDefaultLocaleMutex); UBool canonicalize = FALSE; @@ -711,7 +708,7 @@ const Locale& U_EXPORT2 Locale::getDefault() { { - Mutex lock(gDefaultLocaleMutex()); + Mutex lock(&gDefaultLocaleMutex); if (gDefaultLocale != NULL) { return *gDefaultLocale; } @@ -1399,5 +1396,7 @@ Locale::getBaseName() const { return baseName; } +Locale::Iterator::~Iterator() = default; + //eof U_NAMESPACE_END diff --git a/deps/icu-small/source/common/loclikely.cpp b/deps/icu-small/source/common/loclikely.cpp index 50cc2a65de0b2d..3b71708e549d5f 100644 --- a/deps/icu-small/source/common/loclikely.cpp +++ b/deps/icu-small/source/common/loclikely.cpp @@ -807,24 +807,24 @@ createLikelySubtagsString( return FALSE; } -#define CHECK_TRAILING_VARIANT_SIZE(trailing, trailingLength) \ - { int32_t count = 0; \ - int32_t i; \ - for (i = 0; i < trailingLength; i++) { \ - if (trailing[i] == '-' || trailing[i] == '_') { \ - count = 0; \ - if (count > 8) { \ - goto error; \ - } \ - } else if (trailing[i] == '@') { \ - break; \ - } else if (count > 8) { \ +#define CHECK_TRAILING_VARIANT_SIZE(trailing, trailingLength) UPRV_BLOCK_MACRO_BEGIN { \ + int32_t count = 0; \ + int32_t i; \ + for (i = 0; i < trailingLength; i++) { \ + if (trailing[i] == '-' || trailing[i] == '_') { \ + count = 0; \ + if (count > 8) { \ goto error; \ - } else { \ - count++; \ } \ + } else if (trailing[i] == '@') { \ + break; \ + } else if (count > 8) { \ + goto error; \ + } else { \ + count++; \ } \ - } + } \ +} UPRV_BLOCK_MACRO_END static void _uloc_addLikelySubtags(const char* localeID, diff --git a/deps/icu-small/source/common/loclikelysubtags.cpp b/deps/icu-small/source/common/loclikelysubtags.cpp new file mode 100644 index 00000000000000..d7f5e124c2c790 --- /dev/null +++ b/deps/icu-small/source/common/loclikelysubtags.cpp @@ -0,0 +1,638 @@ +// © 2019 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html#License + +// loclikelysubtags.cpp +// created: 2019may08 Markus W. Scherer + +#include +#include "unicode/utypes.h" +#include "unicode/bytestrie.h" +#include "unicode/localpointer.h" +#include "unicode/locid.h" +#include "unicode/uobject.h" +#include "unicode/ures.h" +#include "charstr.h" +#include "cstring.h" +#include "loclikelysubtags.h" +#include "lsr.h" +#include "uassert.h" +#include "ucln_cmn.h" +#include "uhash.h" +#include "uinvchar.h" +#include "umutex.h" +#include "uresdata.h" +#include "uresimp.h" + +U_NAMESPACE_BEGIN + +namespace { + +constexpr char PSEUDO_ACCENTS_PREFIX = '\''; // -XA, -PSACCENT +constexpr char PSEUDO_BIDI_PREFIX = '+'; // -XB, -PSBIDI +constexpr char PSEUDO_CRACKED_PREFIX = ','; // -XC, -PSCRACK + +/** + * Stores NUL-terminated strings with duplicate elimination. + * Checks for unique UTF-16 string pointers and converts to invariant characters. + */ +class UniqueCharStrings { +public: + UniqueCharStrings(UErrorCode &errorCode) : strings(nullptr) { + uhash_init(&map, uhash_hashUChars, uhash_compareUChars, uhash_compareLong, &errorCode); + if (U_FAILURE(errorCode)) { return; } + strings = new CharString(); + if (strings == nullptr) { + errorCode = U_MEMORY_ALLOCATION_ERROR; + } + } + ~UniqueCharStrings() { + uhash_close(&map); + delete strings; + } + + /** Returns/orphans the CharString that contains all strings. */ + CharString *orphanCharStrings() { + CharString *result = strings; + strings = nullptr; + return result; + } + + /** Adds a string and returns a unique number for it. */ + int32_t add(const UnicodeString &s, UErrorCode &errorCode) { + if (U_FAILURE(errorCode)) { return 0; } + if (isFrozen) { + errorCode = U_NO_WRITE_PERMISSION; + return 0; + } + // The string points into the resource bundle. + const char16_t *p = s.getBuffer(); + int32_t oldIndex = uhash_geti(&map, p); + if (oldIndex != 0) { // found duplicate + return oldIndex; + } + // Explicit NUL terminator for the previous string. + // The strings object is also terminated with one implicit NUL. + strings->append(0, errorCode); + int32_t newIndex = strings->length(); + strings->appendInvariantChars(s, errorCode); + uhash_puti(&map, const_cast(p), newIndex, &errorCode); + return newIndex; + } + + void freeze() { isFrozen = true; } + + /** + * Returns a string pointer for its unique number, if this object is frozen. + * Otherwise nullptr. + */ + const char *get(int32_t i) const { + U_ASSERT(isFrozen); + return isFrozen && i > 0 ? strings->data() + i : nullptr; + } + +private: + UHashtable map; + CharString *strings; + bool isFrozen = false; +}; + +} // namespace + +LocaleDistanceData::LocaleDistanceData(LocaleDistanceData &&data) : + distanceTrieBytes(data.distanceTrieBytes), + regionToPartitions(data.regionToPartitions), + partitions(data.partitions), + paradigms(data.paradigms), paradigmsLength(data.paradigmsLength), + distances(data.distances) { + data.partitions = nullptr; + data.paradigms = nullptr; +} + +LocaleDistanceData::~LocaleDistanceData() { + uprv_free(partitions); + delete[] paradigms; +} + +// TODO(ICU-20777): Rename to just LikelySubtagsData. +struct XLikelySubtagsData { + UResourceBundle *langInfoBundle = nullptr; + UniqueCharStrings strings; + CharStringMap languageAliases; + CharStringMap regionAliases; + const uint8_t *trieBytes = nullptr; + LSR *lsrs = nullptr; + int32_t lsrsLength = 0; + + LocaleDistanceData distanceData; + + XLikelySubtagsData(UErrorCode &errorCode) : strings(errorCode) {} + + ~XLikelySubtagsData() { + ures_close(langInfoBundle); + delete[] lsrs; + } + + void load(UErrorCode &errorCode) { + langInfoBundle = ures_openDirect(nullptr, "langInfo", &errorCode); + if (U_FAILURE(errorCode)) { return; } + StackUResourceBundle stackTempBundle; + ResourceDataValue value; + ures_getValueWithFallback(langInfoBundle, "likely", stackTempBundle.getAlias(), + value, errorCode); + ResourceTable likelyTable = value.getTable(errorCode); + if (U_FAILURE(errorCode)) { return; } + + // Read all strings in the resource bundle and convert them to invariant char *. + LocalMemory languageIndexes, regionIndexes, lsrSubtagIndexes; + int32_t languagesLength = 0, regionsLength = 0, lsrSubtagsLength = 0; + if (!readStrings(likelyTable, "languageAliases", value, + languageIndexes, languagesLength, errorCode) || + !readStrings(likelyTable, "regionAliases", value, + regionIndexes, regionsLength, errorCode) || + !readStrings(likelyTable, "lsrs", value, + lsrSubtagIndexes,lsrSubtagsLength, errorCode)) { + return; + } + if ((languagesLength & 1) != 0 || + (regionsLength & 1) != 0 || + (lsrSubtagsLength % 3) != 0) { + errorCode = U_INVALID_FORMAT_ERROR; + return; + } + if (lsrSubtagsLength == 0) { + errorCode = U_MISSING_RESOURCE_ERROR; + return; + } + + if (!likelyTable.findValue("trie", value)) { + errorCode = U_MISSING_RESOURCE_ERROR; + return; + } + int32_t length; + trieBytes = value.getBinary(length, errorCode); + if (U_FAILURE(errorCode)) { return; } + + // Also read distance/matcher data if available, + // to open & keep only one resource bundle pointer + // and to use one single UniqueCharStrings. + UErrorCode matchErrorCode = U_ZERO_ERROR; + ures_getValueWithFallback(langInfoBundle, "match", stackTempBundle.getAlias(), + value, matchErrorCode); + LocalMemory partitionIndexes, paradigmSubtagIndexes; + int32_t partitionsLength = 0, paradigmSubtagsLength = 0; + if (U_SUCCESS(matchErrorCode)) { + ResourceTable matchTable = value.getTable(errorCode); + if (U_FAILURE(errorCode)) { return; } + + if (matchTable.findValue("trie", value)) { + distanceData.distanceTrieBytes = value.getBinary(length, errorCode); + if (U_FAILURE(errorCode)) { return; } + } + + if (matchTable.findValue("regionToPartitions", value)) { + distanceData.regionToPartitions = value.getBinary(length, errorCode); + if (U_FAILURE(errorCode)) { return; } + if (length < LSR::REGION_INDEX_LIMIT) { + errorCode = U_INVALID_FORMAT_ERROR; + return; + } + } + + if (!readStrings(matchTable, "partitions", value, + partitionIndexes, partitionsLength, errorCode) || + !readStrings(matchTable, "paradigms", value, + paradigmSubtagIndexes, paradigmSubtagsLength, errorCode)) { + return; + } + if ((paradigmSubtagsLength % 3) != 0) { + errorCode = U_INVALID_FORMAT_ERROR; + return; + } + + if (matchTable.findValue("distances", value)) { + distanceData.distances = value.getIntVector(length, errorCode); + if (U_FAILURE(errorCode)) { return; } + if (length < 4) { // LocaleDistance IX_LIMIT + errorCode = U_INVALID_FORMAT_ERROR; + return; + } + } + } else if (matchErrorCode == U_MISSING_RESOURCE_ERROR) { + // ok for likely subtags + } else { // error other than missing resource + errorCode = matchErrorCode; + return; + } + + // Fetch & store invariant-character versions of strings + // only after we have collected and de-duplicated all of them. + strings.freeze(); + + languageAliases = CharStringMap(languagesLength / 2, errorCode); + for (int32_t i = 0; i < languagesLength; i += 2) { + languageAliases.put(strings.get(languageIndexes[i]), + strings.get(languageIndexes[i + 1]), errorCode); + } + + regionAliases = CharStringMap(regionsLength / 2, errorCode); + for (int32_t i = 0; i < regionsLength; i += 2) { + regionAliases.put(strings.get(regionIndexes[i]), + strings.get(regionIndexes[i + 1]), errorCode); + } + if (U_FAILURE(errorCode)) { return; } + + lsrsLength = lsrSubtagsLength / 3; + lsrs = new LSR[lsrsLength]; + if (lsrs == nullptr) { + errorCode = U_MEMORY_ALLOCATION_ERROR; + return; + } + for (int32_t i = 0, j = 0; i < lsrSubtagsLength; i += 3, ++j) { + lsrs[j] = LSR(strings.get(lsrSubtagIndexes[i]), + strings.get(lsrSubtagIndexes[i + 1]), + strings.get(lsrSubtagIndexes[i + 2])); + } + + if (partitionsLength > 0) { + distanceData.partitions = static_cast( + uprv_malloc(partitionsLength * sizeof(const char *))); + if (distanceData.partitions == nullptr) { + errorCode = U_MEMORY_ALLOCATION_ERROR; + return; + } + for (int32_t i = 0; i < partitionsLength; ++i) { + distanceData.partitions[i] = strings.get(partitionIndexes[i]); + } + } + + if (paradigmSubtagsLength > 0) { + distanceData.paradigmsLength = paradigmSubtagsLength / 3; + LSR *paradigms = new LSR[distanceData.paradigmsLength]; + if (paradigms == nullptr) { + errorCode = U_MEMORY_ALLOCATION_ERROR; + return; + } + for (int32_t i = 0, j = 0; i < paradigmSubtagsLength; i += 3, ++j) { + paradigms[j] = LSR(strings.get(paradigmSubtagIndexes[i]), + strings.get(paradigmSubtagIndexes[i + 1]), + strings.get(paradigmSubtagIndexes[i + 2])); + } + distanceData.paradigms = paradigms; + } + } + +private: + bool readStrings(const ResourceTable &table, const char *key, ResourceValue &value, + LocalMemory &indexes, int32_t &length, UErrorCode &errorCode) { + if (table.findValue(key, value)) { + ResourceArray stringArray = value.getArray(errorCode); + if (U_FAILURE(errorCode)) { return false; } + length = stringArray.getSize(); + if (length == 0) { return true; } + int32_t *rawIndexes = indexes.allocateInsteadAndCopy(length); + if (rawIndexes == nullptr) { + errorCode = U_MEMORY_ALLOCATION_ERROR; + return false; + } + for (int i = 0; i < length; ++i) { + stringArray.getValue(i, value); // returns TRUE because i < length + rawIndexes[i] = strings.add(value.getUnicodeString(errorCode), errorCode); + if (U_FAILURE(errorCode)) { return false; } + } + } + return true; + } +}; + +namespace { + +XLikelySubtags *gLikelySubtags = nullptr; +UInitOnce gInitOnce = U_INITONCE_INITIALIZER; + +UBool U_CALLCONV cleanup() { + delete gLikelySubtags; + gLikelySubtags = nullptr; + gInitOnce.reset(); + return TRUE; +} + +} // namespace + +void U_CALLCONV XLikelySubtags::initLikelySubtags(UErrorCode &errorCode) { + // This function is invoked only via umtx_initOnce(). + U_ASSERT(gLikelySubtags == nullptr); + XLikelySubtagsData data(errorCode); + data.load(errorCode); + if (U_FAILURE(errorCode)) { return; } + gLikelySubtags = new XLikelySubtags(data); + if (gLikelySubtags == nullptr) { + errorCode = U_MEMORY_ALLOCATION_ERROR; + return; + } + ucln_common_registerCleanup(UCLN_COMMON_LIKELY_SUBTAGS, cleanup); +} + +const XLikelySubtags *XLikelySubtags::getSingleton(UErrorCode &errorCode) { + if (U_FAILURE(errorCode)) { return nullptr; } + umtx_initOnce(gInitOnce, &XLikelySubtags::initLikelySubtags, errorCode); + return gLikelySubtags; +} + +XLikelySubtags::XLikelySubtags(XLikelySubtagsData &data) : + langInfoBundle(data.langInfoBundle), + strings(data.strings.orphanCharStrings()), + languageAliases(std::move(data.languageAliases)), + regionAliases(std::move(data.regionAliases)), + trie(data.trieBytes), + lsrs(data.lsrs), +#if U_DEBUG + lsrsLength(data.lsrsLength), +#endif + distanceData(std::move(data.distanceData)) { + data.langInfoBundle = nullptr; + data.lsrs = nullptr; + + // Cache the result of looking up language="und" encoded as "*", and "und-Zzzz" ("**"). + UStringTrieResult result = trie.next(u'*'); + U_ASSERT(USTRINGTRIE_HAS_NEXT(result)); + trieUndState = trie.getState64(); + result = trie.next(u'*'); + U_ASSERT(USTRINGTRIE_HAS_NEXT(result)); + trieUndZzzzState = trie.getState64(); + result = trie.next(u'*'); + U_ASSERT(USTRINGTRIE_HAS_VALUE(result)); + defaultLsrIndex = trie.getValue(); + trie.reset(); + + for (char16_t c = u'a'; c <= u'z'; ++c) { + result = trie.next(c); + if (result == USTRINGTRIE_NO_VALUE) { + trieFirstLetterStates[c - u'a'] = trie.getState64(); + } + trie.reset(); + } +} + +XLikelySubtags::~XLikelySubtags() { + ures_close(langInfoBundle); + delete strings; + delete[] lsrs; +} + +LSR XLikelySubtags::makeMaximizedLsrFrom(const Locale &locale, UErrorCode &errorCode) const { + const char *name = locale.getName(); + if (uprv_isAtSign(name[0]) && name[1] == 'x' && name[2] == '=') { // name.startsWith("@x=") + // Private use language tag x-subtag-subtag... + return LSR(name, "", ""); + } + return makeMaximizedLsr(locale.getLanguage(), locale.getScript(), locale.getCountry(), + locale.getVariant(), errorCode); +} + +namespace { + +const char *getCanonical(const CharStringMap &aliases, const char *alias) { + const char *canonical = aliases.get(alias); + return canonical == nullptr ? alias : canonical; +} + +} // namespace + +LSR XLikelySubtags::makeMaximizedLsr(const char *language, const char *script, const char *region, + const char *variant, UErrorCode &errorCode) const { + // Handle pseudolocales like en-XA, ar-XB, fr-PSCRACK. + // They should match only themselves, + // not other locales with what looks like the same language and script subtags. + char c1; + if (region[0] == 'X' && (c1 = region[1]) != 0 && region[2] == 0) { + switch (c1) { + case 'A': + return LSR(PSEUDO_ACCENTS_PREFIX, language, script, region, errorCode); + case 'B': + return LSR(PSEUDO_BIDI_PREFIX, language, script, region, errorCode); + case 'C': + return LSR(PSEUDO_CRACKED_PREFIX, language, script, region, errorCode); + default: // normal locale + break; + } + } + + if (variant[0] == 'P' && variant[1] == 'S') { + if (uprv_strcmp(variant, "PSACCENT") == 0) { + return LSR(PSEUDO_ACCENTS_PREFIX, language, script, + *region == 0 ? "XA" : region, errorCode); + } else if (uprv_strcmp(variant, "PSBIDI") == 0) { + return LSR(PSEUDO_BIDI_PREFIX, language, script, + *region == 0 ? "XB" : region, errorCode); + } else if (uprv_strcmp(variant, "PSCRACK") == 0) { + return LSR(PSEUDO_CRACKED_PREFIX, language, script, + *region == 0 ? "XC" : region, errorCode); + } + // else normal locale + } + + language = getCanonical(languageAliases, language); + // (We have no script mappings.) + region = getCanonical(regionAliases, region); + return maximize(language, script, region); +} + +LSR XLikelySubtags::maximize(const char *language, const char *script, const char *region) const { + if (uprv_strcmp(language, "und") == 0) { + language = ""; + } + if (uprv_strcmp(script, "Zzzz") == 0) { + script = ""; + } + if (uprv_strcmp(region, "ZZ") == 0) { + region = ""; + } + if (*script != 0 && *region != 0 && *language != 0) { + return LSR(language, script, region); // already maximized + } + + uint32_t retainOldMask = 0; + BytesTrie iter(trie); + uint64_t state; + int32_t value; + // Small optimization: Array lookup for first language letter. + int32_t c0; + if (0 <= (c0 = uprv_lowerOrdinal(language[0])) && c0 <= 25 && + language[1] != 0 && // language.length() >= 2 + (state = trieFirstLetterStates[c0]) != 0) { + value = trieNext(iter.resetToState64(state), language, 1); + } else { + value = trieNext(iter, language, 0); + } + if (value >= 0) { + if (*language != 0) { + retainOldMask |= 4; + } + state = iter.getState64(); + } else { + retainOldMask |= 4; + iter.resetToState64(trieUndState); // "und" ("*") + state = 0; + } + + if (value > 0) { + // Intermediate or final value from just language. + if (value == SKIP_SCRIPT) { + value = 0; + } + if (*script != 0) { + retainOldMask |= 2; + } + } else { + value = trieNext(iter, script, 0); + if (value >= 0) { + if (*script != 0) { + retainOldMask |= 2; + } + state = iter.getState64(); + } else { + retainOldMask |= 2; + if (state == 0) { + iter.resetToState64(trieUndZzzzState); // "und-Zzzz" ("**") + } else { + iter.resetToState64(state); + value = trieNext(iter, "", 0); + U_ASSERT(value >= 0); + state = iter.getState64(); + } + } + } + + if (value > 0) { + // Final value from just language or language+script. + if (*region != 0) { + retainOldMask |= 1; + } + } else { + value = trieNext(iter, region, 0); + if (value >= 0) { + if (*region != 0) { + retainOldMask |= 1; + } + } else { + retainOldMask |= 1; + if (state == 0) { + value = defaultLsrIndex; + } else { + iter.resetToState64(state); + value = trieNext(iter, "", 0); + U_ASSERT(value > 0); + } + } + } + U_ASSERT(value < lsrsLength); + const LSR &result = lsrs[value]; + + if (*language == 0) { + language = "und"; + } + + if (retainOldMask == 0) { + // Quickly return a copy of the lookup-result LSR + // without new allocation of the subtags. + return LSR(result.language, result.script, result.region); + } + if ((retainOldMask & 4) == 0) { + language = result.language; + } + if ((retainOldMask & 2) == 0) { + script = result.script; + } + if ((retainOldMask & 1) == 0) { + region = result.region; + } + return LSR(language, script, region); +} + +int32_t XLikelySubtags::trieNext(BytesTrie &iter, const char *s, int32_t i) { + UStringTrieResult result; + uint8_t c; + if ((c = s[i]) == 0) { + result = iter.next(u'*'); + } else { + for (;;) { + c = uprv_invCharToAscii(c); + // EBCDIC: If s[i] is not an invariant character, + // then c is now 0 and will simply not match anything, which is harmless. + uint8_t next = s[++i]; + if (next != 0) { + if (!USTRINGTRIE_HAS_NEXT(iter.next(c))) { + return -1; + } + } else { + // last character of this subtag + result = iter.next(c | 0x80); + break; + } + c = next; + } + } + switch (result) { + case USTRINGTRIE_NO_MATCH: return -1; + case USTRINGTRIE_NO_VALUE: return 0; + case USTRINGTRIE_INTERMEDIATE_VALUE: + U_ASSERT(iter.getValue() == SKIP_SCRIPT); + return SKIP_SCRIPT; + case USTRINGTRIE_FINAL_VALUE: return iter.getValue(); + default: return -1; + } +} + +// TODO(ICU-20777): Switch Locale/uloc_ likely-subtags API from the old code +// in loclikely.cpp to this new code, including activating this +// minimizeSubtags() function. The LocaleMatcher does not minimize. +#if 0 +LSR XLikelySubtags::minimizeSubtags(const char *languageIn, const char *scriptIn, + const char *regionIn, ULocale.Minimize fieldToFavor, + UErrorCode &errorCode) const { + LSR result = maximize(languageIn, scriptIn, regionIn); + + // We could try just a series of checks, like: + // LSR result2 = addLikelySubtags(languageIn, "", ""); + // if result.equals(result2) return result2; + // However, we can optimize 2 of the cases: + // (languageIn, "", "") + // (languageIn, "", regionIn) + + // value00 = lookup(result.language, "", "") + BytesTrie iter = new BytesTrie(trie); + int value = trieNext(iter, result.language, 0); + U_ASSERT(value >= 0); + if (value == 0) { + value = trieNext(iter, "", 0); + U_ASSERT(value >= 0); + if (value == 0) { + value = trieNext(iter, "", 0); + } + } + U_ASSERT(value > 0); + LSR value00 = lsrs[value]; + boolean favorRegionOk = false; + if (result.script.equals(value00.script)) { //script is default + if (result.region.equals(value00.region)) { + return new LSR(result.language, "", ""); + } else if (fieldToFavor == ULocale.Minimize.FAVOR_REGION) { + return new LSR(result.language, "", result.region); + } else { + favorRegionOk = true; + } + } + + // The last case is not as easy to optimize. + // Maybe do later, but for now use the straightforward code. + LSR result2 = maximize(languageIn, scriptIn, ""); + if (result2.equals(result)) { + return new LSR(result.language, result.script, ""); + } else if (favorRegionOk) { + return new LSR(result.language, "", result.region); + } + return result; +} +#endif + +U_NAMESPACE_END diff --git a/deps/icu-small/source/common/loclikelysubtags.h b/deps/icu-small/source/common/loclikelysubtags.h new file mode 100644 index 00000000000000..8c8a08ac5e314e --- /dev/null +++ b/deps/icu-small/source/common/loclikelysubtags.h @@ -0,0 +1,143 @@ +// © 2019 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html#License + +// loclikelysubtags.h +// created: 2019may08 Markus W. Scherer + +#ifndef __LOCLIKELYSUBTAGS_H__ +#define __LOCLIKELYSUBTAGS_H__ + +#include +#include "unicode/utypes.h" +#include "unicode/bytestrie.h" +#include "unicode/locid.h" +#include "unicode/uobject.h" +#include "unicode/ures.h" +#include "lsr.h" +#include "uhash.h" + +U_NAMESPACE_BEGIN + +struct XLikelySubtagsData; + +/** + * Map of const char * keys & values. + * Stores pointers as is: Does not own/copy/adopt/release strings. + */ +class CharStringMap final : public UMemory { +public: + /** Constructs an unusable non-map. */ + CharStringMap() : map(nullptr) {} + CharStringMap(int32_t size, UErrorCode &errorCode) { + map = uhash_openSize(uhash_hashChars, uhash_compareChars, uhash_compareChars, + size, &errorCode); + } + CharStringMap(CharStringMap &&other) U_NOEXCEPT : map(other.map) { + other.map = nullptr; + } + CharStringMap(const CharStringMap &other) = delete; + ~CharStringMap() { + uhash_close(map); + } + + CharStringMap &operator=(CharStringMap &&other) U_NOEXCEPT { + map = other.map; + other.map = nullptr; + return *this; + } + CharStringMap &operator=(const CharStringMap &other) = delete; + + const char *get(const char *key) const { return static_cast(uhash_get(map, key)); } + void put(const char *key, const char *value, UErrorCode &errorCode) { + uhash_put(map, const_cast(key), const_cast(value), &errorCode); + } + +private: + UHashtable *map; +}; + +struct LocaleDistanceData { + LocaleDistanceData() = default; + LocaleDistanceData(LocaleDistanceData &&data); + ~LocaleDistanceData(); + + const uint8_t *distanceTrieBytes = nullptr; + const uint8_t *regionToPartitions = nullptr; + const char **partitions = nullptr; + const LSR *paradigms = nullptr; + int32_t paradigmsLength = 0; + const int32_t *distances = nullptr; + +private: + LocaleDistanceData &operator=(const LocaleDistanceData &) = delete; +}; + +// TODO(ICU-20777): Rename to just LikelySubtags. +class XLikelySubtags final : public UMemory { +public: + ~XLikelySubtags(); + + static constexpr int32_t SKIP_SCRIPT = 1; + + // VisibleForTesting + static const XLikelySubtags *getSingleton(UErrorCode &errorCode); + + // VisibleForTesting + LSR makeMaximizedLsrFrom(const Locale &locale, UErrorCode &errorCode) const; + + // TODO(ICU-20777): Switch Locale/uloc_ likely-subtags API from the old code + // in loclikely.cpp to this new code, including activating this + // minimizeSubtags() function. The LocaleMatcher does not minimize. +#if 0 + LSR minimizeSubtags(const char *languageIn, const char *scriptIn, const char *regionIn, + ULocale.Minimize fieldToFavor, UErrorCode &errorCode) const; +#endif + + // visible for LocaleDistance + const LocaleDistanceData &getDistanceData() const { return distanceData; } + +private: + XLikelySubtags(XLikelySubtagsData &data); + XLikelySubtags(const XLikelySubtags &other) = delete; + XLikelySubtags &operator=(const XLikelySubtags &other) = delete; + + static void initLikelySubtags(UErrorCode &errorCode); + + LSR makeMaximizedLsr(const char *language, const char *script, const char *region, + const char *variant, UErrorCode &errorCode) const; + + /** + * Raw access to addLikelySubtags. Input must be in canonical format, eg "en", not "eng" or "EN". + */ + LSR maximize(const char *language, const char *script, const char *region) const; + + static int32_t trieNext(BytesTrie &iter, const char *s, int32_t i); + + UResourceBundle *langInfoBundle; + // We could store the strings by value, except that if there were few enough strings, + // moving the contents could copy it to a different array, + // invalidating the pointers stored in the maps. + CharString *strings; + CharStringMap languageAliases; + CharStringMap regionAliases; + + // The trie maps each lang+script+region (encoded in ASCII) to an index into lsrs. + // There is also a trie value for each intermediate lang and lang+script. + // '*' is used instead of "und", "Zzzz"/"" and "ZZ"/"". + BytesTrie trie; + uint64_t trieUndState; + uint64_t trieUndZzzzState; + int32_t defaultLsrIndex; + uint64_t trieFirstLetterStates[26]; + const LSR *lsrs; +#if U_DEBUG + int32_t lsrsLength; +#endif + + // distance/matcher data: see comment in XLikelySubtagsData::load() + LocaleDistanceData distanceData; +}; + +U_NAMESPACE_END + +#endif // __LOCLIKELYSUBTAGS_H__ diff --git a/deps/icu-small/source/common/lsr.cpp b/deps/icu-small/source/common/lsr.cpp new file mode 100644 index 00000000000000..0c28eeda1bc7b6 --- /dev/null +++ b/deps/icu-small/source/common/lsr.cpp @@ -0,0 +1,101 @@ +// © 2019 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html#License + +// lsr.cpp +// created: 2019may08 Markus W. Scherer + +#include "unicode/utypes.h" +#include "charstr.h" +#include "cmemory.h" +#include "cstring.h" +#include "lsr.h" +#include "uinvchar.h" +#include "ustr_imp.h" + +U_NAMESPACE_BEGIN + +LSR::LSR(char prefix, const char *lang, const char *scr, const char *r, UErrorCode &errorCode) : + language(nullptr), script(nullptr), region(r), + regionIndex(indexForRegion(region)) { + if (U_SUCCESS(errorCode)) { + CharString langScript; + langScript.append(prefix, errorCode).append(lang, errorCode).append('\0', errorCode); + int32_t scriptOffset = langScript.length(); + langScript.append(prefix, errorCode).append(scr, errorCode); + owned = langScript.cloneData(errorCode); + if (U_SUCCESS(errorCode)) { + language = owned; + script = owned + scriptOffset; + } + } +} + +LSR::LSR(LSR &&other) U_NOEXCEPT : + language(other.language), script(other.script), region(other.region), owned(other.owned), + regionIndex(other.regionIndex), hashCode(other.hashCode) { + if (owned != nullptr) { + other.language = other.script = ""; + other.owned = nullptr; + other.hashCode = 0; + } +} + +void LSR::deleteOwned() { + uprv_free(owned); +} + +LSR &LSR::operator=(LSR &&other) U_NOEXCEPT { + this->~LSR(); + language = other.language; + script = other.script; + region = other.region; + regionIndex = other.regionIndex; + owned = other.owned; + hashCode = other.hashCode; + if (owned != nullptr) { + other.language = other.script = ""; + other.owned = nullptr; + other.hashCode = 0; + } + return *this; +} + +UBool LSR::operator==(const LSR &other) const { + return + uprv_strcmp(language, other.language) == 0 && + uprv_strcmp(script, other.script) == 0 && + regionIndex == other.regionIndex && + // Compare regions if both are ill-formed (and their indexes are 0). + (regionIndex > 0 || uprv_strcmp(region, other.region) == 0); +} + +int32_t LSR::indexForRegion(const char *region) { + int32_t c = region[0]; + int32_t a = c - '0'; + if (0 <= a && a <= 9) { // digits: "419" + int32_t b = region[1] - '0'; + if (b < 0 || 9 < b) { return 0; } + c = region[2] - '0'; + if (c < 0 || 9 < c || region[3] != 0) { return 0; } + return (10 * a + b) * 10 + c + 1; + } else { // letters: "DE" + a = uprv_upperOrdinal(c); + if (a < 0 || 25 < a) { return 0; } + int32_t b = uprv_upperOrdinal(region[1]); + if (b < 0 || 25 < b || region[2] != 0) { return 0; } + return 26 * a + b + 1001; + } + return 0; +} + +LSR &LSR::setHashCode() { + if (hashCode == 0) { + hashCode = + (ustr_hashCharsN(language, static_cast(uprv_strlen(language))) * 37 + + ustr_hashCharsN(script, static_cast(uprv_strlen(script)))) * 37 + + regionIndex; + } + return *this; +} + +U_NAMESPACE_END diff --git a/deps/icu-small/source/common/lsr.h b/deps/icu-small/source/common/lsr.h new file mode 100644 index 00000000000000..db6cf938f47d02 --- /dev/null +++ b/deps/icu-small/source/common/lsr.h @@ -0,0 +1,72 @@ +// © 2019 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html#License + +// lsr.h +// created: 2019may08 Markus W. Scherer + +#ifndef __LSR_H__ +#define __LSR_H__ + +#include "unicode/utypes.h" +#include "unicode/uobject.h" +#include "cstring.h" + +U_NAMESPACE_BEGIN + +struct LSR final : public UMemory { + static constexpr int32_t REGION_INDEX_LIMIT = 1001 + 26 * 26; + + const char *language; + const char *script; + const char *region; + char *owned = nullptr; + /** Index for region, 0 if ill-formed. @see indexForRegion */ + int32_t regionIndex = 0; + /** Only set for LSRs that will be used in a hash table. */ + int32_t hashCode = 0; + + LSR() : language("und"), script(""), region("") {} + + /** Constructor which aliases all subtag pointers. */ + LSR(const char *lang, const char *scr, const char *r) : + language(lang), script(scr), region(r), + regionIndex(indexForRegion(region)) {} + /** + * Constructor which prepends the prefix to the language and script, + * copies those into owned memory, and aliases the region. + */ + LSR(char prefix, const char *lang, const char *scr, const char *r, UErrorCode &errorCode); + LSR(LSR &&other) U_NOEXCEPT; + LSR(const LSR &other) = delete; + inline ~LSR() { + // Pure inline code for almost all instances. + if (owned != nullptr) { + deleteOwned(); + } + } + + LSR &operator=(LSR &&other) U_NOEXCEPT; + LSR &operator=(const LSR &other) = delete; + + /** + * Returns a positive index (>0) for a well-formed region code. + * Do not rely on a particular region->index mapping; it may change. + * Returns 0 for ill-formed strings. + */ + static int32_t indexForRegion(const char *region); + + UBool operator==(const LSR &other) const; + + inline UBool operator!=(const LSR &other) const { + return !operator==(other); + } + + LSR &setHashCode(); + +private: + void deleteOwned(); +}; + +U_NAMESPACE_END + +#endif // __LSR_H__ diff --git a/deps/icu-small/source/common/mutex.h b/deps/icu-small/source/common/mutex.h index 5223397bbcc10a..44b1f90ba04dd2 100644 --- a/deps/icu-small/source/common/mutex.h +++ b/deps/icu-small/source/common/mutex.h @@ -28,50 +28,48 @@ U_NAMESPACE_BEGIN -//---------------------------------------------------------------------------- -// Code within that accesses shared static or global data should -// should instantiate a Mutex object while doing so. You should make your own -// private mutex where possible. - -// For example: -// -// UMutex myMutex = U_MUTEX_INITIALIZER; -// -// void Function(int arg1, int arg2) -// { -// static Object* foo; // Shared read-write object -// Mutex mutex(&myMutex); // or no args for the global lock -// foo->Method(); -// // When 'mutex' goes out of scope and gets destroyed here, the lock is released -// } -// -// Note: Do NOT use the form 'Mutex mutex();' as that merely forward-declares a function -// returning a Mutex. This is a common mistake which silently slips through the -// compiler!! -// +/** + * Mutex is a helper class for convenient locking and unlocking of a UMutex. + * + * Creating a local scope Mutex will lock a UMutex, holding the lock until the Mutex + * goes out of scope. + * + * If no UMutex is specified, the ICU global mutex is implied. + * + * For example: + * + * static UMutex myMutex; + * + * void Function(int arg1, int arg2) + * { + * static Object* foo; // Shared read-write object + * Mutex mutex(&myMutex); // or no args for the global lock + * foo->Method(); + * // When 'mutex' goes out of scope and gets destroyed here, the lock is released + * } + * + * Note: Do NOT use the form 'Mutex mutex();' as that merely forward-declares a function + * returning a Mutex. This is a common mistake which silently slips through the + * compiler!! + */ class U_COMMON_API Mutex : public UMemory { public: - inline Mutex(UMutex *mutex = NULL); - inline ~Mutex(); + Mutex(UMutex *mutex = nullptr) : fMutex(mutex) { + umtx_lock(fMutex); + } + ~Mutex() { + umtx_unlock(fMutex); + } -private: - UMutex *fMutex; + Mutex(const Mutex &other) = delete; // forbid assigning of this class + Mutex &operator=(const Mutex &other) = delete; // forbid copying of this class + void *operator new(size_t s) = delete; // forbid heap allocation. Locals only. - Mutex(const Mutex &other); // forbid copying of this class - Mutex &operator=(const Mutex &other); // forbid copying of this class +private: + UMutex *fMutex; }; -inline Mutex::Mutex(UMutex *mutex) - : fMutex(mutex) -{ - umtx_lock(fMutex); -} - -inline Mutex::~Mutex() -{ - umtx_unlock(fMutex); -} U_NAMESPACE_END diff --git a/deps/icu-small/source/common/normalizer2impl.h b/deps/icu-small/source/common/normalizer2impl.h index 7ecdef6d9c8032..cf3015ea881bfc 100644 --- a/deps/icu-small/source/common/normalizer2impl.h +++ b/deps/icu-small/source/common/normalizer2impl.h @@ -245,9 +245,7 @@ class U_COMMON_API ReorderingBuffer : public UMemory { */ class U_COMMON_API Normalizer2Impl : public UObject { public: - Normalizer2Impl() : normTrie(NULL), fCanonIterData(NULL) { - fCanonIterDataInitOnce.reset(); - } + Normalizer2Impl() : normTrie(NULL), fCanonIterData(NULL) { } virtual ~Normalizer2Impl(); void init(const int32_t *inIndexes, const UCPTrie *inTrie, @@ -723,7 +721,7 @@ class U_COMMON_API Normalizer2Impl : public UObject { const uint16_t *extraData; // mappings and/or compositions for yesYes, yesNo & noNo characters const uint8_t *smallFCD; // [0x100] one bit per 32 BMP code points, set if any FCD!=0 - UInitOnce fCanonIterDataInitOnce; + UInitOnce fCanonIterDataInitOnce = U_INITONCE_INITIALIZER; CanonIterData *fCanonIterData; }; diff --git a/deps/icu-small/source/common/putil.cpp b/deps/icu-small/source/common/putil.cpp index e105befc3fc740..207350f8f26120 100644 --- a/deps/icu-small/source/common/putil.cpp +++ b/deps/icu-small/source/common/putil.cpp @@ -249,7 +249,7 @@ static UDate getUTCtime_real() { } static UDate getUTCtime_fake() { - static UMutex fakeClockMutex = U_MUTEX_INTIALIZER; + static UMutex fakeClockMutex; umtx_lock(&fakeClockMutex); if(!fakeClock_set) { UDate real = getUTCtime_real(); @@ -1315,11 +1315,10 @@ uprv_pathIsAbsolute(const char *path) # endif #endif -#if U_PLATFORM_HAS_WINUWP_API != 0 +#if defined(ICU_DATA_DIR_WINDOWS) // Helper function to get the ICU Data Directory under the Windows directory location. static BOOL U_CALLCONV getIcuDataDirectoryUnderWindowsDirectory(char* directoryBuffer, UINT bufferLength) { -#if defined(ICU_DATA_DIR_WINDOWS) wchar_t windowsPath[MAX_PATH]; char windowsPathUtf8[MAX_PATH]; @@ -1346,7 +1345,6 @@ static BOOL U_CALLCONV getIcuDataDirectoryUnderWindowsDirectory(char* directoryB } } } -#endif return FALSE; } @@ -1380,9 +1378,9 @@ static void U_CALLCONV dataDirectoryInitFn() { */ # if !defined(ICU_NO_USER_DATA_OVERRIDE) && !UCONFIG_NO_FILE_IO /* First try to get the environment variable */ -# if U_PLATFORM_HAS_WINUWP_API == 0 // Windows UWP does not support getenv +# if U_PLATFORM_HAS_WINUWP_API == 0 // Windows UWP does not support getenv path=getenv("ICU_DATA"); -# endif +# endif # endif /* ICU_DATA_DIR may be set as a compile option. @@ -1411,7 +1409,7 @@ static void U_CALLCONV dataDirectoryInitFn() { } #endif -#if U_PLATFORM_HAS_WINUWP_API != 0 && defined(ICU_DATA_DIR_WINDOWS) +#if defined(ICU_DATA_DIR_WINDOWS) char datadir_path_buffer[MAX_PATH]; if (getIcuDataDirectoryUnderWindowsDirectory(datadir_path_buffer, UPRV_LENGTHOF(datadir_path_buffer))) { path = datadir_path_buffer; @@ -1461,12 +1459,17 @@ static void U_CALLCONV TimeZoneDataDirInitFn(UErrorCode &status) { const char *dir = ""; -#if U_PLATFORM_HAS_WINUWP_API != 0 - // The UWP version does not support the environment variable setting, but can possibly pick them up from the Windows directory. +#if U_PLATFORM_HAS_WINUWP_API == 1 +// The UWP version does not support the environment variable setting. + +# if defined(ICU_DATA_DIR_WINDOWS) + // When using the Windows system data, we can possibly pick up time zone data from the Windows directory. char datadir_path_buffer[MAX_PATH]; if (getIcuDataDirectoryUnderWindowsDirectory(datadir_path_buffer, UPRV_LENGTHOF(datadir_path_buffer))) { dir = datadir_path_buffer; } +# endif + #else dir = getenv("ICU_TIMEZONE_FILES_DIR"); #endif // U_PLATFORM_HAS_WINUWP_API @@ -1560,6 +1563,10 @@ static const char *uprv_getPOSIXIDForCategory(int category) { /* Nothing worked. Give it a nice POSIX default value. */ posixID = "en_US_POSIX"; + // Note: this test will not catch 'C.UTF-8', + // that will be handled in uprv_getDefaultLocaleID(). + // Leave this mapping here for the uprv_getPOSIXIDForDefaultCodepage() + // caller which expects to see "en_US_POSIX" in many branches. } return posixID; } @@ -1631,8 +1638,8 @@ The leftmost codepage (.xxx) wins. } // Copy the ID into owned memory. - // Over-allocate in case we replace "@" with "__". - char *correctedPOSIXLocale = static_cast(uprv_malloc(uprv_strlen(posixID) + 1 + 1)); + // Over-allocate in case we replace "C" with "en_US_POSIX" (+10), + null termination + char *correctedPOSIXLocale = static_cast(uprv_malloc(uprv_strlen(posixID) + 10 + 1)); if (correctedPOSIXLocale == nullptr) { return nullptr; } @@ -1641,9 +1648,16 @@ The leftmost codepage (.xxx) wins. char *limit; if ((limit = uprv_strchr(correctedPOSIXLocale, '.')) != nullptr) { *limit = 0; - if ((limit = uprv_strchr(correctedPOSIXLocale, '@')) != nullptr) { - *limit = 0; - } + } + if ((limit = uprv_strchr(correctedPOSIXLocale, '@')) != nullptr) { + *limit = 0; + } + + if ((uprv_strcmp("C", correctedPOSIXLocale) == 0) // no @ variant + || (uprv_strcmp("POSIX", correctedPOSIXLocale) == 0)) { + // Raw input was C.* or POSIX.*, Give it a nice POSIX default value. + // (The "C"/"POSIX" case is handled in uprv_getPOSIXIDForCategory()) + uprv_strcpy(correctedPOSIXLocale, "en_US_POSIX"); } /* Note that we scan the *uncorrected* ID. */ @@ -1668,7 +1682,7 @@ The leftmost codepage (.xxx) wins. if ((q = uprv_strchr(p, '.')) != nullptr) { /* How big will the resulting string be? */ int32_t len = (int32_t)(uprv_strlen(correctedPOSIXLocale) + (q-p)); - uprv_strncat(correctedPOSIXLocale, p, q-p); + uprv_strncat(correctedPOSIXLocale, p, q-p); // do not include charset correctedPOSIXLocale[len] = 0; } else { @@ -2053,7 +2067,7 @@ int_getDefaultCodepage() static char codepage[64]; DWORD codepageNumber = 0; -#if U_PLATFORM_HAS_WINUWP_API > 0 +#if U_PLATFORM_HAS_WINUWP_API == 1 // UWP doesn't have a direct API to get the default ACP as Microsoft would rather // have folks use Unicode than a "system" code page, however this is the same // codepage as the system default locale codepage. (FWIW, the system locale is diff --git a/deps/icu-small/source/common/putilimp.h b/deps/icu-small/source/common/putilimp.h index f9c13d8e1b27bf..2e9fbcc4837cd8 100644 --- a/deps/icu-small/source/common/putilimp.h +++ b/deps/icu-small/source/common/putilimp.h @@ -178,76 +178,6 @@ typedef size_t uintptr_t; /** @} */ -/*===========================================================================*/ -/** @{ GCC built in functions for atomic memory operations */ -/*===========================================================================*/ - -/** - * \def U_HAVE_GCC_ATOMICS - * @internal - */ -#ifdef U_HAVE_GCC_ATOMICS - /* Use the predefined value. */ -#elif U_PLATFORM == U_PF_MINGW - #define U_HAVE_GCC_ATOMICS 0 -#elif U_GCC_MAJOR_MINOR >= 404 || defined(__clang__) - /* TODO: Intel icc and IBM xlc on AIX also support gcc atomics. (Intel originated them.) - * Add them for these compilers. - * Note: Clang sets __GNUC__ defines for version 4.2, so misses the 4.4 test here. - */ -# define U_HAVE_GCC_ATOMICS 1 -#else -# define U_HAVE_GCC_ATOMICS 0 -#endif - -/** @} */ - -/** - * \def U_HAVE_STD_ATOMICS - * Defines whether to use the C++11 std::atomic functions. - * If false, ICU will fall back to compiler or platform specific alternatives. - * Note: support for these fall back options for atomics will be removed in a future version - * of ICU, and the use of C++ 11 atomics will be required. - * @internal - */ -#ifdef U_HAVE_STD_ATOMICS - /* Use the predefined value. */ -#else -# define U_HAVE_STD_ATOMICS 1 -#endif - -/** - * \def U_HAVE_CLANG_ATOMICS - * Defines whether Clang c11 style built-in atomics are available. - * These are used in preference to gcc atomics when both are available. - */ -#ifdef U_HAVE_CLANG_ATOMICS - /* Use the predefined value. */ -#elif __has_builtin(__c11_atomic_load) && \ - __has_builtin(__c11_atomic_store) && \ - __has_builtin(__c11_atomic_fetch_add) && \ - __has_builtin(__c11_atomic_fetch_sub) -# define U_HAVE_CLANG_ATOMICS 1 -#else -# define U_HAVE_CLANG_ATOMICS 0 -#endif - - -/** - * \def U_HAVE_STD_MUTEX - * Defines whether to use the C++11 std::mutex functions. - * If false, ICU will fall back to compiler or platform specific alternatives. - * std::mutex is preferred, and used by default unless this setting is overridden. - * Note: support for other options for mutexes will be removed in a future version - * of ICU, and the use of std::mutex will be required. - * @internal - */ -#ifdef U_HAVE_STD_MUTEX - /* Use the predefined value. */ -#else -# define U_HAVE_STD_MUTEX 1 -#endif - /*===========================================================================*/ /** @{ Programs used by ICU code */ /*===========================================================================*/ diff --git a/deps/icu-small/source/common/rbbi.cpp b/deps/icu-small/source/common/rbbi.cpp index 3b116ffaf6cba7..01dae48de44c1d 100644 --- a/deps/icu-small/source/common/rbbi.cpp +++ b/deps/icu-small/source/common/rbbi.cpp @@ -323,8 +323,8 @@ void RuleBasedBreakIterator::init(UErrorCode &status) { // Virtual function: does the right thing with subclasses. // //----------------------------------------------------------------------------- -BreakIterator* -RuleBasedBreakIterator::clone(void) const { +RuleBasedBreakIterator* +RuleBasedBreakIterator::clone() const { return new RuleBasedBreakIterator(*this); } @@ -352,7 +352,7 @@ RuleBasedBreakIterator::operator==(const BreakIterator& that) const { // or have a different iteration position. // Note that fText's position is always the same as the break iterator's position. return FALSE; - }; + } if (!(fPosition == that2.fPosition && fRuleStatusIndex == that2.fRuleStatusIndex && @@ -1079,10 +1079,8 @@ const uint8_t *RuleBasedBreakIterator::getBinaryRules(uint32_t &length) { } -BreakIterator * RuleBasedBreakIterator::createBufferClone(void * /*stackBuffer*/, - int32_t &bufferSize, - UErrorCode &status) -{ +RuleBasedBreakIterator *RuleBasedBreakIterator::createBufferClone( + void * /*stackBuffer*/, int32_t &bufferSize, UErrorCode &status) { if (U_FAILURE(status)){ return NULL; } diff --git a/deps/icu-small/source/common/rbbi_cache.cpp b/deps/icu-small/source/common/rbbi_cache.cpp index 17ee2320802f60..4f9e83360a2a32 100644 --- a/deps/icu-small/source/common/rbbi_cache.cpp +++ b/deps/icu-small/source/common/rbbi_cache.cpp @@ -519,7 +519,7 @@ UBool RuleBasedBreakIterator::BreakCache::populatePreceding(UErrorCode &status) // The initial handleNext() only advanced by a single code point. Go again. position = fBI->handleNext(); // Safe rules identify safe pairs. } - }; + } positionStatusIdx = fBI->fRuleStatusIndex; } } while (position >= fromPosition); diff --git a/deps/icu-small/source/common/resbund.cpp b/deps/icu-small/source/common/resbund.cpp index 00dbf6f8fe2e9c..5ec7541b4db636 100644 --- a/deps/icu-small/source/common/resbund.cpp +++ b/deps/icu-small/source/common/resbund.cpp @@ -51,6 +51,7 @@ #include "unicode/utypes.h" #include "unicode/resbund.h" +#include "cmemory.h" #include "mutex.h" #include "uassert.h" #include "umutex.h" @@ -377,7 +378,7 @@ void ResourceBundle::getVersion(UVersionInfo versionInfo) const { } const Locale &ResourceBundle::getLocale(void) const { - static UMutex gLocaleLock = U_MUTEX_INITIALIZER; + static UMutex gLocaleLock; Mutex lock(&gLocaleLock); if (fLocale != NULL) { return *fLocale; diff --git a/deps/icu-small/source/common/resource.h b/deps/icu-small/source/common/resource.h index 3dbff785ef12a8..5199b858880770 100644 --- a/deps/icu-small/source/common/resource.h +++ b/deps/icu-small/source/common/resource.h @@ -28,6 +28,7 @@ #include "unicode/utypes.h" #include "unicode/unistr.h" #include "unicode/ures.h" +#include "restrace.h" struct ResourceData; @@ -47,8 +48,10 @@ class U_COMMON_API ResourceArray { ResourceArray() : items16(NULL), items32(NULL), length(0) {} /** Only for implementation use. @internal */ - ResourceArray(const uint16_t *i16, const uint32_t *i32, int32_t len) : - items16(i16), items32(i32), length(len) {} + ResourceArray(const uint16_t *i16, const uint32_t *i32, int32_t len, + const ResourceTracer& traceInfo) : + items16(i16), items32(i32), length(len), + fTraceInfo(traceInfo) {} /** * @return The number of items in the array resource. @@ -68,6 +71,7 @@ class U_COMMON_API ResourceArray { const uint16_t *items16; const uint32_t *items32; int32_t length; + ResourceTracer fTraceInfo; }; /** @@ -80,27 +84,37 @@ class U_COMMON_API ResourceTable { /** Only for implementation use. @internal */ ResourceTable(const uint16_t *k16, const int32_t *k32, - const uint16_t *i16, const uint32_t *i32, int32_t len) : - keys16(k16), keys32(k32), items16(i16), items32(i32), length(len) {} + const uint16_t *i16, const uint32_t *i32, int32_t len, + const ResourceTracer& traceInfo) : + keys16(k16), keys32(k32), items16(i16), items32(i32), length(len), + fTraceInfo(traceInfo) {} /** * @return The number of items in the array resource. */ int32_t getSize() const { return length; } /** - * @param i Array item index. + * @param i Table item index. * @param key Output-only, receives the key of the i'th item. * @param value Output-only, receives the value of the i'th item. * @return TRUE if i is non-negative and less than getSize(). */ UBool getKeyAndValue(int32_t i, const char *&key, ResourceValue &value) const; + /** + * @param key Key string to find in the table. + * @param value Output-only, receives the value of the item with that key. + * @return TRUE if the table contains the key. + */ + UBool findValue(const char *key, ResourceValue &value) const; + private: const uint16_t *keys16; const int32_t *keys32; const uint16_t *items16; const uint32_t *items32; int32_t length; + ResourceTracer fTraceInfo; }; /** diff --git a/deps/icu-small/source/common/restrace.cpp b/deps/icu-small/source/common/restrace.cpp new file mode 100644 index 00000000000000..5c6498850e2f8f --- /dev/null +++ b/deps/icu-small/source/common/restrace.cpp @@ -0,0 +1,130 @@ +// © 2019 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html + +#include "unicode/utypes.h" + +#if U_ENABLE_TRACING + +#include "restrace.h" +#include "charstr.h" +#include "cstring.h" +#include "utracimp.h" +#include "uresimp.h" +#include "uassert.h" +#include "util.h" + +U_NAMESPACE_BEGIN + +ResourceTracer::~ResourceTracer() = default; + +void ResourceTracer::trace(const char* resType) const { + U_ASSERT(fResB || fParent); + UTRACE_ENTRY(UTRACE_UDATA_RESOURCE); + UErrorCode status = U_ZERO_ERROR; + + CharString filePath; + getFilePath(filePath, status); + + CharString resPath; + getResPath(resPath, status); + + // The longest type ("intvector") is 9 chars + const char kSpaces[] = " "; + CharString format; + format.append(kSpaces, sizeof(kSpaces) - 1 - uprv_strlen(resType), status); + format.append("(%s) %s @ %s", status); + + UTRACE_DATA3(UTRACE_VERBOSE, + format.data(), + resType, + filePath.data(), + resPath.data()); + UTRACE_EXIT_STATUS(status); +} + +void ResourceTracer::traceOpen() const { + U_ASSERT(fResB); + UTRACE_ENTRY(UTRACE_UDATA_BUNDLE); + UErrorCode status = U_ZERO_ERROR; + + CharString filePath; + UTRACE_DATA1(UTRACE_VERBOSE, "%s", getFilePath(filePath, status).data()); + UTRACE_EXIT_STATUS(status); +} + +CharString& ResourceTracer::getFilePath(CharString& output, UErrorCode& status) const { + if (fResB) { + output.append(fResB->fData->fPath, status); + output.append('/', status); + output.append(fResB->fData->fName, status); + output.append(".res", status); + } else { + fParent->getFilePath(output, status); + } + return output; +} + +CharString& ResourceTracer::getResPath(CharString& output, UErrorCode& status) const { + if (fResB) { + output.append('/', status); + output.append(fResB->fResPath, status); + // removing the trailing / + U_ASSERT(output[output.length()-1] == '/'); + output.truncate(output.length()-1); + } else { + fParent->getResPath(output, status); + } + if (fKey) { + output.append('/', status); + output.append(fKey, status); + } + if (fIndex != -1) { + output.append('[', status); + UnicodeString indexString; + ICU_Utility::appendNumber(indexString, fIndex); + output.appendInvariantChars(indexString, status); + output.append(']', status); + } + return output; +} + +void FileTracer::traceOpen(const char* path, const char* type, const char* name) { + if (uprv_strcmp(type, "res") == 0) { + traceOpenResFile(path, name); + } else { + traceOpenDataFile(path, type, name); + } +} + +void FileTracer::traceOpenDataFile(const char* path, const char* type, const char* name) { + UTRACE_ENTRY(UTRACE_UDATA_DATA_FILE); + UErrorCode status = U_ZERO_ERROR; + + CharString filePath; + filePath.append(path, status); + filePath.append('/', status); + filePath.append(name, status); + filePath.append('.', status); + filePath.append(type, status); + + UTRACE_DATA1(UTRACE_VERBOSE, "%s", filePath.data()); + UTRACE_EXIT_STATUS(status); +} + +void FileTracer::traceOpenResFile(const char* path, const char* name) { + UTRACE_ENTRY(UTRACE_UDATA_RES_FILE); + UErrorCode status = U_ZERO_ERROR; + + CharString filePath; + filePath.append(path, status); + filePath.append('/', status); + filePath.append(name, status); + filePath.append(".res", status); + + UTRACE_DATA1(UTRACE_VERBOSE, "%s", filePath.data()); + UTRACE_EXIT_STATUS(status); +} + +U_NAMESPACE_END + +#endif // U_ENABLE_TRACING diff --git a/deps/icu-small/source/common/restrace.h b/deps/icu-small/source/common/restrace.h new file mode 100644 index 00000000000000..ef29eaed578107 --- /dev/null +++ b/deps/icu-small/source/common/restrace.h @@ -0,0 +1,147 @@ +// © 2019 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html + +#ifndef __RESTRACE_H__ +#define __RESTRACE_H__ + +#include "unicode/utypes.h" + +#if U_ENABLE_TRACING + +struct UResourceBundle; + +U_NAMESPACE_BEGIN + +class CharString; + +/** + * Instances of this class store information used to trace reads from resource + * bundles when ICU is built with --enable-tracing. + * + * All arguments of type const UResourceBundle*, const char*, and + * const ResourceTracer& are stored as pointers. The caller must retain + * ownership for the lifetime of this ResourceTracer. + * + * Exported as U_COMMON_API for Windows because it is a value field + * in other exported types. + */ +class U_COMMON_API ResourceTracer { +public: + ResourceTracer() : + fResB(nullptr), + fParent(nullptr), + fKey(nullptr), + fIndex(-1) {} + + ResourceTracer(const UResourceBundle* resB) : + fResB(resB), + fParent(nullptr), + fKey(nullptr), + fIndex(-1) {} + + ResourceTracer(const UResourceBundle* resB, const char* key) : + fResB(resB), + fParent(nullptr), + fKey(key), + fIndex(-1) {} + + ResourceTracer(const UResourceBundle* resB, int32_t index) : + fResB(resB), + fParent(nullptr), + fKey(nullptr), + fIndex(index) {} + + ResourceTracer(const ResourceTracer& parent, const char* key) : + fResB(nullptr), + fParent(&parent), + fKey(key), + fIndex(-1) {} + + ResourceTracer(const ResourceTracer& parent, int32_t index) : + fResB(nullptr), + fParent(&parent), + fKey(nullptr), + fIndex(index) {} + + ~ResourceTracer(); + + void trace(const char* type) const; + void traceOpen() const; + + /** + * Calls trace() if the resB or parent provided to the constructor was + * non-null; otherwise, does nothing. + */ + void maybeTrace(const char* type) const { + if (fResB || fParent) { + trace(type); + } + } + +private: + const UResourceBundle* fResB; + const ResourceTracer* fParent; + const char* fKey; + int32_t fIndex; + + CharString& getFilePath(CharString& output, UErrorCode& status) const; + + CharString& getResPath(CharString& output, UErrorCode& status) const; +}; + +/** + * This class provides methods to trace data file reads when ICU is built + * with --enable-tracing. + */ +class FileTracer { +public: + static void traceOpen(const char* path, const char* type, const char* name); + +private: + static void traceOpenDataFile(const char* path, const char* type, const char* name); + static void traceOpenResFile(const char* path, const char* name); +}; + +U_NAMESPACE_END + +#else // U_ENABLE_TRACING + +U_NAMESPACE_BEGIN + +/** + * Default trivial implementation when --enable-tracing is not used. + */ +class U_COMMON_API ResourceTracer { +public: + ResourceTracer() {} + + ResourceTracer(const void*) {} + + ResourceTracer(const void*, const char*) {} + + ResourceTracer(const void*, int32_t) {} + + ResourceTracer(const ResourceTracer&, const char*) {} + + ResourceTracer(const ResourceTracer&, int32_t) {} + + void trace(const char*) const {} + + void traceOpen() const {} + + void maybeTrace(const char*) const {} +}; + +/** + * Default trivial implementation when --enable-tracing is not used. + */ +class FileTracer { +public: + static void traceOpen(const char*, const char*, const char*) {} +}; + +U_NAMESPACE_END + +#endif // U_ENABLE_TRACING + +#endif //__RESTRACE_H__ diff --git a/deps/icu-small/source/common/schriter.cpp b/deps/icu-small/source/common/schriter.cpp index f852800aaae6bd..17b68aee9d923a 100644 --- a/deps/icu-small/source/common/schriter.cpp +++ b/deps/icu-small/source/common/schriter.cpp @@ -101,7 +101,7 @@ StringCharacterIterator::operator==(const ForwardCharacterIterator& that) const && end == realThat.end; } -CharacterIterator* +StringCharacterIterator* StringCharacterIterator::clone() const { return new StringCharacterIterator(*this); } diff --git a/deps/icu-small/source/common/serv.cpp b/deps/icu-small/source/common/serv.cpp index 40940740d02b45..044864b859c7e8 100644 --- a/deps/icu-small/source/common/serv.cpp +++ b/deps/icu-small/source/common/serv.cpp @@ -333,10 +333,7 @@ U_CDECL_END ****************************************************************** */ -static UMutex *lock() { - static UMutex m = U_MUTEX_INITIALIZER; - return &m; -} +static UMutex lock; ICUService::ICUService() : name() @@ -361,7 +358,7 @@ ICUService::ICUService(const UnicodeString& newName) ICUService::~ICUService() { { - Mutex mutex(lock()); + Mutex mutex(&lock); clearCaches(); delete factories; factories = NULL; @@ -452,7 +449,7 @@ ICUService::getKey(ICUServiceKey& key, UnicodeString* actualReturn, const ICUSer // if factory is not null, we're calling from within the mutex, // and since some unix machines don't have reentrant mutexes we // need to make sure not to try to lock it again. - XMutex mutex(lock(), factory != NULL); + XMutex mutex(&lock, factory != NULL); if (serviceCache == NULL) { ncthis->serviceCache = new Hashtable(status); @@ -618,7 +615,7 @@ ICUService::getVisibleIDs(UVector& result, const UnicodeString* matchID, UErrorC } { - Mutex mutex(lock()); + Mutex mutex(&lock); const Hashtable* map = getVisibleIDMap(status); if (map != NULL) { ICUServiceKey* fallbackKey = createKey(matchID, status); @@ -695,7 +692,7 @@ ICUService::getDisplayName(const UnicodeString& id, UnicodeString& result, const { { UErrorCode status = U_ZERO_ERROR; - Mutex mutex(lock()); + Mutex mutex(&lock); const Hashtable* map = getVisibleIDMap(status); if (map != NULL) { ICUServiceFactory* f = (ICUServiceFactory*)map->get(id); @@ -747,7 +744,7 @@ ICUService::getDisplayNames(UVector& result, result.setDeleter(userv_deleteStringPair); if (U_SUCCESS(status)) { ICUService* ncthis = (ICUService*)this; // cast away semantic const - Mutex mutex(lock()); + Mutex mutex(&lock); if (dnCache != NULL && dnCache->locale != locale) { delete dnCache; @@ -852,7 +849,7 @@ URegistryKey ICUService::registerFactory(ICUServiceFactory* factoryToAdopt, UErrorCode& status) { if (U_SUCCESS(status) && factoryToAdopt != NULL) { - Mutex mutex(lock()); + Mutex mutex(&lock); if (factories == NULL) { factories = new UVector(deleteUObject, NULL, status); @@ -883,7 +880,7 @@ ICUService::unregister(URegistryKey rkey, UErrorCode& status) ICUServiceFactory *factory = (ICUServiceFactory*)rkey; UBool result = FALSE; if (factory != NULL && factories != NULL) { - Mutex mutex(lock()); + Mutex mutex(&lock); if (factories->removeElement(factory)) { clearCaches(); @@ -903,7 +900,7 @@ void ICUService::reset() { { - Mutex mutex(lock()); + Mutex mutex(&lock); reInitializeFactories(); clearCaches(); } diff --git a/deps/icu-small/source/common/servls.cpp b/deps/icu-small/source/common/servls.cpp index 0b1b1b947d514e..0c2a73d98e2275 100644 --- a/deps/icu-small/source/common/servls.cpp +++ b/deps/icu-small/source/common/servls.cpp @@ -263,7 +263,7 @@ ICULocaleService::validateFallbackLocale() const { const Locale& loc = Locale::getDefault(); ICULocaleService* ncThis = (ICULocaleService*)this; - static UMutex llock = U_MUTEX_INITIALIZER; + static UMutex llock; { Mutex mutex(&llock); if (loc != fallbackLocale) { diff --git a/deps/icu-small/source/common/servnotf.cpp b/deps/icu-small/source/common/servnotf.cpp index 9b5997bd17f509..435f36b0d00671 100644 --- a/deps/icu-small/source/common/servnotf.cpp +++ b/deps/icu-small/source/common/servnotf.cpp @@ -21,10 +21,7 @@ U_NAMESPACE_BEGIN EventListener::~EventListener() {} UOBJECT_DEFINE_RTTI_IMPLEMENTATION(EventListener) -static UMutex *notifyLock() { - static UMutex m = U_MUTEX_INITIALIZER; - return &m; -} +static UMutex notifyLock; ICUNotifier::ICUNotifier(void) : listeners(NULL) @@ -33,7 +30,7 @@ ICUNotifier::ICUNotifier(void) ICUNotifier::~ICUNotifier(void) { { - Mutex lmx(notifyLock()); + Mutex lmx(¬ifyLock); delete listeners; listeners = NULL; } @@ -50,7 +47,7 @@ ICUNotifier::addListener(const EventListener* l, UErrorCode& status) } if (acceptsListener(*l)) { - Mutex lmx(notifyLock()); + Mutex lmx(¬ifyLock); if (listeners == NULL) { listeners = new UVector(5, status); } else { @@ -83,7 +80,7 @@ ICUNotifier::removeListener(const EventListener *l, UErrorCode& status) } { - Mutex lmx(notifyLock()); + Mutex lmx(¬ifyLock); if (listeners != NULL) { // identity equality check for (int i = 0, e = listeners->size(); i < e; ++i) { @@ -106,7 +103,7 @@ void ICUNotifier::notifyChanged(void) { if (listeners != NULL) { - Mutex lmx(notifyLock()); + Mutex lmx(¬ifyLock); if (listeners != NULL) { for (int i = 0, e = listeners->size(); i < e; ++i) { EventListener* el = (EventListener*)listeners->elementAt(i); diff --git a/deps/icu-small/source/common/uarrsort.cpp b/deps/icu-small/source/common/uarrsort.cpp index 03c4d4e7fc44aa..60905821649db9 100644 --- a/deps/icu-small/source/common/uarrsort.cpp +++ b/deps/icu-small/source/common/uarrsort.cpp @@ -34,6 +34,10 @@ enum { STACK_ITEM_SIZE=200 }; +static constexpr int32_t sizeInMaxAlignTs(int32_t sizeInBytes) { + return (sizeInBytes + sizeof(max_align_t) - 1) / sizeof(max_align_t); +} + /* UComparator convenience implementations ---------------------------------- */ U_CAPI int32_t U_EXPORT2 @@ -134,25 +138,15 @@ doInsertionSort(char *array, int32_t length, int32_t itemSize, static void insertionSort(char *array, int32_t length, int32_t itemSize, UComparator *cmp, const void *context, UErrorCode *pErrorCode) { - UAlignedMemory v[STACK_ITEM_SIZE/sizeof(UAlignedMemory)+1]; - void *pv; - /* allocate an intermediate item variable (v) */ - if(itemSize<=STACK_ITEM_SIZE) { - pv=v; - } else { - pv=uprv_malloc(itemSize); - if(pv==NULL) { - *pErrorCode=U_MEMORY_ALLOCATION_ERROR; - return; - } + icu::MaybeStackArray v; + if (sizeInMaxAlignTs(itemSize) > v.getCapacity() && + v.resize(sizeInMaxAlignTs(itemSize)) == nullptr) { + *pErrorCode = U_MEMORY_ALLOCATION_ERROR; + return; } - doInsertionSort(array, length, itemSize, cmp, context, pv); - - if(pv!=v) { - uprv_free(pv); - } + doInsertionSort(array, length, itemSize, cmp, context, v.getAlias()); } /* QuickSort ---------------------------------------------------------------- */ @@ -238,26 +232,16 @@ subQuickSort(char *array, int32_t start, int32_t limit, int32_t itemSize, static void quickSort(char *array, int32_t length, int32_t itemSize, UComparator *cmp, const void *context, UErrorCode *pErrorCode) { - UAlignedMemory xw[(2*STACK_ITEM_SIZE)/sizeof(UAlignedMemory)+1]; - void *p; - /* allocate two intermediate item variables (x and w) */ - if(itemSize<=STACK_ITEM_SIZE) { - p=xw; - } else { - p=uprv_malloc(2*itemSize); - if(p==NULL) { - *pErrorCode=U_MEMORY_ALLOCATION_ERROR; - return; - } + icu::MaybeStackArray xw; + if(sizeInMaxAlignTs(itemSize)*2 > xw.getCapacity() && + xw.resize(sizeInMaxAlignTs(itemSize) * 2) == nullptr) { + *pErrorCode=U_MEMORY_ALLOCATION_ERROR; + return; } - subQuickSort(array, 0, length, itemSize, - cmp, context, p, (char *)p+itemSize); - - if(p!=xw) { - uprv_free(p); - } + subQuickSort(array, 0, length, itemSize, cmp, context, + xw.getAlias(), xw.getAlias() + sizeInMaxAlignTs(itemSize)); } /* uprv_sortArray() API ----------------------------------------------------- */ diff --git a/deps/icu-small/source/common/ubidiimp.h b/deps/icu-small/source/common/ubidiimp.h index a5d0727495d767..9746b2bc103102 100644 --- a/deps/icu-small/source/common/ubidiimp.h +++ b/deps/icu-small/source/common/ubidiimp.h @@ -198,8 +198,8 @@ typedef struct Run { /* in a Run, logicalStart will get this bit set if the run level is odd */ #define INDEX_ODD_BIT (1UL<<31) -#define MAKE_INDEX_ODD_PAIR(index, level) ((index)|((int32_t)(level)<<31)) -#define ADD_ODD_BIT_FROM_LEVEL(x, level) ((x)|=((int32_t)(level)<<31)) +#define MAKE_INDEX_ODD_PAIR(index, level) ((index)|((int32_t)((level)&1)<<31)) +#define ADD_ODD_BIT_FROM_LEVEL(x, level) ((x)|=((int32_t)((level)&1)<<31)) #define REMOVE_ODD_BIT(x) ((x)&=~INDEX_ODD_BIT) #define GET_INDEX(x) ((x)&~INDEX_ODD_BIT) @@ -387,41 +387,49 @@ typedef union { } BidiMemoryForAllocation; /* Macros for initial checks at function entry */ -#define RETURN_IF_NULL_OR_FAILING_ERRCODE(pErrcode, retvalue) \ - if((pErrcode)==NULL || U_FAILURE(*pErrcode)) return retvalue -#define RETURN_IF_NOT_VALID_PARA(bidi, errcode, retvalue) \ - if(!IS_VALID_PARA(bidi)) { \ - errcode=U_INVALID_STATE_ERROR; \ - return retvalue; \ - } -#define RETURN_IF_NOT_VALID_PARA_OR_LINE(bidi, errcode, retvalue) \ - if(!IS_VALID_PARA_OR_LINE(bidi)) { \ - errcode=U_INVALID_STATE_ERROR; \ - return retvalue; \ - } -#define RETURN_IF_BAD_RANGE(arg, start, limit, errcode, retvalue) \ - if((arg)<(start) || (arg)>=(limit)) { \ - (errcode)=U_ILLEGAL_ARGUMENT_ERROR; \ - return retvalue; \ - } - -#define RETURN_VOID_IF_NULL_OR_FAILING_ERRCODE(pErrcode) \ - if((pErrcode)==NULL || U_FAILURE(*pErrcode)) return -#define RETURN_VOID_IF_NOT_VALID_PARA(bidi, errcode) \ - if(!IS_VALID_PARA(bidi)) { \ - errcode=U_INVALID_STATE_ERROR; \ - return; \ - } -#define RETURN_VOID_IF_NOT_VALID_PARA_OR_LINE(bidi, errcode) \ - if(!IS_VALID_PARA_OR_LINE(bidi)) { \ - errcode=U_INVALID_STATE_ERROR; \ - return; \ - } -#define RETURN_VOID_IF_BAD_RANGE(arg, start, limit, errcode) \ - if((arg)<(start) || (arg)>=(limit)) { \ - (errcode)=U_ILLEGAL_ARGUMENT_ERROR; \ - return; \ - } +#define RETURN_IF_NULL_OR_FAILING_ERRCODE(pErrcode, retvalue) UPRV_BLOCK_MACRO_BEGIN { \ + if((pErrcode)==NULL || U_FAILURE(*pErrcode)) return retvalue; \ +} UPRV_BLOCK_MACRO_END +#define RETURN_IF_NOT_VALID_PARA(bidi, errcode, retvalue) UPRV_BLOCK_MACRO_BEGIN { \ + if(!IS_VALID_PARA(bidi)) { \ + errcode=U_INVALID_STATE_ERROR; \ + return retvalue; \ + } \ +} UPRV_BLOCK_MACRO_END +#define RETURN_IF_NOT_VALID_PARA_OR_LINE(bidi, errcode, retvalue) UPRV_BLOCK_MACRO_BEGIN { \ + if(!IS_VALID_PARA_OR_LINE(bidi)) { \ + errcode=U_INVALID_STATE_ERROR; \ + return retvalue; \ + } \ +} UPRV_BLOCK_MACRO_END +#define RETURN_IF_BAD_RANGE(arg, start, limit, errcode, retvalue) UPRV_BLOCK_MACRO_BEGIN { \ + if((arg)<(start) || (arg)>=(limit)) { \ + (errcode)=U_ILLEGAL_ARGUMENT_ERROR; \ + return retvalue; \ + } \ +} UPRV_BLOCK_MACRO_END + +#define RETURN_VOID_IF_NULL_OR_FAILING_ERRCODE(pErrcode) UPRV_BLOCK_MACRO_BEGIN { \ + if((pErrcode)==NULL || U_FAILURE(*pErrcode)) return; \ +} UPRV_BLOCK_MACRO_END +#define RETURN_VOID_IF_NOT_VALID_PARA(bidi, errcode) UPRV_BLOCK_MACRO_BEGIN { \ + if(!IS_VALID_PARA(bidi)) { \ + errcode=U_INVALID_STATE_ERROR; \ + return; \ + } \ +} UPRV_BLOCK_MACRO_END +#define RETURN_VOID_IF_NOT_VALID_PARA_OR_LINE(bidi, errcode) UPRV_BLOCK_MACRO_BEGIN { \ + if(!IS_VALID_PARA_OR_LINE(bidi)) { \ + errcode=U_INVALID_STATE_ERROR; \ + return; \ + } \ +} UPRV_BLOCK_MACRO_END +#define RETURN_VOID_IF_BAD_RANGE(arg, start, limit, errcode) UPRV_BLOCK_MACRO_BEGIN { \ + if((arg)<(start) || (arg)>=(limit)) { \ + (errcode)=U_ILLEGAL_ARGUMENT_ERROR; \ + return; \ + } \ +} UPRV_BLOCK_MACRO_END /* helper function to (re)allocate memory if allowed */ U_CFUNC UBool diff --git a/deps/icu-small/source/common/ubiditransform.cpp b/deps/icu-small/source/common/ubiditransform.cpp index 394df6092d21b1..bb3ce8cb934d43 100644 --- a/deps/icu-small/source/common/ubiditransform.cpp +++ b/deps/icu-small/source/common/ubiditransform.cpp @@ -31,11 +31,11 @@ #define SHAPE_LOGICAL U_SHAPE_TEXT_DIRECTION_LOGICAL #define SHAPE_VISUAL U_SHAPE_TEXT_DIRECTION_VISUAL_LTR -#define CHECK_LEN(STR, LEN, ERROR) { \ - if (LEN == 0) return 0; \ - if (LEN < -1) { *(ERROR) = U_ILLEGAL_ARGUMENT_ERROR; return 0; } \ - if (LEN == -1) LEN = u_strlen(STR); \ - } +#define CHECK_LEN(STR, LEN, ERROR) UPRV_BLOCK_MACRO_BEGIN { \ + if (LEN == 0) return 0; \ + if (LEN < -1) { *(ERROR) = U_ILLEGAL_ARGUMENT_ERROR; return 0; } \ + if (LEN == -1) LEN = u_strlen(STR); \ +} UPRV_BLOCK_MACRO_END #define MAX_ACTIONS 7 diff --git a/deps/icu-small/source/common/ucase.cpp b/deps/icu-small/source/common/ucase.cpp index 50c8d20c1fce73..57a40327905c00 100644 --- a/deps/icu-small/source/common/ucase.cpp +++ b/deps/icu-small/source/common/ucase.cpp @@ -116,7 +116,7 @@ static const uint8_t flagsOffset[256]={ * moved to the last uint16_t of the value, use +1 for beginning of next slot * @param value (out) int32_t or uint32_t output if hasSlot, otherwise not modified */ -#define GET_SLOT_VALUE(excWord, idx, pExc16, value) \ +#define GET_SLOT_VALUE(excWord, idx, pExc16, value) UPRV_BLOCK_MACRO_BEGIN { \ if(((excWord)&UCASE_EXC_DOUBLE_SLOTS)==0) { \ (pExc16)+=SLOT_OFFSET(excWord, idx); \ (value)=*pExc16; \ @@ -124,7 +124,8 @@ static const uint8_t flagsOffset[256]={ (pExc16)+=2*SLOT_OFFSET(excWord, idx); \ (value)=*pExc16++; \ (value)=((value)<<16)|*pExc16; \ - } + } \ +} UPRV_BLOCK_MACRO_END /* simple case mappings ----------------------------------------------------- */ diff --git a/deps/icu-small/source/common/uchar.cpp b/deps/icu-small/source/common/uchar.cpp index 60fe75c78dec03..12365fd6976e5b 100644 --- a/deps/icu-small/source/common/uchar.cpp +++ b/deps/icu-small/source/common/uchar.cpp @@ -40,7 +40,7 @@ /* constants and macros for access to the data ------------------------------ */ /* getting a uint32_t properties word from the data */ -#define GET_PROPS(c, result) ((result)=UTRIE2_GET16(&propsTrie, c)); +#define GET_PROPS(c, result) ((result)=UTRIE2_GET16(&propsTrie, c)) /* API functions ------------------------------------------------------------ */ diff --git a/deps/icu-small/source/common/uchriter.cpp b/deps/icu-small/source/common/uchriter.cpp index 822168f5c8e600..bedbabc74c2351 100644 --- a/deps/icu-small/source/common/uchriter.cpp +++ b/deps/icu-small/source/common/uchriter.cpp @@ -89,7 +89,7 @@ UCharCharacterIterator::hashCode() const { return ustr_hashUCharsN(text, textLength) ^ pos ^ begin ^ end; } -CharacterIterator* +UCharCharacterIterator* UCharCharacterIterator::clone() const { return new UCharCharacterIterator(*this); } diff --git a/deps/icu-small/source/common/ucln_cmn.cpp b/deps/icu-small/source/common/ucln_cmn.cpp index d78491df419fb0..ab9d3adbd25958 100644 --- a/deps/icu-small/source/common/ucln_cmn.cpp +++ b/deps/icu-small/source/common/ucln_cmn.cpp @@ -65,9 +65,20 @@ U_CFUNC void ucln_common_registerCleanup(ECleanupCommonType type, cleanupFunc *func) { + // Thread safety messiness: From ticket 10295, calls to registerCleanup() may occur + // concurrently. Although such cases should be storing the same value, they raise errors + // from the thread sanity checker. Doing the store within a mutex avoids those. + // BUT that can trigger a recursive entry into std::call_once() in umutex.cpp when this code, + // running from the call_once function, tries to grab the ICU global mutex, which + // re-enters the mutex init path. So, work-around by special casing UCLN_COMMON_MUTEX, not + // using the ICU global mutex for it. + // + // No other point in ICU uses std::call_once(). + U_ASSERT(UCLN_COMMON_START < type && type < UCLN_COMMON_COUNT); - if (UCLN_COMMON_START < type && type < UCLN_COMMON_COUNT) - { + if (type == UCLN_COMMON_MUTEX) { + gCommonCleanupFunctions[type] = func; + } else if (UCLN_COMMON_START < type && type < UCLN_COMMON_COUNT) { icu::Mutex m; // See ticket 10295 for discussion. gCommonCleanupFunctions[type] = func; } diff --git a/deps/icu-small/source/common/ucln_cmn.h b/deps/icu-small/source/common/ucln_cmn.h index 0ca911b47d9875..b837fb946296a1 100644 --- a/deps/icu-small/source/common/ucln_cmn.h +++ b/deps/icu-small/source/common/ucln_cmn.h @@ -22,8 +22,6 @@ /* These are the cleanup functions for various APIs. */ /* @return true if cleanup complete successfully.*/ -U_CFUNC UBool umtx_cleanup(void); - U_CFUNC UBool utrace_cleanup(void); U_CFUNC UBool ucln_lib_cleanup(void); @@ -41,6 +39,8 @@ typedef enum ECleanupCommonType { UCLN_COMMON_LOCALE_KEY_TYPE, UCLN_COMMON_LOCALE, UCLN_COMMON_LOCALE_AVAILABLE, + UCLN_COMMON_LIKELY_SUBTAGS, + UCLN_COMMON_LOCALE_DISTANCE, UCLN_COMMON_ULOC, UCLN_COMMON_CURRENCY, UCLN_COMMON_LOADED_NORMALIZER2, @@ -62,6 +62,7 @@ typedef enum ECleanupCommonType { */ UCLN_COMMON_UNIFIED_CACHE, UCLN_COMMON_URES, + UCLN_COMMON_MUTEX, // Mutexes should be the last to be cleaned up. UCLN_COMMON_COUNT /* This must be last */ } ECleanupCommonType; diff --git a/deps/icu-small/source/common/ucnv.cpp b/deps/icu-small/source/common/ucnv.cpp index abf302eaddb7a8..e2e0c5b9f7f42f 100644 --- a/deps/icu-small/source/common/ucnv.cpp +++ b/deps/icu-small/source/common/ucnv.cpp @@ -25,6 +25,8 @@ #if !UCONFIG_NO_CONVERSION +#include + #include "unicode/ustring.h" #include "unicode/ucnv.h" #include "unicode/ucnv_err.h" @@ -158,7 +160,6 @@ ucnv_safeClone(const UConverter* cnv, void *stackBuffer, int32_t *pBufferSize, U UConverter *localConverter, *allocatedConverter; int32_t stackBufferSize; int32_t bufferSizeNeeded; - char *stackBufferChars = (char *)stackBuffer; UErrorCode cbErr; UConverterToUnicodeArgs toUArgs = { sizeof(UConverterToUnicodeArgs), @@ -224,23 +225,22 @@ ucnv_safeClone(const UConverter* cnv, void *stackBuffer, int32_t *pBufferSize, U } } - - /* Pointers on 64-bit platforms need to be aligned - * on a 64-bit boundary in memory. + /* Adjust (if necessary) the stackBuffer pointer to be aligned correctly for a UConverter. + * TODO(Jira ICU-20736) Redo this using std::align() once g++4.9 compatibility is no longer needed. */ - if (U_ALIGNMENT_OFFSET(stackBuffer) != 0) { - int32_t offsetUp = (int32_t)U_ALIGNMENT_OFFSET_UP(stackBufferChars); - if(stackBufferSize > offsetUp) { - stackBufferSize -= offsetUp; - stackBufferChars += offsetUp; + if (stackBuffer) { + uintptr_t p = reinterpret_cast(stackBuffer); + uintptr_t aligned_p = (p + alignof(UConverter) - 1) & ~(alignof(UConverter) - 1); + ptrdiff_t pointerAdjustment = aligned_p - p; + if (bufferSizeNeeded + pointerAdjustment <= stackBufferSize) { + stackBuffer = reinterpret_cast(aligned_p); + stackBufferSize -= pointerAdjustment; } else { /* prevent using the stack buffer but keep the size > 0 so that we do not just preflight */ stackBufferSize = 1; } } - stackBuffer = (void *)stackBufferChars; - /* Now, see if we must allocate any memory */ if (stackBufferSize < bufferSizeNeeded || stackBuffer == NULL) { @@ -475,7 +475,7 @@ ucnv_setSubstString(UConverter *cnv, const UChar *s, int32_t length, UErrorCode *err) { - UAlignedMemory cloneBuffer[U_CNV_SAFECLONE_BUFFERSIZE / sizeof(UAlignedMemory) + 1]; + alignas(UConverter) char cloneBuffer[U_CNV_SAFECLONE_BUFFERSIZE]; char chars[UCNV_ERROR_BUFFER_LENGTH]; UConverter *clone; diff --git a/deps/icu-small/source/common/ucnv2022.cpp b/deps/icu-small/source/common/ucnv2022.cpp index 4a35ff85e10fa0..6cd9a3d12e40fc 100644 --- a/deps/icu-small/source/common/ucnv2022.cpp +++ b/deps/icu-small/source/common/ucnv2022.cpp @@ -3571,20 +3571,11 @@ _ISO_2022_WriteSub(UConverterFromUnicodeArgs *args, int32_t offsetIndex, UErrorC /* * Structure for cloning an ISO 2022 converter into a single memory block. - * ucnv_safeClone() of the converter will align the entire cloneStruct, - * and then ucnv_safeClone() of the sub-converter may additionally align - * currentConverter inside the cloneStruct, for which we need the deadSpace - * after currentConverter. - * This is because UAlignedMemory may be larger than the actually - * necessary alignment size for the platform. - * The other cloneStruct fields will not be moved around, - * and are aligned properly with cloneStruct's alignment. */ struct cloneStruct { UConverter cnv; UConverter currentConverter; - UAlignedMemory deadSpace; UConverterDataISO2022 mydata; }; @@ -3602,6 +3593,10 @@ _ISO_2022_SafeClone( UConverterDataISO2022 *cnvData; int32_t i, size; + if (U_FAILURE(*status)){ + return nullptr; + } + if (*pBufferSize == 0) { /* 'preflighting' request - set needed size into *pBufferSize */ *pBufferSize = (int32_t)sizeof(struct cloneStruct); return NULL; @@ -3619,7 +3614,7 @@ _ISO_2022_SafeClone( /* share the subconverters */ if(cnvData->currentConverter != NULL) { - size = (int32_t)(sizeof(UConverter) + sizeof(UAlignedMemory)); /* include size of padding */ + size = (int32_t)sizeof(UConverter); localClone->mydata.currentConverter = ucnv_safeClone(cnvData->currentConverter, &localClone->currentConverter, diff --git a/deps/icu-small/source/common/ucnv_bld.cpp b/deps/icu-small/source/common/ucnv_bld.cpp index e6ef833f4e4317..1c2363ea89981f 100644 --- a/deps/icu-small/source/common/ucnv_bld.cpp +++ b/deps/icu-small/source/common/ucnv_bld.cpp @@ -194,10 +194,7 @@ static struct { /*initializes some global variables */ static UHashtable *SHARED_DATA_HASHTABLE = NULL; -static icu::UMutex *cnvCacheMutex() { /* Mutex for synchronizing cnv cache access. */ - static icu::UMutex m = U_MUTEX_INITIALIZER; - return &m; -} +static icu::UMutex cnvCacheMutex; /* Note: the global mutex is used for */ /* reference count updates. */ @@ -602,9 +599,9 @@ U_CFUNC void ucnv_unloadSharedDataIfReady(UConverterSharedData *sharedData) { if(sharedData != NULL && sharedData->isReferenceCounted) { - umtx_lock(cnvCacheMutex()); + umtx_lock(&cnvCacheMutex); ucnv_unload(sharedData); - umtx_unlock(cnvCacheMutex()); + umtx_unlock(&cnvCacheMutex); } } @@ -612,9 +609,9 @@ U_CFUNC void ucnv_incrementRefCount(UConverterSharedData *sharedData) { if(sharedData != NULL && sharedData->isReferenceCounted) { - umtx_lock(cnvCacheMutex()); + umtx_lock(&cnvCacheMutex); sharedData->referenceCounter++; - umtx_unlock(cnvCacheMutex()); + umtx_unlock(&cnvCacheMutex); } } @@ -815,9 +812,9 @@ ucnv_loadSharedData(const char *converterName, pArgs->nestedLoads=1; pArgs->pkg=NULL; - umtx_lock(cnvCacheMutex()); + umtx_lock(&cnvCacheMutex); mySharedConverterData = ucnv_load(pArgs, err); - umtx_unlock(cnvCacheMutex()); + umtx_unlock(&cnvCacheMutex); if (U_FAILURE (*err) || (mySharedConverterData == NULL)) { return NULL; @@ -1064,7 +1061,7 @@ ucnv_flushCache () * because the sequence of looking up in the cache + incrementing * is protected by cnvCacheMutex. */ - umtx_lock(cnvCacheMutex()); + umtx_lock(&cnvCacheMutex); /* * double loop: A delta/extension-only converter has a pointer to its base table's * shared data; the first iteration of the outer loop may see the delta converter @@ -1093,7 +1090,7 @@ ucnv_flushCache () } } } while(++i == 1 && remaining > 0); - umtx_unlock(cnvCacheMutex()); + umtx_unlock(&cnvCacheMutex); UTRACE_DATA1(UTRACE_INFO, "ucnv_flushCache() exits with %d converters remaining", remaining); @@ -1199,7 +1196,7 @@ internalSetName(const char *name, UErrorCode *status) { } algorithmicSharedData = getAlgorithmicTypeFromName(stackArgs.name); - umtx_lock(cnvCacheMutex()); + umtx_lock(&cnvCacheMutex); gDefaultAlgorithmicSharedData = algorithmicSharedData; gDefaultConverterContainsOption = containsOption; @@ -1215,7 +1212,7 @@ internalSetName(const char *name, UErrorCode *status) { ucnv_enableCleanup(); - umtx_unlock(cnvCacheMutex()); + umtx_unlock(&cnvCacheMutex); } #endif @@ -1240,7 +1237,7 @@ ucnv_getDefaultName() { but ucnv_setDefaultName is not thread safe. */ { - icu::Mutex lock(cnvCacheMutex()); + icu::Mutex lock(&cnvCacheMutex); name = gDefaultConverterName; } if(name==NULL) { diff --git a/deps/icu-small/source/common/ucnv_lmb.cpp b/deps/icu-small/source/common/ucnv_lmb.cpp index 6dd8e83428a0af..5e7cfde353d7e3 100644 --- a/deps/icu-small/source/common/ucnv_lmb.cpp +++ b/deps/icu-small/source/common/ucnv_lmb.cpp @@ -1107,11 +1107,13 @@ GetUniFromLMBCSUni(char const ** ppLMBCSin) /* Called with LMBCS-style Unicode all input as required by ICU converter semantics. */ -#define CHECK_SOURCE_LIMIT(index) \ - if (args->source+index > args->sourceLimit){\ - *err = U_TRUNCATED_CHAR_FOUND;\ - args->source = args->sourceLimit;\ - return 0xffff;} +#define CHECK_SOURCE_LIMIT(index) UPRV_BLOCK_MACRO_BEGIN { \ + if (args->source+index > args->sourceLimit) { \ + *err = U_TRUNCATED_CHAR_FOUND; \ + args->source = args->sourceLimit; \ + return 0xffff; \ + } \ +} UPRV_BLOCK_MACRO_END /* Return the Unicode representation for the current LMBCS character */ diff --git a/deps/icu-small/source/common/ucnvbocu.cpp b/deps/icu-small/source/common/ucnvbocu.cpp index 5b66c5059a55ba..7c2aab56558c8c 100644 --- a/deps/icu-small/source/common/ucnvbocu.cpp +++ b/deps/icu-small/source/common/ucnvbocu.cpp @@ -202,14 +202,14 @@ bocu1TrailToByte[BOCU1_TRAIL_CONTROLS_COUNT]={ * @param d Divisor. * @param m Output variable for the rest (modulo result). */ -#define NEGDIVMOD(n, d, m) { \ +#define NEGDIVMOD(n, d, m) UPRV_BLOCK_MACRO_BEGIN { \ (m)=(n)%(d); \ (n)/=(d); \ if((m)<0) { \ --(n); \ (m)+=(d); \ } \ -} +} UPRV_BLOCK_MACRO_END /* Faster versions of packDiff() for single-byte-encoded diff values. */ diff --git a/deps/icu-small/source/common/ucnvhz.cpp b/deps/icu-small/source/common/ucnvhz.cpp index 31595374696d8c..b26cf78289dcab 100644 --- a/deps/icu-small/source/common/ucnvhz.cpp +++ b/deps/icu-small/source/common/ucnvhz.cpp @@ -38,7 +38,7 @@ #define ESC_LEN 2 -#define CONCAT_ESCAPE_MACRO( args, targetIndex,targetLength,strToAppend, err, len,sourceIndex){ \ +#define CONCAT_ESCAPE_MACRO(args, targetIndex,targetLength,strToAppend, err, len,sourceIndex) UPRV_BLOCK_MACRO_BEGIN { \ while(len-->0){ \ if(targetIndex < targetLength){ \ args->target[targetIndex] = (unsigned char) *strToAppend; \ @@ -53,7 +53,7 @@ } \ strToAppend++; \ } \ -} +} UPRV_BLOCK_MACRO_END typedef struct{ @@ -518,19 +518,11 @@ _HZ_WriteSub(UConverterFromUnicodeArgs *args, int32_t offsetIndex, UErrorCode *e /* * Structure for cloning an HZ converter into a single memory block. - * ucnv_safeClone() of the HZ converter will align the entire cloneHZStruct, - * and then ucnv_safeClone() of the sub-converter may additionally align - * subCnv inside the cloneHZStruct, for which we need the deadSpace after - * subCnv. This is because UAlignedMemory may be larger than the actually - * necessary alignment size for the platform. - * The other cloneHZStruct fields will not be moved around, - * and are aligned properly with cloneHZStruct's alignment. */ struct cloneHZStruct { UConverter cnv; UConverter subCnv; - UAlignedMemory deadSpace; UConverterDataHZ mydata; }; @@ -545,12 +537,12 @@ _HZ_SafeClone(const UConverter *cnv, int32_t size, bufferSizeNeeded = sizeof(struct cloneHZStruct); if (U_FAILURE(*status)){ - return 0; + return nullptr; } if (*pBufferSize == 0){ /* 'preflighting' request - set needed size into *pBufferSize */ *pBufferSize = bufferSizeNeeded; - return 0; + return nullptr; } localClone = (struct cloneHZStruct *)stackBuffer; @@ -561,7 +553,7 @@ _HZ_SafeClone(const UConverter *cnv, localClone->cnv.isExtraLocal = TRUE; /* deep-clone the sub-converter */ - size = (int32_t)(sizeof(UConverter) + sizeof(UAlignedMemory)); /* include size of padding */ + size = (int32_t)sizeof(UConverter); ((UConverterDataHZ*)localClone->cnv.extraInfo)->gbConverter = ucnv_safeClone(((UConverterDataHZ*)cnv->extraInfo)->gbConverter, &localClone->subCnv, &size, status); diff --git a/deps/icu-small/source/common/ucnvisci.cpp b/deps/icu-small/source/common/ucnvisci.cpp index d0c07f2b27fae9..c1ab06e137ee22 100644 --- a/deps/icu-small/source/common/ucnvisci.cpp +++ b/deps/icu-small/source/common/ucnvisci.cpp @@ -831,7 +831,7 @@ static const uint16_t nuktaSpecialCases[][2]={ }; -#define WRITE_TO_TARGET_FROM_U(args,offsets,source,target,targetLimit,targetByteUnit,err){ \ +#define WRITE_TO_TARGET_FROM_U(args,offsets,source,target,targetLimit,targetByteUnit,err) UPRV_BLOCK_MACRO_BEGIN { \ int32_t offset = (int32_t)(source - args->source-1); \ /* write the targetUniChar to target */ \ if(target < targetLimit){ \ @@ -884,7 +884,7 @@ static const uint16_t nuktaSpecialCases[][2]={ (uint8_t) (targetByteUnit); \ *err = U_BUFFER_OVERFLOW_ERROR; \ } \ -} +} UPRV_BLOCK_MACRO_END /* Rules: * Explicit Halant : @@ -1119,7 +1119,7 @@ static const uint16_t lookupTable[][2]={ { GURMUKHI, PNJ_MASK } }; -#define WRITE_TO_TARGET_TO_U(args,source,target,offsets,offset,targetUniChar,delta, err){\ +#define WRITE_TO_TARGET_TO_U(args,source,target,offsets,offset,targetUniChar,delta, err) UPRV_BLOCK_MACRO_BEGIN { \ /* add offset to current Indic Block */ \ if(targetUniChar>ASCII_END && \ targetUniChar != ZWJ && \ @@ -1140,9 +1140,9 @@ static const uint16_t lookupTable[][2]={ (UChar)targetUniChar; \ *err = U_BUFFER_OVERFLOW_ERROR; \ } \ -} +} UPRV_BLOCK_MACRO_END -#define GET_MAPPING(sourceChar,targetUniChar,data){ \ +#define GET_MAPPING(sourceChar,targetUniChar,data) UPRV_BLOCK_MACRO_BEGIN { \ targetUniChar = toUnicodeTable[(sourceChar)] ; \ /* is the code point valid in current script? */ \ if(sourceChar> ASCII_END && \ @@ -1153,7 +1153,7 @@ static const uint16_t lookupTable[][2]={ targetUniChar=missingCharMarker; \ } \ } \ -} +} UPRV_BLOCK_MACRO_END /*********** * Rules for ISCII to Unicode converter diff --git a/deps/icu-small/source/common/ucnvsel.cpp b/deps/icu-small/source/common/ucnvsel.cpp index 6ccee1ae61fd70..07b55022c346e8 100644 --- a/deps/icu-small/source/common/ucnvsel.cpp +++ b/deps/icu-small/source/common/ucnvsel.cpp @@ -691,36 +691,36 @@ static int16_t countOnes(uint32_t* mask, int32_t len) { /* internal function! */ static UEnumeration *selectForMask(const UConverterSelector* sel, - uint32_t *mask, UErrorCode *status) { + uint32_t *theMask, UErrorCode *status) { + LocalMemory mask(theMask); // this is the context we will use. Store a table of indices to which // encodings are legit. - struct Enumerator* result = (Enumerator*)uprv_malloc(sizeof(Enumerator)); - if (result == NULL) { - uprv_free(mask); + LocalMemory result(static_cast(uprv_malloc(sizeof(Enumerator)))); + if (result.isNull()) { *status = U_MEMORY_ALLOCATION_ERROR; - return NULL; + return nullptr; } - result->index = NULL; // this will be allocated later! + result->index = nullptr; // this will be allocated later! result->length = result->cur = 0; result->sel = sel; - UEnumeration *en = (UEnumeration *)uprv_malloc(sizeof(UEnumeration)); - if (en == NULL) { + LocalMemory en(static_cast(uprv_malloc(sizeof(UEnumeration)))); + if (en.isNull()) { // TODO(markus): Combine Enumerator and UEnumeration into one struct. - uprv_free(mask); - uprv_free(result); *status = U_MEMORY_ALLOCATION_ERROR; - return NULL; + return nullptr; } - memcpy(en, &defaultEncodings, sizeof(UEnumeration)); - en->context = result; + memcpy(en.getAlias(), &defaultEncodings, sizeof(UEnumeration)); int32_t columns = (sel->encodingsCount+31)/32; - int16_t numOnes = countOnes(mask, columns); + int16_t numOnes = countOnes(mask.getAlias(), columns); // now, we know the exact space we need for index if (numOnes > 0) { - result->index = (int16_t*) uprv_malloc(numOnes * sizeof(int16_t)); - + result->index = static_cast(uprv_malloc(numOnes * sizeof(int16_t))); + if (result->index == nullptr) { + *status = U_MEMORY_ALLOCATION_ERROR; + return nullptr; + } int32_t i, j; int16_t k = 0; for (j = 0 ; j < columns; j++) { @@ -734,8 +734,8 @@ static UEnumeration *selectForMask(const UConverterSelector* sel, } } //otherwise, index will remain NULL (and will never be touched by //the enumerator code anyway) - uprv_free(mask); - return en; + en->context = result.orphan(); + return en.orphan(); } /* check a string against the selector - UTF16 version */ diff --git a/deps/icu-small/source/common/ucptrie.cpp b/deps/icu-small/source/common/ucptrie.cpp index b72e318387a186..0004160a238b0e 100644 --- a/deps/icu-small/source/common/ucptrie.cpp +++ b/deps/icu-small/source/common/ucptrie.cpp @@ -280,7 +280,7 @@ UChar32 getRange(const void *t, UChar32 start, int32_t prevI3Block = -1; int32_t prevBlock = -1; UChar32 c = start; - uint32_t trieValue, value; + uint32_t trieValue, value = nullValue; bool haveValue = false; do { int32_t i3Block; diff --git a/deps/icu-small/source/common/ucurr.cpp b/deps/icu-small/source/common/ucurr.cpp index dba3247fef2c98..d42c2f10b1d4c6 100644 --- a/deps/icu-small/source/common/ucurr.cpp +++ b/deps/icu-small/source/common/ucurr.cpp @@ -365,10 +365,7 @@ U_CDECL_END #if !UCONFIG_NO_SERVICE struct CReg; -static UMutex *gCRegLock() { - static UMutex m = U_MUTEX_INITIALIZER; - return &m; -} +static UMutex gCRegLock; static CReg* gCRegHead = 0; struct CReg : public icu::UMemory { @@ -394,14 +391,14 @@ struct CReg : public icu::UMemory { if (status && U_SUCCESS(*status) && _iso && _id) { CReg* n = new CReg(_iso, _id); if (n) { - umtx_lock(gCRegLock()); + umtx_lock(&gCRegLock); if (!gCRegHead) { /* register for the first time */ ucln_common_registerCleanup(UCLN_COMMON_CURRENCY, currency_cleanup); } n->next = gCRegHead; gCRegHead = n; - umtx_unlock(gCRegLock()); + umtx_unlock(&gCRegLock); return n; } *status = U_MEMORY_ALLOCATION_ERROR; @@ -411,7 +408,7 @@ struct CReg : public icu::UMemory { static UBool unreg(UCurrRegistryKey key) { UBool found = FALSE; - umtx_lock(gCRegLock()); + umtx_lock(&gCRegLock); CReg** p = &gCRegHead; while (*p) { @@ -424,13 +421,13 @@ struct CReg : public icu::UMemory { p = &((*p)->next); } - umtx_unlock(gCRegLock()); + umtx_unlock(&gCRegLock); return found; } static const UChar* get(const char* id) { const UChar* result = NULL; - umtx_lock(gCRegLock()); + umtx_lock(&gCRegLock); CReg* p = gCRegHead; /* register cleanup of the mutex */ @@ -442,7 +439,7 @@ struct CReg : public icu::UMemory { } p = p->next; } - umtx_unlock(gCRegLock()); + umtx_unlock(&gCRegLock); return result; } @@ -716,7 +713,9 @@ ucurr_getName(const UChar* currency, // We no longer support choice format data in names. Data should not contain // choice patterns. - *isChoiceFormat = FALSE; + if (isChoiceFormat != NULL) { + *isChoiceFormat = FALSE; + } if (U_SUCCESS(ec2)) { U_ASSERT(s != NULL); return s; @@ -1356,10 +1355,7 @@ static CurrencyNameCacheEntry* currCache[CURRENCY_NAME_CACHE_NUM] = {NULL}; // It is a simple round-robin replacement strategy. static int8_t currentCacheEntryIndex = 0; -static UMutex *gCurrencyCacheMutex() { - static UMutex m = U_MUTEX_INITIALIZER; - return &m; -} +static UMutex gCurrencyCacheMutex; // Cache deletion static void @@ -1408,7 +1404,7 @@ getCacheEntry(const char* locale, UErrorCode& ec) { CurrencyNameStruct* currencySymbols = NULL; CurrencyNameCacheEntry* cacheEntry = NULL; - umtx_lock(gCurrencyCacheMutex()); + umtx_lock(&gCurrencyCacheMutex); // in order to handle racing correctly, // not putting 'search' in a separate function. int8_t found = -1; @@ -1423,13 +1419,13 @@ getCacheEntry(const char* locale, UErrorCode& ec) { cacheEntry = currCache[found]; ++(cacheEntry->refCount); } - umtx_unlock(gCurrencyCacheMutex()); + umtx_unlock(&gCurrencyCacheMutex); if (found == -1) { collectCurrencyNames(locale, ¤cyNames, &total_currency_name_count, ¤cySymbols, &total_currency_symbol_count, ec); if (U_FAILURE(ec)) { return NULL; } - umtx_lock(gCurrencyCacheMutex()); + umtx_lock(&gCurrencyCacheMutex); // check again. for (int8_t i = 0; i < CURRENCY_NAME_CACHE_NUM; ++i) { if (currCache[i]!= NULL && @@ -1468,19 +1464,19 @@ getCacheEntry(const char* locale, UErrorCode& ec) { cacheEntry = currCache[found]; ++(cacheEntry->refCount); } - umtx_unlock(gCurrencyCacheMutex()); + umtx_unlock(&gCurrencyCacheMutex); } return cacheEntry; } static void releaseCacheEntry(CurrencyNameCacheEntry* cacheEntry) { - umtx_lock(gCurrencyCacheMutex()); + umtx_lock(&gCurrencyCacheMutex); --(cacheEntry->refCount); if (cacheEntry->refCount == 0) { // remove deleteCacheEntry(cacheEntry); } - umtx_unlock(gCurrencyCacheMutex()); + umtx_unlock(&gCurrencyCacheMutex); } U_CAPI void @@ -1601,10 +1597,9 @@ uprv_getStaticCurrencyName(const UChar* iso, const char* loc, { U_NAMESPACE_USE - UBool isChoiceFormat; int32_t len; const UChar* currname = ucurr_getName(iso, loc, UCURR_SYMBOL_NAME, - &isChoiceFormat, &len, &ec); + nullptr /* isChoiceFormat */, &len, &ec); if (U_SUCCESS(ec)) { result.setTo(currname, len); } diff --git a/deps/icu-small/source/common/udata.cpp b/deps/icu-small/source/common/udata.cpp index 99efbc97eed737..f2faa82777a233 100644 --- a/deps/icu-small/source/common/udata.cpp +++ b/deps/icu-small/source/common/udata.cpp @@ -33,6 +33,7 @@ might have to #include some other header #include "cstring.h" #include "mutex.h" #include "putilimp.h" +#include "restrace.h" #include "uassert.h" #include "ucln_cmn.h" #include "ucmndata.h" @@ -110,11 +111,12 @@ static u_atomic_int32_t gHaveTriedToLoadCommonData = ATOMIC_INT32_T_INITIALIZER( static UHashtable *gCommonDataCache = NULL; /* Global hash table of opened ICU data files. */ static icu::UInitOnce gCommonDataCacheInitOnce = U_INITONCE_INITIALIZER; -#if U_PLATFORM_HAS_WINUWP_API == 0 +#if !defined(ICU_DATA_DIR_WINDOWS) static UDataFileAccess gDataFileAccess = UDATA_DEFAULT_ACCESS; // Access not synchronized. // Modifying is documented as thread-unsafe. #else -static UDataFileAccess gDataFileAccess = UDATA_NO_FILES; // Windows UWP looks in one spot explicitly +// If we are using the Windows data directory, then look in one spot only. +static UDataFileAccess gDataFileAccess = UDATA_NO_FILES; #endif static UBool U_CALLCONV @@ -206,7 +208,7 @@ setCommonICUData(UDataMemory *pData, /* The new common data. Belongs to ca return didUpdate; } -#if U_PLATFORM_HAS_WINUWP_API == 0 +#if !defined(ICU_DATA_DIR_WINDOWS) static UBool setCommonICUDataPointer(const void *pData, UBool /*warn*/, UErrorCode *pErrorCode) { @@ -320,7 +322,7 @@ static UDataMemory *udata_findCachedData(const char *path, UErrorCode &err) retVal = el->item; } #ifdef UDATA_DEBUG - fprintf(stderr, "Cache: [%s] -> %p\n", baseName, retVal); + fprintf(stderr, "Cache: [%s] -> %p\n", baseName, (void*) retVal); #endif return retVal; } @@ -383,7 +385,7 @@ static UDataMemory *udata_cacheDataItem(const char *path, UDataMemory *item, UEr #ifdef UDATA_DEBUG fprintf(stderr, "Cache: [%s] <<< %p : %s. vFunc=%p\n", newElement->name, - newElement->item, u_errorName(subErr), newElement->item->vFuncs); + (void*) newElement->item, u_errorName(subErr), (void*) newElement->item->vFuncs); #endif if (subErr == U_USING_DEFAULT_WARNING || U_FAILURE(subErr)) { @@ -477,7 +479,7 @@ UDataPathIterator::UDataPathIterator(const char *inPath, const char *pkg, nextPath = itemPath.data(); } #ifdef UDATA_DEBUG - fprintf(stderr, "SUFFIX=%s [%p]\n", inSuffix, inSuffix); + fprintf(stderr, "SUFFIX=%s [%p]\n", inSuffix, (void*) inSuffix); #endif /** Suffix **/ @@ -492,12 +494,11 @@ UDataPathIterator::UDataPathIterator(const char *inPath, const char *pkg, /* pathBuffer will hold the output path strings returned by this iterator */ #ifdef UDATA_DEBUG - fprintf(stderr, "%p: init %s -> [path=%s], [base=%s], [suff=%s], [itempath=%s], [nextpath=%s], [checklast4=%s]\n", - iter, + fprintf(stderr, "0: init %s -> [path=%s], [base=%s], [suff=%s], [itempath=%s], [nextpath=%s], [checklast4=%s]\n", item, path, basename, - suffix, + suffix.data(), itemPath.data(), nextPath, checkLastFour?"TRUE":"false"); @@ -553,7 +554,7 @@ const char *UDataPathIterator::next(UErrorCode *pErrorCode) fprintf(stderr, "rest of path (IDD) = %s\n", currentPath); fprintf(stderr, " "); { - uint32_t qqq; + int32_t qqq; for(qqq=0;qqqpHeader == &U_ICUDATA_ENTRY_POINT) { @@ -714,7 +717,8 @@ openCommonData(const char *path, /* Path from OpenChoice? */ setCommonICUDataPointer(uprv_getICUData_conversion(), FALSE, pErrorCode); } */ -#if U_PLATFORM_HAS_WINUWP_API == 0 // Windows UWP Platform does not support dll icu data at this time +#if !defined(ICU_DATA_DIR_WINDOWS) +// When using the Windows system data, we expect only a single data file. setCommonICUDataPointer(&U_ICUDATA_ENTRY_POINT, FALSE, pErrorCode); { Mutex lock; @@ -831,7 +835,7 @@ static UBool extendICUData(UErrorCode *pErr) * Use a specific mutex to avoid nested locks of the global mutex. */ #if MAP_IMPLEMENTATION==MAP_STDIO - static UMutex extendICUDataMutex = U_MUTEX_INITIALIZER; + static UMutex extendICUDataMutex; umtx_lock(&extendICUDataMutex); #endif if(!umtx_loadAcquire(gHaveTriedToLoadCommonData)) { @@ -1070,13 +1074,13 @@ static UDataMemory *doLoadFromCommonData(UBool isICUData, const char * /*pkgName /* look up the data piece in the common data */ pHeader=pCommonData->vFuncs->Lookup(pCommonData, tocEntryName, &length, subErrorCode); #ifdef UDATA_DEBUG - fprintf(stderr, "%s: pHeader=%p - %s\n", tocEntryName, pHeader, u_errorName(*subErrorCode)); + fprintf(stderr, "%s: pHeader=%p - %s\n", tocEntryName, (void*) pHeader, u_errorName(*subErrorCode)); #endif if(pHeader!=NULL) { pEntryData = checkDataItem(pHeader, isAcceptable, context, type, name, subErrorCode, pErrorCode); #ifdef UDATA_DEBUG - fprintf(stderr, "pEntryData=%p\n", pEntryData); + fprintf(stderr, "pEntryData=%p\n", (void*) pEntryData); #endif if (U_FAILURE(*pErrorCode)) { return NULL; @@ -1168,6 +1172,9 @@ doOpenChoice(const char *path, const char *type, const char *name, UBool isICUData = FALSE; + FileTracer::traceOpen(path, type, name); + + /* Is this path ICU data? */ if(path == NULL || !strcmp(path, U_ICUDATA_ALIAS) || /* "ICUDATA" */ @@ -1276,12 +1283,12 @@ doOpenChoice(const char *path, const char *type, const char *name, fprintf(stderr, " tocEntryPath = %s\n", tocEntryName.data()); #endif -#if U_PLATFORM_HAS_WINUWP_API == 0 // Windows UWP Platform does not support dll icu data at this time +#if !defined(ICU_DATA_DIR_WINDOWS) if(path == NULL) { path = COMMON_DATA_NAME; /* "icudt26e" */ } #else - // Windows UWP expects only a single data file. + // When using the Windows system data, we expects only a single data file. path = COMMON_DATA_NAME; /* "icudt26e" */ #endif diff --git a/deps/icu-small/source/common/uhash.cpp b/deps/icu-small/source/common/uhash.cpp index 79241a282913ed..86311ceb0b25d1 100644 --- a/deps/icu-small/source/common/uhash.cpp +++ b/deps/icu-small/source/common/uhash.cpp @@ -119,13 +119,14 @@ static const float RESIZE_POLICY_RATIO_TABLE[6] = { /* This macro expects a UHashTok.pointer as its keypointer and valuepointer parameters */ -#define HASH_DELETE_KEY_VALUE(hash, keypointer, valuepointer) \ - if (hash->keyDeleter != NULL && keypointer != NULL) { \ - (*hash->keyDeleter)(keypointer); \ - } \ - if (hash->valueDeleter != NULL && valuepointer != NULL) { \ - (*hash->valueDeleter)(valuepointer); \ - } +#define HASH_DELETE_KEY_VALUE(hash, keypointer, valuepointer) UPRV_BLOCK_MACRO_BEGIN { \ + if (hash->keyDeleter != NULL && keypointer != NULL) { \ + (*hash->keyDeleter)(keypointer); \ + } \ + if (hash->valueDeleter != NULL && valuepointer != NULL) { \ + (*hash->valueDeleter)(valuepointer); \ + } \ +} UPRV_BLOCK_MACRO_END /* * Constants for hinting whether a key or value is an integer diff --git a/deps/icu-small/source/common/uidna.cpp b/deps/icu-small/source/common/uidna.cpp index 6d56fcb8f517af..09347efd6d3c39 100644 --- a/deps/icu-small/source/common/uidna.cpp +++ b/deps/icu-small/source/common/uidna.cpp @@ -57,18 +57,16 @@ toASCIILower(UChar ch){ inline static UBool startsWithPrefix(const UChar* src , int32_t srcLength){ - UBool startsWithPrefix = TRUE; - if(srcLength < ACE_PREFIX_LENGTH){ return FALSE; } for(int8_t i=0; i< ACE_PREFIX_LENGTH; i++){ if(toASCIILower(src[i]) != ACE_PREFIX[i]){ - startsWithPrefix = FALSE; + return FALSE; } } - return startsWithPrefix; + return TRUE; } @@ -441,6 +439,7 @@ _internal_toUnicode(const UChar* src, int32_t srcLength, for(int32_t j=0; j 0x7f){ srcIsASCII = FALSE; + break; }/*else if(isLDHChar(src[j])==FALSE){ // here we do not assemble surrogates // since we know that LDH code points diff --git a/deps/icu-small/source/common/uinvchar.cpp b/deps/icu-small/source/common/uinvchar.cpp index 2e0f42d9274d2a..ac9716066f22b7 100644 --- a/deps/icu-small/source/common/uinvchar.cpp +++ b/deps/icu-small/source/common/uinvchar.cpp @@ -207,7 +207,8 @@ u_UCharsToChars(const UChar *us, char *cs, int32_t length) { while(length>0) { u=*us++; if(!UCHAR_IS_INVARIANT(u)) { - UPRV_UNREACHABLE; /* Variant characters were used. These are not portable in ICU. */ + U_ASSERT(FALSE); /* Variant characters were used. These are not portable in ICU. */ + u=0; } *cs++=(char)UCHAR_TO_CHAR(u); --length; @@ -445,6 +446,13 @@ uprv_copyEbcdic(const UDataSwapper *ds, return length; } +U_CFUNC UBool +uprv_isEbcdicAtSign(char c) { + static const uint8_t ebcdicAtSigns[] = { + 0x7C, 0x44, 0x66, 0x80, 0xAC, 0xAE, 0xAF, 0xB5, 0xEC, 0xEF, 0x00 }; + return c != 0 && uprv_strchr((const char *)ebcdicAtSigns, c) != nullptr; +} + /* compare invariant strings; variant characters compare less than others and unlike each other */ U_CFUNC int32_t uprv_compareInvAscii(const UDataSwapper *ds, @@ -561,6 +569,11 @@ uprv_compareInvEbcdicAsAscii(const char *s1, const char *s2) { } } +U_CAPI char U_EXPORT2 +uprv_ebcdicToAscii(char c) { + return (char)asciiFromEbcdic[(uint8_t)c]; +} + U_CAPI char U_EXPORT2 uprv_ebcdicToLowercaseAscii(char c) { return (char)lowercaseAsciiFromEbcdic[(uint8_t)c]; diff --git a/deps/icu-small/source/common/uinvchar.h b/deps/icu-small/source/common/uinvchar.h index 56dddfa8fde9bb..a43cfcd98286fe 100644 --- a/deps/icu-small/source/common/uinvchar.h +++ b/deps/icu-small/source/common/uinvchar.h @@ -68,6 +68,75 @@ uprv_isInvariantUString(const UChar *s, int32_t length); # error Unknown charset family! #endif +#ifdef __cplusplus + +U_NAMESPACE_BEGIN + +/** + * Like U_UPPER_ORDINAL(x) but with validation. + * Returns 0..25 for A..Z else a value outside 0..25. + */ +inline int32_t uprv_upperOrdinal(int32_t c) { +#if U_CHARSET_FAMILY==U_ASCII_FAMILY + return c - 'A'; +#elif U_CHARSET_FAMILY==U_EBCDIC_FAMILY + // EBCDIC: A-Z (26 letters) is split into three ranges A-I (9 letters), J-R (9), S-Z (8). + // https://en.wikipedia.org/wiki/EBCDIC_037#Codepage_layout + if (c <= 'I') { return c - 'A'; } // A-I --> 0-8 + if (c < 'J') { return -1; } + if (c <= 'R') { return c - 'J' + 9; } // J-R --> 9..17 + if (c < 'S') { return -1; } + return c - 'S' + 18; // S-Z --> 18..25 +#else +# error Unknown charset family! +#endif +} + +// Like U_UPPER_ORDINAL(x) but for lowercase and with validation. +// Returns 0..25 for a..z else a value outside 0..25. +inline int32_t uprv_lowerOrdinal(int32_t c) { +#if U_CHARSET_FAMILY==U_ASCII_FAMILY + return c - 'a'; +#elif U_CHARSET_FAMILY==U_EBCDIC_FAMILY + // EBCDIC: a-z (26 letters) is split into three ranges a-i (9 letters), j-r (9), s-z (8). + // https://en.wikipedia.org/wiki/EBCDIC_037#Codepage_layout + if (c <= 'i') { return c - 'a'; } // a-i --> 0-8 + if (c < 'j') { return -1; } + if (c <= 'r') { return c - 'j' + 9; } // j-r --> 9..17 + if (c < 's') { return -1; } + return c - 's' + 18; // s-z --> 18..25 +#else +# error Unknown charset family! +#endif +} + +U_NAMESPACE_END + +#endif + +/** + * Returns true if c == '@' is possible. + * The @ sign is variant, and the @ sign used on one + * EBCDIC machine won't be compiled the same way on other EBCDIC based machines. + * @internal + */ +U_CFUNC UBool +uprv_isEbcdicAtSign(char c); + +/** + * \def uprv_isAtSign + * Returns true if c == '@' is possible. + * For ASCII, checks for exactly '@'. For EBCDIC, calls uprv_isEbcdicAtSign(). + * @internal + */ +#if U_CHARSET_FAMILY==U_ASCII_FAMILY +# define uprv_isAtSign(c) ((c)=='@') +#elif U_CHARSET_FAMILY==U_EBCDIC_FAMILY +# define uprv_isAtSign(c) uprv_isEbcdicAtSign(c) +#else +# error Unknown charset family! +#endif + /** * Compare two EBCDIC invariant-character strings in ASCII order. * @internal @@ -88,6 +157,26 @@ uprv_compareInvEbcdicAsAscii(const char *s1, const char *s2); # error Unknown charset family! #endif +/** + * Converts an EBCDIC invariant character to ASCII. + * @internal + */ +U_INTERNAL char U_EXPORT2 +uprv_ebcdicToAscii(char c); + +/** + * \def uprv_invCharToAscii + * Converts an invariant character to ASCII. + * @internal + */ +#if U_CHARSET_FAMILY==U_ASCII_FAMILY +# define uprv_invCharToAscii(c) (c) +#elif U_CHARSET_FAMILY==U_EBCDIC_FAMILY +# define uprv_invCharToAscii(c) uprv_ebcdicToAscii(c) +#else +# error Unknown charset family! +#endif + /** * Converts an EBCDIC invariant character to lowercase ASCII. * @internal diff --git a/deps/icu-small/source/common/uloc.cpp b/deps/icu-small/source/common/uloc.cpp index 73b43204b814b9..6a9bfcfbff5999 100644 --- a/deps/icu-small/source/common/uloc.cpp +++ b/deps/icu-small/source/common/uloc.cpp @@ -148,7 +148,8 @@ static const char * const LANGUAGES[] = { "mad", "maf", "mag", "mai", "mak", "man", "mas", "mde", "mdf", "mdh", "mdr", "men", "mer", "mfe", "mg", "mga", "mgh", "mgo", "mh", "mi", "mic", "min", "mis", "mk", - "ml", "mn", "mnc", "mni", "moh", "mos", "mr", "mrj", + "ml", "mn", "mnc", "mni", "mo", + "moh", "mos", "mr", "mrj", "ms", "mt", "mua", "mul", "mus", "mwl", "mwr", "mwv", "my", "mye", "myv", "mzn", "na", "nan", "nap", "naq", "nb", "nd", "nds", "ne", @@ -264,7 +265,8 @@ static const char * const LANGUAGES_3[] = { "mad", "maf", "mag", "mai", "mak", "man", "mas", "mde", "mdf", "mdh", "mdr", "men", "mer", "mfe", "mlg", "mga", "mgh", "mgo", "mah", "mri", "mic", "min", "mis", "mkd", - "mal", "mon", "mnc", "mni", "moh", "mos", "mar", "mrj", + "mal", "mon", "mnc", "mni", "mol", + "moh", "mos", "mar", "mrj", "msa", "mlt", "mua", "mul", "mus", "mwl", "mwr", "mwv", "mya", "mye", "myv", "mzn", "nau", "nan", "nap", "naq", "nob", "nde", "nds", "nep", @@ -480,14 +482,15 @@ static const CanonicalizationMap CANONICALIZE_MAP[] = { /* Test if the locale id has BCP47 u extension and does not have '@' */ #define _hasBCP47Extension(id) (id && uprv_strstr(id, "@") == NULL && getShortestSubtagLength(localeID) == 1) /* Converts the BCP47 id to Unicode id. Does nothing to id if conversion fails */ -#define _ConvertBCP47(finalID, id, buffer, length,err) \ - if (uloc_forLanguageTag(id, buffer, length, NULL, err) <= 0 || \ - U_FAILURE(*err) || *err == U_STRING_NOT_TERMINATED_WARNING) { \ - finalID=id; \ - if (*err == U_STRING_NOT_TERMINATED_WARNING) { *err = U_BUFFER_OVERFLOW_ERROR; } \ - } else { \ - finalID=buffer; \ - } +#define _ConvertBCP47(finalID, id, buffer, length,err) UPRV_BLOCK_MACRO_BEGIN { \ + if (uloc_forLanguageTag(id, buffer, length, NULL, err) <= 0 || \ + U_FAILURE(*err) || *err == U_STRING_NOT_TERMINATED_WARNING) { \ + finalID=id; \ + if (*err == U_STRING_NOT_TERMINATED_WARNING) { *err = U_BUFFER_OVERFLOW_ERROR; } \ + } else { \ + finalID=buffer; \ + } \ +} UPRV_BLOCK_MACRO_END /* Gets the size of the shortest subtag in the given localeID. */ static int32_t getShortestSubtagLength(const char *localeID) { int32_t localeIDLength = static_cast(uprv_strlen(localeID)); @@ -1454,31 +1457,29 @@ static const UEnumeration gKeywordsEnum = { U_CAPI UEnumeration* U_EXPORT2 uloc_openKeywordList(const char *keywordList, int32_t keywordListSize, UErrorCode* status) { - UKeywordsContext *myContext = NULL; - UEnumeration *result = NULL; + LocalMemory myContext; + LocalMemory result; - if(U_FAILURE(*status)) { - return NULL; + if (U_FAILURE(*status)) { + return nullptr; } - result = (UEnumeration *)uprv_malloc(sizeof(UEnumeration)); - /* Null pointer test */ - if (result == NULL) { + myContext.adoptInstead(static_cast(uprv_malloc(sizeof(UKeywordsContext)))); + result.adoptInstead(static_cast(uprv_malloc(sizeof(UEnumeration)))); + if (myContext.isNull() || result.isNull()) { *status = U_MEMORY_ALLOCATION_ERROR; - return NULL; + return nullptr; } - uprv_memcpy(result, &gKeywordsEnum, sizeof(UEnumeration)); - myContext = static_cast(uprv_malloc(sizeof(UKeywordsContext))); - if (myContext == NULL) { + uprv_memcpy(result.getAlias(), &gKeywordsEnum, sizeof(UEnumeration)); + myContext->keywords = static_cast(uprv_malloc(keywordListSize+1)); + if (myContext->keywords == nullptr) { *status = U_MEMORY_ALLOCATION_ERROR; - uprv_free(result); - return NULL; + return nullptr; } - myContext->keywords = (char *)uprv_malloc(keywordListSize+1); uprv_memcpy(myContext->keywords, keywordList, keywordListSize); myContext->keywords[keywordListSize] = 0; myContext->current = myContext->keywords; - result->context = myContext; - return result; + result->context = myContext.orphan(); + return result.orphan(); } U_CAPI UEnumeration* U_EXPORT2 diff --git a/deps/icu-small/source/common/uloc_tag.cpp b/deps/icu-small/source/common/uloc_tag.cpp index c732170cb62b9c..8f673541a76504 100644 --- a/deps/icu-small/source/common/uloc_tag.cpp +++ b/deps/icu-small/source/common/uloc_tag.cpp @@ -1558,10 +1558,8 @@ _appendLDMLExtensionAsKeywords(const char* ldmlext, ExtensionListEntry** appendT return; } - if (!_addAttributeToList(&attrFirst, attr)) { - *status = U_ILLEGAL_ARGUMENT_ERROR; - return; - } + // duplicate attribute is ignored, causes no error. + _addAttributeToList(&attrFirst, attr); /* next tag */ pTag += len; diff --git a/deps/icu-small/source/common/umutex.cpp b/deps/icu-small/source/common/umutex.cpp index 20b03d6cd3e416..ccbee9960a39e7 100644 --- a/deps/icu-small/source/common/umutex.cpp +++ b/deps/icu-small/source/common/umutex.cpp @@ -24,6 +24,7 @@ #include "unicode/utypes.h" #include "uassert.h" +#include "ucln_cmn.h" #include "cmemory.h" U_NAMESPACE_BEGIN @@ -35,60 +36,94 @@ U_NAMESPACE_BEGIN #error U_USER_MUTEX_CPP not supported #endif + /************************************************************************************************* * * ICU Mutex wrappers. * *************************************************************************************************/ -// The ICU global mutex. Used when ICU implementation code passes NULL for the mutex pointer. -static UMutex *globalMutex() { - static UMutex m = U_MUTEX_INITIALIZER; - return &m; -} +namespace { +std::mutex *initMutex; +std::condition_variable *initCondition; -U_CAPI void U_EXPORT2 -umtx_lock(UMutex *mutex) { - if (mutex == nullptr) { - mutex = globalMutex(); - } - mutex->fMutex.lock(); -} +// The ICU global mutex. +// Used when ICU implementation code passes nullptr for the mutex pointer. +UMutex globalMutex; +std::once_flag initFlag; +std::once_flag *pInitFlag = &initFlag; -U_CAPI void U_EXPORT2 -umtx_unlock(UMutex* mutex) -{ - if (mutex == nullptr) { - mutex = globalMutex(); - } - mutex->fMutex.unlock(); -} +} // Anonymous namespace -UConditionVar::UConditionVar() : fCV() { +U_CDECL_BEGIN +static UBool U_CALLCONV umtx_cleanup() { + initMutex->~mutex(); + initCondition->~condition_variable(); + UMutex::cleanup(); + + // Reset the once_flag, by destructing it and creating a fresh one in its place. + // Do not use this trick anywhere else in ICU; use umtx_initOnce, not std::call_once(). + pInitFlag->~once_flag(); + pInitFlag = new(&initFlag) std::once_flag(); + return true; } -UConditionVar::~UConditionVar() { +static void U_CALLCONV umtx_init() { + initMutex = STATIC_NEW(std::mutex); + initCondition = STATIC_NEW(std::condition_variable); + ucln_common_registerCleanup(UCLN_COMMON_MUTEX, umtx_cleanup); +} +U_CDECL_END + + +std::mutex *UMutex::getMutex() { + std::mutex *retPtr = fMutex.load(std::memory_order_acquire); + if (retPtr == nullptr) { + std::call_once(*pInitFlag, umtx_init); + std::lock_guard guard(*initMutex); + retPtr = fMutex.load(std::memory_order_acquire); + if (retPtr == nullptr) { + fMutex = new(fStorage) std::mutex(); + retPtr = fMutex; + fListLink = gListHead; + gListHead = this; + } + } + U_ASSERT(retPtr != nullptr); + return retPtr; } -U_CAPI void U_EXPORT2 -umtx_condWait(UConditionVar *cond, UMutex *mutex) { - if (mutex == nullptr) { - mutex = globalMutex(); +UMutex *UMutex::gListHead = nullptr; + +void UMutex::cleanup() { + UMutex *next = nullptr; + for (UMutex *m = gListHead; m != nullptr; m = next) { + (*m->fMutex).~mutex(); + m->fMutex = nullptr; + next = m->fListLink; + m->fListLink = nullptr; } - cond->fCV.wait(mutex->fMutex); + gListHead = nullptr; } -U_CAPI void U_EXPORT2 -umtx_condBroadcast(UConditionVar *cond) { - cond->fCV.notify_all(); +U_CAPI void U_EXPORT2 +umtx_lock(UMutex *mutex) { + if (mutex == nullptr) { + mutex = &globalMutex; + } + mutex->lock(); } -U_CAPI void U_EXPORT2 -umtx_condSignal(UConditionVar *cond) { - cond->fCV.notify_one(); +U_CAPI void U_EXPORT2 +umtx_unlock(UMutex* mutex) +{ + if (mutex == nullptr) { + mutex = &globalMutex; + } + mutex->unlock(); } @@ -98,17 +133,6 @@ umtx_condSignal(UConditionVar *cond) { * *************************************************************************************************/ -static std::mutex &initMutex() { - static std::mutex m; - return m; -} - -static std::condition_variable &initCondition() { - static std::condition_variable cv; - return cv; -} - - // This function is called when a test of a UInitOnce::fState reveals that // initialization has not completed, that we either need to call the init // function on this thread, or wait for some other thread to complete. @@ -119,8 +143,8 @@ static std::condition_variable &initCondition() { // U_COMMON_API UBool U_EXPORT2 umtx_initImplPreInit(UInitOnce &uio) { - std::unique_lock lock(initMutex()); - + std::call_once(*pInitFlag, umtx_init); + std::unique_lock lock(*initMutex); if (umtx_loadAcquire(uio.fState) == 0) { umtx_storeRelease(uio.fState, 1); return true; // Caller will next call the init function. @@ -128,7 +152,7 @@ umtx_initImplPreInit(UInitOnce &uio) { while (umtx_loadAcquire(uio.fState) == 1) { // Another thread is currently running the initialization. // Wait until it completes. - initCondition().wait(lock); + initCondition->wait(lock); } U_ASSERT(uio.fState == 2); return false; @@ -145,10 +169,10 @@ umtx_initImplPreInit(UInitOnce &uio) { U_COMMON_API void U_EXPORT2 umtx_initImplPostInit(UInitOnce &uio) { { - std::unique_lock lock(initMutex()); + std::unique_lock lock(*initMutex); umtx_storeRelease(uio.fState, 2); } - initCondition().notify_all(); + initCondition->notify_all(); } U_NAMESPACE_END diff --git a/deps/icu-small/source/common/umutex.h b/deps/icu-small/source/common/umutex.h index 1674d00bb2d59b..7588bcc5d9aed6 100755 --- a/deps/icu-small/source/common/umutex.h +++ b/deps/icu-small/source/common/umutex.h @@ -23,6 +23,7 @@ #include #include #include +#include #include "unicode/utypes.h" #include "unicode/uclean.h" @@ -36,10 +37,11 @@ #error U_USER_ATOMICS and U_USER_MUTEX_H are not supported #endif - // Export an explicit template instantiation of std::atomic. // When building DLLs for Windows this is required as it is used as a data member of the exported SharedObject class. // See digitlst.h, pluralaffix.h, datefmt.h, and others for similar examples. +// +// Similar story for std::atomic, and the exported UMutex class. #if U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN && !defined(U_IN_DOXYGEN) #if defined(__clang__) || defined(_MSC_VER) #if defined(__clang__) @@ -48,12 +50,14 @@ #pragma clang diagnostic ignored "-Winstantiation-after-specialization" #endif template struct U_COMMON_API std::atomic; +template struct U_COMMON_API std::atomic; #if defined(__clang__) #pragma clang diagnostic pop #endif #elif defined(__GNUC__) // For GCC this class is already exported/visible, so no need for U_COMMON_API. template struct std::atomic; +template struct std::atomic; #endif #endif @@ -180,49 +184,78 @@ template void umtx_initOnce(UInitOnce &uio, void (U_CALLCONV *fp)(T, UE } } +// UMutex should be constexpr-constructible, so that no initialization code +// is run during startup. +// This works on all C++ libraries except MS VS before VS2019. +#if (defined(_CPPLIB_VER) && !defined(_MSVC_STL_VERSION)) || \ + (defined(_MSVC_STL_VERSION) && _MSVC_STL_VERSION < 142) + // (VS std lib older than VS2017) || (VS std lib version < VS2019) +# define UMUTEX_CONSTEXPR +#else +# define UMUTEX_CONSTEXPR constexpr +#endif -/************************************************************************************************* +/** + * UMutex - ICU Mutex class. * - * ICU Mutex wrappers. Originally wrapped operating system mutexes, giving the rest of ICU a - * platform independent set of mutex operations. Now vestigial, wrapping std::mutex only. - * For internal ICU use only. + * This is the preferred Mutex class for use within ICU implementation code. + * It is a thin wrapper over C++ std::mutex, with these additions: + * - Static instances are safe, not triggering static construction or destruction, + * and the associated order of construction or destruction issues. + * - Plumbed into u_cleanup() for destructing the underlying std::mutex, + * which frees any OS level resources they may be holding. * - *************************************************************************************************/ + * Limitations: + * - Static or global instances only. Cannot be heap allocated. Cannot appear as a + * member of another class. + * - No condition variables or other advanced features. If needed, you will need to use + * std::mutex and std::condition_variable directly. For an example, see unifiedcache.cpp + * + * Typical Usage: + * static UMutex myMutex; + * + * { + * Mutex lock(myMutex); + * ... // Do stuff that is protected by myMutex; + * } // myMutex is released when lock goes out of scope. + */ -struct UMutex : public icu::UMemory { - UMutex() = default; +class U_COMMON_API UMutex { +public: + UMUTEX_CONSTEXPR UMutex() {} ~UMutex() = default; + UMutex(const UMutex &other) = delete; UMutex &operator =(const UMutex &other) = delete; + void *operator new(size_t) = delete; - std::mutex fMutex = {}; // Note: struct - pubic members - because most access is from - // // plain C style functions (umtx_lock(), etc.) -}; + // requirements for C++ BasicLockable, allows UMutex to work with std::lock_guard + void lock() { + std::mutex *m = fMutex.load(std::memory_order_acquire); + if (m == nullptr) { m = getMutex(); } + m->lock(); + } + void unlock() { fMutex.load(std::memory_order_relaxed)->unlock(); } + static void cleanup(); -struct UConditionVar : public icu::UMemory { - U_COMMON_API UConditionVar(); - U_COMMON_API ~UConditionVar(); - UConditionVar(const UConditionVar &other) = delete; - UConditionVar &operator =(const UConditionVar &other) = delete; +private: + alignas(std::mutex) char fStorage[sizeof(std::mutex)] {}; + std::atomic fMutex { nullptr }; - std::condition_variable_any fCV; -}; + /** All initialized UMutexes are kept in a linked list, so that they can be found, + * and the underlying std::mutex destructed, by u_cleanup(). + */ + UMutex *fListLink { nullptr }; + static UMutex *gListHead; -#define U_MUTEX_INITIALIZER {} -#define U_CONDITION_INITIALIZER {} + /** Out-of-line function to lazily initialize a UMutex on first use. + * Initial fast check is inline, in lock(). The returned value may never + * be nullptr. + */ + std::mutex *getMutex(); +}; -// Implementation notes for UConditionVar: -// -// Use an out-of-line constructor to reduce problems with the ICU dependency checker. -// On Linux, the default constructor of std::condition_variable_any -// produces an in-line reference to global operator new(), which the -// dependency checker flags for any file that declares a UConditionVar. With -// an out-of-line constructor, the dependency is constrained to umutex.o -// -// Do not export (U_COMMON_API) the entire class, but only the constructor -// and destructor, to avoid Windows build problems with attempting to export the -// std::condition_variable_any. /* Lock a mutex. * @param mutex The given mutex to be locked. Pass NULL to specify @@ -237,30 +270,6 @@ U_INTERNAL void U_EXPORT2 umtx_lock(UMutex* mutex); */ U_INTERNAL void U_EXPORT2 umtx_unlock (UMutex* mutex); -/* - * Wait on a condition variable. - * The calling thread will unlock the mutex and wait on the condition variable. - * The mutex must be locked by the calling thread when invoking this function. - * - * @param cond the condition variable to wait on. - * @param mutex the associated mutex. - */ - -U_INTERNAL void U_EXPORT2 umtx_condWait(UConditionVar *cond, UMutex *mutex); - - -/* - * Broadcast wakeup of all threads waiting on a Condition. - * - * @param cond the condition variable. - */ -U_INTERNAL void U_EXPORT2 umtx_condBroadcast(UConditionVar *cond); - -/* - * Signal a condition variable, waking up one waiting thread. - */ -U_INTERNAL void U_EXPORT2 umtx_condSignal(UConditionVar *cond); - U_NAMESPACE_END diff --git a/deps/icu-small/source/common/unames.cpp b/deps/icu-small/source/common/unames.cpp index 038743004ea589..a28b6ee6036b96 100644 --- a/deps/icu-small/source/common/unames.cpp +++ b/deps/icu-small/source/common/unames.cpp @@ -212,13 +212,13 @@ isDataLoaded(UErrorCode *pErrorCode) { return U_SUCCESS(*pErrorCode); } -#define WRITE_CHAR(buffer, bufferLength, bufferPos, c) { \ +#define WRITE_CHAR(buffer, bufferLength, bufferPos, c) UPRV_BLOCK_MACRO_BEGIN { \ if((bufferLength)>0) { \ *(buffer)++=c; \ --(bufferLength); \ } \ ++(bufferPos); \ -} +} UPRV_BLOCK_MACRO_END #define U_ISO_COMMENT U_CHAR_NAME_CHOICE_COUNT diff --git a/deps/icu-small/source/common/unicode/appendable.h b/deps/icu-small/source/common/unicode/appendable.h index 8512c2f30311b8..4beacaf6583620 100644 --- a/deps/icu-small/source/common/unicode/appendable.h +++ b/deps/icu-small/source/common/unicode/appendable.h @@ -23,6 +23,9 @@ */ #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/uobject.h" U_NAMESPACE_BEGIN @@ -231,4 +234,6 @@ class U_COMMON_API UnicodeStringAppendable : public Appendable { U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __APPENDABLE_H__ diff --git a/deps/icu-small/source/common/unicode/brkiter.h b/deps/icu-small/source/common/unicode/brkiter.h index ac1bf1df29f214..b944497345479b 100644 --- a/deps/icu-small/source/common/unicode/brkiter.h +++ b/deps/icu-small/source/common/unicode/brkiter.h @@ -29,6 +29,10 @@ * \brief C++ API: Break Iterator. */ +#include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #if UCONFIG_NO_BREAK_ITERATION U_NAMESPACE_BEGIN @@ -135,7 +139,7 @@ class U_COMMON_API BreakIterator : public UObject { * method which subclasses implement. * @stable ICU 2.0 */ - virtual BreakIterator* clone(void) const = 0; + virtual BreakIterator* clone() const = 0; /** * Return a polymorphic class ID for this object. Different subclasses @@ -493,6 +497,7 @@ class U_COMMON_API BreakIterator : public UObject { static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale, UnicodeString& name); +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * Deprecated functionality. Use clone() instead. * @@ -515,6 +520,7 @@ class U_COMMON_API BreakIterator : public UObject { virtual BreakIterator * createBufferClone(void *stackBuffer, int32_t &BufferSize, UErrorCode &status) = 0; +#endif // U_FORCE_HIDE_DEPRECATED_API #ifndef U_HIDE_DEPRECATED_API @@ -658,5 +664,7 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_BREAK_ITERATION */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // BRKITER_H //eof diff --git a/deps/icu-small/source/common/unicode/bytestream.h b/deps/icu-small/source/common/unicode/bytestream.h index 61d1e8aca651d7..2c71c248e3dfa0 100644 --- a/deps/icu-small/source/common/unicode/bytestream.h +++ b/deps/icu-small/source/common/unicode/bytestream.h @@ -38,6 +38,9 @@ */ #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/uobject.h" #include "unicode/std_string.h" @@ -267,4 +270,6 @@ class StringByteSink : public ByteSink { U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __BYTESTREAM_H__ diff --git a/deps/icu-small/source/common/unicode/bytestrie.h b/deps/icu-small/source/common/unicode/bytestrie.h index c57b8ccfeb5960..51405f64a10e64 100644 --- a/deps/icu-small/source/common/unicode/bytestrie.h +++ b/deps/icu-small/source/common/unicode/bytestrie.h @@ -23,6 +23,9 @@ */ #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/stringpiece.h" #include "unicode/uobject.h" #include "unicode/ustringtrie.h" @@ -94,6 +97,41 @@ class U_COMMON_API BytesTrie : public UMemory { return *this; } +#ifndef U_HIDE_DRAFT_API + /** + * Returns the state of this trie as a 64-bit integer. + * The state value is never 0. + * + * @return opaque state value + * @see resetToState64 + * @draft ICU 65 + */ + uint64_t getState64() const { + return (static_cast(remainingMatchLength_ + 2) << kState64RemainingShift) | + (uint64_t)(pos_ - bytes_); + } + + /** + * Resets this trie to the saved state. + * Unlike resetToState(State), the 64-bit state value + * must be from getState64() from the same trie object or + * from one initialized the exact same way. + * Because of no validation, this method is faster. + * + * @param state The opaque trie state value from getState64(). + * @return *this + * @see getState64 + * @see resetToState + * @see reset + * @draft ICU 65 + */ + BytesTrie &resetToState64(uint64_t state) { + remainingMatchLength_ = static_cast(state >> kState64RemainingShift) - 2; + pos_ = bytes_ + (state & kState64PosMask); + return *this; + } +#endif /* U_HIDE_DRAFT_API */ + /** * BytesTrie state object, for saving a trie's current state * and resetting the trie back to this state later. @@ -502,6 +540,13 @@ class U_COMMON_API BytesTrie : public UMemory { static const int32_t kMaxTwoByteDelta=((kMinThreeByteDeltaLead-kMinTwoByteDeltaLead)<<8)-1; // 0x2fff static const int32_t kMaxThreeByteDelta=((kFourByteDeltaLead-kMinThreeByteDeltaLead)<<16)-1; // 0xdffff + // For getState64(): + // The remainingMatchLength_ is -1..14=(kMaxLinearMatchLength=0x10)-2 + // so we need at least 5 bits for that. + // We add 2 to store it as a positive value 1..16=kMaxLinearMatchLength. + static constexpr int32_t kState64RemainingShift = 59; + static constexpr uint64_t kState64PosMask = (UINT64_C(1) << kState64RemainingShift) - 1; + uint8_t *ownedArray_; // Fixed value referencing the BytesTrie bytes. @@ -517,4 +562,6 @@ class U_COMMON_API BytesTrie : public UMemory { U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __BYTESTRIE_H__ diff --git a/deps/icu-small/source/common/unicode/bytestriebuilder.h b/deps/icu-small/source/common/unicode/bytestriebuilder.h index b164e3bbd685f7..e58f18755ef959 100644 --- a/deps/icu-small/source/common/unicode/bytestriebuilder.h +++ b/deps/icu-small/source/common/unicode/bytestriebuilder.h @@ -23,6 +23,9 @@ #define __BYTESTRIEBUILDER_H__ #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/bytestrie.h" #include "unicode/stringpiece.h" #include "unicode/stringtriebuilder.h" @@ -179,4 +182,6 @@ class U_COMMON_API BytesTrieBuilder : public StringTrieBuilder { U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __BYTESTRIEBUILDER_H__ diff --git a/deps/icu-small/source/common/unicode/caniter.h b/deps/icu-small/source/common/unicode/caniter.h index b47e35da07bb7f..87c946c2b4db56 100644 --- a/deps/icu-small/source/common/unicode/caniter.h +++ b/deps/icu-small/source/common/unicode/caniter.h @@ -12,6 +12,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + #if !UCONFIG_NO_NORMALIZATION #include "unicode/uobject.h" @@ -207,4 +209,6 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_NORMALIZATION */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/common/unicode/casemap.h b/deps/icu-small/source/common/unicode/casemap.h index 477eb484d136b6..53af84fa74d65f 100644 --- a/deps/icu-small/source/common/unicode/casemap.h +++ b/deps/icu-small/source/common/unicode/casemap.h @@ -8,6 +8,9 @@ #define __CASEMAP_H__ #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/stringpiece.h" #include "unicode/uobject.h" @@ -489,4 +492,6 @@ class U_COMMON_API CaseMap U_FINAL : public UMemory { U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __CASEMAP_H__ diff --git a/deps/icu-small/source/common/unicode/char16ptr.h b/deps/icu-small/source/common/unicode/char16ptr.h index a7c5f1a0c5ed56..c8a9ae6c35d646 100644 --- a/deps/icu-small/source/common/unicode/char16ptr.h +++ b/deps/icu-small/source/common/unicode/char16ptr.h @@ -7,9 +7,12 @@ #ifndef __CHAR16PTR_H__ #define __CHAR16PTR_H__ -#include #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + +#include + /** * \file * \brief C++ API: char16_t pointer wrappers with @@ -305,4 +308,6 @@ inline OldUChar *toOldUCharPtr(char16_t *p) { U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __CHAR16PTR_H__ diff --git a/deps/icu-small/source/common/unicode/chariter.h b/deps/icu-small/source/common/unicode/chariter.h index 292794f6d65832..7e4f446bb0f8a8 100644 --- a/deps/icu-small/source/common/unicode/chariter.h +++ b/deps/icu-small/source/common/unicode/chariter.h @@ -13,6 +13,9 @@ #define CHARITER_H #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/uobject.h" #include "unicode/unistr.h" /** @@ -377,7 +380,7 @@ class U_COMMON_API CharacterIterator : public ForwardCharacterIterator { * @return a pointer to a new CharacterIterator * @stable ICU 2.0 */ - virtual CharacterIterator* clone(void) const = 0; + virtual CharacterIterator* clone() const = 0; /** * Sets the iterator to refer to the first code unit in its @@ -725,4 +728,7 @@ CharacterIterator::getLength(void) const { } U_NAMESPACE_END + +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/common/unicode/dbbi.h b/deps/icu-small/source/common/unicode/dbbi.h index 62509c5227b9da..9031c0b96b1b40 100644 --- a/deps/icu-small/source/common/unicode/dbbi.h +++ b/deps/icu-small/source/common/unicode/dbbi.h @@ -13,6 +13,10 @@ #ifndef DBBI_H #define DBBI_H +#include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/rbbi.h" #if !UCONFIG_NO_BREAK_ITERATION @@ -39,4 +43,6 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_BREAK_ITERATION */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/common/unicode/docmain.h b/deps/icu-small/source/common/unicode/docmain.h index 89906799877622..2b38692997dd9a 100644 --- a/deps/icu-small/source/common/unicode/docmain.h +++ b/deps/icu-small/source/common/unicode/docmain.h @@ -99,7 +99,7 @@ * * * Codepage Conversion - * ucnv.h, ucnvsel.hb + * ucnv.h, ucnvsel.h * C API * * @@ -115,7 +115,7 @@ * * Locales * uloc.h - * icu::Locale, icu::LocaleBuilder + * icu::Locale, icu::LocaleBuilder, icu::LocaleMatcher * * * Resource Bundles diff --git a/deps/icu-small/source/common/unicode/dtintrv.h b/deps/icu-small/source/common/unicode/dtintrv.h index 625456f0c868e9..325faa3ccb92cb 100644 --- a/deps/icu-small/source/common/unicode/dtintrv.h +++ b/deps/icu-small/source/common/unicode/dtintrv.h @@ -15,6 +15,9 @@ #define __DTINTRV_H__ #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/uobject.h" /** @@ -22,7 +25,6 @@ * \brief C++ API: Date Interval data type */ - U_NAMESPACE_BEGIN @@ -157,4 +159,6 @@ DateInterval::operator!=(const DateInterval& other) const { U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/common/unicode/edits.h b/deps/icu-small/source/common/unicode/edits.h index 79e98b0cc27ac6..c3ceaccb3b3802 100644 --- a/deps/icu-small/source/common/unicode/edits.h +++ b/deps/icu-small/source/common/unicode/edits.h @@ -8,6 +8,9 @@ #define __EDITS_H__ #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/uobject.h" /** @@ -159,7 +162,7 @@ class U_COMMON_API Edits U_FINAL : public UMemory { * @return TRUE if U_FAILURE(outErrorCode) * @stable ICU 59 */ - UBool copyErrorTo(UErrorCode &outErrorCode); + UBool copyErrorTo(UErrorCode &outErrorCode) const; /** * How much longer is the new text compared with the old text? @@ -523,4 +526,6 @@ class U_COMMON_API Edits U_FINAL : public UMemory { U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __EDITS_H__ diff --git a/deps/icu-small/source/common/unicode/errorcode.h b/deps/icu-small/source/common/unicode/errorcode.h index 1e5df8f03e88fe..75cdbb6a98f194 100644 --- a/deps/icu-small/source/common/unicode/errorcode.h +++ b/deps/icu-small/source/common/unicode/errorcode.h @@ -26,6 +26,9 @@ */ #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/uobject.h" U_NAMESPACE_BEGIN @@ -136,4 +139,6 @@ class U_COMMON_API ErrorCode: public UMemory { U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __ERRORCODE_H__ diff --git a/deps/icu-small/source/common/unicode/filteredbrk.h b/deps/icu-small/source/common/unicode/filteredbrk.h index 2444114e9a14bf..42936763259e2d 100644 --- a/deps/icu-small/source/common/unicode/filteredbrk.h +++ b/deps/icu-small/source/common/unicode/filteredbrk.h @@ -11,6 +11,9 @@ #define FILTEREDBRK_H #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/brkiter.h" #if !UCONFIG_NO_BREAK_ITERATION && !UCONFIG_NO_FILTERED_BREAK_ITERATION @@ -101,6 +104,7 @@ class U_COMMON_API FilteredBreakIteratorBuilder : public UObject { */ virtual UBool unsuppressBreakAfter(const UnicodeString& string, UErrorCode& status) = 0; +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * This function has been deprecated in favor of wrapIteratorWithFilter() * The behavior is identical. @@ -111,6 +115,7 @@ class U_COMMON_API FilteredBreakIteratorBuilder : public UObject { * @see wrapBreakIteratorWithFilter() */ virtual BreakIterator *build(BreakIterator* adoptBreakIterator, UErrorCode& status) = 0; +#endif // U_FORCE_HIDE_DEPRECATED_API /** * Wrap (adopt) an existing break iterator in a new filtered instance. @@ -142,4 +147,6 @@ U_NAMESPACE_END #endif // #if !UCONFIG_NO_BREAK_ITERATION && !UCONFIG_NO_FILTERED_BREAK_ITERATION +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // #ifndef FILTEREDBRK_H diff --git a/deps/icu-small/source/common/unicode/idna.h b/deps/icu-small/source/common/unicode/idna.h index f08658e502e200..6dfcfe48db28f1 100644 --- a/deps/icu-small/source/common/unicode/idna.h +++ b/deps/icu-small/source/common/unicode/idna.h @@ -24,6 +24,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + #if !UCONFIG_NO_IDNA #include "unicode/bytestream.h" @@ -322,4 +324,7 @@ class U_COMMON_API IDNAInfo : public UMemory { U_NAMESPACE_END #endif // UCONFIG_NO_IDNA + +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __IDNA_H__ diff --git a/deps/icu-small/source/common/unicode/localebuilder.h b/deps/icu-small/source/common/unicode/localebuilder.h index 960e5980c03c2e..19e10f1c070924 100644 --- a/deps/icu-small/source/common/unicode/localebuilder.h +++ b/deps/icu-small/source/common/unicode/localebuilder.h @@ -3,11 +3,14 @@ #ifndef __LOCALEBUILDER_H__ #define __LOCALEBUILDER_H__ +#include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/locid.h" +#include "unicode/localematcher.h" #include "unicode/stringpiece.h" #include "unicode/uobject.h" -#include "unicode/utypes.h" - #ifndef U_HIDE_DRAFT_API /** @@ -276,7 +279,24 @@ class U_COMMON_API LocaleBuilder : public UObject { */ Locale build(UErrorCode& status); +#ifndef U_HIDE_DRAFT_API + /** + * Sets the UErrorCode if an error occurred while recording sets. + * Preserves older error codes in the outErrorCode. + * @param outErrorCode Set to an error code that occurred while setting subtags. + * Unchanged if there is no such error or if outErrorCode + * already contained an error. + * @return TRUE if U_FAILURE(outErrorCode) + * @draft ICU 65 + */ + UBool copyErrorTo(UErrorCode &outErrorCode) const; +#endif /* U_HIDE_DRAFT_API */ + private: + friend class LocaleMatcher::Result; + + void copyExtensionsFrom(const Locale& src, UErrorCode& errorCode); + UErrorCode status_; char language_[9]; char script_[5]; @@ -289,4 +309,7 @@ class U_COMMON_API LocaleBuilder : public UObject { U_NAMESPACE_END #endif // U_HIDE_DRAFT_API + +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __LOCALEBUILDER_H__ diff --git a/deps/icu-small/source/common/unicode/localematcher.h b/deps/icu-small/source/common/unicode/localematcher.h new file mode 100644 index 00000000000000..701123f750b222 --- /dev/null +++ b/deps/icu-small/source/common/unicode/localematcher.h @@ -0,0 +1,605 @@ +// © 2019 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html#License + +// localematcher.h +// created: 2019may08 Markus W. Scherer + +#ifndef __LOCALEMATCHER_H__ +#define __LOCALEMATCHER_H__ + +#include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + +#include "unicode/locid.h" +#include "unicode/stringpiece.h" +#include "unicode/uobject.h" + +/** + * \file + * \brief C++ API: Locale matcher: User's desired locales vs. application's supported locales. + */ + +#ifndef U_HIDE_DRAFT_API + +/** + * Builder option for whether the language subtag or the script subtag is most important. + * + * @see Builder#setFavorSubtag(FavorSubtag) + * @draft ICU 65 + */ +enum ULocMatchFavorSubtag { + /** + * Language differences are most important, then script differences, then region differences. + * (This is the default behavior.) + * + * @draft ICU 65 + */ + ULOCMATCH_FAVOR_LANGUAGE, + /** + * Makes script differences matter relatively more than language differences. + * + * @draft ICU 65 + */ + ULOCMATCH_FAVOR_SCRIPT +}; +#ifndef U_IN_DOXYGEN +typedef enum ULocMatchFavorSubtag ULocMatchFavorSubtag; +#endif + +/** + * Builder option for whether all desired locales are treated equally or + * earlier ones are preferred. + * + * @see Builder#setDemotionPerDesiredLocale(Demotion) + * @draft ICU 65 + */ +enum ULocMatchDemotion { + /** + * All desired locales are treated equally. + * + * @draft ICU 65 + */ + ULOCMATCH_DEMOTION_NONE, + /** + * Earlier desired locales are preferred. + * + *

From each desired locale to the next, + * the distance to any supported locale is increased by an additional amount + * which is at least as large as most region mismatches. + * A later desired locale has to have a better match with some supported locale + * due to more than merely having the same region subtag. + * + *

For example: Supported={en, sv} desired=[en-GB, sv] + * yields Result(en-GB, en) because + * with the demotion of sv its perfect match is no better than + * the region distance between the earlier desired locale en-GB and en=en-US. + * + *

Notes: + *

    + *
  • In some cases, language and/or script differences can be as small as + * the typical region difference. (Example: sr-Latn vs. sr-Cyrl) + *
  • It is possible for certain region differences to be larger than usual, + * and larger than the demotion. + * (As of CLDR 35 there is no such case, but + * this is possible in future versions of the data.) + *
+ * + * @draft ICU 65 + */ + ULOCMATCH_DEMOTION_REGION +}; +#ifndef U_IN_DOXYGEN +typedef enum ULocMatchDemotion ULocMatchDemotion; +#endif + +struct UHashtable; + +U_NAMESPACE_BEGIN + +struct LSR; + +class LocaleDistance; +class LocaleLsrIterator; +class UVector; +class XLikelySubtags; + +/** + * Immutable class that picks the best match between a user's desired locales and + * an application's supported locales. + * Movable but not copyable. + * + *

Example: + *

+ * UErrorCode errorCode = U_ZERO_ERROR;
+ * LocaleMatcher matcher = LocaleMatcher::Builder().setSupportedLocales("fr, en-GB, en").build(errorCode);
+ * Locale *bestSupported = matcher.getBestLocale(Locale.US, errorCode);  // "en"
+ * 
+ * + *

A matcher takes into account when languages are close to one another, + * such as Danish and Norwegian, + * and when regional variants are close, like en-GB and en-AU as opposed to en-US. + * + *

If there are multiple supported locales with the same (language, script, region) + * likely subtags, then the current implementation returns the first of those locales. + * It ignores variant subtags (except for pseudolocale variants) and extensions. + * This may change in future versions. + * + *

For example, the current implementation does not distinguish between + * de, de-DE, de-Latn, de-1901, de-u-co-phonebk. + * + *

If you prefer one equivalent locale over another, then provide only the preferred one, + * or place it earlier in the list of supported locales. + * + *

Otherwise, the order of supported locales may have no effect on the best-match results. + * The current implementation compares each desired locale with supported locales + * in the following order: + * 1. Default locale, if supported; + * 2. CLDR "paradigm locales" like en-GB and es-419; + * 3. other supported locales. + * This may change in future versions. + * + *

Often a product will just need one matcher instance, built with the languages + * that it supports. However, it may want multiple instances with different + * default languages based on additional information, such as the domain. + * + *

This class is not intended for public subclassing. + * + * @draft ICU 65 + */ +class U_COMMON_API LocaleMatcher : public UMemory { +public: + /** + * Data for the best-matching pair of a desired and a supported locale. + * Movable but not copyable. + * + * @draft ICU 65 + */ + class U_COMMON_API Result : public UMemory { + public: + /** + * Move constructor; might modify the source. + * This object will have the same contents that the source object had. + * + * @param src Result to move contents from. + * @draft ICU 65 + */ + Result(Result &&src) U_NOEXCEPT; + + /** + * Destructor. + * + * @draft ICU 65 + */ + ~Result(); + + /** + * Move assignment; might modify the source. + * This object will have the same contents that the source object had. + * + * @param src Result to move contents from. + * @draft ICU 65 + */ + Result &operator=(Result &&src) U_NOEXCEPT; + + /** + * Returns the best-matching desired locale. + * nullptr if the list of desired locales is empty or if none matched well enough. + * + * @return the best-matching desired locale, or nullptr. + * @draft ICU 65 + */ + inline const Locale *getDesiredLocale() const { return desiredLocale; } + + /** + * Returns the best-matching supported locale. + * If none matched well enough, this is the default locale. + * The default locale is nullptr if the list of supported locales is empty and + * no explicit default locale is set. + * + * @return the best-matching supported locale, or nullptr. + * @draft ICU 65 + */ + inline const Locale *getSupportedLocale() const { return supportedLocale; } + + /** + * Returns the index of the best-matching desired locale in the input Iterable order. + * -1 if the list of desired locales is empty or if none matched well enough. + * + * @return the index of the best-matching desired locale, or -1. + * @draft ICU 65 + */ + inline int32_t getDesiredIndex() const { return desiredIndex; } + + /** + * Returns the index of the best-matching supported locale in the + * constructor’s or builder’s input order (“set” Collection plus “added” locales). + * If the matcher was built from a locale list string, then the iteration order is that + * of a LocalePriorityList built from the same string. + * -1 if the list of supported locales is empty or if none matched well enough. + * + * @return the index of the best-matching supported locale, or -1. + * @draft ICU 65 + */ + inline int32_t getSupportedIndex() const { return supportedIndex; } + + /** + * Takes the best-matching supported locale and adds relevant fields of the + * best-matching desired locale, such as the -t- and -u- extensions. + * May replace some fields of the supported locale. + * The result is the locale that should be used for date and number formatting, collation, etc. + * Returns the root locale if getSupportedLocale() returns nullptr. + * + *

Example: desired=ar-SA-u-nu-latn, supported=ar-EG, resolved locale=ar-SA-u-nu-latn + * + * @return a locale combining the best-matching desired and supported locales. + * @draft ICU 65 + */ + Locale makeResolvedLocale(UErrorCode &errorCode) const; + + private: + Result(const Locale *desired, const Locale *supported, + int32_t desIndex, int32_t suppIndex, UBool owned) : + desiredLocale(desired), supportedLocale(supported), + desiredIndex(desIndex), supportedIndex(suppIndex), + desiredIsOwned(owned) {} + + Result(const Result &other) = delete; + Result &operator=(const Result &other) = delete; + + const Locale *desiredLocale; + const Locale *supportedLocale; + int32_t desiredIndex; + int32_t supportedIndex; + UBool desiredIsOwned; + + friend class LocaleMatcher; + }; + + /** + * LocaleMatcher builder. + * Movable but not copyable. + * + * @see LocaleMatcher#builder() + * @draft ICU 65 + */ + class U_COMMON_API Builder : public UMemory { + public: + /** + * Constructs a builder used in chaining parameters for building a LocaleMatcher. + * + * @return a new Builder object + * @draft ICU 65 + */ + Builder() {} + + /** + * Move constructor; might modify the source. + * This builder will have the same contents that the source builder had. + * + * @param src Builder to move contents from. + * @draft ICU 65 + */ + Builder(Builder &&src) U_NOEXCEPT; + + /** + * Destructor. + * + * @draft ICU 65 + */ + ~Builder(); + + /** + * Move assignment; might modify the source. + * This builder will have the same contents that the source builder had. + * + * @param src Builder to move contents from. + * @draft ICU 65 + */ + Builder &operator=(Builder &&src) U_NOEXCEPT; + + /** + * Parses an Accept-Language string + * (RFC 2616 Section 14.4), + * such as "af, en, fr;q=0.9", and sets the supported locales accordingly. + * Allows whitespace in more places but does not allow "*". + * Clears any previously set/added supported locales first. + * + * @param locales the Accept-Language string of locales to set + * @return this Builder object + * @draft ICU 65 + */ + Builder &setSupportedLocalesFromListString(StringPiece locales); + + /** + * Copies the supported locales, preserving iteration order. + * Clears any previously set/added supported locales first. + * Duplicates are allowed, and are not removed. + * + * @param locales the list of locale + * @return this Builder object + * @draft ICU 65 + */ + Builder &setSupportedLocales(Locale::Iterator &locales); + + /** + * Copies the supported locales from the begin/end range, preserving iteration order. + * Clears any previously set/added supported locales first. + * Duplicates are allowed, and are not removed. + * + * Each of the iterator parameter values must be an + * input iterator whose value is convertible to const Locale &. + * + * @param begin Start of range. + * @param end Exclusive end of range. + * @return this Builder object + * @draft ICU 65 + */ + template + Builder &setSupportedLocales(Iter begin, Iter end) { + if (U_FAILURE(errorCode_)) { return *this; } + clearSupportedLocales(); + while (begin != end) { + addSupportedLocale(*begin++); + } + return *this; + } + + /** + * Copies the supported locales from the begin/end range, preserving iteration order. + * Calls the converter to convert each *begin to a Locale or const Locale &. + * Clears any previously set/added supported locales first. + * Duplicates are allowed, and are not removed. + * + * Each of the iterator parameter values must be an + * input iterator whose value is convertible to const Locale &. + * + * @param begin Start of range. + * @param end Exclusive end of range. + * @param converter Converter from *begin to const Locale & or compatible. + * @return this Builder object + * @draft ICU 65 + */ + template + Builder &setSupportedLocalesViaConverter(Iter begin, Iter end, Conv converter) { + if (U_FAILURE(errorCode_)) { return *this; } + clearSupportedLocales(); + while (begin != end) { + addSupportedLocale(converter(*begin++)); + } + return *this; + } + + /** + * Adds another supported locale. + * Duplicates are allowed, and are not removed. + * + * @param locale another locale + * @return this Builder object + * @draft ICU 65 + */ + Builder &addSupportedLocale(const Locale &locale); + + /** + * Sets the default locale; if nullptr, or if it is not set explicitly, + * then the first supported locale is used as the default locale. + * + * @param defaultLocale the default locale (will be copied) + * @return this Builder object + * @draft ICU 65 + */ + Builder &setDefaultLocale(const Locale *defaultLocale); + + /** + * If ULOCMATCH_FAVOR_SCRIPT, then the language differences are smaller than script + * differences. + * This is used in situations (such as maps) where + * it is better to fall back to the same script than a similar language. + * + * @param subtag the subtag to favor + * @return this Builder object + * @draft ICU 65 + */ + Builder &setFavorSubtag(ULocMatchFavorSubtag subtag); + + /** + * Option for whether all desired locales are treated equally or + * earlier ones are preferred (this is the default). + * + * @param demotion the demotion per desired locale to set. + * @return this Builder object + * @draft ICU 65 + */ + Builder &setDemotionPerDesiredLocale(ULocMatchDemotion demotion); + + /** + * Sets the UErrorCode if an error occurred while setting parameters. + * Preserves older error codes in the outErrorCode. + * + * @param outErrorCode Set to an error code if it does not contain one already + * and an error occurred while setting parameters. + * Otherwise unchanged. + * @return TRUE if U_FAILURE(outErrorCode) + * @draft ICU 65 + */ + UBool copyErrorTo(UErrorCode &outErrorCode) const; + + /** + * Builds and returns a new locale matcher. + * This builder can continue to be used. + * + * @param errorCode ICU error code. Its input value must pass the U_SUCCESS() test, + * or else the function returns immediately. Check for U_FAILURE() + * on output or use with function chaining. (See User Guide for details.) + * @return new LocaleMatcher. + * @draft ICU 65 + */ + LocaleMatcher build(UErrorCode &errorCode) const; + + private: + friend class LocaleMatcher; + + Builder(const Builder &other) = delete; + Builder &operator=(const Builder &other) = delete; + + void clearSupportedLocales(); + bool ensureSupportedLocaleVector(); + + UErrorCode errorCode_ = U_ZERO_ERROR; + UVector *supportedLocales_ = nullptr; + int32_t thresholdDistance_ = -1; + ULocMatchDemotion demotion_ = ULOCMATCH_DEMOTION_REGION; + Locale *defaultLocale_ = nullptr; + ULocMatchFavorSubtag favor_ = ULOCMATCH_FAVOR_LANGUAGE; + }; + + // FYI No public LocaleMatcher constructors in C++; use the Builder. + + /** + * Move copy constructor; might modify the source. + * This matcher will have the same settings that the source matcher had. + * @param src source matcher + * @draft ICU 65 + */ + LocaleMatcher(LocaleMatcher &&src) U_NOEXCEPT; + + /** + * Destructor. + * @draft ICU 65 + */ + ~LocaleMatcher(); + + /** + * Move assignment operator; might modify the source. + * This matcher will have the same settings that the source matcher had. + * The behavior is undefined if *this and src are the same object. + * @param src source matcher + * @return *this + * @draft ICU 65 + */ + LocaleMatcher &operator=(LocaleMatcher &&src) U_NOEXCEPT; + + /** + * Returns the supported locale which best matches the desired locale. + * + * @param desiredLocale Typically a user's language. + * @param errorCode ICU error code. Its input value must pass the U_SUCCESS() test, + * or else the function returns immediately. Check for U_FAILURE() + * on output or use with function chaining. (See User Guide for details.) + * @return the best-matching supported locale. + * @draft ICU 65 + */ + const Locale *getBestMatch(const Locale &desiredLocale, UErrorCode &errorCode) const; + + /** + * Returns the supported locale which best matches one of the desired locales. + * + * @param desiredLocales Typically a user's languages, in order of preference (descending). + * @param errorCode ICU error code. Its input value must pass the U_SUCCESS() test, + * or else the function returns immediately. Check for U_FAILURE() + * on output or use with function chaining. (See User Guide for details.) + * @return the best-matching supported locale. + * @draft ICU 65 + */ + const Locale *getBestMatch(Locale::Iterator &desiredLocales, UErrorCode &errorCode) const; + + /** + * Parses an Accept-Language string + * (RFC 2616 Section 14.4), + * such as "af, en, fr;q=0.9", + * and returns the supported locale which best matches one of the desired locales. + * Allows whitespace in more places but does not allow "*". + * + * @param desiredLocaleList Typically a user's languages, as an Accept-Language string. + * @param errorCode ICU error code. Its input value must pass the U_SUCCESS() test, + * or else the function returns immediately. Check for U_FAILURE() + * on output or use with function chaining. (See User Guide for details.) + * @return the best-matching supported locale. + * @draft ICU 65 + */ + const Locale *getBestMatchForListString(StringPiece desiredLocaleList, UErrorCode &errorCode) const; + + /** + * Returns the best match between the desired locale and the supported locales. + * If the result's desired locale is not nullptr, then it is the address of the input locale. + * It has not been cloned. + * + * @param desiredLocale Typically a user's language. + * @param errorCode ICU error code. Its input value must pass the U_SUCCESS() test, + * or else the function returns immediately. Check for U_FAILURE() + * on output or use with function chaining. (See User Guide for details.) + * @return the best-matching pair of the desired and a supported locale. + * @draft ICU 65 + */ + Result getBestMatchResult(const Locale &desiredLocale, UErrorCode &errorCode) const; + + /** + * Returns the best match between the desired and supported locales. + * If the result's desired locale is not nullptr, then it is a clone of + * the best-matching desired locale. The Result object owns the clone. + * + * @param desiredLocales Typically a user's languages, in order of preference (descending). + * @param errorCode ICU error code. Its input value must pass the U_SUCCESS() test, + * or else the function returns immediately. Check for U_FAILURE() + * on output or use with function chaining. (See User Guide for details.) + * @return the best-matching pair of a desired and a supported locale. + * @draft ICU 65 + */ + Result getBestMatchResult(Locale::Iterator &desiredLocales, UErrorCode &errorCode) const; + +#ifndef U_HIDE_INTERNAL_API + /** + * Returns a fraction between 0 and 1, where 1 means that the languages are a + * perfect match, and 0 means that they are completely different. + * + *

This is mostly an implementation detail, and the precise values may change over time. + * The implementation may use either the maximized forms or the others ones, or both. + * The implementation may or may not rely on the forms to be consistent with each other. + * + *

Callers should construct and use a matcher rather than match pairs of locales directly. + * + * @param desired Desired locale. + * @param supported Supported locale. + * @param errorCode ICU error code. Its input value must pass the U_SUCCESS() test, + * or else the function returns immediately. Check for U_FAILURE() + * on output or use with function chaining. (See User Guide for details.) + * @return value between 0 and 1, inclusive. + * @internal (has a known user) + */ + double internalMatch(const Locale &desired, const Locale &supported, UErrorCode &errorCode) const; +#endif // U_HIDE_INTERNAL_API + +private: + LocaleMatcher(const Builder &builder, UErrorCode &errorCode); + LocaleMatcher(const LocaleMatcher &other) = delete; + LocaleMatcher &operator=(const LocaleMatcher &other) = delete; + + int32_t getBestSuppIndex(LSR desiredLSR, LocaleLsrIterator *remainingIter, UErrorCode &errorCode) const; + + const XLikelySubtags &likelySubtags; + const LocaleDistance &localeDistance; + int32_t thresholdDistance; + int32_t demotionPerDesiredLocale; + ULocMatchFavorSubtag favorSubtag; + + // These are in input order. + const Locale ** supportedLocales; + LSR *lsrs; + int32_t supportedLocalesLength; + // These are in preference order: 1. Default locale 2. paradigm locales 3. others. + UHashtable *supportedLsrToIndex; // Map stores index+1 because 0 is "not found" + // Array versions of the supportedLsrToIndex keys and values. + // The distance lookup loops over the supportedLSRs and returns the index of the best match. + const LSR **supportedLSRs; + int32_t *supportedIndexes; + int32_t supportedLSRsLength; + Locale *ownedDefaultLocale; + const Locale *defaultLocale; + int32_t defaultLocaleIndex; +}; + +U_NAMESPACE_END + +#endif // U_HIDE_DRAFT_API +#endif // U_SHOW_CPLUSPLUS_API +#endif // __LOCALEMATCHER_H__ diff --git a/deps/icu-small/source/common/unicode/locdspnm.h b/deps/icu-small/source/common/unicode/locdspnm.h index f6e778356feced..4f06f857044c6e 100644 --- a/deps/icu-small/source/common/unicode/locdspnm.h +++ b/deps/icu-small/source/common/unicode/locdspnm.h @@ -12,6 +12,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** * \file * \brief C++ API: Provides display names of Locale and its components. @@ -204,4 +206,6 @@ U_NAMESPACE_END #endif +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/common/unicode/locid.h b/deps/icu-small/source/common/unicode/locid.h index 7350e381ffa540..6fb0897fc05d95 100644 --- a/deps/icu-small/source/common/unicode/locid.h +++ b/deps/icu-small/source/common/unicode/locid.h @@ -31,11 +31,14 @@ #ifndef LOCID_H #define LOCID_H +#include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/bytestream.h" #include "unicode/localpointer.h" #include "unicode/strenum.h" #include "unicode/stringpiece.h" -#include "unicode/utypes.h" #include "unicode/uobject.h" #include "unicode/putil.h" #include "unicode/uloc.h" @@ -284,16 +287,14 @@ class U_COMMON_API Locale : public UObject { */ Locale(const Locale& other); -#ifndef U_HIDE_DRAFT_API /** * Move constructor; might leave source in bogus state. * This locale will have the same contents that the source locale had. * * @param other The Locale object being moved in. - * @draft ICU 63 + * @stable ICU 63 */ Locale(Locale&& other) U_NOEXCEPT; -#endif // U_HIDE_DRAFT_API /** * Destructor @@ -310,7 +311,6 @@ class U_COMMON_API Locale : public UObject { */ Locale& operator=(const Locale& other); -#ifndef U_HIDE_DRAFT_API /** * Move assignment operator; might leave source in bogus state. * This locale will have the same contents that the source locale had. @@ -318,10 +318,9 @@ class U_COMMON_API Locale : public UObject { * * @param other The Locale object being moved in. * @return *this - * @draft ICU 63 + * @stable ICU 63 */ Locale& operator=(Locale&& other) U_NOEXCEPT; -#endif // U_HIDE_DRAFT_API /** * Checks if two locale keys are the same. @@ -389,7 +388,6 @@ class U_COMMON_API Locale : public UObject { UErrorCode& success); #endif /* U_HIDE_SYSTEM_API */ -#ifndef U_HIDE_DRAFT_API /** * Returns a Locale for the specified BCP47 language tag string. * If the specified language tag contains any ill-formed subtags, @@ -405,7 +403,7 @@ class U_COMMON_API Locale : public UObject { * @param tag the input BCP47 language tag. * @param status error information if creating the Locale failed. * @return the Locale for the specified BCP47 language tag. - * @draft ICU 63 + * @stable ICU 63 */ static Locale U_EXPORT2 forLanguageTag(StringPiece tag, UErrorCode& status); @@ -420,7 +418,7 @@ class U_COMMON_API Locale : public UObject { * @param sink the output sink receiving the BCP47 language * tag for this Locale. * @param status error information if creating the language tag failed. - * @draft ICU 63 + * @stable ICU 63 */ void toLanguageTag(ByteSink& sink, UErrorCode& status) const; @@ -432,11 +430,10 @@ class U_COMMON_API Locale : public UObject { * * @param status error information if creating the language tag failed. * @return the BCP47 language tag for this Locale. - * @draft ICU 63 + * @stable ICU 63 */ template inline StringClass toLanguageTag(UErrorCode& status) const; -#endif // U_HIDE_DRAFT_API /** * Creates a locale which has had minimal canonicalization @@ -508,7 +505,6 @@ class U_COMMON_API Locale : public UObject { */ const char * getBaseName() const; -#ifndef U_HIDE_DRAFT_API /** * Add the likely subtags for this Locale, per the algorithm described * in the following CLDR technical report: @@ -536,7 +532,7 @@ class U_COMMON_API Locale : public UObject { * @param status error information if maximizing this Locale failed. * If this Locale is not well-formed, the error code is * U_ILLEGAL_ARGUMENT_ERROR. - * @draft ICU 63 + * @stable ICU 63 */ void addLikelySubtags(UErrorCode& status); @@ -567,10 +563,9 @@ class U_COMMON_API Locale : public UObject { * @param status error information if maximizing this Locale failed. * If this Locale is not well-formed, the error code is * U_ILLEGAL_ARGUMENT_ERROR. - * @draft ICU 63 + * @stable ICU 63 */ void minimizeSubtags(UErrorCode& status); -#endif // U_HIDE_DRAFT_API /** * Gets the list of keywords for the specified locale. @@ -583,8 +578,6 @@ class U_COMMON_API Locale : public UObject { */ StringEnumeration * createKeywords(UErrorCode &status) const; -#ifndef U_HIDE_DRAFT_API - /** * Gets the list of Unicode keywords for the specified locale. * @@ -592,7 +585,7 @@ class U_COMMON_API Locale : public UObject { * @return pointer to StringEnumeration class, or NULL if there are no keywords. * Client must dispose of it by calling delete. * @see getUnicodeKeywords - * @draft ICU 63 + * @stable ICU 63 */ StringEnumeration * createUnicodeKeywords(UErrorCode &status) const; @@ -605,7 +598,7 @@ class U_COMMON_API Locale : public UObject { * * @param iterator an STL style output iterator to write the keywords to. * @param status error information if creating set of keywords failed. - * @draft ICU 63 + * @stable ICU 63 */ template inline void getKeywords(OutputIterator iterator, UErrorCode& status) const; @@ -619,13 +612,11 @@ class U_COMMON_API Locale : public UObject { * * @param iterator an STL style output iterator to write the keywords to. * @param status error information if creating set of keywords failed. - * @draft ICU 63 + * @stable ICU 63 */ template inline void getUnicodeKeywords(OutputIterator iterator, UErrorCode& status) const; -#endif // U_HIDE_DRAFT_API - /** * Gets the value for a keyword. * @@ -644,7 +635,6 @@ class U_COMMON_API Locale : public UObject { */ int32_t getKeywordValue(const char* keywordName, char *buffer, int32_t bufferCapacity, UErrorCode &status) const; -#ifndef U_HIDE_DRAFT_API /** * Gets the value for a keyword. * @@ -656,7 +646,7 @@ class U_COMMON_API Locale : public UObject { * @param keywordName name of the keyword for which we want the value. * @param sink the sink to receive the keyword value. * @param status error information if getting the value failed. - * @draft ICU 63 + * @stable ICU 63 */ void getKeywordValue(StringPiece keywordName, ByteSink& sink, UErrorCode& status) const; @@ -671,7 +661,7 @@ class U_COMMON_API Locale : public UObject { * @param keywordName name of the keyword for which we want the value. * @param status error information if getting the value failed. * @return the keyword value. - * @draft ICU 63 + * @stable ICU 63 */ template inline StringClass getKeywordValue(StringPiece keywordName, UErrorCode& status) const; @@ -687,7 +677,7 @@ class U_COMMON_API Locale : public UObject { * @param keywordName name of the keyword for which we want the value. * @param sink the sink to receive the keyword value. * @param status error information if getting the value failed. - * @draft ICU 63 + * @stable ICU 63 */ void getUnicodeKeywordValue(StringPiece keywordName, ByteSink& sink, UErrorCode& status) const; @@ -702,11 +692,10 @@ class U_COMMON_API Locale : public UObject { * @param keywordName name of the keyword for which we want the value. * @param status error information if getting the value failed. * @return the keyword value. - * @draft ICU 63 + * @stable ICU 63 */ template inline StringClass getUnicodeKeywordValue(StringPiece keywordName, UErrorCode& status) const; -#endif // U_HIDE_DRAFT_API /** * Sets or removes the value for a keyword. @@ -729,7 +718,6 @@ class U_COMMON_API Locale : public UObject { */ void setKeywordValue(const char* keywordName, const char* keywordValue, UErrorCode &status); -#ifndef U_HIDE_DRAFT_API /** * Sets or removes the value for a keyword. * @@ -746,7 +734,7 @@ class U_COMMON_API Locale : public UObject { * NULL, will result in the keyword being removed. No error is given if * that keyword does not exist. * @param status Returns any error information while performing this operation. - * @draft ICU 63 + * @stable ICU 63 */ void setKeywordValue(StringPiece keywordName, StringPiece keywordValue, UErrorCode& status); @@ -766,10 +754,9 @@ class U_COMMON_API Locale : public UObject { * NULL, will result in the keyword being removed. No error is given if * that keyword does not exist. * @param status Returns any error information while performing this operation. - * @draft ICU 63 + * @stable ICU 63 */ void setUnicodeKeywordValue(StringPiece keywordName, StringPiece keywordValue, UErrorCode& status); -#endif // U_HIDE_DRAFT_API /** * returns the locale's three-letter language code, as specified @@ -1008,6 +995,104 @@ class U_COMMON_API Locale : public UObject { */ virtual UClassID getDynamicClassID() const; +#ifndef U_HIDE_DRAFT_API + /** + * A Locale iterator interface similar to a Java Iterator. + * @draft ICU 65 + */ + class U_COMMON_API Iterator /* not : public UObject because this is an interface/mixin class */ { + public: + /** @draft ICU 65 */ + virtual ~Iterator(); + + /** + * @return TRUE if next() can be called again. + * @draft ICU 65 + */ + virtual UBool hasNext() const = 0; + + /** + * @return the next locale. + * @draft ICU 65 + */ + virtual const Locale &next() = 0; + }; + + /** + * A generic Locale iterator implementation over Locale input iterators. + * @draft ICU 65 + */ + template + class RangeIterator : public Iterator, public UMemory { + public: + /** + * Constructs an iterator from a begin/end range. + * Each of the iterator parameter values must be an + * input iterator whose value is convertible to const Locale &. + * + * @param begin Start of range. + * @param end Exclusive end of range. + * @draft ICU 65 + */ + RangeIterator(Iter begin, Iter end) : it_(begin), end_(end) {} + + /** + * @return TRUE if next() can be called again. + * @draft ICU 65 + */ + UBool hasNext() const override { return it_ != end_; } + + /** + * @return the next locale. + * @draft ICU 65 + */ + const Locale &next() override { return *it_++; } + + private: + Iter it_; + const Iter end_; + }; + + /** + * A generic Locale iterator implementation over Locale input iterators. + * Calls the converter to convert each *begin to a const Locale &. + * @draft ICU 65 + */ + template + class ConvertingIterator : public Iterator, public UMemory { + public: + /** + * Constructs an iterator from a begin/end range. + * Each of the iterator parameter values must be an + * input iterator whose value the converter converts to const Locale &. + * + * @param begin Start of range. + * @param end Exclusive end of range. + * @param converter Converter from *begin to const Locale & or compatible. + * @draft ICU 65 + */ + ConvertingIterator(Iter begin, Iter end, Conv converter) : + it_(begin), end_(end), converter_(converter) {} + + /** + * @return TRUE if next() can be called again. + * @draft ICU 65 + */ + UBool hasNext() const override { return it_ != end_; } + + /** + * @return the next locale. + * @draft ICU 65 + */ + const Locale &next() override { return converter_(*it_++); } + + private: + Iter it_; + const Iter end_; + Conv converter_; + }; +#endif // U_HIDE_DRAFT_API + protected: /* only protected for testing purposes. DO NOT USE. */ #ifndef U_HIDE_INTERNAL_API /** @@ -1074,7 +1159,6 @@ Locale::operator!=(const Locale& other) const return !operator==(other); } -#ifndef U_HIDE_DRAFT_API template inline StringClass Locale::toLanguageTag(UErrorCode& status) const { @@ -1083,7 +1167,6 @@ Locale::toLanguageTag(UErrorCode& status) const toLanguageTag(sink, status); return result; } -#endif // U_HIDE_DRAFT_API inline const char * Locale::getCountry() const @@ -1115,13 +1198,11 @@ Locale::getName() const return fullName; } -#ifndef U_HIDE_DRAFT_API - template inline void Locale::getKeywords(OutputIterator iterator, UErrorCode& status) const { LocalPointer keys(createKeywords(status)); - if (U_FAILURE(status)) { + if (U_FAILURE(status) || keys.isNull()) { return; } for (;;) { @@ -1138,7 +1219,7 @@ template inline void Locale::getUnicodeKeywords(OutputIterator iterator, UErrorCode& status) const { LocalPointer keys(createUnicodeKeywords(status)); - if (U_FAILURE(status)) { + if (U_FAILURE(status) || keys.isNull()) { return; } for (;;) { @@ -1169,8 +1250,6 @@ Locale::getUnicodeKeywordValue(StringPiece keywordName, UErrorCode& status) cons return result; } -#endif // U_HIDE_DRAFT_API - inline UBool Locale::isBogus(void) const { return fIsBogus; @@ -1178,4 +1257,6 @@ Locale::isBogus(void) const { U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/common/unicode/messagepattern.h b/deps/icu-small/source/common/unicode/messagepattern.h index 9f2a86551ca417..04f00a8757d783 100644 --- a/deps/icu-small/source/common/unicode/messagepattern.h +++ b/deps/icu-small/source/common/unicode/messagepattern.h @@ -24,6 +24,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + #if !UCONFIG_NO_FORMATTING #include "unicode/parseerr.h" @@ -942,4 +944,6 @@ U_NAMESPACE_END #endif // !UCONFIG_NO_FORMATTING +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __MESSAGEPATTERN_H__ diff --git a/deps/icu-small/source/common/unicode/normalizer2.h b/deps/icu-small/source/common/unicode/normalizer2.h index 4caa0e31034b2d..4aeb3bb3d82921 100644 --- a/deps/icu-small/source/common/unicode/normalizer2.h +++ b/deps/icu-small/source/common/unicode/normalizer2.h @@ -26,6 +26,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + #if !UCONFIG_NO_NORMALIZATION #include "unicode/stringpiece.h" @@ -771,4 +773,7 @@ class U_COMMON_API FilteredNormalizer2 : public Normalizer2 { U_NAMESPACE_END #endif // !UCONFIG_NO_NORMALIZATION + +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __NORMALIZER2_H__ diff --git a/deps/icu-small/source/common/unicode/normlzr.h b/deps/icu-small/source/common/unicode/normlzr.h index 82335ae6d7d19b..00dd820474f734 100644 --- a/deps/icu-small/source/common/unicode/normlzr.h +++ b/deps/icu-small/source/common/unicode/normlzr.h @@ -13,6 +13,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** * \file * \brief C++ API: Unicode Normalization @@ -183,6 +185,7 @@ class U_COMMON_API Normalizer : public UObject { Normalizer(const CharacterIterator& iter, UNormalizationMode mode); #endif /* U_HIDE_DEPRECATED_API */ +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * Copy constructor. * @param copy The object to be copied. @@ -195,7 +198,7 @@ class U_COMMON_API Normalizer : public UObject { * @deprecated ICU 56 Use Normalizer2 instead. */ virtual ~Normalizer(); - +#endif // U_FORCE_HIDE_DEPRECATED_API //------------------------------------------------------------------------- // Static utility methods @@ -599,7 +602,7 @@ class U_COMMON_API Normalizer : public UObject { * @return a pointer to a new Normalizer * @deprecated ICU 56 Use Normalizer2 instead. */ - Normalizer* clone(void) const; + Normalizer* clone() const; /** * Generates a hash code for this iterator. @@ -723,12 +726,14 @@ class U_COMMON_API Normalizer : public UObject { static UClassID U_EXPORT2 getStaticClassID(); #endif /* U_HIDE_DEPRECATED_API */ +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * ICU "poor man's RTTI", returns a UClassID for the actual class. * @return a UClassID for the actual class. * @deprecated ICU 56 Use Normalizer2 instead. */ virtual UClassID getDynamicClassID() const; +#endif // U_FORCE_HIDE_DEPRECATED_API private: //------------------------------------------------------------------------- @@ -807,3 +812,5 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_NORMALIZATION */ #endif // NORMLZR_H + +#endif /* U_SHOW_CPLUSPLUS_API */ diff --git a/deps/icu-small/source/common/unicode/parsepos.h b/deps/icu-small/source/common/unicode/parsepos.h index c02c8169565738..ae5754b8d75132 100644 --- a/deps/icu-small/source/common/unicode/parsepos.h +++ b/deps/icu-small/source/common/unicode/parsepos.h @@ -19,6 +19,9 @@ #define PARSEPOS_H #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/uobject.h" @@ -229,4 +232,6 @@ ParsePosition::setErrorIndex(int32_t ei) } U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/common/unicode/platform.h b/deps/icu-small/source/common/unicode/platform.h index ee0d8b7a000303..74689d790cf79a 100644 --- a/deps/icu-small/source/common/unicode/platform.h +++ b/deps/icu-small/source/common/unicode/platform.h @@ -135,6 +135,14 @@ /** Fuchsia is a POSIX-ish platform. @internal */ #define U_PF_FUCHSIA 4100 /* Maximum value for Linux-based platform is 4499 */ +/** + * Emscripten is a C++ transpiler for the Web that can target asm.js or + * WebAssembly. It provides some POSIX-compatible wrappers and stubs and + * some Linux-like functionality, but is not fully compatible with + * either. + * @internal + */ +#define U_PF_EMSCRIPTEN 5010 /** z/OS is the successor to OS/390 which was the successor to MVS. @internal */ #define U_PF_OS390 9000 /** "IBM i" is the current name of what used to be i5/OS and earlier OS/400. @internal */ @@ -192,6 +200,8 @@ # define U_PLATFORM U_PF_OS390 #elif defined(__OS400__) || defined(__TOS_OS400__) # define U_PLATFORM U_PF_OS400 +#elif defined(__EMSCRIPTEN__) +# define U_PLATFORM U_PF_EMSCRIPTEN #else # define U_PLATFORM U_PF_UNKNOWN #endif @@ -414,26 +424,40 @@ #endif /* Compatibility with compilers other than clang: http://clang.llvm.org/docs/LanguageExtensions.html */ -#ifndef __has_attribute -# define __has_attribute(x) 0 +#ifdef __has_attribute +# define UPRV_HAS_ATTRIBUTE(x) __has_attribute(x) +#else +# define UPRV_HAS_ATTRIBUTE(x) 0 #endif -#ifndef __has_cpp_attribute -# define __has_cpp_attribute(x) 0 +#ifdef __has_cpp_attribute +# define UPRV_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x) +#else +# define UPRV_HAS_CPP_ATTRIBUTE(x) 0 #endif -#ifndef __has_declspec_attribute -# define __has_declspec_attribute(x) 0 +#ifdef __has_declspec_attribute +# define UPRV_HAS_DECLSPEC_ATTRIBUTE(x) __has_declspec_attribute(x) +#else +# define UPRV_HAS_DECLSPEC_ATTRIBUTE(x) 0 #endif -#ifndef __has_builtin -# define __has_builtin(x) 0 +#ifdef __has_builtin +# define UPRV_HAS_BUILTIN(x) __has_builtin(x) +#else +# define UPRV_HAS_BUILTIN(x) 0 #endif -#ifndef __has_feature -# define __has_feature(x) 0 +#ifdef __has_feature +# define UPRV_HAS_FEATURE(x) __has_feature(x) +#else +# define UPRV_HAS_FEATURE(x) 0 #endif -#ifndef __has_extension -# define __has_extension(x) 0 +#ifdef __has_extension +# define UPRV_HAS_EXTENSION(x) __has_extension(x) +#else +# define UPRV_HAS_EXTENSION(x) 0 #endif -#ifndef __has_warning -# define __has_warning(x) 0 +#ifdef __has_warning +# define UPRV_HAS_WARNING(x) __has_warning(x) +#else +# define UPRV_HAS_WARNING(x) 0 #endif /** @@ -452,7 +476,9 @@ * Attribute to specify the size of the allocated buffer for malloc-like functions * @internal */ -#if (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) || __has_attribute(alloc_size) +#if (defined(__GNUC__) && \ + (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) || \ + UPRV_HAS_ATTRIBUTE(alloc_size) # define U_ALLOC_SIZE_ATTR(X) __attribute__ ((alloc_size(X))) # define U_ALLOC_SIZE_ATTR2(X,Y) __attribute__ ((alloc_size(X,Y))) #else @@ -516,8 +542,9 @@ namespace std { #elif defined(__clang__) // Test for compiler vs. feature separately. // Other compilers might choke on the feature test. -# if __has_cpp_attribute(clang::fallthrough) || \ - (__has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough")) +# if UPRV_HAS_CPP_ATTRIBUTE(clang::fallthrough) || \ + (UPRV_HAS_FEATURE(cxx_attributes) && \ + UPRV_HAS_WARNING("-Wimplicit-fallthrough")) # define U_FALLTHROUGH [[clang::fallthrough]] # endif #elif defined(__GNUC__) && (__GNUC__ >= 7) @@ -620,7 +647,8 @@ namespace std { */ #ifdef U_CHARSET_IS_UTF8 /* Use the predefined value. */ -#elif U_PLATFORM_IS_LINUX_BASED || U_PLATFORM_IS_DARWIN_BASED +#elif U_PLATFORM_IS_LINUX_BASED || U_PLATFORM_IS_DARWIN_BASED || \ + U_PLATFORM == U_PF_EMSCRIPTEN # define U_CHARSET_IS_UTF8 1 #else # define U_CHARSET_IS_UTF8 0 @@ -707,7 +735,7 @@ namespace std { * narrow-character strings are in EBCDIC. */ # define U_SIZEOF_WCHAR_T 2 -#else +# else /* * LOCALETYPE(*CLD) or LOCALETYPE(*LOCALE) is specified. * Wide-character strings are in 16-bit EBCDIC, @@ -786,7 +814,8 @@ namespace std { /* Use the predefined value. */ #elif defined(U_STATIC_IMPLEMENTATION) # define U_EXPORT -#elif defined(_MSC_VER) || (__has_declspec_attribute(dllexport) && __has_declspec_attribute(dllimport)) +#elif defined(_MSC_VER) || (UPRV_HAS_DECLSPEC_ATTRIBUTE(dllexport) && \ + UPRV_HAS_DECLSPEC_ATTRIBUTE(dllimport)) # define U_EXPORT __declspec(dllexport) #elif defined(__GNUC__) # define U_EXPORT __attribute__((visibility("default"))) @@ -810,7 +839,8 @@ namespace std { #ifdef U_IMPORT /* Use the predefined value. */ -#elif defined(_MSC_VER) || (__has_declspec_attribute(dllexport) && __has_declspec_attribute(dllimport)) +#elif defined(_MSC_VER) || (UPRV_HAS_DECLSPEC_ATTRIBUTE(dllexport) && \ + UPRV_HAS_DECLSPEC_ATTRIBUTE(dllimport)) /* Windows needs to export/import data. */ # define U_IMPORT __declspec(dllimport) #else @@ -852,4 +882,4 @@ namespace std { #endif /* @} */ -#endif +#endif // _PLATFORM_H diff --git a/deps/icu-small/source/common/unicode/rbbi.h b/deps/icu-small/source/common/unicode/rbbi.h index 365ae2d3d2ac75..7825f603a51c1b 100644 --- a/deps/icu-small/source/common/unicode/rbbi.h +++ b/deps/icu-small/source/common/unicode/rbbi.h @@ -18,6 +18,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** * \file * \brief C++ API: Rule Based Break Iterator @@ -272,7 +274,7 @@ class U_COMMON_API RuleBasedBreakIterator /*U_FINAL*/ : public BreakIterator { * @return a newly-constructed RuleBasedBreakIterator * @stable ICU 2.0 */ - virtual BreakIterator* clone() const; + virtual RuleBasedBreakIterator* clone() const; /** * Compute a hash code for this BreakIterator @@ -536,6 +538,7 @@ class U_COMMON_API RuleBasedBreakIterator /*U_FINAL*/ : public BreakIterator { */ static UClassID U_EXPORT2 getStaticClassID(void); +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * Deprecated functionality. Use clone() instead. * @@ -562,10 +565,10 @@ class U_COMMON_API RuleBasedBreakIterator /*U_FINAL*/ : public BreakIterator { * or if the stackBuffer was too small to hold the clone. * @deprecated ICU 52. Use clone() instead. */ - virtual BreakIterator * createBufferClone(void *stackBuffer, - int32_t &BufferSize, - UErrorCode &status); - + virtual RuleBasedBreakIterator *createBufferClone(void *stackBuffer, + int32_t &BufferSize, + UErrorCode &status); +#endif // U_FORCE_HIDE_DEPRECATED_API /** * Return the binary form of compiled break rules, @@ -696,4 +699,6 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_BREAK_ITERATION */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/common/unicode/rep.h b/deps/icu-small/source/common/unicode/rep.h index b1023a37a2daf1..f66c2ac060e4a8 100644 --- a/deps/icu-small/source/common/unicode/rep.h +++ b/deps/icu-small/source/common/unicode/rep.h @@ -16,6 +16,10 @@ #ifndef REP_H #define REP_H +#include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/uobject.h" /** @@ -189,9 +193,6 @@ class U_COMMON_API Replaceable : public UObject { * Clones can be used concurrently in multiple threads. * If a subclass does not implement clone(), or if an error occurs, * then NULL is returned. - * The clone functions in all subclasses return a pointer to a Replaceable - * because some compilers do not support covariant (same-as-this) - * return types; cast to the appropriate subclass if necessary. * The caller must delete the clone. * * @return a clone of this object @@ -260,4 +261,6 @@ Replaceable::char32At(int32_t offset) const { U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/common/unicode/resbund.h b/deps/icu-small/source/common/unicode/resbund.h index ab0b60bbb28fcc..708a3423d2ae2b 100644 --- a/deps/icu-small/source/common/unicode/resbund.h +++ b/deps/icu-small/source/common/unicode/resbund.h @@ -49,6 +49,9 @@ #define RESBUND_H #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/uobject.h" #include "unicode/ures.h" #include "unicode/unistr.h" @@ -489,4 +492,7 @@ class U_COMMON_API ResourceBundle : public UObject { }; U_NAMESPACE_END + +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/common/unicode/schriter.h b/deps/icu-small/source/common/unicode/schriter.h index 1a12769e8df106..4925ecfe444280 100644 --- a/deps/icu-small/source/common/unicode/schriter.h +++ b/deps/icu-small/source/common/unicode/schriter.h @@ -21,6 +21,9 @@ #define SCHRITER_H #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/chariter.h" #include "unicode/uchriter.h" @@ -130,7 +133,7 @@ class U_COMMON_API StringCharacterIterator : public UCharCharacterIterator { * @return the newly cloned object. * @stable ICU 2.0 */ - virtual CharacterIterator* clone(void) const; + virtual StringCharacterIterator* clone() const; /** * Sets the iterator to iterate over the provided string. @@ -186,4 +189,7 @@ class U_COMMON_API StringCharacterIterator : public UCharCharacterIterator { }; U_NAMESPACE_END + +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/common/unicode/simpleformatter.h b/deps/icu-small/source/common/unicode/simpleformatter.h index 3f7d93dc094a18..9414bca3085ad4 100644 --- a/deps/icu-small/source/common/unicode/simpleformatter.h +++ b/deps/icu-small/source/common/unicode/simpleformatter.h @@ -17,6 +17,9 @@ */ #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/unistr.h" U_NAMESPACE_BEGIN @@ -333,4 +336,6 @@ class U_COMMON_API SimpleFormatter U_FINAL : public UMemory { U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __SIMPLEFORMATTER_H__ diff --git a/deps/icu-small/source/common/unicode/std_string.h b/deps/icu-small/source/common/unicode/std_string.h index 729c56399506eb..bf87230167ecf2 100644 --- a/deps/icu-small/source/common/unicode/std_string.h +++ b/deps/icu-small/source/common/unicode/std_string.h @@ -27,6 +27,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + // Workaround for a libstdc++ bug before libstdc++4.6 (2011). // https://bugs.llvm.org/show_bug.cgi?id=13364 #if defined(__GLIBCXX__) @@ -34,4 +36,6 @@ namespace std { class type_info; } #endif #include +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __STD_STRING_H__ diff --git a/deps/icu-small/source/common/unicode/strenum.h b/deps/icu-small/source/common/unicode/strenum.h index fa525d4f5227da..e813cd84b3413a 100644 --- a/deps/icu-small/source/common/unicode/strenum.h +++ b/deps/icu-small/source/common/unicode/strenum.h @@ -12,6 +12,10 @@ #ifndef STRENUM_H #define STRENUM_H +#include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/uobject.h" #include "unicode/unistr.h" @@ -67,9 +71,6 @@ class U_COMMON_API StringEnumeration : public UObject { * Clones can be used concurrently in multiple threads. * If a subclass does not implement clone(), or if an error occurs, * then NULL is returned. - * The clone functions in all subclasses return a base class pointer - * because some compilers do not support covariant (same-as-this) - * return types; cast to the appropriate subclass if necessary. * The caller must delete the clone. * * @return a clone of this object @@ -274,5 +275,7 @@ class U_COMMON_API StringEnumeration : public UObject { U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + /* STRENUM_H */ #endif diff --git a/deps/icu-small/source/common/unicode/stringpiece.h b/deps/icu-small/source/common/unicode/stringpiece.h index 640fbac5a827d0..15cebb0f202fe7 100644 --- a/deps/icu-small/source/common/unicode/stringpiece.h +++ b/deps/icu-small/source/common/unicode/stringpiece.h @@ -28,6 +28,12 @@ */ #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + +#include +#include + #include "unicode/uobject.h" #include "unicode/std_string.h" @@ -74,6 +80,33 @@ class U_COMMON_API StringPiece : public UMemory { */ StringPiece(const std::string& str) : ptr_(str.data()), length_(static_cast(str.size())) { } +#ifndef U_HIDE_DRAFT_API + /** + * Constructs from some other implementation of a string piece class, from any + * C++ record type that has these two methods: + * + * \code{.cpp} + * + * struct OtherStringPieceClass { + * const char* data(); + * size_t size(); + * }; + * + * \endcode + * + * The other string piece class will typically be std::string_view from C++17 + * or absl::string_view from Abseil. + * + * @param str the other string piece + * @draft ICU 65 + */ + template ::value && + std::is_same::value>::type> + StringPiece(T str) + : ptr_(str.data()), length_(static_cast(str.size())) {} +#endif // U_HIDE_DRAFT_API /** * Constructs from a const char * pointer and a specified length. * @param offset a const char * pointer (need not be terminated) @@ -221,4 +254,6 @@ inline UBool operator!=(const StringPiece& x, const StringPiece& y) { U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __STRINGPIECE_H__ diff --git a/deps/icu-small/source/common/unicode/stringtriebuilder.h b/deps/icu-small/source/common/unicode/stringtriebuilder.h index c27fbd67960d70..2860cbf5513b8e 100644 --- a/deps/icu-small/source/common/unicode/stringtriebuilder.h +++ b/deps/icu-small/source/common/unicode/stringtriebuilder.h @@ -18,6 +18,9 @@ #define __STRINGTRIEBUILDER_H__ #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/uobject.h" /** @@ -418,4 +421,6 @@ class U_COMMON_API StringTrieBuilder : public UObject { U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __STRINGTRIEBUILDER_H__ diff --git a/deps/icu-small/source/common/unicode/symtable.h b/deps/icu-small/source/common/unicode/symtable.h index c2dc95a61bc020..f5a77b01eced80 100644 --- a/deps/icu-small/source/common/unicode/symtable.h +++ b/deps/icu-small/source/common/unicode/symtable.h @@ -13,6 +13,9 @@ #define SYMTABLE_H #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/uobject.h" /** @@ -111,4 +114,6 @@ class U_COMMON_API SymbolTable /* not : public UObject because this is an interf }; U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/common/unicode/uchar.h b/deps/icu-small/source/common/unicode/uchar.h index d70c964e38e5b8..1b7ee099be7ca2 100644 --- a/deps/icu-small/source/common/unicode/uchar.h +++ b/deps/icu-small/source/common/unicode/uchar.h @@ -2578,8 +2578,6 @@ typedef enum UVerticalOrientation { U_STABLE UBool U_EXPORT2 u_hasBinaryProperty(UChar32 c, UProperty which); -#ifndef U_HIDE_DRAFT_API - /** * Returns a frozen USet for a binary property. * The library retains ownership over the returned object. @@ -2593,13 +2591,11 @@ u_hasBinaryProperty(UChar32 c, UProperty which); * @see UProperty * @see u_hasBinaryProperty * @see Unicode::fromUSet - * @draft ICU 63 + * @stable ICU 63 */ U_CAPI const USet * U_EXPORT2 u_getBinaryPropertySet(UProperty property, UErrorCode *pErrorCode); -#endif // U_HIDE_DRAFT_API - /** * Check if a code point has the Alphabetic Unicode property. * Same as u_hasBinaryProperty(c, UCHAR_ALPHABETIC). @@ -2757,8 +2753,6 @@ u_getIntPropertyMinValue(UProperty which); U_STABLE int32_t U_EXPORT2 u_getIntPropertyMaxValue(UProperty which); -#ifndef U_HIDE_DRAFT_API - /** * Returns an immutable UCPMap for an enumerated/catalog/int-valued property. * The library retains ownership over the returned object. @@ -2772,13 +2766,11 @@ u_getIntPropertyMaxValue(UProperty which); * @return the property as a map * @see UProperty * @see u_getIntPropertyValue - * @draft ICU 63 + * @stable ICU 63 */ U_CAPI const UCPMap * U_EXPORT2 u_getIntPropertyMap(UProperty property, UErrorCode *pErrorCode); -#endif // U_HIDE_DRAFT_API - /** * Get the numeric value for a Unicode code point as defined in the * Unicode Character Database. @@ -3197,15 +3189,14 @@ U_STABLE UBool U_EXPORT2 u_isprint(UChar32 c); /** - * Determines whether the specified code point is a base character. + * Non-standard: Determines whether the specified code point is a base character. * True for general categories "L" (letters), "N" (numbers), * "Mc" (spacing combining marks), and "Me" (enclosing marks). * - * Note that this is different from the Unicode definition in - * chapter 3.5, conformance clause D13, - * which defines base characters to be all characters (not Cn) - * that do not graphically combine with preceding characters (M) - * and that are neither control (Cc) or format (Cf) characters. + * Note that this is different from the Unicode Standard definition in + * chapter 3.6, conformance clause D51 “Base character”, + * which defines base characters as the code points with general categories + * Letter (L), Number (N), Punctuation (P), Symbol (S), or Space Separator (Zs). * * @param c the code point to be tested * @return TRUE if the code point is a base character according to this function diff --git a/deps/icu-small/source/common/unicode/ucharstrie.h b/deps/icu-small/source/common/unicode/ucharstrie.h index dfc93f6d0bae8a..d5729d944ee3a2 100644 --- a/deps/icu-small/source/common/unicode/ucharstrie.h +++ b/deps/icu-small/source/common/unicode/ucharstrie.h @@ -24,6 +24,9 @@ */ #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/unistr.h" #include "unicode/uobject.h" #include "unicode/ustringtrie.h" @@ -94,6 +97,41 @@ class U_COMMON_API UCharsTrie : public UMemory { return *this; } +#ifndef U_HIDE_DRAFT_API + /** + * Returns the state of this trie as a 64-bit integer. + * The state value is never 0. + * + * @return opaque state value + * @see resetToState64 + * @draft ICU 65 + */ + uint64_t getState64() const { + return (static_cast(remainingMatchLength_ + 2) << kState64RemainingShift) | + (uint64_t)(pos_ - uchars_); + } + + /** + * Resets this trie to the saved state. + * Unlike resetToState(State), the 64-bit state value + * must be from getState64() from the same trie object or + * from one initialized the exact same way. + * Because of no validation, this method is faster. + * + * @param state The opaque trie state value from getState64(). + * @return *this + * @see getState64 + * @see resetToState + * @see reset + * @draft ICU 65 + */ + UCharsTrie &resetToState64(uint64_t state) { + remainingMatchLength_ = static_cast(state >> kState64RemainingShift) - 2; + pos_ = uchars_ + (state & kState64PosMask); + return *this; + } +#endif /* U_HIDE_DRAFT_API */ + /** * UCharsTrie state object, for saving a trie's current state * and resetting the trie back to this state later. @@ -560,6 +598,13 @@ class U_COMMON_API UCharsTrie : public UMemory { static const int32_t kMaxTwoUnitDelta=((kThreeUnitDeltaLead-kMinTwoUnitDeltaLead)<<16)-1; // 0x03feffff + // For getState64(): + // The remainingMatchLength_ is -1..14=(kMaxLinearMatchLength=0x10)-2 + // so we need at least 5 bits for that. + // We add 2 to store it as a positive value 1..16=kMaxLinearMatchLength. + static constexpr int32_t kState64RemainingShift = 59; + static constexpr uint64_t kState64PosMask = (UINT64_C(1) << kState64RemainingShift) - 1; + char16_t *ownedArray_; // Fixed value referencing the UCharsTrie words. @@ -575,4 +620,6 @@ class U_COMMON_API UCharsTrie : public UMemory { U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __UCHARSTRIE_H__ diff --git a/deps/icu-small/source/common/unicode/ucharstriebuilder.h b/deps/icu-small/source/common/unicode/ucharstriebuilder.h index 2aa4757e52cb07..540dcc047fd563 100644 --- a/deps/icu-small/source/common/unicode/ucharstriebuilder.h +++ b/deps/icu-small/source/common/unicode/ucharstriebuilder.h @@ -18,6 +18,9 @@ #define __UCHARSTRIEBUILDER_H__ #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/stringtriebuilder.h" #include "unicode/ucharstrie.h" #include "unicode/unistr.h" @@ -184,4 +187,6 @@ class U_COMMON_API UCharsTrieBuilder : public StringTrieBuilder { U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __UCHARSTRIEBUILDER_H__ diff --git a/deps/icu-small/source/common/unicode/uchriter.h b/deps/icu-small/source/common/unicode/uchriter.h index 38f67c5b454cba..bee842cc259f07 100644 --- a/deps/icu-small/source/common/unicode/uchriter.h +++ b/deps/icu-small/source/common/unicode/uchriter.h @@ -11,6 +11,9 @@ #define UCHRITER_H #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/chariter.h" /** @@ -132,7 +135,7 @@ class U_COMMON_API UCharCharacterIterator : public CharacterIterator { * @return the CharacterIterator newly created * @stable ICU 2.0 */ - virtual CharacterIterator* clone(void) const; + virtual UCharCharacterIterator* clone() const; /** * Sets the iterator to refer to the first code unit in its @@ -384,4 +387,7 @@ class U_COMMON_API UCharCharacterIterator : public CharacterIterator { }; U_NAMESPACE_END + +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/common/unicode/uconfig.h b/deps/icu-small/source/common/unicode/uconfig.h index 9c82d828125603..c0157efe6d4ede 100644 --- a/deps/icu-small/source/common/unicode/uconfig.h +++ b/deps/icu-small/source/common/unicode/uconfig.h @@ -453,4 +453,4 @@ # define UCONFIG_NO_FILTERED_BREAK_ITERATION 0 #endif -#endif +#endif // __UCONFIG_H__ diff --git a/deps/icu-small/source/common/unicode/ucpmap.h b/deps/icu-small/source/common/unicode/ucpmap.h index f2c42b6b7f4bee..31e1365cac850a 100644 --- a/deps/icu-small/source/common/unicode/ucpmap.h +++ b/deps/icu-small/source/common/unicode/ucpmap.h @@ -9,8 +9,6 @@ #include "unicode/utypes.h" -#ifndef U_HIDE_DRAFT_API - U_CDECL_BEGIN /** @@ -28,7 +26,7 @@ U_CDECL_BEGIN * * @see UCPTrie * @see UMutableCPTrie - * @draft ICU 63 + * @stable ICU 63 */ typedef struct UCPMap UCPMap; @@ -39,13 +37,13 @@ typedef struct UCPMap UCPMap; * @see ucpmap_getRange * @see ucptrie_getRange * @see umutablecptrie_getRange - * @draft ICU 63 + * @stable ICU 63 */ enum UCPMapRangeOption { /** * ucpmap_getRange() enumerates all same-value ranges as stored in the map. * Most users should use this option. - * @draft ICU 63 + * @stable ICU 63 */ UCPMAP_RANGE_NORMAL, /** @@ -61,7 +59,7 @@ enum UCPMapRangeOption { * special values optimized for UTF-16 string processing * or for special error behavior for unpaired surrogates, * but those values are not to be associated with the lead surrogate code *points*. - * @draft ICU 63 + * @stable ICU 63 */ UCPMAP_RANGE_FIXED_LEAD_SURROGATES, /** @@ -77,7 +75,7 @@ enum UCPMapRangeOption { * special values optimized for UTF-16 string processing * or for special error behavior for unpaired surrogates, * but those values are not to be associated with the lead surrogate code *points*. - * @draft ICU 63 + * @stable ICU 63 */ UCPMAP_RANGE_FIXED_ALL_SURROGATES }; @@ -93,7 +91,7 @@ typedef enum UCPMapRangeOption UCPMapRangeOption; * @param c the code point * @return the map value, * or an implementation-defined error value if the code point is not in the range 0..U+10FFFF - * @draft ICU 63 + * @stable ICU 63 */ U_CAPI uint32_t U_EXPORT2 ucpmap_get(const UCPMap *map, UChar32 c); @@ -110,7 +108,7 @@ ucpmap_get(const UCPMap *map, UChar32 c); * @param context an opaque pointer, as passed into the getRange function * @param value a value from the map * @return the modified value - * @draft ICU 63 + * @stable ICU 63 */ typedef uint32_t U_CALLCONV UCPMapValueFilter(const void *context, uint32_t value); @@ -149,7 +147,7 @@ UCPMapValueFilter(const void *context, uint32_t value); * may have been modified by filter(context, map value) * if that function pointer is not NULL * @return the range end code point, or -1 if start is not a valid code point - * @draft ICU 63 + * @stable ICU 63 */ U_CAPI UChar32 U_EXPORT2 ucpmap_getRange(const UCPMap *map, UChar32 start, @@ -158,5 +156,4 @@ ucpmap_getRange(const UCPMap *map, UChar32 start, U_CDECL_END -#endif // U_HIDE_DRAFT_API #endif diff --git a/deps/icu-small/source/common/unicode/ucptrie.h b/deps/icu-small/source/common/unicode/ucptrie.h index 2718c984e43197..be06a227928286 100644 --- a/deps/icu-small/source/common/unicode/ucptrie.h +++ b/deps/icu-small/source/common/unicode/ucptrie.h @@ -9,8 +9,6 @@ #include "unicode/utypes.h" -#ifndef U_HIDE_DRAFT_API - #include "unicode/localpointer.h" #include "unicode/ucpmap.h" #include "unicode/utf8.h" @@ -55,7 +53,7 @@ typedef union UCPTrieData { * The macros will return bogus values, or may crash, if used on the wrong type or value width. * * @see UMutableCPTrie - * @draft ICU 63 + * @stable ICU 63 */ struct UCPTrie { #ifndef U_IN_DOXYGEN @@ -115,23 +113,23 @@ typedef struct UCPTrie UCPTrie; * @see umutablecptrie_buildImmutable * @see ucptrie_openFromBinary * @see ucptrie_getType - * @draft ICU 63 + * @stable ICU 63 */ enum UCPTrieType { /** * For ucptrie_openFromBinary() to accept any type. * ucptrie_getType() will return the actual type. - * @draft ICU 63 + * @stable ICU 63 */ UCPTRIE_TYPE_ANY = -1, /** * Fast/simple/larger BMP data structure. Use functions and "fast" macros. - * @draft ICU 63 + * @stable ICU 63 */ UCPTRIE_TYPE_FAST, /** * Small/slower BMP data structure. Use functions and "small" macros. - * @draft ICU 63 + * @stable ICU 63 */ UCPTRIE_TYPE_SMALL }; @@ -145,30 +143,30 @@ typedef enum UCPTrieType UCPTrieType; * @see umutablecptrie_buildImmutable * @see ucptrie_openFromBinary * @see ucptrie_getValueWidth - * @draft ICU 63 + * @stable ICU 63 */ enum UCPTrieValueWidth { /** * For ucptrie_openFromBinary() to accept any data value width. * ucptrie_getValueWidth() will return the actual data value width. - * @draft ICU 63 + * @stable ICU 63 */ UCPTRIE_VALUE_BITS_ANY = -1, /** * The trie stores 16 bits per data value. * It returns them as unsigned values 0..0xffff=65535. - * @draft ICU 63 + * @stable ICU 63 */ UCPTRIE_VALUE_BITS_16, /** * The trie stores 32 bits per data value. - * @draft ICU 63 + * @stable ICU 63 */ UCPTRIE_VALUE_BITS_32, /** * The trie stores 8 bits per data value. * It returns them as unsigned values 0..0xff=255. - * @draft ICU 63 + * @stable ICU 63 */ UCPTRIE_VALUE_BITS_8 }; @@ -200,7 +198,7 @@ typedef enum UCPTrieValueWidth UCPTrieValueWidth; * @see umutablecptrie_open * @see umutablecptrie_buildImmutable * @see ucptrie_toBinary - * @draft ICU 63 + * @stable ICU 63 */ U_CAPI UCPTrie * U_EXPORT2 ucptrie_openFromBinary(UCPTrieType type, UCPTrieValueWidth valueWidth, @@ -211,30 +209,11 @@ ucptrie_openFromBinary(UCPTrieType type, UCPTrieValueWidth valueWidth, * Closes a trie and releases associated memory. * * @param trie the trie - * @draft ICU 63 + * @stable ICU 63 */ U_CAPI void U_EXPORT2 ucptrie_close(UCPTrie *trie); -#if U_SHOW_CPLUSPLUS_API - -U_NAMESPACE_BEGIN - -/** - * \class LocalUCPTriePointer - * "Smart pointer" class, closes a UCPTrie via ucptrie_close(). - * For most methods see the LocalPointerBase base class. - * - * @see LocalPointerBase - * @see LocalPointer - * @draft ICU 63 - */ -U_DEFINE_LOCAL_OPEN_POINTER(LocalUCPTriePointer, UCPTrie, ucptrie_close); - -U_NAMESPACE_END - -#endif - /** * Returns the trie type. * @@ -242,7 +221,7 @@ U_NAMESPACE_END * @return the trie type * @see ucptrie_openFromBinary * @see UCPTRIE_TYPE_ANY - * @draft ICU 63 + * @stable ICU 63 */ U_CAPI UCPTrieType U_EXPORT2 ucptrie_getType(const UCPTrie *trie); @@ -254,7 +233,7 @@ ucptrie_getType(const UCPTrie *trie); * @return the number of bits in a trie data value * @see ucptrie_openFromBinary * @see UCPTRIE_VALUE_BITS_ANY - * @draft ICU 63 + * @stable ICU 63 */ U_CAPI UCPTrieValueWidth U_EXPORT2 ucptrie_getValueWidth(const UCPTrie *trie); @@ -271,7 +250,7 @@ ucptrie_getValueWidth(const UCPTrie *trie); * @param c the code point * @return the trie value, * or the trie error value if the code point is not in the range 0..U+10FFFF - * @draft ICU 63 + * @stable ICU 63 */ U_CAPI uint32_t U_EXPORT2 ucptrie_get(const UCPTrie *trie, UChar32 c); @@ -310,7 +289,7 @@ ucptrie_get(const UCPTrie *trie, UChar32 c); * may have been modified by filter(context, trie value) * if that function pointer is not NULL * @return the range end code point, or -1 if start is not a valid code point - * @draft ICU 63 + * @stable ICU 63 */ U_CAPI UChar32 U_EXPORT2 ucptrie_getRange(const UCPTrie *trie, UChar32 start, @@ -330,7 +309,7 @@ ucptrie_getRange(const UCPTrie *trie, UChar32 start, * @return the number of bytes written or (if buffer overflow) needed for the trie * * @see ucptrie_openFromBinary() - * @draft ICU 63 + * @stable ICU 63 */ U_CAPI int32_t U_EXPORT2 ucptrie_toBinary(const UCPTrie *trie, void *data, int32_t capacity, UErrorCode *pErrorCode); @@ -341,7 +320,7 @@ ucptrie_toBinary(const UCPTrie *trie, void *data, int32_t capacity, UErrorCode * * Do not use this macro in any other way. * * @see UCPTRIE_VALUE_BITS_16 - * @draft ICU 63 + * @stable ICU 63 */ #define UCPTRIE_16(trie, i) ((trie)->data.ptr16[i]) @@ -351,7 +330,7 @@ ucptrie_toBinary(const UCPTrie *trie, void *data, int32_t capacity, UErrorCode * * Do not use this macro in any other way. * * @see UCPTRIE_VALUE_BITS_32 - * @draft ICU 63 + * @stable ICU 63 */ #define UCPTRIE_32(trie, i) ((trie)->data.ptr32[i]) @@ -361,7 +340,7 @@ ucptrie_toBinary(const UCPTrie *trie, void *data, int32_t capacity, UErrorCode * * Do not use this macro in any other way. * * @see UCPTRIE_VALUE_BITS_8 - * @draft ICU 63 + * @stable ICU 63 */ #define UCPTRIE_8(trie, i) ((trie)->data.ptr8[i]) @@ -373,7 +352,7 @@ ucptrie_toBinary(const UCPTrie *trie, void *data, int32_t capacity, UErrorCode * * @param dataAccess UCPTRIE_16, UCPTRIE_32, or UCPTRIE_8 according to the trie’s value width * @param c (UChar32, in) the input code point * @return The code point's trie value. - * @draft ICU 63 + * @stable ICU 63 */ #define UCPTRIE_FAST_GET(trie, dataAccess, c) dataAccess(trie, _UCPTRIE_CP_INDEX(trie, 0xffff, c)) @@ -385,7 +364,7 @@ ucptrie_toBinary(const UCPTrie *trie, void *data, int32_t capacity, UErrorCode * * @param dataAccess UCPTRIE_16, UCPTRIE_32, or UCPTRIE_8 according to the trie’s value width * @param c (UChar32, in) the input code point * @return The code point's trie value. - * @draft ICU 63 + * @stable ICU 63 */ #define UCPTRIE_SMALL_GET(trie, dataAccess, c) \ dataAccess(trie, _UCPTRIE_CP_INDEX(trie, UCPTRIE_SMALL_MAX, c)) @@ -401,9 +380,9 @@ ucptrie_toBinary(const UCPTrie *trie, void *data, int32_t capacity, UErrorCode * * @param limit (const UChar *, in) the limit pointer for the text, or NULL if NUL-terminated * @param c (UChar32, out) variable for the code point * @param result (out) variable for the trie lookup result - * @draft ICU 63 + * @stable ICU 63 */ -#define UCPTRIE_FAST_U16_NEXT(trie, dataAccess, src, limit, c, result) { \ +#define UCPTRIE_FAST_U16_NEXT(trie, dataAccess, src, limit, c, result) UPRV_BLOCK_MACRO_BEGIN { \ (c) = *(src)++; \ int32_t __index; \ if (!U16_IS_SURROGATE(c)) { \ @@ -419,7 +398,7 @@ ucptrie_toBinary(const UCPTrie *trie, void *data, int32_t capacity, UErrorCode * } \ } \ (result) = dataAccess(trie, __index); \ -} +} UPRV_BLOCK_MACRO_END /** * UTF-16: Reads the previous code point (UChar32 c, out), pre-decrements src, @@ -432,9 +411,9 @@ ucptrie_toBinary(const UCPTrie *trie, void *data, int32_t capacity, UErrorCode * * @param src (const UChar *, in/out) the source text pointer * @param c (UChar32, out) variable for the code point * @param result (out) variable for the trie lookup result - * @draft ICU 63 + * @stable ICU 63 */ -#define UCPTRIE_FAST_U16_PREV(trie, dataAccess, start, src, c, result) { \ +#define UCPTRIE_FAST_U16_PREV(trie, dataAccess, start, src, c, result) UPRV_BLOCK_MACRO_BEGIN { \ (c) = *--(src); \ int32_t __index; \ if (!U16_IS_SURROGATE(c)) { \ @@ -450,7 +429,7 @@ ucptrie_toBinary(const UCPTrie *trie, void *data, int32_t capacity, UErrorCode * } \ } \ (result) = dataAccess(trie, __index); \ -} +} UPRV_BLOCK_MACRO_END /** * UTF-8: Post-increments src and gets a value from the trie. @@ -466,9 +445,9 @@ ucptrie_toBinary(const UCPTrie *trie, void *data, int32_t capacity, UErrorCode * * @param src (const char *, in/out) the source text pointer * @param limit (const char *, in) the limit pointer for the text (must not be NULL) * @param result (out) variable for the trie lookup result - * @draft ICU 63 + * @stable ICU 63 */ -#define UCPTRIE_FAST_U8_NEXT(trie, dataAccess, src, limit, result) { \ +#define UCPTRIE_FAST_U8_NEXT(trie, dataAccess, src, limit, result) UPRV_BLOCK_MACRO_BEGIN { \ int32_t __lead = (uint8_t)*(src)++; \ if (!U8_IS_SINGLE(__lead)) { \ uint8_t __t1, __t2, __t3; \ @@ -496,7 +475,7 @@ ucptrie_toBinary(const UCPTrie *trie, void *data, int32_t capacity, UErrorCode * } \ } \ (result) = dataAccess(trie, __lead); \ -} +} UPRV_BLOCK_MACRO_END /** * UTF-8: Pre-decrements src and gets a value from the trie. @@ -512,9 +491,9 @@ ucptrie_toBinary(const UCPTrie *trie, void *data, int32_t capacity, UErrorCode * * @param start (const char *, in) the start pointer for the text * @param src (const char *, in/out) the source text pointer * @param result (out) variable for the trie lookup result - * @draft ICU 63 + * @stable ICU 63 */ -#define UCPTRIE_FAST_U8_PREV(trie, dataAccess, start, src, result) { \ +#define UCPTRIE_FAST_U8_PREV(trie, dataAccess, start, src, result) UPRV_BLOCK_MACRO_BEGIN { \ int32_t __index = (uint8_t)*--(src); \ if (!U8_IS_SINGLE(__index)) { \ __index = ucptrie_internalU8PrevIndex((trie), __index, (const uint8_t *)(start), \ @@ -523,7 +502,7 @@ ucptrie_toBinary(const UCPTrie *trie, void *data, int32_t capacity, UErrorCode * __index >>= 3; \ } \ (result) = dataAccess(trie, __index); \ -} +} UPRV_BLOCK_MACRO_END /** * Returns a trie value for an ASCII code point, without range checking. @@ -532,7 +511,7 @@ ucptrie_toBinary(const UCPTrie *trie, void *data, int32_t capacity, UErrorCode * * @param dataAccess UCPTRIE_16, UCPTRIE_32, or UCPTRIE_8 according to the trie’s value width * @param c (UChar32, in) the input code point; must be U+0000..U+007F * @return The ASCII code point's trie value. - * @draft ICU 63 + * @stable ICU 63 */ #define UCPTRIE_ASCII_GET(trie, dataAccess, c) dataAccess(trie, c) @@ -545,7 +524,7 @@ ucptrie_toBinary(const UCPTrie *trie, void *data, int32_t capacity, UErrorCode * * @param dataAccess UCPTRIE_16, UCPTRIE_32, or UCPTRIE_8 according to the trie’s value width * @param c (UChar32, in) the input code point, must be U+0000..U+FFFF * @return The BMP code point's trie value. - * @draft ICU 63 + * @stable ICU 63 */ #define UCPTRIE_FAST_BMP_GET(trie, dataAccess, c) dataAccess(trie, _UCPTRIE_FAST_INDEX(trie, c)) @@ -557,7 +536,7 @@ ucptrie_toBinary(const UCPTrie *trie, void *data, int32_t capacity, UErrorCode * * @param dataAccess UCPTRIE_16, UCPTRIE_32, or UCPTRIE_8 according to the trie’s value width * @param c (UChar32, in) the input code point, must be U+10000..U+10FFFF * @return The supplementary code point's trie value. - * @draft ICU 63 + * @stable ICU 63 */ #define UCPTRIE_FAST_SUPP_GET(trie, dataAccess, c) dataAccess(trie, _UCPTRIE_SMALL_INDEX(trie, c)) @@ -642,5 +621,24 @@ ucptrie_internalU8PrevIndex(const UCPTrie *trie, UChar32 c, U_CDECL_END #endif // U_IN_DOXYGEN -#endif // U_HIDE_DRAFT_API + +#if U_SHOW_CPLUSPLUS_API + +U_NAMESPACE_BEGIN + +/** + * \class LocalUCPTriePointer + * "Smart pointer" class, closes a UCPTrie via ucptrie_close(). + * For most methods see the LocalPointerBase base class. + * + * @see LocalPointerBase + * @see LocalPointer + * @stable ICU 63 + */ +U_DEFINE_LOCAL_OPEN_POINTER(LocalUCPTriePointer, UCPTrie, ucptrie_close); + +U_NAMESPACE_END + +#endif // U_SHOW_CPLUSPLUS_API + #endif diff --git a/deps/icu-small/source/common/unicode/ucurr.h b/deps/icu-small/source/common/unicode/ucurr.h index a1c6de80b772f7..7149e7adf13067 100644 --- a/deps/icu-small/source/common/unicode/ucurr.h +++ b/deps/icu-small/source/common/unicode/ucurr.h @@ -159,14 +159,14 @@ ucurr_unregister(UCurrRegistryKey key, UErrorCode* status); * @param currency null-terminated 3-letter ISO 4217 code * @param locale locale in which to display currency * @param nameStyle selector for which kind of name to return - * @param isChoiceFormat fill-in set to TRUE if the returned value - * is a ChoiceFormat pattern; otherwise it is a static string + * @param isChoiceFormat always set to FALSE, or can be NULL; + * display names are static strings; + * since ICU 4.4, ChoiceFormat patterns are no longer supported * @param len fill-in parameter to receive length of result * @param ec error code * @return pointer to display string of 'len' UChars. If the resource * data contains no entry for 'currency', then 'currency' itself is - * returned. If *isChoiceFormat is TRUE, then the result is a - * ChoiceFormat pattern. Otherwise it is a static string. + * returned. * @stable ICU 2.6 */ U_STABLE const UChar* U_EXPORT2 @@ -183,8 +183,9 @@ ucurr_getName(const UChar* currency, * currency object in the en_US locale is "US dollar" or "US dollars". * @param currency null-terminated 3-letter ISO 4217 code * @param locale locale in which to display currency - * @param isChoiceFormat fill-in set to TRUE if the returned value - * is a ChoiceFormat pattern; otherwise it is a static string + * @param isChoiceFormat always set to FALSE, or can be NULL; + * display names are static strings; + * since ICU 4.4, ChoiceFormat patterns are no longer supported * @param pluralCount plural count * @param len fill-in parameter to receive length of result * @param ec error code @@ -320,7 +321,7 @@ typedef enum UCurrCurrencyType { * Provides a UEnumeration object for listing ISO-4217 codes. * @param currType You can use one of several UCurrCurrencyType values for this * variable. You can also | (or) them together to get a specific list of - * currencies. Most people will want to use the (UCURR_CURRENCY|UCURR_NON_DEPRECATED) value to + * currencies. Most people will want to use the (UCURR_COMMON|UCURR_NON_DEPRECATED) value to * get a list of current currencies. * @param pErrorCode Error code * @stable ICU 3.2 diff --git a/deps/icu-small/source/common/unicode/udata.h b/deps/icu-small/source/common/unicode/udata.h index 6419c359f606af..8236877b443d3d 100644 --- a/deps/icu-small/source/common/unicode/udata.h +++ b/deps/icu-small/source/common/unicode/udata.h @@ -264,25 +264,6 @@ udata_openChoice(const char *path, const char *type, const char *name, U_STABLE void U_EXPORT2 udata_close(UDataMemory *pData); -#if U_SHOW_CPLUSPLUS_API - -U_NAMESPACE_BEGIN - -/** - * \class LocalUDataMemoryPointer - * "Smart pointer" class, closes a UDataMemory via udata_close(). - * For most methods see the LocalPointerBase base class. - * - * @see LocalPointerBase - * @see LocalPointer - * @stable ICU 4.4 - */ -U_DEFINE_LOCAL_OPEN_POINTER(LocalUDataMemoryPointer, UDataMemory, udata_close); - -U_NAMESPACE_END - -#endif - /** * Get the pointer to the actual data inside the data memory. * The data is read-only. @@ -434,4 +415,23 @@ udata_setFileAccess(UDataFileAccess access, UErrorCode *status); U_CDECL_END +#if U_SHOW_CPLUSPLUS_API + +U_NAMESPACE_BEGIN + +/** + * \class LocalUDataMemoryPointer + * "Smart pointer" class, closes a UDataMemory via udata_close(). + * For most methods see the LocalPointerBase base class. + * + * @see LocalPointerBase + * @see LocalPointer + * @stable ICU 4.4 + */ +U_DEFINE_LOCAL_OPEN_POINTER(LocalUDataMemoryPointer, UDataMemory, udata_close); + +U_NAMESPACE_END + +#endif // U_SHOW_CPLUSPLUS_API + #endif diff --git a/deps/icu-small/source/common/unicode/uloc.h b/deps/icu-small/source/common/unicode/uloc.h index 5531070841187d..882f79bedca62c 100644 --- a/deps/icu-small/source/common/unicode/uloc.h +++ b/deps/icu-small/source/common/unicode/uloc.h @@ -742,12 +742,18 @@ uloc_getDisplayName(const char* localeID, /** - * Gets the specified locale from a list of all available locales. - * The return value is a pointer to an item of - * a locale name array. Both this array and the pointers - * it contains are owned by ICU and should not be deleted or written through - * by the caller. The locale name is terminated by a null pointer. - * @param n the specific locale name index of the available locale list + * Gets the specified locale from a list of available locales. + * + * This method corresponds to uloc_openAvailableByType called with the + * ULOC_AVAILABLE_DEFAULT type argument. + * + * The return value is a pointer to an item of a locale name array. Both this + * array and the pointers it contains are owned by ICU and should not be + * deleted or written through by the caller. The locale name is terminated by + * a null pointer. + * + * @param n the specific locale name index of the available locale list; + * should not exceed the number returned by uloc_countAvailable. * @return a specified locale name of all available locales * @stable ICU 2.0 */ @@ -762,6 +768,72 @@ uloc_getAvailable(int32_t n); */ U_STABLE int32_t U_EXPORT2 uloc_countAvailable(void); +#ifndef U_HIDE_DRAFT_API + +/** + * Types for uloc_getAvailableByType and uloc_countAvailableByType. + * + * @draft ICU 65 + */ +typedef enum ULocAvailableType { + /** + * Locales that return data when passed to ICU APIs, + * but not including legacy or alias locales. + * + * @draft ICU 65 + */ + ULOC_AVAILABLE_DEFAULT, + + /** + * Legacy or alias locales that return data when passed to ICU APIs. + * Examples of supported legacy or alias locales: + * + * - iw (alias to he) + * - mo (alias to ro) + * - zh_CN (alias to zh_Hans_CN) + * - sr_BA (alias to sr_Cyrl_BA) + * - ars (alias to ar_SA) + * + * The locales in this set are disjoint from the ones in + * ULOC_AVAILABLE_DEFAULT. To get both sets at the same time, use + * ULOC_AVAILABLE_WITH_LEGACY_ALIASES. + * + * @draft ICU 65 + */ + ULOC_AVAILABLE_ONLY_LEGACY_ALIASES, + + /** + * The union of the locales in ULOC_AVAILABLE_DEFAULT and + * ULOC_AVAILABLE_ONLY_LEGACY_ALIAS. + * + * @draft ICU 65 + */ + ULOC_AVAILABLE_WITH_LEGACY_ALIASES, + +#ifndef U_HIDE_INTERNAL_API + /** + * @internal + */ + ULOC_AVAILABLE_COUNT +#endif +} ULocAvailableType; + +/** + * Gets a list of available locales according to the type argument, allowing + * the user to access different sets of supported locales in ICU. + * + * The returned UEnumeration must be closed by the caller. + * + * @param type Type choice from ULocAvailableType. + * @param status Set if an error occurred. + * @return a UEnumeration owned by the caller, or nullptr on failure. + * @draft ICU 65 + */ +U_DRAFT UEnumeration* U_EXPORT2 +uloc_openAvailableByType(ULocAvailableType type, UErrorCode* status); + +#endif // U_HIDE_DRAFT_API + /** * * Gets a list of all available 2-letter language codes defined in ISO 639, diff --git a/deps/icu-small/source/common/unicode/umachine.h b/deps/icu-small/source/common/unicode/umachine.h index 6d932cfcfb2ae4..5cb95e58f37295 100644 --- a/deps/icu-small/source/common/unicode/umachine.h +++ b/deps/icu-small/source/common/unicode/umachine.h @@ -140,6 +140,42 @@ #define U_FINAL final #endif +// Before ICU 65, function-like, multi-statement ICU macros were just defined as +// series of statements wrapped in { } blocks and the caller could choose to +// either treat them as if they were actual functions and end the invocation +// with a trailing ; creating an empty statement after the block or else omit +// this trailing ; using the knowledge that the macro would expand to { }. +// +// But doing so doesn't work well with macros that look like functions and +// compiler warnings about empty statements (ICU-20601) and ICU 65 therefore +// switches to the standard solution of wrapping such macros in do { } while. +// +// This will however break existing code that depends on being able to invoke +// these macros without a trailing ; so to be able to remain compatible with +// such code the wrapper is itself defined as macros so that it's possible to +// build ICU 65 and later with the old macro behaviour, like this: +// +// export CPPFLAGS='-DUPRV_BLOCK_MACRO_BEGIN="" -DUPRV_BLOCK_MACRO_END=""' +// runConfigureICU ... +// + +/** + * \def UPRV_BLOCK_MACRO_BEGIN + * Defined as the "do" keyword by default. + * @internal + */ +#ifndef UPRV_BLOCK_MACRO_BEGIN +#define UPRV_BLOCK_MACRO_BEGIN do +#endif + +/** + * \def UPRV_BLOCK_MACRO_END + * Defined as "while (FALSE)" by default. + * @internal + */ +#ifndef UPRV_BLOCK_MACRO_END +#define UPRV_BLOCK_MACRO_END while (FALSE) +#endif /*==========================================================================*/ /* limits for int32_t etc., like in POSIX inttypes.h */ diff --git a/deps/icu-small/source/common/unicode/umutablecptrie.h b/deps/icu-small/source/common/unicode/umutablecptrie.h index e75191a4495209..13e71ef25e8c87 100644 --- a/deps/icu-small/source/common/unicode/umutablecptrie.h +++ b/deps/icu-small/source/common/unicode/umutablecptrie.h @@ -9,8 +9,6 @@ #include "unicode/utypes.h" -#ifndef U_HIDE_DRAFT_API - #include "unicode/localpointer.h" #include "unicode/ucpmap.h" #include "unicode/ucptrie.h" @@ -44,7 +42,7 @@ U_CDECL_BEGIN * * @see UCPTrie * @see umutablecptrie_buildImmutable - * @draft ICU 63 + * @stable ICU 63 */ typedef struct UMutableCPTrie UMutableCPTrie; @@ -59,7 +57,7 @@ typedef struct UMutableCPTrie UMutableCPTrie; * @param errorValue the value for out-of-range code points and ill-formed UTF-8/16 * @param pErrorCode an in/out ICU UErrorCode * @return the trie - * @draft ICU 63 + * @stable ICU 63 */ U_CAPI UMutableCPTrie * U_EXPORT2 umutablecptrie_open(uint32_t initialValue, uint32_t errorValue, UErrorCode *pErrorCode); @@ -71,7 +69,7 @@ umutablecptrie_open(uint32_t initialValue, uint32_t errorValue, UErrorCode *pErr * @param other the trie to clone * @param pErrorCode an in/out ICU UErrorCode * @return the trie clone - * @draft ICU 63 + * @stable ICU 63 */ U_CAPI UMutableCPTrie * U_EXPORT2 umutablecptrie_clone(const UMutableCPTrie *other, UErrorCode *pErrorCode); @@ -80,7 +78,7 @@ umutablecptrie_clone(const UMutableCPTrie *other, UErrorCode *pErrorCode); * Closes a mutable trie and releases associated memory. * * @param trie the trie - * @draft ICU 63 + * @stable ICU 63 */ U_CAPI void U_EXPORT2 umutablecptrie_close(UMutableCPTrie *trie); @@ -96,7 +94,7 @@ U_NAMESPACE_BEGIN * * @see LocalPointerBase * @see LocalPointer - * @draft ICU 63 + * @stable ICU 63 */ U_DEFINE_LOCAL_OPEN_POINTER(LocalUMutableCPTriePointer, UMutableCPTrie, umutablecptrie_close); @@ -111,7 +109,7 @@ U_NAMESPACE_END * @param map the source map * @param pErrorCode an in/out ICU UErrorCode * @return the mutable trie - * @draft ICU 63 + * @stable ICU 63 */ U_CAPI UMutableCPTrie * U_EXPORT2 umutablecptrie_fromUCPMap(const UCPMap *map, UErrorCode *pErrorCode); @@ -123,7 +121,7 @@ umutablecptrie_fromUCPMap(const UCPMap *map, UErrorCode *pErrorCode); * @param trie the immutable trie * @param pErrorCode an in/out ICU UErrorCode * @return the mutable trie - * @draft ICU 63 + * @stable ICU 63 */ U_CAPI UMutableCPTrie * U_EXPORT2 umutablecptrie_fromUCPTrie(const UCPTrie *trie, UErrorCode *pErrorCode); @@ -134,7 +132,7 @@ umutablecptrie_fromUCPTrie(const UCPTrie *trie, UErrorCode *pErrorCode); * @param trie the trie * @param c the code point * @return the value - * @draft ICU 63 + * @stable ICU 63 */ U_CAPI uint32_t U_EXPORT2 umutablecptrie_get(const UMutableCPTrie *trie, UChar32 c); @@ -166,7 +164,7 @@ umutablecptrie_get(const UMutableCPTrie *trie, UChar32 c); * may have been modified by filter(context, trie value) * if that function pointer is not NULL * @return the range end code point, or -1 if start is not a valid code point - * @draft ICU 63 + * @stable ICU 63 */ U_CAPI UChar32 U_EXPORT2 umutablecptrie_getRange(const UMutableCPTrie *trie, UChar32 start, @@ -180,7 +178,7 @@ umutablecptrie_getRange(const UMutableCPTrie *trie, UChar32 start, * @param c the code point * @param value the value * @param pErrorCode an in/out ICU UErrorCode - * @draft ICU 63 + * @stable ICU 63 */ U_CAPI void U_EXPORT2 umutablecptrie_set(UMutableCPTrie *trie, UChar32 c, uint32_t value, UErrorCode *pErrorCode); @@ -194,7 +192,7 @@ umutablecptrie_set(UMutableCPTrie *trie, UChar32 c, uint32_t value, UErrorCode * * @param end the last code point to get the value (inclusive) * @param value the value * @param pErrorCode an in/out ICU UErrorCode - * @draft ICU 63 + * @stable ICU 63 */ U_CAPI void U_EXPORT2 umutablecptrie_setRange(UMutableCPTrie *trie, @@ -229,7 +227,7 @@ umutablecptrie_setRange(UMutableCPTrie *trie, * @param pErrorCode an in/out ICU UErrorCode * * @see umutablecptrie_fromUCPTrie - * @draft ICU 63 + * @stable ICU 63 */ U_CAPI UCPTrie * U_EXPORT2 umutablecptrie_buildImmutable(UMutableCPTrie *trie, UCPTrieType type, UCPTrieValueWidth valueWidth, @@ -237,5 +235,4 @@ umutablecptrie_buildImmutable(UMutableCPTrie *trie, UCPTrieType type, UCPTrieVal U_CDECL_END -#endif // U_HIDE_DRAFT_API #endif diff --git a/deps/icu-small/source/common/unicode/unifilt.h b/deps/icu-small/source/common/unicode/unifilt.h index 99cce785b6eec8..1a77089233bf10 100644 --- a/deps/icu-small/source/common/unicode/unifilt.h +++ b/deps/icu-small/source/common/unicode/unifilt.h @@ -12,6 +12,10 @@ #ifndef UNIFILT_H #define UNIFILT_H +#include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/unifunct.h" #include "unicode/unimatch.h" @@ -67,6 +71,14 @@ class U_COMMON_API UnicodeFilter : public UnicodeFunctor, public UnicodeMatcher */ virtual ~UnicodeFilter(); + /** + * Clones this object polymorphically. + * The caller owns the result and should delete it when done. + * @return clone, or nullptr if an error occurred + * @stable ICU 2.4 + */ + virtual UnicodeFilter* clone() const = 0; + /** * Returns true for characters that are in the selected * subset. In other words, if a character is to be @@ -119,4 +131,6 @@ class U_COMMON_API UnicodeFilter : public UnicodeFunctor, public UnicodeMatcher U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/common/unicode/unifunct.h b/deps/icu-small/source/common/unicode/unifunct.h index 66a02ce7cd5ce8..2b1b766ea76187 100644 --- a/deps/icu-small/source/common/unicode/unifunct.h +++ b/deps/icu-small/source/common/unicode/unifunct.h @@ -13,6 +13,9 @@ #define UNIFUNCT_H #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/uobject.h" /** @@ -124,4 +127,6 @@ class U_COMMON_API UnicodeFunctor : public UObject { U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/common/unicode/unimatch.h b/deps/icu-small/source/common/unicode/unimatch.h index 8bf39950187b1b..2d3c5210c38e25 100644 --- a/deps/icu-small/source/common/unicode/unimatch.h +++ b/deps/icu-small/source/common/unicode/unimatch.h @@ -17,6 +17,7 @@ * \brief C++ API: Unicode Matcher */ +#if U_SHOW_CPLUSPLUS_API U_NAMESPACE_BEGIN @@ -162,4 +163,6 @@ class U_COMMON_API UnicodeMatcher /* not : public UObject because this is an int U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/common/unicode/uniset.h b/deps/icu-small/source/common/unicode/uniset.h index e5e7726d604a73..18cc9376442a2f 100644 --- a/deps/icu-small/source/common/unicode/uniset.h +++ b/deps/icu-small/source/common/unicode/uniset.h @@ -13,6 +13,10 @@ #ifndef UNICODESET_H #define UNICODESET_H +#include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/ucpmap.h" #include "unicode/unifilt.h" #include "unicode/unistr.h" @@ -501,7 +505,7 @@ class U_COMMON_API UnicodeSet U_FINAL : public UnicodeFilter { * @see cloneAsThawed * @stable ICU 2.0 */ - virtual UnicodeFunctor* clone() const; + virtual UnicodeSet* clone() const; /** * Returns the hash code value for this set. @@ -579,7 +583,7 @@ class U_COMMON_API UnicodeSet U_FINAL : public UnicodeFilter { * @see cloneAsThawed * @stable ICU 3.8 */ - UnicodeFunctor *freeze(); + UnicodeSet *freeze(); /** * Clone the set and make the clone mutable. @@ -589,7 +593,7 @@ class U_COMMON_API UnicodeSet U_FINAL : public UnicodeFilter { * @see isFrozen * @stable ICU 3.8 */ - UnicodeFunctor *cloneAsThawed() const; + UnicodeSet *cloneAsThawed() const; //---------------------------------------------------------------- // Public API @@ -1651,11 +1655,10 @@ class U_COMMON_API UnicodeSet U_FINAL : public UnicodeFilter { const UnicodeSet* inclusions, UErrorCode &status); -#ifndef U_HIDE_DRAFT_API // Skipped: ucpmap.h is draft only. + // UCPMap is now stable ICU 63 void applyIntPropertyValue(const UCPMap *map, UCPMapValueFilter *filter, const void *context, UErrorCode &errorCode); -#endif /* U_HIDE_DRAFT_API */ /** * Set the new pattern to cache. @@ -1736,4 +1739,6 @@ inline int32_t UnicodeSet::spanBack(const UnicodeString &s, int32_t limit, USetS U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/common/unicode/unistr.h b/deps/icu-small/source/common/unicode/unistr.h index 8fd144425e87c0..da79053765acf6 100644 --- a/deps/icu-small/source/common/unicode/unistr.h +++ b/deps/icu-small/source/common/unicode/unistr.h @@ -28,8 +28,11 @@ * \brief C++ API: Unicode String */ -#include #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + +#include #include "unicode/char16ptr.h" #include "unicode/rep.h" #include "unicode/std_string.h" @@ -209,7 +212,9 @@ class UnicodeStringAppendable; // unicode/appendable.h * similar functionality as the Java String and StringBuffer/StringBuilder classes. * It is a concrete implementation of the abstract class Replaceable (for transliteration). * - * A UnicodeString may also "alias" an external array of characters + * The UnicodeString equivalent of std::string’s clear() is remove(). + * + * A UnicodeString may "alias" an external array of characters * (that is, point to it, rather than own the array) * whose lifetime must then at least match the lifetime of the aliasing object. * This aliasing may be preserved when returning a UnicodeString by value, @@ -2092,8 +2097,7 @@ class U_COMMON_API UnicodeString : public Replaceable * s.truncate(0); // set to an empty string (complete truncation), or * s=UnicodeString(); // assign an empty string, or * s.setTo((UChar32)-1); // set to a pseudo code point that is out of range, or - * static const char16_t nul=0; - * s.setTo(&nul, 0); // set to an empty C Unicode string + * s.setTo(u"", 0); // set to an empty C Unicode string * } * \endcode * @@ -2534,11 +2538,14 @@ class U_COMMON_API UnicodeString : public Replaceable /* Remove operations */ /** - * Remove all characters from the UnicodeString object. + * Removes all characters from the UnicodeString object and clears the bogus flag. + * This is the UnicodeString equivalent of std::string’s clear(). + * * @return a reference to this + * @see setToBogus * @stable ICU 2.0 */ - inline UnicodeString& remove(void); + inline UnicodeString& remove(); /** * Remove the characters in the range @@ -3034,11 +3041,11 @@ class U_COMMON_API UnicodeString : public Replaceable * uint16_t * constructor. * Delegates to UnicodeString(const char16_t *, int32_t). * @param text UTF-16 string - * @param length string length + * @param textLength string length * @stable ICU 59 */ - UnicodeString(const uint16_t *text, int32_t length) : - UnicodeString(ConstChar16Ptr(text), length) {} + UnicodeString(const uint16_t *text, int32_t textLength) : + UnicodeString(ConstChar16Ptr(text), textLength) {} #endif #if U_SIZEOF_WCHAR_T==2 || defined(U_IN_DOXYGEN) @@ -3047,21 +3054,21 @@ class U_COMMON_API UnicodeString : public Replaceable * (Only defined if U_SIZEOF_WCHAR_T==2.) * Delegates to UnicodeString(const char16_t *, int32_t). * @param text NUL-terminated UTF-16 string - * @param length string length + * @param textLength string length * @stable ICU 59 */ - UnicodeString(const wchar_t *text, int32_t length) : - UnicodeString(ConstChar16Ptr(text), length) {} + UnicodeString(const wchar_t *text, int32_t textLength) : + UnicodeString(ConstChar16Ptr(text), textLength) {} #endif /** * nullptr_t constructor. * Effectively the same as the default constructor, makes an empty string object. * @param text nullptr - * @param length ignored + * @param textLength ignored * @stable ICU 59 */ - inline UnicodeString(const std::nullptr_t text, int32_t length); + inline UnicodeString(const std::nullptr_t text, int32_t textLength); /** * Readonly-aliasing char16_t* constructor. @@ -3266,13 +3273,13 @@ class U_COMMON_API UnicodeString : public Replaceable * } * \endcode * @param src String using only invariant characters. - * @param length Length of src, or -1 if NUL-terminated. + * @param textLength Length of src, or -1 if NUL-terminated. * @param inv Signature-distinguishing paramater, use US_INV. * * @see US_INV * @stable ICU 3.2 */ - UnicodeString(const char *src, int32_t length, enum EInvariant inv); + UnicodeString(const char *src, int32_t textLength, enum EInvariant inv); /** @@ -3323,9 +3330,6 @@ class U_COMMON_API UnicodeString : public Replaceable * Clones can be used concurrently in multiple threads. * If a subclass does not implement clone(), or if an error occurs, * then NULL is returned. - * The clone functions in all subclasses return a pointer to a Replaceable - * because some compilers do not support covariant (same-as-this) - * return types; cast to the appropriate subclass if necessary. * The caller must delete the clone. * * @return a clone of this object @@ -3334,7 +3338,7 @@ class U_COMMON_API UnicodeString : public Replaceable * @see getDynamicClassID * @stable ICU 2.6 */ - virtual Replaceable *clone() const; + virtual UnicodeString *clone() const; /** Destructor. * @stable ICU 2.0 @@ -4748,4 +4752,6 @@ UnicodeString::reverse(int32_t start, U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/common/unicode/unorm.h b/deps/icu-small/source/common/unicode/unorm.h index 3839de129573c1..09dd366a968c1b 100644 --- a/deps/icu-small/source/common/unicode/unorm.h +++ b/deps/icu-small/source/common/unicode/unorm.h @@ -131,6 +131,8 @@ // Do not conditionalize the following enum with #ifndef U_HIDE_DEPRECATED_API, // it is needed for layout of Normalizer object. +#ifndef U_FORCE_HIDE_DEPRECATED_API + /** * Constants for normalization modes. * @deprecated ICU 56 Use unorm2.h instead. @@ -155,6 +157,8 @@ typedef enum { UNORM_MODE_COUNT } UNormalizationMode; +#endif // U_FORCE_HIDE_DEPRECATED_API + #ifndef U_HIDE_DEPRECATED_API /** diff --git a/deps/icu-small/source/common/unicode/uobject.h b/deps/icu-small/source/common/unicode/uobject.h index 53b8eb005f4cc0..6a137af83c2456 100644 --- a/deps/icu-small/source/common/unicode/uobject.h +++ b/deps/icu-small/source/common/unicode/uobject.h @@ -20,6 +20,9 @@ #define __UOBJECT_H__ #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/platform.h" /** @@ -43,7 +46,7 @@ * @stable ICU 4.2. Since ICU 64, Use U_NOEXCEPT instead. See ICU-20422. */ #ifndef U_NO_THROW -#define U_NO_THROW throw() +#define U_NO_THROW U_NOEXCEPT #endif /*===========================================================================*/ @@ -212,11 +215,8 @@ class U_COMMON_API UMemory { * The clone() function is not available in UObject because it is not * implemented by all ICU classes. * Many ICU services provide a clone() function for their class trees, - * defined on the service's C++ base class, and all subclasses within that - * service class tree return a pointer to the service base class + * defined on the service's C++ base class * (which itself is a subclass of UObject). - * This is because some compilers do not support covariant (same-as-this) - * return types; cast to the appropriate subclass if necessary. * * @stable ICU 2.2 */ @@ -319,4 +319,6 @@ class U_COMMON_API UObject : public UMemory { U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/common/unicode/urename.h b/deps/icu-small/source/common/unicode/urename.h index eaf56c9614d7f2..e302bf0976e01d 100644 --- a/deps/icu-small/source/common/unicode/urename.h +++ b/deps/icu-small/source/common/unicode/urename.h @@ -193,10 +193,13 @@ #define res_getAlias U_ICU_ENTRY_POINT_RENAME(res_getAlias) #define res_getArrayItem U_ICU_ENTRY_POINT_RENAME(res_getArrayItem) #define res_getBinary U_ICU_ENTRY_POINT_RENAME(res_getBinary) +#define res_getBinaryNoTrace U_ICU_ENTRY_POINT_RENAME(res_getBinaryNoTrace) #define res_getIntVector U_ICU_ENTRY_POINT_RENAME(res_getIntVector) +#define res_getIntVectorNoTrace U_ICU_ENTRY_POINT_RENAME(res_getIntVectorNoTrace) #define res_getPublicType U_ICU_ENTRY_POINT_RENAME(res_getPublicType) #define res_getResource U_ICU_ENTRY_POINT_RENAME(res_getResource) #define res_getString U_ICU_ENTRY_POINT_RENAME(res_getString) +#define res_getStringNoTrace U_ICU_ENTRY_POINT_RENAME(res_getStringNoTrace) #define res_getTableItemByIndex U_ICU_ENTRY_POINT_RENAME(res_getTableItemByIndex) #define res_getTableItemByKey U_ICU_ENTRY_POINT_RENAME(res_getTableItemByKey) #define res_load U_ICU_ENTRY_POINT_RENAME(res_load) @@ -523,6 +526,7 @@ #define ucal_getDefaultTimeZone U_ICU_ENTRY_POINT_RENAME(ucal_getDefaultTimeZone) #define ucal_getFieldDifference U_ICU_ENTRY_POINT_RENAME(ucal_getFieldDifference) #define ucal_getGregorianChange U_ICU_ENTRY_POINT_RENAME(ucal_getGregorianChange) +#define ucal_getHostTimeZone U_ICU_ENTRY_POINT_RENAME(ucal_getHostTimeZone) #define ucal_getKeywordValuesForLocale U_ICU_ENTRY_POINT_RENAME(ucal_getKeywordValuesForLocale) #define ucal_getLimit U_ICU_ENTRY_POINT_RENAME(ucal_getLimit) #define ucal_getLocaleByType U_ICU_ENTRY_POINT_RENAME(ucal_getLocaleByType) @@ -575,7 +579,6 @@ #define ucasemap_getLocale U_ICU_ENTRY_POINT_RENAME(ucasemap_getLocale) #define ucasemap_getOptions U_ICU_ENTRY_POINT_RENAME(ucasemap_getOptions) #define ucasemap_internalUTF8ToTitle U_ICU_ENTRY_POINT_RENAME(ucasemap_internalUTF8ToTitle) -#define ucasemap_mapUTF8 U_ICU_ENTRY_POINT_RENAME(ucasemap_mapUTF8) #define ucasemap_open U_ICU_ENTRY_POINT_RENAME(ucasemap_open) #define ucasemap_setBreakIterator U_ICU_ENTRY_POINT_RENAME(ucasemap_setBreakIterator) #define ucasemap_setLocale U_ICU_ENTRY_POINT_RENAME(ucasemap_setLocale) @@ -930,16 +933,9 @@ #define ufieldpositer_close U_ICU_ENTRY_POINT_RENAME(ufieldpositer_close) #define ufieldpositer_next U_ICU_ENTRY_POINT_RENAME(ufieldpositer_next) #define ufieldpositer_open U_ICU_ENTRY_POINT_RENAME(ufieldpositer_open) -#define ufile_close_translit U_ICU_ENTRY_POINT_RENAME(ufile_close_translit) -#define ufile_fill_uchar_buffer U_ICU_ENTRY_POINT_RENAME(ufile_fill_uchar_buffer) -#define ufile_flush_io U_ICU_ENTRY_POINT_RENAME(ufile_flush_io) -#define ufile_flush_translit U_ICU_ENTRY_POINT_RENAME(ufile_flush_translit) #define ufile_getch U_ICU_ENTRY_POINT_RENAME(ufile_getch) #define ufile_getch32 U_ICU_ENTRY_POINT_RENAME(ufile_getch32) -#define ufmt_64tou U_ICU_ENTRY_POINT_RENAME(ufmt_64tou) #define ufmt_close U_ICU_ENTRY_POINT_RENAME(ufmt_close) -#define ufmt_defaultCPToUnicode U_ICU_ENTRY_POINT_RENAME(ufmt_defaultCPToUnicode) -#define ufmt_digitvalue U_ICU_ENTRY_POINT_RENAME(ufmt_digitvalue) #define ufmt_getArrayItemByIndex U_ICU_ENTRY_POINT_RENAME(ufmt_getArrayItemByIndex) #define ufmt_getArrayLength U_ICU_ENTRY_POINT_RENAME(ufmt_getArrayLength) #define ufmt_getDate U_ICU_ENTRY_POINT_RENAME(ufmt_getDate) @@ -951,11 +947,7 @@ #define ufmt_getType U_ICU_ENTRY_POINT_RENAME(ufmt_getType) #define ufmt_getUChars U_ICU_ENTRY_POINT_RENAME(ufmt_getUChars) #define ufmt_isNumeric U_ICU_ENTRY_POINT_RENAME(ufmt_isNumeric) -#define ufmt_isdigit U_ICU_ENTRY_POINT_RENAME(ufmt_isdigit) #define ufmt_open U_ICU_ENTRY_POINT_RENAME(ufmt_open) -#define ufmt_ptou U_ICU_ENTRY_POINT_RENAME(ufmt_ptou) -#define ufmt_uto64 U_ICU_ENTRY_POINT_RENAME(ufmt_uto64) -#define ufmt_utop U_ICU_ENTRY_POINT_RENAME(ufmt_utop) #define ufmtval_getString U_ICU_ENTRY_POINT_RENAME(ufmtval_getString) #define ufmtval_nextPosition U_ICU_ENTRY_POINT_RENAME(ufmtval_nextPosition) #define ugender_getInstance U_ICU_ENTRY_POINT_RENAME(ugender_getInstance) @@ -1103,6 +1095,7 @@ #define uloc_getVariant U_ICU_ENTRY_POINT_RENAME(uloc_getVariant) #define uloc_isRightToLeft U_ICU_ENTRY_POINT_RENAME(uloc_isRightToLeft) #define uloc_minimizeSubtags U_ICU_ENTRY_POINT_RENAME(uloc_minimizeSubtags) +#define uloc_openAvailableByType U_ICU_ENTRY_POINT_RENAME(uloc_openAvailableByType) #define uloc_openKeywordList U_ICU_ENTRY_POINT_RENAME(uloc_openKeywordList) #define uloc_openKeywords U_ICU_ENTRY_POINT_RENAME(uloc_openKeywords) #define uloc_setDefault U_ICU_ENTRY_POINT_RENAME(uloc_setDefault) @@ -1159,9 +1152,6 @@ #define umsg_toPattern U_ICU_ENTRY_POINT_RENAME(umsg_toPattern) #define umsg_vformat U_ICU_ENTRY_POINT_RENAME(umsg_vformat) #define umsg_vparse U_ICU_ENTRY_POINT_RENAME(umsg_vparse) -#define umtx_condBroadcast U_ICU_ENTRY_POINT_RENAME(umtx_condBroadcast) -#define umtx_condSignal U_ICU_ENTRY_POINT_RENAME(umtx_condSignal) -#define umtx_condWait U_ICU_ENTRY_POINT_RENAME(umtx_condWait) #define umtx_lock U_ICU_ENTRY_POINT_RENAME(umtx_lock) #define umtx_unlock U_ICU_ENTRY_POINT_RENAME(umtx_unlock) #define umutablecptrie_buildImmutable U_ICU_ENTRY_POINT_RENAME(umutablecptrie_buildImmutable) @@ -1327,7 +1317,6 @@ #define uprv_decNumberAbs U_ICU_ENTRY_POINT_RENAME(uprv_decNumberAbs) #define uprv_decNumberAdd U_ICU_ENTRY_POINT_RENAME(uprv_decNumberAdd) #define uprv_decNumberAnd U_ICU_ENTRY_POINT_RENAME(uprv_decNumberAnd) -#define uprv_decNumberClass U_ICU_ENTRY_POINT_RENAME(uprv_decNumberClass) #define uprv_decNumberClassToString U_ICU_ENTRY_POINT_RENAME(uprv_decNumberClassToString) #define uprv_decNumberCompare U_ICU_ENTRY_POINT_RENAME(uprv_decNumberCompare) #define uprv_decNumberCompareSignal U_ICU_ENTRY_POINT_RENAME(uprv_decNumberCompareSignal) @@ -1393,6 +1382,7 @@ #define uprv_dlsym_func U_ICU_ENTRY_POINT_RENAME(uprv_dlsym_func) #define uprv_eastrncpy U_ICU_ENTRY_POINT_RENAME(uprv_eastrncpy) #define uprv_ebcdicFromAscii U_ICU_ENTRY_POINT_RENAME(uprv_ebcdicFromAscii) +#define uprv_ebcdicToAscii U_ICU_ENTRY_POINT_RENAME(uprv_ebcdicToAscii) #define uprv_ebcdicToLowercaseAscii U_ICU_ENTRY_POINT_RENAME(uprv_ebcdicToLowercaseAscii) #define uprv_ebcdictolower U_ICU_ENTRY_POINT_RENAME(uprv_ebcdictolower) #define uprv_fabs U_ICU_ENTRY_POINT_RENAME(uprv_fabs) @@ -1412,6 +1402,7 @@ #define uprv_getUTCtime U_ICU_ENTRY_POINT_RENAME(uprv_getUTCtime) #define uprv_int32Comparator U_ICU_ENTRY_POINT_RENAME(uprv_int32Comparator) #define uprv_isASCIILetter U_ICU_ENTRY_POINT_RENAME(uprv_isASCIILetter) +#define uprv_isEbcdicAtSign U_ICU_ENTRY_POINT_RENAME(uprv_isEbcdicAtSign) #define uprv_isInfinite U_ICU_ENTRY_POINT_RENAME(uprv_isInfinite) #define uprv_isInvariantString U_ICU_ENTRY_POINT_RENAME(uprv_isInvariantString) #define uprv_isInvariantUString U_ICU_ENTRY_POINT_RENAME(uprv_isInvariantUString) @@ -1579,6 +1570,7 @@ #define ures_getUTF8String U_ICU_ENTRY_POINT_RENAME(ures_getUTF8String) #define ures_getUTF8StringByIndex U_ICU_ENTRY_POINT_RENAME(ures_getUTF8StringByIndex) #define ures_getUTF8StringByKey U_ICU_ENTRY_POINT_RENAME(ures_getUTF8StringByKey) +#define ures_getValueWithFallback U_ICU_ENTRY_POINT_RENAME(ures_getValueWithFallback) #define ures_getVersion U_ICU_ENTRY_POINT_RENAME(ures_getVersion) #define ures_getVersionByKey U_ICU_ENTRY_POINT_RENAME(ures_getVersionByKey) #define ures_getVersionNumber U_ICU_ENTRY_POINT_RENAME(ures_getVersionNumber) diff --git a/deps/icu-small/source/common/unicode/usetiter.h b/deps/icu-small/source/common/unicode/usetiter.h index 057adbc04f5f05..f3f470f95aa5f5 100644 --- a/deps/icu-small/source/common/unicode/usetiter.h +++ b/deps/icu-small/source/common/unicode/usetiter.h @@ -10,6 +10,9 @@ #define USETITER_H #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/uobject.h" #include "unicode/unistr.h" @@ -317,4 +320,6 @@ inline UChar32 UnicodeSetIterator::getCodepointEnd() const { U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/common/unicode/utext.h b/deps/icu-small/source/common/unicode/utext.h index ff78784c61ec54..6f1e3409d8fdeb 100644 --- a/deps/icu-small/source/common/unicode/utext.h +++ b/deps/icu-small/source/common/unicode/utext.h @@ -766,12 +766,14 @@ utext_extract(UText *ut, * * @stable ICU 3.8 */ -#define UTEXT_SETNATIVEINDEX(ut, ix) \ - { int64_t __offset = (ix) - (ut)->chunkNativeStart; \ - if (__offset>=0 && __offset<(int64_t)(ut)->nativeIndexingLimit && (ut)->chunkContents[__offset]<0xdc00) { \ - (ut)->chunkOffset=(int32_t)__offset; \ - } else { \ - utext_setNativeIndex((ut), (ix)); } } +#define UTEXT_SETNATIVEINDEX(ut, ix) UPRV_BLOCK_MACRO_BEGIN { \ + int64_t __offset = (ix) - (ut)->chunkNativeStart; \ + if (__offset>=0 && __offset<(int64_t)(ut)->nativeIndexingLimit && (ut)->chunkContents[__offset]<0xdc00) { \ + (ut)->chunkOffset=(int32_t)__offset; \ + } else { \ + utext_setNativeIndex((ut), (ix)); \ + } \ +} UPRV_BLOCK_MACRO_END diff --git a/deps/icu-small/source/common/unicode/utf16.h b/deps/icu-small/source/common/unicode/utf16.h index 0908b4f00e9bf1..3315214ae69d86 100644 --- a/deps/icu-small/source/common/unicode/utf16.h +++ b/deps/icu-small/source/common/unicode/utf16.h @@ -163,7 +163,7 @@ * @see U16_GET * @stable ICU 2.4 */ -#define U16_GET_UNSAFE(s, i, c) { \ +#define U16_GET_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[i]; \ if(U16_IS_SURROGATE(c)) { \ if(U16_IS_SURROGATE_LEAD(c)) { \ @@ -172,7 +172,7 @@ (c)=U16_GET_SUPPLEMENTARY((s)[(i)-1], (c)); \ } \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Get a code point from a string at a random-access offset, @@ -197,7 +197,7 @@ * @see U16_GET_UNSAFE * @stable ICU 2.4 */ -#define U16_GET(s, start, i, length, c) { \ +#define U16_GET(s, start, i, length, c) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[i]; \ if(U16_IS_SURROGATE(c)) { \ uint16_t __c2; \ @@ -211,7 +211,7 @@ } \ } \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Get a code point from a string at a random-access offset, @@ -236,7 +236,7 @@ * @see U16_GET_UNSAFE * @stable ICU 60 */ -#define U16_GET_OR_FFFD(s, start, i, length, c) { \ +#define U16_GET_OR_FFFD(s, start, i, length, c) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[i]; \ if(U16_IS_SURROGATE(c)) { \ uint16_t __c2; \ @@ -254,7 +254,7 @@ } \ } \ } \ -} +} UPRV_BLOCK_MACRO_END /* definitions with forward iteration --------------------------------------- */ @@ -277,12 +277,12 @@ * @see U16_NEXT * @stable ICU 2.4 */ -#define U16_NEXT_UNSAFE(s, i, c) { \ +#define U16_NEXT_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[(i)++]; \ if(U16_IS_LEAD(c)) { \ (c)=U16_GET_SUPPLEMENTARY((c), (s)[(i)++]); \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Get a code point from a string at a code point boundary offset, @@ -305,7 +305,7 @@ * @see U16_NEXT_UNSAFE * @stable ICU 2.4 */ -#define U16_NEXT(s, i, length, c) { \ +#define U16_NEXT(s, i, length, c) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[(i)++]; \ if(U16_IS_LEAD(c)) { \ uint16_t __c2; \ @@ -314,7 +314,7 @@ (c)=U16_GET_SUPPLEMENTARY((c), __c2); \ } \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Get a code point from a string at a code point boundary offset, @@ -337,7 +337,7 @@ * @see U16_NEXT_UNSAFE * @stable ICU 60 */ -#define U16_NEXT_OR_FFFD(s, i, length, c) { \ +#define U16_NEXT_OR_FFFD(s, i, length, c) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[(i)++]; \ if(U16_IS_SURROGATE(c)) { \ uint16_t __c2; \ @@ -348,7 +348,7 @@ (c)=0xfffd; \ } \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Append a code point to a string, overwriting 1 or 2 code units. @@ -363,14 +363,14 @@ * @see U16_APPEND * @stable ICU 2.4 */ -#define U16_APPEND_UNSAFE(s, i, c) { \ +#define U16_APPEND_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \ if((uint32_t)(c)<=0xffff) { \ (s)[(i)++]=(uint16_t)(c); \ } else { \ (s)[(i)++]=(uint16_t)(((c)>>10)+0xd7c0); \ (s)[(i)++]=(uint16_t)(((c)&0x3ff)|0xdc00); \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Append a code point to a string, overwriting 1 or 2 code units. @@ -389,7 +389,7 @@ * @see U16_APPEND_UNSAFE * @stable ICU 2.4 */ -#define U16_APPEND(s, i, capacity, c, isError) { \ +#define U16_APPEND(s, i, capacity, c, isError) UPRV_BLOCK_MACRO_BEGIN { \ if((uint32_t)(c)<=0xffff) { \ (s)[(i)++]=(uint16_t)(c); \ } else if((uint32_t)(c)<=0x10ffff && (i)+1<(capacity)) { \ @@ -398,7 +398,7 @@ } else /* c>0x10ffff or not enough space */ { \ (isError)=TRUE; \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Advance the string offset from one code point boundary to the next. @@ -410,11 +410,11 @@ * @see U16_FWD_1 * @stable ICU 2.4 */ -#define U16_FWD_1_UNSAFE(s, i) { \ +#define U16_FWD_1_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \ if(U16_IS_LEAD((s)[(i)++])) { \ ++(i); \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Advance the string offset from one code point boundary to the next. @@ -429,11 +429,11 @@ * @see U16_FWD_1_UNSAFE * @stable ICU 2.4 */ -#define U16_FWD_1(s, i, length) { \ +#define U16_FWD_1(s, i, length) UPRV_BLOCK_MACRO_BEGIN { \ if(U16_IS_LEAD((s)[(i)++]) && (i)!=(length) && U16_IS_TRAIL((s)[i])) { \ ++(i); \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Advance the string offset from one code point boundary to the n-th next one, @@ -447,13 +447,13 @@ * @see U16_FWD_N * @stable ICU 2.4 */ -#define U16_FWD_N_UNSAFE(s, i, n) { \ +#define U16_FWD_N_UNSAFE(s, i, n) UPRV_BLOCK_MACRO_BEGIN { \ int32_t __N=(n); \ while(__N>0) { \ U16_FWD_1_UNSAFE(s, i); \ --__N; \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Advance the string offset from one code point boundary to the n-th next one, @@ -470,13 +470,13 @@ * @see U16_FWD_N_UNSAFE * @stable ICU 2.4 */ -#define U16_FWD_N(s, i, length, n) { \ +#define U16_FWD_N(s, i, length, n) UPRV_BLOCK_MACRO_BEGIN { \ int32_t __N=(n); \ while(__N>0 && ((i)<(length) || ((length)<0 && (s)[i]!=0))) { \ U16_FWD_1(s, i, length); \ --__N; \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Adjust a random-access offset to a code point boundary @@ -491,11 +491,11 @@ * @see U16_SET_CP_START * @stable ICU 2.4 */ -#define U16_SET_CP_START_UNSAFE(s, i) { \ +#define U16_SET_CP_START_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \ if(U16_IS_TRAIL((s)[i])) { \ --(i); \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Adjust a random-access offset to a code point boundary @@ -511,11 +511,11 @@ * @see U16_SET_CP_START_UNSAFE * @stable ICU 2.4 */ -#define U16_SET_CP_START(s, start, i) { \ +#define U16_SET_CP_START(s, start, i) UPRV_BLOCK_MACRO_BEGIN { \ if(U16_IS_TRAIL((s)[i]) && (i)>(start) && U16_IS_LEAD((s)[(i)-1])) { \ --(i); \ } \ -} +} UPRV_BLOCK_MACRO_END /* definitions with backward iteration -------------------------------------- */ @@ -539,12 +539,12 @@ * @see U16_PREV * @stable ICU 2.4 */ -#define U16_PREV_UNSAFE(s, i, c) { \ +#define U16_PREV_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[--(i)]; \ if(U16_IS_TRAIL(c)) { \ (c)=U16_GET_SUPPLEMENTARY((s)[--(i)], (c)); \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Move the string offset from one code point boundary to the previous one @@ -566,7 +566,7 @@ * @see U16_PREV_UNSAFE * @stable ICU 2.4 */ -#define U16_PREV(s, start, i, c) { \ +#define U16_PREV(s, start, i, c) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[--(i)]; \ if(U16_IS_TRAIL(c)) { \ uint16_t __c2; \ @@ -575,7 +575,7 @@ (c)=U16_GET_SUPPLEMENTARY(__c2, (c)); \ } \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Move the string offset from one code point boundary to the previous one @@ -597,7 +597,7 @@ * @see U16_PREV_UNSAFE * @stable ICU 60 */ -#define U16_PREV_OR_FFFD(s, start, i, c) { \ +#define U16_PREV_OR_FFFD(s, start, i, c) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[--(i)]; \ if(U16_IS_SURROGATE(c)) { \ uint16_t __c2; \ @@ -608,7 +608,7 @@ (c)=0xfffd; \ } \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Move the string offset from one code point boundary to the previous one. @@ -621,11 +621,11 @@ * @see U16_BACK_1 * @stable ICU 2.4 */ -#define U16_BACK_1_UNSAFE(s, i) { \ +#define U16_BACK_1_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \ if(U16_IS_TRAIL((s)[--(i)])) { \ --(i); \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Move the string offset from one code point boundary to the previous one. @@ -639,11 +639,11 @@ * @see U16_BACK_1_UNSAFE * @stable ICU 2.4 */ -#define U16_BACK_1(s, start, i) { \ +#define U16_BACK_1(s, start, i) UPRV_BLOCK_MACRO_BEGIN { \ if(U16_IS_TRAIL((s)[--(i)]) && (i)>(start) && U16_IS_LEAD((s)[(i)-1])) { \ --(i); \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Move the string offset from one code point boundary to the n-th one before it, @@ -658,13 +658,13 @@ * @see U16_BACK_N * @stable ICU 2.4 */ -#define U16_BACK_N_UNSAFE(s, i, n) { \ +#define U16_BACK_N_UNSAFE(s, i, n) UPRV_BLOCK_MACRO_BEGIN { \ int32_t __N=(n); \ while(__N>0) { \ U16_BACK_1_UNSAFE(s, i); \ --__N; \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Move the string offset from one code point boundary to the n-th one before it, @@ -680,13 +680,13 @@ * @see U16_BACK_N_UNSAFE * @stable ICU 2.4 */ -#define U16_BACK_N(s, start, i, n) { \ +#define U16_BACK_N(s, start, i, n) UPRV_BLOCK_MACRO_BEGIN { \ int32_t __N=(n); \ while(__N>0 && (i)>(start)) { \ U16_BACK_1(s, start, i); \ --__N; \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Adjust a random-access offset to a code point boundary after a code point. @@ -701,11 +701,11 @@ * @see U16_SET_CP_LIMIT * @stable ICU 2.4 */ -#define U16_SET_CP_LIMIT_UNSAFE(s, i) { \ +#define U16_SET_CP_LIMIT_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \ if(U16_IS_LEAD((s)[(i)-1])) { \ ++(i); \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Adjust a random-access offset to a code point boundary after a code point. @@ -724,10 +724,10 @@ * @see U16_SET_CP_LIMIT_UNSAFE * @stable ICU 2.4 */ -#define U16_SET_CP_LIMIT(s, start, i, length) { \ +#define U16_SET_CP_LIMIT(s, start, i, length) UPRV_BLOCK_MACRO_BEGIN { \ if((start)<(i) && ((i)<(length) || (length)<0) && U16_IS_LEAD((s)[(i)-1]) && U16_IS_TRAIL((s)[i])) { \ ++(i); \ } \ -} +} UPRV_BLOCK_MACRO_END #endif diff --git a/deps/icu-small/source/common/unicode/utf8.h b/deps/icu-small/source/common/unicode/utf8.h index 41155f119bbb86..bb001303747efe 100644 --- a/deps/icu-small/source/common/unicode/utf8.h +++ b/deps/icu-small/source/common/unicode/utf8.h @@ -229,11 +229,11 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @see U8_GET * @stable ICU 2.4 */ -#define U8_GET_UNSAFE(s, i, c) { \ +#define U8_GET_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \ int32_t _u8_get_unsafe_index=(int32_t)(i); \ U8_SET_CP_START_UNSAFE(s, _u8_get_unsafe_index); \ U8_NEXT_UNSAFE(s, _u8_get_unsafe_index, c); \ -} +} UPRV_BLOCK_MACRO_END /** * Get a code point from a string at a random-access offset, @@ -256,11 +256,11 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @see U8_GET_UNSAFE * @stable ICU 2.4 */ -#define U8_GET(s, start, i, length, c) { \ +#define U8_GET(s, start, i, length, c) UPRV_BLOCK_MACRO_BEGIN { \ int32_t _u8_get_index=(i); \ U8_SET_CP_START(s, start, _u8_get_index); \ U8_NEXT(s, _u8_get_index, length, c); \ -} +} UPRV_BLOCK_MACRO_END /** * Get a code point from a string at a random-access offset, @@ -287,11 +287,11 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @see U8_GET * @stable ICU 51 */ -#define U8_GET_OR_FFFD(s, start, i, length, c) { \ +#define U8_GET_OR_FFFD(s, start, i, length, c) UPRV_BLOCK_MACRO_BEGIN { \ int32_t _u8_get_index=(i); \ U8_SET_CP_START(s, start, _u8_get_index); \ U8_NEXT_OR_FFFD(s, _u8_get_index, length, c); \ -} +} UPRV_BLOCK_MACRO_END /* definitions with forward iteration --------------------------------------- */ @@ -312,7 +312,7 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @see U8_NEXT * @stable ICU 2.4 */ -#define U8_NEXT_UNSAFE(s, i, c) { \ +#define U8_NEXT_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(uint8_t)(s)[(i)++]; \ if(!U8_IS_SINGLE(c)) { \ if((c)<0xe0) { \ @@ -326,7 +326,7 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); (i)+=3; \ } \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Get a code point from a string at a code point boundary offset, @@ -377,7 +377,7 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); #define U8_NEXT_OR_FFFD(s, i, length, c) U8_INTERNAL_NEXT_OR_SUB(s, i, length, c, 0xfffd) /** @internal */ -#define U8_INTERNAL_NEXT_OR_SUB(s, i, length, c, sub) { \ +#define U8_INTERNAL_NEXT_OR_SUB(s, i, length, c, sub) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(uint8_t)(s)[(i)++]; \ if(!U8_IS_SINGLE(c)) { \ uint8_t __t = 0; \ @@ -403,7 +403,7 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); (c)=(sub); /* ill-formed*/ \ } \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Append a code point to a string, overwriting 1 to 4 bytes. @@ -418,7 +418,7 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @see U8_APPEND * @stable ICU 2.4 */ -#define U8_APPEND_UNSAFE(s, i, c) { \ +#define U8_APPEND_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \ uint32_t __uc=(c); \ if(__uc<=0x7f) { \ (s)[(i)++]=(uint8_t)__uc; \ @@ -436,7 +436,7 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); } \ (s)[(i)++]=(uint8_t)((__uc&0x3f)|0x80); \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Append a code point to a string, overwriting 1 to 4 bytes. @@ -455,7 +455,7 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @see U8_APPEND_UNSAFE * @stable ICU 2.4 */ -#define U8_APPEND(s, i, capacity, c, isError) { \ +#define U8_APPEND(s, i, capacity, c, isError) UPRV_BLOCK_MACRO_BEGIN { \ uint32_t __uc=(c); \ if(__uc<=0x7f) { \ (s)[(i)++]=(uint8_t)__uc; \ @@ -474,7 +474,7 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); } else { \ (isError)=TRUE; \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Advance the string offset from one code point boundary to the next. @@ -486,9 +486,9 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @see U8_FWD_1 * @stable ICU 2.4 */ -#define U8_FWD_1_UNSAFE(s, i) { \ +#define U8_FWD_1_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \ (i)+=1+U8_COUNT_TRAIL_BYTES_UNSAFE((s)[i]); \ -} +} UPRV_BLOCK_MACRO_END /** * Advance the string offset from one code point boundary to the next. @@ -503,7 +503,7 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @see U8_FWD_1_UNSAFE * @stable ICU 2.4 */ -#define U8_FWD_1(s, i, length) { \ +#define U8_FWD_1(s, i, length) UPRV_BLOCK_MACRO_BEGIN { \ uint8_t __b=(s)[(i)++]; \ if(U8_IS_LEAD(__b) && (i)!=(length)) { \ uint8_t __t1=(s)[i]; \ @@ -524,7 +524,7 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); } \ } \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Advance the string offset from one code point boundary to the n-th next one, @@ -538,13 +538,13 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @see U8_FWD_N * @stable ICU 2.4 */ -#define U8_FWD_N_UNSAFE(s, i, n) { \ +#define U8_FWD_N_UNSAFE(s, i, n) UPRV_BLOCK_MACRO_BEGIN { \ int32_t __N=(n); \ while(__N>0) { \ U8_FWD_1_UNSAFE(s, i); \ --__N; \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Advance the string offset from one code point boundary to the n-th next one, @@ -561,13 +561,13 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @see U8_FWD_N_UNSAFE * @stable ICU 2.4 */ -#define U8_FWD_N(s, i, length, n) { \ +#define U8_FWD_N(s, i, length, n) UPRV_BLOCK_MACRO_BEGIN { \ int32_t __N=(n); \ while(__N>0 && ((i)<(length) || ((length)<0 && (s)[i]!=0))) { \ U8_FWD_1(s, i, length); \ --__N; \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Adjust a random-access offset to a code point boundary @@ -582,9 +582,9 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @see U8_SET_CP_START * @stable ICU 2.4 */ -#define U8_SET_CP_START_UNSAFE(s, i) { \ +#define U8_SET_CP_START_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \ while(U8_IS_TRAIL((s)[i])) { --(i); } \ -} +} UPRV_BLOCK_MACRO_END /** * Adjust a random-access offset to a code point boundary @@ -603,11 +603,11 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @see U8_TRUNCATE_IF_INCOMPLETE * @stable ICU 2.4 */ -#define U8_SET_CP_START(s, start, i) { \ +#define U8_SET_CP_START(s, start, i) UPRV_BLOCK_MACRO_BEGIN { \ if(U8_IS_TRAIL((s)[(i)])) { \ (i)=utf8_back1SafeBody(s, start, (i)); \ } \ -} +} UPRV_BLOCK_MACRO_END /** * If the string ends with a UTF-8 byte sequence that is valid so far @@ -635,7 +635,7 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @see U8_SET_CP_START * @stable ICU 61 */ -#define U8_TRUNCATE_IF_INCOMPLETE(s, start, length) \ +#define U8_TRUNCATE_IF_INCOMPLETE(s, start, length) UPRV_BLOCK_MACRO_BEGIN { \ if((length)>(start)) { \ uint8_t __b1=s[(length)-1]; \ if(U8_IS_SINGLE(__b1)) { \ @@ -656,7 +656,8 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); } \ } \ } \ - } + } \ +} UPRV_BLOCK_MACRO_END /* definitions with backward iteration -------------------------------------- */ @@ -679,7 +680,7 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @see U8_PREV * @stable ICU 2.4 */ -#define U8_PREV_UNSAFE(s, i, c) { \ +#define U8_PREV_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(uint8_t)(s)[--(i)]; \ if(U8_IS_TRAIL(c)) { \ uint8_t __b, __count=1, __shift=6; \ @@ -699,7 +700,7 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); } \ } \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Move the string offset from one code point boundary to the previous one @@ -721,12 +722,12 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @see U8_PREV_UNSAFE * @stable ICU 2.4 */ -#define U8_PREV(s, start, i, c) { \ +#define U8_PREV(s, start, i, c) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(uint8_t)(s)[--(i)]; \ if(!U8_IS_SINGLE(c)) { \ (c)=utf8_prevCharSafeBody((const uint8_t *)s, start, &(i), c, -1); \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Move the string offset from one code point boundary to the previous one @@ -752,12 +753,12 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @see U8_PREV * @stable ICU 51 */ -#define U8_PREV_OR_FFFD(s, start, i, c) { \ +#define U8_PREV_OR_FFFD(s, start, i, c) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(uint8_t)(s)[--(i)]; \ if(!U8_IS_SINGLE(c)) { \ (c)=utf8_prevCharSafeBody((const uint8_t *)s, start, &(i), c, -3); \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Move the string offset from one code point boundary to the previous one. @@ -770,9 +771,9 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @see U8_BACK_1 * @stable ICU 2.4 */ -#define U8_BACK_1_UNSAFE(s, i) { \ +#define U8_BACK_1_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \ while(U8_IS_TRAIL((s)[--(i)])) {} \ -} +} UPRV_BLOCK_MACRO_END /** * Move the string offset from one code point boundary to the previous one. @@ -786,11 +787,11 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @see U8_BACK_1_UNSAFE * @stable ICU 2.4 */ -#define U8_BACK_1(s, start, i) { \ +#define U8_BACK_1(s, start, i) UPRV_BLOCK_MACRO_BEGIN { \ if(U8_IS_TRAIL((s)[--(i)])) { \ (i)=utf8_back1SafeBody(s, start, (i)); \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Move the string offset from one code point boundary to the n-th one before it, @@ -805,13 +806,13 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @see U8_BACK_N * @stable ICU 2.4 */ -#define U8_BACK_N_UNSAFE(s, i, n) { \ +#define U8_BACK_N_UNSAFE(s, i, n) UPRV_BLOCK_MACRO_BEGIN { \ int32_t __N=(n); \ while(__N>0) { \ U8_BACK_1_UNSAFE(s, i); \ --__N; \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Move the string offset from one code point boundary to the n-th one before it, @@ -827,13 +828,13 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @see U8_BACK_N_UNSAFE * @stable ICU 2.4 */ -#define U8_BACK_N(s, start, i, n) { \ +#define U8_BACK_N(s, start, i, n) UPRV_BLOCK_MACRO_BEGIN { \ int32_t __N=(n); \ while(__N>0 && (i)>(start)) { \ U8_BACK_1(s, start, i); \ --__N; \ } \ -} +} UPRV_BLOCK_MACRO_END /** * Adjust a random-access offset to a code point boundary after a code point. @@ -848,10 +849,10 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @see U8_SET_CP_LIMIT * @stable ICU 2.4 */ -#define U8_SET_CP_LIMIT_UNSAFE(s, i) { \ +#define U8_SET_CP_LIMIT_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \ U8_BACK_1_UNSAFE(s, i); \ U8_FWD_1_UNSAFE(s, i); \ -} +} UPRV_BLOCK_MACRO_END /** * Adjust a random-access offset to a code point boundary after a code point. @@ -870,11 +871,11 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); * @see U8_SET_CP_LIMIT_UNSAFE * @stable ICU 2.4 */ -#define U8_SET_CP_LIMIT(s, start, i, length) { \ +#define U8_SET_CP_LIMIT(s, start, i, length) UPRV_BLOCK_MACRO_BEGIN { \ if((start)<(i) && ((i)<(length) || (length)<0)) { \ U8_BACK_1(s, start, i); \ U8_FWD_1(s, i, length); \ } \ -} +} UPRV_BLOCK_MACRO_END #endif diff --git a/deps/icu-small/source/common/unicode/utf_old.h b/deps/icu-small/source/common/unicode/utf_old.h index 55c17c01df6db3..b2428e6b31e282 100644 --- a/deps/icu-small/source/common/unicode/utf_old.h +++ b/deps/icu-small/source/common/unicode/utf_old.h @@ -19,9 +19,6 @@ /** * \file * \brief C API: Deprecated macros for Unicode string handling - */ - -/** * * The macros in utf_old.h are all deprecated and their use discouraged. * Some of the design principles behind the set of UTF macros @@ -139,12 +136,16 @@ * *


* - * @deprecated ICU 2.4. Use the macros in utf.h, utf16.h, utf8.h instead. + * Deprecated ICU 2.4. Use the macros in utf.h, utf16.h, utf8.h instead. */ #ifndef __UTF_OLD_H__ #define __UTF_OLD_H__ +#include "unicode/utf.h" +#include "unicode/utf8.h" +#include "unicode/utf16.h" + /** * \def U_HIDE_OBSOLETE_UTF_OLD_H * @@ -162,10 +163,6 @@ #if !defined(U_HIDE_DEPRECATED_API) && !U_HIDE_OBSOLETE_UTF_OLD_H -#include "unicode/utf.h" -#include "unicode/utf8.h" -#include "unicode/utf16.h" - /* Formerly utf.h, part 1 --------------------------------------------------- */ #ifdef U_USE_UTF_DEPRECATES @@ -365,21 +362,21 @@ U_CFUNC U_IMPORT const uint8_t utf8_countTrailBytes[]; /* U_IMPORT2? */ /*U_I #define UTF8_ARRAY_SIZE(size) ((5*(size))/2) /** @deprecated ICU 2.4. Renamed to U8_GET_UNSAFE, see utf_old.h. */ -#define UTF8_GET_CHAR_UNSAFE(s, i, c) { \ +#define UTF8_GET_CHAR_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \ int32_t _utf8_get_char_unsafe_index=(int32_t)(i); \ UTF8_SET_CHAR_START_UNSAFE(s, _utf8_get_char_unsafe_index); \ UTF8_NEXT_CHAR_UNSAFE(s, _utf8_get_char_unsafe_index, c); \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Use U8_GET instead, see utf_old.h. */ -#define UTF8_GET_CHAR_SAFE(s, start, i, length, c, strict) { \ +#define UTF8_GET_CHAR_SAFE(s, start, i, length, c, strict) UPRV_BLOCK_MACRO_BEGIN { \ int32_t _utf8_get_char_safe_index=(int32_t)(i); \ UTF8_SET_CHAR_START_SAFE(s, start, _utf8_get_char_safe_index); \ UTF8_NEXT_CHAR_SAFE(s, _utf8_get_char_safe_index, length, c, strict); \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Renamed to U8_NEXT_UNSAFE, see utf_old.h. */ -#define UTF8_NEXT_CHAR_UNSAFE(s, i, c) { \ +#define UTF8_NEXT_CHAR_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[(i)++]; \ if((uint8_t)((c)-0xc0)<0x35) { \ uint8_t __count=UTF8_COUNT_TRAIL_BYTES(c); \ @@ -396,10 +393,10 @@ U_CFUNC U_IMPORT const uint8_t utf8_countTrailBytes[]; /* U_IMPORT2? */ /*U_I break; \ } \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Renamed to U8_APPEND_UNSAFE, see utf_old.h. */ -#define UTF8_APPEND_CHAR_UNSAFE(s, i, c) { \ +#define UTF8_APPEND_CHAR_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \ if((uint32_t)(c)<=0x7f) { \ (s)[(i)++]=(uint8_t)(c); \ } else { \ @@ -416,29 +413,29 @@ U_CFUNC U_IMPORT const uint8_t utf8_countTrailBytes[]; /* U_IMPORT2? */ /*U_I } \ (s)[(i)++]=(uint8_t)(((c)&0x3f)|0x80); \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Renamed to U8_FWD_1_UNSAFE, see utf_old.h. */ -#define UTF8_FWD_1_UNSAFE(s, i) { \ +#define UTF8_FWD_1_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \ (i)+=1+UTF8_COUNT_TRAIL_BYTES((s)[i]); \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Renamed to U8_FWD_N_UNSAFE, see utf_old.h. */ -#define UTF8_FWD_N_UNSAFE(s, i, n) { \ +#define UTF8_FWD_N_UNSAFE(s, i, n) UPRV_BLOCK_MACRO_BEGIN { \ int32_t __N=(n); \ while(__N>0) { \ UTF8_FWD_1_UNSAFE(s, i); \ --__N; \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Renamed to U8_SET_CP_START_UNSAFE, see utf_old.h. */ -#define UTF8_SET_CHAR_START_UNSAFE(s, i) { \ +#define UTF8_SET_CHAR_START_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \ while(UTF8_IS_TRAIL((s)[i])) { --(i); } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Use U8_NEXT instead, see utf_old.h. */ -#define UTF8_NEXT_CHAR_SAFE(s, i, length, c, strict) { \ +#define UTF8_NEXT_CHAR_SAFE(s, i, length, c, strict) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[(i)++]; \ if((c)>=0x80) { \ if(UTF8_IS_LEAD(c)) { \ @@ -447,16 +444,16 @@ U_CFUNC U_IMPORT const uint8_t utf8_countTrailBytes[]; /* U_IMPORT2? */ /*U_I (c)=UTF8_ERROR_VALUE_1; \ } \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Use U8_APPEND instead, see utf_old.h. */ -#define UTF8_APPEND_CHAR_SAFE(s, i, length, c) { \ +#define UTF8_APPEND_CHAR_SAFE(s, i, length, c) UPRV_BLOCK_MACRO_BEGIN { \ if((uint32_t)(c)<=0x7f) { \ (s)[(i)++]=(uint8_t)(c); \ } else { \ (i)=utf8_appendCharSafeBody(s, (int32_t)(i), (int32_t)(length), c, NULL); \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Renamed to U8_FWD_1, see utf_old.h. */ #define UTF8_FWD_1_SAFE(s, i, length) U8_FWD_1(s, i, length) @@ -468,7 +465,7 @@ U_CFUNC U_IMPORT const uint8_t utf8_countTrailBytes[]; /* U_IMPORT2? */ /*U_I #define UTF8_SET_CHAR_START_SAFE(s, start, i) U8_SET_CP_START(s, start, i) /** @deprecated ICU 2.4. Renamed to U8_PREV_UNSAFE, see utf_old.h. */ -#define UTF8_PREV_CHAR_UNSAFE(s, i, c) { \ +#define UTF8_PREV_CHAR_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[--(i)]; \ if(UTF8_IS_TRAIL(c)) { \ uint8_t __b, __count=1, __shift=6; \ @@ -488,30 +485,30 @@ U_CFUNC U_IMPORT const uint8_t utf8_countTrailBytes[]; /* U_IMPORT2? */ /*U_I } \ } \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Renamed to U8_BACK_1_UNSAFE, see utf_old.h. */ -#define UTF8_BACK_1_UNSAFE(s, i) { \ +#define UTF8_BACK_1_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \ while(UTF8_IS_TRAIL((s)[--(i)])) {} \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Renamed to U8_BACK_N_UNSAFE, see utf_old.h. */ -#define UTF8_BACK_N_UNSAFE(s, i, n) { \ +#define UTF8_BACK_N_UNSAFE(s, i, n) UPRV_BLOCK_MACRO_BEGIN { \ int32_t __N=(n); \ while(__N>0) { \ UTF8_BACK_1_UNSAFE(s, i); \ --__N; \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Renamed to U8_SET_CP_LIMIT_UNSAFE, see utf_old.h. */ -#define UTF8_SET_CHAR_LIMIT_UNSAFE(s, i) { \ +#define UTF8_SET_CHAR_LIMIT_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \ UTF8_BACK_1_UNSAFE(s, i); \ UTF8_FWD_1_UNSAFE(s, i); \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Use U8_PREV instead, see utf_old.h. */ -#define UTF8_PREV_CHAR_SAFE(s, start, i, c, strict) { \ +#define UTF8_PREV_CHAR_SAFE(s, start, i, c, strict) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[--(i)]; \ if((c)>=0x80) { \ if((c)<=0xbf) { \ @@ -520,7 +517,7 @@ U_CFUNC U_IMPORT const uint8_t utf8_countTrailBytes[]; /* U_IMPORT2? */ /*U_I (c)=UTF8_ERROR_VALUE_1; \ } \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Renamed to U8_BACK_1, see utf_old.h. */ #define UTF8_BACK_1_SAFE(s, start, i) U8_BACK_1(s, start, i) @@ -593,7 +590,7 @@ U_CFUNC U_IMPORT const uint8_t utf8_countTrailBytes[]; /* U_IMPORT2? */ /*U_I * UTF16_PREV_CHAR[_UNSAFE]() is more efficient for that. * @deprecated ICU 2.4. Renamed to U16_GET_UNSAFE, see utf_old.h. */ -#define UTF16_GET_CHAR_UNSAFE(s, i, c) { \ +#define UTF16_GET_CHAR_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[i]; \ if(UTF_IS_SURROGATE(c)) { \ if(UTF_IS_SURROGATE_FIRST(c)) { \ @@ -602,10 +599,10 @@ U_CFUNC U_IMPORT const uint8_t utf8_countTrailBytes[]; /* U_IMPORT2? */ /*U_I (c)=UTF16_GET_PAIR_VALUE((s)[(i)-1], (c)); \ } \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Use U16_GET instead, see utf_old.h. */ -#define UTF16_GET_CHAR_SAFE(s, start, i, length, c, strict) { \ +#define UTF16_GET_CHAR_SAFE(s, start, i, length, c, strict) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[i]; \ if(UTF_IS_SURROGATE(c)) { \ uint16_t __c2; \ @@ -629,51 +626,51 @@ U_CFUNC U_IMPORT const uint8_t utf8_countTrailBytes[]; /* U_IMPORT2? */ /*U_I } else if((strict) && !UTF_IS_UNICODE_CHAR(c)) { \ (c)=UTF_ERROR_VALUE; \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Renamed to U16_NEXT_UNSAFE, see utf_old.h. */ -#define UTF16_NEXT_CHAR_UNSAFE(s, i, c) { \ +#define UTF16_NEXT_CHAR_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[(i)++]; \ if(UTF_IS_FIRST_SURROGATE(c)) { \ (c)=UTF16_GET_PAIR_VALUE((c), (s)[(i)++]); \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Renamed to U16_APPEND_UNSAFE, see utf_old.h. */ -#define UTF16_APPEND_CHAR_UNSAFE(s, i, c) { \ +#define UTF16_APPEND_CHAR_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \ if((uint32_t)(c)<=0xffff) { \ (s)[(i)++]=(uint16_t)(c); \ } else { \ (s)[(i)++]=(uint16_t)(((c)>>10)+0xd7c0); \ (s)[(i)++]=(uint16_t)(((c)&0x3ff)|0xdc00); \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Renamed to U16_FWD_1_UNSAFE, see utf_old.h. */ -#define UTF16_FWD_1_UNSAFE(s, i) { \ +#define UTF16_FWD_1_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \ if(UTF_IS_FIRST_SURROGATE((s)[(i)++])) { \ ++(i); \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Renamed to U16_FWD_N_UNSAFE, see utf_old.h. */ -#define UTF16_FWD_N_UNSAFE(s, i, n) { \ +#define UTF16_FWD_N_UNSAFE(s, i, n) UPRV_BLOCK_MACRO_BEGIN { \ int32_t __N=(n); \ while(__N>0) { \ UTF16_FWD_1_UNSAFE(s, i); \ --__N; \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Renamed to U16_SET_CP_START_UNSAFE, see utf_old.h. */ -#define UTF16_SET_CHAR_START_UNSAFE(s, i) { \ +#define UTF16_SET_CHAR_START_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \ if(UTF_IS_SECOND_SURROGATE((s)[i])) { \ --(i); \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Use U16_NEXT instead, see utf_old.h. */ -#define UTF16_NEXT_CHAR_SAFE(s, i, length, c, strict) { \ +#define UTF16_NEXT_CHAR_SAFE(s, i, length, c, strict) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[(i)++]; \ if(UTF_IS_FIRST_SURROGATE(c)) { \ uint16_t __c2; \ @@ -689,10 +686,10 @@ U_CFUNC U_IMPORT const uint8_t utf8_countTrailBytes[]; /* U_IMPORT2? */ /*U_I /* unmatched second surrogate or other non-character */ \ (c)=UTF_ERROR_VALUE; \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Use U16_APPEND instead, see utf_old.h. */ -#define UTF16_APPEND_CHAR_SAFE(s, i, length, c) { \ +#define UTF16_APPEND_CHAR_SAFE(s, i, length, c) UPRV_BLOCK_MACRO_BEGIN { \ if((uint32_t)(c)<=0xffff) { \ (s)[(i)++]=(uint16_t)(c); \ } else if((uint32_t)(c)<=0x10ffff) { \ @@ -705,7 +702,7 @@ U_CFUNC U_IMPORT const uint8_t utf8_countTrailBytes[]; /* U_IMPORT2? */ /*U_I } else /* c>0x10ffff, write error value */ { \ (s)[(i)++]=UTF_ERROR_VALUE; \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Renamed to U16_FWD_1, see utf_old.h. */ #define UTF16_FWD_1_SAFE(s, i, length) U16_FWD_1(s, i, length) @@ -717,38 +714,38 @@ U_CFUNC U_IMPORT const uint8_t utf8_countTrailBytes[]; /* U_IMPORT2? */ /*U_I #define UTF16_SET_CHAR_START_SAFE(s, start, i) U16_SET_CP_START(s, start, i) /** @deprecated ICU 2.4. Renamed to U16_PREV_UNSAFE, see utf_old.h. */ -#define UTF16_PREV_CHAR_UNSAFE(s, i, c) { \ +#define UTF16_PREV_CHAR_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[--(i)]; \ if(UTF_IS_SECOND_SURROGATE(c)) { \ (c)=UTF16_GET_PAIR_VALUE((s)[--(i)], (c)); \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Renamed to U16_BACK_1_UNSAFE, see utf_old.h. */ -#define UTF16_BACK_1_UNSAFE(s, i) { \ +#define UTF16_BACK_1_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \ if(UTF_IS_SECOND_SURROGATE((s)[--(i)])) { \ --(i); \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Renamed to U16_BACK_N_UNSAFE, see utf_old.h. */ -#define UTF16_BACK_N_UNSAFE(s, i, n) { \ +#define UTF16_BACK_N_UNSAFE(s, i, n) UPRV_BLOCK_MACRO_BEGIN { \ int32_t __N=(n); \ while(__N>0) { \ UTF16_BACK_1_UNSAFE(s, i); \ --__N; \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Renamed to U16_SET_CP_LIMIT_UNSAFE, see utf_old.h. */ -#define UTF16_SET_CHAR_LIMIT_UNSAFE(s, i) { \ +#define UTF16_SET_CHAR_LIMIT_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \ if(UTF_IS_FIRST_SURROGATE((s)[(i)-1])) { \ ++(i); \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Use U16_PREV instead, see utf_old.h. */ -#define UTF16_PREV_CHAR_SAFE(s, start, i, c, strict) { \ +#define UTF16_PREV_CHAR_SAFE(s, start, i, c, strict) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[--(i)]; \ if(UTF_IS_SECOND_SURROGATE(c)) { \ uint16_t __c2; \ @@ -764,7 +761,7 @@ U_CFUNC U_IMPORT const uint8_t utf8_countTrailBytes[]; /* U_IMPORT2? */ /*U_I /* unmatched first surrogate or other non-character */ \ (c)=UTF_ERROR_VALUE; \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Renamed to U16_BACK_1, see utf_old.h. */ #define UTF16_BACK_1_SAFE(s, start, i) U16_BACK_1(s, start, i) @@ -830,122 +827,122 @@ U_CFUNC U_IMPORT const uint8_t utf8_countTrailBytes[]; /* U_IMPORT2? */ /*U_I #define UTF32_ARRAY_SIZE(size) (size) /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ -#define UTF32_GET_CHAR_UNSAFE(s, i, c) { \ +#define UTF32_GET_CHAR_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[i]; \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ -#define UTF32_GET_CHAR_SAFE(s, start, i, length, c, strict) { \ +#define UTF32_GET_CHAR_SAFE(s, start, i, length, c, strict) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[i]; \ if(!UTF32_IS_SAFE(c, strict)) { \ (c)=UTF_ERROR_VALUE; \ } \ -} +} UPRV_BLOCK_MACRO_END /* definitions with forward iteration --------------------------------------- */ /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ -#define UTF32_NEXT_CHAR_UNSAFE(s, i, c) { \ +#define UTF32_NEXT_CHAR_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[(i)++]; \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ -#define UTF32_APPEND_CHAR_UNSAFE(s, i, c) { \ +#define UTF32_APPEND_CHAR_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \ (s)[(i)++]=(c); \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ -#define UTF32_FWD_1_UNSAFE(s, i) { \ +#define UTF32_FWD_1_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \ ++(i); \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ -#define UTF32_FWD_N_UNSAFE(s, i, n) { \ +#define UTF32_FWD_N_UNSAFE(s, i, n) UPRV_BLOCK_MACRO_BEGIN { \ (i)+=(n); \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ -#define UTF32_SET_CHAR_START_UNSAFE(s, i) { \ -} +#define UTF32_SET_CHAR_START_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \ +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ -#define UTF32_NEXT_CHAR_SAFE(s, i, length, c, strict) { \ +#define UTF32_NEXT_CHAR_SAFE(s, i, length, c, strict) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[(i)++]; \ if(!UTF32_IS_SAFE(c, strict)) { \ (c)=UTF_ERROR_VALUE; \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ -#define UTF32_APPEND_CHAR_SAFE(s, i, length, c) { \ +#define UTF32_APPEND_CHAR_SAFE(s, i, length, c) UPRV_BLOCK_MACRO_BEGIN { \ if((uint32_t)(c)<=0x10ffff) { \ (s)[(i)++]=(c); \ } else /* c>0x10ffff, write 0xfffd */ { \ (s)[(i)++]=0xfffd; \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ -#define UTF32_FWD_1_SAFE(s, i, length) { \ +#define UTF32_FWD_1_SAFE(s, i, length) UPRV_BLOCK_MACRO_BEGIN { \ ++(i); \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ -#define UTF32_FWD_N_SAFE(s, i, length, n) { \ +#define UTF32_FWD_N_SAFE(s, i, length, n) UPRV_BLOCK_MACRO_BEGIN { \ if(((i)+=(n))>(length)) { \ (i)=(length); \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ -#define UTF32_SET_CHAR_START_SAFE(s, start, i) { \ -} +#define UTF32_SET_CHAR_START_SAFE(s, start, i) UPRV_BLOCK_MACRO_BEGIN { \ +} UPRV_BLOCK_MACRO_END /* definitions with backward iteration -------------------------------------- */ /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ -#define UTF32_PREV_CHAR_UNSAFE(s, i, c) { \ +#define UTF32_PREV_CHAR_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[--(i)]; \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ -#define UTF32_BACK_1_UNSAFE(s, i) { \ +#define UTF32_BACK_1_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \ --(i); \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ -#define UTF32_BACK_N_UNSAFE(s, i, n) { \ +#define UTF32_BACK_N_UNSAFE(s, i, n) UPRV_BLOCK_MACRO_BEGIN { \ (i)-=(n); \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ -#define UTF32_SET_CHAR_LIMIT_UNSAFE(s, i) { \ -} +#define UTF32_SET_CHAR_LIMIT_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \ +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ -#define UTF32_PREV_CHAR_SAFE(s, start, i, c, strict) { \ +#define UTF32_PREV_CHAR_SAFE(s, start, i, c, strict) UPRV_BLOCK_MACRO_BEGIN { \ (c)=(s)[--(i)]; \ if(!UTF32_IS_SAFE(c, strict)) { \ (c)=UTF_ERROR_VALUE; \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ -#define UTF32_BACK_1_SAFE(s, start, i) { \ +#define UTF32_BACK_1_SAFE(s, start, i) UPRV_BLOCK_MACRO_BEGIN { \ --(i); \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ -#define UTF32_BACK_N_SAFE(s, start, i, n) { \ +#define UTF32_BACK_N_SAFE(s, start, i, n) UPRV_BLOCK_MACRO_BEGIN { \ (i)-=(n); \ if((i)<(start)) { \ (i)=(start); \ } \ -} +} UPRV_BLOCK_MACRO_END /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ -#define UTF32_SET_CHAR_LIMIT_SAFE(s, i, length) { \ -} +#define UTF32_SET_CHAR_LIMIT_SAFE(s, i, length) UPRV_BLOCK_MACRO_BEGIN { \ +} UPRV_BLOCK_MACRO_END /* Formerly utf.h, part 2 --------------------------------------------------- */ diff --git a/deps/icu-small/source/common/unicode/utrace.h b/deps/icu-small/source/common/unicode/utrace.h index bf6fd036f06c41..0af050756fc38a 100644 --- a/deps/icu-small/source/common/unicode/utrace.h +++ b/deps/icu-small/source/common/unicode/utrace.h @@ -66,6 +66,7 @@ typedef enum UTraceFunctionNumber { UTRACE_FUNCTION_START=0, UTRACE_U_INIT=UTRACE_FUNCTION_START, UTRACE_U_CLEANUP, + #ifndef U_HIDE_DEPRECATED_API /** * One more than the highest normal collation trace location. @@ -83,6 +84,7 @@ typedef enum UTraceFunctionNumber { UTRACE_UCNV_FLUSH_CACHE, UTRACE_UCNV_LOAD, UTRACE_UCNV_UNLOAD, + #ifndef U_HIDE_DEPRECATED_API /** * One more than the highest normal collation trace location. @@ -101,13 +103,80 @@ typedef enum UTraceFunctionNumber { UTRACE_UCOL_STRCOLLITER, UTRACE_UCOL_OPEN_FROM_SHORT_STRING, UTRACE_UCOL_STRCOLLUTF8, /**< @stable ICU 50 */ + #ifndef U_HIDE_DEPRECATED_API /** * One more than the highest normal collation trace location. * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420. */ - UTRACE_COLLATION_LIMIT + UTRACE_COLLATION_LIMIT, #endif // U_HIDE_DEPRECATED_API + +#ifndef U_HIDE_DRAFT_API + + /** + * The lowest resource/data location. + * @draft ICU 65 + */ + UTRACE_UDATA_START=0x3000, + + /** + * Indicates that a value was read from a resource bundle. Provides three + * C-style strings to UTraceData: type, file name, and resource path. The + * possible types are: + * + * - "string" (a string value was accessed) + * - "binary" (a binary value was accessed) + * - "intvector" (a integer vector value was accessed) + * - "int" (a signed integer value was accessed) + * - "uint" (a unsigned integer value was accessed) + * - "get" (a path was loaded, but the value was not accessed) + * - "getalias" (a path was loaded, and an alias was resolved) + * + * @draft ICU 65 + */ + UTRACE_UDATA_RESOURCE=UTRACE_UDATA_START, + + /** + * Indicates that a resource bundle was opened. + * + * Provides one C-style string to UTraceData: file name. + * @draft ICU 65 + */ + UTRACE_UDATA_BUNDLE, + + /** + * Indicates that a data file was opened, but not *.res files. + * + * Provides one C-style string to UTraceData: file name. + * + * @draft ICU 65 + */ + UTRACE_UDATA_DATA_FILE, + + /** + * Indicates that a *.res file was opened. + * + * This differs from UTRACE_UDATA_BUNDLE because a res file is typically + * opened only once per application runtime, but the bundle corresponding + * to that res file may be opened many times. + * + * Provides one C-style string to UTraceData: file name. + * + * @draft ICU 65 + */ + UTRACE_UDATA_RES_FILE, + +#endif // U_HIDE_DRAFT_API + +#ifndef U_HIDE_INTERNAL_API + /** + * One more than the highest normal resource/data trace location. + * @internal The numeric value may change over time, see ICU ticket #12420. + */ + UTRACE_RES_DATA_LIMIT, +#endif // U_HIDE_INTERNAL_API + } UTraceFunctionNumber; /** diff --git a/deps/icu-small/source/common/unicode/utypes.h b/deps/icu-small/source/common/unicode/utypes.h index 49eb12cd40022c..c98de9e6fc3dad 100644 --- a/deps/icu-small/source/common/unicode/utypes.h +++ b/deps/icu-small/source/common/unicode/utypes.h @@ -385,17 +385,31 @@ typedef double UDate; /*===========================================================================*/ /** - * Error code to replace exception handling, so that the code is compatible with all C++ compilers, - * and to use the same mechanism for C and C++. + * Standard ICU4C error code type, a substitute for exceptions. + * + * Initialize the UErrorCode with U_ZERO_ERROR, and check for success or + * failure using U_SUCCESS() or U_FAILURE(): + * + * UErrorCode errorCode = U_ZERO_ERROR; + * // call ICU API that needs an error code parameter. + * if (U_FAILURE(errorCode)) { + * // An error occurred. Handle it here. + * } + * + * C++ code should use icu::ErrorCode, available in unicode/errorcode.h, or a + * suitable subclass. + * + * For more information, see: + * http://icu-project.org/userguide/conventions + * + * Note: By convention, ICU functions that take a reference (C++) or a pointer + * (C) to a UErrorCode first test: + * + * if (U_FAILURE(errorCode)) { return immediately; } * - * \par - * ICU functions that take a reference (C++) or a pointer (C) to a UErrorCode - * first test if(U_FAILURE(errorCode)) { return immediately; } * so that in a chain of such functions the first one that sets an error code * causes the following ones to not perform any operations. * - * \par - * Error codes should be tested using U_FAILURE() and U_SUCCESS(). * @stable ICU 2.0 */ typedef enum UErrorCode { diff --git a/deps/icu-small/source/common/unicode/uvernum.h b/deps/icu-small/source/common/unicode/uvernum.h index 7c114be2cc87f1..0923c1d9189d0f 100644 --- a/deps/icu-small/source/common/unicode/uvernum.h +++ b/deps/icu-small/source/common/unicode/uvernum.h @@ -60,13 +60,13 @@ * This value will change in the subsequent releases of ICU * @stable ICU 2.4 */ -#define U_ICU_VERSION_MAJOR_NUM 64 +#define U_ICU_VERSION_MAJOR_NUM 65 /** The current ICU minor version as an integer. * This value will change in the subsequent releases of ICU * @stable ICU 2.6 */ -#define U_ICU_VERSION_MINOR_NUM 2 +#define U_ICU_VERSION_MINOR_NUM 1 /** The current ICU patchlevel version as an integer. * This value will change in the subsequent releases of ICU @@ -86,7 +86,7 @@ * This value will change in the subsequent releases of ICU * @stable ICU 2.6 */ -#define U_ICU_VERSION_SUFFIX _64 +#define U_ICU_VERSION_SUFFIX _65 /** * \def U_DEF2_ICU_ENTRY_POINT_RENAME @@ -139,7 +139,7 @@ * This value will change in the subsequent releases of ICU * @stable ICU 2.4 */ -#define U_ICU_VERSION "64.2" +#define U_ICU_VERSION "65.1" /** * The current ICU library major version number as a string, for library name suffixes. @@ -152,13 +152,13 @@ * * @stable ICU 2.6 */ -#define U_ICU_VERSION_SHORT "64" +#define U_ICU_VERSION_SHORT "65" #ifndef U_HIDE_INTERNAL_API /** Data version in ICU4C. * @internal ICU 4.4 Internal Use Only **/ -#define U_ICU_DATA_VERSION "64.2" +#define U_ICU_DATA_VERSION "65.1" #endif /* U_HIDE_INTERNAL_API */ /*=========================================================================== diff --git a/deps/icu-small/source/common/unicode/uversion.h b/deps/icu-small/source/common/unicode/uversion.h index 3f0251d3994bcb..c8c7a374c820b2 100644 --- a/deps/icu-small/source/common/unicode/uversion.h +++ b/deps/icu-small/source/common/unicode/uversion.h @@ -62,26 +62,22 @@ typedef uint8_t UVersionInfo[U_MAX_VERSION_LENGTH]; /* C++ namespace if supported. Versioned unless versioning is disabled. */ /*===========================================================================*/ +/* Define C++ namespace symbols. */ +#ifdef __cplusplus + /** * \def U_NAMESPACE_BEGIN - * This is used to begin a declaration of a public ICU C++ API. - * When not compiling for C++, it does nothing. - * When compiling for C++, it begins an extern "C++" linkage block (to protect - * against cases in which an external client includes ICU header files inside - * an extern "C" linkage block). + * This is used to begin a declaration of a public ICU C++ API within + * versioned-ICU-namespace block. * - * It also begins a versioned-ICU-namespace block. * @stable ICU 2.4 */ /** * \def U_NAMESPACE_END * This is used to end a declaration of a public ICU C++ API. - * When not compiling for C++, it does nothing. - * When compiling for C++, it ends the extern "C++" block begun by - * U_NAMESPACE_BEGIN. + * It ends the versioned-ICU-namespace block begun by U_NAMESPACE_BEGIN. * - * It also ends the versioned-ICU-namespace block begun by U_NAMESPACE_BEGIN. * @stable ICU 2.4 */ @@ -89,9 +85,6 @@ typedef uint8_t UVersionInfo[U_MAX_VERSION_LENGTH]; * \def U_NAMESPACE_USE * This is used to specify that the rest of the code uses the * public ICU C++ API namespace. - * This is invoked by default; we recommend that you turn it off: - * See the "Recommended Build Options" section of the ICU4C readme - * (http://source.icu-project.org/repos/icu/icu/trunk/readme.html#RecBuild) * @stable ICU 2.4 */ @@ -105,8 +98,6 @@ typedef uint8_t UVersionInfo[U_MAX_VERSION_LENGTH]; * @stable ICU 2.4 */ -/* Define C++ namespace symbols. */ -#ifdef __cplusplus # if U_DISABLE_RENAMING # define U_ICU_NAMESPACE icu namespace U_ICU_NAMESPACE { } @@ -116,8 +107,8 @@ typedef uint8_t UVersionInfo[U_MAX_VERSION_LENGTH]; namespace icu = U_ICU_NAMESPACE; # endif -# define U_NAMESPACE_BEGIN extern "C++" { namespace U_ICU_NAMESPACE { -# define U_NAMESPACE_END } } +# define U_NAMESPACE_BEGIN namespace U_ICU_NAMESPACE { +# define U_NAMESPACE_END } # define U_NAMESPACE_USE using namespace U_ICU_NAMESPACE; # define U_NAMESPACE_QUALIFIER U_ICU_NAMESPACE:: @@ -133,12 +124,7 @@ typedef uint8_t UVersionInfo[U_MAX_VERSION_LENGTH]; # if U_USING_ICU_NAMESPACE U_NAMESPACE_USE # endif -#else -# define U_NAMESPACE_BEGIN -# define U_NAMESPACE_END -# define U_NAMESPACE_USE -# define U_NAMESPACE_QUALIFIER -#endif +#endif /* __cplusplus */ /*===========================================================================*/ /* General version helper functions. Definitions in putil.c */ diff --git a/deps/icu-small/source/common/unifiedcache.cpp b/deps/icu-small/source/common/unifiedcache.cpp index 641f4ec6594e12..f2dd916559588c 100644 --- a/deps/icu-small/source/common/unifiedcache.cpp +++ b/deps/icu-small/source/common/unifiedcache.cpp @@ -13,22 +13,15 @@ #include "unifiedcache.h" #include // For std::max() +#include -#include "mutex.h" #include "uassert.h" #include "uhash.h" #include "ucln_cmn.h" -#include "umutex.h" static icu::UnifiedCache *gCache = NULL; -static icu::UMutex *gCacheMutex() { - static icu::UMutex m = U_MUTEX_INITIALIZER; - return &m; -} -static icu::UConditionVar *gInProgressValueAddedCond() { - static icu::UConditionVar cv = U_CONDITION_INITIALIZER; - return &cv; -} +static std::mutex *gCacheMutex = nullptr; +static std::condition_variable *gInProgressValueAddedCond; static icu::UInitOnce gCacheInitOnce = U_INITONCE_INITIALIZER; static const int32_t MAX_EVICT_ITERATIONS = 10; @@ -39,10 +32,12 @@ static const int32_t DEFAULT_PERCENTAGE_OF_IN_USE = 100; U_CDECL_BEGIN static UBool U_CALLCONV unifiedcache_cleanup() { gCacheInitOnce.reset(); - if (gCache) { - delete gCache; - gCache = NULL; - } + delete gCache; + gCache = nullptr; + gCacheMutex->~mutex(); + gCacheMutex = nullptr; + gInProgressValueAddedCond->~condition_variable(); + gInProgressValueAddedCond = nullptr; return TRUE; } U_CDECL_END @@ -77,6 +72,8 @@ static void U_CALLCONV cacheInit(UErrorCode &status) { ucln_common_registerCleanup( UCLN_COMMON_UNIFIED_CACHE, unifiedcache_cleanup); + gCacheMutex = STATIC_NEW(std::mutex); + gInProgressValueAddedCond = STATIC_NEW(std::condition_variable); gCache = new UnifiedCache(status); if (gCache == NULL) { status = U_MEMORY_ALLOCATION_ERROR; @@ -138,28 +135,28 @@ void UnifiedCache::setEvictionPolicy( status = U_ILLEGAL_ARGUMENT_ERROR; return; } - Mutex lock(gCacheMutex()); + std::lock_guard lock(*gCacheMutex); fMaxUnused = count; fMaxPercentageOfInUse = percentageOfInUseItems; } int32_t UnifiedCache::unusedCount() const { - Mutex lock(gCacheMutex()); + std::lock_guard lock(*gCacheMutex); return uhash_count(fHashtable) - fNumValuesInUse; } int64_t UnifiedCache::autoEvictedCount() const { - Mutex lock(gCacheMutex()); + std::lock_guard lock(*gCacheMutex); return fAutoEvictedCount; } int32_t UnifiedCache::keyCount() const { - Mutex lock(gCacheMutex()); + std::lock_guard lock(*gCacheMutex); return uhash_count(fHashtable); } void UnifiedCache::flush() const { - Mutex lock(gCacheMutex()); + std::lock_guard lock(*gCacheMutex); // Use a loop in case cache items that are flushed held hard references to // other cache items making those additional cache items eligible for @@ -168,7 +165,7 @@ void UnifiedCache::flush() const { } void UnifiedCache::handleUnreferencedObject() const { - Mutex lock(gCacheMutex()); + std::lock_guard lock(*gCacheMutex); --fNumValuesInUse; _runEvictionSlice(); } @@ -187,7 +184,7 @@ void UnifiedCache::dump() { } void UnifiedCache::dumpContents() const { - Mutex lock(gCacheMutex()); + std::lock_guard lock(*gCacheMutex); _dumpContents(); } @@ -227,7 +224,7 @@ UnifiedCache::~UnifiedCache() { // Now all that should be left in the cache are entries that refer to // each other and entries with hard references from outside the cache. // Nothing we can do about these so proceed to wipe out the cache. - Mutex lock(gCacheMutex()); + std::lock_guard lock(*gCacheMutex); _flush(TRUE); } uhash_close(fHashtable); @@ -328,7 +325,7 @@ void UnifiedCache::_putIfAbsentAndGet( const CacheKeyBase &key, const SharedObject *&value, UErrorCode &status) const { - Mutex lock(gCacheMutex()); + std::lock_guard lock(*gCacheMutex); const UHashElement *element = uhash_find(fHashtable, &key); if (element != NULL && !_inProgress(element)) { _fetch(element, value, status); @@ -353,15 +350,15 @@ UBool UnifiedCache::_poll( UErrorCode &status) const { U_ASSERT(value == NULL); U_ASSERT(status == U_ZERO_ERROR); - Mutex lock(gCacheMutex()); + std::unique_lock lock(*gCacheMutex); const UHashElement *element = uhash_find(fHashtable, &key); // If the hash table contains an inProgress placeholder entry for this key, // this means that another thread is currently constructing the value object. // Loop, waiting for that construction to complete. while (element != NULL && _inProgress(element)) { - umtx_condWait(gInProgressValueAddedCond(), gCacheMutex()); - element = uhash_find(fHashtable, &key); + gInProgressValueAddedCond->wait(lock); + element = uhash_find(fHashtable, &key); } // If the hash table contains an entry for the key, @@ -433,7 +430,7 @@ void UnifiedCache::_put( // Tell waiting threads that we replace in-progress status with // an error. - umtx_condBroadcast(gInProgressValueAddedCond()); + gInProgressValueAddedCond->notify_all(); } void UnifiedCache::_fetch( diff --git a/deps/icu-small/source/common/uniset.cpp b/deps/icu-small/source/common/uniset.cpp index 1db382afe6f6ba..3807b837475948 100644 --- a/deps/icu-small/source/common/uniset.cpp +++ b/deps/icu-small/source/common/uniset.cpp @@ -278,11 +278,11 @@ UnicodeSet& UnicodeSet::copyFrom(const UnicodeSet& o, UBool asThawed) { * to support cloning in order to allow classes using * UnicodeMatchers, such as Transliterator, to implement cloning. */ -UnicodeFunctor* UnicodeSet::clone() const { +UnicodeSet* UnicodeSet::clone() const { return new UnicodeSet(*this); } -UnicodeFunctor *UnicodeSet::cloneAsThawed() const { +UnicodeSet *UnicodeSet::cloneAsThawed() const { return new UnicodeSet(*this, TRUE); } @@ -2172,7 +2172,7 @@ void UnicodeSet::setPattern(const char16_t *newPat, int32_t newPatLen) { // We can regenerate an equivalent pattern later when requested. } -UnicodeFunctor *UnicodeSet::freeze() { +UnicodeSet *UnicodeSet::freeze() { if(!isFrozen() && !isBogus()) { compact(); diff --git a/deps/icu-small/source/common/uniset_props.cpp b/deps/icu-small/source/common/uniset_props.cpp index 6f7918a91ab9ed..45d3dab9938b29 100644 --- a/deps/icu-small/source/common/uniset_props.cpp +++ b/deps/icu-small/source/common/uniset_props.cpp @@ -802,7 +802,10 @@ static UBool mungeCharName(char* dst, const char* src, int32_t dstCapacity) { // Property set API //---------------------------------------------------------------- -#define FAIL(ec) {ec=U_ILLEGAL_ARGUMENT_ERROR; return *this;} +#define FAIL(ec) UPRV_BLOCK_MACRO_BEGIN { \ + ec=U_ILLEGAL_ARGUMENT_ERROR; \ + return *this; \ +} UPRV_BLOCK_MACRO_END UnicodeSet& UnicodeSet::applyIntPropertyValue(UProperty prop, int32_t value, UErrorCode& ec) { diff --git a/deps/icu-small/source/common/unisetspan.cpp b/deps/icu-small/source/common/unisetspan.cpp index 0a8893472f958b..68e44d91ee7066 100644 --- a/deps/icu-small/source/common/unisetspan.cpp +++ b/deps/icu-small/source/common/unisetspan.cpp @@ -400,7 +400,7 @@ UnicodeSetStringSpan::UnicodeSetStringSpan(const UnicodeSetStringSpan &otherStri if(otherStringSpan.pSpanNotSet==&otherStringSpan.spanSet) { pSpanNotSet=&spanSet; } else { - pSpanNotSet=(UnicodeSet *)otherStringSpan.pSpanNotSet->clone(); + pSpanNotSet=otherStringSpan.pSpanNotSet->clone(); } // Allocate a block of meta data. @@ -436,7 +436,7 @@ void UnicodeSetStringSpan::addToSpanNotSet(UChar32 c) { if(spanSet.contains(c)) { return; // Nothing to do. } - UnicodeSet *newSet=(UnicodeSet *)spanSet.cloneAsThawed(); + UnicodeSet *newSet=spanSet.cloneAsThawed(); if(newSet==NULL) { return; // Out of memory. } else { diff --git a/deps/icu-small/source/common/unistr.cpp b/deps/icu-small/source/common/unistr.cpp index 31b0ed84bee07d..eeb0c3a679a5e9 100644 --- a/deps/icu-small/source/common/unistr.cpp +++ b/deps/icu-small/source/common/unistr.cpp @@ -332,7 +332,7 @@ Replaceable::clone() const { } // UnicodeString overrides clone() with a real implementation -Replaceable * +UnicodeString * UnicodeString::clone() const { return new UnicodeString(*this); } diff --git a/deps/icu-small/source/common/uresbund.cpp b/deps/icu-small/source/common/uresbund.cpp index c9f2c860da7c33..3a9b4340bb4a38 100644 --- a/deps/icu-small/source/common/uresbund.cpp +++ b/deps/icu-small/source/common/uresbund.cpp @@ -31,6 +31,7 @@ #include "ucln_cmn.h" #include "cmemory.h" #include "cstring.h" +#include "mutex.h" #include "uhash.h" #include "unicode/uenum.h" #include "uenumimp.h" @@ -38,6 +39,7 @@ #include "umutex.h" #include "putilimp.h" #include "uassert.h" +#include "uresdata.h" using namespace icu; @@ -47,12 +49,9 @@ TODO: This cache should probably be removed when the deprecated code is completely removed. */ static UHashtable *cache = NULL; -static icu::UInitOnce gCacheInitOnce; +static icu::UInitOnce gCacheInitOnce = U_INITONCE_INITIALIZER; -static UMutex *resbMutex() { - static UMutex m = U_MUTEX_INITIALIZER; - return &m; -} +static UMutex resbMutex; /* INTERNAL: hashes an entry */ static int32_t U_CALLCONV hashEntry(const UHashTok parm) { @@ -96,13 +95,12 @@ static UBool chopLocale(char *name) { * Internal function */ static void entryIncrease(UResourceDataEntry *entry) { - umtx_lock(resbMutex()); + Mutex lock(&resbMutex); entry->fCountExisting++; while(entry->fParent != NULL) { entry = entry->fParent; entry->fCountExisting++; } - umtx_unlock(resbMutex()); } /** @@ -184,9 +182,8 @@ static int32_t ures_flushCache() /*if shared data hasn't even been lazy evaluated yet * return 0 */ - umtx_lock(resbMutex()); + Mutex lock(&resbMutex); if (cache == NULL) { - umtx_unlock(resbMutex()); return 0; } @@ -218,7 +215,6 @@ static int32_t ures_flushCache() * got decremented by free_entry(). */ } while(deletedMore); - umtx_unlock(resbMutex()); return rbDeletedNum; } @@ -232,9 +228,8 @@ U_CAPI UBool U_EXPORT2 ures_dumpCacheContents(void) { const UHashElement *e; UResourceDataEntry *resB; - umtx_lock(resbMutex()); + Mutex lock(&resbMutex); if (cache == NULL) { - umtx_unlock(resbMutex()); fprintf(stderr,"%s:%d: RB Cache is NULL.\n", __FILE__, __LINE__); return FALSE; } @@ -253,9 +248,6 @@ U_CAPI UBool U_EXPORT2 ures_dumpCacheContents(void) { } fprintf(stderr,"%s:%d: RB Cache still contains %d items.\n", __FILE__, __LINE__, uhash_count(cache)); - - umtx_unlock(resbMutex()); - return cacheNotEmpty; } @@ -401,7 +393,8 @@ static UResourceDataEntry *init_entry(const char *localeID, const char *path, UE /* We'll try to get alias string from the bundle */ aliasres = res_getResource(&(r->fData), "%%ALIAS"); if (aliasres != RES_BOGUS) { - const UChar *alias = res_getString(&(r->fData), aliasres, &aliasLen); + // No tracing: called during initial data loading + const UChar *alias = res_getStringNoTrace(&(r->fData), aliasres, &aliasLen); if(alias != NULL && aliasLen > 0) { /* if there is actual alias - unload and load new data */ u_UCharsToChars(alias, aliasName, aliasLen+1); r->fAlias = init_entry(aliasName, path, status); @@ -542,7 +535,8 @@ loadParentsExceptRoot(UResourceDataEntry *&t1, Resource parentRes = res_getResource(&t1->fData, "%%Parent"); if (parentRes != RES_BOGUS) { // An explicit parent was found. int32_t parentLocaleLen = 0; - const UChar *parentLocaleName = res_getString(&(t1->fData), parentRes, &parentLocaleLen); + // No tracing: called during initial data loading + const UChar *parentLocaleName = res_getStringNoTrace(&(t1->fData), parentRes, &parentLocaleLen); if(parentLocaleName != NULL && 0 < parentLocaleLen && parentLocaleLen < nameCapacity) { u_UCharsToChars(parentLocaleName, name, parentLocaleLen + 1); if (uprv_strcmp(name, kRootLocaleName) == 0) { @@ -666,107 +660,105 @@ static UResourceDataEntry *entryOpen(const char* path, const char* localeID, } } - umtx_lock(resbMutex()); - { /* umtx_lock */ - /* We're going to skip all the locales that do not have any data */ - r = findFirstExisting(path, name, &isRoot, &hasChopped, &isDefault, &intStatus); + Mutex lock(&resbMutex); // Lock resbMutex until the end of this function. + + /* We're going to skip all the locales that do not have any data */ + r = findFirstExisting(path, name, &isRoot, &hasChopped, &isDefault, &intStatus); + + // If we failed due to out-of-memory, report the failure and exit early. + if (intStatus == U_MEMORY_ALLOCATION_ERROR) { + *status = intStatus; + goto finish; + } + + if(r != NULL) { /* if there is one real locale, we can look for parents. */ + t1 = r; + hasRealData = TRUE; + if ( usingUSRData ) { /* This code inserts user override data into the inheritance chain */ + UErrorCode usrStatus = U_ZERO_ERROR; + UResourceDataEntry *u1 = init_entry(t1->fName, usrDataPath, &usrStatus); + // If we failed due to out-of-memory, report the failure and exit early. + if (intStatus == U_MEMORY_ALLOCATION_ERROR) { + *status = intStatus; + goto finish; + } + if ( u1 != NULL ) { + if(u1->fBogus == U_ZERO_ERROR) { + u1->fParent = t1; + r = u1; + } else { + /* the USR override data wasn't found, set it to be deleted */ + u1->fCountExisting = 0; + } + } + } + if (hasChopped && !isRoot) { + if (!loadParentsExceptRoot(t1, name, UPRV_LENGTHOF(name), usingUSRData, usrDataPath, status)) { + goto finish; + } + } + } + /* we could have reached this point without having any real data */ + /* if that is the case, we need to chain in the default locale */ + if(r==NULL && openType == URES_OPEN_LOCALE_DEFAULT_ROOT && !isDefault && !isRoot) { + /* insert default locale */ + uprv_strcpy(name, uloc_getDefault()); + r = findFirstExisting(path, name, &isRoot, &hasChopped, &isDefault, &intStatus); // If we failed due to out-of-memory, report the failure and exit early. if (intStatus == U_MEMORY_ALLOCATION_ERROR) { *status = intStatus; - goto finishUnlock; + goto finish; } - - if(r != NULL) { /* if there is one real locale, we can look for parents. */ + intStatus = U_USING_DEFAULT_WARNING; + if(r != NULL) { /* the default locale exists */ t1 = r; hasRealData = TRUE; - if ( usingUSRData ) { /* This code inserts user override data into the inheritance chain */ - UErrorCode usrStatus = U_ZERO_ERROR; - UResourceDataEntry *u1 = init_entry(t1->fName, usrDataPath, &usrStatus); - // If we failed due to out-of-memory, report the failure and exit early. - if (intStatus == U_MEMORY_ALLOCATION_ERROR) { - *status = intStatus; - goto finishUnlock; - } - if ( u1 != NULL ) { - if(u1->fBogus == U_ZERO_ERROR) { - u1->fParent = t1; - r = u1; - } else { - /* the USR override data wasn't found, set it to be deleted */ - u1->fCountExisting = 0; - } - } - } + isDefault = TRUE; + // TODO: Why not if (usingUSRData) { ... } like in the non-default-locale code path? if (hasChopped && !isRoot) { if (!loadParentsExceptRoot(t1, name, UPRV_LENGTHOF(name), usingUSRData, usrDataPath, status)) { - goto finishUnlock; + goto finish; } } } + } - /* we could have reached this point without having any real data */ - /* if that is the case, we need to chain in the default locale */ - if(r==NULL && openType == URES_OPEN_LOCALE_DEFAULT_ROOT && !isDefault && !isRoot) { - /* insert default locale */ - uprv_strcpy(name, uloc_getDefault()); - r = findFirstExisting(path, name, &isRoot, &hasChopped, &isDefault, &intStatus); - // If we failed due to out-of-memory, report the failure and exit early. - if (intStatus == U_MEMORY_ALLOCATION_ERROR) { - *status = intStatus; - goto finishUnlock; - } + /* we could still have r == NULL at this point - maybe even default locale is not */ + /* present */ + if(r == NULL) { + uprv_strcpy(name, kRootLocaleName); + r = findFirstExisting(path, name, &isRoot, &hasChopped, &isDefault, &intStatus); + // If we failed due to out-of-memory, report the failure and exit early. + if (intStatus == U_MEMORY_ALLOCATION_ERROR) { + *status = intStatus; + goto finish; + } + if(r != NULL) { + t1 = r; intStatus = U_USING_DEFAULT_WARNING; - if(r != NULL) { /* the default locale exists */ - t1 = r; - hasRealData = TRUE; - isDefault = TRUE; - // TODO: Why not if (usingUSRData) { ... } like in the non-default-locale code path? - if (hasChopped && !isRoot) { - if (!loadParentsExceptRoot(t1, name, UPRV_LENGTHOF(name), usingUSRData, usrDataPath, status)) { - goto finishUnlock; - } - } - } + hasRealData = TRUE; + } else { /* we don't even have the root locale */ + *status = U_MISSING_RESOURCE_ERROR; + goto finish; } - - /* we could still have r == NULL at this point - maybe even default locale is not */ - /* present */ - if(r == NULL) { - uprv_strcpy(name, kRootLocaleName); - r = findFirstExisting(path, name, &isRoot, &hasChopped, &isDefault, &intStatus); - // If we failed due to out-of-memory, report the failure and exit early. - if (intStatus == U_MEMORY_ALLOCATION_ERROR) { - *status = intStatus; - goto finishUnlock; - } - if(r != NULL) { - t1 = r; - intStatus = U_USING_DEFAULT_WARNING; - hasRealData = TRUE; - } else { /* we don't even have the root locale */ - *status = U_MISSING_RESOURCE_ERROR; - goto finishUnlock; - } - } else if(!isRoot && uprv_strcmp(t1->fName, kRootLocaleName) != 0 && - t1->fParent == NULL && !r->fData.noFallback) { - if (!insertRootBundle(t1, status)) { - goto finishUnlock; - } - if(!hasRealData) { - r->fBogus = U_USING_DEFAULT_WARNING; - } + } else if(!isRoot && uprv_strcmp(t1->fName, kRootLocaleName) != 0 && + t1->fParent == NULL && !r->fData.noFallback) { + if (!insertRootBundle(t1, status)) { + goto finish; } - - // TODO: Does this ever loop? - while(r != NULL && !isRoot && t1->fParent != NULL) { - t1->fParent->fCountExisting++; - t1 = t1->fParent; + if(!hasRealData) { + r->fBogus = U_USING_DEFAULT_WARNING; } - } /* umtx_lock */ -finishUnlock: - umtx_unlock(resbMutex()); + } + // TODO: Does this ever loop? + while(r != NULL && !isRoot && t1->fParent != NULL) { + t1->fParent->fCountExisting++; + t1 = t1->fParent; + } + +finish: if(U_SUCCESS(*status)) { if(intStatus != U_ZERO_ERROR) { *status = intStatus; @@ -790,7 +782,7 @@ entryOpenDirect(const char* path, const char* localeID, UErrorCode* status) { return NULL; } - umtx_lock(resbMutex()); + Mutex lock(&resbMutex); // findFirstExisting() without fallbacks. UResourceDataEntry *r = init_entry(localeID, path, status); if(U_SUCCESS(*status)) { @@ -828,7 +820,6 @@ entryOpenDirect(const char* path, const char* localeID, UErrorCode* status) { t1 = t1->fParent; } } - umtx_unlock(resbMutex()); return r; } @@ -871,9 +862,8 @@ static void entryCloseInt(UResourceDataEntry *resB) { */ static void entryClose(UResourceDataEntry *resB) { - umtx_lock(resbMutex()); + Mutex lock(&resbMutex); entryCloseInt(resB); - umtx_unlock(resbMutex()); } /* @@ -1177,6 +1167,7 @@ static UResourceBundle *init_resb_result(const ResourceData *rdata, Resource r, if(mainRes != result) { ures_close(mainRes); } + ResourceTracer(resB).maybeTrace("getalias"); return result; } } else { @@ -1256,6 +1247,7 @@ static UResourceBundle *init_resb_result(const ResourceData *rdata, Resource r, /*resB->fParent = parent->fRes;*/ uprv_memmove(&resB->fResData, rdata, sizeof(ResourceData)); resB->fSize = res_countArrayItems(&(resB->fResData), resB->fRes); + ResourceTracer(resB).trace("get"); return resB; } @@ -1304,7 +1296,7 @@ U_CAPI const UChar* U_EXPORT2 ures_getString(const UResourceBundle* resB, int32_ *status = U_ILLEGAL_ARGUMENT_ERROR; return NULL; } - s = res_getString(&(resB->fResData), resB->fRes, len); + s = res_getString({resB}, &(resB->fResData), resB->fRes, len); if (s == NULL) { *status = U_RESOURCE_TYPE_MISMATCH; } @@ -1393,7 +1385,7 @@ U_CAPI const uint8_t* U_EXPORT2 ures_getBinary(const UResourceBundle* resB, int3 *status = U_ILLEGAL_ARGUMENT_ERROR; return NULL; } - p = res_getBinary(&(resB->fResData), resB->fRes, len); + p = res_getBinary({resB}, &(resB->fResData), resB->fRes, len); if (p == NULL) { *status = U_RESOURCE_TYPE_MISMATCH; } @@ -1410,7 +1402,7 @@ U_CAPI const int32_t* U_EXPORT2 ures_getIntVector(const UResourceBundle* resB, i *status = U_ILLEGAL_ARGUMENT_ERROR; return NULL; } - p = res_getIntVector(&(resB->fResData), resB->fRes, len); + p = res_getIntVector({resB}, &(resB->fResData), resB->fRes, len); if (p == NULL) { *status = U_RESOURCE_TYPE_MISMATCH; } @@ -1431,7 +1423,7 @@ U_CAPI int32_t U_EXPORT2 ures_getInt(const UResourceBundle* resB, UErrorCode *st *status = U_RESOURCE_TYPE_MISMATCH; return 0xffffffff; } - return RES_GET_INT(resB->fRes); + return res_getInt({resB}, resB->fRes); } U_CAPI uint32_t U_EXPORT2 ures_getUInt(const UResourceBundle* resB, UErrorCode *status) { @@ -1446,7 +1438,7 @@ U_CAPI uint32_t U_EXPORT2 ures_getUInt(const UResourceBundle* resB, UErrorCode * *status = U_RESOURCE_TYPE_MISMATCH; return 0xffffffff; } - return RES_GET_UINT(resB->fRes); + return res_getUInt({resB}, resB->fRes); } U_CAPI UResType U_EXPORT2 ures_getType(const UResourceBundle *resB) { @@ -1457,10 +1449,18 @@ U_CAPI UResType U_EXPORT2 ures_getType(const UResourceBundle *resB) { } U_CAPI const char * U_EXPORT2 ures_getKey(const UResourceBundle *resB) { + // + // TODO: Trace ures_getKey? I guess not usually. + // + // We usually get the key string to decide whether we want the value, or to + // make a key-value pair. Tracing the value should suffice. + // + // However, I believe we have some data (e.g., in res_index) where the key + // strings are the data. Tracing the enclosing table should suffice. + // if(resB == NULL) { return NULL; } - return(resB->fKey); } @@ -1480,7 +1480,7 @@ static const UChar* ures_getStringWithAlias(const UResourceBundle *resB, Resourc ures_close(tempRes); return result; } else { - return res_getString(&(resB->fResData), r, len); + return res_getString({resB, sIndex}, &(resB->fResData), r, len); } } @@ -1516,7 +1516,7 @@ U_CAPI const UChar* U_EXPORT2 ures_getNextString(UResourceBundle *resB, int32_t* switch(RES_GET_TYPE(resB->fRes)) { case URES_STRING: case URES_STRING_V2: - return res_getString(&(resB->fResData), resB->fRes, len); + return res_getString({resB}, &(resB->fResData), resB->fRes, len); case URES_TABLE: case URES_TABLE16: case URES_TABLE32: @@ -1661,7 +1661,7 @@ U_CAPI const UChar* U_EXPORT2 ures_getStringByIndex(const UResourceBundle *resB, switch(RES_GET_TYPE(resB->fRes)) { case URES_STRING: case URES_STRING_V2: - return res_getString(&(resB->fResData), resB->fRes, len); + return res_getString({resB}, &(resB->fResData), resB->fRes, len); case URES_TABLE: case URES_TABLE16: case URES_TABLE32: @@ -1953,10 +1953,10 @@ void getAllItemsWithFallback( // When the sink sees the no-fallback/no-inheritance marker, // then it would remove the parent's item. // We would deserialize parent values even though they are overridden in a child bundle. - value.pResData = &bundle->fResData; + value.setData(&bundle->fResData); UResourceDataEntry *parentEntry = bundle->fData->fParent; UBool hasParent = parentEntry != NULL && U_SUCCESS(parentEntry->fBogus); - value.setResource(bundle->fRes); + value.setResource(bundle->fRes, ResourceTracer(bundle)); sink.put(bundle->fKey, value, !hasParent, errorCode); if (hasParent) { // We might try to query the sink whether @@ -2001,31 +2001,60 @@ void getAllItemsWithFallback( } // namespace +// Requires a ResourceDataValue fill-in, so that we need not cast from a ResourceValue. +// Unfortunately, the caller must know which subclass to make and pass in. +// Alternatively, we could make it as polymorphic as in Java by +// returning a ResourceValue pointer (possibly wrapped into a LocalPointer) +// that the caller then owns. +// +// Also requires a UResourceBundle fill-in, so that the value's ResourceTracer +// can point to a non-local bundle. +// Without tracing, the child bundle could be a function-local object. +U_CAPI void U_EXPORT2 +ures_getValueWithFallback(const UResourceBundle *bundle, const char *path, + UResourceBundle *tempFillIn, + ResourceDataValue &value, UErrorCode &errorCode) { + if (U_FAILURE(errorCode)) { return; } + if (path == nullptr) { + errorCode = U_ILLEGAL_ARGUMENT_ERROR; + return; + } + const UResourceBundle *rb; + if (*path == 0) { + // empty path + rb = bundle; + } else { + rb = ures_getByKeyWithFallback(bundle, path, tempFillIn, &errorCode); + if (U_FAILURE(errorCode)) { + return; + } + } + value.setData(&rb->fResData); + value.setResource(rb->fRes, ResourceTracer(rb)); +} + U_CAPI void U_EXPORT2 ures_getAllItemsWithFallback(const UResourceBundle *bundle, const char *path, icu::ResourceSink &sink, UErrorCode &errorCode) { if (U_FAILURE(errorCode)) { return; } - if (path == NULL) { + if (path == nullptr) { errorCode = U_ILLEGAL_ARGUMENT_ERROR; return; } - UResourceBundle stackBundle; - ures_initStackObject(&stackBundle); + StackUResourceBundle stackBundle; const UResourceBundle *rb; if (*path == 0) { // empty path rb = bundle; } else { - rb = ures_getByKeyWithFallback(bundle, path, &stackBundle, &errorCode); + rb = ures_getByKeyWithFallback(bundle, path, stackBundle.getAlias(), &errorCode); if (U_FAILURE(errorCode)) { - ures_close(&stackBundle); return; } } // Get all table items with fallback. ResourceDataValue value; getAllItemsWithFallback(rb, value, sink, errorCode); - ures_close(&stackBundle); } U_CAPI UResourceBundle* U_EXPORT2 ures_getByKey(const UResourceBundle *resB, const char* inKey, UResourceBundle *fillIn, UErrorCode *status) { @@ -2108,7 +2137,7 @@ U_CAPI const UChar* U_EXPORT2 ures_getStringByKey(const UResourceBundle *resB, c switch (RES_GET_TYPE(res)) { case URES_STRING: case URES_STRING_V2: - return res_getString(rd, res, len); + return res_getString({resB, key}, rd, res, len); case URES_ALIAS: { const UChar* result = 0; @@ -2130,7 +2159,7 @@ U_CAPI const UChar* U_EXPORT2 ures_getStringByKey(const UResourceBundle *resB, c switch (RES_GET_TYPE(res)) { case URES_STRING: case URES_STRING_V2: - return res_getString(&(resB->fResData), res, len); + return res_getString({resB, key}, &(resB->fResData), res, len); case URES_ALIAS: { const UChar* result = 0; @@ -2151,6 +2180,7 @@ U_CAPI const UChar* U_EXPORT2 ures_getStringByKey(const UResourceBundle *resB, c /* here should go a first attempt to locate the key using index table */ const ResourceData *rd = getFallbackData(resB, &key, &realData, &res, status); if(U_SUCCESS(*status)) { + // TODO: Tracing return res_getString(rd, res, len); } else { *status = U_MISSING_RESOURCE_ERROR; @@ -2296,6 +2326,8 @@ ures_openWithType(UResourceBundle *r, const char* path, const char* localeID, r->fSize = res_countArrayItems(&(r->fResData), r->fRes); r->fIndex = -1; + ResourceTracer(r).traceOpen(); + return r; } diff --git a/deps/icu-small/source/common/uresdata.cpp b/deps/icu-small/source/common/uresdata.cpp index a0b8d3ba904ad6..1bb938be62c35b 100644 --- a/deps/icu-small/source/common/uresdata.cpp +++ b/deps/icu-small/source/common/uresdata.cpp @@ -33,6 +33,7 @@ #include "uinvchar.h" #include "uresdata.h" #include "uresimp.h" +#include "utracimp.h" /* * Resource access helpers @@ -307,7 +308,7 @@ res_getPublicType(Resource res) { } U_CAPI const UChar * U_EXPORT2 -res_getString(const ResourceData *pResData, Resource res, int32_t *pLength) { +res_getStringNoTrace(const ResourceData *pResData, Resource res, int32_t *pLength) { const UChar *p; uint32_t offset=RES_GET_OFFSET(res); int32_t length; @@ -402,7 +403,8 @@ int32_t getStringArray(const ResourceData *pResData, const icu::ResourceArray &a } for(int32_t i = 0; i < length; ++i) { int32_t sLength; - const UChar *s = res_getString(pResData, array.internalGetResource(pResData, i), &sLength); + // No tracing: handled by the caller + const UChar *s = res_getStringNoTrace(pResData, array.internalGetResource(pResData, i), &sLength); if(s == NULL) { errorCode = U_RESOURCE_TYPE_MISMATCH; return 0; @@ -434,7 +436,7 @@ res_getAlias(const ResourceData *pResData, Resource res, int32_t *pLength) { } U_CAPI const uint8_t * U_EXPORT2 -res_getBinary(const ResourceData *pResData, Resource res, int32_t *pLength) { +res_getBinaryNoTrace(const ResourceData *pResData, Resource res, int32_t *pLength) { const uint8_t *p; uint32_t offset=RES_GET_OFFSET(res); int32_t length; @@ -454,7 +456,7 @@ res_getBinary(const ResourceData *pResData, Resource res, int32_t *pLength) { U_CAPI const int32_t * U_EXPORT2 -res_getIntVector(const ResourceData *pResData, Resource res, int32_t *pLength) { +res_getIntVectorNoTrace(const ResourceData *pResData, Resource res, int32_t *pLength) { const int32_t *p; uint32_t offset=RES_GET_OFFSET(res); int32_t length; @@ -507,7 +509,7 @@ const UChar *ResourceDataValue::getString(int32_t &length, UErrorCode &errorCode if(U_FAILURE(errorCode)) { return NULL; } - const UChar *s = res_getString(pResData, res, &length); + const UChar *s = res_getString(fTraceInfo, &getData(), res, &length); if(s == NULL) { errorCode = U_RESOURCE_TYPE_MISMATCH; } @@ -518,7 +520,7 @@ const UChar *ResourceDataValue::getAliasString(int32_t &length, UErrorCode &erro if(U_FAILURE(errorCode)) { return NULL; } - const UChar *s = res_getAlias(pResData, res, &length); + const UChar *s = res_getAlias(&getData(), res, &length); if(s == NULL) { errorCode = U_RESOURCE_TYPE_MISMATCH; } @@ -532,7 +534,7 @@ int32_t ResourceDataValue::getInt(UErrorCode &errorCode) const { if(RES_GET_TYPE(res) != URES_INT) { errorCode = U_RESOURCE_TYPE_MISMATCH; } - return RES_GET_INT(res); + return res_getInt(fTraceInfo, res); } uint32_t ResourceDataValue::getUInt(UErrorCode &errorCode) const { @@ -542,14 +544,14 @@ uint32_t ResourceDataValue::getUInt(UErrorCode &errorCode) const { if(RES_GET_TYPE(res) != URES_INT) { errorCode = U_RESOURCE_TYPE_MISMATCH; } - return RES_GET_UINT(res); + return res_getUInt(fTraceInfo, res); } const int32_t *ResourceDataValue::getIntVector(int32_t &length, UErrorCode &errorCode) const { if(U_FAILURE(errorCode)) { return NULL; } - const int32_t *iv = res_getIntVector(pResData, res, &length); + const int32_t *iv = res_getIntVector(fTraceInfo, &getData(), res, &length); if(iv == NULL) { errorCode = U_RESOURCE_TYPE_MISMATCH; } @@ -560,7 +562,7 @@ const uint8_t *ResourceDataValue::getBinary(int32_t &length, UErrorCode &errorCo if(U_FAILURE(errorCode)) { return NULL; } - const uint8_t *b = res_getBinary(pResData, res, &length); + const uint8_t *b = res_getBinary(fTraceInfo, &getData(), res, &length); if(b == NULL) { errorCode = U_RESOURCE_TYPE_MISMATCH; } @@ -578,19 +580,19 @@ ResourceArray ResourceDataValue::getArray(UErrorCode &errorCode) const { switch(RES_GET_TYPE(res)) { case URES_ARRAY: if (offset!=0) { // empty if offset==0 - items32 = (const Resource *)pResData->pRoot+offset; + items32 = (const Resource *)getData().pRoot+offset; length = *items32++; } break; case URES_ARRAY16: - items16 = pResData->p16BitUnits+offset; + items16 = getData().p16BitUnits+offset; length = *items16++; break; default: errorCode = U_RESOURCE_TYPE_MISMATCH; return ResourceArray(); } - return ResourceArray(items16, items32, length); + return ResourceArray(items16, items32, length, fTraceInfo); } ResourceTable ResourceDataValue::getTable(UErrorCode &errorCode) const { @@ -606,19 +608,19 @@ ResourceTable ResourceDataValue::getTable(UErrorCode &errorCode) const { switch(RES_GET_TYPE(res)) { case URES_TABLE: if (offset != 0) { // empty if offset==0 - keys16 = (const uint16_t *)(pResData->pRoot+offset); + keys16 = (const uint16_t *)(getData().pRoot+offset); length = *keys16++; items32 = (const Resource *)(keys16+length+(~length&1)); } break; case URES_TABLE16: - keys16 = pResData->p16BitUnits+offset; + keys16 = getData().p16BitUnits+offset; length = *keys16++; items16 = keys16 + length; break; case URES_TABLE32: if (offset != 0) { // empty if offset==0 - keys32 = pResData->pRoot+offset; + keys32 = getData().pRoot+offset; length = *keys32++; items32 = (const Resource *)keys32 + length; } @@ -627,22 +629,22 @@ ResourceTable ResourceDataValue::getTable(UErrorCode &errorCode) const { errorCode = U_RESOURCE_TYPE_MISMATCH; return ResourceTable(); } - return ResourceTable(keys16, keys32, items16, items32, length); + return ResourceTable(keys16, keys32, items16, items32, length, fTraceInfo); } UBool ResourceDataValue::isNoInheritanceMarker() const { - return ::isNoInheritanceMarker(pResData, res); + return ::isNoInheritanceMarker(&getData(), res); } int32_t ResourceDataValue::getStringArray(UnicodeString *dest, int32_t capacity, UErrorCode &errorCode) const { - return ::getStringArray(pResData, getArray(errorCode), dest, capacity, errorCode); + return ::getStringArray(&getData(), getArray(errorCode), dest, capacity, errorCode); } int32_t ResourceDataValue::getStringArrayOrStringAsArray(UnicodeString *dest, int32_t capacity, UErrorCode &errorCode) const { if(URES_IS_ARRAY(res)) { - return ::getStringArray(pResData, getArray(errorCode), dest, capacity, errorCode); + return ::getStringArray(&getData(), getArray(errorCode), dest, capacity, errorCode); } if(U_FAILURE(errorCode)) { return 0; @@ -656,7 +658,7 @@ int32_t ResourceDataValue::getStringArrayOrStringAsArray(UnicodeString *dest, in return 1; } int32_t sLength; - const UChar *s = res_getString(pResData, res, &sLength); + const UChar *s = res_getString(fTraceInfo, &getData(), res, &sLength); if(s != NULL) { dest[0].setTo(TRUE, s, sLength); return 1; @@ -671,7 +673,7 @@ UnicodeString ResourceDataValue::getStringOrFirstOfArray(UErrorCode &errorCode) return us; } int32_t sLength; - const UChar *s = res_getString(pResData, res, &sLength); + const UChar *s = res_getString(fTraceInfo, &getData(), res, &sLength); if(s != NULL) { us.setTo(TRUE, s, sLength); return us; @@ -681,7 +683,8 @@ UnicodeString ResourceDataValue::getStringOrFirstOfArray(UErrorCode &errorCode) return us; } if(array.getSize() > 0) { - s = res_getString(pResData, array.internalGetResource(pResData, 0), &sLength); + // Tracing is already performed above (unimportant for trace that this is an array) + s = res_getStringNoTrace(&getData(), array.internalGetResource(&getData(), 0), &sLength); if(s != NULL) { us.setTo(TRUE, s, sLength); return us; @@ -818,18 +821,45 @@ UBool icu::ResourceTable::getKeyAndValue(int32_t i, const char *&key, icu::ResourceValue &value) const { if(0 <= i && i < length) { icu::ResourceDataValue &rdValue = static_cast(value); - if (keys16 != NULL) { - key = RES_GET_KEY16(rdValue.pResData, keys16[i]); + if (keys16 != nullptr) { + key = RES_GET_KEY16(&rdValue.getData(), keys16[i]); } else { - key = RES_GET_KEY32(rdValue.pResData, keys32[i]); + key = RES_GET_KEY32(&rdValue.getData(), keys32[i]); } Resource res; - if (items16 != NULL) { - res = makeResourceFrom16(rdValue.pResData, items16[i]); + if (items16 != nullptr) { + res = makeResourceFrom16(&rdValue.getData(), items16[i]); } else { res = items32[i]; } - rdValue.setResource(res); + // Note: the ResourceTracer keeps a reference to the field of this + // ResourceTable. This is OK because the ResourceTable should remain + // alive for the duration that fields are being read from it + // (including nested fields). + rdValue.setResource(res, ResourceTracer(fTraceInfo, key)); + return TRUE; + } + return FALSE; +} + +UBool icu::ResourceTable::findValue(const char *key, ResourceValue &value) const { + icu::ResourceDataValue &rdValue = static_cast(value); + const char *realKey = nullptr; + int32_t i; + if (keys16 != nullptr) { + i = _res_findTableItem(&rdValue.getData(), keys16, length, key, &realKey); + } else { + i = _res_findTable32Item(&rdValue.getData(), keys32, length, key, &realKey); + } + if (i >= 0) { + Resource res; + if (items16 != nullptr) { + res = makeResourceFrom16(&rdValue.getData(), items16[i]); + } else { + res = items32[i]; + } + // Same note about lifetime as in getKeyAndValue(). + rdValue.setResource(res, ResourceTracer(fTraceInfo, key)); return TRUE; } return FALSE; @@ -875,7 +905,13 @@ uint32_t icu::ResourceArray::internalGetResource(const ResourceData *pResData, i UBool icu::ResourceArray::getValue(int32_t i, icu::ResourceValue &value) const { if(0 <= i && i < length) { icu::ResourceDataValue &rdValue = static_cast(value); - rdValue.setResource(internalGetResource(rdValue.pResData, i)); + // Note: the ResourceTracer keeps a reference to the field of this + // ResourceArray. This is OK because the ResourceArray should remain + // alive for the duration that fields are being read from it + // (including nested fields). + rdValue.setResource( + internalGetResource(&rdValue.getData(), i), + ResourceTracer(fTraceInfo, i)); return TRUE; } return FALSE; diff --git a/deps/icu-small/source/common/uresdata.h b/deps/icu-small/source/common/uresdata.h index 4e28ddccf63199..d1b67babf29049 100644 --- a/deps/icu-small/source/common/uresdata.h +++ b/deps/icu-small/source/common/uresdata.h @@ -69,14 +69,16 @@ typedef uint32_t Resource; #define RES_GET_OFFSET(res) ((res)&0x0fffffff) #define RES_GET_POINTER(pRoot, res) ((pRoot)+RES_GET_OFFSET(res)) -/* get signed and unsigned integer values directly from the Resource handle */ +/* get signed and unsigned integer values directly from the Resource handle + * NOTE: For proper logging, please use the res_getInt() constexpr + */ #if U_SIGNED_RIGHT_SHIFT_IS_ARITHMETIC -# define RES_GET_INT(res) (((int32_t)((res)<<4L))>>4L) +# define RES_GET_INT_NO_TRACE(res) (((int32_t)((res)<<4L))>>4L) #else -# define RES_GET_INT(res) (int32_t)(((res)&0x08000000) ? (res)|0xf0000000 : (res)&0x07ffffff) +# define RES_GET_INT_NO_TRACE(res) (int32_t)(((res)&0x08000000) ? (res)|0xf0000000 : (res)&0x07ffffff) #endif -#define RES_GET_UINT(res) ((res)&0x0fffffff) +#define RES_GET_UINT_NO_TRACE(res) ((res)&0x0fffffff) #define URES_IS_ARRAY(type) ((int32_t)(type)==URES_ARRAY || (int32_t)(type)==URES_ARRAY16) #define URES_IS_TABLE(type) ((int32_t)(type)==URES_TABLE || (int32_t)(type)==URES_TABLE16 || (int32_t)(type)==URES_TABLE32) @@ -423,22 +425,26 @@ res_unload(ResourceData *pResData); U_INTERNAL UResType U_EXPORT2 res_getPublicType(Resource res); +/////////////////////////////////////////////////////////////////////////// +// To enable tracing, use the inline versions of the res_get* functions. // +/////////////////////////////////////////////////////////////////////////// + /* * Return a pointer to a zero-terminated, const UChar* string * and set its length in *pLength. * Returns NULL if not found. */ U_INTERNAL const UChar * U_EXPORT2 -res_getString(const ResourceData *pResData, Resource res, int32_t *pLength); - -U_INTERNAL const UChar * U_EXPORT2 -res_getAlias(const ResourceData *pResData, Resource res, int32_t *pLength); +res_getStringNoTrace(const ResourceData *pResData, Resource res, int32_t *pLength); U_INTERNAL const uint8_t * U_EXPORT2 -res_getBinary(const ResourceData *pResData, Resource res, int32_t *pLength); +res_getBinaryNoTrace(const ResourceData *pResData, Resource res, int32_t *pLength); U_INTERNAL const int32_t * U_EXPORT2 -res_getIntVector(const ResourceData *pResData, Resource res, int32_t *pLength); +res_getIntVectorNoTrace(const ResourceData *pResData, Resource res, int32_t *pLength); + +U_INTERNAL const UChar * U_EXPORT2 +res_getAlias(const ResourceData *pResData, Resource res, int32_t *pLength); U_INTERNAL Resource U_EXPORT2 res_getResource(const ResourceData *pResData, const char *key); @@ -470,17 +476,55 @@ U_CFUNC Resource res_findResource(const ResourceData *pResData, Resource r, #ifdef __cplusplus #include "resource.h" +#include "restrace.h" U_NAMESPACE_BEGIN +inline const UChar* res_getString(const ResourceTracer& traceInfo, + const ResourceData *pResData, Resource res, int32_t *pLength) { + traceInfo.trace("string"); + return res_getStringNoTrace(pResData, res, pLength); +} + +inline const uint8_t* res_getBinary(const ResourceTracer& traceInfo, + const ResourceData *pResData, Resource res, int32_t *pLength) { + traceInfo.trace("binary"); + return res_getBinaryNoTrace(pResData, res, pLength); +} + +inline const int32_t* res_getIntVector(const ResourceTracer& traceInfo, + const ResourceData *pResData, Resource res, int32_t *pLength) { + traceInfo.trace("intvector"); + return res_getIntVectorNoTrace(pResData, res, pLength); +} + +inline int32_t res_getInt(const ResourceTracer& traceInfo, Resource res) { + traceInfo.trace("int"); + return RES_GET_INT_NO_TRACE(res); +} + +inline uint32_t res_getUInt(const ResourceTracer& traceInfo, Resource res) { + traceInfo.trace("uint"); + return RES_GET_UINT_NO_TRACE(res); +} + class ResourceDataValue : public ResourceValue { public: - ResourceDataValue() : pResData(NULL), res(static_cast(URES_NONE)) {} + ResourceDataValue() : + res(static_cast(URES_NONE)), + fTraceInfo() {} virtual ~ResourceDataValue(); - void setData(const ResourceData *data) { pResData = data; } - void setResource(Resource r) { res = r; } + void setData(const ResourceData *data) { + resData = *data; + } + void setResource(Resource r, ResourceTracer&& traceInfo) { + res = r; + fTraceInfo = traceInfo; + } + + const ResourceData &getData() const { return resData; } virtual UResType getType() const; virtual const UChar *getString(int32_t &length, UErrorCode &errorCode) const; virtual const UChar *getAliasString(int32_t &length, UErrorCode &errorCode) const; @@ -497,10 +541,12 @@ class ResourceDataValue : public ResourceValue { UErrorCode &errorCode) const; virtual UnicodeString getStringOrFirstOfArray(UErrorCode &errorCode) const; - const ResourceData *pResData; - private: + // TODO(ICU-20769): If UResourceBundle.fResData becomes a pointer, + // then remove this value field again and just store a pResData pointer. + ResourceData resData; Resource res; + ResourceTracer fTraceInfo; }; U_NAMESPACE_END diff --git a/deps/icu-small/source/common/uresimp.h b/deps/icu-small/source/common/uresimp.h index 16144012a5bc0d..2e477dfad3e98f 100644 --- a/deps/icu-small/source/common/uresimp.h +++ b/deps/icu-small/source/common/uresimp.h @@ -67,6 +67,9 @@ struct UResourceBundle { char *fVersion; UResourceDataEntry *fTopLevelData; /* for getting the valid locale */ char *fResPath; /* full path to the resource: "zh_TW/CollationElements/Sequence" */ + // TODO(ICU-20769): Try to change the by-value fResData into a pointer, + // with the struct in only one place for each bundle. + // Also replace class ResourceDataValue.resData with a pResData pointer again. ResourceData fResData; char fResBuf[RES_BUFSIZE]; int32_t fResPathLen; @@ -281,6 +284,11 @@ ures_getStringByKeyWithFallback(const UResourceBundle *resB, #ifdef __cplusplus +U_CAPI void U_EXPORT2 +ures_getValueWithFallback(const UResourceBundle *bundle, const char *path, + UResourceBundle *tempFillIn, + icu::ResourceDataValue &value, UErrorCode &errorCode); + U_CAPI void U_EXPORT2 ures_getAllItemsWithFallback(const UResourceBundle *bundle, const char *path, icu::ResourceSink &sink, UErrorCode &errorCode); diff --git a/deps/icu-small/source/common/usprep.cpp b/deps/icu-small/source/common/usprep.cpp index 9155ae077b3497..f1c075a391116f 100644 --- a/deps/icu-small/source/common/usprep.cpp +++ b/deps/icu-small/source/common/usprep.cpp @@ -45,13 +45,9 @@ U_CDECL_BEGIN Static cache for already opened StringPrep profiles */ static UHashtable *SHARED_DATA_HASHTABLE = NULL; -static icu::UInitOnce gSharedDataInitOnce; - -static UMutex *usprepMutex() { - static UMutex m = U_MUTEX_INITIALIZER; - return &m; -} +static icu::UInitOnce gSharedDataInitOnce = U_INITONCE_INITIALIZER; +static UMutex usprepMutex; /* format version of spp file */ //static uint8_t formatVersion[4]={ 0, 0, 0, 0 }; @@ -151,9 +147,9 @@ usprep_internal_flushCache(UBool noRefCount){ * if shared data hasn't even been lazy evaluated yet * return 0 */ - umtx_lock(usprepMutex()); + umtx_lock(&usprepMutex); if (SHARED_DATA_HASHTABLE == NULL) { - umtx_unlock(usprepMutex()); + umtx_unlock(&usprepMutex); return 0; } @@ -184,7 +180,7 @@ usprep_internal_flushCache(UBool noRefCount){ } } - umtx_unlock(usprepMutex()); + umtx_unlock(&usprepMutex); return deletedNum; } @@ -262,7 +258,7 @@ loadData(UStringPrepProfile* profile, } /* in the mutex block, set the data for this process */ - umtx_lock(usprepMutex()); + umtx_lock(&usprepMutex); if(profile->sprepData==NULL) { profile->sprepData=dataMemory; dataMemory=NULL; @@ -271,7 +267,7 @@ loadData(UStringPrepProfile* profile, } else { p=(const int32_t *)udata_getMemory(profile->sprepData); } - umtx_unlock(usprepMutex()); + umtx_unlock(&usprepMutex); /* initialize some variables */ profile->mappingData=(uint16_t *)((uint8_t *)(p+_SPREP_INDEX_TOP)+profile->indexes[_SPREP_INDEX_TRIE_SIZE]); @@ -328,12 +324,12 @@ usprep_getProfile(const char* path, stackKey.path = (char*) path; /* fetch the data from the cache */ - umtx_lock(usprepMutex()); + umtx_lock(&usprepMutex); profile = (UStringPrepProfile*) (uhash_get(SHARED_DATA_HASHTABLE,&stackKey)); if(profile != NULL) { profile->refCount++; } - umtx_unlock(usprepMutex()); + umtx_unlock(&usprepMutex); if(profile == NULL) { /* else load the data and put the data in the cache */ @@ -365,7 +361,7 @@ usprep_getProfile(const char* path, return NULL; } - umtx_lock(usprepMutex()); + umtx_lock(&usprepMutex); // If another thread already inserted the same key/value, refcount and cleanup our thread data profile = (UStringPrepProfile*) (uhash_get(SHARED_DATA_HASHTABLE,&stackKey)); if(profile != NULL) { @@ -386,7 +382,7 @@ usprep_getProfile(const char* path, profile->refCount = 1; uhash_put(SHARED_DATA_HASHTABLE, key.orphan(), profile, status); } - umtx_unlock(usprepMutex()); + umtx_unlock(&usprepMutex); } return profile; @@ -425,12 +421,12 @@ usprep_close(UStringPrepProfile* profile){ return; } - umtx_lock(usprepMutex()); + umtx_lock(&usprepMutex); /* decrement the ref count*/ if(profile->refCount > 0){ profile->refCount--; } - umtx_unlock(usprepMutex()); + umtx_unlock(&usprepMutex); } diff --git a/deps/icu-small/source/common/ustr_titlecase_brkiter.cpp b/deps/icu-small/source/common/ustr_titlecase_brkiter.cpp index 056b40eb4175f6..457905eb60da00 100644 --- a/deps/icu-small/source/common/ustr_titlecase_brkiter.cpp +++ b/deps/icu-small/source/common/ustr_titlecase_brkiter.cpp @@ -45,7 +45,7 @@ class WholeStringBreakIterator : public BreakIterator { WholeStringBreakIterator() : BreakIterator(), length(0) {} ~WholeStringBreakIterator() U_OVERRIDE; UBool operator==(const BreakIterator&) const U_OVERRIDE; - BreakIterator *clone() const U_OVERRIDE; + WholeStringBreakIterator *clone() const U_OVERRIDE; static UClassID U_EXPORT2 getStaticClassID(); UClassID getDynamicClassID() const U_OVERRIDE; CharacterIterator &getText() const U_OVERRIDE; @@ -62,9 +62,9 @@ class WholeStringBreakIterator : public BreakIterator { int32_t preceding(int32_t offset) U_OVERRIDE; UBool isBoundary(int32_t offset) U_OVERRIDE; int32_t next(int32_t n) U_OVERRIDE; - BreakIterator *createBufferClone(void *stackBuffer, int32_t &BufferSize, - UErrorCode &errorCode) U_OVERRIDE; - BreakIterator &refreshInputText(UText *input, UErrorCode &errorCode) U_OVERRIDE; + WholeStringBreakIterator *createBufferClone(void *stackBuffer, int32_t &BufferSize, + UErrorCode &errorCode) U_OVERRIDE; + WholeStringBreakIterator &refreshInputText(UText *input, UErrorCode &errorCode) U_OVERRIDE; private: int32_t length; @@ -74,7 +74,7 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(WholeStringBreakIterator) WholeStringBreakIterator::~WholeStringBreakIterator() {} UBool WholeStringBreakIterator::operator==(const BreakIterator&) const { return FALSE; } -BreakIterator *WholeStringBreakIterator::clone() const { return nullptr; } +WholeStringBreakIterator *WholeStringBreakIterator::clone() const { return nullptr; } CharacterIterator &WholeStringBreakIterator::getText() const { UPRV_UNREACHABLE; // really should not be called @@ -113,14 +113,14 @@ int32_t WholeStringBreakIterator::preceding(int32_t /*offset*/) { return 0; } UBool WholeStringBreakIterator::isBoundary(int32_t /*offset*/) { return FALSE; } int32_t WholeStringBreakIterator::next(int32_t /*n*/) { return length; } -BreakIterator *WholeStringBreakIterator::createBufferClone( +WholeStringBreakIterator *WholeStringBreakIterator::createBufferClone( void * /*stackBuffer*/, int32_t & /*BufferSize*/, UErrorCode &errorCode) { if (U_SUCCESS(errorCode)) { errorCode = U_UNSUPPORTED_ERROR; } return nullptr; } -BreakIterator &WholeStringBreakIterator::refreshInputText( +WholeStringBreakIterator &WholeStringBreakIterator::refreshInputText( UText * /*input*/, UErrorCode &errorCode) { if (U_SUCCESS(errorCode)) { errorCode = U_UNSUPPORTED_ERROR; diff --git a/deps/icu-small/source/common/ustring.cpp b/deps/icu-small/source/common/ustring.cpp index a1a51f4b1e1734..6886c145d9a216 100644 --- a/deps/icu-small/source/common/ustring.cpp +++ b/deps/icu-small/source/common/ustring.cpp @@ -1428,7 +1428,7 @@ u_unescape(const char *src, UChar *dest, int32_t destCapacity) { * NUL-terminate a string no matter what its type. * Set warning and error codes accordingly. */ -#define __TERMINATE_STRING(dest, destCapacity, length, pErrorCode) \ +#define __TERMINATE_STRING(dest, destCapacity, length, pErrorCode) UPRV_BLOCK_MACRO_BEGIN { \ if(pErrorCode!=NULL && U_SUCCESS(*pErrorCode)) { \ /* not a public function, so no complete argument checking */ \ \ @@ -1448,7 +1448,8 @@ u_unescape(const char *src, UChar *dest, int32_t destCapacity) { /* even the string itself did not fit - set an error code */ \ *pErrorCode=U_BUFFER_OVERFLOW_ERROR; \ } \ - } + } \ +} UPRV_BLOCK_MACRO_END U_CAPI int32_t U_EXPORT2 u_terminateUChars(UChar *dest, int32_t destCapacity, int32_t length, UErrorCode *pErrorCode) { @@ -1488,7 +1489,7 @@ u_terminateWChars(wchar_t *dest, int32_t destCapacity, int32_t length, UErrorCod the output range. [LIU] */ -#define STRING_HASH(TYPE, STR, STRLEN, DEREF) \ +#define STRING_HASH(TYPE, STR, STRLEN, DEREF) UPRV_BLOCK_MACRO_BEGIN { \ uint32_t hash = 0; \ const TYPE *p = (const TYPE*) STR; \ if (p != NULL) { \ @@ -1500,7 +1501,8 @@ u_terminateWChars(wchar_t *dest, int32_t destCapacity, int32_t length, UErrorCod p += inc; \ } \ } \ - return static_cast(hash) + return static_cast(hash); \ +} UPRV_BLOCK_MACRO_END /* Used by UnicodeString to compute its hashcode - Not public API. */ U_CAPI int32_t U_EXPORT2 diff --git a/deps/icu-small/source/common/utext.cpp b/deps/icu-small/source/common/utext.cpp index 5e3a005626e6b8..324341f1ba65dc 100644 --- a/deps/icu-small/source/common/utext.cpp +++ b/deps/icu-small/source/common/utext.cpp @@ -567,7 +567,7 @@ enum { struct ExtendedUText { UText ut; - UAlignedMemory extension; + max_align_t extension; }; static const UText emptyText = UTEXT_INITIALIZER; @@ -582,7 +582,7 @@ utext_setup(UText *ut, int32_t extraSpace, UErrorCode *status) { // We need to heap-allocate storage for the new UText int32_t spaceRequired = sizeof(UText); if (extraSpace > 0) { - spaceRequired = sizeof(ExtendedUText) + extraSpace - sizeof(UAlignedMemory); + spaceRequired = sizeof(ExtendedUText) + extraSpace - sizeof(max_align_t); } ut = (UText *)uprv_malloc(spaceRequired); if (ut == NULL) { diff --git a/deps/icu-small/source/common/util.cpp b/deps/icu-small/source/common/util.cpp index 838a201a73d803..56dd4f1bfa76a0 100644 --- a/deps/icu-small/source/common/util.cpp +++ b/deps/icu-small/source/common/util.cpp @@ -276,6 +276,16 @@ int32_t ICU_Utility::parsePattern(const UnicodeString& pat, return -1; // text ended before end of pat } +int32_t ICU_Utility::parseAsciiInteger(const UnicodeString& str, int32_t& pos) { + int32_t result = 0; + UChar c; + while (pos < str.length() && (c = str.charAt(pos)) >= u'0' && c <= u'9') { + result = result * 10 + (c - u'0'); + pos++; + } + return result; +} + /** * Append a character to a rule that is being built up. To flush * the quoteBuf to rule, make one final call with isLiteral == TRUE. diff --git a/deps/icu-small/source/common/util.h b/deps/icu-small/source/common/util.h index 92cdc9ef69a58a..a2be25056e9acb 100644 --- a/deps/icu-small/source/common/util.h +++ b/deps/icu-small/source/common/util.h @@ -179,12 +179,21 @@ class U_COMMON_API ICU_Utility /* not : public UObject because all methods are s * Parse an integer at pos, either of the form \d+ or of the form * 0x[0-9A-Fa-f]+ or 0[0-7]+, that is, in standard decimal, hex, * or octal format. - * @param pos INPUT-OUTPUT parameter. On input, the first - * character to parse. On output, the character after the last - * parsed character. + * @param pos INPUT-OUTPUT parameter. On input, the index of the first + * character to parse. On output, the index of the character after the + * last parsed character. */ static int32_t parseInteger(const UnicodeString& rule, int32_t& pos, int32_t limit); + /** + * Parse an integer at pos using only ASCII digits. + * Base 10 only. + * @param pos INPUT-OUTPUT parameter. On input, the index of the first + * character to parse. On output, the index of the character after the + * last parsed character. + */ + static int32_t parseAsciiInteger(const UnicodeString& str, int32_t& pos); + /** * Parse a Unicode identifier from the given string at the given * position. Return the identifier, or an empty string if there diff --git a/deps/icu-small/source/common/utrace.cpp b/deps/icu-small/source/common/utrace.cpp index 01bdb38e907518..04488d06a0e233 100644 --- a/deps/icu-small/source/common/utrace.cpp +++ b/deps/icu-small/source/common/utrace.cpp @@ -477,6 +477,16 @@ trCollNames[] = { }; +static const char* const +trResDataNames[] = { + "resc", + "bundle-open", + "file-open", + "res-open", + NULL +}; + + U_CAPI const char * U_EXPORT2 utrace_functionName(int32_t fnNumber) { if(UTRACE_FUNCTION_START <= fnNumber && fnNumber < UTRACE_FUNCTION_LIMIT) { @@ -485,6 +495,8 @@ utrace_functionName(int32_t fnNumber) { return trConvNames[fnNumber - UTRACE_CONVERSION_START]; } else if(UTRACE_COLLATION_START <= fnNumber && fnNumber < UTRACE_COLLATION_LIMIT){ return trCollNames[fnNumber - UTRACE_COLLATION_START]; + } else if(UTRACE_UDATA_START <= fnNumber && fnNumber < UTRACE_RES_DATA_LIMIT){ + return trResDataNames[fnNumber - UTRACE_UDATA_START]; } else { return "[BOGUS Trace Function Number]"; } diff --git a/deps/icu-small/source/common/utracimp.h b/deps/icu-small/source/common/utracimp.h index c2819830e1ba52..84e7031da8bc17 100644 --- a/deps/icu-small/source/common/utracimp.h +++ b/deps/icu-small/source/common/utracimp.h @@ -144,10 +144,12 @@ U_CDECL_END */ #define UTRACE_ENTRY(fnNumber) \ int32_t utraceFnNumber=(fnNumber); \ +UPRV_BLOCK_MACRO_BEGIN { \ if(utrace_getLevel()>=UTRACE_INFO) { \ utrace_entry(fnNumber); \ utraceFnNumber |= UTRACE_TRACED_ENTRY; \ - } + } \ +} UPRV_BLOCK_MACRO_END /** @@ -162,10 +164,12 @@ U_CDECL_END */ #define UTRACE_ENTRY_OC(fnNumber) \ int32_t utraceFnNumber=(fnNumber); \ +UPRV_BLOCK_MACRO_BEGIN { \ if(utrace_getLevel()>=UTRACE_OPEN_CLOSE) { \ utrace_entry(fnNumber); \ utraceFnNumber |= UTRACE_TRACED_ENTRY; \ - } + } \ +} UPRV_BLOCK_MACRO_END /** * Trace statement for each exit point of a function that has a UTRACE_ENTRY() @@ -179,10 +183,11 @@ U_CDECL_END * * @internal */ -#define UTRACE_EXIT() \ - {if(utraceFnNumber & UTRACE_TRACED_ENTRY) { \ +#define UTRACE_EXIT() UPRV_BLOCK_MACRO_BEGIN { \ + if(utraceFnNumber & UTRACE_TRACED_ENTRY) { \ utrace_exit(utraceFnNumber & ~UTRACE_TRACED_ENTRY, UTRACE_EXITV_NONE); \ - }} + } \ +} UPRV_BLOCK_MACRO_END /** * Trace statement for each exit point of a function that has a UTRACE_ENTRY() @@ -192,25 +197,29 @@ U_CDECL_END * * @internal */ -#define UTRACE_EXIT_VALUE(val) \ - {if(utraceFnNumber & UTRACE_TRACED_ENTRY) { \ +#define UTRACE_EXIT_VALUE(val) UPRV_BLOCK_MACRO_BEGIN { \ + if(utraceFnNumber & UTRACE_TRACED_ENTRY) { \ utrace_exit(utraceFnNumber & ~UTRACE_TRACED_ENTRY, UTRACE_EXITV_I32, val); \ - }} + } \ +} UPRV_BLOCK_MACRO_END -#define UTRACE_EXIT_STATUS(status) \ - {if(utraceFnNumber & UTRACE_TRACED_ENTRY) { \ +#define UTRACE_EXIT_STATUS(status) UPRV_BLOCK_MACRO_BEGIN { \ + if(utraceFnNumber & UTRACE_TRACED_ENTRY) { \ utrace_exit(utraceFnNumber & ~UTRACE_TRACED_ENTRY, UTRACE_EXITV_STATUS, status); \ - }} + } \ +} UPRV_BLOCK_MACRO_END -#define UTRACE_EXIT_VALUE_STATUS(val, status) \ - {if(utraceFnNumber & UTRACE_TRACED_ENTRY) { \ +#define UTRACE_EXIT_VALUE_STATUS(val, status) UPRV_BLOCK_MACRO_BEGIN { \ + if(utraceFnNumber & UTRACE_TRACED_ENTRY) { \ utrace_exit(utraceFnNumber & ~UTRACE_TRACED_ENTRY, (UTRACE_EXITV_I32 | UTRACE_EXITV_STATUS), val, status); \ - }} + } \ +} UPRV_BLOCK_MACRO_END -#define UTRACE_EXIT_PTR_STATUS(ptr, status) \ - {if(utraceFnNumber & UTRACE_TRACED_ENTRY) { \ +#define UTRACE_EXIT_PTR_STATUS(ptr, status) UPRV_BLOCK_MACRO_BEGIN { \ + if(utraceFnNumber & UTRACE_TRACED_ENTRY) { \ utrace_exit(utraceFnNumber & ~UTRACE_TRACED_ENTRY, (UTRACE_EXITV_PTR | UTRACE_EXITV_STATUS), ptr, status); \ - }} + } \ +} UPRV_BLOCK_MACRO_END /** * Trace statement used inside functions that have a UTRACE_ENTRY() statement. @@ -220,10 +229,11 @@ U_CDECL_END * Calls utrace_data() if the level is high enough. * @internal */ -#define UTRACE_DATA0(level, fmt) \ +#define UTRACE_DATA0(level, fmt) UPRV_BLOCK_MACRO_BEGIN { \ if(UTRACE_LEVEL(level)) { \ utrace_data(utraceFnNumber & ~UTRACE_TRACED_ENTRY, (level), (fmt)); \ - } + } \ +} UPRV_BLOCK_MACRO_END /** * Trace statement used inside functions that have a UTRACE_ENTRY() statement. @@ -233,10 +243,11 @@ U_CDECL_END * Calls utrace_data() if the level is high enough. * @internal */ -#define UTRACE_DATA1(level, fmt, a) \ +#define UTRACE_DATA1(level, fmt, a) UPRV_BLOCK_MACRO_BEGIN { \ if(UTRACE_LEVEL(level)) { \ utrace_data(utraceFnNumber & ~UTRACE_TRACED_ENTRY , (level), (fmt), (a)); \ - } + } \ +} UPRV_BLOCK_MACRO_END /** * Trace statement used inside functions that have a UTRACE_ENTRY() statement. @@ -246,10 +257,11 @@ U_CDECL_END * Calls utrace_data() if the level is high enough. * @internal */ -#define UTRACE_DATA2(level, fmt, a, b) \ +#define UTRACE_DATA2(level, fmt, a, b) UPRV_BLOCK_MACRO_BEGIN { \ if(UTRACE_LEVEL(level)) { \ utrace_data(utraceFnNumber & ~UTRACE_TRACED_ENTRY , (level), (fmt), (a), (b)); \ - } + } \ +} UPRV_BLOCK_MACRO_END /** * Trace statement used inside functions that have a UTRACE_ENTRY() statement. @@ -259,10 +271,11 @@ U_CDECL_END * Calls utrace_data() if the level is high enough. * @internal */ -#define UTRACE_DATA3(level, fmt, a, b, c) \ +#define UTRACE_DATA3(level, fmt, a, b, c) UPRV_BLOCK_MACRO_BEGIN { \ if(UTRACE_LEVEL(level)) { \ utrace_data(utraceFnNumber & ~UTRACE_TRACED_ENTRY, (level), (fmt), (a), (b), (c)); \ - } + } \ +} UPRV_BLOCK_MACRO_END /** * Trace statement used inside functions that have a UTRACE_ENTRY() statement. @@ -272,10 +285,11 @@ U_CDECL_END * Calls utrace_data() if the level is high enough. * @internal */ -#define UTRACE_DATA4(level, fmt, a, b, c, d) \ +#define UTRACE_DATA4(level, fmt, a, b, c, d) UPRV_BLOCK_MACRO_BEGIN { \ if(UTRACE_LEVEL(level)) { \ utrace_data(utraceFnNumber & ~UTRACE_TRACED_ENTRY, (level), (fmt), (a), (b), (c), (d)); \ - } + } \ +} UPRV_BLOCK_MACRO_END /** * Trace statement used inside functions that have a UTRACE_ENTRY() statement. @@ -285,10 +299,11 @@ U_CDECL_END * Calls utrace_data() if the level is high enough. * @internal */ -#define UTRACE_DATA5(level, fmt, a, b, c, d, e) \ +#define UTRACE_DATA5(level, fmt, a, b, c, d, e) UPRV_BLOCK_MACRO_BEGIN { \ if(UTRACE_LEVEL(level)) { \ utrace_data(utraceFnNumber & ~UTRACE_TRACED_ENTRY, (level), (fmt), (a), (b), (c), (d), (e)); \ - } + } \ +} UPRV_BLOCK_MACRO_END /** * Trace statement used inside functions that have a UTRACE_ENTRY() statement. @@ -298,10 +313,11 @@ U_CDECL_END * Calls utrace_data() if the level is high enough. * @internal */ -#define UTRACE_DATA6(level, fmt, a, b, c, d, e, f) \ +#define UTRACE_DATA6(level, fmt, a, b, c, d, e, f) UPRV_BLOCK_MACRO_BEGIN { \ if(UTRACE_LEVEL(level)) { \ utrace_data(utraceFnNumber & ~UTRACE_TRACED_ENTRY, (level), (fmt), (a), (b), (c), (d), (e), (f)); \ - } + } \ +} UPRV_BLOCK_MACRO_END /** * Trace statement used inside functions that have a UTRACE_ENTRY() statement. @@ -311,10 +327,11 @@ U_CDECL_END * Calls utrace_data() if the level is high enough. * @internal */ -#define UTRACE_DATA7(level, fmt, a, b, c, d, e, f, g) \ +#define UTRACE_DATA7(level, fmt, a, b, c, d, e, f, g) UPRV_BLOCK_MACRO_BEGIN { \ if(UTRACE_LEVEL(level)) { \ utrace_data(utraceFnNumber & ~UTRACE_TRACED_ENTRY, (level), (fmt), (a), (b), (c), (d), (e), (f), (g)); \ - } + } \ +} UPRV_BLOCK_MACRO_END /** * Trace statement used inside functions that have a UTRACE_ENTRY() statement. @@ -324,10 +341,11 @@ U_CDECL_END * Calls utrace_data() if the level is high enough. * @internal */ -#define UTRACE_DATA8(level, fmt, a, b, c, d, e, f, g, h) \ +#define UTRACE_DATA8(level, fmt, a, b, c, d, e, f, g, h) UPRV_BLOCK_MACRO_BEGIN { \ if(UTRACE_LEVEL(level)) { \ utrace_data(utraceFnNumber & ~UTRACE_TRACED_ENTRY, (level), (fmt), (a), (b), (c), (d), (e), (f), (g), (h)); \ - } + } \ +} UPRV_BLOCK_MACRO_END /** * Trace statement used inside functions that have a UTRACE_ENTRY() statement. @@ -337,10 +355,11 @@ U_CDECL_END * Calls utrace_data() if the level is high enough. * @internal */ -#define UTRACE_DATA9(level, fmt, a, b, c, d, e, f, g, h, i) \ +#define UTRACE_DATA9(level, fmt, a, b, c, d, e, f, g, h, i) UPRV_BLOCK_MACRO_BEGIN { \ if(UTRACE_LEVEL(level)) { \ utrace_data(utraceFnNumber & ~UTRACE_TRACED_ENTRY, (level), (fmt), (a), (b), (c), (d), (e), (f), (g), (h), (i)); \ - } + } \ +} UPRV_BLOCK_MACRO_END #else diff --git a/deps/icu-small/source/common/utrie.h b/deps/icu-small/source/common/utrie.h index 3e2197eda6c261..532ba778eb6ed1 100644 --- a/deps/icu-small/source/common/utrie.h +++ b/deps/icu-small/source/common/utrie.h @@ -182,7 +182,7 @@ typedef struct UTrie UTrie; ] /** Internal trie getter from a pair of surrogates */ -#define _UTRIE_GET_FROM_PAIR(trie, data, c, c2, result, resultType) { \ +#define _UTRIE_GET_FROM_PAIR(trie, data, c, c2, result, resultType) UPRV_BLOCK_MACRO_BEGIN { \ int32_t __offset; \ \ /* get data for lead surrogate */ \ @@ -195,18 +195,18 @@ typedef struct UTrie UTrie; } else { \ (result)=(resultType)((trie)->initialValue); \ } \ -} +} UPRV_BLOCK_MACRO_END /** Internal trie getter from a BMP code point, treating a lead surrogate as a normal code point */ #define _UTRIE_GET_FROM_BMP(trie, data, c16) \ - _UTRIE_GET_RAW(trie, data, 0xd800<=(c16) && (c16)<=0xdbff ? UTRIE_LEAD_INDEX_DISP : 0, c16); + _UTRIE_GET_RAW(trie, data, 0xd800<=(c16) && (c16)<=0xdbff ? UTRIE_LEAD_INDEX_DISP : 0, c16) /** * Internal trie getter from a code point. * Could be faster(?) but longer with * if((c32)<=0xd7ff) { (result)=_UTRIE_GET_RAW(trie, data, 0, c32); } */ -#define _UTRIE_GET(trie, data, c32, result, resultType) \ +#define _UTRIE_GET(trie, data, c32, result, resultType) UPRV_BLOCK_MACRO_BEGIN { \ if((uint32_t)(c32)<=0xffff) { \ /* BMP code points */ \ (result)=_UTRIE_GET_FROM_BMP(trie, data, c32); \ @@ -217,10 +217,11 @@ typedef struct UTrie UTrie; } else { \ /* out of range */ \ (result)=(resultType)((trie)->initialValue); \ - } + } \ +} UPRV_BLOCK_MACRO_END /** Internal next-post-increment: get the next code point (c, c2) and its data */ -#define _UTRIE_NEXT(trie, data, src, limit, c, c2, result, resultType) { \ +#define _UTRIE_NEXT(trie, data, src, limit, c, c2, result, resultType) UPRV_BLOCK_MACRO_BEGIN { \ (c)=*(src)++; \ if(!U16_IS_LEAD(c)) { \ (c2)=0; \ @@ -233,10 +234,10 @@ typedef struct UTrie UTrie; (c2)=0; \ (result)=_UTRIE_GET_RAW((trie), data, UTRIE_LEAD_INDEX_DISP, (c)); \ } \ -} +} UPRV_BLOCK_MACRO_END /** Internal previous: get the previous code point (c, c2) and its data */ -#define _UTRIE_PREVIOUS(trie, data, start, src, c, c2, result, resultType) { \ +#define _UTRIE_PREVIOUS(trie, data, start, src, c, c2, result, resultType) UPRV_BLOCK_MACRO_BEGIN { \ (c)=*--(src); \ if(!U16_IS_SURROGATE(c)) { \ (c2)=0; \ @@ -257,7 +258,7 @@ typedef struct UTrie UTrie; (c2)=0; \ (result)=_UTRIE_GET_RAW((trie), data, UTRIE_LEAD_INDEX_DISP, (c)); \ } \ -} +} UPRV_BLOCK_MACRO_END /* Public UTrie API ---------------------------------------------------------*/ diff --git a/deps/icu-small/source/common/utrie2.h b/deps/icu-small/source/common/utrie2.h index 75028ee23ac1e9..671f44e16a65cc 100644 --- a/deps/icu-small/source/common/utrie2.h +++ b/deps/icu-small/source/common/utrie2.h @@ -871,7 +871,7 @@ utrie2_internalU8PrevIndex(const UTrie2 *trie, UChar32 c, (trie)->data[_UTRIE2_INDEX_FROM_CP(trie, asciiOffset, c)] /** Internal next-post-increment: get the next code point (c) and its data. */ -#define _UTRIE2_U16_NEXT(trie, data, src, limit, c, result) { \ +#define _UTRIE2_U16_NEXT(trie, data, src, limit, c, result) UPRV_BLOCK_MACRO_BEGIN { \ { \ uint16_t __c2; \ (c)=*(src)++; \ @@ -885,10 +885,10 @@ utrie2_internalU8PrevIndex(const UTrie2 *trie, UChar32 c, (result)=_UTRIE2_GET_FROM_SUPP((trie), data, (c)); \ } \ } \ -} +} UPRV_BLOCK_MACRO_END /** Internal pre-decrement-previous: get the previous code point (c) and its data */ -#define _UTRIE2_U16_PREV(trie, data, start, src, c, result) { \ +#define _UTRIE2_U16_PREV(trie, data, start, src, c, result) UPRV_BLOCK_MACRO_BEGIN { \ { \ uint16_t __c2; \ (c)=*--(src); \ @@ -900,10 +900,10 @@ utrie2_internalU8PrevIndex(const UTrie2 *trie, UChar32 c, (result)=_UTRIE2_GET_FROM_SUPP((trie), data, (c)); \ } \ } \ -} +} UPRV_BLOCK_MACRO_END /** Internal UTF-8 next-post-increment: get the next code point's data. */ -#define _UTRIE2_U8_NEXT(trie, ascii, data, src, limit, result) { \ +#define _UTRIE2_U8_NEXT(trie, ascii, data, src, limit, result) UPRV_BLOCK_MACRO_BEGIN { \ uint8_t __lead=(uint8_t)*(src)++; \ if(U8_IS_SINGLE(__lead)) { \ (result)=(trie)->ascii[__lead]; \ @@ -935,10 +935,10 @@ utrie2_internalU8PrevIndex(const UTrie2 *trie, UChar32 c, (result)=(trie)->data[__index>>3]; \ } \ } \ -} +} UPRV_BLOCK_MACRO_END /** Internal UTF-8 pre-decrement-previous: get the previous code point's data. */ -#define _UTRIE2_U8_PREV(trie, ascii, data, start, src, result) { \ +#define _UTRIE2_U8_PREV(trie, ascii, data, start, src, result) UPRV_BLOCK_MACRO_BEGIN { \ uint8_t __b=(uint8_t)*--(src); \ if(U8_IS_SINGLE(__b)) { \ (result)=(trie)->ascii[__b]; \ @@ -948,7 +948,7 @@ utrie2_internalU8PrevIndex(const UTrie2 *trie, UChar32 c, (src)-=__index&7; \ (result)=(trie)->data[__index>>3]; \ } \ -} +} UPRV_BLOCK_MACRO_END U_CDECL_END diff --git a/deps/icu-small/source/data/in/icudt64l.dat.bz2 b/deps/icu-small/source/data/in/icudt65l.dat.bz2 similarity index 54% rename from deps/icu-small/source/data/in/icudt64l.dat.bz2 rename to deps/icu-small/source/data/in/icudt65l.dat.bz2 index 962fe59750de58..f55e9252f6da9b 100644 Binary files a/deps/icu-small/source/data/in/icudt64l.dat.bz2 and b/deps/icu-small/source/data/in/icudt65l.dat.bz2 differ diff --git a/deps/icu-small/source/i18n/alphaindex.cpp b/deps/icu-small/source/i18n/alphaindex.cpp index 99f70114cbdb15..532e3373835e7c 100644 --- a/deps/icu-small/source/i18n/alphaindex.cpp +++ b/deps/icu-small/source/i18n/alphaindex.cpp @@ -260,8 +260,7 @@ AlphabeticIndex::ImmutableIndex *AlphabeticIndex::buildImmutableIndex(UErrorCode // but that would be worth it only if this method is called multiple times, // or called after using the old-style bucket iterator API. LocalPointer immutableBucketList(createBucketList(errorCode)); - LocalPointer coll( - static_cast(collatorPrimaryOnly_->clone())); + LocalPointer coll(collatorPrimaryOnly_->clone()); if (immutableBucketList.isNull() || coll.isNull()) { errorCode = U_MEMORY_ALLOCATION_ERROR; return NULL; @@ -907,7 +906,7 @@ void AlphabeticIndex::init(const Locale *locale, UErrorCode &status) { return; } } - collatorPrimaryOnly_ = static_cast(collator_->clone()); + collatorPrimaryOnly_ = collator_->clone(); if (collatorPrimaryOnly_ == NULL) { status = U_MEMORY_ALLOCATION_ERROR; return; @@ -958,7 +957,7 @@ collatorComparator(const void *context, const void *left, const void *right) { } if (leftString == NULL) { return 1; - }; + } if (rightString == NULL) { return -1; } diff --git a/deps/icu-small/source/i18n/anytrans.cpp b/deps/icu-small/source/i18n/anytrans.cpp index 6e382b824b95b7..167b0185285371 100644 --- a/deps/icu-small/source/i18n/anytrans.cpp +++ b/deps/icu-small/source/i18n/anytrans.cpp @@ -226,7 +226,7 @@ AnyTransliterator::AnyTransliterator(const AnyTransliterator& o) : /** * Transliterator API. */ -Transliterator* AnyTransliterator::clone() const { +AnyTransliterator* AnyTransliterator::clone() const { return new AnyTransliterator(*this); } diff --git a/deps/icu-small/source/i18n/anytrans.h b/deps/icu-small/source/i18n/anytrans.h index 703d42b6d4be55..627dee3c814e68 100644 --- a/deps/icu-small/source/i18n/anytrans.h +++ b/deps/icu-small/source/i18n/anytrans.h @@ -66,7 +66,7 @@ class AnyTransliterator : public Transliterator { /** * Transliterator API. */ - virtual Transliterator* clone() const; + virtual AnyTransliterator* clone() const; /** * Implements {@link Transliterator#handleTransliterate}. diff --git a/deps/icu-small/source/i18n/astro.cpp b/deps/icu-small/source/i18n/astro.cpp index 0d521b037dd772..d28e516472e1b9 100644 --- a/deps/icu-small/source/i18n/astro.cpp +++ b/deps/icu-small/source/i18n/astro.cpp @@ -65,10 +65,7 @@ static inline UBool isINVALID(double d) { return(uprv_isNaN(d)); } -static icu::UMutex *ccLock() { - static icu::UMutex m = U_MUTEX_INITIALIZER; - return &m; -} +static icu::UMutex ccLock; U_CDECL_BEGIN static UBool calendar_astro_cleanup(void) { @@ -1552,12 +1549,12 @@ int32_t CalendarCache::get(CalendarCache** cache, int32_t key, UErrorCode &statu if(U_FAILURE(status)) { return 0; } - umtx_lock(ccLock()); + umtx_lock(&ccLock); if(*cache == NULL) { createCache(cache, status); if(U_FAILURE(status)) { - umtx_unlock(ccLock()); + umtx_unlock(&ccLock); return 0; } } @@ -1565,7 +1562,7 @@ int32_t CalendarCache::get(CalendarCache** cache, int32_t key, UErrorCode &statu res = uhash_igeti((*cache)->fTable, key); U_DEBUG_ASTRO_MSG(("%p: GET: [%d] == %d\n", (*cache)->fTable, key, res)); - umtx_unlock(ccLock()); + umtx_unlock(&ccLock); return res; } @@ -1573,12 +1570,12 @@ void CalendarCache::put(CalendarCache** cache, int32_t key, int32_t value, UErro if(U_FAILURE(status)) { return; } - umtx_lock(ccLock()); + umtx_lock(&ccLock); if(*cache == NULL) { createCache(cache, status); if(U_FAILURE(status)) { - umtx_unlock(ccLock()); + umtx_unlock(&ccLock); return; } } @@ -1586,7 +1583,7 @@ void CalendarCache::put(CalendarCache** cache, int32_t key, int32_t value, UErro uhash_iputi((*cache)->fTable, key, value, &status); U_DEBUG_ASTRO_MSG(("%p: PUT: [%d] := %d\n", (*cache)->fTable, key, value)); - umtx_unlock(ccLock()); + umtx_unlock(&ccLock); } CalendarCache::CalendarCache(int32_t size, UErrorCode &status) { diff --git a/deps/icu-small/source/i18n/bocsu.h b/deps/icu-small/source/i18n/bocsu.h index 6b8ed5197097fd..631e29aa768b9d 100644 --- a/deps/icu-small/source/i18n/bocsu.h +++ b/deps/icu-small/source/i18n/bocsu.h @@ -144,14 +144,14 @@ U_NAMESPACE_END * yields negative modulo results and quotients that are one more than * what we need here. */ -#define NEGDIVMOD(n, d, m) { \ +#define NEGDIVMOD(n, d, m) UPRV_BLOCK_MACRO_BEGIN { \ (m)=(n)%(d); \ (n)/=(d); \ if((m)<0) { \ --(n); \ (m)+=(d); \ } \ -} +} UPRV_BLOCK_MACRO_END U_CFUNC UChar32 u_writeIdenticalLevelRun(UChar32 prev, const UChar *s, int32_t length, icu::ByteSink &sink); diff --git a/deps/icu-small/source/i18n/brktrans.cpp b/deps/icu-small/source/i18n/brktrans.cpp index ac9e2afb7e4679..46b0e345dae97d 100644 --- a/deps/icu-small/source/i18n/brktrans.cpp +++ b/deps/icu-small/source/i18n/brktrans.cpp @@ -64,7 +64,7 @@ BreakTransliterator::BreakTransliterator(const BreakTransliterator& o) : /** * Transliterator API. */ -Transliterator* BreakTransliterator::clone(void) const { +BreakTransliterator* BreakTransliterator::clone() const { return new BreakTransliterator(*this); } diff --git a/deps/icu-small/source/i18n/brktrans.h b/deps/icu-small/source/i18n/brktrans.h index fcc8bdd002ca76..caa1e16ee6e62e 100644 --- a/deps/icu-small/source/i18n/brktrans.h +++ b/deps/icu-small/source/i18n/brktrans.h @@ -54,7 +54,7 @@ class BreakTransliterator : public Transliterator { * Transliterator API. * @return A copy of the object. */ - virtual Transliterator* clone(void) const; + virtual BreakTransliterator* clone() const; virtual const UnicodeString &getInsertion() const; diff --git a/deps/icu-small/source/i18n/buddhcal.cpp b/deps/icu-small/source/i18n/buddhcal.cpp index b6ccbc4749955a..bddfd1768a0aba 100644 --- a/deps/icu-small/source/i18n/buddhcal.cpp +++ b/deps/icu-small/source/i18n/buddhcal.cpp @@ -53,7 +53,7 @@ BuddhistCalendar& BuddhistCalendar::operator= ( const BuddhistCalendar& right) return *this; } -Calendar* BuddhistCalendar::clone(void) const +BuddhistCalendar* BuddhistCalendar::clone() const { return new BuddhistCalendar(*this); } @@ -133,7 +133,7 @@ void BuddhistCalendar::timeToFields(UDate theTime, UBool quick, UErrorCode& stat */ static UDate gSystemDefaultCenturyStart = DBL_MIN; static int32_t gSystemDefaultCenturyStartYear = -1; -static icu::UInitOnce gBCInitOnce; +static icu::UInitOnce gBCInitOnce = U_INITONCE_INITIALIZER; UBool BuddhistCalendar::haveDefaultCentury() const diff --git a/deps/icu-small/source/i18n/buddhcal.h b/deps/icu-small/source/i18n/buddhcal.h index 89e3f3dec36625..c3ffa6a41d3565 100644 --- a/deps/icu-small/source/i18n/buddhcal.h +++ b/deps/icu-small/source/i18n/buddhcal.h @@ -94,7 +94,7 @@ class BuddhistCalendar : public GregorianCalendar { * @return return a polymorphic copy of this calendar. * @internal */ - virtual Calendar* clone(void) const; + virtual BuddhistCalendar* clone() const; public: /** diff --git a/deps/icu-small/source/i18n/calendar.cpp b/deps/icu-small/source/i18n/calendar.cpp index 85a387ef49ed16..94625465614547 100644 --- a/deps/icu-small/source/i18n/calendar.cpp +++ b/deps/icu-small/source/i18n/calendar.cpp @@ -268,6 +268,8 @@ static ECalType getCalendarTypeForLocale(const char *locid) { // canonicalize, so grandfathered variant will be transformed to keywords // e.g ja_JP_TRADITIONAL -> ja_JP@calendar=japanese + // NOTE: Since ICU-20187, ja_JP_TRADITIONAL no longer canonicalizes, and + // the Gregorian calendar is returned instead. int32_t canonicalLen = uloc_canonicalize(locid, canonicalName, sizeof(canonicalName) - 1, &status); if (U_FAILURE(status)) { return CALTYPE_GREGORIAN; @@ -748,6 +750,7 @@ fSkippedWallTime(UCAL_WALLTIME_LAST) validLocale[0] = 0; actualLocale[0] = 0; if (U_FAILURE(success)) { + delete zone; return; } if(zone == 0) { @@ -2592,7 +2595,7 @@ Calendar::isWeekend(UDate date, UErrorCode &status) const return FALSE; } // clone the calendar so we don't mess with the real one. - Calendar *work = (Calendar*)this->clone(); + Calendar *work = this->clone(); if (work == NULL) { status = U_MEMORY_ALLOCATION_ERROR; return FALSE; @@ -2752,7 +2755,7 @@ Calendar::getActualMinimum(UCalendarDateFields field, UErrorCode& status) const // clone the calendar so we don't mess with the real one, and set it to // accept anything for the field values - Calendar *work = (Calendar*)this->clone(); + Calendar *work = this->clone(); if (work == NULL) { status = U_MEMORY_ALLOCATION_ERROR; return 0; diff --git a/deps/icu-small/source/i18n/casetrn.cpp b/deps/icu-small/source/i18n/casetrn.cpp index f08d448881d364..06750b29837223 100644 --- a/deps/icu-small/source/i18n/casetrn.cpp +++ b/deps/icu-small/source/i18n/casetrn.cpp @@ -125,7 +125,7 @@ CaseMapTransliterator::CaseMapTransliterator(const CaseMapTransliterator& o) : /** * Transliterator API. */ -/*Transliterator* CaseMapTransliterator::clone(void) const { +/*CaseMapTransliterator* CaseMapTransliterator::clone() const { return new CaseMapTransliterator(*this); }*/ diff --git a/deps/icu-small/source/i18n/casetrn.h b/deps/icu-small/source/i18n/casetrn.h index eee443fc81d4e6..47914022f857eb 100644 --- a/deps/icu-small/source/i18n/casetrn.h +++ b/deps/icu-small/source/i18n/casetrn.h @@ -58,7 +58,7 @@ class CaseMapTransliterator : public Transliterator { * Transliterator API. * @return a copy of the object. */ - virtual Transliterator* clone(void) const = 0; + virtual CaseMapTransliterator* clone() const = 0; /** * ICU "poor man's RTTI", returns a UClassID for the actual class. diff --git a/deps/icu-small/source/i18n/chnsecal.cpp b/deps/icu-small/source/i18n/chnsecal.cpp index 3c4ad2a846619f..2ff9f755afe1f1 100644 --- a/deps/icu-small/source/i18n/chnsecal.cpp +++ b/deps/icu-small/source/i18n/chnsecal.cpp @@ -51,10 +51,7 @@ static void debug_chnsecal_msg(const char *pat, ...) // --- The cache -- -static icu::UMutex *astroLock() { // Protects access to gChineseCalendarAstro. - static icu::UMutex m = U_MUTEX_INITIALIZER; - return &m; -} +static icu::UMutex astroLock; static icu::CalendarAstronomer *gChineseCalendarAstro = NULL; // Lazy Creation & Access synchronized by class CalendarCache with a mutex. @@ -121,7 +118,7 @@ U_NAMESPACE_BEGIN //------------------------------------------------------------------------- -Calendar* ChineseCalendar::clone() const { +ChineseCalendar* ChineseCalendar::clone() const { return new ChineseCalendar(*this); } @@ -538,14 +535,14 @@ int32_t ChineseCalendar::winterSolstice(int32_t gyear) const { // PST 1298 with a final result of Dec 14 10:31:59 PST 1299. double ms = daysToMillis(Grego::fieldsToDay(gyear, UCAL_DECEMBER, 1)); - umtx_lock(astroLock()); + umtx_lock(&astroLock); if(gChineseCalendarAstro == NULL) { gChineseCalendarAstro = new CalendarAstronomer(); ucln_i18n_registerCleanup(UCLN_I18N_CHINESE_CALENDAR, calendar_chinese_cleanup); } gChineseCalendarAstro->setTime(ms); UDate solarLong = gChineseCalendarAstro->getSunTime(CalendarAstronomer::WINTER_SOLSTICE(), TRUE); - umtx_unlock(astroLock()); + umtx_unlock(&astroLock); // Winter solstice is 270 degrees solar longitude aka Dongzhi cacheValue = (int32_t)millisToDays(solarLong); @@ -568,14 +565,14 @@ int32_t ChineseCalendar::winterSolstice(int32_t gyear) const { */ int32_t ChineseCalendar::newMoonNear(double days, UBool after) const { - umtx_lock(astroLock()); + umtx_lock(&astroLock); if(gChineseCalendarAstro == NULL) { gChineseCalendarAstro = new CalendarAstronomer(); ucln_i18n_registerCleanup(UCLN_I18N_CHINESE_CALENDAR, calendar_chinese_cleanup); } gChineseCalendarAstro->setTime(daysToMillis(days)); UDate newMoon = gChineseCalendarAstro->getMoonTime(CalendarAstronomer::NEW_MOON(), after); - umtx_unlock(astroLock()); + umtx_unlock(&astroLock); return (int32_t) millisToDays(newMoon); } @@ -600,14 +597,14 @@ int32_t ChineseCalendar::synodicMonthsBetween(int32_t day1, int32_t day2) const */ int32_t ChineseCalendar::majorSolarTerm(int32_t days) const { - umtx_lock(astroLock()); + umtx_lock(&astroLock); if(gChineseCalendarAstro == NULL) { gChineseCalendarAstro = new CalendarAstronomer(); ucln_i18n_registerCleanup(UCLN_I18N_CHINESE_CALENDAR, calendar_chinese_cleanup); } gChineseCalendarAstro->setTime(daysToMillis(days)); UDate solarLongitude = gChineseCalendarAstro->getSunLongitude(); - umtx_unlock(astroLock()); + umtx_unlock(&astroLock); // Compute (floor(solarLongitude / (pi/6)) + 2) % 12 int32_t term = ( ((int32_t)(6 * solarLongitude / CalendarAstronomer::PI)) + 2 ) % 12; diff --git a/deps/icu-small/source/i18n/chnsecal.h b/deps/icu-small/source/i18n/chnsecal.h index 1b27d2d1bcc78b..c7c063738145e7 100644 --- a/deps/icu-small/source/i18n/chnsecal.h +++ b/deps/icu-small/source/i18n/chnsecal.h @@ -144,7 +144,7 @@ class U_I18N_API ChineseCalendar : public Calendar { virtual ~ChineseCalendar(); // clone - virtual Calendar* clone() const; + virtual ChineseCalendar* clone() const; private: diff --git a/deps/icu-small/source/i18n/choicfmt.cpp b/deps/icu-small/source/i18n/choicfmt.cpp index 1b846704bfe1e4..16880706d3f1dc 100644 --- a/deps/icu-small/source/i18n/choicfmt.cpp +++ b/deps/icu-small/source/i18n/choicfmt.cpp @@ -563,7 +563,7 @@ ChoiceFormat::matchStringUntilLimitPart( // ------------------------------------- -Format* +ChoiceFormat* ChoiceFormat::clone() const { ChoiceFormat *aCopy = new ChoiceFormat(*this); diff --git a/deps/icu-small/source/i18n/coll.cpp b/deps/icu-small/source/i18n/coll.cpp index 8bbe133664c2cd..984831e761bdd6 100644 --- a/deps/icu-small/source/i18n/coll.cpp +++ b/deps/icu-small/source/i18n/coll.cpp @@ -67,7 +67,7 @@ static int32_t availableLocaleListCount; static icu::ICULocaleService* gService = NULL; static icu::UInitOnce gServiceInitOnce = U_INITONCE_INITIALIZER; #endif -static icu::UInitOnce gAvailableLocaleListInitOnce; +static icu::UInitOnce gAvailableLocaleListInitOnce = U_INITONCE_INITIALIZER; /** * Release all static memory held by collator. diff --git a/deps/icu-small/source/i18n/collationiterator.cpp b/deps/icu-small/source/i18n/collationiterator.cpp index 961c9e9acef675..18ccf014f0a48c 100644 --- a/deps/icu-small/source/i18n/collationiterator.cpp +++ b/deps/icu-small/source/i18n/collationiterator.cpp @@ -872,7 +872,7 @@ CollationIterator::previousCE(UVector32 &offsets, UErrorCode &errorCode) { // consistent with forward iteration. while(offsets.size() <= ceBuffer.length) { offsets.addElement(limitOffset, errorCode); - }; + } } return ceBuffer.get(--ceBuffer.length); } else { @@ -932,7 +932,7 @@ CollationIterator::previousCEUnsafe(UChar32 c, UVector32 &offsets, UErrorCode &e offset = getOffset(); while(offsets.size() < ceBuffer.length) { offsets.addElement(offset, errorCode); - }; + } } U_ASSERT(offsets.size() == ceBuffer.length); // End offset corresponding to just after the unsafe-backwards segment. diff --git a/deps/icu-small/source/i18n/compactdecimalformat.cpp b/deps/icu-small/source/i18n/compactdecimalformat.cpp index 4dd2241b23d0a6..a4c9dad25c408f 100644 --- a/deps/icu-small/source/i18n/compactdecimalformat.cpp +++ b/deps/icu-small/source/i18n/compactdecimalformat.cpp @@ -30,9 +30,9 @@ CompactDecimalFormat::CompactDecimalFormat(const Locale& inLocale, UNumberCompac : DecimalFormat(new DecimalFormatSymbols(inLocale, status), status) { if (U_FAILURE(status)) return; // Minimal properties: let the non-shim code path do most of the logic for us. - fields->properties->compactStyle = style; - fields->properties->groupingSize = -2; // do not forward grouping information - fields->properties->minimumGroupingDigits = 2; + fields->properties.compactStyle = style; + fields->properties.groupingSize = -2; // do not forward grouping information + fields->properties.minimumGroupingDigits = 2; touch(status); } @@ -45,7 +45,7 @@ CompactDecimalFormat& CompactDecimalFormat::operator=(const CompactDecimalFormat return *this; } -Format* CompactDecimalFormat::clone() const { +CompactDecimalFormat* CompactDecimalFormat::clone() const { return new CompactDecimalFormat(*this); } diff --git a/deps/icu-small/source/i18n/coptccal.cpp b/deps/icu-small/source/i18n/coptccal.cpp index 39691217d0fcb5..229119bf164e80 100644 --- a/deps/icu-small/source/i18n/coptccal.cpp +++ b/deps/icu-small/source/i18n/coptccal.cpp @@ -40,7 +40,7 @@ CopticCalendar::~CopticCalendar() { } -Calendar* +CopticCalendar* CopticCalendar::clone() const { return new CopticCalendar(*this); diff --git a/deps/icu-small/source/i18n/coptccal.h b/deps/icu-small/source/i18n/coptccal.h index 0b82c36088fb0d..dc2d79c89e6c22 100644 --- a/deps/icu-small/source/i18n/coptccal.h +++ b/deps/icu-small/source/i18n/coptccal.h @@ -145,7 +145,7 @@ class CopticCalendar : public CECalendar { * @return return a polymorphic copy of this calendar. * @internal */ - virtual Calendar* clone(void) const; + virtual CopticCalendar* clone() const; /** * return the calendar type, "coptic" diff --git a/deps/icu-small/source/i18n/cpdtrans.cpp b/deps/icu-small/source/i18n/cpdtrans.cpp index a204de5a5352dd..624ae431d35aa6 100644 --- a/deps/icu-small/source/i18n/cpdtrans.cpp +++ b/deps/icu-small/source/i18n/cpdtrans.cpp @@ -323,7 +323,7 @@ CompoundTransliterator& CompoundTransliterator::operator=( /** * Transliterator API. */ -Transliterator* CompoundTransliterator::clone(void) const { +CompoundTransliterator* CompoundTransliterator::clone() const { return new CompoundTransliterator(*this); } diff --git a/deps/icu-small/source/i18n/cpdtrans.h b/deps/icu-small/source/i18n/cpdtrans.h index 29f3ba83fc1d57..e51b209411f68b 100644 --- a/deps/icu-small/source/i18n/cpdtrans.h +++ b/deps/icu-small/source/i18n/cpdtrans.h @@ -98,7 +98,7 @@ class U_I18N_API CompoundTransliterator : public Transliterator { /** * Transliterator API. */ - virtual Transliterator* clone(void) const; + virtual CompoundTransliterator* clone() const; /** * Returns the number of transliterators in this chain. diff --git a/deps/icu-small/source/i18n/csdetect.cpp b/deps/icu-small/source/i18n/csdetect.cpp index ad3565155dd382..566333fec667ad 100644 --- a/deps/icu-small/source/i18n/csdetect.cpp +++ b/deps/icu-small/source/i18n/csdetect.cpp @@ -47,7 +47,7 @@ struct CSRecognizerInfo : public UMemory { U_NAMESPACE_END static icu::CSRecognizerInfo **fCSRecognizers = NULL; -static icu::UInitOnce gCSRecognizersInitOnce; +static icu::UInitOnce gCSRecognizersInitOnce = U_INITONCE_INITIALIZER; static int32_t fCSRecognizers_size = 0; U_CDECL_BEGIN diff --git a/deps/icu-small/source/i18n/curramt.cpp b/deps/icu-small/source/i18n/curramt.cpp index 019c17df8e3379..69ab42ace9d9ec 100644 --- a/deps/icu-small/source/i18n/curramt.cpp +++ b/deps/icu-small/source/i18n/curramt.cpp @@ -38,7 +38,7 @@ CurrencyAmount& CurrencyAmount::operator=(const CurrencyAmount& other) { return *this; } -UObject* CurrencyAmount::clone() const { +CurrencyAmount* CurrencyAmount::clone() const { return new CurrencyAmount(*this); } diff --git a/deps/icu-small/source/i18n/currfmt.cpp b/deps/icu-small/source/i18n/currfmt.cpp index 8f20f783d25031..0ad0492ee7afbc 100644 --- a/deps/icu-small/source/i18n/currfmt.cpp +++ b/deps/icu-small/source/i18n/currfmt.cpp @@ -33,7 +33,7 @@ CurrencyFormat::CurrencyFormat(const CurrencyFormat& other) : CurrencyFormat::~CurrencyFormat() { } -Format* CurrencyFormat::clone() const { +CurrencyFormat* CurrencyFormat::clone() const { return new CurrencyFormat(*this); } diff --git a/deps/icu-small/source/i18n/currfmt.h b/deps/icu-small/source/i18n/currfmt.h index cc9bb3c1bacd05..69a031957bcea9 100644 --- a/deps/icu-small/source/i18n/currfmt.h +++ b/deps/icu-small/source/i18n/currfmt.h @@ -57,7 +57,7 @@ class CurrencyFormat : public MeasureFormat { /** * Override Format API. */ - virtual Format* clone() const; + virtual CurrencyFormat* clone() const; using MeasureFormat::format; diff --git a/deps/icu-small/source/i18n/currunit.cpp b/deps/icu-small/source/i18n/currunit.cpp index 39c49e468d117d..03347604a4c1fc 100644 --- a/deps/icu-small/source/i18n/currunit.cpp +++ b/deps/icu-small/source/i18n/currunit.cpp @@ -109,7 +109,7 @@ CurrencyUnit& CurrencyUnit::operator=(const CurrencyUnit& other) { return *this; } -UObject* CurrencyUnit::clone() const { +CurrencyUnit* CurrencyUnit::clone() const { return new CurrencyUnit(*this); } diff --git a/deps/icu-small/source/i18n/dangical.cpp b/deps/icu-small/source/i18n/dangical.cpp index bc3951f210ec45..54e2e99fa66711 100644 --- a/deps/icu-small/source/i18n/dangical.cpp +++ b/deps/icu-small/source/i18n/dangical.cpp @@ -65,7 +65,7 @@ DangiCalendar::~DangiCalendar() { } -Calendar* +DangiCalendar* DangiCalendar::clone() const { return new DangiCalendar(*this); diff --git a/deps/icu-small/source/i18n/dangical.h b/deps/icu-small/source/i18n/dangical.h index 1a1e06b9020295..4f2cf384f57664 100644 --- a/deps/icu-small/source/i18n/dangical.h +++ b/deps/icu-small/source/i18n/dangical.h @@ -66,7 +66,7 @@ class DangiCalendar : public ChineseCalendar { * Clone. * @internal */ - virtual Calendar* clone() const; + virtual DangiCalendar* clone() const; //---------------------------------------------------------------------- // Internal methods & astronomical calculations diff --git a/deps/icu-small/source/i18n/datefmt.cpp b/deps/icu-small/source/i18n/datefmt.cpp index 039f5bc226bb0a..413139db84c50d 100644 --- a/deps/icu-small/source/i18n/datefmt.cpp +++ b/deps/icu-small/source/i18n/datefmt.cpp @@ -154,7 +154,7 @@ DateFormat& DateFormat::operator=(const DateFormat& other) fCalendar = NULL; } if(other.fNumberFormat) { - fNumberFormat = (NumberFormat*)other.fNumberFormat->clone(); + fNumberFormat = other.fNumberFormat->clone(); } else { fNumberFormat = NULL; } @@ -598,7 +598,7 @@ DateFormat::adoptNumberFormat(NumberFormat* newNumberFormat) void DateFormat::setNumberFormat(const NumberFormat& newNumberFormat) { - NumberFormat* newNumFmtClone = (NumberFormat*)newNumberFormat.clone(); + NumberFormat* newNumFmtClone = newNumberFormat.clone(); if (newNumFmtClone != NULL) { adoptNumberFormat(newNumFmtClone); } diff --git a/deps/icu-small/source/i18n/decNumberLocal.h b/deps/icu-small/source/i18n/decNumberLocal.h index f6c291a9ad3359..e8d1b38653eb9d 100644 --- a/deps/icu-small/source/i18n/decNumberLocal.h +++ b/deps/icu-small/source/i18n/decNumberLocal.h @@ -259,7 +259,7 @@ /* 2,000,000,000 (as is needed for negative exponents of */ /* subnormals). The unsigned integer pow is used as a temporary */ /* variable. */ - #define TODIGIT(u, cut, c, pow) { \ + #define TODIGIT(u, cut, c, pow) UPRV_BLOCK_MACRO_BEGIN { \ *(c)='0'; \ pow=DECPOWERS[cut]*2; \ if ((u)>pow) { \ @@ -272,7 +272,7 @@ if ((u)>=pow) {(u)-=pow; *(c)+=2;} \ pow/=2; \ if ((u)>=pow) {(u)-=pow; *(c)+=1;} \ - } + } UPRV_BLOCK_MACRO_END /* ---------------------------------------------------------------- */ /* Definitions for fixed-precision modules (only valid after */ diff --git a/deps/icu-small/source/i18n/decimfmt.cpp b/deps/icu-small/source/i18n/decimfmt.cpp index 2a1e9347fa10d0..6a69c9d7a300e6 100644 --- a/deps/icu-small/source/i18n/decimfmt.cpp +++ b/deps/icu-small/source/i18n/decimfmt.cpp @@ -95,7 +95,7 @@ DecimalFormat::DecimalFormat(const UnicodeString& pattern, DecimalFormatSymbols* new CurrencyPluralInfo(fields->symbols->getLocale(), status), status); if (U_FAILURE(status)) { return; } - fields->properties->currencyPluralInfo.fPtr.adoptInstead(cpi.orphan()); + fields->properties.currencyPluralInfo.fPtr.adoptInstead(cpi.orphan()); } touch(status); } @@ -111,21 +111,14 @@ DecimalFormat::DecimalFormat(const DecimalFormatSymbols* symbolsToAdopt, UErrorC status = U_MEMORY_ALLOCATION_ERROR; return; } - fields->formatter.adoptInsteadAndCheckErrorCode(new LocalizedNumberFormatter(), status); - fields->properties.adoptInsteadAndCheckErrorCode(new DecimalFormatProperties(), status); - fields->exportedProperties.adoptInsteadAndCheckErrorCode(new DecimalFormatProperties(), status); if (adoptedSymbols.isNull()) { fields->symbols.adoptInsteadAndCheckErrorCode(new DecimalFormatSymbols(status), status); } else { fields->symbols.adoptInsteadAndCheckErrorCode(adoptedSymbols.orphan(), status); } - // In order to simplify error handling logic in the various getters/setters/etc, we do not allow - // any partially populated DecimalFormatFields object. We must have a fully complete fields object - // or else we set it to nullptr. - if (fields->formatter.isNull() || fields->properties.isNull() || fields->exportedProperties.isNull() || fields->symbols.isNull()) { + if (U_FAILURE(status)) { delete fields; fields = nullptr; - status = U_MEMORY_ALLOCATION_ERROR; } } @@ -133,8 +126,8 @@ DecimalFormat::DecimalFormat(const DecimalFormatSymbols* symbolsToAdopt, UErrorC void DecimalFormat::setParseAllInput(UNumberFormatAttributeValue value) { if (fields == nullptr) { return; } - if (value == fields->properties->parseAllInput) { return; } - fields->properties->parseAllInput = value; + if (value == fields->properties.parseAllInput) { return; } + fields->properties.parseAllInput = value; } #endif @@ -379,9 +372,9 @@ void DecimalFormat::setGroupingUsed(UBool enabled) { if (fields == nullptr) { return; } - if (UBOOL_TO_BOOL(enabled) == fields->properties->groupingUsed) { return; } + if (UBOOL_TO_BOOL(enabled) == fields->properties.groupingUsed) { return; } NumberFormat::setGroupingUsed(enabled); // to set field for compatibility - fields->properties->groupingUsed = enabled; + fields->properties.groupingUsed = enabled; touchNoError(); } @@ -389,9 +382,9 @@ void DecimalFormat::setParseIntegerOnly(UBool value) { if (fields == nullptr) { return; } - if (UBOOL_TO_BOOL(value) == fields->properties->parseIntegerOnly) { return; } + if (UBOOL_TO_BOOL(value) == fields->properties.parseIntegerOnly) { return; } NumberFormat::setParseIntegerOnly(value); // to set field for compatibility - fields->properties->parseIntegerOnly = value; + fields->properties.parseIntegerOnly = value; touchNoError(); } @@ -400,9 +393,9 @@ void DecimalFormat::setLenient(UBool enable) { return; } ParseMode mode = enable ? PARSE_MODE_LENIENT : PARSE_MODE_STRICT; - if (!fields->properties->parseMode.isNull() && mode == fields->properties->parseMode.getNoError()) { return; } + if (!fields->properties.parseMode.isNull() && mode == fields->properties.parseMode.getNoError()) { return; } NumberFormat::setLenient(enable); // to set field for compatibility - fields->properties->parseMode = mode; + fields->properties.parseMode = mode; touchNoError(); } @@ -441,19 +434,16 @@ DecimalFormat::DecimalFormat(const DecimalFormat& source) : NumberFormat(source) // Note: it is not safe to copy fields->formatter or fWarehouse directly because fields->formatter might have // dangling pointers to fields inside fWarehouse. The safe thing is to re-construct fields->formatter from // the property bag, despite being somewhat slower. - fields = new DecimalFormatFields(); + fields = new DecimalFormatFields(source.fields->properties); if (fields == nullptr) { return; // no way to report an error. } UErrorCode status = U_ZERO_ERROR; - fields->formatter.adoptInsteadAndCheckErrorCode(new LocalizedNumberFormatter(), status); - fields->properties.adoptInsteadAndCheckErrorCode(new DecimalFormatProperties(*source.fields->properties), status); fields->symbols.adoptInsteadAndCheckErrorCode(new DecimalFormatSymbols(*source.fields->symbols), status); - fields->exportedProperties.adoptInsteadAndCheckErrorCode(new DecimalFormatProperties(), status); // In order to simplify error handling logic in the various getters/setters/etc, we do not allow // any partially populated DecimalFormatFields object. We must have a fully complete fields object // or else we set it to nullptr. - if (fields->formatter.isNull() || fields->properties.isNull() || fields->exportedProperties.isNull() || fields->symbols.isNull()) { + if (U_FAILURE(status)) { delete fields; fields = nullptr; return; @@ -470,8 +460,8 @@ DecimalFormat& DecimalFormat::operator=(const DecimalFormat& rhs) { if (fields == nullptr || rhs.fields == nullptr) { return *this; // unfortunately, no way to report an error. } - *fields->properties = *rhs.fields->properties; - fields->exportedProperties->clear(); + fields->properties = rhs.fields->properties; + fields->exportedProperties.clear(); UErrorCode status = U_ZERO_ERROR; LocalPointer dfs(new DecimalFormatSymbols(*rhs.fields->symbols), status); if (U_FAILURE(status)) { @@ -495,7 +485,7 @@ DecimalFormat::~DecimalFormat() { delete fields; } -Format* DecimalFormat::clone() const { +DecimalFormat* DecimalFormat::clone() const { // can only clone valid objects. if (fields == nullptr) { return nullptr; @@ -517,7 +507,7 @@ UBool DecimalFormat::operator==(const Format& other) const { if (fields == nullptr || otherDF->fields == nullptr) { return false; } - return *fields->properties == *otherDF->fields->properties && *fields->symbols == *otherDF->fields->symbols; + return fields->properties == otherDF->fields->properties && *fields->symbols == *otherDF->fields->symbols; } UnicodeString& DecimalFormat::format(double number, UnicodeString& appendTo, FieldPosition& pos) const { @@ -529,7 +519,7 @@ UnicodeString& DecimalFormat::format(double number, UnicodeString& appendTo, Fie return appendTo; } UErrorCode localStatus = U_ZERO_ERROR; - FormattedNumber output = fields->formatter->formatDouble(number, localStatus); + FormattedNumber output = fields->formatter.formatDouble(number, localStatus); fieldPositionHelper(output, pos, appendTo.length(), localStatus); auto appendable = UnicodeStringAppendable(appendTo); output.appendTo(appendable, localStatus); @@ -550,7 +540,7 @@ UnicodeString& DecimalFormat::format(double number, UnicodeString& appendTo, Fie if (pos.getField() == FieldPosition::DONT_CARE && fastFormatDouble(number, appendTo)) { return appendTo; } - FormattedNumber output = fields->formatter->formatDouble(number, status); + FormattedNumber output = fields->formatter.formatDouble(number, status); fieldPositionHelper(output, pos, appendTo.length(), status); auto appendable = UnicodeStringAppendable(appendTo); output.appendTo(appendable, status); @@ -572,7 +562,7 @@ DecimalFormat::format(double number, UnicodeString& appendTo, FieldPositionItera if (posIter == nullptr && fastFormatDouble(number, appendTo)) { return appendTo; } - FormattedNumber output = fields->formatter->formatDouble(number, status); + FormattedNumber output = fields->formatter.formatDouble(number, status); fieldPositionIteratorHelper(output, posIter, appendTo.length(), status); auto appendable = UnicodeStringAppendable(appendTo); output.appendTo(appendable, status); @@ -603,7 +593,7 @@ UnicodeString& DecimalFormat::format(int64_t number, UnicodeString& appendTo, Fi return appendTo; } UErrorCode localStatus = U_ZERO_ERROR; - FormattedNumber output = fields->formatter->formatInt(number, localStatus); + FormattedNumber output = fields->formatter.formatInt(number, localStatus); fieldPositionHelper(output, pos, appendTo.length(), localStatus); auto appendable = UnicodeStringAppendable(appendTo); output.appendTo(appendable, localStatus); @@ -624,7 +614,7 @@ UnicodeString& DecimalFormat::format(int64_t number, UnicodeString& appendTo, Fi if (pos.getField() == FieldPosition::DONT_CARE && fastFormatInt64(number, appendTo)) { return appendTo; } - FormattedNumber output = fields->formatter->formatInt(number, status); + FormattedNumber output = fields->formatter.formatInt(number, status); fieldPositionHelper(output, pos, appendTo.length(), status); auto appendable = UnicodeStringAppendable(appendTo); output.appendTo(appendable, status); @@ -646,7 +636,7 @@ DecimalFormat::format(int64_t number, UnicodeString& appendTo, FieldPositionIter if (posIter == nullptr && fastFormatInt64(number, appendTo)) { return appendTo; } - FormattedNumber output = fields->formatter->formatInt(number, status); + FormattedNumber output = fields->formatter.formatInt(number, status); fieldPositionIteratorHelper(output, posIter, appendTo.length(), status); auto appendable = UnicodeStringAppendable(appendTo); output.appendTo(appendable, status); @@ -665,7 +655,7 @@ DecimalFormat::format(StringPiece number, UnicodeString& appendTo, FieldPosition appendTo.setToBogus(); return appendTo; } - FormattedNumber output = fields->formatter->formatDecimal(number, status); + FormattedNumber output = fields->formatter.formatDecimal(number, status); fieldPositionIteratorHelper(output, posIter, appendTo.length(), status); auto appendable = UnicodeStringAppendable(appendTo); output.appendTo(appendable, status); @@ -683,7 +673,7 @@ UnicodeString& DecimalFormat::format(const DecimalQuantity& number, UnicodeStrin appendTo.setToBogus(); return appendTo; } - FormattedNumber output = fields->formatter->formatDecimalQuantity(number, status); + FormattedNumber output = fields->formatter.formatDecimalQuantity(number, status); fieldPositionIteratorHelper(output, posIter, appendTo.length(), status); auto appendable = UnicodeStringAppendable(appendTo); output.appendTo(appendable, status); @@ -702,7 +692,7 @@ DecimalFormat::format(const DecimalQuantity& number, UnicodeString& appendTo, Fi appendTo.setToBogus(); return appendTo; } - FormattedNumber output = fields->formatter->formatDecimalQuantity(number, status); + FormattedNumber output = fields->formatter.formatDecimalQuantity(number, status); fieldPositionHelper(output, pos, appendTo.length(), status); auto appendable = UnicodeStringAppendable(appendTo); output.appendTo(appendable, status); @@ -823,7 +813,7 @@ const CurrencyPluralInfo* DecimalFormat::getCurrencyPluralInfo(void) const { if (fields == nullptr) { return nullptr; } - return fields->properties->currencyPluralInfo.fPtr.getAlias(); + return fields->properties.currencyPluralInfo.fPtr.getAlias(); } void DecimalFormat::adoptCurrencyPluralInfo(CurrencyPluralInfo* toAdopt) { @@ -833,7 +823,7 @@ void DecimalFormat::adoptCurrencyPluralInfo(CurrencyPluralInfo* toAdopt) { if (fields == nullptr) { return; } - fields->properties->currencyPluralInfo.fPtr.adoptInstead(cpi.orphan()); + fields->properties.currencyPluralInfo.fPtr.adoptInstead(cpi.orphan()); touchNoError(); } @@ -841,11 +831,11 @@ void DecimalFormat::setCurrencyPluralInfo(const CurrencyPluralInfo& info) { if (fields == nullptr) { return; } - if (fields->properties->currencyPluralInfo.fPtr.isNull()) { + if (fields->properties.currencyPluralInfo.fPtr.isNull()) { // Note: clone() can fail with OOM error, but we have no way to report it. :( - fields->properties->currencyPluralInfo.fPtr.adoptInstead(info.clone()); + fields->properties.currencyPluralInfo.fPtr.adoptInstead(info.clone()); } else { - *fields->properties->currencyPluralInfo.fPtr = info; // copy-assignment operator + *fields->properties.currencyPluralInfo.fPtr = info; // copy-assignment operator } touchNoError(); } @@ -856,7 +846,7 @@ UnicodeString& DecimalFormat::getPositivePrefix(UnicodeString& result) const { return result; } UErrorCode status = U_ZERO_ERROR; - fields->formatter->getAffixImpl(true, false, result, status); + fields->formatter.getAffixImpl(true, false, result, status); if (U_FAILURE(status)) { result.setToBogus(); } return result; } @@ -865,8 +855,8 @@ void DecimalFormat::setPositivePrefix(const UnicodeString& newValue) { if (fields == nullptr) { return; } - if (newValue == fields->properties->positivePrefix) { return; } - fields->properties->positivePrefix = newValue; + if (newValue == fields->properties.positivePrefix) { return; } + fields->properties.positivePrefix = newValue; touchNoError(); } @@ -876,7 +866,7 @@ UnicodeString& DecimalFormat::getNegativePrefix(UnicodeString& result) const { return result; } UErrorCode status = U_ZERO_ERROR; - fields->formatter->getAffixImpl(true, true, result, status); + fields->formatter.getAffixImpl(true, true, result, status); if (U_FAILURE(status)) { result.setToBogus(); } return result; } @@ -885,8 +875,8 @@ void DecimalFormat::setNegativePrefix(const UnicodeString& newValue) { if (fields == nullptr) { return; } - if (newValue == fields->properties->negativePrefix) { return; } - fields->properties->negativePrefix = newValue; + if (newValue == fields->properties.negativePrefix) { return; } + fields->properties.negativePrefix = newValue; touchNoError(); } @@ -896,7 +886,7 @@ UnicodeString& DecimalFormat::getPositiveSuffix(UnicodeString& result) const { return result; } UErrorCode status = U_ZERO_ERROR; - fields->formatter->getAffixImpl(false, false, result, status); + fields->formatter.getAffixImpl(false, false, result, status); if (U_FAILURE(status)) { result.setToBogus(); } return result; } @@ -905,8 +895,8 @@ void DecimalFormat::setPositiveSuffix(const UnicodeString& newValue) { if (fields == nullptr) { return; } - if (newValue == fields->properties->positiveSuffix) { return; } - fields->properties->positiveSuffix = newValue; + if (newValue == fields->properties.positiveSuffix) { return; } + fields->properties.positiveSuffix = newValue; touchNoError(); } @@ -916,7 +906,7 @@ UnicodeString& DecimalFormat::getNegativeSuffix(UnicodeString& result) const { return result; } UErrorCode status = U_ZERO_ERROR; - fields->formatter->getAffixImpl(false, true, result, status); + fields->formatter.getAffixImpl(false, true, result, status); if (U_FAILURE(status)) { result.setToBogus(); } return result; } @@ -925,8 +915,8 @@ void DecimalFormat::setNegativeSuffix(const UnicodeString& newValue) { if (fields == nullptr) { return; } - if (newValue == fields->properties->negativeSuffix) { return; } - fields->properties->negativeSuffix = newValue; + if (newValue == fields->properties.negativeSuffix) { return; } + fields->properties.negativeSuffix = newValue; touchNoError(); } @@ -935,13 +925,13 @@ UBool DecimalFormat::isSignAlwaysShown() const { if (fields == nullptr) { return DecimalFormatProperties::getDefault().signAlwaysShown; } - return fields->properties->signAlwaysShown; + return fields->properties.signAlwaysShown; } void DecimalFormat::setSignAlwaysShown(UBool value) { if (fields == nullptr) { return; } - if (UBOOL_TO_BOOL(value) == fields->properties->signAlwaysShown) { return; } - fields->properties->signAlwaysShown = value; + if (UBOOL_TO_BOOL(value) == fields->properties.signAlwaysShown) { return; } + fields->properties.signAlwaysShown = value; touchNoError(); } @@ -952,7 +942,7 @@ int32_t DecimalFormat::getMultiplier(void) const { // Fallback to using the default instance of DecimalFormatProperties. dfp = &(DecimalFormatProperties::getDefault()); } else { - dfp = fields->properties.getAlias(); + dfp = &fields->properties; } if (dfp->multiplier != 1) { return dfp->multiplier; @@ -984,11 +974,11 @@ void DecimalFormat::setMultiplier(int32_t multiplier) { value = temp; } if (delta != -1) { - fields->properties->magnitudeMultiplier = delta; - fields->properties->multiplier = 1; + fields->properties.magnitudeMultiplier = delta; + fields->properties.multiplier = 1; } else { - fields->properties->magnitudeMultiplier = 0; - fields->properties->multiplier = multiplier; + fields->properties.magnitudeMultiplier = 0; + fields->properties.multiplier = multiplier; } touchNoError(); } @@ -999,13 +989,13 @@ int32_t DecimalFormat::getMultiplierScale() const { // Fallback to using the default instance of DecimalFormatProperties. return DecimalFormatProperties::getDefault().multiplierScale; } - return fields->properties->multiplierScale; + return fields->properties.multiplierScale; } void DecimalFormat::setMultiplierScale(int32_t newValue) { if (fields == nullptr) { return; } - if (newValue == fields->properties->multiplierScale) { return; } - fields->properties->multiplierScale = newValue; + if (newValue == fields->properties.multiplierScale) { return; } + fields->properties.multiplierScale = newValue; touchNoError(); } @@ -1015,13 +1005,13 @@ double DecimalFormat::getRoundingIncrement(void) const { // Fallback to using the default instance of DecimalFormatProperties. return DecimalFormatProperties::getDefault().roundingIncrement; } - return fields->exportedProperties->roundingIncrement; + return fields->exportedProperties.roundingIncrement; } void DecimalFormat::setRoundingIncrement(double newValue) { if (fields == nullptr) { return; } - if (newValue == fields->properties->roundingIncrement) { return; } - fields->properties->roundingIncrement = newValue; + if (newValue == fields->properties.roundingIncrement) { return; } + fields->properties.roundingIncrement = newValue; touchNoError(); } @@ -1032,17 +1022,17 @@ ERoundingMode DecimalFormat::getRoundingMode(void) const { return static_cast(DecimalFormatProperties::getDefault().roundingMode.getNoError()); } // UNumberFormatRoundingMode and ERoundingMode have the same values. - return static_cast(fields->exportedProperties->roundingMode.getNoError()); + return static_cast(fields->exportedProperties.roundingMode.getNoError()); } void DecimalFormat::setRoundingMode(ERoundingMode roundingMode) { if (fields == nullptr) { return; } auto uRoundingMode = static_cast(roundingMode); - if (!fields->properties->roundingMode.isNull() && uRoundingMode == fields->properties->roundingMode.getNoError()) { + if (!fields->properties.roundingMode.isNull() && uRoundingMode == fields->properties.roundingMode.getNoError()) { return; } NumberFormat::setMaximumIntegerDigits(roundingMode); // to set field for compatibility - fields->properties->roundingMode = uRoundingMode; + fields->properties.roundingMode = uRoundingMode; touchNoError(); } @@ -1052,52 +1042,52 @@ int32_t DecimalFormat::getFormatWidth(void) const { // Fallback to using the default instance of DecimalFormatProperties. return DecimalFormatProperties::getDefault().formatWidth; } - return fields->properties->formatWidth; + return fields->properties.formatWidth; } void DecimalFormat::setFormatWidth(int32_t width) { if (fields == nullptr) { return; } - if (width == fields->properties->formatWidth) { return; } - fields->properties->formatWidth = width; + if (width == fields->properties.formatWidth) { return; } + fields->properties.formatWidth = width; touchNoError(); } UnicodeString DecimalFormat::getPadCharacterString() const { - if (fields == nullptr || fields->properties->padString.isBogus()) { + if (fields == nullptr || fields->properties.padString.isBogus()) { // Readonly-alias the static string kFallbackPaddingString return {TRUE, kFallbackPaddingString, -1}; } else { - return fields->properties->padString; + return fields->properties.padString; } } void DecimalFormat::setPadCharacter(const UnicodeString& padChar) { if (fields == nullptr) { return; } - if (padChar == fields->properties->padString) { return; } + if (padChar == fields->properties.padString) { return; } if (padChar.length() > 0) { - fields->properties->padString = UnicodeString(padChar.char32At(0)); + fields->properties.padString = UnicodeString(padChar.char32At(0)); } else { - fields->properties->padString.setToBogus(); + fields->properties.padString.setToBogus(); } touchNoError(); } EPadPosition DecimalFormat::getPadPosition(void) const { - if (fields == nullptr || fields->properties->padPosition.isNull()) { + if (fields == nullptr || fields->properties.padPosition.isNull()) { return EPadPosition::kPadBeforePrefix; } else { // UNumberFormatPadPosition and EPadPosition have the same values. - return static_cast(fields->properties->padPosition.getNoError()); + return static_cast(fields->properties.padPosition.getNoError()); } } void DecimalFormat::setPadPosition(EPadPosition padPos) { if (fields == nullptr) { return; } auto uPadPos = static_cast(padPos); - if (!fields->properties->padPosition.isNull() && uPadPos == fields->properties->padPosition.getNoError()) { + if (!fields->properties.padPosition.isNull() && uPadPos == fields->properties.padPosition.getNoError()) { return; } - fields->properties->padPosition = uPadPos; + fields->properties.padPosition = uPadPos; touchNoError(); } @@ -1107,17 +1097,17 @@ UBool DecimalFormat::isScientificNotation(void) const { // Fallback to using the default instance of DecimalFormatProperties. return (DecimalFormatProperties::getDefault().minimumExponentDigits != -1); } - return (fields->properties->minimumExponentDigits != -1); + return (fields->properties.minimumExponentDigits != -1); } void DecimalFormat::setScientificNotation(UBool useScientific) { if (fields == nullptr) { return; } int32_t minExp = useScientific ? 1 : -1; - if (fields->properties->minimumExponentDigits == minExp) { return; } + if (fields->properties.minimumExponentDigits == minExp) { return; } if (useScientific) { - fields->properties->minimumExponentDigits = 1; + fields->properties.minimumExponentDigits = 1; } else { - fields->properties->minimumExponentDigits = -1; + fields->properties.minimumExponentDigits = -1; } touchNoError(); } @@ -1128,13 +1118,13 @@ int8_t DecimalFormat::getMinimumExponentDigits(void) const { // Fallback to using the default instance of DecimalFormatProperties. return static_cast(DecimalFormatProperties::getDefault().minimumExponentDigits); } - return static_cast(fields->properties->minimumExponentDigits); + return static_cast(fields->properties.minimumExponentDigits); } void DecimalFormat::setMinimumExponentDigits(int8_t minExpDig) { if (fields == nullptr) { return; } - if (minExpDig == fields->properties->minimumExponentDigits) { return; } - fields->properties->minimumExponentDigits = minExpDig; + if (minExpDig == fields->properties.minimumExponentDigits) { return; } + fields->properties.minimumExponentDigits = minExpDig; touchNoError(); } @@ -1144,13 +1134,13 @@ UBool DecimalFormat::isExponentSignAlwaysShown(void) const { // Fallback to using the default instance of DecimalFormatProperties. return DecimalFormatProperties::getDefault().exponentSignAlwaysShown; } - return fields->properties->exponentSignAlwaysShown; + return fields->properties.exponentSignAlwaysShown; } void DecimalFormat::setExponentSignAlwaysShown(UBool expSignAlways) { if (fields == nullptr) { return; } - if (UBOOL_TO_BOOL(expSignAlways) == fields->properties->exponentSignAlwaysShown) { return; } - fields->properties->exponentSignAlwaysShown = expSignAlways; + if (UBOOL_TO_BOOL(expSignAlways) == fields->properties.exponentSignAlwaysShown) { return; } + fields->properties.exponentSignAlwaysShown = expSignAlways; touchNoError(); } @@ -1161,7 +1151,7 @@ int32_t DecimalFormat::getGroupingSize(void) const { // Fallback to using the default instance of DecimalFormatProperties. groupingSize = DecimalFormatProperties::getDefault().groupingSize; } else { - groupingSize = fields->properties->groupingSize; + groupingSize = fields->properties.groupingSize; } if (groupingSize < 0) { return 0; @@ -1171,8 +1161,8 @@ int32_t DecimalFormat::getGroupingSize(void) const { void DecimalFormat::setGroupingSize(int32_t newValue) { if (fields == nullptr) { return; } - if (newValue == fields->properties->groupingSize) { return; } - fields->properties->groupingSize = newValue; + if (newValue == fields->properties.groupingSize) { return; } + fields->properties.groupingSize = newValue; touchNoError(); } @@ -1183,7 +1173,7 @@ int32_t DecimalFormat::getSecondaryGroupingSize(void) const { // Fallback to using the default instance of DecimalFormatProperties. grouping2 = DecimalFormatProperties::getDefault().secondaryGroupingSize; } else { - grouping2 = fields->properties->secondaryGroupingSize; + grouping2 = fields->properties.secondaryGroupingSize; } if (grouping2 < 0) { return 0; @@ -1193,8 +1183,8 @@ int32_t DecimalFormat::getSecondaryGroupingSize(void) const { void DecimalFormat::setSecondaryGroupingSize(int32_t newValue) { if (fields == nullptr) { return; } - if (newValue == fields->properties->secondaryGroupingSize) { return; } - fields->properties->secondaryGroupingSize = newValue; + if (newValue == fields->properties.secondaryGroupingSize) { return; } + fields->properties.secondaryGroupingSize = newValue; touchNoError(); } @@ -1204,13 +1194,13 @@ int32_t DecimalFormat::getMinimumGroupingDigits() const { // Fallback to using the default instance of DecimalFormatProperties. return DecimalFormatProperties::getDefault().minimumGroupingDigits; } - return fields->properties->minimumGroupingDigits; + return fields->properties.minimumGroupingDigits; } void DecimalFormat::setMinimumGroupingDigits(int32_t newValue) { if (fields == nullptr) { return; } - if (newValue == fields->properties->minimumGroupingDigits) { return; } - fields->properties->minimumGroupingDigits = newValue; + if (newValue == fields->properties.minimumGroupingDigits) { return; } + fields->properties.minimumGroupingDigits = newValue; touchNoError(); } @@ -1220,13 +1210,13 @@ UBool DecimalFormat::isDecimalSeparatorAlwaysShown(void) const { // Fallback to using the default instance of DecimalFormatProperties. return DecimalFormatProperties::getDefault().decimalSeparatorAlwaysShown; } - return fields->properties->decimalSeparatorAlwaysShown; + return fields->properties.decimalSeparatorAlwaysShown; } void DecimalFormat::setDecimalSeparatorAlwaysShown(UBool newValue) { if (fields == nullptr) { return; } - if (UBOOL_TO_BOOL(newValue) == fields->properties->decimalSeparatorAlwaysShown) { return; } - fields->properties->decimalSeparatorAlwaysShown = newValue; + if (UBOOL_TO_BOOL(newValue) == fields->properties.decimalSeparatorAlwaysShown) { return; } + fields->properties.decimalSeparatorAlwaysShown = newValue; touchNoError(); } @@ -1236,13 +1226,13 @@ UBool DecimalFormat::isDecimalPatternMatchRequired(void) const { // Fallback to using the default instance of DecimalFormatProperties. return DecimalFormatProperties::getDefault().decimalPatternMatchRequired; } - return fields->properties->decimalPatternMatchRequired; + return fields->properties.decimalPatternMatchRequired; } void DecimalFormat::setDecimalPatternMatchRequired(UBool newValue) { if (fields == nullptr) { return; } - if (UBOOL_TO_BOOL(newValue) == fields->properties->decimalPatternMatchRequired) { return; } - fields->properties->decimalPatternMatchRequired = newValue; + if (UBOOL_TO_BOOL(newValue) == fields->properties.decimalPatternMatchRequired) { return; } + fields->properties.decimalPatternMatchRequired = newValue; touchNoError(); } @@ -1252,13 +1242,13 @@ UBool DecimalFormat::isParseNoExponent() const { // Fallback to using the default instance of DecimalFormatProperties. return DecimalFormatProperties::getDefault().parseNoExponent; } - return fields->properties->parseNoExponent; + return fields->properties.parseNoExponent; } void DecimalFormat::setParseNoExponent(UBool value) { if (fields == nullptr) { return; } - if (UBOOL_TO_BOOL(value) == fields->properties->parseNoExponent) { return; } - fields->properties->parseNoExponent = value; + if (UBOOL_TO_BOOL(value) == fields->properties.parseNoExponent) { return; } + fields->properties.parseNoExponent = value; touchNoError(); } @@ -1268,13 +1258,13 @@ UBool DecimalFormat::isParseCaseSensitive() const { // Fallback to using the default instance of DecimalFormatProperties. return DecimalFormatProperties::getDefault().parseCaseSensitive; } - return fields->properties->parseCaseSensitive; + return fields->properties.parseCaseSensitive; } void DecimalFormat::setParseCaseSensitive(UBool value) { if (fields == nullptr) { return; } - if (UBOOL_TO_BOOL(value) == fields->properties->parseCaseSensitive) { return; } - fields->properties->parseCaseSensitive = value; + if (UBOOL_TO_BOOL(value) == fields->properties.parseCaseSensitive) { return; } + fields->properties.parseCaseSensitive = value; touchNoError(); } @@ -1284,13 +1274,13 @@ UBool DecimalFormat::isFormatFailIfMoreThanMaxDigits() const { // Fallback to using the default instance of DecimalFormatProperties. return DecimalFormatProperties::getDefault().formatFailIfMoreThanMaxDigits; } - return fields->properties->formatFailIfMoreThanMaxDigits; + return fields->properties.formatFailIfMoreThanMaxDigits; } void DecimalFormat::setFormatFailIfMoreThanMaxDigits(UBool value) { if (fields == nullptr) { return; } - if (UBOOL_TO_BOOL(value) == fields->properties->formatFailIfMoreThanMaxDigits) { return; } - fields->properties->formatFailIfMoreThanMaxDigits = value; + if (UBOOL_TO_BOOL(value) == fields->properties.formatFailIfMoreThanMaxDigits) { return; } + fields->properties.formatFailIfMoreThanMaxDigits = value; touchNoError(); } @@ -1305,7 +1295,7 @@ UnicodeString& DecimalFormat::toPattern(UnicodeString& result) const { // so that CurrencyUsage is reflected properly. // TODO: Consider putting this logic in number_patternstring.cpp instead. ErrorCode localStatus; - DecimalFormatProperties tprops(*fields->properties); + DecimalFormatProperties tprops(fields->properties); bool useCurrency = ( !tprops.currency.isNull() || !tprops.currencyPluralInfo.fPtr.isNull() || @@ -1315,9 +1305,9 @@ UnicodeString& DecimalFormat::toPattern(UnicodeString& result) const { AffixUtils::hasCurrencySymbols(tprops.negativePrefixPattern, localStatus) || AffixUtils::hasCurrencySymbols(tprops.negativeSuffixPattern, localStatus)); if (useCurrency) { - tprops.minimumFractionDigits = fields->exportedProperties->minimumFractionDigits; - tprops.maximumFractionDigits = fields->exportedProperties->maximumFractionDigits; - tprops.roundingIncrement = fields->exportedProperties->roundingIncrement; + tprops.minimumFractionDigits = fields->exportedProperties.minimumFractionDigits; + tprops.maximumFractionDigits = fields->exportedProperties.maximumFractionDigits; + tprops.roundingIncrement = fields->exportedProperties.roundingIncrement; } result = PatternStringUtils::propertiesToPatternString(tprops, localStatus); return result; @@ -1373,49 +1363,53 @@ void DecimalFormat::applyLocalizedPattern(const UnicodeString& localizedPattern, void DecimalFormat::setMaximumIntegerDigits(int32_t newValue) { if (fields == nullptr) { return; } - if (newValue == fields->properties->maximumIntegerDigits) { return; } + if (newValue == fields->properties.maximumIntegerDigits) { return; } // For backwards compatibility, conflicting min/max need to keep the most recent setting. - int32_t min = fields->properties->minimumIntegerDigits; + int32_t min = fields->properties.minimumIntegerDigits; if (min >= 0 && min > newValue) { - fields->properties->minimumIntegerDigits = newValue; + fields->properties.minimumIntegerDigits = newValue; } - fields->properties->maximumIntegerDigits = newValue; + fields->properties.maximumIntegerDigits = newValue; touchNoError(); } void DecimalFormat::setMinimumIntegerDigits(int32_t newValue) { if (fields == nullptr) { return; } - if (newValue == fields->properties->minimumIntegerDigits) { return; } + if (newValue == fields->properties.minimumIntegerDigits) { return; } // For backwards compatibility, conflicting min/max need to keep the most recent setting. - int32_t max = fields->properties->maximumIntegerDigits; + int32_t max = fields->properties.maximumIntegerDigits; if (max >= 0 && max < newValue) { - fields->properties->maximumIntegerDigits = newValue; + fields->properties.maximumIntegerDigits = newValue; } - fields->properties->minimumIntegerDigits = newValue; + fields->properties.minimumIntegerDigits = newValue; touchNoError(); } void DecimalFormat::setMaximumFractionDigits(int32_t newValue) { if (fields == nullptr) { return; } - if (newValue == fields->properties->maximumFractionDigits) { return; } + if (newValue == fields->properties.maximumFractionDigits) { return; } + // cap for backward compatibility, formerly 340, now 999 + if (newValue > kMaxIntFracSig) { + newValue = kMaxIntFracSig; + } // For backwards compatibility, conflicting min/max need to keep the most recent setting. - int32_t min = fields->properties->minimumFractionDigits; + int32_t min = fields->properties.minimumFractionDigits; if (min >= 0 && min > newValue) { - fields->properties->minimumFractionDigits = newValue; + fields->properties.minimumFractionDigits = newValue; } - fields->properties->maximumFractionDigits = newValue; + fields->properties.maximumFractionDigits = newValue; touchNoError(); } void DecimalFormat::setMinimumFractionDigits(int32_t newValue) { if (fields == nullptr) { return; } - if (newValue == fields->properties->minimumFractionDigits) { return; } + if (newValue == fields->properties.minimumFractionDigits) { return; } // For backwards compatibility, conflicting min/max need to keep the most recent setting. - int32_t max = fields->properties->maximumFractionDigits; + int32_t max = fields->properties.maximumFractionDigits; if (max >= 0 && max < newValue) { - fields->properties->maximumFractionDigits = newValue; + fields->properties.maximumFractionDigits = newValue; } - fields->properties->minimumFractionDigits = newValue; + fields->properties.minimumFractionDigits = newValue; touchNoError(); } @@ -1425,7 +1419,7 @@ int32_t DecimalFormat::getMinimumSignificantDigits() const { // Fallback to using the default instance of DecimalFormatProperties. return DecimalFormatProperties::getDefault().minimumSignificantDigits; } - return fields->exportedProperties->minimumSignificantDigits; + return fields->exportedProperties.minimumSignificantDigits; } int32_t DecimalFormat::getMaximumSignificantDigits() const { @@ -1434,28 +1428,28 @@ int32_t DecimalFormat::getMaximumSignificantDigits() const { // Fallback to using the default instance of DecimalFormatProperties. return DecimalFormatProperties::getDefault().maximumSignificantDigits; } - return fields->exportedProperties->maximumSignificantDigits; + return fields->exportedProperties.maximumSignificantDigits; } void DecimalFormat::setMinimumSignificantDigits(int32_t value) { if (fields == nullptr) { return; } - if (value == fields->properties->minimumSignificantDigits) { return; } - int32_t max = fields->properties->maximumSignificantDigits; + if (value == fields->properties.minimumSignificantDigits) { return; } + int32_t max = fields->properties.maximumSignificantDigits; if (max >= 0 && max < value) { - fields->properties->maximumSignificantDigits = value; + fields->properties.maximumSignificantDigits = value; } - fields->properties->minimumSignificantDigits = value; + fields->properties.minimumSignificantDigits = value; touchNoError(); } void DecimalFormat::setMaximumSignificantDigits(int32_t value) { if (fields == nullptr) { return; } - if (value == fields->properties->maximumSignificantDigits) { return; } - int32_t min = fields->properties->minimumSignificantDigits; + if (value == fields->properties.maximumSignificantDigits) { return; } + int32_t min = fields->properties.minimumSignificantDigits; if (min >= 0 && min > value) { - fields->properties->minimumSignificantDigits = value; + fields->properties.minimumSignificantDigits = value; } - fields->properties->maximumSignificantDigits = value; + fields->properties.maximumSignificantDigits = value; touchNoError(); } @@ -1466,7 +1460,7 @@ UBool DecimalFormat::areSignificantDigitsUsed() const { // Fallback to using the default instance of DecimalFormatProperties. dfp = &(DecimalFormatProperties::getDefault()); } else { - dfp = fields->properties.getAlias(); + dfp = &fields->properties; } return dfp->minimumSignificantDigits != -1 || dfp->maximumSignificantDigits != -1; } @@ -1476,20 +1470,20 @@ void DecimalFormat::setSignificantDigitsUsed(UBool useSignificantDigits) { // These are the default values from the old implementation. if (useSignificantDigits) { - if (fields->properties->minimumSignificantDigits != -1 || - fields->properties->maximumSignificantDigits != -1) { + if (fields->properties.minimumSignificantDigits != -1 || + fields->properties.maximumSignificantDigits != -1) { return; } } else { - if (fields->properties->minimumSignificantDigits == -1 && - fields->properties->maximumSignificantDigits == -1) { + if (fields->properties.minimumSignificantDigits == -1 && + fields->properties.maximumSignificantDigits == -1) { return; } } int32_t minSig = useSignificantDigits ? 1 : -1; int32_t maxSig = useSignificantDigits ? 6 : -1; - fields->properties->minimumSignificantDigits = minSig; - fields->properties->maximumSignificantDigits = maxSig; + fields->properties.minimumSignificantDigits = minSig; + fields->properties.maximumSignificantDigits = maxSig; touchNoError(); } @@ -1503,11 +1497,11 @@ void DecimalFormat::setCurrency(const char16_t* theCurrency, UErrorCode& ec) { } CurrencyUnit currencyUnit(theCurrency, ec); if (U_FAILURE(ec)) { return; } - if (!fields->properties->currency.isNull() && fields->properties->currency.getNoError() == currencyUnit) { + if (!fields->properties.currency.isNull() && fields->properties.currency.getNoError() == currencyUnit) { return; } NumberFormat::setCurrency(theCurrency, ec); // to set field for compatibility - fields->properties->currency = currencyUnit; + fields->properties.currency = currencyUnit; // TODO: Set values in fields->symbols, too? touchNoError(); } @@ -1525,20 +1519,20 @@ void DecimalFormat::setCurrencyUsage(UCurrencyUsage newUsage, UErrorCode* ec) { *ec = U_MEMORY_ALLOCATION_ERROR; return; } - if (!fields->properties->currencyUsage.isNull() && newUsage == fields->properties->currencyUsage.getNoError()) { + if (!fields->properties.currencyUsage.isNull() && newUsage == fields->properties.currencyUsage.getNoError()) { return; } - fields->properties->currencyUsage = newUsage; + fields->properties.currencyUsage = newUsage; touch(*ec); } UCurrencyUsage DecimalFormat::getCurrencyUsage() const { // CurrencyUsage is not exported, so we have to get it from the input property bag. // TODO: Should we export CurrencyUsage instead? - if (fields == nullptr || fields->properties->currencyUsage.isNull()) { + if (fields == nullptr || fields->properties.currencyUsage.isNull()) { return UCURR_USAGE_STANDARD; } - return fields->properties->currencyUsage.getNoError(); + return fields->properties.currencyUsage.getNoError(); } void @@ -1550,7 +1544,7 @@ DecimalFormat::formatToDecimalQuantity(double number, DecimalQuantity& output, U status = U_MEMORY_ALLOCATION_ERROR; return; } - fields->formatter->formatDouble(number, status).getDecimalQuantity(output, status); + fields->formatter.formatDouble(number, status).getDecimalQuantity(output, status); } void DecimalFormat::formatToDecimalQuantity(const Formattable& number, DecimalQuantity& output, @@ -1564,7 +1558,7 @@ void DecimalFormat::formatToDecimalQuantity(const Formattable& number, DecimalQu } UFormattedNumberData obj; number.populateDecimalQuantity(obj.quantity, status); - fields->formatter->formatImpl(&obj, status); + fields->formatter.formatImpl(&obj, status); output = std::move(obj.quantity); } @@ -1576,12 +1570,7 @@ const number::LocalizedNumberFormatter* DecimalFormat::toNumberFormatter(UErrorC status = U_MEMORY_ALLOCATION_ERROR; return nullptr; } - return &*fields->formatter; -} - -const number::LocalizedNumberFormatter& DecimalFormat::toNumberFormatter() const { - UErrorCode localStatus = U_ZERO_ERROR; - return *toNumberFormatter(localStatus); + return &fields->formatter; } /** Rebuilds the formatter object from the property bag. */ @@ -1608,9 +1597,9 @@ void DecimalFormat::touch(UErrorCode& status) { // Since memory has already been allocated for the formatter, we can move assign a stack-allocated object // and don't need to call new. (Which is slower and could possibly fail). - *fields->formatter = NumberPropertyMapper::create( - *fields->properties, *fields->symbols, fields->warehouse, *fields->exportedProperties, status).locale( - locale); + fields->formatter = NumberPropertyMapper::create( + fields->properties, *fields->symbols, fields->warehouse, fields->exportedProperties, status + ).locale(locale); // Do this after fields->exportedProperties are set up setupFastFormat(); @@ -1620,13 +1609,13 @@ void DecimalFormat::touch(UErrorCode& status) { delete fields->atomicCurrencyParser.exchange(nullptr); // In order for the getters to work, we need to populate some fields in NumberFormat. - NumberFormat::setCurrency(fields->exportedProperties->currency.get(status).getISOCurrency(), status); - NumberFormat::setMaximumIntegerDigits(fields->exportedProperties->maximumIntegerDigits); - NumberFormat::setMinimumIntegerDigits(fields->exportedProperties->minimumIntegerDigits); - NumberFormat::setMaximumFractionDigits(fields->exportedProperties->maximumFractionDigits); - NumberFormat::setMinimumFractionDigits(fields->exportedProperties->minimumFractionDigits); + NumberFormat::setCurrency(fields->exportedProperties.currency.get(status).getISOCurrency(), status); + NumberFormat::setMaximumIntegerDigits(fields->exportedProperties.maximumIntegerDigits); + NumberFormat::setMinimumIntegerDigits(fields->exportedProperties.minimumIntegerDigits); + NumberFormat::setMaximumFractionDigits(fields->exportedProperties.maximumFractionDigits); + NumberFormat::setMinimumFractionDigits(fields->exportedProperties.minimumFractionDigits); // fImpl->properties, not fields->exportedProperties, since this information comes from the pattern: - NumberFormat::setGroupingUsed(fields->properties->groupingUsed); + NumberFormat::setGroupingUsed(fields->properties.groupingUsed); } void DecimalFormat::touchNoError() { @@ -1639,7 +1628,7 @@ void DecimalFormat::setPropertiesFromPattern(const UnicodeString& pattern, int32 if (U_SUCCESS(status)) { // Cast workaround to get around putting the enum in the public header file auto actualIgnoreRounding = static_cast(ignoreRounding); - PatternParser::parseToExistingProperties(pattern, *fields->properties, actualIgnoreRounding, status); + PatternParser::parseToExistingProperties(pattern, fields->properties, actualIgnoreRounding, status); } } @@ -1658,7 +1647,7 @@ const numparse::impl::NumberParserImpl* DecimalFormat::getParser(UErrorCode& sta } // Try computing the parser on our own - auto* temp = NumberParserImpl::createParserFromProperties(*fields->properties, *fields->symbols, false, status); + auto* temp = NumberParserImpl::createParserFromProperties(fields->properties, *fields->symbols, false, status); if (U_FAILURE(status)) { return nullptr; } @@ -1691,7 +1680,7 @@ const numparse::impl::NumberParserImpl* DecimalFormat::getCurrencyParser(UErrorC } // Try computing the parser on our own - auto* temp = NumberParserImpl::createParserFromProperties(*fields->properties, *fields->symbols, true, status); + auto* temp = NumberParserImpl::createParserFromProperties(fields->properties, *fields->symbols, true, status); if (temp == nullptr) { status = U_MEMORY_ALLOCATION_ERROR; // although we may still dereference, call sites should be guarded @@ -1739,7 +1728,7 @@ DecimalFormat::fieldPositionIteratorHelper(const number::FormattedNumber& format void DecimalFormat::setupFastFormat() { // Check the majority of properties: - if (!fields->properties->equalsDefaultExceptFastFormat()) { + if (!fields->properties.equalsDefaultExceptFastFormat()) { trace("no fast format: equality\n"); fields->canUseFastFormat = false; return; @@ -1747,12 +1736,12 @@ void DecimalFormat::setupFastFormat() { // Now check the remaining properties. // Nontrivial affixes: - UBool trivialPP = fields->properties->positivePrefixPattern.isEmpty(); - UBool trivialPS = fields->properties->positiveSuffixPattern.isEmpty(); - UBool trivialNP = fields->properties->negativePrefixPattern.isBogus() || ( - fields->properties->negativePrefixPattern.length() == 1 && - fields->properties->negativePrefixPattern.charAt(0) == u'-'); - UBool trivialNS = fields->properties->negativeSuffixPattern.isEmpty(); + UBool trivialPP = fields->properties.positivePrefixPattern.isEmpty(); + UBool trivialPS = fields->properties.positiveSuffixPattern.isEmpty(); + UBool trivialNP = fields->properties.negativePrefixPattern.isBogus() || ( + fields->properties.negativePrefixPattern.length() == 1 && + fields->properties.negativePrefixPattern.charAt(0) == u'-'); + UBool trivialNS = fields->properties.negativeSuffixPattern.isEmpty(); if (!trivialPP || !trivialPS || !trivialNP || !trivialNS) { trace("no fast format: affixes\n"); fields->canUseFastFormat = false; @@ -1760,8 +1749,8 @@ void DecimalFormat::setupFastFormat() { } // Grouping (secondary grouping is forbidden in equalsDefaultExceptFastFormat): - bool groupingUsed = fields->properties->groupingUsed; - int32_t groupingSize = fields->properties->groupingSize; + bool groupingUsed = fields->properties.groupingUsed; + int32_t groupingSize = fields->properties.groupingSize; bool unusualGroupingSize = groupingSize > 0 && groupingSize != 3; const UnicodeString& groupingString = fields->symbols->getConstSymbol(DecimalFormatSymbols::kGroupingSeparatorSymbol); if (groupingUsed && (unusualGroupingSize || groupingString.length() != 1)) { @@ -1771,8 +1760,8 @@ void DecimalFormat::setupFastFormat() { } // Integer length: - int32_t minInt = fields->exportedProperties->minimumIntegerDigits; - int32_t maxInt = fields->exportedProperties->maximumIntegerDigits; + int32_t minInt = fields->exportedProperties.minimumIntegerDigits; + int32_t maxInt = fields->exportedProperties.maximumIntegerDigits; // Fastpath supports up to only 10 digits (length of INT32_MIN) if (minInt > 10) { trace("no fast format: integer\n"); @@ -1781,7 +1770,7 @@ void DecimalFormat::setupFastFormat() { } // Fraction length (no fraction part allowed in fast path): - int32_t minFrac = fields->exportedProperties->minimumFractionDigits; + int32_t minFrac = fields->exportedProperties.minimumFractionDigits; if (minFrac > 0) { trace("no fast format: fraction\n"); fields->canUseFastFormat = false; diff --git a/deps/icu-small/source/i18n/double-conversion-bignum-dtoa.cpp b/deps/icu-small/source/i18n/double-conversion-bignum-dtoa.cpp index 2add399f87c91f..a95910df0421d1 100644 --- a/deps/icu-small/source/i18n/double-conversion-bignum-dtoa.cpp +++ b/deps/icu-small/source/i18n/double-conversion-bignum-dtoa.cpp @@ -49,7 +49,7 @@ U_NAMESPACE_BEGIN namespace double_conversion { static int NormalizedExponent(uint64_t significand, int exponent) { - ASSERT(significand != 0); + DOUBLE_CONVERSION_ASSERT(significand != 0); while ((significand & Double::kHiddenBit) == 0) { significand = significand << 1; exponent = exponent - 1; @@ -90,26 +90,26 @@ static void GenerateShortestDigits(Bignum* numerator, Bignum* denominator, // Generates 'requested_digits' after the decimal point. static void BignumToFixed(int requested_digits, int* decimal_point, Bignum* numerator, Bignum* denominator, - Vector(buffer), int* length); + Vector buffer, int* length); // Generates 'count' digits of numerator/denominator. // Once 'count' digits have been produced rounds the result depending on the // remainder (remainders of exactly .5 round upwards). Might update the // decimal_point when rounding up (for example for 0.9999). static void GenerateCountedDigits(int count, int* decimal_point, Bignum* numerator, Bignum* denominator, - Vector(buffer), int* length); + Vector buffer, int* length); void BignumDtoa(double v, BignumDtoaMode mode, int requested_digits, Vector buffer, int* length, int* decimal_point) { - ASSERT(v > 0); - ASSERT(!Double(v).IsSpecial()); + DOUBLE_CONVERSION_ASSERT(v > 0); + DOUBLE_CONVERSION_ASSERT(!Double(v).IsSpecial()); uint64_t significand; int exponent; bool lower_boundary_is_closer; if (mode == BIGNUM_DTOA_SHORTEST_SINGLE) { float f = static_cast(v); - ASSERT(f == v); + DOUBLE_CONVERSION_ASSERT(f == v); significand = Single(f).Significand(); exponent = Single(f).Exponent(); lower_boundary_is_closer = Single(f).LowerBoundaryIsCloser(); @@ -148,7 +148,7 @@ void BignumDtoa(double v, BignumDtoaMode mode, int requested_digits, // 4e-324. In this case the denominator needs fewer than 324*4 binary digits. // The maximum double is 1.7976931348623157e308 which needs fewer than // 308*4 binary digits. - ASSERT(Bignum::kMaxSignificantBits >= 324*4); + DOUBLE_CONVERSION_ASSERT(Bignum::kMaxSignificantBits >= 324*4); InitialScaledStartValues(significand, exponent, lower_boundary_is_closer, estimated_power, need_boundary_deltas, &numerator, &denominator, @@ -177,7 +177,7 @@ void BignumDtoa(double v, BignumDtoaMode mode, int requested_digits, buffer, length); break; default: - UNREACHABLE(); + DOUBLE_CONVERSION_UNREACHABLE(); } buffer[*length] = '\0'; } @@ -209,7 +209,7 @@ static void GenerateShortestDigits(Bignum* numerator, Bignum* denominator, for (;;) { uint16_t digit; digit = numerator->DivideModuloIntBignum(*denominator); - ASSERT(digit <= 9); // digit is a uint16_t and therefore always positive. + DOUBLE_CONVERSION_ASSERT(digit <= 9); // digit is a uint16_t and therefore always positive. // digit = numerator / denominator (integer division). // numerator = numerator % denominator. buffer[(*length)++] = static_cast(digit + '0'); @@ -255,7 +255,7 @@ static void GenerateShortestDigits(Bignum* numerator, Bignum* denominator, // loop would have stopped earlier. // We still have an assert here in case the preconditions were not // satisfied. - ASSERT(buffer[(*length) - 1] != '9'); + DOUBLE_CONVERSION_ASSERT(buffer[(*length) - 1] != '9'); buffer[(*length) - 1]++; } else { // Halfway case. @@ -266,7 +266,7 @@ static void GenerateShortestDigits(Bignum* numerator, Bignum* denominator, if ((buffer[(*length) - 1] - '0') % 2 == 0) { // Round down => Do nothing. } else { - ASSERT(buffer[(*length) - 1] != '9'); + DOUBLE_CONVERSION_ASSERT(buffer[(*length) - 1] != '9'); buffer[(*length) - 1]++; } } @@ -278,9 +278,9 @@ static void GenerateShortestDigits(Bignum* numerator, Bignum* denominator, // Round up. // Note again that the last digit could not be '9' since this would have // stopped the loop earlier. - // We still have an ASSERT here, in case the preconditions were not + // We still have an DOUBLE_CONVERSION_ASSERT here, in case the preconditions were not // satisfied. - ASSERT(buffer[(*length) -1] != '9'); + DOUBLE_CONVERSION_ASSERT(buffer[(*length) -1] != '9'); buffer[(*length) - 1]++; return; } @@ -297,11 +297,11 @@ static void GenerateShortestDigits(Bignum* numerator, Bignum* denominator, static void GenerateCountedDigits(int count, int* decimal_point, Bignum* numerator, Bignum* denominator, Vector buffer, int* length) { - ASSERT(count >= 0); + DOUBLE_CONVERSION_ASSERT(count >= 0); for (int i = 0; i < count - 1; ++i) { uint16_t digit; digit = numerator->DivideModuloIntBignum(*denominator); - ASSERT(digit <= 9); // digit is a uint16_t and therefore always positive. + DOUBLE_CONVERSION_ASSERT(digit <= 9); // digit is a uint16_t and therefore always positive. // digit = numerator / denominator (integer division). // numerator = numerator % denominator. buffer[i] = static_cast(digit + '0'); @@ -314,7 +314,7 @@ static void GenerateCountedDigits(int count, int* decimal_point, if (Bignum::PlusCompare(*numerator, *numerator, *denominator) >= 0) { digit++; } - ASSERT(digit <= 10); + DOUBLE_CONVERSION_ASSERT(digit <= 10); buffer[count - 1] = static_cast(digit + '0'); // Correct bad digits (in case we had a sequence of '9's). Propagate the // carry until we hat a non-'9' or til we reach the first digit. @@ -339,7 +339,7 @@ static void GenerateCountedDigits(int count, int* decimal_point, // Input verifies: 1 <= (numerator + delta) / denominator < 10. static void BignumToFixed(int requested_digits, int* decimal_point, Bignum* numerator, Bignum* denominator, - Vector(buffer), int* length) { + Vector buffer, int* length) { // Note that we have to look at more than just the requested_digits, since // a number could be rounded up. Example: v=0.5 with requested_digits=0. // Even though the power of v equals 0 we can't just stop here. @@ -355,7 +355,7 @@ static void BignumToFixed(int requested_digits, int* decimal_point, } else if (-(*decimal_point) == requested_digits) { // We only need to verify if the number rounds down or up. // Ex: 0.04 and 0.06 with requested_digits == 1. - ASSERT(*decimal_point == -requested_digits); + DOUBLE_CONVERSION_ASSERT(*decimal_point == -requested_digits); // Initially the fraction lies in range (1, 10]. Multiply the denominator // by 10 so that we can compare more easily. denominator->Times10(); @@ -434,7 +434,7 @@ static void InitialScaledStartValuesPositiveExponent( Bignum* numerator, Bignum* denominator, Bignum* delta_minus, Bignum* delta_plus) { // A positive exponent implies a positive power. - ASSERT(estimated_power >= 0); + DOUBLE_CONVERSION_ASSERT(estimated_power >= 0); // Since the estimated_power is positive we simply multiply the denominator // by 10^estimated_power. @@ -520,7 +520,7 @@ static void InitialScaledStartValuesNegativeExponentNegativePower( // numerator = v * 10^-estimated_power * 2 * 2^-exponent. // Remember: numerator has been abused as power_ten. So no need to assign it // to itself. - ASSERT(numerator == power_ten); + DOUBLE_CONVERSION_ASSERT(numerator == power_ten); numerator->MultiplyByUInt64(significand); // denominator = 2 * 2^-exponent with exponent < 0. diff --git a/deps/icu-small/source/i18n/double-conversion-bignum.cpp b/deps/icu-small/source/i18n/double-conversion-bignum.cpp index 5356923921c3c1..996d75c9f60a14 100644 --- a/deps/icu-small/source/i18n/double-conversion-bignum.cpp +++ b/deps/icu-small/source/i18n/double-conversion-bignum.cpp @@ -34,6 +34,9 @@ #include "unicode/utypes.h" #if !UCONFIG_NO_FORMATTING +#include +#include + // ICU PATCH: Customize header file paths for ICU. #include "double-conversion-bignum.h" @@ -44,136 +47,129 @@ U_NAMESPACE_BEGIN namespace double_conversion { -Bignum::Bignum() - : bigits_buffer_(), bigits_(bigits_buffer_, kBigitCapacity), used_digits_(0), exponent_(0) { - for (int i = 0; i < kBigitCapacity; ++i) { - bigits_[i] = 0; - } +Bignum::Chunk& Bignum::RawBigit(const int index) { + DOUBLE_CONVERSION_ASSERT(static_cast(index) < kBigitCapacity); + return bigits_buffer_[index]; +} + + +const Bignum::Chunk& Bignum::RawBigit(const int index) const { + DOUBLE_CONVERSION_ASSERT(static_cast(index) < kBigitCapacity); + return bigits_buffer_[index]; } template -static int BitSize(S value) { +static int BitSize(const S value) { (void) value; // Mark variable as used. return 8 * sizeof(value); } // Guaranteed to lie in one Bigit. -void Bignum::AssignUInt16(uint16_t value) { - ASSERT(kBigitSize >= BitSize(value)); +void Bignum::AssignUInt16(const uint16_t value) { + DOUBLE_CONVERSION_ASSERT(kBigitSize >= BitSize(value)); Zero(); - if (value == 0) return; - - EnsureCapacity(1); - bigits_[0] = value; - used_digits_ = 1; + if (value > 0) { + RawBigit(0) = value; + used_bigits_ = 1; + } } void Bignum::AssignUInt64(uint64_t value) { - const int kUInt64Size = 64; - Zero(); - if (value == 0) return; - - int needed_bigits = kUInt64Size / kBigitSize + 1; - EnsureCapacity(needed_bigits); - for (int i = 0; i < needed_bigits; ++i) { - bigits_[i] = value & kBigitMask; - value = value >> kBigitSize; + for(int i = 0; value > 0; ++i) { + RawBigit(i) = value & kBigitMask; + value >>= kBigitSize; + ++used_bigits_; } - used_digits_ = needed_bigits; - Clamp(); } void Bignum::AssignBignum(const Bignum& other) { exponent_ = other.exponent_; - for (int i = 0; i < other.used_digits_; ++i) { - bigits_[i] = other.bigits_[i]; + for (int i = 0; i < other.used_bigits_; ++i) { + RawBigit(i) = other.RawBigit(i); } - // Clear the excess digits (if there were any). - for (int i = other.used_digits_; i < used_digits_; ++i) { - bigits_[i] = 0; - } - used_digits_ = other.used_digits_; + used_bigits_ = other.used_bigits_; } -static uint64_t ReadUInt64(Vector buffer, - int from, - int digits_to_read) { +static uint64_t ReadUInt64(const Vector buffer, + const int from, + const int digits_to_read) { uint64_t result = 0; for (int i = from; i < from + digits_to_read; ++i) { - int digit = buffer[i] - '0'; - ASSERT(0 <= digit && digit <= 9); + const int digit = buffer[i] - '0'; + DOUBLE_CONVERSION_ASSERT(0 <= digit && digit <= 9); result = result * 10 + digit; } return result; } -void Bignum::AssignDecimalString(Vector value) { +void Bignum::AssignDecimalString(const Vector value) { // 2^64 = 18446744073709551616 > 10^19 - const int kMaxUint64DecimalDigits = 19; + static const int kMaxUint64DecimalDigits = 19; Zero(); int length = value.length(); - unsigned int pos = 0; + unsigned pos = 0; // Let's just say that each digit needs 4 bits. while (length >= kMaxUint64DecimalDigits) { - uint64_t digits = ReadUInt64(value, pos, kMaxUint64DecimalDigits); + const uint64_t digits = ReadUInt64(value, pos, kMaxUint64DecimalDigits); pos += kMaxUint64DecimalDigits; length -= kMaxUint64DecimalDigits; MultiplyByPowerOfTen(kMaxUint64DecimalDigits); AddUInt64(digits); } - uint64_t digits = ReadUInt64(value, pos, length); + const uint64_t digits = ReadUInt64(value, pos, length); MultiplyByPowerOfTen(length); AddUInt64(digits); Clamp(); } -static int HexCharValue(char c) { - if ('0' <= c && c <= '9') return c - '0'; - if ('a' <= c && c <= 'f') return 10 + c - 'a'; - ASSERT('A' <= c && c <= 'F'); +static uint64_t HexCharValue(const int c) { + if ('0' <= c && c <= '9') { + return c - '0'; + } + if ('a' <= c && c <= 'f') { + return 10 + c - 'a'; + } + DOUBLE_CONVERSION_ASSERT('A' <= c && c <= 'F'); return 10 + c - 'A'; } +// Unlike AssignDecimalString(), this function is "only" used +// for unit-tests and therefore not performance critical. void Bignum::AssignHexString(Vector value) { Zero(); - int length = value.length(); - - int needed_bigits = length * 4 / kBigitSize + 1; - EnsureCapacity(needed_bigits); - int string_index = length - 1; - for (int i = 0; i < needed_bigits - 1; ++i) { - // These bigits are guaranteed to be "full". - Chunk current_bigit = 0; - for (int j = 0; j < kBigitSize / 4; j++) { - current_bigit += HexCharValue(value[string_index--]) << (j * 4); + // Required capacity could be reduced by ignoring leading zeros. + EnsureCapacity(((value.length() * 4) + kBigitSize - 1) / kBigitSize); + DOUBLE_CONVERSION_ASSERT(sizeof(uint64_t) * 8 >= kBigitSize + 4); // TODO: static_assert + // Accumulates converted hex digits until at least kBigitSize bits. + // Works with non-factor-of-four kBigitSizes. + uint64_t tmp = 0; // Accumulates converted hex digits until at least + for (int cnt = 0; !value.is_empty(); value.pop_back()) { + tmp |= (HexCharValue(value.last()) << cnt); + if ((cnt += 4) >= kBigitSize) { + RawBigit(used_bigits_++) = (tmp & kBigitMask); + cnt -= kBigitSize; + tmp >>= kBigitSize; } - bigits_[i] = current_bigit; - } - used_digits_ = needed_bigits - 1; - - Chunk most_significant_bigit = 0; // Could be = 0; - for (int j = 0; j <= string_index; ++j) { - most_significant_bigit <<= 4; - most_significant_bigit += HexCharValue(value[j]); } - if (most_significant_bigit != 0) { - bigits_[used_digits_] = most_significant_bigit; - used_digits_++; + if (tmp > 0) { + RawBigit(used_bigits_++) = tmp; } Clamp(); } -void Bignum::AddUInt64(uint64_t operand) { - if (operand == 0) return; +void Bignum::AddUInt64(const uint64_t operand) { + if (operand == 0) { + return; + } Bignum other; other.AssignUInt64(operand); AddBignum(other); @@ -181,8 +177,8 @@ void Bignum::AddUInt64(uint64_t operand) { void Bignum::AddBignum(const Bignum& other) { - ASSERT(IsClamped()); - ASSERT(other.IsClamped()); + DOUBLE_CONVERSION_ASSERT(IsClamped()); + DOUBLE_CONVERSION_ASSERT(other.IsClamped()); // If this has a greater exponent than other append zero-bigits to this. // After this call exponent_ <= other.exponent_. @@ -200,48 +196,52 @@ void Bignum::AddBignum(const Bignum& other) { // cccccccccccc 0000 // In both cases we might need a carry bigit. - EnsureCapacity(1 + Max(BigitLength(), other.BigitLength()) - exponent_); + EnsureCapacity(1 + (std::max)(BigitLength(), other.BigitLength()) - exponent_); Chunk carry = 0; int bigit_pos = other.exponent_ - exponent_; - ASSERT(bigit_pos >= 0); - for (int i = 0; i < other.used_digits_; ++i) { - Chunk sum = bigits_[bigit_pos] + other.bigits_[i] + carry; - bigits_[bigit_pos] = sum & kBigitMask; + DOUBLE_CONVERSION_ASSERT(bigit_pos >= 0); + for (int i = used_bigits_; i < bigit_pos; ++i) { + RawBigit(i) = 0; + } + for (int i = 0; i < other.used_bigits_; ++i) { + const Chunk my = (bigit_pos < used_bigits_) ? RawBigit(bigit_pos) : 0; + const Chunk sum = my + other.RawBigit(i) + carry; + RawBigit(bigit_pos) = sum & kBigitMask; carry = sum >> kBigitSize; - bigit_pos++; + ++bigit_pos; } - while (carry != 0) { - Chunk sum = bigits_[bigit_pos] + carry; - bigits_[bigit_pos] = sum & kBigitMask; + const Chunk my = (bigit_pos < used_bigits_) ? RawBigit(bigit_pos) : 0; + const Chunk sum = my + carry; + RawBigit(bigit_pos) = sum & kBigitMask; carry = sum >> kBigitSize; - bigit_pos++; + ++bigit_pos; } - used_digits_ = Max(bigit_pos, used_digits_); - ASSERT(IsClamped()); + used_bigits_ = (std::max)(bigit_pos, static_cast(used_bigits_)); + DOUBLE_CONVERSION_ASSERT(IsClamped()); } void Bignum::SubtractBignum(const Bignum& other) { - ASSERT(IsClamped()); - ASSERT(other.IsClamped()); + DOUBLE_CONVERSION_ASSERT(IsClamped()); + DOUBLE_CONVERSION_ASSERT(other.IsClamped()); // We require this to be bigger than other. - ASSERT(LessEqual(other, *this)); + DOUBLE_CONVERSION_ASSERT(LessEqual(other, *this)); Align(other); - int offset = other.exponent_ - exponent_; + const int offset = other.exponent_ - exponent_; Chunk borrow = 0; int i; - for (i = 0; i < other.used_digits_; ++i) { - ASSERT((borrow == 0) || (borrow == 1)); - Chunk difference = bigits_[i + offset] - other.bigits_[i] - borrow; - bigits_[i + offset] = difference & kBigitMask; + for (i = 0; i < other.used_bigits_; ++i) { + DOUBLE_CONVERSION_ASSERT((borrow == 0) || (borrow == 1)); + const Chunk difference = RawBigit(i + offset) - other.RawBigit(i) - borrow; + RawBigit(i + offset) = difference & kBigitMask; borrow = difference >> (kChunkSize - 1); } while (borrow != 0) { - Chunk difference = bigits_[i + offset] - borrow; - bigits_[i + offset] = difference & kBigitMask; + const Chunk difference = RawBigit(i + offset) - borrow; + RawBigit(i + offset) = difference & kBigitMask; borrow = difference >> (kChunkSize - 1); ++i; } @@ -249,91 +249,105 @@ void Bignum::SubtractBignum(const Bignum& other) { } -void Bignum::ShiftLeft(int shift_amount) { - if (used_digits_ == 0) return; - exponent_ += shift_amount / kBigitSize; - int local_shift = shift_amount % kBigitSize; - EnsureCapacity(used_digits_ + 1); +void Bignum::ShiftLeft(const int shift_amount) { + if (used_bigits_ == 0) { + return; + } + exponent_ += (shift_amount / kBigitSize); + const int local_shift = shift_amount % kBigitSize; + EnsureCapacity(used_bigits_ + 1); BigitsShiftLeft(local_shift); } -void Bignum::MultiplyByUInt32(uint32_t factor) { - if (factor == 1) return; +void Bignum::MultiplyByUInt32(const uint32_t factor) { + if (factor == 1) { + return; + } if (factor == 0) { Zero(); return; } - if (used_digits_ == 0) return; - + if (used_bigits_ == 0) { + return; + } // The product of a bigit with the factor is of size kBigitSize + 32. // Assert that this number + 1 (for the carry) fits into double chunk. - ASSERT(kDoubleChunkSize >= kBigitSize + 32 + 1); + DOUBLE_CONVERSION_ASSERT(kDoubleChunkSize >= kBigitSize + 32 + 1); DoubleChunk carry = 0; - for (int i = 0; i < used_digits_; ++i) { - DoubleChunk product = static_cast(factor) * bigits_[i] + carry; - bigits_[i] = static_cast(product & kBigitMask); + for (int i = 0; i < used_bigits_; ++i) { + const DoubleChunk product = static_cast(factor) * RawBigit(i) + carry; + RawBigit(i) = static_cast(product & kBigitMask); carry = (product >> kBigitSize); } while (carry != 0) { - EnsureCapacity(used_digits_ + 1); - bigits_[used_digits_] = carry & kBigitMask; - used_digits_++; + EnsureCapacity(used_bigits_ + 1); + RawBigit(used_bigits_) = carry & kBigitMask; + used_bigits_++; carry >>= kBigitSize; } } -void Bignum::MultiplyByUInt64(uint64_t factor) { - if (factor == 1) return; +void Bignum::MultiplyByUInt64(const uint64_t factor) { + if (factor == 1) { + return; + } if (factor == 0) { Zero(); return; } - ASSERT(kBigitSize < 32); + if (used_bigits_ == 0) { + return; + } + DOUBLE_CONVERSION_ASSERT(kBigitSize < 32); uint64_t carry = 0; - uint64_t low = factor & 0xFFFFFFFF; - uint64_t high = factor >> 32; - for (int i = 0; i < used_digits_; ++i) { - uint64_t product_low = low * bigits_[i]; - uint64_t product_high = high * bigits_[i]; - uint64_t tmp = (carry & kBigitMask) + product_low; - bigits_[i] = tmp & kBigitMask; + const uint64_t low = factor & 0xFFFFFFFF; + const uint64_t high = factor >> 32; + for (int i = 0; i < used_bigits_; ++i) { + const uint64_t product_low = low * RawBigit(i); + const uint64_t product_high = high * RawBigit(i); + const uint64_t tmp = (carry & kBigitMask) + product_low; + RawBigit(i) = tmp & kBigitMask; carry = (carry >> kBigitSize) + (tmp >> kBigitSize) + (product_high << (32 - kBigitSize)); } while (carry != 0) { - EnsureCapacity(used_digits_ + 1); - bigits_[used_digits_] = carry & kBigitMask; - used_digits_++; + EnsureCapacity(used_bigits_ + 1); + RawBigit(used_bigits_) = carry & kBigitMask; + used_bigits_++; carry >>= kBigitSize; } } -void Bignum::MultiplyByPowerOfTen(int exponent) { - const uint64_t kFive27 = UINT64_2PART_C(0x6765c793, fa10079d); - const uint16_t kFive1 = 5; - const uint16_t kFive2 = kFive1 * 5; - const uint16_t kFive3 = kFive2 * 5; - const uint16_t kFive4 = kFive3 * 5; - const uint16_t kFive5 = kFive4 * 5; - const uint16_t kFive6 = kFive5 * 5; - const uint32_t kFive7 = kFive6 * 5; - const uint32_t kFive8 = kFive7 * 5; - const uint32_t kFive9 = kFive8 * 5; - const uint32_t kFive10 = kFive9 * 5; - const uint32_t kFive11 = kFive10 * 5; - const uint32_t kFive12 = kFive11 * 5; - const uint32_t kFive13 = kFive12 * 5; - const uint32_t kFive1_to_12[] = +void Bignum::MultiplyByPowerOfTen(const int exponent) { + static const uint64_t kFive27 = DOUBLE_CONVERSION_UINT64_2PART_C(0x6765c793, fa10079d); + static const uint16_t kFive1 = 5; + static const uint16_t kFive2 = kFive1 * 5; + static const uint16_t kFive3 = kFive2 * 5; + static const uint16_t kFive4 = kFive3 * 5; + static const uint16_t kFive5 = kFive4 * 5; + static const uint16_t kFive6 = kFive5 * 5; + static const uint32_t kFive7 = kFive6 * 5; + static const uint32_t kFive8 = kFive7 * 5; + static const uint32_t kFive9 = kFive8 * 5; + static const uint32_t kFive10 = kFive9 * 5; + static const uint32_t kFive11 = kFive10 * 5; + static const uint32_t kFive12 = kFive11 * 5; + static const uint32_t kFive13 = kFive12 * 5; + static const uint32_t kFive1_to_12[] = { kFive1, kFive2, kFive3, kFive4, kFive5, kFive6, kFive7, kFive8, kFive9, kFive10, kFive11, kFive12 }; - ASSERT(exponent >= 0); - if (exponent == 0) return; - if (used_digits_ == 0) return; + DOUBLE_CONVERSION_ASSERT(exponent >= 0); + if (exponent == 0) { + return; + } + if (used_bigits_ == 0) { + return; + } // We shift by exponent at the end just before returning. int remaining_exponent = exponent; while (remaining_exponent >= 27) { @@ -352,8 +366,8 @@ void Bignum::MultiplyByPowerOfTen(int exponent) { void Bignum::Square() { - ASSERT(IsClamped()); - int product_length = 2 * used_digits_; + DOUBLE_CONVERSION_ASSERT(IsClamped()); + const int product_length = 2 * used_bigits_; EnsureCapacity(product_length); // Comba multiplication: compute each column separately. @@ -368,64 +382,64 @@ void Bignum::Square() { // // Assert that the additional number of bits in a DoubleChunk are enough to // sum up used_digits of Bigit*Bigit. - if ((1 << (2 * (kChunkSize - kBigitSize))) <= used_digits_) { - UNIMPLEMENTED(); + if ((1 << (2 * (kChunkSize - kBigitSize))) <= used_bigits_) { + DOUBLE_CONVERSION_UNIMPLEMENTED(); } DoubleChunk accumulator = 0; // First shift the digits so we don't overwrite them. - int copy_offset = used_digits_; - for (int i = 0; i < used_digits_; ++i) { - bigits_[copy_offset + i] = bigits_[i]; + const int copy_offset = used_bigits_; + for (int i = 0; i < used_bigits_; ++i) { + RawBigit(copy_offset + i) = RawBigit(i); } // We have two loops to avoid some 'if's in the loop. - for (int i = 0; i < used_digits_; ++i) { + for (int i = 0; i < used_bigits_; ++i) { // Process temporary digit i with power i. // The sum of the two indices must be equal to i. int bigit_index1 = i; int bigit_index2 = 0; // Sum all of the sub-products. while (bigit_index1 >= 0) { - Chunk chunk1 = bigits_[copy_offset + bigit_index1]; - Chunk chunk2 = bigits_[copy_offset + bigit_index2]; + const Chunk chunk1 = RawBigit(copy_offset + bigit_index1); + const Chunk chunk2 = RawBigit(copy_offset + bigit_index2); accumulator += static_cast(chunk1) * chunk2; bigit_index1--; bigit_index2++; } - bigits_[i] = static_cast(accumulator) & kBigitMask; + RawBigit(i) = static_cast(accumulator) & kBigitMask; accumulator >>= kBigitSize; } - for (int i = used_digits_; i < product_length; ++i) { - int bigit_index1 = used_digits_ - 1; + for (int i = used_bigits_; i < product_length; ++i) { + int bigit_index1 = used_bigits_ - 1; int bigit_index2 = i - bigit_index1; // Invariant: sum of both indices is again equal to i. // Inner loop runs 0 times on last iteration, emptying accumulator. - while (bigit_index2 < used_digits_) { - Chunk chunk1 = bigits_[copy_offset + bigit_index1]; - Chunk chunk2 = bigits_[copy_offset + bigit_index2]; + while (bigit_index2 < used_bigits_) { + const Chunk chunk1 = RawBigit(copy_offset + bigit_index1); + const Chunk chunk2 = RawBigit(copy_offset + bigit_index2); accumulator += static_cast(chunk1) * chunk2; bigit_index1--; bigit_index2++; } - // The overwritten bigits_[i] will never be read in further loop iterations, + // The overwritten RawBigit(i) will never be read in further loop iterations, // because bigit_index1 and bigit_index2 are always greater - // than i - used_digits_. - bigits_[i] = static_cast(accumulator) & kBigitMask; + // than i - used_bigits_. + RawBigit(i) = static_cast(accumulator) & kBigitMask; accumulator >>= kBigitSize; } // Since the result was guaranteed to lie inside the number the // accumulator must be 0 now. - ASSERT(accumulator == 0); + DOUBLE_CONVERSION_ASSERT(accumulator == 0); // Don't forget to update the used_digits and the exponent. - used_digits_ = product_length; + used_bigits_ = product_length; exponent_ *= 2; Clamp(); } -void Bignum::AssignPowerUInt16(uint16_t base, int power_exponent) { - ASSERT(base != 0); - ASSERT(power_exponent >= 0); +void Bignum::AssignPowerUInt16(uint16_t base, const int power_exponent) { + DOUBLE_CONVERSION_ASSERT(base != 0); + DOUBLE_CONVERSION_ASSERT(power_exponent >= 0); if (power_exponent == 0) { AssignUInt16(1); return; @@ -445,7 +459,7 @@ void Bignum::AssignPowerUInt16(uint16_t base, int power_exponent) { tmp_base >>= 1; bit_size++; } - int final_size = bit_size * power_exponent; + const int final_size = bit_size * power_exponent; // 1 extra bigit for the shifting, and one for rounded final_size. EnsureCapacity(final_size / kBigitSize + 2); @@ -466,10 +480,10 @@ void Bignum::AssignPowerUInt16(uint16_t base, int power_exponent) { // Verify that there is enough space in this_value to perform the // multiplication. The first bit_size bits must be 0. if ((power_exponent & mask) != 0) { - ASSERT(bit_size > 0); - uint64_t base_bits_mask = - ~((static_cast(1) << (64 - bit_size)) - 1); - bool high_bits_zero = (this_value & base_bits_mask) == 0; + DOUBLE_CONVERSION_ASSERT(bit_size > 0); + const uint64_t base_bits_mask = + ~((static_cast(1) << (64 - bit_size)) - 1); + const bool high_bits_zero = (this_value & base_bits_mask) == 0; if (high_bits_zero) { this_value *= base; } else { @@ -499,9 +513,9 @@ void Bignum::AssignPowerUInt16(uint16_t base, int power_exponent) { // Precondition: this/other < 16bit. uint16_t Bignum::DivideModuloIntBignum(const Bignum& other) { - ASSERT(IsClamped()); - ASSERT(other.IsClamped()); - ASSERT(other.used_digits_ > 0); + DOUBLE_CONVERSION_ASSERT(IsClamped()); + DOUBLE_CONVERSION_ASSERT(other.IsClamped()); + DOUBLE_CONVERSION_ASSERT(other.used_bigits_ > 0); // Easy case: if we have less digits than the divisor than the result is 0. // Note: this handles the case where this == 0, too. @@ -519,34 +533,34 @@ uint16_t Bignum::DivideModuloIntBignum(const Bignum& other) { // This naive approach is extremely inefficient if `this` divided by other // is big. This function is implemented for doubleToString where // the result should be small (less than 10). - ASSERT(other.bigits_[other.used_digits_ - 1] >= ((1 << kBigitSize) / 16)); - ASSERT(bigits_[used_digits_ - 1] < 0x10000); + DOUBLE_CONVERSION_ASSERT(other.RawBigit(other.used_bigits_ - 1) >= ((1 << kBigitSize) / 16)); + DOUBLE_CONVERSION_ASSERT(RawBigit(used_bigits_ - 1) < 0x10000); // Remove the multiples of the first digit. // Example this = 23 and other equals 9. -> Remove 2 multiples. - result += static_cast(bigits_[used_digits_ - 1]); - SubtractTimes(other, bigits_[used_digits_ - 1]); + result += static_cast(RawBigit(used_bigits_ - 1)); + SubtractTimes(other, RawBigit(used_bigits_ - 1)); } - ASSERT(BigitLength() == other.BigitLength()); + DOUBLE_CONVERSION_ASSERT(BigitLength() == other.BigitLength()); // Both bignums are at the same length now. // Since other has more than 0 digits we know that the access to - // bigits_[used_digits_ - 1] is safe. - Chunk this_bigit = bigits_[used_digits_ - 1]; - Chunk other_bigit = other.bigits_[other.used_digits_ - 1]; + // RawBigit(used_bigits_ - 1) is safe. + const Chunk this_bigit = RawBigit(used_bigits_ - 1); + const Chunk other_bigit = other.RawBigit(other.used_bigits_ - 1); - if (other.used_digits_ == 1) { + if (other.used_bigits_ == 1) { // Shortcut for easy (and common) case. int quotient = this_bigit / other_bigit; - bigits_[used_digits_ - 1] = this_bigit - other_bigit * quotient; - ASSERT(quotient < 0x10000); + RawBigit(used_bigits_ - 1) = this_bigit - other_bigit * quotient; + DOUBLE_CONVERSION_ASSERT(quotient < 0x10000); result += static_cast(quotient); Clamp(); return result; } - int division_estimate = this_bigit / (other_bigit + 1); - ASSERT(division_estimate < 0x10000); + const int division_estimate = this_bigit / (other_bigit + 1); + DOUBLE_CONVERSION_ASSERT(division_estimate < 0x10000); result += static_cast(division_estimate); SubtractTimes(other, division_estimate); @@ -566,7 +580,7 @@ uint16_t Bignum::DivideModuloIntBignum(const Bignum& other) { template static int SizeInHexChars(S number) { - ASSERT(number > 0); + DOUBLE_CONVERSION_ASSERT(number > 0); int result = 0; while (number != 0) { number >>= 4; @@ -576,29 +590,35 @@ static int SizeInHexChars(S number) { } -static char HexCharOfValue(int value) { - ASSERT(0 <= value && value <= 16); - if (value < 10) return static_cast(value + '0'); +static char HexCharOfValue(const int value) { + DOUBLE_CONVERSION_ASSERT(0 <= value && value <= 16); + if (value < 10) { + return static_cast(value + '0'); + } return static_cast(value - 10 + 'A'); } -bool Bignum::ToHexString(char* buffer, int buffer_size) const { - ASSERT(IsClamped()); +bool Bignum::ToHexString(char* buffer, const int buffer_size) const { + DOUBLE_CONVERSION_ASSERT(IsClamped()); // Each bigit must be printable as separate hex-character. - ASSERT(kBigitSize % 4 == 0); - const int kHexCharsPerBigit = kBigitSize / 4; + DOUBLE_CONVERSION_ASSERT(kBigitSize % 4 == 0); + static const int kHexCharsPerBigit = kBigitSize / 4; - if (used_digits_ == 0) { - if (buffer_size < 2) return false; + if (used_bigits_ == 0) { + if (buffer_size < 2) { + return false; + } buffer[0] = '0'; buffer[1] = '\0'; return true; } // We add 1 for the terminating '\0' character. - int needed_chars = (BigitLength() - 1) * kHexCharsPerBigit + - SizeInHexChars(bigits_[used_digits_ - 1]) + 1; - if (needed_chars > buffer_size) return false; + const int needed_chars = (BigitLength() - 1) * kHexCharsPerBigit + + SizeInHexChars(RawBigit(used_bigits_ - 1)) + 1; + if (needed_chars > buffer_size) { + return false; + } int string_index = needed_chars - 1; buffer[string_index--] = '\0'; for (int i = 0; i < exponent_; ++i) { @@ -606,15 +626,15 @@ bool Bignum::ToHexString(char* buffer, int buffer_size) const { buffer[string_index--] = '0'; } } - for (int i = 0; i < used_digits_ - 1; ++i) { - Chunk current_bigit = bigits_[i]; + for (int i = 0; i < used_bigits_ - 1; ++i) { + Chunk current_bigit = RawBigit(i); for (int j = 0; j < kHexCharsPerBigit; ++j) { buffer[string_index--] = HexCharOfValue(current_bigit & 0xF); current_bigit >>= 4; } } // And finally the last bigit. - Chunk most_significant_bigit = bigits_[used_digits_ - 1]; + Chunk most_significant_bigit = RawBigit(used_bigits_ - 1); while (most_significant_bigit != 0) { buffer[string_index--] = HexCharOfValue(most_significant_bigit & 0xF); most_significant_bigit >>= 4; @@ -623,25 +643,37 @@ bool Bignum::ToHexString(char* buffer, int buffer_size) const { } -Bignum::Chunk Bignum::BigitAt(int index) const { - if (index >= BigitLength()) return 0; - if (index < exponent_) return 0; - return bigits_[index - exponent_]; +Bignum::Chunk Bignum::BigitOrZero(const int index) const { + if (index >= BigitLength()) { + return 0; + } + if (index < exponent_) { + return 0; + } + return RawBigit(index - exponent_); } int Bignum::Compare(const Bignum& a, const Bignum& b) { - ASSERT(a.IsClamped()); - ASSERT(b.IsClamped()); - int bigit_length_a = a.BigitLength(); - int bigit_length_b = b.BigitLength(); - if (bigit_length_a < bigit_length_b) return -1; - if (bigit_length_a > bigit_length_b) return +1; - for (int i = bigit_length_a - 1; i >= Min(a.exponent_, b.exponent_); --i) { - Chunk bigit_a = a.BigitAt(i); - Chunk bigit_b = b.BigitAt(i); - if (bigit_a < bigit_b) return -1; - if (bigit_a > bigit_b) return +1; + DOUBLE_CONVERSION_ASSERT(a.IsClamped()); + DOUBLE_CONVERSION_ASSERT(b.IsClamped()); + const int bigit_length_a = a.BigitLength(); + const int bigit_length_b = b.BigitLength(); + if (bigit_length_a < bigit_length_b) { + return -1; + } + if (bigit_length_a > bigit_length_b) { + return +1; + } + for (int i = bigit_length_a - 1; i >= (std::min)(a.exponent_, b.exponent_); --i) { + const Chunk bigit_a = a.BigitOrZero(i); + const Chunk bigit_b = b.BigitOrZero(i); + if (bigit_a < bigit_b) { + return -1; + } + if (bigit_a > bigit_b) { + return +1; + } // Otherwise they are equal up to this digit. Try the next digit. } return 0; @@ -649,14 +681,18 @@ int Bignum::Compare(const Bignum& a, const Bignum& b) { int Bignum::PlusCompare(const Bignum& a, const Bignum& b, const Bignum& c) { - ASSERT(a.IsClamped()); - ASSERT(b.IsClamped()); - ASSERT(c.IsClamped()); + DOUBLE_CONVERSION_ASSERT(a.IsClamped()); + DOUBLE_CONVERSION_ASSERT(b.IsClamped()); + DOUBLE_CONVERSION_ASSERT(c.IsClamped()); if (a.BigitLength() < b.BigitLength()) { return PlusCompare(b, a, c); } - if (a.BigitLength() + 1 < c.BigitLength()) return -1; - if (a.BigitLength() > c.BigitLength()) return +1; + if (a.BigitLength() + 1 < c.BigitLength()) { + return -1; + } + if (a.BigitLength() > c.BigitLength()) { + return +1; + } // The exponent encodes 0-bigits. So if there are more 0-digits in 'a' than // 'b' has digits, then the bigit-length of 'a'+'b' must be equal to the one // of 'a'. @@ -666,92 +702,83 @@ int Bignum::PlusCompare(const Bignum& a, const Bignum& b, const Bignum& c) { Chunk borrow = 0; // Starting at min_exponent all digits are == 0. So no need to compare them. - int min_exponent = Min(Min(a.exponent_, b.exponent_), c.exponent_); + const int min_exponent = (std::min)((std::min)(a.exponent_, b.exponent_), c.exponent_); for (int i = c.BigitLength() - 1; i >= min_exponent; --i) { - Chunk chunk_a = a.BigitAt(i); - Chunk chunk_b = b.BigitAt(i); - Chunk chunk_c = c.BigitAt(i); - Chunk sum = chunk_a + chunk_b; + const Chunk chunk_a = a.BigitOrZero(i); + const Chunk chunk_b = b.BigitOrZero(i); + const Chunk chunk_c = c.BigitOrZero(i); + const Chunk sum = chunk_a + chunk_b; if (sum > chunk_c + borrow) { return +1; } else { borrow = chunk_c + borrow - sum; - if (borrow > 1) return -1; + if (borrow > 1) { + return -1; + } borrow <<= kBigitSize; } } - if (borrow == 0) return 0; + if (borrow == 0) { + return 0; + } return -1; } void Bignum::Clamp() { - while (used_digits_ > 0 && bigits_[used_digits_ - 1] == 0) { - used_digits_--; + while (used_bigits_ > 0 && RawBigit(used_bigits_ - 1) == 0) { + used_bigits_--; } - if (used_digits_ == 0) { + if (used_bigits_ == 0) { // Zero. exponent_ = 0; } } -bool Bignum::IsClamped() const { - return used_digits_ == 0 || bigits_[used_digits_ - 1] != 0; -} - - -void Bignum::Zero() { - for (int i = 0; i < used_digits_; ++i) { - bigits_[i] = 0; - } - used_digits_ = 0; - exponent_ = 0; -} - - void Bignum::Align(const Bignum& other) { if (exponent_ > other.exponent_) { - // If "X" represents a "hidden" digit (by the exponent) then we are in the + // If "X" represents a "hidden" bigit (by the exponent) then we are in the // following case (a == this, b == other): // a: aaaaaaXXXX or a: aaaaaXXX // b: bbbbbbX b: bbbbbbbbXX // We replace some of the hidden digits (X) of a with 0 digits. // a: aaaaaa000X or a: aaaaa0XX - int zero_digits = exponent_ - other.exponent_; - EnsureCapacity(used_digits_ + zero_digits); - for (int i = used_digits_ - 1; i >= 0; --i) { - bigits_[i + zero_digits] = bigits_[i]; + const int zero_bigits = exponent_ - other.exponent_; + EnsureCapacity(used_bigits_ + zero_bigits); + for (int i = used_bigits_ - 1; i >= 0; --i) { + RawBigit(i + zero_bigits) = RawBigit(i); } - for (int i = 0; i < zero_digits; ++i) { - bigits_[i] = 0; + for (int i = 0; i < zero_bigits; ++i) { + RawBigit(i) = 0; } - used_digits_ += zero_digits; - exponent_ -= zero_digits; - ASSERT(used_digits_ >= 0); - ASSERT(exponent_ >= 0); + used_bigits_ += zero_bigits; + exponent_ -= zero_bigits; + + DOUBLE_CONVERSION_ASSERT(used_bigits_ >= 0); + DOUBLE_CONVERSION_ASSERT(exponent_ >= 0); } } -void Bignum::BigitsShiftLeft(int shift_amount) { - ASSERT(shift_amount < kBigitSize); - ASSERT(shift_amount >= 0); +void Bignum::BigitsShiftLeft(const int shift_amount) { + DOUBLE_CONVERSION_ASSERT(shift_amount < kBigitSize); + DOUBLE_CONVERSION_ASSERT(shift_amount >= 0); Chunk carry = 0; - for (int i = 0; i < used_digits_; ++i) { - Chunk new_carry = bigits_[i] >> (kBigitSize - shift_amount); - bigits_[i] = ((bigits_[i] << shift_amount) + carry) & kBigitMask; + for (int i = 0; i < used_bigits_; ++i) { + const Chunk new_carry = RawBigit(i) >> (kBigitSize - shift_amount); + RawBigit(i) = ((RawBigit(i) << shift_amount) + carry) & kBigitMask; carry = new_carry; } if (carry != 0) { - bigits_[used_digits_] = carry; - used_digits_++; + RawBigit(used_bigits_) = carry; + used_bigits_++; } } -void Bignum::SubtractTimes(const Bignum& other, int factor) { - ASSERT(exponent_ <= other.exponent_); +void Bignum::SubtractTimes(const Bignum& other, const int factor) { + DOUBLE_CONVERSION_ASSERT(exponent_ <= other.exponent_); if (factor < 3) { for (int i = 0; i < factor; ++i) { SubtractBignum(other); @@ -759,19 +786,21 @@ void Bignum::SubtractTimes(const Bignum& other, int factor) { return; } Chunk borrow = 0; - int exponent_diff = other.exponent_ - exponent_; - for (int i = 0; i < other.used_digits_; ++i) { - DoubleChunk product = static_cast(factor) * other.bigits_[i]; - DoubleChunk remove = borrow + product; - Chunk difference = bigits_[i + exponent_diff] - (remove & kBigitMask); - bigits_[i + exponent_diff] = difference & kBigitMask; + const int exponent_diff = other.exponent_ - exponent_; + for (int i = 0; i < other.used_bigits_; ++i) { + const DoubleChunk product = static_cast(factor) * other.RawBigit(i); + const DoubleChunk remove = borrow + product; + const Chunk difference = RawBigit(i + exponent_diff) - (remove & kBigitMask); + RawBigit(i + exponent_diff) = difference & kBigitMask; borrow = static_cast((difference >> (kChunkSize - 1)) + (remove >> kBigitSize)); } - for (int i = other.used_digits_ + exponent_diff; i < used_digits_; ++i) { - if (borrow == 0) return; - Chunk difference = bigits_[i] - borrow; - bigits_[i] = difference & kBigitMask; + for (int i = other.used_bigits_ + exponent_diff; i < used_bigits_; ++i) { + if (borrow == 0) { + return; + } + const Chunk difference = RawBigit(i) - borrow; + RawBigit(i) = difference & kBigitMask; borrow = difference >> (kChunkSize - 1); } Clamp(); diff --git a/deps/icu-small/source/i18n/double-conversion-bignum.h b/deps/icu-small/source/i18n/double-conversion-bignum.h index d39a3dee010d8b..bae900a15a7420 100644 --- a/deps/icu-small/source/i18n/double-conversion-bignum.h +++ b/deps/icu-small/source/i18n/double-conversion-bignum.h @@ -53,26 +53,27 @@ class Bignum { // exponent. static const int kMaxSignificantBits = 3584; - Bignum(); - void AssignUInt16(uint16_t value); + Bignum() : used_bigits_(0), exponent_(0) {} + + void AssignUInt16(const uint16_t value); void AssignUInt64(uint64_t value); void AssignBignum(const Bignum& other); - void AssignDecimalString(Vector value); - void AssignHexString(Vector value); + void AssignDecimalString(const Vector value); + void AssignHexString(const Vector value); - void AssignPowerUInt16(uint16_t base, int exponent); + void AssignPowerUInt16(uint16_t base, const int exponent); - void AddUInt64(uint64_t operand); + void AddUInt64(const uint64_t operand); void AddBignum(const Bignum& other); // Precondition: this >= other. void SubtractBignum(const Bignum& other); void Square(); - void ShiftLeft(int shift_amount); - void MultiplyByUInt32(uint32_t factor); - void MultiplyByUInt64(uint64_t factor); - void MultiplyByPowerOfTen(int exponent); + void ShiftLeft(const int shift_amount); + void MultiplyByUInt32(const uint32_t factor); + void MultiplyByUInt64(const uint64_t factor); + void MultiplyByPowerOfTen(const int exponent); void Times10() { return MultiplyByUInt32(10); } // Pseudocode: // int result = this / other; @@ -80,7 +81,7 @@ class Bignum { // In the worst case this function is in O(this/other). uint16_t DivideModuloIntBignum(const Bignum& other); - bool ToHexString(char* buffer, int buffer_size) const; + bool ToHexString(char* buffer, const int buffer_size) const; // Returns // -1 if a < b, @@ -124,33 +125,40 @@ class Bignum { // grow. There are no checks if the stack-allocated space is sufficient. static const int kBigitCapacity = kMaxSignificantBits / kBigitSize; - void EnsureCapacity(int size) { + static void EnsureCapacity(const int size) { if (size > kBigitCapacity) { - UNREACHABLE(); + DOUBLE_CONVERSION_UNREACHABLE(); } } void Align(const Bignum& other); void Clamp(); - bool IsClamped() const; - void Zero(); + bool IsClamped() const { + return used_bigits_ == 0 || RawBigit(used_bigits_ - 1) != 0; + } + void Zero() { + used_bigits_ = 0; + exponent_ = 0; + } // Requires this to have enough capacity (no tests done). - // Updates used_digits_ if necessary. + // Updates used_bigits_ if necessary. // shift_amount must be < kBigitSize. - void BigitsShiftLeft(int shift_amount); - // BigitLength includes the "hidden" digits encoded in the exponent. - int BigitLength() const { return used_digits_ + exponent_; } - Chunk BigitAt(int index) const; - void SubtractTimes(const Bignum& other, int factor); - + void BigitsShiftLeft(const int shift_amount); + // BigitLength includes the "hidden" bigits encoded in the exponent. + int BigitLength() const { return used_bigits_ + exponent_; } + Chunk& RawBigit(const int index); + const Chunk& RawBigit(const int index) const; + Chunk BigitOrZero(const int index) const; + void SubtractTimes(const Bignum& other, const int factor); + + // The Bignum's value is value(bigits_buffer_) * 2^(exponent_ * kBigitSize), + // where the value of the buffer consists of the lower kBigitSize bits of + // the first used_bigits_ Chunks in bigits_buffer_, first chunk has lowest + // significant bits. + int16_t used_bigits_; + int16_t exponent_; Chunk bigits_buffer_[kBigitCapacity]; - // A vector backed by bigits_buffer_. This way accesses to the array are - // checked for out-of-bounds errors. - Vector bigits_; - int used_digits_; - // The Bignum's value equals value(bigits_) * 2^(exponent_ * kBigitSize). - int exponent_; - - DC_DISALLOW_COPY_AND_ASSIGN(Bignum); + + DOUBLE_CONVERSION_DISALLOW_COPY_AND_ASSIGN(Bignum); }; } // namespace double_conversion diff --git a/deps/icu-small/source/i18n/double-conversion-cached-powers.cpp b/deps/icu-small/source/i18n/double-conversion-cached-powers.cpp index e1b66d2c65c82e..3bc35c8aaf81dc 100644 --- a/deps/icu-small/source/i18n/double-conversion-cached-powers.cpp +++ b/deps/icu-small/source/i18n/double-conversion-cached-powers.cpp @@ -49,6 +49,8 @@ U_NAMESPACE_BEGIN namespace double_conversion { +namespace PowersOfTenCache { + struct CachedPower { uint64_t significand; int16_t binary_exponent; @@ -56,103 +58,99 @@ struct CachedPower { }; static const CachedPower kCachedPowers[] = { - {UINT64_2PART_C(0xfa8fd5a0, 081c0288), -1220, -348}, - {UINT64_2PART_C(0xbaaee17f, a23ebf76), -1193, -340}, - {UINT64_2PART_C(0x8b16fb20, 3055ac76), -1166, -332}, - {UINT64_2PART_C(0xcf42894a, 5dce35ea), -1140, -324}, - {UINT64_2PART_C(0x9a6bb0aa, 55653b2d), -1113, -316}, - {UINT64_2PART_C(0xe61acf03, 3d1a45df), -1087, -308}, - {UINT64_2PART_C(0xab70fe17, c79ac6ca), -1060, -300}, - {UINT64_2PART_C(0xff77b1fc, bebcdc4f), -1034, -292}, - {UINT64_2PART_C(0xbe5691ef, 416bd60c), -1007, -284}, - {UINT64_2PART_C(0x8dd01fad, 907ffc3c), -980, -276}, - {UINT64_2PART_C(0xd3515c28, 31559a83), -954, -268}, - {UINT64_2PART_C(0x9d71ac8f, ada6c9b5), -927, -260}, - {UINT64_2PART_C(0xea9c2277, 23ee8bcb), -901, -252}, - {UINT64_2PART_C(0xaecc4991, 4078536d), -874, -244}, - {UINT64_2PART_C(0x823c1279, 5db6ce57), -847, -236}, - {UINT64_2PART_C(0xc2109436, 4dfb5637), -821, -228}, - {UINT64_2PART_C(0x9096ea6f, 3848984f), -794, -220}, - {UINT64_2PART_C(0xd77485cb, 25823ac7), -768, -212}, - {UINT64_2PART_C(0xa086cfcd, 97bf97f4), -741, -204}, - {UINT64_2PART_C(0xef340a98, 172aace5), -715, -196}, - {UINT64_2PART_C(0xb23867fb, 2a35b28e), -688, -188}, - {UINT64_2PART_C(0x84c8d4df, d2c63f3b), -661, -180}, - {UINT64_2PART_C(0xc5dd4427, 1ad3cdba), -635, -172}, - {UINT64_2PART_C(0x936b9fce, bb25c996), -608, -164}, - {UINT64_2PART_C(0xdbac6c24, 7d62a584), -582, -156}, - {UINT64_2PART_C(0xa3ab6658, 0d5fdaf6), -555, -148}, - {UINT64_2PART_C(0xf3e2f893, dec3f126), -529, -140}, - {UINT64_2PART_C(0xb5b5ada8, aaff80b8), -502, -132}, - {UINT64_2PART_C(0x87625f05, 6c7c4a8b), -475, -124}, - {UINT64_2PART_C(0xc9bcff60, 34c13053), -449, -116}, - {UINT64_2PART_C(0x964e858c, 91ba2655), -422, -108}, - {UINT64_2PART_C(0xdff97724, 70297ebd), -396, -100}, - {UINT64_2PART_C(0xa6dfbd9f, b8e5b88f), -369, -92}, - {UINT64_2PART_C(0xf8a95fcf, 88747d94), -343, -84}, - {UINT64_2PART_C(0xb9447093, 8fa89bcf), -316, -76}, - {UINT64_2PART_C(0x8a08f0f8, bf0f156b), -289, -68}, - {UINT64_2PART_C(0xcdb02555, 653131b6), -263, -60}, - {UINT64_2PART_C(0x993fe2c6, d07b7fac), -236, -52}, - {UINT64_2PART_C(0xe45c10c4, 2a2b3b06), -210, -44}, - {UINT64_2PART_C(0xaa242499, 697392d3), -183, -36}, - {UINT64_2PART_C(0xfd87b5f2, 8300ca0e), -157, -28}, - {UINT64_2PART_C(0xbce50864, 92111aeb), -130, -20}, - {UINT64_2PART_C(0x8cbccc09, 6f5088cc), -103, -12}, - {UINT64_2PART_C(0xd1b71758, e219652c), -77, -4}, - {UINT64_2PART_C(0x9c400000, 00000000), -50, 4}, - {UINT64_2PART_C(0xe8d4a510, 00000000), -24, 12}, - {UINT64_2PART_C(0xad78ebc5, ac620000), 3, 20}, - {UINT64_2PART_C(0x813f3978, f8940984), 30, 28}, - {UINT64_2PART_C(0xc097ce7b, c90715b3), 56, 36}, - {UINT64_2PART_C(0x8f7e32ce, 7bea5c70), 83, 44}, - {UINT64_2PART_C(0xd5d238a4, abe98068), 109, 52}, - {UINT64_2PART_C(0x9f4f2726, 179a2245), 136, 60}, - {UINT64_2PART_C(0xed63a231, d4c4fb27), 162, 68}, - {UINT64_2PART_C(0xb0de6538, 8cc8ada8), 189, 76}, - {UINT64_2PART_C(0x83c7088e, 1aab65db), 216, 84}, - {UINT64_2PART_C(0xc45d1df9, 42711d9a), 242, 92}, - {UINT64_2PART_C(0x924d692c, a61be758), 269, 100}, - {UINT64_2PART_C(0xda01ee64, 1a708dea), 295, 108}, - {UINT64_2PART_C(0xa26da399, 9aef774a), 322, 116}, - {UINT64_2PART_C(0xf209787b, b47d6b85), 348, 124}, - {UINT64_2PART_C(0xb454e4a1, 79dd1877), 375, 132}, - {UINT64_2PART_C(0x865b8692, 5b9bc5c2), 402, 140}, - {UINT64_2PART_C(0xc83553c5, c8965d3d), 428, 148}, - {UINT64_2PART_C(0x952ab45c, fa97a0b3), 455, 156}, - {UINT64_2PART_C(0xde469fbd, 99a05fe3), 481, 164}, - {UINT64_2PART_C(0xa59bc234, db398c25), 508, 172}, - {UINT64_2PART_C(0xf6c69a72, a3989f5c), 534, 180}, - {UINT64_2PART_C(0xb7dcbf53, 54e9bece), 561, 188}, - {UINT64_2PART_C(0x88fcf317, f22241e2), 588, 196}, - {UINT64_2PART_C(0xcc20ce9b, d35c78a5), 614, 204}, - {UINT64_2PART_C(0x98165af3, 7b2153df), 641, 212}, - {UINT64_2PART_C(0xe2a0b5dc, 971f303a), 667, 220}, - {UINT64_2PART_C(0xa8d9d153, 5ce3b396), 694, 228}, - {UINT64_2PART_C(0xfb9b7cd9, a4a7443c), 720, 236}, - {UINT64_2PART_C(0xbb764c4c, a7a44410), 747, 244}, - {UINT64_2PART_C(0x8bab8eef, b6409c1a), 774, 252}, - {UINT64_2PART_C(0xd01fef10, a657842c), 800, 260}, - {UINT64_2PART_C(0x9b10a4e5, e9913129), 827, 268}, - {UINT64_2PART_C(0xe7109bfb, a19c0c9d), 853, 276}, - {UINT64_2PART_C(0xac2820d9, 623bf429), 880, 284}, - {UINT64_2PART_C(0x80444b5e, 7aa7cf85), 907, 292}, - {UINT64_2PART_C(0xbf21e440, 03acdd2d), 933, 300}, - {UINT64_2PART_C(0x8e679c2f, 5e44ff8f), 960, 308}, - {UINT64_2PART_C(0xd433179d, 9c8cb841), 986, 316}, - {UINT64_2PART_C(0x9e19db92, b4e31ba9), 1013, 324}, - {UINT64_2PART_C(0xeb96bf6e, badf77d9), 1039, 332}, - {UINT64_2PART_C(0xaf87023b, 9bf0ee6b), 1066, 340}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xfa8fd5a0, 081c0288), -1220, -348}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xbaaee17f, a23ebf76), -1193, -340}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x8b16fb20, 3055ac76), -1166, -332}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xcf42894a, 5dce35ea), -1140, -324}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x9a6bb0aa, 55653b2d), -1113, -316}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xe61acf03, 3d1a45df), -1087, -308}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xab70fe17, c79ac6ca), -1060, -300}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xff77b1fc, bebcdc4f), -1034, -292}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xbe5691ef, 416bd60c), -1007, -284}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x8dd01fad, 907ffc3c), -980, -276}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xd3515c28, 31559a83), -954, -268}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x9d71ac8f, ada6c9b5), -927, -260}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xea9c2277, 23ee8bcb), -901, -252}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xaecc4991, 4078536d), -874, -244}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x823c1279, 5db6ce57), -847, -236}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xc2109436, 4dfb5637), -821, -228}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x9096ea6f, 3848984f), -794, -220}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xd77485cb, 25823ac7), -768, -212}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xa086cfcd, 97bf97f4), -741, -204}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xef340a98, 172aace5), -715, -196}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xb23867fb, 2a35b28e), -688, -188}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x84c8d4df, d2c63f3b), -661, -180}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xc5dd4427, 1ad3cdba), -635, -172}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x936b9fce, bb25c996), -608, -164}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xdbac6c24, 7d62a584), -582, -156}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xa3ab6658, 0d5fdaf6), -555, -148}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xf3e2f893, dec3f126), -529, -140}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xb5b5ada8, aaff80b8), -502, -132}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x87625f05, 6c7c4a8b), -475, -124}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xc9bcff60, 34c13053), -449, -116}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x964e858c, 91ba2655), -422, -108}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xdff97724, 70297ebd), -396, -100}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xa6dfbd9f, b8e5b88f), -369, -92}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xf8a95fcf, 88747d94), -343, -84}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xb9447093, 8fa89bcf), -316, -76}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x8a08f0f8, bf0f156b), -289, -68}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xcdb02555, 653131b6), -263, -60}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x993fe2c6, d07b7fac), -236, -52}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xe45c10c4, 2a2b3b06), -210, -44}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xaa242499, 697392d3), -183, -36}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xfd87b5f2, 8300ca0e), -157, -28}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xbce50864, 92111aeb), -130, -20}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x8cbccc09, 6f5088cc), -103, -12}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xd1b71758, e219652c), -77, -4}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x9c400000, 00000000), -50, 4}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xe8d4a510, 00000000), -24, 12}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xad78ebc5, ac620000), 3, 20}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x813f3978, f8940984), 30, 28}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xc097ce7b, c90715b3), 56, 36}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x8f7e32ce, 7bea5c70), 83, 44}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xd5d238a4, abe98068), 109, 52}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x9f4f2726, 179a2245), 136, 60}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xed63a231, d4c4fb27), 162, 68}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xb0de6538, 8cc8ada8), 189, 76}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x83c7088e, 1aab65db), 216, 84}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xc45d1df9, 42711d9a), 242, 92}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x924d692c, a61be758), 269, 100}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xda01ee64, 1a708dea), 295, 108}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xa26da399, 9aef774a), 322, 116}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xf209787b, b47d6b85), 348, 124}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xb454e4a1, 79dd1877), 375, 132}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x865b8692, 5b9bc5c2), 402, 140}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xc83553c5, c8965d3d), 428, 148}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x952ab45c, fa97a0b3), 455, 156}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xde469fbd, 99a05fe3), 481, 164}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xa59bc234, db398c25), 508, 172}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xf6c69a72, a3989f5c), 534, 180}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xb7dcbf53, 54e9bece), 561, 188}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x88fcf317, f22241e2), 588, 196}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xcc20ce9b, d35c78a5), 614, 204}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x98165af3, 7b2153df), 641, 212}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xe2a0b5dc, 971f303a), 667, 220}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xa8d9d153, 5ce3b396), 694, 228}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xfb9b7cd9, a4a7443c), 720, 236}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xbb764c4c, a7a44410), 747, 244}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x8bab8eef, b6409c1a), 774, 252}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xd01fef10, a657842c), 800, 260}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x9b10a4e5, e9913129), 827, 268}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xe7109bfb, a19c0c9d), 853, 276}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xac2820d9, 623bf429), 880, 284}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x80444b5e, 7aa7cf85), 907, 292}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xbf21e440, 03acdd2d), 933, 300}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x8e679c2f, 5e44ff8f), 960, 308}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xd433179d, 9c8cb841), 986, 316}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0x9e19db92, b4e31ba9), 1013, 324}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xeb96bf6e, badf77d9), 1039, 332}, + {DOUBLE_CONVERSION_UINT64_2PART_C(0xaf87023b, 9bf0ee6b), 1066, 340}, }; static const int kCachedPowersOffset = 348; // -1 * the first decimal_exponent. static const double kD_1_LOG2_10 = 0.30102999566398114; // 1 / lg(10) -// Difference between the decimal exponents in the table above. -const int PowersOfTenCache::kDecimalExponentDistance = 8; -const int PowersOfTenCache::kMinDecimalExponent = -348; -const int PowersOfTenCache::kMaxDecimalExponent = 340; -void PowersOfTenCache::GetCachedPowerForBinaryExponentRange( +void GetCachedPowerForBinaryExponentRange( int min_exponent, int max_exponent, DiyFp* power, @@ -162,30 +160,32 @@ void PowersOfTenCache::GetCachedPowerForBinaryExponentRange( int foo = kCachedPowersOffset; int index = (foo + static_cast(k) - 1) / kDecimalExponentDistance + 1; - ASSERT(0 <= index && index < static_cast(ARRAY_SIZE(kCachedPowers))); + DOUBLE_CONVERSION_ASSERT(0 <= index && index < static_cast(DOUBLE_CONVERSION_ARRAY_SIZE(kCachedPowers))); CachedPower cached_power = kCachedPowers[index]; - ASSERT(min_exponent <= cached_power.binary_exponent); + DOUBLE_CONVERSION_ASSERT(min_exponent <= cached_power.binary_exponent); (void) max_exponent; // Mark variable as used. - ASSERT(cached_power.binary_exponent <= max_exponent); + DOUBLE_CONVERSION_ASSERT(cached_power.binary_exponent <= max_exponent); *decimal_exponent = cached_power.decimal_exponent; *power = DiyFp(cached_power.significand, cached_power.binary_exponent); } -void PowersOfTenCache::GetCachedPowerForDecimalExponent(int requested_exponent, - DiyFp* power, - int* found_exponent) { - ASSERT(kMinDecimalExponent <= requested_exponent); - ASSERT(requested_exponent < kMaxDecimalExponent + kDecimalExponentDistance); +void GetCachedPowerForDecimalExponent(int requested_exponent, + DiyFp* power, + int* found_exponent) { + DOUBLE_CONVERSION_ASSERT(kMinDecimalExponent <= requested_exponent); + DOUBLE_CONVERSION_ASSERT(requested_exponent < kMaxDecimalExponent + kDecimalExponentDistance); int index = (requested_exponent + kCachedPowersOffset) / kDecimalExponentDistance; CachedPower cached_power = kCachedPowers[index]; *power = DiyFp(cached_power.significand, cached_power.binary_exponent); *found_exponent = cached_power.decimal_exponent; - ASSERT(*found_exponent <= requested_exponent); - ASSERT(requested_exponent < *found_exponent + kDecimalExponentDistance); + DOUBLE_CONVERSION_ASSERT(*found_exponent <= requested_exponent); + DOUBLE_CONVERSION_ASSERT(requested_exponent < *found_exponent + kDecimalExponentDistance); } +} // namespace PowersOfTenCache + } // namespace double_conversion // ICU PATCH: Close ICU namespace diff --git a/deps/icu-small/source/i18n/double-conversion-cached-powers.h b/deps/icu-small/source/i18n/double-conversion-cached-powers.h index 438746b143293f..ade27baef8b0c7 100644 --- a/deps/icu-small/source/i18n/double-conversion-cached-powers.h +++ b/deps/icu-small/source/i18n/double-conversion-cached-powers.h @@ -46,32 +46,32 @@ U_NAMESPACE_BEGIN namespace double_conversion { -class PowersOfTenCache { - public: +namespace PowersOfTenCache { // Not all powers of ten are cached. The decimal exponent of two neighboring // cached numbers will differ by kDecimalExponentDistance. - static const int kDecimalExponentDistance; + static const int kDecimalExponentDistance = 8; - static const int kMinDecimalExponent; - static const int kMaxDecimalExponent; + static const int kMinDecimalExponent = -348; + static const int kMaxDecimalExponent = 340; // Returns a cached power-of-ten with a binary exponent in the range // [min_exponent; max_exponent] (boundaries included). - static void GetCachedPowerForBinaryExponentRange(int min_exponent, - int max_exponent, - DiyFp* power, - int* decimal_exponent); + void GetCachedPowerForBinaryExponentRange(int min_exponent, + int max_exponent, + DiyFp* power, + int* decimal_exponent); // Returns a cached power of ten x ~= 10^k such that // k <= decimal_exponent < k + kCachedPowersDecimalDistance. // The given decimal_exponent must satisfy // kMinDecimalExponent <= requested_exponent, and // requested_exponent < kMaxDecimalExponent + kDecimalExponentDistance. - static void GetCachedPowerForDecimalExponent(int requested_exponent, - DiyFp* power, - int* found_exponent); -}; + void GetCachedPowerForDecimalExponent(int requested_exponent, + DiyFp* power, + int* found_exponent); + +} // namespace PowersOfTenCache } // namespace double_conversion diff --git a/deps/icu-small/source/i18n/double-conversion-diy-fp.cpp b/deps/icu-small/source/i18n/double-conversion-diy-fp.cpp deleted file mode 100644 index f38430c6c3c90f..00000000000000 --- a/deps/icu-small/source/i18n/double-conversion-diy-fp.cpp +++ /dev/null @@ -1,74 +0,0 @@ -// © 2018 and later: Unicode, Inc. and others. -// License & terms of use: http://www.unicode.org/copyright.html -// -// From the double-conversion library. Original license: -// -// Copyright 2010 the V8 project authors. All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials provided -// with the distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived -// from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// ICU PATCH: ifdef around UCONFIG_NO_FORMATTING -#include "unicode/utypes.h" -#if !UCONFIG_NO_FORMATTING - -// ICU PATCH: Customize header file paths for ICU. - -#include "double-conversion-diy-fp.h" -#include "double-conversion-utils.h" - -// ICU PATCH: Wrap in ICU namespace -U_NAMESPACE_BEGIN - -namespace double_conversion { - -void DiyFp::Multiply(const DiyFp& other) { - // Simply "emulates" a 128 bit multiplication. - // However: the resulting number only contains 64 bits. The least - // significant 64 bits are only used for rounding the most significant 64 - // bits. - const uint64_t kM32 = 0xFFFFFFFFU; - uint64_t a = f_ >> 32; - uint64_t b = f_ & kM32; - uint64_t c = other.f_ >> 32; - uint64_t d = other.f_ & kM32; - uint64_t ac = a * c; - uint64_t bc = b * c; - uint64_t ad = a * d; - uint64_t bd = b * d; - uint64_t tmp = (bd >> 32) + (ad & kM32) + (bc & kM32); - // By adding 1U << 31 to tmp we round the final result. - // Halfway cases will be round up. - tmp += 1U << 31; - uint64_t result_f = ac + (ad >> 32) + (bc >> 32) + (tmp >> 32); - e_ += other.e_ + 64; - f_ = result_f; -} - -} // namespace double_conversion - -// ICU PATCH: Close ICU namespace -U_NAMESPACE_END -#endif // ICU PATCH: close #if !UCONFIG_NO_FORMATTING diff --git a/deps/icu-small/source/i18n/double-conversion-diy-fp.h b/deps/icu-small/source/i18n/double-conversion-diy-fp.h index 21896851d22d32..5820abedf35405 100644 --- a/deps/icu-small/source/i18n/double-conversion-diy-fp.h +++ b/deps/icu-small/source/i18n/double-conversion-diy-fp.h @@ -50,36 +50,55 @@ namespace double_conversion { // with a uint64 significand and an int exponent. Normalized DiyFp numbers will // have the most significant bit of the significand set. // Multiplication and Subtraction do not normalize their results. -// DiyFp are not designed to contain special doubles (NaN and Infinity). +// DiyFp store only non-negative numbers and are not designed to contain special +// doubles (NaN and Infinity). class DiyFp { public: static const int kSignificandSize = 64; DiyFp() : f_(0), e_(0) {} - DiyFp(uint64_t significand, int exponent) : f_(significand), e_(exponent) {} + DiyFp(const uint64_t significand, const int32_t exponent) : f_(significand), e_(exponent) {} - // this = this - other. + // this -= other. // The exponents of both numbers must be the same and the significand of this - // must be bigger than the significand of other. + // must be greater or equal than the significand of other. // The result will not be normalized. void Subtract(const DiyFp& other) { - ASSERT(e_ == other.e_); - ASSERT(f_ >= other.f_); + DOUBLE_CONVERSION_ASSERT(e_ == other.e_); + DOUBLE_CONVERSION_ASSERT(f_ >= other.f_); f_ -= other.f_; } // Returns a - b. - // The exponents of both numbers must be the same and this must be bigger - // than other. The result will not be normalized. + // The exponents of both numbers must be the same and a must be greater + // or equal than b. The result will not be normalized. static DiyFp Minus(const DiyFp& a, const DiyFp& b) { DiyFp result = a; result.Subtract(b); return result; } - - // this = this * other. - void Multiply(const DiyFp& other); + // this *= other. + void Multiply(const DiyFp& other) { + // Simply "emulates" a 128 bit multiplication. + // However: the resulting number only contains 64 bits. The least + // significant 64 bits are only used for rounding the most significant 64 + // bits. + const uint64_t kM32 = 0xFFFFFFFFU; + const uint64_t a = f_ >> 32; + const uint64_t b = f_ & kM32; + const uint64_t c = other.f_ >> 32; + const uint64_t d = other.f_ & kM32; + const uint64_t ac = a * c; + const uint64_t bc = b * c; + const uint64_t ad = a * d; + const uint64_t bd = b * d; + // By adding 1U << 31 to tmp we round the final result. + // Halfway cases will be rounded up. + const uint64_t tmp = (bd >> 32) + (ad & kM32) + (bc & kM32) + (1U << 31); + e_ += other.e_ + 64; + f_ = ac + (ad >> 32) + (bc >> 32) + (tmp >> 32); + } // returns a * b; static DiyFp Times(const DiyFp& a, const DiyFp& b) { @@ -89,13 +108,13 @@ class DiyFp { } void Normalize() { - ASSERT(f_ != 0); + DOUBLE_CONVERSION_ASSERT(f_ != 0); uint64_t significand = f_; - int exponent = e_; + int32_t exponent = e_; - // This method is mainly called for normalizing boundaries. In general - // boundaries need to be shifted by 10 bits. We thus optimize for this case. - const uint64_t k10MSBits = UINT64_2PART_C(0xFFC00000, 00000000); + // This method is mainly called for normalizing boundaries. In general, + // boundaries need to be shifted by 10 bits, and we optimize for this case. + const uint64_t k10MSBits = DOUBLE_CONVERSION_UINT64_2PART_C(0xFFC00000, 00000000); while ((significand & k10MSBits) == 0) { significand <<= 10; exponent -= 10; @@ -115,16 +134,16 @@ class DiyFp { } uint64_t f() const { return f_; } - int e() const { return e_; } + int32_t e() const { return e_; } void set_f(uint64_t new_value) { f_ = new_value; } - void set_e(int new_value) { e_ = new_value; } + void set_e(int32_t new_value) { e_ = new_value; } private: - static const uint64_t kUint64MSB = UINT64_2PART_C(0x80000000, 00000000); + static const uint64_t kUint64MSB = DOUBLE_CONVERSION_UINT64_2PART_C(0x80000000, 00000000); uint64_t f_; - int e_; + int32_t e_; }; } // namespace double_conversion diff --git a/deps/icu-small/source/i18n/double-conversion-double-to-string.cpp b/deps/icu-small/source/i18n/double-conversion-double-to-string.cpp new file mode 100644 index 00000000000000..44c176f4f9c958 --- /dev/null +++ b/deps/icu-small/source/i18n/double-conversion-double-to-string.cpp @@ -0,0 +1,450 @@ +// © 2018 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html +// +// From the double-conversion library. Original license: +// +// Copyright 2010 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// ICU PATCH: ifdef around UCONFIG_NO_FORMATTING +#include "unicode/utypes.h" +#if !UCONFIG_NO_FORMATTING + +#include +#include +#include + +// ICU PATCH: Customize header file paths for ICU. +// The file fixed-dtoa.h is not needed. + +#include "double-conversion-double-to-string.h" + +#include "double-conversion-bignum-dtoa.h" +#include "double-conversion-fast-dtoa.h" +#include "double-conversion-ieee.h" +#include "double-conversion-utils.h" + +// ICU PATCH: Wrap in ICU namespace +U_NAMESPACE_BEGIN + +namespace double_conversion { + +#if 0 // not needed for ICU +const DoubleToStringConverter& DoubleToStringConverter::EcmaScriptConverter() { + int flags = UNIQUE_ZERO | EMIT_POSITIVE_EXPONENT_SIGN; + static DoubleToStringConverter converter(flags, + "Infinity", + "NaN", + 'e', + -6, 21, + 6, 0); + return converter; +} + + +bool DoubleToStringConverter::HandleSpecialValues( + double value, + StringBuilder* result_builder) const { + Double double_inspect(value); + if (double_inspect.IsInfinite()) { + if (infinity_symbol_ == NULL) return false; + if (value < 0) { + result_builder->AddCharacter('-'); + } + result_builder->AddString(infinity_symbol_); + return true; + } + if (double_inspect.IsNan()) { + if (nan_symbol_ == NULL) return false; + result_builder->AddString(nan_symbol_); + return true; + } + return false; +} + + +void DoubleToStringConverter::CreateExponentialRepresentation( + const char* decimal_digits, + int length, + int exponent, + StringBuilder* result_builder) const { + DOUBLE_CONVERSION_ASSERT(length != 0); + result_builder->AddCharacter(decimal_digits[0]); + if (length != 1) { + result_builder->AddCharacter('.'); + result_builder->AddSubstring(&decimal_digits[1], length-1); + } + result_builder->AddCharacter(exponent_character_); + if (exponent < 0) { + result_builder->AddCharacter('-'); + exponent = -exponent; + } else { + if ((flags_ & EMIT_POSITIVE_EXPONENT_SIGN) != 0) { + result_builder->AddCharacter('+'); + } + } + if (exponent == 0) { + result_builder->AddCharacter('0'); + return; + } + DOUBLE_CONVERSION_ASSERT(exponent < 1e4); + // Changing this constant requires updating the comment of DoubleToStringConverter constructor + const int kMaxExponentLength = 5; + char buffer[kMaxExponentLength + 1]; + buffer[kMaxExponentLength] = '\0'; + int first_char_pos = kMaxExponentLength; + while (exponent > 0) { + buffer[--first_char_pos] = '0' + (exponent % 10); + exponent /= 10; + } + // Add prefix '0' to make exponent width >= min(min_exponent_with_, kMaxExponentLength) + // For example: convert 1e+9 -> 1e+09, if min_exponent_with_ is set to 2 + while(kMaxExponentLength - first_char_pos < std::min(min_exponent_width_, kMaxExponentLength)) { + buffer[--first_char_pos] = '0'; + } + result_builder->AddSubstring(&buffer[first_char_pos], + kMaxExponentLength - first_char_pos); +} + + +void DoubleToStringConverter::CreateDecimalRepresentation( + const char* decimal_digits, + int length, + int decimal_point, + int digits_after_point, + StringBuilder* result_builder) const { + // Create a representation that is padded with zeros if needed. + if (decimal_point <= 0) { + // "0.00000decimal_rep" or "0.000decimal_rep00". + result_builder->AddCharacter('0'); + if (digits_after_point > 0) { + result_builder->AddCharacter('.'); + result_builder->AddPadding('0', -decimal_point); + DOUBLE_CONVERSION_ASSERT(length <= digits_after_point - (-decimal_point)); + result_builder->AddSubstring(decimal_digits, length); + int remaining_digits = digits_after_point - (-decimal_point) - length; + result_builder->AddPadding('0', remaining_digits); + } + } else if (decimal_point >= length) { + // "decimal_rep0000.00000" or "decimal_rep.0000". + result_builder->AddSubstring(decimal_digits, length); + result_builder->AddPadding('0', decimal_point - length); + if (digits_after_point > 0) { + result_builder->AddCharacter('.'); + result_builder->AddPadding('0', digits_after_point); + } + } else { + // "decima.l_rep000". + DOUBLE_CONVERSION_ASSERT(digits_after_point > 0); + result_builder->AddSubstring(decimal_digits, decimal_point); + result_builder->AddCharacter('.'); + DOUBLE_CONVERSION_ASSERT(length - decimal_point <= digits_after_point); + result_builder->AddSubstring(&decimal_digits[decimal_point], + length - decimal_point); + int remaining_digits = digits_after_point - (length - decimal_point); + result_builder->AddPadding('0', remaining_digits); + } + if (digits_after_point == 0) { + if ((flags_ & EMIT_TRAILING_DECIMAL_POINT) != 0) { + result_builder->AddCharacter('.'); + } + if ((flags_ & EMIT_TRAILING_ZERO_AFTER_POINT) != 0) { + result_builder->AddCharacter('0'); + } + } +} + + +bool DoubleToStringConverter::ToShortestIeeeNumber( + double value, + StringBuilder* result_builder, + DoubleToStringConverter::DtoaMode mode) const { + DOUBLE_CONVERSION_ASSERT(mode == SHORTEST || mode == SHORTEST_SINGLE); + if (Double(value).IsSpecial()) { + return HandleSpecialValues(value, result_builder); + } + + int decimal_point; + bool sign; + const int kDecimalRepCapacity = kBase10MaximalLength + 1; + char decimal_rep[kDecimalRepCapacity]; + int decimal_rep_length; + + DoubleToAscii(value, mode, 0, decimal_rep, kDecimalRepCapacity, + &sign, &decimal_rep_length, &decimal_point); + + bool unique_zero = (flags_ & UNIQUE_ZERO) != 0; + if (sign && (value != 0.0 || !unique_zero)) { + result_builder->AddCharacter('-'); + } + + int exponent = decimal_point - 1; + if ((decimal_in_shortest_low_ <= exponent) && + (exponent < decimal_in_shortest_high_)) { + CreateDecimalRepresentation(decimal_rep, decimal_rep_length, + decimal_point, + (std::max)(0, decimal_rep_length - decimal_point), + result_builder); + } else { + CreateExponentialRepresentation(decimal_rep, decimal_rep_length, exponent, + result_builder); + } + return true; +} + + +bool DoubleToStringConverter::ToFixed(double value, + int requested_digits, + StringBuilder* result_builder) const { + DOUBLE_CONVERSION_ASSERT(kMaxFixedDigitsBeforePoint == 60); + const double kFirstNonFixed = 1e60; + + if (Double(value).IsSpecial()) { + return HandleSpecialValues(value, result_builder); + } + + if (requested_digits > kMaxFixedDigitsAfterPoint) return false; + if (value >= kFirstNonFixed || value <= -kFirstNonFixed) return false; + + // Find a sufficiently precise decimal representation of n. + int decimal_point; + bool sign; + // Add space for the '\0' byte. + const int kDecimalRepCapacity = + kMaxFixedDigitsBeforePoint + kMaxFixedDigitsAfterPoint + 1; + char decimal_rep[kDecimalRepCapacity]; + int decimal_rep_length; + DoubleToAscii(value, FIXED, requested_digits, + decimal_rep, kDecimalRepCapacity, + &sign, &decimal_rep_length, &decimal_point); + + bool unique_zero = ((flags_ & UNIQUE_ZERO) != 0); + if (sign && (value != 0.0 || !unique_zero)) { + result_builder->AddCharacter('-'); + } + + CreateDecimalRepresentation(decimal_rep, decimal_rep_length, decimal_point, + requested_digits, result_builder); + return true; +} + + +bool DoubleToStringConverter::ToExponential( + double value, + int requested_digits, + StringBuilder* result_builder) const { + if (Double(value).IsSpecial()) { + return HandleSpecialValues(value, result_builder); + } + + if (requested_digits < -1) return false; + if (requested_digits > kMaxExponentialDigits) return false; + + int decimal_point; + bool sign; + // Add space for digit before the decimal point and the '\0' character. + const int kDecimalRepCapacity = kMaxExponentialDigits + 2; + DOUBLE_CONVERSION_ASSERT(kDecimalRepCapacity > kBase10MaximalLength); + char decimal_rep[kDecimalRepCapacity]; +#ifndef NDEBUG + // Problem: there is an assert in StringBuilder::AddSubstring() that + // will pass this buffer to strlen(), and this buffer is not generally + // null-terminated. + memset(decimal_rep, 0, sizeof(decimal_rep)); +#endif + int decimal_rep_length; + + if (requested_digits == -1) { + DoubleToAscii(value, SHORTEST, 0, + decimal_rep, kDecimalRepCapacity, + &sign, &decimal_rep_length, &decimal_point); + } else { + DoubleToAscii(value, PRECISION, requested_digits + 1, + decimal_rep, kDecimalRepCapacity, + &sign, &decimal_rep_length, &decimal_point); + DOUBLE_CONVERSION_ASSERT(decimal_rep_length <= requested_digits + 1); + + for (int i = decimal_rep_length; i < requested_digits + 1; ++i) { + decimal_rep[i] = '0'; + } + decimal_rep_length = requested_digits + 1; + } + + bool unique_zero = ((flags_ & UNIQUE_ZERO) != 0); + if (sign && (value != 0.0 || !unique_zero)) { + result_builder->AddCharacter('-'); + } + + int exponent = decimal_point - 1; + CreateExponentialRepresentation(decimal_rep, + decimal_rep_length, + exponent, + result_builder); + return true; +} + + +bool DoubleToStringConverter::ToPrecision(double value, + int precision, + StringBuilder* result_builder) const { + if (Double(value).IsSpecial()) { + return HandleSpecialValues(value, result_builder); + } + + if (precision < kMinPrecisionDigits || precision > kMaxPrecisionDigits) { + return false; + } + + // Find a sufficiently precise decimal representation of n. + int decimal_point; + bool sign; + // Add one for the terminating null character. + const int kDecimalRepCapacity = kMaxPrecisionDigits + 1; + char decimal_rep[kDecimalRepCapacity]; + int decimal_rep_length; + + DoubleToAscii(value, PRECISION, precision, + decimal_rep, kDecimalRepCapacity, + &sign, &decimal_rep_length, &decimal_point); + DOUBLE_CONVERSION_ASSERT(decimal_rep_length <= precision); + + bool unique_zero = ((flags_ & UNIQUE_ZERO) != 0); + if (sign && (value != 0.0 || !unique_zero)) { + result_builder->AddCharacter('-'); + } + + // The exponent if we print the number as x.xxeyyy. That is with the + // decimal point after the first digit. + int exponent = decimal_point - 1; + + int extra_zero = ((flags_ & EMIT_TRAILING_ZERO_AFTER_POINT) != 0) ? 1 : 0; + if ((-decimal_point + 1 > max_leading_padding_zeroes_in_precision_mode_) || + (decimal_point - precision + extra_zero > + max_trailing_padding_zeroes_in_precision_mode_)) { + // Fill buffer to contain 'precision' digits. + // Usually the buffer is already at the correct length, but 'DoubleToAscii' + // is allowed to return less characters. + for (int i = decimal_rep_length; i < precision; ++i) { + decimal_rep[i] = '0'; + } + + CreateExponentialRepresentation(decimal_rep, + precision, + exponent, + result_builder); + } else { + CreateDecimalRepresentation(decimal_rep, decimal_rep_length, decimal_point, + (std::max)(0, precision - decimal_point), + result_builder); + } + return true; +} +#endif // not needed for ICU + + +static BignumDtoaMode DtoaToBignumDtoaMode( + DoubleToStringConverter::DtoaMode dtoa_mode) { + switch (dtoa_mode) { + case DoubleToStringConverter::SHORTEST: return BIGNUM_DTOA_SHORTEST; + case DoubleToStringConverter::SHORTEST_SINGLE: + return BIGNUM_DTOA_SHORTEST_SINGLE; + case DoubleToStringConverter::FIXED: return BIGNUM_DTOA_FIXED; + case DoubleToStringConverter::PRECISION: return BIGNUM_DTOA_PRECISION; + default: + DOUBLE_CONVERSION_UNREACHABLE(); + } +} + + +void DoubleToStringConverter::DoubleToAscii(double v, + DtoaMode mode, + int requested_digits, + char* buffer, + int buffer_length, + bool* sign, + int* length, + int* point) { + Vector vector(buffer, buffer_length); + DOUBLE_CONVERSION_ASSERT(!Double(v).IsSpecial()); + DOUBLE_CONVERSION_ASSERT(mode == SHORTEST || mode == SHORTEST_SINGLE || requested_digits >= 0); + + if (Double(v).Sign() < 0) { + *sign = true; + v = -v; + } else { + *sign = false; + } + + if (mode == PRECISION && requested_digits == 0) { + vector[0] = '\0'; + *length = 0; + return; + } + + if (v == 0) { + vector[0] = '0'; + vector[1] = '\0'; + *length = 1; + *point = 1; + return; + } + + bool fast_worked; + switch (mode) { + case SHORTEST: + fast_worked = FastDtoa(v, FAST_DTOA_SHORTEST, 0, vector, length, point); + break; +#if 0 // not needed for ICU + case SHORTEST_SINGLE: + fast_worked = FastDtoa(v, FAST_DTOA_SHORTEST_SINGLE, 0, + vector, length, point); + break; + case FIXED: + fast_worked = FastFixedDtoa(v, requested_digits, vector, length, point); + break; + case PRECISION: + fast_worked = FastDtoa(v, FAST_DTOA_PRECISION, requested_digits, + vector, length, point); + break; +#endif // not needed for ICU + default: + fast_worked = false; + DOUBLE_CONVERSION_UNREACHABLE(); + } + if (fast_worked) return; + + // If the fast dtoa didn't succeed use the slower bignum version. + BignumDtoaMode bignum_mode = DtoaToBignumDtoaMode(mode); + BignumDtoa(v, bignum_mode, requested_digits, vector, length, point); + vector[*length] = '\0'; +} + +} // namespace double_conversion + +// ICU PATCH: Close ICU namespace +U_NAMESPACE_END +#endif // ICU PATCH: close #if !UCONFIG_NO_FORMATTING diff --git a/deps/icu-small/source/i18n/double-conversion-double-to-string.h b/deps/icu-small/source/i18n/double-conversion-double-to-string.h new file mode 100644 index 00000000000000..27bd86784895f8 --- /dev/null +++ b/deps/icu-small/source/i18n/double-conversion-double-to-string.h @@ -0,0 +1,419 @@ +// © 2018 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html +// +// From the double-conversion library. Original license: +// +// Copyright 2012 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// ICU PATCH: ifdef around UCONFIG_NO_FORMATTING +#include "unicode/utypes.h" +#if !UCONFIG_NO_FORMATTING + +#ifndef DOUBLE_CONVERSION_DOUBLE_TO_STRING_H_ +#define DOUBLE_CONVERSION_DOUBLE_TO_STRING_H_ + +// ICU PATCH: Customize header file paths for ICU. + +#include "double-conversion-utils.h" + +// ICU PATCH: Wrap in ICU namespace +U_NAMESPACE_BEGIN + +namespace double_conversion { + +class DoubleToStringConverter { + public: +#if 0 // not needed for ICU + // When calling ToFixed with a double > 10^kMaxFixedDigitsBeforePoint + // or a requested_digits parameter > kMaxFixedDigitsAfterPoint then the + // function returns false. + static const int kMaxFixedDigitsBeforePoint = 60; + static const int kMaxFixedDigitsAfterPoint = 60; + + // When calling ToExponential with a requested_digits + // parameter > kMaxExponentialDigits then the function returns false. + static const int kMaxExponentialDigits = 120; + + // When calling ToPrecision with a requested_digits + // parameter < kMinPrecisionDigits or requested_digits > kMaxPrecisionDigits + // then the function returns false. + static const int kMinPrecisionDigits = 1; + static const int kMaxPrecisionDigits = 120; + + enum Flags { + NO_FLAGS = 0, + EMIT_POSITIVE_EXPONENT_SIGN = 1, + EMIT_TRAILING_DECIMAL_POINT = 2, + EMIT_TRAILING_ZERO_AFTER_POINT = 4, + UNIQUE_ZERO = 8 + }; + + // Flags should be a bit-or combination of the possible Flags-enum. + // - NO_FLAGS: no special flags. + // - EMIT_POSITIVE_EXPONENT_SIGN: when the number is converted into exponent + // form, emits a '+' for positive exponents. Example: 1.2e+2. + // - EMIT_TRAILING_DECIMAL_POINT: when the input number is an integer and is + // converted into decimal format then a trailing decimal point is appended. + // Example: 2345.0 is converted to "2345.". + // - EMIT_TRAILING_ZERO_AFTER_POINT: in addition to a trailing decimal point + // emits a trailing '0'-character. This flag requires the + // EXMIT_TRAILING_DECIMAL_POINT flag. + // Example: 2345.0 is converted to "2345.0". + // - UNIQUE_ZERO: "-0.0" is converted to "0.0". + // + // Infinity symbol and nan_symbol provide the string representation for these + // special values. If the string is NULL and the special value is encountered + // then the conversion functions return false. + // + // The exponent_character is used in exponential representations. It is + // usually 'e' or 'E'. + // + // When converting to the shortest representation the converter will + // represent input numbers in decimal format if they are in the interval + // [10^decimal_in_shortest_low; 10^decimal_in_shortest_high[ + // (lower boundary included, greater boundary excluded). + // Example: with decimal_in_shortest_low = -6 and + // decimal_in_shortest_high = 21: + // ToShortest(0.000001) -> "0.000001" + // ToShortest(0.0000001) -> "1e-7" + // ToShortest(111111111111111111111.0) -> "111111111111111110000" + // ToShortest(100000000000000000000.0) -> "100000000000000000000" + // ToShortest(1111111111111111111111.0) -> "1.1111111111111111e+21" + // + // When converting to precision mode the converter may add + // max_leading_padding_zeroes before returning the number in exponential + // format. + // Example with max_leading_padding_zeroes_in_precision_mode = 6. + // ToPrecision(0.0000012345, 2) -> "0.0000012" + // ToPrecision(0.00000012345, 2) -> "1.2e-7" + // Similarily the converter may add up to + // max_trailing_padding_zeroes_in_precision_mode in precision mode to avoid + // returning an exponential representation. A zero added by the + // EMIT_TRAILING_ZERO_AFTER_POINT flag is counted for this limit. + // Examples for max_trailing_padding_zeroes_in_precision_mode = 1: + // ToPrecision(230.0, 2) -> "230" + // ToPrecision(230.0, 2) -> "230." with EMIT_TRAILING_DECIMAL_POINT. + // ToPrecision(230.0, 2) -> "2.3e2" with EMIT_TRAILING_ZERO_AFTER_POINT. + // + // The min_exponent_width is used for exponential representations. + // The converter adds leading '0's to the exponent until the exponent + // is at least min_exponent_width digits long. + // The min_exponent_width is clamped to 5. + // As such, the exponent may never have more than 5 digits in total. + DoubleToStringConverter(int flags, + const char* infinity_symbol, + const char* nan_symbol, + char exponent_character, + int decimal_in_shortest_low, + int decimal_in_shortest_high, + int max_leading_padding_zeroes_in_precision_mode, + int max_trailing_padding_zeroes_in_precision_mode, + int min_exponent_width = 0) + : flags_(flags), + infinity_symbol_(infinity_symbol), + nan_symbol_(nan_symbol), + exponent_character_(exponent_character), + decimal_in_shortest_low_(decimal_in_shortest_low), + decimal_in_shortest_high_(decimal_in_shortest_high), + max_leading_padding_zeroes_in_precision_mode_( + max_leading_padding_zeroes_in_precision_mode), + max_trailing_padding_zeroes_in_precision_mode_( + max_trailing_padding_zeroes_in_precision_mode), + min_exponent_width_(min_exponent_width) { + // When 'trailing zero after the point' is set, then 'trailing point' + // must be set too. + DOUBLE_CONVERSION_ASSERT(((flags & EMIT_TRAILING_DECIMAL_POINT) != 0) || + !((flags & EMIT_TRAILING_ZERO_AFTER_POINT) != 0)); + } + + // Returns a converter following the EcmaScript specification. + static const DoubleToStringConverter& EcmaScriptConverter(); + + // Computes the shortest string of digits that correctly represent the input + // number. Depending on decimal_in_shortest_low and decimal_in_shortest_high + // (see constructor) it then either returns a decimal representation, or an + // exponential representation. + // Example with decimal_in_shortest_low = -6, + // decimal_in_shortest_high = 21, + // EMIT_POSITIVE_EXPONENT_SIGN activated, and + // EMIT_TRAILING_DECIMAL_POINT deactived: + // ToShortest(0.000001) -> "0.000001" + // ToShortest(0.0000001) -> "1e-7" + // ToShortest(111111111111111111111.0) -> "111111111111111110000" + // ToShortest(100000000000000000000.0) -> "100000000000000000000" + // ToShortest(1111111111111111111111.0) -> "1.1111111111111111e+21" + // + // Note: the conversion may round the output if the returned string + // is accurate enough to uniquely identify the input-number. + // For example the most precise representation of the double 9e59 equals + // "899999999999999918767229449717619953810131273674690656206848", but + // the converter will return the shorter (but still correct) "9e59". + // + // Returns true if the conversion succeeds. The conversion always succeeds + // except when the input value is special and no infinity_symbol or + // nan_symbol has been given to the constructor. + bool ToShortest(double value, StringBuilder* result_builder) const { + return ToShortestIeeeNumber(value, result_builder, SHORTEST); + } + + // Same as ToShortest, but for single-precision floats. + bool ToShortestSingle(float value, StringBuilder* result_builder) const { + return ToShortestIeeeNumber(value, result_builder, SHORTEST_SINGLE); + } + + + // Computes a decimal representation with a fixed number of digits after the + // decimal point. The last emitted digit is rounded. + // + // Examples: + // ToFixed(3.12, 1) -> "3.1" + // ToFixed(3.1415, 3) -> "3.142" + // ToFixed(1234.56789, 4) -> "1234.5679" + // ToFixed(1.23, 5) -> "1.23000" + // ToFixed(0.1, 4) -> "0.1000" + // ToFixed(1e30, 2) -> "1000000000000000019884624838656.00" + // ToFixed(0.1, 30) -> "0.100000000000000005551115123126" + // ToFixed(0.1, 17) -> "0.10000000000000001" + // + // If requested_digits equals 0, then the tail of the result depends on + // the EMIT_TRAILING_DECIMAL_POINT and EMIT_TRAILING_ZERO_AFTER_POINT. + // Examples, for requested_digits == 0, + // let EMIT_TRAILING_DECIMAL_POINT and EMIT_TRAILING_ZERO_AFTER_POINT be + // - false and false: then 123.45 -> 123 + // 0.678 -> 1 + // - true and false: then 123.45 -> 123. + // 0.678 -> 1. + // - true and true: then 123.45 -> 123.0 + // 0.678 -> 1.0 + // + // Returns true if the conversion succeeds. The conversion always succeeds + // except for the following cases: + // - the input value is special and no infinity_symbol or nan_symbol has + // been provided to the constructor, + // - 'value' > 10^kMaxFixedDigitsBeforePoint, or + // - 'requested_digits' > kMaxFixedDigitsAfterPoint. + // The last two conditions imply that the result will never contain more than + // 1 + kMaxFixedDigitsBeforePoint + 1 + kMaxFixedDigitsAfterPoint characters + // (one additional character for the sign, and one for the decimal point). + bool ToFixed(double value, + int requested_digits, + StringBuilder* result_builder) const; + + // Computes a representation in exponential format with requested_digits + // after the decimal point. The last emitted digit is rounded. + // If requested_digits equals -1, then the shortest exponential representation + // is computed. + // + // Examples with EMIT_POSITIVE_EXPONENT_SIGN deactivated, and + // exponent_character set to 'e'. + // ToExponential(3.12, 1) -> "3.1e0" + // ToExponential(5.0, 3) -> "5.000e0" + // ToExponential(0.001, 2) -> "1.00e-3" + // ToExponential(3.1415, -1) -> "3.1415e0" + // ToExponential(3.1415, 4) -> "3.1415e0" + // ToExponential(3.1415, 3) -> "3.142e0" + // ToExponential(123456789000000, 3) -> "1.235e14" + // ToExponential(1000000000000000019884624838656.0, -1) -> "1e30" + // ToExponential(1000000000000000019884624838656.0, 32) -> + // "1.00000000000000001988462483865600e30" + // ToExponential(1234, 0) -> "1e3" + // + // Returns true if the conversion succeeds. The conversion always succeeds + // except for the following cases: + // - the input value is special and no infinity_symbol or nan_symbol has + // been provided to the constructor, + // - 'requested_digits' > kMaxExponentialDigits. + // The last condition implies that the result will never contain more than + // kMaxExponentialDigits + 8 characters (the sign, the digit before the + // decimal point, the decimal point, the exponent character, the + // exponent's sign, and at most 3 exponent digits). + bool ToExponential(double value, + int requested_digits, + StringBuilder* result_builder) const; + + // Computes 'precision' leading digits of the given 'value' and returns them + // either in exponential or decimal format, depending on + // max_{leading|trailing}_padding_zeroes_in_precision_mode (given to the + // constructor). + // The last computed digit is rounded. + // + // Example with max_leading_padding_zeroes_in_precision_mode = 6. + // ToPrecision(0.0000012345, 2) -> "0.0000012" + // ToPrecision(0.00000012345, 2) -> "1.2e-7" + // Similarily the converter may add up to + // max_trailing_padding_zeroes_in_precision_mode in precision mode to avoid + // returning an exponential representation. A zero added by the + // EMIT_TRAILING_ZERO_AFTER_POINT flag is counted for this limit. + // Examples for max_trailing_padding_zeroes_in_precision_mode = 1: + // ToPrecision(230.0, 2) -> "230" + // ToPrecision(230.0, 2) -> "230." with EMIT_TRAILING_DECIMAL_POINT. + // ToPrecision(230.0, 2) -> "2.3e2" with EMIT_TRAILING_ZERO_AFTER_POINT. + // Examples for max_trailing_padding_zeroes_in_precision_mode = 3, and no + // EMIT_TRAILING_ZERO_AFTER_POINT: + // ToPrecision(123450.0, 6) -> "123450" + // ToPrecision(123450.0, 5) -> "123450" + // ToPrecision(123450.0, 4) -> "123500" + // ToPrecision(123450.0, 3) -> "123000" + // ToPrecision(123450.0, 2) -> "1.2e5" + // + // Returns true if the conversion succeeds. The conversion always succeeds + // except for the following cases: + // - the input value is special and no infinity_symbol or nan_symbol has + // been provided to the constructor, + // - precision < kMinPericisionDigits + // - precision > kMaxPrecisionDigits + // The last condition implies that the result will never contain more than + // kMaxPrecisionDigits + 7 characters (the sign, the decimal point, the + // exponent character, the exponent's sign, and at most 3 exponent digits). + bool ToPrecision(double value, + int precision, + StringBuilder* result_builder) const; +#endif // not needed for ICU + + enum DtoaMode { + // Produce the shortest correct representation. + // For example the output of 0.299999999999999988897 is (the less accurate + // but correct) 0.3. + SHORTEST, + // Same as SHORTEST, but for single-precision floats. + SHORTEST_SINGLE, + // Produce a fixed number of digits after the decimal point. + // For instance fixed(0.1, 4) becomes 0.1000 + // If the input number is big, the output will be big. + FIXED, + // Fixed number of digits (independent of the decimal point). + PRECISION + }; + + // The maximal number of digits that are needed to emit a double in base 10. + // A higher precision can be achieved by using more digits, but the shortest + // accurate representation of any double will never use more digits than + // kBase10MaximalLength. + // Note that DoubleToAscii null-terminates its input. So the given buffer + // should be at least kBase10MaximalLength + 1 characters long. + static const int kBase10MaximalLength = 17; + + // Converts the given double 'v' to digit characters. 'v' must not be NaN, + // +Infinity, or -Infinity. In SHORTEST_SINGLE-mode this restriction also + // applies to 'v' after it has been casted to a single-precision float. That + // is, in this mode static_cast(v) must not be NaN, +Infinity or + // -Infinity. + // + // The result should be interpreted as buffer * 10^(point-length). + // + // The digits are written to the buffer in the platform's charset, which is + // often UTF-8 (with ASCII-range digits) but may be another charset, such + // as EBCDIC. + // + // The output depends on the given mode: + // - SHORTEST: produce the least amount of digits for which the internal + // identity requirement is still satisfied. If the digits are printed + // (together with the correct exponent) then reading this number will give + // 'v' again. The buffer will choose the representation that is closest to + // 'v'. If there are two at the same distance, than the one farther away + // from 0 is chosen (halfway cases - ending with 5 - are rounded up). + // In this mode the 'requested_digits' parameter is ignored. + // - SHORTEST_SINGLE: same as SHORTEST but with single-precision. + // - FIXED: produces digits necessary to print a given number with + // 'requested_digits' digits after the decimal point. The produced digits + // might be too short in which case the caller has to fill the remainder + // with '0's. + // Example: toFixed(0.001, 5) is allowed to return buffer="1", point=-2. + // Halfway cases are rounded towards +/-Infinity (away from 0). The call + // toFixed(0.15, 2) thus returns buffer="2", point=0. + // The returned buffer may contain digits that would be truncated from the + // shortest representation of the input. + // - PRECISION: produces 'requested_digits' where the first digit is not '0'. + // Even though the length of produced digits usually equals + // 'requested_digits', the function is allowed to return fewer digits, in + // which case the caller has to fill the missing digits with '0's. + // Halfway cases are again rounded away from 0. + // DoubleToAscii expects the given buffer to be big enough to hold all + // digits and a terminating null-character. In SHORTEST-mode it expects a + // buffer of at least kBase10MaximalLength + 1. In all other modes the + // requested_digits parameter and the padding-zeroes limit the size of the + // output. Don't forget the decimal point, the exponent character and the + // terminating null-character when computing the maximal output size. + // The given length is only used in debug mode to ensure the buffer is big + // enough. + // ICU PATCH: Export this as U_I18N_API for unit tests. + static void U_I18N_API DoubleToAscii(double v, + DtoaMode mode, + int requested_digits, + char* buffer, + int buffer_length, + bool* sign, + int* length, + int* point); + +#if 0 // not needed for ICU + private: + // Implementation for ToShortest and ToShortestSingle. + bool ToShortestIeeeNumber(double value, + StringBuilder* result_builder, + DtoaMode mode) const; + + // If the value is a special value (NaN or Infinity) constructs the + // corresponding string using the configured infinity/nan-symbol. + // If either of them is NULL or the value is not special then the + // function returns false. + bool HandleSpecialValues(double value, StringBuilder* result_builder) const; + // Constructs an exponential representation (i.e. 1.234e56). + // The given exponent assumes a decimal point after the first decimal digit. + void CreateExponentialRepresentation(const char* decimal_digits, + int length, + int exponent, + StringBuilder* result_builder) const; + // Creates a decimal representation (i.e 1234.5678). + void CreateDecimalRepresentation(const char* decimal_digits, + int length, + int decimal_point, + int digits_after_point, + StringBuilder* result_builder) const; + + const int flags_; + const char* const infinity_symbol_; + const char* const nan_symbol_; + const char exponent_character_; + const int decimal_in_shortest_low_; + const int decimal_in_shortest_high_; + const int max_leading_padding_zeroes_in_precision_mode_; + const int max_trailing_padding_zeroes_in_precision_mode_; + const int min_exponent_width_; +#endif // not needed for ICU + + DOUBLE_CONVERSION_DISALLOW_IMPLICIT_CONSTRUCTORS(DoubleToStringConverter); +}; + +} // namespace double_conversion + +// ICU PATCH: Close ICU namespace +U_NAMESPACE_END + +#endif // DOUBLE_CONVERSION_DOUBLE_TO_STRING_H_ +#endif // ICU PATCH: close #if !UCONFIG_NO_FORMATTING diff --git a/deps/icu-small/source/i18n/double-conversion-fast-dtoa.cpp b/deps/icu-small/source/i18n/double-conversion-fast-dtoa.cpp index 8d1499a79b4a2e..87a3d536bf111f 100644 --- a/deps/icu-small/source/i18n/double-conversion-fast-dtoa.cpp +++ b/deps/icu-small/source/i18n/double-conversion-fast-dtoa.cpp @@ -152,7 +152,7 @@ static bool RoundWeed(Vector buffer, // Conceptually rest ~= too_high - buffer // We need to do the following tests in this order to avoid over- and // underflows. - ASSERT(rest <= unsafe_interval); + DOUBLE_CONVERSION_ASSERT(rest <= unsafe_interval); while (rest < small_distance && // Negated condition 1 unsafe_interval - rest >= ten_kappa && // Negated condition 2 (rest + ten_kappa < small_distance || // buffer{-1} > w_high @@ -198,7 +198,7 @@ static bool RoundWeedCounted(Vector buffer, uint64_t ten_kappa, uint64_t unit, int* kappa) { - ASSERT(rest < ten_kappa); + DOUBLE_CONVERSION_ASSERT(rest < ten_kappa); // The following tests are done in a specific order to avoid overflows. They // will work correctly with any uint64 values of rest < ten_kappa and unit. // @@ -255,7 +255,7 @@ static void BiggestPowerTen(uint32_t number, int number_bits, uint32_t* power, int* exponent_plus_one) { - ASSERT(number < (1u << (number_bits + 1))); + DOUBLE_CONVERSION_ASSERT(number < (1u << (number_bits + 1))); // 1233/4096 is approximately 1/lg(10). int exponent_plus_one_guess = ((number_bits + 1) * 1233 >> 12); // We increment to skip over the first entry in the kPowersOf10 table. @@ -317,9 +317,9 @@ static bool DigitGen(DiyFp low, Vector buffer, int* length, int* kappa) { - ASSERT(low.e() == w.e() && w.e() == high.e()); - ASSERT(low.f() + 1 <= high.f() - 1); - ASSERT(kMinimalTargetExponent <= w.e() && w.e() <= kMaximalTargetExponent); + DOUBLE_CONVERSION_ASSERT(low.e() == w.e() && w.e() == high.e()); + DOUBLE_CONVERSION_ASSERT(low.f() + 1 <= high.f() - 1); + DOUBLE_CONVERSION_ASSERT(kMinimalTargetExponent <= w.e() && w.e() <= kMaximalTargetExponent); // low, w and high are imprecise, but by less than one ulp (unit in the last // place). // If we remove (resp. add) 1 ulp from low (resp. high) we are certain that @@ -361,7 +361,7 @@ static bool DigitGen(DiyFp low, // that is smaller than integrals. while (*kappa > 0) { int digit = integrals / divisor; - ASSERT(digit <= 9); + DOUBLE_CONVERSION_ASSERT(digit <= 9); buffer[*length] = static_cast('0' + digit); (*length)++; integrals %= divisor; @@ -388,16 +388,16 @@ static bool DigitGen(DiyFp low, // data (like the interval or 'unit'), too. // Note that the multiplication by 10 does not overflow, because w.e >= -60 // and thus one.e >= -60. - ASSERT(one.e() >= -60); - ASSERT(fractionals < one.f()); - ASSERT(UINT64_2PART_C(0xFFFFFFFF, FFFFFFFF) / 10 >= one.f()); + DOUBLE_CONVERSION_ASSERT(one.e() >= -60); + DOUBLE_CONVERSION_ASSERT(fractionals < one.f()); + DOUBLE_CONVERSION_ASSERT(DOUBLE_CONVERSION_UINT64_2PART_C(0xFFFFFFFF, FFFFFFFF) / 10 >= one.f()); for (;;) { fractionals *= 10; unit *= 10; unsafe_interval.set_f(unsafe_interval.f() * 10); // Integer division by one. int digit = static_cast(fractionals >> -one.e()); - ASSERT(digit <= 9); + DOUBLE_CONVERSION_ASSERT(digit <= 9); buffer[*length] = static_cast('0' + digit); (*length)++; fractionals &= one.f() - 1; // Modulo by one. @@ -444,9 +444,9 @@ static bool DigitGenCounted(DiyFp w, Vector buffer, int* length, int* kappa) { - ASSERT(kMinimalTargetExponent <= w.e() && w.e() <= kMaximalTargetExponent); - ASSERT(kMinimalTargetExponent >= -60); - ASSERT(kMaximalTargetExponent <= -32); + DOUBLE_CONVERSION_ASSERT(kMinimalTargetExponent <= w.e() && w.e() <= kMaximalTargetExponent); + DOUBLE_CONVERSION_ASSERT(kMinimalTargetExponent >= -60); + DOUBLE_CONVERSION_ASSERT(kMaximalTargetExponent <= -32); // w is assumed to have an error less than 1 unit. Whenever w is scaled we // also scale its error. uint64_t w_error = 1; @@ -472,7 +472,7 @@ static bool DigitGenCounted(DiyFp w, // that is smaller than 'integrals'. while (*kappa > 0) { int digit = integrals / divisor; - ASSERT(digit <= 9); + DOUBLE_CONVERSION_ASSERT(digit <= 9); buffer[*length] = static_cast('0' + digit); (*length)++; requested_digits--; @@ -498,15 +498,15 @@ static bool DigitGenCounted(DiyFp w, // data (the 'unit'), too. // Note that the multiplication by 10 does not overflow, because w.e >= -60 // and thus one.e >= -60. - ASSERT(one.e() >= -60); - ASSERT(fractionals < one.f()); - ASSERT(UINT64_2PART_C(0xFFFFFFFF, FFFFFFFF) / 10 >= one.f()); + DOUBLE_CONVERSION_ASSERT(one.e() >= -60); + DOUBLE_CONVERSION_ASSERT(fractionals < one.f()); + DOUBLE_CONVERSION_ASSERT(DOUBLE_CONVERSION_UINT64_2PART_C(0xFFFFFFFF, FFFFFFFF) / 10 >= one.f()); while (requested_digits > 0 && fractionals > w_error) { fractionals *= 10; w_error *= 10; // Integer division by one. int digit = static_cast(fractionals >> -one.e()); - ASSERT(digit <= 9); + DOUBLE_CONVERSION_ASSERT(digit <= 9); buffer[*length] = static_cast('0' + digit); (*length)++; requested_digits--; @@ -544,11 +544,11 @@ static bool Grisu3(double v, if (mode == FAST_DTOA_SHORTEST) { Double(v).NormalizedBoundaries(&boundary_minus, &boundary_plus); } else { - ASSERT(mode == FAST_DTOA_SHORTEST_SINGLE); + DOUBLE_CONVERSION_ASSERT(mode == FAST_DTOA_SHORTEST_SINGLE); float single_v = static_cast(v); Single(single_v).NormalizedBoundaries(&boundary_minus, &boundary_plus); } - ASSERT(boundary_plus.e() == w.e()); + DOUBLE_CONVERSION_ASSERT(boundary_plus.e() == w.e()); DiyFp ten_mk; // Cached power of ten: 10^-k int mk; // -k int ten_mk_minimal_binary_exponent = @@ -559,7 +559,7 @@ static bool Grisu3(double v, ten_mk_minimal_binary_exponent, ten_mk_maximal_binary_exponent, &ten_mk, &mk); - ASSERT((kMinimalTargetExponent <= w.e() + ten_mk.e() + + DOUBLE_CONVERSION_ASSERT((kMinimalTargetExponent <= w.e() + ten_mk.e() + DiyFp::kSignificandSize) && (kMaximalTargetExponent >= w.e() + ten_mk.e() + DiyFp::kSignificandSize)); @@ -573,7 +573,7 @@ static bool Grisu3(double v, // In other words: let f = scaled_w.f() and e = scaled_w.e(), then // (f-1) * 2^e < w*10^k < (f+1) * 2^e DiyFp scaled_w = DiyFp::Times(w, ten_mk); - ASSERT(scaled_w.e() == + DOUBLE_CONVERSION_ASSERT(scaled_w.e() == boundary_plus.e() + ten_mk.e() + DiyFp::kSignificandSize); // In theory it would be possible to avoid some recomputations by computing // the difference between w and boundary_minus/plus (a power of 2) and to @@ -618,7 +618,7 @@ static bool Grisu3Counted(double v, ten_mk_minimal_binary_exponent, ten_mk_maximal_binary_exponent, &ten_mk, &mk); - ASSERT((kMinimalTargetExponent <= w.e() + ten_mk.e() + + DOUBLE_CONVERSION_ASSERT((kMinimalTargetExponent <= w.e() + ten_mk.e() + DiyFp::kSignificandSize) && (kMaximalTargetExponent >= w.e() + ten_mk.e() + DiyFp::kSignificandSize)); @@ -652,8 +652,8 @@ bool FastDtoa(double v, Vector buffer, int* length, int* decimal_point) { - ASSERT(v > 0); - ASSERT(!Double(v).IsSpecial()); + DOUBLE_CONVERSION_ASSERT(v > 0); + DOUBLE_CONVERSION_ASSERT(!Double(v).IsSpecial()); bool result = false; int decimal_exponent = 0; @@ -667,7 +667,7 @@ bool FastDtoa(double v, buffer, length, &decimal_exponent); break; default: - UNREACHABLE(); + DOUBLE_CONVERSION_UNREACHABLE(); } if (result) { *decimal_point = *length + decimal_exponent; diff --git a/deps/icu-small/source/i18n/double-conversion-ieee.h b/deps/icu-small/source/i18n/double-conversion-ieee.h index c83c8d9abbb46e..f4c62a9a9f8d99 100644 --- a/deps/icu-small/source/i18n/double-conversion-ieee.h +++ b/deps/icu-small/source/i18n/double-conversion-ieee.h @@ -55,12 +55,14 @@ static float uint32_to_float(uint32_t d32) { return BitCast(d32); } // Helper functions for doubles. class Double { public: - static const uint64_t kSignMask = UINT64_2PART_C(0x80000000, 00000000); - static const uint64_t kExponentMask = UINT64_2PART_C(0x7FF00000, 00000000); - static const uint64_t kSignificandMask = UINT64_2PART_C(0x000FFFFF, FFFFFFFF); - static const uint64_t kHiddenBit = UINT64_2PART_C(0x00100000, 00000000); + static const uint64_t kSignMask = DOUBLE_CONVERSION_UINT64_2PART_C(0x80000000, 00000000); + static const uint64_t kExponentMask = DOUBLE_CONVERSION_UINT64_2PART_C(0x7FF00000, 00000000); + static const uint64_t kSignificandMask = DOUBLE_CONVERSION_UINT64_2PART_C(0x000FFFFF, FFFFFFFF); + static const uint64_t kHiddenBit = DOUBLE_CONVERSION_UINT64_2PART_C(0x00100000, 00000000); static const int kPhysicalSignificandSize = 52; // Excludes the hidden bit. static const int kSignificandSize = 53; + static const int kExponentBias = 0x3FF + kPhysicalSignificandSize; + static const int kMaxExponent = 0x7FF - kExponentBias; Double() : d64_(0) {} explicit Double(double d) : d64_(double_to_uint64(d)) {} @@ -71,14 +73,14 @@ class Double { // The value encoded by this Double must be greater or equal to +0.0. // It must not be special (infinity, or NaN). DiyFp AsDiyFp() const { - ASSERT(Sign() > 0); - ASSERT(!IsSpecial()); + DOUBLE_CONVERSION_ASSERT(Sign() > 0); + DOUBLE_CONVERSION_ASSERT(!IsSpecial()); return DiyFp(Significand(), Exponent()); } // The value encoded by this Double must be strictly greater than 0. DiyFp AsNormalizedDiyFp() const { - ASSERT(value() > 0.0); + DOUBLE_CONVERSION_ASSERT(value() > 0.0); uint64_t f = Significand(); int e = Exponent(); @@ -174,7 +176,7 @@ class Double { // Precondition: the value encoded by this Double must be greater or equal // than +0.0. DiyFp UpperBoundary() const { - ASSERT(Sign() > 0); + DOUBLE_CONVERSION_ASSERT(Sign() > 0); return DiyFp(Significand() * 2 + 1, Exponent() - 1); } @@ -183,7 +185,7 @@ class Double { // exponent as m_plus. // Precondition: the value encoded by this Double must be greater than 0. void NormalizedBoundaries(DiyFp* out_m_minus, DiyFp* out_m_plus) const { - ASSERT(value() > 0.0); + DOUBLE_CONVERSION_ASSERT(value() > 0.0); DiyFp v = this->AsDiyFp(); DiyFp m_plus = DiyFp::Normalize(DiyFp((v.f() << 1) + 1, v.e() - 1)); DiyFp m_minus; @@ -236,11 +238,9 @@ class Double { } private: - static const int kExponentBias = 0x3FF + kPhysicalSignificandSize; static const int kDenormalExponent = -kExponentBias + 1; - static const int kMaxExponent = 0x7FF - kExponentBias; - static const uint64_t kInfinity = UINT64_2PART_C(0x7FF00000, 00000000); - static const uint64_t kNaN = UINT64_2PART_C(0x7FF80000, 00000000); + static const uint64_t kInfinity = DOUBLE_CONVERSION_UINT64_2PART_C(0x7FF00000, 00000000); + static const uint64_t kNaN = DOUBLE_CONVERSION_UINT64_2PART_C(0x7FF80000, 00000000); const uint64_t d64_; @@ -271,7 +271,7 @@ class Double { (biased_exponent << kPhysicalSignificandSize); } - DC_DISALLOW_COPY_AND_ASSIGN(Double); + DOUBLE_CONVERSION_DISALLOW_COPY_AND_ASSIGN(Double); }; class Single { @@ -290,8 +290,8 @@ class Single { // The value encoded by this Single must be greater or equal to +0.0. // It must not be special (infinity, or NaN). DiyFp AsDiyFp() const { - ASSERT(Sign() > 0); - ASSERT(!IsSpecial()); + DOUBLE_CONVERSION_ASSERT(Sign() > 0); + DOUBLE_CONVERSION_ASSERT(!IsSpecial()); return DiyFp(Significand(), Exponent()); } @@ -354,7 +354,7 @@ class Single { // exponent as m_plus. // Precondition: the value encoded by this Single must be greater than 0. void NormalizedBoundaries(DiyFp* out_m_minus, DiyFp* out_m_plus) const { - ASSERT(value() > 0.0); + DOUBLE_CONVERSION_ASSERT(value() > 0.0); DiyFp v = this->AsDiyFp(); DiyFp m_plus = DiyFp::Normalize(DiyFp((v.f() << 1) + 1, v.e() - 1)); DiyFp m_minus; @@ -372,7 +372,7 @@ class Single { // Precondition: the value encoded by this Single must be greater or equal // than +0.0. DiyFp UpperBoundary() const { - ASSERT(Sign() > 0); + DOUBLE_CONVERSION_ASSERT(Sign() > 0); return DiyFp(Significand() * 2 + 1, Exponent() - 1); } @@ -408,7 +408,7 @@ class Single { const uint32_t d32_; - DC_DISALLOW_COPY_AND_ASSIGN(Single); + DOUBLE_CONVERSION_DISALLOW_COPY_AND_ASSIGN(Single); }; } // namespace double_conversion diff --git a/deps/icu-small/source/i18n/double-conversion.cpp b/deps/icu-small/source/i18n/double-conversion-string-to-double.cpp similarity index 63% rename from deps/icu-small/source/i18n/double-conversion.cpp rename to deps/icu-small/source/i18n/double-conversion-string-to-double.cpp index 1a60afbd64b6b7..946b2b26e77aa4 100644 --- a/deps/icu-small/source/i18n/double-conversion.cpp +++ b/deps/icu-small/source/i18n/double-conversion-string-to-double.cpp @@ -37,16 +37,13 @@ // ICU PATCH: Do not include std::locale. #include -//#include +// #include #include // ICU PATCH: Customize header file paths for ICU. -// The file fixed-dtoa.h is not needed. -#include "double-conversion.h" +#include "double-conversion-string-to-double.h" -#include "double-conversion-bignum-dtoa.h" -#include "double-conversion-fast-dtoa.h" #include "double-conversion-ieee.h" #include "double-conversion-strtod.h" #include "double-conversion-utils.h" @@ -56,385 +53,6 @@ U_NAMESPACE_BEGIN namespace double_conversion { -#if 0 // not needed for ICU -const DoubleToStringConverter& DoubleToStringConverter::EcmaScriptConverter() { - int flags = UNIQUE_ZERO | EMIT_POSITIVE_EXPONENT_SIGN; - static DoubleToStringConverter converter(flags, - "Infinity", - "NaN", - 'e', - -6, 21, - 6, 0); - return converter; -} - - -bool DoubleToStringConverter::HandleSpecialValues( - double value, - StringBuilder* result_builder) const { - Double double_inspect(value); - if (double_inspect.IsInfinite()) { - if (infinity_symbol_ == NULL) return false; - if (value < 0) { - result_builder->AddCharacter('-'); - } - result_builder->AddString(infinity_symbol_); - return true; - } - if (double_inspect.IsNan()) { - if (nan_symbol_ == NULL) return false; - result_builder->AddString(nan_symbol_); - return true; - } - return false; -} - - -void DoubleToStringConverter::CreateExponentialRepresentation( - const char* decimal_digits, - int length, - int exponent, - StringBuilder* result_builder) const { - ASSERT(length != 0); - result_builder->AddCharacter(decimal_digits[0]); - if (length != 1) { - result_builder->AddCharacter('.'); - result_builder->AddSubstring(&decimal_digits[1], length-1); - } - result_builder->AddCharacter(exponent_character_); - if (exponent < 0) { - result_builder->AddCharacter('-'); - exponent = -exponent; - } else { - if ((flags_ & EMIT_POSITIVE_EXPONENT_SIGN) != 0) { - result_builder->AddCharacter('+'); - } - } - if (exponent == 0) { - result_builder->AddCharacter('0'); - return; - } - ASSERT(exponent < 1e4); - const int kMaxExponentLength = 5; - char buffer[kMaxExponentLength + 1]; - buffer[kMaxExponentLength] = '\0'; - int first_char_pos = kMaxExponentLength; - while (exponent > 0) { - buffer[--first_char_pos] = '0' + (exponent % 10); - exponent /= 10; - } - result_builder->AddSubstring(&buffer[first_char_pos], - kMaxExponentLength - first_char_pos); -} - - -void DoubleToStringConverter::CreateDecimalRepresentation( - const char* decimal_digits, - int length, - int decimal_point, - int digits_after_point, - StringBuilder* result_builder) const { - // Create a representation that is padded with zeros if needed. - if (decimal_point <= 0) { - // "0.00000decimal_rep" or "0.000decimal_rep00". - result_builder->AddCharacter('0'); - if (digits_after_point > 0) { - result_builder->AddCharacter('.'); - result_builder->AddPadding('0', -decimal_point); - ASSERT(length <= digits_after_point - (-decimal_point)); - result_builder->AddSubstring(decimal_digits, length); - int remaining_digits = digits_after_point - (-decimal_point) - length; - result_builder->AddPadding('0', remaining_digits); - } - } else if (decimal_point >= length) { - // "decimal_rep0000.00000" or "decimal_rep.0000". - result_builder->AddSubstring(decimal_digits, length); - result_builder->AddPadding('0', decimal_point - length); - if (digits_after_point > 0) { - result_builder->AddCharacter('.'); - result_builder->AddPadding('0', digits_after_point); - } - } else { - // "decima.l_rep000". - ASSERT(digits_after_point > 0); - result_builder->AddSubstring(decimal_digits, decimal_point); - result_builder->AddCharacter('.'); - ASSERT(length - decimal_point <= digits_after_point); - result_builder->AddSubstring(&decimal_digits[decimal_point], - length - decimal_point); - int remaining_digits = digits_after_point - (length - decimal_point); - result_builder->AddPadding('0', remaining_digits); - } - if (digits_after_point == 0) { - if ((flags_ & EMIT_TRAILING_DECIMAL_POINT) != 0) { - result_builder->AddCharacter('.'); - } - if ((flags_ & EMIT_TRAILING_ZERO_AFTER_POINT) != 0) { - result_builder->AddCharacter('0'); - } - } -} - - -bool DoubleToStringConverter::ToShortestIeeeNumber( - double value, - StringBuilder* result_builder, - DoubleToStringConverter::DtoaMode mode) const { - ASSERT(mode == SHORTEST || mode == SHORTEST_SINGLE); - if (Double(value).IsSpecial()) { - return HandleSpecialValues(value, result_builder); - } - - int decimal_point; - bool sign; - const int kDecimalRepCapacity = kBase10MaximalLength + 1; - char decimal_rep[kDecimalRepCapacity]; - int decimal_rep_length; - - DoubleToAscii(value, mode, 0, decimal_rep, kDecimalRepCapacity, - &sign, &decimal_rep_length, &decimal_point); - - bool unique_zero = (flags_ & UNIQUE_ZERO) != 0; - if (sign && (value != 0.0 || !unique_zero)) { - result_builder->AddCharacter('-'); - } - - int exponent = decimal_point - 1; - if ((decimal_in_shortest_low_ <= exponent) && - (exponent < decimal_in_shortest_high_)) { - CreateDecimalRepresentation(decimal_rep, decimal_rep_length, - decimal_point, - Max(0, decimal_rep_length - decimal_point), - result_builder); - } else { - CreateExponentialRepresentation(decimal_rep, decimal_rep_length, exponent, - result_builder); - } - return true; -} - - -bool DoubleToStringConverter::ToFixed(double value, - int requested_digits, - StringBuilder* result_builder) const { - ASSERT(kMaxFixedDigitsBeforePoint == 60); - const double kFirstNonFixed = 1e60; - - if (Double(value).IsSpecial()) { - return HandleSpecialValues(value, result_builder); - } - - if (requested_digits > kMaxFixedDigitsAfterPoint) return false; - if (value >= kFirstNonFixed || value <= -kFirstNonFixed) return false; - - // Find a sufficiently precise decimal representation of n. - int decimal_point; - bool sign; - // Add space for the '\0' byte. - const int kDecimalRepCapacity = - kMaxFixedDigitsBeforePoint + kMaxFixedDigitsAfterPoint + 1; - char decimal_rep[kDecimalRepCapacity]; - int decimal_rep_length; - DoubleToAscii(value, FIXED, requested_digits, - decimal_rep, kDecimalRepCapacity, - &sign, &decimal_rep_length, &decimal_point); - - bool unique_zero = ((flags_ & UNIQUE_ZERO) != 0); - if (sign && (value != 0.0 || !unique_zero)) { - result_builder->AddCharacter('-'); - } - - CreateDecimalRepresentation(decimal_rep, decimal_rep_length, decimal_point, - requested_digits, result_builder); - return true; -} - - -bool DoubleToStringConverter::ToExponential( - double value, - int requested_digits, - StringBuilder* result_builder) const { - if (Double(value).IsSpecial()) { - return HandleSpecialValues(value, result_builder); - } - - if (requested_digits < -1) return false; - if (requested_digits > kMaxExponentialDigits) return false; - - int decimal_point; - bool sign; - // Add space for digit before the decimal point and the '\0' character. - const int kDecimalRepCapacity = kMaxExponentialDigits + 2; - ASSERT(kDecimalRepCapacity > kBase10MaximalLength); - char decimal_rep[kDecimalRepCapacity]; - int decimal_rep_length; - - if (requested_digits == -1) { - DoubleToAscii(value, SHORTEST, 0, - decimal_rep, kDecimalRepCapacity, - &sign, &decimal_rep_length, &decimal_point); - } else { - DoubleToAscii(value, PRECISION, requested_digits + 1, - decimal_rep, kDecimalRepCapacity, - &sign, &decimal_rep_length, &decimal_point); - ASSERT(decimal_rep_length <= requested_digits + 1); - - for (int i = decimal_rep_length; i < requested_digits + 1; ++i) { - decimal_rep[i] = '0'; - } - decimal_rep_length = requested_digits + 1; - } - - bool unique_zero = ((flags_ & UNIQUE_ZERO) != 0); - if (sign && (value != 0.0 || !unique_zero)) { - result_builder->AddCharacter('-'); - } - - int exponent = decimal_point - 1; - CreateExponentialRepresentation(decimal_rep, - decimal_rep_length, - exponent, - result_builder); - return true; -} - - -bool DoubleToStringConverter::ToPrecision(double value, - int precision, - StringBuilder* result_builder) const { - if (Double(value).IsSpecial()) { - return HandleSpecialValues(value, result_builder); - } - - if (precision < kMinPrecisionDigits || precision > kMaxPrecisionDigits) { - return false; - } - - // Find a sufficiently precise decimal representation of n. - int decimal_point; - bool sign; - // Add one for the terminating null character. - const int kDecimalRepCapacity = kMaxPrecisionDigits + 1; - char decimal_rep[kDecimalRepCapacity]; - int decimal_rep_length; - - DoubleToAscii(value, PRECISION, precision, - decimal_rep, kDecimalRepCapacity, - &sign, &decimal_rep_length, &decimal_point); - ASSERT(decimal_rep_length <= precision); - - bool unique_zero = ((flags_ & UNIQUE_ZERO) != 0); - if (sign && (value != 0.0 || !unique_zero)) { - result_builder->AddCharacter('-'); - } - - // The exponent if we print the number as x.xxeyyy. That is with the - // decimal point after the first digit. - int exponent = decimal_point - 1; - - int extra_zero = ((flags_ & EMIT_TRAILING_ZERO_AFTER_POINT) != 0) ? 1 : 0; - if ((-decimal_point + 1 > max_leading_padding_zeroes_in_precision_mode_) || - (decimal_point - precision + extra_zero > - max_trailing_padding_zeroes_in_precision_mode_)) { - // Fill buffer to contain 'precision' digits. - // Usually the buffer is already at the correct length, but 'DoubleToAscii' - // is allowed to return less characters. - for (int i = decimal_rep_length; i < precision; ++i) { - decimal_rep[i] = '0'; - } - - CreateExponentialRepresentation(decimal_rep, - precision, - exponent, - result_builder); - } else { - CreateDecimalRepresentation(decimal_rep, decimal_rep_length, decimal_point, - Max(0, precision - decimal_point), - result_builder); - } - return true; -} -#endif // not needed for ICU - - -static BignumDtoaMode DtoaToBignumDtoaMode( - DoubleToStringConverter::DtoaMode dtoa_mode) { - switch (dtoa_mode) { - case DoubleToStringConverter::SHORTEST: return BIGNUM_DTOA_SHORTEST; - case DoubleToStringConverter::SHORTEST_SINGLE: - return BIGNUM_DTOA_SHORTEST_SINGLE; - case DoubleToStringConverter::FIXED: return BIGNUM_DTOA_FIXED; - case DoubleToStringConverter::PRECISION: return BIGNUM_DTOA_PRECISION; - default: - UNREACHABLE(); - } -} - - -void DoubleToStringConverter::DoubleToAscii(double v, - DtoaMode mode, - int requested_digits, - char* buffer, - int buffer_length, - bool* sign, - int* length, - int* point) { - Vector vector(buffer, buffer_length); - ASSERT(!Double(v).IsSpecial()); - ASSERT(mode == SHORTEST || mode == SHORTEST_SINGLE || requested_digits >= 0); - - if (Double(v).Sign() < 0) { - *sign = true; - v = -v; - } else { - *sign = false; - } - - if (mode == PRECISION && requested_digits == 0) { - vector[0] = '\0'; - *length = 0; - return; - } - - if (v == 0) { - vector[0] = '0'; - vector[1] = '\0'; - *length = 1; - *point = 1; - return; - } - - bool fast_worked; - switch (mode) { - case SHORTEST: - fast_worked = FastDtoa(v, FAST_DTOA_SHORTEST, 0, vector, length, point); - break; -#if 0 // not needed for ICU - case SHORTEST_SINGLE: - fast_worked = FastDtoa(v, FAST_DTOA_SHORTEST_SINGLE, 0, - vector, length, point); - break; - case FIXED: - fast_worked = FastFixedDtoa(v, requested_digits, vector, length, point); - break; - case PRECISION: - fast_worked = FastDtoa(v, FAST_DTOA_PRECISION, requested_digits, - vector, length, point); - break; -#endif // not needed for ICU - default: - fast_worked = false; - UNREACHABLE(); - } - if (fast_worked) return; - - // If the fast dtoa didn't succeed use the slower bignum version. - BignumDtoaMode bignum_mode = DtoaToBignumDtoaMode(mode); - BignumDtoa(v, bignum_mode, requested_digits, vector, length, point); - vector[*length] = '\0'; -} - - namespace { inline char ToLower(char ch) { @@ -444,7 +62,7 @@ inline char ToLower(char ch) { return cType.tolower(ch); #else (void)ch; - UNREACHABLE(); + DOUBLE_CONVERSION_UNREACHABLE(); #endif } @@ -457,7 +75,7 @@ static inline bool ConsumeSubStringImpl(Iterator* current, Iterator end, const char* substring, Converter converter) { - ASSERT(converter(**current) == *substring); + DOUBLE_CONVERSION_ASSERT(converter(**current) == *substring); for (substring++; *substring != '\0'; substring++) { ++*current; if (*current == end || converter(**current) != *substring) { @@ -474,8 +92,8 @@ template static bool ConsumeSubString(Iterator* current, Iterator end, const char* substring, - bool allow_case_insensibility) { - if (allow_case_insensibility) { + bool allow_case_insensitivity) { + if (allow_case_insensitivity) { return ConsumeSubStringImpl(current, end, substring, ToLower); } else { return ConsumeSubStringImpl(current, end, substring, Pass); @@ -485,8 +103,8 @@ static bool ConsumeSubString(Iterator* current, // Consumes first character of the str is equal to ch inline bool ConsumeFirstCharacter(char ch, const char* str, - bool case_insensibility) { - return case_insensibility ? ToLower(ch) == str[0] : ch == str[0]; + bool case_insensitivity) { + return case_insensitivity ? ToLower(ch) == str[0] : ch == str[0]; } } // namespace @@ -501,15 +119,14 @@ const int kMaxSignificantDigits = 772; static const char kWhitespaceTable7[] = { 32, 13, 10, 9, 11, 12 }; -static const int kWhitespaceTable7Length = ARRAY_SIZE(kWhitespaceTable7); +static const int kWhitespaceTable7Length = DOUBLE_CONVERSION_ARRAY_SIZE(kWhitespaceTable7); static const uc16 kWhitespaceTable16[] = { 160, 8232, 8233, 5760, 6158, 8192, 8193, 8194, 8195, 8196, 8197, 8198, 8199, 8200, 8201, 8202, 8239, 8287, 12288, 65279 }; -static const int kWhitespaceTable16Length = ARRAY_SIZE(kWhitespaceTable16); - +static const int kWhitespaceTable16Length = DOUBLE_CONVERSION_ARRAY_SIZE(kWhitespaceTable16); static bool isWhitespace(int x) { @@ -609,7 +226,7 @@ static bool IsHexFloatString(Iterator start, Iterator end, uc16 separator, bool allow_trailing_junk) { - ASSERT(start != end); + DOUBLE_CONVERSION_ASSERT(start != end); Iterator current = start; @@ -624,8 +241,8 @@ static bool IsHexFloatString(Iterator start, saw_digit = true; if (Advance(¤t, separator, 16, end)) return false; } - if (!saw_digit) return false; // Only the '.', but no digits. } + if (!saw_digit) return false; if (*current != 'p' && *current != 'P') return false; if (Advance(¤t, separator, 16, end)) return false; if (*current == '+' || *current == '-') { @@ -654,8 +271,8 @@ static double RadixStringToIeee(Iterator* current, double junk_string_value, bool read_as_double, bool* result_is_junk) { - ASSERT(*current != end); - ASSERT(!parse_as_hex_float || + DOUBLE_CONVERSION_ASSERT(*current != end); + DOUBLE_CONVERSION_ASSERT(!parse_as_hex_float || IsHexFloatString(*current, end, separator, allow_trailing_junk)); const int kDoubleSize = Double::kSignificandSize; @@ -693,7 +310,7 @@ static double RadixStringToIeee(Iterator* current, } else if (parse_as_hex_float && **current == '.') { post_decimal = true; Advance(current, separator, radix, end); - ASSERT(*current != end); + DOUBLE_CONVERSION_ASSERT(*current != end); continue; } else if (parse_as_hex_float && (**current == 'p' || **current == 'P')) { break; @@ -728,7 +345,7 @@ static double RadixStringToIeee(Iterator* current, // Just run over the '.'. We are just trying to see whether there is // a non-zero digit somewhere. Advance(current, separator, radix, end); - ASSERT(*current != end); + DOUBLE_CONVERSION_ASSERT(*current != end); post_decimal = true; } if (!isDigit(**current, radix)) break; @@ -763,27 +380,31 @@ static double RadixStringToIeee(Iterator* current, if (Advance(current, separator, radix, end)) break; } - ASSERT(number < ((int64_t)1 << kSignificandSize)); - ASSERT(static_cast(static_cast(number)) == number); + DOUBLE_CONVERSION_ASSERT(number < ((int64_t)1 << kSignificandSize)); + DOUBLE_CONVERSION_ASSERT(static_cast(static_cast(number)) == number); *result_is_junk = false; if (parse_as_hex_float) { - ASSERT(**current == 'p' || **current == 'P'); + DOUBLE_CONVERSION_ASSERT(**current == 'p' || **current == 'P'); Advance(current, separator, radix, end); - ASSERT(*current != end); + DOUBLE_CONVERSION_ASSERT(*current != end); bool is_negative = false; if (**current == '+') { Advance(current, separator, radix, end); - ASSERT(*current != end); + DOUBLE_CONVERSION_ASSERT(*current != end); } else if (**current == '-') { is_negative = true; Advance(current, separator, radix, end); - ASSERT(*current != end); + DOUBLE_CONVERSION_ASSERT(*current != end); } int written_exponent = 0; while (IsDecimalDigitForRadix(**current, 10)) { - written_exponent = 10 * written_exponent + **current - '0'; + // No need to read exponents if they are too big. That could potentially overflow + // the `written_exponent` variable. + if (abs(written_exponent) <= 100 * Double::kMaxExponent) { + written_exponent = 10 * written_exponent + **current - '0'; + } if (Advance(current, separator, radix, end)) break; } if (is_negative) written_exponent = -written_exponent; @@ -798,7 +419,7 @@ static double RadixStringToIeee(Iterator* current, return static_cast(number); } - ASSERT(number != 0); + DOUBLE_CONVERSION_ASSERT(number != 0); double result = Double(DiyFp(number, exponent)).value(); return sign ? -result : result; } @@ -818,7 +439,7 @@ double StringToDoubleConverter::StringToIeee( const bool allow_leading_spaces = (flags_ & ALLOW_LEADING_SPACES) != 0; const bool allow_trailing_spaces = (flags_ & ALLOW_TRAILING_SPACES) != 0; const bool allow_spaces_after_sign = (flags_ & ALLOW_SPACES_AFTER_SIGN) != 0; - const bool allow_case_insensibility = (flags_ & ALLOW_CASE_INSENSIBILITY) != 0; + const bool allow_case_insensitivity = (flags_ & ALLOW_CASE_INSENSITIVITY) != 0; // To make sure that iterator dereferencing is valid the following // convention is used: @@ -868,8 +489,8 @@ double StringToDoubleConverter::StringToIeee( } if (infinity_symbol_ != NULL) { - if (ConsumeFirstCharacter(*current, infinity_symbol_, allow_case_insensibility)) { - if (!ConsumeSubString(¤t, end, infinity_symbol_, allow_case_insensibility)) { + if (ConsumeFirstCharacter(*current, infinity_symbol_, allow_case_insensitivity)) { + if (!ConsumeSubString(¤t, end, infinity_symbol_, allow_case_insensitivity)) { return junk_string_value_; } @@ -880,15 +501,15 @@ double StringToDoubleConverter::StringToIeee( return junk_string_value_; } - ASSERT(buffer_pos == 0); + DOUBLE_CONVERSION_ASSERT(buffer_pos == 0); *processed_characters_count = static_cast(current - input); return sign ? -Double::Infinity() : Double::Infinity(); } } if (nan_symbol_ != NULL) { - if (ConsumeFirstCharacter(*current, nan_symbol_, allow_case_insensibility)) { - if (!ConsumeSubString(¤t, end, nan_symbol_, allow_case_insensibility)) { + if (ConsumeFirstCharacter(*current, nan_symbol_, allow_case_insensitivity)) { + if (!ConsumeSubString(¤t, end, nan_symbol_, allow_case_insensitivity)) { return junk_string_value_; } @@ -899,7 +520,7 @@ double StringToDoubleConverter::StringToIeee( return junk_string_value_; } - ASSERT(buffer_pos == 0); + DOUBLE_CONVERSION_ASSERT(buffer_pos == 0); *processed_characters_count = static_cast(current - input); return sign ? -Double::NaN() : Double::NaN(); } @@ -919,10 +540,11 @@ double StringToDoubleConverter::StringToIeee( (*current == 'x' || *current == 'X')) { ++current; + if (current == end) return junk_string_value_; // "0x" + bool parse_as_hex_float = (flags_ & ALLOW_HEX_FLOATS) && IsHexFloatString(current, end, separator_, allow_trailing_junk); - if (current == end) return junk_string_value_; // "0x" if (!parse_as_hex_float && !isDigit(*current, 16)) { return junk_string_value_; } @@ -958,7 +580,7 @@ double StringToDoubleConverter::StringToIeee( // Copy significant digits of the integer part (if any) to the buffer. while (*current >= '0' && *current <= '9') { if (significant_digits < kMaxSignificantDigits) { - ASSERT(buffer_pos < kBufferSize); + DOUBLE_CONVERSION_ASSERT(buffer_pos < kBufferSize); buffer[buffer_pos++] = static_cast(*current); significant_digits++; // Will later check if it's an octal in the buffer. @@ -1003,7 +625,7 @@ double StringToDoubleConverter::StringToIeee( // We don't emit a '.', but adjust the exponent instead. while (*current >= '0' && *current <= '9') { if (significant_digits < kMaxSignificantDigits) { - ASSERT(buffer_pos < kBufferSize); + DOUBLE_CONVERSION_ASSERT(buffer_pos < kBufferSize); buffer[buffer_pos++] = static_cast(*current); significant_digits++; exponent--; @@ -1061,7 +683,7 @@ double StringToDoubleConverter::StringToIeee( } const int max_exponent = INT_MAX / 2; - ASSERT(-max_exponent / 2 <= exponent && exponent <= max_exponent / 2); + DOUBLE_CONVERSION_ASSERT(-max_exponent / 2 <= exponent && exponent <= max_exponent / 2); int num = 0; do { // Check overflow. @@ -1104,7 +726,7 @@ double StringToDoubleConverter::StringToIeee( junk_string_value_, read_as_double, &result_is_junk); - ASSERT(!result_is_junk); + DOUBLE_CONVERSION_ASSERT(!result_is_junk); *processed_characters_count = static_cast(current - input); return result; } @@ -1114,7 +736,7 @@ double StringToDoubleConverter::StringToIeee( exponent--; } - ASSERT(buffer_pos < kBufferSize); + DOUBLE_CONVERSION_ASSERT(buffer_pos < kBufferSize); buffer[buffer_pos] = '\0'; double converted; diff --git a/deps/icu-small/source/i18n/double-conversion-string-to-double.h b/deps/icu-small/source/i18n/double-conversion-string-to-double.h new file mode 100644 index 00000000000000..2eb0c1f8979838 --- /dev/null +++ b/deps/icu-small/source/i18n/double-conversion-string-to-double.h @@ -0,0 +1,244 @@ +// © 2018 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html +// +// From the double-conversion library. Original license: +// +// Copyright 2012 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// ICU PATCH: ifdef around UCONFIG_NO_FORMATTING +#include "unicode/utypes.h" +#if !UCONFIG_NO_FORMATTING + +#ifndef DOUBLE_CONVERSION_STRING_TO_DOUBLE_H_ +#define DOUBLE_CONVERSION_STRING_TO_DOUBLE_H_ + +// ICU PATCH: Customize header file paths for ICU. + +#include "double-conversion-utils.h" + +// ICU PATCH: Wrap in ICU namespace +U_NAMESPACE_BEGIN + +namespace double_conversion { + +class StringToDoubleConverter { + public: + // Enumeration for allowing octals and ignoring junk when converting + // strings to numbers. + enum Flags { + NO_FLAGS = 0, + ALLOW_HEX = 1, + ALLOW_OCTALS = 2, + ALLOW_TRAILING_JUNK = 4, + ALLOW_LEADING_SPACES = 8, + ALLOW_TRAILING_SPACES = 16, + ALLOW_SPACES_AFTER_SIGN = 32, + ALLOW_CASE_INSENSITIVITY = 64, + ALLOW_CASE_INSENSIBILITY = 64, // Deprecated + ALLOW_HEX_FLOATS = 128, + }; + + static const uc16 kNoSeparator = '\0'; + + // Flags should be a bit-or combination of the possible Flags-enum. + // - NO_FLAGS: no special flags. + // - ALLOW_HEX: recognizes the prefix "0x". Hex numbers may only be integers. + // Ex: StringToDouble("0x1234") -> 4660.0 + // In StringToDouble("0x1234.56") the characters ".56" are trailing + // junk. The result of the call is hence dependent on + // the ALLOW_TRAILING_JUNK flag and/or the junk value. + // With this flag "0x" is a junk-string. Even with ALLOW_TRAILING_JUNK, + // the string will not be parsed as "0" followed by junk. + // + // - ALLOW_OCTALS: recognizes the prefix "0" for octals: + // If a sequence of octal digits starts with '0', then the number is + // read as octal integer. Octal numbers may only be integers. + // Ex: StringToDouble("01234") -> 668.0 + // StringToDouble("012349") -> 12349.0 // Not a sequence of octal + // // digits. + // In StringToDouble("01234.56") the characters ".56" are trailing + // junk. The result of the call is hence dependent on + // the ALLOW_TRAILING_JUNK flag and/or the junk value. + // In StringToDouble("01234e56") the characters "e56" are trailing + // junk, too. + // - ALLOW_TRAILING_JUNK: ignore trailing characters that are not part of + // a double literal. + // - ALLOW_LEADING_SPACES: skip over leading whitespace, including spaces, + // new-lines, and tabs. + // - ALLOW_TRAILING_SPACES: ignore trailing whitespace. + // - ALLOW_SPACES_AFTER_SIGN: ignore whitespace after the sign. + // Ex: StringToDouble("- 123.2") -> -123.2. + // StringToDouble("+ 123.2") -> 123.2 + // - ALLOW_CASE_INSENSITIVITY: ignore case of characters for special values: + // infinity and nan. + // - ALLOW_HEX_FLOATS: allows hexadecimal float literals. + // This *must* start with "0x" and separate the exponent with "p". + // Examples: 0x1.2p3 == 9.0 + // 0x10.1p0 == 16.0625 + // ALLOW_HEX and ALLOW_HEX_FLOATS are indendent. + // + // empty_string_value is returned when an empty string is given as input. + // If ALLOW_LEADING_SPACES or ALLOW_TRAILING_SPACES are set, then a string + // containing only spaces is converted to the 'empty_string_value', too. + // + // junk_string_value is returned when + // a) ALLOW_TRAILING_JUNK is not set, and a junk character (a character not + // part of a double-literal) is found. + // b) ALLOW_TRAILING_JUNK is set, but the string does not start with a + // double literal. + // + // infinity_symbol and nan_symbol are strings that are used to detect + // inputs that represent infinity and NaN. They can be null, in which case + // they are ignored. + // The conversion routine first reads any possible signs. Then it compares the + // following character of the input-string with the first character of + // the infinity, and nan-symbol. If either matches, the function assumes, that + // a match has been found, and expects the following input characters to match + // the remaining characters of the special-value symbol. + // This means that the following restrictions apply to special-value symbols: + // - they must not start with signs ('+', or '-'), + // - they must not have the same first character. + // - they must not start with digits. + // + // If the separator character is not kNoSeparator, then that specific + // character is ignored when in between two valid digits of the significant. + // It is not allowed to appear in the exponent. + // It is not allowed to lead or trail the number. + // It is not allowed to appear twice next to each other. + // + // Examples: + // flags = ALLOW_HEX | ALLOW_TRAILING_JUNK, + // empty_string_value = 0.0, + // junk_string_value = NaN, + // infinity_symbol = "infinity", + // nan_symbol = "nan": + // StringToDouble("0x1234") -> 4660.0. + // StringToDouble("0x1234K") -> 4660.0. + // StringToDouble("") -> 0.0 // empty_string_value. + // StringToDouble(" ") -> NaN // junk_string_value. + // StringToDouble(" 1") -> NaN // junk_string_value. + // StringToDouble("0x") -> NaN // junk_string_value. + // StringToDouble("-123.45") -> -123.45. + // StringToDouble("--123.45") -> NaN // junk_string_value. + // StringToDouble("123e45") -> 123e45. + // StringToDouble("123E45") -> 123e45. + // StringToDouble("123e+45") -> 123e45. + // StringToDouble("123E-45") -> 123e-45. + // StringToDouble("123e") -> 123.0 // trailing junk ignored. + // StringToDouble("123e-") -> 123.0 // trailing junk ignored. + // StringToDouble("+NaN") -> NaN // NaN string literal. + // StringToDouble("-infinity") -> -inf. // infinity literal. + // StringToDouble("Infinity") -> NaN // junk_string_value. + // + // flags = ALLOW_OCTAL | ALLOW_LEADING_SPACES, + // empty_string_value = 0.0, + // junk_string_value = NaN, + // infinity_symbol = NULL, + // nan_symbol = NULL: + // StringToDouble("0x1234") -> NaN // junk_string_value. + // StringToDouble("01234") -> 668.0. + // StringToDouble("") -> 0.0 // empty_string_value. + // StringToDouble(" ") -> 0.0 // empty_string_value. + // StringToDouble(" 1") -> 1.0 + // StringToDouble("0x") -> NaN // junk_string_value. + // StringToDouble("0123e45") -> NaN // junk_string_value. + // StringToDouble("01239E45") -> 1239e45. + // StringToDouble("-infinity") -> NaN // junk_string_value. + // StringToDouble("NaN") -> NaN // junk_string_value. + // + // flags = NO_FLAGS, + // separator = ' ': + // StringToDouble("1 2 3 4") -> 1234.0 + // StringToDouble("1 2") -> NaN // junk_string_value + // StringToDouble("1 000 000.0") -> 1000000.0 + // StringToDouble("1.000 000") -> 1.0 + // StringToDouble("1.0e1 000") -> NaN // junk_string_value + StringToDoubleConverter(int flags, + double empty_string_value, + double junk_string_value, + const char* infinity_symbol, + const char* nan_symbol, + uc16 separator = kNoSeparator) + : flags_(flags), + empty_string_value_(empty_string_value), + junk_string_value_(junk_string_value), + infinity_symbol_(infinity_symbol), + nan_symbol_(nan_symbol), + separator_(separator) { + } + + // Performs the conversion. + // The output parameter 'processed_characters_count' is set to the number + // of characters that have been processed to read the number. + // Spaces than are processed with ALLOW_{LEADING|TRAILING}_SPACES are included + // in the 'processed_characters_count'. Trailing junk is never included. + double StringToDouble(const char* buffer, + int length, + int* processed_characters_count) const; + + // Same as StringToDouble above but for 16 bit characters. + double StringToDouble(const uc16* buffer, + int length, + int* processed_characters_count) const; + + // Same as StringToDouble but reads a float. + // Note that this is not equivalent to static_cast(StringToDouble(...)) + // due to potential double-rounding. + float StringToFloat(const char* buffer, + int length, + int* processed_characters_count) const; + + // Same as StringToFloat above but for 16 bit characters. + float StringToFloat(const uc16* buffer, + int length, + int* processed_characters_count) const; + + private: + const int flags_; + const double empty_string_value_; + const double junk_string_value_; + const char* const infinity_symbol_; + const char* const nan_symbol_; + const uc16 separator_; + + template + double StringToIeee(Iterator start_pointer, + int length, + bool read_as_double, + int* processed_characters_count) const; + + DOUBLE_CONVERSION_DISALLOW_IMPLICIT_CONSTRUCTORS(StringToDoubleConverter); +}; + +} // namespace double_conversion + +// ICU PATCH: Close ICU namespace +U_NAMESPACE_END + +#endif // DOUBLE_CONVERSION_STRING_TO_DOUBLE_H_ +#endif // ICU PATCH: close #if !UCONFIG_NO_FORMATTING diff --git a/deps/icu-small/source/i18n/double-conversion-strtod.cpp b/deps/icu-small/source/i18n/double-conversion-strtod.cpp index be9b0b3bce0e76..9cf4854426756c 100644 --- a/deps/icu-small/source/i18n/double-conversion-strtod.cpp +++ b/deps/icu-small/source/i18n/double-conversion-strtod.cpp @@ -34,16 +34,15 @@ #include "unicode/utypes.h" #if !UCONFIG_NO_FORMATTING -#include -#include +#include +#include // ICU PATCH: Customize header file paths for ICU. -// The file fixed-dtoa.h is not needed. -#include "double-conversion-strtod.h" #include "double-conversion-bignum.h" #include "double-conversion-cached-powers.h" #include "double-conversion-ieee.h" +#include "double-conversion-strtod.h" // ICU PATCH: Wrap in ICU namespace U_NAMESPACE_BEGIN @@ -67,7 +66,7 @@ static const int kMaxDecimalPower = 309; static const int kMinDecimalPower = -324; // 2^64 = 18446744073709551616 -static const uint64_t kMaxUint64 = UINT64_2PART_C(0xFFFFFFFF, FFFFFFFF); +static const uint64_t kMaxUint64 = DOUBLE_CONVERSION_UINT64_2PART_C(0xFFFFFFFF, FFFFFFFF); static const double exact_powers_of_ten[] = { @@ -96,7 +95,7 @@ static const double exact_powers_of_ten[] = { // 10^22 = 0x21e19e0c9bab2400000 = 0x878678326eac9 * 2^22 10000000000000000000000.0 }; -static const int kExactPowersOfTenSize = ARRAY_SIZE(exact_powers_of_ten); +static const int kExactPowersOfTenSize = DOUBLE_CONVERSION_ARRAY_SIZE(exact_powers_of_ten); // Maximum number of significant digits in the decimal representation. // In fact the value is 772 (see conversions.cc), but to give us some margin @@ -132,7 +131,7 @@ static void CutToMaxSignificantDigits(Vector buffer, } // The input buffer has been trimmed. Therefore the last digit must be // different from '0'. - ASSERT(buffer[buffer.length() - 1] != '0'); + DOUBLE_CONVERSION_ASSERT(buffer[buffer.length() - 1] != '0'); // Set the last digit to be non-zero. This is sufficient to guarantee // correct rounding. significant_buffer[kMaxSignificantDecimalDigits - 1] = '1'; @@ -153,7 +152,7 @@ static void TrimAndCut(Vector buffer, int exponent, exponent += left_trimmed.length() - right_trimmed.length(); if (right_trimmed.length() > kMaxSignificantDecimalDigits) { (void) space_size; // Mark variable as used. - ASSERT(space_size >= kMaxSignificantDecimalDigits); + DOUBLE_CONVERSION_ASSERT(space_size >= kMaxSignificantDecimalDigits); CutToMaxSignificantDigits(right_trimmed, exponent, buffer_copy_space, updated_exponent); *trimmed = Vector(buffer_copy_space, @@ -176,7 +175,7 @@ static uint64_t ReadUint64(Vector buffer, int i = 0; while (i < buffer.length() && result <= (kMaxUint64 / 10 - 1)) { int digit = buffer[i++] - '0'; - ASSERT(0 <= digit && digit <= 9); + DOUBLE_CONVERSION_ASSERT(0 <= digit && digit <= 9); result = 10 * result + digit; } *number_of_read_digits = i; @@ -220,7 +219,7 @@ static bool DoubleStrtod(Vector trimmed, // Note that the ARM simulator is compiled for 32bits. It therefore exhibits // the same problem. return false; -#endif +#else if (trimmed.length() <= kMaxExactDoubleIntegerDecimalDigits) { int read_digits; // The trimmed input fits into a double. @@ -232,14 +231,14 @@ static bool DoubleStrtod(Vector trimmed, if (exponent < 0 && -exponent < kExactPowersOfTenSize) { // 10^-exponent fits into a double. *result = static_cast(ReadUint64(trimmed, &read_digits)); - ASSERT(read_digits == trimmed.length()); + DOUBLE_CONVERSION_ASSERT(read_digits == trimmed.length()); *result /= exact_powers_of_ten[-exponent]; return true; } if (0 <= exponent && exponent < kExactPowersOfTenSize) { // 10^exponent fits into a double. *result = static_cast(ReadUint64(trimmed, &read_digits)); - ASSERT(read_digits == trimmed.length()); + DOUBLE_CONVERSION_ASSERT(read_digits == trimmed.length()); *result *= exact_powers_of_ten[exponent]; return true; } @@ -251,34 +250,35 @@ static bool DoubleStrtod(Vector trimmed, // 10^remaining_digits. As a result the remaining exponent now fits // into a double too. *result = static_cast(ReadUint64(trimmed, &read_digits)); - ASSERT(read_digits == trimmed.length()); + DOUBLE_CONVERSION_ASSERT(read_digits == trimmed.length()); *result *= exact_powers_of_ten[remaining_digits]; *result *= exact_powers_of_ten[exponent - remaining_digits]; return true; } } return false; +#endif } // Returns 10^exponent as an exact DiyFp. // The given exponent must be in the range [1; kDecimalExponentDistance[. static DiyFp AdjustmentPowerOfTen(int exponent) { - ASSERT(0 < exponent); - ASSERT(exponent < PowersOfTenCache::kDecimalExponentDistance); + DOUBLE_CONVERSION_ASSERT(0 < exponent); + DOUBLE_CONVERSION_ASSERT(exponent < PowersOfTenCache::kDecimalExponentDistance); // Simply hardcode the remaining powers for the given decimal exponent // distance. - ASSERT(PowersOfTenCache::kDecimalExponentDistance == 8); + DOUBLE_CONVERSION_ASSERT(PowersOfTenCache::kDecimalExponentDistance == 8); switch (exponent) { - case 1: return DiyFp(UINT64_2PART_C(0xa0000000, 00000000), -60); - case 2: return DiyFp(UINT64_2PART_C(0xc8000000, 00000000), -57); - case 3: return DiyFp(UINT64_2PART_C(0xfa000000, 00000000), -54); - case 4: return DiyFp(UINT64_2PART_C(0x9c400000, 00000000), -50); - case 5: return DiyFp(UINT64_2PART_C(0xc3500000, 00000000), -47); - case 6: return DiyFp(UINT64_2PART_C(0xf4240000, 00000000), -44); - case 7: return DiyFp(UINT64_2PART_C(0x98968000, 00000000), -40); + case 1: return DiyFp(DOUBLE_CONVERSION_UINT64_2PART_C(0xa0000000, 00000000), -60); + case 2: return DiyFp(DOUBLE_CONVERSION_UINT64_2PART_C(0xc8000000, 00000000), -57); + case 3: return DiyFp(DOUBLE_CONVERSION_UINT64_2PART_C(0xfa000000, 00000000), -54); + case 4: return DiyFp(DOUBLE_CONVERSION_UINT64_2PART_C(0x9c400000, 00000000), -50); + case 5: return DiyFp(DOUBLE_CONVERSION_UINT64_2PART_C(0xc3500000, 00000000), -47); + case 6: return DiyFp(DOUBLE_CONVERSION_UINT64_2PART_C(0xf4240000, 00000000), -44); + case 7: return DiyFp(DOUBLE_CONVERSION_UINT64_2PART_C(0x98968000, 00000000), -40); default: - UNREACHABLE(); + DOUBLE_CONVERSION_UNREACHABLE(); } } @@ -307,7 +307,7 @@ static bool DiyFpStrtod(Vector buffer, input.Normalize(); error <<= old_e - input.e(); - ASSERT(exponent <= PowersOfTenCache::kMaxDecimalExponent); + DOUBLE_CONVERSION_ASSERT(exponent <= PowersOfTenCache::kMaxDecimalExponent); if (exponent < PowersOfTenCache::kMinDecimalExponent) { *result = 0.0; return true; @@ -325,7 +325,7 @@ static bool DiyFpStrtod(Vector buffer, if (kMaxUint64DecimalDigits - buffer.length() >= adjustment_exponent) { // The product of input with the adjustment power fits into a 64 bit // integer. - ASSERT(DiyFp::kSignificandSize == 64); + DOUBLE_CONVERSION_ASSERT(DiyFp::kSignificandSize == 64); } else { // The adjustment power is exact. There is hence only an error of 0.5. error += kDenominator / 2; @@ -367,8 +367,8 @@ static bool DiyFpStrtod(Vector buffer, precision_digits_count -= shift_amount; } // We use uint64_ts now. This only works if the DiyFp uses uint64_ts too. - ASSERT(DiyFp::kSignificandSize == 64); - ASSERT(precision_digits_count < 64); + DOUBLE_CONVERSION_ASSERT(DiyFp::kSignificandSize == 64); + DOUBLE_CONVERSION_ASSERT(precision_digits_count < 64); uint64_t one64 = 1; uint64_t precision_bits_mask = (one64 << precision_digits_count) - 1; uint64_t precision_bits = input.f() & precision_bits_mask; @@ -407,14 +407,14 @@ static bool DiyFpStrtod(Vector buffer, static int CompareBufferWithDiyFp(Vector buffer, int exponent, DiyFp diy_fp) { - ASSERT(buffer.length() + exponent <= kMaxDecimalPower + 1); - ASSERT(buffer.length() + exponent > kMinDecimalPower); - ASSERT(buffer.length() <= kMaxSignificantDecimalDigits); + DOUBLE_CONVERSION_ASSERT(buffer.length() + exponent <= kMaxDecimalPower + 1); + DOUBLE_CONVERSION_ASSERT(buffer.length() + exponent > kMinDecimalPower); + DOUBLE_CONVERSION_ASSERT(buffer.length() <= kMaxSignificantDecimalDigits); // Make sure that the Bignum will be able to hold all our numbers. // Our Bignum implementation has a separate field for exponents. Shifts will // consume at most one bigit (< 64 bits). // ln(10) == 3.3219... - ASSERT(((kMaxDecimalPower + 1) * 333 / 100) < Bignum::kMaxSignificantBits); + DOUBLE_CONVERSION_ASSERT(((kMaxDecimalPower + 1) * 333 / 100) < Bignum::kMaxSignificantBits); Bignum buffer_bignum; Bignum diy_fp_bignum; buffer_bignum.AssignDecimalString(buffer); @@ -460,18 +460,33 @@ static bool ComputeGuess(Vector trimmed, int exponent, return false; } -double Strtod(Vector buffer, int exponent) { - char copy_buffer[kMaxSignificantDecimalDigits]; - Vector trimmed; - int updated_exponent; - TrimAndCut(buffer, exponent, copy_buffer, kMaxSignificantDecimalDigits, - &trimmed, &updated_exponent); - exponent = updated_exponent; +#if U_DEBUG // needed for ICU only in debug mode +static bool IsDigit(const char d) { + return ('0' <= d) && (d <= '9'); +} - double guess; - bool is_correct = ComputeGuess(trimmed, exponent, &guess); - if (is_correct) return guess; +static bool IsNonZeroDigit(const char d) { + return ('1' <= d) && (d <= '9'); +} + +static bool AssertTrimmedDigits(const Vector& buffer) { + for(int i = 0; i < buffer.length(); ++i) { + if(!IsDigit(buffer[i])) { + return false; + } + } + return (buffer.length() == 0) || (IsNonZeroDigit(buffer[0]) && IsNonZeroDigit(buffer[buffer.length()-1])); +} +#endif // needed for ICU only in debug mode +double StrtodTrimmed(Vector trimmed, int exponent) { + DOUBLE_CONVERSION_ASSERT(trimmed.length() <= kMaxSignificantDecimalDigits); + DOUBLE_CONVERSION_ASSERT(AssertTrimmedDigits(trimmed)); + double guess; + const bool is_correct = ComputeGuess(trimmed, exponent, &guess); + if (is_correct) { + return guess; + } DiyFp upper_boundary = Double(guess).UpperBoundary(); int comparison = CompareBufferWithDiyFp(trimmed, exponent, upper_boundary); if (comparison < 0) { @@ -486,6 +501,39 @@ double Strtod(Vector buffer, int exponent) { } } +double Strtod(Vector buffer, int exponent) { + char copy_buffer[kMaxSignificantDecimalDigits]; + Vector trimmed; + int updated_exponent; + TrimAndCut(buffer, exponent, copy_buffer, kMaxSignificantDecimalDigits, + &trimmed, &updated_exponent); + return StrtodTrimmed(trimmed, updated_exponent); +} + +static float SanitizedDoubletof(double d) { + DOUBLE_CONVERSION_ASSERT(d >= 0.0); + // ASAN has a sanitize check that disallows casting doubles to floats if + // they are too big. + // https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html#available-checks + // The behavior should be covered by IEEE 754, but some projects use this + // flag, so work around it. + float max_finite = 3.4028234663852885981170418348451692544e+38; + // The half-way point between the max-finite and infinity value. + // Since infinity has an even significand everything equal or greater than + // this value should become infinity. + double half_max_finite_infinity = + 3.40282356779733661637539395458142568448e+38; + if (d >= max_finite) { + if (d >= half_max_finite_infinity) { + return Single::Infinity(); + } else { + return max_finite; + } + } else { + return static_cast(d); + } +} + float Strtof(Vector buffer, int exponent) { char copy_buffer[kMaxSignificantDecimalDigits]; Vector trimmed; @@ -497,7 +545,7 @@ float Strtof(Vector buffer, int exponent) { double double_guess; bool is_correct = ComputeGuess(trimmed, exponent, &double_guess); - float float_guess = static_cast(double_guess); + float float_guess = SanitizedDoubletof(double_guess); if (float_guess == double_guess) { // This shortcut triggers for integer values. return float_guess; @@ -520,18 +568,18 @@ float Strtof(Vector buffer, int exponent) { double double_next = Double(double_guess).NextDouble(); double double_previous = Double(double_guess).PreviousDouble(); - float f1 = static_cast(double_previous); + float f1 = SanitizedDoubletof(double_previous); float f2 = float_guess; - float f3 = static_cast(double_next); + float f3 = SanitizedDoubletof(double_next); float f4; if (is_correct) { f4 = f3; } else { double double_next2 = Double(double_next).NextDouble(); - f4 = static_cast(double_next2); + f4 = SanitizedDoubletof(double_next2); } (void) f2; // Mark variable as used. - ASSERT(f1 <= f2 && f2 <= f3 && f3 <= f4); + DOUBLE_CONVERSION_ASSERT(f1 <= f2 && f2 <= f3 && f3 <= f4); // If the guess doesn't lie near a single-precision boundary we can simply // return its float-value. @@ -539,11 +587,11 @@ float Strtof(Vector buffer, int exponent) { return float_guess; } - ASSERT((f1 != f2 && f2 == f3 && f3 == f4) || + DOUBLE_CONVERSION_ASSERT((f1 != f2 && f2 == f3 && f3 == f4) || (f1 == f2 && f2 != f3 && f3 == f4) || (f1 == f2 && f2 == f3 && f3 != f4)); - // guess and next are the two possible canditates (in the same way that + // guess and next are the two possible candidates (in the same way that // double_guess was the lower candidate for a double-precision guess). float guess = f1; float next = f4; diff --git a/deps/icu-small/source/i18n/double-conversion-strtod.h b/deps/icu-small/source/i18n/double-conversion-strtod.h index e2d6d3c2fe5d7d..50ef746401a908 100644 --- a/deps/icu-small/source/i18n/double-conversion-strtod.h +++ b/deps/icu-small/source/i18n/double-conversion-strtod.h @@ -54,6 +54,11 @@ double Strtod(Vector buffer, int exponent); // contain a dot or a sign. It must not start with '0', and must not be empty. float Strtof(Vector buffer, int exponent); +// For special use cases, the heart of the Strtod() function is also available +// separately, it assumes that 'trimmed' is as produced by TrimAndCut(), i.e. +// no leading or trailing zeros, also no lone zero, and not 'too many' digits. +double StrtodTrimmed(Vector trimmed, int exponent); + } // namespace double_conversion // ICU PATCH: Close ICU namespace diff --git a/deps/icu-small/source/i18n/double-conversion-utils.h b/deps/icu-small/source/i18n/double-conversion-utils.h index 1e44fcaa0e398d..099298460c63d9 100644 --- a/deps/icu-small/source/i18n/double-conversion-utils.h +++ b/deps/icu-small/source/i18n/double-conversion-utils.h @@ -42,10 +42,12 @@ // ICU PATCH: Use U_ASSERT instead of #include "uassert.h" -#define ASSERT U_ASSERT - -#ifndef UNIMPLEMENTED -#define UNIMPLEMENTED() (abort()) +#ifndef DOUBLE_CONVERSION_ASSERT +#define DOUBLE_CONVERSION_ASSERT(condition) \ + U_ASSERT(condition); +#endif +#ifndef DOUBLE_CONVERSION_UNIMPLEMENTED +#define DOUBLE_CONVERSION_UNIMPLEMENTED() (abort()) #endif #ifndef DOUBLE_CONVERSION_NO_RETURN #ifdef _MSC_VER @@ -54,16 +56,23 @@ #define DOUBLE_CONVERSION_NO_RETURN __attribute__((noreturn)) #endif #endif -#ifndef UNREACHABLE +#ifndef DOUBLE_CONVERSION_UNREACHABLE #ifdef _MSC_VER void DOUBLE_CONVERSION_NO_RETURN abort_noreturn(); inline void abort_noreturn() { abort(); } -#define UNREACHABLE() (abort_noreturn()) +#define DOUBLE_CONVERSION_UNREACHABLE() (abort_noreturn()) #else -#define UNREACHABLE() (abort()) +#define DOUBLE_CONVERSION_UNREACHABLE() (abort()) #endif #endif +#ifndef DOUBLE_CONVERSION_UNUSED +#ifdef __GNUC__ +#define DOUBLE_CONVERSION_UNUSED __attribute__((unused)) +#else +#define DOUBLE_CONVERSION_UNUSED +#endif +#endif // Double operations detection based on target architecture. // Linux uses a 80bit wide floating point stack on x86. This induces double @@ -99,9 +108,9 @@ int main(int argc, char** argv) { defined(_POWER) || defined(_ARCH_PPC) || defined(_ARCH_PPC64) || \ defined(__sparc__) || defined(__sparc) || defined(__s390__) || \ defined(__SH4__) || defined(__alpha__) || \ - defined(_MIPS_ARCH_MIPS32R2) || \ + defined(_MIPS_ARCH_MIPS32R2) || defined(__ARMEB__) ||\ defined(__AARCH64EL__) || defined(__aarch64__) || defined(__AARCH64EB__) || \ - defined(__riscv) || \ + defined(__riscv) || defined(__e2k__) || \ defined(__or1k__) || defined(__arc__) || \ defined(__EMSCRIPTEN__) #define DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS 1 @@ -141,24 +150,24 @@ typedef uint16_t uc16; // The following macro works on both 32 and 64-bit platforms. // Usage: instead of writing 0x1234567890123456 -// write UINT64_2PART_C(0x12345678,90123456); -#define UINT64_2PART_C(a, b) (((static_cast(a) << 32) + 0x##b##u)) +// write DOUBLE_CONVERSION_UINT64_2PART_C(0x12345678,90123456); +#define DOUBLE_CONVERSION_UINT64_2PART_C(a, b) (((static_cast(a) << 32) + 0x##b##u)) -// The expression ARRAY_SIZE(a) is a compile-time constant of type +// The expression DOUBLE_CONVERSION_ARRAY_SIZE(a) is a compile-time constant of type // size_t which represents the number of elements of the given -// array. You should only use ARRAY_SIZE on statically allocated +// array. You should only use DOUBLE_CONVERSION_ARRAY_SIZE on statically allocated // arrays. -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(a) \ +#ifndef DOUBLE_CONVERSION_ARRAY_SIZE +#define DOUBLE_CONVERSION_ARRAY_SIZE(a) \ ((sizeof(a) / sizeof(*(a))) / \ static_cast(!(sizeof(a) % sizeof(*(a))))) #endif // A macro to disallow the evil copy constructor and operator= functions // This should be used in the private: declarations for a class -#ifndef DC_DISALLOW_COPY_AND_ASSIGN -#define DC_DISALLOW_COPY_AND_ASSIGN(TypeName) \ +#ifndef DOUBLE_CONVERSION_DISALLOW_COPY_AND_ASSIGN +#define DOUBLE_CONVERSION_DISALLOW_COPY_AND_ASSIGN(TypeName) \ TypeName(const TypeName&); \ void operator=(const TypeName&) #endif @@ -169,10 +178,10 @@ typedef uint16_t uc16; // This should be used in the private: declarations for a class // that wants to prevent anyone from instantiating it. This is // especially useful for classes containing only static methods. -#ifndef DC_DISALLOW_IMPLICIT_CONSTRUCTORS -#define DC_DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \ +#ifndef DOUBLE_CONVERSION_DISALLOW_IMPLICIT_CONSTRUCTORS +#define DOUBLE_CONVERSION_DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \ TypeName(); \ - DC_DISALLOW_COPY_AND_ASSIGN(TypeName) + DOUBLE_CONVERSION_DISALLOW_COPY_AND_ASSIGN(TypeName) #endif // ICU PATCH: Wrap in ICU namespace @@ -180,25 +189,9 @@ U_NAMESPACE_BEGIN namespace double_conversion { -static const int kCharSize = sizeof(char); - -// Returns the maximum of the two parameters. -template -static T Max(T a, T b) { - return a < b ? b : a; -} - - -// Returns the minimum of the two parameters. -template -static T Min(T a, T b) { - return a < b ? a : b; -} - - inline int StrLength(const char* string) { size_t length = strlen(string); - ASSERT(length == static_cast(static_cast(length))); + DOUBLE_CONVERSION_ASSERT(length == static_cast(static_cast(length))); return static_cast(length); } @@ -208,15 +201,15 @@ class Vector { public: Vector() : start_(NULL), length_(0) {} Vector(T* data, int len) : start_(data), length_(len) { - ASSERT(len == 0 || (len > 0 && data != NULL)); + DOUBLE_CONVERSION_ASSERT(len == 0 || (len > 0 && data != NULL)); } // Returns a vector using the same backing storage as this one, // spanning from and including 'from', to but not including 'to'. Vector SubVector(int from, int to) { - ASSERT(to <= length_); - ASSERT(from < to); - ASSERT(0 <= from); + DOUBLE_CONVERSION_ASSERT(to <= length_); + DOUBLE_CONVERSION_ASSERT(from < to); + DOUBLE_CONVERSION_ASSERT(0 <= from); return Vector(start() + from, to - from); } @@ -231,7 +224,7 @@ class Vector { // Access individual vector elements - checks bounds in debug mode. T& operator[](int index) const { - ASSERT(0 <= index && index < length_); + DOUBLE_CONVERSION_ASSERT(0 <= index && index < length_); return start_[index]; } @@ -239,6 +232,11 @@ class Vector { T& last() { return start_[length_ - 1]; } + void pop_back() { + DOUBLE_CONVERSION_ASSERT(!is_empty()); + --length_; + } + private: T* start_; int length_; @@ -259,7 +257,7 @@ class StringBuilder { // Get the current position in the builder. int position() const { - ASSERT(!is_finalized()); + DOUBLE_CONVERSION_ASSERT(!is_finalized()); return position_; } @@ -270,8 +268,8 @@ class StringBuilder { // 0-characters; use the Finalize() method to terminate the string // instead. void AddCharacter(char c) { - ASSERT(c != '\0'); - ASSERT(!is_finalized() && position_ < buffer_.length()); + DOUBLE_CONVERSION_ASSERT(c != '\0'); + DOUBLE_CONVERSION_ASSERT(!is_finalized() && position_ < buffer_.length()); buffer_[position_++] = c; } @@ -284,9 +282,9 @@ class StringBuilder { // Add the first 'n' characters of the given string 's' to the // builder. The input string must have enough characters. void AddSubstring(const char* s, int n) { - ASSERT(!is_finalized() && position_ + n < buffer_.length()); - ASSERT(static_cast(n) <= strlen(s)); - memmove(&buffer_[position_], s, n * kCharSize); + DOUBLE_CONVERSION_ASSERT(!is_finalized() && position_ + n < buffer_.length()); + DOUBLE_CONVERSION_ASSERT(static_cast(n) <= strlen(s)); + memmove(&buffer_[position_], s, n); position_ += n; } @@ -301,13 +299,13 @@ class StringBuilder { // Finalize the string by 0-terminating it and returning the buffer. char* Finalize() { - ASSERT(!is_finalized() && position_ < buffer_.length()); + DOUBLE_CONVERSION_ASSERT(!is_finalized() && position_ < buffer_.length()); buffer_[position_] = '\0'; // Make sure nobody managed to add a 0-character to the // buffer while building the string. - ASSERT(strlen(buffer_.start()) == static_cast(position_)); + DOUBLE_CONVERSION_ASSERT(strlen(buffer_.start()) == static_cast(position_)); position_ = -1; - ASSERT(is_finalized()); + DOUBLE_CONVERSION_ASSERT(is_finalized()); return buffer_.start(); } @@ -317,7 +315,7 @@ class StringBuilder { bool is_finalized() const { return position_ < 0; } - DC_DISALLOW_IMPLICIT_CONSTRUCTORS(StringBuilder); + DOUBLE_CONVERSION_DISALLOW_IMPLICIT_CONSTRUCTORS(StringBuilder); }; // The type-based aliasing rule allows the compiler to assume that pointers of @@ -345,13 +343,14 @@ class StringBuilder { // enough that it can no longer see that you have cast one pointer type to // another thus avoiding the warning. template -inline Dest BitCast(const Source& source) { +Dest BitCast(const Source& source) { // Compile time assertion: sizeof(Dest) == sizeof(Source) // A compile error here means your Dest and Source have different sizes. #if __cplusplus >= 201103L static_assert(sizeof(Dest) == sizeof(Source), "source and destination size mismatch"); #else + DOUBLE_CONVERSION_UNUSED typedef char VerifySizesAreEqual[sizeof(Dest) == sizeof(Source) ? 1 : -1]; #endif @@ -361,7 +360,7 @@ inline Dest BitCast(const Source& source) { } template -inline Dest BitCast(Source* source) { +Dest BitCast(Source* source) { return BitCast(reinterpret_cast(source)); } diff --git a/deps/icu-small/source/i18n/double-conversion.h b/deps/icu-small/source/i18n/double-conversion.h index 377c710bf791e7..eddc38763becdc 100644 --- a/deps/icu-small/source/i18n/double-conversion.h +++ b/deps/icu-small/source/i18n/double-conversion.h @@ -39,561 +39,8 @@ // ICU PATCH: Customize header file paths for ICU. -#include "double-conversion-utils.h" - -// ICU PATCH: Wrap in ICU namespace -U_NAMESPACE_BEGIN - -namespace double_conversion { - -class DoubleToStringConverter { - public: -#if 0 // not needed for ICU - // When calling ToFixed with a double > 10^kMaxFixedDigitsBeforePoint - // or a requested_digits parameter > kMaxFixedDigitsAfterPoint then the - // function returns false. - static const int kMaxFixedDigitsBeforePoint = 60; - static const int kMaxFixedDigitsAfterPoint = 60; - - // When calling ToExponential with a requested_digits - // parameter > kMaxExponentialDigits then the function returns false. - static const int kMaxExponentialDigits = 120; - - // When calling ToPrecision with a requested_digits - // parameter < kMinPrecisionDigits or requested_digits > kMaxPrecisionDigits - // then the function returns false. - static const int kMinPrecisionDigits = 1; - static const int kMaxPrecisionDigits = 120; - - enum Flags { - NO_FLAGS = 0, - EMIT_POSITIVE_EXPONENT_SIGN = 1, - EMIT_TRAILING_DECIMAL_POINT = 2, - EMIT_TRAILING_ZERO_AFTER_POINT = 4, - UNIQUE_ZERO = 8 - }; - - // Flags should be a bit-or combination of the possible Flags-enum. - // - NO_FLAGS: no special flags. - // - EMIT_POSITIVE_EXPONENT_SIGN: when the number is converted into exponent - // form, emits a '+' for positive exponents. Example: 1.2e+2. - // - EMIT_TRAILING_DECIMAL_POINT: when the input number is an integer and is - // converted into decimal format then a trailing decimal point is appended. - // Example: 2345.0 is converted to "2345.". - // - EMIT_TRAILING_ZERO_AFTER_POINT: in addition to a trailing decimal point - // emits a trailing '0'-character. This flag requires the - // EXMIT_TRAILING_DECIMAL_POINT flag. - // Example: 2345.0 is converted to "2345.0". - // - UNIQUE_ZERO: "-0.0" is converted to "0.0". - // - // Infinity symbol and nan_symbol provide the string representation for these - // special values. If the string is NULL and the special value is encountered - // then the conversion functions return false. - // - // The exponent_character is used in exponential representations. It is - // usually 'e' or 'E'. - // - // When converting to the shortest representation the converter will - // represent input numbers in decimal format if they are in the interval - // [10^decimal_in_shortest_low; 10^decimal_in_shortest_high[ - // (lower boundary included, greater boundary excluded). - // Example: with decimal_in_shortest_low = -6 and - // decimal_in_shortest_high = 21: - // ToShortest(0.000001) -> "0.000001" - // ToShortest(0.0000001) -> "1e-7" - // ToShortest(111111111111111111111.0) -> "111111111111111110000" - // ToShortest(100000000000000000000.0) -> "100000000000000000000" - // ToShortest(1111111111111111111111.0) -> "1.1111111111111111e+21" - // - // When converting to precision mode the converter may add - // max_leading_padding_zeroes before returning the number in exponential - // format. - // Example with max_leading_padding_zeroes_in_precision_mode = 6. - // ToPrecision(0.0000012345, 2) -> "0.0000012" - // ToPrecision(0.00000012345, 2) -> "1.2e-7" - // Similarily the converter may add up to - // max_trailing_padding_zeroes_in_precision_mode in precision mode to avoid - // returning an exponential representation. A zero added by the - // EMIT_TRAILING_ZERO_AFTER_POINT flag is counted for this limit. - // Examples for max_trailing_padding_zeroes_in_precision_mode = 1: - // ToPrecision(230.0, 2) -> "230" - // ToPrecision(230.0, 2) -> "230." with EMIT_TRAILING_DECIMAL_POINT. - // ToPrecision(230.0, 2) -> "2.3e2" with EMIT_TRAILING_ZERO_AFTER_POINT. - DoubleToStringConverter(int flags, - const char* infinity_symbol, - const char* nan_symbol, - char exponent_character, - int decimal_in_shortest_low, - int decimal_in_shortest_high, - int max_leading_padding_zeroes_in_precision_mode, - int max_trailing_padding_zeroes_in_precision_mode) - : flags_(flags), - infinity_symbol_(infinity_symbol), - nan_symbol_(nan_symbol), - exponent_character_(exponent_character), - decimal_in_shortest_low_(decimal_in_shortest_low), - decimal_in_shortest_high_(decimal_in_shortest_high), - max_leading_padding_zeroes_in_precision_mode_( - max_leading_padding_zeroes_in_precision_mode), - max_trailing_padding_zeroes_in_precision_mode_( - max_trailing_padding_zeroes_in_precision_mode) { - // When 'trailing zero after the point' is set, then 'trailing point' - // must be set too. - ASSERT(((flags & EMIT_TRAILING_DECIMAL_POINT) != 0) || - !((flags & EMIT_TRAILING_ZERO_AFTER_POINT) != 0)); - } - - // Returns a converter following the EcmaScript specification. - static const DoubleToStringConverter& EcmaScriptConverter(); - - // Computes the shortest string of digits that correctly represent the input - // number. Depending on decimal_in_shortest_low and decimal_in_shortest_high - // (see constructor) it then either returns a decimal representation, or an - // exponential representation. - // Example with decimal_in_shortest_low = -6, - // decimal_in_shortest_high = 21, - // EMIT_POSITIVE_EXPONENT_SIGN activated, and - // EMIT_TRAILING_DECIMAL_POINT deactived: - // ToShortest(0.000001) -> "0.000001" - // ToShortest(0.0000001) -> "1e-7" - // ToShortest(111111111111111111111.0) -> "111111111111111110000" - // ToShortest(100000000000000000000.0) -> "100000000000000000000" - // ToShortest(1111111111111111111111.0) -> "1.1111111111111111e+21" - // - // Note: the conversion may round the output if the returned string - // is accurate enough to uniquely identify the input-number. - // For example the most precise representation of the double 9e59 equals - // "899999999999999918767229449717619953810131273674690656206848", but - // the converter will return the shorter (but still correct) "9e59". - // - // Returns true if the conversion succeeds. The conversion always succeeds - // except when the input value is special and no infinity_symbol or - // nan_symbol has been given to the constructor. - bool ToShortest(double value, StringBuilder* result_builder) const { - return ToShortestIeeeNumber(value, result_builder, SHORTEST); - } - - // Same as ToShortest, but for single-precision floats. - bool ToShortestSingle(float value, StringBuilder* result_builder) const { - return ToShortestIeeeNumber(value, result_builder, SHORTEST_SINGLE); - } - - - // Computes a decimal representation with a fixed number of digits after the - // decimal point. The last emitted digit is rounded. - // - // Examples: - // ToFixed(3.12, 1) -> "3.1" - // ToFixed(3.1415, 3) -> "3.142" - // ToFixed(1234.56789, 4) -> "1234.5679" - // ToFixed(1.23, 5) -> "1.23000" - // ToFixed(0.1, 4) -> "0.1000" - // ToFixed(1e30, 2) -> "1000000000000000019884624838656.00" - // ToFixed(0.1, 30) -> "0.100000000000000005551115123126" - // ToFixed(0.1, 17) -> "0.10000000000000001" - // - // If requested_digits equals 0, then the tail of the result depends on - // the EMIT_TRAILING_DECIMAL_POINT and EMIT_TRAILING_ZERO_AFTER_POINT. - // Examples, for requested_digits == 0, - // let EMIT_TRAILING_DECIMAL_POINT and EMIT_TRAILING_ZERO_AFTER_POINT be - // - false and false: then 123.45 -> 123 - // 0.678 -> 1 - // - true and false: then 123.45 -> 123. - // 0.678 -> 1. - // - true and true: then 123.45 -> 123.0 - // 0.678 -> 1.0 - // - // Returns true if the conversion succeeds. The conversion always succeeds - // except for the following cases: - // - the input value is special and no infinity_symbol or nan_symbol has - // been provided to the constructor, - // - 'value' > 10^kMaxFixedDigitsBeforePoint, or - // - 'requested_digits' > kMaxFixedDigitsAfterPoint. - // The last two conditions imply that the result will never contain more than - // 1 + kMaxFixedDigitsBeforePoint + 1 + kMaxFixedDigitsAfterPoint characters - // (one additional character for the sign, and one for the decimal point). - bool ToFixed(double value, - int requested_digits, - StringBuilder* result_builder) const; - - // Computes a representation in exponential format with requested_digits - // after the decimal point. The last emitted digit is rounded. - // If requested_digits equals -1, then the shortest exponential representation - // is computed. - // - // Examples with EMIT_POSITIVE_EXPONENT_SIGN deactivated, and - // exponent_character set to 'e'. - // ToExponential(3.12, 1) -> "3.1e0" - // ToExponential(5.0, 3) -> "5.000e0" - // ToExponential(0.001, 2) -> "1.00e-3" - // ToExponential(3.1415, -1) -> "3.1415e0" - // ToExponential(3.1415, 4) -> "3.1415e0" - // ToExponential(3.1415, 3) -> "3.142e0" - // ToExponential(123456789000000, 3) -> "1.235e14" - // ToExponential(1000000000000000019884624838656.0, -1) -> "1e30" - // ToExponential(1000000000000000019884624838656.0, 32) -> - // "1.00000000000000001988462483865600e30" - // ToExponential(1234, 0) -> "1e3" - // - // Returns true if the conversion succeeds. The conversion always succeeds - // except for the following cases: - // - the input value is special and no infinity_symbol or nan_symbol has - // been provided to the constructor, - // - 'requested_digits' > kMaxExponentialDigits. - // The last condition implies that the result will never contain more than - // kMaxExponentialDigits + 8 characters (the sign, the digit before the - // decimal point, the decimal point, the exponent character, the - // exponent's sign, and at most 3 exponent digits). - bool ToExponential(double value, - int requested_digits, - StringBuilder* result_builder) const; - - // Computes 'precision' leading digits of the given 'value' and returns them - // either in exponential or decimal format, depending on - // max_{leading|trailing}_padding_zeroes_in_precision_mode (given to the - // constructor). - // The last computed digit is rounded. - // - // Example with max_leading_padding_zeroes_in_precision_mode = 6. - // ToPrecision(0.0000012345, 2) -> "0.0000012" - // ToPrecision(0.00000012345, 2) -> "1.2e-7" - // Similarily the converter may add up to - // max_trailing_padding_zeroes_in_precision_mode in precision mode to avoid - // returning an exponential representation. A zero added by the - // EMIT_TRAILING_ZERO_AFTER_POINT flag is counted for this limit. - // Examples for max_trailing_padding_zeroes_in_precision_mode = 1: - // ToPrecision(230.0, 2) -> "230" - // ToPrecision(230.0, 2) -> "230." with EMIT_TRAILING_DECIMAL_POINT. - // ToPrecision(230.0, 2) -> "2.3e2" with EMIT_TRAILING_ZERO_AFTER_POINT. - // Examples for max_trailing_padding_zeroes_in_precision_mode = 3, and no - // EMIT_TRAILING_ZERO_AFTER_POINT: - // ToPrecision(123450.0, 6) -> "123450" - // ToPrecision(123450.0, 5) -> "123450" - // ToPrecision(123450.0, 4) -> "123500" - // ToPrecision(123450.0, 3) -> "123000" - // ToPrecision(123450.0, 2) -> "1.2e5" - // - // Returns true if the conversion succeeds. The conversion always succeeds - // except for the following cases: - // - the input value is special and no infinity_symbol or nan_symbol has - // been provided to the constructor, - // - precision < kMinPericisionDigits - // - precision > kMaxPrecisionDigits - // The last condition implies that the result will never contain more than - // kMaxPrecisionDigits + 7 characters (the sign, the decimal point, the - // exponent character, the exponent's sign, and at most 3 exponent digits). - bool ToPrecision(double value, - int precision, - StringBuilder* result_builder) const; -#endif // not needed for ICU - - enum DtoaMode { - // Produce the shortest correct representation. - // For example the output of 0.299999999999999988897 is (the less accurate - // but correct) 0.3. - SHORTEST, - // Same as SHORTEST, but for single-precision floats. - SHORTEST_SINGLE, - // Produce a fixed number of digits after the decimal point. - // For instance fixed(0.1, 4) becomes 0.1000 - // If the input number is big, the output will be big. - FIXED, - // Fixed number of digits (independent of the decimal point). - PRECISION - }; - - // The maximal number of digits that are needed to emit a double in base 10. - // A higher precision can be achieved by using more digits, but the shortest - // accurate representation of any double will never use more digits than - // kBase10MaximalLength. - // Note that DoubleToAscii null-terminates its input. So the given buffer - // should be at least kBase10MaximalLength + 1 characters long. - static const int kBase10MaximalLength = 17; - - // Converts the given double 'v' to digit characters. 'v' must not be NaN, - // +Infinity, or -Infinity. In SHORTEST_SINGLE-mode this restriction also - // applies to 'v' after it has been casted to a single-precision float. That - // is, in this mode static_cast(v) must not be NaN, +Infinity or - // -Infinity. - // - // The result should be interpreted as buffer * 10^(point-length). - // - // The digits are written to the buffer in the platform's charset, which is - // often UTF-8 (with ASCII-range digits) but may be another charset, such - // as EBCDIC. - // - // The output depends on the given mode: - // - SHORTEST: produce the least amount of digits for which the internal - // identity requirement is still satisfied. If the digits are printed - // (together with the correct exponent) then reading this number will give - // 'v' again. The buffer will choose the representation that is closest to - // 'v'. If there are two at the same distance, than the one farther away - // from 0 is chosen (halfway cases - ending with 5 - are rounded up). - // In this mode the 'requested_digits' parameter is ignored. - // - SHORTEST_SINGLE: same as SHORTEST but with single-precision. - // - FIXED: produces digits necessary to print a given number with - // 'requested_digits' digits after the decimal point. The produced digits - // might be too short in which case the caller has to fill the remainder - // with '0's. - // Example: toFixed(0.001, 5) is allowed to return buffer="1", point=-2. - // Halfway cases are rounded towards +/-Infinity (away from 0). The call - // toFixed(0.15, 2) thus returns buffer="2", point=0. - // The returned buffer may contain digits that would be truncated from the - // shortest representation of the input. - // - PRECISION: produces 'requested_digits' where the first digit is not '0'. - // Even though the length of produced digits usually equals - // 'requested_digits', the function is allowed to return fewer digits, in - // which case the caller has to fill the missing digits with '0's. - // Halfway cases are again rounded away from 0. - // DoubleToAscii expects the given buffer to be big enough to hold all - // digits and a terminating null-character. In SHORTEST-mode it expects a - // buffer of at least kBase10MaximalLength + 1. In all other modes the - // requested_digits parameter and the padding-zeroes limit the size of the - // output. Don't forget the decimal point, the exponent character and the - // terminating null-character when computing the maximal output size. - // The given length is only used in debug mode to ensure the buffer is big - // enough. - // ICU PATCH: Export this as U_I18N_API for unit tests. - static void U_I18N_API DoubleToAscii(double v, - DtoaMode mode, - int requested_digits, - char* buffer, - int buffer_length, - bool* sign, - int* length, - int* point); - -#if 0 // not needed for ICU - private: - // Implementation for ToShortest and ToShortestSingle. - bool ToShortestIeeeNumber(double value, - StringBuilder* result_builder, - DtoaMode mode) const; - - // If the value is a special value (NaN or Infinity) constructs the - // corresponding string using the configured infinity/nan-symbol. - // If either of them is NULL or the value is not special then the - // function returns false. - bool HandleSpecialValues(double value, StringBuilder* result_builder) const; - // Constructs an exponential representation (i.e. 1.234e56). - // The given exponent assumes a decimal point after the first decimal digit. - void CreateExponentialRepresentation(const char* decimal_digits, - int length, - int exponent, - StringBuilder* result_builder) const; - // Creates a decimal representation (i.e 1234.5678). - void CreateDecimalRepresentation(const char* decimal_digits, - int length, - int decimal_point, - int digits_after_point, - StringBuilder* result_builder) const; - - const int flags_; - const char* const infinity_symbol_; - const char* const nan_symbol_; - const char exponent_character_; - const int decimal_in_shortest_low_; - const int decimal_in_shortest_high_; - const int max_leading_padding_zeroes_in_precision_mode_; - const int max_trailing_padding_zeroes_in_precision_mode_; -#endif // not needed for ICU - - DC_DISALLOW_IMPLICIT_CONSTRUCTORS(DoubleToStringConverter); -}; - - -class StringToDoubleConverter { - public: - // Enumeration for allowing octals and ignoring junk when converting - // strings to numbers. - enum Flags { - NO_FLAGS = 0, - ALLOW_HEX = 1, - ALLOW_OCTALS = 2, - ALLOW_TRAILING_JUNK = 4, - ALLOW_LEADING_SPACES = 8, - ALLOW_TRAILING_SPACES = 16, - ALLOW_SPACES_AFTER_SIGN = 32, - ALLOW_CASE_INSENSIBILITY = 64, - ALLOW_HEX_FLOATS = 128, - }; - - static const uc16 kNoSeparator = '\0'; - - // Flags should be a bit-or combination of the possible Flags-enum. - // - NO_FLAGS: no special flags. - // - ALLOW_HEX: recognizes the prefix "0x". Hex numbers may only be integers. - // Ex: StringToDouble("0x1234") -> 4660.0 - // In StringToDouble("0x1234.56") the characters ".56" are trailing - // junk. The result of the call is hence dependent on - // the ALLOW_TRAILING_JUNK flag and/or the junk value. - // With this flag "0x" is a junk-string. Even with ALLOW_TRAILING_JUNK, - // the string will not be parsed as "0" followed by junk. - // - // - ALLOW_OCTALS: recognizes the prefix "0" for octals: - // If a sequence of octal digits starts with '0', then the number is - // read as octal integer. Octal numbers may only be integers. - // Ex: StringToDouble("01234") -> 668.0 - // StringToDouble("012349") -> 12349.0 // Not a sequence of octal - // // digits. - // In StringToDouble("01234.56") the characters ".56" are trailing - // junk. The result of the call is hence dependent on - // the ALLOW_TRAILING_JUNK flag and/or the junk value. - // In StringToDouble("01234e56") the characters "e56" are trailing - // junk, too. - // - ALLOW_TRAILING_JUNK: ignore trailing characters that are not part of - // a double literal. - // - ALLOW_LEADING_SPACES: skip over leading whitespace, including spaces, - // new-lines, and tabs. - // - ALLOW_TRAILING_SPACES: ignore trailing whitespace. - // - ALLOW_SPACES_AFTER_SIGN: ignore whitespace after the sign. - // Ex: StringToDouble("- 123.2") -> -123.2. - // StringToDouble("+ 123.2") -> 123.2 - // - ALLOW_CASE_INSENSIBILITY: ignore case of characters for special values: - // infinity and nan. - // - ALLOW_HEX_FLOATS: allows hexadecimal float literals. - // This *must* start with "0x" and separate the exponent with "p". - // Examples: 0x1.2p3 == 9.0 - // 0x10.1p0 == 16.0625 - // ALLOW_HEX and ALLOW_HEX_FLOATS are indendent. - // - // empty_string_value is returned when an empty string is given as input. - // If ALLOW_LEADING_SPACES or ALLOW_TRAILING_SPACES are set, then a string - // containing only spaces is converted to the 'empty_string_value', too. - // - // junk_string_value is returned when - // a) ALLOW_TRAILING_JUNK is not set, and a junk character (a character not - // part of a double-literal) is found. - // b) ALLOW_TRAILING_JUNK is set, but the string does not start with a - // double literal. - // - // infinity_symbol and nan_symbol are strings that are used to detect - // inputs that represent infinity and NaN. They can be null, in which case - // they are ignored. - // The conversion routine first reads any possible signs. Then it compares the - // following character of the input-string with the first character of - // the infinity, and nan-symbol. If either matches, the function assumes, that - // a match has been found, and expects the following input characters to match - // the remaining characters of the special-value symbol. - // This means that the following restrictions apply to special-value symbols: - // - they must not start with signs ('+', or '-'), - // - they must not have the same first character. - // - they must not start with digits. - // - // If the separator character is not kNoSeparator, then that specific - // character is ignored when in between two valid digits of the significant. - // It is not allowed to appear in the exponent. - // It is not allowed to lead or trail the number. - // It is not allowed to appear twice next to each other. - // - // Examples: - // flags = ALLOW_HEX | ALLOW_TRAILING_JUNK, - // empty_string_value = 0.0, - // junk_string_value = NaN, - // infinity_symbol = "infinity", - // nan_symbol = "nan": - // StringToDouble("0x1234") -> 4660.0. - // StringToDouble("0x1234K") -> 4660.0. - // StringToDouble("") -> 0.0 // empty_string_value. - // StringToDouble(" ") -> NaN // junk_string_value. - // StringToDouble(" 1") -> NaN // junk_string_value. - // StringToDouble("0x") -> NaN // junk_string_value. - // StringToDouble("-123.45") -> -123.45. - // StringToDouble("--123.45") -> NaN // junk_string_value. - // StringToDouble("123e45") -> 123e45. - // StringToDouble("123E45") -> 123e45. - // StringToDouble("123e+45") -> 123e45. - // StringToDouble("123E-45") -> 123e-45. - // StringToDouble("123e") -> 123.0 // trailing junk ignored. - // StringToDouble("123e-") -> 123.0 // trailing junk ignored. - // StringToDouble("+NaN") -> NaN // NaN string literal. - // StringToDouble("-infinity") -> -inf. // infinity literal. - // StringToDouble("Infinity") -> NaN // junk_string_value. - // - // flags = ALLOW_OCTAL | ALLOW_LEADING_SPACES, - // empty_string_value = 0.0, - // junk_string_value = NaN, - // infinity_symbol = NULL, - // nan_symbol = NULL: - // StringToDouble("0x1234") -> NaN // junk_string_value. - // StringToDouble("01234") -> 668.0. - // StringToDouble("") -> 0.0 // empty_string_value. - // StringToDouble(" ") -> 0.0 // empty_string_value. - // StringToDouble(" 1") -> 1.0 - // StringToDouble("0x") -> NaN // junk_string_value. - // StringToDouble("0123e45") -> NaN // junk_string_value. - // StringToDouble("01239E45") -> 1239e45. - // StringToDouble("-infinity") -> NaN // junk_string_value. - // StringToDouble("NaN") -> NaN // junk_string_value. - // - // flags = NO_FLAGS, - // separator = ' ': - // StringToDouble("1 2 3 4") -> 1234.0 - // StringToDouble("1 2") -> NaN // junk_string_value - // StringToDouble("1 000 000.0") -> 1000000.0 - // StringToDouble("1.000 000") -> 1.0 - // StringToDouble("1.0e1 000") -> NaN // junk_string_value - StringToDoubleConverter(int flags, - double empty_string_value, - double junk_string_value, - const char* infinity_symbol, - const char* nan_symbol, - uc16 separator = kNoSeparator) - : flags_(flags), - empty_string_value_(empty_string_value), - junk_string_value_(junk_string_value), - infinity_symbol_(infinity_symbol), - nan_symbol_(nan_symbol), - separator_(separator) { - } - - // Performs the conversion. - // The output parameter 'processed_characters_count' is set to the number - // of characters that have been processed to read the number. - // Spaces than are processed with ALLOW_{LEADING|TRAILING}_SPACES are included - // in the 'processed_characters_count'. Trailing junk is never included. - double StringToDouble(const char* buffer, - int length, - int* processed_characters_count) const; - - // Same as StringToDouble above but for 16 bit characters. - double StringToDouble(const uc16* buffer, - int length, - int* processed_characters_count) const; - - // Same as StringToDouble but reads a float. - // Note that this is not equivalent to static_cast(StringToDouble(...)) - // due to potential double-rounding. - float StringToFloat(const char* buffer, - int length, - int* processed_characters_count) const; - - // Same as StringToFloat above but for 16 bit characters. - float StringToFloat(const uc16* buffer, - int length, - int* processed_characters_count) const; - - private: - const int flags_; - const double empty_string_value_; - const double junk_string_value_; - const char* const infinity_symbol_; - const char* const nan_symbol_; - const uc16 separator_; - - template - double StringToIeee(Iterator start_pointer, - int length, - bool read_as_double, - int* processed_characters_count) const; - - DC_DISALLOW_IMPLICIT_CONSTRUCTORS(StringToDoubleConverter); -}; - -} // namespace double_conversion - -// ICU PATCH: Close ICU namespace -U_NAMESPACE_END +#include "double-conversion-string-to-double.h" +#include "double-conversion-double-to-string.h" #endif // DOUBLE_CONVERSION_DOUBLE_CONVERSION_H_ #endif // ICU PATCH: close #if !UCONFIG_NO_FORMATTING diff --git a/deps/icu-small/source/i18n/dtfmtsym.cpp b/deps/icu-small/source/i18n/dtfmtsym.cpp index 04aa01eb4c2459..9dde66c1fba419 100644 --- a/deps/icu-small/source/i18n/dtfmtsym.cpp +++ b/deps/icu-small/source/i18n/dtfmtsym.cpp @@ -1246,7 +1246,7 @@ const UnicodeString** DateFormatSymbols::getZoneStrings(int32_t& rowCount, int32_t& columnCount) const { const UnicodeString **result = NULL; - static UMutex LOCK = U_MUTEX_INITIALIZER; + static UMutex LOCK; umtx_lock(&LOCK); if (fZoneStrings == NULL) { @@ -2177,16 +2177,16 @@ DateFormatSymbols::initializeData(const Locale& locale, const char *type, UError // The ordering of the following statements is important. if (fLeapMonthPatterns[kLeapMonthPatternFormatAbbrev].isEmpty()) { fLeapMonthPatterns[kLeapMonthPatternFormatAbbrev].setTo(fLeapMonthPatterns[kLeapMonthPatternFormatWide]); - }; + } if (fLeapMonthPatterns[kLeapMonthPatternFormatNarrow].isEmpty()) { fLeapMonthPatterns[kLeapMonthPatternFormatNarrow].setTo(fLeapMonthPatterns[kLeapMonthPatternStandaloneNarrow]); - }; + } if (fLeapMonthPatterns[kLeapMonthPatternStandaloneWide].isEmpty()) { fLeapMonthPatterns[kLeapMonthPatternStandaloneWide].setTo(fLeapMonthPatterns[kLeapMonthPatternFormatWide]); - }; + } if (fLeapMonthPatterns[kLeapMonthPatternStandaloneAbbrev].isEmpty()) { fLeapMonthPatterns[kLeapMonthPatternStandaloneAbbrev].setTo(fLeapMonthPatterns[kLeapMonthPatternFormatAbbrev]); - }; + } // end of hack fLeapMonthPatternsCount = kMonthPatternsCount; } else { @@ -2338,11 +2338,21 @@ DateFormatSymbols::initializeData(const Locale& locale, const char *type, UError assignArray(fStandaloneNarrowMonths, fStandaloneNarrowMonthsCount, fShortMonths, fShortMonthsCount); } - // Load AM/PM markers + // Load AM/PM markers; if wide or narrow not available, use short + UErrorCode ampmStatus = U_ZERO_ERROR; initField(&fAmPms, fAmPmsCount, calendarSink, - buildResourcePath(path, gAmPmMarkersTag, status), status); + buildResourcePath(path, gAmPmMarkersTag, ampmStatus), ampmStatus); + if (U_FAILURE(ampmStatus)) { + initField(&fAmPms, fAmPmsCount, calendarSink, + buildResourcePath(path, gAmPmMarkersAbbrTag, status), status); + } + ampmStatus = U_ZERO_ERROR; initField(&fNarrowAmPms, fNarrowAmPmsCount, calendarSink, - buildResourcePath(path, gAmPmMarkersNarrowTag, status), status); + buildResourcePath(path, gAmPmMarkersNarrowTag, ampmStatus), ampmStatus); + if (U_FAILURE(ampmStatus)) { + initField(&fNarrowAmPms, fNarrowAmPmsCount, calendarSink, + buildResourcePath(path, gAmPmMarkersAbbrTag, status), status); + } // Load quarters initField(&fQuarters, fQuartersCount, calendarSink, diff --git a/deps/icu-small/source/i18n/dtitv_impl.h b/deps/icu-small/source/i18n/dtitv_impl.h index 18fe0b8c9b527d..7c4d8a72148919 100644 --- a/deps/icu-small/source/i18n/dtitv_impl.h +++ b/deps/icu-small/source/i18n/dtitv_impl.h @@ -88,7 +88,7 @@ #define MAX_E_COUNT 5 #define MAX_M_COUNT 5 //#define MAX_INTERVAL_INDEX 4 -#define MAX_POSITIVE_INT 56632; +#define MAX_POSITIVE_INT 56632 #endif /* #if !UCONFIG_NO_FORMATTING */ diff --git a/deps/icu-small/source/i18n/dtitvfmt.cpp b/deps/icu-small/source/i18n/dtitvfmt.cpp index 0e124f5624002b..f47e7708ccc128 100644 --- a/deps/icu-small/source/i18n/dtitvfmt.cpp +++ b/deps/icu-small/source/i18n/dtitvfmt.cpp @@ -82,10 +82,7 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(DateIntervalFormat) // Mutex, protects access to fDateFormat, fFromCalendar and fToCalendar. // Needed because these data members are modified by const methods of DateIntervalFormat. -static UMutex *gFormatterMutex() { - static UMutex m = U_MUTEX_INITIALIZER; - return &m; -} +static UMutex gFormatterMutex; DateIntervalFormat* U_EXPORT2 DateIntervalFormat::createInstance(const UnicodeString& skeleton, @@ -171,9 +168,9 @@ DateIntervalFormat::operator=(const DateIntervalFormat& itvfmt) { delete fTimePattern; delete fDateTimeFormat; { - Mutex lock(gFormatterMutex()); + Mutex lock(&gFormatterMutex); if ( itvfmt.fDateFormat ) { - fDateFormat = (SimpleDateFormat*)itvfmt.fDateFormat->clone(); + fDateFormat = itvfmt.fDateFormat->clone(); } else { fDateFormat = NULL; } @@ -199,9 +196,9 @@ DateIntervalFormat::operator=(const DateIntervalFormat& itvfmt) { fIntervalPatterns[i] = itvfmt.fIntervalPatterns[i]; } fLocale = itvfmt.fLocale; - fDatePattern = (itvfmt.fDatePattern)? (UnicodeString*)itvfmt.fDatePattern->clone(): NULL; - fTimePattern = (itvfmt.fTimePattern)? (UnicodeString*)itvfmt.fTimePattern->clone(): NULL; - fDateTimeFormat = (itvfmt.fDateTimeFormat)? (UnicodeString*)itvfmt.fDateTimeFormat->clone(): NULL; + fDatePattern = (itvfmt.fDatePattern)? itvfmt.fDatePattern->clone(): NULL; + fTimePattern = (itvfmt.fTimePattern)? itvfmt.fTimePattern->clone(): NULL; + fDateTimeFormat = (itvfmt.fDateTimeFormat)? itvfmt.fDateTimeFormat->clone(): NULL; } return *this; } @@ -218,8 +215,8 @@ DateIntervalFormat::~DateIntervalFormat() { } -Format* -DateIntervalFormat::clone(void) const { +DateIntervalFormat* +DateIntervalFormat::clone() const { return new DateIntervalFormat(*this); } @@ -233,7 +230,7 @@ DateIntervalFormat::operator==(const Format& other) const { if ((fInfo != fmt->fInfo) && (fInfo == NULL || fmt->fInfo == NULL)) {return FALSE;} if (fInfo && fmt->fInfo && (*fInfo != *fmt->fInfo )) {return FALSE;} { - Mutex lock(gFormatterMutex()); + Mutex lock(&gFormatterMutex); if (fDateFormat != fmt->fDateFormat && (fDateFormat == NULL || fmt->fDateFormat == NULL)) {return FALSE;} if (fDateFormat && fmt->fDateFormat && (*fDateFormat != *fmt->fDateFormat)) {return FALSE;} } @@ -295,7 +292,7 @@ DateIntervalFormat::format(const DateInterval* dtInterval, handler.setAcceptFirstOnly(TRUE); int8_t ignore; - Mutex lock(gFormatterMutex()); + Mutex lock(&gFormatterMutex); return formatIntervalImpl(*dtInterval, appendTo, ignore, handler, status); } @@ -312,7 +309,7 @@ FormattedDateInterval DateIntervalFormat::formatToValue( auto handler = result->getHandler(status); handler.setCategory(UFIELD_CATEGORY_DATE); { - Mutex lock(gFormatterMutex()); + Mutex lock(&gFormatterMutex); formatIntervalImpl(dtInterval, string, firstIndex, handler, status); } handler.getError(status); @@ -344,7 +341,7 @@ DateIntervalFormat::format(Calendar& fromCalendar, handler.setAcceptFirstOnly(TRUE); int8_t ignore; - Mutex lock(gFormatterMutex()); + Mutex lock(&gFormatterMutex); return formatImpl(fromCalendar, toCalendar, appendTo, ignore, handler, status); } @@ -362,7 +359,7 @@ FormattedDateInterval DateIntervalFormat::formatToValue( auto handler = result->getHandler(status); handler.setCategory(UFIELD_CATEGORY_DATE); { - Mutex lock(gFormatterMutex()); + Mutex lock(&gFormatterMutex); formatImpl(fromCalendar, toCalendar, string, firstIndex, handler, status); } handler.getError(status); @@ -600,7 +597,7 @@ const TimeZone& DateIntervalFormat::getTimeZone() const { if (fDateFormat != NULL) { - Mutex lock(gFormatterMutex()); + Mutex lock(&gFormatterMutex); return fDateFormat->getTimeZone(); } // If fDateFormat is NULL (unexpected), create default timezone. diff --git a/deps/icu-small/source/i18n/dtitvinf.cpp b/deps/icu-small/source/i18n/dtitvinf.cpp index c0a6980e5567bc..35ee8c16261934 100644 --- a/deps/icu-small/source/i18n/dtitvinf.cpp +++ b/deps/icu-small/source/i18n/dtitvinf.cpp @@ -42,7 +42,9 @@ U_NAMESPACE_BEGIN #ifdef DTITVINF_DEBUG -#define PRINTMESG(msg) { std::cout << "(" << __FILE__ << ":" << __LINE__ << ") " << msg << "\n"; } +#define PRINTMESG(msg) UPRV_BLOCK_MACRO_BEGIN { \ + std::cout << "(" << __FILE__ << ":" << __LINE__ << ") " << msg << "\n"; \ +} UPRV_BLOCK_MACRO_END #endif UOBJECT_DEFINE_RTTI_IMPLEMENTATION(DateIntervalInfo) diff --git a/deps/icu-small/source/i18n/dtptngen.cpp b/deps/icu-small/source/i18n/dtptngen.cpp index 9ca29a3cc7e608..50a377259aa80e 100644 --- a/deps/icu-small/source/i18n/dtptngen.cpp +++ b/deps/icu-small/source/i18n/dtptngen.cpp @@ -28,6 +28,7 @@ #include "unicode/ures.h" #include "unicode/ustring.h" #include "unicode/rep.h" +#include "unicode/region.h" #include "cpputils.h" #include "mutex.h" #include "umutex.h" @@ -613,29 +614,56 @@ U_CFUNC void U_CALLCONV DateTimePatternGenerator::loadAllowedHourFormatsData(UEr ures_getAllItemsWithFallback(rb.getAlias(), "timeData", sink, status); } -void DateTimePatternGenerator::getAllowedHourFormats(const Locale &locale, UErrorCode &status) { - if (U_FAILURE(status)) { return; } - Locale maxLocale(locale); - maxLocale.addLikelySubtags(status); - if (U_FAILURE(status)) { - return; - } - - const char *country = maxLocale.getCountry(); - if (*country == '\0') { country = "001"; } - const char *language = maxLocale.getLanguage(); - +static int32_t* getAllowedHourFormatsLangCountry(const char* language, const char* country, UErrorCode& status) { CharString langCountry; - langCountry.append(language, static_cast(uprv_strlen(language)), status); + langCountry.append(language, status); langCountry.append('_', status); - langCountry.append(country, static_cast(uprv_strlen(country)), status); + langCountry.append(country, status); - int32_t *allowedFormats; + int32_t* allowedFormats; allowedFormats = (int32_t *)uhash_get(localeToAllowedHourFormatsMap, langCountry.data()); if (allowedFormats == nullptr) { allowedFormats = (int32_t *)uhash_get(localeToAllowedHourFormatsMap, const_cast(country)); } + return allowedFormats; +} + +void DateTimePatternGenerator::getAllowedHourFormats(const Locale &locale, UErrorCode &status) { + if (U_FAILURE(status)) { return; } + + const char *language = locale.getLanguage(); + const char *country = locale.getCountry(); + Locale maxLocale; // must be here for correct lifetime + if (*language == '\0' || *country == '\0') { + maxLocale = locale; + UErrorCode localStatus = U_ZERO_ERROR; + maxLocale.addLikelySubtags(localStatus); + if (U_SUCCESS(localStatus)) { + language = maxLocale.getLanguage(); + country = maxLocale.getCountry(); + } + } + if (*language == '\0') { + // Unexpected, but fail gracefully + language = "und"; + } + if (*country == '\0') { + country = "001"; + } + + int32_t* allowedFormats = getAllowedHourFormatsLangCountry(language, country, status); + + // Check if the region has an alias + if (allowedFormats == nullptr) { + UErrorCode localStatus = U_ZERO_ERROR; + const Region* region = Region::getInstance(country, localStatus); + if (U_SUCCESS(localStatus)) { + country = region->getRegionCode(); // the real region code + allowedFormats = getAllowedHourFormatsLangCountry(language, country, status); + } + } + if (allowedFormats != nullptr) { // Lookup is successful // Here allowedFormats points to a list consisting of key for preferredFormat, // followed by one or more keys for allowedFormats, then followed by ALLOWED_HOUR_FORMAT_UNKNOWN. @@ -787,6 +815,7 @@ void DateTimePatternGenerator::getCalendarTypeToUse(const Locale& locale, CharString& destination, UErrorCode& err) { destination.clear().append(DT_DateTimeGregorianTag, -1, err); // initial default if ( U_SUCCESS(err) ) { + UErrorCode localStatus = U_ZERO_ERROR; char localeWithCalendarKey[ULOC_LOCALE_IDENTIFIER_CAPACITY]; // obtain a locale that always has the calendar key value that should be used ures_getFunctionalEquivalent( @@ -798,8 +827,7 @@ DateTimePatternGenerator::getCalendarTypeToUse(const Locale& locale, CharString& locale.getName(), nullptr, FALSE, - &err); - if (U_FAILURE(err)) { return; } + &localStatus); localeWithCalendarKey[ULOC_LOCALE_IDENTIFIER_CAPACITY-1] = 0; // ensure null termination // now get the calendar key value from that locale char calendarType[ULOC_KEYWORDS_CAPACITY]; @@ -808,13 +836,17 @@ DateTimePatternGenerator::getCalendarTypeToUse(const Locale& locale, CharString& "calendar", calendarType, ULOC_KEYWORDS_CAPACITY, - &err); - if (U_FAILURE(err)) { return; } + &localStatus); + // If the input locale was invalid, don't fail with missing resource error, instead + // continue with default of Gregorian. + if (U_FAILURE(localStatus) && localStatus != U_MISSING_RESOURCE_ERROR) { + err = localStatus; + return; + } if (calendarTypeLen < ULOC_KEYWORDS_CAPACITY) { destination.clear().append(calendarType, -1, err); if (U_FAILURE(err)) { return; } } - err = U_ZERO_ERROR; } } @@ -2543,7 +2575,8 @@ UChar SkeletonFields::getFirstChar() const { } -PtnSkeleton::PtnSkeleton() { +PtnSkeleton::PtnSkeleton() + : addedDefaultDayPeriod(FALSE) { } PtnSkeleton::PtnSkeleton(const PtnSkeleton& other) { @@ -2554,6 +2587,7 @@ void PtnSkeleton::copyFrom(const PtnSkeleton& other) { uprv_memcpy(type, other.type, sizeof(type)); original.copyFrom(other.original); baseOriginal.copyFrom(other.baseOriginal); + addedDefaultDayPeriod = other.addedDefaultDayPeriod; } void PtnSkeleton::clear() { diff --git a/deps/icu-small/source/i18n/esctrn.cpp b/deps/icu-small/source/i18n/esctrn.cpp index 900bed7e45734b..ba0e4c2c7bb618 100644 --- a/deps/icu-small/source/i18n/esctrn.cpp +++ b/deps/icu-small/source/i18n/esctrn.cpp @@ -122,7 +122,7 @@ EscapeTransliterator::~EscapeTransliterator() { /** * Transliterator API. */ -Transliterator* EscapeTransliterator::clone() const { +EscapeTransliterator* EscapeTransliterator::clone() const { return new EscapeTransliterator(*this); } diff --git a/deps/icu-small/source/i18n/esctrn.h b/deps/icu-small/source/i18n/esctrn.h index 60ecc74b498456..2a2c6dcfe9af10 100644 --- a/deps/icu-small/source/i18n/esctrn.h +++ b/deps/icu-small/source/i18n/esctrn.h @@ -115,7 +115,7 @@ class EscapeTransliterator : public Transliterator { /** * Transliterator API. */ - virtual Transliterator* clone() const; + virtual EscapeTransliterator* clone() const; /** * ICU "poor man's RTTI", returns a UClassID for the actual class. diff --git a/deps/icu-small/source/i18n/ethpccal.cpp b/deps/icu-small/source/i18n/ethpccal.cpp index 4377c59b325a1b..0b8ad0e81488c3 100644 --- a/deps/icu-small/source/i18n/ethpccal.cpp +++ b/deps/icu-small/source/i18n/ethpccal.cpp @@ -46,7 +46,7 @@ EthiopicCalendar::~EthiopicCalendar() { } -Calendar* +EthiopicCalendar* EthiopicCalendar::clone() const { return new EthiopicCalendar(*this); diff --git a/deps/icu-small/source/i18n/ethpccal.h b/deps/icu-small/source/i18n/ethpccal.h index 5fae2fb1bea2c7..179a20e85302fb 100644 --- a/deps/icu-small/source/i18n/ethpccal.h +++ b/deps/icu-small/source/i18n/ethpccal.h @@ -141,7 +141,7 @@ class EthiopicCalendar : public CECalendar { * @return return a polymorphic copy of this calendar. * @internal */ - virtual Calendar* clone() const; + virtual EthiopicCalendar* clone() const; /** * return the calendar type, "ethiopic" diff --git a/deps/icu-small/source/i18n/fmtable.cpp b/deps/icu-small/source/i18n/fmtable.cpp index 9baa5ff480db6a..10a6fdb0ff3441 100644 --- a/deps/icu-small/source/i18n/fmtable.cpp +++ b/deps/icu-small/source/i18n/fmtable.cpp @@ -736,7 +736,7 @@ CharString *Formattable::internalGetCharString(UErrorCode &status) { fDecimalStr->append("Infinity", status); } else if (fDecimalQuantity->isNaN()) { fDecimalStr->append("NaN", status); - } else if (fDecimalQuantity->isZero()) { + } else if (fDecimalQuantity->isZeroish()) { fDecimalStr->append("0", -1, status); } else if (fType==kLong || fType==kInt64 || // use toPlainString for integer types (fDecimalQuantity->getMagnitude() != INT32_MIN && std::abs(fDecimalQuantity->getMagnitude()) < 5)) { diff --git a/deps/icu-small/source/i18n/number_stringbuilder.cpp b/deps/icu-small/source/i18n/formatted_string_builder.cpp similarity index 58% rename from deps/icu-small/source/i18n/number_stringbuilder.cpp rename to deps/icu-small/source/i18n/formatted_string_builder.cpp index 03300b33ac5e21..3024bff6addacc 100644 --- a/deps/icu-small/source/i18n/number_stringbuilder.cpp +++ b/deps/icu-small/source/i18n/formatted_string_builder.cpp @@ -5,14 +5,9 @@ #if !UCONFIG_NO_FORMATTING -#include "number_stringbuilder.h" -#include "static_unicode_sets.h" +#include "formatted_string_builder.h" +#include "unicode/ustring.h" #include "unicode/utf16.h" -#include "number_utils.h" - -using namespace icu; -using namespace icu::number; -using namespace icu::number::impl; namespace { @@ -34,7 +29,10 @@ inline void uprv_memmove2(void* dest, const void* src, size_t len) { } // namespace -NumberStringBuilder::NumberStringBuilder() { + +U_NAMESPACE_BEGIN + +FormattedStringBuilder::FormattedStringBuilder() { #if U_DEBUG // Initializing the memory to non-zero helps catch some bugs that involve // reading from an improperly terminated string. @@ -44,18 +42,18 @@ NumberStringBuilder::NumberStringBuilder() { #endif } -NumberStringBuilder::~NumberStringBuilder() { +FormattedStringBuilder::~FormattedStringBuilder() { if (fUsingHeap) { uprv_free(fChars.heap.ptr); uprv_free(fFields.heap.ptr); } } -NumberStringBuilder::NumberStringBuilder(const NumberStringBuilder &other) { +FormattedStringBuilder::FormattedStringBuilder(const FormattedStringBuilder &other) { *this = other; } -NumberStringBuilder &NumberStringBuilder::operator=(const NumberStringBuilder &other) { +FormattedStringBuilder &FormattedStringBuilder::operator=(const FormattedStringBuilder &other) { // Check for self-assignment if (this == &other) { return *this; @@ -78,7 +76,7 @@ NumberStringBuilder &NumberStringBuilder::operator=(const NumberStringBuilder &o // UErrorCode is not available; fail silently. uprv_free(newChars); uprv_free(newFields); - *this = NumberStringBuilder(); // can't fail + *this = FormattedStringBuilder(); // can't fail return *this; } @@ -97,15 +95,15 @@ NumberStringBuilder &NumberStringBuilder::operator=(const NumberStringBuilder &o return *this; } -int32_t NumberStringBuilder::length() const { +int32_t FormattedStringBuilder::length() const { return fLength; } -int32_t NumberStringBuilder::codePointCount() const { +int32_t FormattedStringBuilder::codePointCount() const { return u_countChar32(getCharPtr() + fZero, fLength); } -UChar32 NumberStringBuilder::getFirstCodePoint() const { +UChar32 FormattedStringBuilder::getFirstCodePoint() const { if (fLength == 0) { return -1; } @@ -114,7 +112,7 @@ UChar32 NumberStringBuilder::getFirstCodePoint() const { return cp; } -UChar32 NumberStringBuilder::getLastCodePoint() const { +UChar32 FormattedStringBuilder::getLastCodePoint() const { if (fLength == 0) { return -1; } @@ -125,13 +123,13 @@ UChar32 NumberStringBuilder::getLastCodePoint() const { return cp; } -UChar32 NumberStringBuilder::codePointAt(int32_t index) const { +UChar32 FormattedStringBuilder::codePointAt(int32_t index) const { UChar32 cp; U16_GET(getCharPtr() + fZero, 0, index, fLength, cp); return cp; } -UChar32 NumberStringBuilder::codePointBefore(int32_t index) const { +UChar32 FormattedStringBuilder::codePointBefore(int32_t index) const { int32_t offset = index; U16_BACK_1(getCharPtr() + fZero, 0, offset); UChar32 cp; @@ -139,19 +137,15 @@ UChar32 NumberStringBuilder::codePointBefore(int32_t index) const { return cp; } -NumberStringBuilder &NumberStringBuilder::clear() { +FormattedStringBuilder &FormattedStringBuilder::clear() { // TODO: Reset the heap here? fZero = getCapacity() / 2; fLength = 0; return *this; } -int32_t NumberStringBuilder::appendCodePoint(UChar32 codePoint, Field field, UErrorCode &status) { - return insertCodePoint(fLength, codePoint, field, status); -} - int32_t -NumberStringBuilder::insertCodePoint(int32_t index, UChar32 codePoint, Field field, UErrorCode &status) { +FormattedStringBuilder::insertCodePoint(int32_t index, UChar32 codePoint, Field field, UErrorCode &status) { int32_t count = U16_LENGTH(codePoint); int32_t position = prepareForInsert(index, count, status); if (U_FAILURE(status)) { @@ -168,11 +162,7 @@ NumberStringBuilder::insertCodePoint(int32_t index, UChar32 codePoint, Field fie return count; } -int32_t NumberStringBuilder::append(const UnicodeString &unistr, Field field, UErrorCode &status) { - return insert(fLength, unistr, field, status); -} - -int32_t NumberStringBuilder::insert(int32_t index, const UnicodeString &unistr, Field field, +int32_t FormattedStringBuilder::insert(int32_t index, const UnicodeString &unistr, Field field, UErrorCode &status) { if (unistr.length() == 0) { // Nothing to insert. @@ -186,7 +176,7 @@ int32_t NumberStringBuilder::insert(int32_t index, const UnicodeString &unistr, } int32_t -NumberStringBuilder::insert(int32_t index, const UnicodeString &unistr, int32_t start, int32_t end, +FormattedStringBuilder::insert(int32_t index, const UnicodeString &unistr, int32_t start, int32_t end, Field field, UErrorCode &status) { int32_t count = end - start; int32_t position = prepareForInsert(index, count, status); @@ -201,7 +191,7 @@ NumberStringBuilder::insert(int32_t index, const UnicodeString &unistr, int32_t } int32_t -NumberStringBuilder::splice(int32_t startThis, int32_t endThis, const UnicodeString &unistr, +FormattedStringBuilder::splice(int32_t startThis, int32_t endThis, const UnicodeString &unistr, int32_t startOther, int32_t endOther, Field field, UErrorCode& status) { int32_t thisLength = endThis - startThis; int32_t otherLength = endOther - startOther; @@ -224,12 +214,12 @@ NumberStringBuilder::splice(int32_t startThis, int32_t endThis, const UnicodeSt return count; } -int32_t NumberStringBuilder::append(const NumberStringBuilder &other, UErrorCode &status) { +int32_t FormattedStringBuilder::append(const FormattedStringBuilder &other, UErrorCode &status) { return insert(fLength, other, status); } int32_t -NumberStringBuilder::insert(int32_t index, const NumberStringBuilder &other, UErrorCode &status) { +FormattedStringBuilder::insert(int32_t index, const FormattedStringBuilder &other, UErrorCode &status) { if (this == &other) { status = U_ILLEGAL_ARGUMENT_ERROR; return 0; @@ -250,7 +240,7 @@ NumberStringBuilder::insert(int32_t index, const NumberStringBuilder &other, UEr return count; } -void NumberStringBuilder::writeTerminator(UErrorCode& status) { +void FormattedStringBuilder::writeTerminator(UErrorCode& status) { int32_t position = prepareForInsert(fLength, 1, status); if (U_FAILURE(status)) { return; @@ -260,7 +250,7 @@ void NumberStringBuilder::writeTerminator(UErrorCode& status) { fLength--; } -int32_t NumberStringBuilder::prepareForInsert(int32_t index, int32_t count, UErrorCode &status) { +int32_t FormattedStringBuilder::prepareForInsert(int32_t index, int32_t count, UErrorCode &status) { U_ASSERT(index >= 0); U_ASSERT(index <= fLength); U_ASSERT(count >= 0); @@ -279,7 +269,7 @@ int32_t NumberStringBuilder::prepareForInsert(int32_t index, int32_t count, UErr } } -int32_t NumberStringBuilder::prepareForInsertHelper(int32_t index, int32_t count, UErrorCode &status) { +int32_t FormattedStringBuilder::prepareForInsertHelper(int32_t index, int32_t count, UErrorCode &status) { int32_t oldCapacity = getCapacity(); int32_t oldZero = fZero; char16_t *oldChars = getCharPtr(); @@ -342,7 +332,7 @@ int32_t NumberStringBuilder::prepareForInsertHelper(int32_t index, int32_t count return fZero + index; } -int32_t NumberStringBuilder::remove(int32_t index, int32_t count) { +int32_t FormattedStringBuilder::remove(int32_t index, int32_t count) { // TODO: Reset the heap here? (If the string after removal can fit on stack?) int32_t position = index + fZero; uprv_memmove2(getCharPtr() + position, @@ -355,18 +345,18 @@ int32_t NumberStringBuilder::remove(int32_t index, int32_t count) { return position; } -UnicodeString NumberStringBuilder::toUnicodeString() const { +UnicodeString FormattedStringBuilder::toUnicodeString() const { return UnicodeString(getCharPtr() + fZero, fLength); } -const UnicodeString NumberStringBuilder::toTempUnicodeString() const { +const UnicodeString FormattedStringBuilder::toTempUnicodeString() const { // Readonly-alias constructor: return UnicodeString(FALSE, getCharPtr() + fZero, fLength); } -UnicodeString NumberStringBuilder::toDebugString() const { +UnicodeString FormattedStringBuilder::toDebugString() const { UnicodeString sb; - sb.append(u"= UNUM_FIELD_COUNT) { - status = U_ILLEGAL_ARGUMENT_ERROR; - return FALSE; - } - - ConstrainedFieldPosition cfpos; - cfpos.constrainField(UFIELD_CATEGORY_NUMBER, rawField); - cfpos.setState(UFIELD_CATEGORY_NUMBER, rawField, fp.getBeginIndex(), fp.getEndIndex()); - if (nextPosition(cfpos, 0, status)) { - fp.setBeginIndex(cfpos.getStart()); - fp.setEndIndex(cfpos.getLimit()); - return true; - } - - // Special case: fraction should start after integer if fraction is not present - if (rawField == UNUM_FRACTION_FIELD && fp.getEndIndex() == 0) { - bool inside = false; - int32_t i = fZero; - for (; i < fZero + fLength; i++) { - if (isIntOrGroup(getFieldPtr()[i]) || getFieldPtr()[i] == UNUM_DECIMAL_SEPARATOR_FIELD) { - inside = true; - } else if (inside) { - break; - } - } - fp.setBeginIndex(i - fZero); - fp.setEndIndex(i - fZero); - } - - return false; -} - -void NumberStringBuilder::getAllFieldPositions(FieldPositionIteratorHandler& fpih, - UErrorCode& status) const { - ConstrainedFieldPosition cfpos; - while (nextPosition(cfpos, 0, status)) { - fpih.addAttribute(cfpos.getField(), cfpos.getStart(), cfpos.getLimit()); - } -} - -// Signal the end of the string using a field that doesn't exist and that is -// different from UNUM_FIELD_COUNT, which is used for "null number field". -static constexpr Field kEndField = 0xff; - -bool NumberStringBuilder::nextPosition(ConstrainedFieldPosition& cfpos, Field numericField, UErrorCode& /*status*/) const { - auto numericCAF = NumFieldUtils::expand(numericField); - int32_t fieldStart = -1; - Field currField = UNUM_FIELD_COUNT; - for (int32_t i = fZero + cfpos.getLimit(); i <= fZero + fLength; i++) { - Field _field = (i < fZero + fLength) ? getFieldPtr()[i] : kEndField; - // Case 1: currently scanning a field. - if (currField != UNUM_FIELD_COUNT) { - if (currField != _field) { - int32_t end = i - fZero; - // Grouping separators can be whitespace; don't throw them out! - if (currField != UNUM_GROUPING_SEPARATOR_FIELD) { - end = trimBack(i - fZero); - } - if (end <= fieldStart) { - // Entire field position is ignorable; skip. - fieldStart = -1; - currField = UNUM_FIELD_COUNT; - i--; // look at this index again - continue; - } - int32_t start = fieldStart; - if (currField != UNUM_GROUPING_SEPARATOR_FIELD) { - start = trimFront(start); - } - auto caf = NumFieldUtils::expand(currField); - cfpos.setState(caf.category, caf.field, start, end); - return true; - } - continue; - } - // Special case: coalesce the INTEGER if we are pointing at the end of the INTEGER. - if (cfpos.matchesField(UFIELD_CATEGORY_NUMBER, UNUM_INTEGER_FIELD) - && i > fZero - // don't return the same field twice in a row: - && i - fZero > cfpos.getLimit() - && isIntOrGroup(getFieldPtr()[i - 1]) - && !isIntOrGroup(_field)) { - int j = i - 1; - for (; j >= fZero && isIntOrGroup(getFieldPtr()[j]); j--) {} - cfpos.setState(UFIELD_CATEGORY_NUMBER, UNUM_INTEGER_FIELD, j - fZero + 1, i - fZero); - return true; - } - // Special case: coalesce NUMERIC if we are pointing at the end of the NUMERIC. - if (numericField != 0 - && cfpos.matchesField(numericCAF.category, numericCAF.field) - && i > fZero - // don't return the same field twice in a row: - && (i - fZero > cfpos.getLimit() - || cfpos.getCategory() != numericCAF.category - || cfpos.getField() != numericCAF.field) - && isNumericField(getFieldPtr()[i - 1]) - && !isNumericField(_field)) { - int j = i - 1; - for (; j >= fZero && isNumericField(getFieldPtr()[j]); j--) {} - cfpos.setState(numericCAF.category, numericCAF.field, j - fZero + 1, i - fZero); - return true; - } - // Special case: skip over INTEGER; will be coalesced later. - if (_field == UNUM_INTEGER_FIELD) { - _field = UNUM_FIELD_COUNT; - } - // Case 2: no field starting at this position. - if (_field == UNUM_FIELD_COUNT || _field == kEndField) { - continue; - } - // Case 3: check for field starting at this position - auto caf = NumFieldUtils::expand(_field); - if (cfpos.matchesField(caf.category, caf.field)) { - fieldStart = i - fZero; - currField = _field; - } - } - - U_ASSERT(currField == UNUM_FIELD_COUNT); - return false; -} - -bool NumberStringBuilder::containsField(Field field) const { +bool FormattedStringBuilder::containsField(Field field) const { for (int32_t i = 0; i < fLength; i++) { if (field == fieldAt(i)) { return true; @@ -573,27 +434,6 @@ bool NumberStringBuilder::containsField(Field field) const { return false; } -bool NumberStringBuilder::isIntOrGroup(Field field) { - return field == UNUM_INTEGER_FIELD - || field == UNUM_GROUPING_SEPARATOR_FIELD; -} - -bool NumberStringBuilder::isNumericField(Field field) { - return NumFieldUtils::isNumericField(field); -} - -int32_t NumberStringBuilder::trimBack(int32_t limit) const { - return unisets::get(unisets::DEFAULT_IGNORABLES)->spanBack( - getCharPtr() + fZero, - limit, - USET_SPAN_CONTAINED); -} - -int32_t NumberStringBuilder::trimFront(int32_t start) const { - return start + unisets::get(unisets::DEFAULT_IGNORABLES)->span( - getCharPtr() + fZero + start, - fLength - start, - USET_SPAN_CONTAINED); -} +U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ diff --git a/deps/icu-small/source/i18n/formatted_string_builder.h b/deps/icu-small/source/i18n/formatted_string_builder.h new file mode 100644 index 00000000000000..2949ae73e0ff9e --- /dev/null +++ b/deps/icu-small/source/i18n/formatted_string_builder.h @@ -0,0 +1,253 @@ +// © 2017 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html + +#include "unicode/utypes.h" + +#if !UCONFIG_NO_FORMATTING +#ifndef __NUMBER_STRINGBUILDER_H__ +#define __NUMBER_STRINGBUILDER_H__ + + +#include +#include "unicode/unum.h" // for UNUM_FIELD_COUNT +#include "cstring.h" +#include "uassert.h" +#include "fphdlimp.h" + +U_NAMESPACE_BEGIN + +class FormattedValueStringBuilderImpl; + +/** + * A StringBuilder optimized for formatting. It implements the following key + * features beyond a UnicodeString: + * + *
    + *
  1. Efficient prepend as well as append. + *
  2. Keeps tracks of Fields in an efficient manner. + *
+ * + * See also FormattedValueStringBuilderImpl. + * + * @author sffc (Shane Carr) + */ +class U_I18N_API FormattedStringBuilder : public UMemory { + private: + static const int32_t DEFAULT_CAPACITY = 40; + + template + union ValueOrHeapArray { + T value[DEFAULT_CAPACITY]; + struct { + T *ptr; + int32_t capacity; + } heap; + }; + + public: + FormattedStringBuilder(); + + ~FormattedStringBuilder(); + + FormattedStringBuilder(const FormattedStringBuilder &other); + + // Convention: bottom 4 bits for field, top 4 bits for field category. + // Field category 0 implies the number category so that the number field + // literals can be directly passed as a Field type. + // See the helper functions in "StringBuilderFieldUtils" below. + typedef uint8_t Field; + + FormattedStringBuilder &operator=(const FormattedStringBuilder &other); + + int32_t length() const; + + int32_t codePointCount() const; + + inline char16_t charAt(int32_t index) const { + U_ASSERT(index >= 0); + U_ASSERT(index < fLength); + return getCharPtr()[fZero + index]; + } + + inline Field fieldAt(int32_t index) const { + U_ASSERT(index >= 0); + U_ASSERT(index < fLength); + return getFieldPtr()[fZero + index]; + } + + UChar32 getFirstCodePoint() const; + + UChar32 getLastCodePoint() const; + + UChar32 codePointAt(int32_t index) const; + + UChar32 codePointBefore(int32_t index) const; + + FormattedStringBuilder &clear(); + + /** Appends a UTF-16 code unit. */ + inline int32_t appendChar16(char16_t codeUnit, Field field, UErrorCode& status) { + // appendCodePoint handles both code units and code points. + return insertCodePoint(fLength, codeUnit, field, status); + } + + /** Inserts a UTF-16 code unit. Note: insert at index 0 is very efficient. */ + inline int32_t insertChar16(int32_t index, char16_t codeUnit, Field field, UErrorCode& status) { + // insertCodePoint handles both code units and code points. + return insertCodePoint(index, codeUnit, field, status); + } + + /** Appends a Unicode code point. */ + inline int32_t appendCodePoint(UChar32 codePoint, Field field, UErrorCode &status) { + return insertCodePoint(fLength, codePoint, field, status); + } + + /** Inserts a Unicode code point. Note: insert at index 0 is very efficient. */ + int32_t insertCodePoint(int32_t index, UChar32 codePoint, Field field, UErrorCode &status); + + /** Appends a string. */ + inline int32_t append(const UnicodeString &unistr, Field field, UErrorCode &status) { + return insert(fLength, unistr, field, status); + } + + /** Inserts a string. Note: insert at index 0 is very efficient. */ + int32_t insert(int32_t index, const UnicodeString &unistr, Field field, UErrorCode &status); + + /** Inserts a substring. Note: insert at index 0 is very efficient. + * + * @param start Start index of the substring of unistr to be inserted. + * @param end End index of the substring of unistr to be inserted (exclusive). + */ + int32_t insert(int32_t index, const UnicodeString &unistr, int32_t start, int32_t end, Field field, + UErrorCode &status); + + /** Deletes a substring and then inserts a string at that same position. + * Similar to JavaScript Array.prototype.splice(). + * + * @param startThis Start of the span to delete. + * @param endThis End of the span to delete (exclusive). + * @param unistr The string to insert at the deletion position. + * @param startOther Start index of the substring of unistr to be inserted. + * @param endOther End index of the substring of unistr to be inserted (exclusive). + */ + int32_t splice(int32_t startThis, int32_t endThis, const UnicodeString &unistr, + int32_t startOther, int32_t endOther, Field field, UErrorCode& status); + + /** Appends a formatted string. */ + int32_t append(const FormattedStringBuilder &other, UErrorCode &status); + + /** Inserts a formatted string. Note: insert at index 0 is very efficient. */ + int32_t insert(int32_t index, const FormattedStringBuilder &other, UErrorCode &status); + + /** + * Ensures that the string buffer contains a NUL terminator. The NUL terminator does + * not count toward the string length. Any further changes to the string (insert or + * append) may invalidate the NUL terminator. + * + * You should call this method after the formatted string is completely built if you + * plan to return a pointer to the string from a C API. + */ + void writeTerminator(UErrorCode& status); + + /** + * Gets a "safe" UnicodeString that can be used even after the FormattedStringBuilder is destructed. + */ + UnicodeString toUnicodeString() const; + + /** + * Gets an "unsafe" UnicodeString that is valid only as long as the FormattedStringBuilder is alive and + * unchanged. Slightly faster than toUnicodeString(). + */ + const UnicodeString toTempUnicodeString() const; + + UnicodeString toDebugString() const; + + const char16_t *chars() const; + + bool contentEquals(const FormattedStringBuilder &other) const; + + bool containsField(Field field) const; + + private: + bool fUsingHeap = false; + ValueOrHeapArray fChars; + ValueOrHeapArray fFields; + int32_t fZero = DEFAULT_CAPACITY / 2; + int32_t fLength = 0; + + inline char16_t *getCharPtr() { + return fUsingHeap ? fChars.heap.ptr : fChars.value; + } + + inline const char16_t *getCharPtr() const { + return fUsingHeap ? fChars.heap.ptr : fChars.value; + } + + inline Field *getFieldPtr() { + return fUsingHeap ? fFields.heap.ptr : fFields.value; + } + + inline const Field *getFieldPtr() const { + return fUsingHeap ? fFields.heap.ptr : fFields.value; + } + + inline int32_t getCapacity() const { + return fUsingHeap ? fChars.heap.capacity : DEFAULT_CAPACITY; + } + + int32_t prepareForInsert(int32_t index, int32_t count, UErrorCode &status); + + int32_t prepareForInsertHelper(int32_t index, int32_t count, UErrorCode &status); + + int32_t remove(int32_t index, int32_t count); + + friend class FormattedValueStringBuilderImpl; +}; + +/** + * Helper functions for dealing with the Field typedef, which stores fields + * in a compressed format. + */ +class StringBuilderFieldUtils { +public: + struct CategoryFieldPair { + int32_t category; + int32_t field; + }; + + /** Compile-time function to construct a Field from a category and a field */ + template + static constexpr FormattedStringBuilder::Field compress() { + static_assert(category != 0, "cannot use Undefined category in FieldUtils"); + static_assert(category <= 0xf, "only 4 bits for category"); + static_assert(field <= 0xf, "only 4 bits for field"); + return static_cast((category << 4) | field); + } + + /** Runtime inline function to unpack the category and field from the Field */ + static inline CategoryFieldPair expand(FormattedStringBuilder::Field field) { + if (field == UNUM_FIELD_COUNT) { + return {UFIELD_CATEGORY_UNDEFINED, 0}; + } + CategoryFieldPair ret = { + (field >> 4), + (field & 0xf) + }; + if (ret.category == 0) { + ret.category = UFIELD_CATEGORY_NUMBER; + } + return ret; + } + + static inline bool isNumericField(FormattedStringBuilder::Field field) { + int8_t category = field >> 4; + return category == 0 || category == UFIELD_CATEGORY_NUMBER; + } +}; + +U_NAMESPACE_END + + +#endif //__NUMBER_STRINGBUILDER_H__ + +#endif /* #if !UCONFIG_NO_FORMATTING */ diff --git a/deps/icu-small/source/i18n/formattedval_impl.h b/deps/icu-small/source/i18n/formattedval_impl.h index 69ba0922edc81f..4ee53e4589b2e9 100644 --- a/deps/icu-small/source/i18n/formattedval_impl.h +++ b/deps/icu-small/source/i18n/formattedval_impl.h @@ -18,7 +18,7 @@ #include "fphdlimp.h" #include "util.h" #include "uvectr32.h" -#include "number_stringbuilder.h" +#include "formatted_string_builder.h" /** @@ -67,7 +67,9 @@ typedef enum UCFPosConstraintType { U_NAMESPACE_BEGIN -/** Implementation using FieldPositionHandler to accept fields. */ +/** + * Implementation of FormattedValue using FieldPositionHandler to accept fields. + */ class FormattedValueFieldPositionIteratorImpl : public UMemory, public FormattedValue { public: @@ -112,12 +114,21 @@ class FormattedValueFieldPositionIteratorImpl : public UMemory, public Formatted }; -class FormattedValueNumberStringBuilderImpl : public UMemory, public FormattedValue { +/** + * Implementation of FormattedValue based on FormattedStringBuilder. + * + * The implementation currently revolves around numbers and number fields. + * However, it can be generalized in the future when there is a need. + * + * @author sffc (Shane Carr) + */ +// Exported as U_I18N_API for tests +class U_I18N_API FormattedValueStringBuilderImpl : public UMemory, public FormattedValue { public: - FormattedValueNumberStringBuilderImpl(number::impl::Field numericField); + FormattedValueStringBuilderImpl(FormattedStringBuilder::Field numericField); - virtual ~FormattedValueNumberStringBuilderImpl(); + virtual ~FormattedValueStringBuilderImpl(); // Implementation of FormattedValue (const): @@ -126,17 +137,25 @@ class FormattedValueNumberStringBuilderImpl : public UMemory, public FormattedVa Appendable& appendTo(Appendable& appendable, UErrorCode& status) const U_OVERRIDE; UBool nextPosition(ConstrainedFieldPosition& cfpos, UErrorCode& status) const U_OVERRIDE; - inline number::impl::NumberStringBuilder& getStringRef() { + // Additional helper functions: + UBool nextFieldPosition(FieldPosition& fp, UErrorCode& status) const; + void getAllFieldPositions(FieldPositionIteratorHandler& fpih, UErrorCode& status) const; + inline FormattedStringBuilder& getStringRef() { return fString; } - - inline const number::impl::NumberStringBuilder& getStringRef() const { + inline const FormattedStringBuilder& getStringRef() const { return fString; } private: - number::impl::NumberStringBuilder fString; - number::impl::Field fNumericField; + FormattedStringBuilder fString; + FormattedStringBuilder::Field fNumericField; + + bool nextPositionImpl(ConstrainedFieldPosition& cfpos, FormattedStringBuilder::Field numericField, UErrorCode& status) const; + static bool isIntOrGroup(FormattedStringBuilder::Field field); + static bool isNumericField(FormattedStringBuilder::Field field); + int32_t trimBack(int32_t limit) const; + int32_t trimFront(int32_t start) const; }; diff --git a/deps/icu-small/source/i18n/formattedval_sbimpl.cpp b/deps/icu-small/source/i18n/formattedval_sbimpl.cpp index 1fbecf25ac6bb6..ca28f222813afc 100644 --- a/deps/icu-small/source/i18n/formattedval_sbimpl.cpp +++ b/deps/icu-small/source/i18n/formattedval_sbimpl.cpp @@ -9,35 +9,203 @@ // Other independent implementations should go into their own cpp file for // better dependency modularization. +#include "unicode/ustring.h" #include "formattedval_impl.h" +#include "number_types.h" +#include "formatted_string_builder.h" +#include "number_utils.h" +#include "static_unicode_sets.h" U_NAMESPACE_BEGIN -FormattedValueNumberStringBuilderImpl::FormattedValueNumberStringBuilderImpl(number::impl::Field numericField) +typedef FormattedStringBuilder::Field Field; + + +FormattedValueStringBuilderImpl::FormattedValueStringBuilderImpl(Field numericField) : fNumericField(numericField) { } -FormattedValueNumberStringBuilderImpl::~FormattedValueNumberStringBuilderImpl() { +FormattedValueStringBuilderImpl::~FormattedValueStringBuilderImpl() { } -UnicodeString FormattedValueNumberStringBuilderImpl::toString(UErrorCode&) const { +UnicodeString FormattedValueStringBuilderImpl::toString(UErrorCode&) const { return fString.toUnicodeString(); } -UnicodeString FormattedValueNumberStringBuilderImpl::toTempString(UErrorCode&) const { +UnicodeString FormattedValueStringBuilderImpl::toTempString(UErrorCode&) const { return fString.toTempUnicodeString(); } -Appendable& FormattedValueNumberStringBuilderImpl::appendTo(Appendable& appendable, UErrorCode&) const { +Appendable& FormattedValueStringBuilderImpl::appendTo(Appendable& appendable, UErrorCode&) const { appendable.appendString(fString.chars(), fString.length()); return appendable; } -UBool FormattedValueNumberStringBuilderImpl::nextPosition(ConstrainedFieldPosition& cfpos, UErrorCode& status) const { +UBool FormattedValueStringBuilderImpl::nextPosition(ConstrainedFieldPosition& cfpos, UErrorCode& status) const { // NOTE: MSVC sometimes complains when implicitly converting between bool and UBool - return fString.nextPosition(cfpos, fNumericField, status) ? TRUE : FALSE; + return nextPositionImpl(cfpos, fNumericField, status) ? TRUE : FALSE; +} + +UBool FormattedValueStringBuilderImpl::nextFieldPosition(FieldPosition& fp, UErrorCode& status) const { + int32_t rawField = fp.getField(); + + if (rawField == FieldPosition::DONT_CARE) { + return FALSE; + } + + if (rawField < 0 || rawField >= UNUM_FIELD_COUNT) { + status = U_ILLEGAL_ARGUMENT_ERROR; + return FALSE; + } + + ConstrainedFieldPosition cfpos; + cfpos.constrainField(UFIELD_CATEGORY_NUMBER, rawField); + cfpos.setState(UFIELD_CATEGORY_NUMBER, rawField, fp.getBeginIndex(), fp.getEndIndex()); + if (nextPositionImpl(cfpos, 0, status)) { + fp.setBeginIndex(cfpos.getStart()); + fp.setEndIndex(cfpos.getLimit()); + return TRUE; + } + + // Special case: fraction should start after integer if fraction is not present + if (rawField == UNUM_FRACTION_FIELD && fp.getEndIndex() == 0) { + bool inside = false; + int32_t i = fString.fZero; + for (; i < fString.fZero + fString.fLength; i++) { + if (isIntOrGroup(fString.getFieldPtr()[i]) || fString.getFieldPtr()[i] == UNUM_DECIMAL_SEPARATOR_FIELD) { + inside = true; + } else if (inside) { + break; + } + } + fp.setBeginIndex(i - fString.fZero); + fp.setEndIndex(i - fString.fZero); + } + + return FALSE; +} + +void FormattedValueStringBuilderImpl::getAllFieldPositions(FieldPositionIteratorHandler& fpih, + UErrorCode& status) const { + ConstrainedFieldPosition cfpos; + while (nextPositionImpl(cfpos, 0, status)) { + fpih.addAttribute(cfpos.getField(), cfpos.getStart(), cfpos.getLimit()); + } +} + +// Signal the end of the string using a field that doesn't exist and that is +// different from UNUM_FIELD_COUNT, which is used for "null number field". +static constexpr Field kEndField = 0xff; + +bool FormattedValueStringBuilderImpl::nextPositionImpl(ConstrainedFieldPosition& cfpos, Field numericField, UErrorCode& /*status*/) const { + auto numericCAF = StringBuilderFieldUtils::expand(numericField); + int32_t fieldStart = -1; + Field currField = UNUM_FIELD_COUNT; + for (int32_t i = fString.fZero + cfpos.getLimit(); i <= fString.fZero + fString.fLength; i++) { + Field _field = (i < fString.fZero + fString.fLength) ? fString.getFieldPtr()[i] : kEndField; + // Case 1: currently scanning a field. + if (currField != UNUM_FIELD_COUNT) { + if (currField != _field) { + int32_t end = i - fString.fZero; + // Grouping separators can be whitespace; don't throw them out! + if (currField != UNUM_GROUPING_SEPARATOR_FIELD) { + end = trimBack(i - fString.fZero); + } + if (end <= fieldStart) { + // Entire field position is ignorable; skip. + fieldStart = -1; + currField = UNUM_FIELD_COUNT; + i--; // look at this index again + continue; + } + int32_t start = fieldStart; + if (currField != UNUM_GROUPING_SEPARATOR_FIELD) { + start = trimFront(start); + } + auto caf = StringBuilderFieldUtils::expand(currField); + cfpos.setState(caf.category, caf.field, start, end); + return true; + } + continue; + } + // Special case: coalesce the INTEGER if we are pointing at the end of the INTEGER. + if (cfpos.matchesField(UFIELD_CATEGORY_NUMBER, UNUM_INTEGER_FIELD) + && i > fString.fZero + // don't return the same field twice in a row: + && i - fString.fZero > cfpos.getLimit() + && isIntOrGroup(fString.getFieldPtr()[i - 1]) + && !isIntOrGroup(_field)) { + int j = i - 1; + for (; j >= fString.fZero && isIntOrGroup(fString.getFieldPtr()[j]); j--) {} + cfpos.setState( + UFIELD_CATEGORY_NUMBER, + UNUM_INTEGER_FIELD, + j - fString.fZero + 1, + i - fString.fZero); + return true; + } + // Special case: coalesce NUMERIC if we are pointing at the end of the NUMERIC. + if (numericField != 0 + && cfpos.matchesField(numericCAF.category, numericCAF.field) + && i > fString.fZero + // don't return the same field twice in a row: + && (i - fString.fZero > cfpos.getLimit() + || cfpos.getCategory() != numericCAF.category + || cfpos.getField() != numericCAF.field) + && isNumericField(fString.getFieldPtr()[i - 1]) + && !isNumericField(_field)) { + int j = i - 1; + for (; j >= fString.fZero && isNumericField(fString.getFieldPtr()[j]); j--) {} + cfpos.setState( + numericCAF.category, + numericCAF.field, + j - fString.fZero + 1, + i - fString.fZero); + return true; + } + // Special case: skip over INTEGER; will be coalesced later. + if (_field == UNUM_INTEGER_FIELD) { + _field = UNUM_FIELD_COUNT; + } + // Case 2: no field starting at this position. + if (_field == UNUM_FIELD_COUNT || _field == kEndField) { + continue; + } + // Case 3: check for field starting at this position + auto caf = StringBuilderFieldUtils::expand(_field); + if (cfpos.matchesField(caf.category, caf.field)) { + fieldStart = i - fString.fZero; + currField = _field; + } + } + + U_ASSERT(currField == UNUM_FIELD_COUNT); + return false; +} + +bool FormattedValueStringBuilderImpl::isIntOrGroup(Field field) { + return field == UNUM_INTEGER_FIELD + || field == UNUM_GROUPING_SEPARATOR_FIELD; +} + +bool FormattedValueStringBuilderImpl::isNumericField(Field field) { + return StringBuilderFieldUtils::isNumericField(field); +} + +int32_t FormattedValueStringBuilderImpl::trimBack(int32_t limit) const { + return unisets::get(unisets::DEFAULT_IGNORABLES)->spanBack( + fString.getCharPtr() + fString.fZero, + limit, + USET_SPAN_CONTAINED); +} + +int32_t FormattedValueStringBuilderImpl::trimFront(int32_t start) const { + return start + unisets::get(unisets::DEFAULT_IGNORABLES)->span( + fString.getCharPtr() + fString.fZero + start, + fString.fLength - start, + USET_SPAN_CONTAINED); } diff --git a/deps/icu-small/source/i18n/funcrepl.cpp b/deps/icu-small/source/i18n/funcrepl.cpp index 30bcebbf908794..ceb456e1afc50c 100644 --- a/deps/icu-small/source/i18n/funcrepl.cpp +++ b/deps/icu-small/source/i18n/funcrepl.cpp @@ -59,7 +59,7 @@ FunctionReplacer::~FunctionReplacer() { /** * Implement UnicodeFunctor */ -UnicodeFunctor* FunctionReplacer::clone() const { +FunctionReplacer* FunctionReplacer::clone() const { return new FunctionReplacer(*this); } diff --git a/deps/icu-small/source/i18n/funcrepl.h b/deps/icu-small/source/i18n/funcrepl.h index a835d5be7c2173..fe41f6caaa6d10 100644 --- a/deps/icu-small/source/i18n/funcrepl.h +++ b/deps/icu-small/source/i18n/funcrepl.h @@ -70,7 +70,7 @@ class FunctionReplacer : public UnicodeFunctor, public UnicodeReplacer { /** * Implement UnicodeFunctor */ - virtual UnicodeFunctor* clone() const; + virtual FunctionReplacer* clone() const; /** * UnicodeFunctor API. Cast 'this' to a UnicodeReplacer* pointer diff --git a/deps/icu-small/source/i18n/gender.cpp b/deps/icu-small/source/i18n/gender.cpp index 106cf424c59d88..03c03cecad94ba 100644 --- a/deps/icu-small/source/i18n/gender.cpp +++ b/deps/icu-small/source/i18n/gender.cpp @@ -98,7 +98,7 @@ const GenderInfo* GenderInfo::getInstance(const Locale& locale, UErrorCode& stat return NULL; } - static UMutex gGenderMetaLock = U_MUTEX_INITIALIZER; + static UMutex gGenderMetaLock; const GenderInfo* result = NULL; const char* key = locale.getName(); { diff --git a/deps/icu-small/source/i18n/gregocal.cpp b/deps/icu-small/source/i18n/gregocal.cpp index 4db66758df1f1f..028ab05aa9accc 100644 --- a/deps/icu-small/source/i18n/gregocal.cpp +++ b/deps/icu-small/source/i18n/gregocal.cpp @@ -286,7 +286,7 @@ fIsGregorian(source.fIsGregorian), fInvertGregorian(source.fInvertGregorian) // ------------------------------------- -Calendar* GregorianCalendar::clone() const +GregorianCalendar* GregorianCalendar::clone() const { return new GregorianCalendar(*this); } @@ -324,26 +324,26 @@ GregorianCalendar::setGregorianChange(UDate date, UErrorCode& status) if (U_FAILURE(status)) return; - fGregorianCutover = date; - // Precompute two internal variables which we use to do the actual // cutover computations. These are the normalized cutover, which is the // midnight at or before the cutover, and the cutover year. The // normalized cutover is in pure date milliseconds; it contains no time // of day or timezone component, and it used to compare against other // pure date values. - int32_t cutoverDay = (int32_t)ClockMath::floorDivide(fGregorianCutover, (double)kOneDay); - fNormalizedGregorianCutover = cutoverDay * kOneDay; - - // Handle the rare case of numeric overflow. If the user specifies a - // change of UDate(Long.MIN_VALUE), in order to get a pure Gregorian - // calendar, then the epoch day is -106751991168, which when multiplied - // by ONE_DAY gives 9223372036794351616 -- the negative value is too - // large for 64 bits, and overflows into a positive value. We correct - // this by using the next day, which for all intents is semantically - // equivalent. - if (cutoverDay < 0 && fNormalizedGregorianCutover > 0) { - fNormalizedGregorianCutover = (cutoverDay + 1) * kOneDay; + double cutoverDay = ClockMath::floorDivide(date, (double)kOneDay); + + // Handle the rare case of numeric overflow where the user specifies a time + // outside of INT32_MIN .. INT32_MAX number of days. + + if (cutoverDay <= INT32_MIN) { + cutoverDay = INT32_MIN; + fGregorianCutover = fNormalizedGregorianCutover = cutoverDay * kOneDay; + } else if (cutoverDay >= INT32_MAX) { + cutoverDay = INT32_MAX; + fGregorianCutover = fNormalizedGregorianCutover = cutoverDay * kOneDay; + } else { + fNormalizedGregorianCutover = cutoverDay * kOneDay; + fGregorianCutover = date; } // Normalize the year so BC values are represented as 0 and negative @@ -360,7 +360,7 @@ GregorianCalendar::setGregorianChange(UDate date, UErrorCode& status) fGregorianCutoverYear = cal->get(UCAL_YEAR, status); if (cal->get(UCAL_ERA, status) == BC) fGregorianCutoverYear = 1 - fGregorianCutoverYear; - fCutoverJulianDay = cutoverDay; + fCutoverJulianDay = (int32_t)cutoverDay; delete cal; } diff --git a/deps/icu-small/source/i18n/hebrwcal.cpp b/deps/icu-small/source/i18n/hebrwcal.cpp index 66a3e47a4f1e0f..085ded784651a6 100644 --- a/deps/icu-small/source/i18n/hebrwcal.cpp +++ b/deps/icu-small/source/i18n/hebrwcal.cpp @@ -169,7 +169,7 @@ const char *HebrewCalendar::getType() const { return "hebrew"; } -Calendar* HebrewCalendar::clone() const { +HebrewCalendar* HebrewCalendar::clone() const { return new HebrewCalendar(*this); } diff --git a/deps/icu-small/source/i18n/hebrwcal.h b/deps/icu-small/source/i18n/hebrwcal.h index 9323ad62aa72fa..97e8511705e776 100644 --- a/deps/icu-small/source/i18n/hebrwcal.h +++ b/deps/icu-small/source/i18n/hebrwcal.h @@ -192,7 +192,7 @@ class U_I18N_API HebrewCalendar : public Calendar { * @return return a polymorphic copy of this calendar. * @internal */ - virtual Calendar* clone(void) const; + virtual HebrewCalendar* clone() const; public: /** diff --git a/deps/icu-small/source/i18n/indiancal.cpp b/deps/icu-small/source/i18n/indiancal.cpp index 667b6f2d7a32c5..f1266bb7757939 100644 --- a/deps/icu-small/source/i18n/indiancal.cpp +++ b/deps/icu-small/source/i18n/indiancal.cpp @@ -35,7 +35,7 @@ U_NAMESPACE_BEGIN //------------------------------------------------------------------------- -Calendar* IndianCalendar::clone() const { +IndianCalendar* IndianCalendar::clone() const { return new IndianCalendar(*this); } diff --git a/deps/icu-small/source/i18n/indiancal.h b/deps/icu-small/source/i18n/indiancal.h index ffd4ae8b8a40cd..142597ce0e6b02 100644 --- a/deps/icu-small/source/i18n/indiancal.h +++ b/deps/icu-small/source/i18n/indiancal.h @@ -186,7 +186,7 @@ class U_I18N_API IndianCalendar : public Calendar { // TODO: copy c'tor, etc // clone - virtual Calendar* clone() const; + virtual IndianCalendar* clone() const; private: /** diff --git a/deps/icu-small/source/i18n/islamcal.cpp b/deps/icu-small/source/i18n/islamcal.cpp index 8d6171af011e5d..4e4a6648048208 100644 --- a/deps/icu-small/source/i18n/islamcal.cpp +++ b/deps/icu-small/source/i18n/islamcal.cpp @@ -227,7 +227,7 @@ const char *IslamicCalendar::getType() const { return sType; } -Calendar* IslamicCalendar::clone() const { +IslamicCalendar* IslamicCalendar::clone() const { return new IslamicCalendar(*this); } @@ -470,7 +470,7 @@ double IslamicCalendar::moonAge(UDate time, UErrorCode &status) { double age = 0; - static UMutex astroLock = U_MUTEX_INITIALIZER; // pod bay door lock + static UMutex astroLock; // pod bay door lock umtx_lock(&astroLock); if(gIslamicCalendarAstro == NULL) { gIslamicCalendarAstro = new CalendarAstronomer(); diff --git a/deps/icu-small/source/i18n/islamcal.h b/deps/icu-small/source/i18n/islamcal.h index 17fb6687ef7b63..aad8f07be0f984 100644 --- a/deps/icu-small/source/i18n/islamcal.h +++ b/deps/icu-small/source/i18n/islamcal.h @@ -230,7 +230,7 @@ class U_I18N_API IslamicCalendar : public Calendar { // TODO: copy c'tor, etc // clone - virtual Calendar* clone() const; + virtual IslamicCalendar* clone() const; private: /** diff --git a/deps/icu-small/source/i18n/japancal.cpp b/deps/icu-small/source/i18n/japancal.cpp index cc061fd1410d84..e7e5f4fc5174f6 100644 --- a/deps/icu-small/source/i18n/japancal.cpp +++ b/deps/icu-small/source/i18n/japancal.cpp @@ -136,7 +136,7 @@ JapaneseCalendar& JapaneseCalendar::operator= ( const JapaneseCalendar& right) return *this; } -Calendar* JapaneseCalendar::clone(void) const +JapaneseCalendar* JapaneseCalendar::clone() const { return new JapaneseCalendar(*this); } diff --git a/deps/icu-small/source/i18n/japancal.h b/deps/icu-small/source/i18n/japancal.h index a32f3db5635473..ee86c4ed0e3b93 100644 --- a/deps/icu-small/source/i18n/japancal.h +++ b/deps/icu-small/source/i18n/japancal.h @@ -116,7 +116,7 @@ class JapaneseCalendar : public GregorianCalendar { * @return return a polymorphic copy of this calendar. * @internal */ - virtual Calendar* clone(void) const; + virtual JapaneseCalendar* clone() const; /** * Return the extended year defined by the current fields. In the diff --git a/deps/icu-small/source/i18n/listformatter.cpp b/deps/icu-small/source/i18n/listformatter.cpp index 64d2e36ae15059..35cc00de252aa7 100644 --- a/deps/icu-small/source/i18n/listformatter.cpp +++ b/deps/icu-small/source/i18n/listformatter.cpp @@ -144,7 +144,7 @@ const ListFormatInternal* ListFormatter::getListFormatInternal( keyBuffer.append(':', errorCode).append(style, errorCode); UnicodeString key(keyBuffer.data(), -1, US_INV); ListFormatInternal* result = nullptr; - static UMutex listFormatterMutex = U_MUTEX_INITIALIZER; + static UMutex listFormatterMutex; { Mutex m(&listFormatterMutex); if (listPatternHash == nullptr) { @@ -478,8 +478,8 @@ UnicodeString& ListFormatter::format_( if (index == 0) { offset = 0; } - int32_t offsetFirst; - int32_t offsetSecond; + int32_t offsetFirst = 0; + int32_t offsetSecond = 0; int32_t prefixLength = 0; // for n items, there are 2 * (n + 1) boundary including 0 and the upper // edge. diff --git a/deps/icu-small/source/i18n/measfmt.cpp b/deps/icu-small/source/i18n/measfmt.cpp index 03e4417e64da6a..47ffb140cf6712 100644 --- a/deps/icu-small/source/i18n/measfmt.cpp +++ b/deps/icu-small/source/i18n/measfmt.cpp @@ -55,28 +55,23 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(MeasureFormat) class NumericDateFormatters : public UMemory { public: // Formats like H:mm - SimpleDateFormat hourMinute; + UnicodeString hourMinute; // formats like M:ss - SimpleDateFormat minuteSecond; + UnicodeString minuteSecond; // formats like H:mm:ss - SimpleDateFormat hourMinuteSecond; + UnicodeString hourMinuteSecond; // Constructor that takes the actual patterns for hour-minute, // minute-second, and hour-minute-second respectively. NumericDateFormatters( const UnicodeString &hm, const UnicodeString &ms, - const UnicodeString &hms, - UErrorCode &status) : - hourMinute(hm, status), - minuteSecond(ms, status), - hourMinuteSecond(hms, status) { - const TimeZone *gmt = TimeZone::getGMT(); - hourMinute.setTimeZone(*gmt); - minuteSecond.setTimeZone(*gmt); - hourMinuteSecond.setTimeZone(*gmt); + const UnicodeString &hms) : + hourMinute(hm), + minuteSecond(ms), + hourMinuteSecond(hms) { } private: NumericDateFormatters(const NumericDateFormatters &other); @@ -233,8 +228,7 @@ static NumericDateFormatters *loadNumericDateFormatters( NumericDateFormatters *result = new NumericDateFormatters( loadNumericDateFormatterPattern(resource, "hm", status), loadNumericDateFormatterPattern(resource, "ms", status), - loadNumericDateFormatterPattern(resource, "hms", status), - status); + loadNumericDateFormatterPattern(resource, "hms", status)); if (U_FAILURE(status)) { delete result; return NULL; @@ -466,7 +460,7 @@ UBool MeasureFormat::operator==(const Format &other) const { **numberFormat == **rhs.numberFormat); } -Format *MeasureFormat::clone() const { +MeasureFormat *MeasureFormat::clone() const { return new MeasureFormat(*this); } @@ -691,9 +685,19 @@ UnicodeString &MeasureFormat::formatMeasure( } auto* df = dynamic_cast(&nf); if (df == nullptr) { - // Don't know how to handle other types of NumberFormat - status = U_UNSUPPORTED_ERROR; - return appendTo; + // Handle other types of NumberFormat using the ICU 63 code, modified to + // get the unitPattern from LongNameHandler and handle fallback to OTHER. + UnicodeString formattedNumber; + StandardPlural::Form pluralForm = QuantityFormatter::selectPlural( + amtNumber, nf, **pluralRules, formattedNumber, pos, status); + UnicodeString pattern = number::impl::LongNameHandler::getUnitPattern(getLocale(status), + amtUnit, getUnitWidth(fWidth), pluralForm, status); + // The above handles fallback from other widths to short, and from other plural forms to OTHER + if (U_FAILURE(status)) { + return appendTo; + } + SimpleFormatter formatter(pattern, 0, 1, status); + return QuantityFormatter::format(formatter, formattedNumber, appendTo, pos, status); } number::FormattedNumber result; if (auto* lnf = df->toNumberFormatter(status)) { @@ -706,135 +710,112 @@ UnicodeString &MeasureFormat::formatMeasure( return appendTo; } -// Formats hours-minutes-seconds as 5:37:23 or similar. + +// Formats numeric time duration as 5:00:47 or 3:54. UnicodeString &MeasureFormat::formatNumeric( const Formattable *hms, // always length 3 - int32_t bitMap, // 1=hourset, 2=minuteset, 4=secondset + int32_t bitMap, // 1=hour set, 2=minute set, 4=second set UnicodeString &appendTo, UErrorCode &status) const { if (U_FAILURE(status)) { return appendTo; } - UDate millis = - (UDate) (((uprv_trunc(hms[0].getDouble(status)) * 60.0 - + uprv_trunc(hms[1].getDouble(status))) * 60.0 - + uprv_trunc(hms[2].getDouble(status))) * 1000.0); - switch (bitMap) { - case 5: // hs - case 7: // hms - return formatNumeric( - millis, - cache->getNumericDateFormatters()->hourMinuteSecond, - UDAT_SECOND_FIELD, - hms[2], - appendTo, - status); - break; - case 6: // ms - return formatNumeric( - millis, - cache->getNumericDateFormatters()->minuteSecond, - UDAT_SECOND_FIELD, - hms[2], - appendTo, - status); - break; - case 3: // hm - return formatNumeric( - millis, - cache->getNumericDateFormatters()->hourMinute, - UDAT_MINUTE_FIELD, - hms[1], - appendTo, - status); - break; - default: - status = U_INTERNAL_PROGRAM_ERROR; - return appendTo; - break; - } -} - -static void appendRange( - const UnicodeString &src, - int32_t start, - int32_t end, - UnicodeString &dest) { - dest.append(src, start, end - start); -} -static void appendRange( - const UnicodeString &src, - int32_t end, - UnicodeString &dest) { - dest.append(src, end, src.length() - end); -} + UnicodeString pattern; -// Formats time like 5:37:23 -UnicodeString &MeasureFormat::formatNumeric( - UDate date, // Time since epoch 1:30:00 would be 5400000 - const DateFormat &dateFmt, // h:mm, m:ss, or h:mm:ss - UDateFormatField smallestField, // seconds in 5:37:23.5 - const Formattable &smallestAmount, // 23.5 for 5:37:23.5 - UnicodeString &appendTo, - UErrorCode &status) const { + double hours = hms[0].getDouble(status); + double minutes = hms[1].getDouble(status); + double seconds = hms[2].getDouble(status); if (U_FAILURE(status)) { return appendTo; } - // Format the smallest amount with this object's NumberFormat - UnicodeString smallestAmountFormatted; - - // We keep track of the integer part of smallest amount so that - // we can replace it later so that we get '0:00:09.3' instead of - // '0:00:9.3' - FieldPosition intFieldPosition(UNUM_INTEGER_FIELD); - (*numberFormat)->format( - smallestAmount, smallestAmountFormatted, intFieldPosition, status); - if ( - intFieldPosition.getBeginIndex() == 0 && - intFieldPosition.getEndIndex() == 0) { + + // All possible combinations: "h", "m", "s", "hm", "hs", "ms", "hms" + if (bitMap == 5 || bitMap == 7) { // "hms" & "hs" (we add minutes if "hs") + pattern = cache->getNumericDateFormatters()->hourMinuteSecond; + hours = uprv_trunc(hours); + minutes = uprv_trunc(minutes); + } else if (bitMap == 3) { // "hm" + pattern = cache->getNumericDateFormatters()->hourMinute; + hours = uprv_trunc(hours); + } else if (bitMap == 6) { // "ms" + pattern = cache->getNumericDateFormatters()->minuteSecond; + minutes = uprv_trunc(minutes); + } else { // h m s, handled outside formatNumeric. No value is also an error. status = U_INTERNAL_PROGRAM_ERROR; return appendTo; } - // Format time. draft becomes something like '5:30:45' - // #13606: DateFormat is not thread-safe, but MeasureFormat advertises itself as thread-safe. - FieldPosition smallestFieldPosition(smallestField); - UnicodeString draft; - static UMutex dateFmtMutex = U_MUTEX_INITIALIZER; - umtx_lock(&dateFmtMutex); - dateFmt.format(date, draft, smallestFieldPosition, status); - umtx_unlock(&dateFmtMutex); - - // If we find field for smallest amount replace it with the formatted - // smallest amount from above taking care to replace the integer part - // with what is in original time. For example, If smallest amount - // is 9.35s and the formatted time is 0:00:09 then 9.35 becomes 09.35 - // and replacing yields 0:00:09.35 - if (smallestFieldPosition.getBeginIndex() != 0 || - smallestFieldPosition.getEndIndex() != 0) { - appendRange(draft, 0, smallestFieldPosition.getBeginIndex(), appendTo); - appendRange( - smallestAmountFormatted, - 0, - intFieldPosition.getBeginIndex(), - appendTo); - appendRange( - draft, - smallestFieldPosition.getBeginIndex(), - smallestFieldPosition.getEndIndex(), - appendTo); - appendRange( - smallestAmountFormatted, - intFieldPosition.getEndIndex(), - appendTo); - appendRange( - draft, - smallestFieldPosition.getEndIndex(), - appendTo); + const DecimalFormat *numberFormatter = dynamic_cast(numberFormat->get()); + if (!numberFormatter) { + status = U_INTERNAL_PROGRAM_ERROR; + return appendTo; + } + number::LocalizedNumberFormatter numberFormatter2; + if (auto* lnf = numberFormatter->toNumberFormatter(status)) { + numberFormatter2 = lnf->integerWidth(number::IntegerWidth::zeroFillTo(2)); } else { - appendTo.append(draft); + return appendTo; } + + FormattedStringBuilder fsb; + + UBool protect = FALSE; + const int32_t patternLength = pattern.length(); + for (int32_t i = 0; i < patternLength; i++) { + char16_t c = pattern[i]; + + // Also set the proper field in this switch + // We don't use DateFormat.Field because this is not a date / time, is a duration. + double value = 0; + switch (c) { + case u'H': value = hours; break; + case u'm': value = minutes; break; + case u's': value = seconds; break; + } + + // For undefined field we use UNUM_FIELD_COUNT, for historical reasons. + // See cleanup bug: https://unicode-org.atlassian.net/browse/ICU-20665 + // But we give it a clear name, to keep "the ugly part" in one place. + constexpr UNumberFormatFields undefinedField = UNUM_FIELD_COUNT; + + // There is not enough info to add Field(s) for the unit because all we have are plain + // text patterns. For example in "21:51" there is no text for something like "hour", + // while in something like "21h51" there is ("h"). But we can't really tell... + switch (c) { + case u'H': + case u'm': + case u's': + if (protect) { + fsb.appendChar16(c, undefinedField, status); + } else { + UnicodeString tmp; + if ((i + 1 < patternLength) && pattern[i + 1] == c) { // doubled + tmp = numberFormatter2.formatDouble(value, status).toString(status); + i++; + } else { + numberFormatter->format(value, tmp, status); + } + // TODO: Use proper Field + fsb.append(tmp, undefinedField, status); + } + break; + case u'\'': + // '' is escaped apostrophe + if ((i + 1 < patternLength) && pattern[i + 1] == c) { + fsb.appendChar16(c, undefinedField, status); + i++; + } else { + protect = !protect; + } + break; + default: + fsb.appendChar16(c, undefinedField, status); + } + } + + appendTo.append(fsb.toTempUnicodeString()); + return appendTo; } diff --git a/deps/icu-small/source/i18n/measunit.cpp b/deps/icu-small/source/i18n/measunit.cpp index 428283e6dda8d4..917c0cdfadf235 100644 --- a/deps/icu-small/source/i18n/measunit.cpp +++ b/deps/icu-small/source/i18n/measunit.cpp @@ -43,21 +43,22 @@ static const int32_t gOffsets[] = { 29, 328, 339, - 354, - 358, - 366, + 355, + 359, 368, - 372, - 393, - 395, - 409, - 412, + 370, + 374, + 381, + 402, + 404, 418, - 426, - 430, - 434, - 436, - 463 + 421, + 427, + 437, + 441, + 445, + 447, + 474 }; static const int32_t gIndexes[] = { @@ -69,21 +70,22 @@ static const int32_t gIndexes[] = { 29, 29, 40, - 55, - 59, - 67, + 56, + 60, 69, - 73, - 94, - 96, - 110, - 113, + 71, + 75, + 82, + 103, + 105, 119, - 127, - 131, - 135, - 137, - 164 + 122, + 128, + 138, + 142, + 146, + 148, + 175 }; // Must be sorted alphabetically. @@ -100,6 +102,7 @@ static const char * const gTypes[] = { "energy", "force", "frequency", + "graphics", "length", "light", "mass", @@ -456,6 +459,7 @@ static const char * const gSubTypes[] = { "century", "day", "day-person", + "decade", "hour", "microsecond", "millisecond", @@ -480,12 +484,20 @@ static const char * const gSubTypes[] = { "kilocalorie", "kilojoule", "kilowatt-hour", + "therm-us", "newton", "pound-force", "gigahertz", "hertz", "kilohertz", "megahertz", + "dot-per-centimeter", + "dot-per-inch", + "em", + "megapixel", + "pixel", + "pixel-per-centimeter", + "pixel-per-inch", "astronomical-unit", "centimeter", "decimeter", @@ -533,12 +545,14 @@ static const char * const gSubTypes[] = { "milliwatt", "watt", "atmosphere", + "bar", "hectopascal", "inch-hg", "kilopascal", "megapascal", "millibar", "millimeter-of-mercury", + "pascal", "pound-per-square-inch", "kilometer-per-hour", "knot", @@ -581,18 +595,20 @@ static const char * const gSubTypes[] = { // Must be sorted by first value and then second value. static int32_t unitPerUnitToSingleUnit[][4] = { - {379, 342, 18, 0}, - {381, 349, 18, 2}, - {383, 342, 18, 3}, - {383, 452, 4, 2}, - {383, 453, 4, 3}, - {402, 449, 3, 1}, - {405, 12, 17, 7}, - {455, 379, 4, 1} + {378, 382, 12, 5}, + {378, 387, 12, 6}, + {388, 343, 19, 0}, + {390, 350, 19, 2}, + {392, 343, 19, 3}, + {392, 463, 4, 2}, + {392, 464, 4, 3}, + {411, 460, 3, 1}, + {414, 12, 18, 9}, + {466, 388, 4, 1} }; // Shortcuts to the base unit in order to make the default constructor fast -static const int32_t kBaseTypeIdx = 15; +static const int32_t kBaseTypeIdx = 16; static const int32_t kBaseSubTypeIdx = 0; MeasureUnit *MeasureUnit::createGForce(UErrorCode &status) { @@ -939,102 +955,110 @@ MeasureUnit MeasureUnit::getDayPerson() { return MeasureUnit(7, 2); } -MeasureUnit *MeasureUnit::createHour(UErrorCode &status) { +MeasureUnit *MeasureUnit::createDecade(UErrorCode &status) { return MeasureUnit::create(7, 3, status); } -MeasureUnit MeasureUnit::getHour() { +MeasureUnit MeasureUnit::getDecade() { return MeasureUnit(7, 3); } -MeasureUnit *MeasureUnit::createMicrosecond(UErrorCode &status) { +MeasureUnit *MeasureUnit::createHour(UErrorCode &status) { return MeasureUnit::create(7, 4, status); } -MeasureUnit MeasureUnit::getMicrosecond() { +MeasureUnit MeasureUnit::getHour() { return MeasureUnit(7, 4); } -MeasureUnit *MeasureUnit::createMillisecond(UErrorCode &status) { +MeasureUnit *MeasureUnit::createMicrosecond(UErrorCode &status) { return MeasureUnit::create(7, 5, status); } -MeasureUnit MeasureUnit::getMillisecond() { +MeasureUnit MeasureUnit::getMicrosecond() { return MeasureUnit(7, 5); } -MeasureUnit *MeasureUnit::createMinute(UErrorCode &status) { +MeasureUnit *MeasureUnit::createMillisecond(UErrorCode &status) { return MeasureUnit::create(7, 6, status); } -MeasureUnit MeasureUnit::getMinute() { +MeasureUnit MeasureUnit::getMillisecond() { return MeasureUnit(7, 6); } -MeasureUnit *MeasureUnit::createMonth(UErrorCode &status) { +MeasureUnit *MeasureUnit::createMinute(UErrorCode &status) { return MeasureUnit::create(7, 7, status); } -MeasureUnit MeasureUnit::getMonth() { +MeasureUnit MeasureUnit::getMinute() { return MeasureUnit(7, 7); } -MeasureUnit *MeasureUnit::createMonthPerson(UErrorCode &status) { +MeasureUnit *MeasureUnit::createMonth(UErrorCode &status) { return MeasureUnit::create(7, 8, status); } -MeasureUnit MeasureUnit::getMonthPerson() { +MeasureUnit MeasureUnit::getMonth() { return MeasureUnit(7, 8); } -MeasureUnit *MeasureUnit::createNanosecond(UErrorCode &status) { +MeasureUnit *MeasureUnit::createMonthPerson(UErrorCode &status) { return MeasureUnit::create(7, 9, status); } -MeasureUnit MeasureUnit::getNanosecond() { +MeasureUnit MeasureUnit::getMonthPerson() { return MeasureUnit(7, 9); } -MeasureUnit *MeasureUnit::createSecond(UErrorCode &status) { +MeasureUnit *MeasureUnit::createNanosecond(UErrorCode &status) { return MeasureUnit::create(7, 10, status); } -MeasureUnit MeasureUnit::getSecond() { +MeasureUnit MeasureUnit::getNanosecond() { return MeasureUnit(7, 10); } -MeasureUnit *MeasureUnit::createWeek(UErrorCode &status) { +MeasureUnit *MeasureUnit::createSecond(UErrorCode &status) { return MeasureUnit::create(7, 11, status); } -MeasureUnit MeasureUnit::getWeek() { +MeasureUnit MeasureUnit::getSecond() { return MeasureUnit(7, 11); } -MeasureUnit *MeasureUnit::createWeekPerson(UErrorCode &status) { +MeasureUnit *MeasureUnit::createWeek(UErrorCode &status) { return MeasureUnit::create(7, 12, status); } -MeasureUnit MeasureUnit::getWeekPerson() { +MeasureUnit MeasureUnit::getWeek() { return MeasureUnit(7, 12); } -MeasureUnit *MeasureUnit::createYear(UErrorCode &status) { +MeasureUnit *MeasureUnit::createWeekPerson(UErrorCode &status) { return MeasureUnit::create(7, 13, status); } -MeasureUnit MeasureUnit::getYear() { +MeasureUnit MeasureUnit::getWeekPerson() { return MeasureUnit(7, 13); } -MeasureUnit *MeasureUnit::createYearPerson(UErrorCode &status) { +MeasureUnit *MeasureUnit::createYear(UErrorCode &status) { return MeasureUnit::create(7, 14, status); } -MeasureUnit MeasureUnit::getYearPerson() { +MeasureUnit MeasureUnit::getYear() { return MeasureUnit(7, 14); } +MeasureUnit *MeasureUnit::createYearPerson(UErrorCode &status) { + return MeasureUnit::create(7, 15, status); +} + +MeasureUnit MeasureUnit::getYearPerson() { + return MeasureUnit(7, 15); +} + MeasureUnit *MeasureUnit::createAmpere(UErrorCode &status) { return MeasureUnit::create(8, 0, status); } @@ -1131,6 +1155,14 @@ MeasureUnit MeasureUnit::getKilowattHour() { return MeasureUnit(9, 7); } +MeasureUnit *MeasureUnit::createThermUs(UErrorCode &status) { + return MeasureUnit::create(9, 8, status); +} + +MeasureUnit MeasureUnit::getThermUs() { + return MeasureUnit(9, 8); +} + MeasureUnit *MeasureUnit::createNewton(UErrorCode &status) { return MeasureUnit::create(10, 0, status); } @@ -1179,708 +1211,780 @@ MeasureUnit MeasureUnit::getMegahertz() { return MeasureUnit(11, 3); } -MeasureUnit *MeasureUnit::createAstronomicalUnit(UErrorCode &status) { +MeasureUnit *MeasureUnit::createDotPerCentimeter(UErrorCode &status) { return MeasureUnit::create(12, 0, status); } -MeasureUnit MeasureUnit::getAstronomicalUnit() { +MeasureUnit MeasureUnit::getDotPerCentimeter() { return MeasureUnit(12, 0); } -MeasureUnit *MeasureUnit::createCentimeter(UErrorCode &status) { +MeasureUnit *MeasureUnit::createDotPerInch(UErrorCode &status) { return MeasureUnit::create(12, 1, status); } -MeasureUnit MeasureUnit::getCentimeter() { +MeasureUnit MeasureUnit::getDotPerInch() { return MeasureUnit(12, 1); } -MeasureUnit *MeasureUnit::createDecimeter(UErrorCode &status) { +MeasureUnit *MeasureUnit::createEm(UErrorCode &status) { return MeasureUnit::create(12, 2, status); } -MeasureUnit MeasureUnit::getDecimeter() { +MeasureUnit MeasureUnit::getEm() { return MeasureUnit(12, 2); } -MeasureUnit *MeasureUnit::createFathom(UErrorCode &status) { +MeasureUnit *MeasureUnit::createMegapixel(UErrorCode &status) { return MeasureUnit::create(12, 3, status); } -MeasureUnit MeasureUnit::getFathom() { +MeasureUnit MeasureUnit::getMegapixel() { return MeasureUnit(12, 3); } -MeasureUnit *MeasureUnit::createFoot(UErrorCode &status) { +MeasureUnit *MeasureUnit::createPixel(UErrorCode &status) { return MeasureUnit::create(12, 4, status); } -MeasureUnit MeasureUnit::getFoot() { +MeasureUnit MeasureUnit::getPixel() { return MeasureUnit(12, 4); } -MeasureUnit *MeasureUnit::createFurlong(UErrorCode &status) { +MeasureUnit *MeasureUnit::createPixelPerCentimeter(UErrorCode &status) { return MeasureUnit::create(12, 5, status); } -MeasureUnit MeasureUnit::getFurlong() { +MeasureUnit MeasureUnit::getPixelPerCentimeter() { return MeasureUnit(12, 5); } -MeasureUnit *MeasureUnit::createInch(UErrorCode &status) { +MeasureUnit *MeasureUnit::createPixelPerInch(UErrorCode &status) { return MeasureUnit::create(12, 6, status); } -MeasureUnit MeasureUnit::getInch() { +MeasureUnit MeasureUnit::getPixelPerInch() { return MeasureUnit(12, 6); } +MeasureUnit *MeasureUnit::createAstronomicalUnit(UErrorCode &status) { + return MeasureUnit::create(13, 0, status); +} + +MeasureUnit MeasureUnit::getAstronomicalUnit() { + return MeasureUnit(13, 0); +} + +MeasureUnit *MeasureUnit::createCentimeter(UErrorCode &status) { + return MeasureUnit::create(13, 1, status); +} + +MeasureUnit MeasureUnit::getCentimeter() { + return MeasureUnit(13, 1); +} + +MeasureUnit *MeasureUnit::createDecimeter(UErrorCode &status) { + return MeasureUnit::create(13, 2, status); +} + +MeasureUnit MeasureUnit::getDecimeter() { + return MeasureUnit(13, 2); +} + +MeasureUnit *MeasureUnit::createFathom(UErrorCode &status) { + return MeasureUnit::create(13, 3, status); +} + +MeasureUnit MeasureUnit::getFathom() { + return MeasureUnit(13, 3); +} + +MeasureUnit *MeasureUnit::createFoot(UErrorCode &status) { + return MeasureUnit::create(13, 4, status); +} + +MeasureUnit MeasureUnit::getFoot() { + return MeasureUnit(13, 4); +} + +MeasureUnit *MeasureUnit::createFurlong(UErrorCode &status) { + return MeasureUnit::create(13, 5, status); +} + +MeasureUnit MeasureUnit::getFurlong() { + return MeasureUnit(13, 5); +} + +MeasureUnit *MeasureUnit::createInch(UErrorCode &status) { + return MeasureUnit::create(13, 6, status); +} + +MeasureUnit MeasureUnit::getInch() { + return MeasureUnit(13, 6); +} + MeasureUnit *MeasureUnit::createKilometer(UErrorCode &status) { - return MeasureUnit::create(12, 7, status); + return MeasureUnit::create(13, 7, status); } MeasureUnit MeasureUnit::getKilometer() { - return MeasureUnit(12, 7); + return MeasureUnit(13, 7); } MeasureUnit *MeasureUnit::createLightYear(UErrorCode &status) { - return MeasureUnit::create(12, 8, status); + return MeasureUnit::create(13, 8, status); } MeasureUnit MeasureUnit::getLightYear() { - return MeasureUnit(12, 8); + return MeasureUnit(13, 8); } MeasureUnit *MeasureUnit::createMeter(UErrorCode &status) { - return MeasureUnit::create(12, 9, status); + return MeasureUnit::create(13, 9, status); } MeasureUnit MeasureUnit::getMeter() { - return MeasureUnit(12, 9); + return MeasureUnit(13, 9); } MeasureUnit *MeasureUnit::createMicrometer(UErrorCode &status) { - return MeasureUnit::create(12, 10, status); + return MeasureUnit::create(13, 10, status); } MeasureUnit MeasureUnit::getMicrometer() { - return MeasureUnit(12, 10); + return MeasureUnit(13, 10); } MeasureUnit *MeasureUnit::createMile(UErrorCode &status) { - return MeasureUnit::create(12, 11, status); + return MeasureUnit::create(13, 11, status); } MeasureUnit MeasureUnit::getMile() { - return MeasureUnit(12, 11); + return MeasureUnit(13, 11); } MeasureUnit *MeasureUnit::createMileScandinavian(UErrorCode &status) { - return MeasureUnit::create(12, 12, status); + return MeasureUnit::create(13, 12, status); } MeasureUnit MeasureUnit::getMileScandinavian() { - return MeasureUnit(12, 12); + return MeasureUnit(13, 12); } MeasureUnit *MeasureUnit::createMillimeter(UErrorCode &status) { - return MeasureUnit::create(12, 13, status); + return MeasureUnit::create(13, 13, status); } MeasureUnit MeasureUnit::getMillimeter() { - return MeasureUnit(12, 13); + return MeasureUnit(13, 13); } MeasureUnit *MeasureUnit::createNanometer(UErrorCode &status) { - return MeasureUnit::create(12, 14, status); + return MeasureUnit::create(13, 14, status); } MeasureUnit MeasureUnit::getNanometer() { - return MeasureUnit(12, 14); + return MeasureUnit(13, 14); } MeasureUnit *MeasureUnit::createNauticalMile(UErrorCode &status) { - return MeasureUnit::create(12, 15, status); + return MeasureUnit::create(13, 15, status); } MeasureUnit MeasureUnit::getNauticalMile() { - return MeasureUnit(12, 15); + return MeasureUnit(13, 15); } MeasureUnit *MeasureUnit::createParsec(UErrorCode &status) { - return MeasureUnit::create(12, 16, status); + return MeasureUnit::create(13, 16, status); } MeasureUnit MeasureUnit::getParsec() { - return MeasureUnit(12, 16); + return MeasureUnit(13, 16); } MeasureUnit *MeasureUnit::createPicometer(UErrorCode &status) { - return MeasureUnit::create(12, 17, status); + return MeasureUnit::create(13, 17, status); } MeasureUnit MeasureUnit::getPicometer() { - return MeasureUnit(12, 17); + return MeasureUnit(13, 17); } MeasureUnit *MeasureUnit::createPoint(UErrorCode &status) { - return MeasureUnit::create(12, 18, status); + return MeasureUnit::create(13, 18, status); } MeasureUnit MeasureUnit::getPoint() { - return MeasureUnit(12, 18); + return MeasureUnit(13, 18); } MeasureUnit *MeasureUnit::createSolarRadius(UErrorCode &status) { - return MeasureUnit::create(12, 19, status); + return MeasureUnit::create(13, 19, status); } MeasureUnit MeasureUnit::getSolarRadius() { - return MeasureUnit(12, 19); + return MeasureUnit(13, 19); } MeasureUnit *MeasureUnit::createYard(UErrorCode &status) { - return MeasureUnit::create(12, 20, status); + return MeasureUnit::create(13, 20, status); } MeasureUnit MeasureUnit::getYard() { - return MeasureUnit(12, 20); + return MeasureUnit(13, 20); } MeasureUnit *MeasureUnit::createLux(UErrorCode &status) { - return MeasureUnit::create(13, 0, status); + return MeasureUnit::create(14, 0, status); } MeasureUnit MeasureUnit::getLux() { - return MeasureUnit(13, 0); + return MeasureUnit(14, 0); } MeasureUnit *MeasureUnit::createSolarLuminosity(UErrorCode &status) { - return MeasureUnit::create(13, 1, status); + return MeasureUnit::create(14, 1, status); } MeasureUnit MeasureUnit::getSolarLuminosity() { - return MeasureUnit(13, 1); + return MeasureUnit(14, 1); } MeasureUnit *MeasureUnit::createCarat(UErrorCode &status) { - return MeasureUnit::create(14, 0, status); + return MeasureUnit::create(15, 0, status); } MeasureUnit MeasureUnit::getCarat() { - return MeasureUnit(14, 0); + return MeasureUnit(15, 0); } MeasureUnit *MeasureUnit::createDalton(UErrorCode &status) { - return MeasureUnit::create(14, 1, status); + return MeasureUnit::create(15, 1, status); } MeasureUnit MeasureUnit::getDalton() { - return MeasureUnit(14, 1); + return MeasureUnit(15, 1); } MeasureUnit *MeasureUnit::createEarthMass(UErrorCode &status) { - return MeasureUnit::create(14, 2, status); + return MeasureUnit::create(15, 2, status); } MeasureUnit MeasureUnit::getEarthMass() { - return MeasureUnit(14, 2); + return MeasureUnit(15, 2); } MeasureUnit *MeasureUnit::createGram(UErrorCode &status) { - return MeasureUnit::create(14, 3, status); + return MeasureUnit::create(15, 3, status); } MeasureUnit MeasureUnit::getGram() { - return MeasureUnit(14, 3); + return MeasureUnit(15, 3); } MeasureUnit *MeasureUnit::createKilogram(UErrorCode &status) { - return MeasureUnit::create(14, 4, status); + return MeasureUnit::create(15, 4, status); } MeasureUnit MeasureUnit::getKilogram() { - return MeasureUnit(14, 4); + return MeasureUnit(15, 4); } MeasureUnit *MeasureUnit::createMetricTon(UErrorCode &status) { - return MeasureUnit::create(14, 5, status); + return MeasureUnit::create(15, 5, status); } MeasureUnit MeasureUnit::getMetricTon() { - return MeasureUnit(14, 5); + return MeasureUnit(15, 5); } MeasureUnit *MeasureUnit::createMicrogram(UErrorCode &status) { - return MeasureUnit::create(14, 6, status); + return MeasureUnit::create(15, 6, status); } MeasureUnit MeasureUnit::getMicrogram() { - return MeasureUnit(14, 6); + return MeasureUnit(15, 6); } MeasureUnit *MeasureUnit::createMilligram(UErrorCode &status) { - return MeasureUnit::create(14, 7, status); + return MeasureUnit::create(15, 7, status); } MeasureUnit MeasureUnit::getMilligram() { - return MeasureUnit(14, 7); + return MeasureUnit(15, 7); } MeasureUnit *MeasureUnit::createOunce(UErrorCode &status) { - return MeasureUnit::create(14, 8, status); + return MeasureUnit::create(15, 8, status); } MeasureUnit MeasureUnit::getOunce() { - return MeasureUnit(14, 8); + return MeasureUnit(15, 8); } MeasureUnit *MeasureUnit::createOunceTroy(UErrorCode &status) { - return MeasureUnit::create(14, 9, status); + return MeasureUnit::create(15, 9, status); } MeasureUnit MeasureUnit::getOunceTroy() { - return MeasureUnit(14, 9); + return MeasureUnit(15, 9); } MeasureUnit *MeasureUnit::createPound(UErrorCode &status) { - return MeasureUnit::create(14, 10, status); + return MeasureUnit::create(15, 10, status); } MeasureUnit MeasureUnit::getPound() { - return MeasureUnit(14, 10); + return MeasureUnit(15, 10); } MeasureUnit *MeasureUnit::createSolarMass(UErrorCode &status) { - return MeasureUnit::create(14, 11, status); + return MeasureUnit::create(15, 11, status); } MeasureUnit MeasureUnit::getSolarMass() { - return MeasureUnit(14, 11); + return MeasureUnit(15, 11); } MeasureUnit *MeasureUnit::createStone(UErrorCode &status) { - return MeasureUnit::create(14, 12, status); + return MeasureUnit::create(15, 12, status); } MeasureUnit MeasureUnit::getStone() { - return MeasureUnit(14, 12); + return MeasureUnit(15, 12); } MeasureUnit *MeasureUnit::createTon(UErrorCode &status) { - return MeasureUnit::create(14, 13, status); + return MeasureUnit::create(15, 13, status); } MeasureUnit MeasureUnit::getTon() { - return MeasureUnit(14, 13); + return MeasureUnit(15, 13); } MeasureUnit *MeasureUnit::createGigawatt(UErrorCode &status) { - return MeasureUnit::create(16, 0, status); + return MeasureUnit::create(17, 0, status); } MeasureUnit MeasureUnit::getGigawatt() { - return MeasureUnit(16, 0); + return MeasureUnit(17, 0); } MeasureUnit *MeasureUnit::createHorsepower(UErrorCode &status) { - return MeasureUnit::create(16, 1, status); + return MeasureUnit::create(17, 1, status); } MeasureUnit MeasureUnit::getHorsepower() { - return MeasureUnit(16, 1); + return MeasureUnit(17, 1); } MeasureUnit *MeasureUnit::createKilowatt(UErrorCode &status) { - return MeasureUnit::create(16, 2, status); + return MeasureUnit::create(17, 2, status); } MeasureUnit MeasureUnit::getKilowatt() { - return MeasureUnit(16, 2); + return MeasureUnit(17, 2); } MeasureUnit *MeasureUnit::createMegawatt(UErrorCode &status) { - return MeasureUnit::create(16, 3, status); + return MeasureUnit::create(17, 3, status); } MeasureUnit MeasureUnit::getMegawatt() { - return MeasureUnit(16, 3); + return MeasureUnit(17, 3); } MeasureUnit *MeasureUnit::createMilliwatt(UErrorCode &status) { - return MeasureUnit::create(16, 4, status); + return MeasureUnit::create(17, 4, status); } MeasureUnit MeasureUnit::getMilliwatt() { - return MeasureUnit(16, 4); + return MeasureUnit(17, 4); } MeasureUnit *MeasureUnit::createWatt(UErrorCode &status) { - return MeasureUnit::create(16, 5, status); + return MeasureUnit::create(17, 5, status); } MeasureUnit MeasureUnit::getWatt() { - return MeasureUnit(16, 5); + return MeasureUnit(17, 5); } MeasureUnit *MeasureUnit::createAtmosphere(UErrorCode &status) { - return MeasureUnit::create(17, 0, status); + return MeasureUnit::create(18, 0, status); } MeasureUnit MeasureUnit::getAtmosphere() { - return MeasureUnit(17, 0); + return MeasureUnit(18, 0); +} + +MeasureUnit *MeasureUnit::createBar(UErrorCode &status) { + return MeasureUnit::create(18, 1, status); +} + +MeasureUnit MeasureUnit::getBar() { + return MeasureUnit(18, 1); } MeasureUnit *MeasureUnit::createHectopascal(UErrorCode &status) { - return MeasureUnit::create(17, 1, status); + return MeasureUnit::create(18, 2, status); } MeasureUnit MeasureUnit::getHectopascal() { - return MeasureUnit(17, 1); + return MeasureUnit(18, 2); } MeasureUnit *MeasureUnit::createInchHg(UErrorCode &status) { - return MeasureUnit::create(17, 2, status); + return MeasureUnit::create(18, 3, status); } MeasureUnit MeasureUnit::getInchHg() { - return MeasureUnit(17, 2); + return MeasureUnit(18, 3); } MeasureUnit *MeasureUnit::createKilopascal(UErrorCode &status) { - return MeasureUnit::create(17, 3, status); + return MeasureUnit::create(18, 4, status); } MeasureUnit MeasureUnit::getKilopascal() { - return MeasureUnit(17, 3); + return MeasureUnit(18, 4); } MeasureUnit *MeasureUnit::createMegapascal(UErrorCode &status) { - return MeasureUnit::create(17, 4, status); + return MeasureUnit::create(18, 5, status); } MeasureUnit MeasureUnit::getMegapascal() { - return MeasureUnit(17, 4); + return MeasureUnit(18, 5); } MeasureUnit *MeasureUnit::createMillibar(UErrorCode &status) { - return MeasureUnit::create(17, 5, status); + return MeasureUnit::create(18, 6, status); } MeasureUnit MeasureUnit::getMillibar() { - return MeasureUnit(17, 5); + return MeasureUnit(18, 6); } MeasureUnit *MeasureUnit::createMillimeterOfMercury(UErrorCode &status) { - return MeasureUnit::create(17, 6, status); + return MeasureUnit::create(18, 7, status); } MeasureUnit MeasureUnit::getMillimeterOfMercury() { - return MeasureUnit(17, 6); + return MeasureUnit(18, 7); +} + +MeasureUnit *MeasureUnit::createPascal(UErrorCode &status) { + return MeasureUnit::create(18, 8, status); +} + +MeasureUnit MeasureUnit::getPascal() { + return MeasureUnit(18, 8); } MeasureUnit *MeasureUnit::createPoundPerSquareInch(UErrorCode &status) { - return MeasureUnit::create(17, 7, status); + return MeasureUnit::create(18, 9, status); } MeasureUnit MeasureUnit::getPoundPerSquareInch() { - return MeasureUnit(17, 7); + return MeasureUnit(18, 9); } MeasureUnit *MeasureUnit::createKilometerPerHour(UErrorCode &status) { - return MeasureUnit::create(18, 0, status); + return MeasureUnit::create(19, 0, status); } MeasureUnit MeasureUnit::getKilometerPerHour() { - return MeasureUnit(18, 0); + return MeasureUnit(19, 0); } MeasureUnit *MeasureUnit::createKnot(UErrorCode &status) { - return MeasureUnit::create(18, 1, status); + return MeasureUnit::create(19, 1, status); } MeasureUnit MeasureUnit::getKnot() { - return MeasureUnit(18, 1); + return MeasureUnit(19, 1); } MeasureUnit *MeasureUnit::createMeterPerSecond(UErrorCode &status) { - return MeasureUnit::create(18, 2, status); + return MeasureUnit::create(19, 2, status); } MeasureUnit MeasureUnit::getMeterPerSecond() { - return MeasureUnit(18, 2); + return MeasureUnit(19, 2); } MeasureUnit *MeasureUnit::createMilePerHour(UErrorCode &status) { - return MeasureUnit::create(18, 3, status); + return MeasureUnit::create(19, 3, status); } MeasureUnit MeasureUnit::getMilePerHour() { - return MeasureUnit(18, 3); + return MeasureUnit(19, 3); } MeasureUnit *MeasureUnit::createCelsius(UErrorCode &status) { - return MeasureUnit::create(19, 0, status); + return MeasureUnit::create(20, 0, status); } MeasureUnit MeasureUnit::getCelsius() { - return MeasureUnit(19, 0); + return MeasureUnit(20, 0); } MeasureUnit *MeasureUnit::createFahrenheit(UErrorCode &status) { - return MeasureUnit::create(19, 1, status); + return MeasureUnit::create(20, 1, status); } MeasureUnit MeasureUnit::getFahrenheit() { - return MeasureUnit(19, 1); + return MeasureUnit(20, 1); } MeasureUnit *MeasureUnit::createGenericTemperature(UErrorCode &status) { - return MeasureUnit::create(19, 2, status); + return MeasureUnit::create(20, 2, status); } MeasureUnit MeasureUnit::getGenericTemperature() { - return MeasureUnit(19, 2); + return MeasureUnit(20, 2); } MeasureUnit *MeasureUnit::createKelvin(UErrorCode &status) { - return MeasureUnit::create(19, 3, status); + return MeasureUnit::create(20, 3, status); } MeasureUnit MeasureUnit::getKelvin() { - return MeasureUnit(19, 3); + return MeasureUnit(20, 3); } MeasureUnit *MeasureUnit::createNewtonMeter(UErrorCode &status) { - return MeasureUnit::create(20, 0, status); + return MeasureUnit::create(21, 0, status); } MeasureUnit MeasureUnit::getNewtonMeter() { - return MeasureUnit(20, 0); + return MeasureUnit(21, 0); } MeasureUnit *MeasureUnit::createPoundFoot(UErrorCode &status) { - return MeasureUnit::create(20, 1, status); + return MeasureUnit::create(21, 1, status); } MeasureUnit MeasureUnit::getPoundFoot() { - return MeasureUnit(20, 1); + return MeasureUnit(21, 1); } MeasureUnit *MeasureUnit::createAcreFoot(UErrorCode &status) { - return MeasureUnit::create(21, 0, status); + return MeasureUnit::create(22, 0, status); } MeasureUnit MeasureUnit::getAcreFoot() { - return MeasureUnit(21, 0); + return MeasureUnit(22, 0); } MeasureUnit *MeasureUnit::createBarrel(UErrorCode &status) { - return MeasureUnit::create(21, 1, status); + return MeasureUnit::create(22, 1, status); } MeasureUnit MeasureUnit::getBarrel() { - return MeasureUnit(21, 1); + return MeasureUnit(22, 1); } MeasureUnit *MeasureUnit::createBushel(UErrorCode &status) { - return MeasureUnit::create(21, 2, status); + return MeasureUnit::create(22, 2, status); } MeasureUnit MeasureUnit::getBushel() { - return MeasureUnit(21, 2); + return MeasureUnit(22, 2); } MeasureUnit *MeasureUnit::createCentiliter(UErrorCode &status) { - return MeasureUnit::create(21, 3, status); + return MeasureUnit::create(22, 3, status); } MeasureUnit MeasureUnit::getCentiliter() { - return MeasureUnit(21, 3); + return MeasureUnit(22, 3); } MeasureUnit *MeasureUnit::createCubicCentimeter(UErrorCode &status) { - return MeasureUnit::create(21, 4, status); + return MeasureUnit::create(22, 4, status); } MeasureUnit MeasureUnit::getCubicCentimeter() { - return MeasureUnit(21, 4); + return MeasureUnit(22, 4); } MeasureUnit *MeasureUnit::createCubicFoot(UErrorCode &status) { - return MeasureUnit::create(21, 5, status); + return MeasureUnit::create(22, 5, status); } MeasureUnit MeasureUnit::getCubicFoot() { - return MeasureUnit(21, 5); + return MeasureUnit(22, 5); } MeasureUnit *MeasureUnit::createCubicInch(UErrorCode &status) { - return MeasureUnit::create(21, 6, status); + return MeasureUnit::create(22, 6, status); } MeasureUnit MeasureUnit::getCubicInch() { - return MeasureUnit(21, 6); + return MeasureUnit(22, 6); } MeasureUnit *MeasureUnit::createCubicKilometer(UErrorCode &status) { - return MeasureUnit::create(21, 7, status); + return MeasureUnit::create(22, 7, status); } MeasureUnit MeasureUnit::getCubicKilometer() { - return MeasureUnit(21, 7); + return MeasureUnit(22, 7); } MeasureUnit *MeasureUnit::createCubicMeter(UErrorCode &status) { - return MeasureUnit::create(21, 8, status); + return MeasureUnit::create(22, 8, status); } MeasureUnit MeasureUnit::getCubicMeter() { - return MeasureUnit(21, 8); + return MeasureUnit(22, 8); } MeasureUnit *MeasureUnit::createCubicMile(UErrorCode &status) { - return MeasureUnit::create(21, 9, status); + return MeasureUnit::create(22, 9, status); } MeasureUnit MeasureUnit::getCubicMile() { - return MeasureUnit(21, 9); + return MeasureUnit(22, 9); } MeasureUnit *MeasureUnit::createCubicYard(UErrorCode &status) { - return MeasureUnit::create(21, 10, status); + return MeasureUnit::create(22, 10, status); } MeasureUnit MeasureUnit::getCubicYard() { - return MeasureUnit(21, 10); + return MeasureUnit(22, 10); } MeasureUnit *MeasureUnit::createCup(UErrorCode &status) { - return MeasureUnit::create(21, 11, status); + return MeasureUnit::create(22, 11, status); } MeasureUnit MeasureUnit::getCup() { - return MeasureUnit(21, 11); + return MeasureUnit(22, 11); } MeasureUnit *MeasureUnit::createCupMetric(UErrorCode &status) { - return MeasureUnit::create(21, 12, status); + return MeasureUnit::create(22, 12, status); } MeasureUnit MeasureUnit::getCupMetric() { - return MeasureUnit(21, 12); + return MeasureUnit(22, 12); } MeasureUnit *MeasureUnit::createDeciliter(UErrorCode &status) { - return MeasureUnit::create(21, 13, status); + return MeasureUnit::create(22, 13, status); } MeasureUnit MeasureUnit::getDeciliter() { - return MeasureUnit(21, 13); + return MeasureUnit(22, 13); } MeasureUnit *MeasureUnit::createFluidOunce(UErrorCode &status) { - return MeasureUnit::create(21, 14, status); + return MeasureUnit::create(22, 14, status); } MeasureUnit MeasureUnit::getFluidOunce() { - return MeasureUnit(21, 14); + return MeasureUnit(22, 14); } MeasureUnit *MeasureUnit::createFluidOunceImperial(UErrorCode &status) { - return MeasureUnit::create(21, 15, status); + return MeasureUnit::create(22, 15, status); } MeasureUnit MeasureUnit::getFluidOunceImperial() { - return MeasureUnit(21, 15); + return MeasureUnit(22, 15); } MeasureUnit *MeasureUnit::createGallon(UErrorCode &status) { - return MeasureUnit::create(21, 16, status); + return MeasureUnit::create(22, 16, status); } MeasureUnit MeasureUnit::getGallon() { - return MeasureUnit(21, 16); + return MeasureUnit(22, 16); } MeasureUnit *MeasureUnit::createGallonImperial(UErrorCode &status) { - return MeasureUnit::create(21, 17, status); + return MeasureUnit::create(22, 17, status); } MeasureUnit MeasureUnit::getGallonImperial() { - return MeasureUnit(21, 17); + return MeasureUnit(22, 17); } MeasureUnit *MeasureUnit::createHectoliter(UErrorCode &status) { - return MeasureUnit::create(21, 18, status); + return MeasureUnit::create(22, 18, status); } MeasureUnit MeasureUnit::getHectoliter() { - return MeasureUnit(21, 18); + return MeasureUnit(22, 18); } MeasureUnit *MeasureUnit::createLiter(UErrorCode &status) { - return MeasureUnit::create(21, 19, status); + return MeasureUnit::create(22, 19, status); } MeasureUnit MeasureUnit::getLiter() { - return MeasureUnit(21, 19); + return MeasureUnit(22, 19); } MeasureUnit *MeasureUnit::createMegaliter(UErrorCode &status) { - return MeasureUnit::create(21, 20, status); + return MeasureUnit::create(22, 20, status); } MeasureUnit MeasureUnit::getMegaliter() { - return MeasureUnit(21, 20); + return MeasureUnit(22, 20); } MeasureUnit *MeasureUnit::createMilliliter(UErrorCode &status) { - return MeasureUnit::create(21, 21, status); + return MeasureUnit::create(22, 21, status); } MeasureUnit MeasureUnit::getMilliliter() { - return MeasureUnit(21, 21); + return MeasureUnit(22, 21); } MeasureUnit *MeasureUnit::createPint(UErrorCode &status) { - return MeasureUnit::create(21, 22, status); + return MeasureUnit::create(22, 22, status); } MeasureUnit MeasureUnit::getPint() { - return MeasureUnit(21, 22); + return MeasureUnit(22, 22); } MeasureUnit *MeasureUnit::createPintMetric(UErrorCode &status) { - return MeasureUnit::create(21, 23, status); + return MeasureUnit::create(22, 23, status); } MeasureUnit MeasureUnit::getPintMetric() { - return MeasureUnit(21, 23); + return MeasureUnit(22, 23); } MeasureUnit *MeasureUnit::createQuart(UErrorCode &status) { - return MeasureUnit::create(21, 24, status); + return MeasureUnit::create(22, 24, status); } MeasureUnit MeasureUnit::getQuart() { - return MeasureUnit(21, 24); + return MeasureUnit(22, 24); } MeasureUnit *MeasureUnit::createTablespoon(UErrorCode &status) { - return MeasureUnit::create(21, 25, status); + return MeasureUnit::create(22, 25, status); } MeasureUnit MeasureUnit::getTablespoon() { - return MeasureUnit(21, 25); + return MeasureUnit(22, 25); } MeasureUnit *MeasureUnit::createTeaspoon(UErrorCode &status) { - return MeasureUnit::create(21, 26, status); + return MeasureUnit::create(22, 26, status); } MeasureUnit MeasureUnit::getTeaspoon() { - return MeasureUnit(21, 26); + return MeasureUnit(22, 26); } // End generated code @@ -1923,7 +2027,7 @@ MeasureUnit &MeasureUnit::operator=(const MeasureUnit &other) { return *this; } -UObject *MeasureUnit::clone() const { +MeasureUnit *MeasureUnit::clone() const { return new MeasureUnit(*this); } diff --git a/deps/icu-small/source/i18n/measure.cpp b/deps/icu-small/source/i18n/measure.cpp index d9084f87db2baa..bffa44215e3cde 100644 --- a/deps/icu-small/source/i18n/measure.cpp +++ b/deps/icu-small/source/i18n/measure.cpp @@ -43,12 +43,12 @@ Measure& Measure::operator=(const Measure& other) { if (this != &other) { delete unit; number = other.number; - unit = (MeasureUnit*) other.unit->clone(); + unit = other.unit->clone(); } return *this; } -UObject *Measure::clone() const { +Measure *Measure::clone() const { return new Measure(*this); } diff --git a/deps/icu-small/source/i18n/msgfmt.cpp b/deps/icu-small/source/i18n/msgfmt.cpp index e39b26b969889f..3ca368ef954846 100644 --- a/deps/icu-small/source/i18n/msgfmt.cpp +++ b/deps/icu-small/source/i18n/msgfmt.cpp @@ -436,7 +436,7 @@ MessageFormat::operator==(const Format& rhs) const // ------------------------------------- // Creates a copy of this MessageFormat, the caller owns the copy. -Format* +MessageFormat* MessageFormat::clone() const { return new MessageFormat(*this); @@ -813,7 +813,7 @@ MessageFormat::getFormats(int32_t& cnt) const // Get total required capacity first (it's refreshed on each call). int32_t totalCapacity = 0; - for (int32_t partIndex = 0; (partIndex = nextTopLevelArgStart(partIndex)) >= 0; ++totalCapacity) {}; + for (int32_t partIndex = 0; (partIndex = nextTopLevelArgStart(partIndex)) >= 0; ++totalCapacity) {} MessageFormat* t = const_cast (this); cnt = 0; @@ -1873,7 +1873,7 @@ UBool MessageFormat::DummyFormat::operator==(const Format&) const { return TRUE; } -Format* MessageFormat::DummyFormat::clone() const { +MessageFormat::DummyFormat* MessageFormat::DummyFormat::clone() const { return new DummyFormat(); } diff --git a/deps/icu-small/source/i18n/name2uni.cpp b/deps/icu-small/source/i18n/name2uni.cpp index d901eb126a8a46..90bca9d71bef87 100644 --- a/deps/icu-small/source/i18n/name2uni.cpp +++ b/deps/icu-small/source/i18n/name2uni.cpp @@ -100,7 +100,7 @@ NameUnicodeTransliterator::NameUnicodeTransliterator(const NameUnicodeTransliter /** * Transliterator API. */ -Transliterator* NameUnicodeTransliterator::clone(void) const { +NameUnicodeTransliterator* NameUnicodeTransliterator::clone() const { return new NameUnicodeTransliterator(*this); } diff --git a/deps/icu-small/source/i18n/name2uni.h b/deps/icu-small/source/i18n/name2uni.h index 4c743def32ede2..44ad85fb822cb3 100644 --- a/deps/icu-small/source/i18n/name2uni.h +++ b/deps/icu-small/source/i18n/name2uni.h @@ -49,7 +49,7 @@ class NameUnicodeTransliterator : public Transliterator { * Transliterator API. * @return A copy of the object. */ - virtual Transliterator* clone(void) const; + virtual NameUnicodeTransliterator* clone() const; /** * ICU "poor man's RTTI", returns a UClassID for the actual class. diff --git a/deps/icu-small/source/i18n/nortrans.cpp b/deps/icu-small/source/i18n/nortrans.cpp index 589c82482ec9b9..6a8d2c74194fb0 100644 --- a/deps/icu-small/source/i18n/nortrans.cpp +++ b/deps/icu-small/source/i18n/nortrans.cpp @@ -92,7 +92,7 @@ NormalizationTransliterator::NormalizationTransliterator(const NormalizationTran /** * Transliterator API. */ -Transliterator* NormalizationTransliterator::clone(void) const { +NormalizationTransliterator* NormalizationTransliterator::clone() const { return new NormalizationTransliterator(*this); } diff --git a/deps/icu-small/source/i18n/nortrans.h b/deps/icu-small/source/i18n/nortrans.h index d309452f9a4d6a..198ed29c95e70f 100644 --- a/deps/icu-small/source/i18n/nortrans.h +++ b/deps/icu-small/source/i18n/nortrans.h @@ -44,7 +44,7 @@ class NormalizationTransliterator : public Transliterator { * Transliterator API. * @return A copy of the object. */ - virtual Transliterator* clone(void) const; + virtual NormalizationTransliterator* clone() const; /** * ICU "poor man's RTTI", returns a UClassID for the actual class. diff --git a/deps/icu-small/source/i18n/nounit.cpp b/deps/icu-small/source/i18n/nounit.cpp index db07387c590af8..076f76f199c737 100644 --- a/deps/icu-small/source/i18n/nounit.cpp +++ b/deps/icu-small/source/i18n/nounit.cpp @@ -29,7 +29,7 @@ NoUnit::NoUnit(const char* subtype) { NoUnit::NoUnit(const NoUnit& other) : MeasureUnit(other) { } -UObject* NoUnit::clone() const { +NoUnit* NoUnit::clone() const { return new NoUnit(*this); } diff --git a/deps/icu-small/source/i18n/nultrans.cpp b/deps/icu-small/source/i18n/nultrans.cpp index 62d1290ac75e93..439cc55d381a2a 100644 --- a/deps/icu-small/source/i18n/nultrans.cpp +++ b/deps/icu-small/source/i18n/nultrans.cpp @@ -24,7 +24,7 @@ NullTransliterator::NullTransliterator() : Transliterator(UNICODE_STRING_SIMPLE( NullTransliterator::~NullTransliterator() {} -Transliterator* NullTransliterator::clone(void) const { +NullTransliterator* NullTransliterator::clone() const { return new NullTransliterator(); } diff --git a/deps/icu-small/source/i18n/nultrans.h b/deps/icu-small/source/i18n/nultrans.h index a01b04e9ba1ec9..36c92fa7b189d3 100644 --- a/deps/icu-small/source/i18n/nultrans.h +++ b/deps/icu-small/source/i18n/nultrans.h @@ -45,7 +45,7 @@ class NullTransliterator : public Transliterator { * Transliterator API. * @internal Use transliterator factory methods instead since this class will be removed in that release. */ - virtual Transliterator* clone(void) const; + virtual NullTransliterator* clone() const; /** * Implements {@link Transliterator#handleTransliterate}. diff --git a/deps/icu-small/source/i18n/number_affixutils.cpp b/deps/icu-small/source/i18n/number_affixutils.cpp index 3eb9c59bf49090..1039a84c656124 100644 --- a/deps/icu-small/source/i18n/number_affixutils.cpp +++ b/deps/icu-small/source/i18n/number_affixutils.cpp @@ -156,7 +156,7 @@ Field AffixUtils::getFieldForType(AffixPatternType type) { } int32_t -AffixUtils::unescape(const UnicodeString &affixPattern, NumberStringBuilder &output, int32_t position, +AffixUtils::unescape(const UnicodeString &affixPattern, FormattedStringBuilder &output, int32_t position, const SymbolProvider &provider, Field field, UErrorCode &status) { int32_t length = 0; AffixTag tag; @@ -230,7 +230,7 @@ UnicodeString AffixUtils::replaceType(const UnicodeString &affixPattern, AffixPa UnicodeString output(affixPattern); // copy if (affixPattern.length() == 0) { return output; - }; + } AffixTag tag; while (hasNext(tag, affixPattern)) { tag = nextToken(tag, affixPattern, status); @@ -246,7 +246,7 @@ bool AffixUtils::containsOnlySymbolsAndIgnorables(const UnicodeString& affixPatt const UnicodeSet& ignorables, UErrorCode& status) { if (affixPattern.length() == 0) { return true; - }; + } AffixTag tag; while (hasNext(tag, affixPattern)) { tag = nextToken(tag, affixPattern, status); @@ -262,7 +262,7 @@ void AffixUtils::iterateWithConsumer(const UnicodeString& affixPattern, TokenCon UErrorCode& status) { if (affixPattern.length() == 0) { return; - }; + } AffixTag tag; while (hasNext(tag, affixPattern)) { tag = nextToken(tag, affixPattern, status); diff --git a/deps/icu-small/source/i18n/number_affixutils.h b/deps/icu-small/source/i18n/number_affixutils.h index f011a54b316166..5cfde61ffd0ca2 100644 --- a/deps/icu-small/source/i18n/number_affixutils.h +++ b/deps/icu-small/source/i18n/number_affixutils.h @@ -11,7 +11,7 @@ #include "number_types.h" #include "unicode/stringpiece.h" #include "unicode/unistr.h" -#include "number_stringbuilder.h" +#include "formatted_string_builder.h" #include "unicode/uniset.h" U_NAMESPACE_BEGIN namespace number { @@ -134,16 +134,16 @@ class U_I18N_API AffixUtils { /** * Executes the unescape state machine. Replaces the unquoted characters "-", "+", "%", "‰", and * "¤" with the corresponding symbols provided by the {@link SymbolProvider}, and inserts the - * result into the NumberStringBuilder at the requested location. + * result into the FormattedStringBuilder at the requested location. * *

Example input: "'-'¤x"; example output: "-$x" * * @param affixPattern The original string to be unescaped. - * @param output The NumberStringBuilder to mutate with the result. - * @param position The index into the NumberStringBuilder to insert the string. + * @param output The FormattedStringBuilder to mutate with the result. + * @param position The index into the FormattedStringBuilder to insert the string. * @param provider An object to generate locale symbols. */ - static int32_t unescape(const UnicodeString& affixPattern, NumberStringBuilder& output, + static int32_t unescape(const UnicodeString& affixPattern, FormattedStringBuilder& output, int32_t position, const SymbolProvider& provider, Field field, UErrorCode& status); diff --git a/deps/icu-small/source/i18n/number_asformat.cpp b/deps/icu-small/source/i18n/number_asformat.cpp index 9d3ea69f578e1e..e876174fdce0ee 100644 --- a/deps/icu-small/source/i18n/number_asformat.cpp +++ b/deps/icu-small/source/i18n/number_asformat.cpp @@ -43,7 +43,7 @@ UBool LocalizedNumberFormatterAsFormat::operator==(const Format& other) const { return fFormatter.toSkeleton(localStatus) == _other->fFormatter.toSkeleton(localStatus); } -Format* LocalizedNumberFormatterAsFormat::clone() const { +LocalizedNumberFormatterAsFormat* LocalizedNumberFormatterAsFormat::clone() const { return new LocalizedNumberFormatterAsFormat(*this); } @@ -62,12 +62,12 @@ UnicodeString& LocalizedNumberFormatterAsFormat::format(const Formattable& obj, // always return first occurrence: pos.setBeginIndex(0); pos.setEndIndex(0); - bool found = data.getStringRef().nextFieldPosition(pos, status); + bool found = data.nextFieldPosition(pos, status); if (found && appendTo.length() != 0) { pos.setBeginIndex(pos.getBeginIndex() + appendTo.length()); pos.setEndIndex(pos.getEndIndex() + appendTo.length()); } - appendTo.append(data.getStringRef().toTempUnicodeString()); + appendTo.append(data.toTempString(status)); return appendTo; } @@ -84,10 +84,10 @@ UnicodeString& LocalizedNumberFormatterAsFormat::format(const Formattable& obj, if (U_FAILURE(status)) { return appendTo; } - appendTo.append(data.getStringRef().toTempUnicodeString()); + appendTo.append(data.toTempString(status)); if (posIter != nullptr) { FieldPositionIteratorHandler fpih(posIter, status); - data.getStringRef().getAllFieldPositions(fpih, status); + data.getAllFieldPositions(fpih, status); } return appendTo; } diff --git a/deps/icu-small/source/i18n/number_asformat.h b/deps/icu-small/source/i18n/number_asformat.h index bf82d72ae302a4..7b0a1dee6f438b 100644 --- a/deps/icu-small/source/i18n/number_asformat.h +++ b/deps/icu-small/source/i18n/number_asformat.h @@ -45,7 +45,7 @@ class U_I18N_API LocalizedNumberFormatterAsFormat : public Format { /** * Creates a copy of this object. */ - Format* clone() const U_OVERRIDE; + LocalizedNumberFormatterAsFormat* clone() const U_OVERRIDE; /** * Formats a Number using the wrapped LocalizedNumberFormatter. The provided formattable must be a diff --git a/deps/icu-small/source/i18n/number_compact.cpp b/deps/icu-small/source/i18n/number_compact.cpp index f330251be38c88..3d259999d6ce52 100644 --- a/deps/icu-small/source/i18n/number_compact.cpp +++ b/deps/icu-small/source/i18n/number_compact.cpp @@ -272,15 +272,15 @@ void CompactHandler::processQuantity(DecimalQuantity &quantity, MicroProps &micr parent->processQuantity(quantity, micros, status); if (U_FAILURE(status)) { return; } - // Treat zero as if it had magnitude 0 + // Treat zero, NaN, and infinity as if they had magnitude 0 int32_t magnitude; - if (quantity.isZero()) { + if (quantity.isZeroish()) { magnitude = 0; micros.rounder.apply(quantity, status); } else { // TODO: Revisit chooseMultiplierAndApply int32_t multiplier = micros.rounder.chooseMultiplierAndApply(quantity, data, status); - magnitude = quantity.isZero() ? 0 : quantity.getMagnitude(); + magnitude = quantity.isZeroish() ? 0 : quantity.getMagnitude(); magnitude -= multiplier; } diff --git a/deps/icu-small/source/i18n/number_currencysymbols.cpp b/deps/icu-small/source/i18n/number_currencysymbols.cpp index 0b79d6596f18c0..4d6fb2cb1d8dec 100644 --- a/deps/icu-small/source/i18n/number_currencysymbols.cpp +++ b/deps/icu-small/source/i18n/number_currencysymbols.cpp @@ -53,13 +53,12 @@ UnicodeString CurrencySymbols::getCurrencySymbol(UErrorCode& status) const { UnicodeString CurrencySymbols::loadSymbol(UCurrNameStyle selector, UErrorCode& status) const { const char16_t* isoCode = fCurrency.getISOCurrency(); - UBool ignoredIsChoiceFormatFillIn = FALSE; int32_t symbolLen = 0; const char16_t* symbol = ucurr_getName( isoCode, fLocaleName.data(), selector, - &ignoredIsChoiceFormatFillIn, + nullptr /* isChoiceFormat */, &symbolLen, &status); // If given an unknown currency, ucurr_getName returns the input string, which we can't alias safely! @@ -82,12 +81,11 @@ UnicodeString CurrencySymbols::getIntlCurrencySymbol(UErrorCode&) const { UnicodeString CurrencySymbols::getPluralName(StandardPlural::Form plural, UErrorCode& status) const { const char16_t* isoCode = fCurrency.getISOCurrency(); - UBool isChoiceFormat = FALSE; int32_t symbolLen = 0; const char16_t* symbol = ucurr_getPluralName( isoCode, fLocaleName.data(), - &isChoiceFormat, + nullptr /* isChoiceFormat */, StandardPlural::getKeyword(plural), &symbolLen, &status); diff --git a/deps/icu-small/source/i18n/number_decimalquantity.cpp b/deps/icu-small/source/i18n/number_decimalquantity.cpp index d899c27671181e..2c4c2ce7e9931b 100644 --- a/deps/icu-small/source/i18n/number_decimalquantity.cpp +++ b/deps/icu-small/source/i18n/number_decimalquantity.cpp @@ -205,7 +205,7 @@ void DecimalQuantity::roundToIncrement(double roundingIncrement, RoundingMode ro } void DecimalQuantity::multiplyBy(const DecNum& multiplicand, UErrorCode& status) { - if (isInfinite() || isZero() || isNaN()) { + if (isZeroish()) { return; } // Convert to DecNum, multiply, and convert back. @@ -218,7 +218,7 @@ void DecimalQuantity::multiplyBy(const DecNum& multiplicand, UErrorCode& status) } void DecimalQuantity::divideBy(const DecNum& divisor, UErrorCode& status) { - if (isInfinite() || isZero() || isNaN()) { + if (isZeroish()) { return; } // Convert to DecNum, multiply, and convert back. @@ -318,8 +318,14 @@ bool DecimalQuantity::isNegative() const { return (flags & NEGATIVE_FLAG) != 0; } -int8_t DecimalQuantity::signum() const { - return isNegative() ? -1 : isZero() ? 0 : 1; +Signum DecimalQuantity::signum() const { + if (isNegative()) { + return SIGNUM_NEG; + } else if (isZeroish() && !isInfinite()) { + return SIGNUM_ZERO; + } else { + return SIGNUM_POS; + } } bool DecimalQuantity::isInfinite() const { @@ -330,7 +336,7 @@ bool DecimalQuantity::isNaN() const { return (flags & NAN_FLAG) != 0; } -bool DecimalQuantity::isZero() const { +bool DecimalQuantity::isZeroish() const { return precision == 0; } @@ -548,7 +554,10 @@ uint64_t DecimalQuantity::toFractionLong(bool includeTrailingZeros) const { } bool DecimalQuantity::fitsInLong(bool ignoreFraction) const { - if (isZero()) { + if (isInfinite() || isNaN()) { + return false; + } + if (isZeroish()) { return true; } if (scale < 0 && !ignoreFraction) { diff --git a/deps/icu-small/source/i18n/number_decimalquantity.h b/deps/icu-small/source/i18n/number_decimalquantity.h index 06cc836c7796f2..4ec6c5a5b2bcf7 100644 --- a/deps/icu-small/source/i18n/number_decimalquantity.h +++ b/deps/icu-small/source/i18n/number_decimalquantity.h @@ -146,14 +146,17 @@ class U_I18N_API DecimalQuantity : public IFixedDecimal, public UMemory { */ int32_t getMagnitude() const; - /** @return Whether the value represented by this {@link DecimalQuantity} is zero. */ - bool isZero() const; + /** + * @return Whether the value represented by this {@link DecimalQuantity} is + * zero, infinity, or NaN. + */ + bool isZeroish() const; /** @return Whether the value represented by this {@link DecimalQuantity} is less than zero. */ bool isNegative() const; - /** @return -1 if the value is negative; 1 if positive; or 0 if zero. */ - int8_t signum() const; + /** @return The appropriate value from the Signum enum. */ + Signum signum() const; /** @return Whether the value represented by this {@link DecimalQuantity} is infinite. */ bool isInfinite() const U_OVERRIDE; diff --git a/deps/icu-small/source/i18n/number_decnum.h b/deps/icu-small/source/i18n/number_decnum.h index a7793470b55695..0c7399dbddd43b 100644 --- a/deps/icu-small/source/i18n/number_decnum.h +++ b/deps/icu-small/source/i18n/number_decnum.h @@ -55,6 +55,8 @@ class U_I18N_API DecNum : public UMemory { bool isZero() const; + void toString(ByteSink& output, UErrorCode& status) const; + inline const decNumber* getRawDecNumber() const { return fData.getAlias(); } diff --git a/deps/icu-small/source/i18n/number_fluent.cpp b/deps/icu-small/source/i18n/number_fluent.cpp index 09e0905609eb30..2dbd2fa6cd5acf 100644 --- a/deps/icu-small/source/i18n/number_fluent.cpp +++ b/deps/icu-small/source/i18n/number_fluent.cpp @@ -696,8 +696,8 @@ void LocalizedNumberFormatter::formatImpl(impl::UFormattedNumberData* results, U void LocalizedNumberFormatter::getAffixImpl(bool isPrefix, bool isNegative, UnicodeString& result, UErrorCode& status) const { - NumberStringBuilder string; - auto signum = static_cast(isNegative ? -1 : 1); + FormattedStringBuilder string; + auto signum = static_cast(isNegative ? SIGNUM_NEG : SIGNUM_POS); // Always return affixes for plural form OTHER. static const StandardPlural::Form plural = StandardPlural::OTHER; int32_t prefixLength; diff --git a/deps/icu-small/source/i18n/number_formatimpl.cpp b/deps/icu-small/source/i18n/number_formatimpl.cpp index 08b833beb7ad2e..2e2c4a9620c77c 100644 --- a/deps/icu-small/source/i18n/number_formatimpl.cpp +++ b/deps/icu-small/source/i18n/number_formatimpl.cpp @@ -72,7 +72,7 @@ NumberFormatterImpl::NumberFormatterImpl(const MacroProps& macros, UErrorCode& s } int32_t NumberFormatterImpl::formatStatic(const MacroProps& macros, DecimalQuantity& inValue, - NumberStringBuilder& outString, UErrorCode& status) { + FormattedStringBuilder& outString, UErrorCode& status) { NumberFormatterImpl impl(macros, false, status); MicroProps& micros = impl.preProcessUnsafe(inValue, status); if (U_FAILURE(status)) { return 0; } @@ -81,9 +81,9 @@ int32_t NumberFormatterImpl::formatStatic(const MacroProps& macros, DecimalQuant return length; } -int32_t NumberFormatterImpl::getPrefixSuffixStatic(const MacroProps& macros, int8_t signum, +int32_t NumberFormatterImpl::getPrefixSuffixStatic(const MacroProps& macros, Signum signum, StandardPlural::Form plural, - NumberStringBuilder& outString, UErrorCode& status) { + FormattedStringBuilder& outString, UErrorCode& status) { NumberFormatterImpl impl(macros, false, status); return impl.getPrefixSuffixUnsafe(signum, plural, outString, status); } @@ -93,7 +93,7 @@ int32_t NumberFormatterImpl::getPrefixSuffixStatic(const MacroProps& macros, int // The "unsafe" method simply re-uses fMicros, eliminating the extra copy operation. // See MicroProps::processQuantity() for details. -int32_t NumberFormatterImpl::format(DecimalQuantity& inValue, NumberStringBuilder& outString, +int32_t NumberFormatterImpl::format(DecimalQuantity& inValue, FormattedStringBuilder& outString, UErrorCode& status) const { MicroProps micros; preProcess(inValue, micros, status); @@ -129,8 +129,8 @@ MicroProps& NumberFormatterImpl::preProcessUnsafe(DecimalQuantity& inValue, UErr return fMicros; } -int32_t NumberFormatterImpl::getPrefixSuffix(int8_t signum, StandardPlural::Form plural, - NumberStringBuilder& outString, UErrorCode& status) const { +int32_t NumberFormatterImpl::getPrefixSuffix(Signum signum, StandardPlural::Form plural, + FormattedStringBuilder& outString, UErrorCode& status) const { if (U_FAILURE(status)) { return 0; } // #13453: DecimalFormat wants the affixes from the pattern only (modMiddle, aka pattern modifier). // Safe path: use fImmutablePatternModifier. @@ -140,8 +140,8 @@ int32_t NumberFormatterImpl::getPrefixSuffix(int8_t signum, StandardPlural::Form return modifier->getPrefixLength(); } -int32_t NumberFormatterImpl::getPrefixSuffixUnsafe(int8_t signum, StandardPlural::Form plural, - NumberStringBuilder& outString, UErrorCode& status) { +int32_t NumberFormatterImpl::getPrefixSuffixUnsafe(Signum signum, StandardPlural::Form plural, + FormattedStringBuilder& outString, UErrorCode& status) { if (U_FAILURE(status)) { return 0; } // #13453: DecimalFormat wants the affixes from the pattern only (modMiddle, aka pattern modifier). // Unsafe path: use fPatternModifier. @@ -215,7 +215,12 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps& macros, bool safe, if (macros.symbols.isDecimalFormatSymbols()) { fMicros.symbols = macros.symbols.getDecimalFormatSymbols(); } else { - fMicros.symbols = new DecimalFormatSymbols(macros.locale, *ns, status); + auto newSymbols = new DecimalFormatSymbols(macros.locale, *ns, status); + if (newSymbols == nullptr) { + status = U_MEMORY_ALLOCATION_ERROR; + return nullptr; + } + fMicros.symbols = newSymbols; // Give ownership to the NumberFormatterImpl. fSymbols.adoptInstead(fMicros.symbols); } @@ -229,7 +234,11 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps& macros, bool safe, if (info.exists) { pattern = info.pattern; // It's clunky to clone an object here, but this code is not frequently executed. - auto* symbols = new DecimalFormatSymbols(*fMicros.symbols); + auto symbols = new DecimalFormatSymbols(*fMicros.symbols); + if (symbols == nullptr) { + status = U_MEMORY_ALLOCATION_ERROR; + return nullptr; + } fMicros.symbols = symbols; fSymbols.adoptInstead(symbols); symbols->setSymbol( @@ -260,6 +269,10 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps& macros, bool safe, pattern = utils::getPatternForStyle(macros.locale, nsName, patternStyle, status); } auto patternInfo = new ParsedPatternInfo(); + if (patternInfo == nullptr) { + status = U_MEMORY_ALLOCATION_ERROR; + return nullptr; + } fPatternInfo.adoptInstead(patternInfo); PatternParser::parseToPatternInfo(UnicodeString(pattern), *patternInfo, status); @@ -337,7 +350,12 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps& macros, bool safe, // Inner modifier (scientific notation) if (macros.notation.fType == Notation::NTN_SCIENTIFIC) { - fScientificHandler.adoptInstead(new ScientificHandler(¯os.notation, fMicros.symbols, chain)); + auto newScientificHandler = new ScientificHandler(¯os.notation, fMicros.symbols, chain); + if (newScientificHandler == nullptr) { + status = U_MEMORY_ALLOCATION_ERROR; + return nullptr; + } + fScientificHandler.adoptInstead(newScientificHandler); chain = fScientificHandler.getAlias(); } else { // No inner modifier required @@ -346,6 +364,10 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps& macros, bool safe, // Middle modifier (patterns, positive/negative, currency symbols, percent) auto patternModifier = new MutablePatternModifier(false); + if (patternModifier == nullptr) { + status = U_MEMORY_ALLOCATION_ERROR; + return nullptr; + } fPatternModifier.adoptInstead(patternModifier); patternModifier->setPatternInfo( macros.affixProvider != nullptr ? macros.affixProvider @@ -401,16 +423,20 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps& macros, bool safe, if (macros.notation.fType == Notation::NTN_COMPACT) { CompactType compactType = (isCurrency && unitWidth != UNUM_UNIT_WIDTH_FULL_NAME) ? CompactType::TYPE_CURRENCY : CompactType::TYPE_DECIMAL; - fCompactHandler.adoptInstead( - new CompactHandler( - macros.notation.fUnion.compactStyle, - macros.locale, - nsName, - compactType, - resolvePluralRules(macros.rules, macros.locale, status), - safe ? patternModifier : nullptr, - chain, - status)); + auto newCompactHandler = new CompactHandler( + macros.notation.fUnion.compactStyle, + macros.locale, + nsName, + compactType, + resolvePluralRules(macros.rules, macros.locale, status), + safe ? patternModifier : nullptr, + chain, + status); + if (newCompactHandler == nullptr) { + status = U_MEMORY_ALLOCATION_ERROR; + return nullptr; + } + fCompactHandler.adoptInstead(newCompactHandler); chain = fCompactHandler.getAlias(); } @@ -430,7 +456,7 @@ NumberFormatterImpl::resolvePluralRules(const PluralRules* rulesPtr, const Local return fRules.getAlias(); } -int32_t NumberFormatterImpl::writeAffixes(const MicroProps& micros, NumberStringBuilder& string, +int32_t NumberFormatterImpl::writeAffixes(const MicroProps& micros, FormattedStringBuilder& string, int32_t start, int32_t end, UErrorCode& status) { // Always apply the inner modifier (which is "strong"). int32_t length = micros.modInner->apply(string, start, end, status); @@ -445,7 +471,7 @@ int32_t NumberFormatterImpl::writeAffixes(const MicroProps& micros, NumberString } int32_t NumberFormatterImpl::writeNumber(const MicroProps& micros, DecimalQuantity& quantity, - NumberStringBuilder& string, int32_t index, + FormattedStringBuilder& string, int32_t index, UErrorCode& status) { int32_t length = 0; if (quantity.isInfinite()) { @@ -487,7 +513,7 @@ int32_t NumberFormatterImpl::writeNumber(const MicroProps& micros, DecimalQuanti } int32_t NumberFormatterImpl::writeIntegerDigits(const MicroProps& micros, DecimalQuantity& quantity, - NumberStringBuilder& string, int32_t index, + FormattedStringBuilder& string, int32_t index, UErrorCode& status) { int length = 0; int integerCount = quantity.getUpperDisplayMagnitude() + 1; @@ -513,7 +539,7 @@ int32_t NumberFormatterImpl::writeIntegerDigits(const MicroProps& micros, Decima } int32_t NumberFormatterImpl::writeFractionDigits(const MicroProps& micros, DecimalQuantity& quantity, - NumberStringBuilder& string, int32_t index, + FormattedStringBuilder& string, int32_t index, UErrorCode& status) { int length = 0; int fractionCount = -quantity.getLowerDisplayMagnitude(); diff --git a/deps/icu-small/source/i18n/number_formatimpl.h b/deps/icu-small/source/i18n/number_formatimpl.h index fd8708c532e131..206c5f58c576a1 100644 --- a/deps/icu-small/source/i18n/number_formatimpl.h +++ b/deps/icu-small/source/i18n/number_formatimpl.h @@ -8,7 +8,7 @@ #define __NUMBER_FORMATIMPL_H__ #include "number_types.h" -#include "number_stringbuilder.h" +#include "formatted_string_builder.h" #include "number_patternstring.h" #include "number_utils.h" #include "number_patternmodifier.h" @@ -35,7 +35,7 @@ class NumberFormatterImpl : public UMemory { * Builds and evaluates an "unsafe" MicroPropsGenerator, which is cheaper but can be used only once. */ static int32_t - formatStatic(const MacroProps ¯os, DecimalQuantity &inValue, NumberStringBuilder &outString, + formatStatic(const MacroProps ¯os, DecimalQuantity &inValue, FormattedStringBuilder &outString, UErrorCode &status); /** @@ -44,14 +44,14 @@ class NumberFormatterImpl : public UMemory { * @return The index into the output at which the prefix ends and the suffix starts; in other words, * the prefix length. */ - static int32_t getPrefixSuffixStatic(const MacroProps& macros, int8_t signum, - StandardPlural::Form plural, NumberStringBuilder& outString, + static int32_t getPrefixSuffixStatic(const MacroProps& macros, Signum signum, + StandardPlural::Form plural, FormattedStringBuilder& outString, UErrorCode& status); /** * Evaluates the "safe" MicroPropsGenerator created by "fromMacros". */ - int32_t format(DecimalQuantity& inValue, NumberStringBuilder& outString, UErrorCode& status) const; + int32_t format(DecimalQuantity& inValue, FormattedStringBuilder& outString, UErrorCode& status) const; /** * Like format(), but saves the result into an output MicroProps without additional processing. @@ -61,7 +61,7 @@ class NumberFormatterImpl : public UMemory { /** * Like getPrefixSuffixStatic() but uses the safe compiled object. */ - int32_t getPrefixSuffix(int8_t signum, StandardPlural::Form plural, NumberStringBuilder& outString, + int32_t getPrefixSuffix(Signum signum, StandardPlural::Form plural, FormattedStringBuilder& outString, UErrorCode& status) const; const MicroProps& getRawMicroProps() const { @@ -73,12 +73,12 @@ class NumberFormatterImpl : public UMemory { * This method formats only the main number, not affixes. */ static int32_t writeNumber(const MicroProps& micros, DecimalQuantity& quantity, - NumberStringBuilder& string, int32_t index, UErrorCode& status); + FormattedStringBuilder& string, int32_t index, UErrorCode& status); /** * Adds the affixes. Intended to be called immediately after formatNumber. */ - static int32_t writeAffixes(const MicroProps& micros, NumberStringBuilder& string, int32_t start, + static int32_t writeAffixes(const MicroProps& micros, FormattedStringBuilder& string, int32_t start, int32_t end, UErrorCode& status); private: @@ -109,8 +109,8 @@ class NumberFormatterImpl : public UMemory { MicroProps& preProcessUnsafe(DecimalQuantity &inValue, UErrorCode &status); - int32_t getPrefixSuffixUnsafe(int8_t signum, StandardPlural::Form plural, - NumberStringBuilder& outString, UErrorCode& status); + int32_t getPrefixSuffixUnsafe(Signum signum, StandardPlural::Form plural, + FormattedStringBuilder& outString, UErrorCode& status); /** * If rulesPtr is non-null, return it. Otherwise, return a PluralRules owned by this object for the @@ -136,11 +136,11 @@ class NumberFormatterImpl : public UMemory { macrosToMicroGenerator(const MacroProps ¯os, bool safe, UErrorCode &status); static int32_t - writeIntegerDigits(const MicroProps µs, DecimalQuantity &quantity, NumberStringBuilder &string, + writeIntegerDigits(const MicroProps µs, DecimalQuantity &quantity, FormattedStringBuilder &string, int32_t index, UErrorCode &status); static int32_t - writeFractionDigits(const MicroProps µs, DecimalQuantity &quantity, NumberStringBuilder &string, + writeFractionDigits(const MicroProps µs, DecimalQuantity &quantity, FormattedStringBuilder &string, int32_t index, UErrorCode &status); }; diff --git a/deps/icu-small/source/i18n/number_longnames.cpp b/deps/icu-small/source/i18n/number_longnames.cpp index 0cd160042a46d3..817aa0e0d9c39d 100644 --- a/deps/icu-small/source/i18n/number_longnames.cpp +++ b/deps/icu-small/source/i18n/number_longnames.cpp @@ -148,12 +148,11 @@ void getCurrencyLongNameData(const Locale &locale, const CurrencyUnit ¤cy, if (pattern.isBogus()) { continue; } - UBool isChoiceFormat = FALSE; int32_t longNameLen = 0; const char16_t *longName = ucurr_getPluralName( currency.getISOCurrency(), locale.getName(), - &isChoiceFormat, + nullptr /* isChoiceFormat */, StandardPlural::getKeyword(static_cast(i)), &longNameLen, &status); @@ -265,6 +264,26 @@ UnicodeString LongNameHandler::getUnitDisplayName( return simpleFormats[DNAM_INDEX]; } +UnicodeString LongNameHandler::getUnitPattern( + const Locale& loc, + const MeasureUnit& unit, + UNumberUnitWidth width, + StandardPlural::Form pluralForm, + UErrorCode& status) { + if (U_FAILURE(status)) { + return ICU_Utility::makeBogusString(); + } + UnicodeString simpleFormats[ARRAY_LENGTH]; + getMeasureData(loc, unit, width, simpleFormats, status); + // The above already handles fallback from other widths to short + if (U_FAILURE(status)) { + return ICU_Utility::makeBogusString(); + } + // Now handle fallback from other plural forms to OTHER + return (!(simpleFormats[pluralForm]).isBogus())? simpleFormats[pluralForm]: + simpleFormats[StandardPlural::Form::OTHER]; +} + LongNameHandler* LongNameHandler::forCurrencyLongNames(const Locale &loc, const CurrencyUnit ¤cy, const PluralRules *rules, const MicroPropsGenerator *parent, @@ -289,7 +308,7 @@ void LongNameHandler::simpleFormatsToModifiers(const UnicodeString *simpleFormat if (U_FAILURE(status)) { return; } SimpleFormatter compiledFormatter(simpleFormat, 0, 1, status); if (U_FAILURE(status)) { return; } - fModifiers[i] = SimpleModifier(compiledFormatter, field, false, {this, 0, plural}); + fModifiers[i] = SimpleModifier(compiledFormatter, field, false, {this, SIGNUM_ZERO, plural}); } } @@ -306,7 +325,7 @@ void LongNameHandler::multiSimpleFormatsToModifiers(const UnicodeString *leadFor if (U_FAILURE(status)) { return; } SimpleFormatter compoundCompiled(compoundFormat, 0, 1, status); if (U_FAILURE(status)) { return; } - fModifiers[i] = SimpleModifier(compoundCompiled, field, false, {this, 0, plural}); + fModifiers[i] = SimpleModifier(compoundCompiled, field, false, {this, SIGNUM_ZERO, plural}); } } @@ -317,7 +336,7 @@ void LongNameHandler::processQuantity(DecimalQuantity &quantity, MicroProps &mic micros.modOuter = &fModifiers[pluralForm]; } -const Modifier* LongNameHandler::getModifier(int8_t /*signum*/, StandardPlural::Form plural) const { +const Modifier* LongNameHandler::getModifier(Signum /*signum*/, StandardPlural::Form plural) const { return &fModifiers[plural]; } diff --git a/deps/icu-small/source/i18n/number_longnames.h b/deps/icu-small/source/i18n/number_longnames.h index 76fb82d744b6d4..a19425aa268af6 100644 --- a/deps/icu-small/source/i18n/number_longnames.h +++ b/deps/icu-small/source/i18n/number_longnames.h @@ -22,6 +22,13 @@ class LongNameHandler : public MicroPropsGenerator, public ModifierStore, public UNumberUnitWidth width, UErrorCode& status); + static UnicodeString getUnitPattern( + const Locale& loc, + const MeasureUnit& unit, + UNumberUnitWidth width, + StandardPlural::Form pluralForm, + UErrorCode& status); + static LongNameHandler* forCurrencyLongNames(const Locale &loc, const CurrencyUnit ¤cy, const PluralRules *rules, const MicroPropsGenerator *parent, UErrorCode &status); @@ -34,7 +41,7 @@ class LongNameHandler : public MicroPropsGenerator, public ModifierStore, public void processQuantity(DecimalQuantity &quantity, MicroProps µs, UErrorCode &status) const U_OVERRIDE; - const Modifier* getModifier(int8_t signum, StandardPlural::Form plural) const U_OVERRIDE; + const Modifier* getModifier(Signum signum, StandardPlural::Form plural) const U_OVERRIDE; private: SimpleModifier fModifiers[StandardPlural::Form::COUNT]; diff --git a/deps/icu-small/source/i18n/number_mapper.h b/deps/icu-small/source/i18n/number_mapper.h index d28e9cec393a05..de7d9c3865c8df 100644 --- a/deps/icu-small/source/i18n/number_mapper.h +++ b/deps/icu-small/source/i18n/number_mapper.h @@ -126,8 +126,14 @@ struct DecimalFormatWarehouse { * TODO: Make some of these fields by value instead of by LocalPointer? */ struct DecimalFormatFields : public UMemory { + + DecimalFormatFields() {} + + DecimalFormatFields(const DecimalFormatProperties& propsToCopy) + : properties(propsToCopy) {} + /** The property bag corresponding to user-specified settings and settings from the pattern string. */ - LocalPointer properties; + DecimalFormatProperties properties; /** The symbols for the current locale. */ LocalPointer symbols; @@ -136,7 +142,7 @@ struct DecimalFormatFields : public UMemory { * The pre-computed formatter object. Setters cause this to be re-computed atomically. The {@link * #format} method uses the formatter directly without needing to synchronize. */ - LocalPointer formatter; + LocalizedNumberFormatter formatter; /** The lazy-computed parser for .parse() */ std::atomic<::icu::numparse::impl::NumberParserImpl*> atomicParser = {}; @@ -148,7 +154,7 @@ struct DecimalFormatFields : public UMemory { DecimalFormatWarehouse warehouse; /** The effective properties as exported from the formatter object. Used by some getters. */ - LocalPointer exportedProperties; + DecimalFormatProperties exportedProperties; // Data for fastpath bool canUseFastFormat = false; diff --git a/deps/icu-small/source/i18n/number_modifiers.cpp b/deps/icu-small/source/i18n/number_modifiers.cpp index 1fcbe7b9b79301..3a44f8f6f15328 100644 --- a/deps/icu-small/source/i18n/number_modifiers.cpp +++ b/deps/icu-small/source/i18n/number_modifiers.cpp @@ -57,7 +57,7 @@ Modifier::Parameters::Parameters() : obj(nullptr) {} Modifier::Parameters::Parameters( - const ModifierStore* _obj, int8_t _signum, StandardPlural::Form _plural) + const ModifierStore* _obj, Signum _signum, StandardPlural::Form _plural) : obj(_obj), signum(_signum), plural(_plural) {} ModifierStore::~ModifierStore() = default; @@ -69,7 +69,7 @@ AdoptingModifierStore::~AdoptingModifierStore() { } -int32_t ConstantAffixModifier::apply(NumberStringBuilder &output, int leftIndex, int rightIndex, +int32_t ConstantAffixModifier::apply(FormattedStringBuilder &output, int leftIndex, int rightIndex, UErrorCode &status) const { // Insert the suffix first since inserting the prefix will change the rightIndex int length = output.insert(rightIndex, fSuffix, fField, status); @@ -154,7 +154,7 @@ SimpleModifier::SimpleModifier() : fField(UNUM_FIELD_COUNT), fStrong(false), fPrefixLength(0), fSuffixLength(0) { } -int32_t SimpleModifier::apply(NumberStringBuilder &output, int leftIndex, int rightIndex, +int32_t SimpleModifier::apply(FormattedStringBuilder &output, int leftIndex, int rightIndex, UErrorCode &status) const { return formatAsPrefixSuffix(output, leftIndex, rightIndex, status); } @@ -203,7 +203,7 @@ bool SimpleModifier::semanticallyEquivalent(const Modifier& other) const { int32_t -SimpleModifier::formatAsPrefixSuffix(NumberStringBuilder &result, int32_t startIndex, int32_t endIndex, +SimpleModifier::formatAsPrefixSuffix(FormattedStringBuilder &result, int32_t startIndex, int32_t endIndex, UErrorCode &status) const { if (fSuffixOffset == -1 && fPrefixLength + fSuffixLength > 0) { // There is no argument for the inner number; overwrite the entire segment with our string. @@ -227,7 +227,7 @@ SimpleModifier::formatAsPrefixSuffix(NumberStringBuilder &result, int32_t startI int32_t -SimpleModifier::formatTwoArgPattern(const SimpleFormatter& compiled, NumberStringBuilder& result, +SimpleModifier::formatTwoArgPattern(const SimpleFormatter& compiled, FormattedStringBuilder& result, int32_t index, int32_t* outPrefixLength, int32_t* outSuffixLength, Field field, UErrorCode& status) { const UnicodeString& compiledPattern = compiled.compiledPattern; @@ -284,7 +284,7 @@ SimpleModifier::formatTwoArgPattern(const SimpleFormatter& compiled, NumberStrin } -int32_t ConstantMultiFieldModifier::apply(NumberStringBuilder &output, int leftIndex, int rightIndex, +int32_t ConstantMultiFieldModifier::apply(FormattedStringBuilder &output, int leftIndex, int rightIndex, UErrorCode &status) const { int32_t length = output.insert(leftIndex, fPrefix, status); if (fOverwrite) { @@ -333,8 +333,8 @@ bool ConstantMultiFieldModifier::semanticallyEquivalent(const Modifier& other) c } -CurrencySpacingEnabledModifier::CurrencySpacingEnabledModifier(const NumberStringBuilder &prefix, - const NumberStringBuilder &suffix, +CurrencySpacingEnabledModifier::CurrencySpacingEnabledModifier(const FormattedStringBuilder &prefix, + const FormattedStringBuilder &suffix, bool overwrite, bool strong, const DecimalFormatSymbols &symbols, @@ -374,7 +374,7 @@ CurrencySpacingEnabledModifier::CurrencySpacingEnabledModifier(const NumberStrin } } -int32_t CurrencySpacingEnabledModifier::apply(NumberStringBuilder &output, int leftIndex, int rightIndex, +int32_t CurrencySpacingEnabledModifier::apply(FormattedStringBuilder &output, int leftIndex, int rightIndex, UErrorCode &status) const { // Currency spacing logic int length = 0; @@ -395,7 +395,7 @@ int32_t CurrencySpacingEnabledModifier::apply(NumberStringBuilder &output, int l } int32_t -CurrencySpacingEnabledModifier::applyCurrencySpacing(NumberStringBuilder &output, int32_t prefixStart, +CurrencySpacingEnabledModifier::applyCurrencySpacing(FormattedStringBuilder &output, int32_t prefixStart, int32_t prefixLen, int32_t suffixStart, int32_t suffixLen, const DecimalFormatSymbols &symbols, @@ -414,7 +414,7 @@ CurrencySpacingEnabledModifier::applyCurrencySpacing(NumberStringBuilder &output } int32_t -CurrencySpacingEnabledModifier::applyCurrencySpacingAffix(NumberStringBuilder &output, int32_t index, +CurrencySpacingEnabledModifier::applyCurrencySpacingAffix(FormattedStringBuilder &output, int32_t index, EAffix affix, const DecimalFormatSymbols &symbols, UErrorCode &status) { diff --git a/deps/icu-small/source/i18n/number_modifiers.h b/deps/icu-small/source/i18n/number_modifiers.h index 495128bb149dcf..c84c6aa273ed76 100644 --- a/deps/icu-small/source/i18n/number_modifiers.h +++ b/deps/icu-small/source/i18n/number_modifiers.h @@ -12,7 +12,7 @@ #include "unicode/uniset.h" #include "unicode/simpleformatter.h" #include "standardplural.h" -#include "number_stringbuilder.h" +#include "formatted_string_builder.h" #include "number_types.h" U_NAMESPACE_BEGIN namespace number { @@ -28,7 +28,7 @@ class U_I18N_API ConstantAffixModifier : public Modifier, public UObject { bool strong) : fPrefix(prefix), fSuffix(suffix), fField(field), fStrong(strong) {} - int32_t apply(NumberStringBuilder &output, int32_t leftIndex, int32_t rightIndex, + int32_t apply(FormattedStringBuilder &output, int32_t leftIndex, int32_t rightIndex, UErrorCode &status) const U_OVERRIDE; int32_t getPrefixLength() const U_OVERRIDE; @@ -64,7 +64,7 @@ class U_I18N_API SimpleModifier : public Modifier, public UMemory { // Default constructor for LongNameHandler.h SimpleModifier(); - int32_t apply(NumberStringBuilder &output, int32_t leftIndex, int32_t rightIndex, + int32_t apply(FormattedStringBuilder &output, int32_t leftIndex, int32_t rightIndex, UErrorCode &status) const U_OVERRIDE; int32_t getPrefixLength() const U_OVERRIDE; @@ -81,7 +81,7 @@ class U_I18N_API SimpleModifier : public Modifier, public UMemory { /** * TODO: This belongs in SimpleFormatterImpl. The only reason I haven't moved it there yet is because - * NumberStringBuilder is an internal class and SimpleFormatterImpl feels like it should not depend on it. + * FormattedStringBuilder is an internal class and SimpleFormatterImpl feels like it should not depend on it. * *

* Formats a value that is already stored inside the StringBuilder result between the indices @@ -100,22 +100,22 @@ class U_I18N_API SimpleModifier : public Modifier, public UMemory { * @return The number of characters (UTF-16 code points) that were added to the StringBuilder. */ int32_t - formatAsPrefixSuffix(NumberStringBuilder& result, int32_t startIndex, int32_t endIndex, + formatAsPrefixSuffix(FormattedStringBuilder& result, int32_t startIndex, int32_t endIndex, UErrorCode& status) const; /** * TODO: Like above, this belongs with the rest of the SimpleFormatterImpl code. - * I put it here so that the SimpleFormatter uses in NumberStringBuilder are near each other. + * I put it here so that the SimpleFormatter uses in FormattedStringBuilder are near each other. * *

- * Applies the compiled two-argument pattern to the NumberStringBuilder. + * Applies the compiled two-argument pattern to the FormattedStringBuilder. * *

* This method is optimized for the case where the prefix and suffix are often empty, such as * in the range pattern like "{0}-{1}". */ static int32_t - formatTwoArgPattern(const SimpleFormatter& compiled, NumberStringBuilder& result, + formatTwoArgPattern(const SimpleFormatter& compiled, FormattedStringBuilder& result, int32_t index, int32_t* outPrefixLength, int32_t* outSuffixLength, Field field, UErrorCode& status); @@ -131,13 +131,13 @@ class U_I18N_API SimpleModifier : public Modifier, public UMemory { /** * An implementation of {@link Modifier} that allows for multiple types of fields in the same modifier. Constructed - * based on the contents of two {@link NumberStringBuilder} instances (one for the prefix, one for the suffix). + * based on the contents of two {@link FormattedStringBuilder} instances (one for the prefix, one for the suffix). */ class U_I18N_API ConstantMultiFieldModifier : public Modifier, public UMemory { public: ConstantMultiFieldModifier( - const NumberStringBuilder &prefix, - const NumberStringBuilder &suffix, + const FormattedStringBuilder &prefix, + const FormattedStringBuilder &suffix, bool overwrite, bool strong, const Modifier::Parameters parameters) @@ -148,8 +148,8 @@ class U_I18N_API ConstantMultiFieldModifier : public Modifier, public UMemory { fParameters(parameters) {} ConstantMultiFieldModifier( - const NumberStringBuilder &prefix, - const NumberStringBuilder &suffix, + const FormattedStringBuilder &prefix, + const FormattedStringBuilder &suffix, bool overwrite, bool strong) : fPrefix(prefix), @@ -157,7 +157,7 @@ class U_I18N_API ConstantMultiFieldModifier : public Modifier, public UMemory { fOverwrite(overwrite), fStrong(strong) {} - int32_t apply(NumberStringBuilder &output, int32_t leftIndex, int32_t rightIndex, + int32_t apply(FormattedStringBuilder &output, int32_t leftIndex, int32_t rightIndex, UErrorCode &status) const U_OVERRIDE; int32_t getPrefixLength() const U_OVERRIDE; @@ -173,10 +173,10 @@ class U_I18N_API ConstantMultiFieldModifier : public Modifier, public UMemory { bool semanticallyEquivalent(const Modifier& other) const U_OVERRIDE; protected: - // NOTE: In Java, these are stored as array pointers. In C++, the NumberStringBuilder is stored by + // NOTE: In Java, these are stored as array pointers. In C++, the FormattedStringBuilder is stored by // value and is treated internally as immutable. - NumberStringBuilder fPrefix; - NumberStringBuilder fSuffix; + FormattedStringBuilder fPrefix; + FormattedStringBuilder fSuffix; bool fOverwrite; bool fStrong; Modifier::Parameters fParameters; @@ -187,19 +187,19 @@ class U_I18N_API CurrencySpacingEnabledModifier : public ConstantMultiFieldModif public: /** Safe code path */ CurrencySpacingEnabledModifier( - const NumberStringBuilder &prefix, - const NumberStringBuilder &suffix, + const FormattedStringBuilder &prefix, + const FormattedStringBuilder &suffix, bool overwrite, bool strong, const DecimalFormatSymbols &symbols, UErrorCode &status); - int32_t apply(NumberStringBuilder &output, int32_t leftIndex, int32_t rightIndex, + int32_t apply(FormattedStringBuilder &output, int32_t leftIndex, int32_t rightIndex, UErrorCode &status) const U_OVERRIDE; /** Unsafe code path */ static int32_t - applyCurrencySpacing(NumberStringBuilder &output, int32_t prefixStart, int32_t prefixLen, + applyCurrencySpacing(FormattedStringBuilder &output, int32_t prefixStart, int32_t prefixLen, int32_t suffixStart, int32_t suffixLen, const DecimalFormatSymbols &symbols, UErrorCode &status); @@ -218,7 +218,7 @@ class U_I18N_API CurrencySpacingEnabledModifier : public ConstantMultiFieldModif }; /** Unsafe code path */ - static int32_t applyCurrencySpacingAffix(NumberStringBuilder &output, int32_t index, EAffix affix, + static int32_t applyCurrencySpacingAffix(FormattedStringBuilder &output, int32_t index, EAffix affix, const DecimalFormatSymbols &symbols, UErrorCode &status); static UnicodeSet @@ -234,7 +234,7 @@ class U_I18N_API EmptyModifier : public Modifier, public UMemory { public: explicit EmptyModifier(bool isStrong) : fStrong(isStrong) {} - int32_t apply(NumberStringBuilder &output, int32_t leftIndex, int32_t rightIndex, + int32_t apply(FormattedStringBuilder &output, int32_t leftIndex, int32_t rightIndex, UErrorCode &status) const U_OVERRIDE { (void)output; (void)leftIndex; @@ -289,7 +289,7 @@ class U_I18N_API AdoptingModifierStore : public ModifierStore, public UMemory { /** * Sets the Modifier with the specified signum and plural form. */ - void adoptModifier(int8_t signum, StandardPlural::Form plural, const Modifier *mod) { + void adoptModifier(Signum signum, StandardPlural::Form plural, const Modifier *mod) { U_ASSERT(mods[getModIndex(signum, plural)] == nullptr); mods[getModIndex(signum, plural)] = mod; } @@ -298,13 +298,13 @@ class U_I18N_API AdoptingModifierStore : public ModifierStore, public UMemory { * Sets the Modifier with the specified signum. * The modifier will apply to all plural forms. */ - void adoptModifierWithoutPlural(int8_t signum, const Modifier *mod) { + void adoptModifierWithoutPlural(Signum signum, const Modifier *mod) { U_ASSERT(mods[getModIndex(signum, DEFAULT_STANDARD_PLURAL)] == nullptr); mods[getModIndex(signum, DEFAULT_STANDARD_PLURAL)] = mod; } /** Returns a reference to the modifier; no ownership change. */ - const Modifier *getModifier(int8_t signum, StandardPlural::Form plural) const U_OVERRIDE { + const Modifier *getModifier(Signum signum, StandardPlural::Form plural) const U_OVERRIDE { const Modifier* modifier = mods[getModIndex(signum, plural)]; if (modifier == nullptr && plural != DEFAULT_STANDARD_PLURAL) { modifier = mods[getModIndex(signum, DEFAULT_STANDARD_PLURAL)]; @@ -313,7 +313,7 @@ class U_I18N_API AdoptingModifierStore : public ModifierStore, public UMemory { } /** Returns a reference to the modifier; no ownership change. */ - const Modifier *getModifierWithoutPlural(int8_t signum) const { + const Modifier *getModifierWithoutPlural(Signum signum) const { return mods[getModIndex(signum, DEFAULT_STANDARD_PLURAL)]; } @@ -321,7 +321,7 @@ class U_I18N_API AdoptingModifierStore : public ModifierStore, public UMemory { // NOTE: mods is zero-initialized (to nullptr) const Modifier *mods[3 * StandardPlural::COUNT] = {}; - inline static int32_t getModIndex(int8_t signum, StandardPlural::Form plural) { + inline static int32_t getModIndex(Signum signum, StandardPlural::Form plural) { U_ASSERT(signum >= -1 && signum <= 1); U_ASSERT(plural >= 0 && plural < StandardPlural::COUNT); return static_cast(plural) * 3 + (signum + 1); diff --git a/deps/icu-small/source/i18n/number_output.cpp b/deps/icu-small/source/i18n/number_output.cpp index 6f4e2482044f14..e2f069139a4b47 100644 --- a/deps/icu-small/source/i18n/number_output.cpp +++ b/deps/icu-small/source/i18n/number_output.cpp @@ -9,6 +9,7 @@ #include "number_utypes.h" #include "util.h" #include "number_decimalquantity.h" +#include "number_decnum.h" U_NAMESPACE_BEGIN namespace number { @@ -20,8 +21,7 @@ UPRV_FORMATTED_VALUE_SUBCLASS_AUTO_IMPL(FormattedNumber) UBool FormattedNumber::nextFieldPosition(FieldPosition& fieldPosition, UErrorCode& status) const { UPRV_FORMATTED_VALUE_METHOD_GUARD(FALSE) - // NOTE: MSVC sometimes complains when implicitly converting between bool and UBool - return fData->getStringRef().nextFieldPosition(fieldPosition, status) ? TRUE : FALSE; + return fData->nextFieldPosition(fieldPosition, status); } void FormattedNumber::getAllFieldPositions(FieldPositionIterator& iterator, UErrorCode& status) const { @@ -29,10 +29,17 @@ void FormattedNumber::getAllFieldPositions(FieldPositionIterator& iterator, UErr getAllFieldPositionsImpl(fpih, status); } +void FormattedNumber::toDecimalNumber(ByteSink& sink, UErrorCode& status) const { + UPRV_FORMATTED_VALUE_METHOD_GUARD(UPRV_NOARG) + impl::DecNum decnum; + fData->quantity.toDecNum(decnum, status); + decnum.toString(sink, status); +} + void FormattedNumber::getAllFieldPositionsImpl(FieldPositionIteratorHandler& fpih, UErrorCode& status) const { UPRV_FORMATTED_VALUE_METHOD_GUARD(UPRV_NOARG) - fData->getStringRef().getAllFieldPositions(fpih, status); + fData->getAllFieldPositions(fpih, status); } void FormattedNumber::getDecimalQuantity(impl::DecimalQuantity& output, UErrorCode& status) const { diff --git a/deps/icu-small/source/i18n/number_padding.cpp b/deps/icu-small/source/i18n/number_padding.cpp index 31684d7208b606..c68a9875b2055f 100644 --- a/deps/icu-small/source/i18n/number_padding.cpp +++ b/deps/icu-small/source/i18n/number_padding.cpp @@ -7,7 +7,7 @@ #include "unicode/numberformatter.h" #include "number_types.h" -#include "number_stringbuilder.h" +#include "formatted_string_builder.h" #include "number_decimfmtprops.h" using namespace icu; @@ -17,7 +17,7 @@ using namespace icu::number::impl; namespace { int32_t -addPaddingHelper(UChar32 paddingCp, int32_t requiredPadding, NumberStringBuilder &string, int32_t index, +addPaddingHelper(UChar32 paddingCp, int32_t requiredPadding, FormattedStringBuilder &string, int32_t index, UErrorCode &status) { for (int32_t i = 0; i < requiredPadding; i++) { // TODO: If appending to the end, this will cause actual insertion operations. Improve. @@ -60,7 +60,7 @@ Padder Padder::forProperties(const DecimalFormatProperties& properties) { } int32_t Padder::padAndApply(const Modifier &mod1, const Modifier &mod2, - NumberStringBuilder &string, int32_t leftIndex, int32_t rightIndex, + FormattedStringBuilder &string, int32_t leftIndex, int32_t rightIndex, UErrorCode &status) const { int32_t modLength = mod1.getCodePointCount() + mod2.getCodePointCount(); int32_t requiredPadding = fWidth - modLength - string.codePointCount(); diff --git a/deps/icu-small/source/i18n/number_patternmodifier.cpp b/deps/icu-small/source/i18n/number_patternmodifier.cpp index 75de439f3ed2e1..724f5b9741cc52 100644 --- a/deps/icu-small/source/i18n/number_patternmodifier.cpp +++ b/deps/icu-small/source/i18n/number_patternmodifier.cpp @@ -43,7 +43,7 @@ void MutablePatternModifier::setSymbols(const DecimalFormatSymbols* symbols, fRules = rules; } -void MutablePatternModifier::setNumberProperties(int8_t signum, StandardPlural::Form plural) { +void MutablePatternModifier::setNumberProperties(Signum signum, StandardPlural::Form plural) { fSignum = signum; fPlural = plural; } @@ -79,12 +79,12 @@ MutablePatternModifier::createImmutableAndChain(const MicroPropsGenerator* paren if (needsPlurals()) { // Slower path when we require the plural keyword. for (StandardPlural::Form plural : STANDARD_PLURAL_VALUES) { - setNumberProperties(1, plural); - pm->adoptModifier(1, plural, createConstantModifier(status)); - setNumberProperties(0, plural); - pm->adoptModifier(0, plural, createConstantModifier(status)); - setNumberProperties(-1, plural); - pm->adoptModifier(-1, plural, createConstantModifier(status)); + setNumberProperties(SIGNUM_POS, plural); + pm->adoptModifier(SIGNUM_POS, plural, createConstantModifier(status)); + setNumberProperties(SIGNUM_ZERO, plural); + pm->adoptModifier(SIGNUM_ZERO, plural, createConstantModifier(status)); + setNumberProperties(SIGNUM_NEG, plural); + pm->adoptModifier(SIGNUM_NEG, plural, createConstantModifier(status)); } if (U_FAILURE(status)) { delete pm; @@ -93,12 +93,12 @@ MutablePatternModifier::createImmutableAndChain(const MicroPropsGenerator* paren return new ImmutablePatternModifier(pm, fRules, parent); // adopts pm } else { // Faster path when plural keyword is not needed. - setNumberProperties(1, StandardPlural::Form::COUNT); - pm->adoptModifierWithoutPlural(1, createConstantModifier(status)); - setNumberProperties(0, StandardPlural::Form::COUNT); - pm->adoptModifierWithoutPlural(0, createConstantModifier(status)); - setNumberProperties(-1, StandardPlural::Form::COUNT); - pm->adoptModifierWithoutPlural(-1, createConstantModifier(status)); + setNumberProperties(SIGNUM_POS, StandardPlural::Form::COUNT); + pm->adoptModifierWithoutPlural(SIGNUM_POS, createConstantModifier(status)); + setNumberProperties(SIGNUM_ZERO, StandardPlural::Form::COUNT); + pm->adoptModifierWithoutPlural(SIGNUM_ZERO, createConstantModifier(status)); + setNumberProperties(SIGNUM_NEG, StandardPlural::Form::COUNT); + pm->adoptModifierWithoutPlural(SIGNUM_NEG, createConstantModifier(status)); if (U_FAILURE(status)) { delete pm; return nullptr; @@ -108,8 +108,8 @@ MutablePatternModifier::createImmutableAndChain(const MicroPropsGenerator* paren } ConstantMultiFieldModifier* MutablePatternModifier::createConstantModifier(UErrorCode& status) { - NumberStringBuilder a; - NumberStringBuilder b; + FormattedStringBuilder a; + FormattedStringBuilder b; insertPrefix(a, 0, status); insertSuffix(b, 0, status); if (fPatternInfo->hasCurrencySign()) { @@ -140,7 +140,7 @@ void ImmutablePatternModifier::applyToMicros( } } -const Modifier* ImmutablePatternModifier::getModifier(int8_t signum, StandardPlural::Form plural) const { +const Modifier* ImmutablePatternModifier::getModifier(Signum signum, StandardPlural::Form plural) const { if (rules == nullptr) { return pm->getModifierWithoutPlural(signum); } else { @@ -170,7 +170,7 @@ void MutablePatternModifier::processQuantity(DecimalQuantity& fq, MicroProps& mi micros.modMiddle = this; } -int32_t MutablePatternModifier::apply(NumberStringBuilder& output, int32_t leftIndex, int32_t rightIndex, +int32_t MutablePatternModifier::apply(FormattedStringBuilder& output, int32_t leftIndex, int32_t rightIndex, UErrorCode& status) const { // The unsafe code path performs self-mutation, so we need a const_cast. // This method needs to be const because it overrides a const method in the parent class. @@ -248,13 +248,13 @@ bool MutablePatternModifier::semanticallyEquivalent(const Modifier& other) const UPRV_UNREACHABLE; } -int32_t MutablePatternModifier::insertPrefix(NumberStringBuilder& sb, int position, UErrorCode& status) { +int32_t MutablePatternModifier::insertPrefix(FormattedStringBuilder& sb, int position, UErrorCode& status) { prepareAffix(true); int32_t length = AffixUtils::unescape(currentAffix, sb, position, *this, fField, status); return length; } -int32_t MutablePatternModifier::insertSuffix(NumberStringBuilder& sb, int position, UErrorCode& status) { +int32_t MutablePatternModifier::insertSuffix(FormattedStringBuilder& sb, int position, UErrorCode& status) { prepareAffix(false); int32_t length = AffixUtils::unescape(currentAffix, sb, position, *this, fField, status); return length; diff --git a/deps/icu-small/source/i18n/number_patternmodifier.h b/deps/icu-small/source/i18n/number_patternmodifier.h index 27e293b64ce50f..b2c90e0af76354 100644 --- a/deps/icu-small/source/i18n/number_patternmodifier.h +++ b/deps/icu-small/source/i18n/number_patternmodifier.h @@ -48,7 +48,7 @@ class U_I18N_API ImmutablePatternModifier : public MicroPropsGenerator, public U void applyToMicros(MicroProps& micros, const DecimalQuantity& quantity, UErrorCode& status) const; - const Modifier* getModifier(int8_t signum, StandardPlural::Form plural) const; + const Modifier* getModifier(Signum signum, StandardPlural::Form plural) const; private: ImmutablePatternModifier(AdoptingModifierStore* pm, const PluralRules* rules, @@ -142,7 +142,7 @@ class U_I18N_API MutablePatternModifier * The plural form of the number, required only if the pattern contains the triple * currency sign, "¤¤¤" (and as indicated by {@link #needsPlurals()}). */ - void setNumberProperties(int8_t signum, StandardPlural::Form plural); + void setNumberProperties(Signum signum, StandardPlural::Form plural); /** * Returns true if the pattern represented by this MurkyModifier requires a plural keyword in order to localize. @@ -184,7 +184,7 @@ class U_I18N_API MutablePatternModifier void processQuantity(DecimalQuantity &, MicroProps µs, UErrorCode &status) const U_OVERRIDE; - int32_t apply(NumberStringBuilder &output, int32_t leftIndex, int32_t rightIndex, + int32_t apply(FormattedStringBuilder &output, int32_t leftIndex, int32_t rightIndex, UErrorCode &status) const U_OVERRIDE; int32_t getPrefixLength() const U_OVERRIDE; @@ -223,7 +223,7 @@ class U_I18N_API MutablePatternModifier const PluralRules *fRules; // Number details (initialized in setNumberProperties) - int8_t fSignum; + Signum fSignum; StandardPlural::Form fPlural; // QuantityChain details (initialized in addToChain) @@ -240,17 +240,17 @@ class U_I18N_API MutablePatternModifier * CREATES A NEW HEAP OBJECT; THE CALLER GETS OWNERSHIP. * * @param a - * A working NumberStringBuilder object; passed from the outside to prevent the need to create many new + * A working FormattedStringBuilder object; passed from the outside to prevent the need to create many new * instances if this method is called in a loop. * @param b - * Another working NumberStringBuilder object. + * Another working FormattedStringBuilder object. * @return The constant modifier object. */ ConstantMultiFieldModifier *createConstantModifier(UErrorCode &status); - int32_t insertPrefix(NumberStringBuilder &sb, int position, UErrorCode &status); + int32_t insertPrefix(FormattedStringBuilder &sb, int position, UErrorCode &status); - int32_t insertSuffix(NumberStringBuilder &sb, int position, UErrorCode &status); + int32_t insertSuffix(FormattedStringBuilder &sb, int position, UErrorCode &status); void prepareAffix(bool isPrefix); }; diff --git a/deps/icu-small/source/i18n/number_patternstring.cpp b/deps/icu-small/source/i18n/number_patternstring.cpp index 90754246633064..c7212c1e5c23fe 100644 --- a/deps/icu-small/source/i18n/number_patternstring.cpp +++ b/deps/icu-small/source/i18n/number_patternstring.cpp @@ -352,7 +352,7 @@ void ParsedPatternInfo::consumeIntegerFormat(UErrorCode& status) { result.groupingSizes += 1; result.integerNumerals += 1; result.integerTotal += 1; - if (!result.rounding.isZero() || state.peek() != u'0') { + if (!result.rounding.isZeroish() || state.peek() != u'0') { result.rounding.appendDigit(static_cast(state.peek() - u'0'), 0, true); } break; @@ -532,7 +532,7 @@ PatternParser::patternInfoToProperties(DecimalFormatProperties& properties, Pars properties.roundingIncrement = 0.0; properties.minimumSignificantDigits = positive.integerAtSigns; properties.maximumSignificantDigits = positive.integerAtSigns + positive.integerTrailingHashSigns; - } else if (!positive.rounding.isZero()) { + } else if (!positive.rounding.isZeroish()) { if (!ignoreRounding) { properties.minimumFractionDigits = minFrac; properties.maximumFractionDigits = positive.fractionTotal; @@ -1000,7 +1000,7 @@ PatternStringUtils::convertLocalized(const UnicodeString& input, const DecimalFo } void PatternStringUtils::patternInfoToStringBuilder(const AffixPatternProvider& patternInfo, bool isPrefix, - int8_t signum, UNumberSignDisplay signDisplay, + Signum signum, UNumberSignDisplay signDisplay, StandardPlural::Form plural, bool perMilleReplacesPercent, UnicodeString& output) { @@ -1014,6 +1014,7 @@ void PatternStringUtils::patternInfoToStringBuilder(const AffixPatternProvider& // Should we use the affix from the negative subpattern? (If not, we will use the positive // subpattern.) + // TODO: Deal with signum bool useNegativeAffixPattern = patternInfo.hasNegativeSubpattern() && ( signum == -1 || (patternInfo.negativeHasMinusSign() && plusReplacesMinusSign)); diff --git a/deps/icu-small/source/i18n/number_patternstring.h b/deps/icu-small/source/i18n/number_patternstring.h index 42e7c3916133d1..819c74d4bd886d 100644 --- a/deps/icu-small/source/i18n/number_patternstring.h +++ b/deps/icu-small/source/i18n/number_patternstring.h @@ -295,7 +295,7 @@ class U_I18N_API PatternStringUtils { * substitution, and plural forms for CurrencyPluralInfo. */ static void patternInfoToStringBuilder(const AffixPatternProvider& patternInfo, bool isPrefix, - int8_t signum, UNumberSignDisplay signDisplay, + Signum signum, UNumberSignDisplay signDisplay, StandardPlural::Form plural, bool perMilleReplacesPercent, UnicodeString& output); diff --git a/deps/icu-small/source/i18n/number_rounding.cpp b/deps/icu-small/source/i18n/number_rounding.cpp index 9e369f7925fe2f..813d4b680d497b 100644 --- a/deps/icu-small/source/i18n/number_rounding.cpp +++ b/deps/icu-small/source/i18n/number_rounding.cpp @@ -33,7 +33,7 @@ int32_t getRoundingMagnitudeSignificant(const DecimalQuantity &value, int maxSig if (maxSig == -1) { return INT32_MIN; } - int magnitude = value.isZero() ? 0 : value.getMagnitude(); + int magnitude = value.isZeroish() ? 0 : value.getMagnitude(); return magnitude - maxSig + 1; } @@ -45,7 +45,7 @@ int32_t getDisplayMagnitudeFraction(int minFrac) { } int32_t getDisplayMagnitudeSignificant(const DecimalQuantity &value, int minSig) { - int magnitude = value.isZero() ? 0 : value.getMagnitude(); + int magnitude = value.isZeroish() ? 0 : value.getMagnitude(); return magnitude - minSig + 1; } @@ -306,8 +306,8 @@ bool RoundingImpl::isSignificantDigits() const { int32_t RoundingImpl::chooseMultiplierAndApply(impl::DecimalQuantity &input, const impl::MultiplierProducer &producer, UErrorCode &status) { - // Do not call this method with zero. - U_ASSERT(!input.isZero()); + // Do not call this method with zero, NaN, or infinity. + U_ASSERT(!input.isZeroish()); // Perform the first attempt at rounding. int magnitude = input.getMagnitude(); @@ -316,7 +316,7 @@ RoundingImpl::chooseMultiplierAndApply(impl::DecimalQuantity &input, const impl: apply(input, status); // If the number rounded to zero, exit. - if (input.isZero() || U_FAILURE(status)) { + if (input.isZeroish() || U_FAILURE(status)) { return multiplier; } @@ -374,7 +374,7 @@ void RoundingImpl::apply(impl::DecimalQuantity &value, UErrorCode& status) const value.setMinFraction( uprv_max(0, -getDisplayMagnitudeSignificant(value, fPrecision.fUnion.fracSig.fMinSig))); // Make sure that digits are displayed on zero. - if (value.isZero() && fPrecision.fUnion.fracSig.fMinSig > 0) { + if (value.isZeroish() && fPrecision.fUnion.fracSig.fMinSig > 0) { value.setMinInteger(1); } break; @@ -436,7 +436,7 @@ void RoundingImpl::apply(impl::DecimalQuantity &value, UErrorCode& status) const void RoundingImpl::apply(impl::DecimalQuantity &value, int32_t minInt, UErrorCode /*status*/) { // This method is intended for the one specific purpose of helping print "00.000E0". U_ASSERT(isSignificantDigits()); - U_ASSERT(value.isZero()); + U_ASSERT(value.isZeroish()); value.setMinFraction(fPrecision.fUnion.fracSig.fMinSig - minInt); } diff --git a/deps/icu-small/source/i18n/number_scientific.cpp b/deps/icu-small/source/i18n/number_scientific.cpp index 6df07b9cc9e988..20aa45bff01959 100644 --- a/deps/icu-small/source/i18n/number_scientific.cpp +++ b/deps/icu-small/source/i18n/number_scientific.cpp @@ -8,7 +8,7 @@ #include #include "number_scientific.h" #include "number_utils.h" -#include "number_stringbuilder.h" +#include "formatted_string_builder.h" #include "unicode/unum.h" #include "number_microprops.h" @@ -36,7 +36,7 @@ void ScientificModifier::set(int32_t exponent, const ScientificHandler *handler) fHandler = handler; } -int32_t ScientificModifier::apply(NumberStringBuilder &output, int32_t /*leftIndex*/, int32_t rightIndex, +int32_t ScientificModifier::apply(FormattedStringBuilder &output, int32_t /*leftIndex*/, int32_t rightIndex, UErrorCode &status) const { // FIXME: Localized exponent separator location. int i = rightIndex; @@ -123,9 +123,15 @@ void ScientificHandler::processQuantity(DecimalQuantity &quantity, MicroProps &m fParent->processQuantity(quantity, micros, status); if (U_FAILURE(status)) { return; } + // Do not apply scientific notation to special doubles + if (quantity.isInfinite() || quantity.isNaN()) { + micros.modInner = µs.helpers.emptyStrongModifier; + return; + } + // Treat zero as if it had magnitude 0 int32_t exponent; - if (quantity.isZero()) { + if (quantity.isZeroish()) { if (fSettings.fRequireMinInt && micros.rounder.isSignificantDigits()) { // Show "00.000E0" on pattern "00.000E0" micros.rounder.apply(quantity, fSettings.fEngineeringInterval, status); diff --git a/deps/icu-small/source/i18n/number_scientific.h b/deps/icu-small/source/i18n/number_scientific.h index e377bd941efaeb..1c9ce1efa80a3f 100644 --- a/deps/icu-small/source/i18n/number_scientific.h +++ b/deps/icu-small/source/i18n/number_scientific.h @@ -21,7 +21,7 @@ class U_I18N_API ScientificModifier : public UMemory, public Modifier { void set(int32_t exponent, const ScientificHandler *handler); - int32_t apply(NumberStringBuilder &output, int32_t leftIndex, int32_t rightIndex, + int32_t apply(FormattedStringBuilder &output, int32_t leftIndex, int32_t rightIndex, UErrorCode &status) const U_OVERRIDE; int32_t getPrefixLength() const U_OVERRIDE; diff --git a/deps/icu-small/source/i18n/number_skeletons.cpp b/deps/icu-small/source/i18n/number_skeletons.cpp index 4c280ad11dd8da..4025539239b786 100644 --- a/deps/icu-small/source/i18n/number_skeletons.cpp +++ b/deps/icu-small/source/i18n/number_skeletons.cpp @@ -20,6 +20,7 @@ #include "unicode/numberformatter.h" #include "uinvchar.h" #include "charstr.h" +#include "string_segment.h" using namespace icu; using namespace icu::number; @@ -119,17 +120,17 @@ inline void appendMultiple(UnicodeString& sb, UChar32 cp, int32_t count) { #define CHECK_NULL(seen, field, status) (void)(seen); /* for auto-format line wrapping */ \ -{ \ +UPRV_BLOCK_MACRO_BEGIN { \ if ((seen).field) { \ (status) = U_NUMBER_SKELETON_SYNTAX_ERROR; \ return STATE_NULL; \ } \ (seen).field = true; \ -} +} UPRV_BLOCK_MACRO_END #define SKELETON_UCHAR_TO_CHAR(dest, src, start, end, status) (void)(dest); \ -{ \ +UPRV_BLOCK_MACRO_BEGIN { \ UErrorCode conversionStatus = U_ZERO_ERROR; \ (dest).appendInvariantChars({FALSE, (src).getBuffer() + (start), (end) - (start)}, conversionStatus); \ if (conversionStatus == U_INVARIANT_CONVERSION_ERROR) { \ @@ -140,7 +141,7 @@ inline void appendMultiple(UnicodeString& sb, UChar32 cp, int32_t count) { (status) = conversionStatus; \ return; \ } \ -} +} UPRV_BLOCK_MACRO_END } // anonymous namespace @@ -1217,7 +1218,7 @@ void blueprint_helpers::parseIntegerWidthOption(const StringSegment& segment, Ma maxInt = 0; } for (; offset < segment.length(); offset++) { - if (segment.charAt(offset) == u'#') { + if (maxInt != -1 && segment.charAt(offset) == u'#') { maxInt++; } else { break; diff --git a/deps/icu-small/source/i18n/number_skeletons.h b/deps/icu-small/source/i18n/number_skeletons.h index bc228bd0d7408e..59af771928fbd0 100644 --- a/deps/icu-small/source/i18n/number_skeletons.h +++ b/deps/icu-small/source/i18n/number_skeletons.h @@ -10,10 +10,10 @@ #include "number_types.h" #include "numparse_types.h" #include "unicode/ucharstrie.h" +#include "string_segment.h" -using icu::numparse::impl::StringSegment; - -U_NAMESPACE_BEGIN namespace number { +U_NAMESPACE_BEGIN +namespace number { namespace impl { // Forward-declaration diff --git a/deps/icu-small/source/i18n/number_stringbuilder.h b/deps/icu-small/source/i18n/number_stringbuilder.h deleted file mode 100644 index d48f6e106cf87e..00000000000000 --- a/deps/icu-small/source/i18n/number_stringbuilder.h +++ /dev/null @@ -1,164 +0,0 @@ -// © 2017 and later: Unicode, Inc. and others. -// License & terms of use: http://www.unicode.org/copyright.html - -#include "unicode/utypes.h" - -#if !UCONFIG_NO_FORMATTING -#ifndef __NUMBER_STRINGBUILDER_H__ -#define __NUMBER_STRINGBUILDER_H__ - - -#include -#include "unicode/numfmt.h" -#include "unicode/ustring.h" -#include "cstring.h" -#include "uassert.h" -#include "number_types.h" -#include "fphdlimp.h" - -U_NAMESPACE_BEGIN namespace number { -namespace impl { - -class U_I18N_API NumberStringBuilder : public UMemory { - private: - static const int32_t DEFAULT_CAPACITY = 40; - - template - union ValueOrHeapArray { - T value[DEFAULT_CAPACITY]; - struct { - T *ptr; - int32_t capacity; - } heap; - }; - - public: - NumberStringBuilder(); - - ~NumberStringBuilder(); - - NumberStringBuilder(const NumberStringBuilder &other); - - NumberStringBuilder &operator=(const NumberStringBuilder &other); - - int32_t length() const; - - int32_t codePointCount() const; - - inline char16_t charAt(int32_t index) const { - U_ASSERT(index >= 0); - U_ASSERT(index < fLength); - return getCharPtr()[fZero + index]; - } - - inline Field fieldAt(int32_t index) const { - U_ASSERT(index >= 0); - U_ASSERT(index < fLength); - return getFieldPtr()[fZero + index]; - } - - UChar32 getFirstCodePoint() const; - - UChar32 getLastCodePoint() const; - - UChar32 codePointAt(int32_t index) const; - - UChar32 codePointBefore(int32_t index) const; - - NumberStringBuilder &clear(); - - int32_t appendCodePoint(UChar32 codePoint, Field field, UErrorCode &status); - - int32_t insertCodePoint(int32_t index, UChar32 codePoint, Field field, UErrorCode &status); - - int32_t append(const UnicodeString &unistr, Field field, UErrorCode &status); - - int32_t insert(int32_t index, const UnicodeString &unistr, Field field, UErrorCode &status); - - int32_t insert(int32_t index, const UnicodeString &unistr, int32_t start, int32_t end, Field field, - UErrorCode &status); - - int32_t splice(int32_t startThis, int32_t endThis, const UnicodeString &unistr, - int32_t startOther, int32_t endOther, Field field, UErrorCode& status); - - int32_t append(const NumberStringBuilder &other, UErrorCode &status); - - int32_t insert(int32_t index, const NumberStringBuilder &other, UErrorCode &status); - - void writeTerminator(UErrorCode& status); - - /** - * Gets a "safe" UnicodeString that can be used even after the NumberStringBuilder is destructed. - * */ - UnicodeString toUnicodeString() const; - - /** - * Gets an "unsafe" UnicodeString that is valid only as long as the NumberStringBuilder is alive and - * unchanged. Slightly faster than toUnicodeString(). - */ - const UnicodeString toTempUnicodeString() const; - - UnicodeString toDebugString() const; - - const char16_t *chars() const; - - bool contentEquals(const NumberStringBuilder &other) const; - - bool nextFieldPosition(FieldPosition& fp, UErrorCode& status) const; - - void getAllFieldPositions(FieldPositionIteratorHandler& fpih, UErrorCode& status) const; - - bool nextPosition(ConstrainedFieldPosition& cfpos, Field numericField, UErrorCode& status) const; - - bool containsField(Field field) const; - - private: - bool fUsingHeap = false; - ValueOrHeapArray fChars; - ValueOrHeapArray fFields; - int32_t fZero = DEFAULT_CAPACITY / 2; - int32_t fLength = 0; - - inline char16_t *getCharPtr() { - return fUsingHeap ? fChars.heap.ptr : fChars.value; - } - - inline const char16_t *getCharPtr() const { - return fUsingHeap ? fChars.heap.ptr : fChars.value; - } - - inline Field *getFieldPtr() { - return fUsingHeap ? fFields.heap.ptr : fFields.value; - } - - inline const Field *getFieldPtr() const { - return fUsingHeap ? fFields.heap.ptr : fFields.value; - } - - inline int32_t getCapacity() const { - return fUsingHeap ? fChars.heap.capacity : DEFAULT_CAPACITY; - } - - int32_t prepareForInsert(int32_t index, int32_t count, UErrorCode &status); - - int32_t prepareForInsertHelper(int32_t index, int32_t count, UErrorCode &status); - - int32_t remove(int32_t index, int32_t count); - - static bool isIntOrGroup(Field field); - - static bool isNumericField(Field field); - - int32_t trimBack(int32_t limit) const; - - int32_t trimFront(int32_t start) const; -}; - -} // namespace impl -} // namespace number -U_NAMESPACE_END - - -#endif //__NUMBER_STRINGBUILDER_H__ - -#endif /* #if !UCONFIG_NO_FORMATTING */ diff --git a/deps/icu-small/source/i18n/number_types.h b/deps/icu-small/source/i18n/number_types.h index 225d1e57750490..d62aa6a66b30d3 100644 --- a/deps/icu-small/source/i18n/number_types.h +++ b/deps/icu-small/source/i18n/number_types.h @@ -17,17 +17,16 @@ #include "unicode/platform.h" #include "unicode/uniset.h" #include "standardplural.h" +#include "formatted_string_builder.h" -U_NAMESPACE_BEGIN namespace number { +U_NAMESPACE_BEGIN +namespace number { namespace impl { -// Typedef several enums for brevity and for easier comparison to Java. +// For convenience and historical reasons, import the Field typedef to the namespace. +typedef FormattedStringBuilder::Field Field; -// Convention: bottom 4 bits for field, top 4 bits for field category. -// Field category 0 implies the number category so that the number field -// literals can be directly passed as a Field type. -// See the helper functions in "NumFieldUtils" in number_utils.h -typedef uint8_t Field; +// Typedef several enums for brevity and for easier comparison to Java. typedef UNumberFormatRoundingMode RoundingMode; @@ -49,7 +48,6 @@ static constexpr char16_t kFallbackPaddingString[] = u" "; class Modifier; class MutablePatternModifier; class DecimalQuantity; -class NumberStringBuilder; class ModifierStore; struct MicroProps; @@ -93,6 +91,12 @@ enum CompactType { TYPE_DECIMAL, TYPE_CURRENCY }; +enum Signum { + SIGNUM_NEG = -1, + SIGNUM_ZERO = 0, + SIGNUM_POS = 1 +}; + class U_I18N_API AffixPatternProvider { public: @@ -160,7 +164,7 @@ class U_I18N_API Modifier { * formatted. * @return The number of characters (UTF-16 code units) that were added to the string builder. */ - virtual int32_t apply(NumberStringBuilder& output, int leftIndex, int rightIndex, + virtual int32_t apply(FormattedStringBuilder& output, int leftIndex, int rightIndex, UErrorCode& status) const = 0; /** @@ -196,11 +200,11 @@ class U_I18N_API Modifier { */ struct U_I18N_API Parameters { const ModifierStore* obj = nullptr; - int8_t signum; + Signum signum; StandardPlural::Form plural; Parameters(); - Parameters(const ModifierStore* _obj, int8_t _signum, StandardPlural::Form _plural); + Parameters(const ModifierStore* _obj, Signum _signum, StandardPlural::Form _plural); }; /** @@ -231,7 +235,7 @@ class U_I18N_API ModifierStore { /** * Returns a Modifier with the given parameters (best-effort). */ - virtual const Modifier* getModifier(int8_t signum, StandardPlural::Form plural) const = 0; + virtual const Modifier* getModifier(Signum signum, StandardPlural::Form plural) const = 0; }; diff --git a/deps/icu-small/source/i18n/number_utils.cpp b/deps/icu-small/source/i18n/number_utils.cpp index 0983b7b0726ec2..91d7f335cd82d3 100644 --- a/deps/icu-small/source/i18n/number_utils.cpp +++ b/deps/icu-small/source/i18n/number_utils.cpp @@ -252,4 +252,15 @@ bool DecNum::isZero() const { return decNumberIsZero(fData.getAlias()); } +void DecNum::toString(ByteSink& output, UErrorCode& status) const { + if (U_FAILURE(status)) { + return; + } + // "string must be at least dn->digits+14 characters long" + int32_t minCapacity = fData.getAlias()->digits + 14; + MaybeStackArray buffer(minCapacity); + uprv_decNumberToString(fData, buffer.getAlias()); + output.Append(buffer.getAlias(), static_cast(uprv_strlen(buffer.getAlias()))); +} + #endif /* #if !UCONFIG_NO_FORMATTING */ diff --git a/deps/icu-small/source/i18n/number_utils.h b/deps/icu-small/source/i18n/number_utils.h index 203dec6d83b92b..93195f080b2787 100644 --- a/deps/icu-small/source/i18n/number_utils.h +++ b/deps/icu-small/source/i18n/number_utils.h @@ -17,6 +17,7 @@ #include "number_roundingutils.h" #include "decNumber.h" #include "charstr.h" +#include "formatted_string_builder.h" U_NAMESPACE_BEGIN @@ -32,52 +33,10 @@ enum CldrPatternStyle { CLDR_PATTERN_STYLE_COUNT, }; - -/** - * Helper functions for dealing with the Field typedef, which stores fields - * in a compressed format. - */ -class NumFieldUtils { -public: - struct CategoryFieldPair { - int32_t category; - int32_t field; - }; - - /** Compile-time function to construct a Field from a category and a field */ - template - static constexpr Field compress() { - static_assert(category != 0, "cannot use Undefined category in NumFieldUtils"); - static_assert(category <= 0xf, "only 4 bits for category"); - static_assert(field <= 0xf, "only 4 bits for field"); - return static_cast((category << 4) | field); - } - - /** Runtime inline function to unpack the category and field from the Field */ - static inline CategoryFieldPair expand(Field field) { - if (field == UNUM_FIELD_COUNT) { - return {UFIELD_CATEGORY_UNDEFINED, 0}; - } - CategoryFieldPair ret = { - (field >> 4), - (field & 0xf) - }; - if (ret.category == 0) { - ret.category = UFIELD_CATEGORY_NUMBER; - } - return ret; - } - - static inline bool isNumericField(Field field) { - int8_t category = field >> 4; - return category == 0 || category == UFIELD_CATEGORY_NUMBER; - } -}; - // Namespace for naked functions namespace utils { -inline int32_t insertDigitFromSymbols(NumberStringBuilder& output, int32_t index, int8_t digit, +inline int32_t insertDigitFromSymbols(FormattedStringBuilder& output, int32_t index, int8_t digit, const DecimalFormatSymbols& symbols, Field field, UErrorCode& status) { if (symbols.getCodePointZero() != -1) { diff --git a/deps/icu-small/source/i18n/number_utypes.h b/deps/icu-small/source/i18n/number_utypes.h index 88b493cbc254c9..6dbe5bee68fb71 100644 --- a/deps/icu-small/source/i18n/number_utypes.h +++ b/deps/icu-small/source/i18n/number_utypes.h @@ -10,7 +10,7 @@ #include "unicode/numberformatter.h" #include "number_types.h" #include "number_decimalquantity.h" -#include "number_stringbuilder.h" +#include "formatted_string_builder.h" #include "formattedval_impl.h" U_NAMESPACE_BEGIN namespace number { @@ -31,9 +31,9 @@ const DecimalQuantity* validateUFormattedNumberToDecimalQuantity( * The DecimalQuantity is not currently being used by FormattedNumber, but at some point it could be used * to add a toDecNumber() or similar method. */ -class UFormattedNumberData : public FormattedValueNumberStringBuilderImpl { +class UFormattedNumberData : public FormattedValueStringBuilderImpl { public: - UFormattedNumberData() : FormattedValueNumberStringBuilderImpl(0) {} + UFormattedNumberData() : FormattedValueStringBuilderImpl(0) {} virtual ~UFormattedNumberData(); DecimalQuantity quantity; diff --git a/deps/icu-small/source/i18n/numfmt.cpp b/deps/icu-small/source/i18n/numfmt.cpp index 21efd184558778..bf78179bcddefe 100644 --- a/deps/icu-small/source/i18n/numfmt.cpp +++ b/deps/icu-small/source/i18n/numfmt.cpp @@ -569,7 +569,7 @@ NumberFormat::format(const Formattable& obj, if(arg.wasCurrency() && u_strcmp(iso, getCurrency())) { // trying to format a different currency. // Right now, we clone. - LocalPointer cloneFmt((NumberFormat*)this->clone()); + LocalPointer cloneFmt(this->clone()); cloneFmt->setCurrency(iso, status); // next line should NOT recurse, because n is numeric whereas obj was a wrapper around currency amount. return cloneFmt->format(*n, appendTo, pos, status); @@ -624,7 +624,7 @@ NumberFormat::format(const Formattable& obj, if(arg.wasCurrency() && u_strcmp(iso, getCurrency())) { // trying to format a different currency. // Right now, we clone. - LocalPointer cloneFmt((NumberFormat*)this->clone()); + LocalPointer cloneFmt(this->clone()); cloneFmt->setCurrency(iso, status); // next line should NOT recurse, because n is numeric whereas obj was a wrapper around currency amount. return cloneFmt->format(*n, appendTo, posIter, status); @@ -986,15 +986,19 @@ static UBool haveService() { URegistryKey U_EXPORT2 NumberFormat::registerFactory(NumberFormatFactory* toAdopt, UErrorCode& status) { - ICULocaleService *service = getNumberFormatService(); - if (service) { - NFFactory *tempnnf = new NFFactory(toAdopt); - if (tempnnf != NULL) { - return service->registerFactory(tempnnf, status); - } - } - status = U_MEMORY_ALLOCATION_ERROR; - return NULL; + if (U_FAILURE(status)) { + delete toAdopt; + return nullptr; + } + ICULocaleService *service = getNumberFormatService(); + if (service) { + NFFactory *tempnnf = new NFFactory(toAdopt); + if (tempnnf != NULL) { + return service->registerFactory(tempnnf, status); + } + } + status = U_MEMORY_ALLOCATION_ERROR; + return NULL; } // ------------------------------------- @@ -1055,7 +1059,7 @@ NumberFormat::createInstance(const Locale& loc, UNumberFormatStyle kind, UErrorC if (U_FAILURE(status)) { return NULL; } - NumberFormat *result = static_cast((*shared)->clone()); + NumberFormat *result = (*shared)->clone(); shared->removeRef(); if (result == NULL) { status = U_MEMORY_ALLOCATION_ERROR; @@ -1362,7 +1366,7 @@ NumberFormat::makeInstance(const Locale& desiredLocale, // TODO: Bad hash key usage, see ticket #8504. int32_t hashKey = desiredLocale.hashCode(); - static icu::UMutex nscacheMutex = U_MUTEX_INITIALIZER; + static UMutex nscacheMutex; Mutex lock(&nscacheMutex); ns = (NumberingSystem *)uhash_iget(NumberingSystem_cache, hashKey); if (ns == NULL) { diff --git a/deps/icu-small/source/i18n/numparse_affixes.cpp b/deps/icu-small/source/i18n/numparse_affixes.cpp index 12543a641b5946..4f83e0dd4076c3 100644 --- a/deps/icu-small/source/i18n/numparse_affixes.cpp +++ b/deps/icu-small/source/i18n/numparse_affixes.cpp @@ -13,6 +13,7 @@ #include "numparse_affixes.h" #include "numparse_utils.h" #include "number_utils.h" +#include "string_segment.h" using namespace icu; using namespace icu::numparse; @@ -280,7 +281,9 @@ void AffixMatcherWarehouse::createAffixMatchers(const AffixPatternProvider& patt AffixPatternMatcher* posSuffix = nullptr; // Pre-process the affix strings to resolve LDML rules like sign display. - for (int8_t signum = 1; signum >= -1; signum--) { + for (int8_t signumInt = 1; signumInt >= -1; signumInt--) { + auto signum = static_cast(signumInt); + // Generate Prefix bool hasPrefix = false; PatternStringUtils::patternInfoToStringBuilder( diff --git a/deps/icu-small/source/i18n/numparse_compositions.cpp b/deps/icu-small/source/i18n/numparse_compositions.cpp index 19253da805f0bf..2f7e1ab28d1d22 100644 --- a/deps/icu-small/source/i18n/numparse_compositions.cpp +++ b/deps/icu-small/source/i18n/numparse_compositions.cpp @@ -11,6 +11,7 @@ #include "numparse_types.h" #include "numparse_compositions.h" +#include "string_segment.h" #include "unicode/uniset.h" using namespace icu; diff --git a/deps/icu-small/source/i18n/numparse_currency.cpp b/deps/icu-small/source/i18n/numparse_currency.cpp index 598ace56533c36..6b53a73edf3b85 100644 --- a/deps/icu-small/source/i18n/numparse_currency.cpp +++ b/deps/icu-small/source/i18n/numparse_currency.cpp @@ -14,6 +14,7 @@ #include "ucurrimp.h" #include "unicode/errorcode.h" #include "numparse_utils.h" +#include "string_segment.h" using namespace icu; using namespace icu::numparse; diff --git a/deps/icu-small/source/i18n/numparse_decimal.cpp b/deps/icu-small/source/i18n/numparse_decimal.cpp index b120c5c6ad2f91..cf1e8156726d01 100644 --- a/deps/icu-small/source/i18n/numparse_decimal.cpp +++ b/deps/icu-small/source/i18n/numparse_decimal.cpp @@ -16,6 +16,7 @@ #include "unicode/uchar.h" #include "putilimp.h" #include "number_decimalquantity.h" +#include "string_segment.h" using namespace icu; using namespace icu::numparse; diff --git a/deps/icu-small/source/i18n/numparse_impl.cpp b/deps/icu-small/source/i18n/numparse_impl.cpp index 412ea89c86b651..bf5829061a1511 100644 --- a/deps/icu-small/source/i18n/numparse_impl.cpp +++ b/deps/icu-small/source/i18n/numparse_impl.cpp @@ -39,7 +39,7 @@ NumberParserImpl::createSimpleParser(const Locale& locale, const UnicodeString& LocalPointer parser(new NumberParserImpl(parseFlags)); DecimalFormatSymbols symbols(locale, status); - parser->fLocalMatchers.ignorables = {unisets::DEFAULT_IGNORABLES}; + parser->fLocalMatchers.ignorables = {parseFlags}; IgnorablesMatcher& ignorables = parser->fLocalMatchers.ignorables; DecimalFormatSymbols dfs(locale, status); @@ -114,6 +114,7 @@ NumberParserImpl::createParserFromProperties(const number::impl::DecimalFormatPr parseFlags |= PARSE_FLAG_STRICT_SEPARATORS; parseFlags |= PARSE_FLAG_USE_FULL_AFFIXES; parseFlags |= PARSE_FLAG_EXACT_AFFIX; + parseFlags |= PARSE_FLAG_STRICT_IGNORABLES; } else { parseFlags |= PARSE_FLAG_INCLUDE_UNPAIRED_AFFIXES; } @@ -129,8 +130,7 @@ NumberParserImpl::createParserFromProperties(const number::impl::DecimalFormatPr LocalPointer parser(new NumberParserImpl(parseFlags)); - parser->fLocalMatchers.ignorables = { - isStrict ? unisets::STRICT_IGNORABLES : unisets::DEFAULT_IGNORABLES}; + parser->fLocalMatchers.ignorables = {parseFlags}; IgnorablesMatcher& ignorables = parser->fLocalMatchers.ignorables; ////////////////////// diff --git a/deps/icu-small/source/i18n/numparse_impl.h b/deps/icu-small/source/i18n/numparse_impl.h index 7d5f0b6f0bd07b..380d9aa4c64289 100644 --- a/deps/icu-small/source/i18n/numparse_impl.h +++ b/deps/icu-small/source/i18n/numparse_impl.h @@ -18,6 +18,7 @@ #include "unicode/localpointer.h" #include "numparse_validators.h" #include "number_multiplier.h" +#include "string_segment.h" U_NAMESPACE_BEGIN diff --git a/deps/icu-small/source/i18n/numparse_parsednumber.cpp b/deps/icu-small/source/i18n/numparse_parsednumber.cpp index 3145f718dc26b5..4b373a3c312254 100644 --- a/deps/icu-small/source/i18n/numparse_parsednumber.cpp +++ b/deps/icu-small/source/i18n/numparse_parsednumber.cpp @@ -11,6 +11,7 @@ #include "numparse_types.h" #include "number_decimalquantity.h" +#include "string_segment.h" #include "putilimp.h" #include @@ -73,7 +74,7 @@ double ParsedNumber::getDouble(UErrorCode& status) const { status = U_INVALID_STATE_ERROR; return 0.0; } - if (quantity.isZero() && quantity.isNegative()) { + if (quantity.isZeroish() && quantity.isNegative()) { return -0.0; } @@ -106,7 +107,7 @@ void ParsedNumber::populateFormattable(Formattable& output, parse_flags_t parseF } } U_ASSERT(!quantity.bogus); - if (quantity.isZero() && quantity.isNegative() && !integerOnly) { + if (quantity.isZeroish() && quantity.isNegative() && !integerOnly) { output.setDouble(-0.0); return; } diff --git a/deps/icu-small/source/i18n/numparse_scientific.cpp b/deps/icu-small/source/i18n/numparse_scientific.cpp index de38957440817c..4b88cd998fee09 100644 --- a/deps/icu-small/source/i18n/numparse_scientific.cpp +++ b/deps/icu-small/source/i18n/numparse_scientific.cpp @@ -12,6 +12,7 @@ #include "numparse_types.h" #include "numparse_scientific.h" #include "static_unicode_sets.h" +#include "string_segment.h" using namespace icu; using namespace icu::numparse; @@ -33,7 +34,8 @@ inline const UnicodeSet& plusSignSet() { ScientificMatcher::ScientificMatcher(const DecimalFormatSymbols& dfs, const Grouper& grouper) : fExponentSeparatorString(dfs.getConstSymbol(DecimalFormatSymbols::kExponentialSymbol)), - fExponentMatcher(dfs, grouper, PARSE_FLAG_INTEGER_ONLY | PARSE_FLAG_GROUPING_DISABLED) { + fExponentMatcher(dfs, grouper, PARSE_FLAG_INTEGER_ONLY | PARSE_FLAG_GROUPING_DISABLED), + fIgnorablesMatcher(PARSE_FLAG_STRICT_IGNORABLES) { const UnicodeString& minusSign = dfs.getConstSymbol(DecimalFormatSymbols::kMinusSignSymbol); if (minusSignSet().contains(minusSign)) { @@ -63,15 +65,25 @@ bool ScientificMatcher::match(StringSegment& segment, ParsedNumber& result, UErr // First match the scientific separator, and then match another number after it. // NOTE: This is guarded by the smoke test; no need to check fExponentSeparatorString length again. - int overlap1 = segment.getCommonPrefixLength(fExponentSeparatorString); - if (overlap1 == fExponentSeparatorString.length()) { + int32_t initialOffset = segment.getOffset(); + int32_t overlap = segment.getCommonPrefixLength(fExponentSeparatorString); + if (overlap == fExponentSeparatorString.length()) { // Full exponent separator match. // First attempt to get a code point, returning true if we can't get one. - if (segment.length() == overlap1) { + if (segment.length() == overlap) { + return true; + } + segment.adjustOffset(overlap); + + // Allow ignorables before the sign. + // Note: call site is guarded by the segment.length() check above. + // Note: the ignorables matcher should not touch the result. + fIgnorablesMatcher.match(segment, result, status); + if (segment.length() == 0) { + segment.setOffset(initialOffset); return true; } - segment.adjustOffset(overlap1); // Allow a sign, and then try to match digits. int8_t exponentSign = 1; @@ -81,24 +93,37 @@ bool ScientificMatcher::match(StringSegment& segment, ParsedNumber& result, UErr } else if (segment.startsWith(plusSignSet())) { segment.adjustOffsetByCodePoint(); } else if (segment.startsWith(fCustomMinusSign)) { - // Note: call site is guarded with startsWith, which returns false on empty string - int32_t overlap2 = segment.getCommonPrefixLength(fCustomMinusSign); - if (overlap2 != fCustomMinusSign.length()) { - // Partial custom sign match; un-match the exponent separator. - segment.adjustOffset(-overlap1); + overlap = segment.getCommonPrefixLength(fCustomMinusSign); + if (overlap != fCustomMinusSign.length()) { + // Partial custom sign match + segment.setOffset(initialOffset); return true; } exponentSign = -1; - segment.adjustOffset(overlap2); + segment.adjustOffset(overlap); } else if (segment.startsWith(fCustomPlusSign)) { - // Note: call site is guarded with startsWith, which returns false on empty string - int32_t overlap2 = segment.getCommonPrefixLength(fCustomPlusSign); - if (overlap2 != fCustomPlusSign.length()) { - // Partial custom sign match; un-match the exponent separator. - segment.adjustOffset(-overlap1); + overlap = segment.getCommonPrefixLength(fCustomPlusSign); + if (overlap != fCustomPlusSign.length()) { + // Partial custom sign match + segment.setOffset(initialOffset); return true; } - segment.adjustOffset(overlap2); + segment.adjustOffset(overlap); + } + + // Return true if the segment is empty. + if (segment.length() == 0) { + segment.setOffset(initialOffset); + return true; + } + + // Allow ignorables after the sign. + // Note: call site is guarded by the segment.length() check above. + // Note: the ignorables matcher should not touch the result. + fIgnorablesMatcher.match(segment, result, status); + if (segment.length() == 0) { + segment.setOffset(initialOffset); + return true; } // We are supposed to accept E0 after NaN, so we need to make sure result.quantity is available. @@ -112,12 +137,12 @@ bool ScientificMatcher::match(StringSegment& segment, ParsedNumber& result, UErr // At least one exponent digit was matched. result.flags |= FLAG_HAS_EXPONENT; } else { - // No exponent digits were matched; un-match the exponent separator. - segment.adjustOffset(-overlap1); + // No exponent digits were matched + segment.setOffset(initialOffset); } return digitsReturnValue; - } else if (overlap1 == segment.length()) { + } else if (overlap == segment.length()) { // Partial exponent separator match return true; } diff --git a/deps/icu-small/source/i18n/numparse_scientific.h b/deps/icu-small/source/i18n/numparse_scientific.h index ddecf858af3584..5617c0c6a60822 100644 --- a/deps/icu-small/source/i18n/numparse_scientific.h +++ b/deps/icu-small/source/i18n/numparse_scientific.h @@ -9,6 +9,7 @@ #include "numparse_types.h" #include "numparse_decimal.h" +#include "numparse_symbols.h" #include "unicode/numberformatter.h" using icu::number::impl::Grouper; @@ -32,6 +33,7 @@ class ScientificMatcher : public NumberParseMatcher, public UMemory { private: UnicodeString fExponentSeparatorString; DecimalMatcher fExponentMatcher; + IgnorablesMatcher fIgnorablesMatcher; UnicodeString fCustomMinusSign; UnicodeString fCustomPlusSign; }; diff --git a/deps/icu-small/source/i18n/numparse_stringsegment.h b/deps/icu-small/source/i18n/numparse_stringsegment.h deleted file mode 100644 index 7a84444d414889..00000000000000 --- a/deps/icu-small/source/i18n/numparse_stringsegment.h +++ /dev/null @@ -1,24 +0,0 @@ -// © 2018 and later: Unicode, Inc. and others. -// License & terms of use: http://www.unicode.org/copyright.html - -#include "unicode/utypes.h" - -#if !UCONFIG_NO_FORMATTING -#ifndef __NUMPARSE_STRINGSEGMENT_H__ -#define __NUMPARSE_STRINGSEGMENT_H__ - -#include "numparse_types.h" -#include "number_types.h" -#include "unicode/unistr.h" - -U_NAMESPACE_BEGIN -namespace numparse { -namespace impl { - - -} // namespace impl -} // namespace numparse -U_NAMESPACE_END - -#endif //__NUMPARSE_STRINGSEGMENT_H__ -#endif /* #if !UCONFIG_NO_FORMATTING */ diff --git a/deps/icu-small/source/i18n/numparse_symbols.cpp b/deps/icu-small/source/i18n/numparse_symbols.cpp index e0daab9374f8b1..608f4f5c8b0ee7 100644 --- a/deps/icu-small/source/i18n/numparse_symbols.cpp +++ b/deps/icu-small/source/i18n/numparse_symbols.cpp @@ -12,6 +12,7 @@ #include "numparse_types.h" #include "numparse_symbols.h" #include "numparse_utils.h" +#include "string_segment.h" using namespace icu; using namespace icu::numparse; @@ -68,8 +69,12 @@ UnicodeString SymbolMatcher::toString() const { } -IgnorablesMatcher::IgnorablesMatcher(unisets::Key key) - : SymbolMatcher({}, key) { +IgnorablesMatcher::IgnorablesMatcher(parse_flags_t parseFlags) : + SymbolMatcher( + {}, + (0 != (parseFlags & PARSE_FLAG_STRICT_IGNORABLES)) ? + unisets::STRICT_IGNORABLES : + unisets::DEFAULT_IGNORABLES) { } bool IgnorablesMatcher::isFlexible() const { diff --git a/deps/icu-small/source/i18n/numparse_symbols.h b/deps/icu-small/source/i18n/numparse_symbols.h index 8912ee95b0d009..beb133f7d07a53 100644 --- a/deps/icu-small/source/i18n/numparse_symbols.h +++ b/deps/icu-small/source/i18n/numparse_symbols.h @@ -50,7 +50,7 @@ class U_I18N_API IgnorablesMatcher : public SymbolMatcher { public: IgnorablesMatcher() = default; // WARNING: Leaves the object in an unusable state - IgnorablesMatcher(unisets::Key key); + IgnorablesMatcher(parse_flags_t parseFlags); bool isFlexible() const override; diff --git a/deps/icu-small/source/i18n/numparse_types.h b/deps/icu-small/source/i18n/numparse_types.h index f837d8d2795a2b..b4007c2ff5b52c 100644 --- a/deps/icu-small/source/i18n/numparse_types.h +++ b/deps/icu-small/source/i18n/numparse_types.h @@ -9,12 +9,13 @@ #include "unicode/uobject.h" #include "number_decimalquantity.h" +#include "string_segment.h" -U_NAMESPACE_BEGIN namespace numparse { +U_NAMESPACE_BEGIN +namespace numparse { namespace impl { // Forward-declarations -class StringSegment; class ParsedNumber; typedef int32_t result_flags_t; @@ -50,6 +51,7 @@ enum ParseFlags { // PARSE_FLAG_FORCE_BIG_DECIMAL = 0x1000, // not used in ICU4C PARSE_FLAG_NO_FOREIGN_CURRENCY = 0x2000, PARSE_FLAG_ALLOW_INFINITE_RECURSION = 0x4000, + PARSE_FLAG_STRICT_IGNORABLES = 0x8000, }; @@ -169,115 +171,6 @@ class U_I18N_API ParsedNumber { }; -/** - * A mutable class allowing for a String with a variable offset and length. The charAt, length, and - * subSequence methods all operate relative to the fixed offset into the String. - * - * @author sffc - */ -// Exported as U_I18N_API for tests -class U_I18N_API StringSegment : public UMemory { - public: - StringSegment(const UnicodeString& str, bool ignoreCase); - - int32_t getOffset() const; - - void setOffset(int32_t start); - - /** - * Equivalent to setOffset(getOffset()+delta). - * - *

- * This method is usually called by a Matcher to register that a char was consumed. If the char is - * strong (it usually is, except for things like whitespace), follow this with a call to - * {@link ParsedNumber#setCharsConsumed}. For more information on strong chars, see that method. - */ - void adjustOffset(int32_t delta); - - /** - * Adjusts the offset by the width of the current code point, either 1 or 2 chars. - */ - void adjustOffsetByCodePoint(); - - void setLength(int32_t length); - - void resetLength(); - - int32_t length() const; - - char16_t charAt(int32_t index) const; - - UChar32 codePointAt(int32_t index) const; - - UnicodeString toUnicodeString() const; - - const UnicodeString toTempUnicodeString() const; - - /** - * Returns the first code point in the string segment, or -1 if the string starts with an invalid - * code point. - * - *

- * Important: Most of the time, you should use {@link #matches}, which handles case - * folding logic, instead of this method. - */ - UChar32 getCodePoint() const; - - /** - * Returns true if the first code point of this StringSegment equals the given code point. - * - *

- * This method will perform case folding if case folding is enabled for the parser. - */ - bool startsWith(UChar32 otherCp) const; - - /** - * Returns true if the first code point of this StringSegment is in the given UnicodeSet. - */ - bool startsWith(const UnicodeSet& uniset) const; - - /** - * Returns true if there is at least one code point of overlap between this StringSegment and the - * given UnicodeString. - */ - bool startsWith(const UnicodeString& other) const; - - /** - * Returns the length of the prefix shared by this StringSegment and the given CharSequence. For - * example, if this string segment is "aab", and the char sequence is "aac", this method returns 2, - * since the first 2 characters are the same. - * - *

- * This method only returns offsets along code point boundaries. - * - *

- * This method will perform case folding if case folding was enabled in the constructor. - * - *

- * IMPORTANT: The given UnicodeString must not be empty! It is the caller's responsibility to check. - */ - int32_t getCommonPrefixLength(const UnicodeString& other); - - /** - * Like {@link #getCommonPrefixLength}, but never performs case folding, even if case folding is - * enabled for the parser. - */ - int32_t getCaseSensitivePrefixLength(const UnicodeString& other); - - bool operator==(const UnicodeString& other) const; - - private: - const UnicodeString& fStr; - int32_t fStart; - int32_t fEnd; - bool fFoldCase; - - int32_t getPrefixLengthInternal(const UnicodeString& other, bool foldCase); - - static bool codePointsEqual(UChar32 cp1, UChar32 cp2, bool foldCase); -}; - - /** * The core interface implemented by all matchers used for number parsing. * diff --git a/deps/icu-small/source/i18n/numrange_fluent.cpp b/deps/icu-small/source/i18n/numrange_fluent.cpp index b284561cdc2b6f..654cafaf00bc82 100644 --- a/deps/icu-small/source/i18n/numrange_fluent.cpp +++ b/deps/icu-small/source/i18n/numrange_fluent.cpp @@ -382,7 +382,7 @@ UPRV_FORMATTED_VALUE_SUBCLASS_AUTO_IMPL(FormattedNumberRange) UBool FormattedNumberRange::nextFieldPosition(FieldPosition& fieldPosition, UErrorCode& status) const { UPRV_FORMATTED_VALUE_METHOD_GUARD(FALSE) // NOTE: MSVC sometimes complains when implicitly converting between bool and UBool - return fData->getStringRef().nextFieldPosition(fieldPosition, status) ? TRUE : FALSE; + return fData->nextFieldPosition(fieldPosition, status); } void FormattedNumberRange::getAllFieldPositions(FieldPositionIterator& iterator, UErrorCode& status) const { @@ -393,7 +393,7 @@ void FormattedNumberRange::getAllFieldPositions(FieldPositionIterator& iterator, void FormattedNumberRange::getAllFieldPositionsImpl( FieldPositionIteratorHandler& fpih, UErrorCode& status) const { UPRV_FORMATTED_VALUE_METHOD_GUARD(UPRV_NOARG) - fData->getStringRef().getAllFieldPositions(fpih, status); + fData->getAllFieldPositions(fpih, status); } UnicodeString FormattedNumberRange::getFirstDecimal(UErrorCode& status) const { diff --git a/deps/icu-small/source/i18n/numrange_impl.cpp b/deps/icu-small/source/i18n/numrange_impl.cpp index 05eb2b84de3d87..7d732b31ec177a 100644 --- a/deps/icu-small/source/i18n/numrange_impl.cpp +++ b/deps/icu-small/source/i18n/numrange_impl.cpp @@ -397,7 +397,7 @@ void NumberRangeFormatterImpl::formatRange(UFormattedNumberRangeData& data, break; } - NumberStringBuilder& string = data.getStringRef(); + FormattedStringBuilder& string = data.getStringRef(); int32_t lengthPrefix = 0; int32_t length1 = 0; int32_t lengthInfix = 0; diff --git a/deps/icu-small/source/i18n/numrange_impl.h b/deps/icu-small/source/i18n/numrange_impl.h index dc25dd4d67bfeb..f88e300913642d 100644 --- a/deps/icu-small/source/i18n/numrange_impl.h +++ b/deps/icu-small/source/i18n/numrange_impl.h @@ -13,7 +13,7 @@ #include "number_types.h" #include "number_decimalquantity.h" #include "number_formatimpl.h" -#include "number_stringbuilder.h" +#include "formatted_string_builder.h" #include "formattedval_impl.h" U_NAMESPACE_BEGIN namespace number { @@ -29,9 +29,9 @@ namespace impl { * Possible magic number: 0x46445200 * Reads in ASCII as "FDR" (FormatteDnumberRange with room at the end) */ -class UFormattedNumberRangeData : public FormattedValueNumberStringBuilderImpl { +class UFormattedNumberRangeData : public FormattedValueStringBuilderImpl { public: - UFormattedNumberRangeData() : FormattedValueNumberStringBuilderImpl(0) {} + UFormattedNumberRangeData() : FormattedValueStringBuilderImpl(0) {} virtual ~UFormattedNumberRangeData(); DecimalQuantity quantity1; diff --git a/deps/icu-small/source/i18n/numsys.cpp b/deps/icu-small/source/i18n/numsys.cpp index 80056f925b027f..e3fe54bc1b3f7e 100644 --- a/deps/icu-small/source/i18n/numsys.cpp +++ b/deps/icu-small/source/i18n/numsys.cpp @@ -37,7 +37,7 @@ U_NAMESPACE_BEGIN // Useful constants -#define DEFAULT_DIGITS UNICODE_STRING_SIMPLE("0123456789"); +#define DEFAULT_DIGITS UNICODE_STRING_SIMPLE("0123456789") static const char gNumberingSystems[] = "numberingSystems"; static const char gNumberElements[] = "NumberElements"; static const char gDefault[] = "default"; diff --git a/deps/icu-small/source/i18n/olsontz.cpp b/deps/icu-small/source/i18n/olsontz.cpp index 95fc56bcd71b54..dd01180f8cc078 100644 --- a/deps/icu-small/source/i18n/olsontz.cpp +++ b/deps/icu-small/source/i18n/olsontz.cpp @@ -287,8 +287,7 @@ OlsonTimeZone& OlsonTimeZone::operator=(const OlsonTimeZone& other) { typeMapData = other.typeMapData; delete finalZone; - finalZone = (other.finalZone != 0) ? - (SimpleTimeZone*) other.finalZone->clone() : 0; + finalZone = (other.finalZone != 0) ? other.finalZone->clone() : 0; finalStartYear = other.finalStartYear; finalStartMillis = other.finalStartMillis; @@ -319,7 +318,7 @@ UBool OlsonTimeZone::operator==(const TimeZone& other) const { /** * TimeZone API. */ -TimeZone* OlsonTimeZone::clone() const { +OlsonTimeZone* OlsonTimeZone::clone() const { return new OlsonTimeZone(*this); } @@ -816,7 +815,7 @@ OlsonTimeZone::initTransitionRules(UErrorCode& status) { * For now, we do not set the valid start year when the construction time * and create a clone and set the start year when extracting rules. */ - finalZoneWithStartYear = (SimpleTimeZone*)finalZone->clone(); + finalZoneWithStartYear = finalZone->clone(); // Check to make sure finalZone was actually cloned. if (finalZoneWithStartYear == NULL) { status = U_MEMORY_ALLOCATION_ERROR; @@ -837,7 +836,7 @@ OlsonTimeZone::initTransitionRules(UErrorCode& status) { startTime = tzt.getTime(); } else { // final rule with no transitions - finalZoneWithStartYear = (SimpleTimeZone*)finalZone->clone(); + finalZoneWithStartYear = finalZone->clone(); // Check to make sure finalZone was actually cloned. if (finalZoneWithStartYear == NULL) { status = U_MEMORY_ALLOCATION_ERROR; diff --git a/deps/icu-small/source/i18n/olsontz.h b/deps/icu-small/source/i18n/olsontz.h index 6f0d36e5de5db0..79601546984a23 100644 --- a/deps/icu-small/source/i18n/olsontz.h +++ b/deps/icu-small/source/i18n/olsontz.h @@ -151,7 +151,7 @@ class U_I18N_API OlsonTimeZone: public BasicTimeZone { /** * TimeZone API. */ - virtual TimeZone* clone() const; + virtual OlsonTimeZone* clone() const; /** * TimeZone API. @@ -398,7 +398,7 @@ class U_I18N_API OlsonTimeZone: public BasicTimeZone { TimeArrayTimeZoneRule **historicRules; int16_t historicRuleCount; SimpleTimeZone *finalZoneWithStartYear; // hack - UInitOnce transitionRulesInitOnce; + UInitOnce transitionRulesInitOnce = U_INITONCE_INITIALIZER; }; inline int16_t diff --git a/deps/icu-small/source/i18n/persncal.cpp b/deps/icu-small/source/i18n/persncal.cpp index 3d391f4e3fbe8e..4d366d41f0dffe 100644 --- a/deps/icu-small/source/i18n/persncal.cpp +++ b/deps/icu-small/source/i18n/persncal.cpp @@ -74,7 +74,7 @@ const char *PersianCalendar::getType() const { return "persian"; } -Calendar* PersianCalendar::clone() const { +PersianCalendar* PersianCalendar::clone() const { return new PersianCalendar(*this); } diff --git a/deps/icu-small/source/i18n/persncal.h b/deps/icu-small/source/i18n/persncal.h index ec818822b33a41..a9d940db78e6c7 100644 --- a/deps/icu-small/source/i18n/persncal.h +++ b/deps/icu-small/source/i18n/persncal.h @@ -164,7 +164,7 @@ class PersianCalendar : public Calendar { // TODO: copy c'tor, etc // clone - virtual Calendar* clone() const; + virtual PersianCalendar* clone() const; private: /** diff --git a/deps/icu-small/source/i18n/plurfmt.cpp b/deps/icu-small/source/i18n/plurfmt.cpp index 678d91b9c824bc..b99437630e67b5 100644 --- a/deps/icu-small/source/i18n/plurfmt.cpp +++ b/deps/icu-small/source/i18n/plurfmt.cpp @@ -159,7 +159,7 @@ PluralFormat::copyObjects(const PluralFormat& other) { if (other.numberFormat == NULL) { numberFormat = NumberFormat::createInstance(locale, status); } else { - numberFormat = (NumberFormat*)other.numberFormat->clone(); + numberFormat = other.numberFormat->clone(); } if (other.pluralRulesWrapper.pluralRules == NULL) { pluralRulesWrapper.pluralRules = PluralRules::forLocale(locale, status); @@ -277,7 +277,14 @@ PluralFormat::format(const Formattable& numberObject, double number, UnicodeString numberString; auto *decFmt = dynamic_cast(numberFormat); if(decFmt != nullptr) { - decFmt->toNumberFormatter().formatImpl(&data, status); // mutates &data + const number::LocalizedNumberFormatter* lnf = decFmt->toNumberFormatter(status); + if (U_FAILURE(status)) { + return appendTo; + } + lnf->formatImpl(&data, status); // mutates &data + if (U_FAILURE(status)) { + return appendTo; + } numberString = data.getStringRef().toUnicodeString(); } else { if (offset == 0) { @@ -346,7 +353,7 @@ PluralFormat::setNumberFormat(const NumberFormat* format, UErrorCode& status) { if (U_FAILURE(status)) { return; } - NumberFormat* nf = (NumberFormat*)format->clone(); + NumberFormat* nf = format->clone(); if (nf != NULL) { delete numberFormat; numberFormat = nf; @@ -355,7 +362,7 @@ PluralFormat::setNumberFormat(const NumberFormat* format, UErrorCode& status) { } } -Format* +PluralFormat* PluralFormat::clone() const { return new PluralFormat(*this); diff --git a/deps/icu-small/source/i18n/quant.cpp b/deps/icu-small/source/i18n/quant.cpp index 1908a504846b07..b0e7a3ed52c240 100644 --- a/deps/icu-small/source/i18n/quant.cpp +++ b/deps/icu-small/source/i18n/quant.cpp @@ -47,7 +47,7 @@ Quantifier::~Quantifier() { /** * Implement UnicodeFunctor */ -UnicodeFunctor* Quantifier::clone() const { +Quantifier* Quantifier::clone() const { return new Quantifier(*this); } diff --git a/deps/icu-small/source/i18n/quant.h b/deps/icu-small/source/i18n/quant.h index 1abb0db61aa386..d5aa8e5eeeedee 100644 --- a/deps/icu-small/source/i18n/quant.h +++ b/deps/icu-small/source/i18n/quant.h @@ -45,7 +45,7 @@ class Quantifier : public UnicodeFunctor, public UnicodeMatcher { * Implement UnicodeFunctor * @return a copy of the object. */ - virtual UnicodeFunctor* clone() const; + virtual Quantifier* clone() const; /** * Implement UnicodeMatcher diff --git a/deps/icu-small/source/i18n/quantityformatter.cpp b/deps/icu-small/source/i18n/quantityformatter.cpp index 9182f9e7d379a8..e88b70fbd71795 100644 --- a/deps/icu-small/source/i18n/quantityformatter.cpp +++ b/deps/icu-small/source/i18n/quantityformatter.cpp @@ -26,7 +26,7 @@ #include "uassert.h" #include "number_decimalquantity.h" #include "number_utypes.h" -#include "number_stringbuilder.h" +#include "formatted_string_builder.h" U_NAMESPACE_BEGIN @@ -180,7 +180,7 @@ void QuantityFormatter::formatAndSelect( double quantity, const NumberFormat& fmt, const PluralRules& rules, - number::impl::NumberStringBuilder& output, + FormattedStringBuilder& output, StandardPlural::Form& pluralForm, UErrorCode& status) { UnicodeString pluralKeyword; @@ -188,7 +188,11 @@ void QuantityFormatter::formatAndSelect( if (df != nullptr) { number::impl::UFormattedNumberData fn; fn.quantity.setToDouble(quantity); - df->toNumberFormatter().formatImpl(&fn, status); + const number::LocalizedNumberFormatter* lnf = df->toNumberFormatter(status); + if (U_FAILURE(status)) { + return; + } + lnf->formatImpl(&fn, status); if (U_FAILURE(status)) { return; } diff --git a/deps/icu-small/source/i18n/quantityformatter.h b/deps/icu-small/source/i18n/quantityformatter.h index 3e3f29de57323d..88c3f3844e924d 100644 --- a/deps/icu-small/source/i18n/quantityformatter.h +++ b/deps/icu-small/source/i18n/quantityformatter.h @@ -26,12 +26,7 @@ class PluralRules; class NumberFormat; class Formattable; class FieldPosition; - -namespace number { -namespace impl { -class NumberStringBuilder; -} -} +class FormattedStringBuilder; /** * A plural aware formatter that is good for expressing a single quantity and @@ -129,7 +124,7 @@ class U_I18N_API QuantityFormatter : public UMemory { /** * Formats a quantity and selects its plural form. The output is appended - * to a NumberStringBuilder in order to retain field information. + * to a FormattedStringBuilder in order to retain field information. * * @param quantity The number to format. * @param fmt The formatter to use to format the number. @@ -144,7 +139,7 @@ class U_I18N_API QuantityFormatter : public UMemory { double quantity, const NumberFormat& fmt, const PluralRules& rules, - number::impl::NumberStringBuilder& output, + FormattedStringBuilder& output, StandardPlural::Form& pluralForm, UErrorCode& status); diff --git a/deps/icu-small/source/i18n/rbnf.cpp b/deps/icu-small/source/i18n/rbnf.cpp index 74707ccd22d2ac..c25e61e6b28d94 100644 --- a/deps/icu-small/source/i18n/rbnf.cpp +++ b/deps/icu-small/source/i18n/rbnf.cpp @@ -355,10 +355,16 @@ class LocDataParser { }; #ifdef RBNF_DEBUG -#define ERROR(msg) parseError(msg); return NULL; +#define ERROR(msg) UPRV_BLOCK_MACRO_BEGIN { \ + parseError(msg); \ + return NULL; \ +} UPRV_BLOCK_MACRO_END #define EXPLANATION_ARG explanationArg #else -#define ERROR(msg) parseError(NULL); return NULL; +#define ERROR(msg) UPRV_BLOCK_MACRO_BEGIN { \ + parseError(NULL); \ + return NULL; \ +} UPRV_BLOCK_MACRO_END #define EXPLANATION_ARG #endif @@ -924,8 +930,8 @@ RuleBasedNumberFormat::~RuleBasedNumberFormat() dispose(); } -Format* -RuleBasedNumberFormat::clone(void) const +RuleBasedNumberFormat* +RuleBasedNumberFormat::clone() const { return new RuleBasedNumberFormat(*this); } @@ -1110,45 +1116,6 @@ RuleBasedNumberFormat::findRuleSet(const UnicodeString& name, UErrorCode& status return NULL; } -UnicodeString& -RuleBasedNumberFormat::format(const DecimalQuantity &number, - UnicodeString &appendTo, - FieldPositionIterator *posIter, - UErrorCode &status) const { - if (U_FAILURE(status)) { - return appendTo; - } - DecimalQuantity copy(number); - if (copy.fitsInLong()) { - format(number.toLong(), appendTo, posIter, status); - } - else { - copy.roundToMagnitude(0, number::impl::RoundingMode::UNUM_ROUND_HALFEVEN, status); - if (copy.fitsInLong()) { - format(number.toDouble(), appendTo, posIter, status); - } - else { - // We're outside of our normal range that this framework can handle. - // The DecimalFormat will provide more accurate results. - - // TODO this section should probably be optimized. The DecimalFormat is shared in ICU4J. - LocalPointer decimalFormat(NumberFormat::createInstance(locale, UNUM_DECIMAL, status), status); - if (decimalFormat.isNull()) { - return appendTo; - } - Formattable f; - LocalPointer decimalQuantity(new DecimalQuantity(number), status); - if (decimalQuantity.isNull()) { - return appendTo; - } - f.adoptDecimalQuantity(decimalQuantity.orphan()); // f now owns decimalQuantity. - decimalFormat->format(f, appendTo, posIter, status); - } - } - return appendTo; -} - - UnicodeString& RuleBasedNumberFormat::format(const DecimalQuantity &number, UnicodeString& appendTo, diff --git a/deps/icu-small/source/i18n/rbt.cpp b/deps/icu-small/source/i18n/rbt.cpp index 8ba6a60ff42218..02d0ce6ceb20f8 100644 --- a/deps/icu-small/source/i18n/rbt.cpp +++ b/deps/icu-small/source/i18n/rbt.cpp @@ -191,8 +191,8 @@ RuleBasedTransliterator::~RuleBasedTransliterator() { } } -Transliterator* // Covariant return NOT ALLOWED (for portability) -RuleBasedTransliterator::clone(void) const { +RuleBasedTransliterator* +RuleBasedTransliterator::clone() const { return new RuleBasedTransliterator(*this); } @@ -253,7 +253,7 @@ RuleBasedTransliterator::handleTransliterate(Replaceable& text, UTransPosition& // // TODO(andy): Need a better scheme for handling this. - static UMutex transliteratorDataMutex = U_MUTEX_INITIALIZER; + static UMutex transliteratorDataMutex; UBool needToLock; { Mutex m; diff --git a/deps/icu-small/source/i18n/rbt.h b/deps/icu-small/source/i18n/rbt.h index a18452ab2ecb49..b450dc23f4975c 100644 --- a/deps/icu-small/source/i18n/rbt.h +++ b/deps/icu-small/source/i18n/rbt.h @@ -144,7 +144,7 @@ class RuleBasedTransliterator : public Transliterator { * Implement Transliterator API. * @internal Use transliterator factory methods instead since this class will be removed in that release. */ - virtual Transliterator* clone(void) const; + virtual RuleBasedTransliterator* clone() const; protected: /** diff --git a/deps/icu-small/source/i18n/rbt_pars.cpp b/deps/icu-small/source/i18n/rbt_pars.cpp index e07cc8b63a408c..3eb58a2a904a46 100644 --- a/deps/icu-small/source/i18n/rbt_pars.cpp +++ b/deps/icu-small/source/i18n/rbt_pars.cpp @@ -1111,7 +1111,7 @@ void TransliteratorParser::parseRules(const UnicodeString& rule, int32_t p = UHASH_FIRST; const UHashElement* he = variableNames.nextElement(p); while (he != NULL) { - UnicodeString* tempus = (UnicodeString*)(((UnicodeString*)(he->value.pointer))->clone()); + UnicodeString* tempus = ((UnicodeString*)(he->value.pointer))->clone(); if (tempus == NULL) { status = U_MEMORY_ALLOCATION_ERROR; return; diff --git a/deps/icu-small/source/i18n/rbt_rule.cpp b/deps/icu-small/source/i18n/rbt_rule.cpp index db02f76035c9ea..cd7bd5d9dfb655 100644 --- a/deps/icu-small/source/i18n/rbt_rule.cpp +++ b/deps/icu-small/source/i18n/rbt_rule.cpp @@ -180,13 +180,13 @@ TransliterationRule::TransliterationRule(TransliterationRule& other) : } if (other.anteContext != NULL) { - anteContext = (StringMatcher*) other.anteContext->clone(); + anteContext = other.anteContext->clone(); } if (other.key != NULL) { - key = (StringMatcher*) other.key->clone(); + key = other.key->clone(); } if (other.postContext != NULL) { - postContext = (StringMatcher*) other.postContext->clone(); + postContext = other.postContext->clone(); } output = other.output->clone(); } diff --git a/deps/icu-small/source/i18n/rbtz.cpp b/deps/icu-small/source/i18n/rbtz.cpp index b8dca395fc0403..2c3747abdafeaf 100644 --- a/deps/icu-small/source/i18n/rbtz.cpp +++ b/deps/icu-small/source/i18n/rbtz.cpp @@ -149,7 +149,7 @@ RuleBasedTimeZone::addTransitionRule(TimeZoneRule* rule, UErrorCode& status) { void RuleBasedTimeZone::completeConst(UErrorCode& status) const { - static UMutex gLock = U_MUTEX_INITIALIZER; + static UMutex gLock; if (U_FAILURE(status)) { return; } @@ -356,8 +356,8 @@ RuleBasedTimeZone::complete(UErrorCode& status) { fUpToDate = FALSE; } -TimeZone* -RuleBasedTimeZone::clone(void) const { +RuleBasedTimeZone* +RuleBasedTimeZone::clone() const { return new RuleBasedTimeZone(*this); } diff --git a/deps/icu-small/source/i18n/regexcmp.cpp b/deps/icu-small/source/i18n/regexcmp.cpp index 8d60986fd32ca6..3a6368b07afe73 100644 --- a/deps/icu-small/source/i18n/regexcmp.cpp +++ b/deps/icu-small/source/i18n/regexcmp.cpp @@ -561,7 +561,7 @@ UBool RegexCompile::doParseActions(int32_t action) // sequence; don't change without making updates there too. // // Compiles to - // 1 START_LA dataLoc Saves SP, Input Pos + // 1 LA_START dataLoc Saves SP, Input Pos, Active input region. // 2. STATE_SAVE 4 on failure of lookahead, goto 4 // 3 JMP 6 continue ... // @@ -575,10 +575,14 @@ UBool RegexCompile::doParseActions(int32_t action) // 8. code for parenthesized stuff. // 9. LA_END // - // Two data slots are reserved, for saving the stack ptr and the input position. + // Four data slots are reserved, for saving state on entry to the look-around + // 0: stack pointer on entry. + // 1: input position on entry. + // 2: fActiveStart, the active bounds start on entry. + // 3: fActiveLimit, the active bounds limit on entry. { fixLiterals(); - int32_t dataLoc = allocateData(2); + int32_t dataLoc = allocateData(4); appendOp(URX_LA_START, dataLoc); appendOp(URX_STATE_SAVE, fRXPat->fCompiledPat->size()+ 2); appendOp(URX_JMP, fRXPat->fCompiledPat->size()+ 3); @@ -599,18 +603,23 @@ UBool RegexCompile::doParseActions(int32_t action) case doOpenLookAheadNeg: // Negated Lookahead. (?! stuff ) // Compiles to - // 1. START_LA dataloc + // 1. LA_START dataloc // 2. SAVE_STATE 7 // Fail within look-ahead block restores to this state, // // which continues with the match. // 3. NOP // Std. Open Paren sequence, for possible '|' // 4. code for parenthesized stuff. - // 5. END_LA // Cut back stack, remove saved state from step 2. + // 5. LA_END // Cut back stack, remove saved state from step 2. // 6. BACKTRACK // code in block succeeded, so neg. lookahead fails. // 7. END_LA // Restore match region, in case look-ahead was using // an alternate (transparent) region. + // Four data slots are reserved, for saving state on entry to the look-around + // 0: stack pointer on entry. + // 1: input position on entry. + // 2: fActiveStart, the active bounds start on entry. + // 3: fActiveLimit, the active bounds limit on entry. { fixLiterals(); - int32_t dataLoc = allocateData(2); + int32_t dataLoc = allocateData(4); appendOp(URX_LA_START, dataLoc); appendOp(URX_STATE_SAVE, 0); // dest address will be patched later. appendOp(URX_NOP, 0); @@ -644,14 +653,16 @@ UBool RegexCompile::doParseActions(int32_t action) // Allocate a block of matcher data, to contain (when running a match) // 0: Stack ptr on entry // 1: Input Index on entry - // 2: Start index of match current match attempt. - // 3: Original Input String len. + // 2: fActiveStart, the active bounds start on entry. + // 3: fActiveLimit, the active bounds limit on entry. + // 4: Start index of match current match attempt. + // The first four items must match the layout of data for LA_START / LA_END // Generate match code for any pending literals. fixLiterals(); // Allocate data space - int32_t dataLoc = allocateData(4); + int32_t dataLoc = allocateData(5); // Emit URX_LB_START appendOp(URX_LB_START, dataLoc); @@ -696,14 +707,16 @@ UBool RegexCompile::doParseActions(int32_t action) // Allocate a block of matcher data, to contain (when running a match) // 0: Stack ptr on entry // 1: Input Index on entry - // 2: Start index of match current match attempt. - // 3: Original Input String len. + // 2: fActiveStart, the active bounds start on entry. + // 3: fActiveLimit, the active bounds limit on entry. + // 4: Start index of match current match attempt. + // The first four items must match the layout of data for LA_START / LA_END // Generate match code for any pending literals. fixLiterals(); // Allocate data space - int32_t dataLoc = allocateData(4); + int32_t dataLoc = allocateData(5); // Emit URX_LB_START appendOp(URX_LB_START, dataLoc); @@ -2285,7 +2298,7 @@ void RegexCompile::handleCloseParen() { error(U_REGEX_LOOK_BEHIND_LIMIT); break; } - if (minML == INT32_MAX && maxML == 0) { + if (minML == INT32_MAX) { // This condition happens when no match is possible, such as with a // [set] expression containing no elements. // In principle, the generated code to evaluate the expression could be deleted, @@ -2328,7 +2341,7 @@ void RegexCompile::handleCloseParen() { error(U_REGEX_LOOK_BEHIND_LIMIT); break; } - if (minML == INT32_MAX && maxML == 0) { + if (minML == INT32_MAX) { // This condition happens when no match is possible, such as with a // [set] expression containing no elements. // In principle, the generated code to evaluate the expression could be deleted, @@ -3381,7 +3394,7 @@ int32_t RegexCompile::minMatchLength(int32_t start, int32_t end) { // it assumes that the look-ahead match might be zero-length. // TODO: Positive lookahead could recursively do the block, then continue // with the longer of the block or the value coming in. Ticket 6060 - int32_t depth = (opType == URX_LA_START? 2: 1);; + int32_t depth = (opType == URX_LA_START? 2: 1); for (;;) { loc++; op = (int32_t)fRXPat->fCompiledPat->elementAti(loc); @@ -3463,7 +3476,6 @@ int32_t RegexCompile::maxMatchLength(int32_t start, int32_t end) { U_ASSERT(start <= end); U_ASSERT(end < fRXPat->fCompiledPat->size()); - int32_t loc; int32_t op; int32_t opType; @@ -3672,7 +3684,7 @@ int32_t RegexCompile::maxMatchLength(int32_t start, int32_t end) { case URX_CTR_LOOP: case URX_CTR_LOOP_NG: - // These opcodes will be skipped over by code for URX_CRT_INIT. + // These opcodes will be skipped over by code for URX_CTR_INIT. // We shouldn't encounter them here. UPRV_UNREACHABLE; @@ -3700,21 +3712,15 @@ int32_t RegexCompile::maxMatchLength(int32_t start, int32_t end) { { // Look-behind. Scan forward until the matching look-around end, // without processing the look-behind block. - int32_t depth = 0; - for (;;) { - loc++; + int32_t dataLoc = URX_VAL(op); + for (loc = loc + 1; loc < end; ++loc) { op = (int32_t)fRXPat->fCompiledPat->elementAti(loc); - if (URX_TYPE(op) == URX_LA_START || URX_TYPE(op) == URX_LB_START) { - depth++; - } - if (URX_TYPE(op) == URX_LA_END || URX_TYPE(op)==URX_LBN_END) { - if (depth == 0) { - break; - } - depth--; + int32_t opType = URX_TYPE(op); + if ((opType == URX_LA_END || opType == URX_LBN_END) && (URX_VAL(op) == dataLoc)) { + break; } - U_ASSERT(loc < end); } + U_ASSERT(loc < end); } break; diff --git a/deps/icu-small/source/i18n/regeximp.h b/deps/icu-small/source/i18n/regeximp.h index da4a861bde52dd..9155cd3a31bbe1 100644 --- a/deps/icu-small/source/i18n/regeximp.h +++ b/deps/icu-small/source/i18n/regeximp.h @@ -123,7 +123,7 @@ enum { // saved input position, FAIL rather than taking // the JMP URX_LA_START = 37, // Starting a LookAround expression. - // Save InputPos and SP in static data. + // Save InputPos, SP and active region in static data. // Operand: Static data offset for the save URX_LA_END = 38, // Ending a Lookaround expression. // Restore InputPos and Stack to saved values. diff --git a/deps/icu-small/source/i18n/region.cpp b/deps/icu-small/source/i18n/region.cpp index f182f61486e6d3..198bea8f643a5b 100644 --- a/deps/icu-small/source/i18n/region.cpp +++ b/deps/icu-small/source/i18n/region.cpp @@ -25,7 +25,6 @@ #include "unicode/uobject.h" #include "unicode/unistr.h" #include "unicode/ures.h" -#include "unicode/decimfmt.h" #include "ucln_in.h" #include "cstring.h" #include "mutex.h" @@ -33,6 +32,7 @@ #include "umutex.h" #include "uresimp.h" #include "region_impl.h" +#include "util.h" #if !UCONFIG_NO_FORMATTING @@ -87,7 +87,6 @@ void U_CALLCONV Region::loadRegionData(UErrorCode &status) { LocalUHashtablePointer newRegionIDMap(uhash_open(uhash_hashUnicodeString, uhash_compareUnicodeString, NULL, &status)); LocalUHashtablePointer newNumericCodeMap(uhash_open(uhash_hashLong,uhash_compareLong,NULL,&status)); LocalUHashtablePointer newRegionAliases(uhash_open(uhash_hashUnicodeString,uhash_compareUnicodeString,NULL,&status)); - LocalPointer df(new DecimalFormat(status), status); LocalPointer continents(new UVector(uprv_deleteUObject, uhash_compareUnicodeString, status), status); LocalPointer groupings(new UVector(uprv_deleteUObject, uhash_compareUnicodeString, status), status); @@ -115,7 +114,6 @@ void U_CALLCONV Region::loadRegionData(UErrorCode &status) { } // now, initialize - df->setParseIntegerOnly(TRUE); uhash_setValueDeleter(newRegionIDMap.getAlias(), deleteRegion); // regionIDMap owns objs uhash_setKeyDeleter(newRegionAliases.getAlias(), uprv_deleteUObject); // regionAliases owns the string keys @@ -192,11 +190,10 @@ void U_CALLCONV Region::loadRegionData(UErrorCode &status) { r->idStr.extract(0,r->idStr.length(),r->id,sizeof(r->id),US_INV); r->fType = URGN_TERRITORY; // Only temporary - figure out the real type later once the aliases are known. - Formattable result; - UErrorCode ps = U_ZERO_ERROR; - df->parse(r->idStr,result,ps); - if ( U_SUCCESS(ps) ) { - r->code = result.getLong(); // Convert string to number + int32_t pos = 0; + int32_t result = ICU_Utility::parseAsciiInteger(r->idStr, pos); + if (pos > 0) { + r->code = result; // Convert string to number uhash_iput(newNumericCodeMap.getAlias(),r->code,(void *)(r.getAlias()),&status); r->fType = URGN_SUBCONTINENT; } else { @@ -230,11 +227,10 @@ void U_CALLCONV Region::loadRegionData(UErrorCode &status) { aliasFromRegion->idStr.setTo(*aliasFromStr); aliasFromRegion->idStr.extract(0,aliasFromRegion->idStr.length(),aliasFromRegion->id,sizeof(aliasFromRegion->id),US_INV); uhash_put(newRegionIDMap.getAlias(),(void *)&(aliasFromRegion->idStr),(void *)aliasFromRegion,&status); - Formattable result; - UErrorCode ps = U_ZERO_ERROR; - df->parse(aliasFromRegion->idStr,result,ps); - if ( U_SUCCESS(ps) ) { - aliasFromRegion->code = result.getLong(); // Convert string to number + int32_t pos = 0; + int32_t result = ICU_Utility::parseAsciiInteger(aliasFromRegion->idStr, pos); + if ( pos > 0 ) { + aliasFromRegion->code = result; // Convert string to number uhash_iput(newNumericCodeMap.getAlias(),aliasFromRegion->code,(void *)aliasFromRegion,&status); } else { aliasFromRegion->code = -1; @@ -279,11 +275,10 @@ void U_CALLCONV Region::loadRegionData(UErrorCode &status) { Region *r = (Region *)uhash_get(newRegionIDMap.getAlias(),(void *)&codeMappingID); if ( r ) { - Formattable result; - UErrorCode ps = U_ZERO_ERROR; - df->parse(codeMappingNumber,result,ps); - if ( U_SUCCESS(ps) ) { - r->code = result.getLong(); // Convert string to number + int32_t pos = 0; + int32_t result = ICU_Utility::parseAsciiInteger(codeMappingNumber, pos); + if ( pos > 0 ) { + r->code = result; // Convert string to number uhash_iput(newNumericCodeMap.getAlias(),r->code,(void *)r,&status); } LocalPointer code3(new UnicodeString(codeMapping3Letter), status); @@ -516,15 +511,8 @@ Region::getInstance (int32_t code, UErrorCode &status) { Region *r = (Region *)uhash_iget(numericCodeMap,code); if ( !r ) { // Just in case there's an alias that's numeric, try to find it. - UnicodeString pat = UNICODE_STRING_SIMPLE("0"); - LocalPointer df(new DecimalFormat(pat,status), status); - if( U_FAILURE(status) ) { - return NULL; - } UnicodeString id; - id.remove(); - FieldPosition posIter; - df->format(code,id, posIter, status); + ICU_Utility::appendNumber(id, code, 10, 1); r = (Region *)uhash_get(regionAliases,&id); } diff --git a/deps/icu-small/source/i18n/reldatefmt.cpp b/deps/icu-small/source/i18n/reldatefmt.cpp index cda2564b9a0539..f2568a858d1d20 100644 --- a/deps/icu-small/source/i18n/reldatefmt.cpp +++ b/deps/icu-small/source/i18n/reldatefmt.cpp @@ -43,7 +43,7 @@ #include "standardplural.h" #include "unifiedcache.h" #include "util.h" -#include "number_stringbuilder.h" +#include "formatted_string_builder.h" #include "number_utypes.h" #include "number_modifiers.h" #include "formattedval_impl.h" @@ -315,6 +315,10 @@ struct RelDateTimeFmtDataSink : public ResourceSink { return UDAT_ABSOLUTE_FRIDAY; case SATURDAY: return UDAT_ABSOLUTE_SATURDAY; + case HOUR: + return UDAT_ABSOLUTE_HOUR; + case MINUTE: + return UDAT_ABSOLUTE_MINUTE; default: return -1; } @@ -725,14 +729,14 @@ const RelativeDateTimeCacheData *LocaleCacheKey::crea static constexpr number::impl::Field kRDTNumericField - = number::impl::NumFieldUtils::compress(); + = StringBuilderFieldUtils::compress(); static constexpr number::impl::Field kRDTLiteralField - = number::impl::NumFieldUtils::compress(); + = StringBuilderFieldUtils::compress(); -class FormattedRelativeDateTimeData : public FormattedValueNumberStringBuilderImpl { +class FormattedRelativeDateTimeData : public FormattedValueStringBuilderImpl { public: - FormattedRelativeDateTimeData() : FormattedValueNumberStringBuilderImpl(kRDTNumericField) {} + FormattedRelativeDateTimeData() : FormattedValueStringBuilderImpl(kRDTNumericField) {} virtual ~FormattedRelativeDateTimeData(); }; @@ -1157,6 +1161,8 @@ void RelativeDateTimeFormatter::formatRelativeImpl( case UDAT_REL_UNIT_THURSDAY: absunit = UDAT_ABSOLUTE_THURSDAY; break; case UDAT_REL_UNIT_FRIDAY: absunit = UDAT_ABSOLUTE_FRIDAY; break; case UDAT_REL_UNIT_SATURDAY: absunit = UDAT_ABSOLUTE_SATURDAY; break; + case UDAT_REL_UNIT_HOUR: absunit = UDAT_ABSOLUTE_HOUR; break; + case UDAT_REL_UNIT_MINUTE: absunit = UDAT_ABSOLUTE_MINUTE; break; default: break; } if (direction != UDAT_DIRECTION_COUNT && absunit != UDAT_ABSOLUTE_UNIT_COUNT) { @@ -1184,7 +1190,7 @@ UnicodeString& RelativeDateTimeFormatter::adjustForContext(UnicodeString &str) c // Must guarantee that one thread at a time accesses the shared break // iterator. - static icu::UMutex gBrkIterMutex = U_MUTEX_INITIALIZER; + static UMutex gBrkIterMutex; Mutex lock(&gBrkIterMutex); str.toTitle( fOptBreakIterator->get(), diff --git a/deps/icu-small/source/i18n/reldtfmt.cpp b/deps/icu-small/source/i18n/reldtfmt.cpp index 753672d905f16b..c74c30c20ca383 100644 --- a/deps/icu-small/source/i18n/reldtfmt.cpp +++ b/deps/icu-small/source/i18n/reldtfmt.cpp @@ -51,7 +51,7 @@ RelativeDateFormat::RelativeDateFormat(const RelativeDateFormat& other) : fCapitalizationBrkIter(NULL) { if(other.fDateTimeFormatter != NULL) { - fDateTimeFormatter = (SimpleDateFormat*)other.fDateTimeFormatter->clone(); + fDateTimeFormatter = other.fDateTimeFormatter->clone(); } if(other.fCombinedFormat != NULL) { fCombinedFormat = new SimpleFormatter(*other.fCombinedFormat); @@ -131,7 +131,7 @@ RelativeDateFormat::~RelativeDateFormat() { } -Format* RelativeDateFormat::clone(void) const { +RelativeDateFormat* RelativeDateFormat::clone() const { return new RelativeDateFormat(*this); } diff --git a/deps/icu-small/source/i18n/reldtfmt.h b/deps/icu-small/source/i18n/reldtfmt.h index 0403da11efda76..b36171ce1c6b55 100644 --- a/deps/icu-small/source/i18n/reldtfmt.h +++ b/deps/icu-small/source/i18n/reldtfmt.h @@ -71,7 +71,7 @@ class RelativeDateFormat : public DateFormat { * @return A copy of the object. * @internal ICU 3.8 */ - virtual Format* clone(void) const; + virtual RelativeDateFormat* clone() const; /** * Return true if the given Format objects are semantically equal. Objects diff --git a/deps/icu-small/source/i18n/rematch.cpp b/deps/icu-small/source/i18n/rematch.cpp index 3b8d2333d82098..d9af2b3ddaa77e 100644 --- a/deps/icu-small/source/i18n/rematch.cpp +++ b/deps/icu-small/source/i18n/rematch.cpp @@ -2069,7 +2069,7 @@ int32_t RegexMatcher::split(UText *input, // if (U_FAILURE(status)) { return 0; - }; + } if (destCapacity < 1) { status = U_ILLEGAL_ARGUMENT_ERROR; @@ -3805,11 +3805,13 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) { case URX_LA_START: { - // Entering a lookahead block. + // Entering a look around block. // Save Stack Ptr, Input Pos. - U_ASSERT(opValue>=0 && opValue+1fDataSize); + U_ASSERT(opValue>=0 && opValue+3fDataSize); fData[opValue] = fStack->size(); fData[opValue+1] = fp->fInputIdx; + fData[opValue+2] = fActiveStart; + fData[opValue+3] = fActiveLimit; fActiveStart = fLookStart; // Set the match region change for fActiveLimit = fLookLimit; // transparent bounds. } @@ -3819,7 +3821,7 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) { { // Leaving a look-ahead block. // restore Stack Ptr, Input Pos to positions they had on entry to block. - U_ASSERT(opValue>=0 && opValue+1fDataSize); + U_ASSERT(opValue>=0 && opValue+3fDataSize); int32_t stackSize = fStack->size(); int32_t newStackSize =(int32_t)fData[opValue]; U_ASSERT(stackSize >= newStackSize); @@ -3839,8 +3841,10 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) { // Restore the active region bounds in the input string; they may have // been changed because of transparent bounds on a Region. - fActiveStart = fRegionStart; - fActiveLimit = fRegionLimit; + fActiveStart = fData[opValue+2]; + fActiveLimit = fData[opValue+3]; + U_ASSERT(fActiveStart >= 0); + U_ASSERT(fActiveLimit <= fInputLength); } break; @@ -3916,17 +3920,19 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) { case URX_LB_START: { // Entering a look-behind block. - // Save Stack Ptr, Input Pos. + // Save Stack Ptr, Input Pos and active input region. // TODO: implement transparent bounds. Ticket #6067 - U_ASSERT(opValue>=0 && opValue+1fDataSize); + U_ASSERT(opValue>=0 && opValue+4fDataSize); fData[opValue] = fStack->size(); fData[opValue+1] = fp->fInputIdx; - // Init the variable containing the start index for attempted matches. - fData[opValue+2] = -1; // Save input string length, then reset to pin any matches to end at // the current position. + fData[opValue+2] = fActiveStart; fData[opValue+3] = fActiveLimit; + fActiveStart = fRegionStart; fActiveLimit = fp->fInputIdx; + // Init the variable containing the start index for attempted matches. + fData[opValue+4] = -1; } break; @@ -3949,8 +3955,8 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) { U_ASSERT(minML >= 0); // Fetch (from data) the last input index where a match was attempted. - U_ASSERT(opValue>=0 && opValue+1fDataSize); - int64_t &lbStartIdx = fData[opValue+2]; + U_ASSERT(opValue>=0 && opValue+4fDataSize); + int64_t &lbStartIdx = fData[opValue+4]; if (lbStartIdx < 0) { // First time through loop. lbStartIdx = fp->fInputIdx - minML; @@ -3976,10 +3982,10 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) { // getting a match. Backtrack out, and out of the // Look Behind altogether. fp = (REStackFrame *)fStack->popFrame(fFrameSize); - int64_t restoreInputLen = fData[opValue+3]; - U_ASSERT(restoreInputLen >= fActiveLimit); - U_ASSERT(restoreInputLen <= fInputLength); - fActiveLimit = restoreInputLen; + fActiveStart = fData[opValue+2]; + fActiveLimit = fData[opValue+3]; + U_ASSERT(fActiveStart >= 0); + U_ASSERT(fActiveLimit <= fInputLength); break; } @@ -3993,7 +3999,7 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) { case URX_LB_END: // End of a look-behind block, after a successful match. { - U_ASSERT(opValue>=0 && opValue+1fDataSize); + U_ASSERT(opValue>=0 && opValue+4fDataSize); if (fp->fInputIdx != fActiveLimit) { // The look-behind expression matched, but the match did not // extend all the way to the point that we are looking behind from. @@ -4004,13 +4010,13 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) { break; } - // Look-behind match is good. Restore the orignal input string length, + // Look-behind match is good. Restore the orignal input string region, // which had been truncated to pin the end of the lookbehind match to the // position being looked-behind. - int64_t originalInputLen = fData[opValue+3]; - U_ASSERT(originalInputLen >= fActiveLimit); - U_ASSERT(originalInputLen <= fInputLength); - fActiveLimit = originalInputLen; + fActiveStart = fData[opValue+2]; + fActiveLimit = fData[opValue+3]; + U_ASSERT(fActiveStart >= 0); + U_ASSERT(fActiveLimit <= fInputLength); } break; @@ -4035,8 +4041,8 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) { U_ASSERT(continueLoc > fp->fPatIdx); // Fetch (from data) the last input index where a match was attempted. - U_ASSERT(opValue>=0 && opValue+1fDataSize); - int64_t &lbStartIdx = fData[opValue+2]; + U_ASSERT(opValue>=0 && opValue+4fDataSize); + int64_t &lbStartIdx = fData[opValue+4]; if (lbStartIdx < 0) { // First time through loop. lbStartIdx = fp->fInputIdx - minML; @@ -4061,10 +4067,10 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) { // We have tried all potential match starting points without // getting a match, which means that the negative lookbehind as // a whole has succeeded. Jump forward to the continue location - int64_t restoreInputLen = fData[opValue+3]; - U_ASSERT(restoreInputLen >= fActiveLimit); - U_ASSERT(restoreInputLen <= fInputLength); - fActiveLimit = restoreInputLen; + fActiveStart = fData[opValue+2]; + fActiveLimit = fData[opValue+3]; + U_ASSERT(fActiveStart >= 0); + U_ASSERT(fActiveLimit <= fInputLength); fp->fPatIdx = continueLoc; break; } @@ -4079,7 +4085,7 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) { case URX_LBN_END: // End of a negative look-behind block, after a successful match. { - U_ASSERT(opValue>=0 && opValue+1fDataSize); + U_ASSERT(opValue>=0 && opValue+4fDataSize); if (fp->fInputIdx != fActiveLimit) { // The look-behind expression matched, but the match did not // extend all the way to the point that we are looking behind from. @@ -4096,10 +4102,10 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) { // Restore the orignal input string length, which had been truncated // inorder to pin the end of the lookbehind match // to the position being looked-behind. - int64_t originalInputLen = fData[opValue+3]; - U_ASSERT(originalInputLen >= fActiveLimit); - U_ASSERT(originalInputLen <= fInputLength); - fActiveLimit = originalInputLen; + fActiveStart = fData[opValue+2]; + fActiveLimit = fData[opValue+3]; + U_ASSERT(fActiveStart >= 0); + U_ASSERT(fActiveLimit <= fInputLength); // Restore original stack position, discarding any state saved // by the successful pattern match. @@ -5336,11 +5342,13 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu case URX_LA_START: { - // Entering a lookahead block. + // Entering a look around block. // Save Stack Ptr, Input Pos. - U_ASSERT(opValue>=0 && opValue+1fDataSize); + U_ASSERT(opValue>=0 && opValue+3fDataSize); fData[opValue] = fStack->size(); fData[opValue+1] = fp->fInputIdx; + fData[opValue+2] = fActiveStart; + fData[opValue+3] = fActiveLimit; fActiveStart = fLookStart; // Set the match region change for fActiveLimit = fLookLimit; // transparent bounds. } @@ -5348,9 +5356,9 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu case URX_LA_END: { - // Leaving a look-ahead block. + // Leaving a look around block. // restore Stack Ptr, Input Pos to positions they had on entry to block. - U_ASSERT(opValue>=0 && opValue+1fDataSize); + U_ASSERT(opValue>=0 && opValue+3fDataSize); int32_t stackSize = fStack->size(); int32_t newStackSize = (int32_t)fData[opValue]; U_ASSERT(stackSize >= newStackSize); @@ -5370,8 +5378,10 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu // Restore the active region bounds in the input string; they may have // been changed because of transparent bounds on a Region. - fActiveStart = fRegionStart; - fActiveLimit = fRegionLimit; + fActiveStart = fData[opValue+2]; + fActiveLimit = fData[opValue+3]; + U_ASSERT(fActiveStart >= 0); + U_ASSERT(fActiveLimit <= fInputLength); } break; @@ -5434,17 +5444,19 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu case URX_LB_START: { // Entering a look-behind block. - // Save Stack Ptr, Input Pos. + // Save Stack Ptr, Input Pos and active input region. // TODO: implement transparent bounds. Ticket #6067 - U_ASSERT(opValue>=0 && opValue+1fDataSize); + U_ASSERT(opValue>=0 && opValue+4fDataSize); fData[opValue] = fStack->size(); fData[opValue+1] = fp->fInputIdx; - // Init the variable containing the start index for attempted matches. - fData[opValue+2] = -1; // Save input string length, then reset to pin any matches to end at // the current position. + fData[opValue+2] = fActiveStart; fData[opValue+3] = fActiveLimit; + fActiveStart = fRegionStart; fActiveLimit = fp->fInputIdx; + // Init the variable containing the start index for attempted matches. + fData[opValue+4] = -1; } break; @@ -5462,8 +5474,8 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu U_ASSERT(minML >= 0); // Fetch (from data) the last input index where a match was attempted. - U_ASSERT(opValue>=0 && opValue+1fDataSize); - int64_t &lbStartIdx = fData[opValue+2]; + U_ASSERT(opValue>=0 && opValue+4fDataSize); + int64_t &lbStartIdx = fData[opValue+4]; if (lbStartIdx < 0) { // First time through loop. lbStartIdx = fp->fInputIdx - minML; @@ -5485,10 +5497,10 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu // getting a match. Backtrack out, and out of the // Look Behind altogether. fp = (REStackFrame *)fStack->popFrame(fFrameSize); - int64_t restoreInputLen = fData[opValue+3]; - U_ASSERT(restoreInputLen >= fActiveLimit); - U_ASSERT(restoreInputLen <= fInputLength); - fActiveLimit = restoreInputLen; + fActiveStart = fData[opValue+2]; + fActiveLimit = fData[opValue+3]; + U_ASSERT(fActiveStart >= 0); + U_ASSERT(fActiveLimit <= fInputLength); break; } @@ -5502,7 +5514,7 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu case URX_LB_END: // End of a look-behind block, after a successful match. { - U_ASSERT(opValue>=0 && opValue+1fDataSize); + U_ASSERT(opValue>=0 && opValue+4fDataSize); if (fp->fInputIdx != fActiveLimit) { // The look-behind expression matched, but the match did not // extend all the way to the point that we are looking behind from. @@ -5513,13 +5525,13 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu break; } - // Look-behind match is good. Restore the orignal input string length, + // Look-behind match is good. Restore the orignal input string region, // which had been truncated to pin the end of the lookbehind match to the // position being looked-behind. - int64_t originalInputLen = fData[opValue+3]; - U_ASSERT(originalInputLen >= fActiveLimit); - U_ASSERT(originalInputLen <= fInputLength); - fActiveLimit = originalInputLen; + fActiveStart = fData[opValue+2]; + fActiveLimit = fData[opValue+3]; + U_ASSERT(fActiveStart >= 0); + U_ASSERT(fActiveLimit <= fInputLength); } break; @@ -5539,8 +5551,8 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu U_ASSERT(continueLoc > fp->fPatIdx); // Fetch (from data) the last input index where a match was attempted. - U_ASSERT(opValue>=0 && opValue+1fDataSize); - int64_t &lbStartIdx = fData[opValue+2]; + U_ASSERT(opValue>=0 && opValue+4fDataSize); + int64_t &lbStartIdx = fData[opValue+4]; if (lbStartIdx < 0) { // First time through loop. lbStartIdx = fp->fInputIdx - minML; @@ -5561,10 +5573,10 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu // We have tried all potential match starting points without // getting a match, which means that the negative lookbehind as // a whole has succeeded. Jump forward to the continue location - int64_t restoreInputLen = fData[opValue+3]; - U_ASSERT(restoreInputLen >= fActiveLimit); - U_ASSERT(restoreInputLen <= fInputLength); - fActiveLimit = restoreInputLen; + fActiveStart = fData[opValue+2]; + fActiveLimit = fData[opValue+3]; + U_ASSERT(fActiveStart >= 0); + U_ASSERT(fActiveLimit <= fInputLength); fp->fPatIdx = continueLoc; break; } @@ -5579,7 +5591,7 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu case URX_LBN_END: // End of a negative look-behind block, after a successful match. { - U_ASSERT(opValue>=0 && opValue+1fDataSize); + U_ASSERT(opValue>=0 && opValue+4fDataSize); if (fp->fInputIdx != fActiveLimit) { // The look-behind expression matched, but the match did not // extend all the way to the point that we are looking behind from. @@ -5596,10 +5608,10 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu // Restore the orignal input string length, which had been truncated // inorder to pin the end of the lookbehind match // to the position being looked-behind. - int64_t originalInputLen = fData[opValue+3]; - U_ASSERT(originalInputLen >= fActiveLimit); - U_ASSERT(originalInputLen <= fInputLength); - fActiveLimit = originalInputLen; + fActiveStart = fData[opValue+2]; + fActiveLimit = fData[opValue+3]; + U_ASSERT(fActiveStart >= 0); + U_ASSERT(fActiveLimit <= fInputLength); // Restore original stack position, discarding any state saved // by the successful pattern match. diff --git a/deps/icu-small/source/i18n/remtrans.cpp b/deps/icu-small/source/i18n/remtrans.cpp index 70a6ed3935b579..03b878575ca86c 100644 --- a/deps/icu-small/source/i18n/remtrans.cpp +++ b/deps/icu-small/source/i18n/remtrans.cpp @@ -48,10 +48,10 @@ RemoveTransliterator::RemoveTransliterator() : Transliterator(UnicodeString(TRUE RemoveTransliterator::~RemoveTransliterator() {} -Transliterator* RemoveTransliterator::clone(void) const { - Transliterator* result = new RemoveTransliterator(); +RemoveTransliterator* RemoveTransliterator::clone() const { + RemoveTransliterator* result = new RemoveTransliterator(); if (result != NULL && getFilter() != 0) { - result->adoptFilter((UnicodeFilter*)(getFilter()->clone())); + result->adoptFilter(getFilter()->clone()); } return result; } diff --git a/deps/icu-small/source/i18n/remtrans.h b/deps/icu-small/source/i18n/remtrans.h index ed038d5f2fe0d5..13de01594a3fd9 100644 --- a/deps/icu-small/source/i18n/remtrans.h +++ b/deps/icu-small/source/i18n/remtrans.h @@ -47,7 +47,7 @@ class RemoveTransliterator : public Transliterator { * Transliterator API. * @return A copy of the object. */ - virtual Transliterator* clone(void) const; + virtual RemoveTransliterator* clone() const; /** * Implements {@link Transliterator#handleTransliterate}. diff --git a/deps/icu-small/source/i18n/repattrn.cpp b/deps/icu-small/source/i18n/repattrn.cpp index b03873066c9016..6976056dc1f6e4 100644 --- a/deps/icu-small/source/i18n/repattrn.cpp +++ b/deps/icu-small/source/i18n/repattrn.cpp @@ -646,7 +646,7 @@ int32_t RegexPattern::split(const UnicodeString &input, { if (U_FAILURE(status)) { return 0; - }; + } RegexMatcher m(this); int32_t r = 0; @@ -667,7 +667,7 @@ int32_t RegexPattern::split(UText *input, { if (U_FAILURE(status)) { return 0; - }; + } RegexMatcher m(this); int32_t r = 0; diff --git a/deps/icu-small/source/i18n/rulebasedcollator.cpp b/deps/icu-small/source/i18n/rulebasedcollator.cpp index 92fa5385971889..60acf17815a5ee 100644 --- a/deps/icu-small/source/i18n/rulebasedcollator.cpp +++ b/deps/icu-small/source/i18n/rulebasedcollator.cpp @@ -220,7 +220,7 @@ RuleBasedCollator::adoptTailoring(CollationTailoring *t, UErrorCode &errorCode) actualLocaleIsSameAsValid = FALSE; } -Collator * +RuleBasedCollator * RuleBasedCollator::clone() const { return new RuleBasedCollator(*this); } diff --git a/deps/icu-small/source/i18n/scientificnumberformatter.cpp b/deps/icu-small/source/i18n/scientificnumberformatter.cpp index 03d98dd6e100e2..6c2cb3aeed2743 100644 --- a/deps/icu-small/source/i18n/scientificnumberformatter.cpp +++ b/deps/icu-small/source/i18n/scientificnumberformatter.cpp @@ -121,7 +121,7 @@ ScientificNumberFormatter *ScientificNumberFormatter::createInstance( return result; } -ScientificNumberFormatter::Style *ScientificNumberFormatter::SuperscriptStyle::clone() const { +ScientificNumberFormatter::SuperscriptStyle *ScientificNumberFormatter::SuperscriptStyle::clone() const { return new ScientificNumberFormatter::SuperscriptStyle(*this); } @@ -195,7 +195,7 @@ UnicodeString &ScientificNumberFormatter::SuperscriptStyle::format( return appendTo; } -ScientificNumberFormatter::Style *ScientificNumberFormatter::MarkupStyle::clone() const { +ScientificNumberFormatter::MarkupStyle *ScientificNumberFormatter::MarkupStyle::clone() const { return new ScientificNumberFormatter::MarkupStyle(*this); } diff --git a/deps/icu-small/source/i18n/selfmt.cpp b/deps/icu-small/source/i18n/selfmt.cpp index 29aee3645751f2..47e53d75dec36f 100644 --- a/deps/icu-small/source/i18n/selfmt.cpp +++ b/deps/icu-small/source/i18n/selfmt.cpp @@ -151,7 +151,7 @@ int32_t SelectFormat::findSubMessage(const MessagePattern& pattern, int32_t part return msgStart; } -Format* SelectFormat::clone() const +SelectFormat* SelectFormat::clone() const { return new SelectFormat(*this); } diff --git a/deps/icu-small/source/i18n/simpletz.cpp b/deps/icu-small/source/i18n/simpletz.cpp index 1af5292a823324..12c220595cd2c1 100644 --- a/deps/icu-small/source/i18n/simpletz.cpp +++ b/deps/icu-small/source/i18n/simpletz.cpp @@ -33,6 +33,7 @@ #include "unicode/gregocal.h" #include "unicode/smpdtfmt.h" +#include "cmemory.h" #include "gregoimp.h" #include "umutex.h" @@ -242,7 +243,7 @@ SimpleTimeZone::operator==(const TimeZone& that) const // ------------------------------------- // Called by TimeZone::createDefault() inside a Mutex - be careful. -TimeZone* +SimpleTimeZone* SimpleTimeZone::clone() const { return new SimpleTimeZone(*this); @@ -1083,7 +1084,7 @@ SimpleTimeZone::checkTransitionRules(UErrorCode& status) const { if (U_FAILURE(status)) { return; } - static UMutex gLock = U_MUTEX_INITIALIZER; + static UMutex gLock; umtx_lock(&gLock); if (!transitionRulesInitialized) { SimpleTimeZone *ncThis = const_cast(this); diff --git a/deps/icu-small/source/i18n/smpdtfmt.cpp b/deps/icu-small/source/i18n/smpdtfmt.cpp index e67c4538287b9e..5fcbb5875b2bfb 100644 --- a/deps/icu-small/source/i18n/smpdtfmt.cpp +++ b/deps/icu-small/source/i18n/smpdtfmt.cpp @@ -230,10 +230,7 @@ static const int32_t gFieldRangeBias[] = { static const int32_t HEBREW_CAL_CUR_MILLENIUM_START_YEAR = 5000; static const int32_t HEBREW_CAL_CUR_MILLENIUM_END_YEAR = 6000; -static UMutex *LOCK() { - static UMutex m = U_MUTEX_INITIALIZER; - return &m; -} +static UMutex LOCK; UOBJECT_DEFINE_RTTI_IMPLEMENTATION(SimpleDateFormat) @@ -623,7 +620,7 @@ SimpleDateFormat& SimpleDateFormat::operator=(const SimpleDateFormat& other) //---------------------------------------------------------------------- -Format* +SimpleDateFormat* SimpleDateFormat::clone() const { return new SimpleDateFormat(*this); @@ -1223,10 +1220,14 @@ _appendSymbolWithMonthPattern(UnicodeString& dst, int32_t value, const UnicodeSt //---------------------------------------------------------------------- static number::LocalizedNumberFormatter* -createFastFormatter(const DecimalFormat* df, int32_t minInt, int32_t maxInt) { - return new number::LocalizedNumberFormatter( - df->toNumberFormatter() - .integerWidth(number::IntegerWidth::zeroFillTo(minInt).truncateAt(maxInt))); +createFastFormatter(const DecimalFormat* df, int32_t minInt, int32_t maxInt, UErrorCode& status) { + const number::LocalizedNumberFormatter* lnfBase = df->toNumberFormatter(status); + if (U_FAILURE(status)) { + return nullptr; + } + return lnfBase->integerWidth( + number::IntegerWidth::zeroFillTo(minInt).truncateAt(maxInt) + ).clone().orphan(); } void SimpleDateFormat::initFastNumberFormatters(UErrorCode& status) { @@ -1237,11 +1238,11 @@ void SimpleDateFormat::initFastNumberFormatters(UErrorCode& status) { if (df == nullptr) { return; } - fFastNumberFormatters[SMPDTFMT_NF_1x10] = createFastFormatter(df, 1, 10); - fFastNumberFormatters[SMPDTFMT_NF_2x10] = createFastFormatter(df, 2, 10); - fFastNumberFormatters[SMPDTFMT_NF_3x10] = createFastFormatter(df, 3, 10); - fFastNumberFormatters[SMPDTFMT_NF_4x10] = createFastFormatter(df, 4, 10); - fFastNumberFormatters[SMPDTFMT_NF_2x2] = createFastFormatter(df, 2, 2); + fFastNumberFormatters[SMPDTFMT_NF_1x10] = createFastFormatter(df, 1, 10, status); + fFastNumberFormatters[SMPDTFMT_NF_2x10] = createFastFormatter(df, 2, 10, status); + fFastNumberFormatters[SMPDTFMT_NF_3x10] = createFastFormatter(df, 3, 10, status); + fFastNumberFormatters[SMPDTFMT_NF_4x10] = createFastFormatter(df, 4, 10, status); + fFastNumberFormatters[SMPDTFMT_NF_2x2] = createFastFormatter(df, 2, 2, status); } void SimpleDateFormat::freeFastNumberFormatters() { @@ -1266,14 +1267,14 @@ SimpleDateFormat::initNumberFormatters(const Locale &locale,UErrorCode &status) if ( fDateOverride.isBogus() && fTimeOverride.isBogus() ) { return; } - umtx_lock(LOCK()); + umtx_lock(&LOCK); if (fSharedNumberFormatters == NULL) { fSharedNumberFormatters = allocSharedNumberFormatters(); if (fSharedNumberFormatters == NULL) { status = U_MEMORY_ALLOCATION_ERROR; } } - umtx_unlock(LOCK()); + umtx_unlock(&LOCK); if (U_FAILURE(status)) { return; @@ -1980,9 +1981,11 @@ SimpleDateFormat::subFormat(UnicodeString &appendTo, break; } if (titlecase) { + BreakIterator* const mutableCapitalizationBrkIter = fCapitalizationBrkIter->clone(); UnicodeString firstField(appendTo, beginOffset); - firstField.toTitle(fCapitalizationBrkIter, fLocale, U_TITLECASE_NO_LOWERCASE | U_TITLECASE_NO_BREAK_ADJUSTMENT); + firstField.toTitle(mutableCapitalizationBrkIter, fLocale, U_TITLECASE_NO_LOWERCASE | U_TITLECASE_NO_BREAK_ADJUSTMENT); appendTo.replaceBetween(beginOffset, appendTo.length(), firstField); + delete mutableCapitalizationBrkIter; } } #endif @@ -2107,7 +2110,7 @@ SimpleDateFormat::zeroPaddingNumber( // Fall back to slow path (clone and mutate the NumberFormat) if (currentNumberFormat != nullptr) { FieldPosition pos(FieldPosition::DONT_CARE); - LocalPointer nf(dynamic_cast(currentNumberFormat->clone())); + LocalPointer nf(currentNumberFormat->clone()); nf->setMinimumIntegerDigits(minDigits); nf->setMaximumIntegerDigits(maxDigits); nf->format(value, appendTo, pos); // 3rd arg is there to speed up processing @@ -3770,7 +3773,7 @@ void SimpleDateFormat::parseInt(const UnicodeString& text, auto* fmtAsDF = dynamic_cast(fmt); LocalPointer df; if (!allowNegative && fmtAsDF != nullptr) { - df.adoptInstead(dynamic_cast(fmtAsDF->clone())); + df.adoptInstead(fmtAsDF->clone()); if (df.isNull()) { // Memory allocation error return; @@ -3901,11 +3904,11 @@ SimpleDateFormat::applyPattern(const UnicodeString& pattern) } else if (fDateOverride.isBogus() && fHasHanYearChar) { // No current override (=> no Gannen numbering) but new pattern needs it; // use procedures from initNUmberFormatters / adoptNumberFormat - umtx_lock(LOCK()); + umtx_lock(&LOCK); if (fSharedNumberFormatters == NULL) { fSharedNumberFormatters = allocSharedNumberFormatters(); } - umtx_unlock(LOCK()); + umtx_unlock(&LOCK); if (fSharedNumberFormatters != NULL) { Locale ovrLoc(fLocale.getLanguage(),fLocale.getCountry(),fLocale.getVariant(),"numbers=jpanyear"); UErrorCode status = U_ZERO_ERROR; @@ -3998,6 +4001,7 @@ void SimpleDateFormat::adoptCalendar(Calendar* calendarToAdopt) DateFormatSymbols *newSymbols = DateFormatSymbols::createForLocale(calLocale, status); if (U_FAILURE(status)) { + delete calendarToAdopt; return; } DateFormat::adoptCalendar(calendarToAdopt); @@ -4237,7 +4241,7 @@ SimpleDateFormat::skipUWhiteSpace(const UnicodeString& text, int32_t pos) const TimeZoneFormat * SimpleDateFormat::tzFormat(UErrorCode &status) const { if (fTimeZoneFormat == NULL) { - umtx_lock(LOCK()); + umtx_lock(&LOCK); { if (fTimeZoneFormat == NULL) { TimeZoneFormat *tzfmt = TimeZoneFormat::createInstance(fLocale, status); @@ -4248,7 +4252,7 @@ SimpleDateFormat::tzFormat(UErrorCode &status) const { const_cast(this)->fTimeZoneFormat = tzfmt; } } - umtx_unlock(LOCK()); + umtx_unlock(&LOCK); } return fTimeZoneFormat; } diff --git a/deps/icu-small/source/i18n/numparse_stringsegment.cpp b/deps/icu-small/source/i18n/string_segment.cpp similarity index 96% rename from deps/icu-small/source/i18n/numparse_stringsegment.cpp rename to deps/icu-small/source/i18n/string_segment.cpp index 3db4fe618a603a..5d19ac57f5e0d1 100644 --- a/deps/icu-small/source/i18n/numparse_stringsegment.cpp +++ b/deps/icu-small/source/i18n/string_segment.cpp @@ -10,14 +10,12 @@ #define UNISTR_FROM_STRING_EXPLICIT #include "numparse_types.h" -#include "numparse_stringsegment.h" +#include "string_segment.h" #include "putilimp.h" #include "unicode/utf16.h" #include "unicode/uniset.h" -using namespace icu; -using namespace icu::numparse; -using namespace icu::numparse::impl; +U_NAMESPACE_BEGIN StringSegment::StringSegment(const UnicodeString& str, bool ignoreCase) @@ -143,4 +141,5 @@ bool StringSegment::operator==(const UnicodeString& other) const { } +U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ diff --git a/deps/icu-small/source/i18n/string_segment.h b/deps/icu-small/source/i18n/string_segment.h new file mode 100644 index 00000000000000..b581f7e57599eb --- /dev/null +++ b/deps/icu-small/source/i18n/string_segment.h @@ -0,0 +1,134 @@ +// © 2018 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html + +#include "unicode/utypes.h" + +#if !UCONFIG_NO_FORMATTING +#ifndef __NUMPARSE_STRINGSEGMENT_H__ +#define __NUMPARSE_STRINGSEGMENT_H__ + +#include "unicode/unistr.h" +#include "unicode/uniset.h" + +U_NAMESPACE_BEGIN + + +/** + * A mutable UnicodeString wrapper with a variable offset and length and + * support for case folding. The charAt, length, and subSequence methods all + * operate relative to the fixed offset into the UnicodeString. + * + * Intended to be useful for parsing. + * + * CAUTION: Since this class is mutable, it must not be used anywhere that an + * immutable object is required, like in a cache or as the key of a hash map. + * + * @author sffc (Shane Carr) + */ +// Exported as U_I18N_API for tests +class U_I18N_API StringSegment : public UMemory { + public: + StringSegment(const UnicodeString& str, bool ignoreCase); + + int32_t getOffset() const; + + void setOffset(int32_t start); + + /** + * Equivalent to setOffset(getOffset()+delta). + * + *

+ * This method is usually called by a Matcher to register that a char was consumed. If the char is + * strong (it usually is, except for things like whitespace), follow this with a call to + * {@link ParsedNumber#setCharsConsumed}. For more information on strong chars, see that method. + */ + void adjustOffset(int32_t delta); + + /** + * Adjusts the offset by the width of the current code point, either 1 or 2 chars. + */ + void adjustOffsetByCodePoint(); + + void setLength(int32_t length); + + void resetLength(); + + int32_t length() const; + + char16_t charAt(int32_t index) const; + + UChar32 codePointAt(int32_t index) const; + + UnicodeString toUnicodeString() const; + + const UnicodeString toTempUnicodeString() const; + + /** + * Returns the first code point in the string segment, or -1 if the string starts with an invalid + * code point. + * + *

+ * Important: Most of the time, you should use {@link #startsWith}, which handles case + * folding logic, instead of this method. + */ + UChar32 getCodePoint() const; + + /** + * Returns true if the first code point of this StringSegment equals the given code point. + * + *

+ * This method will perform case folding if case folding is enabled for the parser. + */ + bool startsWith(UChar32 otherCp) const; + + /** + * Returns true if the first code point of this StringSegment is in the given UnicodeSet. + */ + bool startsWith(const UnicodeSet& uniset) const; + + /** + * Returns true if there is at least one code point of overlap between this StringSegment and the + * given UnicodeString. + */ + bool startsWith(const UnicodeString& other) const; + + /** + * Returns the length of the prefix shared by this StringSegment and the given UnicodeString. For + * example, if this string segment is "aab", and the char sequence is "aac", this method returns 2, + * since the first 2 characters are the same. + * + *

+ * This method only returns offsets along code point boundaries. + * + *

+ * This method will perform case folding if case folding was enabled in the constructor. + * + *

+ * IMPORTANT: The given UnicodeString must not be empty! It is the caller's responsibility to check. + */ + int32_t getCommonPrefixLength(const UnicodeString& other); + + /** + * Like {@link #getCommonPrefixLength}, but never performs case folding, even if case folding is + * enabled for the parser. + */ + int32_t getCaseSensitivePrefixLength(const UnicodeString& other); + + bool operator==(const UnicodeString& other) const; + + private: + const UnicodeString& fStr; + int32_t fStart; + int32_t fEnd; + bool fFoldCase; + + int32_t getPrefixLengthInternal(const UnicodeString& other, bool foldCase); + + static bool codePointsEqual(UChar32 cp1, UChar32 cp2, bool foldCase); +}; + + +U_NAMESPACE_END + +#endif //__NUMPARSE_STRINGSEGMENT_H__ +#endif /* #if !UCONFIG_NO_FORMATTING */ diff --git a/deps/icu-small/source/i18n/strmatch.cpp b/deps/icu-small/source/i18n/strmatch.cpp index d5b018aa6b62b6..97c0fba6f1ddb7 100644 --- a/deps/icu-small/source/i18n/strmatch.cpp +++ b/deps/icu-small/source/i18n/strmatch.cpp @@ -58,7 +58,7 @@ StringMatcher::~StringMatcher() { /** * Implement UnicodeFunctor */ -UnicodeFunctor* StringMatcher::clone() const { +StringMatcher* StringMatcher::clone() const { return new StringMatcher(*this); } diff --git a/deps/icu-small/source/i18n/strmatch.h b/deps/icu-small/source/i18n/strmatch.h index 7152a24a0765e4..09d04ede13e61a 100644 --- a/deps/icu-small/source/i18n/strmatch.h +++ b/deps/icu-small/source/i18n/strmatch.h @@ -78,7 +78,7 @@ class StringMatcher : public UnicodeFunctor, public UnicodeMatcher, public Unico * Implement UnicodeFunctor * @return a copy of the object. */ - virtual UnicodeFunctor* clone() const; + virtual StringMatcher* clone() const; /** * UnicodeFunctor API. Cast 'this' to a UnicodeMatcher* pointer diff --git a/deps/icu-small/source/i18n/strrepl.cpp b/deps/icu-small/source/i18n/strrepl.cpp index 132c844c2dff27..e9e71ee540606a 100644 --- a/deps/icu-small/source/i18n/strrepl.cpp +++ b/deps/icu-small/source/i18n/strrepl.cpp @@ -87,7 +87,7 @@ StringReplacer::~StringReplacer() { /** * Implement UnicodeFunctor */ -UnicodeFunctor* StringReplacer::clone() const { +StringReplacer* StringReplacer::clone() const { return new StringReplacer(*this); } diff --git a/deps/icu-small/source/i18n/strrepl.h b/deps/icu-small/source/i18n/strrepl.h index feec058152a8a3..7f74d0d94507f6 100644 --- a/deps/icu-small/source/i18n/strrepl.h +++ b/deps/icu-small/source/i18n/strrepl.h @@ -111,7 +111,7 @@ class StringReplacer : public UnicodeFunctor, public UnicodeReplacer { /** * Implement UnicodeFunctor */ - virtual UnicodeFunctor* clone() const; + virtual StringReplacer* clone() const; /** * UnicodeFunctor API. Cast 'this' to a UnicodeReplacer* pointer diff --git a/deps/icu-small/source/i18n/stsearch.cpp b/deps/icu-small/source/i18n/stsearch.cpp index bf4d80b6db8ed0..32481a14004075 100644 --- a/deps/icu-small/source/i18n/stsearch.cpp +++ b/deps/icu-small/source/i18n/stsearch.cpp @@ -282,7 +282,7 @@ void StringSearch::reset() usearch_reset(m_strsrch_); } -SearchIterator * StringSearch::safeClone(void) const +StringSearch * StringSearch::safeClone() const { UErrorCode status = U_ZERO_ERROR; StringSearch *result = new StringSearch(m_pattern_, m_text_, diff --git a/deps/icu-small/source/i18n/taiwncal.cpp b/deps/icu-small/source/i18n/taiwncal.cpp index e2757dbd550dd9..1a6a0e2e78d201 100644 --- a/deps/icu-small/source/i18n/taiwncal.cpp +++ b/deps/icu-small/source/i18n/taiwncal.cpp @@ -53,7 +53,7 @@ TaiwanCalendar& TaiwanCalendar::operator= ( const TaiwanCalendar& right) return *this; } -Calendar* TaiwanCalendar::clone(void) const +TaiwanCalendar* TaiwanCalendar::clone() const { return new TaiwanCalendar(*this); } diff --git a/deps/icu-small/source/i18n/taiwncal.h b/deps/icu-small/source/i18n/taiwncal.h index 99bbfb53f2b1ab..daadc124f40a18 100644 --- a/deps/icu-small/source/i18n/taiwncal.h +++ b/deps/icu-small/source/i18n/taiwncal.h @@ -91,7 +91,7 @@ class TaiwanCalendar : public GregorianCalendar { * @return return a polymorphic copy of this calendar. * @internal */ - virtual Calendar* clone(void) const; + virtual TaiwanCalendar* clone() const; public: /** diff --git a/deps/icu-small/source/i18n/timezone.cpp b/deps/icu-small/source/i18n/timezone.cpp index 70169b5c1f576d..b90b78614aa00f 100644 --- a/deps/icu-small/source/i18n/timezone.cpp +++ b/deps/icu-small/source/i18n/timezone.cpp @@ -527,6 +527,8 @@ TimeZone::detectHostTimeZone() // ------------------------------------- +static UMutex gDefaultZoneMutex; + /** * Initialize DEFAULT_ZONE from the system default time zone. * Upon return, DEFAULT_ZONE will not be NULL, unless operator new() @@ -536,6 +538,7 @@ static void U_CALLCONV initDefault() { ucln_i18n_registerCleanup(UCLN_I18N_TIMEZONE, timeZone_cleanup); + Mutex lock(&gDefaultZoneMutex); // If setDefault() has already been called we can skip getting the // default zone information from the system. if (DEFAULT_ZONE != NULL) { @@ -557,9 +560,6 @@ static void U_CALLCONV initDefault() TimeZone *default_zone = TimeZone::detectHostTimeZone(); - // The only way for DEFAULT_ZONE to be non-null at this point is if the user - // made a thread-unsafe call to setDefault() or adoptDefault() in another - // thread while this thread was doing something that required getting the default. U_ASSERT(DEFAULT_ZONE == NULL); DEFAULT_ZONE = default_zone; @@ -571,7 +571,10 @@ TimeZone* U_EXPORT2 TimeZone::createDefault() { umtx_initOnce(gDefaultZoneInitOnce, initDefault); - return (DEFAULT_ZONE != NULL) ? DEFAULT_ZONE->clone() : NULL; + { + Mutex lock(&gDefaultZoneMutex); + return (DEFAULT_ZONE != NULL) ? DEFAULT_ZONE->clone() : NULL; + } } // ------------------------------------- @@ -581,9 +584,12 @@ TimeZone::adoptDefault(TimeZone* zone) { if (zone != NULL) { - TimeZone *old = DEFAULT_ZONE; - DEFAULT_ZONE = zone; - delete old; + { + Mutex lock(&gDefaultZoneMutex); + TimeZone *old = DEFAULT_ZONE; + DEFAULT_ZONE = zone; + delete old; + } ucln_i18n_registerCleanup(UCLN_I18N_TIMEZONE, timeZone_cleanup); } } diff --git a/deps/icu-small/source/i18n/titletrn.cpp b/deps/icu-small/source/i18n/titletrn.cpp index 4e75c824a0f7f1..a6beac214915cc 100644 --- a/deps/icu-small/source/i18n/titletrn.cpp +++ b/deps/icu-small/source/i18n/titletrn.cpp @@ -60,7 +60,7 @@ TitlecaseTransliterator::TitlecaseTransliterator(const TitlecaseTransliterator& /** * Transliterator API. */ -Transliterator* TitlecaseTransliterator::clone(void) const { +TitlecaseTransliterator* TitlecaseTransliterator::clone() const { return new TitlecaseTransliterator(*this); } diff --git a/deps/icu-small/source/i18n/titletrn.h b/deps/icu-small/source/i18n/titletrn.h index 166378fe9da5c2..4e45ac6f81fabc 100644 --- a/deps/icu-small/source/i18n/titletrn.h +++ b/deps/icu-small/source/i18n/titletrn.h @@ -52,7 +52,7 @@ class TitlecaseTransliterator : public CaseMapTransliterator { * Transliterator API. * @return a copy of the object. */ - virtual Transliterator* clone(void) const; + virtual TitlecaseTransliterator* clone() const; /** * ICU "poor man's RTTI", returns a UClassID for the actual class. diff --git a/deps/icu-small/source/i18n/tmunit.cpp b/deps/icu-small/source/i18n/tmunit.cpp index 3e980105153da5..b96dfbb5726b6f 100644 --- a/deps/icu-small/source/i18n/tmunit.cpp +++ b/deps/icu-small/source/i18n/tmunit.cpp @@ -102,7 +102,7 @@ TimeUnit::TimeUnit(const TimeUnit& other) : MeasureUnit(other), fTimeUnitField(other.fTimeUnitField) { } -UObject* +TimeUnit* TimeUnit::clone() const { return new TimeUnit(*this); } diff --git a/deps/icu-small/source/i18n/tmutamt.cpp b/deps/icu-small/source/i18n/tmutamt.cpp index 0e2b91fbb2bb6f..a143bcf8f7c2ac 100644 --- a/deps/icu-small/source/i18n/tmutamt.cpp +++ b/deps/icu-small/source/i18n/tmutamt.cpp @@ -50,7 +50,7 @@ TimeUnitAmount::operator==(const UObject& other) const { return Measure::operator==(other); } -UObject* +TimeUnitAmount* TimeUnitAmount::clone() const { return new TimeUnitAmount(*this); } diff --git a/deps/icu-small/source/i18n/tmutfmt.cpp b/deps/icu-small/source/i18n/tmutfmt.cpp index dad8825e70ff33..231ea5799c3764 100644 --- a/deps/icu-small/source/i18n/tmutfmt.cpp +++ b/deps/icu-small/source/i18n/tmutfmt.cpp @@ -136,8 +136,8 @@ TimeUnitFormat::~TimeUnitFormat() { } -Format* -TimeUnitFormat::clone(void) const { +TimeUnitFormat* +TimeUnitFormat::clone() const { return new TimeUnitFormat(*this); } @@ -685,7 +685,7 @@ TimeUnitFormat::setNumberFormat(const NumberFormat& format, UErrorCode& status){ if (U_FAILURE(status)) { return; } - adoptNumberFormat((NumberFormat *)format.clone(), status); + adoptNumberFormat(format.clone(), status); } @@ -721,8 +721,8 @@ TimeUnitFormat::copyHash(const Hashtable* source, Hashtable* target, UErrorCode& const UHashTok valueTok = element->value; const MessageFormat** value = (const MessageFormat**)valueTok.pointer; MessageFormat** newVal = (MessageFormat**)uprv_malloc(UTMUTFMT_FORMAT_STYLE_COUNT*sizeof(MessageFormat*)); - newVal[0] = (MessageFormat*)value[0]->clone(); - newVal[1] = (MessageFormat*)value[1]->clone(); + newVal[0] = value[0]->clone(); + newVal[1] = value[1]->clone(); target->put(UnicodeString(*key), newVal, status); if ( U_FAILURE(status) ) { delete newVal[0]; diff --git a/deps/icu-small/source/i18n/tolowtrn.cpp b/deps/icu-small/source/i18n/tolowtrn.cpp index 063cc88d1c40ce..02ec05cd52ad7a 100644 --- a/deps/icu-small/source/i18n/tolowtrn.cpp +++ b/deps/icu-small/source/i18n/tolowtrn.cpp @@ -58,7 +58,7 @@ LowercaseTransliterator::LowercaseTransliterator(const LowercaseTransliterator& /** * Transliterator API. */ -Transliterator* LowercaseTransliterator::clone(void) const { +LowercaseTransliterator* LowercaseTransliterator::clone() const { return new LowercaseTransliterator(*this); } diff --git a/deps/icu-small/source/i18n/tolowtrn.h b/deps/icu-small/source/i18n/tolowtrn.h index e311431224e5c2..2fbfb90e1bface 100644 --- a/deps/icu-small/source/i18n/tolowtrn.h +++ b/deps/icu-small/source/i18n/tolowtrn.h @@ -50,7 +50,7 @@ class LowercaseTransliterator : public CaseMapTransliterator { * Transliterator API. * @return a copy of the object. */ - virtual Transliterator* clone(void) const; + virtual LowercaseTransliterator* clone() const; /** * ICU "poor man's RTTI", returns a UClassID for the actual class. diff --git a/deps/icu-small/source/i18n/toupptrn.cpp b/deps/icu-small/source/i18n/toupptrn.cpp index 098dba9a3ce4f9..2a8b78b9a69d2f 100644 --- a/deps/icu-small/source/i18n/toupptrn.cpp +++ b/deps/icu-small/source/i18n/toupptrn.cpp @@ -58,7 +58,7 @@ UppercaseTransliterator::UppercaseTransliterator(const UppercaseTransliterator& /** * Transliterator API. */ -Transliterator* UppercaseTransliterator::clone(void) const { +UppercaseTransliterator* UppercaseTransliterator::clone() const { return new UppercaseTransliterator(*this); } diff --git a/deps/icu-small/source/i18n/toupptrn.h b/deps/icu-small/source/i18n/toupptrn.h index 677a04e5c771a9..e96ca8f0ba530a 100644 --- a/deps/icu-small/source/i18n/toupptrn.h +++ b/deps/icu-small/source/i18n/toupptrn.h @@ -50,7 +50,7 @@ class UppercaseTransliterator : public CaseMapTransliterator { * Transliterator API. * @return a copy of the object. */ - virtual Transliterator* clone(void) const; + virtual UppercaseTransliterator* clone() const; /** * ICU "poor man's RTTI", returns a UClassID for the actual class. diff --git a/deps/icu-small/source/i18n/translit.cpp b/deps/icu-small/source/i18n/translit.cpp index 9f5563b4796c19..039acaf157cc93 100644 --- a/deps/icu-small/source/i18n/translit.cpp +++ b/deps/icu-small/source/i18n/translit.cpp @@ -91,10 +91,7 @@ static const char RB_RULE_BASED_IDS[] = "RuleBasedTransliteratorIDs"; /** * The mutex controlling access to registry object. */ -static icu::UMutex *registryMutex() { - static icu::UMutex m = U_MUTEX_INITIALIZER; - return &m; -} +static icu::UMutex registryMutex; /** * System transliterator registry; non-null when initialized. @@ -161,7 +158,7 @@ Transliterator::Transliterator(const Transliterator& other) : if (other.filter != 0) { // We own the filter, so we must have our own copy - filter = (UnicodeFilter*) other.filter->clone(); + filter = other.filter->clone(); } } @@ -178,7 +175,7 @@ Transliterator& Transliterator::operator=(const Transliterator& other) { ID.getTerminatedBuffer(); maximumContextLength = other.maximumContextLength; - adoptFilter((other.filter == 0) ? 0 : (UnicodeFilter*) other.filter->clone()); + adoptFilter((other.filter == 0) ? 0 : other.filter->clone()); return *this; } @@ -926,13 +923,15 @@ Transliterator::createInstance(const UnicodeString& ID, return NULL; } - UnicodeSet* globalFilter; + UnicodeSet* globalFilter = nullptr; // TODO add code for parseError...currently unused, but // later may be used by parsing code... if (!TransliteratorIDParser::parseCompoundID(ID, dir, canonID, list, globalFilter)) { status = U_INVALID_ID; + delete globalFilter; return NULL; } + LocalPointer lpGlobalFilter(globalFilter); TransliteratorIDParser::instantiateList(list, status); if (U_FAILURE(status)) { @@ -956,8 +955,8 @@ Transliterator::createInstance(const UnicodeString& ID, // Check null pointer if (t != NULL) { t->setID(canonID); - if (globalFilter != NULL) { - t->adoptFilter(globalFilter); + if (lpGlobalFilter.isValid()) { + t->adoptFilter(lpGlobalFilter.orphan()); } } else if (U_SUCCESS(status)) { @@ -981,11 +980,11 @@ Transliterator* Transliterator::createBasicInstance(const UnicodeString& id, TransliteratorAlias* alias = 0; Transliterator* t = 0; - umtx_lock(registryMutex()); + umtx_lock(®istryMutex); if (HAVE_REGISTRY(ec)) { t = registry->get(id, alias, ec); } - umtx_unlock(registryMutex()); + umtx_unlock(®istryMutex); if (U_FAILURE(ec)) { delete t; @@ -1013,11 +1012,11 @@ Transliterator* Transliterator::createBasicInstance(const UnicodeString& id, alias = 0; // Step 2. reget - umtx_lock(registryMutex()); + umtx_lock(®istryMutex); if (HAVE_REGISTRY(ec)) { t = registry->reget(id, parser, alias, ec); } - umtx_unlock(registryMutex()); + umtx_unlock(®istryMutex); // Step 3. Loop back around! } else { @@ -1104,6 +1103,10 @@ Transliterator::createFromRules(const UnicodeString& ID, UnicodeString* idBlock = (UnicodeString*)parser.idBlockVector.elementAt(i); if (!idBlock->isEmpty()) { Transliterator* temp = createInstance(*idBlock, UTRANS_FORWARD, parseError, status); + if (U_FAILURE(status)) { + delete temp; + return nullptr; + } if (temp != NULL && typeid(*temp) != typeid(NullTransliterator)) transliterators.addElement(temp, status); else @@ -1117,8 +1120,10 @@ Transliterator::createFromRules(const UnicodeString& ID, data, TRUE); // Check if NULL before adding it to transliterators to avoid future usage of NULL pointer. if (temprbt == NULL) { - status = U_MEMORY_ALLOCATION_ERROR; - return t; + if (U_SUCCESS(status)) { + status = U_MEMORY_ALLOCATION_ERROR; + } + return t; } transliterators.addElement(temprbt, status); } @@ -1215,7 +1220,7 @@ UnicodeSet& Transliterator::getTargetSet(UnicodeSet& result) const { void U_EXPORT2 Transliterator::registerFactory(const UnicodeString& id, Transliterator::Factory factory, Transliterator::Token context) { - Mutex lock(registryMutex()); + Mutex lock(®istryMutex); UErrorCode ec = U_ZERO_ERROR; if (HAVE_REGISTRY(ec)) { _registerFactory(id, factory, context); @@ -1254,7 +1259,7 @@ void Transliterator::_registerSpecialInverse(const UnicodeString& target, * @see #unregister */ void U_EXPORT2 Transliterator::registerInstance(Transliterator* adoptedPrototype) { - Mutex lock(registryMutex()); + Mutex lock(®istryMutex); UErrorCode ec = U_ZERO_ERROR; if (HAVE_REGISTRY(ec)) { _registerInstance(adoptedPrototype); @@ -1268,7 +1273,7 @@ void Transliterator::_registerInstance(Transliterator* adoptedPrototype) { void U_EXPORT2 Transliterator::registerAlias(const UnicodeString& aliasID, const UnicodeString& realID) { - Mutex lock(registryMutex()); + Mutex lock(®istryMutex); UErrorCode ec = U_ZERO_ERROR; if (HAVE_REGISTRY(ec)) { _registerAlias(aliasID, realID); @@ -1290,7 +1295,7 @@ void Transliterator::_registerAlias(const UnicodeString& aliasID, */ void U_EXPORT2 Transliterator::unregister(const UnicodeString& ID) { - Mutex lock(registryMutex()); + Mutex lock(®istryMutex); UErrorCode ec = U_ZERO_ERROR; if (HAVE_REGISTRY(ec)) { registry->remove(ID); @@ -1305,7 +1310,7 @@ void U_EXPORT2 Transliterator::unregister(const UnicodeString& ID) { */ int32_t U_EXPORT2 Transliterator::countAvailableIDs(void) { int32_t retVal = 0; - Mutex lock(registryMutex()); + Mutex lock(®istryMutex); UErrorCode ec = U_ZERO_ERROR; if (HAVE_REGISTRY(ec)) { retVal = registry->countAvailableIDs(); @@ -1321,12 +1326,12 @@ int32_t U_EXPORT2 Transliterator::countAvailableIDs(void) { */ const UnicodeString& U_EXPORT2 Transliterator::getAvailableID(int32_t index) { const UnicodeString* result = NULL; - umtx_lock(registryMutex()); + umtx_lock(®istryMutex); UErrorCode ec = U_ZERO_ERROR; if (HAVE_REGISTRY(ec)) { result = ®istry->getAvailableID(index); } - umtx_unlock(registryMutex()); + umtx_unlock(®istryMutex); U_ASSERT(result != NULL); // fail if no registry return *result; } @@ -1334,11 +1339,11 @@ const UnicodeString& U_EXPORT2 Transliterator::getAvailableID(int32_t index) { StringEnumeration* U_EXPORT2 Transliterator::getAvailableIDs(UErrorCode& ec) { if (U_FAILURE(ec)) return NULL; StringEnumeration* result = NULL; - umtx_lock(registryMutex()); + umtx_lock(®istryMutex); if (HAVE_REGISTRY(ec)) { result = registry->getAvailableIDs(); } - umtx_unlock(registryMutex()); + umtx_unlock(®istryMutex); if (result == NULL) { ec = U_INTERNAL_TRANSLITERATOR_ERROR; } @@ -1346,14 +1351,14 @@ StringEnumeration* U_EXPORT2 Transliterator::getAvailableIDs(UErrorCode& ec) { } int32_t U_EXPORT2 Transliterator::countAvailableSources(void) { - Mutex lock(registryMutex()); + Mutex lock(®istryMutex); UErrorCode ec = U_ZERO_ERROR; return HAVE_REGISTRY(ec) ? _countAvailableSources() : 0; } UnicodeString& U_EXPORT2 Transliterator::getAvailableSource(int32_t index, UnicodeString& result) { - Mutex lock(registryMutex()); + Mutex lock(®istryMutex); UErrorCode ec = U_ZERO_ERROR; if (HAVE_REGISTRY(ec)) { _getAvailableSource(index, result); @@ -1362,7 +1367,7 @@ UnicodeString& U_EXPORT2 Transliterator::getAvailableSource(int32_t index, } int32_t U_EXPORT2 Transliterator::countAvailableTargets(const UnicodeString& source) { - Mutex lock(registryMutex()); + Mutex lock(®istryMutex); UErrorCode ec = U_ZERO_ERROR; return HAVE_REGISTRY(ec) ? _countAvailableTargets(source) : 0; } @@ -1370,7 +1375,7 @@ int32_t U_EXPORT2 Transliterator::countAvailableTargets(const UnicodeString& sou UnicodeString& U_EXPORT2 Transliterator::getAvailableTarget(int32_t index, const UnicodeString& source, UnicodeString& result) { - Mutex lock(registryMutex()); + Mutex lock(®istryMutex); UErrorCode ec = U_ZERO_ERROR; if (HAVE_REGISTRY(ec)) { _getAvailableTarget(index, source, result); @@ -1380,7 +1385,7 @@ UnicodeString& U_EXPORT2 Transliterator::getAvailableTarget(int32_t index, int32_t U_EXPORT2 Transliterator::countAvailableVariants(const UnicodeString& source, const UnicodeString& target) { - Mutex lock(registryMutex()); + Mutex lock(®istryMutex); UErrorCode ec = U_ZERO_ERROR; return HAVE_REGISTRY(ec) ? _countAvailableVariants(source, target) : 0; } @@ -1389,7 +1394,7 @@ UnicodeString& U_EXPORT2 Transliterator::getAvailableVariant(int32_t index, const UnicodeString& source, const UnicodeString& target, UnicodeString& result) { - Mutex lock(registryMutex()); + Mutex lock(®istryMutex); UErrorCode ec = U_ZERO_ERROR; if (HAVE_REGISTRY(ec)) { _getAvailableVariant(index, source, target, result); diff --git a/deps/icu-small/source/i18n/transreg.cpp b/deps/icu-small/source/i18n/transreg.cpp index 032a73fd146559..8c90effcc2a348 100644 --- a/deps/icu-small/source/i18n/transreg.cpp +++ b/deps/icu-small/source/i18n/transreg.cpp @@ -131,7 +131,7 @@ Transliterator* TransliteratorAlias::create(UParseError& pe, return 0; } if (compoundFilter != 0) - t->adoptFilter((UnicodeSet*)compoundFilter->clone()); + t->adoptFilter(compoundFilter->clone()); break; case COMPOUND: { @@ -173,8 +173,8 @@ Transliterator* TransliteratorAlias::create(UParseError& pe, if (U_SUCCESS(ec)) { t = new CompoundTransliterator(ID, transliterators, - (compoundFilter ? (UnicodeSet*)(compoundFilter->clone()) : 0), - anonymousRBTs, pe, ec); + (compoundFilter ? compoundFilter->clone() : nullptr), + anonymousRBTs, pe, ec); if (t == 0) { ec = U_MEMORY_ALLOCATION_ERROR; return 0; @@ -946,7 +946,7 @@ void TransliteratorRegistry::registerEntry(const UnicodeString& ID, if (visible) { registerSTV(source, target, variant); if (!availableIDs.contains((void*) &ID)) { - UnicodeString *newID = (UnicodeString *)ID.clone(); + UnicodeString *newID = ID.clone(); // Check to make sure newID was created. if (newID != NULL) { // NUL-terminate the ID string diff --git a/deps/icu-small/source/i18n/tridpars.cpp b/deps/icu-small/source/i18n/tridpars.cpp index cbfdf03c427850..eb6c6bbba3a9a9 100644 --- a/deps/icu-small/source/i18n/tridpars.cpp +++ b/deps/icu-small/source/i18n/tridpars.cpp @@ -50,10 +50,7 @@ static UInitOnce gSpecialInversesInitOnce = U_INITONCE_INITIALIZER; /** * The mutex controlling access to SPECIAL_INVERSES */ -static UMutex *LOCK() { - static UMutex m = U_MUTEX_INITIALIZER; - return &m; -} +static UMutex LOCK; TransliteratorIDParser::Specs::Specs(const UnicodeString& s, const UnicodeString& t, const UnicodeString& v, UBool sawS, @@ -297,6 +294,7 @@ UnicodeSet* TransliteratorIDParser::parseGlobalFilter(const UnicodeString& id, i pos = ppos.getIndex(); if (withParens == 1 && !ICU_Utility::parseChar(id, pos, CLOSE_REV)) { + delete filter; pos = start; return NULL; } @@ -662,7 +660,7 @@ void TransliteratorIDParser::registerSpecialInverse(const UnicodeString& target, bidirectional = FALSE; } - Mutex lock(LOCK()); + Mutex lock(&LOCK); UnicodeString *tempus = new UnicodeString(inverseTarget); // Used for null pointer check before usage. if (tempus == NULL) { @@ -866,9 +864,9 @@ TransliteratorIDParser::specsToSpecialInverse(const Specs& specs, UErrorCode &st UnicodeString* inverseTarget; - umtx_lock(LOCK()); + umtx_lock(&LOCK); inverseTarget = (UnicodeString*) SPECIAL_INVERSES->get(specs.target); - umtx_unlock(LOCK()); + umtx_unlock(&LOCK); if (inverseTarget != NULL) { // If the original ID contained "Any-" then make the diff --git a/deps/icu-small/source/i18n/tzfmt.cpp b/deps/icu-small/source/i18n/tzfmt.cpp index c948c5f5e7b07c..267d507aa7eca6 100644 --- a/deps/icu-small/source/i18n/tzfmt.cpp +++ b/deps/icu-small/source/i18n/tzfmt.cpp @@ -19,12 +19,15 @@ #include "unicode/udat.h" #include "unicode/ustring.h" #include "unicode/utf16.h" +#include "bytesinkutil.h" +#include "charstr.h" #include "tzgnames.h" #include "cmemory.h" #include "cstring.h" #include "putilimp.h" #include "uassert.h" #include "ucln_in.h" +#include "ulocimp.h" #include "umutex.h" #include "uresimp.h" #include "ureslocs.h" @@ -147,10 +150,7 @@ static icu::UInitOnce gZoneIdTrieInitOnce = U_INITONCE_INITIALIZER; static TextTrieMap *gShortZoneIdTrie = NULL; static icu::UInitOnce gShortZoneIdTrieInitOnce = U_INITONCE_INITIALIZER; -static UMutex *gLock() { - static UMutex m = U_MUTEX_INITIALIZER; - return &m; -} +static UMutex gLock; U_CDECL_BEGIN /** @@ -327,10 +327,13 @@ TimeZoneFormat::TimeZoneFormat(const Locale& locale, UErrorCode& status) const char* region = fLocale.getCountry(); int32_t regionLen = static_cast(uprv_strlen(region)); if (regionLen == 0) { - char loc[ULOC_FULLNAME_CAPACITY]; - uloc_addLikelySubtags(fLocale.getName(), loc, sizeof(loc), &status); + CharString loc; + { + CharStringByteSink sink(&loc); + ulocimp_addLikelySubtags(fLocale.getName(), sink, &status); + } - regionLen = uloc_getCountry(loc, fTargetRegion, sizeof(fTargetRegion), &status); + regionLen = uloc_getCountry(loc.data(), fTargetRegion, sizeof(fTargetRegion), &status); if (U_SUCCESS(status)) { fTargetRegion[regionLen] = 0; } else { @@ -502,7 +505,7 @@ TimeZoneFormat::operator==(const Format& other) const { return isEqual; } -Format* +TimeZoneFormat* TimeZoneFormat::clone() const { return new TimeZoneFormat(*this); } @@ -1385,12 +1388,12 @@ TimeZoneFormat::getTimeZoneGenericNames(UErrorCode& status) const { return NULL; } - umtx_lock(gLock()); + umtx_lock(&gLock); if (fTimeZoneGenericNames == NULL) { TimeZoneFormat *nonConstThis = const_cast(this); nonConstThis->fTimeZoneGenericNames = TimeZoneGenericNames::createInstance(fLocale, status); } - umtx_unlock(gLock()); + umtx_unlock(&gLock); return fTimeZoneGenericNames; } @@ -1401,7 +1404,7 @@ TimeZoneFormat::getTZDBTimeZoneNames(UErrorCode& status) const { return NULL; } - umtx_lock(gLock()); + umtx_lock(&gLock); if (fTZDBTimeZoneNames == NULL) { TZDBTimeZoneNames *tzdbNames = new TZDBTimeZoneNames(fLocale); if (tzdbNames == NULL) { @@ -1411,7 +1414,7 @@ TimeZoneFormat::getTZDBTimeZoneNames(UErrorCode& status) const { nonConstThis->fTZDBTimeZoneNames = tzdbNames; } } - umtx_unlock(gLock()); + umtx_unlock(&gLock); return fTZDBTimeZoneNames; } @@ -1875,7 +1878,7 @@ TimeZoneFormat::parseOffsetFieldsWithPattern(const UnicodeString& text, int32_t while (len > 0) { UChar32 ch; int32_t chLen; - U16_GET(patStr, 0, 0, len, ch) + U16_GET(patStr, 0, 0, len, ch); if (PatternProps::isWhiteSpace(ch)) { chLen = U16_LENGTH(ch); len -= chLen; diff --git a/deps/icu-small/source/i18n/tzgnames.cpp b/deps/icu-small/source/i18n/tzgnames.cpp index 4e3ecb4c6073b8..e056461dc30a63 100644 --- a/deps/icu-small/source/i18n/tzgnames.cpp +++ b/deps/icu-small/source/i18n/tzgnames.cpp @@ -21,12 +21,15 @@ #include "unicode/strenum.h" #include "unicode/vtzone.h" +#include "bytesinkutil.h" +#include "charstr.h" #include "cmemory.h" #include "cstring.h" #include "mutex.h" #include "uhash.h" #include "uassert.h" #include "umutex.h" +#include "ulocimp.h" #include "uresimp.h" #include "ureslocs.h" #include "zonemeta.h" @@ -269,10 +272,7 @@ GNameSearchHandler::getMatches(int32_t& maxMatchLen) { return results; } -static UMutex *gLock() { - static UMutex m = U_MUTEX_INITIALIZER; - return &m; -} +static UMutex gLock; class TZGNCore : public UMemory { public: @@ -412,10 +412,13 @@ TZGNCore::initialize(const Locale& locale, UErrorCode& status) { const char* region = fLocale.getCountry(); int32_t regionLen = static_cast(uprv_strlen(region)); if (regionLen == 0) { - char loc[ULOC_FULLNAME_CAPACITY]; - uloc_addLikelySubtags(fLocale.getName(), loc, sizeof(loc), &status); + CharString loc; + { + CharStringByteSink sink(&loc); + ulocimp_addLikelySubtags(fLocale.getName(), sink, &status); + } - regionLen = uloc_getCountry(loc, fTargetRegion, sizeof(fTargetRegion), &status); + regionLen = uloc_getCountry(loc.data(), fTargetRegion, sizeof(fTargetRegion), &status); if (U_SUCCESS(status)) { fTargetRegion[regionLen] = 0; } else { @@ -488,11 +491,11 @@ TZGNCore::getGenericLocationName(const UnicodeString& tzCanonicalID, UnicodeStri const UChar *locname = NULL; TZGNCore *nonConstThis = const_cast(this); - umtx_lock(gLock()); + umtx_lock(&gLock); { locname = nonConstThis->getGenericLocationName(tzCanonicalID); } - umtx_unlock(gLock()); + umtx_unlock(&gLock); if (locname == NULL) { name.setToBogus(); @@ -743,11 +746,11 @@ TZGNCore::getPartialLocationName(const UnicodeString& tzCanonicalID, const UChar *uplname = NULL; TZGNCore *nonConstThis = const_cast(this); - umtx_lock(gLock()); + umtx_lock(&gLock); { uplname = nonConstThis->getPartialLocationName(tzCanonicalID, mzID, isLong, mzDisplayName); } - umtx_unlock(gLock()); + umtx_unlock(&gLock); if (uplname == NULL) { name.setToBogus(); @@ -1010,11 +1013,11 @@ TZGNCore::findLocal(const UnicodeString& text, int32_t start, uint32_t types, UE TZGNCore *nonConstThis = const_cast(this); - umtx_lock(gLock()); + umtx_lock(&gLock); { fGNamesTrie.search(text, start, (TextTrieMapSearchResultHandler *)&handler, status); } - umtx_unlock(gLock()); + umtx_unlock(&gLock); if (U_FAILURE(status)) { return NULL; @@ -1041,7 +1044,7 @@ TZGNCore::findLocal(const UnicodeString& text, int32_t start, uint32_t types, UE // All names are not yet loaded into the local trie. // Load all available names into the trie. This could be very heavy. - umtx_lock(gLock()); + umtx_lock(&gLock); { if (!fGNamesTrieFullyLoaded) { StringEnumeration *tzIDs = TimeZone::createTimeZoneIDEnumeration(UCAL_ZONE_TYPE_CANONICAL, NULL, NULL, status); @@ -1063,18 +1066,18 @@ TZGNCore::findLocal(const UnicodeString& text, int32_t start, uint32_t types, UE } } } - umtx_unlock(gLock()); + umtx_unlock(&gLock); if (U_FAILURE(status)) { return NULL; } - umtx_lock(gLock()); + umtx_lock(&gLock); { // now try it again fGNamesTrie.search(text, start, (TextTrieMapSearchResultHandler *)&handler, status); } - umtx_unlock(gLock()); + umtx_unlock(&gLock); results = handler.getMatches(maxLen); if (results != NULL && maxLen > 0) { @@ -1115,10 +1118,7 @@ typedef struct TZGNCoreRef { } TZGNCoreRef; // TZGNCore object cache handling -static UMutex *gTZGNLock() { - static UMutex m = U_MUTEX_INITIALIZER; - return &m; -} +static UMutex gTZGNLock; static UHashtable *gTZGNCoreCache = NULL; static UBool gTZGNCoreCacheInitialized = FALSE; @@ -1184,13 +1184,13 @@ TimeZoneGenericNames::TimeZoneGenericNames() } TimeZoneGenericNames::~TimeZoneGenericNames() { - umtx_lock(gTZGNLock()); + umtx_lock(&gTZGNLock); { U_ASSERT(fRef->refCount > 0); // Just decrement the reference count fRef->refCount--; } - umtx_unlock(gTZGNLock()); + umtx_unlock(&gTZGNLock); } TimeZoneGenericNames* @@ -1206,7 +1206,7 @@ TimeZoneGenericNames::createInstance(const Locale& locale, UErrorCode& status) { TZGNCoreRef *cacheEntry = NULL; { - Mutex lock(gTZGNLock()); + Mutex lock(&gTZGNLock); if (!gTZGNCoreCacheInitialized) { // Create empty hashtable @@ -1298,13 +1298,13 @@ TimeZoneGenericNames* TimeZoneGenericNames::clone() const { TimeZoneGenericNames* other = new TimeZoneGenericNames(); if (other) { - umtx_lock(gTZGNLock()); + umtx_lock(&gTZGNLock); { // Just increments the reference count fRef->refCount++; other->fRef = fRef; } - umtx_unlock(gTZGNLock()); + umtx_unlock(&gTZGNLock); } return other; } diff --git a/deps/icu-small/source/i18n/tznames.cpp b/deps/icu-small/source/i18n/tznames.cpp index acd6aecdc0ce7e..d789c123630260 100644 --- a/deps/icu-small/source/i18n/tznames.cpp +++ b/deps/icu-small/source/i18n/tznames.cpp @@ -29,10 +29,7 @@ U_NAMESPACE_BEGIN // TimeZoneNames object cache handling -static UMutex *gTimeZoneNamesLock() { - static UMutex m = U_MUTEX_INITIALIZER; - return &m; -} +static UMutex gTimeZoneNamesLock; static UHashtable *gTimeZoneNamesCache = NULL; static UBool gTimeZoneNamesCacheInitialized = FALSE; @@ -109,7 +106,7 @@ class TimeZoneNamesDelegate : public TimeZoneNames { virtual UBool operator==(const TimeZoneNames& other) const; virtual UBool operator!=(const TimeZoneNames& other) const {return !operator==(other);} - virtual TimeZoneNames* clone() const; + virtual TimeZoneNamesDelegate* clone() const; StringEnumeration* getAvailableMetaZoneIDs(UErrorCode& status) const; StringEnumeration* getAvailableMetaZoneIDs(const UnicodeString& tzID, UErrorCode& status) const; @@ -135,7 +132,7 @@ TimeZoneNamesDelegate::TimeZoneNamesDelegate() } TimeZoneNamesDelegate::TimeZoneNamesDelegate(const Locale& locale, UErrorCode& status) { - Mutex lock(gTimeZoneNamesLock()); + Mutex lock(&gTimeZoneNamesLock); if (!gTimeZoneNamesCacheInitialized) { // Create empty hashtable if it is not already initialized. gTimeZoneNamesCache = uhash_open(uhash_hashChars, uhash_compareChars, NULL, &status); @@ -211,7 +208,7 @@ TimeZoneNamesDelegate::TimeZoneNamesDelegate(const Locale& locale, UErrorCode& s } TimeZoneNamesDelegate::~TimeZoneNamesDelegate() { - umtx_lock(gTimeZoneNamesLock()); + umtx_lock(&gTimeZoneNamesLock); { if (fTZnamesCacheEntry) { U_ASSERT(fTZnamesCacheEntry->refCount > 0); @@ -219,7 +216,7 @@ TimeZoneNamesDelegate::~TimeZoneNamesDelegate() { fTZnamesCacheEntry->refCount--; } } - umtx_unlock(gTimeZoneNamesLock()); + umtx_unlock(&gTimeZoneNamesLock); } UBool @@ -236,17 +233,17 @@ TimeZoneNamesDelegate::operator==(const TimeZoneNames& other) const { return FALSE; } -TimeZoneNames* +TimeZoneNamesDelegate* TimeZoneNamesDelegate::clone() const { TimeZoneNamesDelegate* other = new TimeZoneNamesDelegate(); if (other != NULL) { - umtx_lock(gTimeZoneNamesLock()); + umtx_lock(&gTimeZoneNamesLock); { // Just increment the reference count fTZnamesCacheEntry->refCount++; other->fTZnamesCacheEntry = fTZnamesCacheEntry; } - umtx_unlock(gTimeZoneNamesLock()); + umtx_unlock(&gTimeZoneNamesLock); } return other; } diff --git a/deps/icu-small/source/i18n/tznames_impl.cpp b/deps/icu-small/source/i18n/tznames_impl.cpp index d6e0ee2fbb637a..180b7fefbf3623 100644 --- a/deps/icu-small/source/i18n/tznames_impl.cpp +++ b/deps/icu-small/source/i18n/tznames_impl.cpp @@ -21,11 +21,14 @@ #include "unicode/utf16.h" #include "tznames_impl.h" +#include "bytesinkutil.h" +#include "charstr.h" #include "cmemory.h" #include "cstring.h" #include "uassert.h" #include "mutex.h" #include "resource.h" +#include "ulocimp.h" #include "uresimp.h" #include "ureslocs.h" #include "zonemeta.h" @@ -49,10 +52,7 @@ static const UChar NO_NAME[] = { 0 }; // for empty no-fallback time static const char* TZDBNAMES_KEYS[] = {"ss", "sd"}; static const int32_t TZDBNAMES_KEYS_SIZE = UPRV_LENGTHOF(TZDBNAMES_KEYS); -static UMutex *gDataMutex() { - static UMutex m = U_MUTEX_INITIALIZER; - return &m; -} +static UMutex gDataMutex; static UHashtable* gTZDBNamesMap = NULL; static icu::UInitOnce gTZDBNamesMapInitOnce = U_INITONCE_INITIALIZER; @@ -388,7 +388,7 @@ TextTrieMap::search(const UnicodeString &text, int32_t start, // Don't do unless it's really required. // Mutex for protecting the lazy creation of the Trie node structure on the first call to search(). - static UMutex TextTrieMutex = U_MUTEX_INITIALIZER; + static UMutex TextTrieMutex; Mutex lock(&TextTrieMutex); if (fLazyContents != NULL) { @@ -1113,7 +1113,7 @@ TimeZoneNamesImpl::operator==(const TimeZoneNames& other) const { return FALSE; } -TimeZoneNames* +TimeZoneNamesImpl* TimeZoneNamesImpl::clone() const { UErrorCode status = U_ZERO_ERROR; return new TimeZoneNamesImpl(fLocale, status); @@ -1214,7 +1214,7 @@ TimeZoneNamesImpl::getMetaZoneDisplayName(const UnicodeString& mzID, TimeZoneNamesImpl *nonConstThis = const_cast(this); { - Mutex lock(gDataMutex()); + Mutex lock(&gDataMutex); UErrorCode status = U_ZERO_ERROR; znames = nonConstThis->loadMetaZoneNames(mzID, status); if (U_FAILURE(status)) { return name; } @@ -1240,7 +1240,7 @@ TimeZoneNamesImpl::getTimeZoneDisplayName(const UnicodeString& tzID, UTimeZoneNa TimeZoneNamesImpl *nonConstThis = const_cast(this); { - Mutex lock(gDataMutex()); + Mutex lock(&gDataMutex); UErrorCode status = U_ZERO_ERROR; tznames = nonConstThis->loadTimeZoneNames(tzID, status); if (U_FAILURE(status)) { return name; } @@ -1263,7 +1263,7 @@ TimeZoneNamesImpl::getExemplarLocationName(const UnicodeString& tzID, UnicodeStr TimeZoneNamesImpl *nonConstThis = const_cast(this); { - Mutex lock(gDataMutex()); + Mutex lock(&gDataMutex); UErrorCode status = U_ZERO_ERROR; tznames = nonConstThis->loadTimeZoneNames(tzID, status); if (U_FAILURE(status)) { return name; } @@ -1358,7 +1358,7 @@ TimeZoneNamesImpl::find(const UnicodeString& text, int32_t start, uint32_t types // Synchronize so that data is not loaded multiple times. // TODO: Consider more fine-grained synchronization. { - Mutex lock(gDataMutex()); + Mutex lock(&gDataMutex); // First try of lookup. matches = doFind(handler, text, start, status); @@ -1585,7 +1585,7 @@ void TimeZoneNamesImpl::loadAllDisplayNames(UErrorCode& status) { if (U_FAILURE(status)) return; { - Mutex lock(gDataMutex()); + Mutex lock(&gDataMutex); internalLoadAllDisplayNames(status); } } @@ -1602,7 +1602,7 @@ void TimeZoneNamesImpl::getDisplayNames(const UnicodeString& tzID, // Load the time zone strings { - Mutex lock(gDataMutex()); + Mutex lock(&gDataMutex); tznames = (void*) nonConstThis->loadTimeZoneNames(tzID, status); if (U_FAILURE(status)) { return; } } @@ -1622,7 +1622,7 @@ void TimeZoneNamesImpl::getDisplayNames(const UnicodeString& tzID, } else { // Load the meta zone strings // Mutex is scoped to the "else" statement - Mutex lock(gDataMutex()); + Mutex lock(&gDataMutex); mznames = (void*) nonConstThis->loadMetaZoneNames(mzID, status); if (U_FAILURE(status)) { return; } // Note: when the metazone doesn't exist, in Java, loadMetaZoneNames returns @@ -2135,9 +2135,12 @@ TZDBTimeZoneNames::TZDBTimeZoneNames(const Locale& locale) int32_t regionLen = static_cast(uprv_strlen(region)); if (regionLen == 0) { UErrorCode status = U_ZERO_ERROR; - char loc[ULOC_FULLNAME_CAPACITY]; - uloc_addLikelySubtags(fLocale.getName(), loc, sizeof(loc), &status); - regionLen = uloc_getCountry(loc, fRegion, sizeof(fRegion), &status); + CharString loc; + { + CharStringByteSink sink(&loc); + ulocimp_addLikelySubtags(fLocale.getName(), sink, &status); + } + regionLen = uloc_getCountry(loc.data(), fRegion, sizeof(fRegion), &status); if (U_SUCCESS(status) && regionLen < (int32_t)sizeof(fRegion)) { useWorld = FALSE; } @@ -2162,7 +2165,7 @@ TZDBTimeZoneNames::operator==(const TimeZoneNames& other) const { return FALSE; } -TimeZoneNames* +TZDBTimeZoneNames* TZDBTimeZoneNames::clone() const { return new TZDBTimeZoneNames(fLocale); } @@ -2247,7 +2250,7 @@ TZDBTimeZoneNames::getMetaZoneNames(const UnicodeString& mzID, UErrorCode& statu U_ASSERT(status == U_ZERO_ERROR); // already checked length above mzIDKey[mzID.length()] = 0; - static UMutex gTZDBNamesMapLock = U_MUTEX_INITIALIZER; + static UMutex gTZDBNamesMapLock; umtx_lock(&gTZDBNamesMapLock); { void *cacheVal = uhash_get(gTZDBNamesMap, mzIDKey); diff --git a/deps/icu-small/source/i18n/tznames_impl.h b/deps/icu-small/source/i18n/tznames_impl.h index 4db036e7475e35..1286eeb80dc503 100644 --- a/deps/icu-small/source/i18n/tznames_impl.h +++ b/deps/icu-small/source/i18n/tznames_impl.h @@ -174,7 +174,7 @@ class TimeZoneNamesImpl : public TimeZoneNames { virtual ~TimeZoneNamesImpl(); virtual UBool operator==(const TimeZoneNames& other) const; - virtual TimeZoneNames* clone() const; + virtual TimeZoneNamesImpl* clone() const; StringEnumeration* getAvailableMetaZoneIDs(UErrorCode& status) const; StringEnumeration* getAvailableMetaZoneIDs(const UnicodeString& tzID, UErrorCode& status) const; @@ -236,7 +236,7 @@ class TZDBTimeZoneNames : public TimeZoneNames { virtual ~TZDBTimeZoneNames(); virtual UBool operator==(const TimeZoneNames& other) const; - virtual TimeZoneNames* clone() const; + virtual TZDBTimeZoneNames* clone() const; StringEnumeration* getAvailableMetaZoneIDs(UErrorCode& status) const; StringEnumeration* getAvailableMetaZoneIDs(const UnicodeString& tzID, UErrorCode& status) const; diff --git a/deps/icu-small/source/i18n/tzrule.cpp b/deps/icu-small/source/i18n/tzrule.cpp index f60a5e0dd59a6a..c4bf386fd4996c 100644 --- a/deps/icu-small/source/i18n/tzrule.cpp +++ b/deps/icu-small/source/i18n/tzrule.cpp @@ -108,7 +108,7 @@ InitialTimeZoneRule::~InitialTimeZoneRule() { } InitialTimeZoneRule* -InitialTimeZoneRule::clone(void) const { +InitialTimeZoneRule::clone() const { return new InitialTimeZoneRule(*this); } diff --git a/deps/icu-small/source/i18n/ucal.cpp b/deps/icu-small/source/i18n/ucal.cpp index 4154eea83f2fa9..cca1f70cf54584 100644 --- a/deps/icu-small/source/i18n/ucal.cpp +++ b/deps/icu-small/source/i18n/ucal.cpp @@ -34,7 +34,7 @@ U_NAMESPACE_USE static TimeZone* _createTimeZone(const UChar* zoneID, int32_t len, UErrorCode* ec) { TimeZone* zone = NULL; - if (ec!=NULL && U_SUCCESS(*ec)) { + if (ec != NULL && U_SUCCESS(*ec)) { // Note that if zoneID is invalid, we get back GMT. This odd // behavior is by design and goes back to the JDK. The only // failure we will see is a memory allocation failure. @@ -69,7 +69,7 @@ ucal_openCountryTimeZones(const char* country, UErrorCode* ec) { U_CAPI int32_t U_EXPORT2 ucal_getDefaultTimeZone(UChar* result, int32_t resultCapacity, UErrorCode* ec) { int32_t len = 0; - if (ec!=NULL && U_SUCCESS(*ec)) { + if (ec != NULL && U_SUCCESS(*ec)) { TimeZone* zone = TimeZone::createDefault(); if (zone == NULL) { *ec = U_MEMORY_ALLOCATION_ERROR; @@ -91,6 +91,23 @@ ucal_setDefaultTimeZone(const UChar* zoneID, UErrorCode* ec) { } } +U_DRAFT int32_t U_EXPORT2 +ucal_getHostTimeZone(UChar* result, int32_t resultCapacity, UErrorCode* ec) { + int32_t len = 0; + if (ec != NULL && U_SUCCESS(*ec)) { + TimeZone *zone = TimeZone::detectHostTimeZone(); + if (zone == NULL) { + *ec = U_MEMORY_ALLOCATION_ERROR; + } else { + UnicodeString id; + zone->getID(id); + delete zone; + len = id.extract(result, resultCapacity, *ec); + } + } + return len; +} + U_CAPI int32_t U_EXPORT2 ucal_getDSTSavings(const UChar* zoneID, UErrorCode* ec) { int32_t result = 0; @@ -140,8 +157,8 @@ ucal_open( const UChar* zoneID, if(U_FAILURE(*status)) return 0; - TimeZone* zone = (zoneID==NULL) ? TimeZone::createDefault() - : _createTimeZone(zoneID, len, status); + LocalPointer zone( (zoneID==NULL) ? TimeZone::createDefault() + : _createTimeZone(zoneID, len, status), *status); if (U_FAILURE(*status)) { return NULL; @@ -157,9 +174,9 @@ ucal_open( const UChar* zoneID, if (U_FAILURE(*status)) { return NULL; } - return (UCalendar*)Calendar::createInstance(zone, Locale(localeBuf), *status); + return (UCalendar*)Calendar::createInstance(zone.orphan(), Locale(localeBuf), *status); } - return (UCalendar*)Calendar::createInstance(zone, Locale(locale), *status); + return (UCalendar*)Calendar::createInstance(zone.orphan(), Locale(locale), *status); } U_CAPI void U_EXPORT2 diff --git a/deps/icu-small/source/i18n/udat.cpp b/deps/icu-small/source/i18n/udat.cpp index b7d85cc179ef9a..da8befc9e3c65b 100644 --- a/deps/icu-small/source/i18n/udat.cpp +++ b/deps/icu-small/source/i18n/udat.cpp @@ -167,9 +167,13 @@ udat_open(UDateFormatStyle timeStyle, } } - if(fmt == 0) { + if(fmt == nullptr) { *status = U_MEMORY_ALLOCATION_ERROR; - return 0; + return nullptr; + } + if (U_FAILURE(*status)) { + delete fmt; + return nullptr; } if(tzID != 0) { diff --git a/deps/icu-small/source/i18n/unesctrn.cpp b/deps/icu-small/source/i18n/unesctrn.cpp index fcce9528e2f3dc..604cb0a4ba007f 100644 --- a/deps/icu-small/source/i18n/unesctrn.cpp +++ b/deps/icu-small/source/i18n/unesctrn.cpp @@ -164,7 +164,7 @@ UnescapeTransliterator::~UnescapeTransliterator() { /** * Transliterator API. */ -Transliterator* UnescapeTransliterator::clone() const { +UnescapeTransliterator* UnescapeTransliterator::clone() const { return new UnescapeTransliterator(*this); } diff --git a/deps/icu-small/source/i18n/unesctrn.h b/deps/icu-small/source/i18n/unesctrn.h index e8e171f2bc4a69..57dd8d32cf53f3 100644 --- a/deps/icu-small/source/i18n/unesctrn.h +++ b/deps/icu-small/source/i18n/unesctrn.h @@ -77,7 +77,7 @@ class UnescapeTransliterator : public Transliterator { /** * Transliterator API. */ - virtual Transliterator* clone() const; + virtual UnescapeTransliterator* clone() const; /** * ICU "poor man's RTTI", returns a UClassID for the actual class. diff --git a/deps/icu-small/source/i18n/uni2name.cpp b/deps/icu-small/source/i18n/uni2name.cpp index 86d7a4904a815e..9df3924ae5f147 100644 --- a/deps/icu-small/source/i18n/uni2name.cpp +++ b/deps/icu-small/source/i18n/uni2name.cpp @@ -60,7 +60,7 @@ UnicodeNameTransliterator::UnicodeNameTransliterator(const UnicodeNameTransliter /** * Transliterator API. */ -Transliterator* UnicodeNameTransliterator::clone(void) const { +UnicodeNameTransliterator* UnicodeNameTransliterator::clone() const { return new UnicodeNameTransliterator(*this); } diff --git a/deps/icu-small/source/i18n/uni2name.h b/deps/icu-small/source/i18n/uni2name.h index 4d6eaa0a9a6b65..99309c8e0f8785 100644 --- a/deps/icu-small/source/i18n/uni2name.h +++ b/deps/icu-small/source/i18n/uni2name.h @@ -48,7 +48,7 @@ class UnicodeNameTransliterator : public Transliterator { /** * Transliterator API. */ - virtual Transliterator* clone(void) const; + virtual UnicodeNameTransliterator* clone() const; /** * ICU "poor man's RTTI", returns a UClassID for the actual class. diff --git a/deps/icu-small/source/i18n/unicode/alphaindex.h b/deps/icu-small/source/i18n/unicode/alphaindex.h index dfb6110a36cf11..fe43995fe81155 100644 --- a/deps/icu-small/source/i18n/unicode/alphaindex.h +++ b/deps/icu-small/source/i18n/unicode/alphaindex.h @@ -13,6 +13,9 @@ #define INDEXCHARS_H #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/uobject.h" #include "unicode/locid.h" #include "unicode/unistr.h" @@ -757,4 +760,7 @@ class U_I18N_API AlphabeticIndex: public UObject { U_NAMESPACE_END #endif // !UCONFIG_NO_COLLATION + +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/i18n/unicode/basictz.h b/deps/icu-small/source/i18n/unicode/basictz.h index eb62abaf0a679c..e1db2a8223adde 100644 --- a/deps/icu-small/source/i18n/unicode/basictz.h +++ b/deps/icu-small/source/i18n/unicode/basictz.h @@ -16,6 +16,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + #if !UCONFIG_NO_FORMATTING #include "unicode/timezone.h" @@ -41,6 +43,14 @@ class U_I18N_API BasicTimeZone: public TimeZone { */ virtual ~BasicTimeZone(); + /** + * Clones this object polymorphically. + * The caller owns the result and should delete it when done. + * @return clone, or nullptr if an error occurred + * @stable ICU 3.8 + */ + virtual BasicTimeZone* clone() const = 0; + /** * Gets the first time zone transition after the base time. * @param base The base time. @@ -211,6 +221,8 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // BASICTZ_H //eof diff --git a/deps/icu-small/source/i18n/unicode/calendar.h b/deps/icu-small/source/i18n/unicode/calendar.h index 023cf053f254fb..2a8c2935ca8e24 100644 --- a/deps/icu-small/source/i18n/unicode/calendar.h +++ b/deps/icu-small/source/i18n/unicode/calendar.h @@ -29,6 +29,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** * \file * \brief C++ API: Calendar object @@ -184,7 +186,7 @@ class BasicTimeZone; */ class U_I18N_API Calendar : public UObject { public: - +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * Field IDs for date and time. Used to specify date/time fields. ERA is calendar * specific. Example ranges given are for illustration only; see specific Calendar @@ -227,6 +229,7 @@ class U_I18N_API Calendar : public UObject { FIELD_COUNT = UCAL_FIELD_COUNT // See ucal.h for other fields. #endif /* U_HIDE_DEPRECATED_API */ }; +#endif // U_FORCE_HIDE_DEPRECATED_API #ifndef U_HIDE_DEPRECATED_API /** @@ -287,7 +290,7 @@ class U_I18N_API Calendar : public UObject { * @return a polymorphic copy of this calendar. * @stable ICU 2.0 */ - virtual Calendar* clone(void) const = 0; + virtual Calendar* clone() const = 0; /** * Creates a Calendar using the default timezone and locale. Clients are responsible @@ -518,6 +521,7 @@ class U_I18N_API Calendar : public UObject { */ UBool after(const Calendar& when, UErrorCode& status) const; +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * UDate Arithmetic function. Adds the specified (signed) amount of time to the given * time field, based on the calendar's rules. For example, to subtract 5 days from @@ -539,6 +543,7 @@ class U_I18N_API Calendar : public UObject { * @deprecated ICU 2.6. use add(UCalendarDateFields field, int32_t amount, UErrorCode& status) instead. */ virtual void add(EDateFields field, int32_t amount, UErrorCode& status); +#endif // U_FORCE_HIDE_DEPRECATED_API /** * UDate Arithmetic function. Adds the specified (signed) amount of time to the given @@ -632,6 +637,7 @@ class U_I18N_API Calendar : public UObject { */ inline void roll(UCalendarDateFields field, UBool up, UErrorCode& status); +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * Time Field Rolling function. Rolls by the given amount on the given * time field. For example, to roll the current date up by one day, call @@ -664,6 +670,7 @@ class U_I18N_API Calendar : public UObject { * @deprecated ICU 2.6. Use roll(UCalendarDateFields field, int32_t amount, UErrorCode& status) instead. */ virtual void roll(EDateFields field, int32_t amount, UErrorCode& status); +#endif // U_FORCE_HIDE_DEPRECATED_API /** * Time Field Rolling function. Rolls by the given amount on the given @@ -698,6 +705,7 @@ class U_I18N_API Calendar : public UObject { */ virtual void roll(UCalendarDateFields field, int32_t amount, UErrorCode& status); +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * Return the difference between the given time and the time this * calendar object is set to. If this calendar is set @@ -754,6 +762,7 @@ class U_I18N_API Calendar : public UObject { * @deprecated ICU 2.6. Use fieldDifference(UDate when, UCalendarDateFields field, UErrorCode& status). */ virtual int32_t fieldDifference(UDate when, EDateFields field, UErrorCode& status); +#endif // U_FORCE_HIDE_DEPRECATED_API /** * Return the difference between the given time and the time this @@ -1010,6 +1019,7 @@ class U_I18N_API Calendar : public UObject { */ uint8_t getMinimalDaysInFirstWeek(void) const; +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * Gets the minimum value for the given time field. e.g., for Gregorian * DAY_OF_MONTH, 1. @@ -1019,6 +1029,7 @@ class U_I18N_API Calendar : public UObject { * @deprecated ICU 2.6. Use getMinimum(UCalendarDateFields field) instead. */ virtual int32_t getMinimum(EDateFields field) const; +#endif // U_FORCE_HIDE_DEPRECATED_API /** * Gets the minimum value for the given time field. e.g., for Gregorian @@ -1030,6 +1041,7 @@ class U_I18N_API Calendar : public UObject { */ virtual int32_t getMinimum(UCalendarDateFields field) const; +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * Gets the maximum value for the given time field. e.g. for Gregorian DAY_OF_MONTH, * 31. @@ -1039,6 +1051,7 @@ class U_I18N_API Calendar : public UObject { * @deprecated ICU 2.6. Use getMaximum(UCalendarDateFields field) instead. */ virtual int32_t getMaximum(EDateFields field) const; +#endif // U_FORCE_HIDE_DEPRECATED_API /** * Gets the maximum value for the given time field. e.g. for Gregorian DAY_OF_MONTH, @@ -1050,6 +1063,7 @@ class U_I18N_API Calendar : public UObject { */ virtual int32_t getMaximum(UCalendarDateFields field) const; +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * Gets the highest minimum value for the given field if varies. Otherwise same as * getMinimum(). For Gregorian, no difference. @@ -1059,6 +1073,7 @@ class U_I18N_API Calendar : public UObject { * @deprecated ICU 2.6. Use getGreatestMinimum(UCalendarDateFields field) instead. */ virtual int32_t getGreatestMinimum(EDateFields field) const; +#endif // U_FORCE_HIDE_DEPRECATED_API /** * Gets the highest minimum value for the given field if varies. Otherwise same as @@ -1070,6 +1085,7 @@ class U_I18N_API Calendar : public UObject { */ virtual int32_t getGreatestMinimum(UCalendarDateFields field) const; +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * Gets the lowest maximum value for the given field if varies. Otherwise same as * getMaximum(). e.g., for Gregorian DAY_OF_MONTH, 28. @@ -1079,6 +1095,7 @@ class U_I18N_API Calendar : public UObject { * @deprecated ICU 2.6. Use getLeastMaximum(UCalendarDateFields field) instead. */ virtual int32_t getLeastMaximum(EDateFields field) const; +#endif // U_FORCE_HIDE_DEPRECATED_API /** * Gets the lowest maximum value for the given field if varies. Otherwise same as @@ -1895,11 +1912,13 @@ class U_I18N_API Calendar : public UObject { */ int32_t fFields[UCAL_FIELD_COUNT]; +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * The flags which tell if a specified time field for the calendar is set. * @deprecated ICU 2.8 use (fStamp[n]!=kUnset) */ UBool fIsSet[UCAL_FIELD_COUNT]; +#endif // U_FORCE_HIDE_DEPRECATED_API /** Special values of stamp[] * @stable ICU 2.0 @@ -2281,7 +2300,6 @@ class U_I18N_API Calendar : public UObject { * should only be called if this calendar is not lenient. * @see #isLenient * @see #validateField(int, int&) - * @internal */ void validateFields(UErrorCode &status); @@ -2291,7 +2309,6 @@ class U_I18N_API Calendar : public UObject { * U_ILLEGAL_ARGUMENT_ERROR will be set. Subclasses may * use this method in their implementation of {@link * #validateField(int, int&)}. - * @internal */ void validateField(UCalendarDateFields field, int32_t min, int32_t max, UErrorCode& status); @@ -2529,4 +2546,6 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // _CALENDAR diff --git a/deps/icu-small/source/i18n/unicode/choicfmt.h b/deps/icu-small/source/i18n/unicode/choicfmt.h index c9f0f1114f89ed..3b2f48cb1f853c 100644 --- a/deps/icu-small/source/i18n/unicode/choicfmt.h +++ b/deps/icu-small/source/i18n/unicode/choicfmt.h @@ -26,13 +26,14 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** * \file * \brief C++ API: Choice Format. */ #if !UCONFIG_NO_FORMATTING -#ifndef U_HIDE_DEPRECATED_API #include "unicode/fieldpos.h" #include "unicode/format.h" @@ -40,6 +41,8 @@ #include "unicode/numfmt.h" #include "unicode/unistr.h" +#ifndef U_HIDE_DEPRECATED_API + U_NAMESPACE_BEGIN class MessageFormat; @@ -248,7 +251,7 @@ class U_I18N_API ChoiceFormat: public NumberFormat { * @return a copy of this object * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments. */ - virtual Format* clone(void) const; + virtual ChoiceFormat* clone() const; /** * Returns true if the given Format objects are semantically equal. @@ -592,5 +595,7 @@ U_NAMESPACE_END #endif // U_HIDE_DEPRECATED_API #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // CHOICFMT_H //eof diff --git a/deps/icu-small/source/i18n/unicode/coleitr.h b/deps/icu-small/source/i18n/unicode/coleitr.h index bf0e1d51a41833..809d435e509b49 100644 --- a/deps/icu-small/source/i18n/unicode/coleitr.h +++ b/deps/icu-small/source/i18n/unicode/coleitr.h @@ -35,6 +35,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + #if !UCONFIG_NO_COLLATION #include "unicode/unistr.h" @@ -404,4 +406,6 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_COLLATION */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/i18n/unicode/coll.h b/deps/icu-small/source/i18n/unicode/coll.h index 653434f54ca664..f5564c73944bcb 100644 --- a/deps/icu-small/source/i18n/unicode/coll.h +++ b/deps/icu-small/source/i18n/unicode/coll.h @@ -54,6 +54,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + #if !UCONFIG_NO_COLLATION #include "unicode/uobject.h" @@ -204,6 +206,7 @@ class U_I18N_API Collator : public UObject { // Cannot use #ifndef U_HIDE_DEPRECATED_API for the following, it is // used by virtual methods that cannot have that conditional. +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * LESS is returned if source string is compared to be less than target * string in the compare() method. @@ -220,6 +223,7 @@ class U_I18N_API Collator : public UObject { EQUAL = UCOL_EQUAL, // 0 GREATER = UCOL_GREATER // 1 }; +#endif // U_FORCE_HIDE_DEPRECATED_API // Collator public destructor ----------------------------------------- @@ -265,7 +269,7 @@ class U_I18N_API Collator : public UObject { * @return a copy of this object, owned by the caller * @stable ICU 2.0 */ - virtual Collator* clone(void) const = 0; + virtual Collator* clone() const = 0; /** * Creates the Collator object for the current default locale. @@ -323,6 +327,7 @@ class U_I18N_API Collator : public UObject { */ static Collator* U_EXPORT2 createInstance(const Locale& loc, UErrorCode& err); +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * The comparison function compares the character data stored in two * different strings. Returns information about whether a string is less @@ -336,6 +341,7 @@ class U_I18N_API Collator : public UObject { */ virtual EComparisonResult compare(const UnicodeString& source, const UnicodeString& target) const; +#endif // U_FORCE_HIDE_DEPRECATED_API /** * The comparison function compares the character data stored in two @@ -353,6 +359,7 @@ class U_I18N_API Collator : public UObject { const UnicodeString& target, UErrorCode &status) const = 0; +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * Does the same thing as compare but limits the comparison to a specified * length @@ -368,6 +375,7 @@ class U_I18N_API Collator : public UObject { virtual EComparisonResult compare(const UnicodeString& source, const UnicodeString& target, int32_t length) const; +#endif // U_FORCE_HIDE_DEPRECATED_API /** * Does the same thing as compare but limits the comparison to a specified @@ -387,6 +395,7 @@ class U_I18N_API Collator : public UObject { int32_t length, UErrorCode &status) const = 0; +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * The comparison function compares the character data stored in two * different string arrays. Returns information about whether a string array @@ -423,6 +432,7 @@ class U_I18N_API Collator : public UObject { virtual EComparisonResult compare(const char16_t* source, int32_t sourceLength, const char16_t* target, int32_t targetLength) const; +#endif // U_FORCE_HIDE_DEPRECATED_API /** * The comparison function compares the character data stored in two @@ -527,6 +537,7 @@ class U_I18N_API Collator : public UObject { */ virtual int32_t hashCode(void) const = 0; +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * Gets the locale of the Collator * @@ -540,6 +551,7 @@ class U_I18N_API Collator : public UObject { * in ICU 3.0. */ virtual Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const = 0; +#endif // U_FORCE_HIDE_DEPRECATED_API /** * Convenience method for comparing two strings based on the collation rules. @@ -576,6 +588,7 @@ class U_I18N_API Collator : public UObject { */ UBool equals(const UnicodeString& source, const UnicodeString& target) const; +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * Determines the minimum strength that will be used in comparison or * transformation. @@ -607,6 +620,7 @@ class U_I18N_API Collator : public UObject { * @deprecated ICU 2.6 Use setAttribute(UCOL_STRENGTH...) instead */ virtual void setStrength(ECollationStrength newStrength); +#endif // U_FORCE_HIDE_DEPRECATED_API /** * Retrieves the reordering codes for this collator. @@ -904,6 +918,7 @@ class U_I18N_API Collator : public UObject { */ virtual UColReorderCode getMaxVariable() const; +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * Sets the variable top to the primary weight of the specified string. * @@ -951,6 +966,7 @@ class U_I18N_API Collator : public UObject { * @deprecated ICU 53 Call setMaxVariable() instead. */ virtual void setVariableTop(uint32_t varTop, UErrorCode &status) = 0; +#endif // U_FORCE_HIDE_DEPRECATED_API /** * Gets the variable top value of a Collator. @@ -972,6 +988,7 @@ class U_I18N_API Collator : public UObject { */ virtual UnicodeSet *getTailoredSet(UErrorCode &status) const; +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * Same as clone(). * The base class implementation simply calls clone(). @@ -979,7 +996,8 @@ class U_I18N_API Collator : public UObject { * @see clone() * @deprecated ICU 50 no need to have two methods for cloning */ - virtual Collator* safeClone(void) const; + virtual Collator* safeClone() const; +#endif // U_FORCE_HIDE_DEPRECATED_API /** * Get the sort key as an array of bytes from a UnicodeString. @@ -1271,4 +1289,6 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_COLLATION */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/i18n/unicode/compactdecimalformat.h b/deps/icu-small/source/i18n/unicode/compactdecimalformat.h index 9c1e9183f4657b..9c1e2009969279 100644 --- a/deps/icu-small/source/i18n/unicode/compactdecimalformat.h +++ b/deps/icu-small/source/i18n/unicode/compactdecimalformat.h @@ -14,6 +14,9 @@ #define __COMPACT_DECIMAL_FORMAT_H__ #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + /** * \file * \brief C++ API: Compatibility APIs for compact decimal number formatting. @@ -102,7 +105,7 @@ class U_I18N_API CompactDecimalFormat : public DecimalFormat { * @return a polymorphic copy of this CompactDecimalFormat. * @stable ICU 51 */ - Format* clone() const U_OVERRIDE; + CompactDecimalFormat* clone() const U_OVERRIDE; using DecimalFormat::format; @@ -187,5 +190,7 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __COMPACT_DECIMAL_FORMAT_H__ //eof diff --git a/deps/icu-small/source/i18n/unicode/curramt.h b/deps/icu-small/source/i18n/unicode/curramt.h index 03ec856e3bf585..65e6619db30c16 100644 --- a/deps/icu-small/source/i18n/unicode/curramt.h +++ b/deps/icu-small/source/i18n/unicode/curramt.h @@ -15,6 +15,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + #if !UCONFIG_NO_FORMATTING #include "unicode/measure.h" @@ -79,7 +81,7 @@ class U_I18N_API CurrencyAmount: public Measure { * have the same class as returned by getDynamicClassID(). * @stable ICU 3.0 */ - virtual UObject* clone() const; + virtual CurrencyAmount* clone() const; /** * Destructor @@ -129,4 +131,7 @@ inline const char16_t* CurrencyAmount::getISOCurrency() const { U_NAMESPACE_END #endif // !UCONFIG_NO_FORMATTING + +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __CURRENCYAMOUNT_H__ diff --git a/deps/icu-small/source/i18n/unicode/currpinf.h b/deps/icu-small/source/i18n/unicode/currpinf.h index 80b046251323e9..1b93be08316827 100644 --- a/deps/icu-small/source/i18n/unicode/currpinf.h +++ b/deps/icu-small/source/i18n/unicode/currpinf.h @@ -11,6 +11,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** * \file * \brief C++ API: Currency Plural Information used by Decimal Format @@ -266,5 +268,7 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // _CURRPINFO //eof diff --git a/deps/icu-small/source/i18n/unicode/currunit.h b/deps/icu-small/source/i18n/unicode/currunit.h index 63739c37fd569b..0446154e328f8f 100644 --- a/deps/icu-small/source/i18n/unicode/currunit.h +++ b/deps/icu-small/source/i18n/unicode/currunit.h @@ -15,6 +15,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + #if !UCONFIG_NO_FORMATTING #include "unicode/measunit.h" @@ -94,7 +96,7 @@ class U_I18N_API CurrencyUnit: public MeasureUnit { * have the same class as returned by getDynamicClassID(). * @stable ICU 3.0 */ - virtual UObject* clone() const; + virtual CurrencyUnit* clone() const; /** * Destructor @@ -140,4 +142,7 @@ inline const char16_t* CurrencyUnit::getISOCurrency() const { U_NAMESPACE_END #endif // !UCONFIG_NO_FORMATTING + +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __CURRENCYUNIT_H__ diff --git a/deps/icu-small/source/i18n/unicode/datefmt.h b/deps/icu-small/source/i18n/unicode/datefmt.h index 13c63d937675ea..21217e567acf7d 100644 --- a/deps/icu-small/source/i18n/unicode/datefmt.h +++ b/deps/icu-small/source/i18n/unicode/datefmt.h @@ -23,6 +23,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + #if !UCONFIG_NO_FORMATTING #include "unicode/udat.h" @@ -221,6 +223,14 @@ class U_I18N_API DateFormat : public Format { */ virtual ~DateFormat(); + /** + * Clones this object polymorphically. + * The caller owns the result and should delete it when done. + * @return clone, or nullptr if an error occurred + * @stable ICU 2.0 + */ + virtual DateFormat* clone() const = 0; + /** * Equality operator. Returns true if the two formats have the same behavior. * @stable ICU 2.0 @@ -953,5 +963,7 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // _DATEFMT //eof diff --git a/deps/icu-small/source/i18n/unicode/dcfmtsym.h b/deps/icu-small/source/i18n/unicode/dcfmtsym.h index 55e3d8a6b3b5ec..e1e0ab6b08c523 100644 --- a/deps/icu-small/source/i18n/unicode/dcfmtsym.h +++ b/deps/icu-small/source/i18n/unicode/dcfmtsym.h @@ -28,10 +28,12 @@ #define DCFMTSYM_H #include "unicode/utypes.h" -#include "unicode/uchar.h" + +#if U_SHOW_CPLUSPLUS_API #if !UCONFIG_NO_FORMATTING +#include "unicode/uchar.h" #include "unicode/uobject.h" #include "unicode/locid.h" #include "unicode/numsys.h" @@ -455,13 +457,11 @@ class U_I18N_API DecimalFormatSymbols : public UObject { * to non-resource bundle strings, * then regular UnicodeString copies must be used instead of fastCopyFrom(). * - * @internal */ UnicodeString fSymbols[kFormatSymbolCount]; /** * Non-symbol variable for getConstSymbol(). Always empty. - * @internal */ UnicodeString fNoSymbol; @@ -582,5 +582,7 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // _DCFMTSYM //eof diff --git a/deps/icu-small/source/i18n/unicode/decimfmt.h b/deps/icu-small/source/i18n/unicode/decimfmt.h index 097a38fb88f6b2..e539b9af233ccb 100644 --- a/deps/icu-small/source/i18n/unicode/decimfmt.h +++ b/deps/icu-small/source/i18n/unicode/decimfmt.h @@ -28,6 +28,9 @@ #define DECIMFMT_H #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + /** * \file * \brief C++ API: Compatibility APIs for decimal formatting. @@ -896,7 +899,7 @@ class U_I18N_API DecimalFormat : public NumberFormat { * @return a polymorphic copy of this DecimalFormat. * @stable ICU 2.0 */ - Format* clone(void) const U_OVERRIDE; + DecimalFormat* clone() const U_OVERRIDE; /** * Return true if the given Format objects are semantically equal. @@ -1331,7 +1334,6 @@ class U_I18N_API DecimalFormat : public NumberFormat { */ virtual void setMultiplier(int32_t newValue); -#ifndef U_HIDE_DRAFT_API /** * Gets the power of ten by which number should be multiplied before formatting, which * can be combined with setMultiplier() to multiply by any arbitrary decimal value. @@ -1342,7 +1344,7 @@ class U_I18N_API DecimalFormat : public NumberFormat { * This method is analogous to UNUM_SCALE in getAttribute. * * @return the current value of the power-of-ten multiplier. - * @draft ICU 62 + * @stable ICU 62 */ int32_t getMultiplierScale(void) const; @@ -1363,10 +1365,9 @@ class U_I18N_API DecimalFormat : public NumberFormat { * This method is analogous to UNUM_SCALE in setAttribute. * * @param newValue the new value of the power-of-ten multiplier. - * @draft ICU 62 + * @stable ICU 62 */ void setMultiplierScale(int32_t newValue); -#endif /* U_HIDE_DRAFT_API */ /** * Get the rounding increment. @@ -2020,12 +2021,14 @@ class U_I18N_API DecimalFormat : public NumberFormat { */ void setCurrency(const char16_t* theCurrency, UErrorCode& ec) U_OVERRIDE; +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * Sets the currency used to display currency amounts. See * setCurrency(const char16_t*, UErrorCode&). * @deprecated ICU 3.0. Use setCurrency(const char16_t*, UErrorCode&). */ virtual void setCurrency(const char16_t* theCurrency); +#endif // U_FORCE_HIDE_DEPRECATED_API /** * Sets the `Currency Usage` object used to display currency. @@ -2113,22 +2116,6 @@ class U_I18N_API DecimalFormat : public NumberFormat { const number::LocalizedNumberFormatter* toNumberFormatter(UErrorCode& status) const; #endif /* U_HIDE_DRAFT_API */ -#ifndef U_HIDE_DEPRECATED_API - /** - * Deprecated: Like {@link #toNumberFormatter(UErrorCode&) const}, - * but does not take an error code. - * - * The new signature should be used in case an error occurs while returning the - * LocalizedNumberFormatter. - * - * This old signature will be removed in ICU 65. - * - * @return A reference to an internal object. - * @deprecated ICU 64 - */ - const number::LocalizedNumberFormatter& toNumberFormatter() const; -#endif /* U_HIDE_DEPRECATED_API */ - /** * Return the class ID for this class. This is useful only for * comparing to a return value from getDynamicClassID(). For example: @@ -2216,5 +2203,7 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // _DECIMFMT //eof diff --git a/deps/icu-small/source/i18n/unicode/dtfmtsym.h b/deps/icu-small/source/i18n/unicode/dtfmtsym.h index ed7c1898465e5d..f9ec88272b2b5c 100644 --- a/deps/icu-small/source/i18n/unicode/dtfmtsym.h +++ b/deps/icu-small/source/i18n/unicode/dtfmtsym.h @@ -22,6 +22,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + #if !UCONFIG_NO_FORMATTING #include "unicode/calendar.h" @@ -1011,5 +1013,7 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // _DTFMTSYM //eof diff --git a/deps/icu-small/source/i18n/unicode/dtitvfmt.h b/deps/icu-small/source/i18n/unicode/dtitvfmt.h index 42d77d041f8b28..23fc02e2a7b16b 100644 --- a/deps/icu-small/source/i18n/unicode/dtitvfmt.h +++ b/deps/icu-small/source/i18n/unicode/dtitvfmt.h @@ -16,6 +16,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** * \file * \brief C++ API: Format and parse date interval in a language-independent manner. @@ -432,7 +434,7 @@ class U_I18N_API DateIntervalFormat : public Format { * @return A copy of the object. * @stable ICU 4.0 */ - virtual Format* clone(void) const; + virtual DateIntervalFormat* clone() const; /** * Return true if the given Format objects are semantically equal. Objects @@ -1151,5 +1153,7 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // _DTITVFMT_H__ //eof diff --git a/deps/icu-small/source/i18n/unicode/dtitvinf.h b/deps/icu-small/source/i18n/unicode/dtitvinf.h index 65f568c0700218..3c666231abd060 100644 --- a/deps/icu-small/source/i18n/unicode/dtitvinf.h +++ b/deps/icu-small/source/i18n/unicode/dtitvinf.h @@ -16,6 +16,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** * \file * \brief C++ API: Date/Time interval patterns for formatting date/time interval @@ -195,7 +197,7 @@ class U_I18N_API DateIntervalInfo U_FINAL : public UObject { * @return a copy of the object * @stable ICU 4.0 */ - virtual DateIntervalInfo* clone(void) const; + virtual DateIntervalInfo* clone() const; /** * Destructor. @@ -515,4 +517,6 @@ U_NAMESPACE_END #endif +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/i18n/unicode/dtptngen.h b/deps/icu-small/source/i18n/unicode/dtptngen.h index e50c01b4e360c9..a71938b31cf5d8 100644 --- a/deps/icu-small/source/i18n/unicode/dtptngen.h +++ b/deps/icu-small/source/i18n/unicode/dtptngen.h @@ -14,6 +14,10 @@ #ifndef __DTPTNGEN_H__ #define __DTPTNGEN_H__ +#include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/datefmt.h" #include "unicode/locid.h" #include "unicode/udat.h" @@ -279,7 +283,7 @@ class U_I18N_API DateTimePatternGenerator : public UObject { * * @param field The desired UDateTimePatternField, such as UDATPG_ERA_FIELD. * @param width The desired UDateTimePGDisplayWidth, such as UDATPG_ABBREVIATED. - * @return. The display name for field + * @return The display name for field * @stable ICU 61 */ UnicodeString getFieldDisplayName(UDateTimePatternField field, UDateTimePGDisplayWidth width) const; @@ -561,12 +565,10 @@ class U_I18N_API DateTimePatternGenerator : public UObject { void setDateTimeFromCalendar(const Locale& locale, UErrorCode& status); void setDecimalSymbols(const Locale& locale, UErrorCode& status); UDateTimePatternField getAppendFormatNumber(const char* field) const; -#ifndef U_HIDE_DRAFT_API - // The following three have to be U_HIDE_DRAFT_API (though private) because UDateTimePGDisplayWidth is + // Note for the next 3: UDateTimePGDisplayWidth is now stable ICU 61 UDateTimePatternField getFieldAndWidthIndices(const char* key, UDateTimePGDisplayWidth* widthP) const; void setFieldDisplayName(UDateTimePatternField field, UDateTimePGDisplayWidth width, const UnicodeString& value); UnicodeString& getMutableFieldDisplayName(UDateTimePatternField field, UDateTimePGDisplayWidth width); -#endif // U_HIDE_DRAFT_API void getAppendName(UDateTimePatternField field, UnicodeString& value); UnicodeString mapSkeletonMetacharacters(const UnicodeString& patternForm, int32_t* flags, UErrorCode& status); const UnicodeString* getBestRaw(DateTimeMatcher& source, int32_t includeMask, DistanceInfo* missingFields, UErrorCode& status, const PtnSkeleton** specifiedSkeletonPtr = 0); @@ -587,4 +589,6 @@ class U_I18N_API DateTimePatternGenerator : public UObject { U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/i18n/unicode/dtrule.h b/deps/icu-small/source/i18n/unicode/dtrule.h index 24dfc69de1df22..dba28bf2dc4ede 100644 --- a/deps/icu-small/source/i18n/unicode/dtrule.h +++ b/deps/icu-small/source/i18n/unicode/dtrule.h @@ -11,6 +11,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** * \file * \brief C++ API: Rule for specifying date and time in an year @@ -126,7 +128,7 @@ class U_I18N_API DateTimeRule : public UObject { * @return A copy of the object. * @stable ICU 3.8 */ - DateTimeRule* clone(void) const; + DateTimeRule* clone() const; /** * Assignment operator. @@ -248,5 +250,7 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // DTRULE_H //eof diff --git a/deps/icu-small/source/i18n/unicode/fieldpos.h b/deps/icu-small/source/i18n/unicode/fieldpos.h index 78561a4de7d8b1..c9849d67a37d29 100644 --- a/deps/icu-small/source/i18n/unicode/fieldpos.h +++ b/deps/icu-small/source/i18n/unicode/fieldpos.h @@ -26,6 +26,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** * \file * \brief C++ API: FieldPosition identifies the fields in a formatted output. @@ -290,5 +292,7 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // _FIELDPOS //eof diff --git a/deps/icu-small/source/i18n/unicode/fmtable.h b/deps/icu-small/source/i18n/unicode/fmtable.h index a06c23dc3bd532..7bec4f6906e7ee 100644 --- a/deps/icu-small/source/i18n/unicode/fmtable.h +++ b/deps/icu-small/source/i18n/unicode/fmtable.h @@ -19,6 +19,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** * \file * \brief C++ API: Formattable is a thin wrapper for primitive types used for formatting and parsing @@ -751,5 +753,7 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif //_FMTABLE //eof diff --git a/deps/icu-small/source/i18n/unicode/format.h b/deps/icu-small/source/i18n/unicode/format.h index e64cc1c6eb39b4..28a09159bde1ab 100644 --- a/deps/icu-small/source/i18n/unicode/format.h +++ b/deps/icu-small/source/i18n/unicode/format.h @@ -26,6 +26,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** * \file * \brief C++ API: Base class for all formats. @@ -303,5 +305,7 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // _FORMAT //eof diff --git a/deps/icu-small/source/i18n/unicode/formattedvalue.h b/deps/icu-small/source/i18n/unicode/formattedvalue.h index 2e24c8d99e624b..1b130bbdd9d44c 100644 --- a/deps/icu-small/source/i18n/unicode/formattedvalue.h +++ b/deps/icu-small/source/i18n/unicode/formattedvalue.h @@ -5,8 +5,10 @@ #define __FORMATTEDVALUE_H__ #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #if !UCONFIG_NO_FORMATTING -#ifndef U_HIDE_DRAFT_API #include "unicode/appendable.h" #include "unicode/fpositer.h" @@ -24,6 +26,10 @@ U_NAMESPACE_BEGIN */ +// The following cannot have #ifndef U_HIDE_DRAFT_API because +// class FormattedValue depends on it, and FormattedValue cannot be +// hidden becauseclass FormattedNumber (stable ICU 60) depends on it. +#ifndef U_FORCE_HIDE_DRAFT_API /** * Represents a span of a string containing a given field. * @@ -52,6 +58,7 @@ class U_I18N_API ConstrainedFieldPosition : public UMemory { /** @draft ICU 64 */ ~ConstrainedFieldPosition(); +#ifndef U_HIDE_DRAFT_API /** * Resets this ConstrainedFieldPosition to its initial state, as if it were newly created: * @@ -221,17 +228,23 @@ class U_I18N_API ConstrainedFieldPosition : public UMemory { int32_t field, int32_t start, int32_t limit); +#endif /* U_HIDE_DRAFT_API */ private: int64_t fContext = 0LL; int32_t fField = 0; int32_t fStart = 0; int32_t fLimit = 0; +#ifndef U_HIDE_DRAFT_API int32_t fCategory = UFIELD_CATEGORY_UNDEFINED; +#else /* U_HIDE_DRAFT_API */ + int32_t fCategory = 0; +#endif /* U_HIDE_DRAFT_API */ int8_t fConstraint = 0; }; - +// The following cannot have #ifndef U_HIDE_DRAFT_API because +// class FormattedNumber (stable ICU 60) depends on it. /** * An abstract formatted value: a string with associated field attributes. * Many formatters format to classes implementing FormattedValue. @@ -308,10 +321,12 @@ class U_I18N_API FormattedValue /* not : public UObject because this is an inter */ virtual UBool nextPosition(ConstrainedFieldPosition& cfpos, UErrorCode& status) const = 0; }; - +#endif // U_FORCE_HIDE_DRAFT_API U_NAMESPACE_END -#endif /* U_HIDE_DRAFT_API */ #endif /* #if !UCONFIG_NO_FORMATTING */ + +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __FORMATTEDVALUE_H__ diff --git a/deps/icu-small/source/i18n/unicode/fpositer.h b/deps/icu-small/source/i18n/unicode/fpositer.h index 81091f0ffad6b6..ba2a838315c7cb 100644 --- a/deps/icu-small/source/i18n/unicode/fpositer.h +++ b/deps/icu-small/source/i18n/unicode/fpositer.h @@ -19,6 +19,9 @@ #define FPOSITER_H #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/uobject.h" /** @@ -116,4 +119,6 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // FPOSITER_H diff --git a/deps/icu-small/source/i18n/unicode/gender.h b/deps/icu-small/source/i18n/unicode/gender.h index b7c31cb554a696..5ae111a3aa816a 100644 --- a/deps/icu-small/source/i18n/unicode/gender.h +++ b/deps/icu-small/source/i18n/unicode/gender.h @@ -25,6 +25,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + #if !UCONFIG_NO_FORMATTING #include "unicode/locid.h" @@ -114,5 +116,7 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // _GENDER //eof diff --git a/deps/icu-small/source/i18n/unicode/gregocal.h b/deps/icu-small/source/i18n/unicode/gregocal.h index 1d881e0be76067..236bd003c160a6 100644 --- a/deps/icu-small/source/i18n/unicode/gregocal.h +++ b/deps/icu-small/source/i18n/unicode/gregocal.h @@ -28,6 +28,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + #if !UCONFIG_NO_FORMATTING #include "unicode/calendar.h" @@ -301,7 +303,7 @@ class U_I18N_API GregorianCalendar: public Calendar { * @return return a polymorphic copy of this calendar. * @stable ICU 2.0 */ - virtual Calendar* clone(void) const; + virtual GregorianCalendar* clone() const; /** * Sets the GregorianCalendar change date. This is the point when the switch from @@ -350,6 +352,7 @@ class U_I18N_API GregorianCalendar: public Calendar { */ virtual UBool isEquivalentTo(const Calendar& other) const; +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * (Overrides Calendar) Rolls up or down by the given amount in the specified field. * For more information, see the documentation for Calendar::roll(). @@ -362,6 +365,7 @@ class U_I18N_API GregorianCalendar: public Calendar { * @deprecated ICU 2.6. Use roll(UCalendarDateFields field, int32_t amount, UErrorCode& status) instead. */ virtual void roll(EDateFields field, int32_t amount, UErrorCode& status); +#endif // U_FORCE_HIDE_DEPRECATED_API /** * (Overrides Calendar) Rolls up or down by the given amount in the specified field. @@ -774,5 +778,7 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // _GREGOCAL //eof diff --git a/deps/icu-small/source/i18n/unicode/listformatter.h b/deps/icu-small/source/i18n/unicode/listformatter.h index 9ce8ec8617ce80..88fc46cf37b2a3 100644 --- a/deps/icu-small/source/i18n/unicode/listformatter.h +++ b/deps/icu-small/source/i18n/unicode/listformatter.h @@ -21,6 +21,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + #include "unicode/unistr.h" #include "unicode/locid.h" #include "unicode/formattedvalue.h" @@ -237,7 +239,7 @@ class U_I18N_API ListFormatter : public UObject{ UnicodeString& format(const UnicodeString items[], int32_t n_items, UnicodeString & appendTo, FieldPositionIterator* posIter, UErrorCode& errorCode) const; -#endif /* U_HIDE_DRAFT_API */ +#endif // U_HIDE_DRAFT_API #if !UCONFIG_NO_FORMATTING #ifndef U_HIDE_DRAFT_API @@ -298,4 +300,6 @@ class U_I18N_API ListFormatter : public UObject{ U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __LISTFORMATTER_H__ diff --git a/deps/icu-small/source/i18n/unicode/measfmt.h b/deps/icu-small/source/i18n/unicode/measfmt.h index d518665e1448b5..8f73de87fa55d6 100644 --- a/deps/icu-small/source/i18n/unicode/measfmt.h +++ b/deps/icu-small/source/i18n/unicode/measfmt.h @@ -15,6 +15,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + #if !UCONFIG_NO_FORMATTING #include "unicode/format.h" @@ -151,7 +153,7 @@ class U_I18N_API MeasureFormat : public Format { * Clones this object polymorphically. * @stable ICU 53 */ - virtual Format *clone() const; + virtual MeasureFormat *clone() const; /** * Formats object to produce a string. @@ -163,6 +165,7 @@ class U_I18N_API MeasureFormat : public Format { FieldPosition &pos, UErrorCode &status) const; +#ifndef U_FORCE_HIDE_DRAFT_API /** * Parse a string to produce an object. This implementation sets * status to U_UNSUPPORTED_ERROR. @@ -173,6 +176,7 @@ class U_I18N_API MeasureFormat : public Format { const UnicodeString &source, Formattable &reslt, ParsePosition &pos) const; +#endif // U_FORCE_HIDE_DRAFT_API /** * Formats measure objects to produce a string. An example of such a @@ -382,17 +386,12 @@ class U_I18N_API MeasureFormat : public Format { int32_t bitMap, // 1=hour set, 2=minute set, 4=second set UnicodeString &appendTo, UErrorCode &status) const; - - UnicodeString &formatNumeric( - UDate date, - const DateFormat &dateFmt, - UDateFormatField smallestField, - const Formattable &smallestAmount, - UnicodeString &appendTo, - UErrorCode &status) const; }; U_NAMESPACE_END #endif // #if !UCONFIG_NO_FORMATTING + +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // #ifndef MEASUREFORMAT_H diff --git a/deps/icu-small/source/i18n/unicode/measunit.h b/deps/icu-small/source/i18n/unicode/measunit.h index d8e3c73956f9c3..08f337cb5bb630 100644 --- a/deps/icu-small/source/i18n/unicode/measunit.h +++ b/deps/icu-small/source/i18n/unicode/measunit.h @@ -15,6 +15,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + #if !UCONFIG_NO_FORMATTING #include "unicode/unistr.h" @@ -62,7 +64,7 @@ class U_I18N_API MeasureUnit: public UObject { * have the same class as returned by getDynamicClassID(). * @stable ICU 3.0 */ - virtual UObject* clone() const; + virtual MeasureUnit* clone() const; /** * Destructor @@ -604,16 +606,14 @@ class U_I18N_API MeasureUnit: public UObject { static MeasureUnit getPartPerMillion(); #endif /* U_HIDE_DRAFT_API */ -#ifndef U_HIDE_DRAFT_API /** * Returns by pointer, unit of concentr: percent. * Caller owns returned value and must free it. * Also see {@link #getPercent()}. * @param status ICU error code. - * @draft ICU 63 + * @stable ICU 63 */ static MeasureUnit *createPercent(UErrorCode &status); -#endif /* U_HIDE_DRAFT_API */ #ifndef U_HIDE_DRAFT_API /** @@ -624,16 +624,14 @@ class U_I18N_API MeasureUnit: public UObject { static MeasureUnit getPercent(); #endif /* U_HIDE_DRAFT_API */ -#ifndef U_HIDE_DRAFT_API /** * Returns by pointer, unit of concentr: permille. * Caller owns returned value and must free it. * Also see {@link #getPermille()}. * @param status ICU error code. - * @draft ICU 63 + * @stable ICU 63 */ static MeasureUnit *createPermille(UErrorCode &status); -#endif /* U_HIDE_DRAFT_API */ #ifndef U_HIDE_DRAFT_API /** @@ -878,16 +876,14 @@ class U_I18N_API MeasureUnit: public UObject { static MeasureUnit getMegabyte(); #endif /* U_HIDE_DRAFT_API */ -#ifndef U_HIDE_DRAFT_API /** * Returns by pointer, unit of digital: petabyte. * Caller owns returned value and must free it. * Also see {@link #getPetabyte()}. * @param status ICU error code. - * @draft ICU 63 + * @stable ICU 63 */ static MeasureUnit *createPetabyte(UErrorCode &status); -#endif /* U_HIDE_DRAFT_API */ #ifndef U_HIDE_DRAFT_API /** @@ -979,9 +975,7 @@ class U_I18N_API MeasureUnit: public UObject { * @draft ICU 64 */ static MeasureUnit *createDayPerson(UErrorCode &status); -#endif /* U_HIDE_DRAFT_API */ -#ifndef U_HIDE_DRAFT_API /** * Returns by value, unit of duration: day-person. * Also see {@link #createDayPerson()}. @@ -990,6 +984,24 @@ class U_I18N_API MeasureUnit: public UObject { static MeasureUnit getDayPerson(); #endif /* U_HIDE_DRAFT_API */ +#ifndef U_HIDE_DRAFT_API + /** + * Returns by pointer, unit of duration: decade. + * Caller owns returned value and must free it. + * Also see {@link #getDecade()}. + * @param status ICU error code. + * @draft ICU 65 + */ + static MeasureUnit *createDecade(UErrorCode &status); + + /** + * Returns by value, unit of duration: decade. + * Also see {@link #createDecade()}. + * @draft ICU 65 + */ + static MeasureUnit getDecade(); +#endif /* U_HIDE_DRAFT_API */ + /** * Returns by pointer, unit of duration: hour. * Caller owns returned value and must free it. @@ -1089,9 +1101,7 @@ class U_I18N_API MeasureUnit: public UObject { * @draft ICU 64 */ static MeasureUnit *createMonthPerson(UErrorCode &status); -#endif /* U_HIDE_DRAFT_API */ -#ifndef U_HIDE_DRAFT_API /** * Returns by value, unit of duration: month-person. * Also see {@link #createMonthPerson()}. @@ -1163,9 +1173,7 @@ class U_I18N_API MeasureUnit: public UObject { * @draft ICU 64 */ static MeasureUnit *createWeekPerson(UErrorCode &status); -#endif /* U_HIDE_DRAFT_API */ -#ifndef U_HIDE_DRAFT_API /** * Returns by value, unit of duration: week-person. * Also see {@link #createWeekPerson()}. @@ -1201,9 +1209,7 @@ class U_I18N_API MeasureUnit: public UObject { * @draft ICU 64 */ static MeasureUnit *createYearPerson(UErrorCode &status); -#endif /* U_HIDE_DRAFT_API */ -#ifndef U_HIDE_DRAFT_API /** * Returns by value, unit of duration: year-person. * Also see {@link #createYearPerson()}. @@ -1428,6 +1434,24 @@ class U_I18N_API MeasureUnit: public UObject { static MeasureUnit getKilowattHour(); #endif /* U_HIDE_DRAFT_API */ +#ifndef U_HIDE_DRAFT_API + /** + * Returns by pointer, unit of energy: therm-us. + * Caller owns returned value and must free it. + * Also see {@link #getThermUs()}. + * @param status ICU error code. + * @draft ICU 65 + */ + static MeasureUnit *createThermUs(UErrorCode &status); + + /** + * Returns by value, unit of energy: therm-us. + * Also see {@link #createThermUs()}. + * @draft ICU 65 + */ + static MeasureUnit getThermUs(); +#endif /* U_HIDE_DRAFT_API */ + #ifndef U_HIDE_DRAFT_API /** * Returns by pointer, unit of force: newton. @@ -1536,6 +1560,132 @@ class U_I18N_API MeasureUnit: public UObject { static MeasureUnit getMegahertz(); #endif /* U_HIDE_DRAFT_API */ +#ifndef U_HIDE_DRAFT_API + /** + * Returns by pointer, unit of graphics: dot-per-centimeter. + * Caller owns returned value and must free it. + * Also see {@link #getDotPerCentimeter()}. + * @param status ICU error code. + * @draft ICU 65 + */ + static MeasureUnit *createDotPerCentimeter(UErrorCode &status); + + /** + * Returns by value, unit of graphics: dot-per-centimeter. + * Also see {@link #createDotPerCentimeter()}. + * @draft ICU 65 + */ + static MeasureUnit getDotPerCentimeter(); +#endif /* U_HIDE_DRAFT_API */ + +#ifndef U_HIDE_DRAFT_API + /** + * Returns by pointer, unit of graphics: dot-per-inch. + * Caller owns returned value and must free it. + * Also see {@link #getDotPerInch()}. + * @param status ICU error code. + * @draft ICU 65 + */ + static MeasureUnit *createDotPerInch(UErrorCode &status); + + /** + * Returns by value, unit of graphics: dot-per-inch. + * Also see {@link #createDotPerInch()}. + * @draft ICU 65 + */ + static MeasureUnit getDotPerInch(); +#endif /* U_HIDE_DRAFT_API */ + +#ifndef U_HIDE_DRAFT_API + /** + * Returns by pointer, unit of graphics: em. + * Caller owns returned value and must free it. + * Also see {@link #getEm()}. + * @param status ICU error code. + * @draft ICU 65 + */ + static MeasureUnit *createEm(UErrorCode &status); + + /** + * Returns by value, unit of graphics: em. + * Also see {@link #createEm()}. + * @draft ICU 65 + */ + static MeasureUnit getEm(); +#endif /* U_HIDE_DRAFT_API */ + +#ifndef U_HIDE_DRAFT_API + /** + * Returns by pointer, unit of graphics: megapixel. + * Caller owns returned value and must free it. + * Also see {@link #getMegapixel()}. + * @param status ICU error code. + * @draft ICU 65 + */ + static MeasureUnit *createMegapixel(UErrorCode &status); + + /** + * Returns by value, unit of graphics: megapixel. + * Also see {@link #createMegapixel()}. + * @draft ICU 65 + */ + static MeasureUnit getMegapixel(); +#endif /* U_HIDE_DRAFT_API */ + +#ifndef U_HIDE_DRAFT_API + /** + * Returns by pointer, unit of graphics: pixel. + * Caller owns returned value and must free it. + * Also see {@link #getPixel()}. + * @param status ICU error code. + * @draft ICU 65 + */ + static MeasureUnit *createPixel(UErrorCode &status); + + /** + * Returns by value, unit of graphics: pixel. + * Also see {@link #createPixel()}. + * @draft ICU 65 + */ + static MeasureUnit getPixel(); +#endif /* U_HIDE_DRAFT_API */ + +#ifndef U_HIDE_DRAFT_API + /** + * Returns by pointer, unit of graphics: pixel-per-centimeter. + * Caller owns returned value and must free it. + * Also see {@link #getPixelPerCentimeter()}. + * @param status ICU error code. + * @draft ICU 65 + */ + static MeasureUnit *createPixelPerCentimeter(UErrorCode &status); + + /** + * Returns by value, unit of graphics: pixel-per-centimeter. + * Also see {@link #createPixelPerCentimeter()}. + * @draft ICU 65 + */ + static MeasureUnit getPixelPerCentimeter(); +#endif /* U_HIDE_DRAFT_API */ + +#ifndef U_HIDE_DRAFT_API + /** + * Returns by pointer, unit of graphics: pixel-per-inch. + * Caller owns returned value and must free it. + * Also see {@link #getPixelPerInch()}. + * @param status ICU error code. + * @draft ICU 65 + */ + static MeasureUnit *createPixelPerInch(UErrorCode &status); + + /** + * Returns by value, unit of graphics: pixel-per-inch. + * Also see {@link #createPixelPerInch()}. + * @draft ICU 65 + */ + static MeasureUnit getPixelPerInch(); +#endif /* U_HIDE_DRAFT_API */ + /** * Returns by pointer, unit of length: astronomical-unit. * Caller owns returned value and must free it. @@ -2310,16 +2460,14 @@ class U_I18N_API MeasureUnit: public UObject { static MeasureUnit getWatt(); #endif /* U_HIDE_DRAFT_API */ -#ifndef U_HIDE_DRAFT_API /** * Returns by pointer, unit of pressure: atmosphere. * Caller owns returned value and must free it. * Also see {@link #getAtmosphere()}. * @param status ICU error code. - * @draft ICU 63 + * @stable ICU 63 */ static MeasureUnit *createAtmosphere(UErrorCode &status); -#endif /* U_HIDE_DRAFT_API */ #ifndef U_HIDE_DRAFT_API /** @@ -2330,6 +2478,24 @@ class U_I18N_API MeasureUnit: public UObject { static MeasureUnit getAtmosphere(); #endif /* U_HIDE_DRAFT_API */ +#ifndef U_HIDE_DRAFT_API + /** + * Returns by pointer, unit of pressure: bar. + * Caller owns returned value and must free it. + * Also see {@link #getBar()}. + * @param status ICU error code. + * @draft ICU 65 + */ + static MeasureUnit *createBar(UErrorCode &status); + + /** + * Returns by value, unit of pressure: bar. + * Also see {@link #createBar()}. + * @draft ICU 65 + */ + static MeasureUnit getBar(); +#endif /* U_HIDE_DRAFT_API */ + /** * Returns by pointer, unit of pressure: hectopascal. * Caller owns returned value and must free it. @@ -2438,6 +2604,24 @@ class U_I18N_API MeasureUnit: public UObject { static MeasureUnit getMillimeterOfMercury(); #endif /* U_HIDE_DRAFT_API */ +#ifndef U_HIDE_DRAFT_API + /** + * Returns by pointer, unit of pressure: pascal. + * Caller owns returned value and must free it. + * Also see {@link #getPascal()}. + * @param status ICU error code. + * @draft ICU 65 + */ + static MeasureUnit *createPascal(UErrorCode &status); + + /** + * Returns by value, unit of pressure: pascal. + * Also see {@link #createPascal()}. + * @draft ICU 65 + */ + static MeasureUnit getPascal(); +#endif /* U_HIDE_DRAFT_API */ + /** * Returns by pointer, unit of pressure: pound-per-square-inch. * Caller owns returned value and must free it. @@ -3164,4 +3348,7 @@ class U_I18N_API MeasureUnit: public UObject { U_NAMESPACE_END #endif // !UNCONFIG_NO_FORMATTING + +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __MEASUREUNIT_H__ diff --git a/deps/icu-small/source/i18n/unicode/measure.h b/deps/icu-small/source/i18n/unicode/measure.h index 71438d5c856b78..a15173d739d94f 100644 --- a/deps/icu-small/source/i18n/unicode/measure.h +++ b/deps/icu-small/source/i18n/unicode/measure.h @@ -15,6 +15,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** * \file * \brief C++ API: MeasureUnit object. @@ -72,7 +74,7 @@ class U_I18N_API Measure: public UObject { * have the same class as returned by getDynamicClassID(). * @stable ICU 3.0 */ - virtual UObject* clone() const; + virtual Measure* clone() const; /** * Destructor @@ -158,4 +160,7 @@ inline const MeasureUnit& Measure::getUnit() const { U_NAMESPACE_END #endif // !UCONFIG_NO_FORMATTING + +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __MEASURE_H__ diff --git a/deps/icu-small/source/i18n/unicode/msgfmt.h b/deps/icu-small/source/i18n/unicode/msgfmt.h index 8e1bf9b45f9184..99b0eaeec1dcd8 100644 --- a/deps/icu-small/source/i18n/unicode/msgfmt.h +++ b/deps/icu-small/source/i18n/unicode/msgfmt.h @@ -21,6 +21,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** * \file * \brief C++ API: Formats messages in a language-neutral way. @@ -184,7 +186,7 @@ class NumberFormat; * argSkeletonText * NumberFormatter::forSkeleton(argSkeletonText, status).locale(getLocale()).toFormat(status) * - * date + * date * (none) * DateFormat.createDateInstance(kDefault, getLocale(), status) * @@ -418,7 +420,7 @@ class U_I18N_API MessageFormat : public Format { * result and should delete it when done. * @stable ICU 2.0 */ - virtual Format* clone(void) const; + virtual MessageFormat* clone() const; /** * Returns true if the given Format objects are semantically equal. @@ -1087,7 +1089,7 @@ class U_I18N_API MessageFormat : public Format { class U_I18N_API DummyFormat : public Format { public: virtual UBool operator==(const Format&) const; - virtual Format* clone() const; + virtual DummyFormat* clone() const; virtual UnicodeString& format(const Formattable& obj, UnicodeString& appendTo, UErrorCode& status) const; @@ -1111,5 +1113,7 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // _MSGFMT //eof diff --git a/deps/icu-small/source/i18n/unicode/nounit.h b/deps/icu-small/source/i18n/unicode/nounit.h index 879849b16bd8e0..61b5c16ee3955b 100644 --- a/deps/icu-small/source/i18n/unicode/nounit.h +++ b/deps/icu-small/source/i18n/unicode/nounit.h @@ -12,11 +12,14 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + #if !UCONFIG_NO_FORMATTING -#ifndef U_HIDE_DRAFT_API #include "unicode/measunit.h" +#ifndef U_HIDE_DRAFT_API + /** * \file * \brief C++ API: units for percent and permille @@ -72,7 +75,7 @@ class U_I18N_API NoUnit: public MeasureUnit { * have the same class as returned by getDynamicClassID(). * @draft ICU 60 */ - virtual UObject* clone() const; + virtual NoUnit* clone() const; /** * Returns a unique class ID for this object POLYMORPHICALLY. @@ -106,6 +109,8 @@ U_NAMESPACE_END #endif /* U_HIDE_DRAFT_API */ #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __NOUNIT_H__ //eof // diff --git a/deps/icu-small/source/i18n/unicode/numberformatter.h b/deps/icu-small/source/i18n/unicode/numberformatter.h index e9fe39a9316665..6d48f18ab55a4d 100644 --- a/deps/icu-small/source/i18n/unicode/numberformatter.h +++ b/deps/icu-small/source/i18n/unicode/numberformatter.h @@ -1,15 +1,19 @@ // © 2017 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html +#ifndef __NUMBERFORMATTER_H__ +#define __NUMBERFORMATTER_H__ + #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + #if !UCONFIG_NO_FORMATTING -#ifndef __NUMBERFORMATTER_H__ -#define __NUMBERFORMATTER_H__ #include "unicode/appendable.h" -#include "unicode/dcfmtsym.h" +#include "unicode/bytestream.h" #include "unicode/currunit.h" +#include "unicode/dcfmtsym.h" #include "unicode/fieldpos.h" #include "unicode/formattedvalue.h" #include "unicode/fpositer.h" @@ -22,8 +26,6 @@ #include "unicode/unumberformatter.h" #include "unicode/uobject.h" -#ifndef U_HIDE_DRAFT_API - /** * \file * \brief C++ API: Library for localized number formatting introduced in ICU 60. @@ -85,6 +87,7 @@ U_NAMESPACE_BEGIN // Forward declarations: class IFixedDecimal; class FieldPositionIteratorHandler; +class FormattedStringBuilder; namespace numparse { namespace impl { @@ -142,7 +145,6 @@ class MultiplierProducer; class RoundingImpl; class ScientificHandler; class Modifier; -class NumberStringBuilder; class AffixPatternProvider; class NumberPropertyMapper; struct DecimalFormatProperties; @@ -167,21 +169,21 @@ void touchRangeLocales(impl::RangeMacroProps& macros); /** * Extra name reserved in case it is needed in the future. * - * @draft ICU 63 + * @stable ICU 63 */ typedef Notation CompactNotation; /** * Extra name reserved in case it is needed in the future. * - * @draft ICU 63 + * @stable ICU 63 */ typedef Notation SimpleNotation; /** * A class that defines the notation style to be used when formatting numbers in NumberFormatter. * - * @draft ICU 60 + * @stable ICU 60 */ class U_I18N_API Notation : public UMemory { public: @@ -207,7 +209,7 @@ class U_I18N_API Notation : public UMemory { * * * @return A ScientificNotation for chaining or passing to the NumberFormatter notation() setter. - * @draft ICU 60 + * @stable ICU 60 */ static ScientificNotation scientific(); @@ -231,7 +233,7 @@ class U_I18N_API Notation : public UMemory { * * * @return A ScientificNotation for chaining or passing to the NumberFormatter notation() setter. - * @draft ICU 60 + * @stable ICU 60 */ static ScientificNotation engineering(); @@ -274,7 +276,7 @@ class U_I18N_API Notation : public UMemory { * * * @return A CompactNotation for passing to the NumberFormatter notation() setter. - * @draft ICU 60 + * @stable ICU 60 */ static CompactNotation compactShort(); @@ -298,7 +300,7 @@ class U_I18N_API Notation : public UMemory { * * * @return A CompactNotation for passing to the NumberFormatter notation() setter. - * @draft ICU 60 + * @stable ICU 60 */ static CompactNotation compactLong(); @@ -324,7 +326,7 @@ class U_I18N_API Notation : public UMemory { * * * @return A SimpleNotation for passing to the NumberFormatter notation() setter. - * @draft ICU 60 + * @stable ICU 60 */ static SimpleNotation simple(); @@ -391,7 +393,7 @@ class U_I18N_API Notation : public UMemory { *

* To create a ScientificNotation, use one of the factory methods in {@link Notation}. * - * @draft ICU 60 + * @stable ICU 60 */ class U_I18N_API ScientificNotation : public Notation { public: @@ -406,7 +408,7 @@ class U_I18N_API ScientificNotation : public Notation { * @param minExponentDigits * The minimum number of digits to show in the exponent. * @return A ScientificNotation, for chaining. - * @draft ICU 60 + * @stable ICU 60 */ ScientificNotation withMinExponentDigits(int32_t minExponentDigits) const; @@ -421,7 +423,7 @@ class U_I18N_API ScientificNotation : public Notation { * @param exponentSignDisplay * The strategy for displaying the sign in the exponent. * @return A ScientificNotation, for chaining. - * @draft ICU 60 + * @stable ICU 60 */ ScientificNotation withExponentSignDisplay(UNumberSignDisplay exponentSignDisplay) const; @@ -442,7 +444,7 @@ class U_I18N_API ScientificNotation : public Notation { /** * Extra name reserved in case it is needed in the future. * - * @draft ICU 63 + * @stable ICU 63 */ typedef Precision SignificantDigitsPrecision; @@ -452,7 +454,7 @@ typedef Precision SignificantDigitsPrecision; *

* To create a Precision, use one of the factory methods. * - * @draft ICU 60 + * @stable ICU 60 */ class U_I18N_API Precision : public UMemory { @@ -472,7 +474,7 @@ class U_I18N_API Precision : public UMemory { * http://www.serpentine.com/blog/2011/06/29/here-be-dragons-advances-in-problems-you-didnt-even-know-you-had/ * * @return A Precision for chaining or passing to the NumberFormatter precision() setter. - * @draft ICU 60 + * @stable ICU 60 */ static Precision unlimited(); @@ -480,7 +482,7 @@ class U_I18N_API Precision : public UMemory { * Show numbers rounded if necessary to the nearest integer. * * @return A FractionPrecision for chaining or passing to the NumberFormatter precision() setter. - * @draft ICU 60 + * @stable ICU 60 */ static FractionPrecision integer(); @@ -509,7 +511,7 @@ class U_I18N_API Precision : public UMemory { * The minimum and maximum number of numerals to display after the decimal separator (rounding if too * long or padding with zeros if too short). * @return A FractionPrecision for chaining or passing to the NumberFormatter precision() setter. - * @draft ICU 60 + * @stable ICU 60 */ static FractionPrecision fixedFraction(int32_t minMaxFractionPlaces); @@ -524,7 +526,7 @@ class U_I18N_API Precision : public UMemory { * The minimum number of numerals to display after the decimal separator (padding with zeros if * necessary). * @return A FractionPrecision for chaining or passing to the NumberFormatter precision() setter. - * @draft ICU 60 + * @stable ICU 60 */ static FractionPrecision minFraction(int32_t minFractionPlaces); @@ -536,7 +538,7 @@ class U_I18N_API Precision : public UMemory { * @param maxFractionPlaces * The maximum number of numerals to display after the decimal mark (rounding if necessary). * @return A FractionPrecision for chaining or passing to the NumberFormatter precision() setter. - * @draft ICU 60 + * @stable ICU 60 */ static FractionPrecision maxFraction(int32_t maxFractionPlaces); @@ -551,7 +553,7 @@ class U_I18N_API Precision : public UMemory { * @param maxFractionPlaces * The maximum number of numerals to display after the decimal separator (rounding if necessary). * @return A FractionPrecision for chaining or passing to the NumberFormatter precision() setter. - * @draft ICU 60 + * @stable ICU 60 */ static FractionPrecision minMaxFraction(int32_t minFractionPlaces, int32_t maxFractionPlaces); @@ -566,7 +568,7 @@ class U_I18N_API Precision : public UMemory { * The minimum and maximum number of significant digits to display (rounding if too long or padding with * zeros if too short). * @return A precision for chaining or passing to the NumberFormatter precision() setter. - * @draft ICU 62 + * @stable ICU 62 */ static SignificantDigitsPrecision fixedSignificantDigits(int32_t minMaxSignificantDigits); @@ -580,7 +582,7 @@ class U_I18N_API Precision : public UMemory { * @param minSignificantDigits * The minimum number of significant digits to display (padding with zeros if too short). * @return A precision for chaining or passing to the NumberFormatter precision() setter. - * @draft ICU 62 + * @stable ICU 62 */ static SignificantDigitsPrecision minSignificantDigits(int32_t minSignificantDigits); @@ -590,7 +592,7 @@ class U_I18N_API Precision : public UMemory { * @param maxSignificantDigits * The maximum number of significant digits to display (rounding if too long). * @return A precision for chaining or passing to the NumberFormatter precision() setter. - * @draft ICU 62 + * @stable ICU 62 */ static SignificantDigitsPrecision maxSignificantDigits(int32_t maxSignificantDigits); @@ -603,7 +605,7 @@ class U_I18N_API Precision : public UMemory { * @param maxSignificantDigits * The maximum number of significant digits to display (rounding if necessary). * @return A precision for chaining or passing to the NumberFormatter precision() setter. - * @draft ICU 62 + * @stable ICU 62 */ static SignificantDigitsPrecision minMaxSignificantDigits(int32_t minSignificantDigits, int32_t maxSignificantDigits); @@ -625,7 +627,7 @@ class U_I18N_API Precision : public UMemory { * @param roundingIncrement * The increment to which to round numbers. * @return A precision for chaining or passing to the NumberFormatter precision() setter. - * @draft ICU 60 + * @stable ICU 60 */ static IncrementPrecision increment(double roundingIncrement); @@ -644,7 +646,7 @@ class U_I18N_API Precision : public UMemory { * Either STANDARD (for digital transactions) or CASH (for transactions where the rounding increment may * be limited by the available denominations of cash or coins). * @return A CurrencyPrecision for chaining or passing to the NumberFormatter precision() setter. - * @draft ICU 60 + * @stable ICU 60 */ static CurrencyPrecision currency(UCurrencyUsage currencyUsage); @@ -771,7 +773,7 @@ class U_I18N_API Precision : public UMemory { *

* To create a FractionPrecision, use one of the factory methods on Precision. * - * @draft ICU 60 + * @stable ICU 60 */ class U_I18N_API FractionPrecision : public Precision { public: @@ -789,7 +791,7 @@ class U_I18N_API FractionPrecision : public Precision { * @param minSignificantDigits * The number of significant figures to guarantee. * @return A precision for chaining or passing to the NumberFormatter precision() setter. - * @draft ICU 60 + * @stable ICU 60 */ Precision withMinDigits(int32_t minSignificantDigits) const; @@ -808,7 +810,7 @@ class U_I18N_API FractionPrecision : public Precision { * @param maxSignificantDigits * Round the number to no more than this number of significant figures. * @return A precision for chaining or passing to the NumberFormatter precision() setter. - * @draft ICU 60 + * @stable ICU 60 */ Precision withMaxDigits(int32_t maxSignificantDigits) const; @@ -827,7 +829,7 @@ class U_I18N_API FractionPrecision : public Precision { *

* To create a CurrencyPrecision, use one of the factory methods on Precision. * - * @draft ICU 60 + * @stable ICU 60 */ class U_I18N_API CurrencyPrecision : public Precision { public: @@ -846,7 +848,7 @@ class U_I18N_API CurrencyPrecision : public Precision { * @param currency * The currency to associate with this rounding precision. * @return A precision for chaining or passing to the NumberFormatter precision() setter. - * @draft ICU 60 + * @stable ICU 60 */ Precision withCurrency(const CurrencyUnit ¤cy) const; @@ -865,7 +867,7 @@ class U_I18N_API CurrencyPrecision : public Precision { *

* To create an IncrementPrecision, use one of the factory methods on Precision. * - * @draft ICU 60 + * @stable ICU 60 */ class U_I18N_API IncrementPrecision : public Precision { public: @@ -882,7 +884,7 @@ class U_I18N_API IncrementPrecision : public Precision { * * @param minFrac The minimum number of digits after the decimal separator. * @return A precision for chaining or passing to the NumberFormatter precision() setter. - * @draft ICU 60 + * @stable ICU 60 */ Precision withMinFraction(int32_t minFrac) const; @@ -900,7 +902,7 @@ class U_I18N_API IncrementPrecision : public Precision { *

* To create an IntegerWidth, use one of the factory methods. * - * @draft ICU 60 + * @stable ICU 60 * @see NumberFormatter */ class U_I18N_API IntegerWidth : public UMemory { @@ -914,7 +916,7 @@ class U_I18N_API IntegerWidth : public UMemory { * @param minInt * The minimum number of places before the decimal separator. * @return An IntegerWidth for chaining or passing to the NumberFormatter integerWidth() setter. - * @draft ICU 60 + * @stable ICU 60 */ static IntegerWidth zeroFillTo(int32_t minInt); @@ -927,7 +929,7 @@ class U_I18N_API IntegerWidth : public UMemory { * The maximum number of places before the decimal separator. maxInt == -1 means no * truncation. * @return An IntegerWidth for passing to the NumberFormatter integerWidth() setter. - * @draft ICU 60 + * @stable ICU 60 */ IntegerWidth truncateAt(int32_t maxInt); @@ -994,7 +996,7 @@ class U_I18N_API IntegerWidth : public UMemory { *

* To create a Scale, use one of the factory methods. * - * @draft ICU 62 + * @stable ICU 62 */ class U_I18N_API Scale : public UMemory { public: @@ -1002,7 +1004,7 @@ class U_I18N_API Scale : public UMemory { * Do not change the value of numbers when formatting or parsing. * * @return A Scale to prevent any multiplication. - * @draft ICU 62 + * @stable ICU 62 */ static Scale none(); @@ -1014,7 +1016,7 @@ class U_I18N_API Scale : public UMemory { * * * @return A Scale for passing to the setter in NumberFormatter. - * @draft ICU 62 + * @stable ICU 62 */ static Scale powerOfTen(int32_t power); @@ -1028,7 +1030,7 @@ class U_I18N_API Scale : public UMemory { * Also see the version of this method that takes a double. * * @return A Scale for passing to the setter in NumberFormatter. - * @draft ICU 62 + * @stable ICU 62 */ static Scale byDecimal(StringPiece multiplicand); @@ -1038,7 +1040,7 @@ class U_I18N_API Scale : public UMemory { * This method takes a double; also see the version of this method that takes an exact decimal. * * @return A Scale for passing to the setter in NumberFormatter. - * @draft ICU 62 + * @stable ICU 62 */ static Scale byDouble(double multiplicand); @@ -1046,26 +1048,26 @@ class U_I18N_API Scale : public UMemory { * Multiply a number by both a power of ten and by an arbitrary double value. * * @return A Scale for passing to the setter in NumberFormatter. - * @draft ICU 62 + * @stable ICU 62 */ static Scale byDoubleAndPowerOfTen(double multiplicand, int32_t power); // We need a custom destructor for the DecNum, which means we need to declare // the copy/move constructor/assignment quartet. - /** @draft ICU 62 */ + /** @stable ICU 62 */ Scale(const Scale& other); - /** @draft ICU 62 */ + /** @stable ICU 62 */ Scale& operator=(const Scale& other); - /** @draft ICU 62 */ + /** @stable ICU 62 */ Scale(Scale&& src) U_NOEXCEPT; - /** @draft ICU 62 */ + /** @stable ICU 62 */ Scale& operator=(Scale&& src) U_NOEXCEPT; - /** @draft ICU 62 */ + /** @stable ICU 62 */ ~Scale(); #ifndef U_HIDE_INTERNAL_API @@ -1343,7 +1345,7 @@ class U_I18N_API Padder : public UMemory { } int32_t padAndApply(const impl::Modifier &mod1, const impl::Modifier &mod2, - impl::NumberStringBuilder &string, int32_t leftIndex, int32_t rightIndex, + FormattedStringBuilder &string, int32_t leftIndex, int32_t rightIndex, UErrorCode &status) const; // To allow MacroProps/MicroProps to initialize empty instances: @@ -1465,7 +1467,7 @@ class U_I18N_API NumberFormatterSettings { * The notation strategy to use. * @return The fluent chain. * @see Notation - * @draft ICU 60 + * @stable ICU 60 */ Derived notation(const Notation ¬ation) const &; @@ -1476,7 +1478,7 @@ class U_I18N_API NumberFormatterSettings { * The notation strategy to use. * @return The fluent chain. * @see #notation - * @draft ICU 62 + * @stable ICU 62 */ Derived notation(const Notation ¬ation) &&; @@ -1521,7 +1523,7 @@ class U_I18N_API NumberFormatterSettings { * @see Currency * @see NoUnit * @see #perUnit - * @draft ICU 60 + * @stable ICU 60 */ Derived unit(const icu::MeasureUnit &unit) const &; @@ -1532,7 +1534,7 @@ class U_I18N_API NumberFormatterSettings { * The unit to render. * @return The fluent chain. * @see #unit - * @draft ICU 62 + * @stable ICU 62 */ Derived unit(const icu::MeasureUnit &unit) &&; @@ -1547,7 +1549,7 @@ class U_I18N_API NumberFormatterSettings { * @return The fluent chain. * @see #unit * @see MeasureUnit - * @draft ICU 60 + * @stable ICU 60 */ Derived adoptUnit(icu::MeasureUnit *unit) const &; @@ -1558,7 +1560,7 @@ class U_I18N_API NumberFormatterSettings { * The unit to render. * @return The fluent chain. * @see #adoptUnit - * @draft ICU 62 + * @stable ICU 62 */ Derived adoptUnit(icu::MeasureUnit *unit) &&; @@ -1582,7 +1584,7 @@ class U_I18N_API NumberFormatterSettings { * The unit to render in the denominator. * @return The fluent chain * @see #unit - * @draft ICU 61 + * @stable ICU 61 */ Derived perUnit(const icu::MeasureUnit &perUnit) const &; @@ -1593,7 +1595,7 @@ class U_I18N_API NumberFormatterSettings { * The unit to render in the denominator. * @return The fluent chain. * @see #perUnit - * @draft ICU 62 + * @stable ICU 62 */ Derived perUnit(const icu::MeasureUnit &perUnit) &&; @@ -1608,7 +1610,7 @@ class U_I18N_API NumberFormatterSettings { * @return The fluent chain. * @see #perUnit * @see MeasureUnit - * @draft ICU 61 + * @stable ICU 61 */ Derived adoptPerUnit(icu::MeasureUnit *perUnit) const &; @@ -1619,7 +1621,7 @@ class U_I18N_API NumberFormatterSettings { * The unit to render in the denominator. * @return The fluent chain. * @see #adoptPerUnit - * @draft ICU 62 + * @stable ICU 62 */ Derived adoptPerUnit(icu::MeasureUnit *perUnit) &&; @@ -1651,7 +1653,7 @@ class U_I18N_API NumberFormatterSettings { * The rounding precision to use. * @return The fluent chain. * @see Precision - * @draft ICU 62 + * @stable ICU 62 */ Derived precision(const Precision& precision) const &; @@ -1662,7 +1664,7 @@ class U_I18N_API NumberFormatterSettings { * The rounding precision to use. * @return The fluent chain. * @see #precision - * @draft ICU 62 + * @stable ICU 62 */ Derived precision(const Precision& precision) &&; @@ -1682,7 +1684,7 @@ class U_I18N_API NumberFormatterSettings { * * @param roundingMode The rounding mode to use. * @return The fluent chain. - * @draft ICU 62 + * @stable ICU 62 */ Derived roundingMode(UNumberFormatRoundingMode roundingMode) const &; @@ -1692,7 +1694,7 @@ class U_I18N_API NumberFormatterSettings { * @param roundingMode The rounding mode to use. * @return The fluent chain. * @see #roundingMode - * @draft ICU 62 + * @stable ICU 62 */ Derived roundingMode(UNumberFormatRoundingMode roundingMode) &&; @@ -1721,7 +1723,7 @@ class U_I18N_API NumberFormatterSettings { * @param strategy * The grouping strategy to use. * @return The fluent chain. - * @draft ICU 61 + * @stable ICU 61 */ Derived grouping(UNumberGroupingStrategy strategy) const &; @@ -1732,7 +1734,7 @@ class U_I18N_API NumberFormatterSettings { * The grouping strategy to use. * @return The fluent chain. * @see #grouping - * @draft ICU 62 + * @stable ICU 62 */ Derived grouping(UNumberGroupingStrategy strategy) &&; @@ -1758,7 +1760,7 @@ class U_I18N_API NumberFormatterSettings { * The integer width to use. * @return The fluent chain. * @see IntegerWidth - * @draft ICU 60 + * @stable ICU 60 */ Derived integerWidth(const IntegerWidth &style) const &; @@ -1769,7 +1771,7 @@ class U_I18N_API NumberFormatterSettings { * The integer width to use. * @return The fluent chain. * @see #integerWidth - * @draft ICU 62 + * @stable ICU 62 */ Derived integerWidth(const IntegerWidth &style) &&; @@ -1811,7 +1813,7 @@ class U_I18N_API NumberFormatterSettings { * The DecimalFormatSymbols to use. * @return The fluent chain. * @see DecimalFormatSymbols - * @draft ICU 60 + * @stable ICU 60 */ Derived symbols(const DecimalFormatSymbols &symbols) const &; @@ -1822,7 +1824,7 @@ class U_I18N_API NumberFormatterSettings { * The DecimalFormatSymbols to use. * @return The fluent chain. * @see #symbols - * @draft ICU 62 + * @stable ICU 62 */ Derived symbols(const DecimalFormatSymbols &symbols) &&; @@ -1857,7 +1859,7 @@ class U_I18N_API NumberFormatterSettings { * The NumberingSystem to use. * @return The fluent chain. * @see NumberingSystem - * @draft ICU 60 + * @stable ICU 60 */ Derived adoptSymbols(NumberingSystem *symbols) const &; @@ -1868,7 +1870,7 @@ class U_I18N_API NumberFormatterSettings { * The NumberingSystem to use. * @return The fluent chain. * @see #adoptSymbols - * @draft ICU 62 + * @stable ICU 62 */ Derived adoptSymbols(NumberingSystem *symbols) &&; @@ -1895,7 +1897,7 @@ class U_I18N_API NumberFormatterSettings { * The width to use when rendering numbers. * @return The fluent chain * @see UNumberUnitWidth - * @draft ICU 60 + * @stable ICU 60 */ Derived unitWidth(UNumberUnitWidth width) const &; @@ -1906,7 +1908,7 @@ class U_I18N_API NumberFormatterSettings { * The width to use when rendering numbers. * @return The fluent chain. * @see #unitWidth - * @draft ICU 62 + * @stable ICU 62 */ Derived unitWidth(UNumberUnitWidth width) &&; @@ -1933,7 +1935,7 @@ class U_I18N_API NumberFormatterSettings { * The sign display strategy to use when rendering numbers. * @return The fluent chain * @see UNumberSignDisplay - * @draft ICU 60 + * @stable ICU 60 */ Derived sign(UNumberSignDisplay style) const &; @@ -1944,7 +1946,7 @@ class U_I18N_API NumberFormatterSettings { * The sign display strategy to use when rendering numbers. * @return The fluent chain. * @see #sign - * @draft ICU 62 + * @stable ICU 62 */ Derived sign(UNumberSignDisplay style) &&; @@ -1971,7 +1973,7 @@ class U_I18N_API NumberFormatterSettings { * The decimal separator display strategy to use when rendering numbers. * @return The fluent chain * @see UNumberDecimalSeparatorDisplay - * @draft ICU 60 + * @stable ICU 60 */ Derived decimal(UNumberDecimalSeparatorDisplay style) const &; @@ -1982,7 +1984,7 @@ class U_I18N_API NumberFormatterSettings { * The decimal separator display strategy to use when rendering numbers. * @return The fluent chain. * @see #decimal - * @draft ICU 62 + * @stable ICU 62 */ Derived decimal(UNumberDecimalSeparatorDisplay style) &&; @@ -2008,7 +2010,7 @@ class U_I18N_API NumberFormatterSettings { * @param scale * The scale to apply when rendering numbers. * @return The fluent chain - * @draft ICU 62 + * @stable ICU 62 */ Derived scale(const Scale &scale) const &; @@ -2019,7 +2021,7 @@ class U_I18N_API NumberFormatterSettings { * The scale to apply when rendering numbers. * @return The fluent chain. * @see #scale - * @draft ICU 62 + * @stable ICU 62 */ Derived scale(const Scale &scale) &&; @@ -2076,10 +2078,11 @@ class U_I18N_API NumberFormatterSettings { * behavior should produce the same skeleton. * * @return A number skeleton string with behavior corresponding to this number formatter. - * @draft ICU 62 + * @stable ICU 62 */ UnicodeString toSkeleton(UErrorCode& status) const; +#ifndef U_HIDE_DRAFT_API /** * Returns the current (Un)LocalizedNumberFormatter as a LocalPointer * wrapping a heap-allocated copy of the current object. @@ -2101,12 +2104,13 @@ class U_I18N_API NumberFormatterSettings { * @draft ICU 64 */ LocalPointer clone() &&; +#endif /* U_HIDE_DRAFT_API */ /** * Sets the UErrorCode if an error occurred in the fluent chain. * Preserves older error codes in the outErrorCode. * @return TRUE if U_FAILURE(outErrorCode) - * @draft ICU 60 + * @stable ICU 60 */ UBool copyErrorTo(UErrorCode &outErrorCode) const { if (U_FAILURE(outErrorCode)) { @@ -2139,7 +2143,7 @@ class U_I18N_API NumberFormatterSettings { * Instances of this class are immutable and thread-safe. * * @see NumberFormatter - * @draft ICU 60 + * @stable ICU 60 */ class U_I18N_API UnlocalizedNumberFormatter : public NumberFormatterSettings, public UMemory { @@ -2152,7 +2156,7 @@ class U_I18N_API UnlocalizedNumberFormatter * @param locale * The locale to use when loading data for number formatting. * @return The fluent chain. - * @draft ICU 60 + * @stable ICU 60 */ LocalizedNumberFormatter locale(const icu::Locale &locale) const &; @@ -2163,40 +2167,40 @@ class U_I18N_API UnlocalizedNumberFormatter * The locale to use when loading data for number formatting. * @return The fluent chain. * @see #locale - * @draft ICU 62 + * @stable ICU 62 */ LocalizedNumberFormatter locale(const icu::Locale &locale) &&; /** * Default constructor: puts the formatter into a valid but undefined state. * - * @draft ICU 62 + * @stable ICU 62 */ UnlocalizedNumberFormatter() = default; /** * Returns a copy of this UnlocalizedNumberFormatter. - * @draft ICU 60 + * @stable ICU 60 */ UnlocalizedNumberFormatter(const UnlocalizedNumberFormatter &other); /** * Move constructor: * The source UnlocalizedNumberFormatter will be left in a valid but undefined state. - * @draft ICU 62 + * @stable ICU 62 */ UnlocalizedNumberFormatter(UnlocalizedNumberFormatter&& src) U_NOEXCEPT; /** * Copy assignment operator. - * @draft ICU 62 + * @stable ICU 62 */ UnlocalizedNumberFormatter& operator=(const UnlocalizedNumberFormatter& other); /** * Move assignment operator: * The source UnlocalizedNumberFormatter will be left in a valid but undefined state. - * @draft ICU 62 + * @stable ICU 62 */ UnlocalizedNumberFormatter& operator=(UnlocalizedNumberFormatter&& src) U_NOEXCEPT; @@ -2219,7 +2223,7 @@ class U_I18N_API UnlocalizedNumberFormatter * Instances of this class are immutable and thread-safe. * * @see NumberFormatter - * @draft ICU 60 + * @stable ICU 60 */ class U_I18N_API LocalizedNumberFormatter : public NumberFormatterSettings, public UMemory { @@ -2233,7 +2237,7 @@ class U_I18N_API LocalizedNumberFormatter * @param status * Set to an ErrorCode if one occurred in the setter chain or during formatting. * @return A FormattedNumber object; call .toString() to get the string. - * @draft ICU 60 + * @stable ICU 60 */ FormattedNumber formatInt(int64_t value, UErrorCode &status) const; @@ -2246,7 +2250,7 @@ class U_I18N_API LocalizedNumberFormatter * @param status * Set to an ErrorCode if one occurred in the setter chain or during formatting. * @return A FormattedNumber object; call .toString() to get the string. - * @draft ICU 60 + * @stable ICU 60 */ FormattedNumber formatDouble(double value, UErrorCode &status) const; @@ -2262,7 +2266,7 @@ class U_I18N_API LocalizedNumberFormatter * @param status * Set to an ErrorCode if one occurred in the setter chain or during formatting. * @return A FormattedNumber object; call .toString() to get the string. - * @draft ICU 60 + * @stable ICU 60 */ FormattedNumber formatDecimal(StringPiece value, UErrorCode& status) const; @@ -2303,40 +2307,40 @@ class U_I18N_API LocalizedNumberFormatter * The caller owns the returned object and must delete it when finished. * * @return A Format wrapping this LocalizedNumberFormatter. - * @draft ICU 62 + * @stable ICU 62 */ Format* toFormat(UErrorCode& status) const; /** * Default constructor: puts the formatter into a valid but undefined state. * - * @draft ICU 62 + * @stable ICU 62 */ LocalizedNumberFormatter() = default; /** * Returns a copy of this LocalizedNumberFormatter. - * @draft ICU 60 + * @stable ICU 60 */ LocalizedNumberFormatter(const LocalizedNumberFormatter &other); /** * Move constructor: * The source LocalizedNumberFormatter will be left in a valid but undefined state. - * @draft ICU 62 + * @stable ICU 62 */ LocalizedNumberFormatter(LocalizedNumberFormatter&& src) U_NOEXCEPT; /** * Copy assignment operator. - * @draft ICU 62 + * @stable ICU 62 */ LocalizedNumberFormatter& operator=(const LocalizedNumberFormatter& other); /** * Move assignment operator: * The source LocalizedNumberFormatter will be left in a valid but undefined state. - * @draft ICU 62 + * @stable ICU 62 */ LocalizedNumberFormatter& operator=(LocalizedNumberFormatter&& src) U_NOEXCEPT; @@ -2360,7 +2364,7 @@ class U_I18N_API LocalizedNumberFormatter /** * Destruct this LocalizedNumberFormatter, cleaning up any memory it might own. - * @draft ICU 60 + * @stable ICU 60 */ ~LocalizedNumberFormatter(); @@ -2401,27 +2405,30 @@ class U_I18N_API LocalizedNumberFormatter * * Instances of this class are immutable and thread-safe. * - * @draft ICU 60 + * @stable ICU 60 */ class U_I18N_API FormattedNumber : public UMemory, public FormattedValue { public: + // Default constructor cannot have #ifndef U_HIDE_DRAFT_API +#ifndef U_FORCE_HIDE_DRAFT_API /** * Default constructor; makes an empty FormattedNumber. * @draft ICU 64 */ FormattedNumber() : fData(nullptr), fErrorCode(U_INVALID_STATE_ERROR) {} +#endif // U_FORCE_HIDE_DRAFT_API /** * Move constructor: Leaves the source FormattedNumber in an undefined state. - * @draft ICU 62 + * @stable ICU 62 */ FormattedNumber(FormattedNumber&& src) U_NOEXCEPT; /** * Destruct an instance of FormattedNumber. - * @draft ICU 60 + * @stable ICU 60 */ virtual ~FormattedNumber() U_OVERRIDE; @@ -2433,7 +2440,7 @@ class U_I18N_API FormattedNumber : public UMemory, public FormattedValue { /** * Move assignment: Leaves the source FormattedNumber in an undefined state. - * @draft ICU 62 + * @stable ICU 62 */ FormattedNumber& operator=(FormattedNumber&& src) U_NOEXCEPT; @@ -2443,7 +2450,7 @@ class U_I18N_API FormattedNumber : public UMemory, public FormattedValue { * * For more information, see FormattedValue::toString() * - * @draft ICU 62 + * @stable ICU 62 */ UnicodeString toString(UErrorCode& status) const U_OVERRIDE; @@ -2457,7 +2464,7 @@ class U_I18N_API FormattedNumber : public UMemory, public FormattedValue { * * For more information, see FormattedValue::appendTo() * - * @draft ICU 62 + * @stable ICU 62 */ Appendable &appendTo(Appendable& appendable, UErrorCode& status) const U_OVERRIDE; @@ -2465,6 +2472,7 @@ class U_I18N_API FormattedNumber : public UMemory, public FormattedValue { /** @copydoc FormattedValue::nextPosition() */ UBool nextPosition(ConstrainedFieldPosition& cfpos, UErrorCode& status) const U_OVERRIDE; +#ifndef U_HIDE_DRAFT_API /** * Determines the start (inclusive) and end (exclusive) indices of the next occurrence of the given * field in the output string. This allows you to determine the locations of, for example, @@ -2516,6 +2524,30 @@ class U_I18N_API FormattedNumber : public UMemory, public FormattedValue { * @see UNumberFormatFields */ void getAllFieldPositions(FieldPositionIterator &iterator, UErrorCode &status) const; +#endif /* U_HIDE_DRAFT_API */ + +#ifndef U_HIDE_DRAFT_API + /** + * Export the formatted number as a "numeric string" conforming to the + * syntax defined in the Decimal Arithmetic Specification, available at + * http://speleotrove.com/decimal + * + * This endpoint is useful for obtaining the exact number being printed + * after scaling and rounding have been applied by the number formatter. + * + * Example call site: + * + * auto decimalNumber = fn.toDecimalNumber(status); + * + * @tparam StringClass A string class compatible with StringByteSink; + * for example, std::string. + * @param status Set if an error occurs. + * @return A StringClass containing the numeric string. + * @draft ICU 65 + */ + template + inline StringClass toDecimalNumber(UErrorCode& status) const; +#endif // U_HIDE_DRAFT_API #ifndef U_HIDE_INTERNAL_API @@ -2550,6 +2582,9 @@ class U_I18N_API FormattedNumber : public UMemory, public FormattedValue { explicit FormattedNumber(UErrorCode errorCode) : fData(nullptr), fErrorCode(errorCode) {} + // TODO(ICU-20775): Propose this as API. + void toDecimalNumber(ByteSink& sink, UErrorCode& status) const; + // To give LocalizedNumberFormatter format methods access to this class's constructor: friend class LocalizedNumberFormatter; @@ -2557,10 +2592,21 @@ class U_I18N_API FormattedNumber : public UMemory, public FormattedValue { friend struct impl::UFormattedNumberImpl; }; +#ifndef U_HIDE_DRAFT_API +// Note: This is draft ICU 65 +template +StringClass FormattedNumber::toDecimalNumber(UErrorCode& status) const { + StringClass result; + StringByteSink sink(&result); + toDecimalNumber(sink, status); + return result; +}; +#endif // U_HIDE_DRAFT_API + /** * See the main description in numberformatter.h for documentation and examples. * - * @draft ICU 60 + * @stable ICU 60 */ class U_I18N_API NumberFormatter final { public: @@ -2569,7 +2615,7 @@ class U_I18N_API NumberFormatter final { * the call site. * * @return An {@link UnlocalizedNumberFormatter}, to be used for chaining. - * @draft ICU 60 + * @stable ICU 60 */ static UnlocalizedNumberFormatter with(); @@ -2580,7 +2626,7 @@ class U_I18N_API NumberFormatter final { * @param locale * The locale from which to load formats and symbols for number formatting. * @return A {@link LocalizedNumberFormatter}, to be used for chaining. - * @draft ICU 60 + * @stable ICU 60 */ static LocalizedNumberFormatter withLocale(const Locale &locale); @@ -2596,10 +2642,11 @@ class U_I18N_API NumberFormatter final { * @param status * Set to U_NUMBER_SKELETON_SYNTAX_ERROR if the skeleton was invalid. * @return An UnlocalizedNumberFormatter, to be used for chaining. - * @draft ICU 62 + * @stable ICU 62 */ static UnlocalizedNumberFormatter forSkeleton(const UnicodeString& skeleton, UErrorCode& status); +#ifndef U_HIDE_DRAFT_API /** * Call this method at the beginning of a NumberFormatter fluent chain to create an instance based * on a given number skeleton string. @@ -2619,6 +2666,7 @@ class U_I18N_API NumberFormatter final { */ static UnlocalizedNumberFormatter forSkeleton(const UnicodeString& skeleton, UParseError& perror, UErrorCode& status); +#endif /** * Use factory methods instead of the constructor to create a NumberFormatter. @@ -2629,8 +2677,9 @@ class U_I18N_API NumberFormatter final { } // namespace number U_NAMESPACE_END -#endif // U_HIDE_DRAFT_API +#endif /* #if !UCONFIG_NO_FORMATTING */ + +#endif /* U_SHOW_CPLUSPLUS_API */ #endif // __NUMBERFORMATTER_H__ -#endif /* #if !UCONFIG_NO_FORMATTING */ diff --git a/deps/icu-small/source/i18n/unicode/numberrangeformatter.h b/deps/icu-small/source/i18n/unicode/numberrangeformatter.h index 47c4bfe3f5ef76..e3a72aa8b21257 100644 --- a/deps/icu-small/source/i18n/unicode/numberrangeformatter.h +++ b/deps/icu-small/source/i18n/unicode/numberrangeformatter.h @@ -1,10 +1,15 @@ // © 2018 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html -#if !UCONFIG_NO_FORMATTING #ifndef __NUMBERRANGEFORMATTER_H__ #define __NUMBERRANGEFORMATTER_H__ +#include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + +#if !UCONFIG_NO_FORMATTING + #include #include "unicode/appendable.h" #include "unicode/fieldpos.h" @@ -12,8 +17,6 @@ #include "unicode/fpositer.h" #include "unicode/numberformatter.h" -#ifndef U_HIDE_DRAFT_API - /** * \file * \brief C++ API: Library for localized formatting of number, currency, and unit ranges. @@ -44,7 +47,7 @@ /** * Defines how to merge fields that are identical across the range sign. * - * @draft ICU 63 + * @stable ICU 63 */ typedef enum UNumberRangeCollapse { /** @@ -53,14 +56,14 @@ typedef enum UNumberRangeCollapse { * * The heuristics used for this option are subject to change over time. * - * @draft ICU 63 + * @stable ICU 63 */ UNUM_RANGE_COLLAPSE_AUTO, /** * Do not collapse any part of the number. Example: "3.2 thousand kilograms – 5.3 thousand kilograms" * - * @draft ICU 63 + * @stable ICU 63 */ UNUM_RANGE_COLLAPSE_NONE, @@ -68,7 +71,7 @@ typedef enum UNumberRangeCollapse { * Collapse the unit part of the number, but not the notation, if present. Example: "3.2 thousand – 5.3 thousand * kilograms" * - * @draft ICU 63 + * @stable ICU 63 */ UNUM_RANGE_COLLAPSE_UNIT, @@ -76,7 +79,7 @@ typedef enum UNumberRangeCollapse { * Collapse any field that is equal across the range sign. May introduce ambiguity on the magnitude of the * number. Example: "3.2 – 5.3 thousand kilograms" * - * @draft ICU 63 + * @stable ICU 63 */ UNUM_RANGE_COLLAPSE_ALL } UNumberRangeCollapse; @@ -85,14 +88,14 @@ typedef enum UNumberRangeCollapse { * Defines the behavior when the two numbers in the range are identical after rounding. To programmatically detect * when the identity fallback is used, compare the lower and upper BigDecimals via FormattedNumber. * - * @draft ICU 63 + * @stable ICU 63 * @see NumberRangeFormatter */ typedef enum UNumberRangeIdentityFallback { /** * Show the number as a single value rather than a range. Example: "$5" * - * @draft ICU 63 + * @stable ICU 63 */ UNUM_IDENTITY_FALLBACK_SINGLE_VALUE, @@ -100,7 +103,7 @@ typedef enum UNumberRangeIdentityFallback { * Show the number using a locale-sensitive approximation pattern. If the numbers were the same before rounding, * show the single value. Example: "~$5" or "$5" * - * @draft ICU 63 + * @stable ICU 63 */ UNUM_IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE, @@ -108,7 +111,7 @@ typedef enum UNumberRangeIdentityFallback { * Show the number using a locale-sensitive approximation pattern. Use the range pattern always, even if the * inputs are the same. Example: "~$5" * - * @draft ICU 63 + * @stable ICU 63 */ UNUM_IDENTITY_FALLBACK_APPROXIMATELY, @@ -116,7 +119,7 @@ typedef enum UNumberRangeIdentityFallback { * Show the number as the range of two equal values. Use the range pattern always, even if the inputs are the * same. Example (with RangeCollapse.NONE): "$5 – $5" * - * @draft ICU 63 + * @stable ICU 63 */ UNUM_IDENTITY_FALLBACK_RANGE } UNumberRangeIdentityFallback; @@ -125,14 +128,14 @@ typedef enum UNumberRangeIdentityFallback { * Used in the result class FormattedNumberRange to indicate to the user whether the numbers formatted in the range * were equal or not, and whether or not the identity fallback was applied. * - * @draft ICU 63 + * @stable ICU 63 * @see NumberRangeFormatter */ typedef enum UNumberRangeIdentityResult { /** * Used to indicate that the two numbers in the range were equal, even before any rounding rules were applied. * - * @draft ICU 63 + * @stable ICU 63 * @see NumberRangeFormatter */ UNUM_IDENTITY_RESULT_EQUAL_BEFORE_ROUNDING, @@ -140,7 +143,7 @@ typedef enum UNumberRangeIdentityResult { /** * Used to indicate that the two numbers in the range were equal, but only after rounding rules were applied. * - * @draft ICU 63 + * @stable ICU 63 * @see NumberRangeFormatter */ UNUM_IDENTITY_RESULT_EQUAL_AFTER_ROUNDING, @@ -148,7 +151,7 @@ typedef enum UNumberRangeIdentityResult { /** * Used to indicate that the two numbers in the range were not equal, even after rounding rules were applied. * - * @draft ICU 63 + * @stable ICU 63 * @see NumberRangeFormatter */ UNUM_IDENTITY_RESULT_NOT_EQUAL, @@ -254,7 +257,7 @@ class U_I18N_API NumberRangeFormatterSettings { * @param formatter * The formatter to use for both numbers in the range. * @return The fluent chain. - * @draft ICU 63 + * @stable ICU 63 */ Derived numberFormatterBoth(const UnlocalizedNumberFormatter &formatter) const &; @@ -265,7 +268,7 @@ class U_I18N_API NumberRangeFormatterSettings { * The formatter to use for both numbers in the range. * @return The fluent chain. * @see #numberFormatterBoth - * @draft ICU 63 + * @stable ICU 63 */ Derived numberFormatterBoth(const UnlocalizedNumberFormatter &formatter) &&; @@ -276,7 +279,7 @@ class U_I18N_API NumberRangeFormatterSettings { * The formatter to use for both numbers in the range. * @return The fluent chain. * @see #numberFormatterBoth - * @draft ICU 63 + * @stable ICU 63 */ Derived numberFormatterBoth(UnlocalizedNumberFormatter &&formatter) const &; @@ -287,7 +290,7 @@ class U_I18N_API NumberRangeFormatterSettings { * The formatter to use for both numbers in the range. * @return The fluent chain. * @see #numberFormatterBoth - * @draft ICU 63 + * @stable ICU 63 */ Derived numberFormatterBoth(UnlocalizedNumberFormatter &&formatter) &&; @@ -300,7 +303,7 @@ class U_I18N_API NumberRangeFormatterSettings { * @param formatterFirst * The formatter to use for the first number in the range. * @return The fluent chain. - * @draft ICU 63 + * @stable ICU 63 */ Derived numberFormatterFirst(const UnlocalizedNumberFormatter &formatterFirst) const &; @@ -311,7 +314,7 @@ class U_I18N_API NumberRangeFormatterSettings { * The formatter to use for the first number in the range. * @return The fluent chain. * @see #numberFormatterFirst - * @draft ICU 63 + * @stable ICU 63 */ Derived numberFormatterFirst(const UnlocalizedNumberFormatter &formatterFirst) &&; @@ -322,7 +325,7 @@ class U_I18N_API NumberRangeFormatterSettings { * The formatter to use for the first number in the range. * @return The fluent chain. * @see #numberFormatterFirst - * @draft ICU 63 + * @stable ICU 63 */ Derived numberFormatterFirst(UnlocalizedNumberFormatter &&formatterFirst) const &; @@ -333,7 +336,7 @@ class U_I18N_API NumberRangeFormatterSettings { * The formatter to use for the first number in the range. * @return The fluent chain. * @see #numberFormatterFirst - * @draft ICU 63 + * @stable ICU 63 */ Derived numberFormatterFirst(UnlocalizedNumberFormatter &&formatterFirst) &&; @@ -346,7 +349,7 @@ class U_I18N_API NumberRangeFormatterSettings { * @param formatterSecond * The formatter to use for the second number in the range. * @return The fluent chain. - * @draft ICU 63 + * @stable ICU 63 */ Derived numberFormatterSecond(const UnlocalizedNumberFormatter &formatterSecond) const &; @@ -357,7 +360,7 @@ class U_I18N_API NumberRangeFormatterSettings { * The formatter to use for the second number in the range. * @return The fluent chain. * @see #numberFormatterSecond - * @draft ICU 63 + * @stable ICU 63 */ Derived numberFormatterSecond(const UnlocalizedNumberFormatter &formatterSecond) &&; @@ -368,7 +371,7 @@ class U_I18N_API NumberRangeFormatterSettings { * The formatter to use for the second number in the range. * @return The fluent chain. * @see #numberFormatterSecond - * @draft ICU 63 + * @stable ICU 63 */ Derived numberFormatterSecond(UnlocalizedNumberFormatter &&formatterSecond) const &; @@ -379,7 +382,7 @@ class U_I18N_API NumberRangeFormatterSettings { * The formatter to use for the second number in the range. * @return The fluent chain. * @see #numberFormatterSecond - * @draft ICU 63 + * @stable ICU 63 */ Derived numberFormatterSecond(UnlocalizedNumberFormatter &&formatterSecond) &&; @@ -398,7 +401,7 @@ class U_I18N_API NumberRangeFormatterSettings { * @param collapse * The collapsing strategy to use for this range. * @return The fluent chain. - * @draft ICU 63 + * @stable ICU 63 */ Derived collapse(UNumberRangeCollapse collapse) const &; @@ -409,7 +412,7 @@ class U_I18N_API NumberRangeFormatterSettings { * The collapsing strategy to use for this range. * @return The fluent chain. * @see #collapse - * @draft ICU 63 + * @stable ICU 63 */ Derived collapse(UNumberRangeCollapse collapse) &&; @@ -431,7 +434,7 @@ class U_I18N_API NumberRangeFormatterSettings { * @param identityFallback * The strategy to use when formatting two numbers that end up being the same. * @return The fluent chain. - * @draft ICU 63 + * @stable ICU 63 */ Derived identityFallback(UNumberRangeIdentityFallback identityFallback) const &; @@ -442,10 +445,11 @@ class U_I18N_API NumberRangeFormatterSettings { * The strategy to use when formatting two numbers that end up being the same. * @return The fluent chain. * @see #identityFallback - * @draft ICU 63 + * @stable ICU 63 */ Derived identityFallback(UNumberRangeIdentityFallback identityFallback) &&; +#ifndef U_HIDE_DRAFT_API /** * Returns the current (Un)LocalizedNumberRangeFormatter as a LocalPointer * wrapping a heap-allocated copy of the current object. @@ -467,12 +471,13 @@ class U_I18N_API NumberRangeFormatterSettings { * @draft ICU 64 */ LocalPointer clone() &&; +#endif /* U_HIDE_DRAFT_API */ /** * Sets the UErrorCode if an error occurred in the fluent chain. * Preserves older error codes in the outErrorCode. * @return TRUE if U_FAILURE(outErrorCode) - * @draft ICU 63 + * @stable ICU 63 */ UBool copyErrorTo(UErrorCode &outErrorCode) const { if (U_FAILURE(outErrorCode)) { @@ -501,7 +506,7 @@ class U_I18N_API NumberRangeFormatterSettings { * Instances of this class are immutable and thread-safe. * * @see NumberRangeFormatter - * @draft ICU 63 + * @stable ICU 63 */ class U_I18N_API UnlocalizedNumberRangeFormatter : public NumberRangeFormatterSettings, public UMemory { @@ -514,7 +519,7 @@ class U_I18N_API UnlocalizedNumberRangeFormatter * @param locale * The locale to use when loading data for number formatting. * @return The fluent chain. - * @draft ICU 63 + * @stable ICU 63 */ LocalizedNumberRangeFormatter locale(const icu::Locale &locale) const &; @@ -525,40 +530,40 @@ class U_I18N_API UnlocalizedNumberRangeFormatter * The locale to use when loading data for number formatting. * @return The fluent chain. * @see #locale - * @draft ICU 63 + * @stable ICU 63 */ LocalizedNumberRangeFormatter locale(const icu::Locale &locale) &&; /** * Default constructor: puts the formatter into a valid but undefined state. * - * @draft ICU 63 + * @stable ICU 63 */ UnlocalizedNumberRangeFormatter() = default; /** * Returns a copy of this UnlocalizedNumberRangeFormatter. - * @draft ICU 63 + * @stable ICU 63 */ UnlocalizedNumberRangeFormatter(const UnlocalizedNumberRangeFormatter &other); /** * Move constructor: * The source UnlocalizedNumberRangeFormatter will be left in a valid but undefined state. - * @draft ICU 63 + * @stable ICU 63 */ UnlocalizedNumberRangeFormatter(UnlocalizedNumberRangeFormatter&& src) U_NOEXCEPT; /** * Copy assignment operator. - * @draft ICU 63 + * @stable ICU 63 */ UnlocalizedNumberRangeFormatter& operator=(const UnlocalizedNumberRangeFormatter& other); /** * Move assignment operator: * The source UnlocalizedNumberRangeFormatter will be left in a valid but undefined state. - * @draft ICU 63 + * @stable ICU 63 */ UnlocalizedNumberRangeFormatter& operator=(UnlocalizedNumberRangeFormatter&& src) U_NOEXCEPT; @@ -582,7 +587,7 @@ class U_I18N_API UnlocalizedNumberRangeFormatter * Instances of this class are immutable and thread-safe. * * @see NumberFormatter - * @draft ICU 63 + * @stable ICU 63 */ class U_I18N_API LocalizedNumberRangeFormatter : public NumberRangeFormatterSettings, public UMemory { @@ -598,7 +603,7 @@ class U_I18N_API LocalizedNumberRangeFormatter * @param status * Set if an error occurs while formatting. * @return A FormattedNumberRange object; call .toString() to get the string. - * @draft ICU 63 + * @stable ICU 63 */ FormattedNumberRange formatFormattableRange( const Formattable& first, const Formattable& second, UErrorCode& status) const; @@ -606,33 +611,33 @@ class U_I18N_API LocalizedNumberRangeFormatter /** * Default constructor: puts the formatter into a valid but undefined state. * - * @draft ICU 63 + * @stable ICU 63 */ LocalizedNumberRangeFormatter() = default; /** * Returns a copy of this LocalizedNumberRangeFormatter. - * @draft ICU 63 + * @stable ICU 63 */ LocalizedNumberRangeFormatter(const LocalizedNumberRangeFormatter &other); /** * Move constructor: * The source LocalizedNumberRangeFormatter will be left in a valid but undefined state. - * @draft ICU 63 + * @stable ICU 63 */ LocalizedNumberRangeFormatter(LocalizedNumberRangeFormatter&& src) U_NOEXCEPT; /** * Copy assignment operator. - * @draft ICU 63 + * @stable ICU 63 */ LocalizedNumberRangeFormatter& operator=(const LocalizedNumberRangeFormatter& other); /** * Move assignment operator: * The source LocalizedNumberRangeFormatter will be left in a valid but undefined state. - * @draft ICU 63 + * @stable ICU 63 */ LocalizedNumberRangeFormatter& operator=(LocalizedNumberRangeFormatter&& src) U_NOEXCEPT; @@ -651,11 +656,11 @@ class U_I18N_API LocalizedNumberRangeFormatter void formatImpl(impl::UFormattedNumberRangeData& results, bool equalBeforeRounding, UErrorCode& status) const; -#endif +#endif /* U_HIDE_INTERNAL_API */ /** * Destruct this LocalizedNumberRangeFormatter, cleaning up any memory it might own. - * @draft ICU 63 + * @stable ICU 63 */ ~LocalizedNumberRangeFormatter(); @@ -690,7 +695,7 @@ class U_I18N_API LocalizedNumberRangeFormatter * * Instances of this class are immutable and thread-safe. * - * @draft ICU 63 + * @stable ICU 63 */ class U_I18N_API FormattedNumberRange : public UMemory, public FormattedValue { public: @@ -700,7 +705,7 @@ class U_I18N_API FormattedNumberRange : public UMemory, public FormattedValue { * * For more information, see FormattedValue::toString() * - * @draft ICU 63 + * @stable ICU 63 */ UnicodeString toString(UErrorCode& status) const U_OVERRIDE; @@ -714,7 +719,7 @@ class U_I18N_API FormattedNumberRange : public UMemory, public FormattedValue { * * For more information, see FormattedValue::appendTo() * - * @draft ICU 63 + * @stable ICU 63 */ Appendable &appendTo(Appendable &appendable, UErrorCode& status) const U_OVERRIDE; @@ -722,6 +727,7 @@ class U_I18N_API FormattedNumberRange : public UMemory, public FormattedValue { /** @copydoc FormattedValue::nextPosition() */ UBool nextPosition(ConstrainedFieldPosition& cfpos, UErrorCode& status) const U_OVERRIDE; +#ifndef U_HIDE_DRAFT_API /** * Determines the start (inclusive) and end (exclusive) indices of the next occurrence of the given * field in the output string. This allows you to determine the locations of, for example, @@ -799,6 +805,7 @@ class U_I18N_API FormattedNumberRange : public UMemory, public FormattedValue { * @see #getFirstDecimal */ UnicodeString getSecondDecimal(UErrorCode& status) const; +#endif // U_HIDE_DRAFT_API /** * Returns whether the pair of numbers was successfully formatted as a range or whether an identity fallback was @@ -806,7 +813,7 @@ class U_I18N_API FormattedNumberRange : public UMemory, public FormattedValue { * identity fallback was used. * * @return An indication the resulting identity situation in the formatted number range. - * @draft ICU 63 + * @stable ICU 63 * @see UNumberRangeIdentityFallback */ UNumberRangeIdentityResult getIdentityResult(UErrorCode& status) const; @@ -824,20 +831,20 @@ class U_I18N_API FormattedNumberRange : public UMemory, public FormattedValue { /** * Move constructor: * Leaves the source FormattedNumberRange in an undefined state. - * @draft ICU 63 + * @stable ICU 63 */ FormattedNumberRange(FormattedNumberRange&& src) U_NOEXCEPT; /** * Move assignment: * Leaves the source FormattedNumberRange in an undefined state. - * @draft ICU 63 + * @stable ICU 63 */ FormattedNumberRange& operator=(FormattedNumberRange&& src) U_NOEXCEPT; /** * Destruct an instance of FormattedNumberRange, cleaning up any memory it might own. - * @draft ICU 63 + * @stable ICU 63 */ ~FormattedNumberRange(); @@ -850,7 +857,6 @@ class U_I18N_API FormattedNumberRange : public UMemory, public FormattedValue { /** * Internal constructor from data type. Adopts the data pointer. - * @internal */ explicit FormattedNumberRange(impl::UFormattedNumberRangeData *results) : fData(results), fErrorCode(U_ZERO_ERROR) {} @@ -867,7 +873,7 @@ class U_I18N_API FormattedNumberRange : public UMemory, public FormattedValue { /** * See the main description in numberrangeformatter.h for documentation and examples. * - * @draft ICU 63 + * @stable ICU 63 */ class U_I18N_API NumberRangeFormatter final { public: @@ -876,7 +882,7 @@ class U_I18N_API NumberRangeFormatter final { * known at the call site. * * @return An {@link UnlocalizedNumberRangeFormatter}, to be used for chaining. - * @draft ICU 63 + * @stable ICU 63 */ static UnlocalizedNumberRangeFormatter with(); @@ -887,7 +893,7 @@ class U_I18N_API NumberRangeFormatter final { * @param locale * The locale from which to load formats and symbols for number range formatting. * @return A {@link LocalizedNumberRangeFormatter}, to be used for chaining. - * @draft ICU 63 + * @stable ICU 63 */ static LocalizedNumberRangeFormatter withLocale(const Locale &locale); @@ -900,8 +906,9 @@ class U_I18N_API NumberRangeFormatter final { } // namespace number U_NAMESPACE_END -#endif // U_HIDE_DRAFT_API +#endif /* #if !UCONFIG_NO_FORMATTING */ + +#endif /* U_SHOW_CPLUSPLUS_API */ #endif // __NUMBERRANGEFORMATTER_H__ -#endif /* #if !UCONFIG_NO_FORMATTING */ diff --git a/deps/icu-small/source/i18n/unicode/numfmt.h b/deps/icu-small/source/i18n/unicode/numfmt.h index d8704754dc79c2..fbd4fb4e5655b3 100644 --- a/deps/icu-small/source/i18n/unicode/numfmt.h +++ b/deps/icu-small/source/i18n/unicode/numfmt.h @@ -26,6 +26,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** * \file * \brief C++ API: Compatibility APIs for number formatting. @@ -260,6 +262,14 @@ class U_I18N_API NumberFormat : public Format { */ virtual ~NumberFormat(); + /** + * Clones this object polymorphically. + * The caller owns the result and should delete it when done. + * @return clone, or nullptr if an error occurred + * @stable ICU 2.0 + */ + virtual NumberFormat* clone() const = 0; + /** * Return true if the given Format objects are semantically equal. * Objects of different subclasses are considered unequal. @@ -639,7 +649,9 @@ class U_I18N_API NumberFormat : public Format { * @param result Formattable to be set to the parse result. * If parse fails, return contents are undefined. * @param status Output parameter set to a failure error code - * when a failure occurs. + * when a failure occurs. The error code when the + * string fails to parse is U_INVALID_FORMAT_ERROR, + * unless overridden by a subclass. * @see NumberFormat::isParseIntegerOnly * @stable ICU 2.0 */ @@ -1255,5 +1267,7 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // _NUMFMT //eof diff --git a/deps/icu-small/source/i18n/unicode/numsys.h b/deps/icu-small/source/i18n/unicode/numsys.h index 9e32478cf8de73..4fb7f044eddb76 100644 --- a/deps/icu-small/source/i18n/unicode/numsys.h +++ b/deps/icu-small/source/i18n/unicode/numsys.h @@ -20,6 +20,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** * \file * \brief C++ API: NumberingSystem object @@ -210,5 +212,7 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // _NUMSYS //eof diff --git a/deps/icu-small/source/i18n/unicode/plurfmt.h b/deps/icu-small/source/i18n/unicode/plurfmt.h index 6b757c88419316..7373476dca8fc2 100644 --- a/deps/icu-small/source/i18n/unicode/plurfmt.h +++ b/deps/icu-small/source/i18n/unicode/plurfmt.h @@ -16,6 +16,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** * \file * \brief C++ API: PluralFormat object @@ -448,7 +450,7 @@ class U_I18N_API PluralFormat : public Format { * result and should delete it when done. * @stable ICU 4.0 */ - virtual Format* clone(void) const; + virtual PluralFormat* clone() const; /** * Formats a plural message for a number taken from a Formattable object. @@ -522,7 +524,7 @@ class U_I18N_API PluralFormat : public Format { private: /** - * @internal + * @internal (private) */ class U_I18N_API PluralSelector : public UMemory { public: @@ -534,14 +536,11 @@ class U_I18N_API PluralFormat : public Format { * @param number The number to be plural-formatted. * @param ec Error code. * @return The selected PluralFormat keyword. - * @internal + * @internal (private) */ virtual UnicodeString select(void *context, double number, UErrorCode& ec) const = 0; }; - /** - * @internal - */ class U_I18N_API PluralSelectorAdapter : public PluralSelector { public: PluralSelectorAdapter() : pluralRules(NULL) { @@ -549,7 +548,7 @@ class U_I18N_API PluralFormat : public Format { virtual ~PluralSelectorAdapter(); - virtual UnicodeString select(void *context, double number, UErrorCode& /*ec*/) const; /**< @internal */ + virtual UnicodeString select(void *context, double number, UErrorCode& /*ec*/) const; void reset(); @@ -573,7 +572,7 @@ class U_I18N_API PluralFormat : public Format { UnicodeString& format(const Formattable& numberObject, double number, UnicodeString& appendTo, FieldPosition& pos, - UErrorCode& status) const; /**< @internal */ + UErrorCode& status) const; /** * Finds the PluralFormat sub-message for the given number, or the "other" sub-message. @@ -601,5 +600,7 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // _PLURFMT //eof diff --git a/deps/icu-small/source/i18n/unicode/plurrule.h b/deps/icu-small/source/i18n/unicode/plurrule.h index 04bf3970ba0825..a1553567caf8f5 100644 --- a/deps/icu-small/source/i18n/unicode/plurrule.h +++ b/deps/icu-small/source/i18n/unicode/plurrule.h @@ -20,6 +20,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** * \file * \brief C++ API: PluralRules object @@ -533,5 +535,7 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // _PLURRULE //eof diff --git a/deps/icu-small/source/i18n/unicode/rbnf.h b/deps/icu-small/source/i18n/unicode/rbnf.h index f7cd85a322d1f5..1144bd2fb8b1ba 100644 --- a/deps/icu-small/source/i18n/unicode/rbnf.h +++ b/deps/icu-small/source/i18n/unicode/rbnf.h @@ -12,6 +12,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** * \file * \brief C++ API: Rule Based Number Format @@ -696,7 +698,7 @@ class U_I18N_API RuleBasedNumberFormat : public NumberFormat { * @return A copy of the object. * @stable ICU 2.6 */ - virtual Format* clone(void) const; + virtual RuleBasedNumberFormat* clone() const; /** * Return true if the given Format objects are semantically equal. @@ -866,28 +868,6 @@ class U_I18N_API RuleBasedNumberFormat : public NumberFormat { UErrorCode& status) const; protected: - /** - * Format a decimal number. - * The number is a DigitList wrapper onto a floating point decimal number. - * The default implementation in NumberFormat converts the decimal number - * to a double and formats that. Subclasses of NumberFormat that want - * to specifically handle big decimal numbers must override this method. - * class DecimalFormat does so. - * - * @param number The number, a DigitList format Decimal Floating Point. - * @param appendTo Output parameter to receive result. - * Result is appended to existing contents. - * @param posIter On return, can be used to iterate over positions - * of fields generated by this format call. - * @param status Output param filled with success/failure status. - * @return Reference to 'appendTo' parameter. - * @internal - */ - virtual UnicodeString& format(const number::impl::DecimalQuantity &number, - UnicodeString& appendTo, - FieldPositionIterator* posIter, - UErrorCode& status) const; - /** * Format a decimal number. * The number is a DigitList wrapper onto a floating point decimal number. @@ -1135,5 +1115,7 @@ U_NAMESPACE_END /* U_HAVE_RBNF */ #endif +#endif /* U_SHOW_CPLUSPLUS_API */ + /* RBNF_H */ #endif diff --git a/deps/icu-small/source/i18n/unicode/rbtz.h b/deps/icu-small/source/i18n/unicode/rbtz.h index 542a7c140cda2b..95fd7ab85dd13a 100644 --- a/deps/icu-small/source/i18n/unicode/rbtz.h +++ b/deps/icu-small/source/i18n/unicode/rbtz.h @@ -11,6 +11,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** * \file * \brief C++ API: Rule based customizable time zone @@ -121,7 +123,7 @@ class U_I18N_API RuleBasedTimeZone : public BasicTimeZone { * @return A new copy of this TimeZone object. * @stable ICU 3.8 */ - virtual TimeZone* clone(void) const; + virtual RuleBasedTimeZone* clone() const; /** * Returns the TimeZone's adjusted GMT offset (i.e., the number of milliseconds to add @@ -224,6 +226,7 @@ class U_I18N_API RuleBasedTimeZone : public BasicTimeZone { */ virtual UBool useDaylightTime(void) const; +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * Queries if the given date is in daylight savings time in * this time zone. @@ -238,6 +241,7 @@ class U_I18N_API RuleBasedTimeZone : public BasicTimeZone { * @deprecated ICU 2.4. Use Calendar::inDaylightTime() instead. */ virtual UBool inDaylightTime(UDate date, UErrorCode& status) const; +#endif // U_FORCE_HIDE_DEPRECATED_API /** * Returns true if this zone has the same rule and offset as another zone. @@ -359,6 +363,8 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // RBTZ_H //eof diff --git a/deps/icu-small/source/i18n/unicode/regex.h b/deps/icu-small/source/i18n/unicode/regex.h index a0f9839fe75311..75048af06c9aaa 100644 --- a/deps/icu-small/source/i18n/unicode/regex.h +++ b/deps/icu-small/source/i18n/unicode/regex.h @@ -44,6 +44,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + #if !UCONFIG_NO_REGULAR_EXPRESSIONS #include "unicode/uobject.h" @@ -1876,4 +1878,7 @@ class U_I18N_API RegexMatcher U_FINAL : public UObject { U_NAMESPACE_END #endif // UCONFIG_NO_REGULAR_EXPRESSIONS + +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/i18n/unicode/region.h b/deps/icu-small/source/i18n/unicode/region.h index ccd63901a5d1b1..66f5f920757348 100644 --- a/deps/icu-small/source/i18n/unicode/region.h +++ b/deps/icu-small/source/i18n/unicode/region.h @@ -16,10 +16,12 @@ */ #include "unicode/utypes.h" -#include "unicode/uregion.h" + +#if U_SHOW_CPLUSPLUS_API #if !UCONFIG_NO_FORMATTING +#include "unicode/uregion.h" #include "unicode/uobject.h" #include "unicode/uniset.h" #include "unicode/unistr.h" @@ -219,6 +221,9 @@ class U_I18N_API Region : public UObject { U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ + +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // REGION_H //eof diff --git a/deps/icu-small/source/i18n/unicode/reldatefmt.h b/deps/icu-small/source/i18n/unicode/reldatefmt.h index cfcba0902675cc..fb691a545105b6 100644 --- a/deps/icu-small/source/i18n/unicode/reldatefmt.h +++ b/deps/icu-small/source/i18n/unicode/reldatefmt.h @@ -15,6 +15,9 @@ #define __RELDATEFMT_H #include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/uobject.h" #include "unicode/udisplaycontext.h" #include "unicode/ureldatefmt.h" @@ -166,12 +169,24 @@ typedef enum UDateAbsoluteUnit { */ UDAT_ABSOLUTE_NOW, -#ifndef U_HIDE_DRAFT_API /** * Quarter - * @draft ICU 63 + * @stable ICU 63 */ UDAT_ABSOLUTE_QUARTER, + +#ifndef U_HIDE_DRAFT_API + /** + * Hour + * @draft ICU 65 + */ + UDAT_ABSOLUTE_HOUR, + + /** + * Minute + * @draft ICU 65 + */ + UDAT_ABSOLUTE_MINUTE, #endif // U_HIDE_DRAFT_API #ifndef U_HIDE_DEPRECATED_API @@ -179,7 +194,7 @@ typedef enum UDateAbsoluteUnit { * One more than the highest normal UDateAbsoluteUnit value. * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420. */ - UDAT_ABSOLUTE_UNIT_COUNT = UDAT_ABSOLUTE_NOW + 2 + UDAT_ABSOLUTE_UNIT_COUNT = UDAT_ABSOLUTE_NOW + 4 #endif // U_HIDE_DEPRECATED_API } UDateAbsoluteUnit; @@ -246,6 +261,7 @@ class SharedPluralRules; class SharedBreakIterator; class NumberFormat; class UnicodeString; +class FormattedRelativeDateTime; class FormattedRelativeDateTimeData; #ifndef U_HIDE_DRAFT_API @@ -743,4 +759,7 @@ U_NAMESPACE_END #endif /* !UCONFIG_NO_BREAK_ITERATION */ #endif /* !UCONFIG_NO_FORMATTING */ + +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif /* __RELDATEFMT_H */ diff --git a/deps/icu-small/source/i18n/unicode/scientificnumberformatter.h b/deps/icu-small/source/i18n/unicode/scientificnumberformatter.h index 6c99a246625e2e..a56b8ca2685cf2 100644 --- a/deps/icu-small/source/i18n/unicode/scientificnumberformatter.h +++ b/deps/icu-small/source/i18n/unicode/scientificnumberformatter.h @@ -11,6 +11,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + #if !UCONFIG_NO_FORMATTING @@ -157,7 +159,7 @@ class U_I18N_API ScientificNumberFormatter : public UObject { class U_I18N_API SuperscriptStyle : public Style { public: - virtual Style *clone() const; + virtual SuperscriptStyle *clone() const; protected: virtual UnicodeString &format( const UnicodeString &original, @@ -175,7 +177,7 @@ class U_I18N_API ScientificNumberFormatter : public UObject { : Style(), fBeginMarkup(beginMarkup), fEndMarkup(endMarkup) { } - virtual Style *clone() const; + virtual MarkupStyle *clone() const; protected: virtual UnicodeString &format( const UnicodeString &original, @@ -214,4 +216,7 @@ U_NAMESPACE_END #endif /* !UCONFIG_NO_FORMATTING */ + +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/i18n/unicode/search.h b/deps/icu-small/source/i18n/unicode/search.h index 12dd5c77278f67..986205c62f1ec5 100644 --- a/deps/icu-small/source/i18n/unicode/search.h +++ b/deps/icu-small/source/i18n/unicode/search.h @@ -14,6 +14,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** * \file * \brief C++ API: SearchIterator object. @@ -70,8 +72,7 @@ U_NAMESPACE_BEGIN * UErrorCode error = U_ZERO_ERROR; * for (int pos = iter->first(error); pos != USEARCH_DONE; * pos = iter->next(error)) { - * printf("Found match at %d pos, length is %d\n", pos, - * iter.getMatchLength()); + * printf("Found match at %d pos, length is %d\n", pos, iter.getMatchedLength()); * } * * @@ -573,4 +574,6 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_COLLATION */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/i18n/unicode/selfmt.h b/deps/icu-small/source/i18n/unicode/selfmt.h index 08e9d444ee9715..9b98f6db7adb76 100755 --- a/deps/icu-small/source/i18n/unicode/selfmt.h +++ b/deps/icu-small/source/i18n/unicode/selfmt.h @@ -18,9 +18,12 @@ #ifndef SELFMT #define SELFMT +#include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API + #include "unicode/messagepattern.h" #include "unicode/numfmt.h" -#include "unicode/utypes.h" /** * \file @@ -272,7 +275,7 @@ class U_I18N_API SelectFormat : public Format { * result and should delete it when done. * @stable ICU 4.4 */ - virtual Format* clone(void) const; + virtual SelectFormat* clone() const; /** * Format an object to produce a string. @@ -365,5 +368,7 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // _SELFMT //eof diff --git a/deps/icu-small/source/i18n/unicode/simpletz.h b/deps/icu-small/source/i18n/unicode/simpletz.h index 7f5f1664cca503..d7d4123187e071 100644 --- a/deps/icu-small/source/i18n/unicode/simpletz.h +++ b/deps/icu-small/source/i18n/unicode/simpletz.h @@ -28,6 +28,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** * \file * \brief C++ API: SimpleTimeZone is a concrete subclass of TimeZone. @@ -672,6 +674,7 @@ class U_I18N_API SimpleTimeZone: public BasicTimeZone { */ virtual UBool useDaylightTime(void) const; +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * Returns true if the given date is within the period when daylight savings time * is in effect; false otherwise. If the TimeZone doesn't observe daylight savings @@ -687,6 +690,7 @@ class U_I18N_API SimpleTimeZone: public BasicTimeZone { * @deprecated ICU 2.4. Use Calendar::inDaylightTime() instead. */ virtual UBool inDaylightTime(UDate date, UErrorCode& status) const; +#endif // U_FORCE_HIDE_DEPRECATED_API /** * Return true if this zone has the same rules and offset as another zone. @@ -703,7 +707,7 @@ class U_I18N_API SimpleTimeZone: public BasicTimeZone { * @return A new copy of this TimeZone object. * @stable ICU 2.0 */ - virtual TimeZone* clone(void) const; + virtual SimpleTimeZone* clone() const; /** * Gets the first time zone transition after the base time. @@ -929,4 +933,6 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // _SIMPLETZ diff --git a/deps/icu-small/source/i18n/unicode/smpdtfmt.h b/deps/icu-small/source/i18n/unicode/smpdtfmt.h index a015c5be5c877a..79fa817d5afb89 100644 --- a/deps/icu-small/source/i18n/unicode/smpdtfmt.h +++ b/deps/icu-small/source/i18n/unicode/smpdtfmt.h @@ -28,6 +28,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** * \file * \brief C++ API: Format and parse dates in a language-independent manner. @@ -865,7 +867,7 @@ class U_I18N_API SimpleDateFormat: public DateFormat { * @return A copy of the object. * @stable ICU 2.0 */ - virtual Format* clone(void) const; + virtual SimpleDateFormat* clone() const; /** * Return true if the given Format objects are semantically equal. Objects @@ -1643,7 +1645,7 @@ class U_I18N_API SimpleDateFormat: public DateFormat { UBool fHaveDefaultCentury; - BreakIterator* fCapitalizationBrkIter; + const BreakIterator* fCapitalizationBrkIter; }; inline UDate @@ -1656,5 +1658,7 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // _SMPDTFMT //eof diff --git a/deps/icu-small/source/i18n/unicode/sortkey.h b/deps/icu-small/source/i18n/unicode/sortkey.h index 6895be7a2b0ee4..d2d3ca9fd57dd8 100644 --- a/deps/icu-small/source/i18n/unicode/sortkey.h +++ b/deps/icu-small/source/i18n/unicode/sortkey.h @@ -25,6 +25,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** * \file * \brief C++ API: Keys for comparing strings multiple times. @@ -337,4 +339,6 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_COLLATION */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/i18n/unicode/stsearch.h b/deps/icu-small/source/i18n/unicode/stsearch.h index 46bc51b30e2346..f3963711432986 100644 --- a/deps/icu-small/source/i18n/unicode/stsearch.h +++ b/deps/icu-small/source/i18n/unicode/stsearch.h @@ -14,6 +14,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** * \file * \brief C++ API: Service for searching text based on RuleBasedCollator. @@ -119,8 +121,7 @@ U_NAMESPACE_BEGIN * pos != USEARCH_DONE; * pos = iter.next(error)) * { - * printf("Found match at %d pos, length is %d\n", pos, - * iter.getMatchLength()); + * printf("Found match at %d pos, length is %d\n", pos, iter.getMatchedLength()); * } * *

@@ -412,7 +413,7 @@ class U_I18N_API StringSearch U_FINAL : public SearchIterator * @return cloned object * @stable ICU 2.0 */ - virtual SearchIterator * safeClone(void) const; + virtual StringSearch * safeClone() const; /** * ICU "poor man's RTTI", returns a UClassID for the actual class. @@ -502,4 +503,6 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_COLLATION */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/i18n/unicode/tblcoll.h b/deps/icu-small/source/i18n/unicode/tblcoll.h index 24ba213b41eacc..f5dc135bc49fc1 100644 --- a/deps/icu-small/source/i18n/unicode/tblcoll.h +++ b/deps/icu-small/source/i18n/unicode/tblcoll.h @@ -64,6 +64,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + #if !UCONFIG_NO_COLLATION #include "unicode/coll.h" @@ -228,7 +230,7 @@ class U_I18N_API RuleBasedCollator : public Collator { * @return a copy of this object, owned by the caller * @stable ICU 2.0 */ - virtual Collator* clone(void) const; + virtual RuleBasedCollator* clone() const; /** * Creates a collation element iterator for the source string. The caller of @@ -389,6 +391,7 @@ class U_I18N_API RuleBasedCollator : public Collator { */ virtual int32_t hashCode() const; +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * Gets the locale of the Collator * @param type can be either requested, valid or actual locale. For more @@ -400,6 +403,7 @@ class U_I18N_API RuleBasedCollator : public Collator { * @deprecated ICU 2.8 likely to change in ICU 3.0, based on feedback */ virtual Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const; +#endif // U_FORCE_HIDE_DEPRECATED_API /** * Gets the tailoring rules for this collator. @@ -545,6 +549,7 @@ class U_I18N_API RuleBasedCollator : public Collator { */ virtual UColReorderCode getMaxVariable() const; +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * Sets the variable top to the primary weight of the specified string. * @@ -592,6 +597,7 @@ class U_I18N_API RuleBasedCollator : public Collator { * @deprecated ICU 53 Call setMaxVariable() instead. */ virtual void setVariableTop(uint32_t varTop, UErrorCode &status); +#endif // U_FORCE_HIDE_DEPRECATED_API /** * Gets the variable top value of a Collator. @@ -874,4 +880,7 @@ class U_I18N_API RuleBasedCollator : public Collator { U_NAMESPACE_END #endif // !UCONFIG_NO_COLLATION + +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // TBLCOLL_H diff --git a/deps/icu-small/source/i18n/unicode/timezone.h b/deps/icu-small/source/i18n/unicode/timezone.h index 237ed911d09211..4d321186be495d 100644 --- a/deps/icu-small/source/i18n/unicode/timezone.h +++ b/deps/icu-small/source/i18n/unicode/timezone.h @@ -31,6 +31,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** * \file * \brief C++ API: TimeZone object @@ -321,10 +323,6 @@ class U_I18N_API TimeZone : public UObject { * zone is set to the default host time zone. This call adopts the TimeZone object * passed in; the client is no longer responsible for deleting it. * - *

This function is not thread safe. It is an error for multiple threads - * to concurrently attempt to set the default time zone, or for any thread - * to attempt to reference the default zone while another thread is setting it. - * * @param zone A pointer to the new TimeZone object to use as the default. * @stable ICU 2.0 */ @@ -335,8 +333,6 @@ class U_I18N_API TimeZone : public UObject { * Same as adoptDefault(), except that the TimeZone object passed in is NOT adopted; * the caller remains responsible for deleting it. * - *

See the thread safety note under adoptDefault(). - * * @param zone The given timezone. * @system * @stable ICU 2.0 @@ -726,6 +722,7 @@ class U_I18N_API TimeZone : public UObject { */ virtual UBool useDaylightTime(void) const = 0; +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * Queries if the given date is in daylight savings time in * this time zone. @@ -740,6 +737,7 @@ class U_I18N_API TimeZone : public UObject { * @deprecated ICU 2.4. Use Calendar::inDaylightTime() instead. */ virtual UBool inDaylightTime(UDate date, UErrorCode& status) const = 0; +#endif // U_FORCE_HIDE_DEPRECATED_API /** * Returns true if this zone has the same rule and offset as another zone. @@ -758,7 +756,7 @@ class U_I18N_API TimeZone : public UObject { * @return A new copy of this TimeZone object. * @stable ICU 2.0 */ - virtual TimeZone* clone(void) const = 0; + virtual TimeZone* clone() const = 0; /** * Return the class ID for this class. This is useful only for @@ -972,5 +970,7 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif //_TIMEZONE //eof diff --git a/deps/icu-small/source/i18n/unicode/tmunit.h b/deps/icu-small/source/i18n/unicode/tmunit.h index fa59f104734baa..2e949ddfbd560d 100644 --- a/deps/icu-small/source/i18n/unicode/tmunit.h +++ b/deps/icu-small/source/i18n/unicode/tmunit.h @@ -16,6 +16,9 @@ * \brief C++ API: time unit object */ +#include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API #include "unicode/measunit.h" @@ -70,7 +73,7 @@ class U_I18N_API TimeUnit: public MeasureUnit { * Override clone. * @stable ICU 4.2 */ - virtual UObject* clone() const; + virtual TimeUnit* clone() const; /** * Copy operator. @@ -132,6 +135,8 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __TMUNIT_H__ //eof // diff --git a/deps/icu-small/source/i18n/unicode/tmutamt.h b/deps/icu-small/source/i18n/unicode/tmutamt.h index 1717b7605fb3c5..5ce5922cea8346 100644 --- a/deps/icu-small/source/i18n/unicode/tmutamt.h +++ b/deps/icu-small/source/i18n/unicode/tmutamt.h @@ -16,11 +16,15 @@ * \brief C++ API: time unit amount object. */ -#include "unicode/measure.h" -#include "unicode/tmunit.h" +#include "unicode/utypes.h" + +#if U_SHOW_CPLUSPLUS_API #if !UCONFIG_NO_FORMATTING +#include "unicode/measure.h" +#include "unicode/tmunit.h" + U_NAMESPACE_BEGIN @@ -83,7 +87,7 @@ class U_I18N_API TimeUnitAmount: public Measure { * @return a polymorphic clone of this object. The result will have the same class as returned by getDynamicClassID(). * @stable ICU 4.2 */ - virtual UObject* clone() const; + virtual TimeUnitAmount* clone() const; /** @@ -165,6 +169,8 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __TMUTAMT_H__ //eof // diff --git a/deps/icu-small/source/i18n/unicode/tmutfmt.h b/deps/icu-small/source/i18n/unicode/tmutfmt.h index 8f245859a622ba..ad871f7c09fd4f 100644 --- a/deps/icu-small/source/i18n/unicode/tmutfmt.h +++ b/deps/icu-small/source/i18n/unicode/tmutfmt.h @@ -18,8 +18,9 @@ */ +#if U_SHOW_CPLUSPLUS_API + #if !UCONFIG_NO_FORMATTING -#ifndef U_HIDE_DEPRECATED_API #include "unicode/unistr.h" #include "unicode/tmunit.h" @@ -28,6 +29,7 @@ #include "unicode/numfmt.h" #include "unicode/plurrule.h" +#ifndef U_HIDE_DEPRECATED_API /** * Constants for various styles. @@ -124,7 +126,7 @@ class U_I18N_API TimeUnitFormat: public MeasureFormat { * @return A copy of the object. * @deprecated ICU 53 */ - virtual Format* clone(void) const; + virtual TimeUnitFormat* clone() const; /** * Assignment operator @@ -244,5 +246,7 @@ U_NAMESPACE_END #endif /* U_HIDE_DEPRECATED_API */ #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // __TMUTFMT_H__ //eof diff --git a/deps/icu-small/source/i18n/unicode/translit.h b/deps/icu-small/source/i18n/unicode/translit.h index 6b4888145f1be5..fe2568d50aa020 100644 --- a/deps/icu-small/source/i18n/unicode/translit.h +++ b/deps/icu-small/source/i18n/unicode/translit.h @@ -14,6 +14,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** * \file * \brief C++ API: Tranforms text from one format to another. @@ -1588,4 +1590,6 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_TRANSLITERATION */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/i18n/unicode/tzfmt.h b/deps/icu-small/source/i18n/unicode/tzfmt.h index d2aa768b8c8b34..6d3863b1e5add8 100644 --- a/deps/icu-small/source/i18n/unicode/tzfmt.h +++ b/deps/icu-small/source/i18n/unicode/tzfmt.h @@ -16,6 +16,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + #if !UCONFIG_NO_FORMATTING #include "unicode/format.h" @@ -305,7 +307,7 @@ class U_I18N_API TimeZoneFormat : public Format { * @return A copy of the object * @stable ICU 50 */ - virtual Format* clone() const; + virtual TimeZoneFormat* clone() const; /** * Creates an instance of TimeZoneFormat for the given locale. @@ -1094,4 +1096,7 @@ class U_I18N_API TimeZoneFormat : public Format { U_NAMESPACE_END #endif /* !UCONFIG_NO_FORMATTING */ + +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/i18n/unicode/tznames.h b/deps/icu-small/source/i18n/unicode/tznames.h index 399265d85ae66c..860494221df4f8 100644 --- a/deps/icu-small/source/i18n/unicode/tznames.h +++ b/deps/icu-small/source/i18n/unicode/tznames.h @@ -15,6 +15,8 @@ */ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + #if !UCONFIG_NO_FORMATTING #include "unicode/uloc.h" @@ -411,4 +413,7 @@ class U_I18N_API TimeZoneNames : public UObject { U_NAMESPACE_END #endif + +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/i18n/unicode/tzrule.h b/deps/icu-small/source/i18n/unicode/tzrule.h index 171486f1c79d2a..c6d6b9631fcd69 100644 --- a/deps/icu-small/source/i18n/unicode/tzrule.h +++ b/deps/icu-small/source/i18n/unicode/tzrule.h @@ -16,6 +16,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + #if !UCONFIG_NO_FORMATTING #include "unicode/uobject.h" @@ -45,7 +47,7 @@ class U_I18N_API TimeZoneRule : public UObject { * @return A copy of the object. * @stable ICU 3.8 */ - virtual TimeZoneRule* clone(void) const = 0; + virtual TimeZoneRule* clone() const = 0; /** * Return true if the given TimeZoneRule objects are semantically equal. Objects @@ -229,7 +231,7 @@ class U_I18N_API InitialTimeZoneRule : public TimeZoneRule { * @return A copy of the object. * @stable ICU 3.8 */ - virtual InitialTimeZoneRule* clone(void) const; + virtual InitialTimeZoneRule* clone() const; /** * Assignment operator. @@ -440,7 +442,7 @@ class U_I18N_API AnnualTimeZoneRule : public TimeZoneRule { * @return A copy of the object. * @stable ICU 3.8 */ - virtual AnnualTimeZoneRule* clone(void) const; + virtual AnnualTimeZoneRule* clone() const; /** * Assignment operator. @@ -656,7 +658,7 @@ class U_I18N_API TimeArrayTimeZoneRule : public TimeZoneRule { * @return A copy of the object. * @stable ICU 3.8 */ - virtual TimeArrayTimeZoneRule* clone(void) const; + virtual TimeArrayTimeZoneRule* clone() const; /** * Assignment operator. @@ -825,6 +827,8 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // TZRULE_H //eof diff --git a/deps/icu-small/source/i18n/unicode/tztrans.h b/deps/icu-small/source/i18n/unicode/tztrans.h index 1276d67c312b9a..e87fea7c3cee7f 100644 --- a/deps/icu-small/source/i18n/unicode/tztrans.h +++ b/deps/icu-small/source/i18n/unicode/tztrans.h @@ -16,6 +16,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + #if !UCONFIG_NO_FORMATTING #include "unicode/uobject.h" @@ -68,7 +70,7 @@ class U_I18N_API TimeZoneTransition : public UObject { * @return A copy of the object. * @stable ICU 3.8 */ - TimeZoneTransition* clone(void) const; + TimeZoneTransition* clone() const; /** * Assignment operator. @@ -192,6 +194,8 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // TZTRANS_H //eof diff --git a/deps/icu-small/source/i18n/unicode/ucal.h b/deps/icu-small/source/i18n/unicode/ucal.h index 71120b7aed6d0f..eee2ae9e226474 100644 --- a/deps/icu-small/source/i18n/unicode/ucal.h +++ b/deps/icu-small/source/i18n/unicode/ucal.h @@ -441,11 +441,13 @@ enum UCalendarDateFields { /* Do not conditionalize the following with #ifndef U_HIDE_DEPRECATED_API, * it is needed for layout of Calendar, DateFormat, and other objects */ +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * One more than the highest normal UCalendarDateFields value. * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420. */ - UCAL_FIELD_COUNT, + UCAL_FIELD_COUNT, +#endif // U_FORCE_HIDE_DEPRECATED_API /** * Field number indicating the @@ -657,6 +659,42 @@ ucal_getDefaultTimeZone(UChar* result, int32_t resultCapacity, UErrorCode* ec); U_STABLE void U_EXPORT2 ucal_setDefaultTimeZone(const UChar* zoneID, UErrorCode* ec); +#ifndef U_HIDE_DRAFT_API + +/** + * Return the current host time zone. The host time zone is detected from + * the current host system configuration by querying the host operating + * system. If the host system detection routines fail, or if they specify + * a TimeZone or TimeZone offset which is not recognized, then the special + * TimeZone "Etc/Unknown" is returned. + * + * Note that host time zone and the ICU default time zone can be different. + * + * The ICU default time zone does not change once initialized unless modified + * by calling `ucal_setDefaultTimeZone()` or with the C++ TimeZone API, + * `TimeZone::adoptDefault(TimeZone*)`. + * + * If the host operating system configuration has changed since ICU has + * initialized then the returned value can be different than the ICU default + * time zone, even if the default has not changed. + * + *

This function is not thread safe.

+ * + * @param result A buffer to receive the result, or NULL + * @param resultCapacity The capacity of the result buffer + * @param ec input/output error code + * @return The result string length, not including the terminating + * null + * + * @see #UCAL_UNKNOWN_ZONE_ID + * + * @draft ICU 65 + */ +U_DRAFT int32_t U_EXPORT2 +ucal_getHostTimeZone(UChar *result, int32_t resultCapacity, UErrorCode *ec); + +#endif // U_HIDE_DRAFT_API + /** * Return the amount of time in milliseconds that the clock is * advanced during daylight savings time for the given time zone, or diff --git a/deps/icu-small/source/i18n/unicode/ucol.h b/deps/icu-small/source/i18n/unicode/ucol.h index f084ac61e614f3..34b5d2476aaaa5 100644 --- a/deps/icu-small/source/i18n/unicode/ucol.h +++ b/deps/icu-small/source/i18n/unicode/ucol.h @@ -344,11 +344,13 @@ typedef enum { /* Do not conditionalize the following with #ifndef U_HIDE_DEPRECATED_API, * it is needed for layout of RuleBasedCollator object. */ +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * One more than the highest normal UColAttribute value. * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420. */ UCOL_ATTRIBUTE_COUNT +#endif // U_FORCE_HIDE_DEPRECATED_API } UColAttribute; /** Options for retrieving the rule string diff --git a/deps/icu-small/source/i18n/unicode/udat.h b/deps/icu-small/source/i18n/unicode/udat.h index c67a6d6d4b3a79..bdbd080c005821 100644 --- a/deps/icu-small/source/i18n/unicode/udat.h +++ b/deps/icu-small/source/i18n/unicode/udat.h @@ -923,11 +923,13 @@ typedef enum UDateFormatBooleanAttribute { /* Do not conditionalize the following with #ifndef U_HIDE_DEPRECATED_API, * it is needed for layout of DateFormat object. */ +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * One more than the highest normal UDateFormatBooleanAttribute value. * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420. */ UDAT_BOOLEAN_ATTRIBUTE_COUNT = 4 +#endif // U_FORCE_HIDE_DEPRECATED_API } UDateFormatBooleanAttribute; /** diff --git a/deps/icu-small/source/i18n/unicode/udatpg.h b/deps/icu-small/source/i18n/unicode/udatpg.h index 238a27b4f44a35..81956d12705d7d 100644 --- a/deps/icu-small/source/i18n/unicode/udatpg.h +++ b/deps/icu-small/source/i18n/unicode/udatpg.h @@ -88,11 +88,13 @@ typedef enum UDateTimePatternField { /* Do not conditionalize the following with #ifndef U_HIDE_DEPRECATED_API, * it is needed for layout of DateTimePatternGenerator object. */ +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * One more than the highest normal UDateTimePatternField value. * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420. */ UDATPG_FIELD_COUNT +#endif // U_FORCE_HIDE_DEPRECATED_API } UDateTimePatternField; /** diff --git a/deps/icu-small/source/i18n/unicode/uformattedvalue.h b/deps/icu-small/source/i18n/unicode/uformattedvalue.h index d1c2ad1e49f94d..172558f7fb716a 100644 --- a/deps/icu-small/source/i18n/unicode/uformattedvalue.h +++ b/deps/icu-small/source/i18n/unicode/uformattedvalue.h @@ -7,10 +7,11 @@ #include "unicode/utypes.h" #if !UCONFIG_NO_FORMATTING -#ifndef U_HIDE_DRAFT_API #include "unicode/ufieldpositer.h" +#ifndef U_HIDE_DRAFT_API + /** * \file * \brief C API: Abstract operations for localized strings. diff --git a/deps/icu-small/source/i18n/unicode/ulistformatter.h b/deps/icu-small/source/i18n/unicode/ulistformatter.h index 4327fd5ec1bece..0fbf72c9ff6abb 100644 --- a/deps/icu-small/source/i18n/unicode/ulistformatter.h +++ b/deps/icu-small/source/i18n/unicode/ulistformatter.h @@ -41,7 +41,7 @@ struct UFormattedList; * @draft ICU 64 */ typedef struct UFormattedList UFormattedList; -#endif /* U_HIDE_DRAFT_API */ +#endif /* U_HIDE_DRAFT_API */ #ifndef U_HIDE_DRAFT_API /** @@ -61,7 +61,7 @@ typedef enum UListFormatterField { */ ULISTFMT_ELEMENT_FIELD } UListFormatterField; -#endif // U_HIDE_DRAFT_API +#endif /* U_HIDE_DRAFT_API */ /** * Open a new UListFormatter object using the rules for a given locale. diff --git a/deps/icu-small/source/i18n/unicode/unirepl.h b/deps/icu-small/source/i18n/unicode/unirepl.h index 8fb25d46890d9e..61ee37f07054fb 100644 --- a/deps/icu-small/source/i18n/unicode/unirepl.h +++ b/deps/icu-small/source/i18n/unicode/unirepl.h @@ -14,6 +14,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** * \file * \brief C++ API: UnicodeReplacer @@ -96,4 +98,6 @@ class U_I18N_API UnicodeReplacer /* not : public UObject because this is an inte U_NAMESPACE_END +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif diff --git a/deps/icu-small/source/i18n/unicode/unum.h b/deps/icu-small/source/i18n/unicode/unum.h index c03131f372b8ca..77cde03533f4d1 100644 --- a/deps/icu-small/source/i18n/unicode/unum.h +++ b/deps/icu-small/source/i18n/unicode/unum.h @@ -338,11 +338,13 @@ enum UCurrencySpacing { /* Do not conditionalize the following with #ifndef U_HIDE_DEPRECATED_API, * it is needed for layout of DecimalFormatSymbols object. */ +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * One more than the highest normal UCurrencySpacing value. * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420. */ UNUM_CURRENCY_SPACING_COUNT +#endif // U_FORCE_HIDE_DEPRECATED_API }; typedef enum UCurrencySpacing UCurrencySpacing; /**< @stable ICU 4.8 */ @@ -409,7 +411,7 @@ typedef enum UNumberFormatFields { * respectively. * *

NOTE:: New users with are strongly encouraged to - * use unumf_openWithSkeletonAndLocale instead of unum_open. + * use unumf_openForSkeletonAndLocale instead of unum_open. * * @param pattern A pattern specifying the format to use. * This parameter is ignored unless the style is diff --git a/deps/icu-small/source/i18n/unicode/unumberformatter.h b/deps/icu-small/source/i18n/unicode/unumberformatter.h index e4c21a4e4ab1d1..b27507f7a8f561 100644 --- a/deps/icu-small/source/i18n/unicode/unumberformatter.h +++ b/deps/icu-small/source/i18n/unicode/unumberformatter.h @@ -77,8 +77,6 @@ * */ - -#ifndef U_HIDE_DRAFT_API /** * An enum declaring how to render units, including currencies. Example outputs when formatting 123 USD and 123 * meters in en-CA: @@ -95,7 +93,7 @@ *

* This enum is similar to {@link UMeasureFormatWidth}. * - * @draft ICU 60 + * @stable ICU 60 */ typedef enum UNumberUnitWidth { /** @@ -107,7 +105,7 @@ typedef enum UNumberUnitWidth { * In CLDR, this option corresponds to the "Narrow" format for measure units and the "¤¤¤¤¤" placeholder for * currencies. * - * @draft ICU 60 + * @stable ICU 60 */ UNUM_UNIT_WIDTH_NARROW, @@ -123,7 +121,7 @@ typedef enum UNumberUnitWidth { * In CLDR, this option corresponds to the "Short" format for measure units and the "¤" placeholder for * currencies. * - * @draft ICU 60 + * @stable ICU 60 */ UNUM_UNIT_WIDTH_SHORT, @@ -134,7 +132,7 @@ typedef enum UNumberUnitWidth { * In CLDR, this option corresponds to the default format for measure units and the "¤¤¤" placeholder for * currencies. * - * @draft ICU 60 + * @stable ICU 60 */ UNUM_UNIT_WIDTH_FULL_NAME, @@ -145,7 +143,7 @@ typedef enum UNumberUnitWidth { *

* In CLDR, this option corresponds to the "¤¤" placeholder for currencies. * - * @draft ICU 60 + * @stable ICU 60 */ UNUM_UNIT_WIDTH_ISO_CODE, @@ -154,7 +152,7 @@ typedef enum UNumberUnitWidth { * monetary symbols and formats as with SHORT, but omit the currency symbol. For measure units, the behavior is * equivalent to not specifying the unit at all. * - * @draft ICU 60 + * @stable ICU 60 */ UNUM_UNIT_WIDTH_HIDDEN, @@ -165,9 +163,7 @@ typedef enum UNumberUnitWidth { */ UNUM_UNIT_WIDTH_COUNT } UNumberUnitWidth; -#endif /* U_HIDE_DRAFT_API */ -#ifndef U_HIDE_DRAFT_API /** * An enum declaring the strategy for when and how to display grouping separators (i.e., the * separator, often a comma or period, after every 2-3 powers of ten). The choices are several @@ -192,13 +188,13 @@ typedef enum UNumberUnitWidth { * Note: This enum specifies the strategy for grouping sizes. To set which character to use as the * grouping separator, use the "symbols" setter. * - * @draft ICU 63 + * @stable ICU 63 */ typedef enum UNumberGroupingStrategy { /** * Do not display grouping separators in any locale. * - * @draft ICU 61 + * @stable ICU 61 */ UNUM_GROUPING_OFF, @@ -214,7 +210,7 @@ typedef enum UNumberGroupingStrategy { * Locale data is used to determine whether to separate larger numbers into groups of 2 * (customary in South Asia) or groups of 3 (customary in Europe and the Americas). * - * @draft ICU 61 + * @stable ICU 61 */ UNUM_GROUPING_MIN2, @@ -229,7 +225,7 @@ typedef enum UNumberGroupingStrategy { * Locale data is used to determine whether to separate larger numbers into groups of 2 * (customary in South Asia) or groups of 3 (customary in Europe and the Americas). * - * @draft ICU 61 + * @stable ICU 61 */ UNUM_GROUPING_AUTO, @@ -245,7 +241,7 @@ typedef enum UNumberGroupingStrategy { * Locale data is used to determine whether to separate larger numbers into groups of 2 * (customary in South Asia) or groups of 3 (customary in Europe and the Americas). * - * @draft ICU 61 + * @stable ICU 61 */ UNUM_GROUPING_ON_ALIGNED, @@ -253,7 +249,7 @@ typedef enum UNumberGroupingStrategy { * Use the Western defaults: groups of 3 and enabled for all numbers 1000 or greater. Do not use * locale data for determining the grouping strategy. * - * @draft ICU 61 + * @stable ICU 61 */ UNUM_GROUPING_THOUSANDS @@ -269,10 +265,6 @@ typedef enum UNumberGroupingStrategy { } UNumberGroupingStrategy; - -#endif /* U_HIDE_DRAFT_API */ - -#ifndef U_HIDE_DRAFT_API /** * An enum declaring how to denote positive and negative numbers. Example outputs when formatting * 123, 0, and -123 in en-US: @@ -290,14 +282,14 @@ typedef enum UNumberGroupingStrategy { *

* The exact format, including the position and the code point of the sign, differ by locale. * - * @draft ICU 60 + * @stable ICU 60 */ typedef enum UNumberSignDisplay { /** * Show the minus sign on negative numbers, and do not show the sign on positive numbers. This is the default * behavior. * - * @draft ICU 60 + * @stable ICU 60 */ UNUM_SIGN_AUTO, @@ -305,14 +297,14 @@ typedef enum UNumberSignDisplay { * Show the minus sign on negative numbers and the plus sign on positive numbers, including zero. * To hide the sign on zero, see {@link UNUM_SIGN_EXCEPT_ZERO}. * - * @draft ICU 60 + * @stable ICU 60 */ UNUM_SIGN_ALWAYS, /** * Do not show the sign on positive or negative numbers. * - * @draft ICU 60 + * @stable ICU 60 */ UNUM_SIGN_NEVER, @@ -328,7 +320,7 @@ typedef enum UNumberSignDisplay { * AUTO sign display strategy when formatting without a currency unit. This limitation may be lifted in the * future. * - * @draft ICU 60 + * @stable ICU 60 */ UNUM_SIGN_ACCOUNTING, @@ -338,24 +330,25 @@ typedef enum UNumberSignDisplay { * ACCOUNTING sign display strategy. To hide the sign on zero, see * {@link UNUM_SIGN_ACCOUNTING_EXCEPT_ZERO}. * - * @draft ICU 60 + * @stable ICU 60 */ UNUM_SIGN_ACCOUNTING_ALWAYS, /** * Show the minus sign on negative numbers and the plus sign on positive numbers. Do not show a - * sign on zero. + * sign on zero or NaN, unless the sign bit is set (-0.0 gets a sign). * - * @draft ICU 61 + * @stable ICU 61 */ UNUM_SIGN_EXCEPT_ZERO, /** * Use the locale-dependent accounting format on negative numbers, and show the plus sign on - * positive numbers. Do not show a sign on zero. For more information on the accounting format, - * see the ACCOUNTING sign display strategy. + * positive numbers. Do not show a sign on zero or NaN, unless the sign bit is set (-0.0 gets a + * sign). For more information on the accounting format, see the ACCOUNTING sign display + * strategy. * - * @draft ICU 61 + * @stable ICU 61 */ UNUM_SIGN_ACCOUNTING_EXCEPT_ZERO, @@ -366,9 +359,7 @@ typedef enum UNumberSignDisplay { */ UNUM_SIGN_COUNT } UNumberSignDisplay; -#endif /* U_HIDE_DRAFT_API */ -#ifndef U_HIDE_DRAFT_API /** * An enum declaring how to render the decimal separator. * @@ -378,21 +369,21 @@ typedef enum UNumberSignDisplay { *

  • UNUM_DECIMAL_SEPARATOR_ALWAYS: "1.", "1.1" * * - * @draft ICU 60 + * @stable ICU 60 */ typedef enum UNumberDecimalSeparatorDisplay { /** * Show the decimal separator when there are one or more digits to display after the separator, and do not show * it otherwise. This is the default behavior. * - * @draft ICU 60 + * @stable ICU 60 */ UNUM_DECIMAL_SEPARATOR_AUTO, /** * Always show the decimal separator, even if there are no digits to display after the separator. * - * @draft ICU 60 + * @stable ICU 60 */ UNUM_DECIMAL_SEPARATOR_ALWAYS, @@ -403,7 +394,6 @@ typedef enum UNumberDecimalSeparatorDisplay { */ UNUM_DECIMAL_SEPARATOR_COUNT } UNumberDecimalSeparatorDisplay; -#endif /* U_HIDE_DRAFT_API */ struct UNumberFormatter; /** @@ -649,6 +639,13 @@ unumf_resultGetAllFieldPositions(const UFormattedNumber* uresult, UFieldPosition UErrorCode* ec); +// TODO(ICU-20775): Propose this as API. +// NOTE: This is not currently implemented. +// U_DRAFT int32_t U_EXPORT2 +// unumf_resultToDecimalNumber(const UFormattedNumber* uresult, char* buffer, int32_t bufferCapacity, +// UErrorCode* ec); + + /** * Releases the UNumberFormatter created by unumf_openForSkeletonAndLocale(). * diff --git a/deps/icu-small/source/i18n/unicode/usearch.h b/deps/icu-small/source/i18n/unicode/usearch.h index 6b495ef00140f1..d9d84b4f6a9715 100644 --- a/deps/icu-small/source/i18n/unicode/usearch.h +++ b/deps/icu-small/source/i18n/unicode/usearch.h @@ -24,7 +24,7 @@ * \file * \brief C API: StringSearch * - * C Apis for an engine that provides language-sensitive text searching based + * C APIs for an engine that provides language-sensitive text searching based * on the comparison rules defined in a UCollator data struct, * see ucol.h. This ensures that language eccentricity can be * handled, e.g. for the German collator, characters ß and SS will be matched @@ -55,7 +55,7 @@ *

    * This search has APIs similar to that of other text iteration mechanisms * such as the break iterators in ubrk.h. Using these - * APIs, it is easy to scan through text looking for all occurances of + * APIs, it is easy to scan through text looking for all occurrences of * a given pattern. This search iterator allows changing of direction by * calling a reset followed by a next or previous. * Though a direction change can occur without calling reset first, @@ -130,7 +130,7 @@ * pos = usearch_next(search, &status)) * { * printf("Found match at %d pos, length is %d\n", pos, - * usearch_getMatchLength(search)); + * usearch_getMatchedLength(search)); * } * } * @@ -479,7 +479,7 @@ U_STABLE int32_t U_EXPORT2 usearch_getMatchedLength( * possible. If the buffer fits the matched text exactly, a null-termination * is not possible, then a U_STRING_NOT_TERMINATED_ERROR set in status. * Pre-flighting can be either done with length = 0 or the API -* usearch_getMatchLength. +* usearch_getMatchedLength. * @param strsrch search iterator data struct * @param result UChar buffer to store the matched string * @param resultCapacity length of the result buffer @@ -766,7 +766,7 @@ U_STABLE void U_EXPORT2 usearch_reset(UStringSearch *strsrch); #ifndef U_HIDE_INTERNAL_API /** * Simple forward search for the pattern, starting at a specified index, - * and using using a default set search options. + * and using a default set search options. * * This is an experimental function, and is not an official part of the * ICU API. @@ -783,7 +783,7 @@ U_STABLE void U_EXPORT2 usearch_reset(UStringSearch *strsrch); * are part of a combining sequence, as described below. * * A match will not include a partial combining sequence. Combining - * character sequences are considered to be inseperable units, + * character sequences are considered to be inseparable units, * and either match the pattern completely, or are considered to not match * at all. Thus, for example, an A followed a combining accent mark will * not be found when searching for a plain (unaccented) A. (unless @@ -792,7 +792,7 @@ U_STABLE void U_EXPORT2 usearch_reset(UStringSearch *strsrch); * When beginning a search, the initial starting position, startIdx, * is assumed to be an acceptable match boundary with respect to * combining characters. A combining sequence that spans across the - * starting point will not supress a match beginning at startIdx. + * starting point will not suppress a match beginning at startIdx. * * Characters that expand to multiple collation elements * (German sharp-S becoming 'ss', or the composed forms of accented @@ -843,7 +843,7 @@ U_INTERNAL UBool U_EXPORT2 usearch_search(UStringSearch *strsrch, * are part of a combining sequence, as described below. * * A match will not include a partial combining sequence. Combining - * character sequences are considered to be inseperable units, + * character sequences are considered to be inseparable units, * and either match the pattern completely, or are considered to not match * at all. Thus, for example, an A followed a combining accent mark will * not be found when searching for a plain (unaccented) A. (unless @@ -852,7 +852,7 @@ U_INTERNAL UBool U_EXPORT2 usearch_search(UStringSearch *strsrch, * When beginning a search, the initial starting position, startIdx, * is assumed to be an acceptable match boundary with respect to * combining characters. A combining sequence that spans across the - * starting point will not supress a match beginning at startIdx. + * starting point will not suppress a match beginning at startIdx. * * Characters that expand to multiple collation elements * (German sharp-S becoming 'ss', or the composed forms of accented diff --git a/deps/icu-small/source/i18n/unicode/uspoof.h b/deps/icu-small/source/i18n/unicode/uspoof.h index d15ba4b24235dc..63a13387b063be 100644 --- a/deps/icu-small/source/i18n/unicode/uspoof.h +++ b/deps/icu-small/source/i18n/unicode/uspoof.h @@ -353,6 +353,8 @@ * @stable ICU 4.6 */ +U_CDECL_BEGIN + struct USpoofChecker; /** * @stable ICU 4.2 @@ -471,7 +473,6 @@ typedef enum USpoofChecks { */ USPOOF_MIXED_NUMBERS = 128, -#ifndef U_HIDE_DRAFT_API /** * Check that an identifier does not have a combining character following a character in which that * combining character would be hidden; for example 'i' followed by a U+0307 combining dot. @@ -489,10 +490,9 @@ typedef enum USpoofChecks { * * This list and the number of combing characters considered by this check may grow over time. * - * @draft ICU 62 + * @stable ICU 62 */ USPOOF_HIDDEN_OVERLAY = 256, -#endif /* U_HIDE_DRAFT_API */ /** * Enable all spoof checks. @@ -674,25 +674,6 @@ uspoof_openFromSource(const char *confusables, int32_t confusablesLen, U_STABLE void U_EXPORT2 uspoof_close(USpoofChecker *sc); -#if U_SHOW_CPLUSPLUS_API - -U_NAMESPACE_BEGIN - -/** - * \class LocalUSpoofCheckerPointer - * "Smart pointer" class, closes a USpoofChecker via uspoof_close(). - * For most methods see the LocalPointerBase base class. - * - * @see LocalPointerBase - * @see LocalPointer - * @stable ICU 4.4 - */ -U_DEFINE_LOCAL_OPEN_POINTER(LocalUSpoofCheckerPointer, USpoofChecker, uspoof_close); - -U_NAMESPACE_END - -#endif - /** * Clone a Spoof Checker. The clone will be set to perform the same checks * as the original source. @@ -901,54 +882,6 @@ U_STABLE const USet * U_EXPORT2 uspoof_getAllowedChars(const USpoofChecker *sc, UErrorCode *status); -#if U_SHOW_CPLUSPLUS_API -/** - * Limit the acceptable characters to those specified by a Unicode Set. - * Any previously specified character limit is - * is replaced by the new settings. This includes limits on - * characters that were set with the uspoof_setAllowedLocales() function. - * - * The USPOOF_CHAR_LIMIT test is automatically enabled for this - * USoofChecker by this function. - * - * @param sc The USpoofChecker - * @param chars A Unicode Set containing the list of - * characters that are permitted. Ownership of the set - * remains with the caller. The incoming set is cloned by - * this function, so there are no restrictions on modifying - * or deleting the UnicodeSet after calling this function. - * @param status The error code, set if this function encounters a problem. - * @stable ICU 4.2 - */ -U_STABLE void U_EXPORT2 -uspoof_setAllowedUnicodeSet(USpoofChecker *sc, const icu::UnicodeSet *chars, UErrorCode *status); - - -/** - * Get a UnicodeSet for the characters permitted in an identifier. - * This corresponds to the limits imposed by the Set Allowed Characters / - * UnicodeSet functions. Limitations imposed by other checks will not be - * reflected in the set returned by this function. - * - * The returned set will be frozen, meaning that it cannot be modified - * by the caller. - * - * Ownership of the returned set remains with the Spoof Detector. The - * returned set will become invalid if the spoof detector is closed, - * or if a new set of allowed characters is specified. - * - * - * @param sc The USpoofChecker - * @param status The error code, set if this function encounters a problem. - * @return A UnicodeSet containing the characters that are permitted by - * the USPOOF_CHAR_LIMIT test. - * @stable ICU 4.2 - */ -U_STABLE const icu::UnicodeSet * U_EXPORT2 -uspoof_getAllowedUnicodeSet(const USpoofChecker *sc, UErrorCode *status); -#endif - - /** * Check the specified string for possible security issues. * The text to be checked will typically be an identifier of some sort. @@ -1027,43 +960,6 @@ uspoof_checkUTF8(const USpoofChecker *sc, UErrorCode *status); -#if U_SHOW_CPLUSPLUS_API -/** - * Check the specified string for possible security issues. - * The text to be checked will typically be an identifier of some sort. - * The set of checks to be performed is specified with uspoof_setChecks(). - * - * \note - * Consider using the newer API, {@link uspoof_check2UnicodeString}, instead. - * The newer API exposes additional information from the check procedure - * and is otherwise identical to this method. - * - * @param sc The USpoofChecker - * @param id A identifier to be checked for possible security issues. - * @param position Deprecated in ICU 51. Always returns zero. - * Originally, an out parameter for the index of the first - * string position that failed a check. - * This parameter may be NULL. - * @param status The error code, set if an error occurred while attempting to - * perform the check. - * Spoofing or security issues detected with the input string are - * not reported here, but through the function's return value. - * @return An integer value with bits set for any potential security - * or spoofing issues detected. The bits are defined by - * enum USpoofChecks. (returned_value & USPOOF_ALL_CHECKS) - * will be zero if the input string passes all of the - * enabled checks. - * @see uspoof_check2UnicodeString - * @stable ICU 4.2 - */ -U_STABLE int32_t U_EXPORT2 -uspoof_checkUnicodeString(const USpoofChecker *sc, - const icu::UnicodeString &id, - int32_t *position, - UErrorCode *status); -#endif - - /** * Check the specified string for possible security issues. * The text to be checked will typically be an identifier of some sort. @@ -1135,39 +1031,6 @@ uspoof_check2UTF8(const USpoofChecker *sc, USpoofCheckResult* checkResult, UErrorCode *status); -#if U_SHOW_CPLUSPLUS_API -/** - * Check the specified string for possible security issues. - * The text to be checked will typically be an identifier of some sort. - * The set of checks to be performed is specified with uspoof_setChecks(). - * - * @param sc The USpoofChecker - * @param id A identifier to be checked for possible security issues. - * @param checkResult An instance of USpoofCheckResult to be filled with - * details about the identifier. Can be NULL. - * @param status The error code, set if an error occurred while attempting to - * perform the check. - * Spoofing or security issues detected with the input string are - * not reported here, but through the function's return value. - * @return An integer value with bits set for any potential security - * or spoofing issues detected. The bits are defined by - * enum USpoofChecks. (returned_value & USPOOF_ALL_CHECKS) - * will be zero if the input string passes all of the - * enabled checks. Any information in this bitmask will be - * consistent with the information saved in the optional - * checkResult parameter. - * @see uspoof_openCheckResult - * @see uspoof_check2 - * @see uspoof_check2UTF8 - * @stable ICU 58 - */ -U_STABLE int32_t U_EXPORT2 -uspoof_check2UnicodeString(const USpoofChecker *sc, - const icu::UnicodeString &id, - USpoofCheckResult* checkResult, - UErrorCode *status); -#endif - /** * Create a USpoofCheckResult, used by the {@link uspoof_check2} class of functions to return * information about the identifier. Information includes: @@ -1199,32 +1062,6 @@ uspoof_openCheckResult(UErrorCode *status); U_STABLE void U_EXPORT2 uspoof_closeCheckResult(USpoofCheckResult *checkResult); -#if U_SHOW_CPLUSPLUS_API - -U_NAMESPACE_BEGIN - -/** - * \class LocalUSpoofCheckResultPointer - * "Smart pointer" class, closes a USpoofCheckResult via `uspoof_closeCheckResult()`. - * For most methods see the LocalPointerBase base class. - * - * @see LocalPointerBase - * @see LocalPointer - * @stable ICU 58 - */ - -/** - * \cond - * Note: Doxygen is giving a bogus warning on this U_DEFINE_LOCAL_OPEN_POINTER. - * For now, suppress with a Doxygen cond - */ -U_DEFINE_LOCAL_OPEN_POINTER(LocalUSpoofCheckResultPointer, USpoofCheckResult, uspoof_closeCheckResult); -/** \endcond */ - -U_NAMESPACE_END - -#endif - /** * Indicates which of the spoof check(s) have failed. The value is a bitwise OR of the constants for the tests * in question: USPOOF_RESTRICTION_LEVEL, USPOOF_CHAR_LIMIT, and so on. @@ -1355,36 +1192,6 @@ uspoof_areConfusableUTF8(const USpoofChecker *sc, -#if U_SHOW_CPLUSPLUS_API -/** - * A version of {@link uspoof_areConfusable} accepting UnicodeStrings. - * - * @param sc The USpoofChecker - * @param s1 The first of the two identifiers to be compared for - * confusability. The strings are in UTF-8 format. - * @param s2 The second of the two identifiers to be compared for - * confusability. The strings are in UTF-8 format. - * @param status The error code, set if an error occurred while attempting to - * perform the check. - * Confusability of the identifiers is not reported here, - * but through this function's return value. - * @return An integer value with bit(s) set corresponding to - * the type of confusability found, as defined by - * enum USpoofChecks. Zero is returned if the identifiers - * are not confusable. - * - * @stable ICU 4.2 - * - * @see uspoof_areConfusable - */ -U_STABLE int32_t U_EXPORT2 -uspoof_areConfusableUnicodeString(const USpoofChecker *sc, - const icu::UnicodeString &s1, - const icu::UnicodeString &s2, - UErrorCode *status); -#endif - - /** * Get the "skeleton" for an identifier. * Skeletons are a transformation of the input identifier; @@ -1463,38 +1270,6 @@ uspoof_getSkeletonUTF8(const USpoofChecker *sc, char *dest, int32_t destCapacity, UErrorCode *status); -#if U_SHOW_CPLUSPLUS_API -/** - * Get the "skeleton" for an identifier. - * Skeletons are a transformation of the input identifier; - * Two identifiers are confusable if their skeletons are identical. - * See Unicode UAX #39 for additional information. - * - * Using skeletons directly makes it possible to quickly check - * whether an identifier is confusable with any of some large - * set of existing identifiers, by creating an efficiently - * searchable collection of the skeletons. - * - * @param sc The USpoofChecker. - * @param type Deprecated in ICU 58. You may pass any number. - * Originally, controlled which of the Unicode confusable data - * tables to use. - * @param id The input identifier whose skeleton will be computed. - * @param dest The output identifier, to receive the skeleton string. - * @param status The error code, set if an error occurred while attempting to - * perform the check. - * @return A reference to the destination (skeleton) string. - * - * @stable ICU 4.2 - */ -U_I18N_API icu::UnicodeString & U_EXPORT2 -uspoof_getSkeletonUnicodeString(const USpoofChecker *sc, - uint32_t type, - const icu::UnicodeString &id, - icu::UnicodeString &dest, - UErrorCode *status); -#endif /* U_SHOW_CPLUSPLUS_API */ - /** * Get the set of Candidate Characters for Inclusion in Identifiers, as defined * in http://unicode.org/Public/security/latest/xidmodifications.txt @@ -1525,8 +1300,243 @@ uspoof_getInclusionSet(UErrorCode *status); U_STABLE const USet * U_EXPORT2 uspoof_getRecommendedSet(UErrorCode *status); +/** + * Serialize the data for a spoof detector into a chunk of memory. + * The flattened spoof detection tables can later be used to efficiently + * instantiate a new Spoof Detector. + * + * The serialized spoof checker includes only the data compiled from the + * Unicode data tables by uspoof_openFromSource(); it does not include + * include any other state or configuration that may have been set. + * + * @param sc the Spoof Detector whose data is to be serialized. + * @param data a pointer to 32-bit-aligned memory to be filled with the data, + * can be NULL if capacity==0 + * @param capacity the number of bytes available at data, + * or 0 for preflighting + * @param status an in/out ICU UErrorCode; possible errors include: + * - U_BUFFER_OVERFLOW_ERROR if the data storage block is too small for serialization + * - U_ILLEGAL_ARGUMENT_ERROR the data or capacity parameters are bad + * @return the number of bytes written or needed for the spoof data + * + * @see utrie2_openFromSerialized() + * @stable ICU 4.2 + */ +U_STABLE int32_t U_EXPORT2 +uspoof_serialize(USpoofChecker *sc, + void *data, int32_t capacity, + UErrorCode *status); + +U_CDECL_END + #if U_SHOW_CPLUSPLUS_API +U_NAMESPACE_BEGIN + +/** + * \class LocalUSpoofCheckerPointer + * "Smart pointer" class, closes a USpoofChecker via uspoof_close(). + * For most methods see the LocalPointerBase base class. + * + * @see LocalPointerBase + * @see LocalPointer + * @stable ICU 4.4 + */ +/** + * \cond + * Note: Doxygen is giving a bogus warning on this U_DEFINE_LOCAL_OPEN_POINTER. + * For now, suppress with a Doxygen cond + */ +U_DEFINE_LOCAL_OPEN_POINTER(LocalUSpoofCheckerPointer, USpoofChecker, uspoof_close); +/** \endcond */ + +/** + * \class LocalUSpoofCheckResultPointer + * "Smart pointer" class, closes a USpoofCheckResult via `uspoof_closeCheckResult()`. + * For most methods see the LocalPointerBase base class. + * + * @see LocalPointerBase + * @see LocalPointer + * @stable ICU 58 + */ + +/** + * \cond + * Note: Doxygen is giving a bogus warning on this U_DEFINE_LOCAL_OPEN_POINTER. + * For now, suppress with a Doxygen cond + */ +U_DEFINE_LOCAL_OPEN_POINTER(LocalUSpoofCheckResultPointer, USpoofCheckResult, uspoof_closeCheckResult); +/** \endcond */ + +U_NAMESPACE_END + +/** + * Limit the acceptable characters to those specified by a Unicode Set. + * Any previously specified character limit is + * is replaced by the new settings. This includes limits on + * characters that were set with the uspoof_setAllowedLocales() function. + * + * The USPOOF_CHAR_LIMIT test is automatically enabled for this + * USoofChecker by this function. + * + * @param sc The USpoofChecker + * @param chars A Unicode Set containing the list of + * characters that are permitted. Ownership of the set + * remains with the caller. The incoming set is cloned by + * this function, so there are no restrictions on modifying + * or deleting the UnicodeSet after calling this function. + * @param status The error code, set if this function encounters a problem. + * @stable ICU 4.2 + */ +U_STABLE void U_EXPORT2 +uspoof_setAllowedUnicodeSet(USpoofChecker *sc, const icu::UnicodeSet *chars, UErrorCode *status); + + +/** + * Get a UnicodeSet for the characters permitted in an identifier. + * This corresponds to the limits imposed by the Set Allowed Characters / + * UnicodeSet functions. Limitations imposed by other checks will not be + * reflected in the set returned by this function. + * + * The returned set will be frozen, meaning that it cannot be modified + * by the caller. + * + * Ownership of the returned set remains with the Spoof Detector. The + * returned set will become invalid if the spoof detector is closed, + * or if a new set of allowed characters is specified. + * + * + * @param sc The USpoofChecker + * @param status The error code, set if this function encounters a problem. + * @return A UnicodeSet containing the characters that are permitted by + * the USPOOF_CHAR_LIMIT test. + * @stable ICU 4.2 + */ +U_STABLE const icu::UnicodeSet * U_EXPORT2 +uspoof_getAllowedUnicodeSet(const USpoofChecker *sc, UErrorCode *status); + +/** + * Check the specified string for possible security issues. + * The text to be checked will typically be an identifier of some sort. + * The set of checks to be performed is specified with uspoof_setChecks(). + * + * \note + * Consider using the newer API, {@link uspoof_check2UnicodeString}, instead. + * The newer API exposes additional information from the check procedure + * and is otherwise identical to this method. + * + * @param sc The USpoofChecker + * @param id A identifier to be checked for possible security issues. + * @param position Deprecated in ICU 51. Always returns zero. + * Originally, an out parameter for the index of the first + * string position that failed a check. + * This parameter may be NULL. + * @param status The error code, set if an error occurred while attempting to + * perform the check. + * Spoofing or security issues detected with the input string are + * not reported here, but through the function's return value. + * @return An integer value with bits set for any potential security + * or spoofing issues detected. The bits are defined by + * enum USpoofChecks. (returned_value & USPOOF_ALL_CHECKS) + * will be zero if the input string passes all of the + * enabled checks. + * @see uspoof_check2UnicodeString + * @stable ICU 4.2 + */ +U_STABLE int32_t U_EXPORT2 +uspoof_checkUnicodeString(const USpoofChecker *sc, + const icu::UnicodeString &id, + int32_t *position, + UErrorCode *status); + +/** + * Check the specified string for possible security issues. + * The text to be checked will typically be an identifier of some sort. + * The set of checks to be performed is specified with uspoof_setChecks(). + * + * @param sc The USpoofChecker + * @param id A identifier to be checked for possible security issues. + * @param checkResult An instance of USpoofCheckResult to be filled with + * details about the identifier. Can be NULL. + * @param status The error code, set if an error occurred while attempting to + * perform the check. + * Spoofing or security issues detected with the input string are + * not reported here, but through the function's return value. + * @return An integer value with bits set for any potential security + * or spoofing issues detected. The bits are defined by + * enum USpoofChecks. (returned_value & USPOOF_ALL_CHECKS) + * will be zero if the input string passes all of the + * enabled checks. Any information in this bitmask will be + * consistent with the information saved in the optional + * checkResult parameter. + * @see uspoof_openCheckResult + * @see uspoof_check2 + * @see uspoof_check2UTF8 + * @stable ICU 58 + */ +U_STABLE int32_t U_EXPORT2 +uspoof_check2UnicodeString(const USpoofChecker *sc, + const icu::UnicodeString &id, + USpoofCheckResult* checkResult, + UErrorCode *status); + +/** + * A version of {@link uspoof_areConfusable} accepting UnicodeStrings. + * + * @param sc The USpoofChecker + * @param s1 The first of the two identifiers to be compared for + * confusability. The strings are in UTF-8 format. + * @param s2 The second of the two identifiers to be compared for + * confusability. The strings are in UTF-8 format. + * @param status The error code, set if an error occurred while attempting to + * perform the check. + * Confusability of the identifiers is not reported here, + * but through this function's return value. + * @return An integer value with bit(s) set corresponding to + * the type of confusability found, as defined by + * enum USpoofChecks. Zero is returned if the identifiers + * are not confusable. + * + * @stable ICU 4.2 + * + * @see uspoof_areConfusable + */ +U_STABLE int32_t U_EXPORT2 +uspoof_areConfusableUnicodeString(const USpoofChecker *sc, + const icu::UnicodeString &s1, + const icu::UnicodeString &s2, + UErrorCode *status); + +/** + * Get the "skeleton" for an identifier. + * Skeletons are a transformation of the input identifier; + * Two identifiers are confusable if their skeletons are identical. + * See Unicode UAX #39 for additional information. + * + * Using skeletons directly makes it possible to quickly check + * whether an identifier is confusable with any of some large + * set of existing identifiers, by creating an efficiently + * searchable collection of the skeletons. + * + * @param sc The USpoofChecker. + * @param type Deprecated in ICU 58. You may pass any number. + * Originally, controlled which of the Unicode confusable data + * tables to use. + * @param id The input identifier whose skeleton will be computed. + * @param dest The output identifier, to receive the skeleton string. + * @param status The error code, set if an error occurred while attempting to + * perform the check. + * @return A reference to the destination (skeleton) string. + * + * @stable ICU 4.2 + */ +U_I18N_API icu::UnicodeString & U_EXPORT2 +uspoof_getSkeletonUnicodeString(const USpoofChecker *sc, + uint32_t type, + const icu::UnicodeString &id, + icu::UnicodeString &dest, + UErrorCode *status); + /** * Get the set of Candidate Characters for Inclusion in Identifiers, as defined * in http://unicode.org/Public/security/latest/xidmodifications.txt @@ -1559,34 +1569,6 @@ uspoof_getRecommendedUnicodeSet(UErrorCode *status); #endif /* U_SHOW_CPLUSPLUS_API */ -/** - * Serialize the data for a spoof detector into a chunk of memory. - * The flattened spoof detection tables can later be used to efficiently - * instantiate a new Spoof Detector. - * - * The serialized spoof checker includes only the data compiled from the - * Unicode data tables by uspoof_openFromSource(); it does not include - * include any other state or configuration that may have been set. - * - * @param sc the Spoof Detector whose data is to be serialized. - * @param data a pointer to 32-bit-aligned memory to be filled with the data, - * can be NULL if capacity==0 - * @param capacity the number of bytes available at data, - * or 0 for preflighting - * @param status an in/out ICU UErrorCode; possible errors include: - * - U_BUFFER_OVERFLOW_ERROR if the data storage block is too small for serialization - * - U_ILLEGAL_ARGUMENT_ERROR the data or capacity parameters are bad - * @return the number of bytes written or needed for the spoof data - * - * @see utrie2_openFromSerialized() - * @stable ICU 4.2 - */ -U_STABLE int32_t U_EXPORT2 -uspoof_serialize(USpoofChecker *sc, - void *data, int32_t capacity, - UErrorCode *status); - - -#endif +#endif /* UCONFIG_NO_NORMALIZATION */ #endif /* USPOOF_H */ diff --git a/deps/icu-small/source/i18n/unicode/utrans.h b/deps/icu-small/source/i18n/unicode/utrans.h index 7672b4428fba3c..56640eda967cbe 100644 --- a/deps/icu-small/source/i18n/unicode/utrans.h +++ b/deps/icu-small/source/i18n/unicode/utrans.h @@ -142,7 +142,7 @@ typedef struct UTransPosition { int32_t contextLimit; /** - * Beginning index, inclusive, of the text to be transliteratd. + * Beginning index, inclusive, of the text to be transliterated. * INPUT/OUTPUT parameter: This parameter is advanced past * characters that have already been transliterated by a * transliteration operation. @@ -151,7 +151,7 @@ typedef struct UTransPosition { int32_t start; /** - * Ending index, exclusive, of the text to be transliteratd. + * Ending index, exclusive, of the text to be transliterated. * INPUT/OUTPUT parameter: This parameter is updated to reflect * changes in the length of the text, but points to the same * logical position in the text. @@ -389,7 +389,7 @@ utrans_trans(const UTransliterator* trans, /** * Transliterate the portion of the UReplaceable text buffer that can - * be transliterated unambiguosly. This method is typically called + * be transliterated unambiguously. This method is typically called * after new text has been inserted, e.g. as a result of a keyboard * event. The transliterator will try to transliterate characters of * rep between index.cursor and @@ -454,8 +454,7 @@ utrans_transIncremental(const UTransliterator* trans, * zero-terminated. Upon return, the new length is stored in * *textLength. If textLength is NULL then the string is assumed to * be zero-terminated. - * @param textCapacity a pointer to the length of the text buffer. - * Upon return, + * @param textCapacity the length of the text buffer * @param start the beginning index, inclusive; 0 <= start <= * limit. * @param limit pointer to the ending index, exclusive; start <= @@ -479,7 +478,7 @@ utrans_transUChars(const UTransliterator* trans, /** * Transliterate the portion of the UChar* text buffer that can be - * transliterated unambiguosly. See utrans_transIncremental(). The + * transliterated unambiguously. See utrans_transIncremental(). The * string is passed in in a UChar* buffer. The string is modified in * place. If the result is longer than textCapacity, it is truncated. * The actual length of the result is returned in *textLength, if diff --git a/deps/icu-small/source/i18n/unicode/vtzone.h b/deps/icu-small/source/i18n/unicode/vtzone.h index 5d161778682313..43a5652d6a20f0 100644 --- a/deps/icu-small/source/i18n/unicode/vtzone.h +++ b/deps/icu-small/source/i18n/unicode/vtzone.h @@ -11,6 +11,8 @@ #include "unicode/utypes.h" +#if U_SHOW_CPLUSPLUS_API + /** * \file * \brief C++ API: RFC2445 VTIMEZONE support @@ -185,7 +187,7 @@ class U_I18N_API VTimeZone : public BasicTimeZone { * @return A new copy of this TimeZone object. * @stable ICU 3.8 */ - virtual TimeZone* clone(void) const; + virtual VTimeZone* clone() const; /** * Returns the TimeZone's adjusted GMT offset (i.e., the number of milliseconds to add @@ -288,6 +290,7 @@ class U_I18N_API VTimeZone : public BasicTimeZone { */ virtual UBool useDaylightTime(void) const; +#ifndef U_FORCE_HIDE_DEPRECATED_API /** * Queries if the given date is in daylight savings time in * this time zone. @@ -302,6 +305,7 @@ class U_I18N_API VTimeZone : public BasicTimeZone { * @deprecated ICU 2.4. Use Calendar::inDaylightTime() instead. */ virtual UBool inDaylightTime(UDate date, UErrorCode& status) const; +#endif // U_FORCE_HIDE_DEPRECATED_API /** * Returns true if this zone has the same rule and offset as another zone. @@ -453,5 +457,7 @@ U_NAMESPACE_END #endif /* #if !UCONFIG_NO_FORMATTING */ +#endif /* U_SHOW_CPLUSPLUS_API */ + #endif // VTZONE_H //eof diff --git a/deps/icu-small/source/i18n/unum.cpp b/deps/icu-small/source/i18n/unum.cpp index 907a1cd95e138f..ba3d519162ce54 100644 --- a/deps/icu-small/source/i18n/unum.cpp +++ b/deps/icu-small/source/i18n/unum.cpp @@ -135,6 +135,11 @@ unum_open( UNumberFormatStyle style, *status = U_MEMORY_ALLOCATION_ERROR; } + if (U_FAILURE(*status) && retVal != NULL) { + delete retVal; + retVal = NULL; + } + return reinterpret_cast(retVal); } diff --git a/deps/icu-small/source/i18n/usearch.cpp b/deps/icu-small/source/i18n/usearch.cpp index 0e9b876d2babb7..1b22e201e53294 100644 --- a/deps/icu-small/source/i18n/usearch.cpp +++ b/deps/icu-small/source/i18n/usearch.cpp @@ -317,7 +317,7 @@ inline uint16_t initializePatternCETable(UStringSearch *strsrch, uprv_free(pattern->ces); } - uint16_t offset = 0; + uint32_t offset = 0; uint16_t result = 0; int32_t ce; @@ -388,7 +388,7 @@ inline uint16_t initializePatternPCETable(UStringSearch *strsrch, uprv_free(pattern->pces); } - uint16_t offset = 0; + uint32_t offset = 0; uint16_t result = 0; int64_t pce; @@ -1351,7 +1351,7 @@ inline int getUnblockedAccentIndex(UChar *accents, int32_t *accentsindex) * @param destinationlength target array size, returning the appended length * @param source1 null-terminated first array * @param source2 second array -* @param source2length length of seond array +* @param source2length length of second array * @param source3 null-terminated third array * @param status error status if any * @return new destination array, destination if there was no new allocation @@ -1560,7 +1560,7 @@ inline void cleanUpSafeText(const UStringSearch *strsrch, UChar *safetext, /** * Take the rearranged end accents and tries matching. If match failed at -* a seperate preceding set of accents (seperated from the rearranged on by +* a separate preceding set of accents (separated from the rearranged on by * at least a base character) then we rearrange the preceding accents and * tries matching again. * We allow skipping of the ends of the accent set if the ces do not match. @@ -2220,7 +2220,7 @@ int32_t doPreviousCanonicalSuffixMatch(UStringSearch *strsrch, /** * Take the rearranged start accents and tries matching. If match failed at -* a seperate following set of accents (seperated from the rearranged on by +* a separate following set of accents (separated from the rearranged on by * at least a base character) then we rearrange the preceding accents and * tries matching again. * We allow skipping of the ends of the accent set if the ces do not match. @@ -3544,7 +3544,12 @@ const CEI *CEIBuffer::get(int32_t index) { // Verify that it is the next one in sequence, which is all // that is allowed. if (index != limitIx) { - UPRV_UNREACHABLE; + U_ASSERT(FALSE); + // TODO: In ICU 64 the above assert was changed to use UPRV_UNREACHABLE instead + // which unconditionally calls abort(). However, there were cases where this was + // being hit. This change is reverted for now, restoring the existing behavior. + // ICU-20792 tracks the follow-up work/further investigation on this. + return NULL; } // Manage the circular CE buffer indexing @@ -3581,7 +3586,12 @@ const CEI *CEIBuffer::getPrevious(int32_t index) { // Verify that it is the next one in sequence, which is all // that is allowed. if (index != limitIx) { - UPRV_UNREACHABLE; + U_ASSERT(FALSE); + // TODO: In ICU 64 the above assert was changed to use UPRV_UNREACHABLE instead + // which unconditionally calls abort(). However, there were cases where this was + // being hit. This change is reverted for now, restoring the existing behavior. + // ICU-20792 tracks the follow-up work/further investigation on this. + return NULL; } // Manage the circular CE buffer indexing @@ -3852,7 +3862,7 @@ U_CAPI UBool U_EXPORT2 usearch_search(UStringSearch *strsrch, #endif // Input parameter sanity check. - // TODO: should input indicies clip to the text length + // TODO: should input indices clip to the text length // in the same way that UText does. if(strsrch->pattern.cesLength == 0 || startIdx < 0 || @@ -4014,7 +4024,7 @@ U_CAPI UBool U_EXPORT2 usearch_search(UStringSearch *strsrch, // Check for the start of the match being within an Collation Element Expansion, // meaning that the first char of the match is only partially matched. - // With exapnsions, the first CE will report the index of the source + // With expansions, the first CE will report the index of the source // character, and all subsequent (expansions) CEs will report the source index of the // _following_ character. int32_t secondIx = firstCEI->highIndex; diff --git a/deps/icu-small/source/i18n/uspoof.cpp b/deps/icu-small/source/i18n/uspoof.cpp index c8fbec27bb9b6f..c44c60028badcc 100644 --- a/deps/icu-small/source/i18n/uspoof.cpp +++ b/deps/icu-small/source/i18n/uspoof.cpp @@ -349,7 +349,7 @@ uspoof_setAllowedUnicodeSet(USpoofChecker *sc, const UnicodeSet *chars, UErrorCo *status = U_ILLEGAL_ARGUMENT_ERROR; return; } - UnicodeSet *clonedSet = static_cast(chars->clone()); + UnicodeSet *clonedSet = chars->clone(); if (clonedSet == NULL || clonedSet->isBogus()) { *status = U_MEMORY_ALLOCATION_ERROR; return; diff --git a/deps/icu-small/source/i18n/uspoof_impl.cpp b/deps/icu-small/source/i18n/uspoof_impl.cpp index 85a028bdfa02f2..3c1f84a19ba929 100644 --- a/deps/icu-small/source/i18n/uspoof_impl.cpp +++ b/deps/icu-small/source/i18n/uspoof_impl.cpp @@ -82,7 +82,7 @@ SpoofImpl::SpoofImpl(const SpoofImpl &src, UErrorCode &status) : if (src.fSpoofData != NULL) { fSpoofData = src.fSpoofData->addReference(); } - fAllowedCharsSet = static_cast(src.fAllowedCharsSet->clone()); + fAllowedCharsSet = src.fAllowedCharsSet->clone(); fAllowedLocales = uprv_strdup(src.fAllowedLocales); if (fAllowedCharsSet == NULL || fAllowedLocales == NULL) { status = U_MEMORY_ALLOCATION_ERROR; @@ -193,7 +193,7 @@ void SpoofImpl::setAllowedLocales(const char *localesList, UErrorCode &status) { } // Store the updated spoof checker state. - tmpSet = static_cast(allowedChars.clone()); + tmpSet = allowedChars.clone(); const char *tmpLocalesList = uprv_strdup(localesList); if (tmpSet == NULL || tmpLocalesList == NULL) { status = U_MEMORY_ALLOCATION_ERROR; diff --git a/deps/icu-small/source/i18n/vtzone.cpp b/deps/icu-small/source/i18n/vtzone.cpp index e39eada51b7f61..bda3d1115e3d13 100644 --- a/deps/icu-small/source/i18n/vtzone.cpp +++ b/deps/icu-small/source/i18n/vtzone.cpp @@ -965,7 +965,7 @@ VTimeZone::VTimeZone(const VTimeZone& source) tzurl(source.tzurl), lastmod(source.lastmod), olsonzid(source.olsonzid), icutzver(source.icutzver) { if (source.tz != NULL) { - tz = (BasicTimeZone*)source.tz->clone(); + tz = source.tz->clone(); } if (source.vtzlines != NULL) { UErrorCode status = U_ZERO_ERROR; @@ -1007,7 +1007,7 @@ VTimeZone::operator=(const VTimeZone& right) { tz = NULL; } if (right.tz != NULL) { - tz = (BasicTimeZone*)right.tz->clone(); + tz = right.tz->clone(); } if (vtzlines != NULL) { delete vtzlines; @@ -1092,7 +1092,7 @@ VTimeZone::createVTimeZoneFromBasicTimeZone(const BasicTimeZone& basic_time_zone status = U_MEMORY_ALLOCATION_ERROR; return NULL; } - vtz->tz = (BasicTimeZone *)basic_time_zone.clone(); + vtz->tz = basic_time_zone.clone(); if (vtz->tz == NULL) { status = U_MEMORY_ALLOCATION_ERROR; delete vtz; @@ -1177,8 +1177,8 @@ VTimeZone::writeSimple(UDate time, UnicodeString& result, UErrorCode& status) co writeSimple(time, writer, status); } -TimeZone* -VTimeZone::clone(void) const { +VTimeZone* +VTimeZone::clone() const { return new VTimeZone(*this); } @@ -1957,7 +1957,7 @@ VTimeZone::writeZone(VTZWriter& w, BasicTimeZone& basictz, && (atzrule = dynamic_cast(tzt.getTo())) != NULL && atzrule->getEndYear() == AnnualTimeZoneRule::MAX_YEAR ) { - finalDstRule = (AnnualTimeZoneRule*)tzt.getTo()->clone(); + finalDstRule = atzrule->clone(); } if (dstCount > 0) { if (year == dstStartYear + dstCount @@ -2008,7 +2008,7 @@ VTimeZone::writeZone(VTZWriter& w, BasicTimeZone& basictz, && (atzrule = dynamic_cast(tzt.getTo())) != NULL && atzrule->getEndYear() == AnnualTimeZoneRule::MAX_YEAR ) { - finalStdRule = (AnnualTimeZoneRule*)tzt.getTo()->clone(); + finalStdRule = atzrule->clone(); } if (stdCount > 0) { if (year == stdStartYear + stdCount diff --git a/deps/icu-small/source/i18n/windtfmt.cpp b/deps/icu-small/source/i18n/windtfmt.cpp index 983fd46c122e6f..c35adc09875724 100644 --- a/deps/icu-small/source/i18n/windtfmt.cpp +++ b/deps/icu-small/source/i18n/windtfmt.cpp @@ -213,7 +213,7 @@ Win32DateFormat &Win32DateFormat::operator=(const Win32DateFormat &other) return *this; } -Format *Win32DateFormat::clone(void) const +Win32DateFormat *Win32DateFormat::clone() const { return new Win32DateFormat(*this); } diff --git a/deps/icu-small/source/i18n/windtfmt.h b/deps/icu-small/source/i18n/windtfmt.h index 43b6fe6dba269e..f13a1ae687c342 100644 --- a/deps/icu-small/source/i18n/windtfmt.h +++ b/deps/icu-small/source/i18n/windtfmt.h @@ -48,7 +48,7 @@ class Win32DateFormat : public DateFormat virtual ~Win32DateFormat(); - virtual Format *clone(void) const; + virtual Win32DateFormat *clone() const; Win32DateFormat &operator=(const Win32DateFormat &other); diff --git a/deps/icu-small/source/i18n/winnmfmt.cpp b/deps/icu-small/source/i18n/winnmfmt.cpp index b1724b62c27279..1ae2310123a252 100644 --- a/deps/icu-small/source/i18n/winnmfmt.cpp +++ b/deps/icu-small/source/i18n/winnmfmt.cpp @@ -294,7 +294,7 @@ Win32NumberFormat &Win32NumberFormat::operator=(const Win32NumberFormat &other) return *this; } -Format *Win32NumberFormat::clone(void) const +Win32NumberFormat *Win32NumberFormat::clone() const { return new Win32NumberFormat(*this); } diff --git a/deps/icu-small/source/i18n/winnmfmt.h b/deps/icu-small/source/i18n/winnmfmt.h index 7ea5da91705476..8cf59ccf48d740 100644 --- a/deps/icu-small/source/i18n/winnmfmt.h +++ b/deps/icu-small/source/i18n/winnmfmt.h @@ -44,7 +44,7 @@ class Win32NumberFormat : public NumberFormat virtual ~Win32NumberFormat(); - virtual Format *clone(void) const; + virtual Win32NumberFormat *clone() const; Win32NumberFormat &operator=(const Win32NumberFormat &other); diff --git a/deps/icu-small/source/i18n/zonemeta.cpp b/deps/icu-small/source/i18n/zonemeta.cpp index 0e3ee893161122..72c590f424723f 100644 --- a/deps/icu-small/source/i18n/zonemeta.cpp +++ b/deps/icu-small/source/i18n/zonemeta.cpp @@ -30,10 +30,7 @@ #include "olsontz.h" #include "uinvchar.h" -static icu::UMutex *gZoneMetaLock() { - static icu::UMutex m = U_MUTEX_INITIALIZER; - return &m; -} +static icu::UMutex gZoneMetaLock; // CLDR Canonical ID mapping table static UHashtable *gCanonicalIDCache = NULL; @@ -266,11 +263,11 @@ ZoneMeta::getCanonicalCLDRID(const UnicodeString &tzid, UErrorCode& status) { } // Check if it was already cached - umtx_lock(gZoneMetaLock()); + umtx_lock(&gZoneMetaLock); { canonicalID = (const UChar *)uhash_get(gCanonicalIDCache, utzid); } - umtx_unlock(gZoneMetaLock()); + umtx_unlock(&gZoneMetaLock); if (canonicalID != NULL) { return canonicalID; @@ -351,7 +348,7 @@ ZoneMeta::getCanonicalCLDRID(const UnicodeString &tzid, UErrorCode& status) { U_ASSERT(canonicalID != NULL); // canocanilD must be non-NULL here // Put the resolved canonical ID to the cache - umtx_lock(gZoneMetaLock()); + umtx_lock(&gZoneMetaLock); { const UChar* idInCache = (const UChar *)uhash_get(gCanonicalIDCache, utzid); if (idInCache == NULL) { @@ -371,7 +368,7 @@ ZoneMeta::getCanonicalCLDRID(const UnicodeString &tzid, UErrorCode& status) { } } } - umtx_unlock(gZoneMetaLock()); + umtx_unlock(&gZoneMetaLock); } return canonicalID; @@ -449,14 +446,14 @@ ZoneMeta::getCanonicalCountry(const UnicodeString &tzid, UnicodeString &country, // Check if it was already cached UBool cached = FALSE; UBool singleZone = FALSE; - umtx_lock(gZoneMetaLock()); + umtx_lock(&gZoneMetaLock); { singleZone = cached = gSingleZoneCountries->contains((void*)region); if (!cached) { cached = gMultiZonesCountries->contains((void*)region); } } - umtx_unlock(gZoneMetaLock()); + umtx_unlock(&gZoneMetaLock); if (!cached) { // We need to go through all zones associated with the region. @@ -475,7 +472,7 @@ ZoneMeta::getCanonicalCountry(const UnicodeString &tzid, UnicodeString &country, delete ids; // Cache the result - umtx_lock(gZoneMetaLock()); + umtx_lock(&gZoneMetaLock); { UErrorCode ec = U_ZERO_ERROR; if (singleZone) { @@ -488,7 +485,7 @@ ZoneMeta::getCanonicalCountry(const UnicodeString &tzid, UnicodeString &country, } } } - umtx_unlock(gZoneMetaLock()); + umtx_unlock(&gZoneMetaLock); } if (singleZone) { @@ -575,11 +572,11 @@ ZoneMeta::getMetazoneMappings(const UnicodeString &tzid) { // get the mapping from cache const UVector *result = NULL; - umtx_lock(gZoneMetaLock()); + umtx_lock(&gZoneMetaLock); { result = (UVector*) uhash_get(gOlsonToMeta, tzidUChars); } - umtx_unlock(gZoneMetaLock()); + umtx_unlock(&gZoneMetaLock); if (result != NULL) { return result; @@ -593,7 +590,7 @@ ZoneMeta::getMetazoneMappings(const UnicodeString &tzid) { } // put the new one into the cache - umtx_lock(gZoneMetaLock()); + umtx_lock(&gZoneMetaLock); { // make sure it's already created result = (UVector*) uhash_get(gOlsonToMeta, tzidUChars); @@ -621,7 +618,7 @@ ZoneMeta::getMetazoneMappings(const UnicodeString &tzid) { delete tmpResult; } } - umtx_unlock(gZoneMetaLock()); + umtx_unlock(&gZoneMetaLock); return result; } diff --git a/deps/icu-small/source/python/icutools/databuilder/filtration_schema.json b/deps/icu-small/source/python/icutools/databuilder/filtration_schema.json new file mode 100644 index 00000000000000..2b7ff9989992a1 --- /dev/null +++ b/deps/icu-small/source/python/icutools/databuilder/filtration_schema.json @@ -0,0 +1,169 @@ +// Copyright (C) 2018 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html + +{ + "$id": "http://unicode.org/icu-filter-schema", + "$schema": "http://json-schema.org/draft-04/schema#", + "description": "JSON Schema for an ICU data filter file", + "type": "object", + "properties": { + "strategy": { + "type": "string", + "enum": ["additive", "subtractive"] + }, + "localeFilter": { "$ref": "#/definitions/filter" }, + "featureFilters": { + "type": "object", + "additionalProperties": { + "oneOf": [ + { "$ref": "#/definitions/filter" }, + { + "type": "string", + "enum": ["include", "exclude"] + } + ] + } + }, + "resourceFilters": { + "type": "array", + "items": { + "type": "object", + "properties": { + "categories": { + "type": "array", + "items": { "type": "string" } + }, + "files": { "$ref": "#/definitions/filter" }, + "rules": { + "type": "array", + "items": { + "type": "string", + "pattern": "^[+-]/[\\S]*$" + } + } + }, + "required": ["categories", "rules"], + "additionalProperties": false + } + }, + "fileReplacements": { + "type": "object", + "properties": { + "directory": { + "type": "string", + "pattern": "^(\\$SRC|\\$FILTERS|\\$CWD|/$|/[^/]+)(/[^/]+)*$" + }, + "replacements": { + "type": "array", + "items": { + "oneOf": [ + { "type": "string" }, + { + "type": "object", + "properties": { + "src": { "type": "string" }, + "dest": { "type": "string" } + }, + "additionalProperties": false, + "required": ["src", "dest"] + } + ] + } + } + }, + "additionalProperties": false, + "required": ["directory", "replacements"] + }, + "collationUCAData": { + "type": "string", + "enum": ["unihan", "implicithan"] + }, + "usePoolBundle": { + "type": "boolean" + } + }, + "additionalProperties": false, + "definitions": { + "filter": { + "type": "object", + "oneOf": [ + { + "properties": { + "filterType": { + "$ref": "#/definitions/blacklistWhitelistFilterTypes" + }, + "whitelist": { "$ref": "#/definitions/stringList" } + }, + "required": ["whitelist"], + "additionalProperties": false + }, + { + "properties": { + "filterType": { + "$ref": "#/definitions/blacklistWhitelistFilterTypes" + }, + "blacklist": { "$ref": "#/definitions/stringList" } + }, + "required": ["blacklist"], + "additionalProperties": false + }, + { + "properties": { + "filterType": { + "type": "string", + "enum": ["exclude"] + } + }, + "required": ["filterType"], + "additionalProperties": false + }, + { + "properties": { + "filterType": { + "type": "string", + "enum": ["locale"] + }, + "includeChildren": { + "type": "boolean" + }, + "includeScripts": { + "type": "boolean" + }, + "whitelist": { "$ref": "#/definitions/stringList" } + }, + "required": ["filterType", "whitelist"], + "additionalProperties": false + }, + { + "properties": { + "filterType": { + "type": "string", + "enum": ["union"] + }, + "unionOf": { + "type": "array", + "items": { "$ref": "#/definitions/filter" } + } + }, + "required": ["filterType", "unionOf"], + "additionalProperties": false + } + ] + }, + "blacklistWhitelistFilterTypes": { + "type": "string", + "enum": [ + "language", + "regex" + ] + }, + "stringList": { + "type": "array", + "items": { + "type": "string" + }, + "minItems": 1, + "uniqueItems": true + } + } +} diff --git a/deps/icu-small/source/tools/genccode/genccode.c b/deps/icu-small/source/tools/genccode/genccode.c index d35b5890105d9c..91e94d7f5181c4 100644 --- a/deps/icu-small/source/tools/genccode/genccode.c +++ b/deps/icu-small/source/tools/genccode/genccode.c @@ -63,6 +63,7 @@ enum { kOptHelpH = 0, kOptHelpQuestionMark, kOptDestDir, + kOptQuiet, kOptName, kOptEntryPoint, #ifdef CAN_GENERATE_OBJECTS @@ -77,6 +78,7 @@ static UOption options[]={ /*0*/UOPTION_HELP_H, UOPTION_HELP_QUESTION_MARK, UOPTION_DESTDIR, + UOPTION_QUIET, UOPTION_DEF("name", 'n', UOPT_REQUIRES_ARG), UOPTION_DEF("entrypoint", 'e', UOPT_REQUIRES_ARG), #ifdef CAN_GENERATE_OBJECTS @@ -116,6 +118,7 @@ main(int argc, char* argv[]) { "options:\n" "\t-h or -? or --help this usage text\n" "\t-d or --destdir destination directory, followed by the path\n" + "\t-q or --quiet do not display warnings and progress\n" "\t-n or --name symbol prefix, followed by the prefix\n" "\t-e or --entrypoint entry point name, followed by the name (_dat will be appended)\n" "\t-r or --revision Specify a version\n" @@ -159,6 +162,9 @@ main(int argc, char* argv[]) { writeCode = CALL_WRITECCODE; /* TODO: remove writeCode=&writeCCode; */ } + if (options[kOptQuiet].doesOccur) { + verbose = FALSE; + } while(--argc) { filename=getLongPathname(argv[argc]); if (verbose) { @@ -170,13 +176,15 @@ main(int argc, char* argv[]) { writeCCode(filename, options[kOptDestDir].value, options[kOptName].doesOccur ? options[kOptName].value : NULL, options[kOptFilename].doesOccur ? options[kOptFilename].value : NULL, - NULL); + NULL, + 0); break; case CALL_WRITEASSEMBLY: writeAssemblyCode(filename, options[kOptDestDir].value, options[kOptEntryPoint].doesOccur ? options[kOptEntryPoint].value : NULL, options[kOptFilename].doesOccur ? options[kOptFilename].value : NULL, - NULL); + NULL, + 0); break; #ifdef CAN_GENERATE_OBJECTS case CALL_WRITEOBJECT: @@ -184,7 +192,8 @@ main(int argc, char* argv[]) { options[kOptEntryPoint].doesOccur ? options[kOptEntryPoint].value : NULL, options[kOptMatchArch].doesOccur ? options[kOptMatchArch].value : NULL, options[kOptFilename].doesOccur ? options[kOptFilename].value : NULL, - NULL); + NULL, + 0); break; #endif default: diff --git a/deps/icu-small/source/tools/genrb/derb.cpp b/deps/icu-small/source/tools/genrb/derb.cpp index ac26d95be4ca01..997b400129532c 100644 --- a/deps/icu-small/source/tools/genrb/derb.cpp +++ b/deps/icu-small/source/tools/genrb/derb.cpp @@ -631,7 +631,7 @@ static const char *getEncodingName(const char *encoding) { if (!(enc = ucnv_getStandardName(encoding, "MIME", &err))) { err = U_ZERO_ERROR; if (!(enc = ucnv_getStandardName(encoding, "IANA", &err))) { - ; + // do nothing } } diff --git a/deps/icu-small/source/tools/genrb/filterrb.cpp b/deps/icu-small/source/tools/genrb/filterrb.cpp index d62d185d773224..dcc02fc6210903 100644 --- a/deps/icu-small/source/tools/genrb/filterrb.cpp +++ b/deps/icu-small/source/tools/genrb/filterrb.cpp @@ -23,6 +23,9 @@ ResKeyPath::ResKeyPath(const std::string& path, UErrorCode& status) { status = U_PARSE_ERROR; return; } + if (path.length() == 1) { + return; + } size_t i; size_t j = 0; while (true) { diff --git a/deps/icu-small/source/tools/genrb/genrb.cpp b/deps/icu-small/source/tools/genrb/genrb.cpp index 885f3039bf6d7b..6f3a13a0a6107c 100644 --- a/deps/icu-small/source/tools/genrb/genrb.cpp +++ b/deps/icu-small/source/tools/genrb/genrb.cpp @@ -205,10 +205,10 @@ main(int argc, "\t-c or --copyright include copyright notice\n"); fprintf(stderr, "\t-e or --encoding encoding of source files\n" - "\t-d of --destdir destination directory, followed by the path, defaults to %s\n" - "\t-s or --sourcedir source directory for files followed by path, defaults to %s\n" + "\t-d or --destdir destination directory, followed by the path, defaults to '%s'\n" + "\t-s or --sourcedir source directory for files followed by path, defaults to '%s'\n" "\t-i or --icudatadir directory for locating any needed intermediate data files,\n" - "\t followed by path, defaults to %s\n", + "\t followed by path, defaults to '%s'\n", u_getDataDirectory(), u_getDataDirectory(), u_getDataDirectory()); fprintf(stderr, "\t-j or --write-java write a Java ListResourceBundle for ICU4J, followed by optional encoding\n" @@ -240,7 +240,7 @@ main(int argc, "\t (--writePoolBundle and --usePoolBundle cannot be combined)\n"); fprintf(stderr, "\t --filterDir Input directory where filter files are available.\n" - "\t For more on filter files, see Python buildtool.\n"); + "\t For more on filter files, see ICU Data Build Tool.\n"); return illegalArg ? U_ILLEGAL_ARGUMENT_ERROR : U_ZERO_ERROR; } diff --git a/deps/icu-small/source/tools/genrb/parse.cpp b/deps/icu-small/source/tools/genrb/parse.cpp index 884d5d5666081a..18a8c76dbc5df1 100644 --- a/deps/icu-small/source/tools/genrb/parse.cpp +++ b/deps/icu-small/source/tools/genrb/parse.cpp @@ -274,11 +274,11 @@ expect(ParseState* state, enum ETokenType expectedToken, struct UString **tokenV } } -static char *getInvariantString(ParseState* state, uint32_t *line, struct UString *comment, UErrorCode *status) +static char *getInvariantString(ParseState* state, uint32_t *line, struct UString *comment, + int32_t &stringLength, UErrorCode *status) { struct UString *tokenValue; char *result; - uint32_t count; expect(state, TOK_STRING, &tokenValue, comment, line, status); @@ -287,14 +287,13 @@ static char *getInvariantString(ParseState* state, uint32_t *line, struct UStrin return NULL; } - count = u_strlen(tokenValue->fChars); - if(!uprv_isInvariantUString(tokenValue->fChars, count)) { + if(!uprv_isInvariantUString(tokenValue->fChars, tokenValue->fLength)) { *status = U_INVALID_FORMAT_ERROR; error(*line, "invariant characters required for table keys, binary data, etc."); return NULL; } - result = static_cast(uprv_malloc(count+1)); + result = static_cast(uprv_malloc(tokenValue->fLength+1)); if (result == NULL) { @@ -302,7 +301,8 @@ static char *getInvariantString(ParseState* state, uint32_t *line, struct UStrin return NULL; } - u_UCharsToChars(tokenValue->fChars, result, count+1); + u_UCharsToChars(tokenValue->fChars, result, tokenValue->fLength+1); + stringLength = tokenValue->fLength; return result; } @@ -1371,7 +1371,6 @@ parseIntVector(ParseState* state, char *tag, uint32_t startline, const struct US int32_t value; UBool readToken = FALSE; char *stopstring; - uint32_t len; struct UString memberComments; IntVectorResource *result = intvector_open(state->bundle, tag, comment, status); @@ -1404,7 +1403,8 @@ parseIntVector(ParseState* state, char *tag, uint32_t startline, const struct US return result; } - string = getInvariantString(state, NULL, NULL, status); + int32_t stringLength; + string = getInvariantString(state, NULL, NULL, stringLength, status); if (U_FAILURE(*status)) { @@ -1414,9 +1414,9 @@ parseIntVector(ParseState* state, char *tag, uint32_t startline, const struct US /* For handling illegal char in the Intvector */ value = uprv_strtoul(string, &stopstring, 0);/* make intvector support decimal,hexdigit,octal digit ranging from -2^31-2^32-1*/ - len=(uint32_t)(stopstring-string); + int32_t len = (int32_t)(stopstring-string); - if(len==uprv_strlen(string)) + if(len==stringLength) { result->add(value, *status); uprv_free(string); @@ -1454,7 +1454,8 @@ static struct SResource * parseBinary(ParseState* state, char *tag, uint32_t startline, const struct UString *comment, UErrorCode *status) { uint32_t line; - LocalMemory string(getInvariantString(state, &line, NULL, status)); + int32_t stringLength; + LocalMemory string(getInvariantString(state, &line, NULL, stringLength, status)); if (string.isNull() || U_FAILURE(*status)) { return NULL; @@ -1470,46 +1471,45 @@ parseBinary(ParseState* state, char *tag, uint32_t startline, const struct UStri printf(" binary %s at line %i \n", (tag == NULL) ? "(null)" : tag, (int)startline); } - uint32_t count = (uint32_t)uprv_strlen(string.getAlias()); - if (count > 0){ - if((count % 2)==0){ - LocalMemory value; - if (value.allocateInsteadAndCopy(count) == NULL) - { - *status = U_MEMORY_ALLOCATION_ERROR; - return NULL; - } - - char toConv[3] = {'\0', '\0', '\0'}; - for (uint32_t i = 0; i < count; i += 2) - { - toConv[0] = string[i]; - toConv[1] = string[i + 1]; + LocalMemory value; + int32_t count = 0; + if (stringLength > 0 && value.allocateInsteadAndCopy(stringLength) == NULL) + { + *status = U_MEMORY_ALLOCATION_ERROR; + return NULL; + } - char *stopstring; - value[i >> 1] = (uint8_t) uprv_strtoul(toConv, &stopstring, 16); - uint32_t len=(uint32_t)(stopstring-toConv); + char toConv[3] = {'\0', '\0', '\0'}; + for (int32_t i = 0; i < stringLength;) + { + // Skip spaces (which may have been line endings). + char c0 = string[i++]; + if (c0 == ' ') { continue; } + if (i == stringLength) { + *status=U_INVALID_CHAR_FOUND; + error(line, "Encountered invalid binary value (odd number of hex digits)"); + return NULL; + } + toConv[0] = c0; + toConv[1] = string[i++]; - if(len!=2) - { - *status=U_INVALID_CHAR_FOUND; - return NULL; - } - } + char *stopstring; + value[count++] = (uint8_t) uprv_strtoul(toConv, &stopstring, 16); + uint32_t len=(uint32_t)(stopstring-toConv); - return bin_open(state->bundle, tag, count >> 1, value.getAlias(), NULL, comment, status); - } - else + if(len!=2) { - *status = U_INVALID_CHAR_FOUND; - error(line, "Encountered invalid binary value (length is odd)"); + *status=U_INVALID_CHAR_FOUND; + error(line, "Encountered invalid binary value (not all pairs of hex digits)"); return NULL; } } - else - { + + if (count == 0) { warning(startline, "Encountered empty binary value"); return bin_open(state->bundle, tag, 0, NULL, "", comment, status); + } else { + return bin_open(state->bundle, tag, count, value.getAlias(), NULL, comment, status); } } @@ -1520,9 +1520,9 @@ parseInteger(ParseState* state, char *tag, uint32_t startline, const struct UStr int32_t value; char *string; char *stopstring; - uint32_t len; - string = getInvariantString(state, NULL, NULL, status); + int32_t stringLength; + string = getInvariantString(state, NULL, NULL, stringLength, status); if (string == NULL || U_FAILURE(*status)) { @@ -1541,7 +1541,7 @@ parseInteger(ParseState* state, char *tag, uint32_t startline, const struct UStr printf(" integer %s at line %i \n", (tag == NULL) ? "(null)" : tag, (int)startline); } - if (uprv_strlen(string) <= 0) + if (stringLength == 0) { warning(startline, "Encountered empty integer. Default value is 0."); } @@ -1549,8 +1549,8 @@ parseInteger(ParseState* state, char *tag, uint32_t startline, const struct UStr /* Allow integer support for hexdecimal, octal digit and decimal*/ /* and handle illegal char in the integer*/ value = uprv_strtoul(string, &stopstring, 0); - len=(uint32_t)(stopstring-string); - if(len==uprv_strlen(string)) + int32_t len = (int32_t)(stopstring-string); + if(len==stringLength) { result = int_open(state->bundle, tag, value, comment, status); } @@ -1567,7 +1567,8 @@ static struct SResource * parseImport(ParseState* state, char *tag, uint32_t startline, const struct UString* comment, UErrorCode *status) { uint32_t line; - LocalMemory filename(getInvariantString(state, &line, NULL, status)); + int32_t stringLength; + LocalMemory filename(getInvariantString(state, &line, NULL, stringLength, status)); if (U_FAILURE(*status)) { return NULL; @@ -1628,12 +1629,11 @@ parseInclude(ParseState* state, char *tag, uint32_t startline, const struct UStr UCHARBUF *ucbuf; char *fullname = NULL; - int32_t count = 0; const char* cp = NULL; const UChar* uBuffer = NULL; - filename = getInvariantString(state, &line, NULL, status); - count = (int32_t)uprv_strlen(filename); + int32_t stringLength; + filename = getInvariantString(state, &line, NULL, stringLength, status); if (U_FAILURE(*status)) { @@ -1652,7 +1652,7 @@ parseInclude(ParseState* state, char *tag, uint32_t startline, const struct UStr printf(" include %s at line %i \n", (tag == NULL) ? "(null)" : tag, (int)startline); } - fullname = (char *) uprv_malloc(state->inputdirLength + count + 2); + fullname = (char *) uprv_malloc(state->inputdirLength + stringLength + 2); /* test for NULL */ if(fullname == NULL) { diff --git a/deps/icu-small/source/tools/genrb/reslist.cpp b/deps/icu-small/source/tools/genrb/reslist.cpp index bf57516047e901..3186c781e934f3 100644 --- a/deps/icu-small/source/tools/genrb/reslist.cpp +++ b/deps/icu-small/source/tools/genrb/reslist.cpp @@ -1371,7 +1371,7 @@ SRBRoot::compactKeys(UErrorCode &errorCode) { } int32_t keysCount = fUsePoolBundle->fKeysCount + fKeysCount; - if (U_FAILURE(errorCode) || fKeysCount == 0 || fKeyMap != NULL) { + if (U_FAILURE(errorCode) || fKeyMap != NULL) { return; } map = (KeyMapEntry *)uprv_malloc(keysCount * sizeof(KeyMapEntry)); diff --git a/deps/icu-small/source/tools/genrb/rle.c b/deps/icu-small/source/tools/genrb/rle.c index 08495c2b4f4666..3d034f78ca3881 100644 --- a/deps/icu-small/source/tools/genrb/rle.c +++ b/deps/icu-small/source/tools/genrb/rle.c @@ -91,14 +91,14 @@ encodeRunByte(uint16_t* buffer,uint16_t* bufLimit, uint8_t value, int32_t length return buffer; } -#define APPEND( buffer, bufLimit, value, num, status){ \ +#define APPEND( buffer, bufLimit, value, num, status) UPRV_BLOCK_MACRO_BEGIN { \ if(buffer3) && checkAssemblyHeaderName(genccodeAssembly+3)) { - writeAssemblyCode(datFileNamePath, o->tmpDir, o->entryName, NULL, gencFilePath); + writeAssemblyCode( + datFileNamePath, + o->tmpDir, + o->entryName, + NULL, + gencFilePath, + sizeof(gencFilePath)); result = pkg_createWithAssemblyCode(targetDir, mode, gencFilePath); if (result != 0) { @@ -753,7 +766,14 @@ static int32_t pkg_executeOptions(UPKGOptions *o) { /* Try to detect the arch type, use NULL if unsuccessful */ char optMatchArch[10] = { 0 }; pkg_createOptMatchArch(optMatchArch); - writeObjectCode(datFileNamePath, o->tmpDir, o->entryName, (optMatchArch[0] == 0 ? NULL : optMatchArch), NULL, gencFilePath); + writeObjectCode( + datFileNamePath, + o->tmpDir, + o->entryName, + (optMatchArch[0] == 0 ? NULL : optMatchArch), + NULL, + gencFilePath, + sizeof(gencFilePath)); pkg_destroyOptMatchArch(optMatchArch); #if U_PLATFORM_IS_LINUX_BASED result = pkg_generateLibraryFile(targetDir, mode, gencFilePath); @@ -1685,7 +1705,13 @@ static int32_t pkg_createWithoutAssemblyCode(UPKGOptions *o, const char *targetD printf("# Generating %s \n", gencmnFile); } - writeCCode(file, o->tmpDir, dataName[0] != 0 ? dataName : o->shortName, newName[0] != 0 ? newName : NULL, gencmnFile); + writeCCode( + file, + o->tmpDir, + dataName[0] != 0 ? dataName : o->shortName, + newName[0] != 0 ? newName : NULL, + gencmnFile, + sizeof(gencmnFile)); #ifdef USE_SINGLE_CCODE_FILE sprintf(cmd, "#include \"%s\"\n", gencmnFile); @@ -1758,14 +1784,12 @@ static int32_t pkg_createWithoutAssemblyCode(UPKGOptions *o, const char *targetD #ifdef WINDOWS_WITH_MSVC #define LINK_CMD "link.exe /nologo /release /out:" -#define LINK_FLAGS "/DLL /NOENTRY /MANIFEST:NO /implib:" -#ifdef _WIN64 -#define LINK_EXTRA_UWP_FLAGS "/NXCOMPAT /DYNAMICBASE /APPCONTAINER " -#else -#define LINK_EXTRA_UWP_FLAGS "/NXCOMPAT /SAFESEH /DYNAMICBASE /APPCONTAINER /MACHINE:X86" -#endif -#define LINK_EXTRA_UWP_FLAGS_ARM "/NXCOMPAT /DYNAMICBASE /APPCONTAINER /MACHINE:ARM" -#define LINK_EXTRA_NO_UWP_FLAGS "/base:0x4ad00000 " +#define LINK_FLAGS "/NXCOMPAT /DYNAMICBASE /DLL /NOENTRY /MANIFEST:NO /implib:" + +#define LINK_EXTRA_UWP_FLAGS "/APPCONTAINER " +#define LINK_EXTRA_UWP_FLAGS_X86_ONLY "/SAFESEH " + +#define LINK_EXTRA_FLAGS_MACHINE "/MACHINE:" #define LIB_CMD "LIB.exe /nologo /out:" #define LIB_FILE "icudt.lib" #define LIB_EXT UDATA_LIB_SUFFIX @@ -1845,23 +1869,23 @@ static int32_t pkg_createWindowsDLL(const char mode, const char *gencFilePath, U return 0; } - char *extraFlags = ""; + char extraFlags[SMALL_BUFFER_MAX_SIZE] = ""; #ifdef WINDOWS_WITH_MSVC - if (options[UWP_BUILD].doesOccur) - { - if (options[UWP_ARM_BUILD].doesOccur) - { - extraFlags = LINK_EXTRA_UWP_FLAGS_ARM; - } - else - { - extraFlags = LINK_EXTRA_UWP_FLAGS; + if (options[WIN_UWP_BUILD].doesOccur) { + uprv_strcat(extraFlags, LINK_EXTRA_UWP_FLAGS); + + if (options[WIN_DLL_ARCH].doesOccur) { + if (uprv_strcmp(options[WIN_DLL_ARCH].value, "X86") == 0) { + uprv_strcat(extraFlags, LINK_EXTRA_UWP_FLAGS_X86_ONLY); + } } } - else - { - extraFlags = LINK_EXTRA_NO_UWP_FLAGS; + + if (options[WIN_DLL_ARCH].doesOccur) { + uprv_strcat(extraFlags, LINK_EXTRA_FLAGS_MACHINE); + uprv_strcat(extraFlags, options[WIN_DLL_ARCH].value); } + #endif sprintf(cmd, "%s\"%s\" %s %s\"%s\" \"%s\" %s", LINK_CMD, diff --git a/deps/icu-small/source/tools/toolutil/filetools.cpp b/deps/icu-small/source/tools/toolutil/filetools.cpp index 6e88c94b5200b5..0f0e9c59846774 100644 --- a/deps/icu-small/source/tools/toolutil/filetools.cpp +++ b/deps/icu-small/source/tools/toolutil/filetools.cpp @@ -65,7 +65,7 @@ isFileModTimeLater(const char *filePath, const char *checkAgainst, UBool isDir) if (U_FAILURE(status)) { fprintf(stderr, "%s:%d: %s\n", __FILE__, __LINE__, u_errorName(status)); return FALSE; - }; + } if ((subDirp = opendir(newpath.data())) != NULL) { /* If this new path is a directory, make a recursive call with the newpath. */ diff --git a/deps/icu-small/source/tools/toolutil/pkg_genc.cpp b/deps/icu-small/source/tools/toolutil/pkg_genc.cpp index 2a8425e334119e..1a63eb0fa10225 100644 --- a/deps/icu-small/source/tools/toolutil/pkg_genc.cpp +++ b/deps/icu-small/source/tools/toolutil/pkg_genc.cpp @@ -48,6 +48,8 @@ #include "uoptions.h" #include "pkg_genc.h" #include "filetools.h" +#include "charstr.h" +#include "unicode/errorcode.h" #define MAX_COLUMN ((uint32_t)(0xFFFFFFFFU)) @@ -56,7 +58,15 @@ /* prototypes --------------------------------------------------------------- */ static void -getOutFilename(const char *inFilename, const char *destdir, char *outFilename, char *entryName, const char *newSuffix, const char *optFilename); +getOutFilename( + const char *inFilename, + const char *destdir, + char *outFilename, + int32_t outFilenameCapacity, + char *entryName, + int32_t entryNameCapacity, + const char *newSuffix, + const char *optFilename); static uint32_t write8(FileStream *out, uint8_t byte, uint32_t column); @@ -259,13 +269,21 @@ printAssemblyHeadersToStdErr(void) { } U_CAPI void U_EXPORT2 -writeAssemblyCode(const char *filename, const char *destdir, const char *optEntryPoint, const char *optFilename, char *outFilePath) { +writeAssemblyCode( + const char *filename, + const char *destdir, + const char *optEntryPoint, + const char *optFilename, + char *outFilePath, + size_t outFilePathCapacity) { uint32_t column = MAX_COLUMN; - char entry[64]; - uint32_t buffer[1024]; - char *bufferStr = (char *)buffer; + char entry[96]; + union { + uint32_t uint32s[1024]; + char chars[4096]; + } buffer; FileStream *in, *out; - size_t i, length; + size_t i, length, count; in=T_FileStream_open(filename, "rb"); if(in==NULL) { @@ -273,15 +291,27 @@ writeAssemblyCode(const char *filename, const char *destdir, const char *optEntr exit(U_FILE_ACCESS_ERROR); } - getOutFilename(filename, destdir, bufferStr, entry, ".S", optFilename); - out=T_FileStream_open(bufferStr, "w"); + getOutFilename( + filename, + destdir, + buffer.chars, + sizeof(buffer.chars), + entry, + sizeof(entry), + ".S", + optFilename); + out=T_FileStream_open(buffer.chars, "w"); if(out==NULL) { - fprintf(stderr, "genccode: unable to open output file %s\n", bufferStr); + fprintf(stderr, "genccode: unable to open output file %s\n", buffer.chars); exit(U_FILE_ACCESS_ERROR); } if (outFilePath != NULL) { - uprv_strcpy(outFilePath, bufferStr); + if (uprv_strlen(buffer.chars) >= outFilePathCapacity) { + fprintf(stderr, "genccode: filename too long\n"); + exit(U_ILLEGAL_ARGUMENT_ERROR); + } + uprv_strcpy(outFilePath, buffer.chars); } #if defined (WINDOWS_WITH_GNUC) && U_PLATFORM != U_PF_CYGWIN @@ -302,29 +332,42 @@ writeAssemblyCode(const char *filename, const char *destdir, const char *optEntr } } - sprintf(bufferStr, assemblyHeader[assemblyHeaderIndex].header, + count = snprintf( + buffer.chars, sizeof(buffer.chars), + assemblyHeader[assemblyHeaderIndex].header, entry, entry, entry, entry, entry, entry, entry, entry); - T_FileStream_writeLine(out, bufferStr); + if (count >= sizeof(buffer.chars)) { + fprintf(stderr, "genccode: entry name too long (long filename?)\n"); + exit(U_ILLEGAL_ARGUMENT_ERROR); + } + T_FileStream_writeLine(out, buffer.chars); T_FileStream_writeLine(out, assemblyHeader[assemblyHeaderIndex].beginLine); for(;;) { - memset(buffer, 0, sizeof(buffer)); - length=T_FileStream_read(in, buffer, sizeof(buffer)); + memset(buffer.uint32s, 0, sizeof(buffer.uint32s)); + length=T_FileStream_read(in, buffer.uint32s, sizeof(buffer.uint32s)); if(length==0) { break; } - for(i=0; i<(length/sizeof(buffer[0])); i++) { - column = write32(out, buffer[i], column); + for(i=0; i<(length/sizeof(buffer.uint32s[0])); i++) { + // TODO: What if the last read sees length not as a multiple of 4? + column = write32(out, buffer.uint32s[i], column); } } T_FileStream_writeLine(out, "\n"); - sprintf(bufferStr, assemblyHeader[assemblyHeaderIndex].footer, + count = snprintf( + buffer.chars, sizeof(buffer.chars), + assemblyHeader[assemblyHeaderIndex].footer, entry, entry, entry, entry, entry, entry, entry, entry); - T_FileStream_writeLine(out, bufferStr); + if (count >= sizeof(buffer.chars)) { + fprintf(stderr, "genccode: entry name too long (long filename?)\n"); + exit(U_ILLEGAL_ARGUMENT_ERROR); + } + T_FileStream_writeLine(out, buffer.chars); if(T_FileStream_error(in)) { fprintf(stderr, "genccode: file read error while generating from file %s\n", filename); @@ -341,11 +384,17 @@ writeAssemblyCode(const char *filename, const char *destdir, const char *optEntr } U_CAPI void U_EXPORT2 -writeCCode(const char *filename, const char *destdir, const char *optName, const char *optFilename, char *outFilePath) { +writeCCode( + const char *filename, + const char *destdir, + const char *optName, + const char *optFilename, + char *outFilePath, + size_t outFilePathCapacity) { uint32_t column = MAX_COLUMN; - char buffer[4096], entry[64]; + char buffer[4096], entry[96]; FileStream *in, *out; - size_t i, length; + size_t i, length, count; in=T_FileStream_open(filename, "rb"); if(in==NULL) { @@ -354,16 +403,35 @@ writeCCode(const char *filename, const char *destdir, const char *optName, const } if(optName != NULL) { /* prepend 'icudt28_' */ - strcpy(entry, optName); - strcat(entry, "_"); + // +2 includes the _ and the NUL + if (uprv_strlen(optName) + 2 > sizeof(entry)) { + fprintf(stderr, "genccode: entry name too long (long filename?)\n"); + exit(U_ILLEGAL_ARGUMENT_ERROR); + } + strcpy(entry, optName); + strcat(entry, "_"); } else { - entry[0] = 0; + entry[0] = 0; } - getOutFilename(filename, destdir, buffer, entry+uprv_strlen(entry), ".c", optFilename); + getOutFilename( + filename, + destdir, + buffer, + sizeof(buffer), + entry + uprv_strlen(entry), + sizeof(entry) - uprv_strlen(entry), + ".c", + optFilename); + if (outFilePath != NULL) { + if (uprv_strlen(buffer) >= outFilePathCapacity) { + fprintf(stderr, "genccode: filename too long\n"); + exit(U_ILLEGAL_ARGUMENT_ERROR); + } uprv_strcpy(outFilePath, buffer); } + out=T_FileStream_open(buffer, "w"); if(out==NULL) { fprintf(stderr, "genccode: unable to open output file %s\n", buffer); @@ -391,7 +459,7 @@ writeCCode(const char *filename, const char *destdir, const char *optName, const magic numbers we must still use the initial double. [grhoten 4/24/2003] */ - sprintf(buffer, + count = snprintf(buffer, sizeof(buffer), "#ifndef IN_GENERATED_CCODE\n" "#define IN_GENERATED_CCODE\n" "#define U_DISABLE_RENAMING 1\n" @@ -403,6 +471,10 @@ writeCCode(const char *filename, const char *destdir, const char *optName, const " const char *bytes; \n" "} %s={ 0.0, \n", entry); + if (count >= sizeof(buffer)) { + fprintf(stderr, "genccode: entry name too long (long filename?)\n"); + exit(U_ILLEGAL_ARGUMENT_ERROR); + } T_FileStream_writeLine(out, buffer); for(;;) { @@ -418,7 +490,7 @@ writeCCode(const char *filename, const char *destdir, const char *optName, const T_FileStream_writeLine(out, "\"\n};\nU_CDECL_END\n"); #else /* Function renaming shouldn't be done in data */ - sprintf(buffer, + count = snprintf(buffer, sizeof(buffer), "#ifndef IN_GENERATED_CCODE\n" "#define IN_GENERATED_CCODE\n" "#define U_DISABLE_RENAMING 1\n" @@ -430,6 +502,10 @@ writeCCode(const char *filename, const char *destdir, const char *optName, const " uint8_t bytes[%ld]; \n" "} %s={ 0.0, {\n", (long)T_FileStream_size(in), entry); + if (count >= sizeof(buffer)) { + fprintf(stderr, "genccode: entry name too long (long filename?)\n"); + exit(U_ILLEGAL_ARGUMENT_ERROR); + } T_FileStream_writeLine(out, buffer); for(;;) { @@ -583,66 +659,84 @@ write8str(FileStream *out, uint8_t byte, uint32_t column) { #endif static void -getOutFilename(const char *inFilename, const char *destdir, char *outFilename, char *entryName, const char *newSuffix, const char *optFilename) { +getOutFilename( + const char *inFilename, + const char *destdir, + char *outFilename, + int32_t outFilenameCapacity, + char *entryName, + int32_t entryNameCapacity, + const char *newSuffix, + const char *optFilename) { const char *basename=findBasename(inFilename), *suffix=uprv_strrchr(basename, '.'); + icu::CharString outFilenameBuilder; + icu::CharString entryNameBuilder; + icu::ErrorCode status; + /* copy path */ if(destdir!=NULL && *destdir!=0) { - do { - *outFilename++=*destdir++; - } while(*destdir!=0); - if(*(outFilename-1)!=U_FILE_SEP_CHAR) { - *outFilename++=U_FILE_SEP_CHAR; - } - inFilename=basename; + outFilenameBuilder.append(destdir, status); + outFilenameBuilder.ensureEndsWithFileSeparator(status); } else { - while(inFilename= outFilenameCapacity) { + fprintf(stderr, "genccode: output filename too long\n"); + exit(U_ILLEGAL_ARGUMENT_ERROR); + } + + if (entryNameBuilder.length() >= entryNameCapacity) { + fprintf(stderr, "genccode: entry name too long (long filename?)\n"); + exit(U_ILLEGAL_ARGUMENT_ERROR); + } + + uprv_strcpy(outFilename, outFilenameBuilder.data()); + uprv_strcpy(entryName, entryNameBuilder.data()); } #ifdef CAN_GENERATE_OBJECTS @@ -777,7 +871,14 @@ getArchitecture(uint16_t *pCPU, uint16_t *pBits, UBool *pIsBigEndian, const char } U_CAPI void U_EXPORT2 -writeObjectCode(const char *filename, const char *destdir, const char *optEntryPoint, const char *optMatchArch, const char *optFilename, char *outFilePath) { +writeObjectCode( + const char *filename, + const char *destdir, + const char *optEntryPoint, + const char *optMatchArch, + const char *optFilename, + char *outFilePath, + size_t outFilePathCapacity) { /* common variables */ char buffer[4096], entry[96]={ 0 }; FileStream *in, *out; @@ -1061,8 +1162,21 @@ writeObjectCode(const char *filename, const char *destdir, const char *optEntryP } size=T_FileStream_size(in); - getOutFilename(filename, destdir, buffer, entry+entryOffset, newSuffix, optFilename); + getOutFilename( + filename, + destdir, + buffer, + sizeof(buffer), + entry + entryOffset, + sizeof(entry) - entryOffset, + newSuffix, + optFilename); + if (outFilePath != NULL) { + if (uprv_strlen(buffer) >= outFilePathCapacity) { + fprintf(stderr, "genccode: filename too long\n"); + exit(U_ILLEGAL_ARGUMENT_ERROR); + } uprv_strcpy(outFilePath, buffer); } diff --git a/deps/icu-small/source/tools/toolutil/pkg_genc.h b/deps/icu-small/source/tools/toolutil/pkg_genc.h index 5039f27db5e030..47e8304a6890c5 100644 --- a/deps/icu-small/source/tools/toolutil/pkg_genc.h +++ b/deps/icu-small/source/tools/toolutil/pkg_genc.h @@ -75,12 +75,31 @@ U_INTERNAL UBool U_EXPORT2 checkAssemblyHeaderName(const char* optAssembly); U_INTERNAL void U_EXPORT2 -writeCCode(const char *filename, const char *destdir, const char *optName, const char *optFilename, char *outFilePath); +writeCCode( + const char *filename, + const char *destdir, + const char *optName, + const char *optFilename, + char *outFilePath, + size_t outFilePathCapacity); U_INTERNAL void U_EXPORT2 -writeAssemblyCode(const char *filename, const char *destdir, const char *optEntryPoint, const char *optFilename, char *outFilePath); +writeAssemblyCode( + const char *filename, + const char *destdir, + const char *optEntryPoint, + const char *optFilename, + char *outFilePath, + size_t outFilePathCapacity); U_INTERNAL void U_EXPORT2 -writeObjectCode(const char *filename, const char *destdir, const char *optEntryPoint, const char *optMatchArch, const char *optFilename, char *outFilePath); +writeObjectCode( + const char *filename, + const char *destdir, + const char *optEntryPoint, + const char *optMatchArch, + const char *optFilename, + char *outFilePath, + size_t outFilePathCapacity); #endif diff --git a/deps/icu-small/source/tools/toolutil/pkgitems.cpp b/deps/icu-small/source/tools/toolutil/pkgitems.cpp index dd414c2f873e22..b0ea980d605dcb 100644 --- a/deps/icu-small/source/tools/toolutil/pkgitems.cpp +++ b/deps/icu-small/source/tools/toolutil/pkgitems.cpp @@ -305,7 +305,8 @@ ures_enumDependencies(const char *itemName, break; } int32_t length; - const UChar *alias=res_getString(pResData, res, &length); + // No tracing: build tool + const UChar *alias=res_getStringNoTrace(pResData, res, &length); checkAlias(itemName, res, alias, length, useResSuffix, check, context, pErrorCode); } break; diff --git a/deps/icu-small/source/tools/toolutil/toolutil.cpp b/deps/icu-small/source/tools/toolutil/toolutil.cpp index 21dca7fe5d6a82..25f9c116ee18d4 100644 --- a/deps/icu-small/source/tools/toolutil/toolutil.cpp +++ b/deps/icu-small/source/tools/toolutil/toolutil.cpp @@ -243,7 +243,7 @@ struct UToolMemory { char name[64]; int32_t capacity, maxCapacity, size, idx; void *array; - UAlignedMemory staticArray[1]; + alignas(max_align_t) char staticArray[1]; }; U_CAPI UToolMemory * U_EXPORT2 diff --git a/deps/icu-small/source/tools/toolutil/ucbuf.h b/deps/icu-small/source/tools/toolutil/ucbuf.h index 48d41ef4cd2d95..7a9b7af5cc71ac 100644 --- a/deps/icu-small/source/tools/toolutil/ucbuf.h +++ b/deps/icu-small/source/tools/toolutil/ucbuf.h @@ -32,11 +32,11 @@ typedef struct UCHARBUF UCHARBUF; /** * End of file value */ -#define U_EOF 0xFFFFFFFF +#define U_EOF ((int32_t)0xFFFFFFFF) /** * Error value if a sequence cannot be unescaped */ -#define U_ERR 0xFFFFFFFE +#define U_ERR ((int32_t)0xFFFFFFFE) typedef struct ULine ULine; diff --git a/deps/icu-small/source/tools/toolutil/xmlparser.cpp b/deps/icu-small/source/tools/toolutil/xmlparser.cpp index ae7ef170207cf5..e3d5b42ef47a73 100644 --- a/deps/icu-small/source/tools/toolutil/xmlparser.cpp +++ b/deps/icu-small/source/tools/toolutil/xmlparser.cpp @@ -313,7 +313,7 @@ UXMLParser::parseFile(const char *filename, UErrorCode &errorCode) { // reached end of file, convert once more to flush the converter flush=TRUE; } - }; + } exit: ucnv_close(cnv); diff --git a/deps/npm/AUTHORS b/deps/npm/AUTHORS index eef45f2df19be2..9e95ac15f62e79 100644 --- a/deps/npm/AUTHORS +++ b/deps/npm/AUTHORS @@ -672,3 +672,8 @@ Amal Hussein Brett Zamir Menelaos Kotsollaris Mehdi Hasan Khan +Craig Loewen +Fighting-Jack <574637316@qq.com> +Bakel, Roel van +Charlie West-Toebe <38671683+Hoidberg@users.noreply.github.com> +Richard Lau diff --git a/deps/npm/CHANGELOG.md b/deps/npm/CHANGELOG.md index d83c57f6d9a772..945ac7583bac2a 100644 --- a/deps/npm/CHANGELOG.md +++ b/deps/npm/CHANGELOG.md @@ -1,3 +1,79 @@ +## 6.13.4 (2019-12-11) + +## BUGFIXES + +* [`320ac9aee`](https://github.com/npm/cli/commit/320ac9aeeafd11bb693c53b31148b8d10c4165e8) + [npm/bin-links#12](https://github.com/npm/bin-links/pull/12) + [npm/gentle-fs#7](https://github.com/npm/gentle-fs/pull/7) + Do not remove global bin/man links inappropriately + ([@isaacs](https://github.com/isaacs)) + +## DEPENDENCIES + +* [`52fd21061`](https://github.com/npm/cli/commit/52fd21061ff8b1a73429294620ffe5ebaaa60d3e) + `gentle-fs@2.3.0` + ([@isaacs](https://github.com/isaacs)) +* [`d06f5c0b0`](https://github.com/npm/cli/commit/d06f5c0b0611c43b6e70ded92af24fa5d83a0f48) + `bin-links@1.1.6` + ([@isaacs](https://github.com/isaacs)) + +## 6.13.3 (2019-12-09) + +### DEPENDENCIES + +* [`19ce061a2`](https://github.com/npm/cli/commit/19ce061a2ee165d8de862c8f0f733c222846b9e1) + `bin-links@1.1.5` Properly normalize, sanitize, and verify `bin` entries + in `package.json`. +* [`59c836aae`](https://github.com/npm/cli/commit/59c836aae8d0104a767e80c540b963c91774012a) + `npm-packlist@1.4.7` +* [`fb4ecd7d2`](https://github.com/npm/cli/commit/fb4ecd7d2810b0b4897daaf081a5e2f3f483b310) + `pacote@9.5.11` + * [`5f33040`](https://github.com/npm/pacote/commit/5f3304028b6985fd380fc77c4840ff12a4898301) + [#476](https://github.com/npm/cli/issues/476) + [npm/pacote#22](https://github.com/npm/pacote/issues/22) + [npm/pacote#14](https://github.com/npm/pacote/issues/14) fix: Do not + drop perms in git when not root ([isaacs](https://github.com/isaacs), + [@darcyclarke](https://github.com/darcyclarke)) + * [`6f229f7`](https://github.com/npm/pacote/6f229f78d9911b4734f0a19c6afdc5454034c759) + sanitize and normalize package bin field + ([isaacs](https://github.com/isaacs)) +* [`1743cb339`](https://github.com/npm/cli/commit/1743cb339767e86431dcd565c7bdb0aed67b293d) + `read-package-json@2.1.1` + + +## 6.13.2 (2019-12-03) + +### BUG FIXES + +* [`4429645b3`](https://github.com/npm/cli/commit/4429645b3538e1cda54d8d1b7ecb3da7a88fdd3c) + [#546](https://github.com/npm/cli/pull/546) + fix docs target typo + ([@richardlau](https://github.com/richardlau)) +* [`867642942`](https://github.com/npm/cli/commit/867642942bec69bb9ab71cff1914fb6a9fe67de8) + [#142](https://github.com/npm/cli/pull/142) + fix(packageRelativePath): fix 'where' for file deps + ([@larsgw](https://github.com/larsgw)) +* [`d480f2c17`](https://github.com/npm/cli/commit/d480f2c176e6976b3cca3565e4c108b599b0379b) + [#527](https://github.com/npm/cli/pull/527) + Revert "windows: Add preliminary WSL support for npm and npx" + ([@craigloewen-msft](https://github.com/craigloewen-msft)) +* [`e4b97962e`](https://github.com/npm/cli/commit/e4b97962e5fce0d49beb541ce5a0f96aee0525de) + [#504](https://github.com/npm/cli/pull/504) + remove unnecessary package.json read when reading shrinkwrap + ([@Lighting-Jack](https://github.com/Lighting-Jack)) +* [`1c65d26ac`](https://github.com/npm/cli/commit/1c65d26ac9f10ac0037094c207d216fbf0e969bf) + [#501](https://github.com/npm/cli/pull/501) + fix(fund): open url for string shorthand + ([@ruyadorno](https://github.com/ruyadorno)) +* [`ae7afe565`](https://github.com/npm/cli/commit/ae7afe56504dbffabf9f73d55b6dac1e3e9fed4a) + [#263](https://github.com/npm/cli/pull/263) + Don't log error message if git tagging is disabled + ([@woppa684](https://github.com/woppa684)) +* [`4c1b16f6a`](https://github.com/npm/cli/commit/4c1b16f6aecaf78956b9335734cfde2ac076ee11) + [#182](https://github.com/npm/cli/pull/182) + Warn the user that it is uninstalling npm-install + ([@Hoidberg](https://github.com/Hoidberg)) + ## 6.13.1 (2019-11-18) ### BUG FIXES diff --git a/deps/npm/Makefile b/deps/npm/Makefile index 11e656c43a458f..dde925f1c438ca 100644 --- a/deps/npm/Makefile +++ b/deps/npm/Makefile @@ -129,11 +129,11 @@ publish: gitclean ls-ok link docs-clean docs git push origin --tags &&\ node bin/npm-cli.js publish --tag=$(PUBLISHTAG) -release: gitclean ls-ok markedclean marked-manclean docs-clean doc +release: gitclean ls-ok markedclean marked-manclean docs-clean docs node bin/npm-cli.js prune --production --no-save @bash scripts/release.sh sandwich: @[ $$(whoami) = "root" ] && (echo "ok"; echo "ham" > sandwich) || (echo "make it yourself" && exit 13) -.PHONY: all latest install dev link doc clean uninstall test man docs-clean docclean release ls-ok realclean +.PHONY: all latest install dev link docs clean uninstall test man docs-clean docclean release ls-ok realclean diff --git a/deps/npm/bin/npm b/deps/npm/bin/npm index 737d1f17064890..4183703a7857e9 100755 --- a/deps/npm/bin/npm +++ b/deps/npm/bin/npm @@ -8,10 +8,6 @@ case `uname` in esac NODE_EXE="$basedir/node.exe" -if [ -x "$NODE_EXE" ] && [ -f "/bin/wslpath" ]; then # run the corresponding command prompt when Node for Windows is executed within WSL - cmd.exe /c `wslpath -w "$basedir/npm.cmd"` "$@" - exit $? -fi if ! [ -x "$NODE_EXE" ]; then NODE_EXE="$basedir/node" fi diff --git a/deps/npm/bin/npx b/deps/npm/bin/npx index 3516c8c415dba2..261e339850da5e 100644 --- a/deps/npm/bin/npx +++ b/deps/npm/bin/npx @@ -8,10 +8,6 @@ case `uname` in esac NODE_EXE="$basedir/node.exe" -if [ -x "$NODE_EXE" ] && [ -f "/bin/wslpath" ]; then # run the corresponding command prompt when Node for Windows is executed within WSL - cmd.exe /c `wslpath -w "$basedir/npx.cmd"` "$@" - exit $? -fi if ! [ -x "$NODE_EXE" ]; then NODE_EXE=node fi diff --git a/deps/npm/docs/public/cli-commands/npm-access/index.html b/deps/npm/docs/public/cli-commands/npm-access/index.html new file mode 100644 index 00000000000000..7a4103aaaedf44 --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-access/index.html @@ -0,0 +1,145 @@ +

    npm access

    +

    Set access level on published packages

    +

    Synopsis

    +
    npm access public [<package>]
    +npm access restricted [<package>]
    +
    +npm access grant <read-only|read-write> <scope:team> [<package>]
    +npm access revoke <scope:team> [<package>]
    +
    +npm access 2fa-required [<package>]
    +npm access 2fa-not-required [<package>]
    +
    +npm access ls-packages [<user>|<scope>|<scope:team>]
    +npm access ls-collaborators [<package> [<user>]]
    +npm access edit [<package>]
    +

    Description

    +

    Used to set access controls on private packages.

    +

    For all of the subcommands, npm access will perform actions on the packages +in the current working directory if no package name is passed to the +subcommand.

    +
      +
    • public / restricted: +Set a package to be either publicly accessible or restricted.
    • +
    • grant / revoke: +Add or remove the ability of users and teams to have read-only or read-write +access to a package.
    • +
    • 2fa-required / 2fa-not-required: +Configure whether a package requires that anyone publishing it have two-factor +authentication enabled on their account.
    • +
    • ls-packages: +Show all of the packages a user or a team is able to access, along with the +access level, except for read-only public packages (it won't print the whole +registry listing)
    • +
    • ls-collaborators: +Show all of the access privileges for a package. Will only show permissions +for packages to which you have at least read access. If <user> is passed in, +the list is filtered only to teams that user happens to belong to.
    • +
    • edit: +Set the access privileges for a package at once using $EDITOR.
    • +
    +

    Details

    +

    npm access always operates directly on the current registry, configurable +from the command line using --registry=<registry url>.

    +

    Unscoped packages are always public.

    +

    Scoped packages default to restricted, but you can either publish them as +public using npm publish --access=public, or set their access as public using +npm access public after the initial publish.

    +

    You must have privileges to set the access of a package:

    +
      +
    • You are an owner of an unscoped or scoped package.
    • +
    • You are a member of the team that owns a scope.
    • +
    • You have been given read-write privileges for a package, either as a member +of a team or directly as an owner.
    • +
    +

    If you have two-factor authentication enabled then you'll have to pass in an +otp with --otp when making access changes.

    +

    If your account is not paid, then attempts to publish scoped packages will fail +with an HTTP 402 status code (logically enough), unless you use +--access=public.

    +

    Management of teams and team memberships is done with the npm team command.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-adduser/index.html b/deps/npm/docs/public/cli-commands/npm-adduser/index.html new file mode 100644 index 00000000000000..9c6a0432096eda --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-adduser/index.html @@ -0,0 +1,140 @@ +

    +

    section: cli-commands +title: npm-adduser +description: Set access level on published packages

    +
    +

    npm adduser

    +

    Add a registry user account

    +

    Synopsis

    +
    npm adduser [--registry=url] [--scope=@orgname] [--always-auth] [--auth-type=legacy]
    +
    +aliases: login, add-user
    +

    Description

    +

    Create or verify a user named <username> in the specified registry, and +save the credentials to the .npmrc file. If no registry is specified, +the default registry will be used (see config).

    +

    The username, password, and email are read in from prompts.

    +

    To reset your password, go to https://www.npmjs.com/forgot

    +

    To change your email address, go to https://www.npmjs.com/email-edit

    +

    You may use this command multiple times with the same user account to +authorize on a new machine. When authenticating on a new machine, +the username, password and email address must all match with +your existing record.

    +

    npm login is an alias to adduser and behaves exactly the same way.

    +

    Configuration

    +

    registry

    +

    Default: https://registry.npmjs.org/

    +

    The base URL of the npm package registry. If scope is also specified, +this registry will only be used for packages with that scope. scope defaults +to the scope of the project directory you're currently in, if any. See scope.

    +

    scope

    +

    Default: none

    +

    If specified, the user and login credentials given will be associated +with the specified scope. See scope. You can use both at the same time, +e.g.

    +
        npm adduser --registry=http://myregistry.example.com --scope=@myco
    +

    This will set a registry for the given scope and login or create a user for +that registry at the same time.

    +

    always-auth

    +

    Default: false

    +

    If specified, save configuration indicating that all requests to the given +registry should include authorization information. Useful for private +registries. Can be used with --registry and / or --scope, e.g.

    +
        npm adduser --registry=http://private-registry.example.com --always-auth
    +

    This will ensure that all requests to that registry (including for tarballs) +include an authorization header. This setting may be necessary for use with +private registries where metadata and package tarballs are stored on hosts with +different hostnames. See always-auth in config for more details on always-auth. Registry-specific configuration of always-auth takes precedence over any global configuration.

    +

    auth-type

    +
      +
    • Default: 'legacy'
    • +
    • Type: 'legacy', 'sso', 'saml', 'oauth'
    • +
    +

    What authentication strategy to use with adduser/login. Some npm registries +(for example, npmE) might support alternative auth strategies besides classic +username/password entry in legacy npm.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-audit/index.html b/deps/npm/docs/public/cli-commands/npm-audit/index.html new file mode 100644 index 00000000000000..96b3cda738bb77 --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-audit/index.html @@ -0,0 +1,162 @@ +

    npm audit

    +

    Run a security audit

    +

    Synopsis

    +
    npm audit [--json|--parseable|--audit-level=(low|moderate|high|critical)]
    +npm audit fix [--force|--package-lock-only|--dry-run]
    +
    +common options: [--production] [--only=(dev|prod)]
    +

    Examples

    +

    Scan your project for vulnerabilities and automatically install any compatible +updates to vulnerable dependencies:

    +
    $ npm audit fix
    +

    Run audit fix without modifying node_modules, but still updating the +pkglock:

    +
    $ npm audit fix --package-lock-only
    +

    Skip updating devDependencies:

    +
    $ npm audit fix --only=prod
    +

    Have audit fix install semver-major updates to toplevel dependencies, not just +semver-compatible ones:

    +
    $ npm audit fix --force
    +

    Do a dry run to get an idea of what audit fix will do, and also output +install information in JSON format:

    +
    $ npm audit fix --dry-run --json
    +

    Scan your project for vulnerabilities and just show the details, without fixing +anything:

    +
    $ npm audit
    +

    Get the detailed audit report in JSON format:

    +
    $ npm audit --json
    +

    Get the detailed audit report in plain text result, separated by tab characters, allowing for +future reuse in scripting or command line post processing, like for example, selecting +some of the columns printed:

    +
    $ npm audit --parseable
    +

    To parse columns, you can use for example awk, and just print some of them:

    +
    $ npm audit --parseable | awk -F $'\t' '{print $1,$4}'
    +

    Fail an audit only if the results include a vulnerability with a level of moderate or higher:

    +
    $ npm audit --audit-level=moderate
    +

    Description

    +

    The audit command submits a description of the dependencies configured in +your project to your default registry and asks for a report of known +vulnerabilities. The report returned includes instructions on how to act on +this information. The command will exit with a 0 exit code if no +vulnerabilities were found.

    +

    You can also have npm automatically fix the vulnerabilities by running npm +audit fix. Note that some vulnerabilities cannot be fixed automatically and +will require manual intervention or review. Also note that since npm audit fix +runs a full-fledged npm install under the hood, all configs that apply to the +installer will also apply to npm install -- so things like npm audit fix +--package-lock-only will work as expected.

    +

    By default, the audit command will exit with a non-zero code if any vulnerability +is found. It may be useful in CI environments to include the --audit-level parameter +to specify the minimum vulnerability level that will cause the command to fail. This +option does not filter the report output, it simply changes the command's failure +threshold.

    +

    Content Submitted

    +
      +
    • npm_version
    • +
    • node_version
    • +
    • platform
    • +
    • node_env
    • +
    • A scrubbed version of your package-lock.json or npm-shrinkwrap.json
    • +
    +

    Scrubbing

    +

    In order to ensure that potentially sensitive information is not included in +the audit data bundle, some dependencies may have their names (and sometimes +versions) replaced with opaque non-reversible identifiers. It is done for +the following dependency types:

    +
      +
    • Any module referencing a scope that is configured for a non-default +registry has its name scrubbed. (That is, a scope you did a npm login --scope=@ourscope for.)
    • +
    • All git dependencies have their names and specifiers scrubbed.
    • +
    • All remote tarball dependencies have their names and specifiers scrubbed.
    • +
    • All local directory and tarball dependencies have their names and specifiers scrubbed.
    • +
    +

    The non-reversible identifiers are a sha256 of a session-specific UUID and the +value being replaced, ensuring a consistent value within the payload that is +different between runs.

    +

    Exit Code

    +

    The npm audit command will exit with a 0 exit code if no vulnerabilities were found.

    +

    If vulnerabilities were found the exit code will depend on the audit-level +configuration setting.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-bin/index.html b/deps/npm/docs/public/cli-commands/npm-bin/index.html new file mode 100644 index 00000000000000..d7069d3798c7ee --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-bin/index.html @@ -0,0 +1,91 @@ +

    npm bin

    +

    Display npm bin folder

    +

    Synopsis

    +
    npm bin [-g|--global]
    +

    Description

    +

    Print the folder where npm will install executables.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-bugs/index.html b/deps/npm/docs/public/cli-commands/npm-bugs/index.html new file mode 100644 index 00000000000000..d2d1c7f4563e63 --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-bugs/index.html @@ -0,0 +1,111 @@ +

    npm bugs

    +

    Bugs for a package in a web browser maybe

    +

    Synopsis

    +
    npm bugs [<pkgname>]
    +
    +aliases: issues
    +

    Description

    +

    This command tries to guess at the likely location of a package's +bug tracker URL, and then tries to open it using the --browser +config param. If no package name is provided, it will search for +a package.json in the current folder and use the name property.

    +

    Configuration

    +

    browser

    +
      +
    • Default: OS X: "open", Windows: "start", Others: "xdg-open"
    • +
    • Type: String
    • +
    +

    The browser that is called by the npm bugs command to open websites.

    +

    registry

    + +

    The base URL of the npm package registry.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-build/index.html b/deps/npm/docs/public/cli-commands/npm-build/index.html new file mode 100644 index 00000000000000..4ef773207957b2 --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-build/index.html @@ -0,0 +1,97 @@ +

    npm build

    +

    Build a package

    +

    Synopsis

    +
    npm build [<package-folder>]
    +
      +
    • <package-folder>: +A folder containing a package.json file in its root.
    • +
    +

    Description

    +

    This is the plumbing command called by npm link and npm install.

    +

    It should generally be called during installation, but if you need to run it +directly, run:

    +
        npm run-script build
    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-bundle/index.html b/deps/npm/docs/public/cli-commands/npm-bundle/index.html new file mode 100644 index 00000000000000..017939b4ecfb91 --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-bundle/index.html @@ -0,0 +1,88 @@ +

    npm bundle

    +

    REMOVED

    +

    Description

    +

    The npm bundle command has been removed in 1.0, for the simple reason +that it is no longer necessary, as the default behavior is now to +install packages into the local space.

    +

    Just use npm install now to do what npm bundle used to do.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-cache/index.html b/deps/npm/docs/public/cli-commands/npm-cache/index.html new file mode 100644 index 00000000000000..974582d36a1b66 --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-cache/index.html @@ -0,0 +1,142 @@ +

    npm cache

    +

    Manipulates packages cache

    +

    Synopsis

    +
    npm cache add <tarball file>
    +npm cache add <folder>
    +npm cache add <tarball url>
    +npm cache add <name>@<version>
    +
    +npm cache clean [<path>]
    +aliases: npm cache clear, npm cache rm
    +
    +npm cache verify
    +

    Description

    +

    Used to add, list, or clean the npm cache folder.

    +
      +
    • add: +Add the specified package to the local cache. This command is primarily +intended to be used internally by npm, but it can provide a way to +add data to the local installation cache explicitly.
    • +
    • clean: +Delete all data out of the cache folder.
    • +
    • verify: +Verify the contents of the cache folder, garbage collecting any unneeded data, +and verifying the integrity of the cache index and all cached data.
    • +
    +

    Details

    +

    npm stores cache data in an opaque directory within the configured cache, +named _cacache. This directory is a cacache-based content-addressable cache +that stores all http request data as well as other package-related data. This +directory is primarily accessed through pacote, the library responsible for +all package fetching as of npm@5.

    +

    All data that passes through the cache is fully verified for integrity on both +insertion and extraction. Cache corruption will either trigger an error, or +signal to pacote that the data must be refetched, which it will do +automatically. For this reason, it should never be necessary to clear the cache +for any reason other than reclaiming disk space, thus why clean now requires +--force to run.

    +

    There is currently no method exposed through npm to inspect or directly manage +the contents of this cache. In order to access it, cacache must be used +directly.

    +

    npm will not remove data by itself: the cache will grow as new packages are +installed.

    +

    A note about the cache's design

    +

    The npm cache is strictly a cache: it should not be relied upon as a persistent +and reliable data store for package data. npm makes no guarantee that a +previously-cached piece of data will be available later, and will automatically +delete corrupted contents. The primary guarantee that the cache makes is that, +if it does return data, that data will be exactly the data that was inserted.

    +

    To run an offline verification of existing cache contents, use npm cache +verify.

    +

    Configuration

    +

    cache

    +

    Default: ~/.npm on Posix, or %AppData%/npm-cache on Windows.

    +

    The root cache folder.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-ci/index.html b/deps/npm/docs/public/cli-commands/npm-ci/index.html new file mode 100644 index 00000000000000..f5620f496ae57c --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-ci/index.html @@ -0,0 +1,119 @@ +

    npm ci

    +

    Install a project with a clean slate

    +

    Synopsis

    +
    npm ci
    +

    Example

    +

    Make sure you have a package-lock and an up-to-date install:

    +
    $ cd ./my/npm/project
    +$ npm install
    +added 154 packages in 10s
    +$ ls | grep package-lock
    +

    Run npm ci in that project

    +
    $ npm ci
    +added 154 packages in 5s
    +

    Configure Travis to build using npm ci instead of npm install:

    +
    # .travis.yml
    +install:
    +- npm ci
    +# keep the npm cache around to speed up installs
    +cache:
    +  directories:
    +  - "$HOME/.npm"
    +

    Description

    +

    This command is similar to npm install, except it's meant to be used in +automated environments such as test platforms, continuous integration, and +deployment -- or any situation where you want to make sure you're doing a clean +install of your dependencies. It can be significantly faster than a regular npm +install by skipping certain user-oriented features. It is also more strict than +a regular install, which can help catch errors or inconsistencies caused by the +incrementally-installed local environments of most npm users.

    +

    In short, the main differences between using npm install and npm ci are:

    +
      +
    • The project must have an existing package-lock.json or npm-shrinkwrap.json.
    • +
    • If dependencies in the package lock do not match those in package.json, npm ci will exit with an error, instead of updating the package lock.
    • +
    • npm ci can only install entire projects at a time: individual dependencies cannot be added with this command.
    • +
    • If a node_modules is already present, it will be automatically removed before npm ci begins its install.
    • +
    • It will never write to package.json or any of the package-locks: installs are essentially frozen.
    • +
    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-completion/index.html b/deps/npm/docs/public/cli-commands/npm-completion/index.html new file mode 100644 index 00000000000000..3483cbc66784f2 --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-completion/index.html @@ -0,0 +1,101 @@ +

    npm completion

    +

    Tab Completion for npm

    +

    Synopsis

    +
    source <(npm completion)
    +

    Description

    +

    Enables tab-completion in all npm commands.

    +

    The synopsis above +loads the completions into your current shell. Adding it to +your ~/.bashrc or ~/.zshrc will make the completions available +everywhere:

    +
    npm completion >> ~/.bashrc
    +npm completion >> ~/.zshrc
    +

    You may of course also pipe the output of npm completion to a file +such as /usr/local/etc/bash_completion.d/npm or +/etc/bash_completion.d/npm if you have a system that will read +that file for you.

    +

    When COMP_CWORD, COMP_LINE, and COMP_POINT are defined in the +environment, npm completion acts in "plumbing mode", and outputs +completions based on the arguments.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-config/index.html b/deps/npm/docs/public/cli-commands/npm-config/index.html new file mode 100644 index 00000000000000..f9beefcd4039b5 --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-config/index.html @@ -0,0 +1,125 @@ +

    npm config

    +

    Manage the npm configuration files

    +

    Synopsis

    +
    npm config set <key> <value> [-g|--global]
    +npm config get <key>
    +npm config delete <key>
    +npm config list [-l] [--json]
    +npm config edit
    +npm get <key>
    +npm set <key> <value> [-g|--global]
    +
    +aliases: c
    +

    Description

    +

    npm gets its config settings from the command line, environment +variables, npmrc files, and in some cases, the package.json file.

    +

    See npmrc for more information about the npmrc files.

    +

    See config for a more thorough discussion of the mechanisms +involved.

    +

    The npm config command can be used to update and edit the contents +of the user and global npmrc files.

    +

    Sub-commands

    +

    Config supports the following sub-commands:

    +

    set

    +
    npm config set key value
    +

    Sets the config key to the value.

    +

    If value is omitted, then it sets it to "true".

    +

    get

    +
    npm config get key
    +

    Echo the config value to stdout.

    +

    list

    +
    npm config list
    +

    Show all the config settings. Use -l to also show defaults. Use --json +to show the settings in json format.

    +

    delete

    +
    npm config delete key
    +

    Deletes the key from all configuration files.

    +

    edit

    +
    npm config edit
    +

    Opens the config file in an editor. Use the --global flag to edit the +global config.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-dedupe/index.html b/deps/npm/docs/public/cli-commands/npm-dedupe/index.html new file mode 100644 index 00000000000000..571a3a34f2e02d --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-dedupe/index.html @@ -0,0 +1,118 @@ +

    npm dedupe

    +

    Reduce duplication

    +

    Synopsis

    +
    npm dedupe
    +npm ddp
    +
    +aliases: find-dupes, ddp
    +

    Description

    +

    Searches the local package tree and attempts to simplify the overall +structure by moving dependencies further up the tree, where they can +be more effectively shared by multiple dependent packages.

    +

    For example, consider this dependency graph:

    +
    a
    ++-- b <-- depends on c@1.0.x
    +|   `-- c@1.0.3
    +`-- d <-- depends on c@~1.0.9
    +    `-- c@1.0.10
    +

    In this case, npm dedupe will transform the tree to:

    +
    a
    ++-- b
    ++-- d
    +`-- c@1.0.10
    +

    Because of the hierarchical nature of node's module lookup, b and d +will both get their dependency met by the single c package at the root +level of the tree.

    +

    The deduplication algorithm walks the tree, moving each dependency as far +up in the tree as possible, even if duplicates are not found. This will +result in both a flat and deduplicated tree.

    +

    If a suitable version exists at the target location in the tree +already, then it will be left untouched, but the other duplicates will +be deleted.

    +

    Arguments are ignored. Dedupe always acts on the entire tree.

    +

    Modules

    +

    Note that this operation transforms the dependency tree, but will never +result in new modules being installed.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-deprecate/index.html b/deps/npm/docs/public/cli-commands/npm-deprecate/index.html new file mode 100644 index 00000000000000..ef5df5c9a1339e --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-deprecate/index.html @@ -0,0 +1,97 @@ +

    npm deprecate

    +

    Deprecate a version of a package

    +

    Synopsis

    +
    npm deprecate <pkg>[@<version>] <message>
    +

    Description

    +

    This command will update the npm registry entry for a package, providing +a deprecation warning to all who attempt to install it.

    +

    It works on version ranges as well as specific +versions, so you can do something like this:

    +
    npm deprecate my-thing@"< 0.2.3" "critical bug fixed in v0.2.3"
    +

    Note that you must be the package owner to deprecate something. See the +owner and adduser help topics.

    +

    To un-deprecate a package, specify an empty string ("") for the message +argument. Note that you must use double quotes with no space between them to +format an empty string.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-dist-tag/index.html b/deps/npm/docs/public/cli-commands/npm-dist-tag/index.html new file mode 100644 index 00000000000000..c560d919aa6d29 --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-dist-tag/index.html @@ -0,0 +1,146 @@ +

    +

    section: cli-commands +title: npm-dist-tag +description: Modify package distribution tags

    +
    +

    npm dist-tag

    +

    Modify package distribution tags

    +

    Synopsis

    +
    npm dist-tag add <pkg>@<version> [<tag>]
    +npm dist-tag rm <pkg> <tag>
    +npm dist-tag ls [<pkg>]
    +
    +aliases: dist-tags
    +

    Description

    +

    Add, remove, and enumerate distribution tags on a package:

    +
      +
    • add: +Tags the specified version of the package with the specified tag, or the +--tag config if not specified. If you have two-factor authentication on +auth-and-writes then you’ll need to include a one-time password on the +command line with --otp <one-time password>.
    • +
    • rm: +Clear a tag that is no longer in use from the package.
    • +
    • ls: +Show all of the dist-tags for a package, defaulting to the package in +the current prefix. This is the default action if none is specified.
    • +
    +

    A tag can be used when installing packages as a reference to a version instead +of using a specific version number:

    +
    npm install <name>@<tag>
    +

    When installing dependencies, a preferred tagged version may be specified:

    +
    npm install --tag <tag>
    +

    This also applies to npm dedupe.

    +

    Publishing a package sets the latest tag to the published version unless the +--tag option is used. For example, npm publish --tag=beta.

    +

    By default, npm install <pkg> (without any @<version> or @<tag> +specifier) installs the latest tag.

    +

    Purpose

    +

    Tags can be used to provide an alias instead of version numbers.

    +

    For example, a project might choose to have multiple streams of development +and use a different tag for each stream, +e.g., stable, beta, dev, canary.

    +

    By default, the latest tag is used by npm to identify the current version of +a package, and npm install <pkg> (without any @<version> or @<tag> +specifier) installs the latest tag. Typically, projects only use the latest +tag for stable release versions, and use other tags for unstable versions such +as prereleases.

    +

    The next tag is used by some projects to identify the upcoming version.

    +

    By default, other than latest, no tag has any special significance to npm +itself.

    +

    Caveats

    +

    This command used to be known as npm tag, which only created new tags, and so +had a different syntax.

    +

    Tags must share a namespace with version numbers, because they are specified in +the same slot: npm install <pkg>@<version> vs npm install <pkg>@<tag>.

    +

    Tags that can be interpreted as valid semver ranges will be rejected. For +example, v1.4 cannot be used as a tag, because it is interpreted by semver as +>=1.4.0 <1.5.0. See https://github.com/npm/npm/issues/6082.

    +

    The simplest way to avoid semver problems with tags is to use tags that do not +begin with a number or the letter v.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-docs/index.html b/deps/npm/docs/public/cli-commands/npm-docs/index.html new file mode 100644 index 00000000000000..99ba5bed69f941 --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-docs/index.html @@ -0,0 +1,112 @@ +

    npm docs

    +

    Docs for a package in a web browser maybe

    +

    Synopsis

    +
    npm docs [<pkgname> [<pkgname> ...]]
    +npm docs .
    +npm home [<pkgname> [<pkgname> ...]]
    +npm home .
    +

    Description

    +

    This command tries to guess at the likely location of a package's +documentation URL, and then tries to open it using the --browser +config param. You can pass multiple package names at once. If no +package name is provided, it will search for a package.json in +the current folder and use the name property.

    +

    Configuration

    +

    browser

    +
      +
    • Default: OS X: "open", Windows: "start", Others: "xdg-open"
    • +
    • Type: String
    • +
    +

    The browser that is called by the npm docs command to open websites.

    +

    registry

    + +

    The base URL of the npm package registry.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-doctor/index.html b/deps/npm/docs/public/cli-commands/npm-doctor/index.html new file mode 100644 index 00000000000000..1edad5dff749e6 --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-doctor/index.html @@ -0,0 +1,160 @@ +

    npm doctor

    +

    Check your environments

    +

    Synopsis

    +
    npm doctor
    +

    Description

    +

    npm doctor runs a set of checks to ensure that your npm installation has +what it needs to manage your JavaScript packages. npm is mostly a standalone tool, but it does +have some basic requirements that must be met:

    +
      +
    • Node.js and git must be executable by npm.
    • +
    • The primary npm registry, registry.npmjs.com, or another service that uses +the registry API, is available.
    • +
    • The directories that npm uses, node_modules (both locally and globally), +exist and can be written by the current user.
    • +
    • The npm cache exists, and the package tarballs within it aren't corrupt.
    • +
    +

    Without all of these working properly, npm may not work properly. Many issues +are often attributable to things that are outside npm's code base, so npm +doctor confirms that the npm installation is in a good state.

    +

    Also, in addition to this, there are also very many issue reports due to using +old versions of npm. Since npm is constantly improving, running npm@latest is +better than an old version.

    +

    npm doctor verifies the following items in your environment, and if there are +any recommended changes, it will display them.

    +

    npm ping

    +

    By default, npm installs from the primary npm registry, registry.npmjs.org. +npm doctor hits a special ping endpoint within the registry. This can also be +checked with npm ping. If this check fails, you may be using a proxy that +needs to be configured, or may need to talk to your IT staff to get access over +HTTPS to registry.npmjs.org.

    +

    This check is done against whichever registry you've configured (you can see +what that is by running npm config get registry), and if you're using a +private registry that doesn't support the /whoami endpoint supported by the +primary registry, this check may fail.

    +

    npm -v

    +

    While Node.js may come bundled with a particular version of npm, it's the +policy of the CLI team that we recommend all users run npm@latest if they +can. As the CLI is maintained by a small team of contributors, there are only +resources for a single line of development, so npm's own long-term support +releases typically only receive critical security and regression fixes. The +team believes that the latest tested version of npm is almost always likely to +be the most functional and defect-free version of npm.

    +

    node -v

    +

    For most users, in most circumstances, the best version of Node will be the +latest long-term support (LTS) release. Those of you who want access to new +ECMAscript features or bleeding-edge changes to Node's standard library may be +running a newer version, and some of you may be required to run an older +version of Node because of enterprise change control policies. That's OK! But +in general, the npm team recommends that most users run Node.js LTS.

    +

    npm config get registry

    +

    Some of you may be installing from private package registries for your project +or company. That's great! Others of you may be following tutorials or +StackOverflow questions in an effort to troubleshoot problems you may be +having. Sometimes, this may entail changing the registry you're pointing at. +This part of npm doctor just lets you, and maybe whoever's helping you with +support, know that you're not using the default registry.

    +

    which git

    +

    While it's documented in the README, it may not be obvious that npm needs Git +installed to do many of the things that it does. Also, in some cases +– especially on Windows – you may have Git set up in such a way that it's not +accessible via your PATH so that npm can find it. This check ensures that Git +is available.

    +

    Permissions checks

    +
      +
    • Your cache must be readable and writable by the user running npm.
    • +
    • Global package binaries must be writable by the user running npm.
    • +
    • Your local node_modules path, if you're running npm doctor with a project +directory, must be readable and writable by the user running npm.
    • +
    +

    Validate the checksums of cached packages

    +

    When an npm package is published, the publishing process generates a checksum +that npm uses at install time to verify that the package didn't get corrupted +in transit. npm doctor uses these checksums to validate the package tarballs +in your local cache (you can see where that cache is located with npm config +get cache, and see what's in that cache with npm cache ls – probably more +than you were expecting!). In the event that there are corrupt packages in your +cache, you should probably run npm cache clean and reset the cache.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-edit/index.html b/deps/npm/docs/public/cli-commands/npm-edit/index.html new file mode 100644 index 00000000000000..54e257bf84feef --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-edit/index.html @@ -0,0 +1,107 @@ +

    npm edit

    +

    Edit an installed package

    +

    Synopsis

    +
    npm edit <pkg>[/<subpkg>...]
    +

    Description

    +

    Selects a (sub)dependency in the current +working directory and opens the package folder in the default editor +(or whatever you've configured as the npm editor config -- see +npm-config.)

    +

    After it has been edited, the package is rebuilt so as to pick up any +changes in compiled packages.

    +

    For instance, you can do npm install connect to install connect +into your package, and then npm edit connect to make a few +changes to your locally installed copy.

    +

    Configuration

    +

    editor

    +
      +
    • Default: EDITOR environment variable if set, or "vi" on Posix, +or "notepad" on Windows.
    • +
    • Type: path
    • +
    +

    The command to run for npm edit or npm config edit.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-explore/index.html b/deps/npm/docs/public/cli-commands/npm-explore/index.html new file mode 100644 index 00000000000000..0b94db69d86c4e --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-explore/index.html @@ -0,0 +1,111 @@ +

    +

    section: cli-commands +title: npm-explore +description: Browse an installed package

    +
    +

    npm explore

    +

    Browse an installed package

    +

    Synopsis

    +
    npm explore <pkg> [ -- <command>]
    +

    Description

    +

    Spawn a subshell in the directory of the installed package specified.

    +

    If a command is specified, then it is run in the subshell, which then +immediately terminates.

    +

    This is particularly handy in the case of git submodules in the +node_modules folder:

    +
    npm explore some-dependency -- git pull origin master
    +

    Note that the package is not automatically rebuilt afterwards, so be +sure to use npm rebuild <pkg> if you make any changes.

    +

    Configuration

    +

    shell

    +
      +
    • Default: SHELL environment variable, or "bash" on Posix, or "cmd" on +Windows
    • +
    • Type: path
    • +
    +

    The shell to run for the npm explore command.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-fund/index.html b/deps/npm/docs/public/cli-commands/npm-fund/index.html new file mode 100644 index 00000000000000..77f637f4ba388c --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-fund/index.html @@ -0,0 +1,118 @@ +

    npm fund

    +

    Retrieve funding information

    +

    Synopsis

    +
        npm fund [<pkg>]
    +

    Description

    +

    This command retrieves information on how to fund the dependencies of +a given project. If no package name is provided, it will list all +dependencies that are looking for funding in a tree-structure in which +are listed the type of funding and the url to visit. If a package name +is provided then it tries to open its funding url using the --browser +config param.

    +

    The list will avoid duplicated entries and will stack all packages +that share the same type/url as a single entry. Given this nature the +list is not going to have the same shape of the output from npm ls.

    +

    Configuration

    +

    browser

    +
      +
    • Default: OS X: "open", Windows: "start", Others: "xdg-open"
    • +
    • Type: String
    • +
    +

    The browser that is called by the npm fund command to open websites.

    +

    json

    +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    Show information in JSON format.

    +

    unicode

    +
      +
    • Type: Boolean
    • +
    • Default: true
    • +
    +

    Whether to represent the tree structure using unicode characters. +Set it to false in order to use all-ansi output.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-help-search/index.html b/deps/npm/docs/public/cli-commands/npm-help-search/index.html new file mode 100644 index 00000000000000..9c4a06fa9114d0 --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-help-search/index.html @@ -0,0 +1,102 @@ +

    npm help-search

    +

    Search npm help documentation

    +

    Synopsis

    +
    npm help-search <text>
    +

    Description

    +

    This command will search the npm markdown documentation files for the +terms provided, and then list the results, sorted by relevance.

    +

    If only one result is found, then it will show that help topic.

    +

    If the argument to npm help is not a known help topic, then it will +call help-search. It is rarely if ever necessary to call this +command directly.

    +

    Configuration

    +

    long

    +
      +
    • Type: Boolean
    • +
    • Default: false
    • +
    +

    If true, the "long" flag will cause help-search to output context around +where the terms were found in the documentation.

    +

    If false, then help-search will just list out the help topics found.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-help/index.html b/deps/npm/docs/public/cli-commands/npm-help/index.html new file mode 100644 index 00000000000000..f6fb102efb1b3b --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-help/index.html @@ -0,0 +1,104 @@ +

    npm help

    +

    Get help on npm

    +

    Synopsis

    +
    npm help <term> [<terms..>]
    +

    Description

    +

    If supplied a topic, then show the appropriate documentation page.

    +

    If the topic does not exist, or if multiple terms are provided, then run +the help-search command to find a match. Note that, if help-search +finds a single subject, then it will run help on that topic, so unique +matches are equivalent to specifying a topic name.

    +

    Configuration

    +

    viewer

    +
      +
    • Default: "man" on Posix, "browser" on Windows
    • +
    • Type: path
    • +
    +

    The program to use to view help content.

    +

    Set to "browser" to view html help content in the default web browser.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-hook/index.html b/deps/npm/docs/public/cli-commands/npm-hook/index.html new file mode 100644 index 00000000000000..6556b3b3dc967d --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-hook/index.html @@ -0,0 +1,116 @@ +

    npm hook

    +

    Manage registry hooks

    +

    Synopsis

    +
    npm hook ls [pkg]
    +npm hook add <entity> <url> <secret>
    +npm hook update <id> <url> [secret]
    +npm hook rm <id>
    +

    Example

    +

    Add a hook to watch a package for changes:

    +
    $ npm hook add lodash https://example.com/ my-shared-secret
    +

    Add a hook to watch packages belonging to the user substack:

    +
    $ npm hook add ~substack https://example.com/ my-shared-secret
    +

    Add a hook to watch packages in the scope @npm

    +
    $ npm hook add @npm https://example.com/ my-shared-secret
    +

    List all your active hooks:

    +
    $ npm hook ls
    +

    List your active hooks for the lodash package:

    +
    $ npm hook ls lodash
    +

    Update an existing hook's url:

    +
    $ npm hook update id-deadbeef https://my-new-website.here/
    +

    Remove a hook:

    +
    $ npm hook rm id-deadbeef
    +

    Description

    +

    Allows you to manage npm hooks, +including adding, removing, listing, and updating.

    +

    Hooks allow you to configure URL endpoints that will be notified whenever a +change happens to any of the supported entity types. Three different types of +entities can be watched by hooks: packages, owners, and scopes.

    +

    To create a package hook, simply reference the package name.

    +

    To create an owner hook, prefix the owner name with ~ (as in, ~youruser).

    +

    To create a scope hook, prefix the scope name with @ (as in, @yourscope).

    +

    The hook id used by update and rm are the IDs listed in npm hook ls for +that particular hook.

    +

    The shared secret will be sent along to the URL endpoint so you can verify the +request came from your own configured hook.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-init/index.html b/deps/npm/docs/public/cli-commands/npm-init/index.html new file mode 100644 index 00000000000000..4f619bb65d0e7a --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-init/index.html @@ -0,0 +1,123 @@ +

    npm init

    +

    create a package.json file

    +

    Synopsis

    +
    npm init [--force|-f|--yes|-y|--scope]
    +npm init <@scope> (same as `npx <@scope>/create`)
    +npm init [<@scope>/]<name> (same as `npx [<@scope>/]create-<name>`)
    +

    Examples

    +

    Create a new React-based project using create-react-app:

    +
    $ npm init react-app ./my-react-app
    +

    Create a new esm-compatible package using create-esm:

    +
    $ mkdir my-esm-lib && cd my-esm-lib
    +$ npm init esm --yes
    +

    Generate a plain old package.json using legacy init:

    +
    $ mkdir my-npm-pkg && cd my-npm-pkg
    +$ git init
    +$ npm init
    +

    Generate it without having it ask any questions:

    +
    $ npm init -y
    +

    Description

    +

    npm init <initializer> can be used to set up a new or existing npm package.

    +

    initializer in this case is an npm package named create-<initializer>, which +will be installed by npx, and then have its main bin +executed -- presumably creating or updating package.json and running any other +initialization-related operations.

    +

    The init command is transformed to a corresponding npx operation as follows:

    +
      +
    • npm init foo -> npx create-foo
    • +
    • npm init @usr/foo -> npx @usr/create-foo
    • +
    • npm init @usr -> npx @usr/create
    • +
    +

    Any additional options will be passed directly to the command, so npm init foo +--hello will map to npx create-foo --hello.

    +

    If the initializer is omitted (by just calling npm init), init will fall back +to legacy init behavior. It will ask you a bunch of questions, and then write a +package.json for you. It will attempt to make reasonable guesses based on +existing fields, dependencies, and options selected. It is strictly additive, so +it will keep any fields and values that were already set. You can also use +-y/--yes to skip the questionnaire altogether. If you pass --scope, it +will create a scoped package.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-install-ci-test/index.html b/deps/npm/docs/public/cli-commands/npm-install-ci-test/index.html new file mode 100644 index 00000000000000..8e54986627e34a --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-install-ci-test/index.html @@ -0,0 +1,90 @@ +

    npm install-ci-test

    +

    Install a project with a clean slate and run tests

    +

    Synopsis

    +
    npm install-ci-test
    +
    +alias: npm cit
    +

    Description

    +

    This command runs an npm ci followed immediately by an npm test.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-install-test/index.html b/deps/npm/docs/public/cli-commands/npm-install-test/index.html new file mode 100644 index 00000000000000..7cde472b8564c7 --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-install-test/index.html @@ -0,0 +1,99 @@ +

    npm install-test

    +

    Install package(s) and run tests

    +

    Synopsis

    +
    npm install-test (with no args, in package dir)
    +npm install-test [<@scope>/]<name>
    +npm install-test [<@scope>/]<name>@<tag>
    +npm install-test [<@scope>/]<name>@<version>
    +npm install-test [<@scope>/]<name>@<version range>
    +npm install-test <tarball file>
    +npm install-test <tarball url>
    +npm install-test <folder>
    +
    +alias: npm it
    +common options: [--save|--save-dev|--save-optional] [--save-exact] [--dry-run]
    +

    Description

    +

    This command runs an npm install followed immediately by an npm test. It +takes exactly the same arguments as npm install.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-install/index.html b/deps/npm/docs/public/cli-commands/npm-install/index.html new file mode 100644 index 00000000000000..9ab2a20f5ecc62 --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-install/index.html @@ -0,0 +1,465 @@ +

    npm install

    +

    Install a package

    +

    Synopsis

    +
    npm install (with no args, in package dir)
    +npm install [<@scope>/]<name>
    +npm install [<@scope>/]<name>@<tag>
    +npm install [<@scope>/]<name>@<version>
    +npm install [<@scope>/]<name>@<version range>
    +npm install <alias>@npm:<name>
    +npm install <git-host>:<git-user>/<repo-name>
    +npm install <git repo url>
    +npm install <tarball file>
    +npm install <tarball url>
    +npm install <folder>
    +
    +aliases: npm i, npm add
    +common options: [-P|--save-prod|-D|--save-dev|-O|--save-optional] [-E|--save-exact] [-B|--save-bundle] [--no-save] [--dry-run]
    +

    Description

    +

    This command installs a package, and any packages that it depends on. If the +package has a package-lock or shrinkwrap file, the installation of dependencies +will be driven by that, with an npm-shrinkwrap.json taking precedence if both +files exist. See package-lock.json and npm shrinkwrap.

    +

    A package is:

    +
      +
    • a) a folder containing a program described by a package.json file
    • +
    • b) a gzipped tarball containing (a)
    • +
    • c) a url that resolves to (b)
    • +
    • d) a <name>@<version> that is published on the registry (see registry) with (c)
    • +
    • e) a <name>@<tag> (see npm dist-tag) that points to (d)
    • +
    • f) a <name> that has a "latest" tag satisfying (e)
    • +
    • g) a <git remote url> that resolves to (a)
    • +
    +

    Even if you never publish your package, you can still get a lot of +benefits of using npm if you just want to write a node program (a), and +perhaps if you also want to be able to easily install it elsewhere +after packing it up into a tarball (b).

    +
      +
    • +

      npm install (in package directory, no arguments):

      +

      Install the dependencies in the local node_modules folder.

      +

      In global mode (ie, with -g or --global appended to the command), +it installs the current package context (ie, the current working +directory) as a global package.

      +

      By default, npm install will install all modules listed as dependencies +in package.json.

      +

      With the --production flag (or when the NODE_ENV environment variable +is set to production), npm will not install modules listed in +devDependencies. To install all modules listed in both dependencies +and devDependencies when NODE_ENV environment variable is set to production, +you can use --production=false.

      +
      +

      NOTE: The --production flag has no particular meaning when adding a +dependency to a project.

      +
      +
    • +
    • +

      npm install <folder>:

      +

      Install the package in the directory as a symlink in the current project. +Its dependencies will be installed before it's linked. If <folder> sits +inside the root of your project, its dependencies may be hoisted to the +toplevel node_modules as they would for other types of dependencies.

      +
    • +
    • +

      npm install <tarball file>:

      +

      Install a package that is sitting on the filesystem. Note: if you just want +to link a dev directory into your npm root, you can do this more easily by +using npm link.

      +

      Tarball requirements:

      +
        +
      • The filename must use .tar, .tar.gz, or .tgz as +the extension.
      • +
      • The package contents should reside in a subfolder inside the tarball (usually it is called package/). npm strips one directory layer when installing the package (an equivalent of tar x --strip-components=1 is run).
      • +
      • The package must contain a package.json file with name and version properties.
      • +
      +

      Example:

      +
        npm install ./package.tgz
      +
    • +
    • +

      npm install <tarball url>:

      +

      Fetch the tarball url, and then install it. In order to distinguish between +this and other options, the argument must start with "http://" or "https://"

      +

      Example:

      +
        npm install https://github.com/indexzero/forever/tarball/v0.5.6
      +
    • +
    • +

      npm install [<@scope>/]<name>:

      +

      Do a <name>@<tag> install, where <tag> is the "tag" config. (See +config. The config's default value is latest.)

      +

      In most cases, this will install the version of the modules tagged as +latest on the npm registry.

      +

      Example:

      +
        npm install sax
      +
    • +
    • +

      npm install <alias>@npm:<name>:

      +

      Install a package under a custom alias. Allows multiple versions of +a same-name package side-by-side, more convenient import names for +packages with otherwise long ones and using git forks replacements +or forked npm packages as replacements. Aliasing works only on your +project and does not rename packages in transitive dependencies. +Aliases should follow the naming conventions stated in +validate-npm-package-name.

      +

      Examples:

      +
        npm install my-react@npm:react
      +  npm install jquery2@npm:jquery@2
      +  npm install jquery3@npm:jquery@3
      +  npm install npa@npm:npm-package-arg
      +

      npm install saves any specified packages into dependencies by default. +Additionally, you can control where and how they get saved with some +additional flags:

      +
        +
      • -P, --save-prod: Package will appear in your dependencies. This is the +default unless -D or -O are present.
      • +
      • -D, --save-dev: Package will appear in your devDependencies.
      • +
      • -O, --save-optional: Package will appear in your optionalDependencies.
      • +
      • --no-save: Prevents saving to dependencies.
      • +
      +

      When using any of the above options to save dependencies to your +package.json, there are two additional, optional flags:

      +
        +
      • -E, --save-exact: Saved dependencies will be configured with an +exact version rather than using npm's default semver range +operator.
      • +
      • -B, --save-bundle: Saved dependencies will also be added to your bundleDependencies list.
      • +
      +

      Further, if you have an npm-shrinkwrap.json or package-lock.json then it +will be updated as well.

      +

      <scope> is optional. The package will be downloaded from the registry +associated with the specified scope. If no registry is associated with +the given scope the default registry is assumed. See scope.

      +

      Note: if you do not include the @-symbol on your scope name, npm will +interpret this as a GitHub repository instead, see below. Scopes names +must also be followed by a slash.

      +

      Examples:

      +
      npm install sax
      +npm install githubname/reponame
      +npm install @myorg/privatepackage
      +npm install node-tap --save-dev
      +npm install dtrace-provider --save-optional
      +npm install readable-stream --save-exact
      +npm install ansi-regex --save-bundle
      +

      Note: If there is a file or folder named <name> in the current +working directory, then it will try to install that, and only try to +fetch the package by name if it is not valid.

      +
    • +
    • +

      npm install [<@scope>/]<name>@<tag>:

      +

      Install the version of the package that is referenced by the specified tag. +If the tag does not exist in the registry data for that package, then this +will fail.

      +

      Example:

      +
      npm install sax@latest
      +npm install @myorg/mypackage@latest
      +
    • +
    • +

      npm install [<@scope>/]<name>@<version>:

      +

      Install the specified version of the package. This will fail if the +version has not been published to the registry.

      +

      Example:

      +
      npm install sax@0.1.1
      +npm install @myorg/privatepackage@1.5.0
      +
    • +
    • +

      npm install [<@scope>/]<name>@<version range>:

      +

      Install a version of the package matching the specified version range. This +will follow the same rules for resolving dependencies described in package.json.

      +

      Note that most version ranges must be put in quotes so that your shell will +treat it as a single argument.

      +

      Example:

      +
      npm install sax@">=0.1.0 <0.2.0"
      +npm install @myorg/privatepackage@">=0.1.0 <0.2.0"
      +
    • +
    • +

      npm install <git remote url>:

      +

      Installs the package from the hosted git provider, cloning it with git. +For a full git remote url, only that URL will be attempted.

      +
        <protocol>://[<user>[:<password>]@]<hostname>[:<port>][:][/]<path>[#<commit-ish> | #semver:<semver>]
      +

      <protocol> is one of git, git+ssh, git+http, git+https, or +git+file.

      +

      If #<commit-ish> is provided, it will be used to clone exactly that +commit. If the commit-ish has the format #semver:<semver>, <semver> can +be any valid semver range or exact version, and npm will look for any tags +or refs matching that range in the remote repository, much as it would for a +registry dependency. If neither #<commit-ish> or #semver:<semver> is +specified, then the default branch of the repository is used.

      +

      If the repository makes use of submodules, those submodules will be cloned +as well.

      +

      If the package being installed contains a prepare script, its +dependencies and devDependencies will be installed, and the prepare +script will be run, before the package is packaged and installed.

      +

      The following git environment variables are recognized by npm and will be +added to the environment when running git:

      +
        +
      • GIT_ASKPASS
      • +
      • GIT_EXEC_PATH
      • +
      • GIT_PROXY_COMMAND
      • +
      • GIT_SSH
      • +
      • GIT_SSH_COMMAND
      • +
      • GIT_SSL_CAINFO
      • +
      • GIT_SSL_NO_VERIFY
      • +
      +

      See the git man page for details.

      +

      Examples:

      +
      npm install git+ssh://git@github.com:npm/cli.git#v1.0.27
      +npm install git+ssh://git@github.com:npm/cli#semver:^5.0
      +npm install git+https://isaacs@github.com/npm/cli.git
      +npm install git://github.com/npm/cli.git#v1.0.27
      +GIT_SSH_COMMAND='ssh -i ~/.ssh/custom_ident' npm install git+ssh://git@github.com:npm/cli.git
      +
    • +
    • npm install <githubname>/<githubrepo>[#<commit-ish>]:
    • +
    • +

      npm install github:<githubname>/<githubrepo>[#<commit-ish>]:

      +

      Install the package at https://github.com/githubname/githubrepo by +attempting to clone it using git.

      +

      If #<commit-ish> is provided, it will be used to clone exactly that +commit. If the commit-ish has the format #semver:<semver>, <semver> can +be any valid semver range or exact version, and npm will look for any tags +or refs matching that range in the remote repository, much as it would for a +registry dependency. If neither #<commit-ish> or #semver:<semver> is +specified, then master is used.

      +

      As with regular git dependencies, dependencies and devDependencies will +be installed if the package has a prepare script, before the package is +done installing.

      +

      Examples:

      +
      npm install mygithubuser/myproject
      +npm install github:mygithubuser/myproject
      +
    • +
    • +

      npm install gist:[<githubname>/]<gistID>[#<commit-ish>|#semver:<semver>]:

      +

      Install the package at https://gist.github.com/gistID by attempting to +clone it using git. The GitHub username associated with the gist is +optional and will not be saved in package.json.

      +

      As with regular git dependencies, dependencies and devDependencies will +be installed if the package has a prepare script, before the package is +done installing.

      +

      Example:

      +
      npm install gist:101a11beef
      +
    • +
    • +

      npm install bitbucket:<bitbucketname>/<bitbucketrepo>[#<commit-ish>]:

      +

      Install the package at https://bitbucket.org/bitbucketname/bitbucketrepo +by attempting to clone it using git.

      +

      If #<commit-ish> is provided, it will be used to clone exactly that +commit. If the commit-ish has the format #semver:<semver>, <semver> can +be any valid semver range or exact version, and npm will look for any tags +or refs matching that range in the remote repository, much as it would for a +registry dependency. If neither #<commit-ish> or #semver:<semver> is +specified, then master is used.

      +

      As with regular git dependencies, dependencies and devDependencies will +be installed if the package has a prepare script, before the package is +done installing.

      +

      Example:

      +
      npm install bitbucket:mybitbucketuser/myproject
      +
    • +
    • +

      npm install gitlab:<gitlabname>/<gitlabrepo>[#<commit-ish>]:

      +

      Install the package at https://gitlab.com/gitlabname/gitlabrepo +by attempting to clone it using git.

      +

      If #<commit-ish> is provided, it will be used to clone exactly that +commit. If the commit-ish has the format #semver:<semver>, <semver> can +be any valid semver range or exact version, and npm will look for any tags +or refs matching that range in the remote repository, much as it would for a +registry dependency. If neither #<commit-ish> or #semver:<semver> is +specified, then master is used.

      +

      As with regular git dependencies, dependencies and devDependencies will +be installed if the package has a prepare script, before the package is +done installing.

      +

      Example:

      +
      npm install gitlab:mygitlabuser/myproject
      +npm install gitlab:myusr/myproj#semver:^5.0
      +
    • +
    +

    You may combine multiple arguments, and even multiple types of arguments. +For example:

    +
    npm install sax@">=0.1.0 <0.2.0" bench supervisor
    +

    The --tag argument will apply to all of the specified install targets. If a +tag with the given name exists, the tagged version is preferred over newer +versions.

    +

    The --dry-run argument will report in the usual way what the install would +have done without actually installing anything.

    +

    The --package-lock-only argument will only update the package-lock.json, +instead of checking node_modules and downloading dependencies.

    +

    The -f or --force argument will force npm to fetch remote resources even if a +local copy exists on disk.

    +
    npm install sax --force
    +

    The --no-fund argument will hide the message displayed at the end of each +install that acknowledges the number of dependencies looking for funding. +See npm-fund(1)

    +

    The -g or --global argument will cause npm to install the package globally +rather than locally. See folders.

    +

    The --global-style argument will cause npm to install the package into +your local node_modules folder with the same layout it uses with the +global node_modules folder. Only your direct dependencies will show in +node_modules and everything they depend on will be flattened in their +node_modules folders. This obviously will eliminate some deduping.

    +

    The --ignore-scripts argument will cause npm to not execute any +scripts defined in the package.json. See scripts.

    +

    The --legacy-bundling argument will cause npm to install the package such +that versions of npm prior to 1.4, such as the one included with node 0.8, +can install the package. This eliminates all automatic deduping.

    +

    The --link argument will cause npm to link global installs into the +local space in some cases.

    +

    The --no-bin-links argument will prevent npm from creating symlinks for +any binaries the package might contain.

    +

    The --no-optional argument will prevent optional dependencies from +being installed.

    +

    The --no-shrinkwrap argument, which will ignore an available +package lock or shrinkwrap file and use the package.json instead.

    +

    The --no-package-lock argument will prevent npm from creating a +package-lock.json file. When running with package-lock's disabled npm +will not automatically prune your node modules when installing.

    +

    The --nodedir=/path/to/node/source argument will allow npm to find the +node source code so that npm can compile native modules.

    +

    The --only={prod[uction]|dev[elopment]} argument will cause either only +devDependencies or only non-devDependencies to be installed regardless of the NODE_ENV.

    +

    The --no-audit argument can be used to disable sending of audit reports to +the configured registries. See npm-audit for details on what is sent.

    +

    See config. Many of the configuration params have some +effect on installation, since that's most of what npm does.

    +

    Algorithm

    +

    To install a package, npm uses the following algorithm:

    +
    load the existing node_modules tree from disk
    +clone the tree
    +fetch the package.json and assorted metadata and add it to the clone
    +walk the clone and add any missing dependencies
    +  dependencies will be added as close to the top as is possible
    +  without breaking any other modules
    +compare the original tree with the cloned tree and make a list of
    +actions to take to convert one to the other
    +execute all of the actions, deepest first
    +  kinds of actions are install, update, remove and move
    +

    For this package{dep} structure: A{B,C}, B{C}, C{D}, +this algorithm produces:

    +
    A
    ++-- B
    ++-- C
    ++-- D
    +

    That is, the dependency from B to C is satisfied by the fact that A +already caused C to be installed at a higher level. D is still installed +at the top level because nothing conflicts with it.

    +

    For A{B,C}, B{C,D@1}, C{D@2}, this algorithm produces:

    +
    A
    ++-- B
    ++-- C
    +   `-- D@2
    ++-- D@1
    +

    Because B's D@1 will be installed in the top level, C now has to install D@2 +privately for itself. This algorithm is deterministic, but different trees may +be produced if two dependencies are requested for installation in a different +order.

    +

    See folders for a more detailed description of the specific folder structures that npm creates.

    +

    Limitations of npm's Install Algorithm

    +

    npm will refuse to install any package with an identical name to the +current package. This can be overridden with the --force flag, but in +most cases can simply be addressed by changing the local package name.

    +

    There are some very rare and pathological edge-cases where a cycle can +cause npm to try to install a never-ending tree of packages. Here is +the simplest case:

    +
    A -> B -> A' -> B' -> A -> B -> A' -> B' -> A -> ...
    +

    where A is some version of a package, and A' is a different version +of the same package. Because B depends on a different version of A +than the one that is already in the tree, it must install a separate +copy. The same is true of A', which must install B'. Because B' +depends on the original version of A, which has been overridden, the +cycle falls into infinite regress.

    +

    To avoid this situation, npm flat-out refuses to install any +name@version that is already present anywhere in the tree of package +folder ancestors. A more correct, but more complex, solution would be +to symlink the existing version into the new location. If this ever +affects a real use-case, it will be investigated.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-link/index.html b/deps/npm/docs/public/cli-commands/npm-link/index.html new file mode 100644 index 00000000000000..330ea407c2767f --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-link/index.html @@ -0,0 +1,131 @@ +

    npm link

    + +

    Synopsis

    +
    npm link (in package dir)
    +npm link [<@scope>/]<pkg>[@<version>]
    +
    +alias: npm ln
    +

    Description

    +

    Package linking is a two-step process.

    +

    First, npm link in a package folder will create a symlink in the global folder +{prefix}/lib/node_modules/<package> that links to the package where the npm +link command was executed. (see npm-config for the value of prefix). It +will also link any bins in the package to {prefix}/bin/{name}.

    +

    Next, in some other location, npm link package-name will create a +symbolic link from globally-installed package-name to node_modules/ +of the current folder.

    +

    Note that package-name is taken from package.json, +not from directory name.

    +

    The package name can be optionally prefixed with a scope. See scope. +The scope must be preceded by an @-symbol and followed by a slash.

    +

    When creating tarballs for npm publish, the linked packages are +"snapshotted" to their current state by resolving the symbolic links.

    +

    This is handy for installing your own stuff, so that you can work on it and +test it iteratively without having to continually rebuild.

    +

    For example:

    +
        cd ~/projects/node-redis    # go into the package directory
    +    npm link                    # creates global link
    +    cd ~/projects/node-bloggy   # go into some other package directory.
    +    npm link redis              # link-install the package
    +

    Now, any changes to ~/projects/node-redis will be reflected in +~/projects/node-bloggy/node_modules/node-redis/. Note that the link should +be to the package name, not the directory name for that package.

    +

    You may also shortcut the two steps in one. For example, to do the +above use-case in a shorter way:

    +
    cd ~/projects/node-bloggy  # go into the dir of your main project
    +npm link ../node-redis     # link the dir of your dependency
    +

    The second line is the equivalent of doing:

    +
    (cd ../node-redis; npm link)
    +npm link redis
    +

    That is, it first creates a global link, and then links the global +installation target into your project's node_modules folder.

    +

    Note that in this case, you are referring to the directory name, node-redis, +rather than the package name redis.

    +

    If your linked package is scoped (see scope) your link command must include that scope, e.g.

    +
    npm link @myorg/privatepackage
    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-logout/index.html b/deps/npm/docs/public/cli-commands/npm-logout/index.html new file mode 100644 index 00000000000000..a5126df803b915 --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-logout/index.html @@ -0,0 +1,106 @@ +

    npm logout

    +

    Log out of the registry

    +

    Synopsis

    +
    npm logout [--registry=<url>] [--scope=<@scope>]
    +

    Description

    +

    When logged into a registry that supports token-based authentication, tell the +server to end this token's session. This will invalidate the token everywhere +you're using it, not just for the current environment.

    +

    When logged into a legacy registry that uses username and password authentication, this will +clear the credentials in your user configuration. In this case, it will only affect +the current environment.

    +

    If --scope is provided, this will find the credentials for the registry +connected to that scope, if set.

    +

    Configuration

    +

    registry

    +

    Default: https://registry.npmjs.org/

    +

    The base URL of the npm package registry. If scope is also specified, +it takes precedence.

    +

    scope

    +

    Default: The scope of your current project, if any, otherwise none.

    +

    If specified, you will be logged out of the specified scope. See scope.

    +
    npm logout --scope=@myco
    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-ls/index.html b/deps/npm/docs/public/cli-commands/npm-ls/index.html new file mode 100644 index 00000000000000..5658a377e99742 --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-ls/index.html @@ -0,0 +1,173 @@ +

    npm ls

    +

    List installed packages

    +

    Synopsis

    +
    npm ls [[<@scope>/]<pkg> ...]
    +
    +aliases: list, la, ll
    +

    Description

    +

    This command will print to stdout all the versions of packages that are +installed, as well as their dependencies, in a tree-structure.

    +

    Positional arguments are name@version-range identifiers, which will +limit the results to only the paths to the packages named. Note that +nested packages will also show the paths to the specified packages. +For example, running npm ls promzard in npm's source tree will show:

    +
        npm@6.13.4 /path/to/npm
    +    └─┬ init-package-json@0.0.4
    +      └── promzard@0.1.5
    +

    It will print out extraneous, missing, and invalid packages.

    +

    If a project specifies git urls for dependencies these are shown +in parentheses after the name@version to make it easier for users to +recognize potential forks of a project.

    +

    The tree shown is the logical dependency tree, based on package +dependencies, not the physical layout of your node_modules folder.

    +

    When run as ll or la, it shows extended information by default.

    +

    Configuration

    +

    json

    +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    Show information in JSON format.

    +

    long

    +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    Show extended information.

    +

    parseable

    +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    Show parseable output instead of tree view.

    +

    global

    +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    List packages in the global install prefix instead of in the current +project.

    +

    depth

    +
      +
    • Type: Int
    • +
    +

    Max display depth of the dependency tree.

    +

    prod / production

    +
      +
    • Type: Boolean
    • +
    • Default: false
    • +
    +

    Display only the dependency tree for packages in dependencies.

    +

    dev / development

    +
      +
    • Type: Boolean
    • +
    • Default: false
    • +
    +

    Display only the dependency tree for packages in devDependencies.

    +

    only

    +
      +
    • Type: String
    • +
    +

    When "dev" or "development", is an alias to dev.

    +

    When "prod" or "production", is an alias to production.

    + +
      +
    • Type: Boolean
    • +
    • Default: false
    • +
    +

    Display only dependencies which are linked

    +

    unicode

    +
      +
    • Type: Boolean
    • +
    • Default: true
    • +
    +

    Whether to represent the tree structure using unicode characters. +Set it to false in order to use all-ansi output.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-org/index.html b/deps/npm/docs/public/cli-commands/npm-org/index.html new file mode 100644 index 00000000000000..977f4e8cef976e --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-org/index.html @@ -0,0 +1,104 @@ +

    npm org

    +

    Manage orgs

    +

    Synopsis

    +
    npm org set <orgname> <username> [developer | admin | owner]
    +npm org rm <orgname> <username>
    +npm org ls <orgname> [<username>]
    +

    Example

    +

    Add a new developer to an org:

    +
    $ npm org set my-org @mx-smith
    +

    Add a new admin to an org (or change a developer to an admin):

    +
    $ npm org set my-org @mx-santos admin
    +

    Remove a user from an org:

    +
    $ npm org rm my-org mx-santos
    +

    List all users in an org:

    +
    $ npm org ls my-org
    +

    List all users in JSON format:

    +
    $ npm org ls my-org --json
    +

    See what role a user has in an org:

    +
    $ npm org ls my-org @mx-santos
    +

    Description

    +

    You can use the npm org commands to manage and view users of an organization. +It supports adding and removing users, changing their roles, listing them, and +finding specific ones and their roles.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-outdated/index.html b/deps/npm/docs/public/cli-commands/npm-outdated/index.html new file mode 100644 index 00000000000000..98b2cf029157e7 --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-outdated/index.html @@ -0,0 +1,175 @@ +

    npm outdated

    +

    Check for outdated packages

    +

    Synopsis

    +
    npm outdated [[<@scope>/]<pkg> ...]
    +

    Description

    +

    This command will check the registry to see if any (or, specific) installed +packages are currently outdated.

    +

    In the output:

    +
      +
    • wanted is the maximum version of the package that satisfies the semver +range specified in package.json. If there's no available semver range (i.e. +you're running npm outdated --global, or the package isn't included in +package.json), then wanted shows the currently-installed version.
    • +
    • latest is the version of the package tagged as latest in the registry. +Running npm publish with no special configuration will publish the package +with a dist-tag of latest. This may or may not be the maximum version of +the package, or the most-recently published version of the package, depending +on how the package's developer manages the latest dist-tag.
    • +
    • location is where in the dependency tree the package is located. Note that +npm outdated defaults to a depth of 0, so unless you override that, you'll +always be seeing only top-level dependencies that are outdated.
    • +
    • package type (when using --long / -l) tells you whether this package is +a dependency or a devDependency. Packages not included in package.json +are always marked dependencies.
    • +
    • homepage (when using --long / -l) is the homepage value contained in the package's package.json
    • +
    • Red means there's a newer version matching your semver requirements, so you should update now.
    • +
    • Yellow indicates that there's a newer version above your semver requirements (usually new major, or new 0.x minor) so proceed with caution.
    • +
    +

    An example

    +
    $ npm outdated
    +Package      Current   Wanted   Latest  Location
    +glob          5.0.15   5.0.15    6.0.1  test-outdated-output
    +nothingness    0.0.3      git      git  test-outdated-output
    +npm            3.5.1    3.5.2    3.5.1  test-outdated-output
    +local-dev      0.0.3   linked   linked  test-outdated-output
    +once           1.3.2    1.3.3    1.3.3  test-outdated-output
    +

    With these dependencies:

    +
    {
    +  "glob": "^5.0.15",
    +  "nothingness": "github:othiym23/nothingness#master",
    +  "npm": "^3.5.1",
    +  "once": "^1.3.1"
    +}
    +

    A few things to note:

    +
      +
    • glob requires ^5, which prevents npm from installing glob@6, which is +outside the semver range.
    • +
    • Git dependencies will always be reinstalled, because of how they're specified. +The installed committish might satisfy the dependency specifier (if it's +something immutable, like a commit SHA), or it might not, so npm outdated and +npm update have to fetch Git repos to check. This is why currently doing a +reinstall of a Git dependency always forces a new clone and install.
    • +
    • npm@3.5.2 is marked as "wanted", but "latest" is npm@3.5.1 because npm +uses dist-tags to manage its latest and next release channels. npm update +will install the newest version, but npm install npm (with no semver range) +will install whatever's tagged as latest.
    • +
    • once is just plain out of date. Reinstalling node_modules from scratch or +running npm update will bring it up to spec.
    • +
    +

    Configuration

    +

    json

    +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    Show information in JSON format.

    +

    long

    +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    Show extended information.

    +

    parseable

    +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    Show parseable output instead of tree view.

    +

    global

    +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    Check packages in the global install prefix instead of in the current +project.

    +

    depth

    +
      +
    • Default: 0
    • +
    • Type: Int
    • +
    +

    Max depth for checking dependency tree.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-owner/index.html b/deps/npm/docs/public/cli-commands/npm-owner/index.html new file mode 100644 index 00000000000000..87d6510c7d37da --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-owner/index.html @@ -0,0 +1,111 @@ +

    npm owner

    +

    Manage package owners

    +

    Synopsis

    +
    npm owner add <user> [<@scope>/]<pkg>
    +npm owner rm <user> [<@scope>/]<pkg>
    +npm owner ls [<@scope>/]<pkg>
    +
    +aliases: author
    +

    Description

    +

    Manage ownership of published packages.

    +
      +
    • ls: +List all the users who have access to modify a package and push new versions. +Handy when you need to know who to bug for help.
    • +
    • add: +Add a new user as a maintainer of a package. This user is enabled to modify +metadata, publish new versions, and add other owners.
    • +
    • rm: +Remove a user from the package owner list. This immediately revokes their +privileges.
    • +
    +

    Note that there is only one level of access. Either you can modify a package, +or you can't. Future versions may contain more fine-grained access levels, but +that is not implemented at this time.

    +

    If you have two-factor authentication enabled with auth-and-writes then +you'll need to include an otp on the command line when changing ownership +with --otp.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-pack/index.html b/deps/npm/docs/public/cli-commands/npm-pack/index.html new file mode 100644 index 00000000000000..3db98ee2758b4a --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-pack/index.html @@ -0,0 +1,99 @@ +

    npm pack

    +

    Create a tarball from a package

    +

    Synopsis

    +
    npm pack [[<@scope>/]<pkg>...] [--dry-run]
    +

    Description

    +

    For anything that's installable (that is, a package folder, tarball, +tarball url, name@tag, name@version, name, or scoped name), this +command will fetch it to the cache, and then copy the tarball to the +current working directory as <name>-<version>.tgz, and then write +the filenames out to stdout.

    +

    If the same package is specified multiple times, then the file will be +overwritten the second time.

    +

    If no arguments are supplied, then npm packs the current package folder.

    +

    The --dry-run argument will do everything that pack usually does without +actually packing anything. Reports on what would have gone into the tarball.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-ping/index.html b/deps/npm/docs/public/cli-commands/npm-ping/index.html new file mode 100644 index 00000000000000..202f197dd8a6e8 --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-ping/index.html @@ -0,0 +1,92 @@ +

    npm ping

    +

    Ping npm registry

    +

    Synopsis

    +
    npm ping [--registry <registry>]
    +

    Description

    +

    Ping the configured or given npm registry and verify authentication. +If it works it will output something like:

    +
    Ping success: {*Details about registry*}
    +

    otherwise you will get:

    +
    Ping error: {*Detail about error}
    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-prefix/index.html b/deps/npm/docs/public/cli-commands/npm-prefix/index.html new file mode 100644 index 00000000000000..35f8f6cdce2180 --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-prefix/index.html @@ -0,0 +1,95 @@ +

    npm prefix

    +

    Display prefix

    +

    Synopsis

    +
    npm prefix [-g]
    +

    Description

    +

    Print the local prefix to standard out. This is the closest parent directory +to contain a package.json file or node_modules directory, unless -g is +also specified.

    +

    If -g is specified, this will be the value of the global prefix. See +npm config for more detail.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-profile/index.html b/deps/npm/docs/public/cli-commands/npm-profile/index.html new file mode 100644 index 00000000000000..e8301c809d213a --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-profile/index.html @@ -0,0 +1,145 @@ +

    npm profile

    +

    Change settings on your registry profile

    +

    Synopsis

    +
    npm profile get [--json|--parseable] [<property>]
    +npm profile set [--json|--parseable] <property> <value>
    +npm profile set password
    +npm profile enable-2fa [auth-and-writes|auth-only]
    +npm profile disable-2fa
    +

    Description

    +

    Change your profile information on the registry. This not be available if +you're using a non-npmjs registry.

    +
      +
    • npm profile get [<property>]: +Display all of the properties of your profile, or one or more specific +properties. It looks like:
    • +
    +
    +-----------------+---------------------------+
    +| name            | example                   |
    ++-----------------+---------------------------+
    +| email           | me@example.com (verified) |
    ++-----------------+---------------------------+
    +| two factor auth | auth-and-writes           |
    ++-----------------+---------------------------+
    +| fullname        | Example User              |
    ++-----------------+---------------------------+
    +| homepage        |                           |
    ++-----------------+---------------------------+
    +| freenode        |                           |
    ++-----------------+---------------------------+
    +| twitter         |                           |
    ++-----------------+---------------------------+
    +| github          |                           |
    ++-----------------+---------------------------+
    +| created         | 2015-02-26T01:38:35.892Z  |
    ++-----------------+---------------------------+
    +| updated         | 2017-10-02T21:29:45.922Z  |
    ++-----------------+---------------------------+
    +
      +
    • npm profile set <property> <value>: +Set the value of a profile property. You can set the following properties this way: +email, fullname, homepage, freenode, twitter, github
    • +
    • npm profile set password: +Change your password. This is interactive, you'll be prompted for your +current password and a new password. You'll also be prompted for an OTP +if you have two-factor authentication enabled.
    • +
    • +

      npm profile enable-2fa [auth-and-writes|auth-only]: +Enables two-factor authentication. Defaults to auth-and-writes mode. Modes are:

      +
        +
      • auth-only: Require an OTP when logging in or making changes to your +account's authentication. The OTP will be required on both the website +and the command line.
      • +
      • auth-and-writes: Requires an OTP at all the times auth-only does, and also requires one when +publishing a module, setting the latest dist-tag, or changing access +via npm access and npm owner.
      • +
      +
    • +
    • npm profile disable-2fa: +Disables two-factor authentication.
    • +
    +

    Details

    +

    All of the npm profile subcommands accept --json and --parseable and +will tailor their output based on those. Some of these commands may not be +available on non npmjs.com registries.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-prune/index.html b/deps/npm/docs/public/cli-commands/npm-prune/index.html new file mode 100644 index 00000000000000..34c2f9905f1c50 --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-prune/index.html @@ -0,0 +1,105 @@ +

    npm prune

    +

    Remove extraneous packages

    +

    Synopsis

    +
    npm prune [[<@scope>/]<pkg>...] [--production] [--dry-run] [--json]
    +

    Description

    +

    This command removes "extraneous" packages. If a package name is +provided, then only packages matching one of the supplied names are +removed.

    +

    Extraneous packages are packages that are not listed on the parent +package's dependencies list.

    +

    If the --production flag is specified or the NODE_ENV environment +variable is set to production, this command will remove the packages +specified in your devDependencies. Setting --no-production will +negate NODE_ENV being set to production.

    +

    If the --dry-run flag is used then no changes will actually be made.

    +

    If the --json flag is used then the changes npm prune made (or would +have made with --dry-run) are printed as a JSON object.

    +

    In normal operation with package-locks enabled, extraneous modules are +pruned automatically when modules are installed and you'll only need +this command with the --production flag.

    +

    If you've disabled package-locks then extraneous modules will not be removed +and it's up to you to run npm prune from time-to-time to remove them.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-publish/index.html b/deps/npm/docs/public/cli-commands/npm-publish/index.html new file mode 100644 index 00000000000000..8096dd81de6628 --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-publish/index.html @@ -0,0 +1,137 @@ +

    npm publish

    +

    Publish a package

    +

    Synopsis

    +
    npm publish [<tarball>|<folder>] [--tag <tag>] [--access <public|restricted>] [--otp otpcode] [--dry-run]
    +
    +Publishes '.' if no argument supplied
    +Sets tag 'latest' if no --tag specified
    +

    Description

    +

    Publishes a package to the registry so that it can be installed by name. All +files in the package directory are included if no local .gitignore or +.npmignore file exists. If both files exist and a file is ignored by +.gitignore but not by .npmignore then it will be included. See +developers for full details on what's included in the published package, as well as details on how the package is built.

    +

    By default npm will publish to the public registry. This can be overridden by +specifying a different default registry or using a scope in the name (see package.json).

    +
      +
    • <folder>: +A folder containing a package.json file
    • +
    • <tarball>: +A url or file path to a gzipped tar archive containing a single folder +with a package.json file inside.
    • +
    • [--tag <tag>] +Registers the published package with the given tag, such that npm install +<name>@<tag> will install this version. By default, npm publish updates +and npm install installs the latest tag. See npm-dist-tag for +details about tags.
    • +
    • [--access <public|restricted>] +Tells the registry whether this package should be published as public or +restricted. Only applies to scoped packages, which default to restricted. +If you don't have a paid account, you must publish with --access public +to publish scoped packages.
    • +
    • [--otp <otpcode>] +If you have two-factor authentication enabled in auth-and-writes mode +then you can provide a code from your authenticator with this. If you +don't include this and you're running from a TTY then you'll be prompted.
    • +
    • [--dry-run] +As of npm@6, does everything publish would do except actually publishing +to the registry. Reports the details of what would have been published.
    • +
    +

    Fails if the package name and version combination already exists in +the specified registry.

    +

    Once a package is published with a given name and version, that +specific name and version combination can never be used again, even if +it is removed with npm unpublish.

    +

    As of npm@5, both a sha1sum and an integrity field with a sha512sum of the +tarball will be submitted to the registry during publication. Subsequent +installs will use the strongest supported algorithm to verify downloads.

    +

    Similar to --dry-run see npm pack, which figures out the files to be +included and packs them into a tarball to be uploaded to the registry.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-rebuild/index.html b/deps/npm/docs/public/cli-commands/npm-rebuild/index.html new file mode 100644 index 00000000000000..cd37ea2810314e --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-rebuild/index.html @@ -0,0 +1,90 @@ +

    npm rebuild

    +

    Rebuild a package

    +

    Synopsis

    +
    npm rebuild [[<@scope>/<name>]...]
    +
    +alias: npm rb
    +

    Description

    +

    This command runs the npm build command on the matched folders. This is useful when you install a new version of node, and must recompile all your C++ addons with the new binary.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-repo/index.html b/deps/npm/docs/public/cli-commands/npm-repo/index.html new file mode 100644 index 00000000000000..20bf77637ffb3b --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-repo/index.html @@ -0,0 +1,98 @@ +

    npm repo

    +

    Open package repository page in the browser

    +

    Synopsis

    +
    npm repo [<pkg>]
    +

    Description

    +

    This command tries to guess at the likely location of a package's +repository URL, and then tries to open it using the --browser +config param. If no package name is provided, it will search for +a package.json in the current folder and use the name property.

    +

    Configuration

    +

    browser

    +
      +
    • Default: OS X: "open", Windows: "start", Others: "xdg-open"
    • +
    • Type: String
    • +
    +

    The browser that is called by the npm repo command to open websites.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-restart/index.html b/deps/npm/docs/public/cli-commands/npm-restart/index.html new file mode 100644 index 00000000000000..16a9827976f183 --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-restart/index.html @@ -0,0 +1,110 @@ +

    npm restart

    +

    Restart a package

    +

    Synopsis

    +
    npm restart [-- <args>]
    +

    Description

    +

    This restarts a package.

    +

    This runs a package's "stop", "restart", and "start" scripts, and associated +pre- and post- scripts, in the order given below:

    +
      +
    1. prerestart
    2. +
    3. prestop
    4. +
    5. stop
    6. +
    7. poststop
    8. +
    9. restart
    10. +
    11. prestart
    12. +
    13. start
    14. +
    15. poststart
    16. +
    17. postrestart
    18. +
    +

    Note

    +

    Note that the "restart" script is run in addition to the "stop" +and "start" scripts, not instead of them.

    +

    This is the behavior as of npm major version 2. A change in this +behavior will be accompanied by an increase in major version number

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-root/index.html b/deps/npm/docs/public/cli-commands/npm-root/index.html new file mode 100644 index 00000000000000..6c415ca02c99ae --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-root/index.html @@ -0,0 +1,91 @@ +

    npm root

    +

    Display npm root

    +

    Synopsis

    +
    npm root [-g]
    +

    Description

    +

    Print the effective node_modules folder to standard out.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-run-script/index.html b/deps/npm/docs/public/cli-commands/npm-run-script/index.html new file mode 100644 index 00000000000000..7b437ad7a938f8 --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-run-script/index.html @@ -0,0 +1,140 @@ +

    npm run-script

    +

    Run arbitrary package scripts

    +

    Synopsis

    +
    npm run-script <command> [--silent] [-- <args>...]
    +
    +alias: npm run
    +

    Description

    +

    This runs an arbitrary command from a package's "scripts" object. If no +"command" is provided, it will list the available scripts. run[-script] is +used by the test, start, restart, and stop commands, but can be called +directly, as well. When the scripts in the package are printed out, they're +separated into lifecycle (test, start, restart) and directly-run scripts.

    +

    As of npm@2.0.0, you can +use custom arguments when executing scripts. The special option -- is used by +getopt to delimit the end of the options. npm will pass +all the arguments after the -- directly to your script:

    +
    npm run test -- --grep="pattern"
    +

    The arguments will only be passed to the script specified after npm run +and not to any pre or post script.

    +

    The env script is a special built-in command that can be used to list +environment variables that will be available to the script at runtime. If an +"env" command is defined in your package, it will take precedence over the +built-in.

    +

    In addition to the shell's pre-existing PATH, npm run adds +node_modules/.bin to the PATH provided to scripts. Any binaries provided by +locally-installed dependencies can be used without the node_modules/.bin +prefix. For example, if there is a devDependency on tap in your package, +you should write:

    +
    "scripts": {"test": "tap test/\*.js"}
    +

    instead of

    +
    "scripts": {"test": "node_modules/.bin/tap test/\*.js"}
    +

    to run your tests.

    +

    The actual shell your script is run within is platform dependent. By default, +on Unix-like systems it is the /bin/sh command, on Windows it is the cmd.exe. +The actual shell referred to by /bin/sh also depends on the system. +As of npm@5.1.0 you can +customize the shell with the script-shell configuration.

    +

    Scripts are run from the root of the module, regardless of what your current +working directory is when you call npm run. If you want your script to +use different behavior based on what subdirectory you're in, you can use the +INIT_CWD environment variable, which holds the full path you were in when +you ran npm run.

    +

    npm run sets the NODE environment variable to the node executable with +which npm is executed. Also, if the --scripts-prepend-node-path is passed, +the directory within which node resides is added to the +PATH. If --scripts-prepend-node-path=auto is passed (which has been the +default in npm v3), this is only performed when that node executable is +not found in the PATH.

    +

    If you try to run a script without having a node_modules directory and it fails, +you will be given a warning to run npm install, just in case you've forgotten.

    +

    You can use the --silent flag to prevent showing npm ERR! output on error.

    +

    You can use the --if-present flag to avoid exiting with a non-zero exit code +when the script is undefined. This lets you run potentially undefined scripts +without breaking the execution chain.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-search/index.html b/deps/npm/docs/public/cli-commands/npm-search/index.html new file mode 100644 index 00000000000000..b2e91e373cf91e --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-search/index.html @@ -0,0 +1,165 @@ +

    npm search

    +

    Search for packages

    +

    Synopsis

    +
    npm search [-l|--long] [--json] [--parseable] [--no-description] [search terms ...]
    +
    +aliases: s, se, find
    +

    Description

    +

    Search the registry for packages matching the search terms. npm search +performs a linear, incremental, lexically-ordered search through package +metadata for all files in the registry. If color is enabled, it will further +highlight the matches in the results.

    +

    Additionally, using the --searchopts and --searchexclude options paired with +more search terms will respectively include and exclude further patterns. The +main difference between --searchopts and the standard search terms is that the +former does not highlight results in the output and can be used for more +fine-grained filtering. Additionally, both of these can be added to .npmrc for +default search filtering behavior.

    +

    Search also allows targeting of maintainers in search results, by prefixing +their npm username with =.

    +

    If a term starts with /, then it's interpreted as a regular expression and +supports standard JavaScript RegExp syntax. A trailing / will be ignored in +this case. (Note that many regular expression characters must be escaped or +quoted in most shells.)

    +

    A Note on caching

    +

    Configuration

    +

    description

    +
      +
    • Default: true
    • +
    • Type: Boolean
    • +
    +

    Used as --no-description, disables search matching in package descriptions and +suppresses display of that field in results.

    +

    json

    +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    Output search results as a JSON array.

    +

    parseable

    +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    Output search results as lines with tab-separated columns.

    +

    long

    +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    Display full package descriptions and other long text across multiple +lines. When disabled (default) search results are truncated to fit +neatly on a single line. Modules with extremely long names will +fall on multiple lines.

    +

    searchopts

    +
      +
    • Default: ""
    • +
    • Type: String
    • +
    +

    Space-separated options that are always passed to search.

    +

    searchexclude

    +
      +
    • Default: ""
    • +
    • Type: String
    • +
    +

    Space-separated options that limit the results from search.

    +

    searchstaleness

    +
      +
    • Default: 900 (15 minutes)
    • +
    • Type: Number
    • +
    +

    The age of the cache, in seconds, before another registry request is made.

    +

    registry

    + +

    Search the specified registry for modules. If you have configured npm to point +to a different default registry, such as your internal private module +repository, npm search will default to that registry when searching. Pass a +different registry url such as the default above in order to override this +setting.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-shrinkwrap/index.html b/deps/npm/docs/public/cli-commands/npm-shrinkwrap/index.html new file mode 100644 index 00000000000000..c4537b43edec05 --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-shrinkwrap/index.html @@ -0,0 +1,98 @@ +

    npm shrinkwrap

    +

    Lock down dependency versions for publication

    +

    Synopsis

    +
    npm shrinkwrap
    +

    Description

    +

    This command repurposes package-lock.json into a publishable +npm-shrinkwrap.json or simply creates a new one. The file created and updated +by this command will then take precedence over any other existing or future +package-lock.json files. For a detailed explanation of the design and purpose +of package locks in npm, see package-locks.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-star/index.html b/deps/npm/docs/public/cli-commands/npm-star/index.html new file mode 100644 index 00000000000000..f00ac985b1433a --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-star/index.html @@ -0,0 +1,93 @@ +

    npm star

    +

    Mark your favorite packages

    +

    Synopsis

    +
    npm star [<pkg>...]
    +npm unstar [<pkg>...]
    +

    Description

    +

    "Starring" a package means that you have some interest in it. It's +a vaguely positive way to show that you care.

    +

    "Unstarring" is the same thing, but in reverse.

    +

    It's a boolean thing. Starring repeatedly has no additional effect.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-stars/index.html b/deps/npm/docs/public/cli-commands/npm-stars/index.html new file mode 100644 index 00000000000000..ee36575ada2452 --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-stars/index.html @@ -0,0 +1,93 @@ +

    npm stars

    +

    View packages marked as favorites

    +

    Synopsis

    +
    npm stars [<user>]
    +

    Description

    +

    If you have starred a lot of neat things and want to find them again +quickly this command lets you do just that.

    +

    You may also want to see your friend's favorite packages, in this case +you will most certainly enjoy this command.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-start/index.html b/deps/npm/docs/public/cli-commands/npm-start/index.html new file mode 100644 index 00000000000000..c5b8984a11ecd2 --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-start/index.html @@ -0,0 +1,95 @@ +

    npm start

    +

    Start a package

    +

    Synopsis

    +
    npm start [-- <args>]
    +

    Description

    +

    This runs an arbitrary command specified in the package's "start" property of +its "scripts" object. If no "start" property is specified on the +"scripts" object, it will run node server.js.

    +

    As of npm@2.0.0, you can +use custom arguments when executing scripts. Refer to npm run-script for more details.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-stop/index.html b/deps/npm/docs/public/cli-commands/npm-stop/index.html new file mode 100644 index 00000000000000..3559b9b8ca3bf6 --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-stop/index.html @@ -0,0 +1,91 @@ +

    npm stop

    +

    Stop a package

    +

    Synopsis

    +
    npm stop [-- <args>]
    +

    Description

    +

    This runs a package's "stop" script, if one was provided.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-team/index.html b/deps/npm/docs/public/cli-commands/npm-team/index.html new file mode 100644 index 00000000000000..58c99f13f84da2 --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-team/index.html @@ -0,0 +1,121 @@ +

    npm team

    +

    Manage organization teams and team memberships

    +

    Synopsis

    +
    npm team create <scope:team>
    +npm team destroy <scope:team>
    +
    +npm team add <scope:team> <user>
    +npm team rm <scope:team> <user>
    +
    +npm team ls <scope>|<scope:team>
    +
    +npm team edit <scope:team>
    +

    Description

    +

    Used to manage teams in organizations, and change team memberships. Does not +handle permissions for packages.

    +

    Teams must always be fully qualified with the organization/scope they belong to +when operating on them, separated by a colon (:). That is, if you have a wombats team in a wisdom organization, you must always refer to that team as wisdom:wombats in these commands.

    +
      +
    • create / destroy: +Create a new team, or destroy an existing one. Note: You cannot remove the developers team, learn more.
    • +
    • add / rm: +Add a user to an existing team, or remove a user from a team they belong to.
    • +
    • ls: +If performed on an organization name, will return a list of existing teams +under that organization. If performed on a team, it will instead return a list +of all users belonging to that particular team.
    • +
    • edit: +Edit a current team.
    • +
    +

    Details

    +

    npm team always operates directly on the current registry, configurable from +the command line using --registry=<registry url>.

    +

    In order to create teams and manage team membership, you must be a team admin +under the given organization. Listing teams and team memberships may be done by +any member of the organizations.

    +

    Organization creation and management of team admins and organization members +is done through the website, not the npm CLI.

    +

    To use teams to manage permissions on packages belonging to your organization, +use the npm access command to grant or revoke the appropriate permissions.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-test/index.html b/deps/npm/docs/public/cli-commands/npm-test/index.html new file mode 100644 index 00000000000000..f0a6a411dc1783 --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-test/index.html @@ -0,0 +1,93 @@ +

    npm test

    +

    Test a package

    +

    Synopsis

    +
    npm test [-- <args>]
    +
    +aliases: t, tst
    +

    Description

    +

    This runs a package's "test" script, if one was provided.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-token/index.html b/deps/npm/docs/public/cli-commands/npm-token/index.html new file mode 100644 index 00000000000000..f42f3b5e32e7f9 --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-token/index.html @@ -0,0 +1,130 @@ +

    npm token

    +

    Manage your authentication tokens

    +

    Synopsis

    +
      npm token list [--json|--parseable]
    +  npm token create [--read-only] [--cidr=1.1.1.1/24,2.2.2.2/16]
    +  npm token revoke <id|token>
    +

    Description

    +

    This lets you list, create and revoke authentication tokens.

    +
      +
    • npm token list: +Shows a table of all active authentication tokens. You can request this as +JSON with --json or tab-separated values with --parseable.
    • +
    +
    +--------+---------+------------+----------+----------------+
    +| id     | token   | created    | read-only | CIDR whitelist |
    ++--------+---------+------------+----------+----------------+
    +| 7f3134 | 1fa9ba… | 2017-10-02 | yes      |                |
    ++--------+---------+------------+----------+----------------+
    +| c03241 | af7aef… | 2017-10-02 | no       | 192.168.0.1/24 |
    ++--------+---------+------------+----------+----------------+
    +| e0cf92 | 3a436a… | 2017-10-02 | no       |                |
    ++--------+---------+------------+----------+----------------+
    +| 63eb9d | 74ef35… | 2017-09-28 | no       |                |
    ++--------+---------+------------+----------+----------------+
    +| 2daaa8 | cbad5f… | 2017-09-26 | no       |                |
    ++--------+---------+------------+----------+----------------+
    +| 68c2fe | 127e51… | 2017-09-23 | no       |                |
    ++--------+---------+------------+----------+----------------+
    +| 6334e1 | 1dadd1… | 2017-09-23 | no       |                |
    ++--------+---------+------------+----------+----------------+
    +
      +
    • npm token create [--read-only] [--cidr=<cidr-ranges>]: +Create a new authentication token. It can be --read-only or accept a list of +CIDR ranges to +limit use of this token to. This will prompt you for your password, and, if you have +two-factor authentication enabled, an otp.
    • +
    +
    +----------------+--------------------------------------+
    +| token          | a73c9572-f1b9-8983-983d-ba3ac3cc913d |
    ++----------------+--------------------------------------+
    +| cidr_whitelist |                                      |
    ++----------------+--------------------------------------+
    +| readonly       | false                                |
    ++----------------+--------------------------------------+
    +| created        | 2017-10-02T07:52:24.838Z             |
    ++----------------+--------------------------------------+
    +
      +
    • npm token revoke <token|id>: +This removes an authentication token, making it immediately unusable. This can accept +both complete tokens (as you get back from npm token create and will +find in your .npmrc) and ids as seen in the npm token list output. +This will NOT accept the truncated token found in npm token list output.
    • +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-uninstall/index.html b/deps/npm/docs/public/cli-commands/npm-uninstall/index.html new file mode 100644 index 00000000000000..869c5d76cce8aa --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-uninstall/index.html @@ -0,0 +1,115 @@ +

    npm uninstall

    +

    Remove a package

    +

    Synopsis

    +
    npm uninstall [<@scope>/]<pkg>[@<version>]... [-S|--save|-D|--save-dev|-O|--save-optional|--no-save]
    +
    +aliases: remove, rm, r, un, unlink
    +

    Description

    +

    This uninstalls a package, completely removing everything npm installed +on its behalf.

    +

    Example:

    +
    npm uninstall sax
    +

    In global mode (ie, with -g or --global appended to the command), +it uninstalls the current package context as a global package.

    +

    npm uninstall takes 3 exclusive, optional flags which save or update +the package version in your main package.json:

    +
      +
    • -S, --save: Package will be removed from your dependencies.
    • +
    • -D, --save-dev: Package will be removed from your devDependencies.
    • +
    • -O, --save-optional: Package will be removed from your optionalDependencies.
    • +
    • --no-save: Package will not be removed from your package.json file.
    • +
    +

    Further, if you have an npm-shrinkwrap.json then it will be updated as +well.

    +

    Scope is optional and follows the usual rules for scope.

    +

    Examples:

    +
    npm uninstall sax --save
    +npm uninstall @myorg/privatepackage --save
    +npm uninstall node-tap --save-dev
    +npm uninstall dtrace-provider --save-optional
    +npm uninstall lodash --no-save
    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-unpublish/index.html b/deps/npm/docs/public/cli-commands/npm-unpublish/index.html new file mode 100644 index 00000000000000..ef80682fba888b --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-unpublish/index.html @@ -0,0 +1,110 @@ +

    npm unpublish

    +

    Remove a package from the registry

    +

    Synopsis

    +
    npm unpublish [<@scope>/]<pkg>[@<version>]
    +

    Warning

    +

    It is generally considered bad behavior to remove versions of a library +that others are depending on!

    +

    Consider using the deprecate command +instead, if your intent is to encourage users to upgrade.

    +

    There is plenty of room on the registry.

    +

    Description

    +

    This removes a package version from the registry, deleting its +entry and removing the tarball.

    +

    If no version is specified, or if all versions are removed then +the root package entry is removed from the registry entirely.

    +

    Even if a package version is unpublished, that specific name and +version combination can never be reused. In order to publish the +package again, a new version number must be used. Additionally, +new versions of packages with every version unpublished may not +be republished until 24 hours have passed.

    +

    With the default registry (registry.npmjs.org), unpublish is +only allowed with versions published in the last 72 hours. If you +are trying to unpublish a version published longer ago than that, +contact support@npmjs.com.

    +

    The scope is optional and follows the usual rules for scope.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-update/index.html b/deps/npm/docs/public/cli-commands/npm-update/index.html new file mode 100644 index 00000000000000..e7db5859958bc5 --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-update/index.html @@ -0,0 +1,163 @@ +

    npm update

    +

    Update a package

    +

    Synopsis

    +
    npm update [-g] [<pkg>...]
    +
    +aliases: up, upgrade
    +

    Description

    +

    This command will update all the packages listed to the latest version +(specified by the tag config), respecting semver.

    +

    It will also install missing packages. As with all commands that install +packages, the --dev flag will cause devDependencies to be processed +as well.

    +

    If the -g flag is specified, this command will update globally installed +packages.

    +

    If no package name is specified, all packages in the specified location (global +or local) will be updated.

    +

    As of npm@2.6.1, the npm update will only inspect top-level packages. +Prior versions of npm would also recursively inspect all dependencies. +To get the old behavior, use npm --depth 9999 update.

    +

    As of npm@5.0.0, the npm update will change package.json to save the +new version as the minimum required dependency. To get the old behavior, +use npm update --no-save.

    +

    Example

    +

    IMPORTANT VERSION NOTE: these examples assume npm@2.6.1 or later. For +older versions of npm, you must specify --depth 0 to get the behavior +described below.

    +

    For the examples below, assume that the current package is app and it depends +on dependencies, dep1 (dep2, .. etc.). The published versions of dep1 are:

    +
    {
    +  "dist-tags": { "latest": "1.2.2" },
    +  "versions": [
    +    "1.2.2",
    +    "1.2.1",
    +    "1.2.0",
    +    "1.1.2",
    +    "1.1.1",
    +    "1.0.0",
    +    "0.4.1",
    +    "0.4.0",
    +    "0.2.0"
    +  ]
    +}
    +

    Caret Dependencies

    +

    If app's package.json contains:

    +
    "dependencies": {
    +  "dep1": "^1.1.1"
    +}
    +

    Then npm update will install dep1@1.2.2, because 1.2.2 is latest and +1.2.2 satisfies ^1.1.1.

    +

    Tilde Dependencies

    +

    However, if app's package.json contains:

    +
    "dependencies": {
    +  "dep1": "~1.1.1"
    +}
    +

    In this case, running npm update will install dep1@1.1.2. Even though the latest +tag points to 1.2.2, this version does not satisfy ~1.1.1, which is equivalent +to >=1.1.1 <1.2.0. So the highest-sorting version that satisfies ~1.1.1 is used, +which is 1.1.2.

    +

    Caret Dependencies below 1.0.0

    +

    Suppose app has a caret dependency on a version below 1.0.0, for example:

    +
    "dependencies": {
    +  "dep1": "^0.2.0"
    +}
    +

    npm update will install dep1@0.2.0, because there are no other +versions which satisfy ^0.2.0.

    +

    If the dependence were on ^0.4.0:

    +
    "dependencies": {
    +  "dep1": "^0.4.0"
    +}
    +

    Then npm update will install dep1@0.4.1, because that is the highest-sorting +version that satisfies ^0.4.0 (>= 0.4.0 <0.5.0)

    +

    Updating Globally-Installed Packages

    +

    npm update -g will apply the update action to each globally installed +package that is outdated -- that is, has a version that is different from +latest.

    +

    NOTE: If a package has been upgraded to a version newer than latest, it will +be downgraded.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-version/index.html b/deps/npm/docs/public/cli-commands/npm-version/index.html new file mode 100644 index 00000000000000..442bd78028293d --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-version/index.html @@ -0,0 +1,177 @@ +

    npm version

    +

    Bump a package version

    +

    Synopsis

    +
    npm version [<newversion> | major | minor | patch | premajor | preminor | prepatch | prerelease [--preid=<prerelease-id>] | from-git]
    +
    +'npm [-v | --version]' to print npm version
    +'npm view <pkg> version' to view a package's published version
    +'npm ls' to inspect current package/dependency versions
    +

    Description

    +

    Run this in a package directory to bump the version and write the new +data back to package.json, package-lock.json, and, if present, npm-shrinkwrap.json.

    +

    The newversion argument should be a valid semver string, a +valid second argument to semver.inc (one of patch, minor, major, +prepatch, preminor, premajor, prerelease), or from-git. In the second case, +the existing version will be incremented by 1 in the specified field. +from-git will try to read the latest git tag, and use that as the new npm version.

    +

    If run in a git repo, it will also create a version commit and tag. +This behavior is controlled by git-tag-version (see below), and can +be disabled on the command line by running npm --no-git-tag-version version. +It will fail if the working directory is not clean, unless the -f or +--force flag is set.

    +

    If supplied with -m or --message config option, npm will +use it as a commit message when creating a version commit. If the +message config contains %s then that will be replaced with the +resulting version number. For example:

    +
    npm version patch -m "Upgrade to %s for reasons"
    +

    If the sign-git-tag config is set, then the tag will be signed using +the -s flag to git. Note that you must have a default GPG key set up +in your git config for this to work properly. For example:

    +
    $ npm config set sign-git-tag true
    +$ npm version patch
    +
    +You need a passphrase to unlock the secret key for
    +user: "isaacs (http://blog.izs.me/) <i@izs.me>"
    +2048-bit RSA key, ID 6C481CF6, created 2010-08-31
    +
    +Enter passphrase:
    +

    If preversion, version, or postversion are in the scripts property of +the package.json, they will be executed as part of running npm version.

    +

    The exact order of execution is as follows:

    +
      +
    1. Check to make sure the git working directory is clean before we get started. +Your scripts may add files to the commit in future steps. +This step is skipped if the --force flag is set.
    2. +
    3. Run the preversion script. These scripts have access to the old version in package.json. +A typical use would be running your full test suite before deploying. +Any files you want added to the commit should be explicitly added using git add.
    4. +
    5. Bump version in package.json as requested (patch, minor, major, etc).
    6. +
    7. Run the version script. These scripts have access to the new version in package.json +(so they can incorporate it into file headers in generated files for example). +Again, scripts should explicitly add generated files to the commit using git add.
    8. +
    9. Commit and tag.
    10. +
    11. Run the postversion script. Use it to clean up the file system or automatically push +the commit and/or tag.
    12. +
    +

    Take the following example:

    +
        "scripts": {
    +      "preversion": "npm test",
    +      "version": "npm run build && git add -A dist",
    +      "postversion": "git push && git push --tags && rm -rf build/temp"
    +    }
    +

    This runs all your tests, and proceeds only if they pass. Then runs your build script, and +adds everything in the dist directory to the commit. After the commit, it pushes the new commit +and tag up to the server, and deletes the build/temp directory.

    +

    Configuration

    +

    allow-same-version

    +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    Prevents throwing an error when npm version is used to set the new version +to the same value as the current version.

    +

    git-tag-version

    +
      +
    • Default: true
    • +
    • Type: Boolean
    • +
    +

    Commit and tag the version change.

    +

    commit-hooks

    +
      +
    • Default: true
    • +
    • Type: Boolean
    • +
    +

    Run git commit hooks when committing the version change.

    +

    sign-git-tag

    +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    Pass the -s flag to git to sign the tag.

    +

    Note that you must have a default GPG key set up in your git config for this to work properly.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-view/index.html b/deps/npm/docs/public/cli-commands/npm-view/index.html new file mode 100644 index 00000000000000..ffb7342d0fe1fa --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-view/index.html @@ -0,0 +1,142 @@ +

    npm view

    +

    View registry info

    +

    Synopsis

    +
    npm view [<@scope>/]<name>[@<version>] [<field>[.<subfield>]...]
    +
    +aliases: info, show, v
    +

    Description

    +

    This command shows data about a package and prints it to the stream +referenced by the outfd config, which defaults to stdout.

    +

    To show the package registry entry for the connect package, you can do +this:

    +
    npm view connect
    +

    The default version is "latest" if unspecified.

    +

    Field names can be specified after the package descriptor. +For example, to show the dependencies of the ronn package at version +0.3.5, you could do the following:

    +
    npm view ronn@0.3.5 dependencies
    +

    You can view child fields by separating them with a period. +To view the git repository URL for the latest version of npm, you could +do this:

    +
    npm view npm repository.url
    +

    This makes it easy to view information about a dependency with a bit of +shell scripting. For example, to view all the data about the version of +opts that ronn depends on, you can do this:

    +
    npm view opts@$(npm view ronn dependencies.opts)
    +

    For fields that are arrays, requesting a non-numeric field will return +all of the values from the objects in the list. For example, to get all +the contributor names for the "express" project, you can do this:

    +
    npm view express contributors.email
    +

    You may also use numeric indices in square braces to specifically select +an item in an array field. To just get the email address of the first +contributor in the list, you can do this:

    +
    npm view express contributors[0].email
    +

    Multiple fields may be specified, and will be printed one after another. +For example, to get all the contributor names and email addresses, you +can do this:

    +
    npm view express contributors.name contributors.email
    +

    "Person" fields are shown as a string if they would be shown as an +object. So, for example, this will show the list of npm contributors in +the shortened string format. (See package.json for more on this.)

    +
    npm view npm contributors
    +

    If a version range is provided, then data will be printed for every +matching version of the package. This will show which version of jsdom +was required by each matching version of yui3:

    +
    npm view yui3@'>0.5.4' dependencies.jsdom
    +

    To show the connect package version history, you can do +this:

    +
    npm view connect versions
    +

    Output

    +

    If only a single string field for a single version is output, then it +will not be colorized or quoted, so as to enable piping the output to +another command. If the field is an object, it will be output as a JavaScript object literal.

    +

    If the --json flag is given, the outputted fields will be JSON.

    +

    If the version range matches multiple versions, than each printed value +will be prefixed with the version it applies to.

    +

    If multiple fields are requested, than each of them are prefixed with +the field name.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-whoami/index.html b/deps/npm/docs/public/cli-commands/npm-whoami/index.html new file mode 100644 index 00000000000000..37249551ba1e66 --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm-whoami/index.html @@ -0,0 +1,89 @@ +

    npm whoami

    +

    Display npm username

    +

    Synopsis

    +
    npm whoami [--registry <registry>]
    +

    Description

    +

    Print the username config to standard output.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm/index.html b/deps/npm/docs/public/cli-commands/npm/index.html new file mode 100644 index 00000000000000..96bdcfe10462df --- /dev/null +++ b/deps/npm/docs/public/cli-commands/npm/index.html @@ -0,0 +1,208 @@ +

    npm

    +

    javascript package manager

    +

    Synopsis

    +
    npm <command> [args]
    +

    Version

    +

    6.13.4

    +

    Description

    +

    npm is the package manager for the Node JavaScript platform. It puts +modules in place so that node can find them, and manages dependency +conflicts intelligently.

    +

    It is extremely configurable to support a wide variety of use cases. +Most commonly, it is used to publish, discover, install, and develop node +programs.

    +

    Run npm help to get a list of available commands.

    +

    Important

    +

    npm is configured to use npm, Inc.'s public registry at +https://registry.npmjs.org by default. Use of the npm public registry is +subject to terms of use available at https://www.npmjs.com/policies/terms.

    +

    You can configure npm to use any compatible registry you like, and even run +your own registry. Use of someone else's registry may be governed by their +terms of use.

    +

    Introduction

    +

    You probably got npm because you want to install stuff.

    +

    Use npm install blerg to install the latest version of "blerg". Check out +npm install for more info. It can do a lot of stuff.

    +

    Use the npm search command to show everything that's available. +Use npm ls to show everything you've installed.

    +

    Dependencies

    +

    If a package references to another package with a git URL, npm depends +on a preinstalled git.

    +

    If one of the packages npm tries to install is a native node module and +requires compiling of C++ Code, npm will use +node-gyp for that task. +For a Unix system, node-gyp +needs Python, make and a buildchain like GCC. On Windows, +Python and Microsoft Visual Studio C++ are needed. Python 3 is +not supported by node-gyp. +For more information visit +the node-gyp repository and +the node-gyp Wiki.

    +

    Directories

    +

    See folders to learn about where npm puts stuff.

    +

    In particular, npm has two modes of operation:

    +
      +
    • global mode: +npm installs packages into the install prefix at +prefix/lib/node_modules and bins are installed in prefix/bin.
    • +
    • local mode: +npm installs packages into the current project directory, which +defaults to the current working directory. Packages are installed to +./node_modules, and bins are installed to ./node_modules/.bin.
    • +
    +

    Local mode is the default. Use -g or --global on any command to +operate in global mode instead.

    +

    Developer Usage

    +

    If you're using npm to develop and publish your code, check out the +following help topics:

    +
      +
    • json: +Make a package.json file. See package.json.
    • +
    • link: +For linking your current working code into Node's path, so that you +don't have to reinstall every time you make a change. Use +npm link to do this.
    • +
    • install: +It's a good idea to install things if you don't need the symbolic link. +Especially, installing other peoples code from the registry is done via +npm install
    • +
    • adduser: +Create an account or log in. Credentials are stored in the +user config file.
    • +
    • publish: +Use the npm publish command to upload your code to the registry.
    • +
    +

    Configuration

    +

    npm is extremely configurable. It reads its configuration options from +5 places.

    +
      +
    • Command line switches: +Set a config with --key val. All keys take a value, even if they +are booleans (the config parser doesn't know what the options are at +the time of parsing). If no value is provided, then the option is set +to boolean true.
    • +
    • Environment Variables: +Set any config by prefixing the name in an environment variable with +npm_config_. For example, export npm_config_key=val.
    • +
    • User Configs: +The file at $HOME/.npmrc is an ini-formatted list of configs. If +present, it is parsed. If the userconfig option is set in the cli +or env, then that will be used instead.
    • +
    • Global Configs: +The file found at ../etc/npmrc (from the node executable, by default +this resolves to /usr/local/etc/npmrc) will be parsed if it is found. +If the globalconfig option is set in the cli, env, or user config, +then that file is parsed instead.
    • +
    • Defaults: +npm's default configuration options are defined in +lib/utils/config-defs.js. These must not be changed.
    • +
    +

    See config for much much more information.

    +

    Contributions

    +

    Patches welcome!

    +

    If you would like to contribute, but don't know what to work on, read +the contributing guidelines and check the issues list.

    + +

    Bugs

    +

    When you find issues, please report them:

    + +

    Be sure to follow the template and bug reporting guidelines. You can also ask +for help in the support forum if you're +unsure if it's actually a bug or are having trouble coming up with a detailed +reproduction to report.

    +

    Author

    +

    Isaac Z. Schlueter :: +isaacs :: +@izs :: +i@izs.me

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/configuring-npm/folders/index.html b/deps/npm/docs/public/configuring-npm/folders/index.html new file mode 100644 index 00000000000000..bf66afffd5d541 --- /dev/null +++ b/deps/npm/docs/public/configuring-npm/folders/index.html @@ -0,0 +1,237 @@ +

    folders

    +

    Folder Structures Used by npm

    +

    Description

    +

    npm puts various things on your computer. That's its job.

    +

    This document will tell you what it puts where.

    +

    tl;dr

    +
      +
    • Local install (default): puts stuff in ./node_modules of the current +package root.
    • +
    • Global install (with -g): puts stuff in /usr/local or wherever node +is installed.
    • +
    • Install it locally if you're going to require() it.
    • +
    • Install it globally if you're going to run it on the command line.
    • +
    • If you need both, then install it in both places, or use npm link.
    • +
    +

    prefix Configuration

    +

    The prefix config defaults to the location where node is installed. +On most systems, this is /usr/local. On Windows, it's %AppData%\npm. +On Unix systems, it's one level up, since node is typically installed at +{prefix}/bin/node rather than {prefix}/node.exe.

    +

    When the global flag is set, npm installs things into this prefix. +When it is not set, it uses the root of the current package, or the +current working directory if not in a package already.

    +

    Node Modules

    +

    Packages are dropped into the node_modules folder under the prefix. +When installing locally, this means that you can +require("packagename") to load its main module, or +require("packagename/lib/path/to/sub/module") to load other modules.

    +

    Global installs on Unix systems go to {prefix}/lib/node_modules. +Global installs on Windows go to {prefix}/node_modules (that is, no +lib folder.)

    +

    Scoped packages are installed the same way, except they are grouped together +in a sub-folder of the relevant node_modules folder with the name of that +scope prefix by the @ symbol, e.g. npm install @myorg/package would place +the package in {prefix}/node_modules/@myorg/package. See scope for more details.

    +

    If you wish to require() a package, then install it locally.

    +

    Executables

    +

    When in global mode, executables are linked into {prefix}/bin on Unix, +or directly into {prefix} on Windows.

    +

    When in local mode, executables are linked into +./node_modules/.bin so that they can be made available to scripts run +through npm. (For example, so that a test runner will be in the path +when you run npm test.)

    +

    Man Pages

    +

    When in global mode, man pages are linked into {prefix}/share/man.

    +

    When in local mode, man pages are not installed.

    +

    Man pages are not installed on Windows systems.

    +

    Cache

    +

    See npm cache. Cache files are stored in ~/.npm on Posix, or +%AppData%/npm-cache on Windows.

    +

    This is controlled by the cache configuration param.

    +

    Temp Files

    +

    Temporary files are stored by default in the folder specified by the +tmp config, which defaults to the TMPDIR, TMP, or TEMP environment +variables, or /tmp on Unix and c:\windows\temp on Windows.

    +

    Temp files are given a unique folder under this root for each run of the +program, and are deleted upon successful exit.

    +

    More Information

    +

    When installing locally, npm first tries to find an appropriate +prefix folder. This is so that npm install foo@1.2.3 will install +to the sensible root of your package, even if you happen to have cded +into some other folder.

    +

    Starting at the $PWD, npm will walk up the folder tree checking for a +folder that contains either a package.json file, or a node_modules +folder. If such a thing is found, then that is treated as the effective +"current directory" for the purpose of running npm commands. (This +behavior is inspired by and similar to git's .git-folder seeking +logic when running git commands in a working dir.)

    +

    If no package root is found, then the current folder is used.

    +

    When you run npm install foo@1.2.3, then the package is loaded into +the cache, and then unpacked into ./node_modules/foo. Then, any of +foo's dependencies are similarly unpacked into +./node_modules/foo/node_modules/....

    +

    Any bin files are symlinked to ./node_modules/.bin/, so that they may +be found by npm scripts when necessary.

    +

    Global Installation

    +

    If the global configuration is set to true, then npm will +install packages "globally".

    +

    For global installation, packages are installed roughly the same way, +but using the folders described above.

    +

    Cycles, Conflicts, and Folder Parsimony

    +

    Cycles are handled using the property of node's module system that it +walks up the directories looking for node_modules folders. So, at every +stage, if a package is already installed in an ancestor node_modules +folder, then it is not installed at the current location.

    +

    Consider the case above, where foo -> bar -> baz. Imagine if, in +addition to that, baz depended on bar, so you'd have: +foo -> bar -> baz -> bar -> baz .... However, since the folder +structure is: foo/node_modules/bar/node_modules/baz, there's no need to +put another copy of bar into .../baz/node_modules, since when it calls +require("bar"), it will get the copy that is installed in +foo/node_modules/bar.

    +

    This shortcut is only used if the exact same +version would be installed in multiple nested node_modules folders. It +is still possible to have a/node_modules/b/node_modules/a if the two +"a" packages are different versions. However, without repeating the +exact same package multiple times, an infinite regress will always be +prevented.

    +

    Another optimization can be made by installing dependencies at the +highest level possible, below the localized "target" folder.

    +

    Example

    +

    Consider this dependency graph:

    +
    foo
    ++-- blerg@1.2.5
    ++-- bar@1.2.3
    +|   +-- blerg@1.x (latest=1.3.7)
    +|   +-- baz@2.x
    +|   |   `-- quux@3.x
    +|   |       `-- bar@1.2.3 (cycle)
    +|   `-- asdf@*
    +`-- baz@1.2.3
    +    `-- quux@3.x
    +        `-- bar
    +

    In this case, we might expect a folder structure like this:

    +
    foo
    ++-- node_modules
    +    +-- blerg (1.2.5) <---[A]
    +    +-- bar (1.2.3) <---[B]
    +    |   `-- node_modules
    +    |       +-- baz (2.0.2) <---[C]
    +    |       |   `-- node_modules
    +    |       |       `-- quux (3.2.0)
    +    |       `-- asdf (2.3.4)
    +    `-- baz (1.2.3) <---[D]
    +        `-- node_modules
    +            `-- quux (3.2.0) <---[E]
    +

    Since foo depends directly on bar@1.2.3 and baz@1.2.3, those are +installed in foo's node_modules folder.

    +

    Even though the latest copy of blerg is 1.3.7, foo has a specific +dependency on version 1.2.5. So, that gets installed at [A]. Since the +parent installation of blerg satisfies bar's dependency on blerg@1.x, +it does not install another copy under [B].

    +

    Bar [B] also has dependencies on baz and asdf, so those are installed in +bar's node_modules folder. Because it depends on baz@2.x, it cannot +re-use the baz@1.2.3 installed in the parent node_modules folder [D], +and must install its own copy [C].

    +

    Underneath bar, the baz -> quux -> bar dependency creates a cycle. +However, because bar is already in quux's ancestry [B], it does not +unpack another copy of bar into that folder.

    +

    Underneath foo -> baz [D], quux's [E] folder tree is empty, because its +dependency on bar is satisfied by the parent folder copy installed at [B].

    +

    For a graphical breakdown of what is installed where, use npm ls.

    +

    Publishing

    +

    Upon publishing, npm will look in the node_modules folder. If any of +the items there are not in the bundledDependencies array, then they will +not be included in the package tarball.

    +

    This allows a package maintainer to install all of their dependencies +(and dev dependencies) locally, but only re-publish those items that +cannot be found elsewhere. See package.json for more information.

    +

    See also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/configuring-npm/install/index.html b/deps/npm/docs/public/configuring-npm/install/index.html new file mode 100644 index 00000000000000..2d220314d40c8b --- /dev/null +++ b/deps/npm/docs/public/configuring-npm/install/index.html @@ -0,0 +1,120 @@ +

    install

    +

    Download and Install npm

    +

    Description

    +

    To publish and install packages to and from the public npm registry, you must install Node.js and the npm command line interface using either a Node version manager or a Node installer. We strongly recommend using a Node version manager to install Node.js and npm. We do not recommend using a Node installer, since the Node installation process installs npm in a directory with local permissions and can cause permissions errors when you run npm packages globally.

    +

    Overview

    + +

    Checking your version of npm and Node.js

    +

    To see if you already have Node.js and npm installed and check the installed version, run the following commands:

    +
    node -v
    +npm -v
    +

    Using a Node version manager to install Node.js and npm

    +

    Node version managers allow you to install and switch between multiple versions of Node.js and npm on your system so you can test your applications on multiple versions of npm to ensure they work for users on different versions.

    +

    OSX or Linux Node version managers

    + +

    Windows Node version managers

    + +

    Using a Node installer to install Node.js and npm

    +

    If you are unable to use a Node version manager, you can use a Node installer to install both Node.js and npm on your system.

    + +

    OS X or Windows Node installers

    +

    If you're using OS X or Windows, use one of the installers from the Node.js download page. Be sure to install the version labeled LTS. Other versions have not yet been tested with npm.

    +

    Linux or other operating systems Node installers

    +

    If you're using Linux or another operating system, use one of the following installers:

    + +

    Or see this page to install npm for Linux in the way many Linux developers prefer.

    +

    Less-common operating systems

    +

    For more information on installing Node.js on a variety of operating systems, see this page.

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/configuring-npm/npmrc/index.html b/deps/npm/docs/public/configuring-npm/npmrc/index.html new file mode 100644 index 00000000000000..efffdb4cfb40f8 --- /dev/null +++ b/deps/npm/docs/public/configuring-npm/npmrc/index.html @@ -0,0 +1,142 @@ +

    npmrc

    +

    The npm config files

    +

    Description

    +

    npm gets its config settings from the command line, environment +variables, and npmrc files.

    +

    The npm config command can be used to update and edit the contents +of the user and global npmrc files.

    +

    For a list of available configuration options, see config.

    +

    Files

    +

    The four relevant files are:

    +
      +
    • per-project config file (/path/to/my/project/.npmrc)
    • +
    • per-user config file (~/.npmrc)
    • +
    • global config file ($PREFIX/etc/npmrc)
    • +
    • npm builtin config file (/path/to/npm/npmrc)
    • +
    +

    All npm config files are an ini-formatted list of key = value +parameters. Environment variables can be replaced using +${VARIABLE_NAME}. For example:

    +
    prefix = ${HOME}/.npm-packages
    +

    Each of these files is loaded, and config options are resolved in +priority order. For example, a setting in the userconfig file would +override the setting in the globalconfig file.

    +

    Array values are specified by adding "[]" after the key name. For +example:

    +
    key[] = "first value"
    +key[] = "second value"
    +

    Comments

    +

    Lines in .npmrc files are interpreted as comments when they begin with a ; or # character. .npmrc files are parsed by npm/ini, which specifies this comment syntax.

    +

    For example:

    +
    # last modified: 01 Jan 2016
    +; Set a new registry for a scoped package
    +@myscope:registry=https://mycustomregistry.example.org
    +

    Per-project config file

    +

    When working locally in a project, a .npmrc file in the root of the +project (ie, a sibling of node_modules and package.json) will set +config values specific to this project.

    +

    Note that this only applies to the root of the project that you're +running npm in. It has no effect when your module is published. For +example, you can't publish a module that forces itself to install +globally, or in a different location.

    +

    Additionally, this file is not read in global mode, such as when running +npm install -g.

    +

    Per-user config file

    +

    $HOME/.npmrc (or the userconfig param, if set in the environment +or on the command line)

    +

    Global config file

    +

    $PREFIX/etc/npmrc (or the globalconfig param, if set above): +This file is an ini-file formatted list of key = value parameters. +Environment variables can be replaced as above.

    +

    Built-in config file

    +

    path/to/npm/itself/npmrc

    +

    This is an unchangeable "builtin" configuration file that npm keeps +consistent across updates. Set fields in here using the ./configure +script that comes with npm. This is primarily for distribution +maintainers to override default configs in a standard and consistent +manner.

    +

    See also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/configuring-npm/package-json/index.html b/deps/npm/docs/public/configuring-npm/package-json/index.html new file mode 100644 index 00000000000000..da8a44c1c371d0 --- /dev/null +++ b/deps/npm/docs/public/configuring-npm/package-json/index.html @@ -0,0 +1,693 @@ +

    package.json

    +

    Specifics of npm's package.json handling

    +

    Description

    +

    This document is all you need to know about what's required in your package.json +file. It must be actual JSON, not just a JavaScript object literal.

    +

    A lot of the behavior described in this document is affected by the config +settings described in config.

    +

    name

    +

    If you plan to publish your package, the most important things in your +package.json are the name and version fields as they will be required. The name +and version together form an identifier that is assumed to be completely unique. +Changes to the package should come along with changes to the version. If you don't +plan to publish your package, the name and version fields are optional.

    +

    The name is what your thing is called.

    +

    Some rules:

    +
      +
    • The name must be less than or equal to 214 characters. This includes the scope for +scoped packages.
    • +
    • The names of scoped packages can begin with a dot or an underscore. This is not permitted without a scope.
    • +
    • New packages must not have uppercase letters in the name.
    • +
    • The name ends up being part of a URL, an argument on the command line, and a +folder name. Therefore, the name can't contain any non-URL-safe characters.
    • +
    +

    Some tips:

    +
      +
    • Don't use the same name as a core Node module.
    • +
    • Don't put "js" or "node" in the name. It's assumed that it's js, since you're +writing a package.json file, and you can specify the engine using the "engines" +field. (See below.)
    • +
    • The name will probably be passed as an argument to require(), so it should +be something short, but also reasonably descriptive.
    • +
    • You may want to check the npm registry to see if there's something by that name +already, before you get too attached to it. https://www.npmjs.com/
    • +
    +

    A name can be optionally prefixed by a scope, e.g. @myorg/mypackage. See +scope for more detail.

    +

    version

    +

    If you plan to publish your package, the most important things in your +package.json are the name and version fields as they will be required. The name +and version together form an identifier that is assumed to be completely unique. +Changes to the package should come along with changes to the version. If you don't +plan to publish your package, the name and version fields are optional.

    +

    Version must be parseable by +node-semver, which is bundled +with npm as a dependency. (npm install semver to use it yourself.)

    +

    More on version numbers and ranges at semver.

    +

    description

    +

    Put a description in it. It's a string. This helps people discover your +package, as it's listed in npm search.

    +

    keywords

    +

    Put keywords in it. It's an array of strings. This helps people +discover your package as it's listed in npm search.

    +

    homepage

    +

    The url to the project homepage.

    +

    Example:

    +
    "homepage": "https://github.com/owner/project#readme"
    +

    bugs

    +

    The url to your project's issue tracker and / or the email address to which +issues should be reported. These are helpful for people who encounter issues +with your package.

    +

    It should look like this:

    +
    { "url" : "https://github.com/owner/project/issues"
    +, "email" : "project@hostname.com"
    +}
    +

    You can specify either one or both values. If you want to provide only a url, +you can specify the value for "bugs" as a simple string instead of an object.

    +

    If a url is provided, it will be used by the npm bugs command.

    +

    license

    +

    You should specify a license for your package so that people know how they are +permitted to use it, and any restrictions you're placing on it.

    +

    If you're using a common license such as BSD-2-Clause or MIT, add a +current SPDX license identifier for the license you're using, like this:

    +
    { "license" : "BSD-3-Clause" }
    +

    You can check the full list of SPDX license IDs. +Ideally you should pick one that is +OSI approved.

    +

    If your package is licensed under multiple common licenses, use an SPDX license +expression syntax version 2.0 string, like this:

    +
    { "license" : "(ISC OR GPL-3.0)" }
    +

    If you are using a license that hasn't been assigned an SPDX identifier, or if +you are using a custom license, use a string value like this one:

    +
    { "license" : "SEE LICENSE IN <filename>" }
    +

    Then include a file named <filename> at the top level of the package.

    +

    Some old packages used license objects or a "licenses" property containing an +array of license objects:

    +
    // Not valid metadata
    +{ "license" :
    +  { "type" : "ISC"
    +  , "url" : "https://opensource.org/licenses/ISC"
    +  }
    +}
    +
    +// Not valid metadata
    +{ "licenses" :
    +  [
    +    { "type": "MIT"
    +    , "url": "https://www.opensource.org/licenses/mit-license.php"
    +    }
    +  , { "type": "Apache-2.0"
    +    , "url": "https://opensource.org/licenses/apache2.0.php"
    +    }
    +  ]
    +}
    +

    Those styles are now deprecated. Instead, use SPDX expressions, like this:

    +
    { "license": "ISC" }
    +
    +{ "license": "(MIT OR Apache-2.0)" }
    +

    Finally, if you do not wish to grant others the right to use a private or +unpublished package under any terms:

    +
    { "license": "UNLICENSED" }
    +

    Consider also setting "private": true to prevent accidental publication.

    +

    people fields: author, contributors

    +

    The "author" is one person. "contributors" is an array of people. A "person" +is an object with a "name" field and optionally "url" and "email", like this:

    +
    { "name" : "Barney Rubble"
    +, "email" : "b@rubble.com"
    +, "url" : "http://barnyrubble.tumblr.com/"
    +}
    +

    Or you can shorten that all into a single string, and npm will parse it for you:

    +
    "Barney Rubble <b@rubble.com> (http://barnyrubble.tumblr.com/)"
    +

    Both email and url are optional either way.

    +

    npm also sets a top-level "maintainers" field with your npm user info.

    +

    funding

    +

    You can specify an object containing an URL that provides up-to-date +information about ways to help fund development of your package:

    +
    "funding": {
    +  "type" : "individual",
    +  "url" : "http://example.com/donate"
    +}
    +
    +"funding": {
    +  "type" : "patreon",
    +  "url" : "https://www.patreon.com/my-account"
    +}
    +

    Users can use the npm fund subcommand to list the funding URLs of all +dependencies of their project, direct and indirect. A shortcut to visit each +funding url is also available when providing the project name such as: +npm fund <projectname>.

    +

    files

    +

    The optional files field is an array of file patterns that describes +the entries to be included when your package is installed as a +dependency. File patterns follow a similar syntax to .gitignore, but +reversed: including a file, directory, or glob pattern (*, **/*, and such) +will make it so that file is included in the tarball when it's packed. Omitting +the field will make it default to ["*"], which means it will include all files.

    +

    Some special files and directories are also included or excluded regardless of +whether they exist in the files array (see below).

    +

    You can also provide a .npmignore file in the root of your package or +in subdirectories, which will keep files from being included. At the +root of your package it will not override the "files" field, but in +subdirectories it will. The .npmignore file works just like a +.gitignore. If there is a .gitignore file, and .npmignore is +missing, .gitignore's contents will be used instead.

    +

    Files included with the "package.json#files" field cannot be excluded +through .npmignore or .gitignore.

    +

    Certain files are always included, regardless of settings:

    +
      +
    • package.json
    • +
    • README
    • +
    • CHANGES / CHANGELOG / HISTORY
    • +
    • LICENSE / LICENCE
    • +
    • NOTICE
    • +
    • The file in the "main" field
    • +
    +

    README, CHANGES, LICENSE & NOTICE can have any case and extension.

    +

    Conversely, some files are always ignored:

    +
      +
    • .git
    • +
    • CVS
    • +
    • .svn
    • +
    • .hg
    • +
    • .lock-wscript
    • +
    • .wafpickle-N
    • +
    • .*.swp
    • +
    • .DS_Store
    • +
    • ._*
    • +
    • npm-debug.log
    • +
    • .npmrc
    • +
    • node_modules
    • +
    • config.gypi
    • +
    • *.orig
    • +
    • package-lock.json (use shrinkwrap instead)
    • +
    +

    main

    +

    The main field is a module ID that is the primary entry point to your program. +That is, if your package is named foo, and a user installs it, and then does +require("foo"), then your main module's exports object will be returned.

    +

    This should be a module ID relative to the root of your package folder.

    +

    For most modules, it makes the most sense to have a main script and often not +much else.

    +

    browser

    +

    If your module is meant to be used client-side the browser field should be +used instead of the main field. This is helpful to hint users that it might +rely on primitives that aren't available in Node.js modules. (e.g. window)

    +

    bin

    +

    A lot of packages have one or more executable files that they'd like to +install into the PATH. npm makes this pretty easy (in fact, it uses this +feature to install the "npm" executable.)

    +

    To use this, supply a bin field in your package.json which is a map of +command name to local file name. On install, npm will symlink that file into +prefix/bin for global installs, or ./node_modules/.bin/ for local +installs.

    +

    For example, myapp could have this:

    +
    { "bin" : { "myapp" : "./cli.js" } }
    +

    So, when you install myapp, it'll create a symlink from the cli.js script to +/usr/local/bin/myapp.

    +

    If you have a single executable, and its name should be the name +of the package, then you can just supply it as a string. For example:

    +
    { "name": "my-program"
    +, "version": "1.2.5"
    +, "bin": "./path/to/program" }
    +

    would be the same as this:

    +
    { "name": "my-program"
    +, "version": "1.2.5"
    +, "bin" : { "my-program" : "./path/to/program" } }
    +

    Please make sure that your file(s) referenced in bin starts with +#!/usr/bin/env node, otherwise the scripts are started without the node +executable!

    +

    man

    +

    Specify either a single file or an array of filenames to put in place for the +man program to find.

    +

    If only a single file is provided, then it's installed such that it is the +result from man <pkgname>, regardless of its actual filename. For example:

    +
    { "name" : "foo"
    +, "version" : "1.2.3"
    +, "description" : "A packaged foo fooer for fooing foos"
    +, "main" : "foo.js"
    +, "man" : "./man/doc.1"
    +}
    +

    would link the ./man/doc.1 file in such that it is the target for man foo

    +

    If the filename doesn't start with the package name, then it's prefixed. +So, this:

    +
    { "name" : "foo"
    +, "version" : "1.2.3"
    +, "description" : "A packaged foo fooer for fooing foos"
    +, "main" : "foo.js"
    +, "man" : [ "./man/foo.1", "./man/bar.1" ]
    +}
    +

    will create files to do man foo and man foo-bar.

    +

    Man files must end with a number, and optionally a .gz suffix if they are +compressed. The number dictates which man section the file is installed into.

    +
    { "name" : "foo"
    +, "version" : "1.2.3"
    +, "description" : "A packaged foo fooer for fooing foos"
    +, "main" : "foo.js"
    +, "man" : [ "./man/foo.1", "./man/foo.2" ]
    +}
    +

    will create entries for man foo and man 2 foo

    +

    directories

    +

    The CommonJS Packages spec details a +few ways that you can indicate the structure of your package using a directories +object. If you look at npm's package.json, +you'll see that it has directories for doc, lib, and man.

    +

    In the future, this information may be used in other creative ways.

    +

    directories.lib

    +

    Tell people where the bulk of your library is. Nothing special is done +with the lib folder in any way, but it's useful meta info.

    +

    directories.bin

    +

    If you specify a bin directory in directories.bin, all the files in +that folder will be added.

    +

    Because of the way the bin directive works, specifying both a +bin path and setting directories.bin is an error. If you want to +specify individual files, use bin, and for all the files in an +existing bin directory, use directories.bin.

    +

    directories.man

    +

    A folder that is full of man pages. Sugar to generate a "man" array by +walking the folder.

    +

    directories.doc

    +

    Put markdown files in here. Eventually, these will be displayed nicely, +maybe, someday.

    +

    directories.example

    +

    Put example scripts in here. Someday, it might be exposed in some clever way.

    +

    directories.test

    +

    Put your tests in here. It is currently not exposed, but it might be in the +future.

    +

    repository

    +

    Specify the place where your code lives. This is helpful for people who +want to contribute. If the git repo is on GitHub, then the npm docs +command will be able to find you.

    +

    Do it like this:

    +
    "repository": {
    +  "type" : "git",
    +  "url" : "https://github.com/npm/cli.git"
    +}
    +
    +"repository": {
    +  "type" : "svn",
    +  "url" : "https://v8.googlecode.com/svn/trunk/"
    +}
    +

    The URL should be a publicly available (perhaps read-only) url that can be handed +directly to a VCS program without any modification. It should not be a url to an +html project page that you put in your browser. It's for computers.

    +

    For GitHub, GitHub gist, Bitbucket, or GitLab repositories you can use the same +shortcut syntax you use for npm install:

    +
    "repository": "npm/npm"
    +
    +"repository": "github:user/repo"
    +
    +"repository": "gist:11081aaa281"
    +
    +"repository": "bitbucket:user/repo"
    +
    +"repository": "gitlab:user/repo"
    +

    If the package.json for your package is not in the root directory (for example +if it is part of a monorepo), you can specify the directory in which it lives:

    +
    "repository": {
    +  "type" : "git",
    +  "url" : "https://github.com/facebook/react.git",
    +  "directory": "packages/react-dom"
    +}
    +

    scripts

    +

    The "scripts" property is a dictionary containing script commands that are run +at various times in the lifecycle of your package. The key is the lifecycle +event, and the value is the command to run at that point.

    +

    See scripts to find out more about writing package scripts.

    +

    config

    +

    A "config" object can be used to set configuration parameters used in package +scripts that persist across upgrades. For instance, if a package had the +following:

    +
    { "name" : "foo"
    +, "config" : { "port" : "8080" } }
    +

    and then had a "start" command that then referenced the +npm_package_config_port environment variable, then the user could +override that by doing npm config set foo:port 8001.

    +

    See config and scripts for more on package +configs.

    +

    dependencies

    +

    Dependencies are specified in a simple object that maps a package name to a +version range. The version range is a string which has one or more +space-separated descriptors. Dependencies can also be identified with a +tarball or git URL.

    +

    Please do not put test harnesses or transpilers in your +dependencies object. See devDependencies, below.

    +

    See semver for more details about specifying version ranges.

    +
      +
    • version Must match version exactly
    • +
    • >version Must be greater than version
    • +
    • >=version etc
    • +
    • <version
    • +
    • <=version
    • +
    • ~version "Approximately equivalent to version" See semver
    • +
    • ^version "Compatible with version" See semver
    • +
    • 1.2.x 1.2.0, 1.2.1, etc., but not 1.3.0
    • +
    • http://... See 'URLs as Dependencies' below
    • +
    • * Matches any version
    • +
    • "" (just an empty string) Same as *
    • +
    • version1 - version2 Same as >=version1 <=version2.
    • +
    • range1 || range2 Passes if either range1 or range2 are satisfied.
    • +
    • git... See 'Git URLs as Dependencies' below
    • +
    • user/repo See 'GitHub URLs' below
    • +
    • tag A specific version tagged and published as tag See npm dist-tag
    • +
    • path/path/path See Local Paths below
    • +
    +

    For example, these are all valid:

    +
    { "dependencies" :
    +  { "foo" : "1.0.0 - 2.9999.9999"
    +  , "bar" : ">=1.0.2 <2.1.2"
    +  , "baz" : ">1.0.2 <=2.3.4"
    +  , "boo" : "2.0.1"
    +  , "qux" : "<1.0.0 || >=2.3.1 <2.4.5 || >=2.5.2 <3.0.0"
    +  , "asd" : "http://asdf.com/asdf.tar.gz"
    +  , "til" : "~1.2"
    +  , "elf" : "~1.2.3"
    +  , "two" : "2.x"
    +  , "thr" : "3.3.x"
    +  , "lat" : "latest"
    +  , "dyl" : "file:../dyl"
    +  }
    +}
    +

    URLs as Dependencies

    +

    You may specify a tarball URL in place of a version range.

    +

    This tarball will be downloaded and installed locally to your package at +install time.

    +

    Git URLs as Dependencies

    +

    Git urls are of the form:

    +
    <protocol>://[<user>[:<password>]@]<hostname>[:<port>][:][/]<path>[#<commit-ish> | #semver:<semver>]
    +

    <protocol> is one of git, git+ssh, git+http, git+https, or +git+file.

    +

    If #<commit-ish> is provided, it will be used to clone exactly that +commit. If the commit-ish has the format #semver:<semver>, <semver> can +be any valid semver range or exact version, and npm will look for any tags +or refs matching that range in the remote repository, much as it would for a +registry dependency. If neither #<commit-ish> or #semver:<semver> is +specified, then master is used.

    +

    Examples:

    +
    git+ssh://git@github.com:npm/cli.git#v1.0.27
    +git+ssh://git@github.com:npm/cli#semver:^5.0
    +git+https://isaacs@github.com/npm/cli.git
    +git://github.com/npm/cli.git#v1.0.27
    +

    GitHub URLs

    +

    As of version 1.1.65, you can refer to GitHub urls as just "foo": +"user/foo-project". Just as with git URLs, a commit-ish suffix can be +included. For example:

    +
    {
    +  "name": "foo",
    +  "version": "0.0.0",
    +  "dependencies": {
    +    "express": "expressjs/express",
    +    "mocha": "mochajs/mocha#4727d357ea",
    +    "module": "user/repo#feature\/branch"
    +  }
    +}
    +

    Local Paths

    +

    As of version 2.0.0 you can provide a path to a local directory that contains a +package. Local paths can be saved using npm install -S or +npm install --save, using any of these forms:

    +
    ../foo/bar
    +~/foo/bar
    +./foo/bar
    +/foo/bar
    +

    in which case they will be normalized to a relative path and added to your +package.json. For example:

    +
    {
    +  "name": "baz",
    +  "dependencies": {
    +    "bar": "file:../foo/bar"
    +  }
    +}
    +

    This feature is helpful for local offline development and creating +tests that require npm installing where you don't want to hit an +external server, but should not be used when publishing packages +to the public registry.

    +

    devDependencies

    +

    If someone is planning on downloading and using your module in their +program, then they probably don't want or need to download and build +the external test or documentation framework that you use.

    +

    In this case, it's best to map these additional items in a devDependencies +object.

    +

    These things will be installed when doing npm link or npm install +from the root of a package, and can be managed like any other npm +configuration param. See config for more on the topic.

    +

    For build steps that are not platform-specific, such as compiling +CoffeeScript or other languages to JavaScript, use the prepare +script to do this, and make the required package a devDependency.

    +

    For example:

    +
    { "name": "ethopia-waza",
    +  "description": "a delightfully fruity coffee varietal",
    +  "version": "1.2.3",
    +  "devDependencies": {
    +    "coffee-script": "~1.6.3"
    +  },
    +  "scripts": {
    +    "prepare": "coffee -o lib/ -c src/waza.coffee"
    +  },
    +  "main": "lib/waza.js"
    +}
    +

    The prepare script will be run before publishing, so that users +can consume the functionality without requiring them to compile it +themselves. In dev mode (ie, locally running npm install), it'll +run this script as well, so that you can test it easily.

    +

    peerDependencies

    +

    In some cases, you want to express the compatibility of your package with a +host tool or library, while not necessarily doing a require of this host. +This is usually referred to as a plugin. Notably, your module may be exposing +a specific interface, expected and specified by the host documentation.

    +

    For example:

    +
    {
    +  "name": "tea-latte",
    +  "version": "1.3.5",
    +  "peerDependencies": {
    +    "tea": "2.x"
    +  }
    +}
    +

    This ensures your package tea-latte can be installed along with the second +major version of the host package tea only. npm install tea-latte could +possibly yield the following dependency graph:

    +
    ├── tea-latte@1.3.5
    +└── tea@2.2.0
    +

    NOTE: npm versions 1 and 2 will automatically install peerDependencies if +they are not explicitly depended upon higher in the dependency tree. In the +next major version of npm (npm@3), this will no longer be the case. You will +receive a warning that the peerDependency is not installed instead. The +behavior in npms 1 & 2 was frequently confusing and could easily put you into +dependency hell, a situation that npm is designed to avoid as much as possible.

    +

    Trying to install another plugin with a conflicting requirement will cause an +error. For this reason, make sure your plugin requirement is as broad as +possible, and not to lock it down to specific patch versions.

    +

    Assuming the host complies with semver, only changes in +the host package's major version will break your plugin. Thus, if you've worked +with every 1.x version of the host package, use "^1.0" or "1.x" to express +this. If you depend on features introduced in 1.5.2, use ">= 1.5.2 < 2".

    +

    bundledDependencies

    +

    This defines an array of package names that will be bundled when publishing +the package.

    +

    In cases where you need to preserve npm packages locally or have them +available through a single file download, you can bundle the packages in a +tarball file by specifying the package names in the bundledDependencies +array and executing npm pack.

    +

    For example:

    +

    If we define a package.json like this:

    +
    {
    +  "name": "awesome-web-framework",
    +  "version": "1.0.0",
    +  "bundledDependencies": [
    +    "renderized", "super-streams"
    +  ]
    +}
    +

    we can obtain awesome-web-framework-1.0.0.tgz file by running npm pack. +This file contains the dependencies renderized and super-streams which +can be installed in a new project by executing npm install +awesome-web-framework-1.0.0.tgz. Note that the package names do not include +any versions, as that information is specified in dependencies.

    +

    If this is spelled "bundleDependencies", then that is also honored.

    +

    optionalDependencies

    +

    If a dependency can be used, but you would like npm to proceed if it cannot be +found or fails to install, then you may put it in the optionalDependencies +object. This is a map of package name to version or url, just like the +dependencies object. The difference is that build failures do not cause +installation to fail.

    +

    It is still your program's responsibility to handle the lack of the +dependency. For example, something like this:

    +
    try {
    +  var foo = require('foo')
    +  var fooVersion = require('foo/package.json').version
    +} catch (er) {
    +  foo = null
    +}
    +if ( notGoodFooVersion(fooVersion) ) {
    +  foo = null
    +}
    +
    +// .. then later in your program ..
    +
    +if (foo) {
    +  foo.doFooThings()
    +}
    +

    Entries in optionalDependencies will override entries of the same name in +dependencies, so it's usually best to only put in one place.

    +

    engines

    +

    You can specify the version of node that your stuff works on:

    +
    { "engines" : { "node" : ">=0.10.3 <0.12" } }
    +

    And, like with dependencies, if you don't specify the version (or if you +specify "*" as the version), then any version of node will do.

    +

    If you specify an "engines" field, then npm will require that "node" be +somewhere on that list. If "engines" is omitted, then npm will just assume +that it works on node.

    +

    You can also use the "engines" field to specify which versions of npm +are capable of properly installing your program. For example:

    +
    { "engines" : { "npm" : "~1.0.20" } }
    +

    Unless the user has set the engine-strict config flag, this +field is advisory only and will only produce warnings when your package is installed as a dependency.

    +

    engineStrict

    +

    This feature was removed in npm 3.0.0

    +

    Prior to npm 3.0.0, this feature was used to treat this package as if the +user had set engine-strict. It is no longer used.

    +

    os

    +

    You can specify which operating systems your +module will run on:

    +
    "os" : [ "darwin", "linux" ]
    +

    You can also blacklist instead of whitelist operating systems, +just prepend the blacklisted os with a '!':

    +
    "os" : [ "!win32" ]
    +

    The host operating system is determined by process.platform

    +

    It is allowed to both blacklist, and whitelist, although there isn't any +good reason to do this.

    +

    cpu

    +

    If your code only runs on certain cpu architectures, +you can specify which ones.

    +
    "cpu" : [ "x64", "ia32" ]
    +

    Like the os option, you can also blacklist architectures:

    +
    "cpu" : [ "!arm", "!mips" ]
    +

    The host architecture is determined by process.arch

    +

    preferGlobal

    +

    DEPRECATED

    +

    This option used to trigger an npm warning, but it will no longer warn. It is +purely there for informational purposes. It is now recommended that you install +any binaries as local devDependencies wherever possible.

    +

    private

    +

    If you set "private": true in your package.json, then npm will refuse +to publish it.

    +

    This is a way to prevent accidental publication of private repositories. If +you would like to ensure that a given package is only ever published to a +specific registry (for example, an internal registry), then use the +publishConfig dictionary described below to override the registry config +param at publish-time.

    +

    publishConfig

    +

    This is a set of config values that will be used at publish-time. It's +especially handy if you want to set the tag, registry or access, so that +you can ensure that a given package is not tagged with "latest", published +to the global public registry or that a scoped module is private by default.

    +

    Any config values can be overridden, but only "tag", "registry" and "access" +probably matter for the purposes of publishing.

    +

    See config to see the list of config options that can be +overridden.

    +

    DEFAULT VALUES

    +

    npm will default some values based on package contents.

    +
      +
    • +

      "scripts": {"start": "node server.js"}

      +

      If there is a server.js file in the root of your package, then npm +will default the start command to node server.js.

      +
    • +
    • +

      "scripts":{"install": "node-gyp rebuild"}

      +

      If there is a binding.gyp file in the root of your package and you have not defined an install or preinstall script, npm will +default the install command to compile using node-gyp.

      +
    • +
    • +

      "contributors": [...]

      +

      If there is an AUTHORS file in the root of your package, npm will +treat each line as a Name <email> (url) format, where email and url +are optional. Lines which start with a # or are blank, will be +ignored.

      +
    • +
    +

    SEE ALSO

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/configuring-npm/package-lock-json/index.html b/deps/npm/docs/public/configuring-npm/package-lock-json/index.html new file mode 100644 index 00000000000000..3f09e0ec572c60 --- /dev/null +++ b/deps/npm/docs/public/configuring-npm/package-lock-json/index.html @@ -0,0 +1,183 @@ +

    package-lock.json

    +

    A manifestation of the manifest

    +

    Description

    +

    package-lock.json is automatically generated for any operations where npm +modifies either the node_modules tree, or package.json. It describes the +exact tree that was generated, such that subsequent installs are able to +generate identical trees, regardless of intermediate dependency updates.

    +

    This file is intended to be committed into source repositories, and serves +various purposes:

    +
      +
    • Describe a single representation of a dependency tree such that teammates, deployments, and continuous integration are guaranteed to install exactly the same dependencies.
    • +
    • Provide a facility for users to "time-travel" to previous states of node_modules without having to commit the directory itself.
    • +
    • To facilitate greater visibility of tree changes through readable source control diffs.
    • +
    • And optimize the installation process by allowing npm to skip repeated metadata resolutions for previously-installed packages.
    • +
    +

    One key detail about package-lock.json is that it cannot be published, and it +will be ignored if found in any place other than the toplevel package. It shares +a format with npm-shrinkwrap.json, which is essentially the same file, but +allows publication. This is not recommended unless deploying a CLI tool or +otherwise using the publication process for producing production packages.

    +

    If both package-lock.json and npm-shrinkwrap.json are present in the root of +a package, package-lock.json will be completely ignored.

    +

    File Format

    +

    name

    +

    The name of the package this is a package-lock for. This must match what's in +package.json.

    +

    version

    +

    The version of the package this is a package-lock for. This must match what's in +package.json.

    +

    lockfileVersion

    +

    An integer version, starting at 1 with the version number of this document +whose semantics were used when generating this package-lock.json.

    +

    packageIntegrity

    +

    This is a subresource +integrity value +created from the package.json. No preprocessing of the package.json should +be done. Subresource integrity strings can be produced by modules like +ssri.

    + +

    Indicates that the install was done with the environment variable +NODE_PRESERVE_SYMLINKS enabled. The installer should insist that the value of +this property match that environment variable.

    +

    dependencies

    +

    A mapping of package name to dependency object. Dependency objects have the +following properties:

    +
    version
    +

    This is a specifier that uniquely identifies this package and should be +usable in fetching a new copy of it.

    +
      +
    • bundled dependencies: Regardless of source, this is a version number that is purely for informational purposes.
    • +
    • registry sources: This is a version number. (eg, 1.2.3)
    • +
    • git sources: This is a git specifier with resolved committish. (eg, git+https://example.com/foo/bar#115311855adb0789a0466714ed48a1499ffea97e)
    • +
    • http tarball sources: This is the URL of the tarball. (eg, https://example.com/example-1.3.0.tgz)
    • +
    • local tarball sources: This is the file URL of the tarball. (eg file:///opt/storage/example-1.3.0.tgz)
    • +
    • local link sources: This is the file URL of the link. (eg file:libs/our-module)
    • +
    +
    integrity
    +

    This is a Standard Subresource +Integrity for this +resource.

    +
      +
    • For bundled dependencies this is not included, regardless of source.
    • +
    • For registry sources, this is the integrity that the registry provided, or if one wasn't provided the SHA1 in shasum.
    • +
    • For git sources this is the specific commit hash we cloned from.
    • +
    • For remote tarball sources this is an integrity based on a SHA512 of +the file.
    • +
    • For local tarball sources: This is an integrity field based on the SHA512 of the file.
    • +
    +
    resolved
    +
      +
    • For bundled dependencies this is not included, regardless of source.
    • +
    • For registry sources this is path of the tarball relative to the registry +URL. If the tarball URL isn't on the same server as the registry URL then +this is a complete URL.
    • +
    +
    bundled
    +

    If true, this is the bundled dependency and will be installed by the parent +module. When installing, this module will be extracted from the parent +module during the extract phase, not installed as a separate dependency.

    +
    dev
    +

    If true then this dependency is either a development dependency ONLY of the +top level module or a transitive dependency of one. This is false for +dependencies that are both a development dependency of the top level and a +transitive dependency of a non-development dependency of the top level.

    +
    optional
    +

    If true then this dependency is either an optional dependency ONLY of the +top level module or a transitive dependency of one. This is false for +dependencies that are both an optional dependency of the top level and a +transitive dependency of a non-optional dependency of the top level.

    +

    All optional dependencies should be included even if they're uninstallable +on the current platform.

    +
    requires
    +

    This is a mapping of module name to version. This is a list of everything +this module requires, regardless of where it will be installed. The version +should match via normal matching rules a dependency either in our +dependencies or in a level higher than us.

    +
    dependencies
    +

    The dependencies of this dependency, exactly as at the top level.

    +

    See also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/configuring-npm/package-locks/index.html b/deps/npm/docs/public/configuring-npm/package-locks/index.html new file mode 100644 index 00000000000000..3308e55e82051a --- /dev/null +++ b/deps/npm/docs/public/configuring-npm/package-locks/index.html @@ -0,0 +1,211 @@ +

    package-locks

    +

    An explanation of npm lockfiles

    +

    Description

    +

    Conceptually, the "input" to npm install is a package.json, while its +"output" is a fully-formed node_modules tree: a representation of the +dependencies you declared. In an ideal world, npm would work like a pure +function: the same package.json should produce the exact same node_modules +tree, any time. In some cases, this is indeed true. But in many others, npm is +unable to do this. There are multiple reasons for this:

    +
      +
    • different versions of npm (or other package managers) may have been used to install a package, each using slightly different installation algorithms.
    • +
    • a new version of a direct semver-range package may have been published since the last time your packages were installed, and thus a newer version will be used.
    • +
    • A dependency of one of your dependencies may have published a new version, which will update even if you used pinned dependency specifiers (1.2.3 instead of ^1.2.3)
    • +
    • The registry you installed from is no longer available, or allows mutation of versions (unlike the primary npm registry), and a different version of a package exists under the same version number now.
    • +
    +

    As an example, consider package A:

    +
    {
    +  "name": "A",
    +  "version": "0.1.0",
    +  "dependencies": {
    +    "B": "<0.1.0"
    +  }
    +}
    +

    package B:

    +
    {
    +  "name": "B",
    +  "version": "0.0.1",
    +  "dependencies": {
    +    "C": "<0.1.0"
    +  }
    +}
    +

    and package C:

    +
    {
    +  "name": "C",
    +  "version": "0.0.1"
    +}
    +

    If these are the only versions of A, B, and C available in the +registry, then a normal npm install A will install:

    +
    A@0.1.0
    +`-- B@0.0.1
    +    `-- C@0.0.1
    +

    However, if B@0.0.2 is published, then a fresh npm install A will +install:

    +
    A@0.1.0
    +`-- B@0.0.2
    +    `-- C@0.0.1
    +

    assuming the new version did not modify B's dependencies. Of course, +the new version of B could include a new version of C and any number +of new dependencies. If such changes are undesirable, the author of A +could specify a dependency on B@0.0.1. However, if A's author and B's +author are not the same person, there's no way for A's author to say +that he or she does not want to pull in newly published versions of C +when B hasn't changed at all.

    +

    To prevent this potential issue, npm uses package-lock.json or, if present, npm-shrinkwrap.json. These files are called package locks, or lockfiles.

    +

    Whenever you run npm install, npm generates or updates your package lock, +which will look something like this:

    +
    {
    +  "name": "A",
    +  "version": "0.1.0",
    +  ...metadata fields...
    +  "dependencies": {
    +    "B": {
    +      "version": "0.0.1",
    +      "resolved": "https://registry.npmjs.org/B/-/B-0.0.1.tgz",
    +      "integrity": "sha512-DeAdb33F+"
    +      "dependencies": {
    +        "C": {
    +          "version": "git://github.com/org/C.git#5c380ae319fc4efe9e7f2d9c78b0faa588fd99b4"
    +        }
    +      }
    +    }
    +  }
    +}
    +

    This file describes an exact, and more importantly reproducible +node_modules tree. Once it's present, any future installation will base its +work off this file, instead of recalculating dependency versions off +package.json.

    +

    The presence of a package lock changes the installation behavior such that:

    +
      +
    1. The module tree described by the package lock is reproduced. This means +reproducing the structure described in the file, using the specific files +referenced in "resolved" if available, falling back to normal package resolution +using "version" if one isn't.
    2. +
    3. The tree is walked and any missing dependencies are installed in the usual +fashion.
    4. +
    +

    If preshrinkwrap, shrinkwrap or postshrinkwrap are in the scripts +property of the package.json, they will be executed in order. preshrinkwrap +and shrinkwrap are executed before the shrinkwrap, postshrinkwrap is +executed afterwards. These scripts run for both package-lock.json and +npm-shrinkwrap.json. For example to run some postprocessing on the generated +file:

    +
      "scripts": {
    +    "postshrinkwrap": "json -I -e \"this.myMetadata = $MY_APP_METADATA\""
    +  }
    +

    Using locked packages

    +

    Using a locked package is no different than using any package without a package +lock: any commands that update node_modules and/or package.json's +dependencies will automatically sync the existing lockfile. This includes npm +install, npm rm, npm update, etc. To prevent this update from happening, +you can use the --no-save option to prevent saving altogether, or +--no-shrinkwrap to allow package.json to be updated while leaving +package-lock.json or npm-shrinkwrap.json intact.

    +

    It is highly recommended you commit the generated package lock to source +control: this will allow anyone else on your team, your deployments, your +CI/continuous integration, and anyone else who runs npm install in your +package source to get the exact same dependency tree that you were developing +on. Additionally, the diffs from these changes are human-readable and will +inform you of any changes npm has made to your node_modules, so you can notice +if any transitive dependencies were updated, hoisted, etc.

    +

    Resolving lockfile conflicts

    +

    Occasionally, two separate npm install will create package locks that cause +merge conflicts in source control systems. As of npm@5.7.0, these conflicts +can be resolved by manually fixing any package.json conflicts, and then +running npm install [--package-lock-only] again. npm will automatically +resolve any conflicts for you and write a merged package lock that includes all +the dependencies from both branches in a reasonable tree. If +--package-lock-only is provided, it will do this without also modifying your +local node_modules/.

    +

    To make this process seamless on git, consider installing +npm-merge-driver, which will teach git how +to do this itself without any user interaction. In short: $ npx +npm-merge-driver install -g will let you do this, and even works with +pre-npm@5.7.0 versions of npm 5, albeit a bit more noisily. Note that if +package.json itself conflicts, you will have to resolve that by hand and run +npm install manually, even with the merge driver.

    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/configuring-npm/shrinkwrap-json/index.html b/deps/npm/docs/public/configuring-npm/shrinkwrap-json/index.html new file mode 100644 index 00000000000000..9c90ad71c562fb --- /dev/null +++ b/deps/npm/docs/public/configuring-npm/shrinkwrap-json/index.html @@ -0,0 +1,99 @@ +

    npm shrinkwrap.json

    +

    A publishable lockfile

    +

    Description

    +

    npm-shrinkwrap.json is a file created by npm shrinkwrap. It is identical to +package-lock.json, with one major caveat: Unlike package-lock.json, +npm-shrinkwrap.json may be included when publishing a package.

    +

    The recommended use-case for npm-shrinkwrap.json is applications deployed +through the publishing process on the registry: for example, daemons and +command-line tools intended as global installs or devDependencies. It's +strongly discouraged for library authors to publish this file, since that would +prevent end users from having control over transitive dependency updates.

    +

    Additionally, if both package-lock.json and npm-shrinkwrap.json are present +in a package root, package-lock.json will be ignored in favor of this file.

    +

    For full details and description of the npm-shrinkwrap.json file format, refer +to the manual page for package-lock.json.

    +

    See also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/google-fonts/s/inconsolata/v18/QldKNThLqRwH-OJ1UHjlKGlZ5q4.woff b/deps/npm/docs/public/google-fonts/s/inconsolata/v18/QldKNThLqRwH-OJ1UHjlKGlZ5q4.woff new file mode 100644 index 00000000000000..9771531d13dd6e Binary files /dev/null and b/deps/npm/docs/public/google-fonts/s/inconsolata/v18/QldKNThLqRwH-OJ1UHjlKGlZ5q4.woff differ diff --git a/deps/npm/docs/public/google-fonts/s/inconsolata/v18/QldKNThLqRwH-OJ1UHjlKGlZ5qg.woff2 b/deps/npm/docs/public/google-fonts/s/inconsolata/v18/QldKNThLqRwH-OJ1UHjlKGlZ5qg.woff2 new file mode 100644 index 00000000000000..77829329c652e9 Binary files /dev/null and b/deps/npm/docs/public/google-fonts/s/inconsolata/v18/QldKNThLqRwH-OJ1UHjlKGlZ5qg.woff2 differ diff --git a/deps/npm/docs/public/google-fonts/s/inconsolata/v18/QldXNThLqRwH-OJ1UHjlKGHiw71p5_o.woff b/deps/npm/docs/public/google-fonts/s/inconsolata/v18/QldXNThLqRwH-OJ1UHjlKGHiw71p5_o.woff new file mode 100644 index 00000000000000..656168951dd20d Binary files /dev/null and b/deps/npm/docs/public/google-fonts/s/inconsolata/v18/QldXNThLqRwH-OJ1UHjlKGHiw71p5_o.woff differ diff --git a/deps/npm/docs/public/google-fonts/s/inconsolata/v18/QldXNThLqRwH-OJ1UHjlKGHiw71p5_w.woff2 b/deps/npm/docs/public/google-fonts/s/inconsolata/v18/QldXNThLqRwH-OJ1UHjlKGHiw71p5_w.woff2 new file mode 100644 index 00000000000000..8be24ab2809ad5 Binary files /dev/null and b/deps/npm/docs/public/google-fonts/s/inconsolata/v18/QldXNThLqRwH-OJ1UHjlKGHiw71p5_w.woff2 differ diff --git a/deps/npm/docs/public/google-fonts/s/poppins/v9/pxiByp8kv8JHgFVrLDz8Z1xlEw.woff b/deps/npm/docs/public/google-fonts/s/poppins/v9/pxiByp8kv8JHgFVrLDz8Z1xlEw.woff new file mode 100644 index 00000000000000..cdafba1a23117d Binary files /dev/null and b/deps/npm/docs/public/google-fonts/s/poppins/v9/pxiByp8kv8JHgFVrLDz8Z1xlEw.woff differ diff --git a/deps/npm/docs/public/google-fonts/s/poppins/v9/pxiByp8kv8JHgFVrLDz8Z1xlFQ.woff2 b/deps/npm/docs/public/google-fonts/s/poppins/v9/pxiByp8kv8JHgFVrLDz8Z1xlFQ.woff2 new file mode 100644 index 00000000000000..f0dad30bf8d852 Binary files /dev/null and b/deps/npm/docs/public/google-fonts/s/poppins/v9/pxiByp8kv8JHgFVrLDz8Z1xlFQ.woff2 differ diff --git a/deps/npm/docs/public/google-fonts/s/poppins/v9/pxiByp8kv8JHgFVrLGT9Z1xlEw.woff b/deps/npm/docs/public/google-fonts/s/poppins/v9/pxiByp8kv8JHgFVrLGT9Z1xlEw.woff new file mode 100644 index 00000000000000..a2d64a1fb360d4 Binary files /dev/null and b/deps/npm/docs/public/google-fonts/s/poppins/v9/pxiByp8kv8JHgFVrLGT9Z1xlEw.woff differ diff --git a/deps/npm/docs/public/google-fonts/s/poppins/v9/pxiByp8kv8JHgFVrLGT9Z1xlFQ.woff2 b/deps/npm/docs/public/google-fonts/s/poppins/v9/pxiByp8kv8JHgFVrLGT9Z1xlFQ.woff2 new file mode 100644 index 00000000000000..fcf632b49d3edb Binary files /dev/null and b/deps/npm/docs/public/google-fonts/s/poppins/v9/pxiByp8kv8JHgFVrLGT9Z1xlFQ.woff2 differ diff --git a/deps/npm/docs/public/google-fonts/s/poppins/v9/pxiEyp8kv8JHgFVrJJfecg.woff2 b/deps/npm/docs/public/google-fonts/s/poppins/v9/pxiEyp8kv8JHgFVrJJfecg.woff2 new file mode 100644 index 00000000000000..6711b0b85fcf49 Binary files /dev/null and b/deps/npm/docs/public/google-fonts/s/poppins/v9/pxiEyp8kv8JHgFVrJJfecg.woff2 differ diff --git a/deps/npm/docs/public/google-fonts/s/poppins/v9/pxiEyp8kv8JHgFVrJJfedA.woff b/deps/npm/docs/public/google-fonts/s/poppins/v9/pxiEyp8kv8JHgFVrJJfedA.woff new file mode 100644 index 00000000000000..606db1d7a31299 Binary files /dev/null and b/deps/npm/docs/public/google-fonts/s/poppins/v9/pxiEyp8kv8JHgFVrJJfedA.woff differ diff --git a/deps/npm/docs/public/icons/icon-144x144.png b/deps/npm/docs/public/icons/icon-144x144.png new file mode 100644 index 00000000000000..cdc55431449e2e Binary files /dev/null and b/deps/npm/docs/public/icons/icon-144x144.png differ diff --git a/deps/npm/docs/public/icons/icon-192x192.png b/deps/npm/docs/public/icons/icon-192x192.png new file mode 100644 index 00000000000000..31dcbfa6bdc219 Binary files /dev/null and b/deps/npm/docs/public/icons/icon-192x192.png differ diff --git a/deps/npm/docs/public/icons/icon-256x256.png b/deps/npm/docs/public/icons/icon-256x256.png new file mode 100644 index 00000000000000..ea952cc115d9b4 Binary files /dev/null and b/deps/npm/docs/public/icons/icon-256x256.png differ diff --git a/deps/npm/docs/public/icons/icon-384x384.png b/deps/npm/docs/public/icons/icon-384x384.png new file mode 100644 index 00000000000000..57649823c6c3c3 Binary files /dev/null and b/deps/npm/docs/public/icons/icon-384x384.png differ diff --git a/deps/npm/docs/public/icons/icon-48x48.png b/deps/npm/docs/public/icons/icon-48x48.png new file mode 100644 index 00000000000000..a6fe2644f92e34 Binary files /dev/null and b/deps/npm/docs/public/icons/icon-48x48.png differ diff --git a/deps/npm/docs/public/icons/icon-512x512.png b/deps/npm/docs/public/icons/icon-512x512.png new file mode 100644 index 00000000000000..7abc6a58653069 Binary files /dev/null and b/deps/npm/docs/public/icons/icon-512x512.png differ diff --git a/deps/npm/docs/public/icons/icon-72x72.png b/deps/npm/docs/public/icons/icon-72x72.png new file mode 100644 index 00000000000000..f4ccb61f49c6eb Binary files /dev/null and b/deps/npm/docs/public/icons/icon-72x72.png differ diff --git a/deps/npm/docs/public/icons/icon-96x96.png b/deps/npm/docs/public/icons/icon-96x96.png new file mode 100644 index 00000000000000..739a5fe5379e12 Binary files /dev/null and b/deps/npm/docs/public/icons/icon-96x96.png differ diff --git a/deps/npm/docs/public/index.html b/deps/npm/docs/public/index.html new file mode 100644 index 00000000000000..cab38416ba2291 --- /dev/null +++ b/deps/npm/docs/public/index.html @@ -0,0 +1,125 @@ +npm cli | npm cli documentation
    npm cli _
    The intelligent package manager for the Node Javascript Platform. Install stuff and get coding!
    npm cli _
    The intelligent package manager for the Node Javascript Platform. Install stuff and get coding!
    npm cli _
    The intelligent package manager for the Node Javascript Platform. Install stuff and get coding!

    The current stable version of npm is available on GitHub.

    To upgrade, run: npm install npm@latest -g

    \ No newline at end of file diff --git a/deps/npm/docs/public/static/d/2215187023.json b/deps/npm/docs/public/static/d/2215187023.json new file mode 100644 index 00000000000000..c26e85bd6966e2 --- /dev/null +++ b/deps/npm/docs/public/static/d/2215187023.json @@ -0,0 +1 @@ +{"data":{"allMarkdownRemark":{"nodes":[{"fields":{"slug":"/using-npm/semver"},"frontmatter":{"description":null,"section":null,"title":""}},{"fields":{"slug":"/cli-commands/npm-adduser"},"frontmatter":{"description":null,"section":null,"title":""}},{"fields":{"slug":"/cli-commands/npm-dist-tag"},"frontmatter":{"description":null,"section":null,"title":""}},{"fields":{"slug":"/cli-commands/npm-explore"},"frontmatter":{"description":null,"section":null,"title":""}},{"fields":{"slug":"/using-npm/config"},"frontmatter":{"description":"More than you probably want to know about npm configuration","section":"using-npm","title":"config"}},{"fields":{"slug":"/using-npm/developers"},"frontmatter":{"description":"Developer Guide","section":"using-npm","title":"developers"}},{"fields":{"slug":"/using-npm/disputes"},"frontmatter":{"description":"Handling Module Name Disputes","section":"using-npm","title":"disputes"}},{"fields":{"slug":"/configuring-npm/folders"},"frontmatter":{"description":"Folder Structures Used by npm","section":"configuring-npm","title":"folders"}},{"fields":{"slug":"/configuring-npm/install"},"frontmatter":{"description":"Download and install node and npm","section":"configuring-npm","title":"install"}},{"fields":{"slug":"/cli-commands/npm"},"frontmatter":{"description":"javascript package manager","section":"cli-commands","title":"npm"}},{"fields":{"slug":"/cli-commands/npm-access"},"frontmatter":{"description":"Set access level on published packages","section":"cli-commands","title":"npm-access"}},{"fields":{"slug":"/cli-commands/npm-audit"},"frontmatter":{"description":"Run a security audit","section":"cli-commands","title":"npm-audit"}},{"fields":{"slug":"/cli-commands/npm-bin"},"frontmatter":{"description":"Display npm bin folder","section":"cli-commands","title":"npm-bin"}},{"fields":{"slug":"/cli-commands/npm-bugs"},"frontmatter":{"description":"Bugs for a package in a web browser maybe","section":"cli-commands","title":"npm-bugs"}},{"fields":{"slug":"/cli-commands/npm-build"},"frontmatter":{"description":"Build a package","section":"cli-commands","title":"npm-build"}},{"fields":{"slug":"/cli-commands/npm-bundle"},"frontmatter":{"description":"REMOVED","section":"cli-commands","title":"npm-bundle"}},{"fields":{"slug":"/cli-commands/npm-cache"},"frontmatter":{"description":"Manipulates packages cache","section":"cli-commands","title":"npm-cache"}},{"fields":{"slug":"/cli-commands/npm-ci"},"frontmatter":{"description":"Install a project with a clean slate","section":"cli-commands","title":"npm-ci"}},{"fields":{"slug":"/cli-commands/npm-completion"},"frontmatter":{"description":"Tab Completion for npm","section":"cli-commands","title":"npm-completion"}},{"fields":{"slug":"/cli-commands/npm-config"},"frontmatter":{"description":"Manage the npm configuration files","section":"cli-commands","title":"npm-config"}},{"fields":{"slug":"/cli-commands/npm-dedupe"},"frontmatter":{"description":"Reduce duplication","section":"cli-commands","title":"npm-dedupe"}},{"fields":{"slug":"/cli-commands/npm-deprecate"},"frontmatter":{"description":"Deprecate a version of a package","section":"cli-commands","title":"npm-deprecate"}},{"fields":{"slug":"/cli-commands/npm-docs"},"frontmatter":{"description":"Docs for a package in a web browser maybe","section":"cli-commands","title":"npm-docs"}},{"fields":{"slug":"/cli-commands/npm-doctor"},"frontmatter":{"description":"Check your environments","section":"cli-commands","title":"npm-doctor"}},{"fields":{"slug":"/cli-commands/npm-edit"},"frontmatter":{"description":"Edit an installed package","section":"cli-commands","title":"npm-edit"}},{"fields":{"slug":"/cli-commands/npm-fund"},"frontmatter":{"description":"Retrieve funding information","section":"cli-commands","title":"npm-fund"}},{"fields":{"slug":"/cli-commands/npm-help"},"frontmatter":{"description":"Get help on npm","section":"cli-commands","title":"npm-help"}},{"fields":{"slug":"/cli-commands/npm-help-search"},"frontmatter":{"description":"Search npm help documentation","section":"cli-commands","title":"npm-help-search"}},{"fields":{"slug":"/cli-commands/npm-hook"},"frontmatter":{"description":"Manage registry hooks","section":"cli-commands","title":"npm-hook"}},{"fields":{"slug":"/cli-commands/npm-init"},"frontmatter":{"description":"create a package.json file","section":"cli-commands","title":"npm-init"}},{"fields":{"slug":"/cli-commands/npm-install"},"frontmatter":{"description":"Install a package","section":"cli-commands","title":"npm-install"}},{"fields":{"slug":"/cli-commands/npm-install-ci-test"},"frontmatter":{"description":"Install a project with a clean slate and run tests","section":"cli-commands","title":"npm-install-ci-test"}},{"fields":{"slug":"/cli-commands/npm-install-test"},"frontmatter":{"description":"Install package(s) and run tests","section":"cli-commands","title":"npm-install-test"}},{"fields":{"slug":"/cli-commands/npm-link"},"frontmatter":{"description":"Symlink a package folder","section":"cli-commands","title":"npm-link"}},{"fields":{"slug":"/cli-commands/npm-logout"},"frontmatter":{"description":"Log out of the registry","section":"cli-commands","title":"npm-logout"}},{"fields":{"slug":"/cli-commands/npm-ls"},"frontmatter":{"description":"List installed packages","section":"cli-commands","title":"npm-ls"}},{"fields":{"slug":"/cli-commands/npm-org"},"frontmatter":{"description":"Manage orgs","section":"cli-commands","title":"npm-org"}},{"fields":{"slug":"/cli-commands/npm-outdated"},"frontmatter":{"description":"Check for outdated packages","section":"cli-commands","title":"npm-outdated"}},{"fields":{"slug":"/cli-commands/npm-owner"},"frontmatter":{"description":"Manage package owners","section":"cli-commands","title":"npm-owner"}},{"fields":{"slug":"/cli-commands/npm-pack"},"frontmatter":{"description":"Create a tarball from a package","section":"cli-commands","title":"npm-pack"}},{"fields":{"slug":"/cli-commands/npm-ping"},"frontmatter":{"description":"Ping npm registry","section":"cli-commands","title":"npm-ping"}},{"fields":{"slug":"/cli-commands/npm-prefix"},"frontmatter":{"description":"Display prefix","section":"cli-commands","title":"npm-prefix"}},{"fields":{"slug":"/cli-commands/npm-profile"},"frontmatter":{"description":"Change settings on your registry profile","section":"cli-commands","title":"npm-profile"}},{"fields":{"slug":"/cli-commands/npm-prune"},"frontmatter":{"description":"Remove extraneous packages","section":"cli-commands","title":"npm-prune"}},{"fields":{"slug":"/cli-commands/npm-publish"},"frontmatter":{"description":"Publish a package","section":"cli-commands","title":"npm-publish"}},{"fields":{"slug":"/cli-commands/npm-rebuild"},"frontmatter":{"description":"Rebuild a package","section":"cli-commands","title":"npm-rebuild"}},{"fields":{"slug":"/cli-commands/npm-repo"},"frontmatter":{"description":"Open package repository page in the browser","section":"cli-commands","title":"npm-repo"}},{"fields":{"slug":"/cli-commands/npm-restart"},"frontmatter":{"description":"Restart a package","section":"cli-commands","title":"npm-restart"}},{"fields":{"slug":"/cli-commands/npm-root"},"frontmatter":{"description":"Display npm root","section":"cli-commands","title":"npm-root"}},{"fields":{"slug":"/cli-commands/npm-run-script"},"frontmatter":{"description":"Run arbitrary package scripts","section":"cli-commands","title":"npm-run-script"}},{"fields":{"slug":"/cli-commands/npm-search"},"frontmatter":{"description":"Search for packages","section":"cli-commands","title":"npm-search"}},{"fields":{"slug":"/cli-commands/npm-shrinkwrap"},"frontmatter":{"description":"Lock down dependency versions for publication","section":"cli-commands","title":"npm-shrinkwrap"}},{"fields":{"slug":"/cli-commands/npm-star"},"frontmatter":{"description":"Mark your favorite packages","section":"cli-commands","title":"npm-star"}},{"fields":{"slug":"/cli-commands/npm-stars"},"frontmatter":{"description":"View packages marked as favorites","section":"cli-commands","title":"npm-stars"}},{"fields":{"slug":"/cli-commands/npm-start"},"frontmatter":{"description":"Start a package","section":"cli-commands","title":"npm-start"}},{"fields":{"slug":"/cli-commands/npm-stop"},"frontmatter":{"description":"Stop a package","section":"cli-commands","title":"npm-stop"}},{"fields":{"slug":"/cli-commands/npm-team"},"frontmatter":{"description":"Manage organization teams and team memberships","section":"cli-commands","title":"npm-team"}},{"fields":{"slug":"/cli-commands/npm-test"},"frontmatter":{"description":"Test a package","section":"cli-commands","title":"npm-test"}},{"fields":{"slug":"/cli-commands/npm-token"},"frontmatter":{"description":"Manage your authentication tokens","section":"cli-commands","title":"npm-token"}},{"fields":{"slug":"/cli-commands/npm-uninstall"},"frontmatter":{"description":"Remove a package","section":"cli-commands","title":"npm-uninstall"}},{"fields":{"slug":"/cli-commands/npm-unpublish"},"frontmatter":{"description":"Remove a package from the registry","section":"cli-commands","title":"npm-unpublish"}},{"fields":{"slug":"/cli-commands/npm-update"},"frontmatter":{"description":"Update a package","section":"cli-commands","title":"npm-update"}},{"fields":{"slug":"/cli-commands/npm-version"},"frontmatter":{"description":"Bump a package version","section":"cli-commands","title":"npm-version"}},{"fields":{"slug":"/cli-commands/npm-view"},"frontmatter":{"description":"View registry info","section":"cli-commands","title":"npm-view"}},{"fields":{"slug":"/cli-commands/npm-whoami"},"frontmatter":{"description":"Display npm username","section":"cli-commands","title":"npm-whoami"}},{"fields":{"slug":"/configuring-npm/npmrc"},"frontmatter":{"description":"The npm config files","section":"configuring-npm","title":"npmrc"}},{"fields":{"slug":"/using-npm/orgs"},"frontmatter":{"description":"Working with Teams & Orgs","section":"using-npm","title":"orgs"}},{"fields":{"slug":"/configuring-npm/package-lock-json"},"frontmatter":{"description":"A manifestation of the manifest","section":"configuring-npm","title":"package-lock.json"}},{"fields":{"slug":"/configuring-npm/package-locks"},"frontmatter":{"description":"An explanation of npm lockfiles","section":"configuring-npm","title":"package-locks"}},{"fields":{"slug":"/configuring-npm/package-json"},"frontmatter":{"description":"Specifics of npm's package.json handling","section":"configuring-npm","title":"package.json"}},{"fields":{"slug":"/using-npm/registry"},"frontmatter":{"description":"The JavaScript Package Registry","section":"using-npm","title":"registry"}},{"fields":{"slug":"/using-npm/removal"},"frontmatter":{"description":"Cleaning the Slate","section":"using-npm","title":"removal"}},{"fields":{"slug":"/using-npm/scope"},"frontmatter":{"description":"Scoped packages","section":"using-npm","title":"scope"}},{"fields":{"slug":"/using-npm/scripts"},"frontmatter":{"description":"How npm handles the \"scripts\" field","section":"using-npm","title":"scripts"}},{"fields":{"slug":"/configuring-npm/shrinkwrap-json"},"frontmatter":{"description":"A publishable lockfile","section":"configuring-npm","title":"shrinkwrap.json"}}]}}} \ No newline at end of file diff --git a/deps/npm/docs/public/static/d/2417117884.json b/deps/npm/docs/public/static/d/2417117884.json new file mode 100644 index 00000000000000..a7412e7c9b4e80 --- /dev/null +++ b/deps/npm/docs/public/static/d/2417117884.json @@ -0,0 +1 @@ +{"data":{"site":{"siteMetadata":{"title":"npm cli documentation","description":"Documentation for the npm cli.","author":"@gatsbyjs"}}}} \ No newline at end of file diff --git a/deps/npm/docs/public/static/network-icon-f659855f70bb0e12addd96250807c241.svg b/deps/npm/docs/public/static/network-icon-f659855f70bb0e12addd96250807c241.svg new file mode 100644 index 00000000000000..d7ff6bfb1aee8b --- /dev/null +++ b/deps/npm/docs/public/static/network-icon-f659855f70bb0e12addd96250807c241.svg @@ -0,0 +1 @@ +network-icon \ No newline at end of file diff --git a/deps/npm/docs/public/styles.e93b5499b63484750fba.css b/deps/npm/docs/public/styles.e93b5499b63484750fba.css new file mode 100644 index 00000000000000..43ab98eaf07a2c --- /dev/null +++ b/deps/npm/docs/public/styles.e93b5499b63484750fba.css @@ -0,0 +1 @@ +code[class*=language-],pre[class*=language-]{color:#ccc;background:none;font-family:Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace;font-size:1em;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-ms-hyphens:none;hyphens:none}pre[class*=language-]{padding:1em;margin:.5em 0;overflow:auto}:not(pre)>code[class*=language-],pre[class*=language-]{background:#2d2d2d}:not(pre)>code[class*=language-]{padding:.1em;border-radius:.3em;white-space:normal}.token.block-comment,.token.cdata,.token.comment,.token.doctype,.token.prolog{color:#999}.token.punctuation{color:#ccc}.token.attr-name,.token.deleted,.token.namespace,.token.tag{color:#e2777a}.token.function-name{color:#6196cc}.token.boolean,.token.function,.token.number{color:#f08d49}.token.class-name,.token.constant,.token.property,.token.symbol{color:#f8c555}.token.atrule,.token.builtin,.token.important,.token.keyword,.token.selector{color:#cc99cd}.token.attr-value,.token.char,.token.regex,.token.string,.token.variable{color:#7ec699}.token.entity,.token.operator,.token.url{color:#67cdcc}.token.bold,.token.important{font-weight:700}.token.italic{font-style:italic}.token.entity{cursor:help}.token.inserted{color:green}a,abbr,acronym,address,applet,article,aside,audio,b,big,blockquote,body,canvas,caption,center,cite,code,dd,del,details,dfn,div,dl,dt,em,embed,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,html,i,iframe,img,ins,kbd,label,legend,li,mark,menu,nav,object,ol,output,p,pre,q,ruby,s,samp,section,small,span,strike,strong,sub,summary,sup,table,tbody,td,tfoot,th,thead,time,tr,tt,u,ul,var,video{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:after,blockquote:before,q:after,q:before{content:"";content:none}table{border-collapse:collapse;border-spacing:0}[hidden]{display:none}html{font-family:Poppins,sans-serif}*{box-sizing:border-box}li,p{font-size:15px;line-height:1.7;font-weight:300}p,ul{padding:10px 0}strong{font-weight:700;color:#c3f}li{list-style-type:disc;list-style-position:inside;padding:8px 0}.documentation h1{font-size:42px;font-weight:600;padding:30px 0 10px}.documentation h2{font-size:22px;font-weight:300}.documentation h3{color:#c3f;font-size:22px;padding:30px 0 5px;font-weight:500}.documentation h4{font-weight:600;padding:20px 0 5px}.documentation p{display:inline-block}:not(pre)>code[class*=language-],pre[class*=language-]{border-radius:4px;background-color:#413844;font-size:13px}:not(pre)>code[class*=language-text]{background-color:rgba(204,139,216,.1);color:#413844;padding:2px 6px;border-radius:0;font-size:14px;font-weight:700;border-radius:1px;display:inline-block}.documentation a,a>code[class*=language-text]{color:#fb3b49;font-weight:600}p>code[class*=language-text]{display:inline-block}.documentation h1:before{content:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0 0 27 26'%3E%3Cdefs%3E%3ClinearGradient id='a' x1='18.13' x2='25.6' y1='13.48' y2='13.48' gradientUnits='userSpaceOnUse'%3E%3Cstop offset='0' stop-color='%23fb8817'/%3E%3Cstop offset='.37' stop-color='%23fb8719'/%3E%3Cstop offset='.51' stop-color='%23fa8420'/%3E%3Cstop offset='.61' stop-color='%23f9802c'/%3E%3Cstop offset='.69' stop-color='%23f7793d'/%3E%3Cstop offset='.76' stop-color='%23f47053'/%3E%3Cstop offset='.82' stop-color='%23f1656e'/%3E%3Cstop offset='.87' stop-color='%23ed578f'/%3E%3Cstop offset='.92' stop-color='%23e948b5'/%3E%3Cstop offset='.97' stop-color='%23e437de'/%3E%3Cstop offset='1' stop-color='%23e02aff'/%3E%3C/linearGradient%3E%3ClinearGradient id='b' x1='17.89' x2='25.84' y1='13.48' y2='13.48' gradientUnits='userSpaceOnUse'%3E%3Cstop offset='0' stop-color='%23fb8817'/%3E%3Cstop offset='1' stop-color='%23e02aff'/%3E%3C/linearGradient%3E%3ClinearGradient id='c' x1='1' x2='18.69' y1='17.84' y2='17.84' xlink:href='%23a'/%3E%3ClinearGradient id='d' x1='.76' x2='18.93' y1='17.84' y2='17.84' xlink:href='%23b'/%3E%3ClinearGradient id='e' x1='1' x2='20.48' y1='7.33' y2='7.33' xlink:href='%23a'/%3E%3ClinearGradient id='f' x1='.76' x2='20.72' y1='7.33' y2='7.33' xlink:href='%23b'/%3E%3C/defs%3E%3Cpath fill='url(%23a)' stroke='url(%23b)' stroke-miterlimit='10' stroke-width='.48' d='M18.53 24.24a.28.28 0 01-.34-.41L25 14.06l-5-11a.28.28 0 11.5-.23L25.58 14a.28.28 0 010 .28l-6.91 9.9a.28.28 0 01-.14.06z'/%3E%3Cpath fill='url(%23c)' stroke='url(%23d)' stroke-miterlimit='10' stroke-width='.48' d='M18.53 24.24a.28.28 0 01-.14 0l-12-1.15a.28.28 0 01-.23-.09L1 11.81a.28.28 0 11.5-.23l5.07 11L18 23.68 13 13a.28.28 0 11.5-.23l5.12 11.12a.28.28 0 01-.09.35z'/%3E%3Cpath fill='url(%23e)' stroke='url(%23f)' stroke-miterlimit='10' stroke-width='.48' d='M13.4 13.12a.25.25 0 01-.14 0L1.25 12a.28.28 0 01-.2-.44L8 1.64a.28.28 0 01.25-.12l12 1.18a.28.28 0 01.2.44L13.51 13a.25.25 0 01-.11.12z'/%3E%3C/svg%3E");position:relative;display:inline-block;padding-right:8px;top:3px;width:28px}.active-sidebar-link{background-color:#ffebff}.active-navbar-link{border-bottom:3px solid #c3f}.header-link-class{margin-left:-24px}.disabled-body{overflow:hidden} \ No newline at end of file diff --git a/deps/npm/docs/public/using-npm/config/index.html b/deps/npm/docs/public/using-npm/config/index.html new file mode 100644 index 00000000000000..90b88a641b48ae --- /dev/null +++ b/deps/npm/docs/public/using-npm/config/index.html @@ -0,0 +1,1158 @@ +

    config

    +

    More than you probably want to know about npm configuration

    +

    Description

    +

    npm gets its configuration values from the following sources, sorted by priority:

    +

    Command Line Flags

    +

    Putting --foo bar on the command line sets the foo configuration +parameter to "bar". A -- argument tells the cli parser to stop +reading flags. Using --flag without specifying any value will set +the value to true.

    +

    Example: --flag1 --flag2 will set both configuration parameters +to true, while --flag1 --flag2 bar will set flag1 to true, +and flag2 to bar. Finally, --flag1 --flag2 -- bar will set +both configuration parameters to true, and the bar is taken +as a command argument.

    +

    Environment Variables

    +

    Any environment variables that start with npm_config_ will be +interpreted as a configuration parameter. For example, putting +npm_config_foo=bar in your environment will set the foo +configuration parameter to bar. Any environment configurations that +are not given a value will be given the value of true. Config +values are case-insensitive, so NPM_CONFIG_FOO=bar will work the +same. However, please note that inside scripts +npm will set its own environment variables and Node will prefer +those lowercase versions over any uppercase ones that you might set. +For details see this issue.

    +

    Notice that you need to use underscores instead of dashes, so --allow-same-version +would become npm_config_allow_same_version=true.

    +

    npmrc Files

    +

    The four relevant files are:

    +
      +
    • per-project configuration file (/path/to/my/project/.npmrc)
    • +
    • per-user configuration file (defaults to $HOME/.npmrc; configurable via CLI +option --userconfig or environment variable $NPM_CONFIG_USERCONFIG)
    • +
    • global configuration file (defaults to $PREFIX/etc/npmrc; configurable via +CLI option --globalconfig or environment variable $NPM_CONFIG_GLOBALCONFIG)
    • +
    • npm's built-in configuration file (/path/to/npm/npmrc)
    • +
    +

    See npmrc for more details.

    +

    Default Configs

    +

    Run npm config ls -l to see a set of configuration parameters that are +internal to npm, and are defaults if nothing else is specified.

    +

    Shorthands and Other CLI Niceties

    +

    The following shorthands are parsed on the command-line:

    +
      +
    • -v: --version
    • +
    • -h, -?, --help, -H: --usage
    • +
    • -s, --silent: --loglevel silent
    • +
    • -q, --quiet: --loglevel warn
    • +
    • -d: --loglevel info
    • +
    • -dd, --verbose: --loglevel verbose
    • +
    • -ddd: --loglevel silly
    • +
    • -g: --global
    • +
    • -C: --prefix
    • +
    • -l: --long
    • +
    • -m: --message
    • +
    • -p, --porcelain: --parseable
    • +
    • -reg: --registry
    • +
    • -f: --force
    • +
    • -desc: --description
    • +
    • -S: --save
    • +
    • -P: --save-prod
    • +
    • -D: --save-dev
    • +
    • -O: --save-optional
    • +
    • -B: --save-bundle
    • +
    • -E: --save-exact
    • +
    • -y: --yes
    • +
    • -n: --yes false
    • +
    • ll and la commands: ls --long
    • +
    +

    If the specified configuration param resolves unambiguously to a known +configuration parameter, then it is expanded to that configuration +parameter. For example:

    +
    npm ls --par
    +# same as:
    +npm ls --parseable
    +

    If multiple single-character shorthands are strung together, and the +resulting combination is unambiguously not some other configuration +param, then it is expanded to its various component pieces. For +example:

    +
    npm ls -gpld
    +# same as:
    +npm ls --global --parseable --long --loglevel info
    +

    Per-Package Config Settings

    +

    When running scripts (see scripts) the package.json "config" +keys are overwritten in the environment if there is a config param of +<name>[@<version>]:<key>. For example, if the package.json has +this:

    +
    { "name" : "foo"
    +, "config" : { "port" : "8080" }
    +, "scripts" : { "start" : "node server.js" } }
    +

    and the server.js is this:

    +
    http.createServer(...).listen(process.env.npm_package_config_port)
    +

    then the user could change the behavior by doing:

    +
    npm config set foo:port 80
    +

    See package.json for more information.

    +

    Config Settings

    +

    access

    +
      +
    • Default: restricted
    • +
    • Type: Access
    • +
    +

    When publishing scoped packages, the access level defaults to restricted. If +you want your scoped package to be publicly viewable (and installable) set +--access=public. The only valid values for access are public and +restricted. Unscoped packages always have an access level of public.

    +

    allow-same-version

    +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    Prevents throwing an error when npm version is used to set the new version +to the same value as the current version.

    +

    always-auth

    +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    Force npm to always require authentication when accessing the registry, +even for GET requests.

    +

    also

    +
      +
    • Default: null
    • +
    • Type: String
    • +
    +

    When "dev" or "development" and running local npm shrinkwrap, +npm outdated, or npm update, is an alias for --dev.

    +

    audit

    +
      +
    • Default: true
    • +
    • Type: Boolean
    • +
    +

    When "true" submit audit reports alongside npm install runs to the default +registry and all registries configured for scopes. See the documentation +for npm audit for details on what is submitted.

    +

    audit-level

    +
      +
    • Default: "low"
    • +
    • Type: 'low', 'moderate', 'high', 'critical'
    • +
    +

    The minimum level of vulnerability for npm audit to exit with +a non-zero exit code.

    +

    auth-type

    +
      +
    • Default: 'legacy'
    • +
    • Type: 'legacy', 'sso', 'saml', 'oauth'
    • +
    +

    What authentication strategy to use with adduser/login.

    +

    before

    +
      +
    • Alias: enjoy-by
    • +
    • Default: null
    • +
    • Type: Date
    • +
    +

    If passed to npm install, will rebuild the npm tree such that only versions +that were available on or before the --before time get installed. +If there's no versions available for the current set of direct dependencies, the +command will error.

    +

    If the requested version is a dist-tag and the given tag does not pass the +--before filter, the most recent version less than or equal to that tag will +be used. For example, foo@latest might install foo@1.2 even though latest +is 2.0.

    + +
      +
    • Default: true
    • +
    • Type: Boolean
    • +
    +

    Tells npm to create symlinks (or .cmd shims on Windows) for package +executables.

    +

    Set to false to have it not do this. This can be used to work around +the fact that some file systems don't support symlinks, even on +ostensibly Unix systems.

    +

    browser

    +
      +
    • Default: OS X: "open", Windows: "start", Others: "xdg-open"
    • +
    • Type: String
    • +
    +

    The browser that is called by the npm docs command to open websites.

    +

    ca

    +
      +
    • Default: The npm CA certificate
    • +
    • Type: String, Array or null
    • +
    +

    The Certificate Authority signing certificate that is trusted for SSL +connections to the registry. Values should be in PEM format (Windows calls it "Base-64 encoded X.509 (.CER)") with newlines +replaced by the string "\n". For example:

    +
    ca="-----BEGIN CERTIFICATE-----\nXXXX\nXXXX\n-----END CERTIFICATE-----"
    +

    Set to null to only allow "known" registrars, or to a specific CA cert +to trust only that specific signing authority.

    +

    Multiple CAs can be trusted by specifying an array of certificates:

    +
    ca[]="..."
    +ca[]="..."
    +

    See also the strict-ssl config.

    +

    cafile

    +
      +
    • Default: null
    • +
    • Type: path
    • +
    +

    A path to a file containing one or multiple Certificate Authority signing +certificates. Similar to the ca setting, but allows for multiple CA's, as +well as for the CA information to be stored in a file on disk.

    +

    cache

    +
      +
    • Default: Windows: %AppData%\npm-cache, Posix: ~/.npm
    • +
    • Type: path
    • +
    +

    The location of npm's cache directory. See npm cache

    +

    cache-lock-stale

    +
      +
    • Default: 60000 (1 minute)
    • +
    • Type: Number
    • +
    +

    The number of ms before cache folder lockfiles are considered stale.

    +

    cache-lock-retries

    +
      +
    • Default: 10
    • +
    • Type: Number
    • +
    +

    Number of times to retry to acquire a lock on cache folder lockfiles.

    +

    cache-lock-wait

    +
      +
    • Default: 10000 (10 seconds)
    • +
    • Type: Number
    • +
    +

    Number of ms to wait for cache lock files to expire.

    +

    cache-max

    +
      +
    • Default: Infinity
    • +
    • Type: Number
    • +
    +

    DEPRECATED: This option has been deprecated in favor of --prefer-online.

    +

    --cache-max=0 is an alias for --prefer-online.

    +

    cache-min

    +
      +
    • Default: 10
    • +
    • Type: Number
    • +
    +

    DEPRECATED: This option has been deprecated in favor of --prefer-offline.

    +

    --cache-min=9999 (or bigger) is an alias for --prefer-offline.

    +

    cert

    +
      +
    • Default: null
    • +
    • Type: String
    • +
    +

    A client certificate to pass when accessing the registry. Values should be in +PEM format (Windows calls it "Base-64 encoded X.509 (.CER)") with newlines replaced by the string "\n". For example:

    +
    cert="-----BEGIN CERTIFICATE-----\nXXXX\nXXXX\n-----END CERTIFICATE-----"
    +

    It is not the path to a certificate file (and there is no "certfile" option).

    +

    cidr

    +
      +
    • Default: null
    • +
    • Type: String, Array, null
    • +
    +

    This is a list of CIDR address to be used when configuring limited access tokens with the npm token create command.

    +

    color

    +
      +
    • Default: true
    • +
    • Type: Boolean or "always"
    • +
    +

    If false, never shows colors. If "always" then always shows colors. +If true, then only prints color codes for tty file descriptors.

    +

    This option can also be changed using the environment: colors are +disabled when the environment variable NO_COLOR is set to any value.

    +

    depth

    +
      +
    • Default: Infinity
    • +
    • Type: Number
    • +
    +

    The depth to go when recursing directories for npm ls, +npm cache ls, and npm outdated.

    +

    For npm outdated, a setting of Infinity will be treated as 0 +since that gives more useful information. To show the outdated status +of all packages and dependents, use a large integer value, +e.g., npm outdated --depth 9999

    +

    description

    +
      +
    • Default: true
    • +
    • Type: Boolean
    • +
    +

    Show the description in npm search

    +

    dev

    +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    Install dev-dependencies along with packages.

    +

    dry-run

    +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    Indicates that you don't want npm to make any changes and that it should +only report what it would have done. This can be passed into any of the +commands that modify your local installation, eg, install, update, +dedupe, uninstall. This is NOT currently honored by some network related +commands, eg dist-tags, owner, etc.

    +

    editor

    +
      +
    • Default: EDITOR environment variable if set, or "vi" on Posix, +or "notepad" on Windows.
    • +
    • Type: path
    • +
    +

    The command to run for npm edit or npm config edit.

    +

    engine-strict

    +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    If set to true, then npm will stubbornly refuse to install (or even +consider installing) any package that claims to not be compatible with +the current Node.js version.

    +

    force

    +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    Makes various commands more forceful.

    +
      +
    • lifecycle script failure does not block progress.
    • +
    • publishing clobbers previously published versions.
    • +
    • skips cache when requesting from the registry.
    • +
    • prevents checks against clobbering non-npm files.
    • +
    +

    format-package-lock

    +
      +
    • Default: true
    • +
    • Type: Boolean
    • +
    +

    Format package-lock.json or npm-shrinkwrap.json as a human readable file.

    +

    fetch-retries

    +
      +
    • Default: 2
    • +
    • Type: Number
    • +
    +

    The "retries" config for the retry module to use when fetching +packages from the registry.

    +

    fetch-retry-factor

    +
      +
    • Default: 10
    • +
    • Type: Number
    • +
    +

    The "factor" config for the retry module to use when fetching +packages.

    +

    fetch-retry-mintimeout

    +
      +
    • Default: 10000 (10 seconds)
    • +
    • Type: Number
    • +
    +

    The "minTimeout" config for the retry module to use when fetching +packages.

    +

    fetch-retry-maxtimeout

    +
      +
    • Default: 60000 (1 minute)
    • +
    • Type: Number
    • +
    +

    The "maxTimeout" config for the retry module to use when fetching +packages.

    +

    fund

    +
      +
    • Default: true
    • +
    • Type: Boolean
    • +
    +

    When "true" displays the message at the end of each npm install +aknowledging the number of dependencies looking for funding. +See npm fund for details.

    +

    git

    +
      +
    • Default: "git"
    • +
    • Type: String
    • +
    +

    The command to use for git commands. If git is installed on the +computer, but is not in the PATH, then set this to the full path to +the git binary.

    +

    git-tag-version

    +
      +
    • Default: true
    • +
    • Type: Boolean
    • +
    +

    Tag the commit when using the npm version command.

    +

    commit-hooks

    +
      +
    • Default: true
    • +
    • Type: Boolean
    • +
    +

    Run git commit hooks when using the npm version command.

    +

    global

    +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    Operates in "global" mode, so that packages are installed into the +prefix folder instead of the current working directory. See +folders for more on the differences in behavior.

    +
      +
    • packages are installed into the {prefix}/lib/node_modules folder, instead of the +current working directory.
    • +
    • bin files are linked to {prefix}/bin
    • +
    • man pages are linked to {prefix}/share/man
    • +
    +

    globalconfig

    +
      +
    • Default: {prefix}/etc/npmrc
    • +
    • Type: path
    • +
    +

    The config file to read for global config options.

    +

    global-style

    +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    Causes npm to install the package into your local node_modules folder with +the same layout it uses with the global node_modules folder. Only your +direct dependencies will show in node_modules and everything they depend +on will be flattened in their node_modules folders. This obviously will +eliminate some deduping. If used with legacy-bundling, legacy-bundling will be +preferred.

    +

    group

    +
      +
    • Default: GID of the current process
    • +
    • Type: String or Number
    • +
    +

    The group to use when running package scripts in global mode as the root +user.

    +

    heading

    +
      +
    • Default: "npm"
    • +
    • Type: String
    • +
    +

    The string that starts all the debugging log output.

    +

    https-proxy

    +
      +
    • Default: null
    • +
    • Type: url
    • +
    +

    A proxy to use for outgoing https requests. If the HTTPS_PROXY or +https_proxy or HTTP_PROXY or http_proxy environment variables are set, +proxy settings will be honored by the underlying request library.

    +

    if-present

    +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    If true, npm will not exit with an error code when run-script is invoked for +a script that isn't defined in the scripts section of package.json. This +option can be used when it's desirable to optionally run a script when it's +present and fail if the script fails. This is useful, for example, when running +scripts that may only apply for some builds in an otherwise generic CI setup.

    +

    ignore-prepublish

    +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    If true, npm will not run prepublish scripts.

    +

    ignore-scripts

    +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    If true, npm does not run scripts specified in package.json files.

    +

    init-module

    +
      +
    • Default: ~/.npm-init.js
    • +
    • Type: path
    • +
    +

    A module that will be loaded by the npm init command. See the +documentation for the +init-package-json module +for more information, or npm init.

    +

    init-author-name

    +
      +
    • Default: ""
    • +
    • Type: String
    • +
    +

    The value npm init should use by default for the package author's name.

    +

    init-author-email

    +
      +
    • Default: ""
    • +
    • Type: String
    • +
    +

    The value npm init should use by default for the package author's email.

    +

    init-author-url

    +
      +
    • Default: ""
    • +
    • Type: String
    • +
    +

    The value npm init should use by default for the package author's homepage.

    +

    init-license

    +
      +
    • Default: "ISC"
    • +
    • Type: String
    • +
    +

    The value npm init should use by default for the package license.

    +

    init-version

    +
      +
    • Default: "1.0.0"
    • +
    • Type: semver
    • +
    +

    The value that npm init should use by default for the package +version number, if not already set in package.json.

    +

    json

    +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    Whether or not to output JSON data, rather than the normal output.

    +

    This feature is currently experimental, and the output data structures for many +commands is either not implemented in JSON yet, or subject to change. Only the +output from npm ls --json and npm search --json are currently valid.

    +

    key

    +
      +
    • Default: null
    • +
    • Type: String
    • +
    +

    A client key to pass when accessing the registry. Values should be in PEM +format with newlines replaced by the string "\n". For example:

    +
    key="-----BEGIN PRIVATE KEY-----\nXXXX\nXXXX\n-----END PRIVATE KEY-----"
    +

    It is not the path to a key file (and there is no "keyfile" option).

    +

    legacy-bundling

    +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    Causes npm to install the package such that versions of npm prior to 1.4, +such as the one included with node 0.8, can install the package. This +eliminates all automatic deduping. If used with global-style this option +will be preferred.

    + +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    If true, then local installs will link if there is a suitable globally +installed package.

    +

    Note that this means that local installs can cause things to be +installed into the global space at the same time. The link is only done +if one of the two conditions are met:

    +
      +
    • The package is not already installed globally, or
    • +
    • the globally installed version is identical to the version that is +being installed locally.
    • +
    +

    local-address

    +
      +
    • Default: undefined
    • +
    • Type: IP Address
    • +
    +

    The IP address of the local interface to use when making connections +to the npm registry. Must be IPv4 in versions of Node prior to 0.12.

    +

    loglevel

    +
      +
    • Default: "notice"
    • +
    • Type: String
    • +
    • Values: "silent", "error", "warn", "notice", "http", "timing", "info", +"verbose", "silly"
    • +
    +

    What level of logs to report. On failure, all logs are written to +npm-debug.log in the current working directory.

    +

    Any logs of a higher level than the setting are shown. The default is "notice".

    +

    logstream

    +
      +
    • Default: process.stderr
    • +
    • Type: Stream
    • +
    +

    This is the stream that is passed to the +npmlog module at run time.

    +

    It cannot be set from the command line, but if you are using npm +programmatically, you may wish to send logs to somewhere other than +stderr.

    +

    If the color config is set to true, then this stream will receive +colored output if it is a TTY.

    +

    logs-max

    +
      +
    • Default: 10
    • +
    • Type: Number
    • +
    +

    The maximum number of log files to store.

    +

    long

    +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    Show extended information in npm ls and npm search.

    +

    maxsockets

    +
      +
    • Default: 50
    • +
    • Type: Number
    • +
    +

    The maximum number of connections to use per origin (protocol/host/port +combination). Passed to the http Agent used to make the request.

    +

    message

    +
      +
    • Default: "%s"
    • +
    • Type: String
    • +
    +

    Commit message which is used by npm version when creating version commit.

    +

    Any "%s" in the message will be replaced with the version number.

    +

    metrics-registry

    + +

    The registry you want to send cli metrics to if send-metrics is true.

    +

    node-options

    +
      +
    • Default: null
    • +
    • Type: String
    • +
    +

    Options to pass through to Node.js via the NODE_OPTIONS environment +variable. This does not impact how npm itself is executed but it does +impact how lifecycle scripts are called.

    +

    node-version

    +
      +
    • Default: process.version
    • +
    • Type: semver or false
    • +
    +

    The node version to use when checking a package's engines map.

    +

    noproxy

    +
      +
    • Default: null
    • +
    • Type: String or Array
    • +
    +

    A comma-separated string or an array of domain extensions that a proxy should not be used for.

    +

    offline

    +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    Force offline mode: no network requests will be done during install. To allow +the CLI to fill in missing cache data, see --prefer-offline.

    +

    onload-script

    +
      +
    • Default: false
    • +
    • Type: path
    • +
    +

    A node module to require() when npm loads. Useful for programmatic +usage.

    +

    only

    +
      +
    • Default: null
    • +
    • Type: String
    • +
    +

    When "dev" or "development" and running local npm install without any +arguments, only devDependencies (and their dependencies) are installed.

    +

    When "dev" or "development" and running local npm ls, npm outdated, or +npm update, is an alias for --dev.

    +

    When "prod" or "production" and running local npm install without any +arguments, only non-devDependencies (and their dependencies) are +installed.

    +

    When "prod" or "production" and running local npm ls, npm outdated, or +npm update, is an alias for --production.

    +

    optional

    +
      +
    • Default: true
    • +
    • Type: Boolean
    • +
    +

    Attempt to install packages in the optionalDependencies object. Note +that if these packages fail to install, the overall installation +process is not aborted.

    +

    otp

    +
      +
    • Default: null
    • +
    • Type: Number
    • +
    +

    This is a one-time password from a two-factor authenticator. It's needed +when publishing or changing package permissions with npm access.

    +

    package-lock

    +
      +
    • Default: true
    • +
    • Type: Boolean
    • +
    +

    If set to false, then ignore package-lock.json files when installing. This +will also prevent writing package-lock.json if save is true.

    +

    When package package-locks are disabled, automatic pruning of extraneous +modules will also be disabled. To remove extraneous modules with +package-locks disabled use npm prune.

    +

    This option is an alias for --shrinkwrap.

    +

    package-lock-only

    +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    If set to true, it will update only the package-lock.json, +instead of checking node_modules and downloading dependencies.

    +

    parseable

    +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    Output parseable results from commands that write to +standard output. For npm search, this will be tab-separated table format.

    +

    prefer-offline

    +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    If true, staleness checks for cached data will be bypassed, but missing data +will be requested from the server. To force full offline mode, use --offline.

    +

    This option is effectively equivalent to --cache-min=9999999.

    +

    prefer-online

    +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    If true, staleness checks for cached data will be forced, making the CLI look +for updates immediately even for fresh package data.

    +

    prefix

    +
      +
    • Default: see folders
    • +
    • Type: path
    • +
    +

    The location to install global items. If set on the command line, then +it forces non-global commands to run in the specified folder.

    +

    preid

    +
      +
    • Default: ""
    • +
    • Type: String
    • +
    +

    The "prerelease identifier" to use as a prefix for the "prerelease" part of a +semver. Like the rc in 1.2.0-rc.8.

    +

    production

    +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    Set to true to run in "production" mode.

    +
      +
    1. devDependencies are not installed at the topmost level when running +local npm install without any arguments.
    2. +
    3. Set the NODE_ENV="production" for lifecycle scripts.
    4. +
    +

    progress

    +
      +
    • Default: true, unless TRAVIS or CI env vars set.
    • +
    • Type: Boolean
    • +
    +

    When set to true, npm will display a progress bar during time intensive +operations, if process.stderr is a TTY.

    +

    Set to false to suppress the progress bar.

    +

    proxy

    +
      +
    • Default: null
    • +
    • Type: url
    • +
    +

    A proxy to use for outgoing http requests. If the HTTP_PROXY or +http_proxy environment variables are set, proxy settings will be +honored by the underlying request library.

    +

    read-only

    +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    This is used to mark a token as unable to publish when configuring limited access tokens with the npm token create command.

    +

    rebuild-bundle

    +
      +
    • Default: true
    • +
    • Type: Boolean
    • +
    +

    Rebuild bundled dependencies after installation.

    +

    registry

    + +

    The base URL of the npm package registry.

    +

    rollback

    +
      +
    • Default: true
    • +
    • Type: Boolean
    • +
    +

    Remove failed installs.

    +

    save

    +
      +
    • Default: true
    • +
    • Type: Boolean
    • +
    +

    Save installed packages to a package.json file as dependencies.

    +

    When used with the npm rm command, it removes it from the dependencies +object.

    +

    Only works if there is already a package.json file present.

    +

    save-bundle

    +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    If a package would be saved at install time by the use of --save, +--save-dev, or --save-optional, then also put it in the +bundleDependencies list.

    +

    When used with the npm rm command, it removes it from the +bundledDependencies list.

    +

    save-prod

    +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    Makes sure that a package will be saved into dependencies specifically. This +is useful if a package already exists in devDependencies or +optionalDependencies, but you want to move it to be a production dep. This is +also the default behavior if --save is true, and neither --save-dev or +--save-optional are true.

    +

    save-dev

    +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    Save installed packages to a package.json file as devDependencies.

    +

    When used with the npm rm command, it removes it from the +devDependencies object.

    +

    Only works if there is already a package.json file present.

    +

    save-exact

    +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    Dependencies saved to package.json using --save, --save-dev or +--save-optional will be configured with an exact version rather than +using npm's default semver range operator.

    +

    save-optional

    +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    Save installed packages to a package.json file as +optionalDependencies.

    +

    When used with the npm rm command, it removes it from the +devDependencies object.

    +

    Only works if there is already a package.json file present.

    +

    save-prefix

    +
      +
    • Default: '^'
    • +
    • Type: String
    • +
    +

    Configure how versions of packages installed to a package.json file via +--save or --save-dev get prefixed.

    +

    For example if a package has version 1.2.3, by default its version is +set to ^1.2.3 which allows minor upgrades for that package, but after +npm config set save-prefix='~' it would be set to ~1.2.3 which only allows +patch upgrades.

    +

    scope

    +
      +
    • Default: the scope of the current project, if any, or ""
    • +
    • Type: String
    • +
    +

    Associate an operation with a scope for a scoped registry. Useful when logging +in to a private registry for the first time: +npm login --scope=@organization --registry=registry.organization.com, which +will cause @organization to be mapped to the registry for future installation +of packages specified according to the pattern @organization/package.

    +

    script-shell

    +
      +
    • Default: null
    • +
    • Type: path
    • +
    +

    The shell to use for scripts run with the npm run command.

    +

    scripts-prepend-node-path

    +
      +
    • Default: "warn-only"
    • +
    • Type: Boolean, "auto" or "warn-only"
    • +
    +

    If set to true, add the directory in which the current node executable +resides to the PATH environment variable when running scripts, +even if that means that npm will invoke a different node executable than +the one which it is running.

    +

    If set to false, never modify PATH with that.

    +

    If set to "warn-only", never modify PATH but print a warning if npm thinks +that you may want to run it with true, e.g. because the node executable +in the PATH is not the one npm was invoked with.

    +

    If set to auto, only add that directory to the PATH environment variable +if the node executable with which npm was invoked and the one that is found +first on the PATH are different.

    +

    searchexclude

    +
      +
    • Default: ""
    • +
    • Type: String
    • +
    +

    Space-separated options that limit the results from search.

    +

    searchopts

    +
      +
    • Default: ""
    • +
    • Type: String
    • +
    +

    Space-separated options that are always passed to search.

    +

    searchlimit

    +
      +
    • Default: 20
    • +
    • Type: Number
    • +
    +

    Number of items to limit search results to. Will not apply at all to legacy +searches.

    +

    searchstaleness

    +
      +
    • Default: 900 (15 minutes)
    • +
    • Type: Number
    • +
    +

    The age of the cache, in seconds, before another registry request is made if +using legacy search endpoint.

    +

    send-metrics

    +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    If true, success/failure metrics will be reported to the registry stored in +metrics-registry. These requests contain the number of successful and +failing runs of the npm CLI and the time period overwhich those counts were +gathered. No identifying information is included in these requests.

    +

    shell

    +
      +
    • Default: SHELL environment variable, or "bash" on Posix, or "cmd" on +Windows
    • +
    • Type: path
    • +
    +

    The shell to run for the npm explore command.

    +

    shrinkwrap

    +
      +
    • Default: true
    • +
    • Type: Boolean
    • +
    +

    If set to false, then ignore npm-shrinkwrap.json files when installing. This +will also prevent writing npm-shrinkwrap.json if save is true.

    +

    This option is an alias for --package-lock.

    +

    sign-git-commit

    +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    If set to true, then the npm version command will commit the new package +version using -S to add a signature.

    +

    Note that git requires you to have set up GPG keys in your git configs +for this to work properly.

    +

    sign-git-tag

    +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    If set to true, then the npm version command will tag the version +using -s to add a signature.

    +

    Note that git requires you to have set up GPG keys in your git configs +for this to work properly.

    +

    sso-poll-frequency

    +
      +
    • Default: 500
    • +
    • Type: Number
    • +
    +

    When used with SSO-enabled auth-types, configures how regularly the registry +should be polled while the user is completing authentication.

    +

    sso-type

    +
      +
    • Default: 'oauth'
    • +
    • Type: 'oauth', 'saml', or null
    • +
    +

    If --auth-type=sso, the type of SSO type to use.

    +

    strict-ssl

    +
      +
    • Default: true
    • +
    • Type: Boolean
    • +
    +

    Whether or not to do SSL key validation when making requests to the +registry via https.

    +

    See also the ca config.

    +

    tag

    +
      +
    • Default: latest
    • +
    • Type: String
    • +
    +

    If you ask npm to install a package and don't tell it a specific version, then +it will install the specified tag.

    +

    Also the tag that is added to the package@version specified by the npm +tag command, if no explicit tag is given.

    +

    tag-version-prefix

    +
      +
    • Default: "v"
    • +
    • Type: String
    • +
    +

    If set, alters the prefix used when tagging a new version when performing a +version increment using npm-version. To remove the prefix altogether, set it +to the empty string: "".

    +

    Because other tools may rely on the convention that npm version tags look like +v1.0.0, only use this property if it is absolutely necessary. In +particular, use care when overriding this setting for public packages.

    +

    timing

    +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    If true, writes an npm-debug log to _logs and timing information to +_timing.json, both in your cache. _timing.json is a newline delimited +list of JSON objects. You can quickly view it with this +json command line: +json -g < ~/.npm/_timing.json.

    +

    tmp

    +
      +
    • Default: TMPDIR environment variable, or "/tmp"
    • +
    • Type: path
    • +
    +

    Where to store temporary files and folders. All temp files are deleted +on success, but left behind on failure for forensic purposes.

    +

    unicode

    +
      +
    • Default: false on windows, true on mac/unix systems with a unicode locale
    • +
    • Type: Boolean
    • +
    +

    When set to true, npm uses unicode characters in the tree output. When +false, it uses ascii characters to draw trees.

    +

    unsafe-perm

    +
      +
    • Default: false if running as root, true otherwise
    • +
    • Type: Boolean
    • +
    +

    Set to true to suppress the UID/GID switching when running package +scripts. If set explicitly to false, then installing as a non-root user +will fail.

    +

    update-notifier

    +
      +
    • Default: true
    • +
    • Type: Boolean
    • +
    +

    Set to false to suppress the update notification when using an older +version of npm than the latest.

    +

    usage

    +
      +
    • Default: false
    • +
    • Type: Boolean
    • +
    +

    Set to show short usage output (like the -H output) +instead of complete help when doing npm help.

    +

    user

    +
      +
    • Default: "nobody"
    • +
    • Type: String or Number
    • +
    +

    The UID to set to when running package scripts as root.

    +

    userconfig

    +
      +
    • Default: ~/.npmrc
    • +
    • Type: path
    • +
    +

    The location of user-level configuration settings.

    +

    umask

    +
      +
    • Default: 022
    • +
    • Type: Octal numeric string in range 0000..0777 (0..511)
    • +
    +

    The "umask" value to use when setting the file creation mode on files +and folders.

    +

    Folders and executables are given a mode which is 0777 masked against +this value. Other files are given a mode which is 0666 masked against +this value. Thus, the defaults are 0755 and 0644 respectively.

    +

    user-agent

    +
      +
    • Default: node/{process.version} {process.platform} {process.arch}
    • +
    • Type: String
    • +
    +

    Sets a User-Agent to the request header

    +

    version

    +
      +
    • Default: false
    • +
    • Type: boolean
    • +
    +

    If true, output the npm version and exit successfully.

    +

    Only relevant when specified explicitly on the command line.

    +

    versions

    +
      +
    • Default: false
    • +
    • Type: boolean
    • +
    +

    If true, output the npm version as well as node's process.versions map, and +exit successfully.

    +

    Only relevant when specified explicitly on the command line.

    +

    viewer

    +
      +
    • Default: "man" on Posix, "browser" on Windows
    • +
    • Type: path
    • +
    +

    The program to use to view help content.

    +

    Set to "browser" to view html help content in the default web browser.

    +

    See also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/using-npm/developers/index.html b/deps/npm/docs/public/using-npm/developers/index.html new file mode 100644 index 00000000000000..c1a93d97d44cb2 --- /dev/null +++ b/deps/npm/docs/public/using-npm/developers/index.html @@ -0,0 +1,256 @@ +

    developers

    +

    Developer Guide

    +

    Description

    +

    So, you've decided to use npm to develop (and maybe publish/deploy) +your project.

    +

    Fantastic!

    +

    There are a few things that you need to do above the simple steps +that your users will do to install your program.

    +

    About These Documents

    +

    These are man pages. If you install npm, you should be able to +then do man npm-thing to get the documentation on a particular +topic, or npm help thing to see the same information.

    +

    What is a package

    +

    A package is:

    +
      +
    • a) a folder containing a program described by a package.json file
    • +
    • b) a gzipped tarball containing (a)
    • +
    • c) a url that resolves to (b)
    • +
    • d) a <name>@<version> that is published on the registry with (c)
    • +
    • e) a <name>@<tag> that points to (d)
    • +
    • f) a <name> that has a "latest" tag satisfying (e)
    • +
    • g) a git url that, when cloned, results in (a).
    • +
    +

    Even if you never publish your package, you can still get a lot of +benefits of using npm if you just want to write a node program (a), and +perhaps if you also want to be able to easily install it elsewhere +after packing it up into a tarball (b).

    +

    Git urls can be of the form:

    +
    git://github.com/user/project.git#commit-ish
    +git+ssh://user@hostname:project.git#commit-ish
    +git+http://user@hostname/project/blah.git#commit-ish
    +git+https://user@hostname/project/blah.git#commit-ish
    +

    The commit-ish can be any tag, sha, or branch which can be supplied as +an argument to git checkout. The default is master.

    +

    The package.json File

    +

    You need to have a package.json file in the root of your project to do +much of anything with npm. That is basically the whole interface.

    +

    See package.json for details about what goes in that file. At the very +least, you need:

    +
      +
    • +

      name: +This should be a string that identifies your project. Please do not +use the name to specify that it runs on node, or is in JavaScript. +You can use the "engines" field to explicitly state the versions of +node (or whatever else) that your program requires, and it's pretty +well assumed that it's JavaScript.

      +

      It does not necessarily need to match your github repository name.

      +

      So, node-foo and bar-js are bad names. foo or bar are better.

      +
    • +
    • version: +A semver-compatible version.
    • +
    • engines: +Specify the versions of node (or whatever else) that your program +runs on. The node API changes a lot, and there may be bugs or new +functionality that you depend on. Be explicit.
    • +
    • author: +Take some credit.
    • +
    • scripts: +If you have a special compilation or installation script, then you +should put it in the scripts object. You should definitely have at +least a basic smoke-test command as the "scripts.test" field. +See scripts.
    • +
    • main: +If you have a single module that serves as the entry point to your +program (like what the "foo" package gives you at require("foo")), +then you need to specify that in the "main" field.
    • +
    • directories: +This is an object mapping names to folders. The best ones to include are +"lib" and "doc", but if you use "man" to specify a folder full of man pages, +they'll get installed just like these ones.
    • +
    +

    You can use npm init in the root of your package in order to get you +started with a pretty basic package.json file. See npm init for +more info.

    +

    Keeping files out of your package

    +

    Use a .npmignore file to keep stuff out of your package. If there's +no .npmignore file, but there is a .gitignore file, then npm will +ignore the stuff matched by the .gitignore file. If you want to +include something that is excluded by your .gitignore file, you can +create an empty .npmignore file to override it. Like git, npm looks +for .npmignore and .gitignore files in all subdirectories of your +package, not only the root directory.

    +

    .npmignore files follow the same pattern rules +as .gitignore files:

    +
      +
    • Blank lines or lines starting with # are ignored.
    • +
    • Standard glob patterns work.
    • +
    • You can end patterns with a forward slash / to specify a directory.
    • +
    • You can negate a pattern by starting it with an exclamation point !.
    • +
    +

    By default, the following paths and files are ignored, so there's no +need to add them to .npmignore explicitly:

    +
      +
    • .*.swp
    • +
    • ._*
    • +
    • .DS_Store
    • +
    • .git
    • +
    • .hg
    • +
    • .npmrc
    • +
    • .lock-wscript
    • +
    • .svn
    • +
    • .wafpickle-*
    • +
    • config.gypi
    • +
    • CVS
    • +
    • npm-debug.log
    • +
    +

    Additionally, everything in node_modules is ignored, except for +bundled dependencies. npm automatically handles this for you, so don't +bother adding node_modules to .npmignore.

    +

    The following paths and files are never ignored, so adding them to +.npmignore is pointless:

    +
      +
    • package.json
    • +
    • README (and its variants)
    • +
    • CHANGELOG (and its variants)
    • +
    • LICENSE / LICENCE
    • +
    +

    If, given the structure of your project, you find .npmignore to be a +maintenance headache, you might instead try populating the files +property of package.json, which is an array of file or directory names +that should be included in your package. Sometimes a whitelist is easier +to manage than a blacklist.

    +

    Testing whether your .npmignore or files config works

    +

    If you want to double check that your package will include only the files +you intend it to when published, you can run the npm pack command locally +which will generate a tarball in the working directory, the same way it +does for publishing.

    + +

    npm link is designed to install a development package and see the +changes in real time without having to keep re-installing it. (You do +need to either re-link or npm rebuild -g to update compiled packages, +of course.)

    +

    More info at npm link.

    +

    Before Publishing: Make Sure Your Package Installs and Works

    +

    This is important.

    +

    If you can not install it locally, you'll have +problems trying to publish it. Or, worse yet, you'll be able to +publish it, but you'll be publishing a broken or pointless package. +So don't do that.

    +

    In the root of your package, do this:

    +
    npm install . -g
    +

    That'll show you that it's working. If you'd rather just create a symlink +package that points to your working directory, then do this:

    +
    npm link
    +

    Use npm ls -g to see if it's there.

    +

    To test a local install, go into some other folder, and then do:

    +
    cd ../some-other-folder
    +npm install ../my-package
    +

    to install it locally into the node_modules folder in that other place.

    +

    Then go into the node-repl, and try using require("my-thing") to +bring in your module's main module.

    +

    Create a User Account

    +

    Create a user with the adduser command. It works like this:

    +
    npm adduser
    +

    and then follow the prompts.

    +

    This is documented better in npm adduser.

    +

    Publish your package

    +

    This part's easy. In the root of your folder, do this:

    +
    npm publish
    +

    You can give publish a url to a tarball, or a filename of a tarball, +or a path to a folder.

    +

    Note that pretty much everything in that folder will be exposed +by default. So, if you have secret stuff in there, use a +.npmignore file to list out the globs to ignore, or publish +from a fresh checkout.

    +

    Brag about it

    +

    Send emails, write blogs, blab in IRC.

    +

    Tell the world how easy it is to install your program!

    +

    See also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/using-npm/disputes/index.html b/deps/npm/docs/public/using-npm/disputes/index.html new file mode 100644 index 00000000000000..facb5d7c51f957 --- /dev/null +++ b/deps/npm/docs/public/using-npm/disputes/index.html @@ -0,0 +1,189 @@ +

    disputes

    +

    Handling Module Name Disputes

    +

    This document describes the steps that you should take to resolve module name +disputes with other npm publishers. It also describes special steps you should +take about names you think infringe your trademarks.

    +

    This document is a clarification of the acceptable behavior outlined in the +npm Code of Conduct, and nothing in +this document should be interpreted to contradict any aspect of the npm Code of +Conduct.

    +

    TL;DR

    +
      +
    1. Get the author email with npm owner ls <pkgname>
    2. +
    3. Email the author, CC support@npmjs.com
    4. +
    5. After a few weeks, if there's no resolution, we'll sort it out.
    6. +
    +

    Don't squat on package names. Publish code or move out of the way.

    +

    Description

    +

    There sometimes arise cases where a user publishes a module, and then later, +some other user wants to use that name. Here are some common ways that happens +(each of these is based on actual events.)

    +
      +
    1. Alice writes a JavaScript module foo, which is not node-specific. Alice +doesn't use node at all. Yusuf wants to use foo in node, so he wraps it in +an npm module. Some time later, Alice starts using node, and wants to take +over management of her program.
    2. +
    3. Yusuf writes an npm module foo, and publishes it. Perhaps much later, Alice +finds a bug in foo, and fixes it. She sends a pull request to Yusuf, but +Yusuf doesn't have the time to deal with it, because he has a new job and a +new baby and is focused on his new Erlang project, and kind of not involved +with node any more. Alice would like to publish a new foo, but can't, +because the name is taken.
    4. +
    5. Yusuf writes a 10-line flow-control library, and calls it foo, and +publishes it to the npm registry. Being a simple little thing, it never +really has to be updated. Alice works for Foo Inc, the makers of the +critically acclaimed and widely-marketed foo JavaScript toolkit framework. +They publish it to npm as foojs, but people are routinely confused when +npm install foo is some different thing.
    6. +
    7. Yusuf writes a parser for the widely-known foo file format, because he +needs it for work. Then, he gets a new job, and never updates the prototype. +Later on, Alice writes a much more complete foo parser, but can't publish, +because Yusuf's foo is in the way.
    8. +
    9. npm owner ls foo. This will tell Alice the email address of the owner +(Yusuf).
    10. +
    11. Alice emails Yusuf, explaining the situation as respectfully as possible, +and what she would like to do with the module name. She adds the npm support +staff support@npmjs.com to the CC list of the email. Mention in the email +that Yusuf can run npm owner add alice foo to add Alice as an owner of the +foo package.
    12. +
    13. After a reasonable amount of time, if Yusuf has not responded, or if Yusuf +and Alice can't come to any sort of resolution, email support +support@npmjs.com and we'll sort it out. ("Reasonable" is usually at least +4 weeks.)
    14. +
    +

    Reasoning

    +

    In almost every case so far, the parties involved have been able to reach an +amicable resolution without any major intervention. Most people really do want +to be reasonable, and are probably not even aware that they're in your way.

    +

    Module ecosystems are most vibrant and powerful when they are as self-directed +as possible. If an admin one day deletes something you had worked on, then that +is going to make most people quite upset, regardless of the justification. When +humans solve their problems by talking to other humans with respect, everyone +has the chance to end up feeling good about the interaction.

    +

    Exceptions

    +

    Some things are not allowed, and will be removed without discussion if they are +brought to the attention of the npm registry admins, including but not limited +to:

    +
      +
    1. Malware (that is, a package designed to exploit or harm the machine on which +it is installed).
    2. +
    3. Violations of copyright or licenses (for example, cloning an MIT-licensed +program, and then removing or changing the copyright and license statement).
    4. +
    5. Illegal content.
    6. +
    7. "Squatting" on a package name that you plan to use, but aren't actually +using. Sorry, I don't care how great the name is, or how perfect a fit it is +for the thing that someday might happen. If someone wants to use it today, +and you're just taking up space with an empty tarball, you're going to be +evicted.
    8. +
    9. Putting empty packages in the registry. Packages must have SOME +functionality. It can be silly, but it can't be nothing. (See also: +squatting.)
    10. +
    11. Doing weird things with the registry, like using it as your own personal +application database or otherwise putting non-packagey things into it.
    12. +
    13. Other things forbidden by the npm +Code of Conduct such as hateful +language, pornographic content, or harassment.
    14. +
    +

    If you see bad behavior like this, please report it to abuse@npmjs.com right +away. You are never expected to resolve abusive behavior on your own. We are +here to help.

    +

    Trademarkss

    +

    If you think another npm publisher is infringing your trademark, such as by +using a confusingly similar package name, email abuse@npmjs.com with a link to +the package or user account on https://www.npmjs.com/. +Attach a copy of your trademark registration certificate.

    +

    If we see that the package's publisher is intentionally misleading others by +misusing your registered mark without permission, we will transfer the package +name to you. Otherwise, we will contact the package publisher and ask them to +clear up any confusion with changes to their package's README file or +metadata.

    +

    Changes

    +

    This is a living document and may be updated from time to time. Please refer to +the git history for this document +to view the changes.

    +

    License

    +

    Copyright (C) npm, Inc., All rights reserved

    +

    This document may be reused under a Creative Commons Attribution-ShareAlike +License.

    +

    See also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/using-npm/orgs/index.html b/deps/npm/docs/public/using-npm/orgs/index.html new file mode 100644 index 00000000000000..72fedfb33fcfba --- /dev/null +++ b/deps/npm/docs/public/using-npm/orgs/index.html @@ -0,0 +1,141 @@ +

    orgs

    +

    Working with Teams & Orgs

    +

    Description

    +

    There are three levels of org users:

    +
      +
    1. Super admin, controls billing & adding people to the org.
    2. +
    3. Team admin, manages team membership & package access.
    4. +
    5. Developer, works on packages they are given access to.
    6. +
    +

    The super admin is the only person who can add users to the org because it impacts the monthly bill. The super admin will use the website to manage membership. Every org has a developers team that all users are automatically added to.

    +

    The team admin is the person who manages team creation, team membership, and package access for teams. The team admin grants package access to teams, not individuals.

    +

    The developer will be able to access packages based on the teams they are on. Access is either read-write or read-only.

    +

    There are two main commands:

    +
      +
    1. npm team see npm team for more details
    2. +
    3. npm access see npm access for more details
    4. +
    +

    Team Admins create teams

    +
      +
    • Check who you’ve added to your org:
    • +
    +
    npm team ls <org>:developers
    +
      +
    • Each org is automatically given a developers team, so you can see the whole list of team members in your org. This team automatically gets read-write access to all packages, but you can change that with the access command.
    • +
    • Create a new team:
    • +
    +
    npm team create <org:team>
    +
      +
    • Add members to that team:
    • +
    +
    npm team add <org:team> <user>
    +

    Publish a package and adjust package access

    +
      +
    • In package directory, run
    • +
    +
    npm init --scope=<org>
    +

    to scope it for your org & publish as usual

    +
      +
    • Grant access:
    • +
    +
    npm access grant <read-only|read-write> <org:team> [<package>]
    +
      +
    • Revoke access:
    • +
    +
    npm access revoke <org:team> [<package>]
    +

    Monitor your package access

    +
      +
    • See what org packages a team member can access:
    • +
    +
    npm access ls-packages <org> <user>
    +
      +
    • See packages available to a specific team:
    • +
    +
    npm access ls-packages <org:team>
    +
      +
    • Check which teams are collaborating on a package:
    • +
    +
    npm access ls-collaborators <pkg>
    +

    See also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/using-npm/registry/index.html b/deps/npm/docs/public/using-npm/registry/index.html new file mode 100644 index 00000000000000..d6bdb097a6cc67 --- /dev/null +++ b/deps/npm/docs/public/using-npm/registry/index.html @@ -0,0 +1,153 @@ +

    registry

    +

    The JavaScript Package Registry

    +

    Description

    +

    To resolve packages by name and version, npm talks to a registry website +that implements the CommonJS Package Registry specification for reading +package info.

    +

    npm is configured to use npm, Inc.'s public registry at +https://registry.npmjs.org by default. Use of the npm public registry is +subject to terms of use available at https://www.npmjs.com/policies/terms.

    +

    You can configure npm to use any compatible registry you like, and even run +your own registry. Use of someone else's registry may be governed by their +terms of use.

    +

    npm's package registry implementation supports several +write APIs as well, to allow for publishing packages and managing user +account information.

    +

    The npm public registry is powered by a CouchDB database, +of which there is a public mirror at +https://skimdb.npmjs.com/registry. The code for the couchapp is +available at https://github.com/npm/npm-registry-couchapp.

    +

    The registry URL used is determined by the scope of the package (see +scope. If no scope is specified, the default registry is used, which is +supplied by the registry config parameter. See npm config, +npmrc, and config for more on managing npm's configuration.

    +

    Does npm send any information about me back to the registry?

    +

    Yes.

    +

    When making requests of the registry npm adds two headers with information +about your environment:

    +
      +
    • Npm-Scope – If your project is scoped, this header will contain its +scope. In the future npm hopes to build registry features that use this +information to allow you to customize your experience for your +organization.
    • +
    • Npm-In-CI – Set to "true" if npm believes this install is running in a +continuous integration environment, "false" otherwise. This is detected by +looking for the following environment variables: CI, TDDIUM, +JENKINS_URL, bamboo.buildKey. If you'd like to learn more you may find +the original PR +interesting. +This is used to gather better metrics on how npm is used by humans, versus +build farms.
    • +
    +

    The npm registry does not try to correlate the information in these headers +with any authenticated accounts that may be used in the same requests.

    +

    Can I run my own private registry?

    +

    Yes!

    +

    The easiest way is to replicate the couch database, and use the same (or +similar) design doc to implement the APIs.

    +

    If you set up continuous replication from the official CouchDB, and then +set your internal CouchDB as the registry config, then you'll be able +to read any published packages, in addition to your private ones, and by +default will only publish internally.

    +

    If you then want to publish a package for the whole world to see, you can +simply override the --registry option for that publish command.

    +

    I don't want my package published in the official registry. It's private.

    +

    Set "private": true in your package.json to prevent it from being +published at all, or +"publishConfig":{"registry":"http://my-internal-registry.local"} +to force it to be published only to your internal registry.

    +

    See package.json for more info on what goes in the package.json file.

    +

    Will you replicate from my registry into the public one?

    +

    No. If you want things to be public, then publish them into the public +registry using npm. What little security there is would be for nought +otherwise.

    +

    Do I have to use couchdb to build a registry that npm can talk to?

    +

    No, but it's way easier. Basically, yes, you do, or you have to +effectively implement the entire CouchDB API anyway.

    +

    Is there a website or something to see package docs and such?

    +

    Yes, head over to https://www.npmjs.com/

    +

    See also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/using-npm/removal/index.html b/deps/npm/docs/public/using-npm/removal/index.html new file mode 100644 index 00000000000000..d75978c0b72b08 --- /dev/null +++ b/deps/npm/docs/public/using-npm/removal/index.html @@ -0,0 +1,113 @@ +

    removal

    +

    Cleaning the Slate

    +

    Synopsis

    +

    So sad to see you go.

    +
    sudo npm uninstall npm -g
    +

    Or, if that fails, get the npm source code, and do:

    +
    sudo make uninstall
    +

    More Severe Uninstalling

    +

    Usually, the above instructions are sufficient. That will remove +npm, but leave behind anything you've installed.

    +

    If that doesn't work, or if you require more drastic measures, +continue reading.

    +

    Note that this is only necessary for globally-installed packages. Local +installs are completely contained within a project's node_modules +folder. Delete that folder, and everything is gone less a package's +install script is particularly ill-behaved).

    +

    This assumes that you installed node and npm in the default place. If +you configured node with a different --prefix, or installed npm with a +different prefix setting, then adjust the paths accordingly, replacing +/usr/local with your install prefix.

    +

    To remove everything npm-related manually:

    +
    rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/npm*
    +

    If you installed things with npm, then your best bet is to uninstall +them with npm first, and then install them again once you have a +proper install. This can help find any symlinks that are lying +around:

    +
    ls -laF /usr/local/{lib/node{,/.npm},bin,share/man} | grep npm
    +

    Prior to version 0.3, npm used shim files for executables and node +modules. To track those down, you can do the following:

    +
    find /usr/local/{lib/node,bin} -exec grep -l npm \{\} \; ;
    +

    (This is also in the README file.)

    +

    See also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/using-npm/scope/index.html b/deps/npm/docs/public/using-npm/scope/index.html new file mode 100644 index 00000000000000..ab6ddaac128813 --- /dev/null +++ b/deps/npm/docs/public/using-npm/scope/index.html @@ -0,0 +1,156 @@ +

    scope

    +

    Scoped packages

    +

    Description

    +

    All npm packages have a name. Some package names also have a scope. A scope +follows the usual rules for package names (URL-safe characters, no leading dots +or underscores). When used in package names, scopes are preceded by an @ symbol +and followed by a slash, e.g.

    +
    @somescope/somepackagename
    +

    Scopes are a way of grouping related packages together, and also affect a few +things about the way npm treats the package.

    +

    Each npm user/organization has their own scope, and only you can add packages +in your scope. This means you don't have to worry about someone taking your +package name ahead of you. Thus it is also a good way to signal official packages +for organizations.

    +

    Scoped packages can be published and installed as of npm@2 and are supported +by the primary npm registry. Unscoped packages can depend on scoped packages and +vice versa. The npm client is backwards-compatible with unscoped registries, +so it can be used to work with scoped and unscoped registries at the same time.

    +

    Installing scoped packages

    +

    Scoped packages are installed to a sub-folder of the regular installation +folder, e.g. if your other packages are installed in node_modules/packagename, +scoped modules will be installed in node_modules/@myorg/packagename. The scope +folder (@myorg) is simply the name of the scope preceded by an @ symbol, and can +contain any number of scoped packages.

    +

    A scoped package is installed by referencing it by name, preceded by an +@ symbol, in npm install:

    +
    npm install @myorg/mypackage
    +

    Or in package.json:

    +
    "dependencies": {
    +  "@myorg/mypackage": "^1.3.0"
    +}
    +

    Note that if the @ symbol is omitted, in either case, npm will instead attempt to +install from GitHub; see npm install.

    +

    Requiring scoped packages

    +

    Because scoped packages are installed into a scope folder, you have to +include the name of the scope when requiring them in your code, e.g.

    +
    require('@myorg/mypackage')
    +

    There is nothing special about the way Node treats scope folders. This +simply requires the mypackage module in the folder named @myorg.

    +

    Publishing scoped packages

    +

    Scoped packages can be published from the CLI as of npm@2 and can be +published to any registry that supports them, including the primary npm +registry.

    +

    (As of 2015-04-19, and with npm 2.0 or better, the primary npm registry +does support scoped packages.)

    +

    If you wish, you may associate a scope with a registry; see below.

    +

    Publishing public scoped packages to the primary npm registry

    +

    To publish a public scoped package, you must specify --access public with +the initial publication. This will publish the package and set access +to public as if you had run npm access public after publishing.

    +

    Publishing private scoped packages to the npm registry

    +

    To publish a private scoped package to the npm registry, you must have +an npm Private Modules +account.

    +

    You can then publish the module with npm publish or npm publish +--access restricted, and it will be present in the npm registry, with +restricted access. You can then change the access permissions, if +desired, with npm access or on the npmjs.com website.

    +

    Associating a scope with a registry

    +

    Scopes can be associated with a separate registry. This allows you to +seamlessly use a mix of packages from the primary npm registry and one or more +private registries, such as npm Enterprise.

    +

    You can associate a scope with a registry at login, e.g.

    +
    npm login --registry=http://reg.example.com --scope=@myco
    +

    Scopes have a many-to-one relationship with registries: one registry can +host multiple scopes, but a scope only ever points to one registry.

    +

    You can also associate a scope with a registry using npm config:

    +
    npm config set @myco:registry http://reg.example.com
    +

    Once a scope is associated with a registry, any npm install for a package +with that scope will request packages from that registry instead. Any +npm publish for a package name that contains the scope will be published to +that registry instead.

    +

    See also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/using-npm/scripts/index.html b/deps/npm/docs/public/using-npm/scripts/index.html new file mode 100644 index 00000000000000..f08811cc7d268b --- /dev/null +++ b/deps/npm/docs/public/using-npm/scripts/index.html @@ -0,0 +1,300 @@ +

    scripts

    +

    How npm handles the "scripts" field

    +

    Description

    +

    npm supports the "scripts" property of the package.json file, for the +following scripts:

    +
      +
    • prepublish (as of npm@5, prepublish is deprecated. Use prepare for build steps and prepublishOnly for upload-only.): +Run BEFORE the package is packed and published, as well as on local npm +install without any arguments. (See below)
    • +
    • prepare: +Run both BEFORE the package is packed and published, on local npm +install without any arguments, and when installing git dependencies (See +below). This is run AFTER prepublish, but BEFORE prepublishOnly.
    • +
    • prepublishOnly: +Run BEFORE the package is prepared and packed, ONLY on npm publish. (See +below.)
    • +
    • prepack: +run BEFORE a tarball is packed (on npm pack, npm publish, and when +installing git dependencies)
    • +
    • postpack: +Run AFTER the tarball has been generated and moved to its final destination.
    • +
    • publish, postpublish: +Run AFTER the package is published.
    • +
    • preinstall: +Run BEFORE the package is installed
    • +
    • install, postinstall: +Run AFTER the package is installed.
    • +
    • preuninstall, uninstall: +Run BEFORE the package is uninstalled.
    • +
    • postuninstall: +Run AFTER the package is uninstalled.
    • +
    • preversion: +Run BEFORE bumping the package version.
    • +
    • version: +Run AFTER bumping the package version, but BEFORE commit.
    • +
    • postversion: +Run AFTER bumping the package version, and AFTER commit.
    • +
    • pretest, test, posttest: +Run by the npm test command.
    • +
    • prestop, stop, poststop: +Run by the npm stop command.
    • +
    • prestart, start, poststart: +Run by the npm start command.
    • +
    • prerestart, restart, postrestart: +Run by the npm restart command. Note: npm restart will run the +stop and start scripts if no restart script is provided.
    • +
    • preshrinkwrap, shrinkwrap, postshrinkwrap: +Run by the npm shrinkwrap command.
    • +
    +

    Additionally, arbitrary scripts can be executed by running npm +run-script <stage>. Pre and post commands with matching +names will be run for those as well (e.g. premyscript, myscript, +postmyscript). Scripts from dependencies can be run with +npm explore <pkg> -- npm run <stage>.

    +

    Prepublish and Prepare

    +

    Deprecation Note

    +

    Since npm@1.1.71, the npm CLI has run the prepublish script for both npm +publish and npm install, because it's a convenient way to prepare a package +for use (some common use cases are described in the section below). It has +also turned out to be, in practice, very +confusing. As of npm@4.0.0, a new +event has been introduced, prepare, that preserves this existing behavior. A +new event, prepublishOnly has been added as a transitional strategy to +allow users to avoid the confusing behavior of existing npm versions and only +run on npm publish (for instance, running the tests one last time to ensure +they're in good shape).

    +

    See https://github.com/npm/npm/issues/10074 for a much lengthier +justification, with further reading, for this change.

    +

    Use Cases

    +

    If you need to perform operations on your package before it is used, in a way +that is not dependent on the operating system or architecture of the +target system, use a prepublish script. This includes +tasks such as:

    +
      +
    • Compiling CoffeeScript source code into JavaScript.
    • +
    • Creating minified versions of JavaScript source code.
    • +
    • Fetching remote resources that your package will use.
    • +
    +

    The advantage of doing these things at prepublish time is that they can be done once, in a +single place, thus reducing complexity and variability. +Additionally, this means that:

    +
      +
    • You can depend on coffee-script as a devDependency, and thus +your users don't need to have it installed.
    • +
    • You don't need to include minifiers in your package, reducing +the size for your users.
    • +
    • You don't need to rely on your users having curl or wget or +other system tools on the target machines.
    • +
    +

    Default Values

    +

    npm will default some script values based on package contents.

    +
      +
    • +

      "start": "node server.js":

      +

      If there is a server.js file in the root of your package, then npm +will default the start command to node server.js.

      +
    • +
    • +

      "install": "node-gyp rebuild":

      +

      If there is a binding.gyp file in the root of your package and you +haven't defined your own install or preinstall scripts, npm will +default the install command to compile using node-gyp.

      +
    • +
    +

    User

    +

    If npm was invoked with root privileges, then it will change the uid +to the user account or uid specified by the user config, which +defaults to nobody. Set the unsafe-perm flag to run scripts with +root privileges.

    +

    Environment

    +

    Package scripts run in an environment where many pieces of information +are made available regarding the setup of npm and the current state of +the process.

    +

    path

    +

    If you depend on modules that define executable scripts, like test +suites, then those executables will be added to the PATH for +executing the scripts. So, if your package.json has this:

    +
    { "name" : "foo"
    +, "dependencies" : { "bar" : "0.1.x" }
    +, "scripts": { "start" : "bar ./test" } }
    +

    then you could run npm start to execute the bar script, which is +exported into the node_modules/.bin directory on npm install.

    +

    package.json vars

    +

    The package.json fields are tacked onto the npm_package_ prefix. So, +for instance, if you had {"name":"foo", "version":"1.2.5"} in your +package.json file, then your package scripts would have the +npm_package_name environment variable set to "foo", and the +npm_package_version set to "1.2.5". You can access these variables +in your code with process.env.npm_package_name and +process.env.npm_package_version, and so on for other fields.

    +

    configuration

    +

    Configuration parameters are put in the environment with the +npm_config_ prefix. For instance, you can view the effective root +config by checking the npm_config_root environment variable.

    +

    Special: package.json "config" object

    +

    The package.json "config" keys are overwritten in the environment if +there is a config param of <name>[@<version>]:<key>. For example, +if the package.json has this:

    +
    { "name" : "foo"
    +, "config" : { "port" : "8080" }
    +, "scripts" : { "start" : "node server.js" } }
    +

    and the server.js is this:

    +
    http.createServer(...).listen(process.env.npm_package_config_port)
    +

    then the user could change the behavior by doing:

    +
      npm config set foo:port 80
    +

    current lifecycle event

    +

    Lastly, the npm_lifecycle_event environment variable is set to +whichever stage of the cycle is being executed. So, you could have a +single script used for different parts of the process which switches +based on what's currently happening.

    +

    Objects are flattened following this format, so if you had +{"scripts":{"install":"foo.js"}} in your package.json, then you'd +see this in the script:

    +
    process.env.npm_package_scripts_install === "foo.js"
    +

    Examples

    +

    For example, if your package.json contains this:

    +
    { "scripts" :
    +  { "install" : "scripts/install.js"
    +  , "postinstall" : "scripts/install.js"
    +  , "uninstall" : "scripts/uninstall.js"
    +  }
    +}
    +

    then scripts/install.js will be called for the install +and post-install stages of the lifecycle, and scripts/uninstall.js +will be called when the package is uninstalled. Since +scripts/install.js is running for two different phases, it would +be wise in this case to look at the npm_lifecycle_event environment +variable.

    +

    If you want to run a make command, you can do so. This works just +fine:

    +
    { "scripts" :
    +  { "preinstall" : "./configure"
    +  , "install" : "make && make install"
    +  , "test" : "make test"
    +  }
    +}
    +

    Exiting

    +

    Scripts are run by passing the line as a script argument to sh.

    +

    If the script exits with a code other than 0, then this will abort the +process.

    +

    Note that these script files don't have to be nodejs or even +javascript programs. They just have to be some kind of executable +file.

    +

    Hook Scripts

    +

    If you want to run a specific script at a specific lifecycle event for +ALL packages, then you can use a hook script.

    +

    Place an executable file at node_modules/.hooks/{eventname}, and +it'll get run for all packages when they are going through that point +in the package lifecycle for any packages installed in that root.

    +

    Hook scripts are run exactly the same way as package.json scripts. +That is, they are in a separate child process, with the env described +above.

    +

    Best Practices

    +
      +
    • Don't exit with a non-zero error code unless you really mean it. +Except for uninstall scripts, this will cause the npm action to +fail, and potentially be rolled back. If the failure is minor or +only will prevent some optional features, then it's better to just +print a warning and exit successfully.
    • +
    • Try not to use scripts to do what npm can do for you. Read through +package.json to see all the things that you can specify and enable +by simply describing your package appropriately. In general, this +will lead to a more robust and consistent state.
    • +
    • Inspect the env to determine where to put things. For instance, if +the npm_config_binroot environment variable is set to /home/user/bin, then +don't try to install executables into /usr/local/bin. The user +probably set it up that way for a reason.
    • +
    • Don't prefix your script commands with "sudo". If root permissions +are required for some reason, then it'll fail with that error, and +the user will sudo the npm command in question.
    • +
    • Don't use install. Use a .gyp file for compilation, and prepublish +for anything else. You should almost never have to explicitly set a +preinstall or install script. If you are doing this, please consider if +there is another option. The only valid use of install or preinstall +scripts is for compilation which must be done on the target architecture.
    • +
    +

    See Also

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/docs/public/using-npm/semver/index.html b/deps/npm/docs/public/using-npm/semver/index.html new file mode 100644 index 00000000000000..d1bd745a08ea89 --- /dev/null +++ b/deps/npm/docs/public/using-npm/semver/index.html @@ -0,0 +1,432 @@ +

    semver(7) -- The semantic versioner for npm

    +

    Install

    +
    npm install --save semver
    +

    Usage

    +

    As a node module:

    +
    const semver = require('semver')
    +
    +semver.valid('1.2.3') // '1.2.3'
    +semver.valid('a.b.c') // null
    +semver.clean('  =v1.2.3   ') // '1.2.3'
    +semver.satisfies('1.2.3', '1.x || >=2.5.0 || 5.0.0 - 7.2.3') // true
    +semver.gt('1.2.3', '9.8.7') // false
    +semver.lt('1.2.3', '9.8.7') // true
    +semver.minVersion('>=1.0.0') // '1.0.0'
    +semver.valid(semver.coerce('v2')) // '2.0.0'
    +semver.valid(semver.coerce('42.6.7.9.3-alpha')) // '42.6.7'
    +

    As a command-line utility:

    +
    $ semver -h
    +
    +A JavaScript implementation of the https://semver.org/ specification
    +Copyright Isaac Z. Schlueter
    +
    +Usage: semver [options] <version> [<version> [...]]
    +Prints valid versions sorted by SemVer precedence
    +
    +Options:
    +-r --range <range>
    +        Print versions that match the specified range.
    +
    +-i --increment [<level>]
    +        Increment a version by the specified level.  Level can
    +        be one of: major, minor, patch, premajor, preminor,
    +        prepatch, or prerelease.  Default level is 'patch'.
    +        Only one version may be specified.
    +
    +--preid <identifier>
    +        Identifier to be used to prefix premajor, preminor,
    +        prepatch or prerelease version increments.
    +
    +-l --loose
    +        Interpret versions and ranges loosely
    +
    +-p --include-prerelease
    +        Always include prerelease versions in range matching
    +
    +-c --coerce
    +        Coerce a string into SemVer if possible
    +        (does not imply --loose)
    +
    +Program exits successfully if any valid version satisfies
    +all supplied ranges, and prints all satisfying versions.
    +
    +If no satisfying versions are found, then exits failure.
    +
    +Versions are printed in ascending order, so supplying
    +multiple versions to the utility will just sort them.
    +

    Versions

    +

    A "version" is described by the v2.0.0 specification found at +https://semver.org/.

    +

    A leading "=" or "v" character is stripped off and ignored.

    +

    Ranges

    +

    A version range is a set of comparators which specify versions +that satisfy the range.

    +

    A comparator is composed of an operator and a version. The set +of primitive operators is:

    +
      +
    • < Less than
    • +
    • <= Less than or equal to
    • +
    • > Greater than
    • +
    • >= Greater than or equal to
    • +
    • = Equal. If no operator is specified, then equality is assumed, +so this operator is optional, but MAY be included.
    • +
    +

    For example, the comparator >=1.2.7 would match the versions +1.2.7, 1.2.8, 2.5.3, and 1.3.9, but not the versions 1.2.6 +or 1.1.0.

    +

    Comparators can be joined by whitespace to form a comparator set, +which is satisfied by the intersection of all of the comparators +it includes.

    +

    A range is composed of one or more comparator sets, joined by ||. A +version matches a range if and only if every comparator in at least +one of the ||-separated comparator sets is satisfied by the version.

    +

    For example, the range >=1.2.7 <1.3.0 would match the versions +1.2.7, 1.2.8, and 1.2.99, but not the versions 1.2.6, 1.3.0, +or 1.1.0.

    +

    The range 1.2.7 || >=1.2.9 <2.0.0 would match the versions 1.2.7, +1.2.9, and 1.4.6, but not the versions 1.2.8 or 2.0.0.

    +

    Prerelease Tags

    +

    If a version has a prerelease tag (for example, 1.2.3-alpha.3) then +it will only be allowed to satisfy comparator sets if at least one +comparator with the same [major, minor, patch] tuple also has a +prerelease tag.

    +

    For example, the range >1.2.3-alpha.3 would be allowed to match the +version 1.2.3-alpha.7, but it would not be satisfied by +3.4.5-alpha.9, even though 3.4.5-alpha.9 is technically "greater +than" 1.2.3-alpha.3 according to the SemVer sort rules. The version +range only accepts prerelease tags on the 1.2.3 version. The +version 3.4.5 would satisfy the range, because it does not have a +prerelease flag, and 3.4.5 is greater than 1.2.3-alpha.7.

    +

    The purpose for this behavior is twofold. First, prerelease versions +frequently are updated very quickly, and contain many breaking changes +that are (by the author's design) not yet fit for public consumption. +Therefore, by default, they are excluded from range matching +semantics.

    +

    Second, a user who has opted into using a prerelease version has +clearly indicated the intent to use that specific set of +alpha/beta/rc versions. By including a prerelease tag in the range, +the user is indicating that they are aware of the risk. However, it +is still not appropriate to assume that they have opted into taking a +similar risk on the next set of prerelease versions.

    +

    Note that this behavior can be suppressed (treating all prerelease +versions as if they were normal versions, for the purpose of range +matching) by setting the includePrerelease flag on the options +object to any +functions that do +range matching.

    +

    Prerelease Identifiers

    +

    The method .inc takes an additional identifier string argument that +will append the value of the string as a prerelease identifier:

    +
    semver.inc('1.2.3', 'prerelease', 'beta')
    +// '1.2.4-beta.0'
    +

    command-line example:

    +
    $ semver 1.2.3 -i prerelease --preid beta
    +1.2.4-beta.0
    +

    Which then can be used to increment further:

    +
    $ semver 1.2.4-beta.0 -i prerelease
    +1.2.4-beta.1
    +

    Advanced Range Syntax

    +

    Advanced range syntax desugars to primitive comparators in +deterministic ways.

    +

    Advanced ranges may be combined in the same way as primitive +comparators using white space or ||.

    +

    Hyphen Ranges X.Y.Z - A.B.C

    +

    Specifies an inclusive set.

    +
      +
    • 1.2.3 - 2.3.4 := >=1.2.3 <=2.3.4
    • +
    +

    If a partial version is provided as the first version in the inclusive +range, then the missing pieces are replaced with zeroes.

    +
      +
    • 1.2 - 2.3.4 := >=1.2.0 <=2.3.4
    • +
    +

    If a partial version is provided as the second version in the +inclusive range, then all versions that start with the supplied parts +of the tuple are accepted, but nothing that would be greater than the +provided tuple parts.

    +
      +
    • 1.2.3 - 2.3 := >=1.2.3 <2.4.0
    • +
    • 1.2.3 - 2 := >=1.2.3 <3.0.0
    • +
    +

    X-Ranges 1.2.x 1.X 1.2.* *

    +

    Any of X, x, or * may be used to "stand in" for one of the +numeric values in the [major, minor, patch] tuple.

    +
      +
    • * := >=0.0.0 (Any version satisfies)
    • +
    • 1.x := >=1.0.0 <2.0.0 (Matching major version)
    • +
    • 1.2.x := >=1.2.0 <1.3.0 (Matching major and minor versions)
    • +
    +

    A partial version range is treated as an X-Range, so the special +character is in fact optional.

    +
      +
    • "" (empty string) := * := >=0.0.0
    • +
    • 1 := 1.x.x := >=1.0.0 <2.0.0
    • +
    • 1.2 := 1.2.x := >=1.2.0 <1.3.0
    • +
    +

    Tilde Ranges ~1.2.3 ~1.2 ~1

    +

    Allows patch-level changes if a minor version is specified on the +comparator. Allows minor-level changes if not.

    +
      +
    • ~1.2.3 := >=1.2.3 <1.(2+1).0 := >=1.2.3 <1.3.0
    • +
    • ~1.2 := >=1.2.0 <1.(2+1).0 := >=1.2.0 <1.3.0 (Same as 1.2.x)
    • +
    • ~1 := >=1.0.0 <(1+1).0.0 := >=1.0.0 <2.0.0 (Same as 1.x)
    • +
    • ~0.2.3 := >=0.2.3 <0.(2+1).0 := >=0.2.3 <0.3.0
    • +
    • ~0.2 := >=0.2.0 <0.(2+1).0 := >=0.2.0 <0.3.0 (Same as 0.2.x)
    • +
    • ~0 := >=0.0.0 <(0+1).0.0 := >=0.0.0 <1.0.0 (Same as 0.x)
    • +
    • ~1.2.3-beta.2 := >=1.2.3-beta.2 <1.3.0 Note that prereleases in +the 1.2.3 version will be allowed, if they are greater than or +equal to beta.2. So, 1.2.3-beta.4 would be allowed, but +1.2.4-beta.2 would not, because it is a prerelease of a +different [major, minor, patch] tuple.
    • +
    +

    Caret Ranges ^1.2.3 ^0.2.5 ^0.0.4

    +

    Allows changes that do not modify the left-most non-zero digit in the +[major, minor, patch] tuple. In other words, this allows patch and +minor updates for versions 1.0.0 and above, patch updates for +versions 0.X >=0.1.0, and no updates for versions 0.0.X.

    +

    Many authors treat a 0.x version as if the x were the major +"breaking-change" indicator.

    +

    Caret ranges are ideal when an author may make breaking changes +between 0.2.4 and 0.3.0 releases, which is a common practice. +However, it presumes that there will not be breaking changes between +0.2.4 and 0.2.5. It allows for changes that are presumed to be +additive (but non-breaking), according to commonly observed practices.

    +
      +
    • ^1.2.3 := >=1.2.3 <2.0.0
    • +
    • ^0.2.3 := >=0.2.3 <0.3.0
    • +
    • ^0.0.3 := >=0.0.3 <0.0.4
    • +
    • ^1.2.3-beta.2 := >=1.2.3-beta.2 <2.0.0 Note that prereleases in +the 1.2.3 version will be allowed, if they are greater than or +equal to beta.2. So, 1.2.3-beta.4 would be allowed, but +1.2.4-beta.2 would not, because it is a prerelease of a +different [major, minor, patch] tuple.
    • +
    • ^0.0.3-beta := >=0.0.3-beta <0.0.4 Note that prereleases in the +0.0.3 version only will be allowed, if they are greater than or +equal to beta. So, 0.0.3-pr.2 would be allowed.
    • +
    +

    When parsing caret ranges, a missing patch value desugars to the +number 0, but will allow flexibility within that value, even if the +major and minor versions are both 0.

    +
      +
    • ^1.2.x := >=1.2.0 <2.0.0
    • +
    • ^0.0.x := >=0.0.0 <0.1.0
    • +
    • ^0.0 := >=0.0.0 <0.1.0
    • +
    +

    A missing minor and patch values will desugar to zero, but also +allow flexibility within those values, even if the major version is +zero.

    +
      +
    • ^1.x := >=1.0.0 <2.0.0
    • +
    • ^0.x := >=0.0.0 <1.0.0
    • +
    +

    Range Grammar

    +

    Putting all this together, here is a Backus-Naur grammar for ranges, +for the benefit of parser authors:

    +
    range-set  ::= range ( logical-or range ) *
    +logical-or ::= ( ' ' ) * '||' ( ' ' ) *
    +range      ::= hyphen | simple ( ' ' simple ) * | ''
    +hyphen     ::= partial ' - ' partial
    +simple     ::= primitive | partial | tilde | caret
    +primitive  ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial
    +partial    ::= xr ( '.' xr ( '.' xr qualifier ? )? )?
    +xr         ::= 'x' | 'X' | '*' | nr
    +nr         ::= '0' | ['1'-'9'] ( ['0'-'9'] ) *
    +tilde      ::= '~' partial
    +caret      ::= '^' partial
    +qualifier  ::= ( '-' pre )? ( '+' build )?
    +pre        ::= parts
    +build      ::= parts
    +parts      ::= part ( '.' part ) *
    +part       ::= nr | [-0-9A-Za-z]+
    +

    Functions

    +

    All methods and classes take a final options object argument. All +options in this object are false by default. The options supported +are:

    +
      +
    • loose Be more forgiving about not-quite-valid semver strings. +(Any resulting output will always be 100% strict compliant, of +course.) For backwards compatibility reasons, if the options +argument is a boolean value instead of an object, it is interpreted +to be the loose param.
    • +
    • includePrerelease Set to suppress the default +behavior of +excluding prerelease tagged versions from ranges unless they are +explicitly opted into.
    • +
    +

    Strict-mode Comparators and Ranges will be strict about the SemVer +strings that they parse.

    +
      +
    • valid(v): Return the parsed version, or null if it's not valid.
    • +
    • +

      inc(v, release): Return the version incremented by the release +type (major, premajor, minor, preminor, patch, +prepatch, or prerelease), or null if it's not valid

      +
        +
      • premajor in one call will bump the version up to the next major +version and down to a prerelease of that major version. +preminor, and prepatch work the same way.
      • +
      • If called from a non-prerelease version, the prerelease will work the +same as prepatch. It increments the patch version, then makes a +prerelease. If the input version is already a prerelease it simply +increments it.
      • +
      +
    • +
    • prerelease(v): Returns an array of prerelease components, or null +if none exist. Example: prerelease('1.2.3-alpha.1') -> ['alpha', 1]
    • +
    • major(v): Return the major version number.
    • +
    • minor(v): Return the minor version number.
    • +
    • patch(v): Return the patch version number.
    • +
    • intersects(r1, r2, loose): Return true if the two supplied ranges +or comparators intersect.
    • +
    • parse(v): Attempt to parse a string as a semantic version, returning either +a SemVer object or null.
    • +
    +

    Comparison

    +
      +
    • gt(v1, v2): v1 > v2
    • +
    • gte(v1, v2): v1 >= v2
    • +
    • lt(v1, v2): v1 < v2
    • +
    • lte(v1, v2): v1 <= v2
    • +
    • eq(v1, v2): v1 == v2 This is true if they're logically equivalent, +even if they're not the exact same string. You already know how to +compare strings.
    • +
    • neq(v1, v2): v1 != v2 The opposite of eq.
    • +
    • cmp(v1, comparator, v2): Pass in a comparison string, and it'll call +the corresponding function above. "===" and "!==" do simple +string comparison, but are included for completeness. Throws if an +invalid comparison string is provided.
    • +
    • compare(v1, v2): Return 0 if v1 == v2, or 1 if v1 is greater, or -1 if +v2 is greater. Sorts in ascending order if passed to Array.sort().
    • +
    • rcompare(v1, v2): The reverse of compare. Sorts an array of versions +in descending order when passed to Array.sort().
    • +
    • diff(v1, v2): Returns difference between two versions by the release type +(major, premajor, minor, preminor, patch, prepatch, or prerelease), +or null if the versions are the same.
    • +
    +

    Comparators

    +
      +
    • intersects(comparator): Return true if the comparators intersect
    • +
    +

    Ranges

    +
      +
    • validRange(range): Return the valid range or null if it's not valid
    • +
    • satisfies(version, range): Return true if the version satisfies the +range.
    • +
    • maxSatisfying(versions, range): Return the highest version in the list +that satisfies the range, or null if none of them do.
    • +
    • minSatisfying(versions, range): Return the lowest version in the list +that satisfies the range, or null if none of them do.
    • +
    • minVersion(range): Return the lowest version that can possibly match +the given range.
    • +
    • gtr(version, range): Return true if version is greater than all the +versions possible in the range.
    • +
    • ltr(version, range): Return true if version is less than all the +versions possible in the range.
    • +
    • outside(version, range, hilo): Return true if the version is outside +the bounds of the range in either the high or low direction. The +hilo argument must be either the string '>' or '<'. (This is +the function called by gtr and ltr.)
    • +
    • intersects(range): Return true if any of the ranges comparators intersect
    • +
    +

    Note that, since ranges may be non-contiguous, a version might not be +greater than a range, less than a range, or satisfy a range! For +example, the range 1.2 <1.2.9 || >2.0.0 would have a hole from 1.2.9 +until 2.0.0, so the version 1.2.10 would not be greater than the +range (because 2.0.1 satisfies, which is higher), nor less than the +range (since 1.2.8 satisfies, which is lower), and it also does not +satisfy the range.

    +

    If you want to know if a version satisfies or does not satisfy a +range, use the satisfies(version, range) function.

    +

    Coercion

    +
      +
    • coerce(version): Coerces a string to semver if possible
    • +
    +

    This aims to provide a very forgiving translation of a non-semver string to +semver. It looks for the first digit in a string, and consumes all +remaining characters which satisfy at least a partial semver (e.g., 1, +1.2, 1.2.3) up to the max permitted length (256 characters). Longer +versions are simply truncated (4.6.3.9.2-alpha2 becomes 4.6.3). All +surrounding text is simply ignored (v3.4 replaces v3.3.1 becomes +3.4.0). Only text which lacks digits will fail coercion (version one +is not valid). The maximum length for any semver component considered for +coercion is 16 characters; longer components will be ignored +(10000000000000000.4.7.4 becomes 4.7.4). The maximum value for any +semver component is Number.MAX_SAFE_INTEGER || (2**53 - 1); higher value +components are invalid (9999999999999999.4.7.4 is likely invalid).

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file diff --git a/deps/npm/lib/fund.js b/deps/npm/lib/fund.js index 4981e461596c07..00954c844d7981 100644 --- a/deps/npm/lib/fund.js +++ b/deps/npm/lib/fund.js @@ -14,7 +14,7 @@ const readShrinkwrap = require('./install/read-shrinkwrap.js') const mutateIntoLogicalTree = require('./install/mutate-into-logical-tree.js') const output = require('./utils/output.js') const openUrl = require('./utils/open-url.js') -const { getFundingInfo, validFundingUrl } = require('./utils/funding.js') +const { getFundingInfo, retrieveFunding, validFundingUrl } = require('./utils/funding.js') const FundConfig = figgyPudding({ browser: {}, // used by ./utils/open-url @@ -132,7 +132,7 @@ function printHuman (fundingInfo, opts) { function openFundingUrl (packageName, cb) { function getUrlAndOpen (packageMetadata) { const { funding } = packageMetadata - const { type, url } = funding || {} + const { type, url } = retrieveFunding(funding) || {} const noFundingError = new Error(`No funding method available for: ${packageName}`) noFundingError.code = 'ENOFUND' diff --git a/deps/npm/lib/install/deps.js b/deps/npm/lib/install/deps.js index dfe30b6c0f38c0..3d8b333c64441c 100644 --- a/deps/npm/lib/install/deps.js +++ b/deps/npm/lib/install/deps.js @@ -203,10 +203,15 @@ function removeObsoleteDep (child, log) { function packageRelativePath (tree) { if (!tree) return '' var requested = tree.package._requested || {} - var isLocal = requested.type === 'directory' || requested.type === 'file' - return isLocal ? requested.fetchSpec - : (tree.isLink || tree.isInLink) && !preserveSymlinks() ? tree.realpath - : tree.path + if (requested.type === 'directory') { + return requested.fetchSpec + } else if (requested.type === 'file') { + return path.dirname(requested.fetchSpec) + } else if ((tree.isLink || tree.isInLink) && !preserveSymlinks()) { + return tree.realpath + } else { + return tree.path + } } function matchingDep (tree, name) { diff --git a/deps/npm/lib/install/read-shrinkwrap.js b/deps/npm/lib/install/read-shrinkwrap.js index 70746780111275..1d9fb99c1d8078 100644 --- a/deps/npm/lib/install/read-shrinkwrap.js +++ b/deps/npm/lib/install/read-shrinkwrap.js @@ -19,8 +19,7 @@ function readShrinkwrap (child, next) { maybeReadFile('npm-shrinkwrap.json', child), // Don't read non-root lockfiles child.isTop && maybeReadFile('package-lock.json', child), - child.isTop && maybeReadFile('package.json', child), - (shrinkwrap, lockfile, pkgJson) => { + (shrinkwrap, lockfile) => { if (shrinkwrap && lockfile) { log.warn('read-shrinkwrap', 'Ignoring package-lock.json because there is already an npm-shrinkwrap.json. Please use only one of the two.') } diff --git a/deps/npm/lib/utils/error-message.js b/deps/npm/lib/utils/error-message.js index 5ddfb37682a2e6..12f304d1e894ac 100644 --- a/deps/npm/lib/utils/error-message.js +++ b/deps/npm/lib/utils/error-message.js @@ -280,8 +280,9 @@ function errorMessage (er) { case 'EEXIST': short.push(['', er.message]) - short.push(['', 'File exists: ' + er.path]) - detail.push(['', 'Move it away, and try again.']) + short.push(['', 'File exists: ' + (er.dest || er.path)]) + detail.push(['', 'Remove the existing file and try again, or run npm']) + detail.push(['', 'with --force to overwrite files recklessly.']) break case 'ENEEDAUTH': diff --git a/deps/npm/lib/utils/funding.js b/deps/npm/lib/utils/funding.js index dce40147642c5f..c3d06b10899638 100644 --- a/deps/npm/lib/utils/funding.js +++ b/deps/npm/lib/utils/funding.js @@ -3,8 +3,18 @@ const URL = require('url').URL exports.getFundingInfo = getFundingInfo +exports.retrieveFunding = retrieveFunding exports.validFundingUrl = validFundingUrl +// supports both object funding and string shorthand +function retrieveFunding (funding) { + return typeof funding === 'string' + ? { + url: funding + } + : funding +} + // Is the value of a `funding` property of a `package.json` // a valid type+url for `npm fund` to display? function validFundingUrl (funding) { @@ -60,14 +70,6 @@ function getFundingInfo (idealTree, opts) { ) } - function retrieveFunding (funding) { - return typeof funding === 'string' - ? { - url: funding - } - : funding - } - function getFundingDependencies (tree) { const deps = tree && tree.dependencies if (!deps) return empty() diff --git a/deps/npm/lib/version.js b/deps/npm/lib/version.js index 0f1e97aedd4038..a8c2a648c74736 100644 --- a/deps/npm/lib/version.js +++ b/deps/npm/lib/version.js @@ -256,7 +256,7 @@ function checkGit (localData, cb) { statGitFolder(function (er) { var doGit = !er && npm.config.get('git-tag-version') if (!doGit) { - if (er) log.verbose('version', 'error checking for .git', er) + if (er && npm.config.get('git-tag-version')) log.verbose('version', 'error checking for .git', er) log.verbose('version', 'not tagging in git') return cb(null, false) } diff --git a/deps/npm/man/man1/npm-README.1 b/deps/npm/man/man1/npm-README.1 index c2535cc28a1a51..d3028ee37bfd02 100644 --- a/deps/npm/man/man1/npm-README.1 +++ b/deps/npm/man/man1/npm-README.1 @@ -1,4 +1,4 @@ -.TH "NPM" "1" "November 2019" "" "" +.TH "NPM" "1" "December 2019" "" "" .SH "NAME" \fBnpm\fR \- a JavaScript package manager .P diff --git a/deps/npm/man/man1/npm-access.1 b/deps/npm/man/man1/npm-access.1 index ac6274bacdb066..a08b24798002e3 100644 --- a/deps/npm/man/man1/npm-access.1 +++ b/deps/npm/man/man1/npm-access.1 @@ -1,4 +1,4 @@ -.TH "NPM\-ACCESS" "1" "November 2019" "" "" +.TH "NPM\-ACCESS" "1" "December 2019" "" "" .SH "NAME" \fBnpm-access\fR \- Set access level on published packages .SS Synopsis diff --git a/deps/npm/man/man1/npm-adduser.1 b/deps/npm/man/man1/npm-adduser.1 index 89cda8029790e5..f2f9557dcc7d13 100644 --- a/deps/npm/man/man1/npm-adduser.1 +++ b/deps/npm/man/man1/npm-adduser.1 @@ -1,4 +1,4 @@ -.TH "NPM\-ADDUSER" "1" "November 2019" "" "" +.TH "NPM\-ADDUSER" "1" "December 2019" "" "" .SH "NAME" \fBnpm-adduser\fR \- Add a registry user account .SS Synopsis diff --git a/deps/npm/man/man1/npm-audit.1 b/deps/npm/man/man1/npm-audit.1 index 50e61c60d1748e..1536217ad0a109 100644 --- a/deps/npm/man/man1/npm-audit.1 +++ b/deps/npm/man/man1/npm-audit.1 @@ -1,4 +1,4 @@ -.TH "NPM\-AUDIT" "1" "November 2019" "" "" +.TH "NPM\-AUDIT" "1" "December 2019" "" "" .SH "NAME" \fBnpm-audit\fR \- Run a security audit .SS Synopsis diff --git a/deps/npm/man/man1/npm-bin.1 b/deps/npm/man/man1/npm-bin.1 index 8a925ee708ee5d..1045b8a057a38f 100644 --- a/deps/npm/man/man1/npm-bin.1 +++ b/deps/npm/man/man1/npm-bin.1 @@ -1,4 +1,4 @@ -.TH "NPM\-BIN" "1" "November 2019" "" "" +.TH "NPM\-BIN" "1" "December 2019" "" "" .SH "NAME" \fBnpm-bin\fR \- Display npm bin folder .SS Synopsis diff --git a/deps/npm/man/man1/npm-bugs.1 b/deps/npm/man/man1/npm-bugs.1 index 953d83bc78ac68..26cf705225edbf 100644 --- a/deps/npm/man/man1/npm-bugs.1 +++ b/deps/npm/man/man1/npm-bugs.1 @@ -1,4 +1,4 @@ -.TH "NPM\-BUGS" "1" "November 2019" "" "" +.TH "NPM\-BUGS" "1" "December 2019" "" "" .SH "NAME" \fBnpm-bugs\fR \- Bugs for a package in a web browser maybe .SS Synopsis diff --git a/deps/npm/man/man1/npm-build.1 b/deps/npm/man/man1/npm-build.1 index 7ea03625729cd2..ccee0f7c094fdb 100644 --- a/deps/npm/man/man1/npm-build.1 +++ b/deps/npm/man/man1/npm-build.1 @@ -1,4 +1,4 @@ -.TH "NPM\-BUILD" "1" "November 2019" "" "" +.TH "NPM\-BUILD" "1" "December 2019" "" "" .SH "NAME" \fBnpm-build\fR \- Build a package .SS Synopsis diff --git a/deps/npm/man/man1/npm-bundle.1 b/deps/npm/man/man1/npm-bundle.1 index 8c911b2d570f3e..936659595a8e3c 100644 --- a/deps/npm/man/man1/npm-bundle.1 +++ b/deps/npm/man/man1/npm-bundle.1 @@ -1,4 +1,4 @@ -.TH "NPM\-BUNDLE" "1" "November 2019" "" "" +.TH "NPM\-BUNDLE" "1" "December 2019" "" "" .SH "NAME" \fBnpm-bundle\fR \- REMOVED .SS Description diff --git a/deps/npm/man/man1/npm-cache.1 b/deps/npm/man/man1/npm-cache.1 index 5740233250a513..da2a65f513b4ef 100644 --- a/deps/npm/man/man1/npm-cache.1 +++ b/deps/npm/man/man1/npm-cache.1 @@ -1,4 +1,4 @@ -.TH "NPM\-CACHE" "1" "November 2019" "" "" +.TH "NPM\-CACHE" "1" "December 2019" "" "" .SH "NAME" \fBnpm-cache\fR \- Manipulates packages cache .SS Synopsis diff --git a/deps/npm/man/man1/npm-ci.1 b/deps/npm/man/man1/npm-ci.1 index adad70234939f4..75cc55041a9c1f 100644 --- a/deps/npm/man/man1/npm-ci.1 +++ b/deps/npm/man/man1/npm-ci.1 @@ -1,4 +1,4 @@ -.TH "NPM\-CI" "1" "November 2019" "" "" +.TH "NPM\-CI" "1" "December 2019" "" "" .SH "NAME" \fBnpm-ci\fR \- Install a project with a clean slate .SS Synopsis diff --git a/deps/npm/man/man1/npm-completion.1 b/deps/npm/man/man1/npm-completion.1 index ce6654a0c93a63..b267ffe8387016 100644 --- a/deps/npm/man/man1/npm-completion.1 +++ b/deps/npm/man/man1/npm-completion.1 @@ -1,4 +1,4 @@ -.TH "NPM\-COMPLETION" "1" "November 2019" "" "" +.TH "NPM\-COMPLETION" "1" "December 2019" "" "" .SH "NAME" \fBnpm-completion\fR \- Tab Completion for npm .SS Synopsis diff --git a/deps/npm/man/man1/npm-config.1 b/deps/npm/man/man1/npm-config.1 index 423f7f258b67d0..1300519368339f 100644 --- a/deps/npm/man/man1/npm-config.1 +++ b/deps/npm/man/man1/npm-config.1 @@ -1,4 +1,4 @@ -.TH "NPM\-CONFIG" "1" "November 2019" "" "" +.TH "NPM\-CONFIG" "1" "December 2019" "" "" .SH "NAME" \fBnpm-config\fR \- Manage the npm configuration files .SS Synopsis diff --git a/deps/npm/man/man1/npm-dedupe.1 b/deps/npm/man/man1/npm-dedupe.1 index f4b0e6fd56c281..ef7c109d770f98 100644 --- a/deps/npm/man/man1/npm-dedupe.1 +++ b/deps/npm/man/man1/npm-dedupe.1 @@ -1,4 +1,4 @@ -.TH "NPM\-DEDUPE" "1" "November 2019" "" "" +.TH "NPM\-DEDUPE" "1" "December 2019" "" "" .SH "NAME" \fBnpm-dedupe\fR \- Reduce duplication .SS Synopsis diff --git a/deps/npm/man/man1/npm-deprecate.1 b/deps/npm/man/man1/npm-deprecate.1 index cfbe9dcf2be5f6..ccbb03b550a3b4 100644 --- a/deps/npm/man/man1/npm-deprecate.1 +++ b/deps/npm/man/man1/npm-deprecate.1 @@ -1,4 +1,4 @@ -.TH "NPM\-DEPRECATE" "1" "November 2019" "" "" +.TH "NPM\-DEPRECATE" "1" "December 2019" "" "" .SH "NAME" \fBnpm-deprecate\fR \- Deprecate a version of a package .SS Synopsis diff --git a/deps/npm/man/man1/npm-dist-tag.1 b/deps/npm/man/man1/npm-dist-tag.1 index 211c02dbac9a24..50896edfd10561 100644 --- a/deps/npm/man/man1/npm-dist-tag.1 +++ b/deps/npm/man/man1/npm-dist-tag.1 @@ -1,4 +1,4 @@ -.TH "NPM\-DIST\-TAG" "1" "November 2019" "" "" +.TH "NPM\-DIST\-TAG" "1" "December 2019" "" "" .SH "NAME" \fBnpm-dist-tag\fR \- Modify package distribution tags .SS Synopsis diff --git a/deps/npm/man/man1/npm-docs.1 b/deps/npm/man/man1/npm-docs.1 index 7adbedd9a0f019..c4c80b2396e515 100644 --- a/deps/npm/man/man1/npm-docs.1 +++ b/deps/npm/man/man1/npm-docs.1 @@ -1,4 +1,4 @@ -.TH "NPM\-DOCS" "1" "November 2019" "" "" +.TH "NPM\-DOCS" "1" "December 2019" "" "" .SH "NAME" \fBnpm-docs\fR \- Docs for a package in a web browser maybe .SS Synopsis diff --git a/deps/npm/man/man1/npm-doctor.1 b/deps/npm/man/man1/npm-doctor.1 index 52ccfb0c4cb52c..d92053da430b90 100644 --- a/deps/npm/man/man1/npm-doctor.1 +++ b/deps/npm/man/man1/npm-doctor.1 @@ -1,4 +1,4 @@ -.TH "NPM\-DOCTOR" "1" "November 2019" "" "" +.TH "NPM\-DOCTOR" "1" "December 2019" "" "" .SH "NAME" \fBnpm-doctor\fR \- Check your environments .SS Synopsis diff --git a/deps/npm/man/man1/npm-edit.1 b/deps/npm/man/man1/npm-edit.1 index 36abc611f88c6a..e76ae46c7af092 100644 --- a/deps/npm/man/man1/npm-edit.1 +++ b/deps/npm/man/man1/npm-edit.1 @@ -1,4 +1,4 @@ -.TH "NPM\-EDIT" "1" "November 2019" "" "" +.TH "NPM\-EDIT" "1" "December 2019" "" "" .SH "NAME" \fBnpm-edit\fR \- Edit an installed package .SS Synopsis diff --git a/deps/npm/man/man1/npm-explore.1 b/deps/npm/man/man1/npm-explore.1 index 5b27fcf9b76bef..bf34d050ed4dca 100644 --- a/deps/npm/man/man1/npm-explore.1 +++ b/deps/npm/man/man1/npm-explore.1 @@ -1,4 +1,4 @@ -.TH "NPM\-EXPLORE" "1" "November 2019" "" "" +.TH "NPM\-EXPLORE" "1" "December 2019" "" "" .SH "NAME" \fBnpm-explore\fR \- Browse an installed package .SS Synopsis diff --git a/deps/npm/man/man1/npm-fund.1 b/deps/npm/man/man1/npm-fund.1 index 83280693f2794b..170d93753f56ca 100644 --- a/deps/npm/man/man1/npm-fund.1 +++ b/deps/npm/man/man1/npm-fund.1 @@ -1,4 +1,4 @@ -.TH "NPM\-FUND" "1" "November 2019" "" "" +.TH "NPM\-FUND" "1" "December 2019" "" "" .SH "NAME" \fBnpm-fund\fR \- Retrieve funding information .SS Synopsis diff --git a/deps/npm/man/man1/npm-help-search.1 b/deps/npm/man/man1/npm-help-search.1 index 01400fe1528523..fcf4b863541cb4 100644 --- a/deps/npm/man/man1/npm-help-search.1 +++ b/deps/npm/man/man1/npm-help-search.1 @@ -1,4 +1,4 @@ -.TH "NPM\-HELP\-SEARCH" "1" "November 2019" "" "" +.TH "NPM\-HELP\-SEARCH" "1" "December 2019" "" "" .SH "NAME" \fBnpm-help-search\fR \- Search npm help documentation .SS Synopsis diff --git a/deps/npm/man/man1/npm-help.1 b/deps/npm/man/man1/npm-help.1 index f5331a6ac72e83..2fd749f88d1ade 100644 --- a/deps/npm/man/man1/npm-help.1 +++ b/deps/npm/man/man1/npm-help.1 @@ -1,4 +1,4 @@ -.TH "NPM\-HELP" "1" "November 2019" "" "" +.TH "NPM\-HELP" "1" "December 2019" "" "" .SH "NAME" \fBnpm-help\fR \- Get help on npm .SS Synopsis diff --git a/deps/npm/man/man1/npm-hook.1 b/deps/npm/man/man1/npm-hook.1 index 521f44f01ad2a8..dbc6f8b898644a 100644 --- a/deps/npm/man/man1/npm-hook.1 +++ b/deps/npm/man/man1/npm-hook.1 @@ -1,4 +1,4 @@ -.TH "NPM\-HOOK" "1" "November 2019" "" "" +.TH "NPM\-HOOK" "1" "December 2019" "" "" .SH "NAME" \fBnpm-hook\fR \- Manage registry hooks .SS Synopsis diff --git a/deps/npm/man/man1/npm-init.1 b/deps/npm/man/man1/npm-init.1 index d0bf42286e182e..bdd4ab126fa26f 100644 --- a/deps/npm/man/man1/npm-init.1 +++ b/deps/npm/man/man1/npm-init.1 @@ -1,4 +1,4 @@ -.TH "NPM\-INIT" "1" "November 2019" "" "" +.TH "NPM\-INIT" "1" "December 2019" "" "" .SH "NAME" \fBnpm-init\fR \- create a package\.json file .SS Synopsis diff --git a/deps/npm/man/man1/npm-install-ci-test.1 b/deps/npm/man/man1/npm-install-ci-test.1 index 8ac6535034ea1c..487de9cbe4ee45 100644 --- a/deps/npm/man/man1/npm-install-ci-test.1 +++ b/deps/npm/man/man1/npm-install-ci-test.1 @@ -1,4 +1,4 @@ -.TH "NPM" "" "November 2019" "" "" +.TH "NPM" "" "December 2019" "" "" .SH "NAME" \fBnpm\fR .SS Synopsis diff --git a/deps/npm/man/man1/npm-install-test.1 b/deps/npm/man/man1/npm-install-test.1 index 470d20f3574047..0b5915cd2ed5c7 100644 --- a/deps/npm/man/man1/npm-install-test.1 +++ b/deps/npm/man/man1/npm-install-test.1 @@ -1,4 +1,4 @@ -.TH "NPM" "" "November 2019" "" "" +.TH "NPM" "" "December 2019" "" "" .SH "NAME" \fBnpm\fR .SS Synopsis diff --git a/deps/npm/man/man1/npm-install.1 b/deps/npm/man/man1/npm-install.1 index c3ab9dc7740435..ba9e8cc12dcfa1 100644 --- a/deps/npm/man/man1/npm-install.1 +++ b/deps/npm/man/man1/npm-install.1 @@ -1,4 +1,4 @@ -.TH "NPM\-INSTALL" "1" "November 2019" "" "" +.TH "NPM\-INSTALL" "1" "December 2019" "" "" .SH "NAME" \fBnpm-install\fR \- Install a package .SS Synopsis diff --git a/deps/npm/man/man1/npm-link.1 b/deps/npm/man/man1/npm-link.1 index 3485c817455caf..9120d99ebfac26 100644 --- a/deps/npm/man/man1/npm-link.1 +++ b/deps/npm/man/man1/npm-link.1 @@ -1,4 +1,4 @@ -.TH "NPM\-LINK" "1" "November 2019" "" "" +.TH "NPM\-LINK" "1" "December 2019" "" "" .SH "NAME" \fBnpm-link\fR \- Symlink a package folder .SS Synopsis diff --git a/deps/npm/man/man1/npm-logout.1 b/deps/npm/man/man1/npm-logout.1 index 997668379c100a..1469659def9e49 100644 --- a/deps/npm/man/man1/npm-logout.1 +++ b/deps/npm/man/man1/npm-logout.1 @@ -1,4 +1,4 @@ -.TH "NPM\-LOGOUT" "1" "November 2019" "" "" +.TH "NPM\-LOGOUT" "1" "December 2019" "" "" .SH "NAME" \fBnpm-logout\fR \- Log out of the registry .SS Synopsis diff --git a/deps/npm/man/man1/npm-ls.1 b/deps/npm/man/man1/npm-ls.1 index c6d035446ff2cc..fc46b3ad787e65 100644 --- a/deps/npm/man/man1/npm-ls.1 +++ b/deps/npm/man/man1/npm-ls.1 @@ -1,4 +1,4 @@ -.TH "NPM\-LS" "1" "November 2019" "" "" +.TH "NPM\-LS" "1" "December 2019" "" "" .SH "NAME" \fBnpm-ls\fR \- List installed packages .SS Synopsis @@ -22,7 +22,7 @@ For example, running \fBnpm ls promzard\fP in npm's source tree will show: .P .RS 2 .nf - npm@6\.13\.1 /path/to/npm + npm@6\.13\.4 /path/to/npm └─┬ init\-package\-json@0\.0\.4 └── promzard@0\.1\.5 .fi diff --git a/deps/npm/man/man1/npm-org.1 b/deps/npm/man/man1/npm-org.1 index d3e7cb74f5bc30..bb0f44eee8110a 100644 --- a/deps/npm/man/man1/npm-org.1 +++ b/deps/npm/man/man1/npm-org.1 @@ -1,4 +1,4 @@ -.TH "NPM\-ORG" "1" "November 2019" "" "" +.TH "NPM\-ORG" "1" "December 2019" "" "" .SH "NAME" \fBnpm-org\fR \- Manage orgs .SS Synopsis diff --git a/deps/npm/man/man1/npm-outdated.1 b/deps/npm/man/man1/npm-outdated.1 index 681b457d8d611c..c180c6f1c378a7 100644 --- a/deps/npm/man/man1/npm-outdated.1 +++ b/deps/npm/man/man1/npm-outdated.1 @@ -1,4 +1,4 @@ -.TH "NPM\-OUTDATED" "1" "November 2019" "" "" +.TH "NPM\-OUTDATED" "1" "December 2019" "" "" .SH "NAME" \fBnpm-outdated\fR \- Check for outdated packages .SS Synopsis diff --git a/deps/npm/man/man1/npm-owner.1 b/deps/npm/man/man1/npm-owner.1 index 343fcc3ea3f67e..609562e7aa105c 100644 --- a/deps/npm/man/man1/npm-owner.1 +++ b/deps/npm/man/man1/npm-owner.1 @@ -1,4 +1,4 @@ -.TH "NPM\-OWNER" "1" "November 2019" "" "" +.TH "NPM\-OWNER" "1" "December 2019" "" "" .SH "NAME" \fBnpm-owner\fR \- Manage package owners .SS Synopsis diff --git a/deps/npm/man/man1/npm-pack.1 b/deps/npm/man/man1/npm-pack.1 index 9b8feaaa67f864..73d12bbab94fdb 100644 --- a/deps/npm/man/man1/npm-pack.1 +++ b/deps/npm/man/man1/npm-pack.1 @@ -1,4 +1,4 @@ -.TH "NPM\-PACK" "1" "November 2019" "" "" +.TH "NPM\-PACK" "1" "December 2019" "" "" .SH "NAME" \fBnpm-pack\fR \- Create a tarball from a package .SS Synopsis diff --git a/deps/npm/man/man1/npm-ping.1 b/deps/npm/man/man1/npm-ping.1 index dda31466bffe25..f555c4f6e2ba0d 100644 --- a/deps/npm/man/man1/npm-ping.1 +++ b/deps/npm/man/man1/npm-ping.1 @@ -1,4 +1,4 @@ -.TH "NPM\-PING" "1" "November 2019" "" "" +.TH "NPM\-PING" "1" "December 2019" "" "" .SH "NAME" \fBnpm-ping\fR \- Ping npm registry .SS Synopsis diff --git a/deps/npm/man/man1/npm-prefix.1 b/deps/npm/man/man1/npm-prefix.1 index 04d7c00ecfd983..d4fe8fb2ef74e3 100644 --- a/deps/npm/man/man1/npm-prefix.1 +++ b/deps/npm/man/man1/npm-prefix.1 @@ -1,4 +1,4 @@ -.TH "NPM\-PREFIX" "1" "November 2019" "" "" +.TH "NPM\-PREFIX" "1" "December 2019" "" "" .SH "NAME" \fBnpm-prefix\fR \- Display prefix .SS Synopsis diff --git a/deps/npm/man/man1/npm-prune.1 b/deps/npm/man/man1/npm-prune.1 index 58ccd7b3852cdc..15cdbc2d69fa45 100644 --- a/deps/npm/man/man1/npm-prune.1 +++ b/deps/npm/man/man1/npm-prune.1 @@ -1,4 +1,4 @@ -.TH "NPM\-PRUNE" "1" "November 2019" "" "" +.TH "NPM\-PRUNE" "1" "December 2019" "" "" .SH "NAME" \fBnpm-prune\fR \- Remove extraneous packages .SS Synopsis diff --git a/deps/npm/man/man1/npm-publish.1 b/deps/npm/man/man1/npm-publish.1 index 45de41045e180f..63a08a5f19bd0a 100644 --- a/deps/npm/man/man1/npm-publish.1 +++ b/deps/npm/man/man1/npm-publish.1 @@ -1,4 +1,4 @@ -.TH "NPM\-PUBLISH" "1" "November 2019" "" "" +.TH "NPM\-PUBLISH" "1" "December 2019" "" "" .SH "NAME" \fBnpm-publish\fR \- Publish a package .SS Synopsis diff --git a/deps/npm/man/man1/npm-rebuild.1 b/deps/npm/man/man1/npm-rebuild.1 index 49674eca385994..367766f81f5484 100644 --- a/deps/npm/man/man1/npm-rebuild.1 +++ b/deps/npm/man/man1/npm-rebuild.1 @@ -1,4 +1,4 @@ -.TH "NPM\-REBUILD" "1" "November 2019" "" "" +.TH "NPM\-REBUILD" "1" "December 2019" "" "" .SH "NAME" \fBnpm-rebuild\fR \- Rebuild a package .SS Synopsis diff --git a/deps/npm/man/man1/npm-repo.1 b/deps/npm/man/man1/npm-repo.1 index 597292b8d43e6e..aa72275dfe730b 100644 --- a/deps/npm/man/man1/npm-repo.1 +++ b/deps/npm/man/man1/npm-repo.1 @@ -1,4 +1,4 @@ -.TH "NPM\-REPO" "1" "November 2019" "" "" +.TH "NPM\-REPO" "1" "December 2019" "" "" .SH "NAME" \fBnpm-repo\fR \- Open package repository page in the browser .SS Synopsis diff --git a/deps/npm/man/man1/npm-restart.1 b/deps/npm/man/man1/npm-restart.1 index 9d566ef0c26ffe..a10b578c2d18c8 100644 --- a/deps/npm/man/man1/npm-restart.1 +++ b/deps/npm/man/man1/npm-restart.1 @@ -1,4 +1,4 @@ -.TH "NPM\-RESTART" "1" "November 2019" "" "" +.TH "NPM\-RESTART" "1" "December 2019" "" "" .SH "NAME" \fBnpm-restart\fR \- Restart a package .SS Synopsis diff --git a/deps/npm/man/man1/npm-root.1 b/deps/npm/man/man1/npm-root.1 index f86181ef7c5635..f670fd7edd226c 100644 --- a/deps/npm/man/man1/npm-root.1 +++ b/deps/npm/man/man1/npm-root.1 @@ -1,4 +1,4 @@ -.TH "NPM\-ROOT" "1" "November 2019" "" "" +.TH "NPM\-ROOT" "1" "December 2019" "" "" .SH "NAME" \fBnpm-root\fR \- Display npm root .SS Synopsis diff --git a/deps/npm/man/man1/npm-run-script.1 b/deps/npm/man/man1/npm-run-script.1 index 22c9f95306a9a9..d618c879456894 100644 --- a/deps/npm/man/man1/npm-run-script.1 +++ b/deps/npm/man/man1/npm-run-script.1 @@ -1,4 +1,4 @@ -.TH "NPM\-RUN\-SCRIPT" "1" "November 2019" "" "" +.TH "NPM\-RUN\-SCRIPT" "1" "December 2019" "" "" .SH "NAME" \fBnpm-run-script\fR \- Run arbitrary package scripts .SS Synopsis diff --git a/deps/npm/man/man1/npm-search.1 b/deps/npm/man/man1/npm-search.1 index b792f39e813ff1..3fc442642c14f0 100644 --- a/deps/npm/man/man1/npm-search.1 +++ b/deps/npm/man/man1/npm-search.1 @@ -1,4 +1,4 @@ -.TH "NPM\-SEARCH" "1" "November 2019" "" "" +.TH "NPM\-SEARCH" "1" "December 2019" "" "" .SH "NAME" \fBnpm-search\fR \- Search for packages .SS Synopsis diff --git a/deps/npm/man/man1/npm-shrinkwrap.1 b/deps/npm/man/man1/npm-shrinkwrap.1 index 33286dc895f391..70e8924d67b5ac 100644 --- a/deps/npm/man/man1/npm-shrinkwrap.1 +++ b/deps/npm/man/man1/npm-shrinkwrap.1 @@ -1,4 +1,4 @@ -.TH "NPM\-SHRINKWRAP" "1" "November 2019" "" "" +.TH "NPM\-SHRINKWRAP" "1" "December 2019" "" "" .SH "NAME" \fBnpm-shrinkwrap\fR \- Lock down dependency versions for publication .SS Synopsis diff --git a/deps/npm/man/man1/npm-star.1 b/deps/npm/man/man1/npm-star.1 index 4ad11a7efbcdf0..e5ba538f9ce361 100644 --- a/deps/npm/man/man1/npm-star.1 +++ b/deps/npm/man/man1/npm-star.1 @@ -1,4 +1,4 @@ -.TH "NPM\-STAR" "1" "November 2019" "" "" +.TH "NPM\-STAR" "1" "December 2019" "" "" .SH "NAME" \fBnpm-star\fR \- Mark your favorite packages .SS Synopsis diff --git a/deps/npm/man/man1/npm-stars.1 b/deps/npm/man/man1/npm-stars.1 index 2c7b6f243098a2..e2d447fee790fe 100644 --- a/deps/npm/man/man1/npm-stars.1 +++ b/deps/npm/man/man1/npm-stars.1 @@ -1,4 +1,4 @@ -.TH "NPM\-STARS" "1" "November 2019" "" "" +.TH "NPM\-STARS" "1" "December 2019" "" "" .SH "NAME" \fBnpm-stars\fR \- View packages marked as favorites .SS Synopsis diff --git a/deps/npm/man/man1/npm-start.1 b/deps/npm/man/man1/npm-start.1 index e83e6800f7d01a..7768a9bc9eea78 100644 --- a/deps/npm/man/man1/npm-start.1 +++ b/deps/npm/man/man1/npm-start.1 @@ -1,4 +1,4 @@ -.TH "NPM\-START" "1" "November 2019" "" "" +.TH "NPM\-START" "1" "December 2019" "" "" .SH "NAME" \fBnpm-start\fR \- Start a package .SS Synopsis diff --git a/deps/npm/man/man1/npm-stop.1 b/deps/npm/man/man1/npm-stop.1 index d3b612b08adffb..d81ba646e033b5 100644 --- a/deps/npm/man/man1/npm-stop.1 +++ b/deps/npm/man/man1/npm-stop.1 @@ -1,4 +1,4 @@ -.TH "NPM\-STOP" "1" "November 2019" "" "" +.TH "NPM\-STOP" "1" "December 2019" "" "" .SH "NAME" \fBnpm-stop\fR \- Stop a package .SS Synopsis diff --git a/deps/npm/man/man1/npm-team.1 b/deps/npm/man/man1/npm-team.1 index ca7f0beb1fafb2..d7194d5c8c2b83 100644 --- a/deps/npm/man/man1/npm-team.1 +++ b/deps/npm/man/man1/npm-team.1 @@ -1,4 +1,4 @@ -.TH "NPM\-TEAM" "1" "November 2019" "" "" +.TH "NPM\-TEAM" "1" "December 2019" "" "" .SH "NAME" \fBnpm-team\fR \- Manage organization teams and team memberships .SS Synopsis diff --git a/deps/npm/man/man1/npm-test.1 b/deps/npm/man/man1/npm-test.1 index bd18fedb505bfd..e68297858b4c4f 100644 --- a/deps/npm/man/man1/npm-test.1 +++ b/deps/npm/man/man1/npm-test.1 @@ -1,4 +1,4 @@ -.TH "NPM\-TEST" "1" "November 2019" "" "" +.TH "NPM\-TEST" "1" "December 2019" "" "" .SH "NAME" \fBnpm-test\fR \- Test a package .SS Synopsis diff --git a/deps/npm/man/man1/npm-uninstall.1 b/deps/npm/man/man1/npm-uninstall.1 index 35523df7a17d5f..7e5a6feab701c1 100644 --- a/deps/npm/man/man1/npm-uninstall.1 +++ b/deps/npm/man/man1/npm-uninstall.1 @@ -1,4 +1,4 @@ -.TH "NPM\-UNINSTALL" "1" "November 2019" "" "" +.TH "NPM\-UNINSTALL" "1" "December 2019" "" "" .SH "NAME" \fBnpm-uninstall\fR \- Remove a package .SS Synopsis diff --git a/deps/npm/man/man1/npm-unpublish.1 b/deps/npm/man/man1/npm-unpublish.1 index f0ce9fa92db2ca..2cfa8071372e95 100644 --- a/deps/npm/man/man1/npm-unpublish.1 +++ b/deps/npm/man/man1/npm-unpublish.1 @@ -1,4 +1,4 @@ -.TH "NPM\-UNPUBLISH" "1" "November 2019" "" "" +.TH "NPM\-UNPUBLISH" "1" "December 2019" "" "" .SH "NAME" \fBnpm-unpublish\fR \- Remove a package from the registry .SS Synopsis diff --git a/deps/npm/man/man1/npm-update.1 b/deps/npm/man/man1/npm-update.1 index 2ebe4a29456c04..dd61226c352498 100644 --- a/deps/npm/man/man1/npm-update.1 +++ b/deps/npm/man/man1/npm-update.1 @@ -1,4 +1,4 @@ -.TH "NPM\-UPDATE" "1" "November 2019" "" "" +.TH "NPM\-UPDATE" "1" "December 2019" "" "" .SH "NAME" \fBnpm-update\fR \- Update a package .SS Synopsis diff --git a/deps/npm/man/man1/npm-version.1 b/deps/npm/man/man1/npm-version.1 index df14c7f67e88fa..f87f182c8d3809 100644 --- a/deps/npm/man/man1/npm-version.1 +++ b/deps/npm/man/man1/npm-version.1 @@ -1,4 +1,4 @@ -.TH "NPM\-VERSION" "1" "November 2019" "" "" +.TH "NPM\-VERSION" "1" "December 2019" "" "" .SH "NAME" \fBnpm-version\fR \- Bump a package version .SS Synopsis diff --git a/deps/npm/man/man1/npm-view.1 b/deps/npm/man/man1/npm-view.1 index 72d41b9cf18d0d..ee47347e5c10ee 100644 --- a/deps/npm/man/man1/npm-view.1 +++ b/deps/npm/man/man1/npm-view.1 @@ -1,4 +1,4 @@ -.TH "NPM\-VIEW" "1" "November 2019" "" "" +.TH "NPM\-VIEW" "1" "December 2019" "" "" .SH "NAME" \fBnpm-view\fR \- View registry info .SS Synopsis diff --git a/deps/npm/man/man1/npm-whoami.1 b/deps/npm/man/man1/npm-whoami.1 index 40c627e8c44f11..4958d4cc2d8fd1 100644 --- a/deps/npm/man/man1/npm-whoami.1 +++ b/deps/npm/man/man1/npm-whoami.1 @@ -1,4 +1,4 @@ -.TH "NPM\-WHOAMI" "1" "November 2019" "" "" +.TH "NPM\-WHOAMI" "1" "December 2019" "" "" .SH "NAME" \fBnpm-whoami\fR \- Display npm username .SS Synopsis diff --git a/deps/npm/man/man1/npm.1 b/deps/npm/man/man1/npm.1 index 6ef81e031837b0..44859cc22e3123 100644 --- a/deps/npm/man/man1/npm.1 +++ b/deps/npm/man/man1/npm.1 @@ -1,4 +1,4 @@ -.TH "NPM" "1" "November 2019" "" "" +.TH "NPM" "1" "December 2019" "" "" .SH "NAME" \fBnpm\fR \- javascript package manager .SS Synopsis @@ -10,7 +10,7 @@ npm [args] .RE .SS Version .P -6\.13\.1 +6\.13\.4 .SS Description .P npm is the package manager for the Node JavaScript platform\. It puts diff --git a/deps/npm/man/man5/install.5 b/deps/npm/man/man5/install.5 index d14b649fe75e72..f01da284796b41 100644 --- a/deps/npm/man/man5/install.5 +++ b/deps/npm/man/man5/install.5 @@ -1,4 +1,4 @@ -.TH "INSTALL" "5" "November 2019" "" "" +.TH "INSTALL" "5" "December 2019" "" "" .SH "NAME" \fBinstall\fR \- Download and Install npm .SS Description diff --git a/deps/npm/man/man5/npmrc.5 b/deps/npm/man/man5/npmrc.5 index d11cb449c019ef..73a298cf626343 100644 --- a/deps/npm/man/man5/npmrc.5 +++ b/deps/npm/man/man5/npmrc.5 @@ -1,4 +1,4 @@ -.TH "NPMRC" "5" "November 2019" "" "" +.TH "NPMRC" "5" "December 2019" "" "" .SH "NAME" \fBnpmrc\fR \- The npm config files .SS Description diff --git a/deps/npm/man/man5/package-json.5 b/deps/npm/man/man5/package-json.5 index 01350c641035e1..c278ee7acfc99c 100644 --- a/deps/npm/man/man5/package-json.5 +++ b/deps/npm/man/man5/package-json.5 @@ -1,4 +1,4 @@ -.TH "PACKAGE\.JSON" "5" "November 2019" "" "" +.TH "PACKAGE\.JSON" "5" "December 2019" "" "" .SH "NAME" \fBpackage.json\fR \- Specifics of npm's package\.json handling .SS Description diff --git a/deps/npm/man/man5/package-lock-json.5 b/deps/npm/man/man5/package-lock-json.5 index 36dbbc402341d5..5f190bf08c852d 100644 --- a/deps/npm/man/man5/package-lock-json.5 +++ b/deps/npm/man/man5/package-lock-json.5 @@ -1,4 +1,4 @@ -.TH "PACKAGE\-LOCK\.JSON" "5" "November 2019" "" "" +.TH "PACKAGE\-LOCK\.JSON" "5" "December 2019" "" "" .SH "NAME" \fBpackage-lock.json\fR \- A manifestation of the manifest .SS Description diff --git a/deps/npm/man/man5/package-locks.5 b/deps/npm/man/man5/package-locks.5 index ea2e51fc69714c..0c8af6163305a9 100644 --- a/deps/npm/man/man5/package-locks.5 +++ b/deps/npm/man/man5/package-locks.5 @@ -1,4 +1,4 @@ -.TH "PACKAGE\-LOCKS" "5" "November 2019" "" "" +.TH "PACKAGE\-LOCKS" "5" "December 2019" "" "" .SH "NAME" \fBpackage-locks\fR \- An explanation of npm lockfiles .SS Description diff --git a/deps/npm/man/man5/shrinkwrap-json.5 b/deps/npm/man/man5/shrinkwrap-json.5 index 5c1e05f8b7816d..22b517dbbbaf41 100644 --- a/deps/npm/man/man5/shrinkwrap-json.5 +++ b/deps/npm/man/man5/shrinkwrap-json.5 @@ -1,4 +1,4 @@ -.TH "NPM\-SHRINKWRAP\.JSON" "5" "November 2019" "" "" +.TH "NPM\-SHRINKWRAP\.JSON" "5" "December 2019" "" "" .SH "NAME" \fBnpm-shrinkwrap.json\fR \- A publishable lockfile .SS Description diff --git a/deps/npm/man/man7/developers.7 b/deps/npm/man/man7/developers.7 index 2f24215d26b19f..60fe6234cffd09 100644 --- a/deps/npm/man/man7/developers.7 +++ b/deps/npm/man/man7/developers.7 @@ -1,4 +1,4 @@ -.TH "DEVELOPERS" "7" "November 2019" "" "" +.TH "DEVELOPERS" "7" "December 2019" "" "" .SH "NAME" \fBdevelopers\fR \- Developer Guide .SS Description diff --git a/deps/npm/man/man7/disputes.7 b/deps/npm/man/man7/disputes.7 index c815d206351fbd..53cf2464a9ea8c 100644 --- a/deps/npm/man/man7/disputes.7 +++ b/deps/npm/man/man7/disputes.7 @@ -1,4 +1,4 @@ -.TH "DISPUTES" "7" "November 2019" "" "" +.TH "DISPUTES" "7" "December 2019" "" "" .SH "NAME" \fBdisputes\fR \- Handling Module Name Disputes .P diff --git a/deps/npm/man/man7/orgs.7 b/deps/npm/man/man7/orgs.7 index 2c52a2db466960..bd3adcaa5eca12 100644 --- a/deps/npm/man/man7/orgs.7 +++ b/deps/npm/man/man7/orgs.7 @@ -1,4 +1,4 @@ -.TH "ORGS" "7" "November 2019" "" "" +.TH "ORGS" "7" "December 2019" "" "" .SH "NAME" \fBorgs\fR \- Working with Teams & Orgs .SS Description diff --git a/deps/npm/man/man7/registry.7 b/deps/npm/man/man7/registry.7 index bbb5e802bfb826..c21d6d6e617817 100644 --- a/deps/npm/man/man7/registry.7 +++ b/deps/npm/man/man7/registry.7 @@ -1,4 +1,4 @@ -.TH "REGISTRY" "7" "November 2019" "" "" +.TH "REGISTRY" "7" "December 2019" "" "" .SH "NAME" \fBregistry\fR \- The JavaScript Package Registry .SS Description diff --git a/deps/npm/man/man7/removal.7 b/deps/npm/man/man7/removal.7 index a4df8b446127b2..0a08017f0dcd2b 100644 --- a/deps/npm/man/man7/removal.7 +++ b/deps/npm/man/man7/removal.7 @@ -1,4 +1,4 @@ -.TH "REMOVAL" "7" "November 2019" "" "" +.TH "REMOVAL" "7" "December 2019" "" "" .SH "NAME" \fBremoval\fR \- Cleaning the Slate .SS Synopsis diff --git a/deps/npm/man/man7/scope.7 b/deps/npm/man/man7/scope.7 index ffe5570ae87b33..933e2e23c77430 100644 --- a/deps/npm/man/man7/scope.7 +++ b/deps/npm/man/man7/scope.7 @@ -1,4 +1,4 @@ -.TH "SCOPE" "7" "November 2019" "" "" +.TH "SCOPE" "7" "December 2019" "" "" .SH "NAME" \fBscope\fR \- Scoped packages .SS Description diff --git a/deps/npm/man/man7/scripts.7 b/deps/npm/man/man7/scripts.7 index 7517c5997585fd..a6756a376c59bd 100644 --- a/deps/npm/man/man7/scripts.7 +++ b/deps/npm/man/man7/scripts.7 @@ -1,4 +1,4 @@ -.TH "SCRIPTS" "7" "November 2019" "" "" +.TH "SCRIPTS" "7" "December 2019" "" "" .SH "NAME" \fBscripts\fR \- How npm handles the "scripts" field .SS Description diff --git a/deps/npm/man/man7/semver.7 b/deps/npm/man/man7/semver.7 index b65c475f6eb67e..23d513d4238b28 100644 --- a/deps/npm/man/man7/semver.7 +++ b/deps/npm/man/man7/semver.7 @@ -1,4 +1,4 @@ -.TH "SEMVER" "7" "November 2019" "" "" +.TH "SEMVER" "7" "December 2019" "" "" .SH "NAME" \fBsemver\fR \- The semantic versioner for npm .SH Install diff --git a/deps/npm/node_modules/bin-links/CHANGELOG.md b/deps/npm/node_modules/bin-links/CHANGELOG.md index e5293027887bb3..697e3c53559b40 100644 --- a/deps/npm/node_modules/bin-links/CHANGELOG.md +++ b/deps/npm/node_modules/bin-links/CHANGELOG.md @@ -2,6 +2,36 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. + +## [1.1.6](https://github.com/npm/bin-links/compare/v1.1.5...v1.1.6) (2019-12-11) + + +### Bug Fixes + +* prevent improper clobbering of man/bin links ([642cd18](https://github.com/npm/bin-links/commit/642cd18)), closes [#11](https://github.com/npm/bin-links/issues/11) [#12](https://github.com/npm/bin-links/issues/12) + + + + +## [1.1.5](https://github.com/npm/bin-links/compare/v1.1.4...v1.1.5) (2019-12-10) + + +### Bug Fixes + +* don't filter out ./ man references ([b3cfd2e](https://github.com/npm/bin-links/commit/b3cfd2e)) + + + + +## [1.1.4](https://github.com/npm/bin-links/compare/v1.1.3...v1.1.4) (2019-12-09) + + +### Bug Fixes + +* sanitize and validate bin and man link targets ([25a34f9](https://github.com/npm/bin-links/commit/25a34f9)) + + + ## [1.1.3](https://github.com/npm/bin-links/compare/v1.1.2...v1.1.3) (2019-08-14) diff --git a/deps/npm/node_modules/bin-links/index.js b/deps/npm/node_modules/bin-links/index.js index 5f867554752231..4f6d3c055c02ee 100644 --- a/deps/npm/node_modules/bin-links/index.js +++ b/deps/npm/node_modules/bin-links/index.js @@ -3,18 +3,22 @@ const path = require('path') const fs = require('graceful-fs') const BB = require('bluebird') -const linkIfExists = BB.promisify(require('gentle-fs').linkIfExists) -const cmdShimIfExists = BB.promisify(require('cmd-shim').ifExists) +const gentleFs = require('gentle-fs') +const linkIfExists = BB.promisify(gentleFs.linkIfExists) +const gentleFsBinLink = BB.promisify(gentleFs.binLink) const open = BB.promisify(fs.open) const close = BB.promisify(fs.close) const read = BB.promisify(fs.read, {multiArgs: true}) const chmod = BB.promisify(fs.chmod) const readFile = BB.promisify(fs.readFile) const writeFileAtomic = BB.promisify(require('write-file-atomic')) +const normalize = require('npm-normalize-package-bin') module.exports = BB.promisify(binLinks) function binLinks (pkg, folder, global, opts, cb) { + pkg = normalize(pkg) + // if it's global, and folder is in {prefix}/node_modules, // then bins are in {prefix}/bin // otherwise, then bins are in folder/../.bin @@ -39,9 +43,9 @@ function isHashbangFile (file) { return read(fileHandle, Buffer.alloc(2), 0, 2, 0).spread((_, buf) => { if (!hasHashbang(buf)) return [] return read(fileHandle, Buffer.alloc(2048), 0, 2048, 0) - }).spread((_, buf) => buf && hasCR(buf), () => false) + }).spread((_, buf) => buf && hasCR(buf), /* istanbul ignore next */ () => false) .finally(() => close(fileHandle)) - }).catch(() => false) + }).catch(/* istanbul ignore next */ () => false) } function hasHashbang (buf) { @@ -77,6 +81,12 @@ function linkBins (pkg, folder, parent, gtop, opts) { var dest = path.resolve(binRoot, bin) var src = path.resolve(folder, pkg.bin[bin]) + /* istanbul ignore if - that unpossible */ + if (src.indexOf(folder) !== 0) { + throw new Error('invalid bin entry for package ' + + pkg._id + '. key=' + bin + ', value=' + pkg.bin[bin]) + } + return linkBin(src, dest, linkOpts).then(() => { // bins should always be executable. // XXX skip chmod on windows? @@ -100,6 +110,7 @@ function linkBins (pkg, folder, parent, gtop, opts) { opts.log.showProgress() } }).catch(err => { + /* istanbul ignore next */ if (err.code === 'ENOENT' && opts.ignoreScripts) return throw err }) @@ -107,11 +118,11 @@ function linkBins (pkg, folder, parent, gtop, opts) { } function linkBin (from, to, opts) { - if (process.platform !== 'win32') { - return linkIfExists(from, to, opts) - } else { - return cmdShimIfExists(from, to) + // do not clobber global bins + if (opts.globalBin && to.indexOf(opts.globalBin) === 0) { + opts.clobberLinkGently = true } + return gentleFsBinLink(from, to, opts) } function linkMans (pkg, folder, parent, gtop, opts) { @@ -123,15 +134,22 @@ function linkMans (pkg, folder, parent, gtop, opts) { // make sure that the mans are unique. // otherwise, if there are dupes, it'll fail with EEXIST var set = pkg.man.reduce(function (acc, man) { - acc[path.basename(man)] = man + if (typeof man !== 'string') { + return acc + } + const cleanMan = path.join('/', man).replace(/\\|:/g, '/').substr(1) + acc[path.basename(man)] = cleanMan return acc }, {}) var manpages = pkg.man.filter(function (man) { - return set[path.basename(man)] === man + if (typeof man !== 'string') { + return false + } + const cleanMan = path.join('/', man).replace(/\\|:/g, '/').substr(1) + return set[path.basename(man)] === cleanMan }) return BB.map(manpages, man => { - if (typeof man !== 'string') return opts.log.silly('linkMans', 'preparing to link', man) var parseMan = man.match(/(.*\.([0-9]+)(\.gz)?)$/) if (!parseMan) { @@ -146,8 +164,19 @@ function linkMans (pkg, folder, parent, gtop, opts) { var sxn = parseMan[2] var bn = path.basename(stem) var manSrc = path.resolve(folder, man) + /* istanbul ignore if - that unpossible */ + if (manSrc.indexOf(folder) !== 0) { + throw new Error('invalid man entry for package ' + + pkg._id + '. man=' + manSrc) + } + var manDest = path.join(manRoot, 'man' + sxn, bn) + // man pages should always be clobbering gently, because they are + // only installed for top-level global packages, so never destroy + // a link if it doesn't point into the folder we're linking + opts.clobberLinkGently = true + return linkIfExists(manSrc, manDest, getLinkOpts(opts, gtop && folder)) }) } diff --git a/deps/npm/node_modules/bin-links/package.json b/deps/npm/node_modules/bin-links/package.json index e14be1e6926dfa..a4d2c02226e5f1 100644 --- a/deps/npm/node_modules/bin-links/package.json +++ b/deps/npm/node_modules/bin-links/package.json @@ -1,19 +1,19 @@ { - "_from": "bin-links@1.1.3", - "_id": "bin-links@1.1.3", + "_from": "bin-links@1.1.6", + "_id": "bin-links@1.1.6", "_inBundle": false, - "_integrity": "sha512-TEwmH4PHU/D009stP+fkkazMJgkBNCv60z01lQ/Mn8E6+ThHoD03svMnBVuCowwXo2nP2qKyKZxKxp58OHRzxw==", + "_integrity": "sha512-b5rV3uVyrlrJWLI3mawUUf5t2f9mCEQm/TqT5zNj6DPYhYDZaNp0AYaYd/CVASkSEklayNDLliZHVdo2J3niPw==", "_location": "/bin-links", "_phantomChildren": {}, "_requested": { "type": "version", "registry": true, - "raw": "bin-links@1.1.3", + "raw": "bin-links@1.1.6", "name": "bin-links", "escapedName": "bin-links", - "rawSpec": "1.1.3", + "rawSpec": "1.1.6", "saveSpec": null, - "fetchSpec": "1.1.3" + "fetchSpec": "1.1.6" }, "_requiredBy": [ "#USER", @@ -21,9 +21,9 @@ "/libcipm", "/libnpm" ], - "_resolved": "https://registry.npmjs.org/bin-links/-/bin-links-1.1.3.tgz", - "_shasum": "702fd59552703727313bc624bdbc4c0d3431c2ca", - "_spec": "bin-links@1.1.3", + "_resolved": "https://registry.npmjs.org/bin-links/-/bin-links-1.1.6.tgz", + "_shasum": "30d33e810829305e5e61b90cfcb9a3a4f65eb516", + "_spec": "bin-links@1.1.6", "_where": "/Users/isaacs/dev/npm/cli", "author": { "name": "Mike Sherov" @@ -35,8 +35,9 @@ "dependencies": { "bluebird": "^3.5.3", "cmd-shim": "^3.0.0", - "gentle-fs": "^2.0.1", + "gentle-fs": "^2.3.0", "graceful-fs": "^4.1.15", + "npm-normalize-package-bin": "^1.0.0", "write-file-atomic": "^2.3.0" }, "deprecated": false, @@ -69,12 +70,12 @@ }, "scripts": { "postrelease": "npm publish && git push --follow-tags", + "posttest": "standard", "prerelease": "npm t", - "pretest": "standard", "release": "standard-version -s", - "test": "tap -J --nyc-arg=--all --coverage test/*.js", + "test": "tap -J --nyc-arg=--all --coverage test/*.js --100", "update-coc": "weallbehave -o . && git add CODE_OF_CONDUCT.md && git commit -m 'docs(coc): updated CODE_OF_CONDUCT.md'", "update-contrib": "weallcontribute -o . && git add CONTRIBUTING.md && git commit -m 'docs(contributing): updated CONTRIBUTING.md'" }, - "version": "1.1.3" + "version": "1.1.6" } diff --git a/deps/npm/node_modules/gentle-fs/CHANGELOG.md b/deps/npm/node_modules/gentle-fs/CHANGELOG.md index 38fc91cba587d9..50dfcd74c99f1c 100644 --- a/deps/npm/node_modules/gentle-fs/CHANGELOG.md +++ b/deps/npm/node_modules/gentle-fs/CHANGELOG.md @@ -2,6 +2,16 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. + +# [2.3.0](https://github.com/npm/gentle-fs/compare/v2.2.1...v2.3.0) (2019-12-11) + + +### Features + +* add option to gently create bin links/shims ([a929196](https://github.com/npm/gentle-fs/commit/a929196)) + + + ## [2.2.1](https://github.com/npm/gentle-fs/compare/v2.2.0...v2.2.1) (2019-08-15) diff --git a/deps/npm/node_modules/gentle-fs/index.js b/deps/npm/node_modules/gentle-fs/index.js index 9807ed9d8580be..4aeda1c846bf2b 100644 --- a/deps/npm/node_modules/gentle-fs/index.js +++ b/deps/npm/node_modules/gentle-fs/index.js @@ -3,10 +3,12 @@ const rm = require('./lib/rm.js') const link = require('./lib/link.js') const mkdir = require('./lib/mkdir.js') +const binLink = require('./lib/bin-link.js') exports = module.exports = { rm: rm, link: link.link, linkIfExists: link.linkIfExists, - mkdir: mkdir + mkdir: mkdir, + binLink: binLink } diff --git a/deps/npm/node_modules/gentle-fs/lib/bin-link.js b/deps/npm/node_modules/gentle-fs/lib/bin-link.js new file mode 100644 index 00000000000000..104c5b6c935c88 --- /dev/null +++ b/deps/npm/node_modules/gentle-fs/lib/bin-link.js @@ -0,0 +1,96 @@ +'use strict' +// calls linkIfExists on unix, or cmdShimIfExists on Windows +// reads the cmd shim to ensure it's where we need it to be in the case of +// top level global packages + +const readCmdShim = require('read-cmd-shim') +const cmdShim = require('cmd-shim') +const {linkIfExists} = require('./link.js') + +const binLink = (from, to, opts, cb) => { + // just for testing + const platform = opts._FAKE_PLATFORM_ || process.platform + if (platform !== 'win32') { + return linkIfExists(from, to, opts, cb) + } + + if (!opts.clobberLinkGently || + opts.force === true || + !opts.gently || + typeof opts.gently !== 'string') { + // easy, just go ahead and delete anything in the way + return cmdShim.ifExists(from, to, cb) + } + + // read all three shim targets + // if any exist, and are not a shim to our gently folder, then + // exit with a simulated EEXIST error. + + const shimFiles = [ + to, + to + '.cmd', + to + '.ps1' + ] + + // call this once we've checked all three, if we're good + const done = () => cmdShim.ifExists(from, to, cb) + const then = times(3, done, cb) + shimFiles.forEach(to => isClobberable(from, to, opts, then)) +} + +const times = (n, ok, cb) => { + let errState = null + return er => { + if (!errState) { + if (er) { + cb(errState = er) + } else if (--n === 0) { + ok() + } + } + } +} + +const isClobberable = (from, to, opts, cb) => { + readCmdShim(to, (er, target) => { + // either going to get an error, or the target of where this + // cmd shim points. + // shim, not in opts.gently: simulate EEXIST + // not a shim: simulate EEXIST + // ENOENT: fine, move forward + // shim in opts.gently: fine + if (er) { + switch (er.code) { + case 'ENOENT': + // totally fine, nothing there to clobber + return cb() + case 'ENOTASHIM': + // something is there, and it's not one of ours + return cb(simulateEEXIST(from, to)) + default: + // would probably fail this way later anyway + // can't read the file, likely can't write it either + return cb(er) + } + } + // no error, check the target + if (target.indexOf(opts.gently) !== 0) { + return cb(simulateEEXIST(from, to)) + } + // ok! it's one of ours. + return cb() + }) +} + +const simulateEEXIST = (from, to) => { + // simulate the EEXIST we'd get from fs.symlink to the file + const err = new Error('EEXIST: file already exists, cmd shim \'' + + from + '\' -> \'' + to + '\'') + + err.code = 'EEXIST' + err.path = from + err.dest = to + return err +} + +module.exports = binLink diff --git a/deps/npm/node_modules/gentle-fs/lib/link.js b/deps/npm/node_modules/gentle-fs/lib/link.js index 4623e7e82cf882..7cdfef4ca95d39 100644 --- a/deps/npm/node_modules/gentle-fs/lib/link.js +++ b/deps/npm/node_modules/gentle-fs/lib/link.js @@ -14,15 +14,22 @@ exports = module.exports = { } function linkIfExists (from, to, opts, cb) { + opts.currentIsLink = false + opts.currentExists = false fs.stat(from, function (er) { if (er) return cb() fs.readlink(to, function (er, fromOnDisk) { + if (!er || er.code !== 'ENOENT') { + opts.currentExists = true + } // if the link already exists and matches what we would do, // we don't need to do anything if (!er) { + opts.currentIsLink = true var toDir = path.dirname(to) var absoluteFrom = path.resolve(toDir, from) var absoluteFromOnDisk = path.resolve(toDir, fromOnDisk) + opts.currentTarget = absoluteFromOnDisk if (absoluteFrom === absoluteFromOnDisk) return cb() } link(from, to, opts, cb) @@ -58,7 +65,7 @@ function link (from, to, opts, cb) { const tasks = [ [ensureFromIsNotSource, absTarget, to], [fs, 'stat', absTarget], - [rm, to, opts], + [clobberLinkGently, from, to, opts], [mkdir, path.dirname(to)], [fs, 'symlink', target, to, 'junction'] ] @@ -72,3 +79,48 @@ function link (from, to, opts, cb) { }) } } + +exports._clobberLinkGently = clobberLinkGently +function clobberLinkGently (from, to, opts, cb) { + if (opts.currentExists === false) { + // nothing to clobber! + opts.log.silly('gently link', 'link does not already exist', { + link: to, + target: from + }) + return cb() + } + + if (!opts.clobberLinkGently || + opts.force === true || + !opts.gently || + typeof opts.gently !== 'string') { + opts.log.silly('gently link', 'deleting existing link forcefully', { + link: to, + target: from, + force: opts.force, + gently: opts.gently, + clobberLinkGently: opts.clobberLinkGently + }) + return rm(to, opts, cb) + } + + if (!opts.currentIsLink) { + opts.log.verbose('gently link', 'cannot remove, not a link', to) + // don't delete. it'll fail with EEXIST when it tries to symlink. + return cb() + } + + if (opts.currentTarget.indexOf(opts.gently) === 0) { + opts.log.silly('gently link', 'delete existing link', to) + return rm(to, opts, cb) + } else { + opts.log.verbose('gently link', 'refusing to delete existing link', { + link: to, + currentTarget: opts.currentTarget, + newTarget: from, + gently: opts.gently + }) + return cb() + } +} diff --git a/deps/npm/node_modules/gentle-fs/package.json b/deps/npm/node_modules/gentle-fs/package.json index bf4867c08d328a..d162899757b0f7 100644 --- a/deps/npm/node_modules/gentle-fs/package.json +++ b/deps/npm/node_modules/gentle-fs/package.json @@ -1,28 +1,28 @@ { - "_from": "gentle-fs@2.2.1", - "_id": "gentle-fs@2.2.1", + "_from": "gentle-fs@2.3.0", + "_id": "gentle-fs@2.3.0", "_inBundle": false, - "_integrity": "sha512-e7dRgUM5fsS+7wm2oggZpgcRx6sEvJHXujPH5RzgQ1ziQY4+HuVBYsnUzJwJ+C7mjOJN27DjiFy1TaL+TNltow==", + "_integrity": "sha512-3k2CgAmPxuz7S6nKK+AqFE2AdM1QuwqKLPKzIET3VRwK++3q96MsNFobScDjlCrq97ZJ8y5R725MOlm6ffUCjg==", "_location": "/gentle-fs", "_phantomChildren": {}, "_requested": { "type": "version", "registry": true, - "raw": "gentle-fs@2.2.1", + "raw": "gentle-fs@2.3.0", "name": "gentle-fs", "escapedName": "gentle-fs", - "rawSpec": "2.2.1", + "rawSpec": "2.3.0", "saveSpec": null, - "fetchSpec": "2.2.1" + "fetchSpec": "2.3.0" }, "_requiredBy": [ "#USER", "/", "/bin-links" ], - "_resolved": "https://registry.npmjs.org/gentle-fs/-/gentle-fs-2.2.1.tgz", - "_shasum": "1f38df4b4ead685566257201fd526de401ebb215", - "_spec": "gentle-fs@2.2.1", + "_resolved": "https://registry.npmjs.org/gentle-fs/-/gentle-fs-2.3.0.tgz", + "_shasum": "13538db5029400f98684be4894e8a7d8f0d1ea7f", + "_spec": "gentle-fs@2.3.0", "_where": "/Users/isaacs/dev/npm/cli", "author": { "name": "Mike Sherov" @@ -34,6 +34,7 @@ "dependencies": { "aproba": "^1.1.2", "chownr": "^1.1.2", + "cmd-shim": "^3.0.3", "fs-vacuum": "^1.2.10", "graceful-fs": "^4.1.11", "iferr": "^0.1.5", @@ -74,12 +75,12 @@ }, "scripts": { "postrelease": "npm publish && git push --follow-tags", + "posttest": "standard", "prerelease": "npm t", - "pretest": "standard", "release": "standard-version -s", - "test": "tap -J --nyc-arg=--all --coverage test/*.js test/**/*.js", + "test": "tap -J --nyc-arg=--all --coverage test", "update-coc": "weallbehave -o . && git add CODE_OF_CONDUCT.md && git commit -m 'docs(coc): updated CODE_OF_CONDUCT.md'", "update-contrib": "weallcontribute -o . && git add CONTRIBUTING.md && git commit -m 'docs(contributing): updated CONTRIBUTING.md'" }, - "version": "2.2.1" + "version": "2.3.0" } diff --git a/deps/npm/node_modules/json-schema/README.md b/deps/npm/node_modules/json-schema/README.md index 4de0124476e98c..78b81d39683251 100644 --- a/deps/npm/node_modules/json-schema/README.md +++ b/deps/npm/node_modules/json-schema/README.md @@ -1,5 +1,5 @@ JSON Schema is a repository for the JSON Schema specification, reference schemas and a CommonJS implementation of JSON Schema (not the only JavaScript implementation of JSON Schema, JSV is another excellent JavaScript validator). -Code is licensed under the AFL or BSD license as part of the Persevere +Code is licensed under the AFL or BSD license as part of the Persevere project which is administered under the Dojo foundation, and all contributions require a Dojo CLA. \ No newline at end of file diff --git a/deps/npm/node_modules/json-schema/draft-00/hyper-schema b/deps/npm/node_modules/json-schema/draft-00/hyper-schema index de80b918b671c7..36a85ccd244926 100644 --- a/deps/npm/node_modules/json-schema/draft-00/hyper-schema +++ b/deps/npm/node_modules/json-schema/draft-00/hyper-schema @@ -8,61 +8,61 @@ "items" : {"$ref" : "http://json-schema.org/draft-00/links#"}, "optional" : true }, - + "fragmentResolution" : { "type" : "string", "optional" : true, "default" : "dot-delimited" }, - + "root" : { "type" : "boolean", "optional" : true, "default" : false }, - + "readonly" : { "type" : "boolean", "optional" : true, "default" : false }, - + "pathStart" : { "type" : "string", "optional" : true, "format" : "uri" }, - + "mediaType" : { "type" : "string", "optional" : true, "format" : "media-type" }, - + "alternate" : { "type" : "array", "items" : {"$ref" : "#"}, "optional" : true } }, - + "links" : [ { "href" : "{$ref}", "rel" : "full" }, - + { "href" : "{$schema}", "rel" : "describedby" }, - + { "href" : "{id}", "rel" : "self" } ], - + "fragmentResolution" : "dot-delimited", "extends" : {"$ref" : "http://json-schema.org/draft-00/schema#"} } \ No newline at end of file diff --git a/deps/npm/node_modules/json-schema/draft-00/json-ref b/deps/npm/node_modules/json-schema/draft-00/json-ref index 3a872a71c973dc..5d1f76b6a694a4 100644 --- a/deps/npm/node_modules/json-schema/draft-00/json-ref +++ b/deps/npm/node_modules/json-schema/draft-00/json-ref @@ -1,26 +1,26 @@ { "$schema" : "http://json-schema.org/draft-00/hyper-schema#", "id" : "http://json-schema.org/draft-00/json-ref#", - + "items" : {"$ref" : "#"}, "additionalProperties" : {"$ref" : "#"}, - + "links" : [ { "href" : "{$ref}", "rel" : "full" }, - + { "href" : "{$schema}", "rel" : "describedby" }, - + { "href" : "{id}", "rel" : "self" } ], - + "fragmentResolution" : "dot-delimited" } \ No newline at end of file diff --git a/deps/npm/node_modules/json-schema/draft-00/links b/deps/npm/node_modules/json-schema/draft-00/links index 8a5e7807250cf9..cbef326dd3de5b 100644 --- a/deps/npm/node_modules/json-schema/draft-00/links +++ b/deps/npm/node_modules/json-schema/draft-00/links @@ -2,28 +2,28 @@ "$schema" : "http://json-schema.org/draft-00/hyper-schema#", "id" : "http://json-schema.org/draft-00/links#", "type" : "object", - + "properties" : { "href" : { "type" : "string" }, - + "rel" : { "type" : "string" }, - + "method" : { "type" : "string", "default" : "GET", "optional" : true }, - + "enctype" : { "type" : "string", "requires" : "method", "optional" : true }, - + "properties" : { "type" : "object", "additionalProperties" : {"$ref" : "http://json-schema.org/draft-00/hyper-schema#"}, diff --git a/deps/npm/node_modules/json-schema/draft-00/schema b/deps/npm/node_modules/json-schema/draft-00/schema index 9aa2fbc57a4054..d452b023ee484a 100644 --- a/deps/npm/node_modules/json-schema/draft-00/schema +++ b/deps/npm/node_modules/json-schema/draft-00/schema @@ -2,7 +2,7 @@ "$schema" : "http://json-schema.org/draft-00/hyper-schema#", "id" : "http://json-schema.org/draft-00/schema#", "type" : "object", - + "properties" : { "type" : { "type" : ["string", "array"], @@ -12,136 +12,136 @@ "optional" : true, "default" : "any" }, - + "properties" : { "type" : "object", "additionalProperties" : {"$ref" : "#"}, "optional" : true, "default" : {} }, - + "items" : { "type" : [{"$ref" : "#"}, "array"], "items" : {"$ref" : "#"}, "optional" : true, "default" : {} }, - + "optional" : { "type" : "boolean", "optional" : true, "default" : false }, - + "additionalProperties" : { "type" : [{"$ref" : "#"}, "boolean"], "optional" : true, "default" : {} }, - + "requires" : { "type" : ["string", {"$ref" : "#"}], "optional" : true }, - + "minimum" : { "type" : "number", "optional" : true }, - + "maximum" : { "type" : "number", "optional" : true }, - + "minimumCanEqual" : { "type" : "boolean", "optional" : true, "requires" : "minimum", "default" : true }, - + "maximumCanEqual" : { "type" : "boolean", "optional" : true, "requires" : "maximum", "default" : true }, - + "minItems" : { "type" : "integer", "optional" : true, "minimum" : 0, "default" : 0 }, - + "maxItems" : { "type" : "integer", "optional" : true, "minimum" : 0 }, - + "pattern" : { "type" : "string", "optional" : true, "format" : "regex" }, - + "minLength" : { "type" : "integer", "optional" : true, "minimum" : 0, "default" : 0 }, - + "maxLength" : { "type" : "integer", "optional" : true }, - + "enum" : { "type" : "array", "optional" : true, "minItems" : 1 }, - + "title" : { "type" : "string", "optional" : true }, - + "description" : { "type" : "string", "optional" : true }, - + "format" : { "type" : "string", "optional" : true }, - + "contentEncoding" : { "type" : "string", "optional" : true }, - + "default" : { "type" : "any", "optional" : true }, - + "maxDecimal" : { "type" : "integer", "optional" : true, "minimum" : 0 }, - + "disallow" : { "type" : ["string", "array"], "items" : {"type" : "string"}, "optional" : true }, - + "extends" : { "type" : [{"$ref" : "#"}, "array"], "items" : {"$ref" : "#"}, @@ -149,7 +149,7 @@ "default" : {} } }, - + "optional" : true, "default" : {} } \ No newline at end of file diff --git a/deps/npm/node_modules/json-schema/draft-01/hyper-schema b/deps/npm/node_modules/json-schema/draft-01/hyper-schema index 3f6c6cc2c012df..b0fb5e157ef9bd 100644 --- a/deps/npm/node_modules/json-schema/draft-01/hyper-schema +++ b/deps/npm/node_modules/json-schema/draft-01/hyper-schema @@ -8,61 +8,61 @@ "items" : {"$ref" : "http://json-schema.org/draft-01/links#"}, "optional" : true }, - + "fragmentResolution" : { "type" : "string", "optional" : true, "default" : "dot-delimited" }, - + "root" : { "type" : "boolean", "optional" : true, "default" : false }, - + "readonly" : { "type" : "boolean", "optional" : true, "default" : false }, - + "pathStart" : { "type" : "string", "optional" : true, "format" : "uri" }, - + "mediaType" : { "type" : "string", "optional" : true, "format" : "media-type" }, - + "alternate" : { "type" : "array", "items" : {"$ref" : "#"}, "optional" : true } }, - + "links" : [ { "href" : "{$ref}", "rel" : "full" }, - + { "href" : "{$schema}", "rel" : "describedby" }, - + { "href" : "{id}", "rel" : "self" } ], - + "fragmentResolution" : "dot-delimited", "extends" : {"$ref" : "http://json-schema.org/draft-01/schema#"} } \ No newline at end of file diff --git a/deps/npm/node_modules/json-schema/draft-01/json-ref b/deps/npm/node_modules/json-schema/draft-01/json-ref index 4d26174ef17ad9..cbac1ba2e53286 100644 --- a/deps/npm/node_modules/json-schema/draft-01/json-ref +++ b/deps/npm/node_modules/json-schema/draft-01/json-ref @@ -1,26 +1,26 @@ { "$schema" : "http://json-schema.org/draft-01/hyper-schema#", "id" : "http://json-schema.org/draft-01/json-ref#", - + "items" : {"$ref" : "#"}, "additionalProperties" : {"$ref" : "#"}, - + "links" : [ { "href" : "{$ref}", "rel" : "full" }, - + { "href" : "{$schema}", "rel" : "describedby" }, - + { "href" : "{id}", "rel" : "self" } ], - + "fragmentResolution" : "dot-delimited" } \ No newline at end of file diff --git a/deps/npm/node_modules/json-schema/draft-01/links b/deps/npm/node_modules/json-schema/draft-01/links index 52430a5d94ac75..ebc7b7b58b1326 100644 --- a/deps/npm/node_modules/json-schema/draft-01/links +++ b/deps/npm/node_modules/json-schema/draft-01/links @@ -2,28 +2,28 @@ "$schema" : "http://json-schema.org/draft-01/hyper-schema#", "id" : "http://json-schema.org/draft-01/links#", "type" : "object", - + "properties" : { "href" : { "type" : "string" }, - + "rel" : { "type" : "string" }, - + "method" : { "type" : "string", "default" : "GET", "optional" : true }, - + "enctype" : { "type" : "string", "requires" : "method", "optional" : true }, - + "properties" : { "type" : "object", "additionalProperties" : {"$ref" : "http://json-schema.org/draft-01/hyper-schema#"}, diff --git a/deps/npm/node_modules/json-schema/draft-01/schema b/deps/npm/node_modules/json-schema/draft-01/schema index 7a208e680e631b..a0f3801f840cca 100644 --- a/deps/npm/node_modules/json-schema/draft-01/schema +++ b/deps/npm/node_modules/json-schema/draft-01/schema @@ -2,7 +2,7 @@ "$schema" : "http://json-schema.org/draft-01/hyper-schema#", "id" : "http://json-schema.org/draft-01/schema#", "type" : "object", - + "properties" : { "type" : { "type" : ["string", "array"], @@ -12,136 +12,136 @@ "optional" : true, "default" : "any" }, - + "properties" : { "type" : "object", "additionalProperties" : {"$ref" : "#"}, "optional" : true, "default" : {} }, - + "items" : { "type" : [{"$ref" : "#"}, "array"], "items" : {"$ref" : "#"}, "optional" : true, "default" : {} }, - + "optional" : { "type" : "boolean", "optional" : true, "default" : false }, - + "additionalProperties" : { "type" : [{"$ref" : "#"}, "boolean"], "optional" : true, "default" : {} }, - + "requires" : { "type" : ["string", {"$ref" : "#"}], "optional" : true }, - + "minimum" : { "type" : "number", "optional" : true }, - + "maximum" : { "type" : "number", "optional" : true }, - + "minimumCanEqual" : { "type" : "boolean", "optional" : true, "requires" : "minimum", "default" : true }, - + "maximumCanEqual" : { "type" : "boolean", "optional" : true, "requires" : "maximum", "default" : true }, - + "minItems" : { "type" : "integer", "optional" : true, "minimum" : 0, "default" : 0 }, - + "maxItems" : { "type" : "integer", "optional" : true, "minimum" : 0 }, - + "pattern" : { "type" : "string", "optional" : true, "format" : "regex" }, - + "minLength" : { "type" : "integer", "optional" : true, "minimum" : 0, "default" : 0 }, - + "maxLength" : { "type" : "integer", "optional" : true }, - + "enum" : { "type" : "array", "optional" : true, "minItems" : 1 }, - + "title" : { "type" : "string", "optional" : true }, - + "description" : { "type" : "string", "optional" : true }, - + "format" : { "type" : "string", "optional" : true }, - + "contentEncoding" : { "type" : "string", "optional" : true }, - + "default" : { "type" : "any", "optional" : true }, - + "maxDecimal" : { "type" : "integer", "optional" : true, "minimum" : 0 }, - + "disallow" : { "type" : ["string", "array"], "items" : {"type" : "string"}, "optional" : true }, - + "extends" : { "type" : [{"$ref" : "#"}, "array"], "items" : {"$ref" : "#"}, @@ -149,7 +149,7 @@ "default" : {} } }, - + "optional" : true, "default" : {} } \ No newline at end of file diff --git a/deps/npm/node_modules/json-schema/draft-02/hyper-schema b/deps/npm/node_modules/json-schema/draft-02/hyper-schema index 4ec1b7569137c3..0771e2b31e8eef 100644 --- a/deps/npm/node_modules/json-schema/draft-02/hyper-schema +++ b/deps/npm/node_modules/json-schema/draft-02/hyper-schema @@ -8,61 +8,61 @@ "items" : {"$ref" : "http://json-schema.org/draft-02/links#"}, "optional" : true }, - + "fragmentResolution" : { "type" : "string", "optional" : true, "default" : "slash-delimited" }, - + "root" : { "type" : "boolean", "optional" : true, "default" : false }, - + "readonly" : { "type" : "boolean", "optional" : true, "default" : false }, - + "pathStart" : { "type" : "string", "optional" : true, "format" : "uri" }, - + "mediaType" : { "type" : "string", "optional" : true, "format" : "media-type" }, - + "alternate" : { "type" : "array", "items" : {"$ref" : "#"}, "optional" : true } }, - + "links" : [ { "href" : "{$ref}", "rel" : "full" }, - + { "href" : "{$schema}", "rel" : "describedby" }, - + { "href" : "{id}", "rel" : "self" } ], - + "fragmentResolution" : "slash-delimited", "extends" : {"$ref" : "http://json-schema.org/draft-02/schema#"} } \ No newline at end of file diff --git a/deps/npm/node_modules/json-schema/draft-02/json-ref b/deps/npm/node_modules/json-schema/draft-02/json-ref index 6526c394556665..1a6c56d04b665a 100644 --- a/deps/npm/node_modules/json-schema/draft-02/json-ref +++ b/deps/npm/node_modules/json-schema/draft-02/json-ref @@ -1,26 +1,26 @@ { "$schema" : "http://json-schema.org/draft-02/hyper-schema#", "id" : "http://json-schema.org/draft-02/json-ref#", - + "items" : {"$ref" : "#"}, "additionalProperties" : {"$ref" : "#"}, - + "links" : [ { "href" : "{$ref}", "rel" : "full" }, - + { "href" : "{$schema}", "rel" : "describedby" }, - + { "href" : "{id}", "rel" : "self" } ], - + "fragmentResolution" : "dot-delimited" } \ No newline at end of file diff --git a/deps/npm/node_modules/json-schema/draft-02/links b/deps/npm/node_modules/json-schema/draft-02/links index 1b176178a2c333..dacc53a1a4adb6 100644 --- a/deps/npm/node_modules/json-schema/draft-02/links +++ b/deps/npm/node_modules/json-schema/draft-02/links @@ -2,30 +2,30 @@ "$schema" : "http://json-schema.org/draft-02/hyper-schema#", "id" : "http://json-schema.org/draft-02/links#", "type" : "object", - + "properties" : { "href" : { "type" : "string" }, - + "rel" : { "type" : "string" }, - + "targetSchema" : {"$ref" : "http://json-schema.org/draft-02/hyper-schema#"}, - + "method" : { "type" : "string", "default" : "GET", "optional" : true }, - + "enctype" : { "type" : "string", "requires" : "method", "optional" : true }, - + "properties" : { "type" : "object", "additionalProperties" : {"$ref" : "http://json-schema.org/draft-02/hyper-schema#"}, diff --git a/deps/npm/node_modules/json-schema/draft-02/schema b/deps/npm/node_modules/json-schema/draft-02/schema index 61b8de15483962..a4998abea2065e 100644 --- a/deps/npm/node_modules/json-schema/draft-02/schema +++ b/deps/npm/node_modules/json-schema/draft-02/schema @@ -2,7 +2,7 @@ "$schema" : "http://json-schema.org/draft-02/hyper-schema#", "id" : "http://json-schema.org/draft-02/schema#", "type" : "object", - + "properties" : { "type" : { "type" : ["string", "array"], @@ -13,131 +13,131 @@ "uniqueItems" : true, "default" : "any" }, - + "properties" : { "type" : "object", "additionalProperties" : {"$ref" : "#"}, "optional" : true, "default" : {} }, - + "items" : { "type" : [{"$ref" : "#"}, "array"], "items" : {"$ref" : "#"}, "optional" : true, "default" : {} }, - + "optional" : { "type" : "boolean", "optional" : true, "default" : false }, - + "additionalProperties" : { "type" : [{"$ref" : "#"}, "boolean"], "optional" : true, "default" : {} }, - + "requires" : { "type" : ["string", {"$ref" : "#"}], "optional" : true }, - + "minimum" : { "type" : "number", "optional" : true }, - + "maximum" : { "type" : "number", "optional" : true }, - + "minimumCanEqual" : { "type" : "boolean", "optional" : true, "requires" : "minimum", "default" : true }, - + "maximumCanEqual" : { "type" : "boolean", "optional" : true, "requires" : "maximum", "default" : true }, - + "minItems" : { "type" : "integer", "optional" : true, "minimum" : 0, "default" : 0 }, - + "maxItems" : { "type" : "integer", "optional" : true, "minimum" : 0 }, - + "uniqueItems" : { "type" : "boolean", "optional" : true, "default" : false }, - + "pattern" : { "type" : "string", "optional" : true, "format" : "regex" }, - + "minLength" : { "type" : "integer", "optional" : true, "minimum" : 0, "default" : 0 }, - + "maxLength" : { "type" : "integer", "optional" : true }, - + "enum" : { "type" : "array", "optional" : true, "minItems" : 1, "uniqueItems" : true }, - + "title" : { "type" : "string", "optional" : true }, - + "description" : { "type" : "string", "optional" : true }, - + "format" : { "type" : "string", "optional" : true }, - + "contentEncoding" : { "type" : "string", "optional" : true }, - + "default" : { "type" : "any", "optional" : true }, - + "divisibleBy" : { "type" : "number", "minimum" : 0, @@ -145,14 +145,14 @@ "optional" : true, "default" : 1 }, - + "disallow" : { "type" : ["string", "array"], "items" : {"type" : "string"}, "optional" : true, "uniqueItems" : true }, - + "extends" : { "type" : [{"$ref" : "#"}, "array"], "items" : {"$ref" : "#"}, @@ -160,7 +160,7 @@ "default" : {} } }, - + "optional" : true, "default" : {} } \ No newline at end of file diff --git a/deps/npm/node_modules/json-schema/draft-03/examples/calendar b/deps/npm/node_modules/json-schema/draft-03/examples/calendar index 463cfb314b6431..d8fb5335f081b4 100644 --- a/deps/npm/node_modules/json-schema/draft-03/examples/calendar +++ b/deps/npm/node_modules/json-schema/draft-03/examples/calendar @@ -12,12 +12,12 @@ "type":"string", "required":true }, - "location" : { - "type" : "string" + "location" : { + "type" : "string" }, "url" : { - "type" : "string", - "format" : "url" + "type" : "string", + "format" : "url" }, "dtend" : { "format" : "date-time", @@ -47,7 +47,3 @@ "geo" : { "$ref" : "http://json-schema.org/draft-03/geo" } } } - - - - diff --git a/deps/npm/node_modules/json-schema/draft-03/examples/interfaces b/deps/npm/node_modules/json-schema/draft-03/examples/interfaces index 288a19856b7263..84ebf83a993f6d 100644 --- a/deps/npm/node_modules/json-schema/draft-03/examples/interfaces +++ b/deps/npm/node_modules/json-schema/draft-03/examples/interfaces @@ -6,18 +6,18 @@ "type":"object", "description":"This defines the set of methods available to the class instances", "additionalProperties":{ - "type":"object", - "description":"The definition of the method", - "properties":{ - "parameters":{ - "type":"array", - "description":"The set of parameters that should be passed to the method when it is called", - "items":{"$ref":"#"}, - "required": true - }, - "returns":{"$ref":"#"} - } + "type":"object", + "description":"The definition of the method", + "properties":{ + "parameters":{ + "type":"array", + "description":"The set of parameters that should be passed to the method when it is called", + "items":{"$ref":"#"}, + "required": true + }, + "returns":{"$ref":"#"} + } } - } + } } } diff --git a/deps/npm/node_modules/json-schema/draft-03/json-ref b/deps/npm/node_modules/json-schema/draft-03/json-ref index 7e491a8e882347..388476323a08ab 100644 --- a/deps/npm/node_modules/json-schema/draft-03/json-ref +++ b/deps/npm/node_modules/json-schema/draft-03/json-ref @@ -1,26 +1,26 @@ { "$schema" : "http://json-schema.org/draft-03/hyper-schema#", "id" : "http://json-schema.org/draft-03/json-ref#", - + "additionalItems" : {"$ref" : "#"}, "additionalProperties" : {"$ref" : "#"}, - + "links" : [ { "href" : "{id}", "rel" : "self" }, - + { "href" : "{$ref}", "rel" : "full" }, - + { "href" : "{$schema}", "rel" : "describedby" } ], - + "fragmentResolution" : "dot-delimited" } \ No newline at end of file diff --git a/deps/npm/node_modules/json-schema/draft-03/links b/deps/npm/node_modules/json-schema/draft-03/links index 6b0a85a6295b25..3dbcdba73cc4e8 100644 --- a/deps/npm/node_modules/json-schema/draft-03/links +++ b/deps/npm/node_modules/json-schema/draft-03/links @@ -2,31 +2,31 @@ "$schema" : "http://json-schema.org/draft-03/hyper-schema#", "id" : "http://json-schema.org/draft-03/links#", "type" : "object", - + "properties" : { "href" : { "type" : "string", "required" : true, "format" : "link-description-object-template" }, - + "rel" : { "type" : "string", "required" : true }, - + "targetSchema" : {"$ref" : "http://json-schema.org/draft-03/hyper-schema#"}, - + "method" : { "type" : "string", "default" : "GET" }, - + "enctype" : { "type" : "string", "requires" : "method" }, - + "properties" : { "type" : "object", "additionalProperties" : {"$ref" : "http://json-schema.org/draft-03/hyper-schema#"} diff --git a/deps/npm/node_modules/json-schema/draft-03/schema b/deps/npm/node_modules/json-schema/draft-03/schema index 55ae47d808c0ab..361456d8a7e89e 100644 --- a/deps/npm/node_modules/json-schema/draft-03/schema +++ b/deps/npm/node_modules/json-schema/draft-03/schema @@ -2,7 +2,7 @@ "$schema" : "http://json-schema.org/draft-03/schema#", "id" : "http://json-schema.org/draft-03/schema#", "type" : "object", - + "properties" : { "type" : { "type" : ["string", "array"], @@ -12,40 +12,40 @@ "uniqueItems" : true, "default" : "any" }, - + "properties" : { "type" : "object", "additionalProperties" : {"$ref" : "#"}, "default" : {} }, - + "patternProperties" : { "type" : "object", "additionalProperties" : {"$ref" : "#"}, "default" : {} }, - + "additionalProperties" : { "type" : [{"$ref" : "#"}, "boolean"], "default" : {} }, - + "items" : { "type" : [{"$ref" : "#"}, "array"], "items" : {"$ref" : "#"}, "default" : {} }, - + "additionalItems" : { "type" : [{"$ref" : "#"}, "boolean"], "default" : {} }, - + "required" : { "type" : "boolean", "default" : false }, - + "dependencies" : { "type" : "object", "additionalProperties" : { @@ -56,85 +56,85 @@ }, "default" : {} }, - + "minimum" : { "type" : "number" }, - + "maximum" : { "type" : "number" }, - + "exclusiveMinimum" : { "type" : "boolean", "default" : false }, - + "exclusiveMaximum" : { "type" : "boolean", "default" : false }, - + "minItems" : { "type" : "integer", "minimum" : 0, "default" : 0 }, - + "maxItems" : { "type" : "integer", "minimum" : 0 }, - + "uniqueItems" : { "type" : "boolean", "default" : false }, - + "pattern" : { "type" : "string", "format" : "regex" }, - + "minLength" : { "type" : "integer", "minimum" : 0, "default" : 0 }, - + "maxLength" : { "type" : "integer" }, - + "enum" : { "type" : "array", "minItems" : 1, "uniqueItems" : true }, - + "default" : { "type" : "any" }, - + "title" : { "type" : "string" }, - + "description" : { "type" : "string" }, - + "format" : { "type" : "string" }, - + "divisibleBy" : { "type" : "number", "minimum" : 0, "exclusiveMinimum" : true, "default" : 1 }, - + "disallow" : { "type" : ["string", "array"], "items" : { @@ -142,33 +142,33 @@ }, "uniqueItems" : true }, - + "extends" : { "type" : [{"$ref" : "#"}, "array"], "items" : {"$ref" : "#"}, "default" : {} }, - + "id" : { "type" : "string", "format" : "uri" }, - + "$ref" : { "type" : "string", "format" : "uri" }, - + "$schema" : { "type" : "string", "format" : "uri" } }, - + "dependencies" : { "exclusiveMinimum" : "minimum", "exclusiveMaximum" : "maximum" }, - + "default" : {} } \ No newline at end of file diff --git a/deps/npm/node_modules/json-schema/draft-04/links b/deps/npm/node_modules/json-schema/draft-04/links index de272cc4513d0a..7cf7c92c20965c 100644 --- a/deps/npm/node_modules/json-schema/draft-04/links +++ b/deps/npm/node_modules/json-schema/draft-04/links @@ -2,7 +2,7 @@ "$schema" : "http://json-schema.org/draft-04/hyper-schema#", "id" : "http://json-schema.org/draft-04/links#", "type" : "object", - + "properties" : { "rel" : { "type" : "string" @@ -15,26 +15,26 @@ "template" : { "type" : "string" }, - + "targetSchema" : {"$ref" : "http://json-schema.org/draft-04/hyper-schema#"}, - + "method" : { "type" : "string", "default" : "GET" }, - + "enctype" : { "type" : "string" }, - + "properties" : { "type" : "object", "additionalProperties" : {"$ref" : "http://json-schema.org/draft-04/hyper-schema#"} } }, - + "required" : ["rel", "href"], - + "dependencies" : { "enctype" : "method" } diff --git a/deps/npm/node_modules/json-schema/draft-04/schema b/deps/npm/node_modules/json-schema/draft-04/schema index 598951e57d2eb7..e9c90699fda128 100644 --- a/deps/npm/node_modules/json-schema/draft-04/schema +++ b/deps/npm/node_modules/json-schema/draft-04/schema @@ -2,7 +2,7 @@ "$schema" : "http://json-schema.org/draft-04/schema#", "id" : "http://json-schema.org/draft-04/schema#", "type" : "object", - + "properties" : { "type" : { "type" : [ @@ -10,19 +10,19 @@ "id" : "#simple-type", "type" : "string", "enum" : ["object", "array", "string", "number", "boolean", "null", "any"] - }, + }, "array" ], "items" : { "type" : [ - {"$ref" : "#simple-type"}, + {"$ref" : "#simple-type"}, {"$ref" : "#"} ] }, "uniqueItems" : true, "default" : "any" }, - + "disallow" : { "type" : ["string", "array"], "items" : { @@ -30,7 +30,7 @@ }, "uniqueItems" : true }, - + "extends" : { "type" : [{"$ref" : "#"}, "array"], "items" : {"$ref" : "#"}, @@ -42,108 +42,108 @@ "minItems" : 1, "uniqueItems" : true }, - + "minimum" : { "type" : "number" }, - + "maximum" : { "type" : "number" }, - + "exclusiveMinimum" : { "type" : "boolean", "default" : false }, - + "exclusiveMaximum" : { "type" : "boolean", "default" : false }, - + "divisibleBy" : { "type" : "number", "minimum" : 0, "exclusiveMinimum" : true, "default" : 1 }, - + "minLength" : { "type" : "integer", "minimum" : 0, "default" : 0 }, - + "maxLength" : { "type" : "integer" }, - + "pattern" : { "type" : "string" }, - + "items" : { "type" : [{"$ref" : "#"}, "array"], "items" : {"$ref" : "#"}, "default" : {} }, - + "additionalItems" : { "type" : [{"$ref" : "#"}, "boolean"], "default" : {} }, - + "minItems" : { "type" : "integer", "minimum" : 0, "default" : 0 }, - + "maxItems" : { "type" : "integer", "minimum" : 0 }, - + "uniqueItems" : { "type" : "boolean", "default" : false }, - + "properties" : { "type" : "object", "additionalProperties" : {"$ref" : "#"}, "default" : {} }, - + "patternProperties" : { "type" : "object", "additionalProperties" : {"$ref" : "#"}, "default" : {} }, - + "additionalProperties" : { "type" : [{"$ref" : "#"}, "boolean"], "default" : {} }, - + "minProperties" : { "type" : "integer", "minimum" : 0, "default" : 0 }, - + "maxProperties" : { "type" : "integer", "minimum" : 0 }, - + "required" : { "type" : "array", "items" : { "type" : "string" } }, - + "dependencies" : { "type" : "object", "additionalProperties" : { @@ -154,36 +154,36 @@ }, "default" : {} }, - + "id" : { "type" : "string" }, - + "$ref" : { "type" : "string" }, - + "$schema" : { "type" : "string" }, - + "title" : { "type" : "string" }, - + "description" : { "type" : "string" }, - + "default" : { "type" : "any" } }, - + "dependencies" : { "exclusiveMinimum" : "minimum", "exclusiveMaximum" : "maximum" }, - + "default" : {} } \ No newline at end of file diff --git a/deps/npm/node_modules/json-schema/draft-zyp-json-schema-03.xml b/deps/npm/node_modules/json-schema/draft-zyp-json-schema-03.xml index c28f40dcd6ee44..1cf715910b5a83 100644 --- a/deps/npm/node_modules/json-schema/draft-zyp-json-schema-03.xml +++ b/deps/npm/node_modules/json-schema/draft-zyp-json-schema-03.xml @@ -24,7 +24,7 @@ A JSON Media Type for Describing the Structure and Meaning of JSON Documents - + SitePen (USA)
    @@ -37,7 +37,7 @@ kris@sitepen.com
    - +
    @@ -48,7 +48,7 @@ gary.court@gmail.com
    - + Internet Engineering Task Force JSON @@ -58,59 +58,59 @@ Notation Hyper Schema Hypermedia - + - JSON (JavaScript Object Notation) Schema defines the media type "application/schema+json", - a JSON based format for defining - the structure of JSON data. JSON Schema provides a contract for what JSON - data is required for a given application and how to interact with it. JSON - Schema is intended to define validation, documentation, hyperlink - navigation, and interaction control of JSON data. + JSON (JavaScript Object Notation) Schema defines the media type "application/schema+json", + a JSON based format for defining + the structure of JSON data. JSON Schema provides a contract for what JSON + data is required for a given application and how to interact with it. JSON + Schema is intended to define validation, documentation, hyperlink + navigation, and interaction control of JSON data.
    - +
    - JSON (JavaScript Object Notation) Schema is a JSON media type for defining - the structure of JSON data. JSON Schema provides a contract for what JSON - data is required for a given application and how to interact with it. JSON - Schema is intended to define validation, documentation, hyperlink - navigation, and interaction control of JSON data. + JSON (JavaScript Object Notation) Schema is a JSON media type for defining + the structure of JSON data. JSON Schema provides a contract for what JSON + data is required for a given application and how to interact with it. JSON + Schema is intended to define validation, documentation, hyperlink + navigation, and interaction control of JSON data.
    - +
    - - - The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", + + The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.
    - + - +
    - JSON Schema defines the media type "application/schema+json" for + JSON Schema defines the media type "application/schema+json" for describing the structure of other - JSON documents. JSON Schema is JSON-based and includes facilities + JSON documents. JSON Schema is JSON-based and includes facilities for describing the structure of JSON documents in terms of allowable values, descriptions, and interpreting relations with other resources. - JSON Schema format is organized into several separate definitions. The first - definition is the core schema specification. This definition is primary + JSON Schema format is organized into several separate definitions. The first + definition is the core schema specification. This definition is primary concerned with describing a JSON structure and specifying valid elements in the structure. The second definition is the Hyper Schema specification which is intended define elements in a structure that can be interpreted as hyperlinks. - Hyper Schema builds on JSON Schema to describe the hyperlink structure of + Hyper Schema builds on JSON Schema to describe the hyperlink structure of other JSON documents and elements of interaction. This allows user agents to be able to successfully navigate JSON documents based on their schemas. @@ -118,12 +118,12 @@ Cumulatively JSON Schema acts as a meta-document that can be used to define the required type and constraints on property values, as well as define the meaning of the property values for the purpose of describing a resource and determining hyperlinks - within the representation. + within the representation.
    An example JSON Schema that describes products might look like: - - This schema defines the properties of the instance JSON documents, + This schema defines the properties of the instance JSON documents, the required properties (id, name, and price), as well as an optional property (tags). This also defines the link relations of the instance JSON documents.
    - +
    - For this specification, schema will be used to denote a JSON Schema - definition, and an instance refers to a JSON value that the schema + For this specification, schema will be used to denote a JSON Schema + definition, and an instance refers to a JSON value that the schema will be describing and validating.
    - +
    The JSON Schema media type does not attempt to dictate the structure of JSON @@ -194,7 +194,7 @@ This specification is protocol agnostic. The underlying protocol (such as HTTP) should sufficiently define the semantics of the client-server interface, the retrieval of resource - representations linked to by JSON representations, and modification of + representations linked to by JSON representations, and modification of those resources. The goal of this format is to sufficiently describe JSON structures such that one can utilize existing information available in existing JSON @@ -203,7 +203,7 @@
    - +
    JSON Schema instances are correlated to their schema by the "describedby" @@ -217,22 +217,22 @@ representation and messages may retain the self-descriptive characteristic, avoiding the need for out-of-band information about instance data. Two approaches are recommended for declaring the - relation to the schema that describes the meaning of a JSON instance's (or collection + relation to the schema that describes the meaning of a JSON instance's (or collection of instances) structure. A MIME type parameter named "profile" or a relation of "describedby" (which could be defined by a Link header) may be used: - +
    -
    - + or if the content is being transferred by a protocol (such as HTTP) that provides headers, a Link header can be used: - +
    ; rel="describedby" ]]>
    - - Instances MAY specify multiple schemas, to indicate all the schemas that - are applicable to the data, and the data SHOULD be valid by all the schemas. - The instance data MAY have multiple schemas - that it is defined by (the instance data SHOULD be valid for those schemas). - Or if the document is a collection of instances, the collection MAY contain - instances from different schemas. When collections contain heterogeneous - instances, the "pathStart" attribute MAY be specified in the - schema to disambiguate which schema should be applied for each item in the + + Instances MAY specify multiple schemas, to indicate all the schemas that + are applicable to the data, and the data SHOULD be valid by all the schemas. + The instance data MAY have multiple schemas + that it is defined by (the instance data SHOULD be valid for those schemas). + Or if the document is a collection of instances, the collection MAY contain + instances from different schemas. When collections contain heterogeneous + instances, the "pathStart" attribute MAY be specified in the + schema to disambiguate which schema should be applied for each item in the collection. However, ultimately, the mechanism for referencing a schema is up to the media type of the instance documents (if they choose to specify that schemas can be referenced).
    - +
    - JSON Schemas can themselves be described using JSON Schemas. + JSON Schemas can themselves be described using JSON Schemas. A self-describing JSON Schema for the core JSON Schema can - be found at http://json-schema.org/schema for the latest version or - http://json-schema.org/draft-03/schema for the draft-03 version. The hyper schema - self-description can be found at http://json-schema.org/hyper-schema + be found at http://json-schema.org/schema for the latest version or + http://json-schema.org/draft-03/schema for the draft-03 version. The hyper schema + self-description can be found at http://json-schema.org/hyper-schema or http://json-schema.org/draft-03/hyper-schema. All schemas used within a protocol with media type definitions SHOULD include a MIME parameter that refers to the self-descriptive hyper schema or another schema that extends this hyper schema: - +
    - @@ -277,15 +277,15 @@ Content-Type: application/json;
    - +
    - A JSON Schema is a JSON Object that defines various attributes + A JSON Schema is a JSON Object that defines various attributes (including usage and valid values) of a JSON value. JSON Schema has recursive capabilities; there are a number of elements in the structure that allow for nested JSON Schemas. - +
    An example JSON Schema definition could look like: @@ -307,15 +307,15 @@ Content-Type: application/json; ]]>
    - + A JSON Schema object may have any of the following properties, called schema attributes (all attributes are optional): - +
    - This attribute defines what the primitive type or the schema of the instance MUST be in order to validate. + This attribute defines what the primitive type or the schema of the instance MUST be in order to validate. This attribute can take one of two forms: @@ -332,19 +332,19 @@ Content-Type: application/json; Value MUST be null. Note this is mainly for purpose of being able use union types to define nullability. If this type is not included in a union, null values are not allowed (the primitives listed above do not allow nulls on their own). Value MAY be of any type including null. - - If the property is not defined or is not in this list, then any type of value is acceptable. - Other type values MAY be used for custom purposes, but minimal validators of the specification + + If the property is not defined or is not in this list, then any type of value is acceptable. + Other type values MAY be used for custom purposes, but minimal validators of the specification implementation can allow any instance value on unknown type values. - + An array of two or more simple type definitions. Each item in the array MUST be a simple type definition or a schema. - The instance value is valid if it is of the same type as one of the simple type definitions, or valid by one of the schemas, in the array. + The instance value is valid if it is of the same type as one of the simple type definitions, or valid by one of the schemas, in the array. - +
    For example, a schema that defines if an instance can be a string or a number would be: @@ -355,38 +355,38 @@ Content-Type: application/json; ]]>
    - +
    This attribute is an object with property definitions that define the valid values of instance object property values. When the instance value is an object, the property values of the instance object MUST conform to the property definitions in this object. In this object, each property definition's value MUST be a schema, and the property's name MUST be the name of the instance property that it defines. The instance property value MUST be valid according to the schema from the property definition. Properties are considered unordered, the order of the instance properties MAY be in any order.
    - +
    This attribute is an object that defines the schema for a set of property names of an object instance. The name of each property of this attribute's object is a regular expression pattern in the ECMA 262/Perl 5 format, while the value is a schema. If the pattern matches the name of a property on the instance object, the value of the instance's property MUST be valid against the pattern name's schema value.
    - +
    This attribute defines a schema for all properties that are not explicitly defined in an object type definition. If specified, the value MUST be a schema or a boolean. If false is provided, no additional properties are allowed beyond the properties defined in the schema. The default value is an empty schema which allows any value for additional properties.
    - +
    This attribute defines the allowed items in an instance array, and MUST be a schema or an array of schemas. The default value is an empty schema which allows any value for items in the instance array. When this attribute value is a schema and the instance value is an array, then all the items in the array MUST be valid according to the schema. When this attribute value is an array of schemas and the instance value is an array, each position in the instance array MUST conform to the schema in the corresponding position for this array. This called tuple typing. When tuple typing is used, additional items are allowed, disallowed, or constrained by the "additionalItems" attribute using the same rules as "additionalProperties" for objects.
    - +
    This provides a definition for additional items in an array instance when tuple definitions of the items is provided. This can be false to indicate additional items in the array are not allowed, or it can be a schema that defines the schema of the additional items.
    - +
    This attribute indicates if the instance must have a value, and not be undefined. This is false by default, making the instance optional.
    - +
    This attribute is an object that defines the requirements of a property on an instance object. If an object instance has a property with the same name as a property in this attribute's object, then the instance must be valid against the attribute's property value (hereafter referred to as the "dependency value"). The dependency value can take one of two forms: - + If the dependency value is a string, then the instance object MUST have a property with the same name as the dependency value. @@ -398,36 +398,36 @@ Content-Type: application/json;
    - +
    This attribute defines the minimum value of the instance property when the type of the instance value is a number.
    - +
    This attribute defines the maximum value of the instance property when the type of the instance value is a number.
    - +
    This attribute indicates if the value of the instance (if the instance is a number) can not equal the number defined by the "minimum" attribute. This is false by default, meaning the instance value can be greater then or equal to the minimum value.
    - +
    This attribute indicates if the value of the instance (if the instance is a number) can not equal the number defined by the "maximum" attribute. This is false by default, meaning the instance value can be less then or equal to the maximum value.
    - +
    This attribute defines the minimum number of values in an array when the array is the instance value.
    - +
    This attribute defines the maximum number of values in an array when the array is the instance value.
    - +
    This attribute indicates that all items in an array instance MUST be unique (contains no two identical values). Two instance are consider equal if they are both of the same type and: - + are null; or are booleans/numbers/strings and have the same value; or @@ -436,41 +436,41 @@ Content-Type: application/json;
    - +
    When the instance value is a string, this provides a regular expression that a string instance MUST match in order to be valid. Regular expressions SHOULD follow the regular expression specification from ECMA 262/Perl 5
    - +
    When the instance value is a string, this defines the minimum length of the string.
    - +
    When the instance value is a string, this defines the maximum length of the string.
    - +
    This provides an enumeration of all possible values that are valid for the instance property. This MUST be an array, and each item in the array represents a possible value for the instance value. If this attribute is defined, the instance value MUST be one of the values in the array in order for the schema to be valid. Comparison of enum values uses the same algorithm as defined in "uniqueItems".
    - +
    This attribute defines the default value of the instance when the instance is undefined.
    - +
    This attribute is a string that provides a short description of the instance property.
    - +
    This attribute is a string that provides a full description of the of purpose the instance property.
    - +
    This property defines the type of data, content type, or microformat to be expected in the instance property values. A format attribute MAY be one of the values listed below, and if so, SHOULD adhere to the semantics describing for the format. A format SHOULD only be used to give meaning to primitive types (string, integer, number, or boolean). Validators MAY (but are not required to) validate that the instance values conform to a format. - + The following formats are predefined: - + This SHOULD be a date in ISO 8601 format of YYYY-MM-DDThh:mm:ssZ in UTC time. This is the recommended form of date/timestamp. This SHOULD be a date in the format of YYYY-MM-DD. It is recommended that you use the "date-time" format instead of "date" unless you need to transfer only the date part. @@ -487,18 +487,18 @@ Content-Type: application/json; This SHOULD be a host-name. - + Additional custom formats MAY be created. These custom formats MAY be expressed as an URI, and this URI MAY reference a schema of that format.
    - +
    This attribute defines what value the number instance must be divisible by with no remainder (the result of the division must be an integer.) The value of this attribute SHOULD NOT be 0.
    - +
    This attribute takes the same values as the "type" attribute, however if the instance matches the type or if this value is an array and the instance matches any type or schema in the array, then this instance is not valid.
    - +
    The value of this property MUST be another schema which will provide a base schema which the current schema will inherit from. The inheritance rules are such that any instance that is valid according to the current schema MUST be valid according to the referenced schema. This MAY also be an array, in which case, the instance MUST be valid for all the schemas in the array. A schema that extends another schema MAY define additional attributes, constrain existing attributes, or add other constraints. @@ -506,7 +506,7 @@ Content-Type: application/json; instance against all constraints in the extending schema as well as the extended schema(s). More optimized implementations that merge schemas are possible, but are not required. Some examples of using "extends": - +
    - +
    - +
    This attribute defines the current URI of this schema (this attribute is @@ -553,28 +553,28 @@ Content-Type: application/json; is also used to construct relative references such as for $ref.
    - +
    - This attribute defines a URI of a schema that contains the full representation of this schema. - When a validator encounters this attribute, it SHOULD replace the current schema with the schema referenced by the value's URI (if known and available) and re-validate the instance. + This attribute defines a URI of a schema that contains the full representation of this schema. + When a validator encounters this attribute, it SHOULD replace the current schema with the schema referenced by the value's URI (if known and available) and re-validate the instance. This URI MAY be relative or absolute, and relative URIs SHOULD be resolved against the URI of the current schema.
    - +
    - This attribute defines a URI of a JSON Schema that is the schema of the current schema. + This attribute defines a URI of a JSON Schema that is the schema of the current schema. When this attribute is defined, a validator SHOULD use the schema referenced by the value's URI (if known and available) when resolving Hyper Schemalinks. - + - A validator MAY use this attribute's value to determine which version of JSON Schema the current schema is written in, and provide the appropriate validation features and behavior. + A validator MAY use this attribute's value to determine which version of JSON Schema the current schema is written in, and provide the appropriate validation features and behavior. Therefore, it is RECOMMENDED that all schema authors include this attribute in their schemas to prevent conflicts with future JSON Schema specification changes.
    - +
    The following attributes are specified in addition to those @@ -586,28 +586,28 @@ Content-Type: application/json; essentially describes plain JSON (no constraints on the structures). Addition of attributes provides additive information for user agents. - +
    - The value of the links property MUST be an array, where each item + The value of the links property MUST be an array, where each item in the array is a link description object which describes the link relations of the instances. - +
    - A link description object is used to describe link relations. In - the context of a schema, it defines the link relations of the + A link description object is used to describe link relations. In + the context of a schema, it defines the link relations of the instances of the schema, and can be parameterized by the instance values. The link description format can be used on its own in regular (non-schema documents), and use of this format can be declared by referencing the normative link description - schema as the the schema for the data structure that uses the - links. The URI of the normative link description schema is: + schema as the the schema for the data structure that uses the + links. The URI of the normative link description schema is: http://json-schema.org/links (latest version) or http://json-schema.org/draft-03/links (draft-03 version). - +
    The value of the "href" link description property @@ -615,19 +615,19 @@ Content-Type: application/json; of the instance property SHOULD be resolved as a URI-Reference per RFC 3986 and MAY be a relative URI. The base URI to be used for relative resolution SHOULD be the URI used to retrieve the instance object (not the schema) - when used within a schema. Also, when links are used within a schema, the URI - SHOULD be parametrized by the property values of the instance + when used within a schema. Also, when links are used within a schema, the URI + SHOULD be parametrized by the property values of the instance object, if property values exist for the corresponding variables in the template (otherwise they MAY be provided from alternate sources, like user input). - + Instance property values SHOULD be substituted into the URIs where matching braces ('{', '}') are found surrounding zero or more characters, creating an expanded URI. Instance property value substitutions are resolved by using the text between the braces to denote the property name - from the instance to get the value to substitute. - + from the instance to get the value to substitute. +
    For example, if an href value is defined: @@ -637,7 +637,7 @@ http://somesite.com/{id} Then it would be resolved by replace the value of the "id" property value from the instance object.
    - +
    If the value of the "id" property was "45", the expanded URI would be: @@ -646,23 +646,23 @@ http://somesite.com/45 ]]>
    - - If matching braces are found with the string "@" (no quotes) between the braces, then the + + If matching braces are found with the string "@" (no quotes) between the braces, then the actual instance value SHOULD be used to replace the braces, rather than a property value. - This should only be used in situations where the instance is a scalar (string, + This should only be used in situations where the instance is a scalar (string, boolean, or number), and not for objects or arrays.
    - +
    - The value of the "rel" property indicates the name of the + The value of the "rel" property indicates the name of the relation to the target resource. The relation to the target SHOULD be interpreted as specifically from the instance object that the schema (or sub-schema) applies to, not just the top level resource that contains the object within its hierarchy. If a resource JSON representation contains a sub object with a property interpreted as a link, that sub-object holds the relation with the target. A relation to target from the top level resource MUST be indicated with the schema describing the top level JSON representation. - + Relationship definitions SHOULD NOT be media type dependent, and users are encouraged to utilize existing accepted relation definitions, including those in existing relation registries (see RFC 4287). However, we define these relations here for clarity of normative interpretation within the context of JSON hyper schema defined relations: - + If the relation value is "self", when this property is encountered in @@ -670,15 +670,15 @@ http://somesite.com/45 treated as a full representation of the target resource identified by the specified URI. - + This indicates that the target of the link is the full representation for the instance object. The object that contains this link possibly may not be the full representation. - + This indicates the target of the link is the schema for the instance object. This MAY be used to specifically denote the schemas of objects within a JSON object hierarchy, facilitating polymorphic type data structures. - + This relation indicates that the target of the link SHOULD be treated as the root or the body of the representation for the @@ -688,7 +688,7 @@ http://somesite.com/45 - + The following relations are applicable for schemas (the schema as the "from" resource in the relation): @@ -697,7 +697,7 @@ http://somesite.com/45 This indicates a target to use for creating new instances of a schema. This link definition SHOULD be a submission link with a non-safe method (like POST). - +
    For example, if a schema is defined: @@ -718,7 +718,7 @@ http://somesite.com/45 ]]>
    - +
    And if a collection of instance resource's JSON representation was retrieved: @@ -742,37 +742,37 @@ GET /Resource/ The "children" collection would be located at "/Resource/?upId=thing".
    - +
    This property value is a schema that defines the expected structure of the JSON representation of the target of the link.
    - +
    - The following properties also apply to link definition objects, and - provide functionality analogous to HTML forms, in providing a + The following properties also apply to link definition objects, and + provide functionality analogous to HTML forms, in providing a means for submitting extra (often user supplied) information to send to a server. - +
    - This attribute defines which method can be used to access the target resource. - In an HTTP environment, this would be "GET" or "POST" (other HTTP methods - such as "PUT" and "DELETE" have semantics that are clearly implied by - accessed resources, and do not need to be defined here). + This attribute defines which method can be used to access the target resource. + In an HTTP environment, this would be "GET" or "POST" (other HTTP methods + such as "PUT" and "DELETE" have semantics that are clearly implied by + accessed resources, and do not need to be defined here). This defaults to "GET".
    - +
    If present, this property indicates a query media type format that the server - supports for querying or posting to the collection of instances at the target - resource. The query can be + supports for querying or posting to the collection of instances at the target + resource. The query can be suffixed to the target URI to query the collection with property-based constraints on the resources that SHOULD be returned from the server or used to post data to the resource (depending on the method). - +
    For example, with the following schema: @@ -793,7 +793,7 @@ GET /Resource/ This indicates that the client can query the server for instances that have a specific name.
    - +
    For example: @@ -803,23 +803,23 @@ GET /Resource/
    - If no enctype or method is specified, only the single URI specified by - the href property is defined. If the method is POST, "application/json" is + If no enctype or method is specified, only the single URI specified by + the href property is defined. If the method is POST, "application/json" is the default media type.
    - +
    This attribute contains a schema which defines the acceptable structure of the submitted - request (for a GET request, this schema would define the properties for the query string + request (for a GET request, this schema would define the properties for the query string and for a POST request, this would define the body).
    - +
    This property indicates the fragment resolution protocol to use for @@ -829,12 +829,12 @@ GET /Resource/ protocol is "slash-delimited", which is defined below. Other fragment resolution protocols MAY be used, but are not defined in this document. - + The fragment identifier is based on RFC 2396, Sec 5, and defines the mechanism for resolving references to entities within a document. - +
    With the slash-delimited fragment resolution protocol, the fragment @@ -852,15 +852,15 @@ GET /Resource/ item in array the array with the index defined by the next property reference token (which MUST be a number). The target is successively updated for each property reference token, until the entire fragment has - been traversed. + been traversed. - + - Property names SHOULD be URI-encoded. In particular, any "/" in a - property name MUST be encoded to avoid being interpreted as a property + Property names SHOULD be URI-encoded. In particular, any "/" in a + property name MUST be encoded to avoid being interpreted as a property delimiter. - +
    For example, for the following JSON representation: @@ -879,7 +879,7 @@ GET /Resource/ ]]>
    - +
    The following fragment identifiers would be resolved: @@ -889,10 +889,10 @@ fragment identifier resolution # self, the root of the resource itself #/foo the object referred to by the foo property #/foo/another%20prop the object referred to by the "another prop" - property of the object referred to by the + property of the object referred to by the "foo" property #/foo/another%20prop/baz the string referred to by the value of "baz" - property of the "another prop" property of + property of the "another prop" property of the object referred to by the "foo" property #/foo/anArray/0 the first object in the "anArray" array ]]> @@ -900,61 +900,61 @@ fragment identifier resolution
    - +
    - The dot-delimited fragment resolution protocol is the same as - slash-delimited fragment resolution protocol except that the "." character - (\x2E) is used as the delimiter between property names (instead of "/") and + The dot-delimited fragment resolution protocol is the same as + slash-delimited fragment resolution protocol except that the "." character + (\x2E) is used as the delimiter between property names (instead of "/") and the path does not need to start with a ".". For example, #.foo and #foo are a valid fragment identifiers for referencing the value of the foo propery.
    - +
    This attribute indicates that the instance property SHOULD NOT be changed. Attempts by a user agent to modify the value of this property are expected to be rejected by a server.
    - +
    If the instance property value is a string, this attribute defines that the string SHOULD be interpreted as binary data and decoded using the encoding named by this schema property. RFC 2045, Sec 6.1 lists the possible values for this property.
    - +
    - This attribute is a URI that defines what the instance's URI MUST start with in order to validate. - The value of the "pathStart" attribute MUST be resolved as per RFC 3986, Sec 5, + This attribute is a URI that defines what the instance's URI MUST start with in order to validate. + The value of the "pathStart" attribute MUST be resolved as per RFC 3986, Sec 5, and is relative to the instance's URI. - + - When multiple schemas have been referenced for an instance, the user agent - can determine if this schema is applicable for a particular instance by + When multiple schemas have been referenced for an instance, the user agent + can determine if this schema is applicable for a particular instance by determining if the URI of the instance begins with the the value of the "pathStart" - attribute. If the URI of the instance does not start with this URI, - or if another schema specifies a starting URI that is longer and also matches the - instance, this schema SHOULD NOT be applied to the instance. Any schema - that does not have a pathStart attribute SHOULD be considered applicable + attribute. If the URI of the instance does not start with this URI, + or if another schema specifies a starting URI that is longer and also matches the + instance, this schema SHOULD NOT be applied to the instance. Any schema + that does not have a pathStart attribute SHOULD be considered applicable to all the instances for which it is referenced.
    - +
    This attribute defines the media type of the instance representations that this schema is defining.
    - +
    - This specification is a sub-type of the JSON format, and - consequently the security considerations are generally the same as RFC 4627. + This specification is a sub-type of the JSON format, and + consequently the security considerations are generally the same as RFC 4627. However, an additional issue is that when link relation of "self" - is used to denote a full representation of an object, the user agent + is used to denote a full representation of an object, the user agent SHOULD NOT consider the representation to be the authoritative representation of the resource denoted by the target URI if the target URI is not - equivalent to or a sub-path of the the URI used to request the resource + equivalent to or a sub-path of the the URI used to request the resource representation which contains the target URI with the "self" link. - +
    For example, if a hyper schema was defined: @@ -968,7 +968,7 @@ fragment identifier resolution ]]>
    - +
    And a resource was requested from somesite.com: @@ -1005,22 +1005,22 @@ Content-Type: application/json; profile=/schema-for-this-data
    - +
    The proposed MIME media type for JSON Schema is "application/schema+json". Type name: application Subtype name: schema+json Required parameters: profile - The value of the profile parameter SHOULD be a URI (relative or absolute) that - refers to the schema used to define the structure of this structure (the + The value of the profile parameter SHOULD be a URI (relative or absolute) that + refers to the schema used to define the structure of this structure (the meta-schema). Normally the value would be http://json-schema.org/draft-03/hyper-schema, but it is allowable to use other schemas that extend the hyper schema's meta- schema. Optional parameters: pretty The value of the pretty parameter MAY be true or false to indicate if additional whitespace has been included to make the JSON representation easier to read. - +
    This registry is maintained by IANA per RFC 4287 and this specification adds @@ -1032,7 +1032,7 @@ Content-Type: application/json; profile=/schema-for-this-data
    - + @@ -1080,7 +1080,7 @@ Content-Type: application/json; profile=/schema-for-this-data Added "$ref" and "$schema" attributes. - + Replaced "maxDecimal" attribute with "divisibleBy" attribute. @@ -1090,13 +1090,13 @@ Content-Type: application/json; profile=/schema-for-this-data Added "targetSchema" attribute to link description object. - + Fixed category and updates from template. - + Initial draft. @@ -1105,7 +1105,7 @@ Content-Type: application/json; profile=/schema-for-this-data - +
    diff --git a/deps/npm/node_modules/json-schema/draft-zyp-json-schema-04.xml b/deps/npm/node_modules/json-schema/draft-zyp-json-schema-04.xml index f9c1ea5a0c00a2..22fb3290df1472 100644 --- a/deps/npm/node_modules/json-schema/draft-zyp-json-schema-04.xml +++ b/deps/npm/node_modules/json-schema/draft-zyp-json-schema-04.xml @@ -23,7 +23,7 @@ A JSON Media Type for Describing the Structure and Meaning of JSON Documents - + SitePen (USA)
    @@ -36,7 +36,7 @@ kris@sitepen.com
    - +
    @@ -47,7 +47,7 @@ gary.court@gmail.com
    - + Internet Engineering Task Force JSON @@ -57,48 +57,48 @@ Notation Hyper Schema Hypermedia - + - JSON (JavaScript Object Notation) Schema defines the media type "application/schema+json", - a JSON based format for defining the structure of JSON data. JSON Schema provides a contract for what JSON - data is required for a given application and how to interact with it. JSON - Schema is intended to define validation, documentation, hyperlink - navigation, and interaction control of JSON data. + JSON (JavaScript Object Notation) Schema defines the media type "application/schema+json", + a JSON based format for defining the structure of JSON data. JSON Schema provides a contract for what JSON + data is required for a given application and how to interact with it. JSON + Schema is intended to define validation, documentation, hyperlink + navigation, and interaction control of JSON data.
    - +
    - JSON (JavaScript Object Notation) Schema is a JSON media type for defining - the structure of JSON data. JSON Schema provides a contract for what JSON - data is required for a given application and how to interact with it. JSON - Schema is intended to define validation, documentation, hyperlink - navigation, and interaction control of JSON data. + JSON (JavaScript Object Notation) Schema is a JSON media type for defining + the structure of JSON data. JSON Schema provides a contract for what JSON + data is required for a given application and how to interact with it. JSON + Schema is intended to define validation, documentation, hyperlink + navigation, and interaction control of JSON data.
    - +
    - - - The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", + + The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119. - + - The terms "JSON", "JSON text", "JSON value", "member", "element", "object", - "array", "number", "string", "boolean", "true", "false", and "null" in this + The terms "JSON", "JSON text", "JSON value", "member", "element", "object", + "array", "number", "string", "boolean", "true", "false", and "null" in this document are to be interpreted as defined in RFC 4627. - + This specification also uses the following defined terms: - + A JSON Schema object. Equivalent to "JSON value" as defined in RFC 4627. @@ -108,35 +108,35 @@
    - +
    - JSON Schema defines the media type "application/schema+json" for - describing the structure of JSON text. JSON Schemas are also written in JSON and includes facilities + JSON Schema defines the media type "application/schema+json" for + describing the structure of JSON text. JSON Schemas are also written in JSON and includes facilities for describing the structure of JSON in terms of allowable values, descriptions, and interpreting relations with other resources. - This document is organized into several separate definitions. The first - definition is the core schema specification. This definition is primary + This document is organized into several separate definitions. The first + definition is the core schema specification. This definition is primary concerned with describing a JSON structure and specifying valid elements in the structure. The second definition is the Hyper Schema specification which is intended to define elements in a structure that can be interpreted as hyperlinks. - Hyper Schema builds on JSON Schema to describe the hyperlink structure of + Hyper Schema builds on JSON Schema to describe the hyperlink structure of JSON values. This allows user agents to be able to successfully navigate documents containing JSON based on their schemas. - Cumulatively JSON Schema acts as meta-JSON that can be used to define the + Cumulatively JSON Schema acts as meta-JSON that can be used to define the required type and constraints on JSON values, as well as define the meaning of the JSON values for the purpose of describing a resource and determining - hyperlinks within the representation. + hyperlinks within the representation.
    An example JSON Schema that describes products might look like: - - This schema defines the properties of the instance, + This schema defines the properties of the instance, the required properties (id, name, and price), as well as an optional property (tags). This also defines the link relations of the instance.
    - +
    The JSON Schema media type does not attempt to dictate the structure of JSON @@ -195,7 +195,7 @@ This specification is protocol agnostic. The underlying protocol (such as HTTP) should sufficiently define the semantics of the client-server interface, the retrieval of resource - representations linked to by JSON representations, and modification of + representations linked to by JSON representations, and modification of those resources. The goal of this format is to sufficiently describe JSON structures such that one can utilize existing information available in existing JSON @@ -204,35 +204,35 @@
    - +
    JSON values are correlated to their schema by the "describedby" relation, where the schema is the target of the relation. JSON values MUST be of the "application/json" media type or - any other subtype. Consequently, dictating how a JSON value should + any other subtype. Consequently, dictating how a JSON value should specify the relation to the schema is beyond the normative scope of this document since this document specifically defines the JSON Schema media type, and no other. It is RECOMMNENDED that JSON values specify their schema so that user agents can interpret the instance and retain the self-descriptive characteristics. This avoides the need for out-of-band information about instance data. Two approaches are recommended for declaring the - relation to the schema that describes the meaning of a JSON instance's (or collection + relation to the schema that describes the meaning of a JSON instance's (or collection of instances) structure. A MIME type parameter named "profile" or a relation of "describedby" (which could be specified by a Link header) may be used: - +
    -
    - + or if the content is being transferred by a protocol (such as HTTP) that provides headers, a Link header can be used: - +
    ; rel="describedby" ]]>
    - - Instances MAY specify multiple schemas, to indicate all the schemas that - are applicable to the data, and the data SHOULD be valid by all the schemas. - The instance data MAY have multiple schemas - that it is described by (the instance data SHOULD be valid for those schemas). - Or if the document is a collection of instances, the collection MAY contain - instances from different schemas. The mechanism for referencing a schema is - determined by the media type of the instance (if it provides a method for + + Instances MAY specify multiple schemas, to indicate all the schemas that + are applicable to the data, and the data SHOULD be valid by all the schemas. + The instance data MAY have multiple schemas + that it is described by (the instance data SHOULD be valid for those schemas). + Or if the document is a collection of instances, the collection MAY contain + instances from different schemas. The mechanism for referencing a schema is + determined by the media type of the instance (if it provides a method for referencing schemas).
    - +
    - JSON Schemas can themselves be described using JSON Schemas. + JSON Schemas can themselves be described using JSON Schemas. A self-describing JSON Schema for the core JSON Schema can - be found at http://json-schema.org/schema for the latest version or - http://json-schema.org/draft-04/schema for the draft-04 version. The hyper schema - self-description can be found at http://json-schema.org/hyper-schema + be found at http://json-schema.org/schema for the latest version or + http://json-schema.org/draft-04/schema for the draft-04 version. The hyper schema + self-description can be found at http://json-schema.org/hyper-schema or http://json-schema.org/draft-04/hyper-schema. All schemas used within a protocol with a media type specified SHOULD include a MIME parameter that refers to the self-descriptive hyper schema or another schema that extends this hyper schema: - +
    - @@ -273,15 +273,15 @@ Content-Type: application/json;
    - +
    - A JSON Schema is a JSON object that defines various attributes + A JSON Schema is a JSON object that defines various attributes (including usage and valid values) of a JSON value. JSON Schema has recursive capabilities; there are a number of elements in the structure that allow for nested JSON Schemas. - +
    An example JSON Schema could look like: @@ -305,17 +305,17 @@ Content-Type: application/json; ]]>
    - + A JSON Schema object MAY have any of the following optional properties: - + - +
    - This attribute defines what the primitive type or the schema of the instance MUST be in order to validate. + This attribute defines what the primitive type or the schema of the instance MUST be in order to validate. This attribute can take one of two forms: @@ -332,16 +332,16 @@ Content-Type: application/json; Instance MAY be of any type, including null. - + An array of one or more simple or schema types. - The instance value is valid if it is of the same type as one of the simple types, or valid by one of the schemas, in the array. + The instance value is valid if it is of the same type as one of the simple types, or valid by one of the schemas, in the array. - - If this attribute is not specified, then all value types are accepted. + + If this attribute is not specified, then all value types are accepted. - +
    For example, a schema that defines if an instance can be a string or a number would be: @@ -352,37 +352,37 @@ Content-Type: application/json; ]]>
    - +
    This attribute is an object with properties that specify the schemas for the properties of the instance object. - In this attribute's object, each property value MUST be a schema. + In this attribute's object, each property value MUST be a schema. When the instance value is an object, the value of the instance's properties MUST be valid according to the schemas with the same property names specified in this attribute. Objects are unordered, so therefore the order of the instance properties or attribute properties MUST NOT determine validation success.
    - +
    - This attribute is an object that defines the schema for a set of property names of an object instance. - The name of each property of this attribute's object is a regular expression pattern in the ECMA 262/Perl 5 format, while the value is a schema. + This attribute is an object that defines the schema for a set of property names of an object instance. + The name of each property of this attribute's object is a regular expression pattern in the ECMA 262/Perl 5 format, while the value is a schema. If the pattern matches the name of a property on the instance object, the value of the instance's property MUST be valid against the pattern name's schema value.
    - +
    - This attribute specifies how any instance property that is not explicitly defined by either the "properties" or "patternProperties" attributes (hereafter referred to as "additional properties") is handled. If specified, the value MUST be a schema or a boolean. + This attribute specifies how any instance property that is not explicitly defined by either the "properties" or "patternProperties" attributes (hereafter referred to as "additional properties") is handled. If specified, the value MUST be a schema or a boolean. If a schema is provided, then all additional properties MUST be valid according to the schema. If false is provided, then no additional properties are allowed. The default value is an empty schema, which allows any value for additional properties.
    - +
    This attribute provides the allowed items in an array instance. If specified, this attribute MUST be a schema or an array of schemas. When this attribute value is a schema and the instance value is an array, then all the items in the array MUST be valid according to the schema. When this attribute value is an array of schemas and the instance value is an array, each position in the instance array MUST be valid according to the schema in the corresponding position for this array. This called tuple typing. When tuple typing is used, additional items are allowed, disallowed, or constrained by the "additionalItems" attribute the same way as "additionalProperties" for objects is.
    - +
    This attribute specifies how any item in the array instance that is not explicitly defined by "items" (hereafter referred to as "additional items") is handled. If specified, the value MUST be a schema or a boolean. If a schema is provided: @@ -395,16 +395,16 @@ Content-Type: application/json; If false is provided, then any additional items in the array are not allowed. The default value is an empty schema, which allows any value for additional items.
    - +
    This attribute is an array of strings that defines all the property names that must exist on the object instance.
    - +
    This attribute is an object that specifies the requirements of a property on an object instance. If an object instance has a property with the same name as a property in this attribute's object, then the instance must be valid against the attribute's property value (hereafter referred to as the "dependency value"). The dependency value can take one of two forms: - + If the dependency value is a string, then the instance object MUST have a property with the same name as the dependency value. @@ -416,44 +416,44 @@ Content-Type: application/json;
    - +
    This attribute defines the minimum value of the instance property when the type of the instance value is a number.
    - +
    This attribute defines the maximum value of the instance property when the type of the instance value is a number.
    - +
    This attribute indicates if the value of the instance (if the instance is a number) can not equal the number defined by the "minimum" attribute. This is false by default, meaning the instance value can be greater then or equal to the minimum value.
    - +
    This attribute indicates if the value of the instance (if the instance is a number) can not equal the number defined by the "maximum" attribute. This is false by default, meaning the instance value can be less then or equal to the maximum value.
    - +
    This attribute defines the minimum number of values in an array when the array is the instance value.
    - +
    This attribute defines the maximum number of values in an array when the array is the instance value.
    - +
    This attribute defines the minimum number of properties required on an object instance.
    - +
    This attribute defines the maximum number of properties the object instance can have.
    - +
    This attribute indicates that all items in an array instance MUST be unique (contains no two identical values). Two instance are consider equal if they are both of the same type and: - + are null; or are booleans/numbers/strings and have the same value; or @@ -462,43 +462,43 @@ Content-Type: application/json;
    - +
    When the instance value is a string, this provides a regular expression that a string instance MUST match in order to be valid. Regular expressions SHOULD follow the regular expression specification from ECMA 262/Perl 5
    - +
    When the instance value is a string, this defines the minimum length of the string.
    - +
    When the instance value is a string, this defines the maximum length of the string.
    - +
    This provides an enumeration of all possible values that are valid for the instance property. This MUST be an array, and each item in the array represents a possible value for the instance value. If this attribute is defined, the instance value MUST be one of the values in the array in order for the schema to be valid. Comparison of enum values uses the same algorithm as defined in "uniqueItems".
    - +
    This attribute defines the default value of the instance when the instance is undefined.
    - +
    This attribute is a string that provides a short description of the instance property.
    - +
    This attribute is a string that provides a full description of the of purpose the instance property.
    - +
    This attribute defines what value the number instance must be divisible by with no remainder (the result of the division must be an integer.) The value of this attribute SHOULD NOT be 0.
    - +
    This attribute takes the same values as the "type" attribute, however if the instance matches the type or if this value is an array and the instance matches any type or schema in the array, then this instance is not valid.
    - +
    The value of this property MUST be another schema which will provide a base schema which the current schema will inherit from. The inheritance rules are such that any instance that is valid according to the current schema MUST be valid according to the referenced schema. This MAY also be an array, in which case, the instance MUST be valid for all the schemas in the array. A schema that extends another schema MAY define additional attributes, constrain existing attributes, or add other constraints. @@ -506,7 +506,7 @@ Content-Type: application/json; instance against all constraints in the extending schema as well as the extended schema(s). More optimized implementations that merge schemas are possible, but are not required. Some examples of using "extends": - +
    - +
    - +
    This attribute defines the current URI of this schema (this attribute is @@ -553,28 +553,28 @@ Content-Type: application/json; is also used to construct relative references such as for $ref.
    - +
    - This attribute defines a URI of a schema that contains the full representation of this schema. - When a validator encounters this attribute, it SHOULD replace the current schema with the schema referenced by the value's URI (if known and available) and re-validate the instance. + This attribute defines a URI of a schema that contains the full representation of this schema. + When a validator encounters this attribute, it SHOULD replace the current schema with the schema referenced by the value's URI (if known and available) and re-validate the instance. This URI MAY be relative or absolute, and relative URIs SHOULD be resolved against the URI of the current schema.
    - +
    - This attribute defines a URI of a JSON Schema that is the schema of the current schema. + This attribute defines a URI of a JSON Schema that is the schema of the current schema. When this attribute is defined, a validator SHOULD use the schema referenced by the value's URI (if known and available) when resolving Hyper Schemalinks. - + - A validator MAY use this attribute's value to determine which version of JSON Schema the current schema is written in, and provide the appropriate validation features and behavior. + A validator MAY use this attribute's value to determine which version of JSON Schema the current schema is written in, and provide the appropriate validation features and behavior. Therefore, it is RECOMMENDED that all schema authors include this attribute in their schemas to prevent conflicts with future JSON Schema specification changes.
    - +
    The following attributes are specified in addition to those @@ -586,30 +586,30 @@ Content-Type: application/json; essentially describes plain JSON (no constraints on the structures). Addition of attributes provides additive information for user agents. - +
    - The value of the links property MUST be an array, where each item + The value of the links property MUST be an array, where each item in the array is a link description object which describes the link relations of the instances. - + - +
    - A link description object is used to describe link relations. In - the context of a schema, it defines the link relations of the + A link description object is used to describe link relations. In + the context of a schema, it defines the link relations of the instances of the schema, and can be parameterized by the instance - values. The link description format can be used without JSON Schema, + values. The link description format can be used without JSON Schema, and use of this format can be declared by referencing the normative link description - schema as the the schema for the data structure that uses the - links. The URI of the normative link description schema is: + schema as the the schema for the data structure that uses the + links. The URI of the normative link description schema is: http://json-schema.org/links (latest version) or http://json-schema.org/draft-04/links (draft-04 version). - +
    The value of the "href" link description property @@ -617,19 +617,19 @@ Content-Type: application/json; of the instance property SHOULD be resolved as a URI-Reference per RFC 3986 and MAY be a relative URI. The base URI to be used for relative resolution SHOULD be the URI used to retrieve the instance object (not the schema) - when used within a schema. Also, when links are used within a schema, the URI - SHOULD be parametrized by the property values of the instance + when used within a schema. Also, when links are used within a schema, the URI + SHOULD be parametrized by the property values of the instance object, if property values exist for the corresponding variables in the template (otherwise they MAY be provided from alternate sources, like user input). - + Instance property values SHOULD be substituted into the URIs where matching braces ('{', '}') are found surrounding zero or more characters, creating an expanded URI. Instance property value substitutions are resolved by using the text between the braces to denote the property name - from the instance to get the value to substitute. - + from the instance to get the value to substitute. +
    For example, if an href value is defined: @@ -639,7 +639,7 @@ http://somesite.com/{id} Then it would be resolved by replace the value of the "id" property value from the instance object.
    - +
    If the value of the "id" property was "45", the expanded URI would be: @@ -648,23 +648,23 @@ http://somesite.com/45 ]]>
    - - If matching braces are found with the string "@" (no quotes) between the braces, then the + + If matching braces are found with the string "@" (no quotes) between the braces, then the actual instance value SHOULD be used to replace the braces, rather than a property value. - This should only be used in situations where the instance is a scalar (string, + This should only be used in situations where the instance is a scalar (string, boolean, or number), and not for objects or arrays.
    - +
    - The value of the "rel" property indicates the name of the + The value of the "rel" property indicates the name of the relation to the target resource. The relation to the target SHOULD be interpreted as specifically from the instance object that the schema (or sub-schema) applies to, not just the top level resource that contains the object within its hierarchy. If a resource JSON representation contains a sub object with a property interpreted as a link, that sub-object holds the relation with the target. A relation to target from the top level resource MUST be indicated with the schema describing the top level JSON representation. - + Relationship definitions SHOULD NOT be media type dependent, and users are encouraged to utilize existing accepted relation definitions, including those in existing relation registries (see RFC 4287). However, we define these relations here for clarity of normative interpretation within the context of JSON hyper schema defined relations: - + If the relation value is "self", when this property is encountered in @@ -672,15 +672,15 @@ http://somesite.com/45 treated as a full representation of the target resource identified by the specified URI. - + This indicates that the target of the link is the full representation for the instance object. The object that contains this link possibly may not be the full representation. - + This indicates the target of the link is the schema for the instance object. This MAY be used to specifically denote the schemas of objects within a JSON object hierarchy, facilitating polymorphic type data structures. - + This relation indicates that the target of the link SHOULD be treated as the root or the body of the representation for the @@ -690,7 +690,7 @@ http://somesite.com/45 - + The following relations are applicable for schemas (the schema as the "from" resource in the relation): @@ -699,7 +699,7 @@ http://somesite.com/45 This indicates a target to use for creating new instances of a schema. This link definition SHOULD be a submission link with a non-safe method (like POST). - +
    For example, if a schema is defined: @@ -720,7 +720,7 @@ http://somesite.com/45 ]]>
    - +
    And if a collection of instance resource's JSON representation was retrieved: @@ -744,41 +744,41 @@ GET /Resource/ The "children" collection would be located at "/Resource/?upId=thing".
    - +
    This property value is a string that defines the templating language used in the "href" attribute. If no templating language is defined, then the default Link Description Object templating langauge is used.
    - +
    This property value is a schema that defines the expected structure of the JSON representation of the target of the link.
    - +
    - The following properties also apply to link definition objects, and - provide functionality analogous to HTML forms, in providing a + The following properties also apply to link definition objects, and + provide functionality analogous to HTML forms, in providing a means for submitting extra (often user supplied) information to send to a server. - +
    - This attribute defines which method can be used to access the target resource. - In an HTTP environment, this would be "GET" or "POST" (other HTTP methods - such as "PUT" and "DELETE" have semantics that are clearly implied by - accessed resources, and do not need to be defined here). + This attribute defines which method can be used to access the target resource. + In an HTTP environment, this would be "GET" or "POST" (other HTTP methods + such as "PUT" and "DELETE" have semantics that are clearly implied by + accessed resources, and do not need to be defined here). This defaults to "GET".
    - +
    If present, this property indicates a query media type format that the server - supports for querying or posting to the collection of instances at the target - resource. The query can be + supports for querying or posting to the collection of instances at the target + resource. The query can be suffixed to the target URI to query the collection with property-based constraints on the resources that SHOULD be returned from the server or used to post data to the resource (depending on the method). - +
    For example, with the following schema: @@ -799,7 +799,7 @@ GET /Resource/ This indicates that the client can query the server for instances that have a specific name.
    - +
    For example: @@ -809,23 +809,23 @@ GET /Resource/
    - If no enctype or method is specified, only the single URI specified by - the href property is defined. If the method is POST, "application/json" is + If no enctype or method is specified, only the single URI specified by + the href property is defined. If the method is POST, "application/json" is the default media type.
    - +
    This attribute contains a schema which defines the acceptable structure of the submitted - request (for a GET request, this schema would define the properties for the query string + request (for a GET request, this schema would define the properties for the query string and for a POST request, this would define the body).
    - +
    This property indicates the fragment resolution protocol to use for @@ -835,62 +835,62 @@ GET /Resource/ protocol is "json-pointer", which is defined below. Other fragment resolution protocols MAY be used, but are not defined in this document. - + The fragment identifier is based on RFC 3986, Sec 5, and defines the mechanism for resolving references to entities within a document. - +
    The "json-pointer" fragment resolution protocol uses a JSON Pointer to resolve fragment identifiers in URIs within instance representations.
    - + - +
    This attribute indicates that the instance value SHOULD NOT be changed. Attempts by a user agent to modify the value of this property are expected to be rejected by a server.
    - +
    If the instance property value is a string, this attribute defines that the string SHOULD be interpreted as binary data and decoded using the encoding named by this schema property. RFC 2045, Sec 6.1 lists the possible values for this property.
    - +
    - This attribute is a URI that defines what the instance's URI MUST start with in order to validate. - The value of the "pathStart" attribute MUST be resolved as per RFC 3986, Sec 5, + This attribute is a URI that defines what the instance's URI MUST start with in order to validate. + The value of the "pathStart" attribute MUST be resolved as per RFC 3986, Sec 5, and is relative to the instance's URI. - + - When multiple schemas have been referenced for an instance, the user agent - can determine if this schema is applicable for a particular instance by + When multiple schemas have been referenced for an instance, the user agent + can determine if this schema is applicable for a particular instance by determining if the URI of the instance begins with the the value of the "pathStart" - attribute. If the URI of the instance does not start with this URI, - or if another schema specifies a starting URI that is longer and also matches the - instance, this schema SHOULD NOT be applied to the instance. Any schema - that does not have a pathStart attribute SHOULD be considered applicable + attribute. If the URI of the instance does not start with this URI, + or if another schema specifies a starting URI that is longer and also matches the + instance, this schema SHOULD NOT be applied to the instance. Any schema + that does not have a pathStart attribute SHOULD be considered applicable to all the instances for which it is referenced.
    - +
    This attribute defines the media type of the instance representations that this schema is defining.
    - +
    - This specification is a sub-type of the JSON format, and - consequently the security considerations are generally the same as RFC 4627. + This specification is a sub-type of the JSON format, and + consequently the security considerations are generally the same as RFC 4627. However, an additional issue is that when link relation of "self" - is used to denote a full representation of an object, the user agent + is used to denote a full representation of an object, the user agent SHOULD NOT consider the representation to be the authoritative representation of the resource denoted by the target URI if the target URI is not - equivalent to or a sub-path of the the URI used to request the resource + equivalent to or a sub-path of the the URI used to request the resource representation which contains the target URI with the "self" link. - +
    For example, if a hyper schema was defined: @@ -904,7 +904,7 @@ GET /Resource/ ]]>
    - +
    And a resource was requested from somesite.com: @@ -941,22 +941,22 @@ Content-Type: application/json; profile=/schema-for-this-data
    - +
    The proposed MIME media type for JSON Schema is "application/schema+json". Type name: application Subtype name: schema+json Required parameters: profile - The value of the profile parameter SHOULD be a URI (relative or absolute) that - refers to the schema used to define the structure of this structure (the + The value of the profile parameter SHOULD be a URI (relative or absolute) that + refers to the schema used to define the structure of this structure (the meta-schema). Normally the value would be http://json-schema.org/draft-04/hyper-schema, but it is allowable to use other schemas that extend the hyper schema's meta- schema. Optional parameters: pretty The value of the pretty parameter MAY be true or false to indicate if additional whitespace has been included to make the JSON representation easier to read. - +
    This registry is maintained by IANA per RFC 4287 and this specification adds @@ -968,7 +968,7 @@ Content-Type: application/json; profile=/schema-for-this-data
    - + @@ -1019,7 +1019,7 @@ Content-Type: application/json; profile=/schema-for-this-data Improved wording of many sections.
    - + Added example and verbiage to "extends" attribute. @@ -1043,7 +1043,7 @@ Content-Type: application/json; profile=/schema-for-this-data Added "$ref" and "$schema" attributes. - + Replaced "maxDecimal" attribute with "divisibleBy" attribute. @@ -1053,13 +1053,13 @@ Content-Type: application/json; profile=/schema-for-this-data Added "targetSchema" attribute to link description object. - + Fixed category and updates from template. - + Initial draft. diff --git a/deps/npm/node_modules/json-schema/lib/links.js b/deps/npm/node_modules/json-schema/lib/links.js index 2f450ff61d2976..2ef3f9fb7d0afe 100644 --- a/deps/npm/node_modules/json-schema/lib/links.js +++ b/deps/npm/node_modules/json-schema/lib/links.js @@ -1,4 +1,4 @@ -/** +/** * JSON Schema link handler * Copyright (c) 2007 Kris Zyp SitePen (www.sitepen.com) * Licensed under the MIT (MIT-LICENSE.txt) license. @@ -25,11 +25,11 @@ exports.getLink = function(relation, instance, schema){ // gets the URI of the link for the given relation based on the instance and schema // for example: // getLink( - // "brother", - // {"brother_id":33}, + // "brother", + // {"brother_id":33}, // {links:[{rel:"brother", href:"Brother/{brother_id}"}]}) -> // "Brother/33" - var links = schema.__linkTemplates; + var links = schema.__linkTemplates; if(!links){ links = {}; var schemaLinks = schema.links; diff --git a/deps/npm/node_modules/json-schema/lib/validate.js b/deps/npm/node_modules/json-schema/lib/validate.js index 4d0b537941e3cc..4b6108800aafb5 100644 --- a/deps/npm/node_modules/json-schema/lib/validate.js +++ b/deps/npm/node_modules/json-schema/lib/validate.js @@ -207,8 +207,8 @@ var validate = exports._validate = function(/*Any*/instance,/*Object*/schema,/*O if(typeof instance != 'object' || instance instanceof Array){ errors.push({property:path,message:"an object is required"}); } - - for(var i in objTypeDef){ + + for(var i in objTypeDef){ if(objTypeDef.hasOwnProperty(i)){ var value = instance[i]; // skip _not_ specified properties diff --git a/deps/npm/node_modules/npm-bundled/index.js b/deps/npm/node_modules/npm-bundled/index.js index bde0acd164b7d1..197a1bcb99a153 100644 --- a/deps/npm/node_modules/npm-bundled/index.js +++ b/deps/npm/node_modules/npm-bundled/index.js @@ -10,6 +10,9 @@ const fs = require('fs') const path = require('path') const EE = require('events').EventEmitter +// we don't care about the package bins, but we share a pj cache +// with other modules that DO care about it, so keep it nice. +const normalizePackageBin = require('npm-normalize-package-bin') class BundleWalker extends EE { constructor (opt) { @@ -84,7 +87,7 @@ class BundleWalker extends EE { onPackageJson (pj, data) { try { - this.package = JSON.parse(data + '') + this.package = normalizePackageBin(JSON.parse(data + '')) } catch (er) { return this.done() } @@ -92,17 +95,22 @@ class BundleWalker extends EE { this.onPackage(this.package) } + allDepsBundled (pkg) { + return Object.keys(pkg.dependencies || {}).concat( + Object.keys(pkg.optionalDependencies || {})) + } + onPackage (pkg) { // all deps are bundled if we got here as a child. // otherwise, only bundle bundledDeps // Get a unique-ified array with a short-lived Set - const bdRaw = this.parent - ? Object.keys(pkg.dependencies || {}).concat( - Object.keys(pkg.optionalDependencies || {})) + const bdRaw = this.parent ? this.allDepsBundled(pkg) : pkg.bundleDependencies || pkg.bundledDependencies || [] const bd = Array.from(new Set( - Array.isArray(bdRaw) ? bdRaw : Object.keys(bdRaw))) + Array.isArray(bdRaw) ? bdRaw + : bdRaw === true ? this.allDepsBundled(pkg) + : Object.keys(bdRaw))) if (!bd.length) return this.done() diff --git a/deps/npm/node_modules/npm-bundled/package.json b/deps/npm/node_modules/npm-bundled/package.json index 48297374004536..18c578a5cb72da 100644 --- a/deps/npm/node_modules/npm-bundled/package.json +++ b/deps/npm/node_modules/npm-bundled/package.json @@ -1,8 +1,8 @@ { "_from": "npm-bundled@^1.0.1", - "_id": "npm-bundled@1.0.6", + "_id": "npm-bundled@1.1.1", "_inBundle": false, - "_integrity": "sha512-8/JCaftHwbd//k6y2rEWp6k1wxVfpFzB6t1p825+cUb7Ym2XQfhwIC5KwhrvzZRJu+LtDE585zVaS32+CGtf0g==", + "_integrity": "sha512-gqkfgGePhTpAEgUsGEgcq1rqPXA+tv/aVBlgEzfXwA1yiUJF7xtEt3CtVwOjNYQOVknDk0F20w58Fnm3EtG0fA==", "_location": "/npm-bundled", "_phantomChildren": {}, "_requested": { @@ -18,10 +18,10 @@ "_requiredBy": [ "/npm-packlist" ], - "_resolved": "https://registry.npmjs.org/npm-bundled/-/npm-bundled-1.0.6.tgz", - "_shasum": "e7ba9aadcef962bb61248f91721cd932b3fe6bdd", + "_resolved": "https://registry.npmjs.org/npm-bundled/-/npm-bundled-1.1.1.tgz", + "_shasum": "1edd570865a94cdb1bc8220775e29466c9fb234b", "_spec": "npm-bundled@^1.0.1", - "_where": "/Users/aeschright/code/npm-release/node_modules/npm-packlist", + "_where": "/Users/isaacs/dev/npm/cli/node_modules/npm-packlist", "author": { "name": "Isaac Z. Schlueter", "email": "i@izs.me", @@ -31,6 +31,9 @@ "url": "https://github.com/npm/npm-bundled/issues" }, "bundleDependencies": false, + "dependencies": { + "npm-normalize-package-bin": "^1.0.1" + }, "deprecated": false, "description": "list things in node_modules that are bundledDependencies, or transitive dependencies thereof", "devDependencies": { @@ -56,5 +59,5 @@ "preversion": "npm test", "test": "tap test/*.js -J --100" }, - "version": "1.0.6" + "version": "1.1.1" } diff --git a/deps/npm/node_modules/npm-normalize-package-bin/.github/settings.yml b/deps/npm/node_modules/npm-normalize-package-bin/.github/settings.yml new file mode 100644 index 00000000000000..4aaa0dd57e4ad0 --- /dev/null +++ b/deps/npm/node_modules/npm-normalize-package-bin/.github/settings.yml @@ -0,0 +1,2 @@ +--- +_extends: 'open-source-project-boilerplate' diff --git a/deps/npm/node_modules/npm-normalize-package-bin/.npmignore b/deps/npm/node_modules/npm-normalize-package-bin/.npmignore new file mode 100644 index 00000000000000..3870bd5bb72079 --- /dev/null +++ b/deps/npm/node_modules/npm-normalize-package-bin/.npmignore @@ -0,0 +1,24 @@ +# ignore most things, include some others +/* +/.* + +!bin/ +!lib/ +!docs/ +!package.json +!package-lock.json +!README.md +!CONTRIBUTING.md +!LICENSE +!CHANGELOG.md +!example/ +!scripts/ +!tap-snapshots/ +!test/ +!.github/ +!.travis.yml +!.gitignore +!.gitattributes +!coverage-map.js +!map.js +!index.js diff --git a/deps/npm/node_modules/npm-normalize-package-bin/LICENSE b/deps/npm/node_modules/npm-normalize-package-bin/LICENSE new file mode 100644 index 00000000000000..19cec97b184683 --- /dev/null +++ b/deps/npm/node_modules/npm-normalize-package-bin/LICENSE @@ -0,0 +1,15 @@ +The ISC License + +Copyright (c) npm, Inc. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/deps/npm/node_modules/npm-normalize-package-bin/README.md b/deps/npm/node_modules/npm-normalize-package-bin/README.md new file mode 100644 index 00000000000000..65ba316a0d97ee --- /dev/null +++ b/deps/npm/node_modules/npm-normalize-package-bin/README.md @@ -0,0 +1,14 @@ +# npm-normalize-package-bin + +Turn any flavor of allowable package.json bin into a normalized object. + +## API + +```js +const normalize = require('npm-normalize-package-bin') +const pkg = {name: 'foo', bin: 'bar'} +console.log(normalize(pkg)) // {name:'foo', bin:{foo: 'bar'}} +``` + +Also strips out weird dots and slashes to prevent accidental and/or +malicious bad behavior when the package is installed. diff --git a/deps/npm/node_modules/npm-normalize-package-bin/index.js b/deps/npm/node_modules/npm-normalize-package-bin/index.js new file mode 100644 index 00000000000000..5a738ff82e1e3a --- /dev/null +++ b/deps/npm/node_modules/npm-normalize-package-bin/index.js @@ -0,0 +1,60 @@ +// pass in a manifest with a 'bin' field here, and it'll turn it +// into a properly santized bin object +const {join, basename} = require('path') + +const normalize = pkg => + !pkg.bin ? removeBin(pkg) + : typeof pkg.bin === 'string' ? normalizeString(pkg) + : Array.isArray(pkg.bin) ? normalizeArray(pkg) + : typeof pkg.bin === 'object' ? normalizeObject(pkg) + : removeBin(pkg) + +const normalizeString = pkg => { + if (!pkg.name) + return removeBin(pkg) + pkg.bin = { [pkg.name]: pkg.bin } + return normalizeObject(pkg) +} + +const normalizeArray = pkg => { + pkg.bin = pkg.bin.reduce((acc, k) => { + acc[basename(k)] = k + return acc + }, {}) + return normalizeObject(pkg) +} + +const removeBin = pkg => { + delete pkg.bin + return pkg +} + +const normalizeObject = pkg => { + const orig = pkg.bin + const clean = {} + let hasBins = false + Object.keys(orig).forEach(binKey => { + const base = join('/', basename(binKey.replace(/\\|:/g, '/'))).substr(1) + + if (typeof orig[binKey] !== 'string' || !base) + return + + const binTarget = join('/', orig[binKey]) + .replace(/\\/g, '/').substr(1) + + if (!binTarget) + return + + clean[base] = binTarget + hasBins = true + }) + + if (hasBins) + pkg.bin = clean + else + delete pkg.bin + + return pkg +} + +module.exports = normalize diff --git a/deps/npm/node_modules/npm-normalize-package-bin/package-lock.json b/deps/npm/node_modules/npm-normalize-package-bin/package-lock.json new file mode 100644 index 00000000000000..0d3390d4eee636 --- /dev/null +++ b/deps/npm/node_modules/npm-normalize-package-bin/package-lock.json @@ -0,0 +1,3529 @@ +{ + "name": "npm-normalize-package-bin", + "version": "1.0.1", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@babel/code-frame": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz", + "integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==", + "dev": true, + "requires": { + "@babel/highlight": "^7.0.0" + } + }, + "@babel/generator": { + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.7.4.tgz", + "integrity": "sha512-m5qo2WgdOJeyYngKImbkyQrnUN1mPceaG5BV+G0E3gWsa4l/jCSryWJdM2x8OuGAOyh+3d5pVYfZWCiNFtynxg==", + "dev": true, + "requires": { + "@babel/types": "^7.7.4", + "jsesc": "^2.5.1", + "lodash": "^4.17.13", + "source-map": "^0.5.0" + }, + "dependencies": { + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", + "dev": true + } + } + }, + "@babel/helper-function-name": { + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.7.4.tgz", + "integrity": "sha512-AnkGIdiBhEuiwdoMnKm7jfPfqItZhgRaZfMg1XX3bS25INOnLPjPG1Ppnajh8eqgt5kPJnfqrRHqFqmjKDZLzQ==", + "dev": true, + "requires": { + "@babel/helper-get-function-arity": "^7.7.4", + "@babel/template": "^7.7.4", + "@babel/types": "^7.7.4" + } + }, + "@babel/helper-get-function-arity": { + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.7.4.tgz", + "integrity": "sha512-QTGKEdCkjgzgfJ3bAyRwF4yyT3pg+vDgan8DSivq1eS0gwi+KGKE5x8kRcbeFTb/673mkO5SN1IZfmCfA5o+EA==", + "dev": true, + "requires": { + "@babel/types": "^7.7.4" + } + }, + "@babel/helper-split-export-declaration": { + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.7.4.tgz", + "integrity": "sha512-guAg1SXFcVr04Guk9eq0S4/rWS++sbmyqosJzVs8+1fH5NI+ZcmkaSkc7dmtAFbHFva6yRJnjW3yAcGxjueDug==", + "dev": true, + "requires": { + "@babel/types": "^7.7.4" + } + }, + "@babel/highlight": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.5.0.tgz", + "integrity": "sha512-7dV4eu9gBxoM0dAnj/BCFDW9LFU0zvTrkq0ugM7pnHEgguOEeOz1so2ZghEdzviYzQEED0r4EAgpsBChKy1TRQ==", + "dev": true, + "requires": { + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^4.0.0" + } + }, + "@babel/parser": { + "version": "7.7.5", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.7.5.tgz", + "integrity": "sha512-KNlOe9+/nk4i29g0VXgl8PEXIRms5xKLJeuZ6UptN0fHv+jDiriG+y94X6qAgWTR0h3KaoM1wK5G5h7MHFRSig==", + "dev": true + }, + "@babel/runtime": { + "version": "7.7.6", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.7.6.tgz", + "integrity": "sha512-BWAJxpNVa0QlE5gZdWjSxXtemZyZ9RmrmVozxt3NUXeZhVIJ5ANyqmMc0JDrivBZyxUuQvFxlvH4OWWOogGfUw==", + "dev": true, + "requires": { + "regenerator-runtime": "^0.13.2" + } + }, + "@babel/template": { + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.7.4.tgz", + "integrity": "sha512-qUzihgVPguAzXCK7WXw8pqs6cEwi54s3E+HrejlkuWO6ivMKx9hZl3Y2fSXp9i5HgyWmj7RKP+ulaYnKM4yYxw==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "@babel/parser": "^7.7.4", + "@babel/types": "^7.7.4" + } + }, + "@babel/traverse": { + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.7.4.tgz", + "integrity": "sha512-P1L58hQyupn8+ezVA2z5KBm4/Zr4lCC8dwKCMYzsa5jFMDMQAzaBNy9W5VjB+KAmBjb40U7a/H6ao+Xo+9saIw==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.5.5", + "@babel/generator": "^7.7.4", + "@babel/helper-function-name": "^7.7.4", + "@babel/helper-split-export-declaration": "^7.7.4", + "@babel/parser": "^7.7.4", + "@babel/types": "^7.7.4", + "debug": "^4.1.0", + "globals": "^11.1.0", + "lodash": "^4.17.13" + } + }, + "@babel/types": { + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.7.4.tgz", + "integrity": "sha512-cz5Ji23KCi4T+YIE/BolWosrJuSmoZeN1EFnRtBwF+KKLi8GG/Z2c2hOJJeCXPk4mwk4QFvTmwIodJowXgttRA==", + "dev": true, + "requires": { + "esutils": "^2.0.2", + "lodash": "^4.17.13", + "to-fast-properties": "^2.0.0" + } + }, + "ajv": { + "version": "6.10.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.2.tgz", + "integrity": "sha512-TXtUUEYHuaTEbLZWIKUr5pmBuhDLy+8KYtPYdcV8qC+pOZL+NKqYwvWSRrVXHn+ZmRRAu8vJTAznH7Oag6RVRw==", + "dev": true, + "requires": { + "fast-deep-equal": "^2.0.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "anymatch": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.1.tgz", + "integrity": "sha512-mM8522psRCqzV+6LhomX5wgp25YVibjh8Wj23I5RPkPppSVSjyKD2A2mBJmWGa+KN7f2D6LNh9jkBCeyLktzjg==", + "dev": true, + "requires": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + } + }, + "append-transform": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/append-transform/-/append-transform-1.0.0.tgz", + "integrity": "sha512-P009oYkeHyU742iSZJzZZywj4QRJdnTWffaKuJQLablCZ1uz6/cW4yaRgcDaoQ+uwOxxnt0gRUcwfsNP2ri0gw==", + "dev": true, + "requires": { + "default-require-extensions": "^2.0.0" + } + }, + "archy": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/archy/-/archy-1.0.0.tgz", + "integrity": "sha1-+cjBN1fMHde8N5rHeyxipcKGjEA=", + "dev": true + }, + "arg": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.2.tgz", + "integrity": "sha512-+ytCkGcBtHZ3V2r2Z06AncYO8jz46UEamcspGoU8lHcEbpn6J77QK0vdWvChsclg/tM5XIJC5tnjmPp7Eq6Obg==", + "dev": true + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "requires": { + "sprintf-js": "~1.0.2" + } + }, + "asn1": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", + "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", + "dev": true, + "requires": { + "safer-buffer": "~2.1.0" + } + }, + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", + "dev": true + }, + "async-hook-domain": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/async-hook-domain/-/async-hook-domain-1.1.3.tgz", + "integrity": "sha512-ZovMxSbADV3+biB7oR1GL5lGyptI24alp0LWHlmz1OFc5oL47pz3EiIF6nXOkDW7yLqih4NtsiYduzdDW0i+Wg==", + "dev": true, + "requires": { + "source-map-support": "^0.5.11" + } + }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", + "dev": true + }, + "aws-sign2": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", + "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=", + "dev": true + }, + "aws4": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.9.0.tgz", + "integrity": "sha512-Uvq6hVe90D0B2WEnUqtdgY1bATGz3mw33nH9Y+dmA+w5DHvUmBgkr5rM/KCHpCsiFNRUfokW/szpPPgMK2hm4A==", + "dev": true + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "bcrypt-pbkdf": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", + "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", + "dev": true, + "requires": { + "tweetnacl": "^0.14.3" + } + }, + "binary-extensions": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.0.0.tgz", + "integrity": "sha512-Phlt0plgpIIBOGTT/ehfFnbNlfsDEiqmzE2KRXoX1bLIlir4X/MR+zSyBEkL05ffWgnRSf/DXv+WrUAVr93/ow==", + "dev": true + }, + "bind-obj-methods": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/bind-obj-methods/-/bind-obj-methods-2.0.0.tgz", + "integrity": "sha512-3/qRXczDi2Cdbz6jE+W3IflJOutRVica8frpBn14de1mBOkzDo+6tY33kNhvkw54Kn3PzRRD2VnGbGPcTAk4sw==", + "dev": true + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dev": true, + "requires": { + "fill-range": "^7.0.1" + } + }, + "browser-process-hrtime": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/browser-process-hrtime/-/browser-process-hrtime-1.0.0.tgz", + "integrity": "sha512-9o5UecI3GhkpM6DrXr69PblIuWxPKk9Y0jHBRhdocZ2y7YECBFCsHm79Pr3OyR2AvjhDkabFJaDJMYRazHgsow==", + "dev": true + }, + "buffer-from": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", + "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", + "dev": true + }, + "caching-transform": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/caching-transform/-/caching-transform-3.0.2.tgz", + "integrity": "sha512-Mtgcv3lh3U0zRii/6qVgQODdPA4G3zhG+jtbCWj39RXuUFTMzH0vcdMtaJS1jPowd+It2Pqr6y3NJMQqOqCE2w==", + "dev": true, + "requires": { + "hasha": "^3.0.0", + "make-dir": "^2.0.0", + "package-hash": "^3.0.0", + "write-file-atomic": "^2.4.2" + }, + "dependencies": { + "write-file-atomic": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-2.4.3.tgz", + "integrity": "sha512-GaETH5wwsX+GcnzhPgKcKjJ6M2Cq3/iZp1WyY/X1CSqrW+jVNM9Y7D8EC2sM4ZG/V8wZlSniJnCKWPmBYAucRQ==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.11", + "imurmurhash": "^0.1.4", + "signal-exit": "^3.0.2" + } + } + } + }, + "camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true + }, + "caseless": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", + "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", + "dev": true + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "chokidar": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.3.0.tgz", + "integrity": "sha512-dGmKLDdT3Gdl7fBUe8XK+gAtGmzy5Fn0XkkWQuYxGIgWVPPse2CxFA5mtrlD0TOHaHjEUqkWNyP1XdHoJES/4A==", + "dev": true, + "requires": { + "anymatch": "~3.1.1", + "braces": "~3.0.2", + "fsevents": "~2.1.1", + "glob-parent": "~5.1.0", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.2.0" + } + }, + "cliui": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-4.1.0.tgz", + "integrity": "sha512-4FG+RSG9DL7uEwRUZXZn3SS34DiDPfzP0VOiEwtUWlE+AR2EIg+hSyvrIgUUfhdgR/UkAeW2QHgeP+hWrXs7jQ==", + "dev": true, + "requires": { + "string-width": "^2.1.1", + "strip-ansi": "^4.0.0", + "wrap-ansi": "^2.0.0" + } + }, + "code-point-at": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", + "dev": true + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + }, + "color-support": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz", + "integrity": "sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==", + "dev": true + }, + "combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dev": true, + "requires": { + "delayed-stream": "~1.0.0" + } + }, + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true, + "optional": true + }, + "commondir": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", + "integrity": "sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=", + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "convert-source-map": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.7.0.tgz", + "integrity": "sha512-4FJkXzKXEDB1snCFZlLP4gpC3JILicCpGbzG9f9G7tGqGCzETQ2hWPrcinA9oU4wtf2biUaEH5065UnMeR33oA==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.1" + }, + "dependencies": { + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + } + } + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "dev": true + }, + "coveralls": { + "version": "3.0.9", + "resolved": "https://registry.npmjs.org/coveralls/-/coveralls-3.0.9.tgz", + "integrity": "sha512-nNBg3B1+4iDox5A5zqHKzUTiwl2ey4k2o0NEcVZYvl+GOSJdKBj4AJGKLv6h3SvWch7tABHePAQOSZWM9E2hMg==", + "dev": true, + "requires": { + "js-yaml": "^3.13.1", + "lcov-parse": "^1.0.0", + "log-driver": "^1.2.7", + "minimist": "^1.2.0", + "request": "^2.88.0" + } + }, + "cp-file": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/cp-file/-/cp-file-6.2.0.tgz", + "integrity": "sha512-fmvV4caBnofhPe8kOcitBwSn2f39QLjnAnGq3gO9dfd75mUytzKNZB1hde6QHunW2Rt+OwuBOMc3i1tNElbszA==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "make-dir": "^2.0.0", + "nested-error-stacks": "^2.0.0", + "pify": "^4.0.1", + "safe-buffer": "^5.0.1" + } + }, + "cross-spawn": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-4.0.2.tgz", + "integrity": "sha1-e5JHYhwjrf3ThWAEqCPL45dCTUE=", + "dev": true, + "requires": { + "lru-cache": "^4.0.1", + "which": "^1.2.9" + }, + "dependencies": { + "which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + } + } + }, + "dashdash": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", + "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", + "dev": true, + "requires": { + "assert-plus": "^1.0.0" + } + }, + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", + "dev": true + }, + "default-require-extensions": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/default-require-extensions/-/default-require-extensions-2.0.0.tgz", + "integrity": "sha1-9fj7sYp9bVCyH2QfZJ67Uiz+JPc=", + "dev": true, + "requires": { + "strip-bom": "^3.0.0" + } + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", + "dev": true + }, + "diff": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.1.tgz", + "integrity": "sha512-s2+XdvhPCOF01LRQBC8hf4vhbVmI2CGS5aZnxLJlT5FtdhPCDFq80q++zK2KlrVorVDdL5BOGZ/VfLrVtYNF+Q==", + "dev": true + }, + "diff-frag": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/diff-frag/-/diff-frag-1.0.1.tgz", + "integrity": "sha512-6/v2PC/6UTGcWPPetb9acL8foberUg/CtPdALeJUdD1B/weHNvzftoo00gYznqHGRhHEbykUGzqfG9RWOSr5yw==", + "dev": true + }, + "ecc-jsbn": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", + "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", + "dev": true, + "requires": { + "jsbn": "~0.1.0", + "safer-buffer": "^2.1.0" + } + }, + "emoji-regex": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", + "dev": true + }, + "error-ex": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", + "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", + "dev": true, + "requires": { + "is-arrayish": "^0.2.1" + } + }, + "es6-error": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/es6-error/-/es6-error-4.1.1.tgz", + "integrity": "sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==", + "dev": true + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + }, + "esm": { + "version": "3.2.25", + "resolved": "https://registry.npmjs.org/esm/-/esm-3.2.25.tgz", + "integrity": "sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA==", + "dev": true + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true + }, + "esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true + }, + "events-to-array": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/events-to-array/-/events-to-array-1.1.2.tgz", + "integrity": "sha1-LUH1Y+H+QA7Uli/hpNXGp1Od9/Y=", + "dev": true + }, + "extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", + "dev": true + }, + "extsprintf": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", + "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=", + "dev": true + }, + "fast-deep-equal": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", + "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=", + "dev": true + }, + "fast-json-stable-stringify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", + "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=", + "dev": true + }, + "fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dev": true, + "requires": { + "to-regex-range": "^5.0.1" + } + }, + "find-cache-dir": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-2.1.0.tgz", + "integrity": "sha512-Tq6PixE0w/VMFfCgbONnkiQIVol/JJL7nRMi20fqzA4NRs9AfeqMGeRdPi3wIhYkxjeBaWh2rxwapn5Tu3IqOQ==", + "dev": true, + "requires": { + "commondir": "^1.0.1", + "make-dir": "^2.0.0", + "pkg-dir": "^3.0.0" + } + }, + "find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "dev": true, + "requires": { + "locate-path": "^3.0.0" + } + }, + "findit": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/findit/-/findit-2.0.0.tgz", + "integrity": "sha1-ZQnwEmr0wXhVHPqZOU4DLhOk1W4=", + "dev": true + }, + "flow-parser": { + "version": "0.113.0", + "resolved": "https://registry.npmjs.org/flow-parser/-/flow-parser-0.113.0.tgz", + "integrity": "sha512-+hRyEB1sVLNMTMniDdM1JIS8BJ3HUL7IFIJaxX+t/JUy0GNYdI0Tg1QLx8DJmOF8HeoCrUDcREpnDAc/pPta3w==", + "dev": true + }, + "flow-remove-types": { + "version": "2.113.0", + "resolved": "https://registry.npmjs.org/flow-remove-types/-/flow-remove-types-2.113.0.tgz", + "integrity": "sha512-Rp4hN/JlGmUjNxXuBXr6Or+MgDH9xKc+ZiUSRzl/fbpiH9RaCPAQKsgVEYNPcIE26q6RpAuMQfvzR0jQfuwUZQ==", + "dev": true, + "requires": { + "flow-parser": "^0.113.0", + "pirates": "^3.0.2", + "vlq": "^0.2.1" + } + }, + "foreground-child": { + "version": "1.5.6", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-1.5.6.tgz", + "integrity": "sha1-T9ca0t/elnibmApcCilZN8svXOk=", + "dev": true, + "requires": { + "cross-spawn": "^4", + "signal-exit": "^3.0.0" + } + }, + "forever-agent": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", + "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=", + "dev": true + }, + "form-data": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", + "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", + "dev": true, + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.6", + "mime-types": "^2.1.12" + } + }, + "fs-exists-cached": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs-exists-cached/-/fs-exists-cached-1.0.0.tgz", + "integrity": "sha1-zyVVTKBQ3EmuZla0HeQiWJidy84=", + "dev": true + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "fsevents": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.1.2.tgz", + "integrity": "sha512-R4wDiBwZ0KzpgOWetKDug1FZcYhqYnUYKtfZYt4mD5SBz76q0KR4Q9o7GIPamsVPGmW3EYPPJ0dOOjvx32ldZA==", + "dev": true, + "optional": true + }, + "function-loop": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/function-loop/-/function-loop-1.0.2.tgz", + "integrity": "sha512-Iw4MzMfS3udk/rqxTiDDCllhGwlOrsr50zViTOO/W6lS/9y6B1J0BD2VZzrnWUYBJsl3aeqjgR5v7bWWhZSYbA==", + "dev": true + }, + "get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true + }, + "getpass": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", + "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", + "dev": true, + "requires": { + "assert-plus": "^1.0.0" + } + }, + "glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "glob-parent": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.0.tgz", + "integrity": "sha512-qjtRgnIVmOfnKUE3NJAQEdk+lKrxfw8t5ke7SXtfMTHcjsBfOfWXCQfdb30zfDoZQ2IRSIiidmjtbHZPZ++Ihw==", + "dev": true, + "requires": { + "is-glob": "^4.0.1" + } + }, + "globals": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "dev": true + }, + "graceful-fs": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.3.tgz", + "integrity": "sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ==", + "dev": true + }, + "handlebars": { + "version": "4.5.3", + "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.5.3.tgz", + "integrity": "sha512-3yPecJoJHK/4c6aZhSvxOyG4vJKDshV36VHp0iVCDVh7o9w2vwi3NSnL2MMPj3YdduqaBcu7cGbggJQM0br9xA==", + "dev": true, + "requires": { + "neo-async": "^2.6.0", + "optimist": "^0.6.1", + "source-map": "^0.6.1", + "uglify-js": "^3.1.4" + } + }, + "har-schema": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", + "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=", + "dev": true + }, + "har-validator": { + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.3.tgz", + "integrity": "sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g==", + "dev": true, + "requires": { + "ajv": "^6.5.5", + "har-schema": "^2.0.0" + } + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "hasha": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/hasha/-/hasha-3.0.0.tgz", + "integrity": "sha1-UqMvq4Vp1BymmmH/GiFPjrfIvTk=", + "dev": true, + "requires": { + "is-stream": "^1.0.1" + } + }, + "hosted-git-info": { + "version": "2.8.5", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.5.tgz", + "integrity": "sha512-kssjab8CvdXfcXMXVcvsXum4Hwdq9XGtRD3TteMEvEbq0LXyiNQr6AprqKqfeaDXze7SxWvRxdpwE6ku7ikLkg==", + "dev": true + }, + "http-signature": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", + "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", + "dev": true, + "requires": { + "assert-plus": "^1.0.0", + "jsprim": "^1.2.2", + "sshpk": "^1.7.0" + } + }, + "imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", + "dev": true + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", + "dev": true + }, + "is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "requires": { + "binary-extensions": "^2.0.0" + } + }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "is-glob": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", + "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", + "dev": true, + "requires": { + "is-extglob": "^2.1.1" + } + }, + "is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true + }, + "is-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", + "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", + "dev": true + }, + "is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", + "dev": true + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true, + "optional": true + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "dev": true + }, + "isstream": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", + "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", + "dev": true + }, + "istanbul-lib-coverage": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.5.tgz", + "integrity": "sha512-8aXznuEPCJvGnMSRft4udDRDtb1V3pkQkMMI5LI+6HuQz5oQ4J2UFn1H82raA3qJtyOLkkwVqICBQkjnGtn5mA==", + "dev": true + }, + "istanbul-lib-hook": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/istanbul-lib-hook/-/istanbul-lib-hook-2.0.7.tgz", + "integrity": "sha512-vrRztU9VRRFDyC+aklfLoeXyNdTfga2EI3udDGn4cZ6fpSXpHLV9X6CHvfoMCPtggg8zvDDmC4b9xfu0z6/llA==", + "dev": true, + "requires": { + "append-transform": "^1.0.0" + } + }, + "istanbul-lib-instrument": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-3.3.0.tgz", + "integrity": "sha512-5nnIN4vo5xQZHdXno/YDXJ0G+I3dAm4XgzfSVTPLQpj/zAV2dV6Juy0yaf10/zrJOJeHoN3fraFe+XRq2bFVZA==", + "dev": true, + "requires": { + "@babel/generator": "^7.4.0", + "@babel/parser": "^7.4.3", + "@babel/template": "^7.4.0", + "@babel/traverse": "^7.4.3", + "@babel/types": "^7.4.0", + "istanbul-lib-coverage": "^2.0.5", + "semver": "^6.0.0" + }, + "dependencies": { + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + } + } + }, + "istanbul-lib-processinfo": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-processinfo/-/istanbul-lib-processinfo-1.0.0.tgz", + "integrity": "sha512-FY0cPmWa4WoQNlvB8VOcafiRoB5nB+l2Pz2xGuXHRSy1KM8QFOYfz/rN+bGMCAeejrY3mrpF5oJHcN0s/garCg==", + "dev": true, + "requires": { + "archy": "^1.0.0", + "cross-spawn": "^6.0.5", + "istanbul-lib-coverage": "^2.0.3", + "rimraf": "^2.6.3", + "uuid": "^3.3.2" + }, + "dependencies": { + "cross-spawn": { + "version": "6.0.5", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", + "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", + "dev": true, + "requires": { + "nice-try": "^1.0.4", + "path-key": "^2.0.1", + "semver": "^5.5.0", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + } + }, + "which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + } + } + }, + "istanbul-lib-report": { + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-2.0.8.tgz", + "integrity": "sha512-fHBeG573EIihhAblwgxrSenp0Dby6tJMFR/HvlerBsrCTD5bkUuoNtn3gVh29ZCS824cGGBPn7Sg7cNk+2xUsQ==", + "dev": true, + "requires": { + "istanbul-lib-coverage": "^2.0.5", + "make-dir": "^2.1.0", + "supports-color": "^6.1.0" + }, + "dependencies": { + "supports-color": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.1.0.tgz", + "integrity": "sha512-qe1jfm1Mg7Nq/NSh6XE24gPXROEVsWHxC1LIx//XNlD9iw7YZQGjZNjYN7xGaEG6iKdA8EtNFW6R0gjnVXp+wQ==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "istanbul-lib-source-maps": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-3.0.6.tgz", + "integrity": "sha512-R47KzMtDJH6X4/YW9XTx+jrLnZnscW4VpNN+1PViSYTejLVPWv7oov+Duf8YQSPyVRUvueQqz1TcsC6mooZTXw==", + "dev": true, + "requires": { + "debug": "^4.1.1", + "istanbul-lib-coverage": "^2.0.5", + "make-dir": "^2.1.0", + "rimraf": "^2.6.3", + "source-map": "^0.6.1" + } + }, + "istanbul-reports": { + "version": "2.2.6", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-2.2.6.tgz", + "integrity": "sha512-SKi4rnMyLBKe0Jy2uUdx28h8oG7ph2PPuQPvIAh31d+Ci+lSiEu4C+h3oBPuJ9+mPKhOyW0M8gY4U5NM1WLeXA==", + "dev": true, + "requires": { + "handlebars": "^4.1.2" + } + }, + "jackspeak": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-1.4.0.tgz", + "integrity": "sha512-VDcSunT+wcccoG46FtzuBAyQKlzhHjli4q31e1fIHGOsRspqNUFjVzGb+7eIFDlTvqLygxapDHPHS0ouT2o/tw==", + "dev": true, + "requires": { + "cliui": "^4.1.0" + } + }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true + }, + "js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", + "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", + "dev": true + }, + "jsesc": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", + "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", + "dev": true + }, + "json-parse-better-errors": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz", + "integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==", + "dev": true + }, + "json-schema": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", + "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=", + "dev": true + }, + "json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true + }, + "json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", + "dev": true + }, + "jsprim": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", + "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", + "dev": true, + "requires": { + "assert-plus": "1.0.0", + "extsprintf": "1.3.0", + "json-schema": "0.2.3", + "verror": "1.10.0" + } + }, + "lcov-parse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/lcov-parse/-/lcov-parse-1.0.0.tgz", + "integrity": "sha1-6w1GtUER68VhrLTECO+TY73I9+A=", + "dev": true + }, + "load-json-file": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz", + "integrity": "sha1-L19Fq5HjMhYjT9U62rZo607AmTs=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "parse-json": "^4.0.0", + "pify": "^3.0.0", + "strip-bom": "^3.0.0" + }, + "dependencies": { + "pify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", + "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", + "dev": true + } + } + }, + "locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "dev": true, + "requires": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + } + }, + "lodash": { + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", + "dev": true + }, + "lodash.flattendeep": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz", + "integrity": "sha1-+wMJF/hqMTTlvJvsDWngAT3f7bI=", + "dev": true + }, + "log-driver": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/log-driver/-/log-driver-1.2.7.tgz", + "integrity": "sha512-U7KCmLdqsGHBLeWqYlFA0V0Sl6P08EE1ZrmA9cxjUE0WVqT9qnyVDPz1kzpFEP0jdJuFnasWIfSd7fsaNXkpbg==", + "dev": true + }, + "loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "dev": true, + "requires": { + "js-tokens": "^3.0.0 || ^4.0.0" + } + }, + "lru-cache": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz", + "integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==", + "dev": true, + "requires": { + "pseudomap": "^1.0.2", + "yallist": "^2.1.2" + } + }, + "make-dir": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-2.1.0.tgz", + "integrity": "sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA==", + "dev": true, + "requires": { + "pify": "^4.0.1", + "semver": "^5.6.0" + } + }, + "make-error": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.5.tgz", + "integrity": "sha512-c3sIjNUow0+8swNwVpqoH4YCShKNFkMaw6oH1mNS2haDZQqkeZFlHS3dhoeEbKKmJB4vXpJucU6oH75aDYeE9g==", + "dev": true + }, + "merge-source-map": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/merge-source-map/-/merge-source-map-1.1.0.tgz", + "integrity": "sha512-Qkcp7P2ygktpMPh2mCQZaf3jhN6D3Z/qVZHSdWvQ+2Ef5HgRAPBO57A77+ENm0CPx2+1Ce/MYKi3ymqdfuqibw==", + "dev": true, + "requires": { + "source-map": "^0.6.1" + } + }, + "mime-db": { + "version": "1.42.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.42.0.tgz", + "integrity": "sha512-UbfJCR4UAVRNgMpfImz05smAXK7+c+ZntjaA26ANtkXLlOe947Aag5zdIcKQULAiF9Cq4WxBi9jUs5zkA84bYQ==", + "dev": true + }, + "mime-types": { + "version": "2.1.25", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.25.tgz", + "integrity": "sha512-5KhStqB5xpTAeGqKBAMgwaYMnQik7teQN4IAzC7npDv6kzeU6prfkR67bc87J1kWMPGkoaZSq1npmexMgkmEVg==", + "dev": true, + "requires": { + "mime-db": "1.42.0" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "dev": true + }, + "minipass": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.1.1.tgz", + "integrity": "sha512-UFqVihv6PQgwj8/yTGvl9kPz7xIAY+R5z6XYjRInD3Gk3qx6QGSD6zEcpeG4Dy/lQnv1J6zv8ejV90hyYIKf3w==", + "dev": true, + "requires": { + "yallist": "^4.0.0" + }, + "dependencies": { + "yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + } + } + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "dev": true, + "requires": { + "minimist": "0.0.8" + }, + "dependencies": { + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true + } + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "neo-async": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.1.tgz", + "integrity": "sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw==", + "dev": true + }, + "nested-error-stacks": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/nested-error-stacks/-/nested-error-stacks-2.1.0.tgz", + "integrity": "sha512-AO81vsIO1k1sM4Zrd6Hu7regmJN1NSiAja10gc4bX3F0wd+9rQmcuHQaHVQCYIEC8iFXnE+mavh23GOt7wBgug==", + "dev": true + }, + "nice-try": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", + "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", + "dev": true + }, + "node-modules-regexp": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/node-modules-regexp/-/node-modules-regexp-1.0.0.tgz", + "integrity": "sha1-jZ2+KJZKSsVxLpExZCEHxx6Q7EA=", + "dev": true + }, + "normalize-package-data": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", + "dev": true, + "requires": { + "hosted-git-info": "^2.1.4", + "resolve": "^1.10.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" + } + }, + "normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true + }, + "number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", + "dev": true + }, + "nyc": { + "version": "14.1.1", + "resolved": "https://registry.npmjs.org/nyc/-/nyc-14.1.1.tgz", + "integrity": "sha512-OI0vm6ZGUnoGZv/tLdZ2esSVzDwUC88SNs+6JoSOMVxA+gKMB8Tk7jBwgemLx4O40lhhvZCVw1C+OYLOBOPXWw==", + "dev": true, + "requires": { + "archy": "^1.0.0", + "caching-transform": "^3.0.2", + "convert-source-map": "^1.6.0", + "cp-file": "^6.2.0", + "find-cache-dir": "^2.1.0", + "find-up": "^3.0.0", + "foreground-child": "^1.5.6", + "glob": "^7.1.3", + "istanbul-lib-coverage": "^2.0.5", + "istanbul-lib-hook": "^2.0.7", + "istanbul-lib-instrument": "^3.3.0", + "istanbul-lib-report": "^2.0.8", + "istanbul-lib-source-maps": "^3.0.6", + "istanbul-reports": "^2.2.4", + "js-yaml": "^3.13.1", + "make-dir": "^2.1.0", + "merge-source-map": "^1.1.0", + "resolve-from": "^4.0.0", + "rimraf": "^2.6.3", + "signal-exit": "^3.0.2", + "spawn-wrap": "^1.4.2", + "test-exclude": "^5.2.3", + "uuid": "^3.3.2", + "yargs": "^13.2.2", + "yargs-parser": "^13.0.0" + } + }, + "oauth-sign": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", + "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==", + "dev": true + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "opener": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/opener/-/opener-1.5.1.tgz", + "integrity": "sha512-goYSy5c2UXE4Ra1xixabeVh1guIX/ZV/YokJksb6q2lubWu6UbvPQ20p542/sFIll1nl8JnCyK9oBaOcCWXwvA==", + "dev": true + }, + "optimist": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", + "integrity": "sha1-2j6nRob6IaGaERwybpDrFaAZZoY=", + "dev": true, + "requires": { + "minimist": "~0.0.1", + "wordwrap": "~0.0.2" + }, + "dependencies": { + "minimist": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz", + "integrity": "sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8=", + "dev": true + } + } + }, + "os-homedir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", + "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", + "dev": true + }, + "own-or": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/own-or/-/own-or-1.0.0.tgz", + "integrity": "sha1-Tod/vtqaLsgAD7wLyuOWRe6L+Nw=", + "dev": true + }, + "own-or-env": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/own-or-env/-/own-or-env-1.0.1.tgz", + "integrity": "sha512-y8qULRbRAlL6x2+M0vIe7jJbJx/kmUTzYonRAa2ayesR2qWLswninkVyeJe4x3IEXhdgoNodzjQRKAoEs6Fmrw==", + "dev": true, + "requires": { + "own-or": "^1.0.0" + } + }, + "p-limit": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.1.tgz", + "integrity": "sha512-85Tk+90UCVWvbDavCLKPOLC9vvY8OwEX/RtKF+/1OADJMVlFfEHOiMTPVyxg7mk/dKa+ipdHm0OUkTvCpMTuwg==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "dev": true, + "requires": { + "p-limit": "^2.0.0" + } + }, + "p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true + }, + "package-hash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/package-hash/-/package-hash-3.0.0.tgz", + "integrity": "sha512-lOtmukMDVvtkL84rJHI7dpTYq+0rli8N2wlnqUcBuDWCfVhRUfOmnR9SsoHFMLpACvEV60dX7rd0rFaYDZI+FA==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.15", + "hasha": "^3.0.0", + "lodash.flattendeep": "^4.4.0", + "release-zalgo": "^1.0.0" + } + }, + "parse-json": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", + "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", + "dev": true, + "requires": { + "error-ex": "^1.3.1", + "json-parse-better-errors": "^1.0.1" + } + }, + "path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", + "dev": true + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "path-key": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", + "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", + "dev": true + }, + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", + "dev": true + }, + "path-type": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz", + "integrity": "sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg==", + "dev": true, + "requires": { + "pify": "^3.0.0" + }, + "dependencies": { + "pify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", + "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", + "dev": true + } + } + }, + "performance-now": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", + "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", + "dev": true + }, + "picomatch": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.1.1.tgz", + "integrity": "sha512-OYMyqkKzK7blWO/+XZYP6w8hH0LDvkBvdvKukti+7kqYFCiEAk+gI3DWnryapc0Dau05ugGTy0foQ6mqn4AHYA==", + "dev": true + }, + "pify": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", + "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==", + "dev": true + }, + "pirates": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/pirates/-/pirates-3.0.2.tgz", + "integrity": "sha512-c5CgUJq6H2k6MJz72Ak1F5sN9n9wlSlJyEnwvpm9/y3WB4E3pHBDT2c6PEiS1vyJvq2bUxUAIu0EGf8Cx4Ic7Q==", + "dev": true, + "requires": { + "node-modules-regexp": "^1.0.0" + } + }, + "pkg-dir": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-3.0.0.tgz", + "integrity": "sha512-/E57AYkoeQ25qkxMj5PBOVgF8Kiu/h7cYS30Z5+R7WaiCCBfLq58ZI/dSeaEKb9WVJV5n/03QwrN3IeWIFllvw==", + "dev": true, + "requires": { + "find-up": "^3.0.0" + } + }, + "process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", + "dev": true, + "optional": true + }, + "prop-types": { + "version": "15.7.2", + "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.7.2.tgz", + "integrity": "sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==", + "dev": true, + "requires": { + "loose-envify": "^1.4.0", + "object-assign": "^4.1.1", + "react-is": "^16.8.1" + } + }, + "pseudomap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", + "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=", + "dev": true + }, + "psl": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.6.0.tgz", + "integrity": "sha512-SYKKmVel98NCOYXpkwUqZqh0ahZeeKfmisiLIcEZdsb+WbLv02g/dI5BUmZnIyOe7RzZtLax81nnb2HbvC2tzA==", + "dev": true + }, + "punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", + "dev": true + }, + "qs": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==", + "dev": true + }, + "react": { + "version": "16.12.0", + "resolved": "https://registry.npmjs.org/react/-/react-16.12.0.tgz", + "integrity": "sha512-fglqy3k5E+81pA8s+7K0/T3DBCF0ZDOher1elBFzF7O6arXJgzyu/FW+COxFvAWXJoJN9KIZbT2LXlukwphYTA==", + "dev": true, + "requires": { + "loose-envify": "^1.1.0", + "object-assign": "^4.1.1", + "prop-types": "^15.6.2" + } + }, + "react-is": { + "version": "16.12.0", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.12.0.tgz", + "integrity": "sha512-rPCkf/mWBtKc97aLL9/txD8DZdemK0vkA3JMLShjlJB3Pj3s+lpf1KaBzMfQrAmhMQB0n1cU/SUGgKKBCe837Q==", + "dev": true + }, + "read-pkg": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz", + "integrity": "sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k=", + "dev": true, + "requires": { + "load-json-file": "^4.0.0", + "normalize-package-data": "^2.3.2", + "path-type": "^3.0.0" + } + }, + "read-pkg-up": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-4.0.0.tgz", + "integrity": "sha512-6etQSH7nJGsK0RbG/2TeDzZFa8shjQ1um+SwQQ5cwKy0dhSXdOncEhb1CPpvQG4h7FyOV6EB6YlV0yJvZQNAkA==", + "dev": true, + "requires": { + "find-up": "^3.0.0", + "read-pkg": "^3.0.0" + } + }, + "readable-stream": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "dev": true, + "optional": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + }, + "dependencies": { + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true, + "optional": true + } + } + }, + "readdirp": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.2.0.tgz", + "integrity": "sha512-crk4Qu3pmXwgxdSgGhgA/eXiJAPQiX4GMOZZMXnqKxHX7TaoL+3gQVo/WeuAiogr07DpnfjIMpXXa+PAIvwPGQ==", + "dev": true, + "requires": { + "picomatch": "^2.0.4" + } + }, + "regenerator-runtime": { + "version": "0.13.3", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.3.tgz", + "integrity": "sha512-naKIZz2GQ8JWh///G7L3X6LaQUAMp2lvb1rvwwsURe/VXwD6VMfr+/1NuNw3ag8v2kY1aQ/go5SNn79O9JU7yw==", + "dev": true + }, + "release-zalgo": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/release-zalgo/-/release-zalgo-1.0.0.tgz", + "integrity": "sha1-CXALflB0Mpc5Mw5TXFqQ+2eFFzA=", + "dev": true, + "requires": { + "es6-error": "^4.0.1" + } + }, + "request": { + "version": "2.88.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", + "integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==", + "dev": true, + "requires": { + "aws-sign2": "~0.7.0", + "aws4": "^1.8.0", + "caseless": "~0.12.0", + "combined-stream": "~1.0.6", + "extend": "~3.0.2", + "forever-agent": "~0.6.1", + "form-data": "~2.3.2", + "har-validator": "~5.1.0", + "http-signature": "~1.2.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.19", + "oauth-sign": "~0.9.0", + "performance-now": "^2.1.0", + "qs": "~6.5.2", + "safe-buffer": "^5.1.2", + "tough-cookie": "~2.4.3", + "tunnel-agent": "^0.6.0", + "uuid": "^3.3.2" + } + }, + "require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", + "dev": true + }, + "require-main-filename": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", + "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", + "dev": true + }, + "resolve": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.13.1.tgz", + "integrity": "sha512-CxqObCX8K8YtAhOBRg+lrcdn+LK+WYOS8tSjqSFbjtrI5PnS63QPhZl4+yKfrU9tdsbMu9Anr/amegT87M9Z6w==", + "dev": true, + "requires": { + "path-parse": "^1.0.6" + } + }, + "resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true + }, + "rimraf": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", + "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + }, + "safe-buffer": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz", + "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==", + "dev": true + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "dev": true + }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true + }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", + "dev": true + }, + "shebang-command": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", + "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "dev": true, + "requires": { + "shebang-regex": "^1.0.0" + } + }, + "shebang-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", + "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", + "dev": true + }, + "signal-exit": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", + "dev": true + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + }, + "source-map-support": { + "version": "0.5.16", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.16.tgz", + "integrity": "sha512-efyLRJDr68D9hBBNIPWFjhpFzURh+KJykQwvMyW5UiZzYwoF6l4YMMDIJJEyFWxWCqfyxLzz6tSfUFR+kXXsVQ==", + "dev": true, + "requires": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "spawn-wrap": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/spawn-wrap/-/spawn-wrap-1.4.3.tgz", + "integrity": "sha512-IgB8md0QW/+tWqcavuFgKYR/qIRvJkRLPJDFaoXtLLUaVcCDK0+HeFTkmQHj3eprcYhc+gOl0aEA1w7qZlYezw==", + "dev": true, + "requires": { + "foreground-child": "^1.5.6", + "mkdirp": "^0.5.0", + "os-homedir": "^1.0.1", + "rimraf": "^2.6.2", + "signal-exit": "^3.0.2", + "which": "^1.3.0" + }, + "dependencies": { + "which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + } + } + }, + "spdx-correct": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.0.tgz", + "integrity": "sha512-lr2EZCctC2BNR7j7WzJ2FpDznxky1sjfxvvYEyzxNyb6lZXHODmEoJeFu4JupYlkfha1KZpJyoqiJ7pgA1qq8Q==", + "dev": true, + "requires": { + "spdx-expression-parse": "^3.0.0", + "spdx-license-ids": "^3.0.0" + } + }, + "spdx-exceptions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.2.0.tgz", + "integrity": "sha512-2XQACfElKi9SlVb1CYadKDXvoajPgBVPn/gOQLrTvHdElaVhr7ZEbqJaRnJLVNeaI4cMEAgVCeBMKF6MWRDCRA==", + "dev": true + }, + "spdx-expression-parse": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", + "dev": true, + "requires": { + "spdx-exceptions": "^2.1.0", + "spdx-license-ids": "^3.0.0" + } + }, + "spdx-license-ids": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.5.tgz", + "integrity": "sha512-J+FWzZoynJEXGphVIS+XEh3kFSjZX/1i9gFBaWQcB+/tmpe2qUsSBABpcxqxnAxFdiUFEgAX1bjYGQvIZmoz9Q==", + "dev": true + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + }, + "sshpk": { + "version": "1.16.1", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz", + "integrity": "sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==", + "dev": true, + "requires": { + "asn1": "~0.2.3", + "assert-plus": "^1.0.0", + "bcrypt-pbkdf": "^1.0.0", + "dashdash": "^1.12.0", + "ecc-jsbn": "~0.1.1", + "getpass": "^0.1.1", + "jsbn": "~0.1.0", + "safer-buffer": "^2.0.2", + "tweetnacl": "~0.14.0" + } + }, + "stack-utils": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-1.0.2.tgz", + "integrity": "sha512-MTX+MeG5U994cazkjd/9KNAapsHnibjMLnfXodlkXw76JEea0UiNzrqidzo1emMwk7w5Qhc9jd4Bn9TBb1MFwA==", + "dev": true + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "optional": true, + "requires": { + "safe-buffer": "~5.1.0" + }, + "dependencies": { + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true, + "optional": true + } + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "^3.0.0" + } + }, + "strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", + "dev": true + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + }, + "tap": { + "version": "14.10.2", + "resolved": "https://registry.npmjs.org/tap/-/tap-14.10.2.tgz", + "integrity": "sha512-JeUDsVrMFmR6b3p9hO9yIT/jibrK6LI7nFza5cqDGsxJyCp7yU3enRgS5nekuoAOzewbrU7P+9QDRDT01urROA==", + "dev": true, + "requires": { + "async-hook-domain": "^1.1.3", + "bind-obj-methods": "^2.0.0", + "browser-process-hrtime": "^1.0.0", + "chokidar": "^3.3.0", + "color-support": "^1.1.0", + "coveralls": "^3.0.8", + "diff": "^4.0.1", + "esm": "^3.2.25", + "findit": "^2.0.0", + "flow-remove-types": "^2.112.0", + "foreground-child": "^1.3.3", + "fs-exists-cached": "^1.0.0", + "function-loop": "^1.0.2", + "glob": "^7.1.6", + "import-jsx": "^3.0.0", + "ink": "^2.5.0", + "isexe": "^2.0.0", + "istanbul-lib-processinfo": "^1.0.0", + "jackspeak": "^1.4.0", + "minipass": "^3.1.1", + "mkdirp": "^0.5.1", + "nyc": "^14.1.1", + "opener": "^1.5.1", + "own-or": "^1.0.0", + "own-or-env": "^1.0.1", + "react": "^16.12.0", + "rimraf": "^2.7.1", + "signal-exit": "^3.0.0", + "source-map-support": "^0.5.16", + "stack-utils": "^1.0.2", + "tap-mocha-reporter": "^5.0.0", + "tap-parser": "^10.0.1", + "tap-yaml": "^1.0.0", + "tcompare": "^3.0.0", + "treport": "^1.0.0", + "trivial-deferred": "^1.0.1", + "ts-node": "^8.5.2", + "typescript": "^3.7.2", + "which": "^2.0.2", + "write-file-atomic": "^3.0.1", + "yaml": "^1.7.2", + "yapool": "^1.0.0" + }, + "dependencies": { + "@babel/code-frame": { + "version": "7.5.5", + "bundled": true, + "requires": { + "@babel/highlight": "^7.0.0" + } + }, + "@babel/core": { + "version": "7.7.4", + "bundled": true, + "dev": true, + "requires": { + "@babel/code-frame": "^7.5.5", + "@babel/generator": "^7.7.4", + "@babel/helpers": "^7.7.4", + "@babel/parser": "^7.7.4", + "@babel/template": "^7.7.4", + "@babel/traverse": "^7.7.4", + "@babel/types": "^7.7.4", + "convert-source-map": "^1.7.0", + "debug": "^4.1.0", + "json5": "^2.1.0", + "lodash": "^4.17.13", + "resolve": "^1.3.2", + "semver": "^5.4.1", + "source-map": "^0.5.0" + }, + "dependencies": { + "@babel/generator": { + "version": "7.7.4", + "bundled": true, + "dev": true, + "requires": { + "@babel/types": "^7.7.4", + "jsesc": "^2.5.1", + "lodash": "^4.17.13", + "source-map": "^0.5.0" + } + }, + "@babel/helper-function-name": { + "version": "7.7.4", + "bundled": true, + "dev": true, + "requires": { + "@babel/helper-get-function-arity": "^7.7.4", + "@babel/template": "^7.7.4", + "@babel/types": "^7.7.4" + } + }, + "@babel/helper-get-function-arity": { + "version": "7.7.4", + "bundled": true, + "dev": true, + "requires": { + "@babel/types": "^7.7.4" + } + }, + "@babel/helper-split-export-declaration": { + "version": "7.7.4", + "bundled": true, + "dev": true, + "requires": { + "@babel/types": "^7.7.4" + } + }, + "@babel/parser": { + "version": "7.7.4", + "bundled": true, + "dev": true + }, + "@babel/template": { + "version": "7.7.4", + "bundled": true, + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "@babel/parser": "^7.7.4", + "@babel/types": "^7.7.4" + } + }, + "@babel/traverse": { + "version": "7.7.4", + "bundled": true, + "dev": true, + "requires": { + "@babel/code-frame": "^7.5.5", + "@babel/generator": "^7.7.4", + "@babel/helper-function-name": "^7.7.4", + "@babel/helper-split-export-declaration": "^7.7.4", + "@babel/parser": "^7.7.4", + "@babel/types": "^7.7.4", + "debug": "^4.1.0", + "globals": "^11.1.0", + "lodash": "^4.17.13" + } + }, + "@babel/types": { + "version": "7.7.4", + "bundled": true, + "dev": true, + "requires": { + "esutils": "^2.0.2", + "lodash": "^4.17.13", + "to-fast-properties": "^2.0.0" + } + }, + "convert-source-map": { + "version": "1.7.0", + "bundled": true, + "dev": true, + "requires": { + "safe-buffer": "~5.1.1" + } + }, + "debug": { + "version": "4.1.1", + "bundled": true, + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "ms": { + "version": "2.1.2", + "bundled": true, + "dev": true + }, + "safe-buffer": { + "version": "5.1.2", + "bundled": true, + "dev": true + }, + "source-map": { + "version": "0.5.7", + "bundled": true, + "dev": true + } + } + }, + "@babel/generator": { + "version": "7.7.2", + "bundled": true, + "requires": { + "@babel/types": "^7.7.2", + "jsesc": "^2.5.1", + "lodash": "^4.17.13", + "source-map": "^0.5.0" + }, + "dependencies": { + "source-map": { + "version": "0.5.7", + "bundled": true + } + } + }, + "@babel/helper-builder-react-jsx": { + "version": "7.7.4", + "bundled": true, + "dev": true, + "requires": { + "@babel/types": "^7.7.4", + "esutils": "^2.0.0" + }, + "dependencies": { + "@babel/types": { + "version": "7.7.4", + "bundled": true, + "dev": true, + "requires": { + "esutils": "^2.0.2", + "lodash": "^4.17.13", + "to-fast-properties": "^2.0.0" + } + } + } + }, + "@babel/helper-plugin-utils": { + "version": "7.0.0", + "bundled": true, + "dev": true + }, + "@babel/helpers": { + "version": "7.7.4", + "bundled": true, + "dev": true, + "requires": { + "@babel/template": "^7.7.4", + "@babel/traverse": "^7.7.4", + "@babel/types": "^7.7.4" + }, + "dependencies": { + "@babel/generator": { + "version": "7.7.4", + "bundled": true, + "dev": true, + "requires": { + "@babel/types": "^7.7.4", + "jsesc": "^2.5.1", + "lodash": "^4.17.13", + "source-map": "^0.5.0" + } + }, + "@babel/helper-function-name": { + "version": "7.7.4", + "bundled": true, + "dev": true, + "requires": { + "@babel/helper-get-function-arity": "^7.7.4", + "@babel/template": "^7.7.4", + "@babel/types": "^7.7.4" + } + }, + "@babel/helper-get-function-arity": { + "version": "7.7.4", + "bundled": true, + "dev": true, + "requires": { + "@babel/types": "^7.7.4" + } + }, + "@babel/helper-split-export-declaration": { + "version": "7.7.4", + "bundled": true, + "dev": true, + "requires": { + "@babel/types": "^7.7.4" + } + }, + "@babel/parser": { + "version": "7.7.4", + "bundled": true, + "dev": true + }, + "@babel/template": { + "version": "7.7.4", + "bundled": true, + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "@babel/parser": "^7.7.4", + "@babel/types": "^7.7.4" + } + }, + "@babel/traverse": { + "version": "7.7.4", + "bundled": true, + "dev": true, + "requires": { + "@babel/code-frame": "^7.5.5", + "@babel/generator": "^7.7.4", + "@babel/helper-function-name": "^7.7.4", + "@babel/helper-split-export-declaration": "^7.7.4", + "@babel/parser": "^7.7.4", + "@babel/types": "^7.7.4", + "debug": "^4.1.0", + "globals": "^11.1.0", + "lodash": "^4.17.13" + } + }, + "@babel/types": { + "version": "7.7.4", + "bundled": true, + "dev": true, + "requires": { + "esutils": "^2.0.2", + "lodash": "^4.17.13", + "to-fast-properties": "^2.0.0" + } + }, + "debug": { + "version": "4.1.1", + "bundled": true, + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "ms": { + "version": "2.1.2", + "bundled": true, + "dev": true + }, + "source-map": { + "version": "0.5.7", + "bundled": true, + "dev": true + } + } + }, + "@babel/highlight": { + "version": "7.5.0", + "bundled": true, + "requires": { + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^4.0.0" + }, + "dependencies": { + "js-tokens": { + "version": "4.0.0", + "bundled": true + } + } + }, + "@babel/parser": { + "version": "7.7.3", + "bundled": true + }, + "@babel/plugin-proposal-object-rest-spread": { + "version": "7.7.4", + "bundled": true, + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/plugin-syntax-object-rest-spread": "^7.7.4" + } + }, + "@babel/plugin-syntax-jsx": { + "version": "7.7.4", + "bundled": true, + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-syntax-object-rest-spread": { + "version": "7.7.4", + "bundled": true, + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-transform-destructuring": { + "version": "7.7.4", + "bundled": true, + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-transform-react-jsx": { + "version": "7.7.4", + "bundled": true, + "dev": true, + "requires": { + "@babel/helper-builder-react-jsx": "^7.7.4", + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/plugin-syntax-jsx": "^7.7.4" + } + }, + "@babel/runtime": { + "version": "7.7.4", + "bundled": true, + "dev": true, + "requires": { + "regenerator-runtime": "^0.13.2" + } + }, + "@babel/template": { + "version": "7.7.0", + "bundled": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "@babel/parser": "^7.7.0", + "@babel/types": "^7.7.0" + } + }, + "@babel/types": { + "version": "7.7.2", + "bundled": true, + "requires": { + "esutils": "^2.0.2", + "lodash": "^4.17.13", + "to-fast-properties": "^2.0.0" + } + }, + "@types/color-name": { + "version": "1.1.1", + "bundled": true, + "dev": true + }, + "@types/prop-types": { + "version": "15.7.3", + "bundled": true, + "dev": true + }, + "@types/react": { + "version": "16.9.13", + "bundled": true, + "dev": true, + "requires": { + "@types/prop-types": "*", + "csstype": "^2.2.0" + } + }, + "ansi-escapes": { + "version": "4.3.0", + "bundled": true, + "dev": true, + "requires": { + "type-fest": "^0.8.1" + } + }, + "ansi-regex": { + "version": "2.1.1", + "bundled": true + }, + "ansi-styles": { + "version": "3.2.1", + "bundled": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "ansicolors": { + "version": "0.3.2", + "bundled": true, + "dev": true + }, + "arrify": { + "version": "1.0.1", + "bundled": true, + "dev": true + }, + "astral-regex": { + "version": "1.0.0", + "bundled": true, + "dev": true + }, + "auto-bind": { + "version": "2.1.1", + "bundled": true, + "dev": true, + "requires": { + "@types/react": "^16.8.12" + } + }, + "caller-callsite": { + "version": "2.0.0", + "bundled": true, + "dev": true, + "requires": { + "callsites": "^2.0.0" + } + }, + "caller-path": { + "version": "2.0.0", + "bundled": true, + "dev": true, + "requires": { + "caller-callsite": "^2.0.0" + } + }, + "callsites": { + "version": "2.0.0", + "bundled": true, + "dev": true + }, + "cardinal": { + "version": "2.1.1", + "bundled": true, + "dev": true, + "requires": { + "ansicolors": "~0.3.2", + "redeyed": "~2.1.0" + } + }, + "chalk": { + "version": "2.4.2", + "bundled": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "ci-info": { + "version": "2.0.0", + "bundled": true, + "dev": true + }, + "cli-cursor": { + "version": "2.1.0", + "bundled": true, + "dev": true, + "requires": { + "restore-cursor": "^2.0.0" + } + }, + "cli-truncate": { + "version": "1.1.0", + "bundled": true, + "dev": true, + "requires": { + "slice-ansi": "^1.0.0", + "string-width": "^2.0.0" + } + }, + "color-convert": { + "version": "1.9.3", + "bundled": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "bundled": true + }, + "csstype": { + "version": "2.6.7", + "bundled": true, + "dev": true + }, + "debug": { + "version": "2.6.9", + "bundled": true, + "requires": { + "ms": "2.0.0" + } + }, + "emoji-regex": { + "version": "7.0.3", + "bundled": true, + "dev": true + }, + "escape-string-regexp": { + "version": "1.0.5", + "bundled": true + }, + "esprima": { + "version": "4.0.1", + "bundled": true, + "dev": true + }, + "esutils": { + "version": "2.0.3", + "bundled": true + }, + "events-to-array": { + "version": "1.1.2", + "bundled": true, + "dev": true + }, + "globals": { + "version": "11.12.0", + "bundled": true, + "dev": true + }, + "has-flag": { + "version": "3.0.0", + "bundled": true + }, + "import-jsx": { + "version": "3.0.0", + "bundled": true, + "dev": true, + "requires": { + "@babel/core": "^7.5.5", + "@babel/plugin-proposal-object-rest-spread": "^7.5.5", + "@babel/plugin-transform-destructuring": "^7.5.0", + "@babel/plugin-transform-react-jsx": "^7.3.0", + "caller-path": "^2.0.0", + "resolve-from": "^3.0.0" + } + }, + "ink": { + "version": "2.5.0", + "bundled": true, + "dev": true, + "requires": { + "@types/react": "^16.8.6", + "ansi-escapes": "^4.2.1", + "arrify": "^1.0.1", + "auto-bind": "^2.0.0", + "chalk": "^2.4.1", + "cli-cursor": "^2.1.0", + "cli-truncate": "^1.1.0", + "is-ci": "^2.0.0", + "lodash.throttle": "^4.1.1", + "log-update": "^3.0.0", + "prop-types": "^15.6.2", + "react-reconciler": "^0.21.0", + "scheduler": "^0.15.0", + "signal-exit": "^3.0.2", + "slice-ansi": "^1.0.0", + "string-length": "^2.0.0", + "widest-line": "^2.0.0", + "wrap-ansi": "^5.0.0", + "yoga-layout-prebuilt": "^1.9.3" + } + }, + "is-ci": { + "version": "2.0.0", + "bundled": true, + "dev": true, + "requires": { + "ci-info": "^2.0.0" + } + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "bundled": true, + "dev": true + }, + "js-tokens": { + "version": "3.0.2", + "bundled": true, + "dev": true + }, + "jsesc": { + "version": "2.5.2", + "bundled": true + }, + "json5": { + "version": "2.1.1", + "bundled": true, + "dev": true, + "requires": { + "minimist": "^1.2.0" + } + }, + "lodash": { + "version": "4.17.15", + "bundled": true + }, + "lodash.throttle": { + "version": "4.1.1", + "bundled": true, + "dev": true + }, + "log-update": { + "version": "3.3.0", + "bundled": true, + "dev": true, + "requires": { + "ansi-escapes": "^3.2.0", + "cli-cursor": "^2.1.0", + "wrap-ansi": "^5.0.0" + }, + "dependencies": { + "ansi-escapes": { + "version": "3.2.0", + "bundled": true, + "dev": true + } + } + }, + "loose-envify": { + "version": "1.4.0", + "bundled": true, + "dev": true, + "requires": { + "js-tokens": "^3.0.0 || ^4.0.0" + } + }, + "mimic-fn": { + "version": "1.2.0", + "bundled": true, + "dev": true + }, + "minimist": { + "version": "1.2.0", + "bundled": true, + "dev": true + }, + "minipass": { + "version": "3.1.1", + "bundled": true, + "dev": true, + "requires": { + "yallist": "^4.0.0" + }, + "dependencies": { + "yallist": { + "version": "4.0.0", + "bundled": true, + "dev": true + } + } + }, + "ms": { + "version": "2.0.0", + "bundled": true + }, + "object-assign": { + "version": "4.1.1", + "bundled": true, + "dev": true + }, + "onetime": { + "version": "2.0.1", + "bundled": true, + "dev": true, + "requires": { + "mimic-fn": "^1.0.0" + } + }, + "path-parse": { + "version": "1.0.6", + "bundled": true, + "dev": true + }, + "prop-types": { + "version": "15.7.2", + "bundled": true, + "dev": true, + "requires": { + "loose-envify": "^1.4.0", + "object-assign": "^4.1.1", + "react-is": "^16.8.1" + } + }, + "punycode": { + "version": "2.1.1", + "bundled": true, + "dev": true + }, + "react-is": { + "version": "16.10.2", + "bundled": true, + "dev": true + }, + "react-reconciler": { + "version": "0.21.0", + "bundled": true, + "dev": true, + "requires": { + "loose-envify": "^1.1.0", + "object-assign": "^4.1.1", + "prop-types": "^15.6.2", + "scheduler": "^0.15.0" + } + }, + "redeyed": { + "version": "2.1.1", + "bundled": true, + "dev": true, + "requires": { + "esprima": "~4.0.0" + } + }, + "regenerator-runtime": { + "version": "0.13.3", + "bundled": true, + "dev": true + }, + "resolve": { + "version": "1.12.0", + "bundled": true, + "dev": true, + "requires": { + "path-parse": "^1.0.6" + } + }, + "resolve-from": { + "version": "3.0.0", + "bundled": true, + "dev": true + }, + "restore-cursor": { + "version": "2.0.0", + "bundled": true, + "dev": true, + "requires": { + "onetime": "^2.0.0", + "signal-exit": "^3.0.2" + } + }, + "scheduler": { + "version": "0.15.0", + "bundled": true, + "dev": true, + "requires": { + "loose-envify": "^1.1.0", + "object-assign": "^4.1.1" + } + }, + "semver": { + "version": "5.7.1", + "bundled": true, + "dev": true + }, + "signal-exit": { + "version": "3.0.2", + "bundled": true, + "dev": true + }, + "slice-ansi": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "requires": { + "is-fullwidth-code-point": "^2.0.0" + } + }, + "source-map": { + "version": "0.6.1", + "bundled": true + }, + "string-length": { + "version": "2.0.0", + "bundled": true, + "dev": true, + "requires": { + "astral-regex": "^1.0.0", + "strip-ansi": "^4.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "bundled": true, + "dev": true + }, + "strip-ansi": { + "version": "4.0.0", + "bundled": true, + "dev": true, + "requires": { + "ansi-regex": "^3.0.0" + } + } + } + }, + "string-width": { + "version": "2.1.1", + "bundled": true, + "dev": true, + "requires": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "bundled": true, + "dev": true + }, + "strip-ansi": { + "version": "4.0.0", + "bundled": true, + "dev": true, + "requires": { + "ansi-regex": "^3.0.0" + } + } + } + }, + "strip-ansi": { + "version": "3.0.1", + "bundled": true, + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "supports-color": { + "version": "5.5.0", + "bundled": true, + "requires": { + "has-flag": "^3.0.0" + } + }, + "tap-parser": { + "version": "10.0.1", + "bundled": true, + "dev": true, + "requires": { + "events-to-array": "^1.0.1", + "minipass": "^3.0.0", + "tap-yaml": "^1.0.0" + } + }, + "tap-yaml": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "requires": { + "yaml": "^1.5.0" + } + }, + "to-fast-properties": { + "version": "2.0.0", + "bundled": true + }, + "treport": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "requires": { + "cardinal": "^2.1.1", + "chalk": "^3.0.0", + "import-jsx": "^3.0.0", + "ink": "^2.5.0", + "ms": "^2.1.2", + "string-length": "^3.1.0", + "tap-parser": "^10.0.1", + "unicode-length": "^2.0.2" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "bundled": true, + "dev": true + }, + "ansi-styles": { + "version": "4.2.0", + "bundled": true, + "dev": true, + "requires": { + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "3.0.0", + "bundled": true, + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "bundled": true, + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "bundled": true, + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "bundled": true, + "dev": true + }, + "ms": { + "version": "2.1.2", + "bundled": true, + "dev": true + }, + "string-length": { + "version": "3.1.0", + "bundled": true, + "dev": true, + "requires": { + "astral-regex": "^1.0.0", + "strip-ansi": "^5.2.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "bundled": true, + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + }, + "supports-color": { + "version": "7.1.0", + "bundled": true, + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + }, + "unicode-length": { + "version": "2.0.2", + "bundled": true, + "dev": true, + "requires": { + "punycode": "^2.0.0", + "strip-ansi": "^3.0.1" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "bundled": true, + "dev": true + }, + "strip-ansi": { + "version": "3.0.1", + "bundled": true, + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + } + } + } + } + }, + "type-fest": { + "version": "0.8.1", + "bundled": true, + "dev": true + }, + "widest-line": { + "version": "2.0.1", + "bundled": true, + "dev": true, + "requires": { + "string-width": "^2.1.1" + } + }, + "wrap-ansi": { + "version": "5.1.0", + "bundled": true, + "dev": true, + "requires": { + "ansi-styles": "^3.2.0", + "string-width": "^3.0.0", + "strip-ansi": "^5.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "bundled": true, + "dev": true + }, + "string-width": { + "version": "3.1.0", + "bundled": true, + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "bundled": true, + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + } + } + }, + "yaml": { + "version": "1.7.2", + "bundled": true, + "dev": true, + "requires": { + "@babel/runtime": "^7.6.3" + } + }, + "yoga-layout-prebuilt": { + "version": "1.9.3", + "bundled": true, + "dev": true + } + } + }, + "tap-mocha-reporter": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/tap-mocha-reporter/-/tap-mocha-reporter-5.0.0.tgz", + "integrity": "sha512-8HlAtdmYGlDZuW83QbF/dc46L7cN+AGhLZcanX3I9ILvxUAl+G2/mtucNPSXecTlG/4iP1hv6oMo0tMhkn3Tsw==", + "dev": true, + "requires": { + "color-support": "^1.1.0", + "debug": "^2.1.3", + "diff": "^1.3.2", + "escape-string-regexp": "^1.0.3", + "glob": "^7.0.5", + "readable-stream": "^2.1.5", + "tap-parser": "^10.0.0", + "tap-yaml": "^1.0.0", + "unicode-length": "^1.0.0" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "diff": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-1.4.0.tgz", + "integrity": "sha1-fyjS657nsVqX79ic5j3P2qPMur8=", + "dev": true + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + } + } + }, + "tap-parser": { + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/tap-parser/-/tap-parser-10.0.1.tgz", + "integrity": "sha512-qdT15H0DoJIi7zOqVXDn9X0gSM68JjNy1w3VemwTJlDnETjbi6SutnqmBfjDJAwkFS79NJ97gZKqie00ZCGmzg==", + "dev": true, + "requires": { + "events-to-array": "^1.0.1", + "minipass": "^3.0.0", + "tap-yaml": "^1.0.0" + } + }, + "tap-yaml": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/tap-yaml/-/tap-yaml-1.0.0.tgz", + "integrity": "sha512-Rxbx4EnrWkYk0/ztcm5u3/VznbyFJpyXO12dDBHKWiDVxy7O2Qw6MRrwO5H6Ww0U5YhRY/4C/VzWmFPhBQc4qQ==", + "dev": true, + "requires": { + "yaml": "^1.5.0" + } + }, + "tcompare": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/tcompare/-/tcompare-3.0.4.tgz", + "integrity": "sha512-Q3TitMVK59NyKgQyFh+857wTAUE329IzLDehuPgU4nF5e8g+EUQ+yUbjUy1/6ugiNnXztphT+NnqlCXolv9P3A==", + "dev": true, + "requires": { + "diff-frag": "^1.0.1" + } + }, + "test-exclude": { + "version": "5.2.3", + "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-5.2.3.tgz", + "integrity": "sha512-M+oxtseCFO3EDtAaGH7iiej3CBkzXqFMbzqYAACdzKui4eZA+pq3tZEwChvOdNfa7xxy8BfbmgJSIr43cC/+2g==", + "dev": true, + "requires": { + "glob": "^7.1.3", + "minimatch": "^3.0.4", + "read-pkg-up": "^4.0.0", + "require-main-filename": "^2.0.0" + } + }, + "to-fast-properties": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", + "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=", + "dev": true + }, + "to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "requires": { + "is-number": "^7.0.0" + } + }, + "tough-cookie": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", + "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==", + "dev": true, + "requires": { + "psl": "^1.1.24", + "punycode": "^1.4.1" + }, + "dependencies": { + "punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", + "dev": true + } + } + }, + "trivial-deferred": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/trivial-deferred/-/trivial-deferred-1.0.1.tgz", + "integrity": "sha1-N21NKdlR1jaKb3oK6FwvTV4GWPM=", + "dev": true + }, + "ts-node": { + "version": "8.5.4", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.5.4.tgz", + "integrity": "sha512-izbVCRV68EasEPQ8MSIGBNK9dc/4sYJJKYA+IarMQct1RtEot6Xp0bXuClsbUSnKpg50ho+aOAx8en5c+y4OFw==", + "dev": true, + "requires": { + "arg": "^4.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "source-map-support": "^0.5.6", + "yn": "^3.0.0" + } + }, + "tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "dev": true, + "requires": { + "safe-buffer": "^5.0.1" + } + }, + "tweetnacl": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", + "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", + "dev": true + }, + "typedarray-to-buffer": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", + "integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==", + "dev": true, + "requires": { + "is-typedarray": "^1.0.0" + } + }, + "typescript": { + "version": "3.7.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.3.tgz", + "integrity": "sha512-Mcr/Qk7hXqFBXMN7p7Lusj1ktCBydylfQM/FZCk5glCNQJrCUKPkMHdo9R0MTFWsC/4kPFvDS0fDPvukfCkFsw==", + "dev": true + }, + "uglify-js": { + "version": "3.7.2", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.7.2.tgz", + "integrity": "sha512-uhRwZcANNWVLrxLfNFEdltoPNhECUR3lc+UdJoG9CBpMcSnKyWA94tc3eAujB1GcMY5Uwq8ZMp4qWpxWYDQmaA==", + "dev": true, + "optional": true, + "requires": { + "commander": "~2.20.3", + "source-map": "~0.6.1" + } + }, + "unicode-length": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/unicode-length/-/unicode-length-1.0.3.tgz", + "integrity": "sha1-Wtp6f+1RhBpBijKM8UlHisg1irs=", + "dev": true, + "requires": { + "punycode": "^1.3.2", + "strip-ansi": "^3.0.1" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + }, + "punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", + "dev": true + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + } + } + }, + "uri-js": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", + "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", + "dev": true, + "requires": { + "punycode": "^2.1.0" + } + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "dev": true, + "optional": true + }, + "uuid": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.3.tgz", + "integrity": "sha512-pW0No1RGHgzlpHJO1nsVrHKpOEIxkGg1xB+v0ZmdNH5OAeAwzAVrCnI2/6Mtx+Uys6iaylxa+D3g4j63IKKjSQ==", + "dev": true + }, + "validate-npm-package-license": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", + "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==", + "dev": true, + "requires": { + "spdx-correct": "^3.0.0", + "spdx-expression-parse": "^3.0.0" + } + }, + "verror": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", + "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", + "dev": true, + "requires": { + "assert-plus": "^1.0.0", + "core-util-is": "1.0.2", + "extsprintf": "^1.2.0" + } + }, + "vlq": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/vlq/-/vlq-0.2.3.tgz", + "integrity": "sha512-DRibZL6DsNhIgYQ+wNdWDL2SL3bKPlVrRiBqV5yuMm++op8W4kGFtaQfCs4KEJn0wBZcHVHJ3eoywX8983k1ow==", + "dev": true + }, + "which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + }, + "which-module": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", + "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", + "dev": true + }, + "wordwrap": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", + "integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=", + "dev": true + }, + "wrap-ansi": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", + "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", + "dev": true, + "requires": { + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "dev": true, + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "dev": true, + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + } + } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + }, + "write-file-atomic": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-3.0.1.tgz", + "integrity": "sha512-JPStrIyyVJ6oCSz/691fAjFtefZ6q+fP6tm+OS4Qw6o+TGQxNp1ziY2PgS+X/m0V8OWhZiO/m4xSj+Pr4RrZvw==", + "dev": true, + "requires": { + "imurmurhash": "^0.1.4", + "is-typedarray": "^1.0.0", + "signal-exit": "^3.0.2", + "typedarray-to-buffer": "^3.1.5" + } + }, + "y18n": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", + "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", + "dev": true + }, + "yallist": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", + "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=", + "dev": true + }, + "yaml": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.7.2.tgz", + "integrity": "sha512-qXROVp90sb83XtAoqE8bP9RwAkTTZbugRUTm5YeFCBfNRPEp2YzTeqWiz7m5OORHzEvrA/qcGS8hp/E+MMROYw==", + "dev": true, + "requires": { + "@babel/runtime": "^7.6.3" + } + }, + "yapool": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/yapool/-/yapool-1.0.0.tgz", + "integrity": "sha1-9pPymjFbUNmp2iZGp6ZkXJaYW2o=", + "dev": true + }, + "yargs": { + "version": "13.3.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.3.0.tgz", + "integrity": "sha512-2eehun/8ALW8TLoIl7MVaRUrg+yCnenu8B4kBlRxj3GJGDKU1Og7sMXPNm1BYyM1DOJmTZ4YeN/Nwxv+8XJsUA==", + "dev": true, + "requires": { + "cliui": "^5.0.0", + "find-up": "^3.0.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^3.0.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^13.1.1" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "cliui": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz", + "integrity": "sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA==", + "dev": true, + "requires": { + "string-width": "^3.1.0", + "strip-ansi": "^5.2.0", + "wrap-ansi": "^5.1.0" + } + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + }, + "wrap-ansi": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-5.1.0.tgz", + "integrity": "sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.0", + "string-width": "^3.0.0", + "strip-ansi": "^5.0.0" + } + } + } + }, + "yargs-parser": { + "version": "13.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.1.tgz", + "integrity": "sha512-oVAVsHz6uFrg3XQheFII8ESO2ssAf9luWuAd6Wexsu4F3OtIW0o8IribPXYrD4WC24LWtPrJlGy87y5udK+dxQ==", + "dev": true, + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } + }, + "yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "dev": true + } + } +} diff --git a/deps/npm/node_modules/npm-normalize-package-bin/package.json b/deps/npm/node_modules/npm-normalize-package-bin/package.json new file mode 100644 index 00000000000000..c0e548cc537bd0 --- /dev/null +++ b/deps/npm/node_modules/npm-normalize-package-bin/package.json @@ -0,0 +1,57 @@ +{ + "_from": "npm-normalize-package-bin@^1.0.0", + "_id": "npm-normalize-package-bin@1.0.1", + "_inBundle": false, + "_integrity": "sha512-EPfafl6JL5/rU+ot6P3gRSCpPDW5VmIzX959Ob1+ySFUuuYHWHekXpwdUZcKP5C+DS4GEtdJluwBjnsNDl+fSA==", + "_location": "/npm-normalize-package-bin", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "npm-normalize-package-bin@^1.0.0", + "name": "npm-normalize-package-bin", + "escapedName": "npm-normalize-package-bin", + "rawSpec": "^1.0.0", + "saveSpec": null, + "fetchSpec": "^1.0.0" + }, + "_requiredBy": [ + "/bin-links" + ], + "_resolved": "https://registry.npmjs.org/npm-normalize-package-bin/-/npm-normalize-package-bin-1.0.1.tgz", + "_shasum": "6e79a41f23fd235c0623218228da7d9c23b8f6e2", + "_spec": "npm-normalize-package-bin@^1.0.0", + "_where": "/Users/isaacs/dev/npm/cli/node_modules/bin-links", + "author": { + "name": "Isaac Z. Schlueter", + "email": "i@izs.me", + "url": "https://izs.me" + }, + "bugs": { + "url": "https://github.com/npm/npm-normalize-package-bin/issues" + }, + "bundleDependencies": false, + "deprecated": false, + "description": "Turn any flavor of allowable package.json bin into a normalized object", + "devDependencies": { + "tap": "^14.10.2" + }, + "homepage": "https://github.com/npm/npm-normalize-package-bin#readme", + "license": "ISC", + "name": "npm-normalize-package-bin", + "repository": { + "type": "git", + "url": "git+https://github.com/npm/npm-normalize-package-bin.git" + }, + "scripts": { + "postpublish": "git push origin --follow-tags", + "postversion": "npm publish", + "preversion": "npm test", + "snap": "tap", + "test": "tap" + }, + "tap": { + "check-coverage": true + }, + "version": "1.0.1" +} diff --git a/deps/npm/node_modules/npm-normalize-package-bin/test/array.js b/deps/npm/node_modules/npm-normalize-package-bin/test/array.js new file mode 100644 index 00000000000000..63dafa89137411 --- /dev/null +++ b/deps/npm/node_modules/npm-normalize-package-bin/test/array.js @@ -0,0 +1,37 @@ +const normalize = require('../') +const t = require('tap') + +t.test('benign array', async t => { + const pkg = { name: 'hello', version: 'world', bin: ['./x/y', 'y/z', './a'] } + const expect = { name: 'hello', version: 'world', bin: { + y: 'x/y', + z: 'y/z', + a: 'a', + } } + t.strictSame(normalize(pkg), expect) + t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok') +}) + +t.test('conflicting array', async t => { + const pkg = { name: 'hello', version: 'world', bin: ['./x/y', 'z/y', './a'] } + const expect = { name: 'hello', version: 'world', bin: { + y: 'z/y', + a: 'a', + } } + t.strictSame(normalize(pkg), expect) + t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok') +}) + +t.test('slashy array', async t => { + const pkg = { name: 'hello', version: 'world', bin: [ '/etc/passwd' ] } + const expect = { name: 'hello', version: 'world', bin: { passwd: 'etc/passwd' } } + t.strictSame(normalize(pkg), expect) + t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok') +}) + +t.test('dotty array', async t => { + const pkg = { name: 'hello', version: 'world', bin: ['../../../../etc/passwd'] } + const expect = { name: 'hello', version: 'world', bin: { passwd: 'etc/passwd' } } + t.strictSame(normalize(pkg), expect) + t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok') +}) diff --git a/deps/npm/node_modules/npm-normalize-package-bin/test/nobin.js b/deps/npm/node_modules/npm-normalize-package-bin/test/nobin.js new file mode 100644 index 00000000000000..536d7eb22f68a9 --- /dev/null +++ b/deps/npm/node_modules/npm-normalize-package-bin/test/nobin.js @@ -0,0 +1,35 @@ +const normalize = require('../') +const t = require('tap') + +// all of these just delete the bins, so expect the same value +const expect = { name: 'hello', version: 'world' } + +t.test('no bin in object', async t => { + const pkg = { name: 'hello', version: 'world' } + t.strictSame(normalize(pkg), expect) + t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok') +}) + +t.test('empty string bin in object', async t => { + const pkg = { name: 'hello', version: 'world', bin: '' } + t.strictSame(normalize(pkg), expect) + t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok') +}) + +t.test('false bin in object', async t => { + const pkg = { name: 'hello', version: 'world', bin: false } + t.strictSame(normalize(pkg), expect) + t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok') +}) + +t.test('null bin in object', async t => { + const pkg = { name: 'hello', version: 'world', bin: null } + t.strictSame(normalize(pkg), expect) + t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok') +}) + +t.test('number bin', async t => { + const pkg = { name: 'hello', version: 'world', bin: 42069 } + t.strictSame(normalize(pkg), expect) + t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok') +}) diff --git a/deps/npm/node_modules/npm-normalize-package-bin/test/object.js b/deps/npm/node_modules/npm-normalize-package-bin/test/object.js new file mode 100644 index 00000000000000..00d23684fb75b6 --- /dev/null +++ b/deps/npm/node_modules/npm-normalize-package-bin/test/object.js @@ -0,0 +1,141 @@ +const normalize = require('../') +const t = require('tap') + +t.test('benign object', async t => { + // just clean up the ./ in the targets and remove anything weird + const pkg = { name: 'hello', version: 'world', bin: { + y: './x/y', + z: './y/z', + a: './a', + } } + const expect = { name: 'hello', version: 'world', bin: { + y: 'x/y', + z: 'y/z', + a: 'a', + } } + t.strictSame(normalize(pkg), expect) + t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok') +}) + +t.test('empty and non-string targets', async t => { + // just clean up the ./ in the targets and remove anything weird + const pkg = { name: 'hello', version: 'world', bin: { + z: './././', + y: '', + './x': 'x.js', + re: /asdf/, + foo: { bar: 'baz' }, + false: false, + null: null, + array: [1,2,3], + func: function () {}, + } } + const expect = { name: 'hello', version: 'world', bin: { + x: 'x.js', + } } + t.strictSame(normalize(pkg), expect) + t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok') +}) + +t.test('slashy object', async t => { + const pkg = { name: 'hello', version: 'world', bin: { + '/path/foo': '/etc/passwd', + 'bar': '/etc/passwd', + '/etc/glorb/baz': '/etc/passwd', + '/etc/passwd:/bin/usr/exec': '/etc/passwd', + } } + const expect = { + name: 'hello', + version: 'world', + bin: { + foo: 'etc/passwd', + bar: 'etc/passwd', + baz: 'etc/passwd', + exec: 'etc/passwd', + } + } + t.strictSame(normalize(pkg), expect) + t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok') +}) + +t.test('dotty object', async t => { + const pkg = { + name: 'hello', + version: 'world', + bin: { + 'nodots': '../../../../etc/passwd', + '../../../../../../dots': '../../../../etc/passwd', + '.././../\\./..//C:\\./': 'this is removed', + '.././../\\./..//C:\\/': 'super safe programming language', + '.././../\\./..//C:\\x\\y\\z/': 'xyz', + } } + const expect = { name: 'hello', version: 'world', bin: { + nodots: 'etc/passwd', + dots: 'etc/passwd', + C: 'super safe programming language', + z: 'xyz', + } } + t.strictSame(normalize(pkg), expect) + t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok') +}) + +t.test('weird object', async t => { + const pkg = { name: 'hello', version: 'world', bin: /asdf/ } + const expect = { name: 'hello', version: 'world' } + t.strictSame(normalize(pkg), expect) + t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok') +}) + +t.test('oddball keys', async t => { + const pkg = { + bin: { + '~': 'target', + '£': 'target', + 'ζ': 'target', + 'ぎ': 'target', + '操': 'target', + '🎱': 'target', + '💎': 'target', + '💸': 'target', + '🦉': 'target', + 'сheck-dom': 'target', + 'Ωpm': 'target', + 'ζλ': 'target', + 'мга': 'target', + 'пше': 'target', + 'тзч': 'target', + 'тзь': 'target', + 'нфкт': 'target', + 'ссср': 'target', + '君の名は': 'target', + '君の名は': 'target', + } + } + + const expect = { + bin: { + '~': 'target', + '£': 'target', + 'ζ': 'target', + 'ぎ': 'target', + '操': 'target', + '🎱': 'target', + '💎': 'target', + '💸': 'target', + '🦉': 'target', + 'сheck-dom': 'target', + 'Ωpm': 'target', + 'ζλ': 'target', + 'мга': 'target', + 'пше': 'target', + 'тзч': 'target', + 'тзь': 'target', + 'нфкт': 'target', + 'ссср': 'target', + '君の名は': 'target', + }, + } + + t.strictSame(normalize(pkg), expect) + t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok') +}) diff --git a/deps/npm/node_modules/npm-normalize-package-bin/test/string.js b/deps/npm/node_modules/npm-normalize-package-bin/test/string.js new file mode 100644 index 00000000000000..b6de8f8f589b5c --- /dev/null +++ b/deps/npm/node_modules/npm-normalize-package-bin/test/string.js @@ -0,0 +1,37 @@ +const normalize = require('../') +const t = require('tap') + +t.test('benign string', async t => { + const pkg = { name: 'hello', version: 'world', bin: 'hello.js' } + const expect = { name: 'hello', version: 'world', bin: { hello: 'hello.js' } } + t.strictSame(normalize(pkg), expect) + t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok') +}) + +t.test('slashy string', async t => { + const pkg = { name: 'hello', version: 'world', bin: '/etc/passwd' } + const expect = { name: 'hello', version: 'world', bin: { hello: 'etc/passwd' } } + t.strictSame(normalize(pkg), expect) + t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok') +}) + +t.test('dotty string', async t => { + const pkg = { name: 'hello', version: 'world', bin: '../../../../etc/passwd' } + const expect = { name: 'hello', version: 'world', bin: { hello: 'etc/passwd' } } + t.strictSame(normalize(pkg), expect) + t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok') +}) + +t.test('double path', async t => { + const pkg = { name: 'hello', version: 'world', bin: '/etc/passwd:/bin/usr/exec' } + const expect = { name: 'hello', version: 'world', bin: { hello: 'etc/passwd:/bin/usr/exec' } } + t.strictSame(normalize(pkg), expect) + t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok') +}) + +t.test('string with no name', async t => { + const pkg = { bin: 'foobar.js' } + const expect = {} + t.strictSame(normalize(pkg), expect) + t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok') +}) diff --git a/deps/npm/node_modules/npm-packlist/index.js b/deps/npm/node_modules/npm-packlist/index.js index dd7706a4aee2a5..eaf14b86617514 100644 --- a/deps/npm/node_modules/npm-packlist/index.js +++ b/deps/npm/node_modules/npm-packlist/index.js @@ -17,6 +17,8 @@ const rootBuiltinRules = Symbol('root-builtin-rules') const packageNecessaryRules = Symbol('package-necessary-rules') const path = require('path') +const normalizePackageBin = require('npm-normalize-package-bin') + const defaultRules = [ '.npmignore', '.gitignore', @@ -176,12 +178,11 @@ const npmWalker = Class => class Walker extends Class { '!npm-shrinkwrap.json', '!@(readme|copying|license|licence|notice|changes|changelog|history){,.*[^~$]}' ] - if (pkg.bin) - if (typeof pkg.bin === "object") - for (const key in pkg.bin) - rules.push('!' + pkg.bin[key]) - else - rules.push('!' + pkg.bin) + if (pkg.bin) { + // always an object, because normalized already + for (const key in pkg.bin) + rules.push('!' + pkg.bin[key]) + } const data = rules.filter(f => f).join('\n') + '\n' super.onReadIgnoreFile(packageNecessaryRules, data, _=>_) @@ -216,7 +217,7 @@ const npmWalker = Class => class Walker extends Class { if (file === 'package.json') try { const ig = path.resolve(this.path, file) - this.onPackageJson(ig, JSON.parse(data), then) + this.onPackageJson(ig, normalizePackageBin(JSON.parse(data)), then) } catch (er) { // ignore package.json files that are not json then() diff --git a/deps/npm/node_modules/npm-packlist/package.json b/deps/npm/node_modules/npm-packlist/package.json index a8fabfa7f12405..c022dcef65b515 100644 --- a/deps/npm/node_modules/npm-packlist/package.json +++ b/deps/npm/node_modules/npm-packlist/package.json @@ -1,29 +1,29 @@ { - "_from": "npm-packlist@1.4.6", - "_id": "npm-packlist@1.4.6", + "_from": "npm-packlist@1.4.7", + "_id": "npm-packlist@1.4.7", "_inBundle": false, - "_integrity": "sha512-u65uQdb+qwtGvEJh/DgQgW1Xg7sqeNbmxYyrvlNznaVTjV3E5P6F/EFjM+BVHXl7JJlsdG8A64M0XI8FI/IOlg==", + "_integrity": "sha512-vAj7dIkp5NhieaGZxBJB8fF4R0078rqsmhJcAfXZ6O7JJhjhPK96n5Ry1oZcfLXgfun0GWTZPOxaEyqv8GBykQ==", "_location": "/npm-packlist", "_phantomChildren": {}, "_requested": { "type": "version", "registry": true, - "raw": "npm-packlist@1.4.6", + "raw": "npm-packlist@1.4.7", "name": "npm-packlist", "escapedName": "npm-packlist", - "rawSpec": "1.4.6", + "rawSpec": "1.4.7", "saveSpec": null, - "fetchSpec": "1.4.6" + "fetchSpec": "1.4.7" }, "_requiredBy": [ "#USER", "/", "/pacote" ], - "_resolved": "https://registry.npmjs.org/npm-packlist/-/npm-packlist-1.4.6.tgz", - "_shasum": "53ba3ed11f8523079f1457376dd379ee4ea42ff4", - "_spec": "npm-packlist@1.4.6", - "_where": "/Users/mperrotte/npminc/cli", + "_resolved": "https://registry.npmjs.org/npm-packlist/-/npm-packlist-1.4.7.tgz", + "_shasum": "9e954365a06b80b18111ea900945af4f88ed4848", + "_spec": "npm-packlist@1.4.7", + "_where": "/Users/isaacs/dev/npm/cli", "author": { "name": "Isaac Z. Schlueter", "email": "i@izs.me", @@ -54,6 +54,9 @@ "license": "ISC", "main": "index.js", "name": "npm-packlist", + "publishConfig": { + "tag": "legacy-v1" + }, "repository": { "type": "git", "url": "git+https://github.com/npm/npm-packlist.git" @@ -68,5 +71,5 @@ "tap": { "jobs": 1 }, - "version": "1.4.6" + "version": "1.4.7" } diff --git a/deps/npm/node_modules/pacote/CHANGELOG.md b/deps/npm/node_modules/pacote/CHANGELOG.md index 6896c4739ce532..722a9fa168876e 100644 --- a/deps/npm/node_modules/pacote/CHANGELOG.md +++ b/deps/npm/node_modules/pacote/CHANGELOG.md @@ -2,6 +2,26 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. + +## [9.5.11](https://github.com/npm/pacote/compare/v9.5.10...v9.5.11) (2019-12-09) + + +### Bug Fixes + +* sanitize and normalize package bin field ([6f229f7](https://github.com/npm/pacote/commit/6f229f7)) + + + + +## [9.5.10](https://github.com/npm/pacote/compare/v9.5.9...v9.5.10) (2019-12-04) + + +### Bug Fixes + +* Do not drop perms in git when not root ([5f33040](https://github.com/npm/pacote/commit/5f33040)), closes [#23](https://github.com/npm/pacote/issues/23) + + + ## [9.5.9](https://github.com/npm/pacote/compare/v9.5.8...v9.5.9) (2019-10-29) diff --git a/deps/npm/node_modules/pacote/lib/fetchers/directory.js b/deps/npm/node_modules/pacote/lib/fetchers/directory.js index 3d4ec24c83f278..fc9c46cd3b7e9c 100644 --- a/deps/npm/node_modules/pacote/lib/fetchers/directory.js +++ b/deps/npm/node_modules/pacote/lib/fetchers/directory.js @@ -9,6 +9,7 @@ const readJson = require('../util/read-json') const path = require('path') const pipe = BB.promisify(require('mississippi').pipe) const through = require('mississippi').through +const normalizePackageBin = require('npm-normalize-package-bin') const readFileAsync = BB.promisify(require('fs').readFile) @@ -63,7 +64,7 @@ Fetcher.impl(fetchDirectory, { } else { return pkg } - }) + }).then(pkg => normalizePackageBin(pkg)) }, // As of npm@5, the npm installer doesn't pack + install directories: it just diff --git a/deps/npm/node_modules/pacote/lib/fetchers/git.js b/deps/npm/node_modules/pacote/lib/fetchers/git.js index 7913be81687912..a1579d1f943125 100644 --- a/deps/npm/node_modules/pacote/lib/fetchers/git.js +++ b/deps/npm/node_modules/pacote/lib/fetchers/git.js @@ -166,7 +166,7 @@ function withTmp (opts, cb) { } } -// Only certain whitelisted hosted gits support shallow cloning +// Only certain whitelisted hosted gits support shadow cloning const SHALLOW_HOSTS = new Set(['github', 'gist', 'gitlab', 'bitbucket']) function cloneRepo (spec, repo, resolvedRef, rawRef, tmp, opts) { const ref = resolvedRef ? resolvedRef.ref : rawRef diff --git a/deps/npm/node_modules/pacote/lib/finalize-manifest.js b/deps/npm/node_modules/pacote/lib/finalize-manifest.js index d1d0f4e563eed2..80b9cda73b6ee1 100644 --- a/deps/npm/node_modules/pacote/lib/finalize-manifest.js +++ b/deps/npm/node_modules/pacote/lib/finalize-manifest.js @@ -14,6 +14,7 @@ const pipe = BB.promisify(require('mississippi').pipe) const ssri = require('ssri') const tar = require('tar') const readJson = require('./util/read-json') +const normalizePackageBin = require('npm-normalize-package-bin') // `finalizeManifest` takes as input the various kinds of manifests that // manifest handlers ('lib/fetchers/*.js#manifest()') return, and makes sure @@ -105,17 +106,8 @@ function Manifest (pkg, fromTarball, fullMetadata) { this._shrinkwrap = pkg._shrinkwrap || fromTarball._shrinkwrap || null this.bin = pkg.bin || fromTarball.bin || null - if (this.bin && Array.isArray(this.bin)) { - // Code yanked from read-package-json. - const m = (pkg.directories && pkg.directories.bin) || '.' - this.bin = this.bin.reduce((acc, mf) => { - if (mf && mf.charAt(0) !== '.') { - const f = path.basename(mf) - acc[f] = path.join(m, mf) - } - return acc - }, {}) - } + // turn arrays and strings into a legit object, strip out bad stuff + normalizePackageBin(this) this._id = null diff --git a/deps/npm/node_modules/pacote/lib/util/git.js b/deps/npm/node_modules/pacote/lib/util/git.js index 7991833abed0e3..d2282bae15edad 100644 --- a/deps/npm/node_modules/pacote/lib/util/git.js +++ b/deps/npm/node_modules/pacote/lib/util/git.js @@ -234,14 +234,17 @@ function spawnGit (gitArgs, gitOpts, opts) { }) } +module.exports._mkOpts = mkOpts function mkOpts (_gitOpts, opts) { const gitOpts = { env: gitEnv() } - if (+opts.uid && !isNaN(opts.uid)) { + const isRoot = process.getuid && process.getuid() === 0 + // don't change child process uid/gid if not root + if (+opts.uid && !isNaN(opts.uid) && isRoot) { gitOpts.uid = +opts.uid } - if (+opts.gid && !isNaN(opts.gid)) { + if (+opts.gid && !isNaN(opts.gid) && isRoot) { gitOpts.gid = +opts.gid } Object.assign(gitOpts, _gitOpts) diff --git a/deps/npm/node_modules/pacote/package.json b/deps/npm/node_modules/pacote/package.json index a60ed752703539..1efb87c5838e68 100644 --- a/deps/npm/node_modules/pacote/package.json +++ b/deps/npm/node_modules/pacote/package.json @@ -1,8 +1,8 @@ { - "_from": "pacote@9.5.9", - "_id": "pacote@9.5.9", + "_from": "pacote@9.5.11", + "_id": "pacote@9.5.11", "_inBundle": false, - "_integrity": "sha512-S1nYW9ly+3btn3VmwRAk2LG3TEh8mkrFdY+psbnHSk8oPODbZ28uG0Z0d3yI0EpqcpLR6BukoVRf3H4IbGCkPQ==", + "_integrity": "sha512-DMDPvFKCjCg6zMS4IfzZyvT57O/bX8XGG00eEoy4K/S4Wj+qiN8KbnmKpsTvfS6OL9r5TAicxMKWbj1yV2Yh4g==", "_location": "/pacote", "_phantomChildren": { "safe-buffer": "5.1.2", @@ -11,12 +11,12 @@ "_requested": { "type": "version", "registry": true, - "raw": "pacote@9.5.9", + "raw": "pacote@9.5.11", "name": "pacote", "escapedName": "pacote", - "rawSpec": "9.5.9", + "rawSpec": "9.5.11", "saveSpec": null, - "fetchSpec": "9.5.9" + "fetchSpec": "9.5.11" }, "_requiredBy": [ "#USER", @@ -24,10 +24,10 @@ "/libcipm", "/libnpm" ], - "_resolved": "https://registry.npmjs.org/pacote/-/pacote-9.5.9.tgz", - "_shasum": "fa3a08629c9390b2b99769c55b2cc137e1a24df3", - "_spec": "pacote@9.5.9", - "_where": "/Users/ruyadorno/Documents/workspace/cli", + "_resolved": "https://registry.npmjs.org/pacote/-/pacote-9.5.11.tgz", + "_shasum": "524152077cb392c47b1fbe198aa28f778bef7ee1", + "_spec": "pacote@9.5.11", + "_where": "/Users/isaacs/dev/npm/cli", "author": { "name": "Kat Marchán", "email": "kzm@sykosomatic.org" @@ -61,6 +61,7 @@ "mississippi": "^3.0.0", "mkdirp": "^0.5.1", "normalize-package-data": "^2.4.0", + "npm-normalize-package-bin": "^1.0.0", "npm-package-arg": "^6.1.0", "npm-packlist": "^1.1.12", "npm-pick-manifest": "^3.0.0", @@ -105,6 +106,9 @@ "license": "MIT", "main": "index.js", "name": "pacote", + "publishConfig": { + "tag": "v9-legacy" + }, "repository": { "type": "git", "url": "git+https://github.com/npm/pacote.git" @@ -119,5 +123,5 @@ "update-coc": "weallbehave -o . && git add CODE_OF_CONDUCT.md && git commit -m 'docs(coc): updated CODE_OF_CONDUCT.md'", "update-contrib": "weallcontribute -o . && git add CONTRIBUTING.md && git commit -m 'docs(contributing): updated CONTRIBUTING.md'" }, - "version": "9.5.9" + "version": "9.5.11" } diff --git a/deps/npm/node_modules/read-package-json/CHANGELOG.md b/deps/npm/node_modules/read-package-json/CHANGELOG.md index b21f94d72792bc..e6f26e59d28ef8 100644 --- a/deps/npm/node_modules/read-package-json/CHANGELOG.md +++ b/deps/npm/node_modules/read-package-json/CHANGELOG.md @@ -2,6 +2,16 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. + +## [2.1.1](https://github.com/npm/read-package-json/compare/v2.1.0...v2.1.1) (2019-12-09) + + +### Bug Fixes + +* normalize and sanitize pkg bin entries ([b8cb5fa](https://github.com/npm/read-package-json/commit/b8cb5fa)) + + + # [2.1.0](https://github.com/npm/read-package-json/compare/v2.0.13...v2.1.0) (2019-08-13) diff --git a/deps/npm/node_modules/read-package-json/package.json b/deps/npm/node_modules/read-package-json/package.json index 5c597498814bd3..7920e43589939a 100644 --- a/deps/npm/node_modules/read-package-json/package.json +++ b/deps/npm/node_modules/read-package-json/package.json @@ -1,19 +1,19 @@ { - "_from": "read-package-json@2.1.0", - "_id": "read-package-json@2.1.0", + "_from": "read-package-json@2.1.1", + "_id": "read-package-json@2.1.1", "_inBundle": false, - "_integrity": "sha512-KLhu8M1ZZNkMcrq1+0UJbR8Dii8KZUqB0Sha4mOx/bknfKI/fyrQVrG/YIt2UOtG667sD8+ee4EXMM91W9dC+A==", + "_integrity": "sha512-dAiqGtVc/q5doFz6096CcnXhpYk0ZN8dEKVkGLU0CsASt8SrgF6SF7OTKAYubfvFhWaqofl+Y8HK19GR8jwW+A==", "_location": "/read-package-json", "_phantomChildren": {}, "_requested": { "type": "version", "registry": true, - "raw": "read-package-json@2.1.0", + "raw": "read-package-json@2.1.1", "name": "read-package-json", "escapedName": "read-package-json", - "rawSpec": "2.1.0", + "rawSpec": "2.1.1", "saveSpec": null, - "fetchSpec": "2.1.0" + "fetchSpec": "2.1.1" }, "_requiredBy": [ "#USER", @@ -24,9 +24,9 @@ "/read-installed", "/read-package-tree" ], - "_resolved": "https://registry.npmjs.org/read-package-json/-/read-package-json-2.1.0.tgz", - "_shasum": "e3d42e6c35ea5ae820d9a03ab0c7291217fc51d5", - "_spec": "read-package-json@2.1.0", + "_resolved": "https://registry.npmjs.org/read-package-json/-/read-package-json-2.1.1.tgz", + "_shasum": "16aa66c59e7d4dad6288f179dd9295fd59bb98f1", + "_spec": "read-package-json@2.1.1", "_where": "/Users/isaacs/dev/npm/cli", "author": { "name": "Isaac Z. Schlueter", @@ -42,7 +42,7 @@ "graceful-fs": "^4.1.2", "json-parse-better-errors": "^1.0.1", "normalize-package-data": "^2.0.0", - "slash": "^1.0.0" + "npm-normalize-package-bin": "^1.0.0" }, "deprecated": false, "description": "The thing npm uses to read package.json files with semantics and defaults and validation", @@ -72,5 +72,5 @@ "release": "standard-version -s", "test": "tap --nyc-arg=--all --coverage test/*.js" }, - "version": "2.1.0" + "version": "2.1.1" } diff --git a/deps/npm/node_modules/read-package-json/read-json.js b/deps/npm/node_modules/read-package-json/read-json.js index 9f8f81bd1cadac..03da84762eb293 100644 --- a/deps/npm/node_modules/read-package-json/read-json.js +++ b/deps/npm/node_modules/read-package-json/read-json.js @@ -11,7 +11,7 @@ var glob = require('glob') var normalizeData = require('normalize-package-data') var safeJSON = require('json-parse-better-errors') var util = require('util') -var slash = require('slash') +var normalizePackageBin = require('npm-normalize-package-bin') module.exports = readJson @@ -301,7 +301,7 @@ function mans_ (file, data, mans, cb) { } function bins (file, data, cb) { - if (Array.isArray(data.bin)) return bins_(file, data, data.bin, cb) + data = normalizePackageBin(data) var m = data.directories && data.directories.bin if (data.bin || !m) return cb(null, data) @@ -318,11 +318,11 @@ function bins_ (file, data, bins, cb) { data.bin = bins.reduce(function (acc, mf) { if (mf && mf.charAt(0) !== '.') { var f = path.basename(mf) - acc[f] = slash(path.join(m, mf)) + acc[f] = path.join(m, mf) } return acc }, {}) - return cb(null, data) + return cb(null, normalizePackageBin(data)) } function bundleDependencies (file, data, cb) { @@ -403,6 +403,7 @@ function checkBinReferences_ (file, data, warn, cb) { keys.forEach(function (key) { var dirName = path.dirname(file) var relName = data.bin[key] + /* istanbul ignore if - impossible, bins have been normalized */ if (typeof relName !== 'string') { var msg = 'Bin filename for ' + key + ' is not a string: ' + util.inspect(relName) diff --git a/deps/npm/node_modules/slash/index.js b/deps/npm/node_modules/slash/index.js deleted file mode 100644 index b946a0841a01f4..00000000000000 --- a/deps/npm/node_modules/slash/index.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; -module.exports = function (str) { - var isExtendedLengthPath = /^\\\\\?\\/.test(str); - var hasNonAscii = /[^\x00-\x80]+/.test(str); - - if (isExtendedLengthPath || hasNonAscii) { - return str; - } - - return str.replace(/\\/g, '/'); -}; diff --git a/deps/npm/node_modules/slash/package.json b/deps/npm/node_modules/slash/package.json deleted file mode 100644 index bedd2680902b42..00000000000000 --- a/deps/npm/node_modules/slash/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "_from": "slash@^1.0.0", - "_id": "slash@1.0.0", - "_inBundle": false, - "_integrity": "sha1-xB8vbDn8FtHNF61LXYlhFK5HDVU=", - "_location": "/slash", - "_phantomChildren": {}, - "_requested": { - "type": "range", - "registry": true, - "raw": "slash@^1.0.0", - "name": "slash", - "escapedName": "slash", - "rawSpec": "^1.0.0", - "saveSpec": null, - "fetchSpec": "^1.0.0" - }, - "_requiredBy": [ - "/read-package-json" - ], - "_resolved": "https://registry.npmjs.org/slash/-/slash-1.0.0.tgz", - "_shasum": "c41f2f6c39fc16d1cd17ad4b5d896114ae470d55", - "_spec": "slash@^1.0.0", - "_where": "/Users/rebecca/code/npm/node_modules/read-package-json", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "http://sindresorhus.com" - }, - "bugs": { - "url": "https://github.com/sindresorhus/slash/issues" - }, - "bundleDependencies": false, - "deprecated": false, - "description": "Convert Windows backslash paths to slash paths", - "devDependencies": { - "mocha": "*" - }, - "engines": { - "node": ">=0.10.0" - }, - "files": [ - "index.js" - ], - "homepage": "https://github.com/sindresorhus/slash#readme", - "keywords": [ - "path", - "seperator", - "sep", - "slash", - "backslash", - "windows", - "win" - ], - "license": "MIT", - "name": "slash", - "repository": { - "type": "git", - "url": "git+https://github.com/sindresorhus/slash.git" - }, - "scripts": { - "test": "mocha" - }, - "version": "1.0.0" -} diff --git a/deps/npm/node_modules/slash/readme.md b/deps/npm/node_modules/slash/readme.md deleted file mode 100644 index 15672f010e182f..00000000000000 --- a/deps/npm/node_modules/slash/readme.md +++ /dev/null @@ -1,44 +0,0 @@ -# slash [![Build Status](https://travis-ci.org/sindresorhus/slash.svg?branch=master)](https://travis-ci.org/sindresorhus/slash) - -> Convert Windows backslash paths to slash paths: `foo\\bar` ➔ `foo/bar` - -[Forward-slash paths can be used in Windows](http://superuser.com/a/176395/6877) as long as they're not extended-length paths and don't contain any non-ascii characters. - -This was created since the `path` methods in Node outputs `\\` paths on Windows. - - -## Install - -```sh -$ npm install --save slash -``` - - -## Usage - -```js -var path = require('path'); -var slash = require('slash'); - -var str = path.join('foo', 'bar'); -// Unix => foo/bar -// Windows => foo\\bar - -slash(str); -// Unix => foo/bar -// Windows => foo/bar -``` - - -## API - -### slash(path) - -Type: `string` - -Accepts a Windows backslash path and returns a slash path. - - -## License - -MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/deps/npm/package.json b/deps/npm/package.json index 6fad0e829f1c54..d6c25dbca1457d 100644 --- a/deps/npm/package.json +++ b/deps/npm/package.json @@ -1,5 +1,5 @@ { - "version": "6.13.1", + "version": "6.13.4", "name": "npm", "description": "a package manager for JavaScript", "keywords": [ @@ -39,7 +39,7 @@ "ansistyles": "~0.1.3", "aproba": "^2.0.0", "archy": "~1.0.0", - "bin-links": "^1.1.3", + "bin-links": "^1.1.6", "bluebird": "^3.5.5", "byte-size": "^5.0.1", "cacache": "^12.0.3", @@ -59,7 +59,7 @@ "find-npm-prefix": "^1.0.2", "fs-vacuum": "~1.2.10", "fs-write-stream-atomic": "~1.0.10", - "gentle-fs": "^2.2.1", + "gentle-fs": "^2.3.0", "glob": "^7.1.4", "graceful-fs": "^4.2.3", "has-unicode": "~2.0.1", @@ -101,7 +101,7 @@ "npm-install-checks": "^3.0.2", "npm-lifecycle": "^3.1.4", "npm-package-arg": "^6.1.1", - "npm-packlist": "^1.4.6", + "npm-packlist": "^1.4.7", "npm-pick-manifest": "^3.0.2", "npm-profile": "^4.0.2", "npm-registry-fetch": "^4.0.2", @@ -110,7 +110,7 @@ "once": "~1.4.0", "opener": "^1.5.1", "osenv": "^0.1.5", - "pacote": "^9.5.9", + "pacote": "^9.5.11", "path-is-inside": "~1.0.2", "promise-inflight": "~1.0.1", "qrcode-terminal": "^0.12.0", @@ -119,7 +119,7 @@ "read": "~1.0.7", "read-cmd-shim": "^1.0.5", "read-installed": "~4.0.3", - "read-package-json": "^2.1.0", + "read-package-json": "^2.1.1", "read-package-tree": "^5.3.1", "readable-stream": "^3.4.0", "readdir-scoped-modules": "^1.1.0", diff --git a/deps/npm/scripts/install.sh b/deps/npm/scripts/install.sh index 4ed1062aa1308b..7f66151daea033 100755 --- a/deps/npm/scripts/install.sh +++ b/deps/npm/scripts/install.sh @@ -23,12 +23,14 @@ if [ "x$0" = "xsh" ]; then if [ $ret -eq 0 ]; then (exit 0) else + echo "Uninstalling npm-install-$$.sh" >&2 rm npm-install-$$.sh echo "Failed to download script" >&2 exit $ret fi sh npm-install-$$.sh ret=$? + echo "Uninstalling npm-install-$$.sh" >&2 rm npm-install-$$.sh exit $ret fi diff --git a/deps/npm/test/fixtures/config/userconfig-with-gc b/deps/npm/test/fixtures/config/userconfig-with-gc index b00d5195bd8361..cf774bb883d966 100644 --- a/deps/npm/test/fixtures/config/userconfig-with-gc +++ b/deps/npm/test/fixtures/config/userconfig-with-gc @@ -1,4 +1,4 @@ -globalconfig = /Users/claudiahdz/npm/cli/test/fixtures/config/globalconfig +globalconfig = /Users/isaacs/dev/npm/cli/test/fixtures/config/globalconfig email = i@izs.me env-thing = ${random_env_var} init.author.name = Isaac Z. Schlueter diff --git a/deps/npm/test/tap/bin-overwriting.js b/deps/npm/test/tap/bin-overwriting.js new file mode 100644 index 00000000000000..155d4abf520506 --- /dev/null +++ b/deps/npm/test/tap/bin-overwriting.js @@ -0,0 +1,107 @@ +const t = require('tap') +const common = require('../common-tap.js') +const pkg = common.pkg + +const { writeFileSync, readFileSync, readlink } = require('fs') +const readCmdShim = require('read-cmd-shim') +const path = require('path') +const readBinCb = process.platform === 'win32' ? readCmdShim : readlink +const readBin = bin => new Promise((resolve, reject) => { + readBinCb(bin, (er, target) => { + if (er) + reject(er) + else + resolve(path.resolve(pkg + '/global/bin', target)) + }) +}) + +// verify that we can't overwrite bins that we shouldn't be able to + +const mkdirp = require('mkdirp').sync + +process.env.npm_config_prefix = pkg + '/global' +process.env.npm_config_global = true + +const globalBin = process.platform === 'win32' + ? path.resolve(pkg, 'global') + : path.resolve(pkg, 'global/bin') + +const globalDir = process.platform === 'win32' + ? path.resolve(pkg, 'global/node_modules') + : path.resolve(pkg, 'global/lib/node_modules') + +const beep = path.resolve(globalBin, 'beep') +const firstBin = path.resolve(globalDir, 'first/first.js') +const secondBin = path.resolve(globalDir, 'second/second.js') + +t.test('setup', { bail: true }, t => { + // set up non-link bin in place + mkdirp(globalBin) + writeFileSync(beep, 'beep boop') + + // create first package + mkdirp(pkg + '/first') + writeFileSync(pkg + '/first/package.json', JSON.stringify({ + name: 'first', + version: '1.0.0', + bin: { beep: 'first.js' } + })) + writeFileSync(pkg + '/first/first.js', `#!/usr/bin/env node + console.log('first')`) + + // create second package + mkdirp(pkg + '/second') + writeFileSync(pkg + '/second/package.json', JSON.stringify({ + name: 'second', + version: '1.0.0', + bin: { beep: 'second.js' } + })) + writeFileSync(pkg + '/second/second.js', `#!/usr/bin/env node + console.log('second')`) + + // pack both to install globally + return common.npm(['pack'], { cwd: pkg + '/first' }) + .then(() => common.npm(['pack'], { cwd: pkg + '/second' })) +}) + +t.test('installing first fails, because pre-existing bin in place', t => { + return common.npm([ + 'install', + pkg + '/first/first-1.0.0.tgz' + ]).then(([code, stdout, stderr]) => { + t.notEqual(code, 0) + t.match(stderr, 'EEXIST') + t.equal(readFileSync(beep, 'utf8'), 'beep boop') + }) +}) + +t.test('installing first with --force succeeds', t => { + return common.npm([ + 'install', + pkg + '/first/first-1.0.0.tgz', + '--force' + ]).then(() => { + return t.resolveMatch(readBin(beep), firstBin, 'bin written to first.js') + }) +}) + +t.test('installing second fails, because bin links to other package', t => { + return common.npm([ + 'install', + pkg + '/second/second-1.0.0.tgz' + ]).then(([code, stdout, stderr]) => { + t.notEqual(code, 0) + t.match(stderr, 'EEXIST') + return t.resolveMatch(readBin(beep), firstBin, 'bin still linked to first') + }) +}) + +t.test('installing second with --force succeeds', t => { + return common.npm([ + 'install', + pkg + '/second/second-1.0.0.tgz', + '--force' + ]).then(() => { + return t.resolveMatch(readBin(beep), secondBin, 'bin written to second.js') + }) +}) diff --git a/deps/npm/test/tap/fund.js b/deps/npm/test/tap/fund.js index 364dc1b6f81795..97b414bf6e0173 100644 --- a/deps/npm/test/tap/fund.js +++ b/deps/npm/test/tap/fund.js @@ -14,6 +14,7 @@ const base = common.pkg const noFunding = path.join(base, 'no-funding-package') const maintainerOwnsAllDeps = path.join(base, 'maintainer-owns-all-deps') const nestedNoFundingPackages = path.join(base, 'nested-no-funding-packages') +const fundingStringShorthand = path.join(base, 'funding-string-shorthand') function getFixturePackage ({ name, version, dependencies, funding }, extras) { const getDeps = () => Object @@ -36,6 +37,13 @@ function getFixturePackage ({ name, version, dependencies, funding }, extras) { } const fixture = new Tacks(Dir({ + 'funding-string-shorthand': Dir({ + 'package.json': File({ + name: 'funding-string-shorthand', + version: '0.0.0', + funding: 'https://example.com/sponsor' + }) + }), 'no-funding-package': Dir({ 'package.json': File({ name: 'no-funding-package', @@ -253,6 +261,13 @@ testFundCmd({ opts: { cwd: maintainerOwnsAllDeps } }) +testFundCmd({ + title: 'fund using string shorthand', + assertionMsg: 'should open string-only url', + args: ['.', '--no-browser'], + opts: { cwd: fundingStringShorthand } +}) + testFundCmd({ title: 'fund using package argument with no browser, using --json option', assertionMsg: 'should open funding url', diff --git a/deps/npm/test/tap/install-dep-classification.js b/deps/npm/test/tap/install-dep-classification.js index 2775c367b0002d..257fc99fc123ff 100644 --- a/deps/npm/test/tap/install-dep-classification.js +++ b/deps/npm/test/tap/install-dep-classification.js @@ -23,18 +23,39 @@ const env = common.newEnv().extend({ npm_config_loglevel: 'error' }) +/** + * NOTE: Tarball Fixtures + * They contain package.json files with dependencies like the following: + * a-1.0.0.tgz: package/package.json + * { + * "name":"a", + * "version":"1.0.0", + * "dependencies":{ + * "b":"./b-1.0.0.tgz" + * } + * } + * example-1.0.0.tgz: package/package.json + * { + * "name":"example", + * "version":"1.0.0", + * "dependencies":{ + * "a":"./a-1.0.0.tgz", + * "b":"./b-1.0.0.tgz" + * } + * } + */ const fixture = new Tacks(Dir({ cache: Dir(), global: Dir(), tmp: Dir(), testdir: Dir({ 'a-1.0.0.tgz': File(Buffer.from( - '1f8b0800000000000003edcfc10e82300c0660ce3ec5d2b38e4eb71d789b' + - '010d41e358187890f0ee56493c71319218937d977feb9aa50daebab886f2' + - 'b0a43cc7ce671b4344abb558ab3f2934223b198b4a598bdcc707a38f9c5b' + - '0fb2668c83eb79946fff597611effc131378772528c0c11e6ed4c7b6f37c' + - '53122572a5a640be265fb514a198a0e43729f3f2f06a9043738779defd7a' + - '89244992e4630fd69e456800080000', + '1f8b0800000000000003edcfc10a83300c06e09df71492f35653567bf06d' + + 'a2067163b558b7c3c4775f54f0e4654c18837e973f4da0249eca1bd59cfa' + + '25d535b4eeb03344b4c6245bfd8946995d328b5a5b3bd55264464beebdc8' + + '9647e8a99355befd67b92559f34f0ce0e8ce9003c1099edc85a675f2d20a' + + '154aa762cfae6257361c201fa090994a8bf33c577dfd82713cfefa86288a' + + 'a2e8736f68a0ff4400080000', 'hex' )), 'b-1.0.0.tgz': File(Buffer.from( @@ -55,12 +76,12 @@ const fixture = new Tacks(Dir({ }) }), 'example-1.0.0.tgz': File(Buffer.from( - '1f8b0800000000000003ed8fc10ac2300c8677f62946cedaa5d8f5e0db64' + - '5b1853d795758a38f6ee4607e261370722f4bbfce5cb4f493c9527aa39f3' + - '73aa63e85cb23288688d4997fc136d304df6b945adad45e9c923375a72ed' + - '4596b884817a59e5db7fe65bd277fe0923386a190ec0376afd99610b57ee' + - '43d339715aa14231157b7615bbb2e100871148664a65b47b15d450dfa554' + - 'ccb2f890d3b4f9f57d9148241259e60112d8208a00080000', + '1f8b0800000000000003ed8fc10a83300c863def2924e7ada6587bf06daa' + + '06719bb55837c6c4775fa6307670a70963d0ef92f02584fcce94275353e2' + + '962a8ebeb3d1c620a2562a5ef34f64aae328cd344aa935f21e379962875b' + + '3fb2c6c50fa6e757bebdb364895ff54f18c19a962007ba99d69d09f670a5' + + 'de379d6527050a645391235b912d1bf2908f607826127398e762a8efbc53' + + 'ccae7873d3b4fb75ba402010087ce2014747c9d500080000', 'hex' )), optional: Dir({ diff --git a/deps/npm/test/tap/install-local-from-local.js b/deps/npm/test/tap/install-local-from-local.js new file mode 100644 index 00000000000000..ec53c74a39206f --- /dev/null +++ b/deps/npm/test/tap/install-local-from-local.js @@ -0,0 +1,94 @@ +'use strict' +var path = require('path') +var fs = require('graceful-fs') +var test = require('tap').test +var common = require('../common-tap.js') +var Tacks = require('tacks') +var Dir = Tacks.Dir +var File = Tacks.File + +var testdir = path.join(__dirname, path.basename(__filename, '.js')) +var cwd = path.join(testdir, '3') + +/** + * NOTE: Tarball Fixtures + * They contain package.json files with dependencies like the following: + * 1-1.0.0.tgz: package/package.json + * { + * "name":"1", + * "version":"1.0.0" + * } + * 2-1.0.0.tgz: package/package.json + * { + * "name":"2", + * "version":"1.0.0", + * "dependencies":{ + * "1":"file:../1/1-1.0.0.tgz" + * } + * } + */ +var fixture = new Tacks(Dir({ + '1': Dir({ + '1-1.0.0.tgz': File(Buffer.from( + '1f8b08000000000000032b484cce4e4c4fd52f80d07a59c5f9790c540606' + + '06066626260ad8c4c1c0d85c81c1d8d4ccc0d0d0cccc00a80ec830353103' + + 'd2d4760836505a5c925804740aa5e640bca200a78708a856ca4bcc4d55b2' + + '523254d2512a4b2d2acecccf03f1f40cf40c946ab906da79a360148c8251' + + '300a6804007849dfdf00080000', + 'hex' + )) + }), + '2': Dir({ + '2-1.0.0.tgz': File(Buffer.from( + '1f8b0800000000000003ed8f3d0e83300c8599394594b90d36840cdc2602' + + '17d19f80087468c5ddeb14a9135b91aa4af996e73c3f47f660eb8b6d291b' + + '565567dfbb646700c0682db6fc00ea5c24456900d118e01c17a52e58f75e' + + '648bd94f76e455befd67bd457cf44f78a64248676f242b21737908cf3b8d' + + 'beeb5d70508182d56d6820d790ab3bf2dc0a83ec62489dba2b554a6598e1' + + 'f13da1a6f62139b0a44bfaeb0b23914824b2c50b8b5b623100080000', + 'hex' + )) + }), + '3': Dir({ + 'package.json': File({ + name: '3', + version: '1.0.0', + dependencies: { + '2': '../2/2-1.0.0.tgz' + } + }) + }) +})) + +function setup () { + fixture.create(testdir) +} + +function cleanup () { + fixture.remove(testdir) +} + +test('setup', function (t) { + cleanup() + setup() + t.end() +}) + +test('installing local package with local dependency', function (t) { + common.npm( + ['install'], + {cwd: cwd}, + function (er, code, stdout, stderr) { + t.is(code, 0, 'no error code') + t.is(stderr, '', 'no error output') + t.ok(fs.existsSync(path.join(cwd, 'node_modules', '2')), 'installed direct dep') + t.ok(fs.existsSync(path.join(cwd, 'node_modules', '1')), 'installed indirect dep') + t.end() + } + ) +}) + +test('cleanup', function (t) { + cleanup() + t.end() +}) diff --git a/deps/npm/test/tap/utils.funding.js b/deps/npm/test/tap/utils.funding.js index 51b89e5f8d340c..709762eacb7bb2 100644 --- a/deps/npm/test/tap/utils.funding.js +++ b/deps/npm/test/tap/utils.funding.js @@ -1,7 +1,7 @@ 'use strict' const { test } = require('tap') -const { getFundingInfo } = require('../../lib/utils/funding') +const { retrieveFunding, getFundingInfo } = require('../../lib/utils/funding') test('empty tree', (t) => { t.deepEqual( @@ -545,3 +545,70 @@ test('handle different versions', (t) => { ) t.end() }) + +test('retrieve funding info from valid objects', (t) => { + t.deepEqual( + retrieveFunding({ + url: 'http://example.com', + type: 'Foo' + }), + { + url: 'http://example.com', + type: 'Foo' + }, + 'should return standard object fields' + ) + t.deepEqual( + retrieveFunding({ + extra: 'Foo', + url: 'http://example.com', + type: 'Foo' + }), + { + extra: 'Foo', + url: 'http://example.com', + type: 'Foo' + }, + 'should leave untouched extra fields' + ) + t.deepEqual( + retrieveFunding({ + url: 'http://example.com' + }), + { + url: 'http://example.com' + }, + 'should accept url-only objects' + ) + t.end() +}) + +test('retrieve funding info from invalid objects', (t) => { + t.deepEqual( + retrieveFunding({}), + {}, + 'should passthrough empty objects' + ) + t.deepEqual( + retrieveFunding(), + undefined, + 'should not care about undefined' + ) + t.deepEqual( + retrieveFunding(), + null, + 'should not care about null' + ) + t.end() +}) + +test('retrieve funding info string shorthand', (t) => { + t.deepEqual( + retrieveFunding('http://example.com'), + { + url: 'http://example.com' + }, + 'should accept string shorthand' + ) + t.end() +}) diff --git a/deps/openssl/openssl_common.gypi b/deps/openssl/openssl_common.gypi index 67640a6325eb52..93b87064b3fb3e 100644 --- a/deps/openssl/openssl_common.gypi +++ b/deps/openssl/openssl_common.gypi @@ -24,7 +24,7 @@ }, 'OS=="win"', { 'defines': [ ## default of Win. See INSTALL in openssl repo. - 'OPENSSLDIR="C:\Program Files\Common Files\SSL"', + 'OPENSSLDIR="C:\\\Program\ Files\\\Common\ Files\\\SSL"', 'ENGINESDIR="NUL"', 'OPENSSL_SYS_WIN32', 'WIN32_LEAN_AND_MEAN', 'L_ENDIAN', '_CRT_SECURE_NO_DEPRECATE', 'UNICODE', '_UNICODE', diff --git a/deps/uv/AUTHORS b/deps/uv/AUTHORS index 408cfd6541a339..dcc36e8c17f929 100644 --- a/deps/uv/AUTHORS +++ b/deps/uv/AUTHORS @@ -411,3 +411,4 @@ Ouyang Yadong ZYSzys Carl Lei Stefan Bender +nia diff --git a/deps/uv/CMakeLists.txt b/deps/uv/CMakeLists.txt index 7da5e688166c04..2ab6d17edddd72 100644 --- a/deps/uv/CMakeLists.txt +++ b/deps/uv/CMakeLists.txt @@ -275,6 +275,8 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Android") src/unix/linux-syscalls.c src/unix/procfs-exepath.c src/unix/pthread-fixes.c + src/unix/random-getrandom.c + src/unix/random-sysctl-linux.c src/unix/sysinfo-loadavg.c) endif() @@ -320,7 +322,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux") src/unix/linux-syscalls.c src/unix/procfs-exepath.c src/unix/random-getrandom.c - src/unix/random-sysctl.c + src/unix/random-sysctl-linux.c src/unix/sysinfo-loadavg.c) endif() diff --git a/deps/uv/ChangeLog b/deps/uv/ChangeLog index cd4451ae69c0c1..a0509e6e153f65 100644 --- a/deps/uv/ChangeLog +++ b/deps/uv/ChangeLog @@ -1,3 +1,40 @@ +2019.12.05, Version 1.34.0 (Stable), 15ae750151ac9341e5945eb38f8982d59fb99201 + +Changes since version 1.33.1: + +* unix: move random-sysctl to random-sysctl-linux (nia) + +* netbsd: use KERN_ARND sysctl to get entropy (nia) + +* unix: refactor uv__fs_copyfile() logic (cjihrig) + +* build: fix android build, add missing sources (Ben Noordhuis) + +* build: fix android build, fix symbol redefinition (Ben Noordhuis) + +* build: fix android autotools build (Ben Noordhuis) + +* fs: handle non-functional statx system call (Milad Farazmand) + +* unix,win: add uv_sleep() (cjihrig) + +* doc: add richardlau to maintainers (Richard Lau) + +* aix: fix netmask for IPv6 (Richard Lau) + +* aix: clean up after errors in uv_interface_addresses() (Richard Lau) + +* aix: fix setting of physical addresses (Richard Lau) + +* fs: add uv_fs_mkstemp (Saúl Ibarra Corretgé) + +* unix: switch uv_sleep() to nanosleep() (Ben Noordhuis) + +* unix: retry on EINTR in uv_sleep() (Ben Noordhuis) + +* zos: fix nanosleep() emulation (Ben Noordhuis) + + 2019.10.20, Version 1.33.1 (Stable), 07ad32138f4d2285ba2226b5e20462b27b091a59 Changes since version 1.33.0: diff --git a/deps/uv/MAINTAINERS.md b/deps/uv/MAINTAINERS.md index a5a11c8dfff16c..0870b88eb6896b 100644 --- a/deps/uv/MAINTAINERS.md +++ b/deps/uv/MAINTAINERS.md @@ -17,6 +17,8 @@ libuv is currently managed by the following individuals: - GPG key: 9DFE AA5F 481B BF77 2D90 03CE D592 4925 2F8E C41A (pubkey-iwuzhere) * **Jameson Nash** ([@vtjnash](https://github.com/vtjnash)) * **John Barboza** ([@jbarz](https://github.com/jbarz)) +* **Richard Lau** ([@richardlau](https://github.com/richardlau)) + - GPG key: C82F A3AE 1CBE DC6B E46B 9360 C43C EC45 C17A B93C (pubkey-richardlau) * **Santiago Gimeno** ([@santigimeno](https://github.com/santigimeno)) - GPG key: 612F 0EAD 9401 6223 79DF 4402 F28C 3C8D A33C 03BE (pubkey-santigimeno) * **Saúl Ibarra Corretgé** ([@saghul](https://github.com/saghul)) diff --git a/deps/uv/Makefile.am b/deps/uv/Makefile.am index ce4ca274b217ee..088b4bbd76f375 100644 --- a/deps/uv/Makefile.am +++ b/deps/uv/Makefile.am @@ -387,7 +387,14 @@ endif if ANDROID uvinclude_HEADERS += include/uv/android-ifaddrs.h libuv_la_SOURCES += src/unix/android-ifaddrs.c \ - src/unix/pthread-fixes.c + src/unix/linux-core.c \ + src/unix/linux-inotify.c \ + src/unix/linux-syscalls.c \ + src/unix/procfs-exepath.c \ + src/unix/pthread-fixes.c \ + src/unix/random-getrandom.c \ + src/unix/random-sysctl-linux.c \ + src/unix/sysinfo-loadavg.c endif if CYGWIN @@ -467,7 +474,7 @@ libuv_la_SOURCES += src/unix/linux-core.c \ src/unix/procfs-exepath.c \ src/unix/proctitle.c \ src/unix/random-getrandom.c \ - src/unix/random-sysctl.c \ + src/unix/random-sysctl-linux.c \ src/unix/sysinfo-loadavg.c test_run_tests_LDFLAGS += -lutil endif diff --git a/deps/uv/configure.ac b/deps/uv/configure.ac index 07ad0cde81a656..6ea6b6a06cd1db 100644 --- a/deps/uv/configure.ac +++ b/deps/uv/configure.ac @@ -13,7 +13,7 @@ # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. AC_PREREQ(2.57) -AC_INIT([libuv], [1.33.1], [https://github.com/libuv/libuv/issues]) +AC_INIT([libuv], [1.34.0], [https://github.com/libuv/libuv/issues]) AC_CONFIG_MACRO_DIR([m4]) m4_include([m4/libuv-extra-automake-flags.m4]) m4_include([m4/as_case.m4]) diff --git a/deps/uv/docs/src/fs.rst b/deps/uv/docs/src/fs.rst index dc16ff08e65a93..28356c2d442e43 100644 --- a/deps/uv/docs/src/fs.rst +++ b/deps/uv/docs/src/fs.rst @@ -99,7 +99,8 @@ Data types UV_FS_LCHOWN, UV_FS_OPENDIR, UV_FS_READDIR, - UV_FS_CLOSEDIR + UV_FS_CLOSEDIR, + UV_FS_MKSTEMP } uv_fs_type; .. c:type:: uv_statfs_t @@ -245,10 +246,14 @@ API .. c:function:: int uv_fs_mkdtemp(uv_loop_t* loop, uv_fs_t* req, const char* tpl, uv_fs_cb cb) - Equivalent to :man:`mkdtemp(3)`. + Equivalent to :man:`mkdtemp(3)`. The result can be found as a null terminated string at `req->path`. - .. note:: - The result can be found as a null terminated string at `req->path`. +.. c:function:: int uv_fs_mkstemp(uv_loop_t* loop, uv_fs_t* req, const char* tpl, uv_fs_cb cb) + + Equivalent to :man:`mkstemp(3)`. The created file path can be found as a null terminated string at `req->path`. + The file descriptor can be found as an integer at `req->result`. + + .. versionadded:: 1.34.0 .. c:function:: int uv_fs_rmdir(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) diff --git a/deps/uv/docs/src/misc.rst b/deps/uv/docs/src/misc.rst index 8e167e3ec4ec1d..3264973bcce151 100644 --- a/deps/uv/docs/src/misc.rst +++ b/deps/uv/docs/src/misc.rst @@ -679,6 +679,7 @@ API :man:`sysctl(2)`. - FreeBSD: `getrandom(2) _`, or `/dev/urandom` after reading from `/dev/random` once. + - NetBSD: `KERN_ARND` `sysctl(3) _` - macOS, OpenBSD: `getentropy(2) _` if available, or `/dev/urandom` after reading from `/dev/random` once. - AIX: `/dev/random`. @@ -693,3 +694,9 @@ API are not used and can be set to `NULL`. .. versionadded:: 1.33.0 + +.. c:function:: void uv_sleep(unsigned int msec) + + Causes the calling thread to sleep for `msec` milliseconds. + + .. versionadded:: 1.34.0 diff --git a/deps/uv/include/uv.h b/deps/uv/include/uv.h index 0e8132e4384be0..626cebabd8c9ea 100644 --- a/deps/uv/include/uv.h +++ b/deps/uv/include/uv.h @@ -1258,7 +1258,8 @@ typedef enum { UV_FS_OPENDIR, UV_FS_READDIR, UV_FS_CLOSEDIR, - UV_FS_STATFS + UV_FS_STATFS, + UV_FS_MKSTEMP } uv_fs_type; struct uv_dir_s { @@ -1349,6 +1350,10 @@ UV_EXTERN int uv_fs_mkdtemp(uv_loop_t* loop, uv_fs_t* req, const char* tpl, uv_fs_cb cb); +UV_EXTERN int uv_fs_mkstemp(uv_loop_t* loop, + uv_fs_t* req, + const char* tpl, + uv_fs_cb cb); UV_EXTERN int uv_fs_rmdir(uv_loop_t* loop, uv_fs_t* req, const char* path, @@ -1641,6 +1646,7 @@ UV_EXTERN uint64_t uv_get_total_memory(void); UV_EXTERN uint64_t uv_get_constrained_memory(void); UV_EXTERN uint64_t uv_hrtime(void); +UV_EXTERN void uv_sleep(unsigned int msec); UV_EXTERN void uv_disable_stdio_inheritance(void); diff --git a/deps/uv/include/uv/version.h b/deps/uv/include/uv/version.h index ca94be6dd4fba6..8017302600d9f3 100644 --- a/deps/uv/include/uv/version.h +++ b/deps/uv/include/uv/version.h @@ -31,8 +31,8 @@ */ #define UV_VERSION_MAJOR 1 -#define UV_VERSION_MINOR 33 -#define UV_VERSION_PATCH 1 +#define UV_VERSION_MINOR 34 +#define UV_VERSION_PATCH 0 #define UV_VERSION_IS_RELEASE 1 #define UV_VERSION_SUFFIX "" diff --git a/deps/uv/src/random.c b/deps/uv/src/random.c index 8c4fe32013dc9a..491bf703309955 100644 --- a/deps/uv/src/random.c +++ b/deps/uv/src/random.c @@ -40,6 +40,8 @@ static int uv__random(void* buf, size_t buflen) { rc = uv__random_getentropy(buf, buflen); if (rc == UV_ENOSYS) rc = uv__random_devurandom(buf, buflen); +#elif defined(__NetBSD__) + rc = uv__random_sysctl(buf, buflen); #elif defined(__FreeBSD__) || defined(__linux__) rc = uv__random_getrandom(buf, buflen); if (rc == UV_ENOSYS) diff --git a/deps/uv/src/unix/aix-common.c b/deps/uv/src/unix/aix-common.c index b9d313c0c5d7cb..e96e34c46373bb 100644 --- a/deps/uv/src/unix/aix-common.c +++ b/deps/uv/src/unix/aix-common.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -158,28 +159,42 @@ int uv_exepath(char* buffer, size_t* size) { int uv_interface_addresses(uv_interface_address_t** addresses, int* count) { uv_interface_address_t* address; - int sockfd, inet6, size = 1; + int sockfd, sock6fd, inet6, i, r, size = 1; struct ifconf ifc; struct ifreq *ifr, *p, flg; + struct in6_ifreq if6; struct sockaddr_dl* sa_addr; + ifc.ifc_req = NULL; + sock6fd = -1; + r = 0; *count = 0; *addresses = NULL; if (0 > (sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP))) { - return UV__ERR(errno); + r = UV__ERR(errno); + goto cleanup; + } + + if (0 > (sock6fd = socket(AF_INET6, SOCK_DGRAM, IPPROTO_IP))) { + r = UV__ERR(errno); + goto cleanup; } if (ioctl(sockfd, SIOCGSIZIFCONF, &size) == -1) { - uv__close(sockfd); - return UV__ERR(errno); + r = UV__ERR(errno); + goto cleanup; } ifc.ifc_req = (struct ifreq*)uv__malloc(size); + if (ifc.ifc_req == NULL) { + r = UV_ENOMEM; + goto cleanup; + } ifc.ifc_len = size; if (ioctl(sockfd, SIOCGIFCONF, &ifc) == -1) { - uv__close(sockfd); - return UV__ERR(errno); + r = UV__ERR(errno); + goto cleanup; } #define ADDR_SIZE(p) MAX((p).sa_len, sizeof(p)) @@ -197,8 +212,8 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) { memcpy(flg.ifr_name, p->ifr_name, sizeof(flg.ifr_name)); if (ioctl(sockfd, SIOCGIFFLAGS, &flg) == -1) { - uv__close(sockfd); - return UV__ERR(errno); + r = UV__ERR(errno); + goto cleanup; } if (!(flg.ifr_flags & IFF_UP && flg.ifr_flags & IFF_RUNNING)) @@ -207,16 +222,14 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) { (*count)++; } - if (*count == 0) { - uv__close(sockfd); - return 0; - } + if (*count == 0) + goto cleanup; /* Alloc the return interface structs */ - *addresses = uv__malloc(*count * sizeof(uv_interface_address_t)); + *addresses = uv__calloc(*count, sizeof(**addresses)); if (!(*addresses)) { - uv__close(sockfd); - return UV_ENOMEM; + r = UV_ENOMEM; + goto cleanup; } address = *addresses; @@ -233,10 +246,8 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) { inet6 = (p->ifr_addr.sa_family == AF_INET6); memcpy(flg.ifr_name, p->ifr_name, sizeof(flg.ifr_name)); - if (ioctl(sockfd, SIOCGIFFLAGS, &flg) == -1) { - uv__close(sockfd); - return UV_ENOSYS; - } + if (ioctl(sockfd, SIOCGIFFLAGS, &flg) == -1) + goto syserror; if (!(flg.ifr_flags & IFF_UP && flg.ifr_flags & IFF_RUNNING)) continue; @@ -250,28 +261,67 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) { else address->address.address4 = *((struct sockaddr_in*) &p->ifr_addr); - sa_addr = (struct sockaddr_dl*) &p->ifr_addr; - memcpy(address->phys_addr, LLADDR(sa_addr), sizeof(address->phys_addr)); - - if (ioctl(sockfd, SIOCGIFNETMASK, p) == -1) { - uv__close(sockfd); - return UV_ENOSYS; - } - - if (inet6) - address->netmask.netmask6 = *((struct sockaddr_in6*) &p->ifr_addr); - else + if (inet6) { + memset(&if6, 0, sizeof(if6)); + r = uv__strscpy(if6.ifr_name, p->ifr_name, sizeof(if6.ifr_name)); + if (r == UV_E2BIG) + goto cleanup; + r = 0; + memcpy(&if6.ifr_Addr, &p->ifr_addr, sizeof(if6.ifr_Addr)); + if (ioctl(sock6fd, SIOCGIFNETMASK6, &if6) == -1) + goto syserror; + address->netmask.netmask6 = *((struct sockaddr_in6*) &if6.ifr_Addr); + /* Explicitly set family as the ioctl call appears to return it as 0. */ + address->netmask.netmask6.sin6_family = AF_INET6; + } else { + if (ioctl(sockfd, SIOCGIFNETMASK, p) == -1) + goto syserror; address->netmask.netmask4 = *((struct sockaddr_in*) &p->ifr_addr); + /* Explicitly set family as the ioctl call appears to return it as 0. */ + address->netmask.netmask4.sin_family = AF_INET; + } address->is_internal = flg.ifr_flags & IFF_LOOPBACK ? 1 : 0; address++; } + /* Fill in physical addresses. */ + ifr = ifc.ifc_req; + while ((char*)ifr < (char*)ifc.ifc_req + ifc.ifc_len) { + p = ifr; + ifr = (struct ifreq*) + ((char*)ifr + sizeof(ifr->ifr_name) + ADDR_SIZE(ifr->ifr_addr)); + + if (p->ifr_addr.sa_family != AF_LINK) + continue; + + address = *addresses; + for (i = 0; i < *count; i++) { + if (strcmp(address->name, p->ifr_name) == 0) { + sa_addr = (struct sockaddr_dl*) &p->ifr_addr; + memcpy(address->phys_addr, LLADDR(sa_addr), sizeof(address->phys_addr)); + } + address++; + } + } + #undef ADDR_SIZE + goto cleanup; - uv__close(sockfd); - return 0; +syserror: + uv_free_interface_addresses(*addresses, *count); + *addresses = NULL; + *count = 0; + r = UV_ENOSYS; + +cleanup: + if (sockfd != -1) + uv__close(sockfd); + if (sock6fd != -1) + uv__close(sock6fd); + uv__free(ifc.ifc_req); + return r; } diff --git a/deps/uv/src/unix/core.c b/deps/uv/src/unix/core.c index ffce948c957403..04999dce36d193 100644 --- a/deps/uv/src/unix/core.c +++ b/deps/uv/src/unix/core.c @@ -1555,3 +1555,17 @@ int uv_gettimeofday(uv_timeval64_t* tv) { tv->tv_usec = (int32_t) time.tv_usec; return 0; } + +void uv_sleep(unsigned int msec) { + struct timespec timeout; + int rc; + + timeout.tv_sec = msec / 1000; + timeout.tv_nsec = (msec % 1000) * 1000 * 1000; + + do + rc = nanosleep(&timeout, &timeout); + while (rc == -1 && errno == EINTR); + + assert(rc == 0); +} diff --git a/deps/uv/src/unix/fs.c b/deps/uv/src/unix/fs.c index b37cfbbc7a04ee..be256bfca6c58a 100644 --- a/deps/uv/src/unix/fs.c +++ b/deps/uv/src/unix/fs.c @@ -30,6 +30,7 @@ #include "internal.h" #include +#include #include #include #include @@ -258,6 +259,80 @@ static ssize_t uv__fs_mkdtemp(uv_fs_t* req) { } +static int uv__fs_mkstemp(uv_fs_t* req) { + int r; +#ifdef O_CLOEXEC + int (*mkostemp_function)(char*, int); + static int no_cloexec_support; +#endif + static const char pattern[] = "XXXXXX"; + static const size_t pattern_size = sizeof(pattern) - 1; + char* path; + size_t path_length; + + path = (char*) req->path; + path_length = strlen(path); + + /* EINVAL can be returned for 2 reasons: + 1. The template's last 6 characters were not XXXXXX + 2. open() didn't support O_CLOEXEC + We want to avoid going to the fallback path in case + of 1, so it's manually checked before. */ + if (path_length < pattern_size || + strcmp(path + path_length - pattern_size, pattern)) { + errno = EINVAL; + return -1; + } + +#ifdef O_CLOEXEC + if (no_cloexec_support == 0) { + *(int**)(&mkostemp_function) = dlsym(RTLD_DEFAULT, "mkostemp"); + + /* We don't care about errors, but we do want to clean them up. + If there has been no error, then dlerror() will just return + NULL. */ + dlerror(); + + if (mkostemp_function != NULL) { + r = mkostemp_function(path, O_CLOEXEC); + + if (r >= 0) + return r; + + /* If mkostemp() returns EINVAL, it means the kernel doesn't + support O_CLOEXEC, so we just fallback to mkstemp() below. */ + if (errno != EINVAL) + return r; + + /* We set the static variable so that next calls don't even + try to use mkostemp. */ + no_cloexec_support = 1; + } + } +#endif /* O_CLOEXEC */ + + if (req->cb != NULL) + uv_rwlock_rdlock(&req->loop->cloexec_lock); + + r = mkstemp(path); + + /* In case of failure `uv__cloexec` will leave error in `errno`, + * so it is enough to just set `r` to `-1`. + */ + if (r >= 0 && uv__cloexec(r, 1) != 0) { + r = uv__close(r); + if (r != 0) + abort(); + r = -1; + } + + if (req->cb != NULL) + uv_rwlock_rdunlock(&req->loop->cloexec_lock); + + return r; +} + + static ssize_t uv__fs_open(uv_fs_t* req) { #ifdef O_CLOEXEC return open(req->path, req->flags | O_CLOEXEC, req->mode); @@ -999,6 +1074,7 @@ static ssize_t uv__fs_copyfile(uv_fs_t* req) { int err; size_t bytes_to_send; int64_t in_offset; + ssize_t bytes_written; dstfd = -1; err = 0; @@ -1076,18 +1152,17 @@ static ssize_t uv__fs_copyfile(uv_fs_t* req) { bytes_to_send = src_statsbuf.st_size; in_offset = 0; while (bytes_to_send != 0) { - err = uv_fs_sendfile(NULL, - &fs_req, - dstfd, - srcfd, - in_offset, - bytes_to_send, - NULL); + uv_fs_sendfile(NULL, &fs_req, dstfd, srcfd, in_offset, bytes_to_send, NULL); + bytes_written = fs_req.result; uv_fs_req_cleanup(&fs_req); - if (err < 0) + + if (bytes_written < 0) { + err = bytes_written; break; - bytes_to_send -= fs_req.result; - in_offset += fs_req.result; + } + + bytes_to_send -= bytes_written; + in_offset += bytes_written; } out: @@ -1234,13 +1309,22 @@ static int uv__fs_statx(int fd, rc = uv__statx(dirfd, path, flags, mode, &statxbuf); - if (rc == -1) { + switch (rc) { + case 0: + break; + case -1: /* EPERM happens when a seccomp filter rejects the system call. * Has been observed with libseccomp < 2.3.3 and docker < 18.04. */ if (errno != EINVAL && errno != EPERM && errno != ENOSYS) return -1; - + /* Fall through. */ + default: + /* Normally on success, zero is returned and On error, -1 is returned. + * Observed on S390 RHEL running in a docker container with statx not + * implemented, rc might return 1 with 0 set as the error code in which + * case we return ENOSYS. + */ no_statx = 1; return UV_ENOSYS; } @@ -1415,6 +1499,7 @@ static void uv__fs_work(struct uv__work* w) { X(LINK, link(req->path, req->new_path)); X(MKDIR, mkdir(req->path, req->mode)); X(MKDTEMP, uv__fs_mkdtemp(req)); + X(MKSTEMP, uv__fs_mkstemp(req)); X(OPEN, uv__fs_open(req)); X(READ, uv__fs_read(req)); X(SCANDIR, uv__fs_scandir(req)); @@ -1639,6 +1724,18 @@ int uv_fs_mkdtemp(uv_loop_t* loop, } +int uv_fs_mkstemp(uv_loop_t* loop, + uv_fs_t* req, + const char* tpl, + uv_fs_cb cb) { + INIT(MKSTEMP); + req->path = uv__strdup(tpl); + if (req->path == NULL) + return UV_ENOMEM; + POST; +} + + int uv_fs_open(uv_loop_t* loop, uv_fs_t* req, const char* path, @@ -1857,10 +1954,12 @@ void uv_fs_req_cleanup(uv_fs_t* req) { /* Only necessary for asychronous requests, i.e., requests with a callback. * Synchronous ones don't copy their arguments and have req->path and - * req->new_path pointing to user-owned memory. UV_FS_MKDTEMP is the - * exception to the rule, it always allocates memory. + * req->new_path pointing to user-owned memory. UV_FS_MKDTEMP and + * UV_FS_MKSTEMP are the exception to the rule, they always allocate memory. */ - if (req->path != NULL && (req->cb != NULL || req->fs_type == UV_FS_MKDTEMP)) + if (req->path != NULL && + (req->cb != NULL || + req->fs_type == UV_FS_MKDTEMP || req->fs_type == UV_FS_MKSTEMP)) uv__free((void*) req->path); /* Memory is shared with req->new_path. */ req->path = NULL; diff --git a/deps/uv/src/unix/netbsd.c b/deps/uv/src/unix/netbsd.c index cfe2c6a49dc3c7..690bd79ef91a36 100644 --- a/deps/uv/src/unix/netbsd.c +++ b/deps/uv/src/unix/netbsd.c @@ -234,3 +234,26 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { uv__free(cp_times); return 0; } + +int uv__random_sysctl(void* buf, size_t len) { + static int name[] = {CTL_KERN, KERN_ARND}; + size_t count, req; + unsigned char* p; + + p = buf; + while (len) { + req = len < 32 ? len : 32; + count = req; + + if (sysctl(name, ARRAY_SIZE(name), p, &count, NULL, 0) == -1) + return UV__ERR(errno); + + if (count != req) + return UV_EIO; /* Can't happen. */ + + p += count; + len -= count; + } + + return 0; +} diff --git a/deps/uv/src/unix/os390-syscalls.c b/deps/uv/src/unix/os390-syscalls.c index 1040d66979da04..d9abdebaeeda59 100644 --- a/deps/uv/src/unix/os390-syscalls.c +++ b/deps/uv/src/unix/os390-syscalls.c @@ -23,11 +23,11 @@ #include "os390-syscalls.h" #include #include -#include #include #include #include +#define CW_INTRPT 1 #define CW_CONDVAR 32 #pragma linkage(BPX4CTW, OS) @@ -350,27 +350,34 @@ int nanosleep(const struct timespec* req, struct timespec* rem) { unsigned secrem; unsigned nanorem; int rv; - int rc; + int err; int rsn; nano = (int)req->tv_nsec; seconds = req->tv_sec; - events = CW_CONDVAR; + events = CW_CONDVAR | CW_INTRPT; + secrem = 0; + nanorem = 0; #if defined(_LP64) - BPX4CTW(&seconds, &nano, &events, &secrem, &nanorem, &rv, &rc, &rsn); + BPX4CTW(&seconds, &nano, &events, &secrem, &nanorem, &rv, &err, &rsn); #else - BPX1CTW(&seconds, &nano, &events, &secrem, &nanorem, &rv, &rc, &rsn); + BPX1CTW(&seconds, &nano, &events, &secrem, &nanorem, &rv, &err, &rsn); #endif - assert(rv == -1 && errno == EAGAIN); + /* Don't clobber errno unless BPX1CTW/BPX4CTW errored. + * Don't leak EAGAIN, that just means the timeout expired. + */ + if (rv == -1) + if (err != EAGAIN) + errno = err; - if(rem != NULL) { + if (rem != NULL && (rv == 0 || err == EINTR || err == EAGAIN)) { rem->tv_nsec = nanorem; rem->tv_sec = secrem; } - return 0; + return rv; } diff --git a/deps/uv/src/unix/random-devurandom.c b/deps/uv/src/unix/random-devurandom.c index bfc40d20f88cb7..9aa762e372ea3f 100644 --- a/deps/uv/src/unix/random-devurandom.c +++ b/deps/uv/src/unix/random-devurandom.c @@ -74,10 +74,10 @@ int uv__random_readpath(const char* path, void* buf, size_t buflen) { static void uv__random_devurandom_init(void) { char c; - /* Linux's and NetBSD's random(4) man page suggests applications should read - * at least once from /dev/random before switching to /dev/urandom in order - * to seed the system RNG. Reads from /dev/random can of course block - * indefinitely until entropy is available but that's the point. + /* Linux's random(4) man page suggests applications should read at least + * once from /dev/random before switching to /dev/urandom in order to seed + * the system RNG. Reads from /dev/random can of course block indefinitely + * until entropy is available but that's the point. */ status = uv__random_readpath("/dev/random", &c, 1); } diff --git a/deps/uv/src/unix/random-sysctl.c b/deps/uv/src/unix/random-sysctl-linux.c similarity index 97% rename from deps/uv/src/unix/random-sysctl.c rename to deps/uv/src/unix/random-sysctl-linux.c index fb182ded09296b..66ba8d74ec22b7 100644 --- a/deps/uv/src/unix/random-sysctl.c +++ b/deps/uv/src/unix/random-sysctl-linux.c @@ -40,7 +40,6 @@ struct uv__sysctl_args { }; -/* TODO(bnoordhuis) Use {CTL_KERN, KERN_ARND} on FreeBSD (and NetBSD?) */ int uv__random_sysctl(void* buf, size_t buflen) { static int name[] = {1 /*CTL_KERN*/, 40 /*KERN_RANDOM*/, 6 /*RANDOM_UUID*/}; struct uv__sysctl_args args; diff --git a/deps/uv/src/win/fs.c b/deps/uv/src/win/fs.c index 3ab486080cdfa7..8502b072021a9e 100644 --- a/deps/uv/src/win/fs.c +++ b/deps/uv/src/win/fs.c @@ -1195,9 +1195,10 @@ void fs__mkdir(uv_fs_t* req) { } } +typedef int (*uv__fs_mktemp_func)(uv_fs_t* req); /* OpenBSD original: lib/libc/stdio/mktemp.c */ -void fs__mkdtemp(uv_fs_t* req) { +void fs__mktemp(uv_fs_t* req, uv__fs_mktemp_func func) { static const WCHAR *tempchars = L"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; static const size_t num_chars = 62; @@ -1227,13 +1228,11 @@ void fs__mkdtemp(uv_fs_t* req) { v /= num_chars; } - if (_wmkdir(req->file.pathw) == 0) { - len = strlen(req->path); - wcstombs((char*) req->path + len - num_x, ep - num_x, num_x); - SET_REQ_RESULT(req, 0); - break; - } else if (errno != EEXIST) { - SET_REQ_RESULT(req, -1); + if (func(req)) { + if (req->result >= 0) { + len = strlen(req->path); + wcstombs((char*) req->path + len - num_x, ep - num_x, num_x); + } break; } } while (--tries); @@ -1244,6 +1243,77 @@ void fs__mkdtemp(uv_fs_t* req) { } +static int fs__mkdtemp_func(uv_fs_t* req) { + if (_wmkdir(req->file.pathw) == 0) { + SET_REQ_RESULT(req, 0); + return 1; + } else if (errno != EEXIST) { + SET_REQ_RESULT(req, -1); + return 1; + } + + return 0; +} + + +void fs__mkdtemp(uv_fs_t* req) { + fs__mktemp(req, fs__mkdtemp_func); +} + + +static int fs__mkstemp_func(uv_fs_t* req) { + HANDLE file; + int fd; + + file = CreateFileW(req->file.pathw, + GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, + NULL, + CREATE_NEW, + FILE_ATTRIBUTE_NORMAL, + NULL); + + if (file == INVALID_HANDLE_VALUE) { + DWORD error; + error = GetLastError(); + + /* If the file exists, the main fs__mktemp() function + will retry. If it's another error, we want to stop. */ + if (error != ERROR_FILE_EXISTS) { + SET_REQ_WIN32_ERROR(req, error); + return 1; + } + + return 0; + } + + fd = _open_osfhandle((intptr_t) file, 0); + if (fd < 0) { + /* The only known failure mode for _open_osfhandle() is EMFILE, in which + * case GetLastError() will return zero. However we'll try to handle other + * errors as well, should they ever occur. + */ + if (errno == EMFILE) + SET_REQ_UV_ERROR(req, UV_EMFILE, ERROR_TOO_MANY_OPEN_FILES); + else if (GetLastError() != ERROR_SUCCESS) + SET_REQ_WIN32_ERROR(req, GetLastError()); + else + SET_REQ_WIN32_ERROR(req, UV_UNKNOWN); + CloseHandle(file); + return 1; + } + + SET_REQ_RESULT(req, fd); + + return 1; +} + + +void fs__mkstemp(uv_fs_t* req) { + fs__mktemp(req, fs__mkstemp_func); +} + + void fs__scandir(uv_fs_t* req) { static const size_t dirents_initial_size = 32; @@ -2609,6 +2679,7 @@ static void uv__fs_work(struct uv__work* w) { XX(RMDIR, rmdir) XX(MKDIR, mkdir) XX(MKDTEMP, mkdtemp) + XX(MKSTEMP, mkstemp) XX(RENAME, rename) XX(SCANDIR, scandir) XX(READDIR, readdir) @@ -2785,8 +2856,10 @@ int uv_fs_mkdir(uv_loop_t* loop, uv_fs_t* req, const char* path, int mode, } -int uv_fs_mkdtemp(uv_loop_t* loop, uv_fs_t* req, const char* tpl, - uv_fs_cb cb) { +int uv_fs_mkdtemp(uv_loop_t* loop, + uv_fs_t* req, + const char* tpl, + uv_fs_cb cb) { int err; INIT(UV_FS_MKDTEMP); @@ -2798,6 +2871,21 @@ int uv_fs_mkdtemp(uv_loop_t* loop, uv_fs_t* req, const char* tpl, } +int uv_fs_mkstemp(uv_loop_t* loop, + uv_fs_t* req, + const char* tpl, + uv_fs_cb cb) { + int err; + + INIT(UV_FS_MKSTEMP); + err = fs__capture_path(req, tpl, NULL, TRUE); + if (err) + return uv_translate_sys_error(err); + + POST; +} + + int uv_fs_rmdir(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) { int err; diff --git a/deps/uv/src/win/util.c b/deps/uv/src/win/util.c index 4bbeb3154123dd..4de638f5971c35 100644 --- a/deps/uv/src/win/util.c +++ b/deps/uv/src/win/util.c @@ -1873,3 +1873,7 @@ int uv__random_rtlgenrandom(void* buf, size_t buflen) { return 0; } + +void uv_sleep(unsigned int msec) { + Sleep(msec); +} diff --git a/deps/uv/test/runner-unix.c b/deps/uv/test/runner-unix.c index 432cf33d482cd9..716c15ff088fa9 100644 --- a/deps/uv/test/runner-unix.c +++ b/deps/uv/test/runner-unix.c @@ -448,17 +448,3 @@ void rewind_cursor(void) { fprintf(stderr, "\033[2K\r"); #endif } - - -/* Pause the calling thread for a number of milliseconds. */ -void uv_sleep(int msec) { - int sec; - int usec; - - sec = msec / 1000; - usec = (msec % 1000) * 1000; - if (sec > 0) - sleep(sec); - if (usec > 0) - usleep(usec); -} diff --git a/deps/uv/test/runner-win.c b/deps/uv/test/runner-win.c index 6bb41a5d0629c8..4167a386921ec7 100644 --- a/deps/uv/test/runner-win.c +++ b/deps/uv/test/runner-win.c @@ -355,9 +355,3 @@ void rewind_cursor() { fprintf(stderr, "\n"); } } - - -/* Pause the calling thread for a number of milliseconds. */ -void uv_sleep(int msec) { - Sleep(msec); -} diff --git a/deps/uv/test/task.h b/deps/uv/test/task.h index e763f89f09dcd1..bc7b53369b538a 100644 --- a/deps/uv/test/task.h +++ b/deps/uv/test/task.h @@ -131,9 +131,6 @@ typedef enum { int run_helper_##name(void); \ int run_helper_##name(void) -/* Pause the calling thread for a number of milliseconds. */ -void uv_sleep(int msec); - /* Format big numbers nicely. WARNING: leaks memory. */ const char* fmt(double d); diff --git a/deps/uv/test/test-fs.c b/deps/uv/test/test-fs.c index 9326c6bc2753f0..ded1eec8dc632c 100644 --- a/deps/uv/test/test-fs.c +++ b/deps/uv/test/test-fs.c @@ -73,6 +73,7 @@ static int write_cb_count; static int unlink_cb_count; static int mkdir_cb_count; static int mkdtemp_cb_count; +static int mkstemp_cb_count; static int rmdir_cb_count; static int scandir_cb_count; static int stat_cb_count; @@ -107,6 +108,9 @@ static uv_fs_t close_req; static uv_fs_t mkdir_req; static uv_fs_t mkdtemp_req1; static uv_fs_t mkdtemp_req2; +static uv_fs_t mkstemp_req1; +static uv_fs_t mkstemp_req2; +static uv_fs_t mkstemp_req3; static uv_fs_t rmdir_req; static uv_fs_t scandir_req; static uv_fs_t stat_req; @@ -538,6 +542,32 @@ static void mkdtemp_cb(uv_fs_t* req) { } +static void check_mkstemp_result(uv_fs_t* req) { + int r; + + ASSERT(req->fs_type == UV_FS_MKSTEMP); + ASSERT(req->result >= 0); + ASSERT(req->path); + ASSERT(strlen(req->path) == 16); + ASSERT(memcmp(req->path, "test_file_", 10) == 0); + ASSERT(memcmp(req->path + 10, "XXXXXX", 6) != 0); + check_permission(req->path, 0600); + + /* Check if req->path is actually a file */ + r = uv_fs_stat(NULL, &stat_req, req->path, NULL); + ASSERT(r == 0); + ASSERT(stat_req.statbuf.st_mode & S_IFREG); + uv_fs_req_cleanup(&stat_req); +} + + +static void mkstemp_cb(uv_fs_t* req) { + ASSERT(req == &mkstemp_req1); + check_mkstemp_result(req); + mkstemp_cb_count++; +} + + static void rmdir_cb(uv_fs_t* req) { ASSERT(req == &rmdir_req); ASSERT(req->fs_type == UV_FS_RMDIR); @@ -1208,6 +1238,69 @@ TEST_IMPL(fs_mkdtemp) { } +TEST_IMPL(fs_mkstemp) { + int r; + int fd; + const char path_template[] = "test_file_XXXXXX"; + uv_fs_t req; + + loop = uv_default_loop(); + + r = uv_fs_mkstemp(loop, &mkstemp_req1, path_template, mkstemp_cb); + ASSERT(r == 0); + + uv_run(loop, UV_RUN_DEFAULT); + ASSERT(mkstemp_cb_count == 1); + + /* sync mkstemp */ + r = uv_fs_mkstemp(NULL, &mkstemp_req2, path_template, NULL); + ASSERT(r >= 0); + check_mkstemp_result(&mkstemp_req2); + + /* mkstemp return different values on subsequent calls */ + ASSERT(strcmp(mkstemp_req1.path, mkstemp_req2.path) != 0); + + /* invalid template returns EINVAL */ + ASSERT(uv_fs_mkstemp(NULL, &mkstemp_req3, "test_file", NULL) == UV_EINVAL); + + /* We can write to the opened file */ + iov = uv_buf_init(test_buf, sizeof(test_buf)); + r = uv_fs_write(NULL, &req, mkstemp_req1.result, &iov, 1, -1, NULL); + ASSERT(r == sizeof(test_buf)); + ASSERT(req.result == sizeof(test_buf)); + uv_fs_req_cleanup(&req); + + /* Cleanup */ + uv_fs_close(NULL, &req, mkstemp_req1.result, NULL); + uv_fs_req_cleanup(&req); + uv_fs_close(NULL, &req, mkstemp_req2.result, NULL); + uv_fs_req_cleanup(&req); + + fd = uv_fs_open(NULL, &req, mkstemp_req1.path , O_RDONLY, 0, NULL); + ASSERT(fd >= 0); + uv_fs_req_cleanup(&req); + + memset(buf, 0, sizeof(buf)); + iov = uv_buf_init(buf, sizeof(buf)); + r = uv_fs_read(NULL, &req, fd, &iov, 1, -1, NULL); + ASSERT(r >= 0); + ASSERT(req.result >= 0); + ASSERT(strcmp(buf, test_buf) == 0); + uv_fs_req_cleanup(&req); + + uv_fs_close(NULL, &req, fd, NULL); + uv_fs_req_cleanup(&req); + + unlink(mkstemp_req1.path); + unlink(mkstemp_req2.path); + uv_fs_req_cleanup(&mkstemp_req1); + uv_fs_req_cleanup(&mkstemp_req2); + + MAKE_VALGRIND_HAPPY(); + return 0; +} + + TEST_IMPL(fs_fstat) { int r; uv_fs_t req; @@ -3784,6 +3877,9 @@ TEST_IMPL(fs_null_req) { r = uv_fs_mkdtemp(NULL, NULL, NULL, NULL); ASSERT(r == UV_EINVAL); + r = uv_fs_mkstemp(NULL, NULL, NULL, NULL); + ASSERT(r == UV_EINVAL); + r = uv_fs_rmdir(NULL, NULL, NULL, NULL); ASSERT(r == UV_EINVAL); diff --git a/deps/uv/test/test-list.h b/deps/uv/test/test-list.h index ad94c52d0c5866..a6cfc6bb9284bd 100644 --- a/deps/uv/test/test-list.h +++ b/deps/uv/test/test-list.h @@ -310,6 +310,7 @@ TEST_DECLARE (fs_async_dir) TEST_DECLARE (fs_async_sendfile) TEST_DECLARE (fs_async_sendfile_nodata) TEST_DECLARE (fs_mkdtemp) +TEST_DECLARE (fs_mkstemp) TEST_DECLARE (fs_fstat) TEST_DECLARE (fs_access) TEST_DECLARE (fs_chmod) @@ -920,6 +921,7 @@ TASK_LIST_START TEST_ENTRY (fs_async_sendfile) TEST_ENTRY (fs_async_sendfile_nodata) TEST_ENTRY (fs_mkdtemp) + TEST_ENTRY (fs_mkstemp) TEST_ENTRY (fs_fstat) TEST_ENTRY (fs_access) TEST_ENTRY (fs_chmod) diff --git a/deps/uv/uv.gyp b/deps/uv/uv.gyp index 051bdc937c9fd3..c4564c04086bc0 100644 --- a/deps/uv/uv.gyp +++ b/deps/uv/uv.gyp @@ -245,7 +245,7 @@ 'src/unix/linux-syscalls.h', 'src/unix/procfs-exepath.c', 'src/unix/random-getrandom.c', - 'src/unix/random-sysctl.c', + 'src/unix/random-sysctl-linux.c', 'src/unix/sysinfo-loadavg.c', ], 'link_settings': { @@ -261,8 +261,9 @@ 'src/unix/pthread-fixes.c', 'src/unix/android-ifaddrs.c', 'src/unix/procfs-exepath.c', + 'src/unix/random-getrandom.c', + 'src/unix/random-sysctl-linux.c', 'src/unix/sysinfo-loadavg.c', - 'src/unix/sysinfo-memory.c', ], 'link_settings': { 'libraries': [ '-ldl' ], diff --git a/deps/uvwasi/include/fd_table.h b/deps/uvwasi/include/fd_table.h index ef87a3ff8f93c5..42a5f0d920ff6e 100644 --- a/deps/uvwasi/include/fd_table.h +++ b/deps/uvwasi/include/fd_table.h @@ -16,6 +16,7 @@ # define PATH_MAX_BYTES (PATH_MAX) #endif +struct uvwasi_s; struct uvwasi_fd_wrap_t { uvwasi_fd_t id; @@ -27,22 +28,28 @@ struct uvwasi_fd_wrap_t { uvwasi_rights_t rights_inheriting; int preopen; int valid; + uv_mutex_t mutex; }; struct uvwasi_fd_table_t { struct uvwasi_fd_wrap_t* fds; uint32_t size; uint32_t used; + uv_rwlock_t rwlock; }; -uvwasi_errno_t uvwasi_fd_table_init(struct uvwasi_fd_table_t* table, +uvwasi_errno_t uvwasi_fd_table_init(struct uvwasi_s* uvwasi, + struct uvwasi_fd_table_t* table, uint32_t init_size); -void uvwasi_fd_table_free(struct uvwasi_fd_table_t* table); -uvwasi_errno_t uvwasi_fd_table_insert_preopen(struct uvwasi_fd_table_t* table, +void uvwasi_fd_table_free(struct uvwasi_s* uvwasi, + struct uvwasi_fd_table_t* table); +uvwasi_errno_t uvwasi_fd_table_insert_preopen(struct uvwasi_s* uvwasi, + struct uvwasi_fd_table_t* table, const uv_file fd, const char* path, const char* real_path); -uvwasi_errno_t uvwasi_fd_table_insert_fd(struct uvwasi_fd_table_t* table, +uvwasi_errno_t uvwasi_fd_table_insert_fd(struct uvwasi_s* uvwasi, + struct uvwasi_fd_table_t* table, const uv_file fd, const int flags, const char* path, diff --git a/deps/uvwasi/include/uvwasi.h b/deps/uvwasi/include/uvwasi.h index a7695734ac2ac6..2a4e389164357d 100644 --- a/deps/uvwasi/include/uvwasi.h +++ b/deps/uvwasi/include/uvwasi.h @@ -20,7 +20,20 @@ extern "C" { #define UVWASI_VERSION_STRING UVWASI_STRINGIFY(UVWASI_VERSION_MAJOR) "." \ UVWASI_STRINGIFY(UVWASI_VERSION_MINOR) "." \ UVWASI_STRINGIFY(UVWASI_VERSION_PATCH) +#define UVWASI_VERSION_WASI "snapshot_0" +typedef void* (*uvwasi_malloc)(size_t size, void* mem_user_data); +typedef void (*uvwasi_free)(void* ptr, void* mem_user_data); +typedef void* (*uvwasi_calloc)(size_t nmemb, size_t size, void* mem_user_data); +typedef void* (*uvwasi_realloc)(void* ptr, size_t size, void* mem_user_data); + +typedef struct uvwasi_mem_s { + void* mem_user_data; + uvwasi_malloc malloc; + uvwasi_free free; + uvwasi_calloc calloc; + uvwasi_realloc realloc; +} uvwasi_mem_t; typedef struct uvwasi_s { struct uvwasi_fd_table_t fds; @@ -32,6 +45,7 @@ typedef struct uvwasi_s { char** env; char* env_buf; size_t env_buf_size; + const uvwasi_mem_t* allocator; } uvwasi_t; typedef struct uvwasi_preopen_s { @@ -46,9 +60,9 @@ typedef struct uvwasi_options_s { size_t argc; char** argv; char** envp; + const uvwasi_mem_t* allocator; } uvwasi_options_t; - // Embedder API. uvwasi_errno_t uvwasi_init(uvwasi_t* uvwasi, uvwasi_options_t* options); void uvwasi_destroy(uvwasi_t* uvwasi); diff --git a/deps/uvwasi/src/fd_table.c b/deps/uvwasi/src/fd_table.c index 9343868074d10c..f716495e9a02b2 100644 --- a/deps/uvwasi/src/fd_table.c +++ b/deps/uvwasi/src/fd_table.c @@ -10,6 +10,7 @@ #include "fd_table.h" #include "wasi_types.h" #include "uv_mapping.h" +#include "uvwasi_alloc.h" #define UVWASI__RIGHTS_ALL (UVWASI_RIGHT_FD_DATASYNC | \ @@ -175,7 +176,8 @@ static uvwasi_errno_t uvwasi__get_type_and_rights(uv_file fd, } -static uvwasi_errno_t uvwasi__fd_table_insert(struct uvwasi_fd_table_t* table, +static uvwasi_errno_t uvwasi__fd_table_insert(uvwasi_t* uvwasi, + struct uvwasi_fd_table_t* table, uv_file fd, const char* mapped_path, const char* real_path, @@ -186,16 +188,22 @@ static uvwasi_errno_t uvwasi__fd_table_insert(struct uvwasi_fd_table_t* table, struct uvwasi_fd_wrap_t** wrap) { struct uvwasi_fd_wrap_t* entry; struct uvwasi_fd_wrap_t* new_fds; + uvwasi_errno_t err; uint32_t new_size; int index; uint32_t i; + int r; + + uv_rwlock_wrlock(&table->rwlock); /* Check that there is room for a new item. If there isn't, grow the table. */ if (table->used >= table->size) { new_size = table->size * 2; - new_fds = realloc(table->fds, new_size * sizeof(*new_fds)); - if (new_fds == NULL) - return UVWASI_ENOMEM; + new_fds = uvwasi__realloc(uvwasi, table->fds, new_size * sizeof(*new_fds)); + if (new_fds == NULL) { + err = UVWASI_ENOMEM; + goto exit; + } for (i = table->size; i < new_size; ++i) new_fds[i].valid = 0; @@ -214,11 +222,20 @@ static uvwasi_errno_t uvwasi__fd_table_insert(struct uvwasi_fd_table_t* table, } /* index should never be -1. */ - if (index == -1) - return UVWASI_ENOSPC; + if (index == -1) { + err = UVWASI_ENOSPC; + goto exit; + } } entry = &table->fds[index]; + + r = uv_mutex_init(&entry->mutex); + if (r != 0) { + err = uvwasi__translate_uv_error(r); + goto exit; + } + entry->id = index; entry->fd = fd; strcpy(entry->path, mapped_path); @@ -233,11 +250,15 @@ static uvwasi_errno_t uvwasi__fd_table_insert(struct uvwasi_fd_table_t* table, if (wrap != NULL) *wrap = entry; - return UVWASI_ESUCCESS; + err = UVWASI_ESUCCESS; +exit: + uv_rwlock_wrunlock(&table->rwlock); + return err; } -uvwasi_errno_t uvwasi_fd_table_init(struct uvwasi_fd_table_t* table, +uvwasi_errno_t uvwasi_fd_table_init(uvwasi_t* uvwasi, + struct uvwasi_fd_table_t* table, uint32_t init_size) { struct uvwasi_fd_wrap_t* wrap; uvwasi_filetype_t type; @@ -245,17 +266,27 @@ uvwasi_errno_t uvwasi_fd_table_init(struct uvwasi_fd_table_t* table, uvwasi_rights_t inheriting; uvwasi_errno_t err; uvwasi_fd_t i; + int r; /* Require an initial size of at least three to store the stdio FDs. */ if (table == NULL || init_size < 3) return UVWASI_EINVAL; + table->fds = NULL; + r = uv_rwlock_init(&table->rwlock); + if (r != 0) + return uvwasi__translate_uv_error(r); + table->used = 0; table->size = init_size; - table->fds = calloc(init_size, sizeof(struct uvwasi_fd_wrap_t)); + table->fds = uvwasi__calloc(uvwasi, + init_size, + sizeof(struct uvwasi_fd_wrap_t)); - if (table->fds == NULL) - return UVWASI_ENOMEM; + if (table->fds == NULL) { + err = UVWASI_ENOMEM; + goto error_exit; + } /* Create the stdio FDs. */ for (i = 0; i < 3; ++i) { @@ -267,7 +298,8 @@ uvwasi_errno_t uvwasi_fd_table_init(struct uvwasi_fd_table_t* table, if (err != UVWASI_ESUCCESS) goto error_exit; - err = uvwasi__fd_table_insert(table, + err = uvwasi__fd_table_insert(uvwasi, + table, i, "", "", @@ -287,23 +319,25 @@ uvwasi_errno_t uvwasi_fd_table_init(struct uvwasi_fd_table_t* table, return UVWASI_ESUCCESS; error_exit: - uvwasi_fd_table_free(table); + uvwasi_fd_table_free(uvwasi, table); return err; } -void uvwasi_fd_table_free(struct uvwasi_fd_table_t* table) { +void uvwasi_fd_table_free(uvwasi_t* uvwasi, struct uvwasi_fd_table_t* table) { if (table == NULL) return; - free(table->fds); + uvwasi__free(uvwasi, table->fds); table->fds = NULL; table->size = 0; table->used = 0; + uv_rwlock_destroy(&table->rwlock); } -uvwasi_errno_t uvwasi_fd_table_insert_preopen(struct uvwasi_fd_table_t* table, +uvwasi_errno_t uvwasi_fd_table_insert_preopen(uvwasi_t* uvwasi, + struct uvwasi_fd_table_t* table, const uv_file fd, const char* path, const char* real_path) { @@ -322,7 +356,8 @@ uvwasi_errno_t uvwasi_fd_table_insert_preopen(struct uvwasi_fd_table_t* table, if (type != UVWASI_FILETYPE_DIRECTORY) return UVWASI_ENOTDIR; - err = uvwasi__fd_table_insert(table, + err = uvwasi__fd_table_insert(uvwasi, + table, fd, path, real_path, @@ -338,7 +373,8 @@ uvwasi_errno_t uvwasi_fd_table_insert_preopen(struct uvwasi_fd_table_t* table, } -uvwasi_errno_t uvwasi_fd_table_insert_fd(struct uvwasi_fd_table_t* table, +uvwasi_errno_t uvwasi_fd_table_insert_fd(uvwasi_t* uvwasi, + struct uvwasi_fd_table_t* table, const uv_file fd, const int flags, const char* path, @@ -358,7 +394,8 @@ uvwasi_errno_t uvwasi_fd_table_insert_fd(struct uvwasi_fd_table_t* table, if (r != UVWASI_ESUCCESS) return r; - r = uvwasi__fd_table_insert(table, + r = uvwasi__fd_table_insert(uvwasi, + table, fd, path, path, @@ -381,42 +418,68 @@ uvwasi_errno_t uvwasi_fd_table_get(const struct uvwasi_fd_table_t* table, uvwasi_rights_t rights_base, uvwasi_rights_t rights_inheriting) { struct uvwasi_fd_wrap_t* entry; + uvwasi_errno_t err; if (table == NULL || wrap == NULL) return UVWASI_EINVAL; - if (id >= table->size) - return UVWASI_EBADF; + + uv_rwlock_rdlock((uv_rwlock_t *)&table->rwlock); + + if (id >= table->size) { + err = UVWASI_EBADF; + goto exit; + } entry = &table->fds[id]; - if (entry->valid != 1 || entry->id != id) - return UVWASI_EBADF; + if (entry->valid != 1 || entry->id != id) { + err = UVWASI_EBADF; + goto exit; + } /* Validate that the fd has the necessary rights. */ if ((~entry->rights_base & rights_base) != 0 || - (~entry->rights_inheriting & rights_inheriting) != 0) - return UVWASI_ENOTCAPABLE; + (~entry->rights_inheriting & rights_inheriting) != 0) { + err = UVWASI_ENOTCAPABLE; + goto exit; + } + uv_mutex_lock(&entry->mutex); *wrap = entry; - return UVWASI_ESUCCESS; + err = UVWASI_ESUCCESS; +exit: + uv_rwlock_rdunlock((uv_rwlock_t *)&table->rwlock); + return err; } uvwasi_errno_t uvwasi_fd_table_remove(struct uvwasi_fd_table_t* table, const uvwasi_fd_t id) { struct uvwasi_fd_wrap_t* entry; + uvwasi_errno_t err; if (table == NULL) return UVWASI_EINVAL; - if (id >= table->size) - return UVWASI_EBADF; + + uv_rwlock_wrlock(&table->rwlock); + + if (id >= table->size) { + err = UVWASI_EBADF; + goto exit; + } entry = &table->fds[id]; - if (entry->valid != 1 || entry->id != id) - return UVWASI_EBADF; + if (entry->valid != 1 || entry->id != id) { + err = UVWASI_EBADF; + goto exit; + } + uv_mutex_destroy(&entry->mutex); entry->valid = 0; table->used--; - return UVWASI_ESUCCESS; + err = UVWASI_ESUCCESS; +exit: + uv_rwlock_wrunlock(&table->rwlock); + return err; } diff --git a/deps/uvwasi/src/uvwasi.c b/deps/uvwasi/src/uvwasi.c index 39a94b6d217c52..0f7c4c5d3aa0ef 100644 --- a/deps/uvwasi/src/uvwasi.c +++ b/deps/uvwasi/src/uvwasi.c @@ -19,26 +19,69 @@ #define UVWASI__READDIR_NUM_ENTRIES 1 #include "uvwasi.h" +#include "uvwasi_alloc.h" #include "uv.h" #include "uv_mapping.h" #include "fd_table.h" #include "clocks.h" +static void* default_malloc(size_t size, void* mem_user_data) { + return malloc(size); +} + +static void default_free(void* ptr, void* mem_user_data) { + free(ptr); +} + +static void* default_calloc(size_t nmemb, size_t size, void* mem_user_data) { + return calloc(nmemb, size); +} + +static void* default_realloc(void* ptr, size_t size, void* mem_user_data) { + return realloc(ptr, size); +} + +void* uvwasi__malloc(const uvwasi_t* uvwasi, size_t size) { + return uvwasi->allocator->malloc(size, uvwasi->allocator->mem_user_data); +} + +void uvwasi__free(const uvwasi_t* uvwasi, void* ptr) { + uvwasi->allocator->free(ptr, uvwasi->allocator->mem_user_data); +} + +void* uvwasi__calloc(const uvwasi_t* uvwasi, size_t nmemb, size_t size) { + return uvwasi->allocator->calloc(nmemb, + size, + uvwasi->allocator->mem_user_data); +} + +void* uvwasi__realloc(const uvwasi_t* uvwasi, void* ptr, size_t size) { + return uvwasi->allocator->realloc(ptr, + size, + uvwasi->allocator->mem_user_data); +} + +static const uvwasi_mem_t default_allocator = { + NULL, + default_malloc, + default_free, + default_calloc, + default_realloc, +}; + static int uvwasi__is_absolute_path(const char* path, size_t path_len) { - /* TODO(cjihrig): Add a Windows implementation. */ - return path != NULL && path_len > 0 && path[0] == SLASH; + /* It's expected that only Unix style paths will be generated by WASI. */ + return path != NULL && path_len > 0 && path[0] == '/'; } -static uvwasi_errno_t uvwasi__resolve_path(const struct uvwasi_fd_wrap_t* fd, +static uvwasi_errno_t uvwasi__resolve_path(const uvwasi_t* uvwasi, + const struct uvwasi_fd_wrap_t* fd, const char* path, size_t path_len, char* resolved_path, uvwasi_lookupflags_t flags) { - /* TODO(cjihrig): path_len is treated as a size. Need to verify if path_len is - really a string length or a size. Also need to verify if it is null - terminated. */ uv_fs_t realpath_req; uvwasi_errno_t err; char* abs_path; @@ -58,7 +101,7 @@ static uvwasi_errno_t uvwasi__resolve_path(const struct uvwasi_fd_wrap_t* fd, if (1 == input_is_absolute) { /* TODO(cjihrig): Revisit this. Copying is probably not necessary here. */ abs_size = path_len; - abs_path = malloc(abs_size); + abs_path = uvwasi__malloc(uvwasi, abs_size); if (abs_path == NULL) { err = UVWASI_ENOMEM; goto exit; @@ -68,7 +111,7 @@ static uvwasi_errno_t uvwasi__resolve_path(const struct uvwasi_fd_wrap_t* fd, } else { /* Resolve the relative path to fd's real path. */ abs_size = path_len + strlen(fd->real_path) + 2; - abs_path = malloc(abs_size); + abs_path = uvwasi__malloc(uvwasi, abs_size); if (abs_path == NULL) { err = UVWASI_ENOMEM; goto exit; @@ -146,7 +189,7 @@ static uvwasi_errno_t uvwasi__resolve_path(const struct uvwasi_fd_wrap_t* fd, } exit: - free(abs_path); + uvwasi__free(uvwasi, abs_path); return err; } @@ -185,13 +228,17 @@ static uvwasi_errno_t uvwasi__lseek(uv_file fd, } -static uvwasi_errno_t uvwasi__setup_iovs(uv_buf_t** buffers, +static uvwasi_errno_t uvwasi__setup_iovs(const uvwasi_t* uvwasi, + uv_buf_t** buffers, const uvwasi_iovec_t* iovs, size_t iovs_len) { uv_buf_t* bufs; size_t i; - bufs = malloc(iovs_len * sizeof(*bufs)); + if ((iovs_len * sizeof(*bufs)) / (sizeof(*bufs)) != iovs_len) + return UVWASI_ENOMEM; + + bufs = uvwasi__malloc(uvwasi, iovs_len * sizeof(*bufs)); if (bufs == NULL) return UVWASI_ENOMEM; @@ -203,13 +250,17 @@ static uvwasi_errno_t uvwasi__setup_iovs(uv_buf_t** buffers, } -static uvwasi_errno_t uvwasi__setup_ciovs(uv_buf_t** buffers, +static uvwasi_errno_t uvwasi__setup_ciovs(const uvwasi_t* uvwasi, + uv_buf_t** buffers, const uvwasi_ciovec_t* iovs, size_t iovs_len) { uv_buf_t* bufs; size_t i; - bufs = malloc(iovs_len * sizeof(*bufs)); + if ((iovs_len * sizeof(*bufs)) / (sizeof(*bufs)) != iovs_len) + return UVWASI_ENOMEM; + + bufs = uvwasi__malloc(uvwasi, iovs_len * sizeof(*bufs)); if (bufs == NULL) return UVWASI_ENOMEM; @@ -236,6 +287,10 @@ uvwasi_errno_t uvwasi_init(uvwasi_t* uvwasi, uvwasi_options_t* options) { if (uvwasi == NULL || options == NULL || options->fd_table_size == 0) return UVWASI_EINVAL; + uvwasi->allocator = options->allocator; + if (uvwasi->allocator == NULL) + uvwasi->allocator = &default_allocator; + uvwasi->argv_buf = NULL; uvwasi->argv = NULL; uvwasi->env_buf = NULL; @@ -250,13 +305,13 @@ uvwasi_errno_t uvwasi_init(uvwasi_t* uvwasi, uvwasi_options_t* options) { uvwasi->argv_buf_size = args_size; if (args_size > 0) { - uvwasi->argv_buf = malloc(args_size); + uvwasi->argv_buf = uvwasi__malloc(uvwasi, args_size); if (uvwasi->argv_buf == NULL) { err = UVWASI_ENOMEM; goto exit; } - uvwasi->argv = calloc(options->argc, sizeof(char*)); + uvwasi->argv = uvwasi__calloc(uvwasi, options->argc, sizeof(char*)); if (uvwasi->argv == NULL) { err = UVWASI_ENOMEM; goto exit; @@ -284,13 +339,13 @@ uvwasi_errno_t uvwasi_init(uvwasi_t* uvwasi, uvwasi_options_t* options) { uvwasi->env_buf_size = env_buf_size; if (env_buf_size > 0) { - uvwasi->env_buf = malloc(env_buf_size); + uvwasi->env_buf = uvwasi__malloc(uvwasi, env_buf_size); if (uvwasi->env_buf == NULL) { err = UVWASI_ENOMEM; goto exit; } - uvwasi->env = calloc(env_count, sizeof(char*)); + uvwasi->env = uvwasi__calloc(uvwasi, env_count, sizeof(char*)); if (uvwasi->env == NULL) { err = UVWASI_ENOMEM; goto exit; @@ -313,7 +368,7 @@ uvwasi_errno_t uvwasi_init(uvwasi_t* uvwasi, uvwasi_options_t* options) { } } - err = uvwasi_fd_table_init(&uvwasi->fds, options->fd_table_size); + err = uvwasi_fd_table_init(uvwasi, &uvwasi->fds, options->fd_table_size); if (err != UVWASI_ESUCCESS) goto exit; @@ -336,7 +391,8 @@ uvwasi_errno_t uvwasi_init(uvwasi_t* uvwasi, uvwasi_options_t* options) { goto exit; } - err = uvwasi_fd_table_insert_preopen(&uvwasi->fds, + err = uvwasi_fd_table_insert_preopen(uvwasi, + &uvwasi->fds, open_req.result, options->preopens[i].mapped_path, realpath_req.ptr); @@ -359,11 +415,11 @@ void uvwasi_destroy(uvwasi_t* uvwasi) { if (uvwasi == NULL) return; - uvwasi_fd_table_free(&uvwasi->fds); - free(uvwasi->argv_buf); - free(uvwasi->argv); - free(uvwasi->env_buf); - free(uvwasi->env); + uvwasi_fd_table_free(uvwasi, &uvwasi->fds); + uvwasi__free(uvwasi, uvwasi->argv_buf); + uvwasi__free(uvwasi, uvwasi->argv); + uvwasi__free(uvwasi, uvwasi->env_buf); + uvwasi__free(uvwasi, uvwasi->env); uvwasi->argv_buf = NULL; uvwasi->argv = NULL; uvwasi->env_buf = NULL; @@ -385,6 +441,7 @@ uvwasi_errno_t uvwasi_embedder_remap_fd(uvwasi_t* uvwasi, return err; wrap->fd = new_host_fd; + uv_mutex_unlock(&wrap->mutex); return UVWASI_ESUCCESS; } @@ -543,12 +600,15 @@ uvwasi_errno_t uvwasi_fd_advise(uvwasi_t* uvwasi, if (err != UVWASI_ESUCCESS) return err; + err = UVWASI_ESUCCESS; + #ifdef POSIX_FADV_NORMAL r = posix_fadvise(wrap->fd, offset, len, mapped_advice); if (r != 0) - return uvwasi__translate_uv_error(uv_translate_sys_error(r)); + err = uvwasi__translate_uv_error(uv_translate_sys_error(r)); #endif /* POSIX_FADV_NORMAL */ - return UVWASI_ESUCCESS; + uv_mutex_unlock(&wrap->mutex); + return err; } @@ -579,23 +639,32 @@ uvwasi_errno_t uvwasi_fd_allocate(uvwasi_t* uvwasi, race condition prone combination of fstat() + ftruncate(). */ #if defined(__POSIX__) r = posix_fallocate(wrap->fd, offset, len); - if (r != 0) - return uvwasi__translate_uv_error(uv_translate_sys_error(r)); + if (r != 0) { + err = uvwasi__translate_uv_error(uv_translate_sys_error(r)); + goto exit; + } #else r = uv_fs_fstat(NULL, &req, wrap->fd, NULL); st_size = req.statbuf.st_size; uv_fs_req_cleanup(&req); - if (r != 0) - return uvwasi__translate_uv_error(r); + if (r != 0) { + err = uvwasi__translate_uv_error(r); + goto exit; + } if (st_size < offset + len) { r = uv_fs_ftruncate(NULL, &req, wrap->fd, offset + len, NULL); - if (r != 0) - return uvwasi__translate_uv_error(r); + if (r != 0) { + err = uvwasi__translate_uv_error(r); + goto exit; + } } #endif /* __POSIX__ */ - return UVWASI_ESUCCESS; + err = UVWASI_ESUCCESS; +exit: + uv_mutex_unlock(&wrap->mutex); + return err; } @@ -613,6 +682,7 @@ uvwasi_errno_t uvwasi_fd_close(uvwasi_t* uvwasi, uvwasi_fd_t fd) { return err; r = uv_fs_close(NULL, &req, wrap->fd, NULL); + uv_mutex_unlock(&wrap->mutex); uv_fs_req_cleanup(&req); if (r != 0) @@ -640,6 +710,7 @@ uvwasi_errno_t uvwasi_fd_datasync(uvwasi_t* uvwasi, uvwasi_fd_t fd) { return err; r = uv_fs_fdatasync(NULL, &req, wrap->fd, NULL); + uv_mutex_unlock(&wrap->mutex); uv_fs_req_cleanup(&req); if (r != 0) @@ -672,11 +743,15 @@ uvwasi_errno_t uvwasi_fd_fdstat_get(uvwasi_t* uvwasi, buf->fs_flags = 0; /* TODO(cjihrig): Missing Windows support. */ #else r = fcntl(wrap->fd, F_GETFL); - if (r < 0) - return uvwasi__translate_uv_error(uv_translate_sys_error(errno)); + if (r < 0) { + err = uvwasi__translate_uv_error(uv_translate_sys_error(errno)); + uv_mutex_unlock(&wrap->mutex); + return err; + } buf->fs_flags = r; #endif /* _WIN32 */ + uv_mutex_unlock(&wrap->mutex); return UVWASI_ESUCCESS; } @@ -731,9 +806,12 @@ uvwasi_errno_t uvwasi_fd_fdstat_set_flags(uvwasi_t* uvwasi, r = fcntl(wrap->fd, F_SETFL, mapped_flags); if (r < 0) - return uvwasi__translate_uv_error(uv_translate_sys_error(errno)); + err = uvwasi__translate_uv_error(uv_translate_sys_error(errno)); + else + err = UVWASI_ESUCCESS; - return UVWASI_ESUCCESS; + uv_mutex_unlock(&wrap->mutex); + return err; #endif /* _WIN32 */ } @@ -754,16 +832,23 @@ uvwasi_errno_t uvwasi_fd_fdstat_set_rights(uvwasi_t* uvwasi, return err; /* Check for attempts to add new permissions. */ - if ((fs_rights_base | wrap->rights_base) > wrap->rights_base) - return UVWASI_ENOTCAPABLE; + if ((fs_rights_base | wrap->rights_base) > wrap->rights_base) { + err = UVWASI_ENOTCAPABLE; + goto exit; + } + if ((fs_rights_inheriting | wrap->rights_inheriting) > wrap->rights_inheriting) { - return UVWASI_ENOTCAPABLE; + err = UVWASI_ENOTCAPABLE; + goto exit; } wrap->rights_base = fs_rights_base; wrap->rights_inheriting = fs_rights_inheriting; - return UVWASI_ESUCCESS; + err = UVWASI_ESUCCESS; +exit: + uv_mutex_unlock(&wrap->mutex); + return err; } @@ -788,14 +873,16 @@ uvwasi_errno_t uvwasi_fd_filestat_get(uvwasi_t* uvwasi, r = uv_fs_fstat(NULL, &req, wrap->fd, NULL); if (r != 0) { - uv_fs_req_cleanup(&req); - return uvwasi__translate_uv_error(r); + err = uvwasi__translate_uv_error(r); + goto exit; } uvwasi__stat_to_filestat(&req.statbuf, buf); + err = UVWASI_ESUCCESS; +exit: + uv_mutex_unlock(&wrap->mutex); uv_fs_req_cleanup(&req); - - return UVWASI_ESUCCESS; + return err; } @@ -820,6 +907,7 @@ uvwasi_errno_t uvwasi_fd_filestat_set_size(uvwasi_t* uvwasi, return err; r = uv_fs_ftruncate(NULL, &req, wrap->fd, st_size, NULL); + uv_mutex_unlock(&wrap->mutex); uv_fs_req_cleanup(&req); if (r != 0) @@ -858,6 +946,7 @@ uvwasi_errno_t uvwasi_fd_filestat_set_times(uvwasi_t* uvwasi, /* TODO(cjihrig): st_atim and st_mtim should not be unconditionally passed. */ r = uv_fs_futime(NULL, &req, wrap->fd, st_atim, st_mtim, NULL); + uv_mutex_unlock(&wrap->mutex); uv_fs_req_cleanup(&req); if (r != 0) @@ -891,14 +980,17 @@ uvwasi_errno_t uvwasi_fd_pread(uvwasi_t* uvwasi, if (err != UVWASI_ESUCCESS) return err; - err = uvwasi__setup_iovs(&bufs, iovs, iovs_len); - if (err != UVWASI_ESUCCESS) + err = uvwasi__setup_iovs(uvwasi, &bufs, iovs, iovs_len); + if (err != UVWASI_ESUCCESS) { + uv_mutex_unlock(&wrap->mutex); return err; + } r = uv_fs_read(NULL, &req, wrap->fd, bufs, iovs_len, offset, NULL); + uv_mutex_unlock(&wrap->mutex); uvread = req.result; uv_fs_req_cleanup(&req); - free(bufs); + uvwasi__free(uvwasi, bufs); if (r < 0) return uvwasi__translate_uv_error(r); @@ -920,12 +1012,17 @@ uvwasi_errno_t uvwasi_fd_prestat_get(uvwasi_t* uvwasi, err = uvwasi_fd_table_get(&uvwasi->fds, fd, &wrap, 0, 0); if (err != UVWASI_ESUCCESS) return err; - if (wrap->preopen != 1) - return UVWASI_EINVAL; + if (wrap->preopen != 1) { + err = UVWASI_EINVAL; + goto exit; + } buf->pr_type = UVWASI_PREOPENTYPE_DIR; buf->u.dir.pr_name_len = strlen(wrap->path) + 1; - return UVWASI_ESUCCESS; + err = UVWASI_ESUCCESS; +exit: + uv_mutex_unlock(&wrap->mutex); + return err; } @@ -943,15 +1040,22 @@ uvwasi_errno_t uvwasi_fd_prestat_dir_name(uvwasi_t* uvwasi, err = uvwasi_fd_table_get(&uvwasi->fds, fd, &wrap, 0, 0); if (err != UVWASI_ESUCCESS) return err; - if (wrap->preopen != 1) - return UVWASI_EBADF; + if (wrap->preopen != 1) { + err = UVWASI_EBADF; + goto exit; + } size = strlen(wrap->path) + 1; - if (size > path_len) - return UVWASI_ENOBUFS; + if (size > path_len) { + err = UVWASI_ENOBUFS; + goto exit; + } memcpy(path, wrap->path, size); - return UVWASI_ESUCCESS; + err = UVWASI_ESUCCESS; +exit: + uv_mutex_unlock(&wrap->mutex); + return err; } @@ -979,14 +1083,17 @@ uvwasi_errno_t uvwasi_fd_pwrite(uvwasi_t* uvwasi, if (err != UVWASI_ESUCCESS) return err; - err = uvwasi__setup_ciovs(&bufs, iovs, iovs_len); - if (err != UVWASI_ESUCCESS) + err = uvwasi__setup_ciovs(uvwasi, &bufs, iovs, iovs_len); + if (err != UVWASI_ESUCCESS) { + uv_mutex_unlock(&wrap->mutex); return err; + } r = uv_fs_write(NULL, &req, wrap->fd, bufs, iovs_len, offset, NULL); + uv_mutex_unlock(&wrap->mutex); uvwritten = req.result; uv_fs_req_cleanup(&req); - free(bufs); + uvwasi__free(uvwasi, bufs); if (r < 0) return uvwasi__translate_uv_error(r); @@ -1015,14 +1122,17 @@ uvwasi_errno_t uvwasi_fd_read(uvwasi_t* uvwasi, if (err != UVWASI_ESUCCESS) return err; - err = uvwasi__setup_iovs(&bufs, iovs, iovs_len); - if (err != UVWASI_ESUCCESS) + err = uvwasi__setup_iovs(uvwasi, &bufs, iovs, iovs_len); + if (err != UVWASI_ESUCCESS) { + uv_mutex_unlock(&wrap->mutex); return err; + } r = uv_fs_read(NULL, &req, wrap->fd, bufs, iovs_len, -1, NULL); + uv_mutex_unlock(&wrap->mutex); uvread = req.result; uv_fs_req_cleanup(&req); - free(bufs); + uvwasi__free(uvwasi, bufs); if (r < 0) return uvwasi__translate_uv_error(r); @@ -1066,8 +1176,10 @@ uvwasi_errno_t uvwasi_fd_readdir(uvwasi_t* uvwasi, /* Open the directory. */ r = uv_fs_opendir(NULL, &req, wrap->real_path, NULL); - if (r != 0) + if (r != 0) { + uv_mutex_unlock(&wrap->mutex); return uvwasi__translate_uv_error(r); + } /* Setup for reading the directory. */ dir = req.ptr; @@ -1161,6 +1273,7 @@ uvwasi_errno_t uvwasi_fd_readdir(uvwasi_t* uvwasi, exit: /* Close the directory. */ r = uv_fs_closedir(NULL, &req, dir, NULL); + uv_mutex_unlock(&wrap->mutex); uv_fs_req_cleanup(&req); if (r != 0) return uvwasi__translate_uv_error(r); @@ -1181,22 +1294,31 @@ uvwasi_errno_t uvwasi_fd_renumber(uvwasi_t* uvwasi, if (uvwasi == NULL) return UVWASI_EINVAL; + if (from == to) + return UVWASI_ESUCCESS; + err = uvwasi_fd_table_get(&uvwasi->fds, from, &from_wrap, 0, 0); if (err != UVWASI_ESUCCESS) return err; err = uvwasi_fd_table_get(&uvwasi->fds, to, &to_wrap, 0, 0); - if (err != UVWASI_ESUCCESS) + if (err != UVWASI_ESUCCESS) { + uv_mutex_unlock(&from_wrap->mutex); return err; + } r = uv_fs_close(NULL, &req, to_wrap->fd, NULL); uv_fs_req_cleanup(&req); - if (r != 0) + if (r != 0) { + uv_mutex_unlock(&from_wrap->mutex); + uv_mutex_unlock(&to_wrap->mutex); return uvwasi__translate_uv_error(r); + } memcpy(to_wrap, from_wrap, sizeof(*to_wrap)); to_wrap->id = to; - + uv_mutex_unlock(&from_wrap->mutex); + uv_mutex_unlock(&to_wrap->mutex); return uvwasi_fd_table_remove(&uvwasi->fds, from); } @@ -1216,7 +1338,9 @@ uvwasi_errno_t uvwasi_fd_seek(uvwasi_t* uvwasi, if (err != UVWASI_ESUCCESS) return err; - return uvwasi__lseek(wrap->fd, offset, whence, newoffset); + err = uvwasi__lseek(wrap->fd, offset, whence, newoffset); + uv_mutex_unlock(&wrap->mutex); + return err; } @@ -1238,6 +1362,7 @@ uvwasi_errno_t uvwasi_fd_sync(uvwasi_t* uvwasi, uvwasi_fd_t fd) { return err; r = uv_fs_fsync(NULL, &req, wrap->fd, NULL); + uv_mutex_unlock(&wrap->mutex); uv_fs_req_cleanup(&req); if (r != 0) @@ -1260,7 +1385,9 @@ uvwasi_errno_t uvwasi_fd_tell(uvwasi_t* uvwasi, if (err != UVWASI_ESUCCESS) return err; - return uvwasi__lseek(wrap->fd, 0, UVWASI_WHENCE_CUR, offset); + err = uvwasi__lseek(wrap->fd, 0, UVWASI_WHENCE_CUR, offset); + uv_mutex_unlock(&wrap->mutex); + return err; } @@ -1283,14 +1410,17 @@ uvwasi_errno_t uvwasi_fd_write(uvwasi_t* uvwasi, if (err != UVWASI_ESUCCESS) return err; - err = uvwasi__setup_ciovs(&bufs, iovs, iovs_len); - if (err != UVWASI_ESUCCESS) + err = uvwasi__setup_ciovs(uvwasi, &bufs, iovs, iovs_len); + if (err != UVWASI_ESUCCESS) { + uv_mutex_unlock(&wrap->mutex); return err; + } r = uv_fs_write(NULL, &req, wrap->fd, bufs, iovs_len, -1, NULL); + uv_mutex_unlock(&wrap->mutex); uvwritten = req.result; uv_fs_req_cleanup(&req); - free(bufs); + uvwasi__free(uvwasi, bufs); if (r < 0) return uvwasi__translate_uv_error(r); @@ -1321,17 +1451,22 @@ uvwasi_errno_t uvwasi_path_create_directory(uvwasi_t* uvwasi, if (err != UVWASI_ESUCCESS) return err; - err = uvwasi__resolve_path(wrap, path, path_len, resolved_path, 0); + err = uvwasi__resolve_path(uvwasi, wrap, path, path_len, resolved_path, 0); if (err != UVWASI_ESUCCESS) - return err; + goto exit; r = uv_fs_mkdir(NULL, &req, resolved_path, 0777, NULL); uv_fs_req_cleanup(&req); - if (r != 0) - return uvwasi__translate_uv_error(r); + if (r != 0) { + err = uvwasi__translate_uv_error(r); + goto exit; + } - return UVWASI_ESUCCESS; + err = UVWASI_ESUCCESS; +exit: + uv_mutex_unlock(&wrap->mutex); + return err; } @@ -1358,20 +1493,28 @@ uvwasi_errno_t uvwasi_path_filestat_get(uvwasi_t* uvwasi, if (err != UVWASI_ESUCCESS) return err; - err = uvwasi__resolve_path(wrap, path, path_len, resolved_path, flags); + err = uvwasi__resolve_path(uvwasi, + wrap, + path, + path_len, + resolved_path, + flags); if (err != UVWASI_ESUCCESS) - return err; + goto exit; r = uv_fs_stat(NULL, &req, resolved_path, NULL); if (r != 0) { uv_fs_req_cleanup(&req); - return uvwasi__translate_uv_error(r); + err = uvwasi__translate_uv_error(r); + goto exit; } uvwasi__stat_to_filestat(&req.statbuf, buf); uv_fs_req_cleanup(&req); - - return UVWASI_ESUCCESS; + err = UVWASI_ESUCCESS; +exit: + uv_mutex_unlock(&wrap->mutex); + return err; } @@ -1406,18 +1549,28 @@ uvwasi_errno_t uvwasi_path_filestat_set_times(uvwasi_t* uvwasi, if (err != UVWASI_ESUCCESS) return err; - err = uvwasi__resolve_path(wrap, path, path_len, resolved_path, flags); + err = uvwasi__resolve_path(uvwasi, + wrap, + path, + path_len, + resolved_path, + flags); if (err != UVWASI_ESUCCESS) - return err; + goto exit; /* TODO(cjihrig): st_atim and st_mtim should not be unconditionally passed. */ r = uv_fs_utime(NULL, &req, resolved_path, st_atim, st_mtim, NULL); uv_fs_req_cleanup(&req); - if (r != 0) - return uvwasi__translate_uv_error(r); + if (r != 0) { + err = uvwasi__translate_uv_error(r); + goto exit; + } - return UVWASI_ESUCCESS; + err = UVWASI_ESUCCESS; +exit: + uv_mutex_unlock(&wrap->mutex); + return err; } @@ -1440,44 +1593,68 @@ uvwasi_errno_t uvwasi_path_link(uvwasi_t* uvwasi, if (uvwasi == NULL || old_path == NULL || new_path == NULL) return UVWASI_EINVAL; - err = uvwasi_fd_table_get(&uvwasi->fds, - old_fd, - &old_wrap, - UVWASI_RIGHT_PATH_LINK_SOURCE, - 0); - if (err != UVWASI_ESUCCESS) - return err; + if (old_fd == new_fd) { + err = uvwasi_fd_table_get(&uvwasi->fds, + old_fd, + &old_wrap, + UVWASI_RIGHT_PATH_LINK_SOURCE | + UVWASI_RIGHT_PATH_LINK_TARGET, + 0); + if (err != UVWASI_ESUCCESS) + return err; - err = uvwasi_fd_table_get(&uvwasi->fds, - new_fd, - &new_wrap, - UVWASI_RIGHT_PATH_LINK_TARGET, - 0); - if (err != UVWASI_ESUCCESS) - return err; + new_wrap = old_wrap; + } else { + err = uvwasi_fd_table_get(&uvwasi->fds, + old_fd, + &old_wrap, + UVWASI_RIGHT_PATH_LINK_SOURCE, + 0); + if (err != UVWASI_ESUCCESS) + return err; + + err = uvwasi_fd_table_get(&uvwasi->fds, + new_fd, + &new_wrap, + UVWASI_RIGHT_PATH_LINK_TARGET, + 0); + if (err != UVWASI_ESUCCESS) { + uv_mutex_unlock(&old_wrap->mutex); + return err; + } + } - err = uvwasi__resolve_path(old_wrap, + err = uvwasi__resolve_path(uvwasi, + old_wrap, old_path, old_path_len, resolved_old_path, old_flags); if (err != UVWASI_ESUCCESS) - return err; + goto exit; - err = uvwasi__resolve_path(new_wrap, + err = uvwasi__resolve_path(uvwasi, + new_wrap, new_path, new_path_len, resolved_new_path, 0); if (err != UVWASI_ESUCCESS) - return err; + goto exit; r = uv_fs_link(NULL, &req, resolved_old_path, resolved_new_path, NULL); uv_fs_req_cleanup(&req); - if (r != 0) - return uvwasi__translate_uv_error(r); + if (r != 0) { + err = uvwasi__translate_uv_error(r); + goto exit; + } - return UVWASI_ESUCCESS; + err = UVWASI_ESUCCESS; +exit: + uv_mutex_unlock(&old_wrap->mutex); + if (old_fd != new_fd) + uv_mutex_unlock(&new_wrap->mutex); + return err; } @@ -1560,39 +1737,49 @@ uvwasi_errno_t uvwasi_path_open(uvwasi_t* uvwasi, if (err != UVWASI_ESUCCESS) return err; - err = uvwasi__resolve_path(dirfd_wrap, + err = uvwasi__resolve_path(uvwasi, + dirfd_wrap, path, path_len, resolved_path, dirflags); - if (err != UVWASI_ESUCCESS) + if (err != UVWASI_ESUCCESS) { + uv_mutex_unlock(&dirfd_wrap->mutex); return err; + } r = uv_fs_open(NULL, &req, resolved_path, flags, 0666, NULL); uv_fs_req_cleanup(&req); - if (r < 0) + if (r < 0) { + uv_mutex_unlock(&dirfd_wrap->mutex); return uvwasi__translate_uv_error(r); + } - err = uvwasi_fd_table_insert_fd(&uvwasi->fds, + err = uvwasi_fd_table_insert_fd(uvwasi, + &uvwasi->fds, r, flags, resolved_path, fs_rights_base, fs_rights_inheriting, &wrap); - if (err != UVWASI_ESUCCESS) + if (err != UVWASI_ESUCCESS) { + uv_mutex_unlock(&dirfd_wrap->mutex); goto close_file_and_error_exit; + } /* Not all platforms support UV_FS_O_DIRECTORY, so enforce it here as well. */ if ((o_flags & UVWASI_O_DIRECTORY) != 0 && wrap.type != UVWASI_FILETYPE_DIRECTORY) { + uv_mutex_unlock(&dirfd_wrap->mutex); uvwasi_fd_table_remove(&uvwasi->fds, wrap.id); err = UVWASI_ENOTDIR; goto close_file_and_error_exit; } *fd = wrap.id; + uv_mutex_unlock(&dirfd_wrap->mutex); return UVWASI_ESUCCESS; close_file_and_error_exit: @@ -1627,11 +1814,14 @@ uvwasi_errno_t uvwasi_path_readlink(uvwasi_t* uvwasi, if (err != UVWASI_ESUCCESS) return err; - err = uvwasi__resolve_path(wrap, path, path_len, resolved_path, 0); - if (err != UVWASI_ESUCCESS) + err = uvwasi__resolve_path(uvwasi, wrap, path, path_len, resolved_path, 0); + if (err != UVWASI_ESUCCESS) { + uv_mutex_unlock(&wrap->mutex); return err; + } r = uv_fs_readlink(NULL, &req, resolved_path, NULL); + uv_mutex_unlock(&wrap->mutex); if (r != 0) { uv_fs_req_cleanup(&req); return uvwasi__translate_uv_error(r); @@ -1672,11 +1862,14 @@ uvwasi_errno_t uvwasi_path_remove_directory(uvwasi_t* uvwasi, if (err != UVWASI_ESUCCESS) return err; - err = uvwasi__resolve_path(wrap, path, path_len, resolved_path, 0); - if (err != UVWASI_ESUCCESS) + err = uvwasi__resolve_path(uvwasi, wrap, path, path_len, resolved_path, 0); + if (err != UVWASI_ESUCCESS) { + uv_mutex_unlock(&wrap->mutex); return err; + } r = uv_fs_rmdir(NULL, &req, resolved_path, NULL); + uv_mutex_unlock(&wrap->mutex); uv_fs_req_cleanup(&req); if (r != 0) @@ -1704,44 +1897,68 @@ uvwasi_errno_t uvwasi_path_rename(uvwasi_t* uvwasi, if (uvwasi == NULL || old_path == NULL || new_path == NULL) return UVWASI_EINVAL; - err = uvwasi_fd_table_get(&uvwasi->fds, - old_fd, - &old_wrap, - UVWASI_RIGHT_PATH_RENAME_SOURCE, - 0); - if (err != UVWASI_ESUCCESS) - return err; - - err = uvwasi_fd_table_get(&uvwasi->fds, - new_fd, - &new_wrap, - UVWASI_RIGHT_PATH_RENAME_TARGET, - 0); - if (err != UVWASI_ESUCCESS) - return err; + if (old_fd == new_fd) { + err = uvwasi_fd_table_get(&uvwasi->fds, + old_fd, + &old_wrap, + UVWASI_RIGHT_PATH_RENAME_SOURCE | + UVWASI_RIGHT_PATH_RENAME_TARGET, + 0); + if (err != UVWASI_ESUCCESS) + return err; + new_wrap = old_wrap; + } else { + err = uvwasi_fd_table_get(&uvwasi->fds, + old_fd, + &old_wrap, + UVWASI_RIGHT_PATH_RENAME_SOURCE, + 0); + if (err != UVWASI_ESUCCESS) + return err; + + err = uvwasi_fd_table_get(&uvwasi->fds, + new_fd, + &new_wrap, + UVWASI_RIGHT_PATH_RENAME_TARGET, + 0); + if (err != UVWASI_ESUCCESS) { + uv_mutex_unlock(&old_wrap->mutex); + return err; + } + } - err = uvwasi__resolve_path(old_wrap, + err = uvwasi__resolve_path(uvwasi, + old_wrap, old_path, old_path_len, resolved_old_path, 0); if (err != UVWASI_ESUCCESS) - return err; + goto exit; - err = uvwasi__resolve_path(new_wrap, + err = uvwasi__resolve_path(uvwasi, + new_wrap, new_path, new_path_len, resolved_new_path, 0); if (err != UVWASI_ESUCCESS) - return err; + goto exit; r = uv_fs_rename(NULL, &req, resolved_old_path, resolved_new_path, NULL); uv_fs_req_cleanup(&req); - if (r != 0) - return uvwasi__translate_uv_error(r); + if (r != 0) { + err = uvwasi__translate_uv_error(r); + goto exit; + } - return UVWASI_ESUCCESS; + err = UVWASI_ESUCCESS; +exit: + uv_mutex_unlock(&old_wrap->mutex); + if (old_fd != new_fd) + uv_mutex_unlock(&new_wrap->mutex); + + return err; } @@ -1768,16 +1985,20 @@ uvwasi_errno_t uvwasi_path_symlink(uvwasi_t* uvwasi, if (err != UVWASI_ESUCCESS) return err; - err = uvwasi__resolve_path(wrap, + err = uvwasi__resolve_path(uvwasi, + wrap, new_path, new_path_len, resolved_new_path, 0); - if (err != UVWASI_ESUCCESS) + if (err != UVWASI_ESUCCESS) { + uv_mutex_unlock(&wrap->mutex); return err; + } /* Windows support may require setting the flags option. */ r = uv_fs_symlink(NULL, &req, old_path, resolved_new_path, 0, NULL); + uv_mutex_unlock(&wrap->mutex); uv_fs_req_cleanup(&req); if (r != 0) return uvwasi__translate_uv_error(r); @@ -1807,11 +2028,14 @@ uvwasi_errno_t uvwasi_path_unlink_file(uvwasi_t* uvwasi, if (err != UVWASI_ESUCCESS) return err; - err = uvwasi__resolve_path(wrap, path, path_len, resolved_path, 0); - if (err != UVWASI_ESUCCESS) + err = uvwasi__resolve_path(uvwasi, wrap, path, path_len, resolved_path, 0); + if (err != UVWASI_ESUCCESS) { + uv_mutex_unlock(&wrap->mutex); return err; + } r = uv_fs_unlink(NULL, &req, resolved_path, NULL); + uv_mutex_unlock(&wrap->mutex); uv_fs_req_cleanup(&req); if (r != 0) diff --git a/deps/uvwasi/src/uvwasi_alloc.h b/deps/uvwasi/src/uvwasi_alloc.h new file mode 100644 index 00000000000000..1486f313911b01 --- /dev/null +++ b/deps/uvwasi/src/uvwasi_alloc.h @@ -0,0 +1,11 @@ +#ifndef __UVWASI_ALLOC_H__ +#define __UVWASI_ALLOC_H__ + +#include "uvwasi.h" + +void* uvwasi__malloc(const uvwasi_t* uvwasi, size_t size); +void uvwasi__free(const uvwasi_t* uvwasi, void* ptr); +void* uvwasi__calloc(const uvwasi_t* uvwasi, size_t nmemb, size_t size); +void* uvwasi__realloc(const uvwasi_t* uvwasi, void* ptr, size_t size); + +#endif diff --git a/doc/STYLE_GUIDE.md b/doc/STYLE_GUIDE.md index 6f98ad1fc8fb4e..9784787428dbf1 100644 --- a/doc/STYLE_GUIDE.md +++ b/doc/STYLE_GUIDE.md @@ -55,9 +55,9 @@ * OK: JavaScript, Google's V8 * NOT OK: Javascript, Google's v8 - * Use _Node.js_ and not _Node_, _NodeJS_, or similar variants. + * When referring to the executable, _`node`_ is acceptable. See also API documentation structure overview in [doctools README][]. diff --git a/doc/api/addons.md b/doc/api/addons.md index 6e5e9bf18c8418..8b17d6b417b8e8 100644 --- a/doc/api/addons.md +++ b/doc/api/addons.md @@ -3,10 +3,9 @@ -Node.js Addons are dynamically-linked shared objects, written in C++, that -can be loaded into Node.js using the [`require()`][require] function, and used -just as if they were an ordinary Node.js module. They are used primarily to -provide an interface between JavaScript running in Node.js and C/C++ libraries. +Addons are dynamically-linked shared objects written in C++. The +[`require()`][require] function can load Addons as ordinary Node.js modules. +Addons provide an interface between JavaScript and C/C++ libraries. There are three options for implementing Addons: N-API, nan, or direct use of internal V8, libuv and Node.js libraries. Unless you need direct diff --git a/doc/api/assert.md b/doc/api/assert.md index b0c8c378e64b9b..9d1a7fb7e169ea 100644 --- a/doc/api/assert.md +++ b/doc/api/assert.md @@ -80,9 +80,9 @@ changes: description: Added strict mode to the assert module. --> -In `strict` mode, `assert` functions use the comparison in the corresponding -strict functions. For example, [`assert.deepEqual()`][] will behave like -[`assert.deepStrictEqual()`][]. +In `strict` mode (not to be confused with `"use strict"`), `assert` functions +use the comparison in the corresponding strict functions. For example, +[`assert.deepEqual()`][] will behave like [`assert.deepStrictEqual()`][]. In `strict` mode, error messages for objects display a diff. In legacy mode, error messages for objects display the objects, often truncated. diff --git a/doc/api/buffer.md b/doc/api/buffer.md index a97ab6c2a6314b..c5b7bf15047177 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -2162,6 +2162,8 @@ added: v0.1.90 Decodes `buf` to a string according to the specified character encoding in `encoding`. `start` and `end` may be passed to decode only a subset of `buf`. +If a byte sequence in the input is not valid in the given `encoding` then +it is replaced with the replacement character `U+FFFD`. The maximum length of a string instance (in UTF-16 code units) is available as [`buffer.constants.MAX_STRING_LENGTH`][]. diff --git a/doc/api/cli.md b/doc/api/cli.md index ad8f86f86121b4..3e7ccc1133c858 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -156,20 +156,6 @@ Enable experimental Source Map V3 support for stack traces. Currently, overriding `Error.prepareStackTrace` is ignored when the `--enable-source-maps` flag is set. -### `--es-module-specifier-resolution=mode` - - -Sets the resolution algorithm for resolving ES module specifiers. Valid options -are `explicit` and `node`. - -The default is `explicit`, which requires providing the full path to a -module. The `node` mode will enable support for optional file extensions and -the ability to import a directory that has an index file. - -Please see [customizing ESM specifier resolution][] for example usage. - ### `--experimental-conditional-exports` + +Sets the resolution algorithm for resolving ES module specifiers. Valid options +are `explicit` and `node`. + +The default is `explicit`, which requires providing the full path to a +module. The `node` mode will enable support for optional file extensions and +the ability to import a directory that has an index file. + +Please see [customizing ESM specifier resolution][] for example usage. + ### `--experimental-vm-modules` + +Use an insecure HTTP parser that accepts invalid HTTP headers. This may allow +interoperability with non-conformant HTTP implementations. It may also allow +request smuggling and other HTTP attacks that rely on invalid headers being +accepted. Avoid using this option. + ### `--max-http-header-size=size` * `--enable-fips` * `--enable-source-maps` -* `--es-module-specifier-resolution` * `--experimental-conditional-exports` * `--experimental-json-modules` * `--experimental-loader` @@ -1054,6 +1063,7 @@ Node.js options that are allowed are: * `--experimental-repl-await` * `--experimental-report` * `--experimental-resolve-self` +* `--experimental-specifier-resolution` * `--experimental-vm-modules` * `--experimental-wasi-unstable-preview0` * `--experimental-wasm-modules` @@ -1064,6 +1074,7 @@ Node.js options that are allowed are: * `--http-parser` * `--icu-data-dir` * `--input-type` +* `--insecure-http-parser` * `--inspect-brk` * `--inspect-port`, `--debug-port` * `--inspect-publish-uid` diff --git a/doc/api/console.md b/doc/api/console.md index 45b8dad997873d..00072793adb496 100644 --- a/doc/api/console.md +++ b/doc/api/console.md @@ -99,8 +99,9 @@ changes: * `ignoreErrors` {boolean} Ignore errors when writing to the underlying streams. **Default:** `true`. * `colorMode` {boolean|string} Set color support for this `Console` instance. - Setting to `true` enables coloring while inspecting values, setting to - `'auto'` will make color support depend on the value of the `isTTY` property + Setting to `true` enables coloring while inspecting values. Setting to + `false` disables coloring while inspecting values. Setting to + `'auto'` makes color support depend on the value of the `isTTY` property and the value returned by `getColorDepth()` on the respective stream. This option can not be used, if `inspectOptions.colors` is set as well. **Default:** `'auto'`. diff --git a/doc/api/crypto.md b/doc/api/crypto.md index 6bf1dcea365d93..5de68740aa3fe8 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -284,7 +284,7 @@ once will result in an error being thrown. added: v1.0.0 --> -* `buffer` {Buffer} +* `buffer` {Buffer | TypedArray | DataView} * `options` {Object} [`stream.transform` options][] * `plaintextLength` {number} * Returns: {Cipher} for method chaining. diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index 50303baa78207f..a73d184993660d 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -2548,6 +2548,27 @@ APIs that do not make sense to use in userland. File streams should always be opened through their corresponding factory methods [`fs.createWriteStream()`][] and [`fs.createReadStream()`][]) or by passing a file descriptor in options. + +### DEP0136: http finished + + +Type: Documentation-only + +[`response.finished`][] indicates whether [`response.end()`][] has been +called, not whether `'finish'` has been emitted and the underlying data +is flushed. + +Use [`response.writableFinished`][] or [`response.writableEnded`][] +accordingly instead to avoid the ambigiuty. + +To maintain existing behaviour `response.finished` should be replaced with +`response.writableEnded`. + [`--pending-deprecation`]: cli.html#cli_pending_deprecation [`--throw-deprecation`]: cli.html#cli_throw_deprecation [`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_class_method_buffer_allocunsafeslow_size @@ -2610,6 +2631,10 @@ and [`fs.createReadStream()`][]) or by passing a file descriptor in options. [`request.connection`]: http.html#http_request_connection [`response.socket`]: http.html#http_response_socket [`response.connection`]: http.html#http_response_connection +[`response.end()`]: http.html#http_response_end_data_encoding_callback +[`response.finished`]: #http_response_finished +[`response.writableFinished`]: #http_response_writablefinished +[`response.writableEnded`]: #http_response_writableended [`script.createCachedData()`]: vm.html#vm_script_createcacheddata [`setInterval()`]: timers.html#timers_setinterval_callback_delay_args [`setTimeout()`]: timers.html#timers_settimeout_callback_delay_args diff --git a/doc/api/esm.md b/doc/api/esm.md index 93b89adec12a98..5245cef465e3c7 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -329,8 +329,8 @@ Node.js and the browser can be written: "main": "./index.js", "exports": { "./feature": { - "browser": "./feature-browser.js", - "default": "./feature-default.js" + "import": "./feature-default.js", + "browser": "./feature-browser.js" } } } @@ -341,16 +341,24 @@ will be used as the final fallback. The conditions supported in Node.js are matched in the following order: -1. `"require"` - matched when the package is loaded via `require()`. - _This is currently only supported behind the - `--experimental-conditional-exports` flag._ -2. `"node"` - matched for any Node.js environment. Can be a CommonJS or ES +1. `"node"` - matched for any Node.js environment. Can be a CommonJS or ES module file. _This is currently only supported behind the - `--experimental-conditional-exports` flag._ -3. `"default"` - the generic fallback that will always match if no other + `--experimental-conditional-exports` flag._ +2. `"require"` - matched when the package is loaded via `require()`. + _This is currently only supported behind the + `--experimental-conditional-exports` flag._ +3. `"import"` - matched when the package is loaded via `import` or + `import()`. Can be any module format, this field does not set the type + interpretation. _This is currently only supported behind the + `--experimental-conditional-exports` flag._ +4. `"default"` - the generic fallback that will always match if no other more specific condition is matched first. Can be a CommonJS or ES module file. +> Setting any of the above flagged conditions for a published package is not +> recommended until they are unflagged to avoid breaking changes to packages in +> future. + Using the `"require"` condition it is possible to define a package that will have a different exported value for CommonJS and ES modules, which can be a hazard in that it can result in having two separate instances of the same @@ -394,8 +402,8 @@ from exports subpaths. { "exports": { ".": { - "require": "./main.cjs", - "default": "./main.js" + "import": "./main.js", + "require": "./main.cjs" } } } @@ -407,8 +415,8 @@ can be written: ```js { "exports": { - "require": "./main.cjs", - "default": "./main.js" + "import": "./main.js", + "require": "./main.cjs" } } ``` @@ -422,8 +430,8 @@ thrown: // Throws on resolution! "exports": { "./feature": "./lib/feature.js", - "require": "./main.cjs", - "default": "./main.js" + "import": "./main.js", + "require": "./main.cjs" } } ``` @@ -508,9 +516,8 @@ ES module wrapper is used for `import` and the CommonJS entry point for `require`. > Note: While `--experimental-conditional-exports` is flagged, a package -> using this pattern will throw when loaded via `require()` in modern -> Node.js, unless package consumers use the `--experimental-conditional-exports` -> flag. +> using this pattern will throw when loaded unless package consumers use the +> `--experimental-conditional-exports` flag. ```js @@ -520,7 +527,7 @@ ES module wrapper is used for `import` and the CommonJS entry point for "main": "./index.cjs", "exports": { "require": "./index.cjs", - "default": "./wrapper.mjs" + "import": "./wrapper.mjs" } } ``` @@ -605,8 +612,8 @@ CommonJS and ES module entry points directly (requires "type": "module", "main": "./index.cjs", "exports": { - "require": "./index.cjs", - "default": "./index.mjs" + "import": "./index.mjs", + "require": "./index.cjs" } } ``` @@ -1149,7 +1156,7 @@ of these top-level routines unless stated otherwise. _isMain_ is **true** when resolving the Node.js application entry point. _defaultEnv_ is the conditional environment name priority array, -`["node", "default"]`. +`["node", "import"]`.
    Resolver algorithm specification @@ -1372,7 +1379,7 @@ the CommonJS loader. One of the behavior differences is automatic resolution of file extensions and the ability to import directories that have an index file. -The `--es-module-specifier-resolution=[mode]` flag can be used to customize +The `--experimental-specifier-resolution=[mode]` flag can be used to customize the extension resolution algorithm. The default mode is `explicit`, which requires the full path to a module be provided to the loader. To enable the automatic extension resolution and importing from directories that include an @@ -1383,7 +1390,7 @@ $ node index.mjs success! $ node index # Failure! Error: Cannot find module -$ node --es-module-specifier-resolution=node index +$ node --experimental-specifier-resolution=node index success! ``` diff --git a/doc/api/events.md b/doc/api/events.md index ec6f608609073f..434d8de8b57cc7 100644 --- a/doc/api/events.md +++ b/doc/api/events.md @@ -155,9 +155,66 @@ myEmitter.emit('error', new Error('whoops!')); // Prints: whoops! there was an error ``` +## Capture Rejections of Promises + +> Stability: 1 - captureRejections is experimental. + +Using `async` functions with event handlers is problematic, because it +can lead to an unhandled rejection in case of a thrown exception: + +```js +const ee = new EventEmitter(); +ee.on('something', async (value) => { + throw new Error('kaboom'); +}); +``` + +The `captureRejections` option in the `EventEmitter` constructor or the global +setting change this behavior, installing a `.then(undefined, handler)` +handler on the `Promise`. This handler routes the exception +asynchronously to the [`Symbol.for('nodejs.rejection')`][rejection] method +if there is one, or to [`'error'`][error] event handler if there is none. + +```js +const ee1 = new EventEmitter({ captureRejections: true }); +ee1.on('something', async (value) => { + throw new Error('kaboom'); +}); + +ee1.on('error', console.log); + +const ee2 = new EventEmitter({ captureRejections: true }); +ee2.on('something', async (value) => { + throw new Error('kaboom'); +}); + +ee2[Symbol.for('nodejs.rejection')] = console.log; +``` + +Setting `EventEmitter.captureRejections = true` will change the default for all +new instances of `EventEmitter`. + +```js +EventEmitter.captureRejections = true; +const ee1 = new EventEmitter(); +ee1.on('something', async (value) => { + throw new Error('kaboom'); +}); + +ee1.on('error', console.log); +``` + +The `'error'` events that are generated by the `captureRejections` behavior +do not have a catch handler to avoid infinite error loops: the +recommendation is to **not use `async` functions as `'error'` event handlers**. + ## Class: EventEmitter The `EventEmitter` class is defined and exposed by the `events` module: @@ -169,6 +226,12 @@ const EventEmitter = require('events'); All `EventEmitter`s emit the event `'newListener'` when new listeners are added and `'removeListener'` when existing listeners are removed. +It supports the following option: + +* `captureRejections` {boolean} It enables + [automatic capturing of promise rejection][capturerejections]. + Default: `false`. + ### Event: 'newListener' + +> Stability: 1 - captureRejections is experimental. + +* `err` Error +* `eventName` {string|symbol} +* `...args` {any} + +The `Symbol.for('nodejs.rejection')` method is called in case a +promise rejection happens when emitting an event and +[`captureRejections`][capturerejections] is enabled on the emitter. +It is possible to use [`events.captureRejectionSymbol`][rejectionsymbol] in +place of `Symbol.for('nodejs.rejection')`. + +```js +const { EventEmitter, captureRejectionSymbol } = require('events'); + +class MyClass extends EventEmitter { + constructor() { + super({ captureRejections: true }); + } + + [captureRejectionSymbol](err, event, ...args) { + console.log('rejection happened for', event, 'with', err, ...args); + this.destroy(err); + } + + destroy(err) { + // Tear the resource down here. + } +} +``` + ## events.once(emitter, name) + +> Stability: 1 - captureRejections is experimental. + +Value: {boolean} + +Change the default `captureRejections` option on all new `EventEmitter` objects. + +## events.captureRejectionSymbol + + +> Stability: 1 - captureRejections is experimental. + +Value: `Symbol.for('nodejs.rejection')` + +See how to write a custom [rejection handler][rejection]. + [WHATWG-EventTarget]: https://dom.spec.whatwg.org/#interface-eventtarget [`--trace-warnings`]: cli.html#cli_trace_warnings [`EventEmitter.defaultMaxListeners`]: #events_eventemitter_defaultmaxlisteners @@ -751,3 +872,7 @@ run(); [`net.Server`]: net.html#net_class_net_server [`process.on('warning')`]: process.html#process_event_warning [stream]: stream.html +[capturerejections]: #events_capture_rejections_of_promises +[rejection]: #events_emitter_symbol_for_nodejs_rejection_err_eventname_args +[rejectionsymbol]: #events_events_capturerejectionsymbol +[error]: #events_error_events diff --git a/doc/api/fs.md b/doc/api/fs.md index 9a91f9f22082e0..643efaae03395d 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -3473,10 +3473,10 @@ completion callback. The `type` argument is only available on Windows and ignored on other platforms. It can be set to `'dir'`, `'file'`, or `'junction'`. If the `type` argument is -not set, Node will autodetect `target` type and use `'file'` or `'dir'`. If the -`target` does not exist, `'file'` will be used. Windows junction points require -the destination path to be absolute. When using `'junction'`, the `target` -argument will automatically be normalized to absolute path. +not set, Node.js will autodetect `target` type and use `'file'` or `'dir'`. If +the `target` does not exist, `'file'` will be used. Windows junction points +require the destination path to be absolute. When using `'junction'`, the +`target` argument will automatically be normalized to absolute path. Relative targets are relative to the link’s parent directory. diff --git a/doc/api/http.md b/doc/api/http.md index 007bbbf5640700..5636a4e1f154ec 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -623,8 +623,11 @@ is finished. ### request.finished +> Stability: 0 - Deprecated. Use [`request.writableEnded`][]. + * {boolean} The `request.finished` property will be `true` if [`request.end()`][] @@ -1305,8 +1308,11 @@ is finished. ### response.finished +> Stability: 0 - Deprecated. Use [`response.writableEnded`][]. + * {boolean} The `response.finished` property will be `true` if [`response.end()`][] @@ -2417,12 +2423,14 @@ not abort the request or do anything besides add a `'timeout'` event. [`request.socket.getPeerCertificate()`]: tls.html#tls_tlssocket_getpeercertificate_detailed [`request.socket`]: #http_request_socket [`request.writableFinished`]: #http_request_writablefinished +[`request.writableEnded`]: #http_request_writableended [`request.write(data, encoding)`]: #http_request_write_chunk_encoding_callback [`response.end()`]: #http_response_end_data_encoding_callback [`response.getHeader()`]: #http_response_getheader_name [`response.setHeader()`]: #http_response_setheader_name_value [`response.socket`]: #http_response_socket [`response.writableFinished`]: #http_response_writablefinished +[`response.writableEnded`]: #http_response_writableended [`response.write()`]: #http_response_write_chunk_encoding_callback [`response.write(data, encoding)`]: #http_response_write_chunk_encoding_callback [`response.writeContinue()`]: #http_response_writecontinue diff --git a/doc/api/http2.md b/doc/api/http2.md index 8339593c13a9cb..f4781fa9965d86 100644 --- a/doc/api/http2.md +++ b/doc/api/http2.md @@ -970,6 +970,11 @@ an `Http2Stream`. added: v8.4.0 --> +* `type` {integer} The frame type. +* `code` {integer} The error code. +* `id` {integer} The stream id (or `0` if the frame isn't associated with a + stream). + The `'frameError'` event is emitted when an error occurs while attempting to send a frame. When invoked, the handler function will receive an integer argument identifying the frame type, and an integer argument identifying the @@ -984,12 +989,16 @@ added: v8.4.0 The `'timeout'` event is emitted after no activity is received for this `Http2Stream` within the number of milliseconds set using `http2stream.setTimeout()`. +Its listener does not expect any arguments. #### Event: 'trailers' +* `headers` {HTTP/2 Headers Object} An object describing the headers +* `flags` {number} The associated numeric flags + The `'trailers'` event is emitted when a block of headers associated with trailing header fields is received. The listener callback is passed the [HTTP/2 Headers Object][] and flags associated with the headers. @@ -3066,8 +3075,11 @@ is finished. #### response.finished +> Stability: 0 - Deprecated. Use [`response.writableEnded`][]. + * {boolean} Boolean value that indicates whether the response has completed. Starts @@ -3550,6 +3562,7 @@ following additional properties: [`response.end()`]: #http2_response_end_data_encoding_callback [`response.setHeader()`]: #http2_response_setheader_name_value [`response.socket`]: #http2_response_socket +[`response.writableEnded`]: #http2_response_writableended [`response.write()`]: #http2_response_write_chunk_encoding_callback [`response.write(data, encoding)`]: http.html#http_response_write_chunk_encoding_callback [`response.writeContinue()`]: #http2_response_writecontinue diff --git a/doc/api/inspector.md b/doc/api/inspector.md index 41d96a0024e934..b2b08160e83f9d 100644 --- a/doc/api/inspector.md +++ b/doc/api/inspector.md @@ -52,6 +52,21 @@ parameter usage. Return the URL of the active inspector, or `undefined` if there is none. +```console +$ node --inspect -p 'inspector.url()' +Debugger listening on ws://127.0.0.1:9229/166e272e-7a30-4d09-97ce-f1c012b43c34 +For help see https://nodejs.org/en/docs/inspector +ws://127.0.0.1:9229/166e272e-7a30-4d09-97ce-f1c012b43c34 + +$ node --inspect=localhost:3000 -p 'inspector.url()' +Debugger listening on ws://localhost:3000/51cf8d0e-3c36-4c59-8efd-54519839e56a +For help see https://nodejs.org/en/docs/inspector +ws://localhost:3000/51cf8d0e-3c36-4c59-8efd-54519839e56a + +$ node -p 'inspector.url()' +undefined +``` + ## inspector.waitForDebugger() + +* {string|undefined} + +The current input data being processed by node. + +This can be used when collecting input from a TTY stream to retrieve the +current value that has been processed thus far, prior to the `line` event +being emitted. Once the `line` event has been emitted, this property will +be an empty string. + +Be aware that modifying the value during the instance runtime may have +unintended consequences if `rl.cursor` is not also controlled. + +**If not using a TTY stream for input, use the [`'line'`][] event.** + +One possible use case would be as follows: + +```js +const values = ['lorem ipsum', 'dolor sit amet']; +const rl = readline.createInterface(process.stdin); +const showResults = debounce(() => { + console.log( + '\n', + values.filter((val) => val.startsWith(rl.line)).join(' ') + ); +}, 300); +process.stdin.on('keypress', (c, k) => { + showResults(); +}); +``` + +### rl.cursor + + +* {number|undefined} + +The cursor position relative to `rl.line`. + +This will track where the current cursor lands in the input string, when +reading input from a TTY stream. The position of cursor determines the +portion of the input string that will be modified as input is processed, +as well as the column where the terminal caret will be rendered. + ## readline.clearLine(stream, dir\[, callback\]) * Returns: {Object} - * `name` {string} The name of the cipher suite. + * `name` {string} OpenSSL name for the cipher suite. + * `standardName` {string} IETF name for the cipher suite. * `version` {string} The minimum TLS protocol version supported by this cipher suite. Returns an object containing information on the negotiated cipher suite. -For example: `{ name: 'AES256-SHA', version: 'TLSv1.2' }`. +For example: +```json +{ + "name": "AES128-SHA256", + "standardName": "TLS_RSA_WITH_AES_128_CBC_SHA256", + "version": "TLSv1.2" +} +``` See [SSL_CIPHER_get_name](https://www.openssl.org/docs/man1.1.1/man3/SSL_CIPHER_get_name.html) diff --git a/doc/api/util.md b/doc/api/util.md index ac23f138ad0d17..88e2f34b7c8b26 100644 --- a/doc/api/util.md +++ b/doc/api/util.md @@ -678,13 +678,72 @@ The default styles and associated colors are: * `symbol`: `green` * `undefined`: `grey` -The predefined color codes are: `white`, `grey`, `black`, `blue`, `cyan`, -`green`, `magenta`, `red` and `yellow`. There are also `bold`, `italic`, -`underline` and `inverse` codes. - Color styling uses ANSI control codes that may not be supported on all terminals. To verify color support use [`tty.hasColors()`][]. +Predefined control codes are listed below (grouped as "Modifiers", "Foreground +colors", and "Background colors"). + +#### Modifiers + +Modifier support varies throughout different terminals. They will mostly be +ignored, if not supported. + +* `reset` - Resets all (color) modifiers to their defaults +* **bold** - Make text bold +* _italic_ - Make text italic +* underline - Make text underlined +* ~~strikethrough~~ - Puts a horizontal line through the center of the text + (Alias: `strikeThrough`, `crossedout`, `crossedOut`) +* `hidden` - Prints the text, but makes it invisible (Alias: conceal) +* dim - Decreased color intensity (Alias: + `faint`) +* overlined - Make text overlined +* blink - Hides and shows the text in an interval +* inverse - Swap foreground and + background colors (Alias: `swapcolors`, `swapColors`) +* doubleunderline - Make text + double underlined (Alias: `doubleUnderline`) +* framed - Draw a frame around the text + +#### Foreground colors + +* `black` +* `red` +* `green` +* `yellow` +* `blue` +* `magenta` +* `cyan` +* `white` +* `gray` (alias: `grey`, `blackBright`) +* `redBright` +* `greenBright` +* `yellowBright` +* `blueBright` +* `magentaBright` +* `cyanBright` +* `whiteBright` + +#### Background colors + +* `bgBlack` +* `bgRed` +* `bgGreen` +* `bgYellow` +* `bgBlue` +* `bgMagenta` +* `bgCyan` +* `bgWhite` +* `bgGray` (alias: `bgGrey`, `bgBlackBright`) +* `bgRedBright` +* `bgGreenBright` +* `bgYellowBright` +* `bgBlueBright` +* `bgMagentaBright` +* `bgCyanBright` +* `bgWhiteBright` + ### Custom inspection functions on Objects diff --git a/doc/api/worker_threads.md b/doc/api/worker_threads.md index b334a1091b47fd..4d355bd0d5613c 100644 --- a/doc/api/worker_threads.md +++ b/doc/api/worker_threads.md @@ -510,6 +510,9 @@ changes: - version: v13.2.0 pr-url: https://github.com/nodejs/node/pull/26628 description: The `resourceLimits` option was introduced. + - version: v13.4.0 + pr-url: https://github.com/nodejs/node/pull/30559 + description: The `argv` option was introduced. --> * `filename` {string} The path to the Worker’s main script. Must be @@ -518,6 +521,10 @@ changes: If `options.eval` is `true`, this is a string containing JavaScript code rather than a path. * `options` {Object} + * `argv` {any[]} List of arguments which would be stringified and appended to + `process.argv` in the worker. This is mostly similar to the `workerData` + but the values will be available on the global `process.argv` as if they + were passed as CLI options to the script. * `env` {Object} If set, specifies the initial value of `process.env` inside the Worker thread. As a special value, [`worker.SHARE_ENV`][] may be used to specify that the parent thread and the child thread should share their diff --git a/doc/changelogs/CHANGELOG_V13.md b/doc/changelogs/CHANGELOG_V13.md index 4cc76438459d23..8e6ba1e1ec1923 100644 --- a/doc/changelogs/CHANGELOG_V13.md +++ b/doc/changelogs/CHANGELOG_V13.md @@ -9,6 +9,7 @@ +13.4.0
    13.3.0
    13.2.0
    13.1.0
    @@ -33,6 +34,161 @@ * [io.js](CHANGELOG_IOJS.md) * [Archive](CHANGELOG_ARCHIVE.md) + +## 2019-12-17, Version 13.4.0 (Current), @MylesBorins + +This is a security release. + +For more details about the vulnerability please consult the npm blog: + +https://blog.npmjs.org/post/189618601100/binary-planting-with-the-npm-cli + +### Notable Changes + +* **deps**: + * update npm to 6.13.4 [#30904](https://github.com/nodejs/node/pull/30904) + * update uvwasi (Anna Henningsen) [#30745](https://github.com/nodejs/node/pull/30745) + * upgrade to libuv 1.34.0 (Colin Ihrig) [#30783](https://github.com/nodejs/node/pull/30783) +* **doc**: + * docs deprecate http finished (Robert Nagy) [#28679](https://github.com/nodejs/node/pull/28679) +* **events**: + * add captureRejection option (Matteo Collina) [#27867](https://github.com/nodejs/node/pull/27867) +* **http**: + * add captureRejection support (Matteo Collina) [#27867](https://github.com/nodejs/node/pull/27867) + * llhttp opt-in insecure HTTP header parsing (Sam Roberts) [#30567](https://github.com/nodejs/node/pull/30567) +* **http2**: + * implement capture rection for 'request' and 'stream' events (Matteo Collina) [#27867](https://github.com/nodejs/node/pull/27867) +* **net**: + * implement capture rejections for 'connection' event (Matteo Collina) [#27867](https://github.com/nodejs/node/pull/27867) +* **repl**: + * support previews by eager evaluating input (Ruben Bridgewater) [#30811](https://github.com/nodejs/node/pull/30811) +* **stream**: + * add support for captureRejection option (Matteo Collina) [#27867](https://github.com/nodejs/node/pull/27867) +* **tls**: + * implement capture rejections for 'secureConnection' event (Matteo Collina) [#27867](https://github.com/nodejs/node/pull/27867) + * expose IETF name for current cipher suite (Sam Roberts) [#30637](https://github.com/nodejs/node/pull/30637) +* **worker**: + * add argv constructor option (legendecas) [#30559](https://github.com/nodejs/node/pull/30559) + +### Commits + +* [[`1c4b2f15d9`](https://github.com/nodejs/node/commit/1c4b2f15d9)] - **assert,util**: stricter type comparison using deep equal comparisons (Ruben Bridgewater) [#30764](https://github.com/nodejs/node/pull/30764) +* [[`78eaf50693`](https://github.com/nodejs/node/commit/78eaf50693)] - **benchmark**: improve `--filter` pattern matching (Matheus Marchini) [#29987](https://github.com/nodejs/node/pull/29987) +* [[`ad4d52d1b5`](https://github.com/nodejs/node/commit/ad4d52d1b5)] - **benchmark**: add more util inspect and format benchmarks (Ruben Bridgewater) [#30767](https://github.com/nodejs/node/pull/30767) +* [[`d90815d08e`](https://github.com/nodejs/node/commit/d90815d08e)] - **build**: on Android, use android log library to print stack traces (Giovanni Campagna) [#29388](https://github.com/nodejs/node/pull/29388) +* [[`d1c4fccde2`](https://github.com/nodejs/node/commit/d1c4fccde2)] - **build**: fix library version and compile flags on Android (Giovanni Campagna) [#29388](https://github.com/nodejs/node/pull/29388) +* [[`dfd3a4d6c1`](https://github.com/nodejs/node/commit/dfd3a4d6c1)] - **(SEMVER-MINOR)** **build**: add flag to enable pointer compression (Matteo Collina) [#30463](https://github.com/nodejs/node/pull/30463) +* [[`3d05d4beea`](https://github.com/nodejs/node/commit/3d05d4beea)] - **build**: ease DragonFlyBSD build (David Carlier) [#30201](https://github.com/nodejs/node/pull/30201) +* [[`43e947a155`](https://github.com/nodejs/node/commit/43e947a155)] - **build**: remove (almost) unused macros/constants (Benjamin Coe) [#30755](https://github.com/nodejs/node/pull/30755) +* [[`0379fb65c1`](https://github.com/nodejs/node/commit/0379fb65c1)] - **deps**: update npm to 6.13.4 (Isaac Z. Schlueter) [#30904](https://github.com/nodejs/node/pull/30904) +* [[`13fe9f7cc8`](https://github.com/nodejs/node/commit/13fe9f7cc8)] - **deps**: update uvwasi (Anna Henningsen) [#30745](https://github.com/nodejs/node/pull/30745) +* [[`ca47f72868`](https://github.com/nodejs/node/commit/ca47f72868)] - **(SEMVER-MINOR)** **deps**: upgrade to libuv 1.34.0 (Colin Ihrig) [#30783](https://github.com/nodejs/node/pull/30783) +* [[`458860691c`](https://github.com/nodejs/node/commit/458860691c)] - **deps**: fix OPENSSLDIR on Windows (Shigeki Ohtsu) [#29456](https://github.com/nodejs/node/pull/29456) +* [[`b3ae532392`](https://github.com/nodejs/node/commit/b3ae532392)] - **doc**: clarify build support text (Rich Trott) [#30899](https://github.com/nodejs/node/pull/30899) +* [[`8bf0da6c93`](https://github.com/nodejs/node/commit/8bf0da6c93)] - **doc**: edit colorMode information (Rich Trott) [#30887](https://github.com/nodejs/node/pull/30887) +* [[`df9df1883e`](https://github.com/nodejs/node/commit/df9df1883e)] - **doc**: fix argument type of setAAD (Tobias Nießen) [#30863](https://github.com/nodejs/node/pull/30863) +* [[`9d1c793ceb`](https://github.com/nodejs/node/commit/9d1c793ceb)] - **doc**: clarify Tier 2 implications in BUILDING.md (Rich Trott) [#30866](https://github.com/nodejs/node/pull/30866) +* [[`1cce00073e`](https://github.com/nodejs/node/commit/1cce00073e)] - **doc**: add code example to inspector.url() method (Juan José Arboleda) [#29496](https://github.com/nodejs/node/pull/29496) +* [[`93ca4f4098`](https://github.com/nodejs/node/commit/93ca4f4098)] - **doc**: deprecate http finished (Robert Nagy) [#28679](https://github.com/nodejs/node/pull/28679) +* [[`0022d7544a`](https://github.com/nodejs/node/commit/0022d7544a)] - **doc**: improve doc Http2Stream: FrameError, Timeout and Trailers (dev-313) [#30373](https://github.com/nodejs/node/pull/30373) +* [[`2123d53c28`](https://github.com/nodejs/node/commit/2123d53c28)] - **doc**: include line/cursor in readline documentation (Jeremy Albright) [#30667](https://github.com/nodejs/node/pull/30667) +* [[`1baa6ab075`](https://github.com/nodejs/node/commit/1baa6ab075)] - **doc**: improve napi formatting (Ruben Bridgewater) [#30772](https://github.com/nodejs/node/pull/30772) +* [[`1d5c4e21de`](https://github.com/nodejs/node/commit/1d5c4e21de)] - **doc**: add documentation about node\_mksnapshot and mkcodecache (Joyee Cheung) [#30773](https://github.com/nodejs/node/pull/30773) +* [[`67823e8fc4`](https://github.com/nodejs/node/commit/67823e8fc4)] - **doc**: remove imprecise and redundant testing text (Rich Trott) [#30763](https://github.com/nodejs/node/pull/30763) +* [[`7cb84fdbe5`](https://github.com/nodejs/node/commit/7cb84fdbe5)] - **doc**: remove usage of "Node" in favor of "Node.js" (Rich Trott) [#30758](https://github.com/nodejs/node/pull/30758) +* [[`510eb3a6eb`](https://github.com/nodejs/node/commit/510eb3a6eb)] - **doc**: revise addons introduction for brevity and clarity (Rich Trott) [#30756](https://github.com/nodejs/node/pull/30756) +* [[`543bf9d8ea`](https://github.com/nodejs/node/commit/543bf9d8ea)] - **doc**: fix up N-API doc (NickNaso) [#30656](https://github.com/nodejs/node/pull/30656) +* [[`2c0f1edfd5`](https://github.com/nodejs/node/commit/2c0f1edfd5)] - **doc**: adds assert doc for strict mode with pointer to strict equality (Shobhit Chittora) [#30486](https://github.com/nodejs/node/pull/30486) +* [[`9428304d4a`](https://github.com/nodejs/node/commit/9428304d4a)] - **doc**: Buffer.toString(): add note about invalid data (Jan-Philip Gehrcke) [#30706](https://github.com/nodejs/node/pull/30706) +* [[`8369562757`](https://github.com/nodejs/node/commit/8369562757)] - **doc**: clarify text about using 'session' event for compatibility (Rich Trott) [#30746](https://github.com/nodejs/node/pull/30746) +* [[`145f881ff9`](https://github.com/nodejs/node/commit/145f881ff9)] - **doc**: update status of Python 3 support (Michael Dawson) [#30722](https://github.com/nodejs/node/pull/30722) +* [[`bbbba76f2c`](https://github.com/nodejs/node/commit/bbbba76f2c)] - **doc,benchmark**: move benchmark guide to benchmark directory (Rich Trott) [#30781](https://github.com/nodejs/node/pull/30781) +* [[`eb4f443a5a`](https://github.com/nodejs/node/commit/eb4f443a5a)] - **esm**: make specifier flag clearly experimental (Myles Borins) [#30678](https://github.com/nodejs/node/pull/30678) +* [[`220a6001c6`](https://github.com/nodejs/node/commit/220a6001c6)] - **(SEMVER-MINOR)** **events**: add captureRejection option (Matteo Collina) [#27867](https://github.com/nodejs/node/pull/27867) +* [[`6c07a72833`](https://github.com/nodejs/node/commit/6c07a72833)] - **fs**: synchronize close with other I/O for streams (Anna Henningsen) [#30837](https://github.com/nodejs/node/pull/30837) +* [[`18758ef183`](https://github.com/nodejs/node/commit/18758ef183)] - **fs**: retry unlink operations in rimraf (Colin Ihrig) [#30569](https://github.com/nodejs/node/pull/30569) +* [[`5e98de1751`](https://github.com/nodejs/node/commit/5e98de1751)] - **fs**: only operate on buffers in rimraf (Colin Ihrig) [#30569](https://github.com/nodejs/node/pull/30569) +* [[`7e1dee3347`](https://github.com/nodejs/node/commit/7e1dee3347)] - **fs**: reduce unnecessary sync rimraf retries (Colin Ihrig) [#30785](https://github.com/nodejs/node/pull/30785) +* [[`5523950b47`](https://github.com/nodejs/node/commit/5523950b47)] - **fs**: add synchronous retries to rimraf (Colin Ihrig) [#30785](https://github.com/nodejs/node/pull/30785) +* [[`60b1e1ad61`](https://github.com/nodejs/node/commit/60b1e1ad61)] - **fs**: fix existsSync for invalid symlink at win32 (Rongjian Zhang) [#30556](https://github.com/nodejs/node/pull/30556) +* [[`daca0780b1`](https://github.com/nodejs/node/commit/daca0780b1)] - **(SEMVER-MINOR)** **http**: llhttp opt-in insecure HTTP header parsing (Sam Roberts) [#30567](https://github.com/nodejs/node/pull/30567) +* [[`334d4f6256`](https://github.com/nodejs/node/commit/334d4f6256)] - **(SEMVER-MINOR)** **http**: add captureRejection support to OutgoingMessage (Matteo Collina) [#27867](https://github.com/nodejs/node/pull/27867) +* [[`33a6bf3a83`](https://github.com/nodejs/node/commit/33a6bf3a83)] - **(SEMVER-MINOR)** **http**: implement capture rejections for 'request' event (Matteo Collina) [#27867](https://github.com/nodejs/node/pull/27867) +* [[`822fb00dbe`](https://github.com/nodejs/node/commit/822fb00dbe)] - **http2**: forward debug message in debugStreamObj (Denys Otrishko) [#30840](https://github.com/nodejs/node/pull/30840) +* [[`d17ea8f584`](https://github.com/nodejs/node/commit/d17ea8f584)] - **http2**: track nghttp2-allocated memory in heap snapshot (Anna Henningsen) [#30745](https://github.com/nodejs/node/pull/30745) +* [[`8a9f57d0d5`](https://github.com/nodejs/node/commit/8a9f57d0d5)] - **http2**: use shared memory tracking implementation (Anna Henningsen) [#30745](https://github.com/nodejs/node/pull/30745) +* [[`71bb026e0c`](https://github.com/nodejs/node/commit/71bb026e0c)] - **http2**: streamline OnStreamRead streamline memory accounting (Denys Otrishko) [#30351](https://github.com/nodejs/node/pull/30351) +* [[`3840abed11`](https://github.com/nodejs/node/commit/3840abed11)] - **http2**: small clean up in OnStreamRead (Denys Otrishko) [#30351](https://github.com/nodejs/node/pull/30351) +* [[`c3ac4c85a5`](https://github.com/nodejs/node/commit/c3ac4c85a5)] - **(SEMVER-MINOR)** **http2**: implement capture rection for 'request' and 'stream' events (Matteo Collina) [#27867](https://github.com/nodejs/node/pull/27867) +* [[`d3f0dd2148`](https://github.com/nodejs/node/commit/d3f0dd2148)] - **inspector**: do not access queueMicrotask from global (Michaël Zasso) [#30732](https://github.com/nodejs/node/pull/30732) +* [[`71c6d44efa`](https://github.com/nodejs/node/commit/71c6d44efa)] - **lib**: enforce use of BigInt from primordials (Michaël Zasso) [#30882](https://github.com/nodejs/node/pull/30882) +* [[`64ab5c9c84`](https://github.com/nodejs/node/commit/64ab5c9c84)] - **lib**: replace Symbol.iterator by SymbolIterator (Sebastien Ahkrin) [#30859](https://github.com/nodejs/node/pull/30859) +* [[`39898a9db4`](https://github.com/nodejs/node/commit/39898a9db4)] - **lib**: replace every Symbol.for by SymbolFor primordials (Sebastien Ahkrin) [#30857](https://github.com/nodejs/node/pull/30857) +* [[`0a34fcb086`](https://github.com/nodejs/node/commit/0a34fcb086)] - **lib**: replace var with let/const (jens-cappelle) [#30384](https://github.com/nodejs/node/pull/30384) +* [[`af014170a7`](https://github.com/nodejs/node/commit/af014170a7)] - **lib**: replace Symbol global by the primordials Symbol (Sebastien Ahkrin) [#30737](https://github.com/nodejs/node/pull/30737) +* [[`2c439bb8ad`](https://github.com/nodejs/node/commit/2c439bb8ad)] - **lib**: add parent to ERR\_UNKNOWN\_FILE\_EXTENSION (qualitymanifest) [#30728](https://github.com/nodejs/node/pull/30728) +* [[`d9d64754f9`](https://github.com/nodejs/node/commit/d9d64754f9)] - **lib**: add warning on dynamic import es modules (Juan José Arboleda) [#30720](https://github.com/nodejs/node/pull/30720) +* [[`325128e469`](https://github.com/nodejs/node/commit/325128e469)] - **lib**: delay access to CLI option to pre-execution (Joyee Cheung) [#30778](https://github.com/nodejs/node/pull/30778) +* [[`94f237e5ac`](https://github.com/nodejs/node/commit/94f237e5ac)] - **lib,test**: improves ERR\_REQUIRE\_ESM message (Juan José Arboleda) [#30694](https://github.com/nodejs/node/pull/30694) +* [[`e61f4ead93`](https://github.com/nodejs/node/commit/e61f4ead93)] - **module**: conditional exports import condition (Guy Bedford) [#30799](https://github.com/nodejs/node/pull/30799) +* [[`8e16093b64`](https://github.com/nodejs/node/commit/8e16093b64)] - **module**: fix require in node repl (Yongsheng Zhang) [#30835](https://github.com/nodejs/node/pull/30835) +* [[`d4aa656d57`](https://github.com/nodejs/node/commit/d4aa656d57)] - **module**: fix dynamic import from eval (Corey Farrell) [#30624](https://github.com/nodejs/node/pull/30624) +* [[`a7ec78f34e`](https://github.com/nodejs/node/commit/a7ec78f34e)] - **module**: fixup lint and test regressions (Guy Bedford) [#30802](https://github.com/nodejs/node/pull/30802) +* [[`bd2f1270f7`](https://github.com/nodejs/node/commit/bd2f1270f7)] - **module**: ignore resolution failures for inspect-brk (Maël Nison) [#30336](https://github.com/nodejs/node/pull/30336) +* [[`851f3135ab`](https://github.com/nodejs/node/commit/851f3135ab)] - **module**: add warnings for experimental flags (Rongjian Zhang) [#30617](https://github.com/nodejs/node/pull/30617) +* [[`123327d4c1`](https://github.com/nodejs/node/commit/123327d4c1)] - **net**: remove duplicate \_undestroy (Robert Nagy) [#30833](https://github.com/nodejs/node/pull/30833) +* [[`4eecee089d`](https://github.com/nodejs/node/commit/4eecee089d)] - **(SEMVER-MINOR)** **net**: implement capture rejections for 'connection' event (Matteo Collina) [#27867](https://github.com/nodejs/node/pull/27867) +* [[`2f1ae4f2bf`](https://github.com/nodejs/node/commit/2f1ae4f2bf)] - **readline**: eagerly load string\_decoder (Ruben Bridgewater) [#30807](https://github.com/nodejs/node/pull/30807) +* [[`e551c169b8`](https://github.com/nodejs/node/commit/e551c169b8)] - **(SEMVER-MINOR)** **repl**: support previews by eager evaluating input (Ruben Bridgewater) [#30811](https://github.com/nodejs/node/pull/30811) +* [[`c440f3fa3d`](https://github.com/nodejs/node/commit/c440f3fa3d)] - **repl**: use better uncaught exceptions indicator (Ruben Bridgewater) [#29676](https://github.com/nodejs/node/pull/29676) +* [[`de368200f3`](https://github.com/nodejs/node/commit/de368200f3)] - **src**: accept single argument in getProxyDetails (Ruben Bridgewater) [#30858](https://github.com/nodejs/node/pull/30858) +* [[`60886036c9`](https://github.com/nodejs/node/commit/60886036c9)] - **src**: fix the false isatty() issue on IBMi (Xu Meng) [#30829](https://github.com/nodejs/node/pull/30829) +* [[`7ed867dddb`](https://github.com/nodejs/node/commit/7ed867dddb)] - **src**: improve checked uv loop close output (Anna Henningsen) [#30814](https://github.com/nodejs/node/pull/30814) +* [[`041daaa273`](https://github.com/nodejs/node/commit/041daaa273)] - **src**: port memory-tracking allocator from QUIC repo (Anna Henningsen) [#30745](https://github.com/nodejs/node/pull/30745) +* [[`ccf0917aef`](https://github.com/nodejs/node/commit/ccf0917aef)] - **src**: don't use deprecated OpenSSL APIs (Rosen Penev) [#30812](https://github.com/nodejs/node/pull/30812) +* [[`8ad53ab2b7`](https://github.com/nodejs/node/commit/8ad53ab2b7)] - **src**: free preopen memory in WASI::New() (Colin Ihrig) [#30809](https://github.com/nodejs/node/pull/30809) +* [[`e6e379ea41`](https://github.com/nodejs/node/commit/e6e379ea41)] - **src**: use checked allocations in WASI::New() (Colin Ihrig) [#30809](https://github.com/nodejs/node/pull/30809) +* [[`838ae10a9b`](https://github.com/nodejs/node/commit/838ae10a9b)] - **src**: delete redundant method in node\_dir.h (gengjiawen) [#30747](https://github.com/nodejs/node/pull/30747) +* [[`66db8746c7`](https://github.com/nodejs/node/commit/66db8746c7)] - **src**: remove redundant cast in node\_dir.cc (gengjiawen) [#30747](https://github.com/nodejs/node/pull/30747) +* [[`cb69ff47f6`](https://github.com/nodejs/node/commit/cb69ff47f6)] - **src**: improve node\_crypto.cc memory allocation (Priyanka Kore) [#30751](https://github.com/nodejs/node/pull/30751) +* [[`b51b26ffef`](https://github.com/nodejs/node/commit/b51b26ffef)] - **src**: fix node\_dir.cc memory allocation (Priyanka Kore) [#30750](https://github.com/nodejs/node/pull/30750) +* [[`89bc571490`](https://github.com/nodejs/node/commit/89bc571490)] - **(SEMVER-MINOR)** **stream**: add support for captureRejection option (Matteo Collina) [#27867](https://github.com/nodejs/node/pull/27867) +* [[`1b534d571a`](https://github.com/nodejs/node/commit/1b534d571a)] - **test**: work around ENOTEMPTY when cleaning tmp dir (Ben Noordhuis) [#30849](https://github.com/nodejs/node/pull/30849) +* [[`eb6e32c2fc`](https://github.com/nodejs/node/commit/eb6e32c2fc)] - **test**: disable colorMode in test-console-group (Rich Trott) [#30886](https://github.com/nodejs/node/pull/30886) +* [[`5f42b1fc6b`](https://github.com/nodejs/node/commit/5f42b1fc6b)] - **test**: assert: fix deepStrictEqual comparing a real array and fake array (Jordan Harband) [#30743](https://github.com/nodejs/node/pull/30743) +* [[`ce21fc7154`](https://github.com/nodejs/node/commit/ce21fc7154)] - **test**: wait for stream close before writing to file (Anna Henningsen) [#30836](https://github.com/nodejs/node/pull/30836) +* [[`cc4a6ed645`](https://github.com/nodejs/node/commit/cc4a6ed645)] - **test**: use fs rimraf to refresh tmpdir (Colin Ihrig) [#30569](https://github.com/nodejs/node/pull/30569) +* [[`5ae3a858f7`](https://github.com/nodejs/node/commit/5ae3a858f7)] - **test**: refactor test-accessor-properties (himself65) [#29943](https://github.com/nodejs/node/pull/29943) +* [[`97e0efeedf`](https://github.com/nodejs/node/commit/97e0efeedf)] - **test**: scale keepalive timeouts for slow machines (Ben Noordhuis) [#30834](https://github.com/nodejs/node/pull/30834) +* [[`305e45a041`](https://github.com/nodejs/node/commit/305e45a041)] - **test**: mark tests as flaky (João Reis) [#30848](https://github.com/nodejs/node/pull/30848) +* [[`4dc9d8db13`](https://github.com/nodejs/node/commit/4dc9d8db13)] - **test**: mark addons/openssl-bindings/test flaky on arm (Richard Lau) [#30838](https://github.com/nodejs/node/pull/30838) +* [[`25e3696a07`](https://github.com/nodejs/node/commit/25e3696a07)] - **test**: improve WASI options validation (Rich Trott) [#30800](https://github.com/nodejs/node/pull/30800) +* [[`a574cb0ab9`](https://github.com/nodejs/node/commit/a574cb0ab9)] - **test**: remove common.busyLoop() (Colin Ihrig) [#30787](https://github.com/nodejs/node/pull/30787) +* [[`3557659afb`](https://github.com/nodejs/node/commit/3557659afb)] - **test**: run more assert tests (Ruben Bridgewater) [#30764](https://github.com/nodejs/node/pull/30764) +* [[`5067463f3c`](https://github.com/nodejs/node/commit/5067463f3c)] - **test**: use callback arguments in getconnections test (Rich Trott) [#30775](https://github.com/nodejs/node/pull/30775) +* [[`30756e36e7`](https://github.com/nodejs/node/commit/30756e36e7)] - **test**: improve wasi test coverage (Rich Trott) [#30770](https://github.com/nodejs/node/pull/30770) +* [[`fb31ab52c0`](https://github.com/nodejs/node/commit/fb31ab52c0)] - **test**: simplify tmpdir import in wasi tests (Rich Trott) [#30770](https://github.com/nodejs/node/pull/30770) +* [[`55a270b583`](https://github.com/nodejs/node/commit/55a270b583)] - **test**: remove duplicate entries from root.status (Richard Lau) [#30769](https://github.com/nodejs/node/pull/30769) +* [[`54a266c878`](https://github.com/nodejs/node/commit/54a266c878)] - **test**: increase debugging information in subprocess test (Rich Trott) [#30761](https://github.com/nodejs/node/pull/30761) +* [[`a0fa327365`](https://github.com/nodejs/node/commit/a0fa327365)] - **test**: use block-scoping in test-net-server-address (Rich Trott) [#30754](https://github.com/nodejs/node/pull/30754) +* [[`9bd5c72104`](https://github.com/nodejs/node/commit/9bd5c72104)] - **test**: move test-child-process-fork-getconnections to parallel (Rich Trott) [#30749](https://github.com/nodejs/node/pull/30749) +* [[`50ab1fa013`](https://github.com/nodejs/node/commit/50ab1fa013)] - **test**: change common.PORT to arbitrary port (Rich Trott) [#30749](https://github.com/nodejs/node/pull/30749) +* [[`255cd7e572`](https://github.com/nodejs/node/commit/255cd7e572)] - **(SEMVER-MINOR)** **tls**: expose IETF name for current cipher suite (Sam Roberts) [#30637](https://github.com/nodejs/node/pull/30637) +* [[`5ad3efbfb3`](https://github.com/nodejs/node/commit/5ad3efbfb3)] - **(SEMVER-MINOR)** **tls**: implement capture rejections for 'secureConnection' event (Matteo Collina) [#27867](https://github.com/nodejs/node/pull/27867) +* [[`5203ffb2f4`](https://github.com/nodejs/node/commit/5203ffb2f4)] - **tools**: update link to google styleguide for cpplint (Daniel Bevenius) [#30876](https://github.com/nodejs/node/pull/30876) +* [[`1ed1a645f2`](https://github.com/nodejs/node/commit/1ed1a645f2)] - **tools**: use CC instead of CXX when pointing to gcc (Milad Farazmand) [#30817](https://github.com/nodejs/node/pull/30817) +* [[`2b687af852`](https://github.com/nodejs/node/commit/2b687af852)] - **tools**: update remark-preset-lint-node to 1.11.0 (Rich Trott) [#30789](https://github.com/nodejs/node/pull/30789) +* [[`0cb7720dd8`](https://github.com/nodejs/node/commit/0cb7720dd8)] - **tools**: update icu to 65.1 (Albert Wang) [#30232](https://github.com/nodejs/node/pull/30232) +* [[`7b9400ce63`](https://github.com/nodejs/node/commit/7b9400ce63)] - **tools**: update ESLint to 6.7.2 (Rich Trott) [#30762](https://github.com/nodejs/node/pull/30762) +* [[`5ab3ca4f96`](https://github.com/nodejs/node/commit/5ab3ca4f96)] - **url**: declare iterator inside loop (Trivikram Kamat) [#30509](https://github.com/nodejs/node/pull/30509) +* [[`dc69cbeb05`](https://github.com/nodejs/node/commit/dc69cbeb05)] - **util**: add internal sleep() function (Colin Ihrig) [#30787](https://github.com/nodejs/node/pull/30787) +* [[`3898b2387b`](https://github.com/nodejs/node/commit/3898b2387b)] - **util**: never trigger any proxy traps using `format()` (Ruben Bridgewater) [#30767](https://github.com/nodejs/node/pull/30767) +* [[`eeaeb51dcc`](https://github.com/nodejs/node/commit/eeaeb51dcc)] - **util**: improve performance inspecting proxies (Ruben Bridgewater) [#30767](https://github.com/nodejs/node/pull/30767) +* [[`608d720834`](https://github.com/nodejs/node/commit/608d720834)] - **(SEMVER-MINOR)** **util**: add more predefined color codes to inspect.colors (Ruben Bridgewater) [#30659](https://github.com/nodejs/node/pull/30659) +* [[`77ffd5482d`](https://github.com/nodejs/node/commit/77ffd5482d)] - **(SEMVER-MINOR)** **util**: improve inspect's customInspect performance (Ruben Bridgewater) [#30659](https://github.com/nodejs/node/pull/30659) +* [[`14269d15cf`](https://github.com/nodejs/node/commit/14269d15cf)] - **wasi**: use memory-tracking allocator (Anna Henningsen) [#30745](https://github.com/nodejs/node/pull/30745) +* [[`71d43a5569`](https://github.com/nodejs/node/commit/71d43a5569)] - **(SEMVER-MINOR)** **worker**: add argv constructor option (legendecas) [#30559](https://github.com/nodejs/node/pull/30559) + ## 2019-12-03, Version 13.3.0 (Current), @BridgeAR diff --git a/doc/guides/contributing/pull-requests.md b/doc/guides/contributing/pull-requests.md index 31e3ba64757c12..cd1bccd20cd691 100644 --- a/doc/guides/contributing/pull-requests.md +++ b/doc/guides/contributing/pull-requests.md @@ -49,7 +49,7 @@ In case of doubt, open an issue in the Node.js has two IRC channels: [#Node.js](https://webchat.freenode.net/?channels=node.js) for general help and questions, and -[#Node-dev](https://webchat.freenode.net/?channels=node-dev) for development of +[#node-dev](https://webchat.freenode.net/?channels=node-dev) for development of Node.js core specifically. ## Setting up your local environment @@ -585,7 +585,7 @@ If you want to know more about the code review and the landing process, see the [Collaborator Guide][]. [approved]: #getting-approvals-for-your-pull-request -[benchmark results]: ../writing-and-running-benchmarks.md +[benchmark results]: ../../../benchmark/writing-and-running-benchmarks.md [Building guide]: ../../../BUILDING.md [CI (Continuous Integration) test run]: #ci-testing [Code of Conduct]: https://github.com/nodejs/admin/blob/master/CODE_OF_CONDUCT.md diff --git a/doc/node.1 b/doc/node.1 index 714772336e07c1..5ea38be56e9f37 100644 --- a/doc/node.1 +++ b/doc/node.1 @@ -110,9 +110,6 @@ Enable FIPS-compliant crypto at startup. Requires Node.js to be built with .Sy ./configure --openssl-fips . . -.It Fl -es-module-specifier-resolution -Select extension resolution algorithm for ES Modules; either 'explicit' (default) or 'node' -. .It Fl -experimental-conditional-exports Enable experimental support for "require" and "node" conditional export targets. . @@ -130,6 +127,9 @@ Enable experimental top-level .Sy await keyword support in REPL. . +.It Fl -experimental-specifier-resolution +Select extension resolution algorithm for ES Modules; either 'explicit' (default) or 'node' +. .It Fl -experimental-report Enable experimental .Sy diagnostic report @@ -213,6 +213,12 @@ Specify the .Ar module to use as a custom module loader. . +.It Fl -insecure-http-parser +Use an insecure HTTP parser that accepts invalid HTTP headers. This may allow +interoperability with non-conformant HTTP implementations. It may also allow +request smuggling and other HTTP attacks that rely on invalid headers being +accepted. Avoid using this option. +. .It Fl -max-http-header-size Ns = Ns Ar size Specify the maximum size of HTTP headers in bytes. Defaults to 8KB. . diff --git a/lib/.eslintrc.yaml b/lib/.eslintrc.yaml index 2823b7aa0d1def..81042a5c9d6f27 100644 --- a/lib/.eslintrc.yaml +++ b/lib/.eslintrc.yaml @@ -11,6 +11,8 @@ rules: - error - name: Array message: "Use `const { Array } = primordials;` instead of the global." + - name: BigInt + message: "Use `const { BigInt } = primordials;` instead of the global." - name: Boolean message: "Use `const { Boolean } = primordials;` instead of the global." - name: JSON @@ -23,6 +25,8 @@ rules: message: "Use `const { Object } = primordials;` instead of the global." - name: Reflect message: "Use `const { Reflect } = primordials;` instead of the global." + - name: Symbol + message: "Use `const { Symbol } = primordials;` instead of the global." no-restricted-syntax: # Config copied from .eslintrc.js - error @@ -46,21 +50,6 @@ rules: node-core/non-ascii-character: error globals: Intl: false - # Assertions - CHECK: false - CHECK_EQ: false - CHECK_GE: false - CHECK_GT: false - CHECK_LE: false - CHECK_LT: false - CHECK_NE: false - DCHECK: false - DCHECK_EQ: false - DCHECK_GE: false - DCHECK_GT: false - DCHECK_LE: false - DCHECK_LT: false - DCHECK_NE: false # Parameters passed to internal modules global: false require: false diff --git a/lib/_http_agent.js b/lib/_http_agent.js index af25b2bba75615..69fdb819a3a330 100644 --- a/lib/_http_agent.js +++ b/lib/_http_agent.js @@ -25,6 +25,7 @@ const { ObjectKeys, ObjectSetPrototypeOf, ObjectValues, + Symbol, } = primordials; const net = require('net'); diff --git a/lib/_http_client.js b/lib/_http_client.js index 6e59fa07c65be8..1d949559d96d93 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -39,6 +39,7 @@ const { freeParser, parsers, HTTPParser, + isLenient, prepareError, } = require('_http_common'); const { OutgoingMessage } = require('_http_outgoing'); @@ -669,7 +670,8 @@ function tickOnSocket(req, socket) { req.socket = socket; parser.initialize(HTTPParser.RESPONSE, new HTTPClientAsyncResource('HTTPINCOMINGMESSAGE', req), - req.maxHeaderSize || 0); + req.maxHeaderSize || 0, + isLenient()); parser.socket = socket; parser.outgoing = req; req.parser = parser; diff --git a/lib/_http_common.js b/lib/_http_common.js index d0f07d3b69e5f5..f1386e1a0915dd 100644 --- a/lib/_http_common.js +++ b/lib/_http_common.js @@ -23,10 +23,13 @@ const { MathMin, + Symbol, } = primordials; const { setImmediate } = require('timers'); const { methods, HTTPParser } = internalBinding('http_parser'); +const { getOptionValue } = require('internal/options'); +const insecureHTTPParser = getOptionValue('--insecure-http-parser'); const FreeList = require('internal/freelist'); const incoming = require('_http_incoming'); @@ -236,6 +239,16 @@ function prepareError(err, parser, rawPacket) { err.message = `Parse Error: ${err.reason}`; } +let warnedLenient = false; + +function isLenient() { + if (insecureHTTPParser && !warnedLenient) { + warnedLenient = true; + process.emitWarning('Using insecure HTTP parsing'); + } + return insecureHTTPParser; +} + module.exports = { _checkInvalidHeaderChar: checkInvalidHeaderChar, _checkIsHttpToken: checkIsHttpToken, @@ -248,5 +261,6 @@ module.exports = { parsers, kIncomingMessage, HTTPParser, + isLenient, prepareError, }; diff --git a/lib/_http_outgoing.js b/lib/_http_outgoing.js index e331d073b57067..f40cf923f9b377 100644 --- a/lib/_http_outgoing.js +++ b/lib/_http_outgoing.js @@ -28,10 +28,12 @@ const { ObjectKeys, ObjectPrototypeHasOwnProperty, ObjectSetPrototypeOf, + Symbol, } = primordials; const { getDefaultHighWaterMark } = require('internal/streams/state'); const assert = require('internal/assert'); +const EE = require('events'); const Stream = require('stream'); const internalUtil = require('internal/util'); const { kOutHeaders, utcDate, kNeedDrain } = require('internal/http'); @@ -884,6 +886,11 @@ OutgoingMessage.prototype.pipe = function pipe() { this.emit('error', new ERR_STREAM_CANNOT_PIPE()); }; +OutgoingMessage.prototype[EE.captureRejectionSymbol] = +function(err, event) { + this.destroy(err); +}; + module.exports = { OutgoingMessage }; diff --git a/lib/_http_server.js b/lib/_http_server.js index 6c52f7adbc919d..453cf9005363dc 100644 --- a/lib/_http_server.js +++ b/lib/_http_server.js @@ -24,9 +24,12 @@ const { ObjectKeys, ObjectSetPrototypeOf, + Symbol, + SymbolFor, } = primordials; const net = require('net'); +const EE = require('events'); const assert = require('internal/assert'); const { parsers, @@ -37,6 +40,7 @@ const { chunkExpression, kIncomingMessage, HTTPParser, + isLenient, _checkInvalidHeaderChar: checkInvalidHeaderChar, prepareError, } = require('_http_common'); @@ -357,6 +361,28 @@ Server.prototype.setTimeout = function setTimeout(msecs, callback) { return this; }; +Server.prototype[EE.captureRejectionSymbol] = function( + err, event, ...args) { + + switch (event) { + case 'request': + const [ , res] = args; + if (!res.headersSent && !res.writableEnded) { + // Don't leak headers. + for (const name of res.getHeaderNames()) { + res.removeHeader(name); + } + res.statusCode = 500; + res.end(STATUS_CODES[500]); + } else { + res.destroy(); + } + break; + default: + net.Server.prototype[SymbolFor('nodejs.rejection')] + .call(this, err, event, ...args); + } +}; function connectionListener(socket) { defaultTriggerAsyncIdScope( @@ -386,7 +412,8 @@ function connectionListenerInternal(server, socket) { parser.initialize( HTTPParser.REQUEST, new HTTPServerAsyncResource('HTTPINCOMINGMESSAGE', socket), - server.maxHeaderSize || 0 + server.maxHeaderSize || 0, + isLenient(), ); parser.socket = socket; diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js index 0d83ada205b835..6226bbf5eb4063 100644 --- a/lib/_stream_readable.js +++ b/lib/_stream_readable.js @@ -27,6 +27,7 @@ const { NumberIsNaN, ObjectDefineProperty, ObjectSetPrototypeOf, + Symbol, } = primordials; module.exports = Readable; @@ -190,7 +191,7 @@ function Readable(options) { this._destroy = options.destroy; } - Stream.call(this); + Stream.call(this, options); } ObjectDefineProperty(Readable.prototype, 'destroyed', { @@ -233,6 +234,14 @@ Readable.prototype._destroy = function(err, cb) { cb(err); }; +Readable.prototype[EE.captureRejectionSymbol] = function(err) { + // TODO(mcollina): remove the destroyed if once errorEmitted lands in + // Readable. + if (!this.destroyed) { + this.destroy(err); + } +}; + // Manually shove something into the read() buffer. // This returns true if the highWaterMark has not been hit yet, // similar to how Writable.write() returns true if you should diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js index 9bea209e257d2a..5a88c817bd9fcc 100644 --- a/lib/_stream_writable.js +++ b/lib/_stream_writable.js @@ -29,12 +29,14 @@ const { Array, ObjectDefineProperty, ObjectSetPrototypeOf, + Symbol, } = primordials; module.exports = Writable; Writable.WritableState = WritableState; const internalUtil = require('internal/util'); +const EE = require('events'); const Stream = require('stream'); const { Buffer } = require('buffer'); const destroyImpl = require('internal/streams/destroy'); @@ -254,7 +256,7 @@ function Writable(options) { this._final = options.final; } - Stream.call(this); + Stream.call(this, options); } // Otherwise people can pipe Writable streams, which is just wrong. @@ -804,3 +806,7 @@ Writable.prototype._undestroy = destroyImpl.undestroy; Writable.prototype._destroy = function(err, cb) { cb(err); }; + +Writable.prototype[EE.captureRejectionSymbol] = function(err) { + this.destroy(err); +}; diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js index 530a41a1e855fd..5d7a5c8e281047 100644 --- a/lib/_tls_wrap.js +++ b/lib/_tls_wrap.js @@ -25,6 +25,8 @@ const { ObjectAssign, ObjectDefineProperty, ObjectSetPrototypeOf, + Symbol, + SymbolFor, } = primordials; const { @@ -37,6 +39,7 @@ assertCrypto(); const { setImmediate } = require('timers'); const assert = require('internal/assert'); const crypto = require('crypto'); +const EE = require('events'); const net = require('net'); const tls = require('tls'); const common = require('_tls_common'); @@ -1284,6 +1287,19 @@ Server.prototype.addContext = function(servername, context) { this._contexts.push([re, tls.createSecureContext(context).context]); }; +Server.prototype[EE.captureRejectionSymbol] = function( + err, event, sock) { + + switch (event) { + case 'secureConnection': + sock.destroy(err); + break; + default: + net.Server.prototype[SymbolFor('nodejs.rejection')] + .call(this, err, event, sock); + } +}; + function SNICallback(servername, callback) { const contexts = this.server._contexts; diff --git a/lib/async_hooks.js b/lib/async_hooks.js index a7ca5af7ef8105..be32f6d1102bbd 100644 --- a/lib/async_hooks.js +++ b/lib/async_hooks.js @@ -3,6 +3,7 @@ const { NumberIsSafeInteger, ReflectApply, + Symbol, } = primordials; const { diff --git a/lib/buffer.js b/lib/buffer.js index 8cbc0af538dbba..e318efc6540165 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -34,6 +34,7 @@ const { ObjectDefineProperties, ObjectDefineProperty, ObjectSetPrototypeOf, + Symbol, } = primordials; const { diff --git a/lib/domain.js b/lib/domain.js index 322e7eb9586c35..4f340f20ec34c3 100644 --- a/lib/domain.js +++ b/lib/domain.js @@ -30,6 +30,7 @@ const { Array, ObjectDefineProperty, ReflectApply, + Symbol, } = primordials; const EventEmitter = require('events'); diff --git a/lib/events.js b/lib/events.js index a09333af443534..13ecbd9ea87433 100644 --- a/lib/events.js +++ b/lib/events.js @@ -23,6 +23,7 @@ const { Array, + Boolean, MathMin, NumberIsNaN, ObjectCreate, @@ -31,7 +32,10 @@ const { ObjectKeys, ReflectApply, ReflectOwnKeys, + Symbol, + SymbolFor, } = primordials; +const kRejection = SymbolFor('nodejs.rejection'); let spliceOne; @@ -49,8 +53,10 @@ const { inspect } = require('internal/util/inspect'); -function EventEmitter() { - EventEmitter.init.call(this); +const kCapture = Symbol('kCapture'); + +function EventEmitter(opts) { + EventEmitter.init.call(this, opts); } module.exports = EventEmitter; module.exports.once = once; @@ -60,6 +66,29 @@ EventEmitter.EventEmitter = EventEmitter; EventEmitter.usingDomains = false; +EventEmitter.captureRejectionSymbol = kRejection; +ObjectDefineProperty(EventEmitter, 'captureRejections', { + get() { + return EventEmitter.prototype[kCapture]; + }, + set(value) { + if (typeof value !== 'boolean') { + throw new ERR_INVALID_ARG_TYPE('EventEmitter.captureRejections', + 'boolean', value); + } + + EventEmitter.prototype[kCapture] = value; + }, + enumerable: true +}); + +// The default for captureRejections is false +ObjectDefineProperty(EventEmitter.prototype, kCapture, { + value: false, + writable: true, + enumerable: false +}); + EventEmitter.prototype._events = undefined; EventEmitter.prototype._eventsCount = 0; EventEmitter.prototype._maxListeners = undefined; @@ -89,7 +118,7 @@ ObjectDefineProperty(EventEmitter, 'defaultMaxListeners', { } }); -EventEmitter.init = function() { +EventEmitter.init = function(opts) { if (this._events === undefined || this._events === ObjectGetPrototypeOf(this)._events) { @@ -98,8 +127,64 @@ EventEmitter.init = function() { } this._maxListeners = this._maxListeners || undefined; + + + if (opts && opts.captureRejections) { + if (typeof opts.captureRejections !== 'boolean') { + throw new ERR_INVALID_ARG_TYPE('options.captureRejections', + 'boolean', opts.captureRejections); + } + this[kCapture] = Boolean(opts.captureRejections); + } else { + // Assigning it directly a prototype lookup, as it slighly expensive + // and it sits in a very sensitive hot path. + this[kCapture] = EventEmitter.prototype[kCapture]; + } }; +function addCatch(that, promise, type, args) { + if (!that[kCapture]) { + return; + } + + // Handle Promises/A+ spec, then could be a getter + // that throws on second use. + try { + const then = promise.then; + + if (typeof then === 'function') { + then.call(promise, undefined, function(err) { + // The callback is called with nextTick to avoid a follow-up + // rejection from this promise. + process.nextTick(emitUnhandledRejectionOrErr, that, err, type, args); + }); + } + } catch (err) { + that.emit('error', err); + } +} + +function emitUnhandledRejectionOrErr(ee, err, type, args) { + if (typeof ee[kRejection] === 'function') { + ee[kRejection](err, type, ...args); + } else { + // We have to disable the capture rejections mechanism, otherwise + // we might end up in an infinite loop. + const prev = ee[kCapture]; + + // If the error handler throws, it is not catcheable and it + // will end up in 'uncaughtException'. We restore the previous + // value of kCapture in case the uncaughtException is present + // and the exception is handled. + try { + ee[kCapture] = false; + ee.emit('error', err); + } finally { + ee[kCapture] = prev; + } + } +} + // Obviously not all Emitters should be limited to 10. This function allows // that to be increased. Set to zero for unlimited. EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) { @@ -216,12 +301,29 @@ EventEmitter.prototype.emit = function emit(type, ...args) { return false; if (typeof handler === 'function') { - ReflectApply(handler, this, args); + const result = ReflectApply(handler, this, args); + + // We check if result is undefined first because that + // is the most common case so we do not pay any perf + // penalty + if (result !== undefined && result !== null) { + addCatch(this, result, type, args); + } } else { const len = handler.length; const listeners = arrayClone(handler, len); - for (let i = 0; i < len; ++i) - ReflectApply(listeners[i], this, args); + for (let i = 0; i < len; ++i) { + const result = ReflectApply(listeners[i], this, args); + + // We check if result is undefined first because that + // is the most common case so we do not pay any perf + // penalty. + // This code is duplicated because extracting it away + // would make it non-inlineable. + if (result !== undefined && result !== null) { + addCatch(this, result, type, args); + } + } } return true; diff --git a/lib/fs.js b/lib/fs.js index 6a5ebb8203af15..de37a0c2a0a704 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -234,7 +234,16 @@ function existsSync(path) { return false; } const ctx = { path }; - binding.access(pathModule.toNamespacedPath(path), F_OK, undefined, ctx); + const nPath = pathModule.toNamespacedPath(path); + binding.access(nPath, F_OK, undefined, ctx); + + // In case of an invalid symlink, `binding.access()` on win32 + // will **not** return an error and is therefore not enough. + // Double check with `binding.stat()`. + if (isWindows && ctx.errno === undefined) { + binding.stat(nPath, false, undefined, ctx); + } + return ctx.errno === undefined; } diff --git a/lib/inspector.js b/lib/inspector.js index 107500938377ce..203cd739a7ac06 100644 --- a/lib/inspector.js +++ b/lib/inspector.js @@ -3,6 +3,7 @@ const { JSONParse, JSONStringify, + Symbol, } = primordials; const { @@ -22,6 +23,7 @@ if (!hasInspector) throw new ERR_INSPECTOR_NOT_AVAILABLE(); const EventEmitter = require('events'); +const { queueMicrotask } = require('internal/process/task_queues'); const { validateString } = require('internal/validators'); const { isMainThread } = require('worker_threads'); diff --git a/lib/internal/async_hooks.js b/lib/internal/async_hooks.js index b17406c78241cd..bf5456a858870f 100644 --- a/lib/internal/async_hooks.js +++ b/lib/internal/async_hooks.js @@ -4,6 +4,7 @@ const { FunctionPrototypeBind, NumberIsSafeInteger, ObjectDefineProperty, + Symbol, } = primordials; const { diff --git a/lib/internal/bootstrap/loaders.js b/lib/internal/bootstrap/loaders.js index 044bea3114b840..cfefc56bd81bc8 100644 --- a/lib/internal/bootstrap/loaders.js +++ b/lib/internal/bootstrap/loaders.js @@ -157,9 +157,6 @@ function NativeModule(id) { this.loaded = false; this.loading = false; this.canBeRequiredByUsers = !id.startsWith('internal/'); - - if (id === 'wasi') - this.canBeRequiredByUsers = !!internalBinding('config').experimentalWasi; } // To be called during pre-execution when --expose-internals is on. diff --git a/lib/internal/bootstrap/pre_execution.js b/lib/internal/bootstrap/pre_execution.js index b3738015922a0c..0529bd6585261d 100644 --- a/lib/internal/bootstrap/pre_execution.js +++ b/lib/internal/bootstrap/pre_execution.js @@ -61,6 +61,7 @@ function prepareMainThreadExecution(expandArgv1 = false) { initializeClusterIPC(); initializeDeprecations(); + initializeWASI(); initializeCJSLoader(); initializeESMLoader(); @@ -399,6 +400,14 @@ function initializePolicy() { } } +function initializeWASI() { + if (getOptionValue('--experimental-wasi-unstable-preview0')) { + const { NativeModule } = require('internal/bootstrap/loaders'); + const mod = NativeModule.map.get('wasi'); + mod.canBeRequiredByUsers = true; + } +} + function initializeCJSLoader() { const CJSLoader = require('internal/modules/cjs/loader'); CJSLoader.Module._initPaths(); @@ -456,5 +465,6 @@ module.exports = { setupTraceCategoryState, setupInspectorHooks, initializeReport, - initializeCJSLoader + initializeCJSLoader, + initializeWASI }; diff --git a/lib/internal/buffer.js b/lib/internal/buffer.js index 8d55f780fadc2d..ff703f11fd648e 100644 --- a/lib/internal/buffer.js +++ b/lib/internal/buffer.js @@ -1,6 +1,7 @@ 'use strict'; const { + BigInt, MathFloor, Number, } = primordials; diff --git a/lib/internal/child_process.js b/lib/internal/child_process.js index 3836ee8e3d5ef5..b07a38d6f6f5ac 100644 --- a/lib/internal/child_process.js +++ b/lib/internal/child_process.js @@ -4,6 +4,7 @@ const { ArrayIsArray, ObjectDefineProperty, ObjectSetPrototypeOf, + Symbol, } = primordials; const { diff --git a/lib/internal/child_process/serialization.js b/lib/internal/child_process/serialization.js index 48b6d7ffe00bf6..9f03a8e8446c43 100644 --- a/lib/internal/child_process/serialization.js +++ b/lib/internal/child_process/serialization.js @@ -3,6 +3,7 @@ const { JSONParse, JSONStringify, + Symbol, } = primordials; const { Buffer } = require('buffer'); const { StringDecoder } = require('string_decoder'); diff --git a/lib/internal/console/constructor.js b/lib/internal/console/constructor.js index 76b2066e9b7fd0..85b88a72ea9290 100644 --- a/lib/internal/console/constructor.js +++ b/lib/internal/console/constructor.js @@ -15,6 +15,7 @@ const { ObjectPrototypeHasOwnProperty, ObjectValues, ReflectOwnKeys, + Symbol, } = primordials; const { trace } = internalBinding('trace_events'); diff --git a/lib/internal/crypto/hash.js b/lib/internal/crypto/hash.js index 56784275f9c0d2..dca0ba767f6e29 100644 --- a/lib/internal/crypto/hash.js +++ b/lib/internal/crypto/hash.js @@ -2,6 +2,7 @@ const { ObjectSetPrototypeOf, + Symbol, } = primordials; const { diff --git a/lib/internal/crypto/keys.js b/lib/internal/crypto/keys.js index 25ef8884953bc9..087cef014f0fb1 100644 --- a/lib/internal/crypto/keys.js +++ b/lib/internal/crypto/keys.js @@ -2,6 +2,7 @@ const { ObjectDefineProperty, + Symbol, } = primordials; const { diff --git a/lib/internal/crypto/util.js b/lib/internal/crypto/util.js index 8bf66e9cdf3268..286efc39a61e4f 100644 --- a/lib/internal/crypto/util.js +++ b/lib/internal/crypto/util.js @@ -1,5 +1,9 @@ 'use strict'; +const { + Symbol, +} = primordials; + const { getCiphers: _getCiphers, getCurves: _getCurves, diff --git a/lib/internal/dgram.js b/lib/internal/dgram.js index 0c0fefa27c1225..8a8d9ba8c0ddd4 100644 --- a/lib/internal/dgram.js +++ b/lib/internal/dgram.js @@ -1,4 +1,9 @@ 'use strict'; + +const { + Symbol, +} = primordials; + const { codes } = require('internal/errors'); const { UDP } = internalBinding('udp_wrap'); const { guessHandleType } = internalBinding('util'); diff --git a/lib/internal/encoding.js b/lib/internal/encoding.js index fe940f6e860497..c053a3cfa317c9 100644 --- a/lib/internal/encoding.js +++ b/lib/internal/encoding.js @@ -7,6 +7,7 @@ const { ObjectCreate, ObjectDefineProperties, ObjectGetOwnPropertyDescriptors, + Symbol, } = primordials; const { diff --git a/lib/internal/errors.js b/lib/internal/errors.js index f85253ec444256..ad12d99c7cc49c 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -16,6 +16,8 @@ const { NumberIsInteger, ObjectDefineProperty, ObjectKeys, + Symbol, + SymbolFor, } = primordials; const messages = new Map(); @@ -198,7 +200,7 @@ class SystemError extends Error { return `${this.name} [${this.code}]: ${this.message}`; } - [Symbol.for('nodejs.util.inspect.custom')](recurseTimes, ctx) { + [SymbolFor('nodejs.util.inspect.custom')](recurseTimes, ctx) { return lazyInternalUtilInspect().inspect(this, { ...ctx, getters: true, @@ -1123,7 +1125,26 @@ E('ERR_OUT_OF_RANGE', msg += ` It must be ${range}. Received ${received}`; return msg; }, RangeError); -E('ERR_REQUIRE_ESM', 'Must use import to load ES Module: %s', Error); +E('ERR_REQUIRE_ESM', + (filename, parentPath = null, packageJsonPath = null) => { + let msg = `Must use import to load ES Module: ${filename}`; + if (parentPath && packageJsonPath) { + const path = require('path'); + const basename = path.basename(filename) === path.basename(parentPath) ? + filename : path.basename(filename); + msg += + '\nrequire() of ES modules is not supported.\nrequire() of ' + + `${filename} ${parentPath ? `from ${parentPath} ` : ''}` + + 'is an ES module file as it is a .js file whose nearest parent ' + + 'package.json contains "type": "module" which defines all .js ' + + 'files in that package scope as ES modules.\nInstead rename ' + + `${basename} to end in .cjs, change the requiring code to use ` + + 'import(), or remove "type": "module" from ' + + `${packageJsonPath}.\n`; + return msg; + } + return msg; + }, Error); E('ERR_SCRIPT_EXECUTION_INTERRUPTED', 'Script execution was interrupted by `SIGINT`', Error); E('ERR_SERVER_ALREADY_LISTEN', @@ -1209,7 +1230,9 @@ E('ERR_UNHANDLED_ERROR', E('ERR_UNKNOWN_BUILTIN_MODULE', 'No such built-in module: %s', Error); E('ERR_UNKNOWN_CREDENTIAL', '%s identifier does not exist: %s', Error); E('ERR_UNKNOWN_ENCODING', 'Unknown encoding: %s', TypeError); -E('ERR_UNKNOWN_FILE_EXTENSION', 'Unknown file extension: %s', TypeError); +E('ERR_UNKNOWN_FILE_EXTENSION', + 'Unknown file extension "%s" for %s imported from %s', + TypeError); E('ERR_UNKNOWN_MODULE_FORMAT', 'Unknown module format: %s', RangeError); E('ERR_UNKNOWN_SIGNAL', 'Unknown signal: %s', TypeError); diff --git a/lib/internal/freeze_intrinsics.js b/lib/internal/freeze_intrinsics.js index 6135c3090dac25..60fff67f2e100c 100644 --- a/lib/internal/freeze_intrinsics.js +++ b/lib/internal/freeze_intrinsics.js @@ -31,7 +31,7 @@ module.exports = function() { getOwnPropertyDescriptors, getOwnPropertyNames, getOwnPropertySymbols, - getPrototypeOf + getPrototypeOf, } = Object; const objectHasOwnProperty = Object.prototype.hasOwnProperty; const { ownKeys } = Reflect; diff --git a/lib/internal/fs/dir.js b/lib/internal/fs/dir.js index c4e0a3746c125a..749e22ee696c6f 100644 --- a/lib/internal/fs/dir.js +++ b/lib/internal/fs/dir.js @@ -2,6 +2,7 @@ const { ObjectDefineProperty, + Symbol, } = primordials; const pathModule = require('path'); diff --git a/lib/internal/fs/promises.js b/lib/internal/fs/promises.js index daf18e19d1c784..cc3f98268c7e55 100644 --- a/lib/internal/fs/promises.js +++ b/lib/internal/fs/promises.js @@ -4,6 +4,7 @@ const { MathMax, MathMin, NumberIsSafeInteger, + Symbol, } = primordials; const { diff --git a/lib/internal/fs/rimraf.js b/lib/internal/fs/rimraf.js index 60310e1cf9427e..3402af60a4022f 100644 --- a/lib/internal/fs/rimraf.js +++ b/lib/internal/fs/rimraf.js @@ -5,6 +5,7 @@ // - Bring your own custom fs module is not currently supported. // - Some basic code cleanup. 'use strict'; +const { Buffer } = require('buffer'); const { chmod, chmodSync, @@ -19,14 +20,17 @@ const { unlink, unlinkSync } = require('fs'); -const { join } = require('path'); +const { sep } = require('path'); const { setTimeout } = require('timers'); +const { sleep } = require('internal/util'); const notEmptyErrorCodes = new Set(['ENOTEMPTY', 'EEXIST', 'EPERM']); const retryErrorCodes = new Set( ['EBUSY', 'EMFILE', 'ENFILE', 'ENOTEMPTY', 'EPERM']); const isWindows = process.platform === 'win32'; const epermHandler = isWindows ? fixWinEPERM : _rmdir; const epermHandlerSync = isWindows ? fixWinEPERMSync : _rmdirSync; +const readdirEncoding = 'buffer'; +const separator = Buffer.from(sep); function rimraf(path, options, callback) { @@ -115,7 +119,9 @@ function _rmdir(path, options, originalErr, callback) { function _rmchildren(path, options, callback) { - readdir(path, (err, files) => { + const pathBuf = Buffer.from(path); + + readdir(pathBuf, readdirEncoding, (err, files) => { if (err) return callback(err); @@ -127,7 +133,9 @@ function _rmchildren(path, options, callback) { let done = false; files.forEach((child) => { - rimraf(join(path, child), options, (err) => { + const childPath = Buffer.concat([pathBuf, separator, child]); + + rimraf(childPath, options, (err) => { if (done) return; @@ -176,7 +184,7 @@ function rimrafSync(path, options) { if (stats !== undefined && stats.isDirectory()) _rmdirSync(path, options, null); else - unlinkSync(path); + _unlinkSync(path, options); } catch (err) { if (err.code === 'ENOENT') return; @@ -190,6 +198,25 @@ function rimrafSync(path, options) { } +function _unlinkSync(path, options) { + const tries = options.maxRetries + 1; + + for (let i = 1; i <= tries; i++) { + try { + return unlinkSync(path); + } catch (err) { + // Only sleep if this is not the last try, and the delay is greater + // than zero, and an error was encountered that warrants a retry. + if (retryErrorCodes.has(err.code) && + i < tries && + options.retryDelay > 0) { + sleep(i * options.retryDelay); + } + } + } +} + + function _rmdirSync(path, options, originalErr) { try { rmdirSync(path); @@ -204,14 +231,28 @@ function _rmdirSync(path, options, originalErr) { // original removal. Windows has a habit of not closing handles promptly // when files are deleted, resulting in spurious ENOTEMPTY failures. Work // around that issue by retrying on Windows. - readdirSync(path).forEach((child) => { - rimrafSync(join(path, child), options); + const pathBuf = Buffer.from(path); + + readdirSync(pathBuf, readdirEncoding).forEach((child) => { + const childPath = Buffer.concat([pathBuf, separator, child]); + + rimrafSync(childPath, options); }); - for (let i = 0; i < options.maxRetries + 1; i++) { + const tries = options.maxRetries + 1; + + for (let i = 1; i <= tries; i++) { try { return rmdirSync(path, options); - } catch {} // Ignore errors. + } catch (err) { + // Only sleep if this is not the last try, and the delay is greater + // than zero, and an error was encountered that warrants a retry. + if (retryErrorCodes.has(err.code) && + i < tries && + options.retryDelay > 0) { + sleep(i * options.retryDelay); + } + } } } } @@ -242,7 +283,7 @@ function fixWinEPERMSync(path, options, originalErr) { if (stats.isDirectory()) _rmdirSync(path, options, originalErr); else - unlinkSync(path); + _unlinkSync(path, options); } diff --git a/lib/internal/fs/streams.js b/lib/internal/fs/streams.js index 7b17eae338aa46..880828e0d7ae57 100644 --- a/lib/internal/fs/streams.js +++ b/lib/internal/fs/streams.js @@ -7,10 +7,12 @@ const { NumberIsSafeInteger, ObjectDefineProperty, ObjectSetPrototypeOf, + Symbol, } = primordials; const { - ERR_OUT_OF_RANGE + ERR_OUT_OF_RANGE, + ERR_STREAM_DESTROYED } = require('internal/errors').codes; const internalUtil = require('internal/util'); const { validateNumber } = require('internal/validators'); @@ -22,6 +24,8 @@ const { } = require('internal/fs/utils'); const { Readable, Writable } = require('stream'); const { toPathIfFileURL } = require('internal/url'); +const kIoDone = Symbol('kIoDone'); +const kIsPerformingIO = Symbol('kIsPerformingIO'); const kMinPoolSpace = 128; @@ -86,6 +90,7 @@ function ReadStream(path, options) { this.pos = undefined; this.bytesRead = 0; this.closed = false; + this[kIsPerformingIO] = false; if (this.start !== undefined) { checkPosition(this.start, 'start'); @@ -155,6 +160,8 @@ ReadStream.prototype._read = function(n) { }); } + if (this.destroyed) return; + if (!pool || pool.length - pool.used < kMinPoolSpace) { // Discard the old pool. allocNewPool(this.readableHighWaterMark); @@ -178,7 +185,12 @@ ReadStream.prototype._read = function(n) { return this.push(null); // the actual read. + this[kIsPerformingIO] = true; fs.read(this.fd, pool, pool.used, toRead, this.pos, (er, bytesRead) => { + this[kIsPerformingIO] = false; + // Tell ._destroy() that it's safe to close the fd now. + if (this.destroyed) return this.emit(kIoDone, er); + if (er) { if (this.autoClose) { this.destroy(); @@ -224,8 +236,12 @@ ReadStream.prototype._destroy = function(err, cb) { return; } + if (this[kIsPerformingIO]) { + this.once(kIoDone, (er) => closeFsStream(this, cb, err || er)); + return; + } + closeFsStream(this, cb, err); - this.fd = null; }; function closeFsStream(stream, cb, err) { @@ -236,6 +252,8 @@ function closeFsStream(stream, cb, err) { if (!er) stream.emit('close'); }); + + stream.fd = null; } ReadStream.prototype.close = function(cb) { @@ -274,6 +292,7 @@ function WriteStream(path, options) { this.pos = undefined; this.bytesWritten = 0; this.closed = false; + this[kIsPerformingIO] = false; if (this.start !== undefined) { checkPosition(this.start, 'start'); @@ -339,7 +358,17 @@ WriteStream.prototype._write = function(data, encoding, cb) { }); } + if (this.destroyed) return cb(new ERR_STREAM_DESTROYED('write')); + + this[kIsPerformingIO] = true; fs.write(this.fd, data, 0, data.length, this.pos, (er, bytes) => { + this[kIsPerformingIO] = false; + // Tell ._destroy() that it's safe to close the fd now. + if (this.destroyed) { + cb(er); + return this.emit(kIoDone, er); + } + if (er) { if (this.autoClose) { this.destroy(); @@ -362,7 +391,8 @@ WriteStream.prototype._writev = function(data, cb) { }); } - const self = this; + if (this.destroyed) return cb(new ERR_STREAM_DESTROYED('write')); + const len = data.length; const chunks = new Array(len); let size = 0; @@ -374,12 +404,22 @@ WriteStream.prototype._writev = function(data, cb) { size += chunk.length; } - fs.writev(this.fd, chunks, this.pos, function(er, bytes) { + this[kIsPerformingIO] = true; + fs.writev(this.fd, chunks, this.pos, (er, bytes) => { + this[kIsPerformingIO] = false; + // Tell ._destroy() that it's safe to close the fd now. + if (this.destroyed) { + cb(er); + return this.emit(kIoDone, er); + } + if (er) { - self.destroy(); + if (this.autoClose) { + this.destroy(); + } return cb(er); } - self.bytesWritten += bytes; + this.bytesWritten += bytes; cb(); }); diff --git a/lib/internal/fs/utils.js b/lib/internal/fs/utils.js index 951030c5a50bd1..f75e71a914c217 100644 --- a/lib/internal/fs/utils.js +++ b/lib/internal/fs/utils.js @@ -2,11 +2,13 @@ const { ArrayIsArray, + BigInt, DateNow, Number, NumberIsFinite, ObjectSetPrototypeOf, ReflectOwnKeys, + Symbol, } = primordials; const { Buffer } = require('buffer'); diff --git a/lib/internal/fs/watchers.js b/lib/internal/fs/watchers.js index 7454ada7671140..bb039fb67f018c 100644 --- a/lib/internal/fs/watchers.js +++ b/lib/internal/fs/watchers.js @@ -3,6 +3,7 @@ const { ObjectDefineProperty, ObjectSetPrototypeOf, + Symbol, } = primordials; const errors = require('internal/errors'); diff --git a/lib/internal/http.js b/lib/internal/http.js index 09294888be5e70..aab4170a2f0e06 100644 --- a/lib/internal/http.js +++ b/lib/internal/http.js @@ -1,5 +1,9 @@ 'use strict'; +const { + Symbol, +} = primordials; + const { setUnrefTimeout } = require('internal/timers'); const { PerformanceEntry, notify } = internalBinding('performance'); diff --git a/lib/internal/http2/compat.js b/lib/internal/http2/compat.js index 6a55b4edd19311..94282cc4bb572a 100644 --- a/lib/internal/http2/compat.js +++ b/lib/internal/http2/compat.js @@ -8,6 +8,7 @@ const { ObjectKeys, ObjectPrototypeHasOwnProperty, ReflectGetPrototypeOf, + Symbol, } = primordials; const assert = require('internal/assert'); diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js index c4d12f9205151c..36e36ec940975f 100644 --- a/lib/internal/http2/core.js +++ b/lib/internal/http2/core.js @@ -11,6 +11,7 @@ const { ObjectDefineProperty, ObjectPrototypeHasOwnProperty, ReflectGetPrototypeOf, + Symbol, } = primordials; const { @@ -159,7 +160,7 @@ function debugStream(id, sessionType, message, ...args) { } function debugStreamObj(stream, message, ...args) { - debugStream(stream[kID], stream[kSession][kType], ...args); + debugStream(stream[kID], stream[kSession][kType], message, ...args); } function debugSession(sessionType, message, ...args) { @@ -1388,6 +1389,17 @@ class Http2Session extends EventEmitter { this[kMaybeDestroy](); } + [EventEmitter.captureRejectionSymbol](err, event, ...args) { + switch (event) { + case 'stream': + const [stream] = args; + stream.destroy(err); + break; + default: + this.destroy(err); + } + } + // Destroy the session if: // * error is not undefined/null // * session is closed and there are no more pending or open streams @@ -2875,6 +2887,40 @@ class Http2Server extends NETServer { } } +Http2Server.prototype[EventEmitter.captureRejectionSymbol] = function( + err, event, ...args) { + + switch (event) { + case 'stream': + // TODO(mcollina): we might want to match this with what we do on + // the compat side. + const [stream] = args; + if (stream.sentHeaders) { + stream.destroy(err); + } else { + stream.respond({ [HTTP2_HEADER_STATUS]: 500 }); + stream.end(); + } + break; + case 'request': + const [, res] = args; + if (!res.headersSent && !res.finished) { + // Don't leak headers. + for (const name of res.getHeaderNames()) { + res.removeHeader(name); + } + res.statusCode = 500; + res.end(http.STATUS_CODES[500]); + } else { + res.destroy(); + } + break; + default: + net.Server.prototype[EventEmitter.captureRejectionSymbol] + .call(this, err, event, ...args); + } +}; + function setupCompat(ev) { if (ev === 'request') { this.removeListener('newListener', setupCompat); diff --git a/lib/internal/http2/util.js b/lib/internal/http2/util.js index d97ce2f13f0306..3bf3a8fdd56df9 100644 --- a/lib/internal/http2/util.js +++ b/lib/internal/http2/util.js @@ -6,6 +6,7 @@ const { Number, ObjectCreate, ObjectKeys, + Symbol, } = primordials; const binding = internalBinding('http2'); diff --git a/lib/internal/js_stream_socket.js b/lib/internal/js_stream_socket.js index 7c35a55b1c9455..1a805ae830bdb2 100644 --- a/lib/internal/js_stream_socket.js +++ b/lib/internal/js_stream_socket.js @@ -1,5 +1,9 @@ 'use strict'; +const { + Symbol, +} = primordials; + const { setImmediate } = require('timers'); const assert = require('internal/assert'); const { Socket } = require('net'); diff --git a/lib/internal/main/worker_thread.js b/lib/internal/main/worker_thread.js index 95fa3026fda90b..3b7a2ef873ffab 100644 --- a/lib/internal/main/worker_thread.js +++ b/lib/internal/main/worker_thread.js @@ -14,6 +14,7 @@ const { setupWarningHandler, setupDebugEnv, initializeDeprecations, + initializeWASI, initializeCJSLoader, initializeESMLoader, initializeFrozenIntrinsics, @@ -92,6 +93,7 @@ if (process.env.NODE_CHANNEL_FD) { port.on('message', (message) => { if (message.type === LOAD_SCRIPT) { const { + argv, cwdCounter, filename, doEval, @@ -108,6 +110,7 @@ port.on('message', (message) => { require('internal/process/policy').setup(manifestSrc, manifestURL); } initializeDeprecations(); + initializeWASI(); initializeCJSLoader(); initializeESMLoader(); @@ -115,6 +118,9 @@ port.on('message', (message) => { assert(!CJSLoader.hasLoadedAnyUserCJSModule); loadPreloadModules(); initializeFrozenIntrinsics(); + if (argv !== undefined) { + process.argv = process.argv.concat(argv); + } publicWorker.parentPort = publicPort; publicWorker.workerData = workerData; @@ -143,12 +149,22 @@ port.on('message', (message) => { port.postMessage({ type: UP_AND_RUNNING }); if (doEval) { const { evalScript } = require('internal/process/execution'); - evalScript('[worker eval]', filename); + const name = '[worker eval]'; + // This is necessary for CJS module compilation. + // TODO: pass this with something really internal. + ObjectDefineProperty(process, '_eval', { + configurable: true, + enumerable: true, + value: filename, + }); + process.argv.splice(1, 0, name); + evalScript(name, filename); } else { // script filename // runMain here might be monkey-patched by users in --require. // XXX: the monkey-patchability here should probably be deprecated. - CJSLoader.Module.runMain(process.argv[1] = filename); + process.argv.splice(1, 0, filename); + CJSLoader.Module.runMain(filename); } } else if (message.type === STDIO_PAYLOAD) { const { stream, chunk, encoding } = message; diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js index d962bc2a4cec30..95e2c18906eb31 100644 --- a/lib/internal/modules/cjs/loader.js +++ b/lib/internal/modules/cjs/loader.js @@ -43,7 +43,7 @@ const { rekeySourceMap } = require('internal/source_map/source_map_cache'); const { pathToFileURL, fileURLToPath, URL } = require('internal/url'); -const { deprecate } = require('internal/util'); +const { deprecate, emitExperimentalWarning } = require('internal/util'); const vm = require('vm'); const assert = require('internal/assert'); const fs = require('fs'); @@ -582,19 +582,23 @@ function resolveExportsTarget(pkgPath, target, subpath, basePath, mappingKey) { } } else if (typeof target === 'object' && target !== null) { if (experimentalConditionalExports && - ObjectPrototypeHasOwnProperty(target, 'require')) { + ObjectPrototypeHasOwnProperty(target, 'node')) { try { - return resolveExportsTarget(pkgPath, target.require, subpath, - basePath, mappingKey); + const result = resolveExportsTarget(pkgPath, target.node, subpath, + basePath, mappingKey); + emitExperimentalWarning('Conditional exports'); + return result; } catch (e) { if (e.code !== 'MODULE_NOT_FOUND') throw e; } } if (experimentalConditionalExports && - ObjectPrototypeHasOwnProperty(target, 'node')) { + ObjectPrototypeHasOwnProperty(target, 'require')) { try { - return resolveExportsTarget(pkgPath, target.node, subpath, - basePath, mappingKey); + const result = resolveExportsTarget(pkgPath, target.require, subpath, + basePath, mappingKey); + emitExperimentalWarning('Conditional exports'); + return result; } catch (e) { if (e.code !== 'MODULE_NOT_FOUND') throw e; } @@ -697,6 +701,7 @@ Module._findPath = function(request, paths, isMain) { const selfFilename = trySelf(paths, exts, isMain, trailingSlash, request); if (selfFilename) { + emitExperimentalWarning('Package name self resolution'); Module._pathCache[cacheKey] = selfFilename; return selfFilename; } @@ -808,11 +813,11 @@ Module._resolveLookupPaths = function(request, parent) { return paths.length > 0 ? paths : null; } - // With --eval, parent.id is not set and parent.filename is null. + // In REPL, parent.filename is null. if (!parent || !parent.id || !parent.filename) { // Make require('./path/to/foo') work - normally the path is taken - // from realpath(__filename) but with eval there is no filename - const mainPaths = ['.'].concat(Module._nodeModulePaths('.'), modulePaths); + // from realpath(__filename) but in REPL there is no filename + const mainPaths = ['.']; debug('looking for %j in %j', request, mainPaths); return mainPaths; @@ -1102,14 +1107,20 @@ Module.prototype._compile = function(content, filename) { if (!resolvedArgv) { // We enter the repl if we're not given a filename argument. if (process.argv[1]) { - resolvedArgv = Module._resolveFilename(process.argv[1], null, false); + try { + resolvedArgv = Module._resolveFilename(process.argv[1], null, false); + } catch { + // We only expect this codepath to be reached in the case of a + // preloaded module (it will fail earlier with the main entry) + assert(ArrayIsArray(getOptionValue('--require'))); + } } else { resolvedArgv = 'repl'; } } // Set breakpoint on module start - if (!hasPausedEntry && filename === resolvedArgv) { + if (resolvedArgv && !hasPausedEntry && filename === resolvedArgv) { hasPausedEntry = true; inspectorWrapper = internalBinding('inspector').callAndPauseOnStart; } @@ -1134,33 +1145,14 @@ Module.prototype._compile = function(content, filename) { }; // Native extension for .js -let warnRequireESM = true; Module._extensions['.js'] = function(module, filename) { if (filename.endsWith('.js')) { const pkg = readPackageScope(filename); + // Function require shouldn't be used in ES modules. if (pkg && pkg.data && pkg.data.type === 'module') { - if (warnRequireESM) { - const parentPath = module.parent && module.parent.filename; - const basename = parentPath && - path.basename(filename) === path.basename(parentPath) ? - filename : path.basename(filename); - process.emitWarning( - 'require() of ES modules is not supported.\nrequire() of ' + - `${filename} ${parentPath ? `from ${module.parent.filename} ` : ''}` + - 'is an ES module file as it is a .js file whose nearest parent ' + - 'package.json contains "type": "module" which defines all .js ' + - 'files in that package scope as ES modules.\nInstead rename ' + - `${basename} to end in .cjs, change the requiring code to use ` + - 'import(), or remove "type": "module" from ' + - `${path.resolve(pkg.path, 'package.json')}.`, - undefined, - undefined, - undefined, - true - ); - warnRequireESM = false; - } - throw new ERR_REQUIRE_ESM(filename); + const parentPath = module.parent && module.parent.filename; + const packageJsonPath = path.resolve(pkg.path, 'package.json'); + throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath); } } const content = fs.readFileSync(filename, 'utf8'); diff --git a/lib/internal/modules/esm/default_resolve.js b/lib/internal/modules/esm/default_resolve.js index 169c6f35694f24..d238930164dcf4 100644 --- a/lib/internal/modules/esm/default_resolve.js +++ b/lib/internal/modules/esm/default_resolve.js @@ -13,8 +13,8 @@ const { getOptionValue } = require('internal/options'); const preserveSymlinks = getOptionValue('--preserve-symlinks'); const preserveSymlinksMain = getOptionValue('--preserve-symlinks-main'); const experimentalJsonModules = getOptionValue('--experimental-json-modules'); -const esModuleSpecifierResolution = - getOptionValue('--es-module-specifier-resolution'); +const experimentalSpeciferResolution = + getOptionValue('--experimental-specifier-resolution'); const typeFlag = getOptionValue('--input-type'); const experimentalWasmModules = getOptionValue('--experimental-wasm-modules'); const { resolve: moduleWrapResolve, @@ -110,10 +110,17 @@ function resolve(specifier, parentURL) { if (ext === '.js' || (!format && isMain)) format = getPackageType(url.href) === TYPE_MODULE ? 'module' : 'commonjs'; if (!format) { - if (esModuleSpecifierResolution === 'node') + if (experimentalSpeciferResolution === 'node') { + process.emitWarning( + 'The Node.js specifier resolution in ESM is experimental.', + 'ExperimentalWarning'); format = legacyExtensionFormatMap[ext]; - else - throw new ERR_UNKNOWN_FILE_EXTENSION(fileURLToPath(url)); + } else { + throw new ERR_UNKNOWN_FILE_EXTENSION( + ext, + fileURLToPath(url), + fileURLToPath(parentURL)); + } } return { url: `${url}`, format }; } diff --git a/lib/internal/modules/esm/loader.js b/lib/internal/modules/esm/loader.js index 97f57935292396..255e5d2aba7bd8 100644 --- a/lib/internal/modules/esm/loader.js +++ b/lib/internal/modules/esm/loader.js @@ -25,7 +25,6 @@ const defaultResolve = require('internal/modules/esm/default_resolve'); const createDynamicModule = require( 'internal/modules/esm/create_dynamic_module'); const { translators } = require('internal/modules/esm/translators'); -const { ModuleWrap } = internalBinding('module_wrap'); const { getOptionValue } = require('internal/options'); const debug = require('internal/util/debuglog').debuglog('esm'); @@ -117,7 +116,17 @@ class Loader { source, url = pathToFileURL(`${process.cwd()}/[eval${++this.evalIndex}]`).href ) { - const evalInstance = (url) => new ModuleWrap(url, undefined, source, 0, 0); + const evalInstance = (url) => { + const { ModuleWrap, callbackMap } = internalBinding('module_wrap'); + const module = new ModuleWrap(url, undefined, source, 0, 0); + callbackMap.set(module, { + importModuleDynamically: (specifier, { url }) => { + return this.import(specifier, url); + } + }); + + return module; + }; const job = new ModuleJob(this, url, evalInstance, false, false); this.moduleMap.set(url, job); const { module, result } = await job.run(); diff --git a/lib/internal/modules/esm/translators.js b/lib/internal/modules/esm/translators.js index dafc1b02f03112..99e4c014053202 100644 --- a/lib/internal/modules/esm/translators.js +++ b/lib/internal/modules/esm/translators.js @@ -22,7 +22,7 @@ const createDynamicModule = require( const fs = require('fs'); const { fileURLToPath, URL } = require('url'); const { debuglog } = require('internal/util/debuglog'); -const { promisify } = require('internal/util'); +const { promisify, emitExperimentalWarning } = require('internal/util'); const { ERR_INVALID_URL, ERR_INVALID_URL_SCHEME, @@ -133,6 +133,7 @@ translators.set('builtin', async function builtinStrategy(url) { // Strategy for loading a JSON file translators.set('json', async function jsonStrategy(url) { + emitExperimentalWarning('Importing JSON modules'); debug(`Translating JSONModule ${url}`); debug(`Loading JSONModule ${url}`); const pathname = url.startsWith('file:') ? fileURLToPath(url) : null; @@ -187,6 +188,7 @@ translators.set('json', async function jsonStrategy(url) { // Strategy for loading a wasm module translators.set('wasm', async function(url) { + emitExperimentalWarning('Importing Web Assembly modules'); const buffer = await getSource(url); debug(`Translating WASMModule ${url}`); let compiled; diff --git a/lib/internal/net.js b/lib/internal/net.js index bbdc9bf8437c39..5f6e476b58295d 100644 --- a/lib/internal/net.js +++ b/lib/internal/net.js @@ -1,5 +1,9 @@ 'use strict'; +const { + Symbol, +} = primordials; + const Buffer = require('buffer').Buffer; const { writeBuffer } = internalBinding('fs'); const errors = require('internal/errors'); diff --git a/lib/internal/priority_queue.js b/lib/internal/priority_queue.js index afd2cef643b9e5..c31c1eea385857 100644 --- a/lib/internal/priority_queue.js +++ b/lib/internal/priority_queue.js @@ -2,6 +2,7 @@ const { Array, + Symbol, } = primordials; const kCompare = Symbol('compare'); diff --git a/lib/internal/process/esm_loader.js b/lib/internal/process/esm_loader.js index 19099d9cbd58fd..404be77338bfe1 100644 --- a/lib/internal/process/esm_loader.js +++ b/lib/internal/process/esm_loader.js @@ -24,6 +24,12 @@ exports.initializeImportMetaObject = function(wrap, meta) { exports.importModuleDynamicallyCallback = async function(wrap, specifier) { assert(calledInitialize === true || !userLoader); + if (!calledInitialize) { + process.emitWarning( + 'The ESM module loader is experimental.', + 'ExperimentalWarning', undefined); + calledInitialize = true; + } const { callbackMap } = internalBinding('module_wrap'); if (callbackMap.has(wrap)) { const { importModuleDynamically } = callbackMap.get(wrap); diff --git a/lib/internal/process/execution.js b/lib/internal/process/execution.js index 44c67452f5a01f..8b15fbbae46f26 100644 --- a/lib/internal/process/execution.js +++ b/lib/internal/process/execution.js @@ -57,6 +57,7 @@ function evalModule(source, print) { function evalScript(name, body, breakFirstLine, print) { const CJSModule = require('internal/modules/cjs/loader').Module; const { kVmBreakFirstLineSymbol } = require('internal/util'); + const { pathToFileURL } = require('url'); const cwd = tryGetCwd(); const origModule = global.module; // Set e.g. when called from the REPL. @@ -64,20 +65,30 @@ function evalScript(name, body, breakFirstLine, print) { const module = new CJSModule(name); module.filename = path.join(cwd, name); module.paths = CJSModule._nodeModulePaths(cwd); + global.kVmBreakFirstLineSymbol = kVmBreakFirstLineSymbol; + global.asyncESM = require('internal/process/esm_loader'); + + const baseUrl = pathToFileURL(module.filename).href; + const script = ` global.__filename = ${JSONStringify(name)}; global.exports = exports; global.module = module; global.__dirname = __dirname; global.require = require; - const { kVmBreakFirstLineSymbol } = global; + const { kVmBreakFirstLineSymbol, asyncESM } = global; delete global.kVmBreakFirstLineSymbol; + delete global.asyncESM; return require("vm").runInThisContext( ${JSONStringify(body)}, { filename: ${JSONStringify(name)}, displayErrors: true, - [kVmBreakFirstLineSymbol]: ${!!breakFirstLine} + [kVmBreakFirstLineSymbol]: ${!!breakFirstLine}, + async importModuleDynamically (specifier) { + const loader = await asyncESM.ESMLoader; + return loader.import(specifier, ${JSONStringify(baseUrl)}); + } });\n`; const result = module._compile(script, `${name}-wrapper`); if (print) { diff --git a/lib/internal/repl/utils.js b/lib/internal/repl/utils.js index d60b33208883d4..c4280c1d1fe9e2 100644 --- a/lib/internal/repl/utils.js +++ b/lib/internal/repl/utils.js @@ -1,6 +1,12 @@ 'use strict'; -const acorn = require('internal/deps/acorn/acorn/dist/acorn'); +const { + MathMin, + Symbol, +} = primordials; + +const { tokTypes: tt, Parser: AcornParser } = + require('internal/deps/acorn/acorn/dist/acorn'); const privateMethods = require('internal/deps/acorn-plugins/acorn-private-methods/index'); const classFields = @@ -9,7 +15,30 @@ const numericSeparator = require('internal/deps/acorn-plugins/acorn-numeric-separator/index'); const staticClassFeatures = require('internal/deps/acorn-plugins/acorn-static-class-features/index'); -const { tokTypes: tt, Parser: AcornParser } = acorn; + +const { sendInspectorCommand } = require('internal/util/inspector'); + +const { + ERR_INSPECTOR_NOT_AVAILABLE +} = require('internal/errors').codes; + +const { + clearLine, + cursorTo, + moveCursor, +} = require('readline'); + +const { inspect } = require('util'); + +const debug = require('internal/util/debuglog').debuglog('repl'); + +const inspectOptions = { + depth: 1, + colors: false, + compact: true, + breakLength: Infinity +}; +const inspectedOptions = inspect(inspectOptions, { colors: false }); // If the error is that we've unexpectedly ended the input, // then let the user try to recover by adding more input. @@ -87,7 +116,144 @@ function isRecoverableError(e, code) { } } +function setupPreview(repl, contextSymbol, bufferSymbol, active) { + // Simple terminals can't handle previews. + if (process.env.TERM === 'dumb' || !active) { + return { showInputPreview() {}, clearPreview() {} }; + } + + let preview = null; + let lastPreview = ''; + + const clearPreview = () => { + if (preview !== null) { + moveCursor(repl.output, 0, 1); + clearLine(repl.output); + moveCursor(repl.output, 0, -1); + lastPreview = preview; + preview = null; + } + }; + + // This returns a code preview for arbitrary input code. + function getPreviewInput(input, callback) { + // For similar reasons as `defaultEval`, wrap expressions starting with a + // curly brace with parenthesis. + if (input.startsWith('{') && !input.endsWith(';')) { + input = `(${input})`; + } + sendInspectorCommand((session) => { + session.post('Runtime.evaluate', { + expression: input, + throwOnSideEffect: true, + timeout: 333, + contextId: repl[contextSymbol], + }, (error, preview) => { + if (error) { + callback(error); + return; + } + const { result } = preview; + if (result.value !== undefined) { + callback(null, inspect(result.value, inspectOptions)); + // Ignore EvalErrors, SyntaxErrors and ReferenceErrors. It is not clear + // where they came from and if they are recoverable or not. Other errors + // may be inspected. + } else if (preview.exceptionDetails && + (result.className === 'EvalError' || + result.className === 'SyntaxError' || + result.className === 'ReferenceError')) { + callback(null, null); + } else if (result.objectId) { + session.post('Runtime.callFunctionOn', { + functionDeclaration: `(v) => util.inspect(v, ${inspectedOptions})`, + objectId: result.objectId, + arguments: [result] + }, (error, preview) => { + if (error) { + callback(error); + } else { + callback(null, preview.result.value); + } + }); + } else { + // Either not serializable or undefined. + callback(null, result.unserializableValue || result.type); + } + }); + }, () => callback(new ERR_INSPECTOR_NOT_AVAILABLE())); + } + + const showInputPreview = () => { + // Prevent duplicated previews after a refresh. + if (preview !== null) { + return; + } + + const line = repl.line.trim(); + + // Do not preview if the command is buffered or if the line is empty. + if (repl[bufferSymbol] || line === '') { + return; + } + + getPreviewInput(line, (error, inspected) => { + // Ignore the output if the value is identical to the current line and the + // former preview is not identical to this preview. + if ((line === inspected && lastPreview !== inspected) || + inspected === null) { + return; + } + if (error) { + debug('Error while generating preview', error); + return; + } + // Do not preview `undefined` if colors are deactivated or explicitly + // requested. + if (inspected === 'undefined' && + (!repl.useColors || repl.ignoreUndefined)) { + return; + } + + preview = inspected; + + // Limit the output to maximum 250 characters. Otherwise it becomes a) + // difficult to read and b) non terminal REPLs would visualize the whole + // output. + const maxColumns = MathMin(repl.columns, 250); + + if (inspected.length > maxColumns) { + inspected = `${inspected.slice(0, maxColumns - 6)}...`; + } + const lineBreakPos = inspected.indexOf('\n'); + if (lineBreakPos !== -1) { + inspected = `${inspected.slice(0, lineBreakPos)}`; + } + const result = repl.useColors ? + `\u001b[90m${inspected}\u001b[39m` : + `// ${inspected}`; + + repl.output.write(`\n${result}`); + moveCursor(repl.output, 0, -1); + cursorTo(repl.output, repl.cursor + repl._prompt.length); + }); + }; + + // Refresh prints the whole screen again and the preview will be removed + // during that procedure. Print the preview again. This also makes sure + // the preview is always correct after resizing the terminal window. + const tmpRefresh = repl._refreshLine.bind(repl); + repl._refreshLine = () => { + preview = null; + tmpRefresh(); + showInputPreview(); + }; + + return { showInputPreview, clearPreview }; +} + module.exports = { isRecoverableError, - kStandaloneREPL: Symbol('kStandaloneREPL') + kStandaloneREPL: Symbol('kStandaloneREPL'), + setupPreview }; diff --git a/lib/internal/stream_base_commons.js b/lib/internal/stream_base_commons.js index 504de5fc57f9ab..800ba4cefd6370 100644 --- a/lib/internal/stream_base_commons.js +++ b/lib/internal/stream_base_commons.js @@ -2,6 +2,7 @@ const { Array, + Symbol, } = primordials; const { Buffer } = require('buffer'); diff --git a/lib/internal/streams/async_iterator.js b/lib/internal/streams/async_iterator.js index e05813e5dfd947..a6b8bd9d181c38 100644 --- a/lib/internal/streams/async_iterator.js +++ b/lib/internal/streams/async_iterator.js @@ -4,6 +4,7 @@ const { ObjectCreate, ObjectGetPrototypeOf, ObjectSetPrototypeOf, + Symbol, } = primordials; const finished = require('internal/streams/end-of-stream'); diff --git a/lib/internal/streams/buffer_list.js b/lib/internal/streams/buffer_list.js index 5e23f2cf464f6c..fc8dd1b1f0fded 100644 --- a/lib/internal/streams/buffer_list.js +++ b/lib/internal/streams/buffer_list.js @@ -1,5 +1,9 @@ 'use strict'; +const { + SymbolIterator, +} = primordials; + const { Buffer } = require('buffer'); const { inspect } = require('internal/util/inspect'); @@ -90,7 +94,7 @@ module.exports = class BufferList { return this.head.data; } - *[Symbol.iterator]() { + *[SymbolIterator]() { for (let p = this.head; p; p = p.next) { yield p.data; } diff --git a/lib/internal/streams/duplexpair.js b/lib/internal/streams/duplexpair.js index 6735bcb2b92531..ec92cbe8716df4 100644 --- a/lib/internal/streams/duplexpair.js +++ b/lib/internal/streams/duplexpair.js @@ -1,4 +1,9 @@ 'use strict'; + +const { + Symbol, +} = primordials; + const { Duplex } = require('stream'); const kCallback = Symbol('Callback'); diff --git a/lib/internal/streams/from.js b/lib/internal/streams/from.js index e809f2658d5a9a..a060638df2dcfe 100644 --- a/lib/internal/streams/from.js +++ b/lib/internal/streams/from.js @@ -1,5 +1,10 @@ 'use strict'; +const { + Symbol, + SymbolIterator +} = primordials; + const { ERR_INVALID_ARG_TYPE } = require('internal/errors').codes; @@ -8,8 +13,8 @@ function from(Readable, iterable, opts) { let iterator; if (iterable && iterable[Symbol.asyncIterator]) iterator = iterable[Symbol.asyncIterator](); - else if (iterable && iterable[Symbol.iterator]) - iterator = iterable[Symbol.iterator](); + else if (iterable && iterable[SymbolIterator]) + iterator = iterable[SymbolIterator](); else throw new ERR_INVALID_ARG_TYPE('iterable', ['Iterable'], iterable); diff --git a/lib/internal/streams/legacy.js b/lib/internal/streams/legacy.js index 702e3c56ba6376..2bc7a86aa050b6 100644 --- a/lib/internal/streams/legacy.js +++ b/lib/internal/streams/legacy.js @@ -6,8 +6,8 @@ const { const EE = require('events'); -function Stream() { - EE.call(this); +function Stream(opts) { + EE.call(this, opts); } ObjectSetPrototypeOf(Stream.prototype, EE.prototype); ObjectSetPrototypeOf(Stream, EE); diff --git a/lib/internal/timers.js b/lib/internal/timers.js index 84b3c34d87cfaf..1b6422f41ea7af 100644 --- a/lib/internal/timers.js +++ b/lib/internal/timers.js @@ -77,6 +77,7 @@ const { MathTrunc, NumberMIN_SAFE_INTEGER, ObjectCreate, + Symbol, } = primordials; const { diff --git a/lib/internal/trace_events_async_hooks.js b/lib/internal/trace_events_async_hooks.js index 87ee63d8ba7426..84c7745e47368f 100644 --- a/lib/internal/trace_events_async_hooks.js +++ b/lib/internal/trace_events_async_hooks.js @@ -4,6 +4,7 @@ const { ObjectKeys, SafeMap, SafeSet, + Symbol, } = primordials; const { trace } = internalBinding('trace_events'); diff --git a/lib/internal/url.js b/lib/internal/url.js index 3c75baf27b0973..f396ec320cfccd 100644 --- a/lib/internal/url.js +++ b/lib/internal/url.js @@ -11,6 +11,8 @@ const { ObjectKeys, ReflectGetOwnPropertyDescriptor, ReflectOwnKeys, + Symbol, + SymbolIterator, } = primordials; const { inspect } = require('internal/util/inspect'); @@ -86,7 +88,7 @@ const kFormat = Symbol('format'); // https://tc39.github.io/ecma262/#sec-%iteratorprototype%-object const IteratorPrototype = ObjectGetPrototypeOf( - ObjectGetPrototypeOf([][Symbol.iterator]()) + ObjectGetPrototypeOf([][SymbolIterator]()) ); const unpairedSurrogateRe = @@ -138,8 +140,8 @@ class URLSearchParams { if (init === null || init === undefined) { this[searchParams] = []; } else if (typeof init === 'object' || typeof init === 'function') { - const method = init[Symbol.iterator]; - if (method === this[Symbol.iterator]) { + const method = init[SymbolIterator]; + if (method === this[SymbolIterator]) { // While the spec does not have this branch, we can use it as a // shortcut to avoid having to go through the costly generic iterator. const childParams = init[searchParams]; @@ -155,7 +157,7 @@ class URLSearchParams { for (const pair of init) { if ((typeof pair !== 'object' && typeof pair !== 'function') || pair === null || - typeof pair[Symbol.iterator] !== 'function') { + typeof pair[SymbolIterator] !== 'function') { throw new ERR_INVALID_TUPLE('Each query pair', '[name, value]'); } const convertedPair = []; @@ -1148,7 +1150,7 @@ defineIDLClass(URLSearchParams.prototype, 'URLSearchParams', { }); // https://heycam.github.io/webidl/#es-iterable-entries -ObjectDefineProperty(URLSearchParams.prototype, Symbol.iterator, { +ObjectDefineProperty(URLSearchParams.prototype, SymbolIterator, { writable: true, configurable: true, value: URLSearchParams.prototype.entries diff --git a/lib/internal/util.js b/lib/internal/util.js index 1ff25dbc7d2a86..f80c9212304a03 100644 --- a/lib/internal/util.js +++ b/lib/internal/util.js @@ -11,7 +11,10 @@ const { ObjectGetPrototypeOf, ObjectSetPrototypeOf, ReflectConstruct, + Symbol, + SymbolFor, } = primordials; + const { codes: { ERR_INVALID_ARG_TYPE, @@ -26,7 +29,8 @@ const { getHiddenValue, setHiddenValue, arrow_message_private_symbol: kArrowMessagePrivateSymbolIndex, - decorated_private_symbol: kDecoratedPrivateSymbolIndex + decorated_private_symbol: kDecoratedPrivateSymbolIndex, + sleep: _sleep } = internalBinding('util'); const { isNativeError } = internalBinding('types'); @@ -385,6 +389,17 @@ function once(callback) { }; } +let validateUint32; + +function sleep(msec) { + // Lazy-load to avoid a circular dependency. + if (validateUint32 === undefined) + ({ validateUint32 } = require('internal/validators')); + + validateUint32(msec, 'msec'); + _sleep(msec); +} + module.exports = { assertCrypto, cachedResult, @@ -402,6 +417,7 @@ module.exports = { normalizeEncoding, once, promisify, + sleep, spliceOne, removeColors, @@ -410,7 +426,7 @@ module.exports = { // Symbol used to provide a custom inspect function for an object as an // alternative to using 'inspect' - customInspectSymbol: Symbol.for('nodejs.util.inspect.custom'), + customInspectSymbol: SymbolFor('nodejs.util.inspect.custom'), // Used by the buffer module to capture an internal reference to the // default isEncoding implementation, just in case userland overrides it. diff --git a/lib/internal/util/comparisons.js b/lib/internal/util/comparisons.js index b2784217171410..0c3e1297222ce0 100644 --- a/lib/internal/util/comparisons.js +++ b/lib/internal/util/comparisons.js @@ -15,10 +15,12 @@ const { ObjectPrototypePropertyIsEnumerable, ObjectPrototypeToString, StringPrototypeValueOf, + Symbol, SymbolPrototypeValueOf, } = primordials; const { compare } = internalBinding('buffer'); +const types = require('internal/util/types'); const { isAnyArrayBuffer, isArrayBufferView, @@ -34,8 +36,17 @@ const { isBigIntObject, isSymbolObject, isFloat32Array, - isFloat64Array -} = require('internal/util/types'); + isFloat64Array, + isUint8Array, + isUint8ClampedArray, + isUint16Array, + isUint32Array, + isInt8Array, + isInt16Array, + isInt32Array, + isBigInt64Array, + isBigUint64Array +} = types; const { getOwnNonIndexProperties, propertyFilter: { @@ -107,6 +118,33 @@ function isEqualBoxedPrimitive(val1, val2) { return false; } +function isIdenticalTypedArrayType(a, b) { + // Fast path to reduce type checks in the common case. + const check = types[`is${a[Symbol.toStringTag]}`]; + if (check !== undefined && check(a)) { + return check(b); + } + // Manipulated Symbol.toStringTag. + for (const check of [ + isUint16Array, + isUint32Array, + isInt8Array, + isInt16Array, + isInt32Array, + isFloat32Array, + isFloat64Array, + isBigInt64Array, + isBigUint64Array, + isUint8ClampedArray, + isUint8Array + ]) { + if (check(a)) { + return check(b); + } + } + return false; +} + // Notes: Type tags are historical [[Class]] properties that can be set by // FunctionTemplate::SetClassName() in C++ or Symbol.toStringTag in JS // and retrieved using Object.prototype.toString.call(obj) in JS @@ -115,15 +153,8 @@ function isEqualBoxedPrimitive(val1, val2) { // There are some unspecified tags in the wild too (e.g. typed array tags). // Since tags can be altered, they only serve fast failures // -// Typed arrays and buffers are checked by comparing the content in their -// underlying ArrayBuffer. This optimization requires that it's -// reasonable to interpret their underlying memory in the same way, -// which is checked by comparing their type tags. -// (e.g. a Uint8Array and a Uint16Array with the same memory content -// could still be different because they will be interpreted differently). -// // For strict comparison, objects should have -// a) The same built-in type tags +// a) The same built-in type tag. // b) The same prototypes. function innerDeepEqual(val1, val2, strict, memos) { @@ -164,9 +195,10 @@ function innerDeepEqual(val1, val2, strict, memos) { if (val1Tag !== val2Tag) { return false; } + if (ArrayIsArray(val1)) { // Check for sparse arrays and general fast path - if (val1.length !== val2.length) { + if (!ArrayIsArray(val2) || val1.length !== val2.length) { return false; } const filter = strict ? ONLY_ENUMERABLE : ONLY_ENUMERABLE | SKIP_SYMBOLS; @@ -176,25 +208,28 @@ function innerDeepEqual(val1, val2, strict, memos) { return false; } return keyCheck(val1, val2, strict, memos, kIsArray, keys1); - } - if (val1Tag === '[object Object]') { + } else if (val1Tag === '[object Object]') { return keyCheck(val1, val2, strict, memos, kNoIterator); - } - if (isDate(val1)) { - if (DatePrototypeGetTime(val1) !== DatePrototypeGetTime(val2)) { + } else if (isDate(val1)) { + if (!isDate(val2) || + DatePrototypeGetTime(val1) !== DatePrototypeGetTime(val2)) { return false; } } else if (isRegExp(val1)) { - if (!areSimilarRegExps(val1, val2)) { + if (!isRegExp(val2) || !areSimilarRegExps(val1, val2)) { return false; } } else if (isNativeError(val1) || val1 instanceof Error) { // Do not compare the stack as it might differ even though the error itself // is otherwise identical. - if (val1.message !== val2.message || val1.name !== val2.name) { + if ((!isNativeError(val2) && !(val2 instanceof Error)) || + val1.message !== val2.message || + val1.name !== val2.name) { return false; } } else if (isArrayBufferView(val1)) { + if (!isIdenticalTypedArrayType(val1, val2)) + return false; if (!strict && (isFloat32Array(val1) || isFloat64Array(val1))) { if (!areSimilarFloatArrays(val1, val2)) { return false; @@ -223,12 +258,23 @@ function innerDeepEqual(val1, val2, strict, memos) { } return keyCheck(val1, val2, strict, memos, kIsMap); } else if (isAnyArrayBuffer(val1)) { - if (!areEqualArrayBuffers(val1, val2)) { + if (!isAnyArrayBuffer(val2) || !areEqualArrayBuffers(val1, val2)) { return false; } - } - if ((isBoxedPrimitive(val1) || isBoxedPrimitive(val2)) && - !isEqualBoxedPrimitive(val1, val2)) { + } else if (isBoxedPrimitive(val1)) { + if (!isEqualBoxedPrimitive(val1, val2)) { + return false; + } + } else if (ArrayIsArray(val2) || + isArrayBufferView(val2) || + isSet(val2) || + isMap(val2) || + isDate(val2) || + isRegExp(val2) || + isAnyArrayBuffer(val2) || + isBoxedPrimitive(val2) || + isNativeError(val2) || + val2 instanceof Error) { return false; } return keyCheck(val1, val2, strict, memos, kNoIterator); diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index f0888dc2a2dac9..c621997c64be44 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -119,6 +119,8 @@ const builtInObjects = new Set( ObjectGetOwnPropertyNames(global).filter((e) => /^([A-Z][a-z]+)+$/.test(e)) ); +// These options must stay in sync with `getUserOptions`. So if any option will +// be added or removed, `getUserOptions` must also be updated accordingly. const inspectDefaultOptions = ObjectSeal({ showHidden: false, depth: 2, @@ -174,13 +176,20 @@ const meta = [ ]; function getUserOptions(ctx) { - const obj = { stylize: ctx.stylize }; - for (const key of ObjectKeys(inspectDefaultOptions)) { - obj[key] = ctx[key]; - } - if (ctx.userOptions === undefined) - return obj; - return { ...obj, ...ctx.userOptions }; + return { + stylize: ctx.stylize, + showHidden: ctx.showHidden, + depth: ctx.depth, + colors: ctx.colors, + customInspect: ctx.customInspect, + showProxy: ctx.showProxy, + maxArrayLength: ctx.maxArrayLength, + breakLength: ctx.breakLength, + compact: ctx.compact, + sorted: ctx.sorted, + getters: ctx.getters, + ...ctx.userOptions + }; } /** @@ -258,23 +267,86 @@ ObjectDefineProperty(inspect, 'defaultOptions', { } }); -// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics +// Set Graphics Rendition http://en.wikipedia.org/wiki/ANSI_escape_code#graphics +// Each color consists of an array with the color code as first entry and the +// reset code as second entry. +const defaultFG = 39; +const defaultBG = 49; inspect.colors = ObjectAssign(ObjectCreate(null), { + reset: [0, 0], bold: [1, 22], + dim: [2, 22], // Alias: faint italic: [3, 23], underline: [4, 24], - inverse: [7, 27], - white: [37, 39], - grey: [90, 39], - black: [30, 39], - blue: [34, 39], - cyan: [36, 39], - green: [32, 39], - magenta: [35, 39], - red: [31, 39], - yellow: [33, 39] + blink: [5, 25], + // Swap forground and background colors + inverse: [7, 27], // Alias: swapcolors, swapColors + hidden: [8, 28], // Alias: conceal + strikethrough: [9, 29], // Alias: strikeThrough, crossedout, crossedOut + doubleunderline: [21, 24], // Alias: doubleUnderline + black: [30, defaultFG], + red: [31, defaultFG], + green: [32, defaultFG], + yellow: [33, defaultFG], + blue: [34, defaultFG], + magenta: [35, defaultFG], + cyan: [36, defaultFG], + white: [37, defaultFG], + bgBlack: [40, defaultBG], + bgRed: [41, defaultBG], + bgGreen: [42, defaultBG], + bgYellow: [43, defaultBG], + bgBlue: [44, defaultBG], + bgMagenta: [45, defaultBG], + bgCyan: [46, defaultBG], + bgWhite: [47, defaultBG], + framed: [51, 54], + overlined: [53, 55], + gray: [90, defaultFG], // Alias: grey, blackBright + redBright: [91, defaultFG], + greenBright: [92, defaultFG], + yellowBright: [93, defaultFG], + blueBright: [94, defaultFG], + magentaBright: [95, defaultFG], + cyanBright: [96, defaultFG], + whiteBright: [97, defaultFG], + bgGray: [100, defaultBG], // Alias: bgGrey, bgBlackBright + bgRedBright: [101, defaultBG], + bgGreenBright: [102, defaultBG], + bgYellowBright: [103, defaultBG], + bgBlueBright: [104, defaultBG], + bgMagentaBright: [105, defaultBG], + bgCyanBright: [106, defaultBG], + bgWhiteBright: [107, defaultBG], }); +function defineColorAlias(target, alias) { + ObjectDefineProperty(inspect.colors, alias, { + get() { + return this[target]; + }, + set(value) { + this[target] = value; + }, + configurable: true, + enumerable: false + }); +} + +defineColorAlias('gray', 'grey'); +defineColorAlias('gray', 'blackBright'); +defineColorAlias('bgGray', 'bgGrey'); +defineColorAlias('bgGray', 'bgBlackBright'); +defineColorAlias('dim', 'faint'); +defineColorAlias('strikethrough', 'crossedout'); +defineColorAlias('strikethrough', 'strikeThrough'); +defineColorAlias('strikethrough', 'crossedOut'); +defineColorAlias('hidden', 'conceal'); +defineColorAlias('inverse', 'swapColors'); +defineColorAlias('inverse', 'swapcolors'); +defineColorAlias('doubleunderline', 'doubleUnderline'); + +// TODO(BridgeAR): Add function style support for more complex styles. // Don't use 'blue' not visible on cmd.exe inspect.styles = ObjectAssign(ObjectCreate(null), { special: 'cyan', @@ -287,6 +359,7 @@ inspect.styles = ObjectAssign(ObjectCreate(null), { symbol: 'green', date: 'magenta', // "name": intentionally not styling + // TODO(BridgeAR): Highlight regular expressions properly. regexp: 'red', module: 'underline' }); @@ -565,12 +638,12 @@ function formatValue(ctx, value, recurseTimes, typedArray) { const context = value; // Always check for proxies to prevent side effects and to prevent triggering // any proxy handlers. - const proxy = getProxyDetails(value); + const proxy = getProxyDetails(value, !!ctx.showProxy); if (proxy !== undefined) { if (ctx.showProxy) { return formatProxy(ctx, proxy, recurseTimes); } - value = proxy[0]; + value = proxy; } // Provide a hook for user-specified inspect functions. @@ -1570,6 +1643,13 @@ function reduceToSingleString( } function hasBuiltInToString(value) { + // Prevent triggering proxy traps. + const getFullProxy = false; + const proxyTarget = getProxyDetails(value, getFullProxy); + if (proxyTarget !== undefined) { + value = proxyTarget; + } + // Count objects that have no `toString` function as built-in. if (typeof value.toString !== 'function') { return true; diff --git a/lib/internal/vm/module.js b/lib/internal/vm/module.js index 88a276e217a7fd..9e6aa6b6b870ae 100644 --- a/lib/internal/vm/module.js +++ b/lib/internal/vm/module.js @@ -1,11 +1,12 @@ 'use strict'; +const { fail } = require('internal/assert'); const { ArrayIsArray, ObjectCreate, ObjectDefineProperty, - Symbol, SafePromise, + Symbol, } = primordials; const { isContext } = internalBinding('contextify'); @@ -58,6 +59,11 @@ const kContext = Symbol('kContext'); const kPerContextModuleId = Symbol('kPerContextModuleId'); const kLink = Symbol('kLink'); +function failIfDebug() { + if (process.features.debug === false) return; + fail('VM Modules'); +} + class Module { constructor(options) { emitExperimentalWarning('VM Modules'); @@ -118,7 +124,7 @@ class Module { syntheticExportNames, syntheticEvaluationSteps); } else { - CHECK(false); + failIfDebug(); } wrapToModuleMap.set(this[kWrap], this); @@ -374,7 +380,7 @@ class SyntheticModule extends Module { identifier, }); - this[kLink] = () => this[kWrap].link(() => { CHECK(false); }); + this[kLink] = () => this[kWrap].link(() => { failIfDebug(); }); } setExport(name, value) { diff --git a/lib/internal/worker.js b/lib/internal/worker.js index 621dfa77693168..6cdd6cba0b18bc 100644 --- a/lib/internal/worker.js +++ b/lib/internal/worker.js @@ -7,6 +7,8 @@ const { MathMax, ObjectCreate, ObjectEntries, + Symbol, + SymbolFor, } = primordials; const EventEmitter = require('events'); @@ -61,7 +63,7 @@ const kOnCouldNotSerializeErr = Symbol('kOnCouldNotSerializeErr'); const kOnErrorMessage = Symbol('kOnErrorMessage'); const kParentSideStdio = Symbol('kParentSideStdio'); -const SHARE_ENV = Symbol.for('nodejs.worker_threads.SHARE_ENV'); +const SHARE_ENV = SymbolFor('nodejs.worker_threads.SHARE_ENV'); const debug = require('internal/util/debuglog').debuglog('worker'); let cwdCounter; @@ -82,9 +84,16 @@ class Worker extends EventEmitter { validateString(filename, 'filename'); if (options.execArgv && !ArrayIsArray(options.execArgv)) { throw new ERR_INVALID_ARG_TYPE('options.execArgv', - 'array', + 'Array', options.execArgv); } + let argv; + if (options.argv) { + if (!ArrayIsArray(options.argv)) { + throw new ERR_INVALID_ARG_TYPE('options.argv', 'Array', options.argv); + } + argv = options.argv.map(String); + } if (!options.eval) { if (!path.isAbsolute(filename) && !/^\.\.?[\\/]/.test(filename)) { throw new ERR_WORKER_PATH(filename); @@ -154,6 +163,7 @@ class Worker extends EventEmitter { this[kPublicPort].on('message', (message) => this.emit('message', message)); setupPortReferencing(this[kPublicPort], this, 'message'); this[kPort].postMessage({ + argv, type: messageTypes.LOAD_SCRIPT, filename, doEval: !!options.eval, diff --git a/lib/internal/worker/io.js b/lib/internal/worker/io.js index a672dac94ce7e5..1167198676b01b 100644 --- a/lib/internal/worker/io.js +++ b/lib/internal/worker/io.js @@ -7,6 +7,7 @@ const { ObjectGetOwnPropertyDescriptors, ObjectGetPrototypeOf, ObjectSetPrototypeOf, + Symbol, } = primordials; const { diff --git a/lib/net.js b/lib/net.js index 02fd18748036a3..751980d6e352ef 100644 --- a/lib/net.js +++ b/lib/net.js @@ -28,6 +28,7 @@ const { NumberIsNaN, ObjectDefineProperty, ObjectSetPrototypeOf, + Symbol, } = primordials; const EventEmitter = require('events'); @@ -936,7 +937,6 @@ Socket.prototype.connect = function(...args) { this.write = Socket.prototype.write; if (this.destroyed) { - this._undestroy(); this._handle = null; this._peername = null; this._sockname = null; @@ -1653,6 +1653,19 @@ function emitCloseNT(self) { } +Server.prototype[EventEmitter.captureRejectionSymbol] = function( + err, event, sock) { + + switch (event) { + case 'connection': + sock.destroy(err); + break; + default: + this.emit('error', err); + } +}; + + // Legacy alias on the C++ wrapper object. This is not public API, so we may // want to runtime-deprecate it at some point. There's no hurry, though. ObjectDefineProperty(TCP.prototype, 'owner', { diff --git a/lib/os.js b/lib/os.js index 51520802d8ecf7..29b2946b80f428 100644 --- a/lib/os.js +++ b/lib/os.js @@ -23,6 +23,7 @@ const { ObjectDefineProperties, + Symbol, } = primordials; const { safeGetenv } = internalBinding('credentials'); diff --git a/lib/perf_hooks.js b/lib/perf_hooks.js index 0b8bab03e48296..3e86f10e222441 100644 --- a/lib/perf_hooks.js +++ b/lib/perf_hooks.js @@ -7,6 +7,7 @@ const { ObjectDefineProperties, ObjectDefineProperty, ObjectKeys, + Symbol, } = primordials; const { diff --git a/lib/readline.js b/lib/readline.js index b25cf9ee64b8a7..ea53cd1bbf80c8 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -36,6 +36,7 @@ const { NumberIsNaN, ObjectDefineProperty, ObjectSetPrototypeOf, + Symbol, } = primordials; const { @@ -64,8 +65,7 @@ const { kClearScreenDown } = CSI; -// Lazy load StringDecoder for startup performance. -let StringDecoder; +const { StringDecoder } = require('string_decoder'); // Lazy load Readable for startup performance. let Readable; @@ -93,9 +93,6 @@ function Interface(input, output, completer, terminal) { return new Interface(input, output, completer, terminal); } - if (StringDecoder === undefined) - StringDecoder = require('string_decoder').StringDecoder; - this._sawReturnAt = 0; this.isCompletionEnabled = true; this._sawKeyPress = false; @@ -1131,8 +1128,6 @@ Interface.prototype[Symbol.asyncIterator] = function() { function emitKeypressEvents(stream, iface) { if (stream[KEYPRESS_DECODER]) return; - if (StringDecoder === undefined) - StringDecoder = require('string_decoder').StringDecoder; stream[KEYPRESS_DECODER] = new StringDecoder('utf8'); stream[ESCAPE_DECODER] = emitKeys(stream); @@ -1147,8 +1142,11 @@ function emitKeypressEvents(stream, iface) { if (r) { clearTimeout(timeoutId); + let escapeTimeout = ESCAPE_CODE_TIMEOUT; + if (iface) { iface._sawKeyPress = r.length === 1; + escapeTimeout = iface.escapeCodeTimeout; } for (let i = 0; i < r.length; i++) { @@ -1160,10 +1158,7 @@ function emitKeypressEvents(stream, iface) { stream[ESCAPE_DECODER].next(r[i]); // Escape letter at the tail position if (r[i] === kEscape && i + 1 === r.length) { - timeoutId = setTimeout( - escapeCodeTimeout, - iface ? iface.escapeCodeTimeout : ESCAPE_CODE_TIMEOUT - ); + timeoutId = setTimeout(escapeCodeTimeout, escapeTimeout); } } catch (err) { // If the generator throws (it could happen in the `keypress` diff --git a/lib/repl.js b/lib/repl.js index c1473588d3942c..98b0d2415d4f70 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -55,6 +55,7 @@ const { ObjectKeys, ObjectPrototypeHasOwnProperty, ObjectSetPrototypeOf, + Symbol, } = primordials; const { @@ -97,7 +98,8 @@ const experimentalREPLAwait = require('internal/options').getOptionValue( ); const { isRecoverableError, - kStandaloneREPL + kStandaloneREPL, + setupPreview, } = require('internal/repl/utils'); const { getOwnNonIndexProperties, @@ -203,6 +205,9 @@ function REPLServer(prompt, } } + const preview = options.terminal && + (options.preview !== undefined ? !!options.preview : true); + this.inputStream = options.input; this.outputStream = options.output; this.useColors = !!options.useColors; @@ -552,11 +557,28 @@ function REPLServer(prompt, }); } else { if (errStack === '') { - errStack = `Thrown: ${self.writer(e)}\n`; - } else { - const ln = errStack.endsWith('\n') ? '' : '\n'; - errStack = `Thrown:\n${errStack}${ln}`; + errStack = self.writer(e); } + const lines = errStack.split(/(?<=\n)/); + let matched = false; + + errStack = ''; + for (const line of lines) { + if (!matched && /^\[?([A-Z][a-z0-9_]*)*Error/.test(line)) { + errStack += writer.options.breakLength >= line.length ? + `Uncaught ${line}` : + `Uncaught:\n${line}`; + matched = true; + } else { + errStack += line; + } + } + if (!matched) { + const ln = lines.length === 1 ? ' ' : ':\n'; + errStack = `Uncaught${ln}${errStack}`; + } + // Normalize line endings. + errStack += errStack.endsWith('\n') ? '' : '\n'; top.outputStream.write(errStack); top.clearBufferedCommand(); top.lines.level = []; @@ -786,9 +808,20 @@ function REPLServer(prompt, } }); + const { + clearPreview, + showInputPreview + } = setupPreview( + this, + kContextId, + kBufferedCommandSymbol, + preview + ); + // Wrap readline tty to enable editor mode and pausing. const ttyWrite = self._ttyWrite.bind(self); self._ttyWrite = (d, key) => { + clearPreview(); key = key || {}; if (paused && !(self.breakEvalOnSigint && key.ctrl && key.name === 'c')) { pausedBuffer.push(['key', [d, key]]); @@ -801,6 +834,7 @@ function REPLServer(prompt, self.clearLine(); } ttyWrite(d, key); + showInputPreview(); return; } diff --git a/lib/string_decoder.js b/lib/string_decoder.js index 0ab74b772559c4..3d2cc2fcb6ab51 100644 --- a/lib/string_decoder.js +++ b/lib/string_decoder.js @@ -24,6 +24,7 @@ const { ArrayBufferIsView, ObjectDefineProperties, + Symbol, } = primordials; const { Buffer } = require('buffer'); diff --git a/lib/trace_events.js b/lib/trace_events.js index 5ec50d32c63424..1ff2b5a4fb1515 100644 --- a/lib/trace_events.js +++ b/lib/trace_events.js @@ -2,6 +2,7 @@ const { ArrayIsArray, + Symbol, } = primordials; const { hasTracing } = internalBinding('config'); diff --git a/lib/url.js b/lib/url.js index 316b2a12ee4524..735390dfd2e59b 100644 --- a/lib/url.js +++ b/lib/url.js @@ -166,8 +166,7 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) { let end = -1; let rest = ''; let lastPos = 0; - let i = 0; - for (let inWs = false, split = false; i < url.length; ++i) { + for (let i = 0, inWs = false, split = false; i < url.length; ++i) { const code = url.charCodeAt(i); // Find first and last non-whitespace characters for trimming @@ -299,7 +298,7 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) { let hostEnd = -1; let atSign = -1; let nonHost = -1; - for (i = 0; i < rest.length; ++i) { + for (let i = 0; i < rest.length; ++i) { switch (rest.charCodeAt(i)) { case CHAR_TAB: case CHAR_LINE_FEED: @@ -415,7 +414,7 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) { let questionIdx = -1; let hashIdx = -1; - for (i = 0; i < rest.length; ++i) { + for (let i = 0; i < rest.length; ++i) { const code = rest.charCodeAt(i); if (code === CHAR_HASH) { this.hash = rest.slice(i); diff --git a/lib/v8.js b/lib/v8.js index 1e0ee43f224c8f..cabe96f345293c 100644 --- a/lib/v8.js +++ b/lib/v8.js @@ -17,6 +17,7 @@ const { Array, ObjectPrototypeToString, + Symbol, } = primordials; const { Buffer } = require('buffer'); diff --git a/lib/vm.js b/lib/vm.js index d12a460df69c39..a4b5b37e83cf28 100644 --- a/lib/vm.js +++ b/lib/vm.js @@ -24,6 +24,7 @@ const { ArrayIsArray, ArrayPrototypeForEach, + Symbol, } = primordials; const { diff --git a/lib/wasi.js b/lib/wasi.js index 65b8473624198c..ff8685cbb06452 100644 --- a/lib/wasi.js +++ b/lib/wasi.js @@ -5,8 +5,10 @@ const { ArrayPrototypeForEach, ArrayPrototypeMap, FunctionPrototypeBind, - ObjectKeys + ObjectKeys, + Symbol, } = primordials; + const { ERR_INVALID_ARG_TYPE, ERR_WASI_ALREADY_STARTED diff --git a/lib/zlib.js b/lib/zlib.js index 375af0fea5a429..3b9e522a06c7e5 100644 --- a/lib/zlib.js +++ b/lib/zlib.js @@ -31,6 +31,7 @@ const { ObjectGetPrototypeOf, ObjectKeys, ObjectSetPrototypeOf, + Symbol, } = primordials; const { diff --git a/node.gyp b/node.gyp index 8becce9062edef..1eb26729679de0 100644 --- a/node.gyp +++ b/node.gyp @@ -2,6 +2,8 @@ 'variables': { 'v8_use_siphash%': 0, 'v8_trace_maps%': 0, + 'v8_enable_pointer_compression%': 0, + 'v8_enable_31bit_smis_on_64bit_arch%': 0, 'node_use_dtrace%': 'false', 'node_use_etw%': 'false', 'node_no_browser_globals%': 'false', @@ -627,6 +629,8 @@ 'src/node_i18n.h', 'src/node_internals.h', 'src/node_main_instance.h', + 'src/node_mem.h', + 'src/node_mem-inl.h', 'src/node_messaging.h', 'src/node_metadata.h', 'src/node_mutex.h', @@ -892,23 +896,11 @@ # Put the code first so it's a dependency and can be used for invocation. 'tools/js2c.py', '<@(library_files)', - 'config.gypi', - 'tools/js2c_macros/check_macros.py' + 'config.gypi' ], 'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/node_javascript.cc', ], - 'conditions': [ - [ 'node_use_dtrace=="false" and node_use_etw=="false"', { - 'inputs': [ 'tools/js2c_macros/notrace_macros.py' ] - }], - [ 'node_debug_lib=="false"', { - 'inputs': [ 'tools/js2c_macros/nodcheck_macros.py' ] - }], - [ 'node_debug_lib=="true"', { - 'inputs': [ 'tools/js2c_macros/dcheck_macros.py' ] - }] - ], 'action': [ 'python', '<@(_inputs)', '--target', '<@(_outputs)', diff --git a/src/debug_utils.cc b/src/debug_utils.cc index 4e52feb69d9027..8dd51b3931959b 100644 --- a/src/debug_utils.cc +++ b/src/debug_utils.cc @@ -26,10 +26,10 @@ #endif // __POSIX__ #if defined(__linux__) || defined(__sun) || \ - defined(__FreeBSD__) || defined(__OpenBSD__) + defined(__FreeBSD__) || defined(__OpenBSD__) || \ + defined(__DragonFly__) #include -#endif // (__linux__) || defined(__sun) || - // (__FreeBSD__) || defined(__OpenBSD__) +#endif #ifdef __APPLE__ #include // _dyld_get_image_name() @@ -292,19 +292,21 @@ void PrintLibuvHandleInformation(uv_loop_t* loop, FILE* stream) { struct Info { std::unique_ptr ctx; FILE* stream; + size_t num_handles; }; - Info info { NativeSymbolDebuggingContext::New(), stream }; + Info info { NativeSymbolDebuggingContext::New(), stream, 0 }; - fprintf(stream, "uv loop at [%p] has %d active handles\n", - loop, loop->active_handles); + fprintf(stream, "uv loop at [%p] has open handles:\n", loop); uv_walk(loop, [](uv_handle_t* handle, void* arg) { Info* info = static_cast(arg); NativeSymbolDebuggingContext* sym_ctx = info->ctx.get(); FILE* stream = info->stream; + info->num_handles++; - fprintf(stream, "[%p] %s\n", handle, uv_handle_type_name(handle->type)); + fprintf(stream, "[%p] %s%s\n", handle, uv_handle_type_name(handle->type), + uv_is_active(handle) ? " (active)" : ""); void* close_cb = reinterpret_cast(handle->close_cb); fprintf(stream, "\tClose callback: %p %s\n", @@ -328,11 +330,15 @@ void PrintLibuvHandleInformation(uv_loop_t* loop, FILE* stream) { first_field, sym_ctx->LookupSymbol(first_field).Display().c_str()); } }, &info); + + fprintf(stream, "uv loop at [%p] has %zu open handles in total\n", + loop, info.num_handles); } std::vector NativeSymbolDebuggingContext::GetLoadedLibraries() { std::vector list; -#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) +#if defined(__linux__) || defined(__FreeBSD__) || \ + defined(__OpenBSD__) || defined(__DragonFly__) dl_iterate_phdr( [](struct dl_phdr_info* info, size_t size, void* data) { auto list = static_cast*>(data); diff --git a/src/env.h b/src/env.h index c25a03ea1e520a..8cd56b4dd66343 100644 --- a/src/env.h +++ b/src/env.h @@ -255,6 +255,7 @@ constexpr size_t kFsStatsBufferLength = V(hostmaster_string, "hostmaster") \ V(http_1_1_string, "http/1.1") \ V(ignore_string, "ignore") \ + V(import_string, "import") \ V(infoaccess_string, "infoAccess") \ V(inherit_string, "inherit") \ V(input_string, "input") \ @@ -351,6 +352,7 @@ constexpr size_t kFsStatsBufferLength = V(sni_context_string, "sni_context") \ V(source_string, "source") \ V(stack_string, "stack") \ + V(standard_name_string, "standardName") \ V(start_time_string, "startTime") \ V(status_string, "status") \ V(stdio_string, "stdio") \ diff --git a/src/module_wrap.cc b/src/module_wrap.cc index 5745cce9e099ab..568e1ad2fdbba0 100644 --- a/src/module_wrap.cc +++ b/src/module_wrap.cc @@ -7,6 +7,7 @@ #include "util-inl.h" #include "node_contextify.h" #include "node_watchdog.h" +#include "node_process.h" #include // S_IFDIR @@ -789,7 +790,7 @@ inline Maybe ResolveIndex(const URL& search) { Maybe FinalizeResolution(Environment* env, const URL& resolved, const URL& base) { - if (env->options()->es_module_specifier_resolution == "node") { + if (env->options()->experimental_specifier_resolution == "node") { Maybe file = ResolveExtensions(resolved); if (!file.IsNothing()) { return file; @@ -961,6 +962,18 @@ Maybe ResolveExportsTarget(Environment* env, target_obj->Get(context, env->node_string()).ToLocalChecked(); Maybe resolved = ResolveExportsTarget(env, pjson_url, conditionalTarget, subpath, pkg_subpath, base, false); + if (!resolved.IsNothing()) { + ProcessEmitExperimentalWarning(env, "Conditional exports"); + return resolved; + } + } + if (env->options()->experimental_conditional_exports && + target_obj->HasOwnProperty(context, env->import_string()).FromJust()) { + matched = true; + conditionalTarget = + target_obj->Get(context, env->import_string()).ToLocalChecked(); + Maybe resolved = ResolveExportsTarget(env, pjson_url, + conditionalTarget, subpath, pkg_subpath, base, false); if (!resolved.IsNothing()) { return resolved; } @@ -1053,7 +1066,7 @@ Maybe PackageMainResolve(Environment* env, return Just(resolved); } } - if (env->options()->es_module_specifier_resolution == "node") { + if (env->options()->experimental_specifier_resolution == "node") { if (pcfg.has_main == HasMain::Yes) { return FinalizeResolution(env, URL(pcfg.main, pjson_url), base); } else { @@ -1267,6 +1280,7 @@ Maybe PackageResolve(Environment* env, Maybe self_url = ResolveSelf(env, specifier, base); if (self_url.IsJust()) { + ProcessEmitExperimentalWarning(env, "Package name self resolution"); return self_url; } diff --git a/src/node.cc b/src/node.cc index 91f07e447f0a6f..b44f021084262e 100644 --- a/src/node.cc +++ b/src/node.cc @@ -108,6 +108,9 @@ #include // STDIN_FILENO, STDERR_FILENO #endif +#ifdef __PASE__ +#include // ioctl +#endif // ========== global C++ headers ========== #include @@ -555,7 +558,14 @@ inline void PlatformInit() { while (s.flags == -1 && errno == EINTR); // NOLINT CHECK_NE(s.flags, -1); +#ifdef __PASE__ + // On IBMi PASE isatty() always returns true for stdin, stdout and stderr. + // Use ioctl() instead to identify whether it's actually a TTY. + if (ioctl(fd, TXISATTY + 0x81, nullptr) == -1 && errno == ENOTTY) + continue; +#else if (!isatty(fd)) continue; +#endif s.isatty = true; do diff --git a/src/node_config.cc b/src/node_config.cc index 16050bdd5b967d..6ee3164a134fe8 100644 --- a/src/node_config.cc +++ b/src/node_config.cc @@ -15,11 +15,14 @@ using v8::Number; using v8::Object; using v8::Value; -// The config binding is used to provide an internal view of compile or runtime +// The config binding is used to provide an internal view of compile time // config options that are required internally by lib/*.js code. This is an // alternative to dropping additional properties onto the process object as // has been the practice previously in node.cc. +// Command line arguments are already accessible in the JS land via +// require('internal/options').getOptionValue('--some-option'). Do not add them +// here. static void Initialize(Local target, Local unused, Local context, @@ -84,9 +87,6 @@ static void Initialize(Local target, READONLY_PROPERTY(target, "hasCachedBuiltins", v8::Boolean::New(isolate, native_module::has_code_cache)); - - if (env->options()->experimental_wasi) - READONLY_TRUE_PROPERTY(target, "experimentalWasi"); } // InitConfig } // namespace node diff --git a/src/node_crypto.cc b/src/node_crypto.cc index d1bd5471f3fba2..c53c5c4ccc4da8 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -2118,7 +2118,7 @@ static Local X509ToObject(Environment* env, X509* cert) { rsa.reset(); ec.reset(); - ASN1_TIME_print(bio.get(), X509_get_notBefore(cert)); + ASN1_TIME_print(bio.get(), X509_get0_notBefore(cert)); BIO_get_mem_ptr(bio.get(), &mem); info->Set(context, env->valid_from_string(), String::NewFromUtf8(env->isolate(), mem->data, @@ -2126,7 +2126,7 @@ static Local X509ToObject(Environment* env, X509* cert) { mem->length).ToLocalChecked()).Check(); USE(BIO_reset(bio.get())); - ASN1_TIME_print(bio.get(), X509_get_notAfter(cert)); + ASN1_TIME_print(bio.get(), X509_get0_notAfter(cert)); BIO_get_mem_ptr(bio.get(), &mem); info->Set(context, env->valid_to_string(), String::NewFromUtf8(env->isolate(), mem->data, @@ -2685,6 +2685,9 @@ void SSLWrap::GetCipher(const FunctionCallbackInfo& args) { const char* cipher_name = SSL_CIPHER_get_name(c); info->Set(context, env->name_string(), OneByteString(args.GetIsolate(), cipher_name)).Check(); + const char* cipher_standard_name = SSL_CIPHER_standard_name(c); + info->Set(context, env->standard_name_string(), + OneByteString(args.GetIsolate(), cipher_standard_name)).Check(); const char* cipher_version = SSL_CIPHER_get_version(c); info->Set(context, env->version_string(), OneByteString(args.GetIsolate(), cipher_version)).Check(); @@ -2697,11 +2700,11 @@ void SSLWrap::GetSharedSigalgs(const FunctionCallbackInfo& args) { Base* w; ASSIGN_OR_RETURN_UNWRAP(&w, args.Holder()); Environment* env = w->ssl_env(); - std::vector> ret_arr; SSL* ssl = w->ssl_.get(); int nsig = SSL_get_shared_sigalgs(ssl, 0, nullptr, nullptr, nullptr, nullptr, nullptr); + MaybeStackBuffer, 16> ret_arr(nsig); for (int i = 0; i < nsig; i++) { int hash_nid; @@ -2765,12 +2768,11 @@ void SSLWrap::GetSharedSigalgs(const FunctionCallbackInfo& args) { } else { sig_with_md += "UNDEF"; } - - ret_arr.push_back(OneByteString(env->isolate(), sig_with_md.c_str())); + ret_arr[i] = OneByteString(env->isolate(), sig_with_md.c_str()); } args.GetReturnValue().Set( - Array::New(env->isolate(), ret_arr.data(), ret_arr.size())); + Array::New(env->isolate(), ret_arr.out(), ret_arr.length())); } diff --git a/src/node_crypto.h b/src/node_crypto.h index 3f14e155dafc49..b57dc29de29785 100644 --- a/src/node_crypto.h +++ b/src/node_crypto.h @@ -35,6 +35,10 @@ #include #include +#include +#include +#include +#include namespace node { namespace crypto { diff --git a/src/node_dir.cc b/src/node_dir.cc index 37285928fbd731..ec53d8216bcba0 100644 --- a/src/node_dir.cc +++ b/src/node_dir.cc @@ -172,7 +172,7 @@ static MaybeLocal DirentListToArray( int num, enum encoding encoding, Local* err_out) { - MaybeStackBuffer, 96> entries(num * 3); + MaybeStackBuffer, 64> entries(num * 2); // Return an array of all read filenames. int j = 0; @@ -320,7 +320,7 @@ static void OpenDir(const FunctionCallbackInfo& args) { const enum encoding encoding = ParseEncoding(isolate, args[1], UTF8); - FSReqBase* req_wrap_async = static_cast(GetReqWrap(env, args[2])); + FSReqBase* req_wrap_async = GetReqWrap(env, args[2]); if (req_wrap_async != nullptr) { // openDir(path, encoding, req) AsyncCall(env, req_wrap_async, args, "opendir", encoding, AfterOpenDir, uv_fs_opendir, *path); diff --git a/src/node_dir.h b/src/node_dir.h index caef7a5d309180..b55245d5b89a2e 100644 --- a/src/node_dir.h +++ b/src/node_dir.h @@ -18,7 +18,6 @@ class DirHandle : public AsyncWrap { ~DirHandle() override; static void New(const v8::FunctionCallbackInfo& args); - static void Open(const v8::FunctionCallbackInfo& args); static void Read(const v8::FunctionCallbackInfo& args); static void Close(const v8::FunctionCallbackInfo& args); diff --git a/src/node_errors.cc b/src/node_errors.cc index 17c1bd7f55c0fb..9474fbb113146d 100644 --- a/src/node_errors.cc +++ b/src/node_errors.cc @@ -10,6 +10,10 @@ #include "node_v8_platform-inl.h" #include "util-inl.h" +#ifdef __ANDROID__ +#include +#endif + namespace node { using errors::TryCatchScope; @@ -429,6 +433,8 @@ void PrintErrorString(const char* format, ...) { // Don't include the null character in the output CHECK_GT(n, 0); WriteConsoleW(stderr_handle, wbuf.data(), n - 1, nullptr, nullptr); +#elif defined(__ANDROID__) + __android_log_vprint(ANDROID_LOG_ERROR, "nodejs", format, ap); #else vfprintf(stderr, format, ap); #endif diff --git a/src/node_http2.cc b/src/node_http2.cc index 9421c36f3be561..760533b605497b 100644 --- a/src/node_http2.cc +++ b/src/node_http2.cc @@ -5,6 +5,7 @@ #include "node_buffer.h" #include "node_http2.h" #include "node_http2_state.h" +#include "node_mem-inl.h" #include "node_perf.h" #include "node_revert.h" #include "util-inl.h" @@ -501,101 +502,20 @@ Http2Session::Callbacks::~Callbacks() { nghttp2_session_callbacks_del(callbacks); } -// Track memory allocated by nghttp2 using a custom allocator. -class Http2Session::MemoryAllocatorInfo { - public: - explicit MemoryAllocatorInfo(Http2Session* session) - : info({ session, H2Malloc, H2Free, H2Calloc, H2Realloc }) {} - - static void* H2Malloc(size_t size, void* user_data) { - return H2Realloc(nullptr, size, user_data); - } - - static void* H2Calloc(size_t nmemb, size_t size, void* user_data) { - size_t real_size = MultiplyWithOverflowCheck(nmemb, size); - void* mem = H2Malloc(real_size, user_data); - if (mem != nullptr) - memset(mem, 0, real_size); - return mem; - } - - static void H2Free(void* ptr, void* user_data) { - if (ptr == nullptr) return; // free(null); happens quite often. - void* result = H2Realloc(ptr, 0, user_data); - CHECK_NULL(result); - } - - static void* H2Realloc(void* ptr, size_t size, void* user_data) { - Http2Session* session = static_cast(user_data); - size_t previous_size = 0; - char* original_ptr = nullptr; - - // We prepend each allocated buffer with a size_t containing the full - // size of the allocation. - if (size > 0) size += sizeof(size_t); - - if (ptr != nullptr) { - // We are free()ing or re-allocating. - original_ptr = static_cast(ptr) - sizeof(size_t); - previous_size = *reinterpret_cast(original_ptr); - // This means we called StopTracking() on this pointer before. - if (previous_size == 0) { - // Fall back to the standard Realloc() function. - char* ret = UncheckedRealloc(original_ptr, size); - if (ret != nullptr) - ret += sizeof(size_t); - return ret; - } - } - CHECK_GE(session->current_nghttp2_memory_, previous_size); - - // TODO(addaleax): Add the following, and handle NGHTTP2_ERR_NOMEM properly - // everywhere: - // - // if (size > previous_size && - // !session->IsAvailableSessionMemory(size - previous_size)) { - // return nullptr; - //} - - char* mem = UncheckedRealloc(original_ptr, size); - - if (mem != nullptr) { - // Adjust the memory info counter. - // TODO(addaleax): Avoid the double bookkeeping we do with - // current_nghttp2_memory_ + AdjustAmountOfExternalAllocatedMemory - // and provide versions of our memory allocation utilities that take an - // Environment*/Isolate* parameter and call the V8 method transparently. - const int64_t new_size = size - previous_size; - session->current_nghttp2_memory_ += new_size; - session->env()->isolate()->AdjustAmountOfExternalAllocatedMemory( - new_size); - *reinterpret_cast(mem) = size; - mem += sizeof(size_t); - } else if (size == 0) { - session->current_nghttp2_memory_ -= previous_size; - session->env()->isolate()->AdjustAmountOfExternalAllocatedMemory( - -static_cast(previous_size)); - } - - return mem; - } - - static void StopTracking(Http2Session* session, void* ptr) { - size_t* original_ptr = reinterpret_cast( - static_cast(ptr) - sizeof(size_t)); - session->current_nghttp2_memory_ -= *original_ptr; - session->env()->isolate()->AdjustAmountOfExternalAllocatedMemory( - -static_cast(*original_ptr)); - *original_ptr = 0; - } +void Http2Session::StopTrackingRcbuf(nghttp2_rcbuf* buf) { + StopTrackingMemory(buf); +} - inline nghttp2_mem* operator*() { return &info; } +void Http2Session::CheckAllocatedSize(size_t previous_size) const { + CHECK_GE(current_nghttp2_memory_, previous_size); +} - nghttp2_mem info; -}; +void Http2Session::IncreaseAllocatedSize(size_t size) { + current_nghttp2_memory_ += size; +} -void Http2Session::StopTrackingRcbuf(nghttp2_rcbuf* buf) { - MemoryAllocatorInfo::StopTracking(this, buf); +void Http2Session::DecreaseAllocatedSize(size_t size) { + current_nghttp2_memory_ -= size; } Http2Session::Http2Session(Environment* env, @@ -632,14 +552,14 @@ Http2Session::Http2Session(Environment* env, nghttp2_session_server_new3 : nghttp2_session_client_new3; - MemoryAllocatorInfo allocator_info(this); + nghttp2_mem alloc_info = MakeAllocator(); // This should fail only if the system is out of memory, which // is going to cause lots of other problems anyway, or if any // of the options are out of acceptable range, which we should // be catching before it gets this far. Either way, crash if this // fails. - CHECK_EQ(fn(&session_, callbacks, this, *opts, *allocator_info), 0); + CHECK_EQ(fn(&session_, callbacks, this, *opts, &alloc_info), 0); outgoing_storage_.reserve(1024); outgoing_buffers_.reserve(32); @@ -1862,33 +1782,31 @@ void Http2Session::OnStreamRead(ssize_t nread, const uv_buf_t& buf_) { statistics_.data_received += nread; - if (UNLIKELY(stream_buf_offset_ > 0)) { + if (LIKELY(stream_buf_offset_ == 0)) { + // Shrink to the actual amount of used data. + buf.Resize(nread); + IncrementCurrentSessionMemory(nread); + } else { // This is a very unlikely case, and should only happen if the ReadStart() // call in OnStreamAfterWrite() immediately provides data. If that does // happen, we concatenate the data we received with the already-stored // pending input data, slicing off the already processed part. - AllocatedBuffer new_buf = env()->AllocateManaged( - stream_buf_.len - stream_buf_offset_ + nread); - memcpy(new_buf.data(), - stream_buf_.base + stream_buf_offset_, - stream_buf_.len - stream_buf_offset_); - memcpy(new_buf.data() + stream_buf_.len - stream_buf_offset_, - buf.data(), - nread); + size_t pending_len = stream_buf_.len - stream_buf_offset_; + AllocatedBuffer new_buf = env()->AllocateManaged(pending_len + nread); + memcpy(new_buf.data(), stream_buf_.base + stream_buf_offset_, pending_len); + memcpy(new_buf.data() + pending_len, buf.data(), nread); + + // The data in stream_buf_ is already accounted for, add nread received + // bytes to session memory but remove the already processed + // stream_buf_offset_ bytes. + IncrementCurrentSessionMemory(nread - stream_buf_offset_); + buf = std::move(new_buf); nread = buf.size(); stream_buf_offset_ = 0; stream_buf_ab_.Reset(); - - // We have now fully processed the stream_buf_ input chunk (by moving the - // remaining part into buf, which will be accounted for below). - DecrementCurrentSessionMemory(stream_buf_.len); } - // Shrink to the actual amount of used data. - buf.Resize(nread); - IncrementCurrentSessionMemory(nread); - // Remember the current buffer, so that OnDataChunkReceived knows the // offset of a DATA frame's data into the socket read buffer. stream_buf_ = uv_buf_init(buf.data(), nread); diff --git a/src/node_http2.h b/src/node_http2.h index e828999f2b73b2..07febd7da40a9b 100644 --- a/src/node_http2.h +++ b/src/node_http2.h @@ -8,6 +8,7 @@ #include "nghttp2/nghttp2.h" #include "node_http2_state.h" +#include "node_mem.h" #include "node_perf.h" #include "stream_base-inl.h" #include "string_bytes.h" @@ -703,7 +704,9 @@ enum SessionBitfieldFlags { kSessionHasAltsvcListeners }; -class Http2Session : public AsyncWrap, public StreamListener { +class Http2Session : public AsyncWrap, + public StreamListener, + public mem::NgLibMemoryManager { public: Http2Session(Environment* env, Local wrap, @@ -712,7 +715,6 @@ class Http2Session : public AsyncWrap, public StreamListener { class Http2Ping; class Http2Settings; - class MemoryAllocatorInfo; void EmitStatistics(); @@ -790,6 +792,7 @@ class Http2Session : public AsyncWrap, public StreamListener { tracker->TrackFieldWithSize("outgoing_storage", outgoing_storage_.size()); tracker->TrackFieldWithSize("pending_rst_streams", pending_rst_streams_.size() * sizeof(int32_t)); + tracker->TrackFieldWithSize("nghttp2_memory", current_nghttp2_memory_); } SET_MEMORY_INFO_NAME(Http2Session) @@ -813,6 +816,11 @@ class Http2Session : public AsyncWrap, public StreamListener { void OnStreamRead(ssize_t nread, const uv_buf_t& buf) override; void OnStreamAfterWrite(WriteWrap* w, int status) override; + // Implementation for mem::NgLibMemoryManager + void CheckAllocatedSize(size_t previous_size) const; + void IncreaseAllocatedSize(size_t size); + void DecreaseAllocatedSize(size_t size); + // The JavaScript API static void New(const FunctionCallbackInfo& args); static void Consume(const FunctionCallbackInfo& args); diff --git a/src/node_http_parser.cc b/src/node_http_parser.cc index 0328dc7c0f684a..5e1da912e0c31e 100644 --- a/src/node_http_parser.cc +++ b/src/node_http_parser.cc @@ -486,11 +486,13 @@ class Parser : public AsyncWrap, public StreamListener { static void Initialize(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); + bool lenient = args[3]->IsTrue(); uint64_t max_http_header_size = 0; CHECK(args[0]->IsInt32()); CHECK(args[1]->IsObject()); + if (args.Length() > 2) { CHECK(args[2]->IsNumber()); max_http_header_size = args[2].As()->Value(); @@ -515,7 +517,7 @@ class Parser : public AsyncWrap, public StreamListener { parser->set_provider_type(provider); parser->AsyncReset(args[1].As()); - parser->Init(type, max_http_header_size); + parser->Init(type, max_http_header_size, lenient); } template @@ -762,8 +764,9 @@ class Parser : public AsyncWrap, public StreamListener { } - void Init(llhttp_type_t type, uint64_t max_http_header_size) { + void Init(llhttp_type_t type, uint64_t max_http_header_size, bool lenient) { llhttp_init(&parser_, type, &settings); + llhttp_set_lenient(&parser_, lenient); header_nread_ = 0; url_.Reset(); status_message_.Reset(); diff --git a/src/node_mem-inl.h b/src/node_mem-inl.h new file mode 100644 index 00000000000000..ad6fc45b36942d --- /dev/null +++ b/src/node_mem-inl.h @@ -0,0 +1,112 @@ +#ifndef SRC_NODE_MEM_INL_H_ +#define SRC_NODE_MEM_INL_H_ + +#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS + +#include "node_mem.h" +#include "node_internals.h" + +namespace node { +namespace mem { + +template +AllocatorStruct NgLibMemoryManager::MakeAllocator() { + return AllocatorStruct { + static_cast(static_cast(this)), + MallocImpl, + FreeImpl, + CallocImpl, + ReallocImpl + }; +} + +template +void* NgLibMemoryManager::ReallocImpl(void* ptr, + size_t size, + void* user_data) { + Class* manager = static_cast(user_data); + + size_t previous_size = 0; + char* original_ptr = nullptr; + + // We prepend each allocated buffer with a size_t containing the full + // size of the allocation. + if (size > 0) size += sizeof(size_t); + + if (ptr != nullptr) { + // We are free()ing or re-allocating. + original_ptr = static_cast(ptr) - sizeof(size_t); + previous_size = *reinterpret_cast(original_ptr); + // This means we called StopTracking() on this pointer before. + if (previous_size == 0) { + // Fall back to the standard Realloc() function. + char* ret = UncheckedRealloc(original_ptr, size); + if (ret != nullptr) + ret += sizeof(size_t); + return ret; + } + } + + manager->CheckAllocatedSize(previous_size); + + char* mem = UncheckedRealloc(original_ptr, size); + + if (mem != nullptr) { + // Adjust the memory info counter. + // TODO(addaleax): Avoid the double bookkeeping we do with + // current_nghttp2_memory_ + AdjustAmountOfExternalAllocatedMemory + // and provide versions of our memory allocation utilities that take an + // Environment*/Isolate* parameter and call the V8 method transparently. + const int64_t new_size = size - previous_size; + manager->IncreaseAllocatedSize(new_size); + manager->env()->isolate()->AdjustAmountOfExternalAllocatedMemory( + new_size); + *reinterpret_cast(mem) = size; + mem += sizeof(size_t); + } else if (size == 0) { + manager->DecreaseAllocatedSize(previous_size); + manager->env()->isolate()->AdjustAmountOfExternalAllocatedMemory( + -static_cast(previous_size)); + } + return mem; +} + +template +void* NgLibMemoryManager::MallocImpl(size_t size, void* user_data) { + return ReallocImpl(nullptr, size, user_data); +} + +template +void NgLibMemoryManager::FreeImpl(void* ptr, void* user_data) { + if (ptr == nullptr) return; + CHECK_NULL(ReallocImpl(ptr, 0, user_data)); +} + +template +void* NgLibMemoryManager::CallocImpl(size_t nmemb, + size_t size, + void* user_data) { + size_t real_size = MultiplyWithOverflowCheck(nmemb, size); + void* mem = MallocImpl(real_size, user_data); + if (mem != nullptr) + memset(mem, 0, real_size); + return mem; +} + +template +void NgLibMemoryManager::StopTrackingMemory(void* ptr) { + size_t* original_ptr = reinterpret_cast( + static_cast(ptr) - sizeof(size_t)); + Class* manager = static_cast(this); + manager->DecreaseAllocatedSize(*original_ptr); + manager->env()->isolate()->AdjustAmountOfExternalAllocatedMemory( + -static_cast(*original_ptr)); + *original_ptr = 0; +} + +} // namespace mem +} // namespace node + +#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS + +#endif // SRC_NODE_MEM_INL_H_ diff --git a/src/node_mem.h b/src/node_mem.h new file mode 100644 index 00000000000000..0d3388ad4766bb --- /dev/null +++ b/src/node_mem.h @@ -0,0 +1,41 @@ +#ifndef SRC_NODE_MEM_H_ +#define SRC_NODE_MEM_H_ + +#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS + +#include + +namespace node { +namespace mem { + +// Both ngtcp2 and nghttp2 allow custom allocators that +// follow exactly the same structure and behavior, but +// use different struct names. To allow for code re-use, +// the NgLibMemoryManager template class can be used for both. + +template +class NgLibMemoryManager { + public: + // Class needs to provide these methods: + // void CheckAllocatedSize(size_t previous_size) const; + // void IncreaseAllocatedSize(size_t size); + // void DecreaseAllocatedSize(size_t size); + // Environment* env() const; + + AllocatorStructName MakeAllocator(); + + void StopTrackingMemory(void* ptr); + + private: + static void* ReallocImpl(void* ptr, size_t size, void* user_data); + static void* MallocImpl(size_t size, void* user_data); + static void FreeImpl(void* ptr, void* user_data); + static void* CallocImpl(size_t nmemb, size_t size, void* user_data); +}; + +} // namespace mem +} // namespace node + +#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS + +#endif // SRC_NODE_MEM_H_ diff --git a/src/node_options.cc b/src/node_options.cc index 498bedd1e5e892..831540f993fcb5 100644 --- a/src/node_options.cc +++ b/src/node_options.cc @@ -128,9 +128,23 @@ void EnvironmentOptions::CheckOptions(std::vector* errors) { } if (!es_module_specifier_resolution.empty()) { - if (es_module_specifier_resolution != "node" && - es_module_specifier_resolution != "explicit") { - errors->push_back("invalid value for --es-module-specifier-resolution"); + if (!experimental_specifier_resolution.empty()) { + errors->push_back( + "bad option: cannot use --es-module-specifier-resolution" + " and --experimental-specifier-resolution at the same time"); + } else { + experimental_specifier_resolution = es_module_specifier_resolution; + if (experimental_specifier_resolution != "node" && + experimental_specifier_resolution != "explicit") { + errors->push_back( + "invalid value for --es-module-specifier-resolution"); + } + } + } else if (!experimental_specifier_resolution.empty()) { + if (experimental_specifier_resolution != "node" && + experimental_specifier_resolution != "explicit") { + errors->push_back( + "invalid value for --experimental-specifier-resolution"); } } @@ -361,13 +375,21 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() { &EnvironmentOptions::heap_snapshot_signal, kAllowedInEnvironment); AddOption("--http-parser", "", NoOp{}, kAllowedInEnvironment); + AddOption("--insecure-http-parser", + "use an insecure HTTP parser that accepts invalid HTTP headers", + &EnvironmentOptions::insecure_http_parser, + kAllowedInEnvironment); AddOption("--input-type", "set module type for string input", &EnvironmentOptions::module_type, kAllowedInEnvironment); - AddOption("--es-module-specifier-resolution", + AddOption("--experimental-specifier-resolution", "Select extension resolution algorithm for es modules; " "either 'explicit' (default) or 'node'", + &EnvironmentOptions::experimental_specifier_resolution, + kAllowedInEnvironment); + AddOption("--es-module-specifier-resolution", + "", &EnvironmentOptions::es_module_specifier_resolution, kAllowedInEnvironment); AddOption("--no-deprecation", diff --git a/src/node_options.h b/src/node_options.h index fea912da446568..7b3ae19fe6c8ad 100644 --- a/src/node_options.h +++ b/src/node_options.h @@ -104,6 +104,7 @@ class EnvironmentOptions : public Options { bool experimental_conditional_exports = false; bool experimental_json_modules = false; bool experimental_resolve_self = false; + std::string experimental_specifier_resolution; std::string es_module_specifier_resolution; bool experimental_wasm_modules = false; std::string module_type; @@ -157,6 +158,8 @@ class EnvironmentOptions : public Options { bool print_eval = false; bool force_repl = false; + bool insecure_http_parser = false; + bool tls_min_v1_0 = false; bool tls_min_v1_1 = false; bool tls_min_v1_2 = false; diff --git a/src/node_process.h b/src/node_process.h index 5db7b004d6f939..ad86b449f95290 100644 --- a/src/node_process.h +++ b/src/node_process.h @@ -27,6 +27,8 @@ v8::Maybe ProcessEmitWarningGeneric(Environment* env, const char* code = nullptr); v8::Maybe ProcessEmitWarning(Environment* env, const char* fmt, ...); +v8::Maybe ProcessEmitExperimentalWarning(Environment* env, + const char* warning); v8::Maybe ProcessEmitDeprecationWarning(Environment* env, const char* warning, const char* deprecation_code); diff --git a/src/node_process_events.cc b/src/node_process_events.cc index 06096226625bb6..d192ef19b7abad 100644 --- a/src/node_process_events.cc +++ b/src/node_process_events.cc @@ -1,4 +1,5 @@ #include +#include #include "env-inl.h" #include "node_process.h" @@ -95,6 +96,21 @@ Maybe ProcessEmitWarning(Environment* env, const char* fmt, ...) { return ProcessEmitWarningGeneric(env, warning); } + +std::set experimental_warnings; + +Maybe ProcessEmitExperimentalWarning(Environment* env, + const char* warning) { + if (experimental_warnings.find(warning) != experimental_warnings.end()) + return Nothing(); + + experimental_warnings.insert(warning); + std::string message(warning); + message.append( + " is an experimental feature. This feature could change at any time"); + return ProcessEmitWarningGeneric(env, message.c_str(), "ExperimentalWarning"); +} + Maybe ProcessEmitDeprecationWarning(Environment* env, const char* warning, const char* deprecation_code) { diff --git a/src/node_util.cc b/src/node_util.cc index 9c24985a47a507..e0ef7d421ff24a 100644 --- a/src/node_util.cc +++ b/src/node_util.cc @@ -93,13 +93,22 @@ static void GetProxyDetails(const FunctionCallbackInfo& args) { Local proxy = args[0].As(); - Local ret[] = { - proxy->GetTarget(), - proxy->GetHandler() - }; - - args.GetReturnValue().Set( - Array::New(args.GetIsolate(), ret, arraysize(ret))); + // TODO(BridgeAR): Remove the length check as soon as we prohibit access to + // the util binding layer. It's accessed in the wild and `esm` would break in + // case the check is removed. + if (args.Length() == 1 || args[1]->IsTrue()) { + Local ret[] = { + proxy->GetTarget(), + proxy->GetHandler() + }; + + args.GetReturnValue().Set( + Array::New(args.GetIsolate(), ret, arraysize(ret))); + } else { + Local ret = proxy->GetTarget(); + + args.GetReturnValue().Set(ret); + } } static void PreviewEntries(const FunctionCallbackInfo& args) { @@ -161,6 +170,12 @@ static void SetHiddenValue(const FunctionCallbackInfo& args) { args.GetReturnValue().Set(maybe_value.FromJust()); } +static void Sleep(const FunctionCallbackInfo& args) { + CHECK(args[0]->IsUint32()); + uint32_t msec = args[0].As()->Value(); + uv_sleep(msec); +} + void ArrayBufferViewHasBuffer(const FunctionCallbackInfo& args) { CHECK(args[0]->IsArrayBufferView()); args.GetReturnValue().Set(args[0].As()->HasBuffer()); @@ -282,6 +297,7 @@ void Initialize(Local target, env->SetMethodNoSideEffect(target, "getOwnNonIndexProperties", GetOwnNonIndexProperties); env->SetMethodNoSideEffect(target, "getConstructorName", GetConstructorName); + env->SetMethod(target, "sleep", Sleep); env->SetMethod(target, "arrayBufferViewHasBuffer", ArrayBufferViewHasBuffer); Local constants = Object::New(env->isolate()); diff --git a/src/node_version.h b/src/node_version.h index 415b0774d26f6a..9d300e9b6c9960 100644 --- a/src/node_version.h +++ b/src/node_version.h @@ -23,13 +23,13 @@ #define SRC_NODE_VERSION_H_ #define NODE_MAJOR_VERSION 13 -#define NODE_MINOR_VERSION 3 -#define NODE_PATCH_VERSION 1 +#define NODE_MINOR_VERSION 4 +#define NODE_PATCH_VERSION 0 #define NODE_VERSION_IS_LTS 0 #define NODE_VERSION_LTS_CODENAME "" -#define NODE_VERSION_IS_RELEASE 0 +#define NODE_VERSION_IS_RELEASE 1 #ifndef NODE_STRINGIFY #define NODE_STRINGIFY(n) NODE_STRINGIFY_HELPER(n) diff --git a/src/node_wasi.cc b/src/node_wasi.cc index 8de7f1fc1cae68..39669df490c957 100644 --- a/src/node_wasi.cc +++ b/src/node_wasi.cc @@ -1,6 +1,8 @@ #include "env-inl.h" #include "base_object-inl.h" #include "debug_utils.h" +#include "memory_tracker-inl.h" +#include "node_mem-inl.h" #include "util-inl.h" #include "node.h" #include "uv.h" @@ -85,14 +87,33 @@ WASI::WASI(Environment* env, Local object, uvwasi_options_t* options) : BaseObject(env, object) { MakeWeak(); + alloc_info_ = MakeAllocator(); + options->allocator = &alloc_info_; CHECK_EQ(uvwasi_init(&uvw_, options), UVWASI_ESUCCESS); } WASI::~WASI() { uvwasi_destroy(&uvw_); + CHECK_EQ(current_uvwasi_memory_, 0); } +void WASI::MemoryInfo(MemoryTracker* tracker) const { + tracker->TrackField("memory", memory_); + tracker->TrackFieldWithSize("uvwasi_memory", current_uvwasi_memory_); +} + +void WASI::CheckAllocatedSize(size_t previous_size) const { + CHECK_GE(current_uvwasi_memory_, previous_size); +} + +void WASI::IncreaseAllocatedSize(size_t size) { + current_uvwasi_memory_ += size; +} + +void WASI::DecreaseAllocatedSize(size_t size) { + current_uvwasi_memory_ -= size; +} void WASI::New(const FunctionCallbackInfo& args) { CHECK(args.IsConstructCall()); @@ -134,7 +155,7 @@ void WASI::New(const FunctionCallbackInfo& args) { Local preopens = args[2].As(); CHECK_EQ(preopens->Length() % 2, 0); options.preopenc = preopens->Length() / 2; - options.preopens = UncheckedCalloc(options.preopenc); + options.preopens = Calloc(options.preopenc); int index = 0; for (uint32_t i = 0; i < preopens->Length(); i += 2) { auto mapped = preopens->Get(context, i).ToLocalChecked(); @@ -144,7 +165,9 @@ void WASI::New(const FunctionCallbackInfo& args) { node::Utf8Value mapped_path(env->isolate(), mapped); node::Utf8Value real_path(env->isolate(), real); options.preopens[index].mapped_path = strdup(*mapped_path); + CHECK_NOT_NULL(options.preopens[index].mapped_path); options.preopens[index].real_path = strdup(*real_path); + CHECK_NOT_NULL(options.preopens[index].real_path); index++; } @@ -161,6 +184,15 @@ void WASI::New(const FunctionCallbackInfo& args) { free(options.envp[i]); delete[] options.envp; } + + if (options.preopens != nullptr) { + for (uint32_t i = 0; i < options.preopenc; i++) { + free(options.preopens[i].mapped_path); + free(options.preopens[i].real_path); + } + + delete[] options.preopens; + } } diff --git a/src/node_wasi.h b/src/node_wasi.h index ca726e48a42a47..7a0be60aa645a7 100644 --- a/src/node_wasi.h +++ b/src/node_wasi.h @@ -4,24 +4,22 @@ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS #include "base_object.h" -#include "memory_tracker-inl.h" +#include "node_mem.h" #include "uvwasi.h" namespace node { namespace wasi { -class WASI : public BaseObject { +class WASI : public BaseObject, + public mem::NgLibMemoryManager { public: WASI(Environment* env, v8::Local object, uvwasi_options_t* options); static void New(const v8::FunctionCallbackInfo& args); - void MemoryInfo(MemoryTracker* tracker) const override { - /* TODO(cjihrig): Get memory consumption from uvwasi. */ - tracker->TrackField("memory", memory_); - } + void MemoryInfo(MemoryTracker* tracker) const override; SET_MEMORY_INFO_NAME(WASI) SET_SELF_SIZE(WASI) @@ -79,6 +77,11 @@ class WASI : public BaseObject { static void _SetMemory(const v8::FunctionCallbackInfo& args); + // Implementation for mem::NgLibMemoryManager + void CheckAllocatedSize(size_t previous_size) const; + void IncreaseAllocatedSize(size_t size); + void DecreaseAllocatedSize(size_t size); + private: ~WASI() override; inline void readUInt8(char* memory, uint8_t* value, uint32_t offset); @@ -92,6 +95,8 @@ class WASI : public BaseObject { uvwasi_errno_t backingStore(char** store, size_t* byte_length); uvwasi_t uvw_; v8::Global memory_; + uvwasi_mem_t alloc_info_; + size_t current_uvwasi_memory_ = 0; }; diff --git a/test/abort/test-addon-uv-handle-leak.js b/test/abort/test-addon-uv-handle-leak.js index 47751954ab5728..c9614e11734e96 100644 --- a/test/abort/test-addon-uv-handle-leak.js +++ b/test/abort/test-addon-uv-handle-leak.js @@ -47,8 +47,8 @@ if (process.argv[2] === 'child') { // Parse output that is formatted like this: - // uv loop at [0x559b65ed5770] has active handles - // [0x7f2de0018430] timer + // uv loop at [0x559b65ed5770] has open handles: + // [0x7f2de0018430] timer (active) // Close callback: 0x7f2df31de220 CloseCallback(uv_handle_s*) [...] // Data: 0x7f2df33df140 example_instance [...] // (First field): 0x7f2df33dedc0 vtable for ExampleOwnerClass [...] @@ -58,6 +58,7 @@ if (process.argv[2] === 'child') { // [0x7f2de000b910] timer // Close callback: 0x7f2df31de220 CloseCallback(uv_handle_s*) [...] // Data: 0x42 + // uv loop at [0x559b65ed5770] has 3 open handles in total function isGlibc() { try { @@ -89,15 +90,15 @@ if (process.argv[2] === 'child') { switch (state) { case 'initial': - assert(/^uv loop at \[.+\] has \d+ active handles$/.test(line), line); + assert(/^uv loop at \[.+\] has open handles:$/.test(line), line); state = 'handle-start'; break; case 'handle-start': - if (/Assertion .+ failed/.test(line)) { - state = 'done'; + if (/^uv loop at \[.+\] has \d+ open handles in total$/.test(line)) { + state = 'assertion-failure'; break; } - assert(/^\[.+\] timer$/.test(line), line); + assert(/^\[.+\] timer( \(active\))?$/.test(line), line); state = 'close-callback'; break; case 'close-callback': @@ -109,15 +110,19 @@ if (process.argv[2] === 'child') { state = 'maybe-first-field'; break; case 'maybe-first-field': - if (/^\(First field\)$/.test(line)) { + if (!/^\(First field\)/.test(line)) { lines.unshift(line); - state = 'handle-start'; - break; } - state = 'maybe-first-field'; + state = 'handle-start'; + break; + case 'assertion-failure': + assert(/Assertion .+ failed/.test(line), line); + state = 'done'; break; case 'done': break; } } + + assert.strictEqual(state, 'done'); } diff --git a/test/addons/addon.status b/test/addons/addon.status index 6a3e3519c15741..081725af9fa465 100644 --- a/test/addons/addon.status +++ b/test/addons/addon.status @@ -1,5 +1,11 @@ prefix addons +# To mark a test as flaky, list the test name in the appropriate section +# below, without ".js", followed by ": PASS,FLAKY". Example: +# sample-test : PASS,FLAKY + [true] # This section applies to all platforms -[$system==aix] +[$arch==arm] +# https://github.com/nodejs/node/issues/30786 +openssl-binding/test: PASS,FLAKY diff --git a/test/async-hooks/async-hooks.status b/test/async-hooks/async-hooks.status index 7f36d5a78a6e2b..344ff8e7affc83 100644 --- a/test/async-hooks/async-hooks.status +++ b/test/async-hooks/async-hooks.status @@ -5,6 +5,8 @@ prefix async-hooks # sample-test : PASS,FLAKY [true] # This section applies to all platforms +# https://github.com/nodejs/node/issues/21425 +test-statwatcher: PASS,FLAKY [$system==win32] diff --git a/test/async-hooks/test-pipeconnectwrap.js b/test/async-hooks/test-pipeconnectwrap.js index b57cc63cf59e46..36980f018598f3 100644 --- a/test/async-hooks/test-pipeconnectwrap.js +++ b/test/async-hooks/test-pipeconnectwrap.js @@ -8,8 +8,7 @@ const { checkInvocations } = require('./hook-checks'); const tmpdir = require('../common/tmpdir'); const net = require('net'); -// Spawning messes up `async_hooks` state. -tmpdir.refresh({ spawn: false }); +tmpdir.refresh(); const hooks = initHooks(); hooks.enable(); diff --git a/test/async-hooks/test-statwatcher.js b/test/async-hooks/test-statwatcher.js index 48d7b0b22eedff..0b9302f21cbce5 100644 --- a/test/async-hooks/test-statwatcher.js +++ b/test/async-hooks/test-statwatcher.js @@ -11,7 +11,7 @@ const path = require('path'); if (!common.isMainThread) common.skip('Worker bootstrapping works differently -> different async IDs'); -tmpdir.refresh({ spawn: false }); +tmpdir.refresh(); const file1 = path.join(tmpdir.path, 'file1'); const file2 = path.join(tmpdir.path, 'file2'); diff --git a/test/benchmark/test-benchmark-util.js b/test/benchmark/test-benchmark-util.js index 97b02bbdeed5cd..b66d4fdb9b4cf6 100644 --- a/test/benchmark/test-benchmark-util.js +++ b/test/benchmark/test-benchmark-util.js @@ -14,5 +14,7 @@ runBenchmark('util', 'size=1', 'type=', 'len=1', - 'version=native'], + 'version=native', + 'isProxy=1', + 'showProxy=1'], { NODEJS_BENCHMARK_ZERO_ALLOWED: 1 }); diff --git a/test/common/README.md b/test/common/README.md index 5f8b6cb3090d9d..afd054eae1fe34 100644 --- a/test/common/README.md +++ b/test/common/README.md @@ -45,11 +45,6 @@ tasks. Takes `whitelist` and concats that with predefined `knownGlobals`. -### busyLoop(time) -* `time` [<number>][] - -Blocks for `time` amount of time. - ### canCreateSymLink() * return [<boolean>][] @@ -903,11 +898,7 @@ The `tmpdir` module supports the use of a temporary directory for testing. The realpath of the testing temporary directory. -### refresh(\[opts\]) - -* `opts` [<Object>][] (optional) Extra options. - * `spawn` [<boolean>][] (default: `true`) Indicates that `refresh` is - allowed to optionally spawn a subprocess. +### refresh() Deletes and recreates the testing temporary directory. diff --git a/test/common/fixtures.mjs b/test/common/fixtures.mjs new file mode 100644 index 00000000000000..3eeef6d6077c4a --- /dev/null +++ b/test/common/fixtures.mjs @@ -0,0 +1,16 @@ +/* eslint-disable node-core/require-common-first, node-core/required-modules */ +import fixtures from './fixtures.js'; + +const { + fixturesDir, + path, + readSync, + readKey, +} = fixtures; + +export { + fixturesDir, + path, + readSync, + readKey, +}; diff --git a/test/common/index.js b/test/common/index.js index 09b7f5577844cb..1be78720810b34 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -481,12 +481,6 @@ function nodeProcessAborted(exitCode, signal) { } } -function busyLoop(time) { - const startTime = Date.now(); - const stopTime = startTime + time; - while (Date.now() < stopTime) {} -} - function isAlive(pid) { try { process.kill(pid, 'SIGCONT'); @@ -744,7 +738,6 @@ function runWithInvalidFD(func) { module.exports = { allowGlobals, buildType, - busyLoop, canCreateSymLink, childShouldThrowAndAbort, createZeroFilledFile, diff --git a/test/common/index.mjs b/test/common/index.mjs index 54f6dc7f173cdf..a5774fc008a9b3 100644 --- a/test/common/index.mjs +++ b/test/common/index.mjs @@ -39,7 +39,6 @@ const { skip, ArrayStream, nodeProcessAborted, - busyLoop, isAlive, expectWarning, expectsError, @@ -86,7 +85,6 @@ export { skip, ArrayStream, nodeProcessAborted, - busyLoop, isAlive, expectWarning, expectsError, diff --git a/test/common/tmpdir.js b/test/common/tmpdir.js index 16d375afff06b1..5e1e21429fe06b 100644 --- a/test/common/tmpdir.js +++ b/test/common/tmpdir.js @@ -1,93 +1,12 @@ /* eslint-disable node-core/require-common-first, node-core/required-modules */ 'use strict'; -const { execSync } = require('child_process'); const fs = require('fs'); const path = require('path'); -const { debuglog } = require('util'); const { isMainThread } = require('worker_threads'); -const debug = debuglog('test/tmpdir'); - -function rimrafSync(pathname, { spawn = true } = {}) { - const st = (() => { - try { - return fs.lstatSync(pathname); - } catch (e) { - if (fs.existsSync(pathname)) - throw new Error(`Something wonky happened rimrafing ${pathname}`); - debug(e); - } - })(); - - // If (!st) then nothing to do. - if (!st) { - return; - } - - // On Windows first try to delegate rmdir to a shell. - if (spawn && process.platform === 'win32' && st.isDirectory()) { - try { - // Try `rmdir` first. - execSync(`rmdir /q /s ${pathname}`, { timeout: 1000 }); - } catch (e) { - // Attempt failed. Log and carry on. - debug(e); - } - } - - try { - if (st.isDirectory()) - rmdirSync(pathname, null); - else - fs.unlinkSync(pathname); - } catch (e) { - debug(e); - switch (e.code) { - case 'ENOENT': - // It's not there anymore. Work is done. Exiting. - return; - - case 'EPERM': - // This can happen, try again with `rmdirSync`. - break; - - case 'EISDIR': - // Got 'EISDIR' even after testing `st.isDirectory()`... - // Try again with `rmdirSync`. - break; - - default: - throw e; - } - rmdirSync(pathname, e); - } - - if (fs.existsSync(pathname)) - throw new Error(`Unable to rimraf ${pathname}`); -} - -function rmdirSync(p, originalEr) { - try { - fs.rmdirSync(p); - } catch (e) { - if (e.code === 'ENOTDIR') - throw originalEr; - if (e.code === 'ENOTEMPTY' || e.code === 'EEXIST' || e.code === 'EPERM') { - const enc = process.platform === 'linux' ? 'buffer' : 'utf8'; - fs.readdirSync(p, enc).forEach((f) => { - if (f instanceof Buffer) { - const buf = Buffer.concat([Buffer.from(p), Buffer.from(path.sep), f]); - rimrafSync(buf); - } else { - rimrafSync(path.join(p, f)); - } - }); - fs.rmdirSync(p); - return; - } - throw e; - } +function rimrafSync(pathname) { + fs.rmdirSync(pathname, { maxRetries: 3, recursive: true }); } const testRoot = process.env.NODE_TEST_DIR ? @@ -100,8 +19,8 @@ const tmpdirName = '.tmp.' + const tmpPath = path.join(testRoot, tmpdirName); let firstRefresh = true; -function refresh(opts = {}) { - rimrafSync(this.path, opts); +function refresh() { + rimrafSync(this.path); fs.mkdirSync(this.path); if (firstRefresh) { @@ -118,7 +37,7 @@ function onexit() { process.chdir(testRoot); try { - rimrafSync(tmpPath, { spawn: false }); + rimrafSync(tmpPath); } catch (e) { console.error('Can\'t clean tmpdir:', tmpPath); diff --git a/test/es-module/test-cjs-esm-warn.js b/test/es-module/test-cjs-esm-warn.js index b1b2e7f434256f..ddeda72fc84b41 100644 --- a/test/es-module/test-cjs-esm-warn.js +++ b/test/es-module/test-cjs-esm-warn.js @@ -26,8 +26,9 @@ child.on('close', common.mustCall((code, signal) => { assert.strictEqual(code, 1); assert.strictEqual(signal, null); - assert.ok(stderr.startsWith(`(node:${child.pid}) Warning: ` + - 'require() of ES modules is not supported.\nrequire() of ' + + assert.ok(stderr.replace(/\r/g, '').includes( + `Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: ${required}` + + '\nrequire() of ES modules is not supported.\nrequire() of ' + `${required} from ${requiring} ` + 'is an ES module file as it is a .js file whose nearest parent ' + 'package.json contains "type": "module" which defines all .js ' + @@ -35,6 +36,6 @@ child.on('close', common.mustCall((code, signal) => { `${basename} to end in .cjs, change the requiring code to use ` + 'import(), or remove "type": "module" from ' + `${pjson}.\n`)); - assert.ok(stderr.indexOf( - 'Error [ERR_REQUIRE_ESM]: Must use import to load ES Module') !== -1); + assert.ok(stderr.includes( + 'Error [ERR_REQUIRE_ESM]: Must use import to load ES Module')); })); diff --git a/test/es-module/test-esm-dynamic-import.js b/test/es-module/test-esm-dynamic-import.js index 8a92ac41edbdfd..1fc22f1d98934a 100644 --- a/test/es-module/test-esm-dynamic-import.js +++ b/test/es-module/test-esm-dynamic-import.js @@ -42,6 +42,9 @@ function expectFsNamespace(result) { // For direct use of import expressions inside of CJS or ES modules, including // via eval, all kinds of specifiers should work without issue. (function testScriptOrModuleImport() { + common.expectWarning('ExperimentalWarning', + 'The ESM module loader is experimental.'); + // Importing another file, both direct & via eval // expectOkNamespace(import(relativePath)); expectOkNamespace(eval(`import("${relativePath}")`)); diff --git a/test/es-module/test-esm-exports.mjs b/test/es-module/test-esm-exports.mjs index a361bafaa83804..fd85e155b0af21 100644 --- a/test/es-module/test-esm-exports.mjs +++ b/test/es-module/test-esm-exports.mjs @@ -1,6 +1,8 @@ // Flags: --experimental-modules import { mustCall } from '../common/index.mjs'; +import { path } from '../common/fixtures.mjs'; import { ok, deepStrictEqual, strictEqual } from 'assert'; +import { spawn } from 'child_process'; import { requireFixture, importFixture } from '../fixtures/pkgexports.mjs'; import fromInside from '../fixtures/node_modules/pkgexports/lib/hole.js'; @@ -29,7 +31,7 @@ import fromInside from '../fixtures/node_modules/pkgexports/lib/hole.js'; ['pkgexports-sugar', { default: 'main' }], // Conditional object exports sugar ['pkgexports-sugar2', isRequire ? { default: 'not-exported' } : - { default: 'main' }] + { default: 'main' }], ]); for (const [validSpecifier, expected] of validSpecifiers) { @@ -49,7 +51,7 @@ import fromInside from '../fixtures/node_modules/pkgexports/lib/hole.js'; ['pkgexports-number/hidden.js', './hidden.js'], // Sugar cases still encapsulate ['pkgexports-sugar/not-exported.js', './not-exported.js'], - ['pkgexports-sugar2/not-exported.js', './not-exported.js'] + ['pkgexports-sugar2/not-exported.js', './not-exported.js'], ]); const invalidExports = new Map([ @@ -95,6 +97,15 @@ import fromInside from '../fixtures/node_modules/pkgexports/lib/hole.js'; })); } + // Conditional export, even with no match, should still be used instead + // of falling back to main + if (isRequire) { + loadFixture('pkgexports-main').catch(mustCall((err) => { + strictEqual(err.code, 'MODULE_NOT_FOUND'); + assertStartsWith(err.message, 'No valid export'); + })); + } + // Covering out bases - not a file is still not a file after dir mapping. loadFixture('pkgexports/sub/not-a-file.js').catch(mustCall((err) => { strictEqual(err.code, (isRequire ? '' : 'ERR_') + 'MODULE_NOT_FOUND'); @@ -149,3 +160,33 @@ function assertIncludes(actual, expected) { ok(actual.toString().indexOf(expected) !== -1, `${JSON.stringify(actual)} includes ${JSON.stringify(expected)}`); } + +// Test warning message +[ + [ + '--experimental-conditional-exports', + '/es-modules/conditional-exports.js', + 'Conditional exports', + ], + [ + '--experimental-resolve-self', + '/node_modules/pkgexports/resolve-self.js', + 'Package name self resolution', + ], +].forEach(([flag, file, message]) => { + const child = spawn(process.execPath, [flag, path(file)]); + + let stderr = ''; + child.stderr.setEncoding('utf8'); + child.stderr.on('data', (data) => { + stderr += data; + }); + child.on('close', (code, signal) => { + strictEqual(code, 0); + strictEqual(signal, null); + ok(stderr.toString().includes( + `ExperimentalWarning: ${message} is an experimental feature. ` + + 'This feature could change at any time' + )); + }); +}); diff --git a/test/es-module/test-esm-invalid-extension.js b/test/es-module/test-esm-invalid-extension.js index cdf9476b29f864..87b0c6691d3445 100644 --- a/test/es-module/test-esm-invalid-extension.js +++ b/test/es-module/test-esm-invalid-extension.js @@ -6,8 +6,10 @@ const { spawnSync } = require('child_process'); const fixture = fixtures.path('/es-modules/import-invalid-ext.mjs'); const child = spawnSync(process.execPath, [fixture]); const errMsg = 'TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension'; +const importMsg = `imported from ${fixture}`; assert.strictEqual(child.status, 1); assert.strictEqual(child.signal, null); assert.strictEqual(child.stdout.toString().trim(), ''); assert(child.stderr.toString().includes(errMsg)); +assert(child.stderr.toString().includes(importMsg)); diff --git a/test/es-module/test-esm-json.mjs b/test/es-module/test-esm-json.mjs index 9dd33f26b557d1..ddcc7cb33e709f 100644 --- a/test/es-module/test-esm-json.mjs +++ b/test/es-module/test-esm-json.mjs @@ -1,7 +1,29 @@ // Flags: --experimental-json-modules import '../common/index.mjs'; -import { strictEqual } from 'assert'; +import { path } from '../common/fixtures.mjs'; +import { strictEqual, ok } from 'assert'; +import { spawn } from 'child_process'; import secret from '../fixtures/experimental.json'; strictEqual(secret.ofLife, 42); + +// Test warning message +const child = spawn(process.execPath, [ + '--experimental-json-modules', + path('/es-modules/json-modules.mjs') +]); + +let stderr = ''; +child.stderr.setEncoding('utf8'); +child.stderr.on('data', (data) => { + stderr += data; +}); +child.on('close', (code, signal) => { + strictEqual(code, 0); + strictEqual(signal, null); + ok(stderr.toString().includes( + 'ExperimentalWarning: Importing JSON modules is an experimental feature. ' + + 'This feature could change at any time' + )); +}); diff --git a/test/es-module/test-esm-specifiers-both-flags.mjs b/test/es-module/test-esm-specifiers-both-flags.mjs new file mode 100644 index 00000000000000..a434684589dc07 --- /dev/null +++ b/test/es-module/test-esm-specifiers-both-flags.mjs @@ -0,0 +1,14 @@ +import { mustCall } from '../common/index.mjs'; +import { exec } from 'child_process'; +import assert from 'assert'; + +const expectedError = + 'cannot use --es-module-specifier-resolution ' + + 'and --experimental-specifier-resolution at the same time'; + +const flags = '--es-module-specifier-resolution=node ' + + '--experimental-specifier-resolution=node'; + +exec(`${process.execPath} ${flags}`, mustCall((error) => { + assert(error.message.includes(expectedError)); +})); diff --git a/test/es-module/test-esm-specifiers-legacy-flag.mjs b/test/es-module/test-esm-specifiers-legacy-flag.mjs new file mode 100644 index 00000000000000..fcf0c915b649f0 --- /dev/null +++ b/test/es-module/test-esm-specifiers-legacy-flag.mjs @@ -0,0 +1,18 @@ +// Flags: --es-module-specifier-resolution=node +import '../common/index.mjs'; +import assert from 'assert'; + +// commonJS index.js +import commonjs from '../fixtures/es-module-specifiers/package-type-commonjs'; +// esm index.js +import module from '../fixtures/es-module-specifiers/package-type-module'; +// Notice the trailing slash +import success, { explicit, implicit, implicitModule } + from '../fixtures/es-module-specifiers/'; + +assert.strictEqual(commonjs, 'commonjs'); +assert.strictEqual(module, 'module'); +assert.strictEqual(success, 'success'); +assert.strictEqual(explicit, 'esm'); +assert.strictEqual(implicit, 'cjs'); +assert.strictEqual(implicitModule, 'cjs'); diff --git a/test/es-module/test-esm-specifiers.mjs b/test/es-module/test-esm-specifiers.mjs index fdf9e5b25ecea4..5e436f21b74cc6 100644 --- a/test/es-module/test-esm-specifiers.mjs +++ b/test/es-module/test-esm-specifiers.mjs @@ -1,4 +1,4 @@ -// Flags: --es-module-specifier-resolution=node +// Flags: --experimental-specifier-resolution=node import { mustNotCall } from '../common/index.mjs'; import assert from 'assert'; import path from 'path'; diff --git a/test/es-module/test-esm-type-flag-errors.js b/test/es-module/test-esm-type-flag-errors.js index 5d19cedd84a844..e0dedc16cabf8c 100644 --- a/test/es-module/test-esm-type-flag-errors.js +++ b/test/es-module/test-esm-type-flag-errors.js @@ -27,7 +27,10 @@ try { require('../fixtures/es-modules/package-type-module/index.js'); assert.fail('Expected CJS to fail loading from type: module package.'); } catch (e) { - assert(e.toString().match(/Error \[ERR_REQUIRE_ESM\]: Must use import to load ES Module:/)); + assert.strictEqual(e.name, 'Error'); + assert.strictEqual(e.code, 'ERR_REQUIRE_ESM'); + assert(e.toString().match(/Must use import to load ES Module/g)); + assert(e.message.match(/Must use import to load ES Module/g)); } function expect(opt = '', inputFile, want, wantsError = false) { diff --git a/test/es-module/test-esm-wasm.mjs b/test/es-module/test-esm-wasm.mjs index 46df5994afa932..b2218ce2f09893 100644 --- a/test/es-module/test-esm-wasm.mjs +++ b/test/es-module/test-esm-wasm.mjs @@ -1,8 +1,10 @@ // Flags: --experimental-wasm-modules import '../common/index.mjs'; +import { path } from '../common/fixtures.mjs'; import { add, addImported } from '../fixtures/es-modules/simple.wasm'; import { state } from '../fixtures/es-modules/wasm-dep.mjs'; -import { strictEqual } from 'assert'; +import { strictEqual, ok } from 'assert'; +import { spawn } from 'child_process'; strictEqual(state, 'WASM Start Executed'); @@ -13,3 +15,23 @@ strictEqual(addImported(0), 42); strictEqual(state, 'WASM JS Function Executed'); strictEqual(addImported(1), 43); + +// Test warning message +const child = spawn(process.execPath, [ + '--experimental-wasm-modules', + path('/es-modules/wasm-modules.mjs') +]); + +let stderr = ''; +child.stderr.setEncoding('utf8'); +child.stderr.on('data', (data) => { + stderr += data; +}); +child.on('close', (code, signal) => { + strictEqual(code, 0); + strictEqual(signal, null); + ok(stderr.toString().includes( + 'ExperimentalWarning: Importing Web Assembly modules is ' + + 'an experimental feature. This feature could change at any time' + )); +}); diff --git a/test/fixtures/es-modules/conditional-exports.js b/test/fixtures/es-modules/conditional-exports.js new file mode 100644 index 00000000000000..b480078bfc47f1 --- /dev/null +++ b/test/fixtures/es-modules/conditional-exports.js @@ -0,0 +1 @@ +require('pkgexports/condition') diff --git a/test/fixtures/es-modules/json-modules.mjs b/test/fixtures/es-modules/json-modules.mjs new file mode 100644 index 00000000000000..fa3f936bac921e --- /dev/null +++ b/test/fixtures/es-modules/json-modules.mjs @@ -0,0 +1 @@ +import secret from '../experimental.json'; diff --git a/test/fixtures/es-modules/wasm-modules.mjs b/test/fixtures/es-modules/wasm-modules.mjs new file mode 100644 index 00000000000000..c56e6a926b2a04 --- /dev/null +++ b/test/fixtures/es-modules/wasm-modules.mjs @@ -0,0 +1,2 @@ +import { add, addImported } from './simple.wasm'; +import { state } from './wasm-dep.mjs'; diff --git a/test/fixtures/node_modules/pkgexports-main/main.cjs b/test/fixtures/node_modules/pkgexports-main/main.cjs new file mode 100644 index 00000000000000..b2825bd3c9949b --- /dev/null +++ b/test/fixtures/node_modules/pkgexports-main/main.cjs @@ -0,0 +1 @@ +module.exports = 'cjs'; diff --git a/test/fixtures/node_modules/pkgexports-main/module.mjs b/test/fixtures/node_modules/pkgexports-main/module.mjs new file mode 100644 index 00000000000000..bd1596224653a3 --- /dev/null +++ b/test/fixtures/node_modules/pkgexports-main/module.mjs @@ -0,0 +1 @@ +export default 'module'; diff --git a/test/fixtures/node_modules/pkgexports-main/package.json b/test/fixtures/node_modules/pkgexports-main/package.json new file mode 100644 index 00000000000000..5546af0c84d7fd --- /dev/null +++ b/test/fixtures/node_modules/pkgexports-main/package.json @@ -0,0 +1,6 @@ +{ + "main": "./main.cjs", + "exports": { + "module": "./module.mjs" + } +} diff --git a/test/fixtures/node_modules/pkgexports-sugar-fail/package.json b/test/fixtures/node_modules/pkgexports-sugar-fail/package.json index 0fb05a427a76e2..bfa040647c509e 100644 --- a/test/fixtures/node_modules/pkgexports-sugar-fail/package.json +++ b/test/fixtures/node_modules/pkgexports-sugar-fail/package.json @@ -1,6 +1,6 @@ { "exports": { - "default": "./main.js", + "module": "./main.js", "./main": "./main.js" } } diff --git a/test/fixtures/node_modules/pkgexports-sugar2/package.json b/test/fixtures/node_modules/pkgexports-sugar2/package.json index 139b06665d85e0..bef4889bea8930 100644 --- a/test/fixtures/node_modules/pkgexports-sugar2/package.json +++ b/test/fixtures/node_modules/pkgexports-sugar2/package.json @@ -1,6 +1,6 @@ { "exports": { "require": "./not-exported.js", - "default": "./main.js" + "import": "./main.js" } } diff --git a/test/fixtures/node_modules/pkgexports/resolve-self.js b/test/fixtures/node_modules/pkgexports/resolve-self.js new file mode 100644 index 00000000000000..7bd3526aaa4e70 --- /dev/null +++ b/test/fixtures/node_modules/pkgexports/resolve-self.js @@ -0,0 +1 @@ +require('@pkgexports/name/valid-cjs') diff --git a/test/fixtures/test-resolution-inspect-brk-main.ext b/test/fixtures/test-resolution-inspect-brk-main.ext new file mode 100644 index 00000000000000..e69de29bb2d1d6 diff --git a/test/fixtures/test-resolution-inspect-brk-resolver.js b/test/fixtures/test-resolution-inspect-brk-resolver.js new file mode 100644 index 00000000000000..fdfb5ca5b170c2 --- /dev/null +++ b/test/fixtures/test-resolution-inspect-brk-resolver.js @@ -0,0 +1,5 @@ +'use strict'; +// eslint-disable-next-line no-unused-vars +const common = require('../common'); + +require.extensions['.ext'] = require.extensions['.js']; diff --git a/test/parallel/parallel.status b/test/parallel/parallel.status index 444cf8d1154c92..dc8d0233d7da96 100644 --- a/test/parallel/parallel.status +++ b/test/parallel/parallel.status @@ -12,13 +12,19 @@ test-net-connect-options-port: PASS,FLAKY [$system==win32] # https://github.com/nodejs/node/issues/20750 -test-http2-pipe: PASS,FLAKY -# https://github.com/nodejs/node/issues/23277 -test-worker-memory: PASS,FLAKY -# https://github.com/nodejs/node/issues/20750 test-http2-client-upload: PASS,FLAKY # https://github.com/nodejs/node/issues/20750 test-http2-client-upload-reject: PASS,FLAKY +# https://github.com/nodejs/node/issues/30847 +test-http2-compat-client-upload-reject: PASS,FLAKY +# https://github.com/nodejs/node/issues/30845 +test-http2-multistream-destroy-on-read-tls: PASS,FLAKY +# https://github.com/nodejs/node/issues/20750 +test-http2-pipe: PASS,FLAKY +# https://github.com/nodejs/node/issues/23277 +test-worker-memory: PASS,FLAKY +# https://github.com/nodejs/node/issues/30846 +test-worker-message-port-transfer-terminate: PASS,FLAKY [$system==linux] diff --git a/test/parallel/test-accessor-properties.js b/test/parallel/test-accessor-properties.js index cbd3ed65bb9dfb..a84889d617b4ad 100644 --- a/test/parallel/test-accessor-properties.js +++ b/test/parallel/test-accessor-properties.js @@ -16,18 +16,6 @@ const UDP = internalBinding('udp_wrap').UDP; { // Should throw instead of raise assertions - assert.throws(() => { - TTY.prototype.bytesRead; - }, TypeError); - - assert.throws(() => { - TTY.prototype.fd; - }, TypeError); - - assert.throws(() => { - TTY.prototype._externalStream; - }, TypeError); - assert.throws(() => { UDP.prototype.fd; }, TypeError); @@ -36,6 +24,11 @@ const UDP = internalBinding('udp_wrap').UDP; const properties = ['bytesRead', 'fd', '_externalStream']; properties.forEach((property) => { + // Should throw instead of raise assertions + assert.throws(() => { + TTY.prototype[property]; + }, TypeError, `Missing expected TypeError for TTY.prototype.${property}`); + // Should not throw for Object.getOwnPropertyDescriptor assert.strictEqual( typeof Object.getOwnPropertyDescriptor(StreamWrapProto, property), diff --git a/test/parallel/test-assert-deep.js b/test/parallel/test-assert-deep.js index 87f2a5f44f7d64..fcc3765105f57c 100644 --- a/test/parallel/test-assert-deep.js +++ b/test/parallel/test-assert-deep.js @@ -109,10 +109,7 @@ class MyDate extends Date { const date2 = new MyDate('2016'); -// deepEqual returns true as long as the time are the same, -// but deepStrictEqual checks own properties -assert.notDeepEqual(date, date2); -assert.notDeepEqual(date2, date); +assertNotDeepOrStrict(date, date2); assert.throws( () => assert.deepStrictEqual(date, date2), { @@ -142,9 +139,7 @@ class MyRegExp extends RegExp { const re1 = new RegExp('test'); const re2 = new MyRegExp('test'); -// deepEqual returns true as long as the regexp-specific properties -// are the same, but deepStrictEqual checks all properties -assert.notDeepEqual(re1, re2); +assertNotDeepOrStrict(re1, re2); assert.throws( () => assert.deepStrictEqual(re1, re2), { @@ -684,7 +679,7 @@ assert.throws( } ); -assert.deepEqual(new Date(2000, 3, 14), new Date(2000, 3, 14)); +assertDeepAndStrictEqual(new Date(2000, 3, 14), new Date(2000, 3, 14)); assert.throws(() => { assert.deepEqual(new Date(), new Date(2000, 3, 14)); }, AssertionError, @@ -702,7 +697,7 @@ assert.throws( 'notDeepEqual("a".repeat(1024), "a".repeat(1024))' ); -assert.notDeepEqual(new Date(), new Date(2000, 3, 14)); +assertNotDeepOrStrict(new Date(), new Date(2000, 3, 14)); assertDeepAndStrictEqual(/a/, /a/); assertDeepAndStrictEqual(/a/g, /a/g); @@ -743,7 +738,7 @@ a2.b = true; a2.a = 'test'; assert.throws(() => assert.deepEqual(Object.keys(a1), Object.keys(a2)), AssertionError); -assert.deepEqual(a1, a2); +assertDeepAndStrictEqual(a1, a2); // Having an identical prototype property. const nbRoot = { @@ -899,14 +894,12 @@ assert.throws( /* eslint-enable */ -assert.deepStrictEqual({ a: 4, b: '1' }, { b: '1', a: 4 }); +assertDeepAndStrictEqual({ a: 4, b: '1' }, { b: '1', a: 4 }); assert.throws( () => assert.deepStrictEqual([0, 1, 2, 'a', 'b'], [0, 1, 2, 'b', 'a']), AssertionError); -assert.deepStrictEqual(a1, a2); - // Prototype check. function Constructor1(first, last) { this.first = first; @@ -926,7 +919,7 @@ assert.throws(() => assert.deepStrictEqual(obj1, obj2), AssertionError); Constructor2.prototype = Constructor1.prototype; obj2 = new Constructor2('Ryan', 'Dahl'); -assert.deepStrictEqual(obj1, obj2); +assertDeepAndStrictEqual(obj1, obj2); // Check extra properties on errors. { @@ -1047,7 +1040,22 @@ assert.throws( Object.defineProperty(a, 'getTime', { value: () => 5 }); - assert.deepStrictEqual(a, b); + assertDeepAndStrictEqual(a, b); +} + +// Verify that an array and the equivalent fake array object +// are correctly compared +{ + const a = [1, 2, 3]; + const o = { + __proto__: Array.prototype, + 0: 1, + 1: 2, + 2: 3, + length: 3, + }; + Object.defineProperty(o, 'length', { enumerable: false }); + assertNotDeepOrStrict(o, a); } // Verify that extra keys will be tested for when using fake arrays. @@ -1064,7 +1072,7 @@ assert.throws( Object.defineProperty(a, 'length', { value: 2 }); - assert.notDeepStrictEqual(a, [1, 1]); + assertNotDeepOrStrict(a, [1, 1]); } // Verify that changed tags will still check for the error message. @@ -1123,3 +1131,69 @@ assert.throws( // The descriptor is not compared. assertDeepAndStrictEqual(a, { a: 5 }); } + +// Verify object types being identical on both sides. +{ + let a = Buffer.from('test'); + let b = Object.create( + Object.getPrototypeOf(a), + Object.getOwnPropertyDescriptors(a) + ); + Object.defineProperty(b, Symbol.toStringTag, { + value: 'Uint8Array' + }); + assertNotDeepOrStrict(a, b); + + a = new Uint8Array(10); + b = new Int8Array(10); + Object.defineProperty(b, Symbol.toStringTag, { + value: 'Uint8Array' + }); + Object.setPrototypeOf(b, Uint8Array.prototype); + assertNotDeepOrStrict(a, b); + + a = [1, 2, 3]; + b = { 0: 1, 1: 2, 2: 3 }; + Object.setPrototypeOf(b, Array.prototype); + Object.defineProperty(b, 'length', { value: 3, enumerable: false }); + Object.defineProperty(b, Symbol.toStringTag, { + value: 'Array' + }); + assertNotDeepOrStrict(a, b); + + a = new Date(2000); + b = Object.create( + Object.getPrototypeOf(a), + Object.getOwnPropertyDescriptors(a) + ); + Object.defineProperty(b, Symbol.toStringTag, { + value: 'Date' + }); + assertNotDeepOrStrict(a, b); + + a = /abc/g; + b = Object.create( + Object.getPrototypeOf(a), + Object.getOwnPropertyDescriptors(a) + ); + Object.defineProperty(b, Symbol.toStringTag, { + value: 'RegExp' + }); + assertNotDeepOrStrict(a, b); + + a = []; + b = /abc/; + Object.setPrototypeOf(b, Array.prototype); + Object.defineProperty(b, Symbol.toStringTag, { + value: 'Array' + }); + assertNotDeepOrStrict(a, b); + + a = Object.create(null); + b = new RangeError('abc'); + Object.defineProperty(a, Symbol.toStringTag, { + value: 'Error' + }); + Object.setPrototypeOf(b, null); + assertNotDeepOrStrict(a, b, assert.AssertionError); +} diff --git a/test/parallel/test-benchmark-cli.js b/test/parallel/test-benchmark-cli.js new file mode 100644 index 00000000000000..49069fecac43ce --- /dev/null +++ b/test/parallel/test-benchmark-cli.js @@ -0,0 +1,38 @@ +'use strict'; + +require('../common'); + +// This tests the CLI parser for our benchmark suite. + +const assert = require('assert'); + +const CLI = require('../../benchmark/_cli.js'); + +const originalArgv = process.argv; + +function testFilterPattern(filters, excludes, filename, expectedResult) { + process.argv = process.argv.concat(...filters.map((p) => ['--filter', p])); + process.argv = process.argv.concat(...excludes.map((p) => ['--exclude', p])); + process.argv = process.argv.concat(['bench']); + + const cli = new CLI('', { 'arrayArgs': ['filter', 'exclude'] }); + assert.deepStrictEqual(cli.shouldSkip(filename), expectedResult); + + process.argv = originalArgv; +} + + +testFilterPattern([], [], 'foo', false); + +testFilterPattern(['foo'], [], 'foo', false); +testFilterPattern(['foo'], [], 'bar', true); +testFilterPattern(['foo', 'bar'], [], 'foo', false); +testFilterPattern(['foo', 'bar'], [], 'bar', false); + +testFilterPattern([], ['foo'], 'foo', true); +testFilterPattern([], ['foo'], 'bar', false); +testFilterPattern([], ['foo', 'bar'], 'foo', true); +testFilterPattern([], ['foo', 'bar'], 'bar', true); + +testFilterPattern(['foo'], ['bar'], 'foo', false); +testFilterPattern(['foo'], ['bar'], 'foo-bar', true); diff --git a/test/sequential/test-child-process-fork-getconnections.js b/test/parallel/test-child-process-fork-getconnections.js similarity index 90% rename from test/sequential/test-child-process-fork-getconnections.js rename to test/parallel/test-child-process-fork-getconnections.js index 9a8f97c2bb2842..b96d61238a0dd8 100644 --- a/test/sequential/test-child-process-fork-getconnections.js +++ b/test/parallel/test-child-process-fork-getconnections.js @@ -20,7 +20,7 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); const fork = require('child_process').fork; const net = require('net'); @@ -58,8 +58,10 @@ if (process.argv[2] === 'child') { const child = fork(process.argv[1], ['child']); child.on('exit', function(code, signal) { - if (!subprocessKilled) - throw new Error('subprocess died unexpectedly!'); + if (!subprocessKilled) { + assert.fail('subprocess died unexpectedly! ' + + `code: ${code} signal: ${signal}`); + } }); const server = net.createServer(); @@ -79,7 +81,7 @@ if (process.argv[2] === 'child') { server.on('listening', function() { let j = count; while (j--) { - const client = net.connect(common.PORT, '127.0.0.1'); + const client = net.connect(server.address().port, '127.0.0.1'); client.on('close', function() { disconnected += 1; }); @@ -98,6 +100,8 @@ if (process.argv[2] === 'child') { child.once('message', function(m) { assert.strictEqual(m.status, 'closed'); server.getConnections(function(err, num) { + assert.ifError(err); + assert.strictEqual(num, count - (i + 1)); closeSockets(i + 1); }); }); @@ -110,7 +114,7 @@ if (process.argv[2] === 'child') { closeEmitted = true; }); - server.listen(common.PORT, '127.0.0.1'); + server.listen(0, '127.0.0.1'); process.on('exit', function() { assert.strictEqual(sent, count); diff --git a/test/parallel/test-child-process-pipe-dataflow.js b/test/parallel/test-child-process-pipe-dataflow.js index abaec73f3ea507..bc5e4e02fdf4e9 100644 --- a/test/parallel/test-child-process-pipe-dataflow.js +++ b/test/parallel/test-child-process-pipe-dataflow.js @@ -37,6 +37,14 @@ const MB = KB * KB; cat.stdout._handle.readStart = common.mustNotCall(); grep.stdout._handle.readStart = common.mustNotCall(); + // Keep an array of error codes and assert on them during process exit. This + // is because stdio can still be open when a child process exits, and we don't + // want to lose information about what caused the error. + const errors = []; + process.on('exit', () => { + assert.deepStrictEqual(errors, []); + }); + [cat, grep, wc].forEach((child, index) => { const errorHandler = (thing, type) => { // Don't want to assert here, as we might miss error code info. @@ -46,7 +54,9 @@ const MB = KB * KB; child.stderr.on('data', (d) => { errorHandler(d, 'data'); }); child.on('error', (err) => { errorHandler(err, 'error'); }); child.on('exit', common.mustCall((code) => { - assert.strictEqual(code, 0, `child ${index} exited with code ${code}`); + if (code !== 0) { + errors.push(`child ${index} exited with code ${code}`); + } })); }); diff --git a/test/parallel/test-cli-eval.js b/test/parallel/test-cli-eval.js index 2cece62a437d52..65d31642055627 100644 --- a/test/parallel/test-cli-eval.js +++ b/test/parallel/test-cli-eval.js @@ -283,3 +283,23 @@ child.exec( assert.ifError(err); assert.strictEqual(stdout, '.mjs file\n'); })); + + +// Assert that packages can be dynamic imported initial cwd-relative with --eval +child.exec( + `${nodejs} ${execOptions} ` + + '--eval "process.chdir(\'..\');' + + 'import(\'./test/fixtures/es-modules/mjs-file.mjs\')"', + common.mustCall((err, stdout) => { + assert.ifError(err); + assert.strictEqual(stdout, '.mjs file\n'); + })); + +child.exec( + `${nodejs} ` + + '--eval "process.chdir(\'..\');' + + 'import(\'./test/fixtures/es-modules/mjs-file.mjs\')"', + common.mustCall((err, stdout) => { + assert.ifError(err); + assert.strictEqual(stdout, '.mjs file\n'); + })); diff --git a/test/parallel/test-console-group.js b/test/parallel/test-console-group.js index c3c70bfa248715..99c01fc36ea469 100644 --- a/test/parallel/test-console-group.js +++ b/test/parallel/test-console-group.js @@ -23,7 +23,9 @@ function setup() { stderr += data; }); - c = new Console(process.stdout, process.stderr); + c = new Console({ stdout: process.stdout, + stderr: process.stderr, + colorMode: false }); } function teardown() { diff --git a/test/parallel/test-event-capture-rejections.js b/test/parallel/test-event-capture-rejections.js new file mode 100644 index 00000000000000..83da3184a67116 --- /dev/null +++ b/test/parallel/test-event-capture-rejections.js @@ -0,0 +1,297 @@ +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const { EventEmitter, captureRejectionSymbol } = require('events'); +const { inherits } = require('util'); + +// Inherits from EE without a call to the +// parent constructor. +function NoConstructor() { +} + +inherits(NoConstructor, EventEmitter); + +function captureRejections() { + const ee = new EventEmitter({ captureRejections: true }); + const _err = new Error('kaboom'); + ee.on('something', common.mustCall(async (value) => { + throw _err; + })); + + ee.on('error', common.mustCall((err) => { + assert.strictEqual(err, _err); + process.nextTick(captureRejectionsTwoHandlers); + })); + + ee.emit('something'); +} + +function captureRejectionsTwoHandlers() { + const ee = new EventEmitter({ captureRejections: true }); + const _err = new Error('kaboom'); + + ee.on('something', common.mustCall(async (value) => { + throw _err; + })); + + // throw twice + ee.on('something', common.mustCall(async (value) => { + throw _err; + })); + + let count = 0; + + ee.on('error', common.mustCall((err) => { + assert.strictEqual(err, _err); + if (++count === 2) { + process.nextTick(defaultValue); + } + }, 2)); + + ee.emit('something'); +} + +function defaultValue() { + const ee = new EventEmitter(); + const _err = new Error('kaboom'); + ee.on('something', common.mustCall(async (value) => { + throw _err; + })); + + process.removeAllListeners('unhandledRejection'); + + process.once('unhandledRejection', common.mustCall((err) => { + // restore default + process.on('unhandledRejection', (err) => { throw err; }); + + assert.strictEqual(err, _err); + process.nextTick(globalSetting); + })); + + ee.emit('something'); +} + +function globalSetting() { + assert.strictEqual(EventEmitter.captureRejections, false); + EventEmitter.captureRejections = true; + const ee = new EventEmitter(); + const _err = new Error('kaboom'); + ee.on('something', common.mustCall(async (value) => { + throw _err; + })); + + ee.on('error', common.mustCall((err) => { + assert.strictEqual(err, _err); + + // restore default + EventEmitter.captureRejections = false; + process.nextTick(configurable); + })); + + ee.emit('something'); +} + +// We need to be able to configure this for streams, as we would +// like to call destro(err) there. +function configurable() { + const ee = new EventEmitter({ captureRejections: true }); + const _err = new Error('kaboom'); + ee.on('something', common.mustCall(async (...args) => { + assert.deepStrictEqual(args, [42, 'foobar']); + throw _err; + })); + + assert.strictEqual(captureRejectionSymbol, Symbol.for('nodejs.rejection')); + + ee[captureRejectionSymbol] = common.mustCall((err, type, ...args) => { + assert.strictEqual(err, _err); + assert.strictEqual(type, 'something'); + assert.deepStrictEqual(args, [42, 'foobar']); + process.nextTick(globalSettingNoConstructor); + }); + + ee.emit('something', 42, 'foobar'); +} + +function globalSettingNoConstructor() { + assert.strictEqual(EventEmitter.captureRejections, false); + EventEmitter.captureRejections = true; + const ee = new NoConstructor(); + const _err = new Error('kaboom'); + ee.on('something', common.mustCall(async (value) => { + throw _err; + })); + + ee.on('error', common.mustCall((err) => { + assert.strictEqual(err, _err); + + // restore default + EventEmitter.captureRejections = false; + process.nextTick(thenable); + })); + + ee.emit('something'); +} + +function thenable() { + const ee = new EventEmitter({ captureRejections: true }); + const _err = new Error('kaboom'); + ee.on('something', common.mustCall((value) => { + const obj = {}; + + Object.defineProperty(obj, 'then', { + get: common.mustCall(() => { + return common.mustCall((resolved, rejected) => { + assert.strictEqual(resolved, undefined); + rejected(_err); + }); + }, 1) // Only 1 call for Promises/A+ compat. + }); + + return obj; + })); + + ee.on('error', common.mustCall((err) => { + assert.strictEqual(err, _err); + process.nextTick(avoidLoopOnRejection); + })); + + ee.emit('something'); +} + +function avoidLoopOnRejection() { + const ee = new EventEmitter({ captureRejections: true }); + const _err1 = new Error('kaboom'); + const _err2 = new Error('kaboom2'); + ee.on('something', common.mustCall(async (value) => { + throw _err1; + })); + + ee[captureRejectionSymbol] = common.mustCall(async (err) => { + assert.strictEqual(err, _err1); + throw _err2; + }); + + process.removeAllListeners('unhandledRejection'); + + process.once('unhandledRejection', common.mustCall((err) => { + // restore default + process.on('unhandledRejection', (err) => { throw err; }); + + assert.strictEqual(err, _err2); + process.nextTick(avoidLoopOnError); + })); + + ee.emit('something'); +} + +function avoidLoopOnError() { + const ee = new EventEmitter({ captureRejections: true }); + const _err1 = new Error('kaboom'); + const _err2 = new Error('kaboom2'); + ee.on('something', common.mustCall(async (value) => { + throw _err1; + })); + + ee.on('error', common.mustCall(async (err) => { + assert.strictEqual(err, _err1); + throw _err2; + })); + + process.removeAllListeners('unhandledRejection'); + + process.once('unhandledRejection', common.mustCall((err) => { + // restore default + process.on('unhandledRejection', (err) => { throw err; }); + + assert.strictEqual(err, _err2); + process.nextTick(thenableThatThrows); + })); + + ee.emit('something'); +} + +function thenableThatThrows() { + const ee = new EventEmitter({ captureRejections: true }); + const _err = new Error('kaboom'); + ee.on('something', common.mustCall((value) => { + const obj = {}; + + Object.defineProperty(obj, 'then', { + get: common.mustCall(() => { + throw _err; + }, 1) // Only 1 call for Promises/A+ compat. + }); + + return obj; + })); + + ee.on('error', common.mustCall((err) => { + assert.strictEqual(err, _err); + process.nextTick(resetCaptureOnThrowInError); + })); + + ee.emit('something'); +} + +function resetCaptureOnThrowInError() { + const ee = new EventEmitter({ captureRejections: true }); + ee.on('something', common.mustCall(async (value) => { + throw new Error('kaboom'); + })); + + ee.once('error', common.mustCall((err) => { + throw err; + })); + + process.removeAllListeners('uncaughtException'); + + process.once('uncaughtException', common.mustCall((err) => { + process.nextTick(next); + })); + + ee.emit('something'); + + function next() { + process.on('uncaughtException', common.mustNotCall()); + + const _err = new Error('kaboom2'); + ee.on('something2', common.mustCall(async (value) => { + throw _err; + })); + + ee.on('error', common.mustCall((err) => { + assert.strictEqual(err, _err); + + process.removeAllListeners('uncaughtException'); + + // restore default + process.on('uncaughtException', (err) => { throw err; }); + + process.nextTick(argValidation); + })); + + ee.emit('something2'); + } +} + +function argValidation() { + + function testType(obj) { + common.expectsError(() => new EventEmitter({ captureRejections: obj }), { + code: 'ERR_INVALID_ARG_TYPE', + type: TypeError + }); + + common.expectsError(() => EventEmitter.captureRejections = obj, { + code: 'ERR_INVALID_ARG_TYPE', + type: TypeError + }); + } + + testType([]); + testType({ hello: 42 }); + testType(42); +} + +captureRejections(); diff --git a/test/parallel/test-fs-symlink-dir-junction.js b/test/parallel/test-fs-symlink-dir-junction.js index fc89ad368401e4..42d6bc1214132b 100644 --- a/test/parallel/test-fs-symlink-dir-junction.js +++ b/test/parallel/test-fs-symlink-dir-junction.js @@ -53,3 +53,20 @@ fs.symlink(linkData, linkPath, 'junction', common.mustCall(function(err) { })); })); })); + +// Test invalid symlink +{ + const linkData = fixtures.path('/not/exists/dir'); + const linkPath = path.join(tmpdir.path, 'invalid_junction_link'); + + fs.symlink(linkData, linkPath, 'junction', common.mustCall(function(err) { + assert.ifError(err); + + assert(!fs.existsSync(linkPath)); + + fs.unlink(linkPath, common.mustCall(function(err) { + assert.ifError(err); + assert(!fs.existsSync(linkPath)); + })); + })); +} diff --git a/test/parallel/test-fs-symlink-dir.js b/test/parallel/test-fs-symlink-dir.js index 1ab1361a43fb9b..707bc5b486d723 100644 --- a/test/parallel/test-fs-symlink-dir.js +++ b/test/parallel/test-fs-symlink-dir.js @@ -44,3 +44,25 @@ for (const linkTarget of linkTargets) { testAsync(linkTarget, `${linkPath}-${path.basename(linkTarget)}-async`); } } + +// Test invalid symlink +{ + function testSync(target, path) { + fs.symlinkSync(target, path); + assert(!fs.existsSync(path)); + } + + function testAsync(target, path) { + fs.symlink(target, path, common.mustCall((err) => { + assert.ifError(err); + assert(!fs.existsSync(path)); + })); + } + + for (const linkTarget of linkTargets.map((p) => p + '-broken')) { + for (const linkPath of linkPaths) { + testSync(linkTarget, `${linkPath}-${path.basename(linkTarget)}-sync`); + testAsync(linkTarget, `${linkPath}-${path.basename(linkTarget)}-async`); + } + } +} diff --git a/test/parallel/test-fs-symlink.js b/test/parallel/test-fs-symlink.js index a6001103190aad..c52ffbc105ffae 100644 --- a/test/parallel/test-fs-symlink.js +++ b/test/parallel/test-fs-symlink.js @@ -58,6 +58,18 @@ fs.symlink(linkData, linkPath, common.mustCall(function(err) { })); })); +// Test invalid symlink +{ + const linkData = fixtures.path('/not/exists/file'); + const linkPath = path.join(tmpdir.path, 'symlink2.js'); + + fs.symlink(linkData, linkPath, common.mustCall(function(err) { + assert.ifError(err); + + assert(!fs.existsSync(linkPath)); + })); +} + [false, 1, {}, [], null, undefined].forEach((input) => { const errObj = { code: 'ERR_INVALID_ARG_TYPE', diff --git a/test/parallel/test-http-outgoing-message-capture-rejection.js b/test/parallel/test-http-outgoing-message-capture-rejection.js new file mode 100644 index 00000000000000..5f667ea17ea156 --- /dev/null +++ b/test/parallel/test-http-outgoing-message-capture-rejection.js @@ -0,0 +1,89 @@ +'use strict'; + +const common = require('../common'); +const assert = require('assert'); +const events = require('events'); +const { createServer, request } = require('http'); + +events.captureRejections = true; + +{ + const server = createServer(common.mustCall((req, res) => { + const _err = new Error('kaboom'); + res.on('drain', common.mustCall(async () => { + throw _err; + })); + + res.socket.on('error', common.mustCall((err) => { + assert.strictEqual(err, _err); + })); + + // Write until there is space in the buffer + while (res.write('hello')) {} + })); + + server.listen(0, common.mustCall(() => { + const req = request({ + method: 'GET', + host: server.address().host, + port: server.address().port + }); + + req.end(); + + req.on('response', common.mustCall((res) => { + res.on('aborted', common.mustCall()); + res.resume(); + server.close(); + })); + })); +} + +{ + let _res; + let shouldEnd = false; + // Not using mustCall here, because it is OS-dependant. + const server = createServer((req, res) => { + // So that we cleanly stop + _res = res; + + if (shouldEnd) { + res.end(); + } + }); + + server.listen(0, common.mustCall(() => { + const _err = new Error('kaboom'); + + const req = request({ + method: 'POST', + host: server.address().host, + port: server.address().port + }); + + req.on('response', common.mustNotCall((res) => { + // So that we cleanly stop + res.resume(); + server.close(); + })); + + req.on('error', common.mustCall((err) => { + server.close(); + // On some variants of Windows, this can happen before + // the server has received the request. + if (_res) { + _res.end(); + } else { + shouldEnd = true; + } + assert.strictEqual(err, _err); + })); + + req.on('drain', common.mustCall(async () => { + throw _err; + })); + + // Write until there is space in the buffer + while (req.write('hello')) {} + })); +} diff --git a/test/parallel/test-http-server-capture-rejections.js b/test/parallel/test-http-server-capture-rejections.js new file mode 100644 index 00000000000000..b437e27b589dfc --- /dev/null +++ b/test/parallel/test-http-server-capture-rejections.js @@ -0,0 +1,108 @@ +'use strict'; + +const common = require('../common'); +const events = require('events'); +const { createServer, request } = require('http'); +const assert = require('assert'); + +events.captureRejections = true; + +{ + const server = createServer(common.mustCall(async (req, res) => { + // We will test that this header is cleaned up before forwarding. + res.setHeader('content-type', 'application/json'); + throw new Error('kaboom'); + })); + + server.listen(0, common.mustCall(() => { + const req = request({ + method: 'GET', + host: server.address().host, + port: server.address().port + }); + + req.end(); + + req.on('response', common.mustCall((res) => { + assert.strictEqual(res.statusCode, 500); + assert.strictEqual(res.headers.hasOwnProperty('content-type'), false); + let data = ''; + res.setEncoding('utf8'); + res.on('data', common.mustCall((chunk) => { + data += chunk; + })); + res.on('end', common.mustCall(() => { + assert.strictEqual(data, 'Internal Server Error'); + server.close(); + })); + })); + })); +} + +{ + let resolve; + const latch = new Promise((_resolve) => { + resolve = _resolve; + }); + const server = createServer(common.mustCall(async (req, res) => { + server.close(); + + // We will test that this header is cleaned up before forwarding. + res.setHeader('content-type', 'application/json'); + res.write('{'); + req.resume(); + + // Wait so the data is on the wire + await latch; + + throw new Error('kaboom'); + })); + + server.listen(0, common.mustCall(() => { + const req = request({ + method: 'GET', + host: server.address().host, + port: server.address().port + }); + + req.end(); + + req.on('response', common.mustCall((res) => { + assert.strictEqual(res.statusCode, 200); + assert.strictEqual(res.headers['content-type'], 'application/json'); + resolve(); + + let data = ''; + res.setEncoding('utf8'); + res.on('data', common.mustCall((chunk) => { + data += chunk; + })); + + req.on('close', common.mustCall(() => { + assert.strictEqual(data, '{'); + })); + })); + })); +} + +{ + const server = createServer(common.mustCall(async (req, res) => { + // We will test that this header is cleaned up before forwarding. + res.writeHead(200); + throw new Error('kaboom'); + })); + + server.listen(0, common.mustCall(() => { + const req = request({ + method: 'GET', + host: server.address().host, + port: server.address().port + }); + + req.end(); + req.on('error', common.mustCall((err) => { + assert.strictEqual(err.code, 'ECONNRESET'); + server.close(); + })); + })); +} diff --git a/test/parallel/test-http2-capture-rejection.js b/test/parallel/test-http2-capture-rejection.js new file mode 100644 index 00000000000000..58f43581eb6bd3 --- /dev/null +++ b/test/parallel/test-http2-capture-rejection.js @@ -0,0 +1,152 @@ +'use strict'; + +const common = require('../common'); +if (!common.hasCrypto) + common.skip('missing crypto'); + +const assert = require('assert'); +const events = require('events'); +const { createServer, connect } = require('http2'); + +events.captureRejections = true; + +{ + // Test error thrown in the server 'stream' event, + // after a respond() + + const server = createServer(); + server.on('stream', common.mustCall(async (stream) => { + server.close(); + + stream.respond({ ':status': 200 }); + + const _err = new Error('kaboom'); + stream.on('error', common.mustCall((err) => { + assert.strictEqual(err, _err); + })); + throw _err; + })); + + server.listen(0, common.mustCall(() => { + const { port } = server.address(); + const session = connect(`http://localhost:${port}`); + + const req = session.request(); + + req.on('error', common.mustCall((err) => { + assert.strictEqual(err.code, 'ERR_HTTP2_STREAM_ERROR'); + })); + + req.on('close', common.mustCall(() => { + session.close(); + })); + })); +} + +{ + // Test error thrown in the server 'stream' event, + // before a respond(). + + const server = createServer(); + server.on('stream', common.mustCall(async (stream) => { + server.close(); + + stream.on('error', common.mustNotCall()); + + throw new Error('kaboom'); + })); + + server.listen(0, common.mustCall(() => { + const { port } = server.address(); + const session = connect(`http://localhost:${port}`); + + const req = session.request(); + + req.on('response', common.mustCall((headers) => { + assert.strictEqual(headers[':status'], 500); + })); + + req.on('close', common.mustCall(() => { + session.close(); + })); + })); +} + + +{ + // Test error thrown in 'request' event + + const server = createServer(common.mustCall(async (req, res) => { + server.close(); + res.setHeader('content-type', 'application/json'); + const _err = new Error('kaboom'); + throw _err; + })); + + server.listen(0, common.mustCall(() => { + const { port } = server.address(); + const session = connect(`http://localhost:${port}`); + + const req = session.request(); + + req.on('response', common.mustCall((headers) => { + assert.strictEqual(headers[':status'], 500); + assert.strictEqual(Object.hasOwnProperty.call(headers, 'content-type'), + false); + })); + + req.on('close', common.mustCall(() => { + session.close(); + })); + + req.resume(); + })); +} + +{ + // Test error thrown in the client 'stream' event + + const server = createServer(); + server.on('stream', common.mustCall(async (stream) => { + const { port } = server.address(); + + server.close(); + + stream.pushStream({ + ':scheme': 'http', + ':path': '/foobar', + ':authority': `localhost:${port}`, + }, common.mustCall((err, push) => { + push.respond({ + 'content-type': 'text/html', + ':status': 200 + }); + push.end('pushed by the server'); + + stream.end('test'); + })); + + stream.respond({ + ':status': 200 + }); + })); + + server.listen(0, common.mustCall(() => { + const { port } = server.address(); + const session = connect(`http://localhost:${port}`); + + const req = session.request(); + + session.on('stream', common.mustCall(async (stream) => { + session.close(); + + const _err = new Error('kaboom'); + stream.on('error', common.mustCall((err) => { + assert.strictEqual(err, _err); + })); + throw _err; + })); + + req.end(); + })); +} diff --git a/test/parallel/test-http2-debug.js b/test/parallel/test-http2-debug.js index ad86e76ab75771..ce1873234e76ec 100644 --- a/test/parallel/test-http2-debug.js +++ b/test/parallel/test-http2-debug.js @@ -18,6 +18,10 @@ assert(stderr.match(/Http2Session client \(\d+\) handling data frame for stream stderr); assert(stderr.match(/HttpStream \d+ \(\d+\) \[Http2Session client \(\d+\)\] reading starting/), stderr); +assert(stderr.match(/HttpStream \d+ \(\d+\) \[Http2Session client \(\d+\)\] closed with code 0/), + stderr); +assert(stderr.match(/HttpStream \d+ \(\d+\) \[Http2Session server \(\d+\)\] closed with code 0/), + stderr); assert(stderr.match(/HttpStream \d+ \(\d+\) \[Http2Session server \(\d+\)\] tearing down stream/), stderr); assert.strictEqual(stdout.trim(), ''); diff --git a/test/parallel/test-net-server-capture-rejection.js b/test/parallel/test-net-server-capture-rejection.js new file mode 100644 index 00000000000000..b1564ec26874af --- /dev/null +++ b/test/parallel/test-net-server-capture-rejection.js @@ -0,0 +1,27 @@ +'use strict'; + +const common = require('../common'); +const assert = require('assert'); +const events = require('events'); +const { createServer, connect } = require('net'); + +events.captureRejections = true; + +const server = createServer(common.mustCall(async (sock) => { + server.close(); + + const _err = new Error('kaboom'); + sock.on('error', common.mustCall((err) => { + assert.strictEqual(err, _err); + })); + throw _err; +})); + +server.listen(0, common.mustCall(() => { + const sock = connect( + server.address().port, + server.address().host + ); + + sock.on('close', common.mustCall()); +})); diff --git a/test/parallel/test-process-env-allowed-flags-are-documented.js b/test/parallel/test-process-env-allowed-flags-are-documented.js index 2e0d67eefcb242..f356f88fe9c740 100644 --- a/test/parallel/test-process-env-allowed-flags-are-documented.js +++ b/test/parallel/test-process-env-allowed-flags-are-documented.js @@ -85,6 +85,7 @@ const undocumented = difference(process.allowedNodeEnvironmentFlags, documented); // Remove intentionally undocumented options. assert(undocumented.delete('--debug-arraybuffer-allocations')); +assert(undocumented.delete('--es-module-specifier-resolution')); assert(undocumented.delete('--experimental-worker')); assert(undocumented.delete('--no-node-snapshot')); assert(undocumented.delete('--loader')); diff --git a/test/parallel/test-readline-async-iterators-destroy.js b/test/parallel/test-readline-async-iterators-destroy.js index ea174d51723aa8..e96f831432b1eb 100644 --- a/test/parallel/test-readline-async-iterators-destroy.js +++ b/test/parallel/test-readline-async-iterators-destroy.js @@ -2,6 +2,7 @@ const common = require('../common'); const fs = require('fs'); +const { once } = require('events'); const { join } = require('path'); const readline = require('readline'); const assert = require('assert'); @@ -45,6 +46,8 @@ async function testSimpleDestroy() { rli.close(); readable.destroy(); + + await once(readable, 'close'); } } @@ -78,6 +81,8 @@ async function testMutualDestroy() { rli.close(); readable.destroy(); + + await once(readable, 'close'); } } diff --git a/test/parallel/test-repl-harmony.js b/test/parallel/test-repl-harmony.js index 0aa8e56bdd6e2e..88b2c9deca1b05 100644 --- a/test/parallel/test-repl-harmony.js +++ b/test/parallel/test-repl-harmony.js @@ -30,7 +30,7 @@ const child = spawn(process.execPath, args); const input = '(function(){"use strict"; const y=1;y=2})()\n'; // This message will vary based on JavaScript engine, so don't check the message // contents beyond confirming that the `Error` is a `TypeError`. -const expectOut = /> Thrown:\nTypeError: /; +const expectOut = /> Uncaught TypeError: /; child.stderr.setEncoding('utf8'); child.stderr.on('data', (d) => { diff --git a/test/parallel/test-repl-history-navigation.js b/test/parallel/test-repl-history-navigation.js index b00f932aa9a253..3bd198880fc015 100644 --- a/test/parallel/test-repl-history-navigation.js +++ b/test/parallel/test-repl-history-navigation.js @@ -46,28 +46,50 @@ ActionStream.prototype.readable = true; const ENTER = { name: 'enter' }; const UP = { name: 'up' }; const DOWN = { name: 'down' }; +const LEFT = { name: 'left' }; +const DELETE = { name: 'delete' }; const prompt = '> '; +const prev = process.features.inspector; + const tests = [ { // Creates few history to navigate for env: { NODE_REPL_HISTORY: defaultHistoryPath }, test: [ 'let ab = 45', ENTER, '555 + 909', ENTER, - '{key : {key2 :[] }}', ENTER], + '{key : {key2 :[] }}', ENTER, + 'Array(100).fill(1).map((e, i) => i ** i)', LEFT, LEFT, DELETE, + '2', ENTER], expected: [], clean: false }, { env: { NODE_REPL_HISTORY: defaultHistoryPath }, - test: [UP, UP, UP, UP, DOWN, DOWN, DOWN], + test: [UP, UP, UP, UP, UP, DOWN, DOWN, DOWN, DOWN], expected: [prompt, + `${prompt}Array(100).fill(1).map((e, i) => i ** 2)`, + prev && '\n// [ 0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, ' + + '144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529,' + + ' 576, 625, 676, 729, 784, 841, 900, 961, 1024, 1089, 1156, ' + + '1225, 1296, 1369, 1444, 1521, 1600, 1681, 1764, 1849, 1936,' + + ' 2025, 2116, 2209, ...', `${prompt}{key : {key2 :[] }}`, + prev && '\n// { key: { key2: [] } }', `${prompt}555 + 909`, + prev && '\n// 1464', `${prompt}let ab = 45`, `${prompt}555 + 909`, + prev && '\n// 1464', `${prompt}{key : {key2 :[] }}`, - prompt], + prev && '\n// { key: { key2: [] } }', + `${prompt}Array(100).fill(1).map((e, i) => i ** 2)`, + prev && '\n// [ 0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, ' + + '144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529,' + + ' 576, 625, 676, 729, 784, 841, 900, 961, 1024, 1089, 1156, ' + + '1225, 1296, 1369, 1444, 1521, 1600, 1681, 1764, 1849, 1936,' + + ' 2025, 2116, 2209, ...', + prompt].filter((e) => typeof e === 'string'), clean: true } ]; diff --git a/test/parallel/test-repl-multiline.js b/test/parallel/test-repl-multiline.js index 454d5b10192fa5..6498923b62ecfc 100644 --- a/test/parallel/test-repl-multiline.js +++ b/test/parallel/test-repl-multiline.js @@ -3,34 +3,44 @@ const common = require('../common'); const ArrayStream = require('../common/arraystream'); const assert = require('assert'); const repl = require('repl'); -const inputStream = new ArrayStream(); -const outputStream = new ArrayStream(); -const input = ['const foo = {', '};', 'foo;']; -let output = ''; +const input = ['const foo = {', '};', 'foo']; -outputStream.write = (data) => { output += data.replace('\r', ''); }; +function run({ useColors }) { + const inputStream = new ArrayStream(); + const outputStream = new ArrayStream(); + let output = ''; -const r = repl.start({ - prompt: '', - input: inputStream, - output: outputStream, - terminal: true, - useColors: false -}); + outputStream.write = (data) => { output += data.replace('\r', ''); }; -r.on('exit', common.mustCall(() => { - const actual = output.split('\n'); + const r = repl.start({ + prompt: '', + input: inputStream, + output: outputStream, + terminal: true, + useColors + }); - // Validate the output, which contains terminal escape codes. - assert.strictEqual(actual.length, 6); - assert.ok(actual[0].endsWith(input[0])); - assert.ok(actual[1].includes('... ')); - assert.ok(actual[1].endsWith(input[1])); - assert.strictEqual(actual[2], 'undefined'); - assert.ok(actual[3].endsWith(input[2])); - assert.strictEqual(actual[4], '{}'); - // Ignore the last line, which is nothing but escape codes. -})); + r.on('exit', common.mustCall(() => { + const actual = output.split('\n'); -inputStream.run(input); -r.close(); + // Validate the output, which contains terminal escape codes. + assert.strictEqual(actual.length, 6 + process.features.inspector); + assert.ok(actual[0].endsWith(input[0])); + assert.ok(actual[1].includes('... ')); + assert.ok(actual[1].endsWith(input[1])); + assert.ok(actual[2].includes('undefined')); + assert.ok(actual[3].endsWith(input[2])); + if (process.features.inspector) { + assert.ok(actual[4].includes(actual[5])); + assert.strictEqual(actual[4].includes('//'), !useColors); + } + assert.strictEqual(actual[4 + process.features.inspector], '{}'); + // Ignore the last line, which is nothing but escape codes. + })); + + inputStream.run(input); + r.close(); +} + +run({ useColors: true }); +run({ useColors: false }); diff --git a/test/parallel/test-repl-null-thrown.js b/test/parallel/test-repl-null-thrown.js index 1fe5d30396d534..0ed4a05fd5de55 100644 --- a/test/parallel/test-repl-null-thrown.js +++ b/test/parallel/test-repl-null-thrown.js @@ -20,5 +20,5 @@ replserver.emit('line', '.exit'); setTimeout(() => { console.log(text); - assert(text.includes('Thrown: null')); + assert(text.includes('Uncaught null')); }, 0); diff --git a/test/parallel/test-repl-pretty-custom-stack.js b/test/parallel/test-repl-pretty-custom-stack.js index 0d2ada134fe2f8..8f633a4d4808c5 100644 --- a/test/parallel/test-repl-pretty-custom-stack.js +++ b/test/parallel/test-repl-pretty-custom-stack.js @@ -48,26 +48,26 @@ const tests = [ { // test .load for a file that throws command: `.load ${fixtures.path('repl-pretty-stack.js')}`, - expected: 'Thrown:\nError: Whoops!--->\nrepl:*:*--->\nd (repl:*:*)' + + expected: 'Uncaught Error: Whoops!--->\nrepl:*:*--->\nd (repl:*:*)' + '--->\nc (repl:*:*)--->\nb (repl:*:*)--->\na (repl:*:*)\n' }, { command: 'let x y;', - expected: 'Thrown:\n' + - 'let x y;\n ^\n\nSyntaxError: Unexpected identifier\n' + expected: 'let x y;\n ^\n\n' + + 'Uncaught SyntaxError: Unexpected identifier\n' }, { command: 'throw new Error(\'Whoops!\')', - expected: 'Thrown:\nError: Whoops!\n' + expected: 'Uncaught Error: Whoops!\n' }, { command: 'foo = bar;', - expected: 'Thrown:\nReferenceError: bar is not defined\n' + expected: 'Uncaught ReferenceError: bar is not defined\n' }, // test anonymous IIFE { command: '(function() { throw new Error(\'Whoops!\'); })()', - expected: 'Thrown:\nError: Whoops!--->\nrepl:*:*\n' + expected: 'Uncaught Error: Whoops!--->\nrepl:*:*\n' } ]; diff --git a/test/parallel/test-repl-pretty-stack.js b/test/parallel/test-repl-pretty-stack.js index 9f307c4f430b8c..456e866b7b20f9 100644 --- a/test/parallel/test-repl-pretty-stack.js +++ b/test/parallel/test-repl-pretty-stack.js @@ -7,7 +7,7 @@ const repl = require('repl'); const stackRegExp = /(at .*repl:)[0-9]+:[0-9]+/g; -function run({ command, expected, ...extraREPLOptions }) { +function run({ command, expected, ...extraREPLOptions }, i) { let accum = ''; const inputStream = new ArrayStream(); @@ -25,6 +25,7 @@ function run({ command, expected, ...extraREPLOptions }) { }); r.write(`${command}\n`); + console.log(i); assert.strictEqual( accum.replace(stackRegExp, '$1*:*'), expected.replace(stackRegExp, '$1*:*') @@ -36,39 +37,39 @@ const tests = [ { // Test .load for a file that throws. command: `.load ${fixtures.path('repl-pretty-stack.js')}`, - expected: 'Thrown:\nError: Whoops!\n at repl:*:*\n' + + expected: 'Uncaught Error: Whoops!\n at repl:*:*\n' + ' at d (repl:*:*)\n at c (repl:*:*)\n' + ' at b (repl:*:*)\n at a (repl:*:*)\n' }, { command: 'let x y;', - expected: 'Thrown:\n' + - 'let x y;\n ^\n\nSyntaxError: Unexpected identifier\n' + expected: 'let x y;\n ^\n\n' + + 'Uncaught SyntaxError: Unexpected identifier\n' }, { command: 'throw new Error(\'Whoops!\')', - expected: 'Thrown:\nError: Whoops!\n' + expected: 'Uncaught Error: Whoops!\n' }, { command: '(() => { const err = Error(\'Whoops!\'); ' + 'err.foo = \'bar\'; throw err; })()', - expected: "Thrown:\nError: Whoops!\n at repl:*:* {\n foo: 'bar'\n}\n", + expected: "Uncaught Error: Whoops!\n at repl:*:* {\n foo: 'bar'\n}\n", }, { command: '(() => { const err = Error(\'Whoops!\'); ' + 'err.foo = \'bar\'; throw err; })()', - expected: 'Thrown:\nError: Whoops!\n at repl:*:* {\n foo: ' + + expected: 'Uncaught Error: Whoops!\n at repl:*:* {\n foo: ' + "\u001b[32m'bar'\u001b[39m\n}\n", useColors: true }, { command: 'foo = bar;', - expected: 'Thrown:\nReferenceError: bar is not defined\n' + expected: 'Uncaught ReferenceError: bar is not defined\n' }, // Test anonymous IIFE. { command: '(function() { throw new Error(\'Whoops!\'); })()', - expected: 'Thrown:\nError: Whoops!\n at repl:*:*\n' + expected: 'Uncaught Error: Whoops!\n at repl:*:*\n' } ]; diff --git a/test/parallel/test-repl-preview.js b/test/parallel/test-repl-preview.js new file mode 100644 index 00000000000000..92e73dd245056f --- /dev/null +++ b/test/parallel/test-repl-preview.js @@ -0,0 +1,131 @@ +'use strict'; + +const common = require('../common'); +const ArrayStream = require('../common/arraystream'); +const assert = require('assert'); +const Repl = require('repl'); + +common.skipIfInspectorDisabled(); + +const PROMPT = 'repl > '; + +class REPLStream extends ArrayStream { + constructor() { + super(); + this.lines = ['']; + } + write(chunk) { + const chunkLines = chunk.toString('utf8').split('\n'); + this.lines[this.lines.length - 1] += chunkLines[0]; + if (chunkLines.length > 1) { + this.lines.push(...chunkLines.slice(1)); + } + this.emit('line'); + return true; + } + wait() { + this.lines = ['']; + return new Promise((resolve, reject) => { + const onError = (err) => { + this.removeListener('line', onLine); + reject(err); + }; + const onLine = () => { + if (this.lines[this.lines.length - 1].includes(PROMPT)) { + this.removeListener('error', onError); + this.removeListener('line', onLine); + resolve(this.lines); + } + }; + this.once('error', onError); + this.on('line', onLine); + }); + } +} + +function runAndWait(cmds, repl) { + const promise = repl.inputStream.wait(); + for (const cmd of cmds) { + repl.inputStream.run([cmd]); + } + return promise; +} + +async function tests(options) { + const repl = Repl.start({ + prompt: PROMPT, + stream: new REPLStream(), + ignoreUndefined: true, + useColors: true, + ...options + }); + + repl.inputStream.run([ + 'function foo(x) { return x; }', + 'function koo() { console.log("abc"); }', + 'a = undefined;' + ]); + const testCases = [ + ['foo', [2, 4], '[Function: foo]', + 'foo', + '\x1B[90m[Function: foo]\x1B[39m\x1B[1A\x1B[11G\x1B[1B\x1B[2K\x1B[1A\r', + '\x1B[36m[Function: foo]\x1B[39m', + '\x1B[1G\x1B[0Jrepl > \x1B[8G'], + ['koo', [2, 4], '[Function: koo]', + 'koo', + '\x1B[90m[Function: koo]\x1B[39m\x1B[1A\x1B[11G\x1B[1B\x1B[2K\x1B[1A\r', + '\x1B[36m[Function: koo]\x1B[39m', + '\x1B[1G\x1B[0Jrepl > \x1B[8G'], + ['a', [1, 2], undefined], + ['{ a: true }', [2, 3], '{ a: \x1B[33mtrue\x1B[39m }', + '{ a: true }\r', + '{ a: \x1B[33mtrue\x1B[39m }', + '\x1B[1G\x1B[0Jrepl > \x1B[8G'], + ['1n + 2n', [2, 5], '\x1B[33m3n\x1B[39m', + '1n + 2', + '\x1B[90mType[39m\x1B[1A\x1B[14G\x1B[1B\x1B[2K\x1B[1An', + '\x1B[90m3n\x1B[39m\x1B[1A\x1B[15G\x1B[1B\x1B[2K\x1B[1A\r', + '\x1B[33m3n\x1B[39m', + '\x1B[1G\x1B[0Jrepl > \x1B[8G'], + ['{ a: true };', [2, 4], '\x1B[33mtrue\x1B[39m', + '{ a: true };', + '\x1B[90mtrue\x1B[39m\x1B[1A\x1B[20G\x1B[1B\x1B[2K\x1B[1A\r', + '\x1B[33mtrue\x1B[39m', + '\x1B[1G\x1B[0Jrepl > \x1B[8G'], + [' \t { a: true};', [2, 5], '\x1B[33mtrue\x1B[39m', + ' \t { a: true}', + '\x1B[90m{ a: true }\x1B[39m\x1B[1A\x1B[21G\x1B[1B\x1B[2K\x1B[1A;', + '\x1B[90mtrue\x1B[39m\x1B[1A\x1B[22G\x1B[1B\x1B[2K\x1B[1A\r', + '\x1B[33mtrue\x1B[39m', + '\x1B[1G\x1B[0Jrepl > \x1B[8G'] + ]; + + const hasPreview = repl.terminal && + (options.preview !== undefined ? !!options.preview : true); + + for (const [input, length, expected, ...preview] of testCases) { + console.log(`Testing ${input}`); + + const toBeRun = input.split('\n'); + let lines = await runAndWait(toBeRun, repl); + + assert.strictEqual(lines.length, length[+hasPreview]); + if (expected === undefined) { + assert(!lines.some((e) => e.includes('undefined'))); + } else if (hasPreview) { + // Remove error messages. That allows the code to run in different + // engines. + // eslint-disable-next-line no-control-regex + lines = lines.map((line) => line.replace(/Error: .+?\x1B/, '')); + assert.deepStrictEqual(lines, preview); + } else { + assert.ok(lines[0].includes(expected), lines); + } + } +} + +tests({ terminal: false }); // No preview +tests({ terminal: true }); // Preview +tests({ terminal: false, preview: false }); // No preview +tests({ terminal: false, preview: true }); // No preview +tests({ terminal: true, preview: true }); // Preview diff --git a/test/parallel/test-repl-require.js b/test/parallel/test-repl-require.js index 818fca7431fa94..391b629b1b3a3b 100644 --- a/test/parallel/test-repl-require.js +++ b/test/parallel/test-repl-require.js @@ -11,28 +11,61 @@ if (!common.isMainThread) process.chdir(fixtures.fixturesDir); const repl = require('repl'); -const server = net.createServer((conn) => { - repl.start('', conn).on('exit', () => { - conn.destroy(); - server.close(); +{ + const server = net.createServer((conn) => { + repl.start('', conn).on('exit', () => { + conn.destroy(); + server.close(); + }); }); -}); - -const host = common.localhostIPv4; -const port = 0; -const options = { host, port }; - -let answer = ''; -server.listen(options, function() { - options.port = this.address().port; - const conn = net.connect(options); - conn.setEncoding('utf8'); - conn.on('data', (data) => answer += data); - conn.write('require("baz")\nrequire("./baz")\n.exit\n'); -}); - -process.on('exit', function() { - assert.strictEqual(/Cannot find module/.test(answer), false); - assert.strictEqual(/Error/.test(answer), false); - assert.strictEqual(answer, '\'eye catcher\'\n\'perhaps I work\'\n'); -}); + + const host = common.localhostIPv4; + const port = 0; + const options = { host, port }; + + let answer = ''; + server.listen(options, function() { + options.port = this.address().port; + const conn = net.connect(options); + conn.setEncoding('utf8'); + conn.on('data', (data) => answer += data); + conn.write('require("baz")\nrequire("./baz")\n.exit\n'); + }); + + process.on('exit', function() { + assert.strictEqual(/Cannot find module/.test(answer), false); + assert.strictEqual(/Error/.test(answer), false); + assert.strictEqual(answer, '\'eye catcher\'\n\'perhaps I work\'\n'); + }); +} + +// Test for https://github.com/nodejs/node/issues/30808 +// In REPL, we shouldn't look up relative modules from 'node_modules'. +{ + const server = net.createServer((conn) => { + repl.start('', conn).on('exit', () => { + conn.destroy(); + server.close(); + }); + }); + + const host = common.localhostIPv4; + const port = 0; + const options = { host, port }; + + let answer = ''; + server.listen(options, function() { + options.port = this.address().port; + const conn = net.connect(options); + conn.setEncoding('utf8'); + conn.on('data', (data) => answer += data); + conn.write('require("./bar")\n.exit\n'); + }); + + process.on('exit', function() { + assert.strictEqual(/Uncaught Error: Cannot find module '\.\/bar'/.test(answer), true); + + assert.strictEqual(/code: 'MODULE_NOT_FOUND'/.test(answer), true); + assert.strictEqual(/requireStack: \[ '' \]/.test(answer), true); + }); +} diff --git a/test/parallel/test-repl-top-level-await.js b/test/parallel/test-repl-top-level-await.js index f629d3f1d0d428..cecbd3ab4563d0 100644 --- a/test/parallel/test-repl-top-level-await.js +++ b/test/parallel/test-repl-top-level-await.js @@ -1,11 +1,13 @@ 'use strict'; -require('../common'); +const common = require('../common'); const ArrayStream = require('../common/arraystream'); const assert = require('assert'); const { stripVTControlCharacters } = require('internal/readline/utils'); const repl = require('repl'); +common.skipIfInspectorDisabled(); + // Flags: --expose-internals --experimental-repl-await const PROMPT = 'await repl > '; @@ -84,61 +86,84 @@ async function ordinaryTests() { const testCases = [ [ 'await Promise.resolve(0)', '0' ], [ '{ a: await Promise.resolve(1) }', '{ a: 1 }' ], - [ '_', '{ a: 1 }' ], - [ 'let { a, b } = await Promise.resolve({ a: 1, b: 2 }), f = 5;', + [ '_', '// { a: 1 }\r', { line: 0 } ], + [ 'let { aa, bb } = await Promise.resolve({ aa: 1, bb: 2 }), f = 5;', 'undefined' ], - [ 'a', '1' ], - [ 'b', '2' ], - [ 'f', '5' ], - [ 'let c = await Promise.resolve(2)', 'undefined' ], - [ 'c', '2' ], - [ 'let d;', 'undefined' ], - [ 'd', 'undefined' ], - [ 'let [i, { abc: { k } }] = [0, { abc: { k: 1 } }];', 'undefined' ], - [ 'i', '0' ], - [ 'k', '1' ], - [ 'var l = await Promise.resolve(2);', 'undefined' ], - [ 'l', '2' ], - [ 'foo(await koo())', '4' ], - [ '_', '4' ], - [ 'const m = foo(await koo());', 'undefined' ], - [ 'm', '4' ], - [ 'const n = foo(await\nkoo());', 'undefined' ], - [ 'n', '4' ], + [ 'aa', ['// 1\r', '1'] ], + [ 'bb', ['// 2\r', '2'] ], + [ 'f', ['// 5\r', '5'] ], + [ 'let cc = await Promise.resolve(2)', 'undefined' ], + [ 'cc', ['// 2\r', '2'] ], + [ 'let dd;', 'undefined' ], + [ 'dd', 'undefined' ], + [ 'let [ii, { abc: { kk } }] = [0, { abc: { kk: 1 } }];', 'undefined' ], + [ 'ii', ['// 0\r', '0'] ], + [ 'kk', ['// 1\r', '1'] ], + [ 'var ll = await Promise.resolve(2);', 'undefined' ], + [ 'll', ['// 2\r', '2'] ], + [ 'foo(await koo())', + [ 'f', '// 5oo', '// [Function: foo](await koo())\r', '4' ] ], + [ '_', ['// 4\r', '4'] ], + [ 'const m = foo(await koo());', + [ 'const m = foo(await koo());\r', 'undefined' ] ], + [ 'm', ['// 4\r', '4' ] ], + [ 'const n = foo(await\nkoo());', + [ 'const n = foo(await\r', '... koo());\r', 'undefined' ] ], + [ 'n', ['// 4\r', '4' ] ], // eslint-disable-next-line no-template-curly-in-string [ '`status: ${(await Promise.resolve({ status: 200 })).status}`', "'status: 200'"], - [ 'for (let i = 0; i < 2; ++i) await i', 'undefined' ], - [ 'for (let i = 0; i < 2; ++i) { await i }', 'undefined' ], - [ 'await 0', '0' ], - [ 'await 0; function foo() {}', 'undefined' ], - [ 'foo', '[Function: foo]' ], - [ 'class Foo {}; await 1;', '1' ], - [ 'Foo', '[Function: Foo]' ], - [ 'if (await true) { function bar() {}; }', 'undefined' ], - [ 'bar', '[Function: bar]' ], + [ 'for (let i = 0; i < 2; ++i) await i', + ['f', '// 5or (let i = 0; i < 2; ++i) await i\r', 'undefined'] ], + [ 'for (let i = 0; i < 2; ++i) { await i }', + [ 'f', '// 5or (let i = 0; i < 2; ++i) { await i }\r', 'undefined' ] ], + [ 'await 0', ['await 0\r', '0'] ], + [ 'await 0; function foo() {}', + ['await 0; function foo() {}\r', 'undefined'] ], + [ 'foo', + ['f', '// 5oo', '// [Function: foo]\r', '[Function: foo]'] ], + [ 'class Foo {}; await 1;', ['class Foo {}; await 1;\r', '1'] ], + [ 'Foo', ['// [Function: Foo]\r', '[Function: Foo]'] ], + [ 'if (await true) { function bar() {}; }', + ['if (await true) { function bar() {}; }\r', 'undefined'] ], + [ 'bar', ['// [Function: bar]\r', '[Function: bar]'] ], [ 'if (await true) { class Bar {}; }', 'undefined' ], - [ 'Bar', 'ReferenceError: Bar is not defined', { line: 1 } ], + [ 'Bar', 'Uncaught ReferenceError: Bar is not defined' ], [ 'await 0; function* gen(){}', 'undefined' ], - [ 'for (var i = 0; i < 10; ++i) { await i; }', 'undefined' ], - [ 'i', '10' ], - [ 'for (let j = 0; j < 5; ++j) { await j; }', 'undefined' ], - [ 'j', 'ReferenceError: j is not defined', { line: 1 } ], - [ 'gen', '[GeneratorFunction: gen]' ], - [ 'return 42; await 5;', 'SyntaxError: Illegal return statement', - { line: 4 } ], + [ 'for (var i = 0; i < 10; ++i) { await i; }', + ['f', '// 5or (var i = 0; i < 10; ++i) { await i; }\r', 'undefined'] ], + [ 'i', ['// 10\r', '10'] ], + [ 'for (let j = 0; j < 5; ++j) { await j; }', + ['f', '// 5or (let j = 0; j < 5; ++j) { await j; }\r', 'undefined'] ], + [ 'j', 'Uncaught ReferenceError: j is not defined', { line: 0 } ], + [ 'gen', ['// [GeneratorFunction: gen]\r', '[GeneratorFunction: gen]'] ], + [ 'return 42; await 5;', 'Uncaught SyntaxError: Illegal return statement', + { line: 3 } ], [ 'let o = await 1, p', 'undefined' ], [ 'p', 'undefined' ], [ 'let q = 1, s = await 2', 'undefined' ], - [ 's', '2' ], - [ 'for await (let i of [1,2,3]) console.log(i)', 'undefined', { line: 3 } ] + [ 's', ['// 2\r', '2'] ], + [ 'for await (let i of [1,2,3]) console.log(i)', + [ + 'f', + '// 5or await (let i of [1,2,3]) console.log(i)\r', + '1', + '2', + '3', + 'undefined' + ] + ] ]; for (const [input, expected, options = {}] of testCases) { console.log(`Testing ${input}`); const toBeRun = input.split('\n'); const lines = await runAndWait(toBeRun); - if ('line' in options) { + if (Array.isArray(expected)) { + if (lines[0] === input) + lines.shift(); + assert.deepStrictEqual(lines, [...expected, PROMPT]); + } else if ('line' in options) { assert.strictEqual(lines[toBeRun.length + options.line], expected); } else { const echoed = toBeRun.map((a, i) => `${i > 0 ? '... ' : ''}${a}\r`); @@ -160,7 +185,7 @@ async function ctrlCTest() { { ctrl: true, name: 'c' } ]), [ 'await timeout(100000)\r', - 'Thrown:', + 'Uncaught:', '[Error [ERR_SCRIPT_EXECUTION_INTERRUPTED]: ' + 'Script execution was interrupted by `SIGINT`] {', " code: 'ERR_SCRIPT_EXECUTION_INTERRUPTED'", diff --git a/test/parallel/test-repl-uncaught-exception-standalone.js b/test/parallel/test-repl-uncaught-exception-standalone.js index ae7b214fefae9e..e7371f9f7c617f 100644 --- a/test/parallel/test-repl-uncaught-exception-standalone.js +++ b/test/parallel/test-repl-uncaught-exception-standalone.js @@ -18,8 +18,7 @@ child.on('exit', common.mustCall(() => { [ 'Type ".help" for more information.', // x\n - '> Thrown:', - 'ReferenceError: x is not defined', + '> Uncaught ReferenceError: x is not defined', // Added `uncaughtException` listener. '> short', 'undefined', diff --git a/test/parallel/test-repl-uncaught-exception.js b/test/parallel/test-repl-uncaught-exception.js index 447b69b1d4a29e..28e62dff22bf3a 100644 --- a/test/parallel/test-repl-uncaught-exception.js +++ b/test/parallel/test-repl-uncaught-exception.js @@ -6,7 +6,7 @@ const repl = require('repl'); let count = 0; -function run({ command, expected }) { +function run({ command, expected, useColors = false }) { let accum = ''; const output = new ArrayStream(); @@ -17,7 +17,7 @@ function run({ command, expected }) { input: new ArrayStream(), output, terminal: false, - useColors: false + useColors }); r.write(`${command}\n`); @@ -30,35 +30,40 @@ function run({ command, expected }) { // Verify that the repl is still working as expected. accum = ''; r.write('1 + 1\n'); - assert.strictEqual(accum, '2\n'); + // eslint-disable-next-line no-control-regex + assert.strictEqual(accum.replace(/\u001b\[[0-9]+m/g, ''), '2\n'); r.close(); count++; } const tests = [ { + useColors: true, command: 'x', - expected: 'Thrown:\n' + - 'ReferenceError: x is not defined\n' + expected: 'Uncaught ReferenceError: x is not defined\n' + }, + { + useColors: true, + command: 'throw { foo: "test" }', + expected: "Uncaught { foo: \x1B[32m'test'\x1B[39m }\n" }, { command: 'process.on("uncaughtException", () => console.log("Foobar"));\n', - expected: /^Thrown:\nTypeError \[ERR_INVALID_REPL_INPUT]: Listeners for `/ + expected: /^Uncaught:\nTypeError \[ERR_INVALID_REPL_INPUT]: Listeners for `/ }, { command: 'x;\n', - expected: 'Thrown:\n' + - 'ReferenceError: x is not defined\n' + expected: 'Uncaught ReferenceError: x is not defined\n' }, { command: 'process.on("uncaughtException", () => console.log("Foobar"));' + 'console.log("Baz");\n', - expected: /^Thrown:\nTypeError \[ERR_INVALID_REPL_INPUT]: Listeners for `/ + expected: /^Uncaught:\nTypeError \[ERR_INVALID_REPL_INPUT]: Listeners for `/ }, { command: 'console.log("Baz");' + 'process.on("uncaughtException", () => console.log("Foobar"));\n', - expected: /^Baz\nThrown:\nTypeError \[ERR_INVALID_REPL_INPUT]:.*uncaughtException/ + expected: /^Baz\nUncaught:\nTypeError \[ERR_INVALID_REPL_INPUT]:.*uncaughtException/ } ]; diff --git a/test/parallel/test-repl-underscore.js b/test/parallel/test-repl-underscore.js index 2e0865f5a75b16..c05c387471b59f 100644 --- a/test/parallel/test-repl-underscore.js +++ b/test/parallel/test-repl-underscore.js @@ -173,13 +173,11 @@ function testError() { 'undefined', // The error, both from the original throw and the `_error` echo. - 'Thrown:', - 'Error: foo', + 'Uncaught Error: foo', '[Error: foo]', // The sync error, with individual property echoes - 'Thrown:', - /^Error: ENOENT: no such file or directory, scandir '.*nonexistent\?'/, + /^Uncaught Error: ENOENT: no such file or directory, scandir '.*nonexistent\?'/, /Object\.readdirSync/, /^ errno: -(2|4058),$/, " syscall: 'scandir',", @@ -194,8 +192,7 @@ function testError() { 'undefined', // The message from the original throw - 'Thrown:', - 'Error: baz', + 'Uncaught Error: baz', ]; for (const line of lines) { const expected = expectedLines.shift(); @@ -218,8 +215,7 @@ function testError() { "'baz'", 'Expression assignment to _error now disabled.', '0', - 'Thrown:', - 'Error: quux', + 'Uncaught Error: quux', '0' ]); }); diff --git a/test/parallel/test-repl.js b/test/parallel/test-repl.js index 05608bd5ee6ac3..b0dad397ccc06b 100644 --- a/test/parallel/test-repl.js +++ b/test/parallel/test-repl.js @@ -126,7 +126,7 @@ const unixTests = [ const strictModeTests = [ { send: 'ref = 1', - expect: ['Thrown:', /^ReferenceError:\s/] + expect: [/^Uncaught ReferenceError:\s/] } ]; @@ -134,11 +134,11 @@ const errorTests = [ // Uncaught error throws and prints out { send: 'throw new Error(\'test error\');', - expect: ['Thrown:', 'Error: test error'] + expect: ['Uncaught Error: test error'] }, { send: "throw { foo: 'bar' };", - expect: "Thrown: { foo: 'bar' }" + expect: "Uncaught { foo: 'bar' }" }, // Common syntax error is treated as multiline command { @@ -153,7 +153,7 @@ const errorTests = [ // But passing the same string to eval() should throw { send: 'eval("function test_func() {")', - expect: ['Thrown:', /^SyntaxError: /] + expect: [/^Uncaught SyntaxError: /] }, // Can handle multiline template literals { @@ -210,89 +210,84 @@ const errorTests = [ // should throw { send: 'JSON.parse(\'{invalid: \\\'json\\\'}\');', - expect: ['Thrown:', /^SyntaxError: /] + expect: [/^Uncaught SyntaxError: /] }, // End of input to JSON.parse error is special case of syntax error, // should throw { send: 'JSON.parse(\'066\');', - expect: ['Thrown:', /^SyntaxError: /] + expect: [/^Uncaught SyntaxError: /] }, // should throw { send: 'JSON.parse(\'{\');', - expect: ['Thrown:', /^SyntaxError: /] + expect: [/^Uncaught SyntaxError: /] }, // invalid RegExps are a special case of syntax error, // should throw { send: '/(/;', - expect: ['Thrown:', /^SyntaxError: /] + expect: [/^Uncaught SyntaxError: /] }, // invalid RegExp modifiers are a special case of syntax error, // should throw (GH-4012) { send: 'new RegExp("foo", "wrong modifier");', - expect: ['Thrown:', /^SyntaxError: /] + expect: [/^Uncaught SyntaxError: /] }, // Strict mode syntax errors should be caught (GH-5178) { send: '(function() { "use strict"; return 0755; })()', expect: [ - 'Thrown:', kSource, kArrow, '', - /^SyntaxError: / + /^Uncaught SyntaxError: / ] }, { send: '(function(a, a, b) { "use strict"; return a + b + c; })()', expect: [ - 'Thrown:', kSource, kArrow, '', - /^SyntaxError: / + /^Uncaught SyntaxError: / ] }, { send: '(function() { "use strict"; with (this) {} })()', expect: [ - 'Thrown:', kSource, kArrow, '', - /^SyntaxError: / + /^Uncaught SyntaxError: / ] }, { send: '(function() { "use strict"; var x; delete x; })()', expect: [ - 'Thrown:', kSource, kArrow, '', - /^SyntaxError: / + /^Uncaught SyntaxError: / ] }, { send: '(function() { "use strict"; eval = 17; })()', expect: [ - 'Thrown:', kSource, kArrow, '', - /^SyntaxError: / + /^Uncaught SyntaxError: / ] }, { send: '(function() { "use strict"; if (true) function f() { } })()', expect: [ - 'Thrown:', kSource, kArrow, '', + 'Uncaught:', /^SyntaxError: / ] }, @@ -413,11 +408,10 @@ const errorTests = [ { send: '[] \\', expect: [ - 'Thrown:', kSource, kArrow, '', - /^SyntaxError: / + /^Uncaught SyntaxError: / ] }, // Do not fail when a String is created with line continuation @@ -548,8 +542,7 @@ const errorTests = [ { send: 'require("internal/repl")', expect: [ - 'Thrown:', - /^Error: Cannot find module 'internal\/repl'/, + /^Uncaught Error: Cannot find module 'internal\/repl'/, /^Require stack:/, /^- /, /^ at .*/, @@ -587,11 +580,10 @@ const errorTests = [ { send: 'a = 3.5e', expect: [ - 'Thrown:', kSource, kArrow, '', - /^SyntaxError: / + /^Uncaught SyntaxError: / ] }, // Mitigate https://github.com/nodejs/node/issues/548 @@ -607,22 +599,20 @@ const errorTests = [ { send: 'a = 3.5e', expect: [ - 'Thrown:', kSource, kArrow, '', - /^SyntaxError: / + /^Uncaught SyntaxError: / ] }, // Avoid emitting stack trace { send: 'a = 3.5e', expect: [ - 'Thrown:', kSource, kArrow, '', - /^SyntaxError: / + /^Uncaught SyntaxError: / ] }, @@ -687,11 +677,10 @@ const errorTests = [ { send: '...[]', expect: [ - 'Thrown:', kSource, kArrow, '', - /^SyntaxError: / + /^Uncaught SyntaxError: / ] }, // Bring back the repl to prompt @@ -702,31 +691,28 @@ const errorTests = [ { send: 'console.log("Missing comma in arg list" process.version)', expect: [ - 'Thrown:', kSource, kArrow, '', - /^SyntaxError: / + /^Uncaught SyntaxError: / ] }, { send: 'x = {\nfield\n{', expect: [ - '... ... Thrown:', - '{', + '... ... {', kArrow, '', - /^SyntaxError: / + /^Uncaught SyntaxError: / ] }, { send: '(2 + 3))', expect: [ - 'Thrown:', kSource, kArrow, '', - /^SyntaxError: / + /^Uncaught SyntaxError: / ] }, { @@ -740,11 +726,10 @@ const errorTests = [ { send: '} else {', expect: [ - 'Thrown:', kSource, kArrow, '', - /^SyntaxError: / + /^Uncaught SyntaxError: / ] }, ]; diff --git a/test/parallel/test-require-resolve.js b/test/parallel/test-require-resolve.js index 2ffcc711854a87..484263c226f4a3 100644 --- a/test/parallel/test-require-resolve.js +++ b/test/parallel/test-require-resolve.js @@ -23,6 +23,8 @@ const common = require('../common'); const fixtures = require('../common/fixtures'); const assert = require('assert'); +const { builtinModules } = require('module'); +const path = require('path'); assert.strictEqual( require.resolve(fixtures.path('a')).toLowerCase(), @@ -52,3 +54,28 @@ const re = /^The "request" argument must be of type string\. Received type \w+$/ message: re }); }); + +// Test require.resolve.paths. +{ + // builtinModules. + builtinModules.forEach((mod) => { + assert.strictEqual(require.resolve.paths(mod), null); + }); + + // node_modules. + const resolvedPaths = require.resolve.paths('eslint'); + assert.strictEqual(Array.isArray(resolvedPaths), true); + assert.strictEqual(resolvedPaths[0].includes('node_modules'), true); + + // relativeModules. + const relativeModules = ['.', '..', './foo', '../bar']; + relativeModules.forEach((mod) => { + const resolvedPaths = require.resolve.paths(mod); + assert.strictEqual(Array.isArray(resolvedPaths), true); + assert.strictEqual(resolvedPaths.length, 1); + assert.strictEqual(resolvedPaths[0], path.dirname(__filename)); + + // Shouldn't look up relative modules from 'node_modules'. + assert.strictEqual(resolvedPaths.includes('/node_modules'), false); + }); +} diff --git a/test/parallel/test-stream-catch-rejections.js b/test/parallel/test-stream-catch-rejections.js new file mode 100644 index 00000000000000..fb5f1fccc18bd2 --- /dev/null +++ b/test/parallel/test-stream-catch-rejections.js @@ -0,0 +1,52 @@ +'use strict'; + +const common = require('../common'); +const stream = require('stream'); +const assert = require('assert'); + +{ + const r = new stream.Readable({ + captureRejections: true, + read() { + this.push('hello'); + this.push('world'); + this.push(null); + } + }); + + const err = new Error('kaboom'); + + r.on('error', common.mustCall((_err) => { + assert.strictEqual(err, _err); + assert.strictEqual(r.destroyed, true); + })); + + r.on('data', async () => { + throw err; + }); +} + +{ + const w = new stream.Writable({ + captureRejections: true, + highWaterMark: 1, + write(chunk, enc, cb) { + cb(); + } + }); + + const err = new Error('kaboom'); + + w.write('hello', () => { + w.write('world'); + }); + + w.on('error', common.mustCall((_err) => { + assert.strictEqual(err, _err); + assert.strictEqual(w.destroyed, true); + })); + + w.on('drain', common.mustCall(async () => { + throw err; + }, 2)); +} diff --git a/test/parallel/test-timers-nested.js b/test/parallel/test-timers-nested.js index 0ff228abf50311..b983b002c5f5ad 100644 --- a/test/parallel/test-timers-nested.js +++ b/test/parallel/test-timers-nested.js @@ -1,7 +1,9 @@ +// Flags: --expose-internals 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); +const { sleep } = require('internal/util'); // Make sure we test 0ms timers, since they would had always wanted to run on // the current tick, and greater than 0ms timers, for scenarios where the @@ -23,7 +25,7 @@ scenarios.forEach(function(delay) { // Busy loop for the same timeout used for the nested timer to ensure that // we are in fact expiring the nested timer. - common.busyLoop(delay); + sleep(delay); // The purpose of running this assert in nextTick is to make sure it runs // after A but before the next iteration of the libuv event loop. diff --git a/test/parallel/test-timers-next-tick.js b/test/parallel/test-timers-next-tick.js index 89ebf6c8c1a9d7..12335013660423 100644 --- a/test/parallel/test-timers-next-tick.js +++ b/test/parallel/test-timers-next-tick.js @@ -1,6 +1,8 @@ +// Flags: --expose-internals 'use strict'; const common = require('../common'); +const { sleep } = require('internal/util'); // This test verifies that the next tick queue runs after each // individual Timeout, as well as each individual Immediate. @@ -16,7 +18,7 @@ const t2 = setTimeout(common.mustNotCall(), 1); const t3 = setTimeout(common.mustNotCall(), 1); setTimeout(common.mustCall(), 1); -common.busyLoop(5); +sleep(5); setImmediate(common.mustCall(() => { process.nextTick(() => { diff --git a/test/parallel/test-tls-getcipher.js b/test/parallel/test-tls-getcipher.js index 624f8efd24ba6e..744276aa59bf37 100644 --- a/test/parallel/test-tls-getcipher.js +++ b/test/parallel/test-tls-getcipher.js @@ -52,6 +52,7 @@ server.listen(0, '127.0.0.1', common.mustCall(function() { }, common.mustCall(function() { const cipher = this.getCipher(); assert.strictEqual(cipher.name, 'AES128-SHA256'); + assert.strictEqual(cipher.standardName, 'TLS_RSA_WITH_AES_128_CBC_SHA256'); assert.strictEqual(cipher.version, 'TLSv1.2'); this.end(); })); @@ -65,6 +66,8 @@ server.listen(0, '127.0.0.1', common.mustCall(function() { }, common.mustCall(function() { const cipher = this.getCipher(); assert.strictEqual(cipher.name, 'ECDHE-RSA-AES128-GCM-SHA256'); + assert.strictEqual(cipher.standardName, + 'TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256'); assert.strictEqual(cipher.version, 'TLSv1.2'); this.end(); })); @@ -86,6 +89,7 @@ tls.createServer({ }, common.mustCall(() => { const cipher = client.getCipher(); assert.strictEqual(cipher.name, 'TLS_AES_128_CCM_8_SHA256'); + assert.strictEqual(cipher.standardName, cipher.name); assert.strictEqual(cipher.version, 'TLSv1.3'); client.end(); })); diff --git a/test/parallel/test-tls-multi-key.js b/test/parallel/test-tls-multi-key.js index c5e66f3980b999..b9eaa05d59feb6 100644 --- a/test/parallel/test-tls-multi-key.js +++ b/test/parallel/test-tls-multi-key.js @@ -157,6 +157,7 @@ function test(options) { }, common.mustCall(function() { assert.deepStrictEqual(ecdsa.getCipher(), { name: 'ECDHE-ECDSA-AES256-GCM-SHA384', + standardName: 'TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384', version: 'TLSv1.2' }); assert.strictEqual(ecdsa.getPeerCertificate().subject.CN, eccCN); @@ -175,6 +176,7 @@ function test(options) { }, common.mustCall(function() { assert.deepStrictEqual(rsa.getCipher(), { name: 'ECDHE-RSA-AES256-GCM-SHA384', + standardName: 'TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384', version: 'TLSv1.2' }); assert.strictEqual(rsa.getPeerCertificate().subject.CN, rsaCN); diff --git a/test/parallel/test-tls-multi-pfx.js b/test/parallel/test-tls-multi-pfx.js index 3b0c0591822adc..c20376a82ad8a8 100644 --- a/test/parallel/test-tls-multi-pfx.js +++ b/test/parallel/test-tls-multi-pfx.js @@ -42,9 +42,11 @@ const server = tls.createServer(options, function(conn) { process.on('exit', function() { assert.deepStrictEqual(ciphers, [{ name: 'ECDHE-ECDSA-AES256-GCM-SHA384', + standardName: 'TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384', version: 'TLSv1.2' }, { name: 'ECDHE-RSA-AES256-GCM-SHA384', + standardName: 'TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384', version: 'TLSv1.2' }]); }); diff --git a/test/parallel/test-tls-server-capture-rejection.js b/test/parallel/test-tls-server-capture-rejection.js new file mode 100644 index 00000000000000..f9bd3320e101f0 --- /dev/null +++ b/test/parallel/test-tls-server-capture-rejection.js @@ -0,0 +1,34 @@ +'use strict'; + +const common = require('../common'); +if (!common.hasCrypto) + common.skip('missing crypto'); + +const assert = require('assert'); +const events = require('events'); +const fixtures = require('../common/fixtures'); +const { createServer, connect } = require('tls'); +const cert = fixtures.readKey('rsa_cert.crt'); +const key = fixtures.readKey('rsa_private.pem'); + +events.captureRejections = true; + +const server = createServer({ cert, key }, common.mustCall(async (sock) => { + server.close(); + + const _err = new Error('kaboom'); + sock.on('error', common.mustCall((err) => { + assert.strictEqual(err, _err); + })); + throw _err; +})); + +server.listen(0, common.mustCall(() => { + const sock = connect({ + port: server.address().port, + host: server.address().host, + rejectUnauthorized: false + }); + + sock.on('close', common.mustCall()); +})); diff --git a/test/parallel/test-util-inspect-proxy.js b/test/parallel/test-util-inspect-proxy.js index da0512eda1a8b2..3e1341fadfc9f9 100644 --- a/test/parallel/test-util-inspect-proxy.js +++ b/test/parallel/test-util-inspect-proxy.js @@ -41,12 +41,22 @@ proxyObj = new Proxy(target, handler); // Inspecting the proxy should not actually walk it's properties util.inspect(proxyObj, opts); +// Make sure inspecting object does not trigger any proxy traps. +util.format('%s', proxyObj); + // getProxyDetails is an internal method, not intended for public use. // This is here to test that the internals are working correctly. -const details = processUtil.getProxyDetails(proxyObj); +let details = processUtil.getProxyDetails(proxyObj, true); assert.strictEqual(target, details[0]); assert.strictEqual(handler, details[1]); +details = processUtil.getProxyDetails(proxyObj); +assert.strictEqual(target, details[0]); +assert.strictEqual(handler, details[1]); + +details = processUtil.getProxyDetails(proxyObj, false); +assert.strictEqual(target, details); + assert.strictEqual( util.inspect(proxyObj, opts), 'Proxy [\n' + @@ -105,7 +115,7 @@ const expected6 = 'Proxy [\n' + ' ]\n' + ']'; assert.strictEqual( - util.inspect(proxy1, { showProxy: true, depth: null }), + util.inspect(proxy1, { showProxy: 1, depth: null }), expected1); assert.strictEqual(util.inspect(proxy2, opts), expected2); assert.strictEqual(util.inspect(proxy3, opts), expected3); diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js index 09ec140a19f9f1..4355e615c4fb0b 100644 --- a/test/parallel/test-util-inspect.js +++ b/test/parallel/test-util-inspect.js @@ -883,6 +883,10 @@ util.inspect({ hasOwnProperty: null }); assert.strictEqual(opts.budget, undefined); assert.strictEqual(opts.indentationLvl, undefined); assert.strictEqual(opts.showHidden, false); + assert.deepStrictEqual( + new Set(Object.keys(util.inspect.defaultOptions).concat(['stylize'])), + new Set(Object.keys(opts)) + ); opts.showHidden = true; return { [util.inspect.custom]: common.mustCall((depth, opts2) => { assert.deepStrictEqual(clone, opts2); @@ -909,10 +913,11 @@ util.inspect({ hasOwnProperty: null }); } { - const subject = { [util.inspect.custom]: common.mustCall((depth) => { + const subject = { [util.inspect.custom]: common.mustCall((depth, opts) => { assert.strictEqual(depth, null); + assert.strictEqual(opts.compact, true); }) }; - util.inspect(subject, { depth: null }); + util.inspect(subject, { depth: null, compact: true }); } { @@ -2070,6 +2075,34 @@ assert.strictEqual(inspect(new BigUint64Array([0n])), 'BigUint64Array [ 0n ]'); `\u001b[${string[0]}m'Oh no!'\u001b[${string[1]}m }` ); rejection.catch(() => {}); + + // Verify that aliases do not show up as key while checking `inspect.colors`. + const colors = Object.keys(inspect.colors); + const aliases = Object.getOwnPropertyNames(inspect.colors) + .filter((c) => !colors.includes(c)); + assert(!colors.includes('grey')); + assert(colors.includes('gray')); + // Verify that all aliases are correctly mapped. + for (const alias of aliases) { + assert(Array.isArray(inspect.colors[alias])); + } + // Check consistent naming. + [ + 'black', + 'red', + 'green', + 'yellow', + 'blue', + 'magenta', + 'cyan', + 'white' + ].forEach((color, i) => { + assert.deepStrictEqual(inspect.colors[color], [30 + i, 39]); + assert.deepStrictEqual(inspect.colors[`${color}Bright`], [90 + i, 39]); + const bgColor = `bg${color[0].toUpperCase()}${color.slice(1)}`; + assert.deepStrictEqual(inspect.colors[bgColor], [40 + i, 49]); + assert.deepStrictEqual(inspect.colors[`${bgColor}Bright`], [100 + i, 49]); + }); } assert.strictEqual( diff --git a/test/parallel/test-util-sleep.js b/test/parallel/test-util-sleep.js new file mode 100644 index 00000000000000..e4cc62b8e07d64 --- /dev/null +++ b/test/parallel/test-util-sleep.js @@ -0,0 +1,19 @@ +// Flags: --expose-internals +'use strict'; +require('../common'); +const assert = require('assert'); +const { sleep } = require('internal/util'); + +[undefined, null, '', {}, true, false].forEach((value) => { + assert.throws( + () => { sleep(value); }, + /The "msec" argument must be of type number/ + ); +}); + +[-1, 3.14, NaN, 4294967296].forEach((value) => { + assert.throws( + () => { sleep(value); }, + /The value of "msec" is out of range/ + ); +}); diff --git a/test/parallel/test-worker-process-argv.js b/test/parallel/test-worker-process-argv.js new file mode 100644 index 00000000000000..ebdebe02ab855c --- /dev/null +++ b/test/parallel/test-worker-process-argv.js @@ -0,0 +1,49 @@ +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const { Worker, isMainThread, workerData } = require('worker_threads'); + +if (isMainThread) { + assert.throws(() => { + new Worker(__filename, { argv: 'foo' }); + }, { + code: 'ERR_INVALID_ARG_TYPE' + }); + + [ + new Worker(__filename, { + argv: [null, 'foo', 123, Symbol('bar')], + // Asserts only if the worker is started by the test. + workerData: 'assert-argv' + }), + new Worker(` + const assert = require('assert'); + assert.deepStrictEqual( + process.argv, + [process.execPath, '[worker eval]'] + ); + `, { + eval: true + }), + new Worker(` + const assert = require('assert'); + assert.deepStrictEqual( + process.argv, + [process.execPath, '[worker eval]', 'null', 'foo', '123', + String(Symbol('bar'))] + ); + `, { + argv: [null, 'foo', 123, Symbol('bar')], + eval: true + }) + ].forEach((worker) => { + worker.on('exit', common.mustCall((code) => { + assert.strictEqual(code, 0); + })); + }); +} else if (workerData === 'assert-argv') { + assert.deepStrictEqual( + process.argv, + [process.execPath, __filename, 'null', 'foo', '123', String(Symbol('bar'))] + ); +} diff --git a/test/pummel/test-heapdump-http2.js b/test/pummel/test-heapdump-http2.js index caece96d01cc72..b3d819edaef91a 100644 --- a/test/pummel/test-heapdump-http2.js +++ b/test/pummel/test-heapdump-http2.js @@ -69,6 +69,7 @@ server.listen(0, () => { { children: [ { node_name: 'Http2Session', edge_name: 'wrapped' }, + { node_name: 'Node / nghttp2_memory', edge_name: 'nghttp2_memory' }, { node_name: 'Node / streams', edge_name: 'streams' } diff --git a/test/root.status b/test/root.status index 25400990b68af8..91aad08caa3527 100644 --- a/test/root.status +++ b/test/root.status @@ -1,11 +1,7 @@ [$mode==debug] async-hooks/test-callback-error: SLOW -async-hooks/test-callback-error: SLOW -async-hooks/test-emit-init: SLOW async-hooks/test-emit-init: SLOW async-hooks/test-querywrap: SLOW -async-hooks/test-querywrap: SLOW -async-hooks/test-tlswrap: SLOW async-hooks/test-tlswrap: SLOW message/eval_messages: SLOW message/stdin_messages: SLOW diff --git a/test/sequential/sequential.status b/test/sequential/sequential.status index 38bc644e974d3d..5c825b135c0db1 100644 --- a/test/sequential/sequential.status +++ b/test/sequential/sequential.status @@ -9,6 +9,8 @@ prefix sequential [$system==win32] # https://github.com/nodejs/node/issues/22327 test-http2-large-file: PASS, FLAKY +# https://github.com/nodejs/node/issues/26401 +test-worker-prof: PASS, FLAKY [$system==linux] diff --git a/test/sequential/test-https-server-keep-alive-timeout.js b/test/sequential/test-https-server-keep-alive-timeout.js index 3c18d325c15b93..5ded520dc7aaf8 100644 --- a/test/sequential/test-https-server-keep-alive-timeout.js +++ b/test/sequential/test-https-server-keep-alive-timeout.js @@ -34,13 +34,13 @@ test(function serverKeepAliveTimeoutWithPipeline(cb) { common.mustCall((req, res) => { res.end(); }, 3)); - server.setTimeout(500, common.mustCall((socket) => { + server.setTimeout(common.platformTimeout(500), common.mustCall((socket) => { // End this test and call `run()` for the next test (if any). socket.destroy(); server.close(); cb(); })); - server.keepAliveTimeout = 50; + server.keepAliveTimeout = common.platformTimeout(50); server.listen(0, common.mustCall(() => { const options = { port: server.address().port, @@ -57,13 +57,13 @@ test(function serverKeepAliveTimeoutWithPipeline(cb) { test(function serverNoEndKeepAliveTimeoutWithPipeline(cb) { const server = https.createServer(serverOptions, common.mustCall(3)); - server.setTimeout(500, common.mustCall((socket) => { + server.setTimeout(common.platformTimeout(500), common.mustCall((socket) => { // End this test and call `run()` for the next test (if any). socket.destroy(); server.close(); cb(); })); - server.keepAliveTimeout = 50; + server.keepAliveTimeout = common.platformTimeout(50); server.listen(0, common.mustCall(() => { const options = { port: server.address().port, diff --git a/test/sequential/test-net-server-address.js b/test/sequential/test-net-server-address.js index 52a8c1ac820e24..4312ffd5a1fe78 100644 --- a/test/sequential/test-net-server-address.js +++ b/test/sequential/test-net-server-address.js @@ -25,77 +25,89 @@ const assert = require('assert'); const net = require('net'); // Test on IPv4 Server -const family_ipv4 = 'IPv4'; -const server_ipv4 = net.createServer(); - -server_ipv4.on('error', common.mustNotCall()); - -server_ipv4 - .listen(common.PORT + 1, common.localhostIPv4, common.mustCall(() => { - const address_ipv4 = server_ipv4.address(); - assert.strictEqual(address_ipv4.address, common.localhostIPv4); - assert.strictEqual(address_ipv4.port, common.PORT + 1); - assert.strictEqual(address_ipv4.family, family_ipv4); - server_ipv4.close(); - })); +{ + const family = 'IPv4'; + const server = net.createServer(); + + server.on('error', common.mustNotCall()); + + server + .listen(common.PORT + 1, common.localhostIPv4, common.mustCall(() => { + const address4 = server.address(); + assert.strictEqual(address4.address, common.localhostIPv4); + assert.strictEqual(address4.port, common.PORT + 1); + assert.strictEqual(address4.family, family); + server.close(); + })); +} if (!common.hasIPv6) { common.printSkipMessage('ipv6 part of test, no IPv6 support'); return; } +const family6 = 'IPv6'; +const anycast6 = '::'; + // Test on IPv6 Server -const localhost_ipv6 = '::1'; -const family_ipv6 = 'IPv6'; -const server_ipv6 = net.createServer(); +{ + const localhost = '::1'; -server_ipv6.on('error', common.mustNotCall()); + const server = net.createServer(); -server_ipv6.listen(common.PORT + 2, localhost_ipv6, common.mustCall(() => { - const address_ipv6 = server_ipv6.address(); - assert.strictEqual(address_ipv6.address, localhost_ipv6); - assert.strictEqual(address_ipv6.port, common.PORT + 2); - assert.strictEqual(address_ipv6.family, family_ipv6); - server_ipv6.close(); -})); + server.on('error', common.mustNotCall()); -// Test without hostname or ip -const anycast_ipv6 = '::'; -const server1 = net.createServer(); - -server1.on('error', common.mustNotCall()); + server.listen(common.PORT + 2, localhost, common.mustCall(() => { + const address = server.address(); + assert.strictEqual(address.address, localhost); + assert.strictEqual(address.port, common.PORT + 2); + assert.strictEqual(address.family, family6); + server.close(); + })); +} -// Specify the port number -server1.listen(common.PORT + 3, common.mustCall(() => { - const address = server1.address(); - assert.strictEqual(address.address, anycast_ipv6); - assert.strictEqual(address.port, common.PORT + 3); - assert.strictEqual(address.family, family_ipv6); - server1.close(); -})); +// Test without hostname or ip +{ + const server = net.createServer(); + + server.on('error', common.mustNotCall()); + + // Specify the port number + server.listen(common.PORT + 3, common.mustCall(() => { + const address = server.address(); + assert.strictEqual(address.address, anycast6); + assert.strictEqual(address.port, common.PORT + 3); + assert.strictEqual(address.family, family6); + server.close(); + })); +} // Test without hostname or port -const server2 = net.createServer(); +{ + const server = net.createServer(); -server2.on('error', common.mustNotCall()); + server.on('error', common.mustNotCall()); -// Don't specify the port number -server2.listen(common.mustCall(() => { - const address = server2.address(); - assert.strictEqual(address.address, anycast_ipv6); - assert.strictEqual(address.family, family_ipv6); - server2.close(); -})); + // Don't specify the port number + server.listen(common.mustCall(() => { + const address = server.address(); + assert.strictEqual(address.address, anycast6); + assert.strictEqual(address.family, family6); + server.close(); + })); +} // Test without hostname, but with a false-y port -const server3 = net.createServer(); +{ + const server = net.createServer(); -server3.on('error', common.mustNotCall()); + server.on('error', common.mustNotCall()); -// Specify a false-y port number -server3.listen(0, common.mustCall(() => { - const address = server3.address(); - assert.strictEqual(address.address, anycast_ipv6); - assert.strictEqual(address.family, family_ipv6); - server3.close(); -})); + // Specify a false-y port number + server.listen(0, common.mustCall(() => { + const address = server.address(); + assert.strictEqual(address.address, anycast6); + assert.strictEqual(address.family, family6); + server.close(); + })); +} diff --git a/test/sequential/test-performance-eventloopdelay.js b/test/sequential/test-performance-eventloopdelay.js index 7b9527b3863905..8e7ee4f0ad9cbf 100644 --- a/test/sequential/test-performance-eventloopdelay.js +++ b/test/sequential/test-performance-eventloopdelay.js @@ -1,4 +1,4 @@ -// Flags: --expose-gc +// Flags: --expose-gc --expose-internals 'use strict'; const common = require('../common'); @@ -6,6 +6,7 @@ const assert = require('assert'); const { monitorEventLoopDelay } = require('perf_hooks'); +const { sleep } = require('internal/util'); { const histogram = monitorEventLoopDelay(); @@ -54,7 +55,7 @@ const { histogram.enable(); let m = 5; function spinAWhile() { - common.busyLoop(1000); + sleep(1000); if (--m > 0) { setTimeout(spinAWhile, common.platformTimeout(500)); } else { diff --git a/test/sequential/test-resolution-inspect-brk.js b/test/sequential/test-resolution-inspect-brk.js new file mode 100644 index 00000000000000..2af32426c03f57 --- /dev/null +++ b/test/sequential/test-resolution-inspect-brk.js @@ -0,0 +1,29 @@ +'use strict'; +const common = require('../common'); +common.skipIfInspectorDisabled(); + +// A test to ensure that preload modules are given a chance to execute before +// resolving the main entry point with --inspect-brk active. + +const assert = require('assert'); +const cp = require('child_process'); +const path = require('path'); + +function test(execArgv) { + const child = cp.spawn(process.execPath, execArgv); + + child.stderr.once('data', common.mustCall(function() { + child.kill('SIGTERM'); + })); + + child.on('exit', common.mustCall(function(code, signal) { + assert.strictEqual(signal, 'SIGTERM'); + })); +} + +test([ + '--require', + path.join(__dirname, '../fixtures/test-resolution-inspect-brk-resolver.js'), + '--inspect-brk', + '../fixtures/test-resolution-inspect-resolver-main.ext', +]); diff --git a/test/sequential/test-timers-block-eventloop.js b/test/sequential/test-timers-block-eventloop.js index 811216fcb29e7d..6118695c9235a2 100644 --- a/test/sequential/test-timers-block-eventloop.js +++ b/test/sequential/test-timers-block-eventloop.js @@ -1,7 +1,9 @@ +// Flags: --expose-internals 'use strict'; const common = require('../common'); const assert = require('assert'); +const { sleep } = require('internal/util'); let called = false; const t1 = setInterval(() => { @@ -14,5 +16,5 @@ const t1 = setInterval(() => { }, 10); const t2 = setInterval(() => { - common.busyLoop(20); + sleep(20); }, 10); diff --git a/test/sequential/test-timers-blocking-callback.js b/test/sequential/test-timers-blocking-callback.js index 053bc767b8fa13..a5e0f596a34b93 100644 --- a/test/sequential/test-timers-blocking-callback.js +++ b/test/sequential/test-timers-blocking-callback.js @@ -1,3 +1,4 @@ +// Flags: --expose-internals 'use strict'; /* @@ -25,6 +26,7 @@ const common = require('../common'); const assert = require('assert'); +const { sleep } = require('internal/util'); const TIMEOUT = 100; @@ -65,7 +67,7 @@ function blockingCallback(retry, callback) { return callback(); } else { // Block by busy-looping to trigger the issue - common.busyLoop(TIMEOUT); + sleep(TIMEOUT); timeCallbackScheduled = Date.now(); setTimeout(blockingCallback.bind(null, retry, callback), TIMEOUT); diff --git a/test/sequential/test-timers-set-interval-excludes-callback-duration.js b/test/sequential/test-timers-set-interval-excludes-callback-duration.js index 90eb16b0e259b3..b32c7e7e3c2e9c 100644 --- a/test/sequential/test-timers-set-interval-excludes-callback-duration.js +++ b/test/sequential/test-timers-set-interval-excludes-callback-duration.js @@ -1,13 +1,15 @@ +// Flags: --expose-internals 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); +const { sleep } = require('internal/util'); let cntr = 0; let first; const t = setInterval(() => { cntr++; if (cntr === 1) { - common.busyLoop(100); + sleep(100); // Ensure that the event loop passes before the second interval setImmediate(() => assert.strictEqual(cntr, 1)); first = Date.now(); diff --git a/test/wasi/test-wasi-options-validation.js b/test/wasi/test-wasi-options-validation.js new file mode 100644 index 00000000000000..f8ec2604d5b9f1 --- /dev/null +++ b/test/wasi/test-wasi-options-validation.js @@ -0,0 +1,22 @@ +'use strict'; + +// Flags: --experimental-wasi-unstable-preview0 + +require('../common'); +const assert = require('assert'); +const { WASI } = require('wasi'); + +// If args is undefined, it should default to [] and should not throw. +new WASI({}); + +// If args is not an Array and not undefined, it should throw. +assert.throws(() => { new WASI({ args: 'fhqwhgads' }); }, + { code: 'ERR_INVALID_ARG_TYPE', message: /\bargs\b/ }); + +// If env is not an Object and not undefined, it should throw. +assert.throws(() => { new WASI({ env: 'fhqwhgads' }); }, + { code: 'ERR_INVALID_ARG_TYPE', message: /\benv\b/ }); + +// If preopens is not an Object and not undefined, it should throw. +assert.throws(() => { new WASI({ preopens: 'fhqwhgads' }); }, + { code: 'ERR_INVALID_ARG_TYPE', message: /\bpreopens\b/ }); diff --git a/test/wasi/test-wasi-symlinks.js b/test/wasi/test-wasi-symlinks.js index 3829464198273b..7c6e6809738975 100644 --- a/test/wasi/test-wasi-symlinks.js +++ b/test/wasi/test-wasi-symlinks.js @@ -33,7 +33,7 @@ if (process.argv[2] === 'wasi-child') { const assert = require('assert'); const cp = require('child_process'); - const tmpdir = require('../../test/common/tmpdir'); + const tmpdir = require('../common/tmpdir'); // Setup the sandbox environment. tmpdir.refresh(); diff --git a/test/wasi/test-wasi.js b/test/wasi/test-wasi.js index fa2e0894c906ce..d1060f5b32d33d 100644 --- a/test/wasi/test-wasi.js +++ b/test/wasi/test-wasi.js @@ -3,7 +3,7 @@ const common = require('../common'); if (process.argv[2] === 'wasi-child') { const fixtures = require('../common/fixtures'); - const tmpdir = require('../../test/common/tmpdir'); + const tmpdir = require('../common/tmpdir'); const fs = require('fs'); const path = require('path'); diff --git a/tools/code_cache/README.md b/tools/code_cache/README.md new file mode 100644 index 00000000000000..f8428c24b0dd4b --- /dev/null +++ b/tools/code_cache/README.md @@ -0,0 +1,38 @@ +# Node.js code cache builder + +This is the V8 code cache builder of Node.js. It pre-compiles all the +JavaScript native modules of Node.js and serializes the code cache (including +the bytecodes) that will be embeded into the Node.js executable. When a Node.js +JavaScript native module is `require`d at runtime, Node.js can deserialize from +the code cache instead of parsing the source code and generating the bytecode +for it before execution, which should reduce the load time of these JavaScript +native modules. + +## How it's built and used + +The code cache builder is built with the `mkcodecache` target in `node.gyp` +when `node_use_node_code_cache` is set to true, which is currently done by +default. + +In the default build of the Node.js executable, to embed the V8 code cache of +the native modules into the Node.js executable, `libnode` is first built with +these unresolved symbols: + +- `node::native_module::has_code_cache` +- `node::native_module::NativeModuleEnv::InitializeCodeCache` + +Then the `mkcodecache` executable is built with C++ files in this directory, +as well as `src/node_code_cache_stub.cc` which defines the unresolved symbols. + +`mkcodecache` is run to generate a C++ file +`<(SHARED_INTERMEDIATE_DIR)/node_code_cache.cc` that is similar to +`src/node_code_cache_stub.cc` in structure, but contains the code cache data +written as static char array literals. Then `libnode` is built with +`node_code_cache.cc` to produce the final Node.js executable with the code +cache data embedded. + +For debugging, Node.js can be built without code cache if +`--without-node-code-cache` is passed to `configure`. Note that even if the +code cache is not pre-compiled and embedded into the Node.js executable, the +internal infrastructure is still used to share code cache between the main +thread and worker threads (if there is any). diff --git a/tools/cpplint.py b/tools/cpplint.py index 2cc586ee5d9a2c..40564789549aba 100755 --- a/tools/cpplint.py +++ b/tools/cpplint.py @@ -3299,7 +3299,7 @@ def CheckForFunctionLengths(filename, clean_lines, linenum, """Reports for long function bodies. For an overview why this is done, see: - https://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Write_Short_Functions + https://google.github.io/styleguide/cppguide.html#Write_Short_Functions Uses a simplistic algorithm assuming other style guidelines (especially spacing) are followed. @@ -5154,7 +5154,7 @@ def CheckLanguage(filename, clean_lines, linenum, file_extension, and line[-1] != '\\'): error(filename, linenum, 'build/namespaces', 4, 'Do not use unnamed namespaces in header files. See ' - 'https://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Namespaces' + 'https://google.github.io/styleguide/cppguide.html#Namespaces' ' for more information.') diff --git a/tools/icu/current_ver.dep b/tools/icu/current_ver.dep index 2d467a6fd01e75..2980335bdd4b3b 100644 --- a/tools/icu/current_ver.dep +++ b/tools/icu/current_ver.dep @@ -1,6 +1,6 @@ [ { - "url": "https://github.com/unicode-org/icu/releases/download/release-64-2/icu4c-64_2-src.tgz", - "md5": "a3d18213beec454e3cdec9a3116d6b05" + "url": "https://github.com/unicode-org/icu/releases/download/release-65-1/icu4c-65_1-src.tgz", + "md5": "d1ff436e26cabcb28e6cb383d32d1339" } ] diff --git a/tools/js2c.py b/tools/js2c.py index 1346b2a87046d3..4594694a2cab0d 100755 --- a/tools/js2c.py +++ b/tools/js2c.py @@ -45,137 +45,6 @@ def ReadFile(filename): return lines -def ReadMacroFiles(filenames): - """ - - :rtype: List(str) - """ - result = [] - for filename in filenames: - with open(filename, "rt") as f: - # strip python-like comments and whitespace padding - lines = [line.split('#')[0].strip() for line in f] - # filter empty lines - result.extend(filter(bool, lines)) - return result - - -def ExpandConstants(lines, constants): - for key, value in constants.items(): - lines = lines.replace(key, str(value)) - return lines - - -def ExpandMacros(lines, macros): - def expander(s): - return ExpandMacros(s, macros) - - for name, macro in macros.items(): - name_pattern = re.compile("\\b%s\\(" % name) - pattern_match = name_pattern.search(lines, 0) - while pattern_match is not None: - # Scan over the arguments - height = 1 - start = pattern_match.start() - end = pattern_match.end() - assert lines[end - 1] == '(' - last_match = end - arg_index = [0] # Wrap state into array, to work around Python "scoping" - mapping = {} - - def add_arg(s): - # Remember to expand recursively in the arguments - if arg_index[0] >= len(macro.args): - return - replacement = expander(s.strip()) - mapping[macro.args[arg_index[0]]] = replacement - arg_index[0] += 1 - - while end < len(lines) and height > 0: - # We don't count commas at higher nesting levels. - if lines[end] == ',' and height == 1: - add_arg(lines[last_match:end]) - last_match = end + 1 - elif lines[end] in ['(', '{', '[']: - height = height + 1 - elif lines[end] in [')', '}', ']']: - height = height - 1 - end = end + 1 - # Remember to add the last match. - add_arg(lines[last_match:end - 1]) - if arg_index[0] < len(macro.args) - 1: - lineno = lines.count(os.linesep, 0, start) + 1 - raise Exception( - 'line %s: Too few arguments for macro "%s"' % (lineno, name)) - result = macro.expand(mapping) - # Replace the occurrence of the macro with the expansion - lines = lines[:start] + result + lines[end:] - pattern_match = name_pattern.search(lines, start + len(result)) - return lines - - -class TextMacro: - def __init__(self, args, body): - self.args = args - self.body = body - - def expand(self, mapping): - result = self.body - for key, value in mapping.items(): - result = result.replace(key, value) - return result - - -class PythonMacro: - def __init__(self, args, fun): - self.args = args - self.fun = fun - - def expand(self, mapping): - args = [] - for arg in self.args: - args.append(mapping[arg]) - return str(self.fun(*args)) - - -CONST_PATTERN = re.compile('^const\s+([a-zA-Z0-9_]+)\s*=\s*([^;]*);$') -MACRO_PATTERN = re.compile('^macro\s+([a-zA-Z0-9_]+)\s*\(([^)]*)\)\s*=\s*([^;]*);$') -PYTHON_MACRO_PATTERN = re.compile('^python\s+macro\s+([a-zA-Z0-9_]+)\s*\(([^)]*)\)\s*=\s*([^;]*);$') - - -def ReadMacros(macro_files): - lines = ReadMacroFiles(macro_files) - constants = {} - macros = {} - for line in lines: - line = line.split('#')[0].strip() - if len(line) == 0: - continue - const_match = CONST_PATTERN.match(line) - if const_match: - name = const_match.group(1) - value = const_match.group(2).strip() - constants[name] = value - else: - macro_match = MACRO_PATTERN.match(line) - if macro_match: - name = macro_match.group(1) - args = [p.strip() for p in macro_match.group(2).split(',')] - body = macro_match.group(3).strip() - macros[name] = TextMacro(args, body) - else: - python_match = PYTHON_MACRO_PATTERN.match(line) - if python_match: - name = python_match.group(1) - args = [p.strip() for p in macro_match.group(2).split(',')] - body = python_match.group(3).strip() - fun = eval("lambda " + ",".join(args) + ': ' + body) - macros[name] = PythonMacro(args, fun) - else: - raise Exception("Illegal line: " + line) - return constants, macros - - TEMPLATE = """ #include "env-inl.h" #include "node_native_module.h" @@ -243,10 +112,8 @@ def GetDefinition(var, source, step=30): return definition, len(code_points) -def AddModule(filename, consts, macros, definitions, initializers): +def AddModule(filename, definitions, initializers): code = ReadFile(filename) - code = ExpandConstants(code, consts) - code = ExpandMacros(code, macros) name = NormalizeFileName(filename) slug = SLUGGER_RE.sub('_', name) var = slug + '_raw' @@ -267,15 +134,12 @@ def NormalizeFileName(filename): def JS2C(source_files, target): - # Process input from all *macro.py files - consts, macros = ReadMacros(source_files['.py']) - # Build source code lines definitions = [] initializers = [] for filename in source_files['.js']: - AddModule(filename, consts, macros, definitions, initializers) + AddModule(filename, definitions, initializers) config_def, config_size = handle_config_gypi(source_files['config.gypi']) definitions.append(config_def) @@ -341,8 +205,8 @@ def main(): global is_verbose is_verbose = options.verbose source_files = functools.reduce(SourceFileByExt, options.sources, {}) - # Should have exactly 3 types: `.js`, `.py`, and `.gypi` - assert len(source_files) == 3 + # Should have exactly 2 types: `.js`, and `.gypi` + assert len(source_files) == 2 # Currently config.gypi is the only `.gypi` file allowed assert source_files['.gypi'] == ['config.gypi'] source_files['config.gypi'] = source_files.pop('.gypi')[0] diff --git a/tools/js2c_macros/check_macros.py b/tools/js2c_macros/check_macros.py deleted file mode 100644 index f24d47c9ee40bf..00000000000000 --- a/tools/js2c_macros/check_macros.py +++ /dev/null @@ -1,8 +0,0 @@ -# flake8: noqa -macro CHECK(x) = do { if (!(x)) (process._rawDebug("CHECK: x == true"), process.abort()) } while (0); -macro CHECK_EQ(a, b) = CHECK((a) === (b)); -macro CHECK_GE(a, b) = CHECK((a) >= (b)); -macro CHECK_GT(a, b) = CHECK((a) > (b)); -macro CHECK_LE(a, b) = CHECK((a) <= (b)); -macro CHECK_LT(a, b) = CHECK((a) < (b)); -macro CHECK_NE(a, b) = CHECK((a) !== (b)); diff --git a/tools/js2c_macros/dcheck_macros.py b/tools/js2c_macros/dcheck_macros.py deleted file mode 100644 index f22c08598fd694..00000000000000 --- a/tools/js2c_macros/dcheck_macros.py +++ /dev/null @@ -1,9 +0,0 @@ -# flake8: noqa - -macro DCHECK(x) = do { if (!(x)) (process._rawDebug("DCHECK: x == true"), process.abort()) } while (0); -macro DCHECK_EQ(a, b) = DCHECK((a) === (b)); -macro DCHECK_GE(a, b) = DCHECK((a) >= (b)); -macro DCHECK_GT(a, b) = DCHECK((a) > (b)); -macro DCHECK_LE(a, b) = DCHECK((a) <= (b)); -macro DCHECK_LT(a, b) = DCHECK((a) < (b)); -macro DCHECK_NE(a, b) = DCHECK((a) !== (b)); diff --git a/tools/js2c_macros/nodcheck_macros.py b/tools/js2c_macros/nodcheck_macros.py deleted file mode 100644 index 0a59001b549fe5..00000000000000 --- a/tools/js2c_macros/nodcheck_macros.py +++ /dev/null @@ -1,9 +0,0 @@ -# flake8: noqa - -macro DCHECK(x) = void(x); -macro DCHECK_EQ(a, b) = void(a, b); -macro DCHECK_GE(a, b) = void(a, b); -macro DCHECK_GT(a, b) = void(a, b); -macro DCHECK_LE(a, b) = void(a, b); -macro DCHECK_LT(a, b) = void(a, b); -macro DCHECK_NE(a, b) = void(a, b); diff --git a/tools/js2c_macros/notrace_macros.py b/tools/js2c_macros/notrace_macros.py deleted file mode 100644 index 334f9c0c7f7a87..00000000000000 --- a/tools/js2c_macros/notrace_macros.py +++ /dev/null @@ -1,12 +0,0 @@ -# This file is used by tools/js2c.py to preprocess out the DTRACE symbols in -# builds that don't support DTrace. This is not used in builds that support -# DTrace. - -# flake8: noqa - -macro DTRACE_HTTP_CLIENT_REQUEST(x) = ; -macro DTRACE_HTTP_CLIENT_RESPONSE(x) = ; -macro DTRACE_HTTP_SERVER_REQUEST(x) = ; -macro DTRACE_HTTP_SERVER_RESPONSE(x) = ; -macro DTRACE_NET_SERVER_CONNECTION(x) = ; -macro DTRACE_NET_STREAM_END(x) = ; diff --git a/tools/lint-md.js b/tools/lint-md.js index f45d334efa1fa6..df78ea99921bc6 100644 --- a/tools/lint-md.js +++ b/tools/lint-md.js @@ -1 +1 @@ -module.exports=function(e,t){"use strict";var r={};function __webpack_require__(t){if(r[t]){return r[t].exports}var i=r[t]={i:t,l:false,exports:{}};e[t].call(i.exports,i,i.exports,__webpack_require__);i.l=true;return i.exports}function startup(){return __webpack_require__(294)}t(__webpack_require__);return startup()}([,function(e){"use strict";e.exports=indentation;var t="\t";var r=" ";var i=1;var n=4;function indentation(e){var a=0;var u=0;var s=e.charAt(a);var o={};var l;while(s===t||s===r){l=s===t?n:i;u+=l;if(l>1){u=Math.floor(u/l)*l}o[u]=a;s=e.charAt(++a)}return{indent:u,stops:o}}},function(e){"use strict";e.exports=locate;function locate(e,t){return e.indexOf("`",t)}},,function(e,t,r){"use strict";var i=r(495);var n=r(682);var a=r(839);var u=r(526);e.exports=i("remark-lint:unordered-list-marker-style",unorderedListMarkerStyle);var s=a.start;var o={"-":true,"*":true,"+":true,null:true};function unorderedListMarkerStyle(e,t,r){var i=String(t);r=typeof r==="string"&&r!=="consistent"?r:null;if(o[r]!==true){t.fail("Invalid unordered list-item marker style `"+r+"`: use either `'-'`, `'*'`, or `'+'`")}n(e,"list",visitor);function visitor(e){var n=e.children;var a=e.ordered?0:n.length;var o=-1;var l;var f;while(++ot){return{line:r+1,column:t-(e[r-1]||0)+1,offset:t}}}return{}}}function positionToOffsetFactory(e){return positionToOffset;function positionToOffset(t){var r=t&&t.line;var i=t&&t.column;if(!isNaN(r)&&!isNaN(i)&&r-1 in e){return(e[r-2]||0)+i-1||0}return-1}}function indices(e){var t=[];var r=e.indexOf("\n");while(r!==-1){t.push(r+1);r=e.indexOf("\n",r+1)}t.push(e.length+1);return t}},,function(e,t,r){"use strict";var i=r(495);var n=r(682);var a=r(526);var u=r(10);e.exports=i("remark-lint:no-inline-padding",noInlinePadding);function noInlinePadding(e,t){n(e,["emphasis","strong","delete","image","link"],visitor);function visitor(e){var r;if(!a(e)){r=u(e);if(r.charAt(0)===" "||r.charAt(r.length-1)===" "){t.message("Don’t pad `"+e.type+"` with inner spaces",e)}}}}},function(e){"use strict";e.exports=toString;function toString(e){return valueOf(e)||e.children&&e.children.map(toString).join("")||""}function valueOf(e){return(e&&e.value?e.value:e.alt?e.alt:e.title)||""}},,function(e){"use strict";if(!process.version||process.version.indexOf("v0.")===0||process.version.indexOf("v1.")===0&&process.version.indexOf("v1.8.")!==0){e.exports={nextTick:nextTick}}else{e.exports=process}function nextTick(e,t,r,i){if(typeof e!=="function"){throw new TypeError('"callback" argument must be a function')}var n=arguments.length;var a,u;switch(n){case 0:case 1:return process.nextTick(e);case 2:return process.nextTick(function afterTickOne(){e.call(null,t)});case 3:return process.nextTick(function afterTickTwo(){e.call(null,t,r)});case 4:return process.nextTick(function afterTickThree(){e.call(null,t,r,i)});default:a=new Array(n-1);u=0;while(u=97&&t<=102||t>=65&&t<=70||t>=48&&t<=57}},,function(e,t,r){"use strict";var i=r(431);function homedir(){var e=process.env;var t=e.HOME;var r=e.LOGNAME||e.USER||e.LNAME||e.USERNAME;if(process.platform==="win32"){return e.USERPROFILE||e.HOMEDRIVE+e.HOMEPATH||t||null}if(process.platform==="darwin"){return t||(r?"/Users/"+r:null)}if(process.platform==="linux"){return t||(process.getuid()===0?"/root":r?"/home/"+r:null)}return t||null}e.exports=typeof i.homedir==="function"?i.homedir:homedir},,,,,,function(e,t,r){"use strict";var i=r(495);var n=r(682);var a=r(270);var u=r(704);var s=r(839);var o=r(526);e.exports=i("remark-lint:no-heading-content-indent",noHeadingContentIndent);var l=s.start;var f=s.end;function noHeadingContentIndent(e,t){var r=String(t);n(e,"heading",visitor);function visitor(e){var i;var n;var s;var c;var h;var p;var v;var d;var D;var m;if(o(e)){return}i=e.depth;n=e.children;s=a(e,"atx");if(s==="atx"||s==="atx-closed"){h=l(e);d=h.offset;D=r.charAt(d);while(D&&D!=="#"){D=r.charAt(++d)}if(!D){return}d=i+(d-h.offset);c=l(n[0]).column;if(!c){return}v=c-h.column-1-d;if(v){m=(v>0?"Remove":"Add")+" "+Math.abs(v)+" "+u("space",v)+" before this heading’s content";t.message(m,l(n[0]))}}if(s==="atx-closed"){p=f(n[n.length-1]);v=f(e).column-p.column-1-i;if(v){m="Remove "+v+" "+u("space",v)+" after this heading’s content";t.message(m,p)}}}}},function(e,t,r){"use strict";var i=r(336);var n=r(440);var a=r(901);var u=r(360);var s=r(315);e.exports=setOptions;var o={entities:{true:true,false:true,numbers:true,escape:true},bullet:{"*":true,"-":true,"+":true},rule:{"-":true,_:true,"*":true},listItemIndent:{tab:true,mixed:true,1:true},emphasis:{_:true,"*":true},strong:{_:true,"*":true},fence:{"`":true,"~":true}};var l={boolean:validateBoolean,string:validateString,number:validateNumber,function:validateFunction};function setOptions(e){var t=this;var r=t.options;var n;var s;if(e==null){e={}}else if(typeof e==="object"){e=i(e)}else{throw new Error("Invalid value `"+e+"` for setting `options`")}for(s in a){l[typeof a[s]](e,s,r[s],o[s])}n=e.ruleRepetition;if(n&&n<3){raise(n,"options.ruleRepetition")}t.encode=encodeFactory(String(e.entities));t.escape=u(e);t.options=e;return t}function validateBoolean(e,t,r){var i=e[t];if(i==null){i=r}if(typeof i!=="boolean"){raise(i,"options."+t)}e[t]=i}function validateNumber(e,t,r){var i=e[t];if(i==null){i=r}if(isNaN(i)){raise(i,"options."+t)}e[t]=i}function validateString(e,t,r,i){var n=e[t];if(n==null){n=r}n=String(n);if(!(n in i)){raise(n,"options."+t)}e[t]=n}function validateFunction(e,t,r){var i=e[t];if(i==null){i=r}if(typeof i!=="function"){raise(i,"options."+t)}e[t]=i}function encodeFactory(e){var t={};if(e==="false"){return s}if(e==="true"){t.useNamedReferences=true}if(e==="escape"){t.escapeOnly=true;t.useNamedReferences=true}return wrapped;function wrapped(e){return n(e,t)}}function raise(e,t){throw new Error("Invalid value `"+e+"` for setting `"+t+"`")}},,function(e,t){t=e.exports=trim;function trim(e){return e.replace(/^\s*|\s*$/g,"")}t.left=function(e){return e.replace(/^\s*/,"")};t.right=function(e){return e.replace(/\s*$/,"")}},function(e,t,r){"use strict";var i=r(814);e.exports=thematic;var n=" ";function thematic(){var e=this.options;var t=i(e.rule,e.ruleRepetition);return e.ruleSpaces?t.split("").join(n):t}},,,,,function(e,t,r){"use strict";var i=r(315);e.exports=enter;function enter(e,t){var r=e.encode;var n=e.escape;var a=e.enterLink();if(t.referenceType!=="shortcut"&&t.referenceType!=="collapsed"){return a}e.escape=i;e.encode=i;return exit;function exit(){e.encode=r;e.escape=n;a()}}},function(e,t,r){"use strict";var i=r(727);e.exports=new i({include:[r(234)],implicit:[r(633),r(843),r(981),r(702)]})},function(e,t,r){"use strict";var i=r(36);var n=r(814);var a=r(439);var u=r(1);var s=r(235);var o=r(724);e.exports=list;var l="*";var f="_";var c="+";var h="-";var p=".";var v=" ";var d="\n";var D="\t";var m=")";var g="x";var E=4;var A=/\n\n(?!\s*$)/;var C=/^\[([ \t]|x|X)][ \t]/;var y=/^([ \t]*)([*+-]|\d+[.)])( {1,4}(?! )| |\t|$|(?=\n))([^\n]*)/;var w=/^([ \t]*)([*+-]|\d+[.)])([ \t]+)/;var x=/^( {1,4}|\t)?/gm;function list(e,t,r){var n=this;var u=n.options.commonmark;var s=n.options.pedantic;var g=n.blockTokenizers;var A=n.interruptList;var C=0;var y=t.length;var w=null;var x=0;var b;var F;var S;var B;var k;var O;var P;var T;var I;var M;var L;var R;var j;var U;var N;var J;var z;var X;var G=false;var q;var W;var _;var V;while(C=E){return}S=t.charAt(C);if(S===l||S===c||S===h){B=S;F=false}else{F=true;b="";while(C=E){V=true}if(J&&x>=J.indent){V=true}S=t.charAt(C);T=null;if(!V){if(S===l||S===c||S===h){T=S;C++;x++}else{b="";while(C=J.indent||x>E}P=false;C=O}M=t.slice(O,k);I=O===C?M:t.slice(C,k);if(T===l||T===f||T===h){if(g.thematicBreak.call(n,e,M,true)){break}}L=R;R=!P&&!i(I).length;if(V&&J){J.value=J.value.concat(N,M);U=U.concat(N,M);N=[]}else if(P){if(N.length!==0){G=true;J.value.push("");J.trail=N.concat()}J={value:[M],indent:x,trail:[]};j.push(J);U=U.concat(N,M);N=[]}else if(R){if(L&&!u){break}N.push(M)}else{if(L){break}if(o(A,g,n,[e,M,true])){break}J.value=J.value.concat(N,M);U=U.concat(N,M);N=[]}C=k+1}q=e(U.join(d)).reset({type:"list",ordered:F,start:w,spread:G,children:[]});z=n.enterList();X=n.enterBlock();C=-1;y=j.length;while(++C1){t.message(s,e)}}}},function(e){e.exports=function isBuffer(e){return e!=null&&e.constructor!=null&&typeof e.constructor.isBuffer==="function"&&e.constructor.isBuffer(e)}},,,,,,,,function(e){e.exports=require("util")},function(e,t,r){"use strict";var i=r(727);e.exports=i.DEFAULT=new i({include:[r(388)],explicit:[r(875),r(555),r(329)]})},function(e){e.exports=require("fs")},function(e){"use strict";e.exports=function(e){if(typeof e!=="string"){throw new TypeError("Expected a string")}return!/[^0-9a-z\xDF-\xFF]/.test(e.toLowerCase())}},,,,,function(e,t,r){"use strict";var i=r(495);var n=r(7);e.exports=i("remark-lint:no-tabs",noTabs);var a="Use spaces instead of hard-tabs";function noTabs(e,t){var r=String(t);var i=n(t).toPosition;var u=r.indexOf("\t");while(u!==-1){t.message(a,i(u));u=r.indexOf("\t",u+1)}}},function(e){function webpackEmptyContext(e){var t=new Error("Cannot find module '"+e+"'");t.code="MODULE_NOT_FOUND";throw t}webpackEmptyContext.keys=function(){return[]};webpackEmptyContext.resolve=webpackEmptyContext;e.exports=webpackEmptyContext;webpackEmptyContext.id=73},function(e,t,r){"use strict";var i=r(864);var n=r(97);var a=r(503);var u=r(123);var s=r(340);var o=r(951);e.exports=unified().freeze();var l=[].slice;var f={}.hasOwnProperty;var c=u().use(pipelineParse).use(pipelineRun).use(pipelineStringify);function pipelineParse(e,t){t.tree=e.parse(t.file)}function pipelineRun(e,t,r){e.run(t.tree,t.file,done);function done(e,i,n){if(e){r(e)}else{t.tree=i;t.file=n;r()}}}function pipelineStringify(e,t){t.file.contents=e.stringify(t.tree,t.file)}function unified(){var e=[];var t=u();var r={};var h=false;var p=-1;processor.data=data;processor.freeze=freeze;processor.attachers=e;processor.use=use;processor.parse=parse;processor.stringify=stringify;processor.run=run;processor.runSync=runSync;processor.process=process;processor.processSync=processSync;return processor;function processor(){var t=unified();var n=e.length;var a=-1;while(++a{if(typeof e!=="string"){throw new TypeError(`Expected \`fromDir\` to be of type \`string\`, got \`${typeof e}\``)}if(typeof t!=="string"){throw new TypeError(`Expected \`moduleId\` to be of type \`string\`, got \`${typeof t}\``)}try{e=a.realpathSync(e)}catch(t){if(t.code==="ENOENT"){e=i.resolve(e)}else if(r){return null}else{throw t}}const u=i.join(e,"noop.js");const s=()=>n._resolveFilename(t,{id:u,filename:u,paths:n._nodeModulePaths(e)});if(r){try{return s()}catch(e){return null}}return s()};e.exports=((e,t)=>u(e,t));e.exports.silent=((e,t)=>u(e,t,true))},,function(e,t,r){"use strict";var i=r(347)("unified-engine:file-pipeline:configure");var n=r(928);var a=r(623);var u=r(692);var s=r(876);e.exports=configure;function configure(e,t,r,o){var l=e.configuration;var f=e.processor;if(n(t).fatal){return o()}l.load(t.path,handleConfiguration);function handleConfiguration(e,t){var n;var l;var c;var h;var p;var v;if(e){return o(e)}i("Using settings `%j`",t.settings);f.data("settings",t.settings);n=t.plugins;h=n.length;p=-1;i("Using `%d` plugins",h);while(++p>10)+55296,(e-65536&1023)+56320)}var C=new Array(256);var y=new Array(256);for(var w=0;w<256;w++){C[w]=simpleEscapeSequence(w)?1:0;y[w]=simpleEscapeSequence(w)}function State(e,t){this.input=e;this.filename=t["filename"]||null;this.schema=t["schema"]||s;this.onWarning=t["onWarning"]||null;this.legacy=t["legacy"]||false;this.json=t["json"]||false;this.listener=t["listener"]||null;this.implicitTypes=this.schema.compiledImplicit;this.typeMap=this.schema.compiledTypeMap;this.length=e.length;this.position=0;this.line=0;this.lineStart=0;this.lineIndent=0;this.documents=[]}function generateError(e,t){return new n(t,new a(e.filename,e.input,e.position,e.line,e.position-e.lineStart))}function throwError(e,t){throw generateError(e,t)}function throwWarning(e,t){if(e.onWarning){e.onWarning.call(null,generateError(e,t))}}var x={YAML:function handleYamlDirective(e,t,r){var i,n,a;if(e.version!==null){throwError(e,"duplication of %YAML directive")}if(r.length!==1){throwError(e,"YAML directive accepts exactly one argument")}i=/^([0-9]+)\.([0-9]+)$/.exec(r[0]);if(i===null){throwError(e,"ill-formed argument of the YAML directive")}n=parseInt(i[1],10);a=parseInt(i[2],10);if(n!==1){throwError(e,"unacceptable YAML version of the document")}e.version=r[0];e.checkLineBreaks=a<2;if(a!==1&&a!==2){throwWarning(e,"unsupported YAML version of the document")}},TAG:function handleTagDirective(e,t,r){var i,n;if(r.length!==2){throwError(e,"TAG directive accepts exactly two arguments")}i=r[0];n=r[1];if(!E.test(i)){throwError(e,"ill-formed tag handle (first argument) of the TAG directive")}if(o.call(e.tagMap,i)){throwError(e,'there is a previously declared suffix for "'+i+'" tag handle')}if(!A.test(n)){throwError(e,"ill-formed tag prefix (second argument) of the TAG directive")}e.tagMap[i]=n}};function captureSegment(e,t,r,i){var n,a,u,s;if(t1){e.result+=i.repeat("\n",t-1)}}function readPlainScalar(e,t,r){var i,n,a,u,s,o,l,f,c=e.kind,h=e.result,p;p=e.input.charCodeAt(e.position);if(is_WS_OR_EOL(p)||is_FLOW_INDICATOR(p)||p===35||p===38||p===42||p===33||p===124||p===62||p===39||p===34||p===37||p===64||p===96){return false}if(p===63||p===45){n=e.input.charCodeAt(e.position+1);if(is_WS_OR_EOL(n)||r&&is_FLOW_INDICATOR(n)){return false}}e.kind="scalar";e.result="";a=u=e.position;s=false;while(p!==0){if(p===58){n=e.input.charCodeAt(e.position+1);if(is_WS_OR_EOL(n)||r&&is_FLOW_INDICATOR(n)){break}}else if(p===35){i=e.input.charCodeAt(e.position-1);if(is_WS_OR_EOL(i)){break}}else if(e.position===e.lineStart&&testDocumentSeparator(e)||r&&is_FLOW_INDICATOR(p)){break}else if(is_EOL(p)){o=e.line;l=e.lineStart;f=e.lineIndent;skipSeparationSpace(e,false,-1);if(e.lineIndent>=t){s=true;p=e.input.charCodeAt(e.position);continue}else{e.position=u;e.line=o;e.lineStart=l;e.lineIndent=f;break}}if(s){captureSegment(e,a,u,false);writeFoldedLines(e,e.line-o);a=u=e.position;s=false}if(!is_WHITE_SPACE(p)){u=e.position+1}p=e.input.charCodeAt(++e.position)}captureSegment(e,a,u,false);if(e.result){return true}e.kind=c;e.result=h;return false}function readSingleQuotedScalar(e,t){var r,i,n;r=e.input.charCodeAt(e.position);if(r!==39){return false}e.kind="scalar";e.result="";e.position++;i=n=e.position;while((r=e.input.charCodeAt(e.position))!==0){if(r===39){captureSegment(e,i,e.position,true);r=e.input.charCodeAt(++e.position);if(r===39){i=e.position;e.position++;n=e.position}else{return true}}else if(is_EOL(r)){captureSegment(e,i,n,true);writeFoldedLines(e,skipSeparationSpace(e,false,t));i=n=e.position}else if(e.position===e.lineStart&&testDocumentSeparator(e)){throwError(e,"unexpected end of the document within a single quoted scalar")}else{e.position++;n=e.position}}throwError(e,"unexpected end of the stream within a single quoted scalar")}function readDoubleQuotedScalar(e,t){var r,i,n,a,u,s;s=e.input.charCodeAt(e.position);if(s!==34){return false}e.kind="scalar";e.result="";e.position++;r=i=e.position;while((s=e.input.charCodeAt(e.position))!==0){if(s===34){captureSegment(e,r,e.position,true);e.position++;return true}else if(s===92){captureSegment(e,r,e.position,true);s=e.input.charCodeAt(++e.position);if(is_EOL(s)){skipSeparationSpace(e,false,t)}else if(s<256&&C[s]){e.result+=y[s];e.position++}else if((u=escapedHexLen(s))>0){n=u;a=0;for(;n>0;n--){s=e.input.charCodeAt(++e.position);if((u=fromHexCode(s))>=0){a=(a<<4)+u}else{throwError(e,"expected hexadecimal character")}}e.result+=charFromCodepoint(a);e.position++}else{throwError(e,"unknown escape sequence")}r=i=e.position}else if(is_EOL(s)){captureSegment(e,r,i,true);writeFoldedLines(e,skipSeparationSpace(e,false,t));r=i=e.position}else if(e.position===e.lineStart&&testDocumentSeparator(e)){throwError(e,"unexpected end of the document within a double quoted scalar")}else{e.position++;i=e.position}}throwError(e,"unexpected end of the stream within a double quoted scalar")}function readFlowCollection(e,t){var r=true,i,n=e.tag,a,u=e.anchor,s,o,f,c,h,p={},v,d,D,m;m=e.input.charCodeAt(e.position);if(m===91){o=93;h=false;a=[]}else if(m===123){o=125;h=true;a={}}else{return false}if(e.anchor!==null){e.anchorMap[e.anchor]=a}m=e.input.charCodeAt(++e.position);while(m!==0){skipSeparationSpace(e,true,t);m=e.input.charCodeAt(e.position);if(m===o){e.position++;e.tag=n;e.anchor=u;e.kind=h?"mapping":"sequence";e.result=a;return true}else if(!r){throwError(e,"missed comma between flow collection entries")}d=v=D=null;f=c=false;if(m===63){s=e.input.charCodeAt(e.position+1);if(is_WS_OR_EOL(s)){f=c=true;e.position++;skipSeparationSpace(e,true,t)}}i=e.line;composeNode(e,t,l,false,true);d=e.tag;v=e.result;skipSeparationSpace(e,true,t);m=e.input.charCodeAt(e.position);if((c||e.line===i)&&m===58){f=true;m=e.input.charCodeAt(++e.position);skipSeparationSpace(e,true,t);composeNode(e,t,l,false,true);D=e.result}if(h){storeMappingPair(e,a,p,d,v,D)}else if(f){a.push(storeMappingPair(e,null,p,d,v,D))}else{a.push(v)}skipSeparationSpace(e,true,t);m=e.input.charCodeAt(e.position);if(m===44){r=true;m=e.input.charCodeAt(++e.position)}else{r=false}}throwError(e,"unexpected end of the stream within a flow collection")}function readBlockScalar(e,t){var r,n,a=p,u=false,s=false,o=t,l=0,f=false,c,h;h=e.input.charCodeAt(e.position);if(h===124){n=false}else if(h===62){n=true}else{return false}e.kind="scalar";e.result="";while(h!==0){h=e.input.charCodeAt(++e.position);if(h===43||h===45){if(p===a){a=h===43?d:v}else{throwError(e,"repeat of a chomping mode identifier")}}else if((c=fromDecimalCode(h))>=0){if(c===0){throwError(e,"bad explicit indentation width of a block scalar; it cannot be less than one")}else if(!s){o=t+c-1;s=true}else{throwError(e,"repeat of an indentation width identifier")}}else{break}}if(is_WHITE_SPACE(h)){do{h=e.input.charCodeAt(++e.position)}while(is_WHITE_SPACE(h));if(h===35){do{h=e.input.charCodeAt(++e.position)}while(!is_EOL(h)&&h!==0)}}while(h!==0){readLineBreak(e);e.lineIndent=0;h=e.input.charCodeAt(e.position);while((!s||e.lineIndento){o=e.lineIndent}if(is_EOL(h)){l++;continue}if(e.lineIndentt)&&o!==0){throwError(e,"bad indentation of a sequence entry")}else if(e.lineIndentt){if(composeNode(e,t,h,true,n)){if(D){v=e.result}else{d=e.result}}if(!D){storeMappingPair(e,l,c,p,v,d,a,u);p=v=d=null}skipSeparationSpace(e,true,-1);g=e.input.charCodeAt(e.position)}if(e.lineIndent>t&&g!==0){throwError(e,"bad indentation of a mapping entry")}else if(e.lineIndentt){p=1}else if(e.lineIndent===t){p=0}else if(e.lineIndentt){p=1}else if(e.lineIndent===t){p=0}else if(e.lineIndent tag; it should be "'+g.kind+'", not "'+e.kind+'"')}if(!g.resolve(e.result)){throwError(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}else{e.result=g.construct(e.result);if(e.anchor!==null){e.anchorMap[e.anchor]=e.result}}}else{throwError(e,"unknown tag !<"+e.tag+">")}}if(e.listener!==null){e.listener("close",e)}return e.tag!==null||e.anchor!==null||d}function readDocument(e){var t=e.position,r,i,n,a=false,u;e.version=null;e.checkLineBreaks=e.legacy;e.tagMap={};e.anchorMap={};while((u=e.input.charCodeAt(e.position))!==0){skipSeparationSpace(e,true,-1);u=e.input.charCodeAt(e.position);if(e.lineIndent>0||u!==37){break}a=true;u=e.input.charCodeAt(++e.position);r=e.position;while(u!==0&&!is_WS_OR_EOL(u)){u=e.input.charCodeAt(++e.position)}i=e.input.slice(r,e.position);n=[];if(i.length<1){throwError(e,"directive name must not be less than one character in length")}while(u!==0){while(is_WHITE_SPACE(u)){u=e.input.charCodeAt(++e.position)}if(u===35){do{u=e.input.charCodeAt(++e.position)}while(u!==0&&!is_EOL(u));break}if(is_EOL(u))break;r=e.position;while(u!==0&&!is_WS_OR_EOL(u)){u=e.input.charCodeAt(++e.position)}n.push(e.input.slice(r,e.position))}if(u!==0)readLineBreak(e);if(o.call(x,i)){x[i](e,i,n)}else{throwWarning(e,'unknown document directive "'+i+'"')}}skipSeparationSpace(e,true,-1);if(e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45){e.position+=3;skipSeparationSpace(e,true,-1)}else if(a){throwError(e,"directives end mark is expected")}composeNode(e,e.lineIndent-1,h,false,true);skipSeparationSpace(e,true,-1);if(e.checkLineBreaks&&m.test(e.input.slice(t,e.position))){throwWarning(e,"non-ASCII line breaks are interpreted as content")}e.documents.push(e.result);if(e.position===e.lineStart&&testDocumentSeparator(e)){if(e.input.charCodeAt(e.position)===46){e.position+=3;skipSeparationSpace(e,true,-1)}return}if(e.position output."+r,""," # Rewrite all applicable files"," $ "+i+" . -o"].join("\n");return{helpMessage:u,cwd:t.cwd,processor:t.processor,help:n.help,version:n.version,files:n._,filePath:n.filePath,watch:n.watch,extensions:f.length===0?t.extensions:f,output:n.output,out:n.stdout,tree:n.tree,treeIn:n.treeIn,treeOut:n.treeOut,inspect:n.inspect,rcName:t.rcName,packageField:t.packageField,rcPath:n.rcPath,detectConfig:n.config,settings:settings(n.setting),ignoreName:t.ignoreName,ignorePath:n.ignorePath,detectIgnore:n.ignore,pluginPrefix:t.pluginPrefix,plugins:plugins(n.use),reporter:c[0],reporterOptions:c[1],color:n.color,silent:n.silent,quiet:n.quiet,frail:n.frail}}function addEach(e){var t=e.default;l.default[e.long]=t===undefined?null:t;if(e.type in l){l[e.type].push(e.long)}if(e.short){l.alias[e.short]=e.long}}function extensions(e){return flatten(normalize(e).map(splitList))}function plugins(e){var t={};normalize(e).map(splitOptions).forEach(function(e){t[e[0]]=e[1]?parseConfig(e[1],{}):null});return t}function reporter(e){var t=normalize(e).map(splitOptions).map(function(e){return[e[0],e[1]?parseConfig(e[1],{}):null]});return t[t.length-1]||[]}function settings(e){var t={};normalize(e).forEach(function(e){parseConfig(e,t)});return t}function parseConfig(e,t){var r;var i;try{e=toCamelCase(parseJSON(e))}catch(t){i=t.message.replace(/at(?= position)/,"around");throw s("Cannot parse `%s` as JSON: %s",e,i)}for(r in e){t[r]=e[r]}return t}function handleUnknownArgument(e){if(e.charAt(0)!=="-"){return}if(e.charAt(1)==="-"){throw s("Unknown option `%s`, expected:\n%s",e,inspectAll(o))}e.slice(1).split("").forEach(each);function each(e){var t=o.length;var r=-1;var i;while(++r=2,has16m:e>=3}}function supportsColor(e){if(u===false){return 0}if(n("color=16m")||n("color=full")||n("color=truecolor")){return 3}if(n("color=256")){return 2}if(e&&!e.isTTY&&u!==true){return 0}const t=u?1:0;if(process.platform==="win32"){const e=i.release().split(".");if(Number(process.versions.node.split(".")[0])>=8&&Number(e[0])>=10&&Number(e[2])>=10586){return Number(e[2])>=14931?3:2}return 1}if("CI"in a){if(["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI"].some(e=>e in a)||a.CI_NAME==="codeship"){return 1}return t}if("TEAMCITY_VERSION"in a){return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(a.TEAMCITY_VERSION)?1:0}if(a.COLORTERM==="truecolor"){return 3}if("TERM_PROGRAM"in a){const e=parseInt((a.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(a.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(a.TERM)){return 2}if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(a.TERM)){return 1}if("COLORTERM"in a){return 1}if(a.TERM==="dumb"){return t}return t}function getSupportLevel(e){const t=supportsColor(e);return translateLevel(t)}e.exports={supportsColor:getSupportLevel,stdout:getSupportLevel(process.stdout),stderr:getSupportLevel(process.stderr)}},,,function(e,t,r){"use strict";var i=r(347)("unified-engine:file-pipeline:queue");var n=r(928);e.exports=queue;function queue(e,t,r,a){var u=t.history[0];var s=r.complete;var o=true;if(!s){s={};r.complete=s}i("Queueing `%s`",u);s[u]=a;r.valueOf().forEach(each);if(!o){i("Not flushing: some files cannot be flushed");return}r.complete={};r.pipeline.run(r,done);function each(e){var t=e.history[0];if(n(e).fatal){return}if(typeof s[t]==="function"){i("`%s` can be flushed",t)}else{i("Interupting flush: `%s` is not finished",t);o=false}}function done(e){i("Flushing: all files can be flushed");for(u in s){s[u](e)}}}},function(e,t,r){"use strict";var i=r(171);var n=r(426);e.exports=definition;definition.notInList=true;definition.notInBlock=true;var a='"';var u="'";var s="\\";var o="\n";var l="\t";var f=" ";var c="[";var h="]";var p="(";var v=")";var d=":";var D="<";var m=">";function definition(e,t,r){var i=this;var m=i.options.commonmark;var g=0;var E=t.length;var A="";var C;var y;var w;var x;var b;var F;var S;var B;while(g"];var r=t.concat(["~","|"]);var i=r.concat(["\n",'"',"$","%","&","'",",","/",":",";","<","=","?","@","^"]);escapes.default=t;escapes.gfm=r;escapes.commonmark=i;function escapes(e){var n=e||{};if(n.commonmark){return i}return n.gfm?r:t}},,function(e){"use strict";e.exports=locate;function locate(e,t){return e.indexOf("~~",t)}},function(e,t,r){"use strict";var i=r(495);var n=r(7);var a=r(682);var u=r(839);var s=r(526);e.exports=i("remark-lint:checkbox-character-style",checkboxCharacterStyle);var o=u.start;var l=u.end;var f={x:true,X:true};var c={" ":true,"\t":true};var h={true:"checked",false:"unchecked"};function checkboxCharacterStyle(e,t,r){var i=String(t);var u=n(t);r=typeof r==="object"?r:{};if(r.unchecked&&c[r.unchecked]!==true){t.fail("Invalid unchecked checkbox marker `"+r.unchecked+"`: use either `'\\t'`, or `' '`")}if(r.checked&&f[r.checked]!==true){t.fail("Invalid checked checkbox marker `"+r.checked+"`: use either `'x'`, or `'X'`")}a(e,"listItem",visitor);function visitor(e){var n;var a;var f;var c;var p;var v;var d;if(typeof e.checked!=="boolean"||s(e)){return}n=h[e.checked];a=o(e).offset;f=(e.children.length===0?l(e):o(e.children[0])).offset;c=i.slice(a,f).trimRight().slice(0,-1);v=c.charAt(c.length-1);p=r[n];if(p){if(v!==p){d=n.charAt(0).toUpperCase()+n.slice(1)+" checkboxes should use `"+p+"` as a marker";t.message(d,{start:u.toPosition(a+c.length-1),end:u.toPosition(a+c.length)})}}else{r[n]=v}}}},,,,function(e){"use strict";e.exports=wordCharacter;var t=String.fromCharCode;var r=/\w/;function wordCharacter(e){return r.test(typeof e==="number"?t(e):e.charAt(0))}},,,,,function(e,t,r){"use strict";var i=r(495);var n=r(682);var a=r(526);e.exports=i("remark-lint:no-shortcut-reference-image",noShortcutReferenceImage);var u="Use the trailing [] on reference images";function noShortcutReferenceImage(e,t){n(e,"imageReference",visitor);function visitor(e){if(!a(e)&&e.referenceType==="shortcut"){t.message(u,e)}}}},,function(e,t,r){"use strict";var i=r(335);e.exports=trough;trough.wrap=i;var n=[].slice;function trough(){var e=[];var t={};t.run=run;t.use=use;return t;function run(){var t=-1;var r=n.call(arguments,0,-1);var a=arguments[arguments.length-1];if(typeof a!=="function"){throw new Error("Expected function as last argument, not "+a)}next.apply(null,[null].concat(r));function next(u){var s=e[++t];var o=n.call(arguments,0);var l=o.slice(1);var f=r.length;var c=-1;if(u){a(u);return}while(++c"){break}if(v!==" "&&v!=="\t"){t.message(o,d);break}}}}}},,function(e,t,r){e.exports=realpath;realpath.realpath=realpath;realpath.sync=realpathSync;realpath.realpathSync=realpathSync;realpath.monkeypatch=monkeypatch;realpath.unmonkeypatch=unmonkeypatch;var i=r(66);var n=i.realpath;var a=i.realpathSync;var u=process.version;var s=/^v[0-5]\./.test(u);var o=r(544);function newError(e){return e&&e.syscall==="realpath"&&(e.code==="ELOOP"||e.code==="ENOMEM"||e.code==="ENAMETOOLONG")}function realpath(e,t,r){if(s){return n(e,t,r)}if(typeof t==="function"){r=t;t=null}n(e,t,function(i,n){if(newError(i)){o.realpath(e,t,r)}else{r(i,n)}})}function realpathSync(e,t){if(s){return a(e,t)}try{return a(e,t)}catch(r){if(newError(r)){return o.realpathSync(e,t)}else{throw r}}}function monkeypatch(){i.realpath=realpath;i.realpathSync=realpathSync}function unmonkeypatch(){i.realpath=n;i.realpathSync=a}},,,,,,function(e){"use strict";var t={}.hasOwnProperty;e.exports=stringify;function stringify(e){if(!e||typeof e!=="object"){return""}if(t.call(e,"position")||t.call(e,"type")){return position(e.position)}if(t.call(e,"start")||t.call(e,"end")){return position(e)}if(t.call(e,"line")||t.call(e,"column")){return point(e)}return""}function point(e){if(!e||typeof e!=="object"){e={}}return index(e.line)+":"+index(e.column)}function position(e){if(!e||typeof e!=="object"){e={}}return point(e.start)+"-"+point(e.end)}function index(e){return e&&typeof e==="number"?e:1}},,function(e,t,r){"use strict";var i=r(495);var n=r(682);var a=r(839);var u=r(526);e.exports=i("remark-lint:fenced-code-flag",fencedCodeFlag);var s=a.start;var o=a.end;var l=/^ {0,3}([~`])\1{2,}/;var f="Invalid code-language flag";var c="Missing code-language flag";function fencedCodeFlag(e,t,r){var i=String(t);var a=false;var h=[];if(typeof r==="object"&&!("length"in r)){a=Boolean(r.allowEmpty);r=r.flags}if(typeof r==="object"&&"length"in r){h=String(r).split(",")}n(e,"code",visitor);function visitor(e){var r;if(!u(e)){if(e.lang){if(h.length!==0&&h.indexOf(e.lang)===-1){t.message(f,e)}}else{r=i.slice(s(e).offset,o(e).offset);if(!a&&l.test(r)){t.message(c,e)}}}}}},function(e){"use strict";e.exports=alphabetical;function alphabetical(e){var t=typeof e==="string"?e.charCodeAt(0):e;return t>=97&&t<=122||t>=65&&t<=90}},function(e){"use strict";e.exports=locate;var t=["https://","http://","mailto:"];function locate(e,r){var i=t.length;var n=-1;var a=-1;var u;if(!this.options.gfm){return-1}while(++na){i[n-a]=e[n]}return i}},,,,,,,,,function(e,t,r){"use strict";var i=r(211);var n=Object.prototype.hasOwnProperty;var a=Object.prototype.toString;function resolveYamlOmap(e){if(e===null)return true;var t=[],r,i,u,s,o,l=e;for(r=0,i=l.length;r-1){a.splice(u,1)}var s=r;a.forEach(function _buildSubObj(e,r){if(!e||typeof s!=="object")return;if(r===a.length-1)s[e]=t[n];if(s[e]===undefined)s[e]={};s=s[e]})}}return r};var c=t.find=function(){var e=a.join.apply(null,[].slice.call(arguments));function find(e,t){var r=a.join(e,t);try{i.statSync(r);return r}catch(r){if(a.dirname(e)!==e)return find(a.dirname(e),t)}}return find(process.cwd(),e)}},,,,function(e,t,r){"use strict";const i=r(202);const n=r(751);const a=i("JSONError",{fileName:i.append("in %s")});e.exports=((e,t,r)=>{if(typeof t==="string"){r=t;t=null}try{try{return JSON.parse(e,t)}catch(r){n(e,t);throw r}}catch(e){e.message=e.message.replace(/\n/g,"");const t=new a(e);if(r){t.fileName=r}throw t}})},function(e,t,r){"use strict";var i=r(495);var n=r(682);var a=r(839);var u=r(526);e.exports=i("remark-lint:maximum-line-length",maximumLineLength);var s=a.start;var o=a.end;function maximumLineLength(e,t,r){var i=typeof r==="number"&&!isNaN(r)?r:80;var a=String(t);var l=a.split(/\r?\n/);var f=l.length;var c=-1;var h;n(e,["heading","table","code","definition","html","jsx"],ignore);n(e,["link","image","inlineCode"],inline);while(++ci){t.message("Line must be at most "+i+" characters",{line:c+1,column:h+1})}}function inline(e,t,r){var n=r.children[t+1];var a;var l;if(u(e)){return}a=s(e);l=o(e);if(a.column>i||l.column0?"Add":"Remove")+" "+Math.abs(i)+" "+n("space",i)+" between blockquote and content";t.message(a,u.start(e.children[0]))}}else{r=check(e)}}}function check(e){var t=e.children[0];var r=u.start(t).column-u.start(e).column;var i=o(t).match(/^ +/);if(i){r+=i[0].length}return r}},,,,,function(e){"use strict";e.exports=whitespace;var t=String.fromCharCode;var r=/\s/;function whitespace(e){return r.test(typeof e==="number"?t(e):e.charAt(0))}},,,function(e,t,r){"use strict";var i=r(814);var n="\n";var a=" ";var u=":";var s="[";var o="]";var l="^";var f=4;var c=n+n;var h=i(a,f);e.exports=footnoteDefinition;function footnoteDefinition(e){var t=this.all(e).join(c+h);return s+l+(e.label||e.identifier)+o+u+a+t}},function(e){"use strict";e.exports=collapse;function collapse(e){return String(e).replace(/\s+/g," ")}},function(e){"use strict";e.exports=label;var t="[";var r="]";var i="shortcut";var n="collapsed";function label(e){var a=e.referenceType;if(a===i){return""}return t+(a===n?"":e.label||e.identifier)+r}},,,,,function(e,t,r){"use strict";var i=r(814);var n=r(705);e.exports=listItem;var a="\n";var u=" ";var s="[";var o="]";var l="x";var f=Math.ceil;var c=a+a;var h=4;function listItem(e,t,r,p){var v=this;var d=v.options.listItemIndent;var D=p||v.options.bullet;var m=e.spread==null?true:e.spread;var g=e.checked;var E=e.children;var A=E.length;var C=[];var y=-1;var w;var x;var b;while(++y",Iacute:"Í",Icirc:"Î",Igrave:"Ì",Iuml:"Ï",LT:"<",Ntilde:"Ñ",Oacute:"Ó",Ocirc:"Ô",Ograve:"Ò",Oslash:"Ø",Otilde:"Õ",Ouml:"Ö",QUOT:'"',REG:"®",THORN:"Þ",Uacute:"Ú",Ucirc:"Û",Ugrave:"Ù",Uuml:"Ü",Yacute:"Ý",aacute:"á",acirc:"â",acute:"´",aelig:"æ",agrave:"à",amp:"&",aring:"å",atilde:"ã",auml:"ä",brvbar:"¦",ccedil:"ç",cedil:"¸",cent:"¢",copy:"©",curren:"¤",deg:"°",divide:"÷",eacute:"é",ecirc:"ê",egrave:"è",eth:"ð",euml:"ë",frac12:"½",frac14:"¼",frac34:"¾",gt:">",iacute:"í",icirc:"î",iexcl:"¡",igrave:"ì",iquest:"¿",iuml:"ï",laquo:"«",lt:"<",macr:"¯",micro:"µ",middot:"·",nbsp:" ",not:"¬",ntilde:"ñ",oacute:"ó",ocirc:"ô",ograve:"ò",ordf:"ª",ordm:"º",oslash:"ø",otilde:"õ",ouml:"ö",para:"¶",plusmn:"±",pound:"£",quot:'"',raquo:"»",reg:"®",sect:"§",shy:"­",sup1:"¹",sup2:"²",sup3:"³",szlig:"ß",thorn:"þ",times:"×",uacute:"ú",ucirc:"û",ugrave:"ù",uml:"¨",uuml:"ü",yacute:"ý",yen:"¥",yuml:"ÿ"}},,,,,function(e,t,r){"use strict";var i=r(64);var n=r(753);var a=function errorEx(e,t){if(!e||e.constructor!==String){t=e||{};e=Error.name}var r=function ErrorEXError(i){if(!this){return new ErrorEXError(i)}i=i instanceof Error?i.message:i||this.message;Error.call(this,i);Error.captureStackTrace(this,r);this.name=e;Object.defineProperty(this,"message",{configurable:true,enumerable:false,get:function(){var e=i.split(/\r?\n/g);for(var r in t){if(!t.hasOwnProperty(r)){continue}var a=t[r];if("message"in a){e=a.message(this[r],e)||e;if(!n(e)){e=[e]}}}return e.join("\n")},set:function(e){i=e}});var a=null;var u=Object.getOwnPropertyDescriptor(this,"stack");var s=u.get;var o=u.value;delete u.value;delete u.writable;u.set=function(e){a=e};u.get=function(){var e=(a||(s?s.call(this):o)).split(/\r?\n+/g);if(!a){e[0]=this.name+": "+this.message}var r=1;for(var i in t){if(!t.hasOwnProperty(i)){continue}var n=t[i];if("line"in n){var u=n.line(this[i]);if(u){e.splice(r++,0," "+u)}}if("stack"in n){n.stack(this[i],e)}}return e.join("\n")};Object.defineProperty(this,"stack",u)};if(Object.setPrototypeOf){Object.setPrototypeOf(r.prototype,Error.prototype);Object.setPrototypeOf(r,Error)}else{i.inherits(r,Error)}return r};a.append=function(e,t){return{message:function(r,i){r=r||t;if(r){i[0]+=" "+e.replace("%s",r.toString())}return i}}};a.line=function(e,t){return{line:function(r){r=r||t;if(r){return e.replace("%s",r.toString())}return null}}};e.exports=a},,,,,function(e,t,r){"use strict";var i=r(211);e.exports=new i("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}})},,,function(e,t,r){"use strict";var i=r(589);function replaceExt(e,t){if(typeof e!=="string"){return e}if(e.length===0){return e}var r=i.basename(e,i.extname(e))+t;return i.join(i.dirname(e),r)}e.exports=replaceExt},function(e,t,r){"use strict";var i=r(833);var n=["kind","resolve","construct","instanceOf","predicate","represent","defaultStyle","styleAliases"];var a=["scalar","sequence","mapping"];function compileStyleAliases(e){var t={};if(e!==null){Object.keys(e).forEach(function(r){e[r].forEach(function(e){t[String(e)]=r})})}return t}function Type(e,t){t=t||{};Object.keys(t).forEach(function(t){if(n.indexOf(t)===-1){throw new i('Unknown option "'+t+'" is met in definition of "'+e+'" YAML type.')}});this.tag=e;this.kind=t["kind"]||null;this.resolve=t["resolve"]||function(){return true};this.construct=t["construct"]||function(e){return e};this.instanceOf=t["instanceOf"]||null;this.predicate=t["predicate"]||null;this.represent=t["represent"]||null;this.defaultStyle=t["defaultStyle"]||null;this.styleAliases=compileStyleAliases(t["styleAliases"]||null);if(a.indexOf(this.kind)===-1){throw new i('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}}e.exports=Type},function(e,t,r){"use strict";var i=r(876);var n=true;try{n="inspect"in r(64)}catch(e){n=false}e.exports=n?inspect:noColor;inspect.color=inspect;noColor.color=inspect;inspect.noColor=noColor;noColor.noColor=noColor;var a=ansiColor(2,22);var u=ansiColor(33,39);var s=ansiColor(32,39);var o=new RegExp("(?:"+"(?:\\u001b\\[)|"+"\\u009b"+")"+"(?:"+"(?:[0-9]{1,3})?(?:(?:;[0-9]{0,3})*)?[A-M|f-m]"+")|"+"\\u001b[A-M]","g");var l=["type","value","children","position"];function noColor(e,t){return stripColor(inspect(e,t))}function inspect(e,t){var r;var i;var n;var a;if(e&&Boolean(e.length)&&typeof e!=="string"){a=e.length;n=-1;r=[];while(++n|$))/i;var l=/<\/(script|pre|style)>/i;var f=/^/;var h=/^<\?/;var p=/\?>/;var v=/^/;var D=/^/;var g=/^$/;var E=new RegExp(i.source+"\\s*$");function blockHtml(e,t,r){var i=this;var A=i.options.blocks.join("|");var C=new RegExp("^|$))","i");var y=t.length;var w=0;var x;var b;var F;var S;var B;var k;var O;var P=[[o,l,true],[f,c,true],[h,p,true],[v,d,true],[D,m,true],[C,g,true],[E,g,false]];while(w0&&v.indenta){return}if(!m||!l&&u.charAt(c+1)===n){return}f=u.length+1;D="";while(++c0){const t=peek();if(!i.isHexDigit(t)){throw invalidChar(read())}e+=read()}return String.fromCodePoint(parseInt(e,16))}const E={start(){if(f.type==="eof"){throw invalidEOF()}push()},beforePropertyName(){switch(f.type){case"identifier":case"string":c=f.value;a="afterPropertyName";return;case"punctuator":pop();return;case"eof":throw invalidEOF()}},afterPropertyName(){if(f.type==="eof"){throw invalidEOF()}a="beforePropertyValue"},beforePropertyValue(){if(f.type==="eof"){throw invalidEOF()}push()},beforeArrayValue(){if(f.type==="eof"){throw invalidEOF()}if(f.type==="punctuator"&&f.value==="]"){pop();return}push()},afterPropertyValue(){if(f.type==="eof"){throw invalidEOF()}switch(f.value){case",":a="beforePropertyName";return;case"}":pop()}},afterArrayValue(){if(f.type==="eof"){throw invalidEOF()}switch(f.value){case",":a="beforeArrayValue";return;case"]":pop()}},end(){}};function push(){let e;switch(f.type){case"punctuator":switch(f.value){case"{":e={};break;case"[":e=[];break}break;case"null":case"boolean":case"numeric":case"string":e=f.value;break}if(h===undefined){h=e}else{const t=u[u.length-1];if(Array.isArray(t)){t.push(e)}else{t[c]=e}}if(e!==null&&typeof e==="object"){u.push(e);if(Array.isArray(e)){a="beforeArrayValue"}else{a="beforePropertyName"}}else{const e=u[u.length-1];if(e==null){a="end"}else if(Array.isArray(e)){a="afterArrayValue"}else{a="afterPropertyValue"}}}function pop(){u.pop();const e=u[u.length-1];if(e==null){a="end"}else if(Array.isArray(e)){a="afterArrayValue"}else{a="afterPropertyValue"}}function invalidChar(e){if(e===undefined){return syntaxError(`JSON5: invalid end of input at ${o}:${l}`)}return syntaxError(`JSON5: invalid character '${formatChar(e)}' at ${o}:${l}`)}function invalidEOF(){return syntaxError(`JSON5: invalid end of input at ${o}:${l}`)}function invalidIdentifier(){l-=5;return syntaxError(`JSON5: invalid identifier character at ${o}:${l}`)}function separatorChar(e){console.warn(`JSON5: '${formatChar(e)}' in strings is not valid ECMAScript; consider escaping`)}function formatChar(e){const t={"'":"\\'",'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\v":"\\v","\0":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"};if(t[e]){return t[e]}if(e<" "){const t=e.charCodeAt(0).toString(16);return"\\x"+("00"+t).substring(t.length)}return e}function syntaxError(e){const t=new SyntaxError(e);t.lineNumber=o;t.columnNumber=l;return t}},,function(e,t,r){"use strict";var i=r(66);var n=r(589);var a=r(345);var u=r(347)("unified-engine:find-up");var s=r(692);e.exports=FindUp;var o=i.readFile;var l=n.resolve;var f=n.relative;var c=n.join;var h=n.dirname;FindUp.prototype.load=load;function FindUp(e){var t=this;var r=e.filePath;t.cache={};t.cwd=e.cwd;t.detect=e.detect;t.names=e.names;t.create=e.create;if(r){t.givenFilePath=l(e.cwd,r)}}function load(e,t){var r=this;var i=r.cache;var n=r.givenFilePath;var p=r.givenFile;var v=r.names;var d=r.create;var D=r.cwd;var m;if(n){if(p){apply(t,p)}else{p=[t];r.givenFile=p;u("Checking given file `%s`",n);o(n,loadGiven)}return}if(!r.detect){return t()}e=l(D,e);m=h(e);if(m in i){apply(t,i[m])}else{i[m]=[t];find(m)}function loadGiven(e,t){var i=r.givenFile;var s;if(e){s=a("Cannot read given file `%s`\n%s",f(D,n),e.stack);s.code="ENOENT";s.path=e.path;s.syscall=e.syscall}else{try{s=d(t,n);u("Read given file `%s`",n)}catch(e){s=a("Cannot parse given file `%s`\n%s",f(D,n),e.stack);u(e.message)}}p=s;r.givenFile=s;applyAll(i,s)}function find(t){var r=-1;var n=v.length;next();function next(){var a;if(++r{if(e)console.error(e);process.exit(t)})},,,,,,,function(e,t,r){"use strict";var i=r(495);var n=r(682);var a=r(839);var u=r(526);e.exports=i("remark-lint:code-block-style",codeBlockStyle);var s=a.start;var o=a.end;var l={null:true,fenced:true,indented:true};function codeBlockStyle(e,t,r){var i=String(t);r=typeof r==="string"&&r!=="consistent"?r:null;if(l[r]!==true){t.fail("Invalid code block style `"+r+"`: use either `'consistent'`, `'fenced'`, or `'indented'`")}n(e,"code",visitor);function visitor(e){var i=check(e);if(i){if(!r){r=i}else if(r!==i){t.message("Code blocks should be "+r,e)}}}function check(e){var t=s(e).offset;var r=o(e).offset;if(u(e)){return null}return e.lang||/^\s*([~`])\1{2,}/.test(i.slice(t,r))?"fenced":"indented"}}},,,function(e,t,r){"use strict";var i=r(589);var n=r(77);var a=r(289);e.exports=Ignore;Ignore.prototype.check=check;var u=i.dirname;var s=i.relative;var o=i.resolve;function Ignore(e){this.cwd=e.cwd;this.findUp=new a({filePath:e.ignorePath,cwd:e.cwd,detect:e.detectIgnore,names:e.ignoreName?[e.ignoreName]:[],create:create})}function check(e,t){var r=this;r.findUp.load(e,done);function done(i,n){var a;if(i){t(i)}else if(n){a=s(n.filePath,o(r.cwd,e));t(null,a?n.ignores(a):false)}else{t(null,false)}}}function create(e,t){var r=n().add(String(e));r.filePath=u(t);return r}},,,,function(e){e.exports={nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"­",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",fnof:"ƒ",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",bull:"•",hellip:"…",prime:"′",Prime:"″",oline:"‾",frasl:"⁄",weierp:"℘",image:"ℑ",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦",quot:'"',amp:"&",lt:"<",gt:">",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",circ:"ˆ",tilde:"˜",ensp:" ",emsp:" ",thinsp:" ",zwnj:"‌",zwj:"‍",lrm:"‎",rlm:"‏",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",permil:"‰",lsaquo:"‹",rsaquo:"›",euro:"€"}},,,,function(e,t,r){"use strict";var i=r(54);e.exports=enclose;var n="(";var a=")";var u="<";var s=">";var o=/\s/;function enclose(e,t){if(t||e.length===0||o.test(e)||i(e,n)!==i(e,a)){return u+e+s}return e}},,function(e,t,r){"use strict";var i=r(495);var n=r(682);var a=r(839);var u=r(526);e.exports=i("remark-lint:table-pipes",tablePipes);var s=a.start;var o=a.end;var l="Missing initial pipe in table fence";var f="Missing final pipe in table fence";function tablePipes(e,t){var r=String(t);n(e,"table",visitor);function visitor(e){var i=e.children;var n=i.length;var a=-1;var c;var h;var p;var v;var d;var D;while(++a0?parseInt(t):null};for(;i1)return true;for(var a=0;athis.maxLength)return t();if(!this.stat&&m(this.cache,r)){var a=this.cache[r];if(Array.isArray(a))a="DIR";if(!n||a==="DIR")return t(null,a);if(n&&a==="FILE")return t()}var u;var s=this.statCache[r];if(s!==undefined){if(s===false)return t(null,s);else{var o=s.isDirectory()?"DIR":"FILE";if(n&&o==="FILE")return t();else return t(null,o,s)}}var l=this;var f=g("stat\0"+r,lstatcb_);if(f)i.lstat(r,f);function lstatcb_(n,a){if(a&&a.isSymbolicLink()){return i.stat(r,function(i,n){if(i)l._stat2(e,r,null,a,t);else l._stat2(e,r,i,n,t)})}else{l._stat2(e,r,n,a,t)}}};Glob.prototype._stat2=function(e,t,r,i,n){if(r&&(r.code==="ENOENT"||r.code==="ENOTDIR")){this.statCache[t]=false;return n()}var a=e.slice(-1)==="/";this.statCache[t]=i;if(t.slice(-1)==="/"&&i&&!i.isDirectory())return n(null,false,i);var u=true;if(i)u=i.isDirectory()?"DIR":"FILE";this.cache[t]=this.cache[t]||u;if(a&&u==="FILE")return n();return n(null,u,i)}},function(e,t,r){"use strict";var i=r(36);var n=r(439);var a=r(934);var u=r(724);e.exports=paragraph;var s="\t";var o="\n";var l=" ";var f=4;function paragraph(e,t,r){var c=this;var h=c.options;var p=h.commonmark;var v=h.gfm;var d=c.blockTokenizers;var D=c.interruptParagraph;var m=t.indexOf(o);var g=t.length;var E;var A;var C;var y;var w;while(m=f&&C!==o){m=t.indexOf(o,m+1);continue}}A=t.slice(m+1);if(u(D,d,c,[e,A,true])){break}if(d.list.call(c,e,A,true)&&(c.inList||p||v&&!n(i.left(A).charAt(0)))){break}E=m;m=t.indexOf(o,m+1);if(m!==-1&&i(t.slice(E,m))===""){m=E;break}}A=t.slice(0,m);if(i(A)===""){e(A);return null}if(r){return true}w=e.now();A=a(A);return e(A)({type:"paragraph",children:c.tokenizeInline(A,w)})}},function(e,t,r){"use strict";var i;var n;try{var a=i;n=r(644)}catch(e){if(typeof window!=="undefined")n=window.esprima}var u=r(211);function resolveJavascriptFunction(e){if(e===null)return false;try{var t="("+e+")",r=n.parse(t,{range:true});if(r.type!=="Program"||r.body.length!==1||r.body[0].type!=="ExpressionStatement"||r.body[0].expression.type!=="ArrowFunctionExpression"&&r.body[0].expression.type!=="FunctionExpression"){return false}return true}catch(e){return false}}function constructJavascriptFunction(e){var t="("+e+")",r=n.parse(t,{range:true}),i=[],a;if(r.type!=="Program"||r.body.length!==1||r.body[0].type!=="ExpressionStatement"||r.body[0].expression.type!=="ArrowFunctionExpression"&&r.body[0].expression.type!=="FunctionExpression"){throw new Error("Failed to resolve function")}r.body[0].expression.params.forEach(function(e){i.push(e.name)});a=r.body[0].expression.body.range;if(r.body[0].expression.body.type==="BlockStatement"){return new Function(i,t.slice(a[0]+1,a[1]-1))}return new Function(i,"return "+t.slice(a[0],a[1]))}function representJavascriptFunction(e){return e.toString()}function isFunction(e){return Object.prototype.toString.call(e)==="[object Function]"}e.exports=new u("tag:yaml.org,2002:js/function",{kind:"scalar",resolve:resolveJavascriptFunction,construct:constructJavascriptFunction,predicate:isFunction,represent:representJavascriptFunction})},,,function(e,t,r){"use strict";var i=r(171);var n=r(984);var a=r(426);e.exports=reference;reference.locator=n;var u="link";var s="image";var o="footnote";var l="shortcut";var f="collapsed";var c="full";var h=" ";var p="!";var v="[";var d="\\";var D="]";var m="^";function reference(e,t,r){var n=this;var g=n.options.commonmark;var E=t.charAt(0);var A=0;var C=t.length;var y="";var w="";var x=u;var b=l;var F;var S;var B;var k;var O;var P;var T;var I;if(E===p){x=s;w=E;E=t.charAt(++A)}if(E!==v){return}A++;w+=E;P="";if(n.options.footnotes&&t.charAt(A)===m){if(x===s){return}w+=m;A++;x=o}I=0;while(A "+h.destination:""}if(!h.stats.total){p+=p?": ":"";if(h.stored){p+=m.yellow.open+"written"+m.yellow.close}else{p+="no issues found"}}if(p){l.push(p)}}else{g=m[h.label==="error"?"red":"yellow"];E=h.reason;A="";C=E.indexOf("\n");if(C!==-1){A=E.slice(C);E=E.slice(0,C)}l.push(["",padLeft(h.location,e.location),padRight(g.open+h.label+g.close,e.label),padRight(E,e.reason),padRight(h.ruleId,e.ruleId),h.source||""].join(" ").replace(c,"")+A)}}if(a.fatal||a.warn){p=[];if(a.fatal){p.push([m.red.open+f.error+m.red.close,a.fatal,plural(D.true,a.fatal)].join(" "))}if(a.warn){p.push([m.yellow.open+f.warning+m.yellow.close,a.warn,plural(D.false,a.warn)].join(" "))}p=p.join(", ");if(a.total!==a.fatal&&a.total!==a.warn){p=a.total+" messages ("+p+")"}l.push("",p)}return l.join("\n")}function applicable(e,t){var r=e.messages;var i=r.length;var n=-1;var a=[];if(t.silent){while(++n64)continue;if(t<0)return false;i+=6}return i%8===0}function constructYamlBinary(e){var t,r,i=e.replace(/[\r\n=]/g,""),a=i.length,u=s,o=0,l=[];for(t=0;t>16&255);l.push(o>>8&255);l.push(o&255)}o=o<<6|u.indexOf(i.charAt(t))}r=a%4*6;if(r===0){l.push(o>>16&255);l.push(o>>8&255);l.push(o&255)}else if(r===18){l.push(o>>10&255);l.push(o>>2&255)}else if(r===12){l.push(o>>4&255)}if(n){return n.from?n.from(l):new n(l)}return l}function representYamlBinary(e){var t="",r=0,i,n,a=e.length,u=s;for(i=0;i>18&63];t+=u[r>>12&63];t+=u[r>>6&63];t+=u[r&63]}r=(r<<8)+e[i]}n=a%3;if(n===0){t+=u[r>>18&63];t+=u[r>>12&63];t+=u[r>>6&63];t+=u[r&63]}else if(n===2){t+=u[r>>10&63];t+=u[r>>4&63];t+=u[r<<2&63];t+=u[64]}else if(n===1){t+=u[r>>2&63];t+=u[r<<4&63];t+=u[64];t+=u[64]}return t}function isBinary(e){return n&&n.isBuffer(e)}e.exports=new u("tag:yaml.org,2002:binary",{kind:"scalar",resolve:resolveYamlBinary,construct:constructYamlBinary,predicate:isBinary,represent:representYamlBinary})},function(e){"use strict";var t=[].slice;e.exports=wrap;function wrap(e,r){var i;return wrapped;function wrapped(){var r=t.call(arguments,0);var n=e.length>r.length;var a;if(n){r.push(done)}try{a=e.apply(null,r)}catch(e){if(n&&i){throw e}return done(e)}if(!n){if(a&&typeof a.then==="function"){a.then(then,done)}else if(a instanceof Error){done(a)}else{then(a)}}}function done(){if(!i){i=true;r.apply(null,arguments)}}function then(e){done(null,e)}}},function(e){e.exports=extend;var t=Object.prototype.hasOwnProperty;function extend(){var e={};for(var r=0;ri){t.message("Move definitions to the end of the file (after the node at line `"+r+"`)",e)}}else if(r===null){r=i}}}},function(e){var t=Object.prototype.toString;e.exports=isString;function isString(e){return t.call(e)==="[object String]"}},function(e,t,r){"use strict";var i=r(874);e.exports=configure;function configure(e,t){e.configuration=new i(t)}},,,,function(e,t,r){"use strict";var i=r(323);var n=create(Error);e.exports=n;n.eval=create(EvalError);n.range=create(RangeError);n.reference=create(ReferenceError);n.syntax=create(SyntaxError);n.type=create(TypeError);n.uri=create(URIError);n.create=create;function create(e){FormattedError.displayName=e.displayName||e.name;return FormattedError;function FormattedError(t){if(t){t=i.apply(null,arguments)}return new e(t)}}},,function(e,t,r){"use strict";if(typeof process==="undefined"||process.type==="renderer"||process.browser===true||process.__nwjs){e.exports=r(470)}else{e.exports=r(970)}},function(e,t,r){var i=r(20);var n=r(491);e.exports=expandTop;var a="\0SLASH"+Math.random()+"\0";var u="\0OPEN"+Math.random()+"\0";var s="\0CLOSE"+Math.random()+"\0";var o="\0COMMA"+Math.random()+"\0";var l="\0PERIOD"+Math.random()+"\0";function numeric(e){return parseInt(e,10)==e?parseInt(e,10):e.charCodeAt(0)}function escapeBraces(e){return e.split("\\\\").join(a).split("\\{").join(u).split("\\}").join(s).split("\\,").join(o).split("\\.").join(l)}function unescapeBraces(e){return e.split(a).join("\\").split(u).join("{").split(s).join("}").split(o).join(",").split(l).join(".")}function parseCommaParts(e){if(!e)return[""];var t=[];var r=n("{","}",e);if(!r)return e.split(",");var i=r.pre;var a=r.body;var u=r.post;var s=i.split(",");s[s.length-1]+="{"+a+"}";var o=parseCommaParts(u);if(u.length){s[s.length-1]+=o.shift();s.push.apply(s,o)}t.push.apply(t,s);return t}function expandTop(e){if(!e)return[];if(e.substr(0,2)==="{}"){e="\\{\\}"+e.substr(2)}return expand(escapeBraces(e),true).map(unescapeBraces)}function identity(e){return e}function embrace(e){return"{"+e+"}"}function isPadded(e){return/^-?0\d/.test(e)}function lte(e,t){return e<=t}function gte(e,t){return e>=t}function expand(e,t){var r=[];var a=n("{","}",e);if(!a||/\$$/.test(a.pre))return[e];var u=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(a.body);var o=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(a.body);var l=u||o;var f=a.body.indexOf(",")>=0;if(!l&&!f){if(a.post.match(/,.*\}/)){e=a.pre+"{"+a.body+s+a.post;return expand(e)}return[e]}var c;if(l){c=a.body.split(/\.\./)}else{c=parseCommaParts(a.body);if(c.length===1){c=expand(c[0],false).map(embrace);if(c.length===1){var h=a.post.length?expand(a.post,false):[""];return h.map(function(e){return a.pre+c[0]+e})}}}var p=a.pre;var h=a.post.length?expand(a.post,false):[""];var v;if(l){var d=numeric(c[0]);var D=numeric(c[1]);var m=Math.max(c[0].length,c[1].length);var g=c.length==3?Math.abs(numeric(c[2])):1;var E=lte;var A=D0){var b=new Array(x+1).join("0");if(y<0)w="-"+b+w.slice(1);else w=b+w}}}v.push(w)}}else{v=i(c,function(e){return expand(e,false)})}for(var F=0;F>5===6)return 2;else if(e>>4===14)return 3;else if(e>>3===30)return 4;return e>>6===2?-1:-2}function utf8CheckIncomplete(e,t,r){var i=t.length-1;if(i=0){if(n>0)e.lastNeed=n-1;return n}if(--i=0){if(n>0)e.lastNeed=n-2;return n}if(--i=0){if(n>0){if(n===2)n=0;else e.lastNeed=n-3}return n}return 0}function utf8CheckExtraBytes(e,t,r){if((t[0]&192)!==128){e.lastNeed=0;return"�"}if(e.lastNeed>1&&t.length>1){if((t[1]&192)!==128){e.lastNeed=1;return"�"}if(e.lastNeed>2&&t.length>2){if((t[2]&192)!==128){e.lastNeed=2;return"�"}}}}function utf8FillLast(e){var t=this.lastTotal-this.lastNeed;var r=utf8CheckExtraBytes(this,e,t);if(r!==undefined)return r;if(this.lastNeed<=e.length){e.copy(this.lastChar,t,0,this.lastNeed);return this.lastChar.toString(this.encoding,0,this.lastTotal)}e.copy(this.lastChar,t,0,e.length);this.lastNeed-=e.length}function utf8Text(e,t){var r=utf8CheckIncomplete(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var i=e.length-(r-this.lastNeed);e.copy(this.lastChar,0,i);return e.toString("utf8",t,i)}function utf8End(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed)return t+"�";return t}function utf16Text(e,t){if((e.length-t)%2===0){var r=e.toString("utf16le",t);if(r){var i=r.charCodeAt(r.length-1);if(i>=55296&&i<=56319){this.lastNeed=2;this.lastTotal=4;this.lastChar[0]=e[e.length-2];this.lastChar[1]=e[e.length-1];return r.slice(0,-1)}}return r}this.lastNeed=1;this.lastTotal=2;this.lastChar[0]=e[e.length-1];return e.toString("utf16le",t,e.length-1)}function utf16End(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function base64Text(e,t){var r=(e.length-t)%3;if(r===0)return e.toString("base64",t);this.lastNeed=3-r;this.lastTotal=3;if(r===1){this.lastChar[0]=e[e.length-1]}else{this.lastChar[0]=e[e.length-2];this.lastChar[1]=e[e.length-1]}return e.toString("base64",t,e.length-r)}function base64End(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed)return t+this.lastChar.toString("base64",0,3-this.lastNeed);return t}function simpleWrite(e){return e.toString(this.encoding)}function simpleEnd(e){return e&&e.length?this.write(e):""}},,,,function(e,t,r){"use strict";var i=r(186);e.exports=VMessage;function VMessagePrototype(){}VMessagePrototype.prototype=Error.prototype;VMessage.prototype=new VMessagePrototype;var n=VMessage.prototype;n.file="";n.name="";n.reason="";n.message="";n.stack="";n.fatal=null;n.column=null;n.line=null;function VMessage(e,t,r){var n;var a;var u;if(typeof t==="string"){r=t;t=null}n=parseOrigin(r);a=i(t)||"1:1";u={start:{line:null,column:null},end:{line:null,column:null}};if(t&&t.position){t=t.position}if(t){if(t.start){u=t;t=t.start}else{u.start=t}}if(e.stack){this.stack=e.stack;e=e.message}this.message=e;this.name=a;this.reason=e;this.line=t?t.line:null;this.column=t?t.column:null;this.location=u;this.source=n[0];this.ruleId=n[1]}function parseOrigin(e){var t=[null,null];var r;if(typeof e==="string"){r=e.indexOf(":");if(r===-1){t[1]=e}else{t[0]=e.slice(0,r);t[1]=e.slice(r+1)}}return t}},,function(e,t,r){"use strict";var i=r(171);var n=r(902);var a=r(49);e.exports=autoLink;autoLink.locator=a;autoLink.notInLink=true;var u="<";var s=">";var o="@";var l="/";var f="mailto:";var c=f.length;function autoLink(e,t,r){var a=this;var h="";var p=t.length;var v=0;var d="";var D=false;var m="";var g;var E;var A;var C;var y;if(t.charAt(0)!==u){return}v++;h=u;while(v0||H===x&&I.inLink||M&&H===B&&t.charAt(W+1)===B||M&&H===S&&(I.inTable||alignment(t,W))||H===b&&W>0&&W=e.expected){e.emit("done")}}},,function(e,t,r){"use strict";var i=r(897);var n=r(336);var a=r(860);e.exports=parse;parse.Parser=a;function parse(e){var t=this.data("settings");var r=i(a);r.prototype.options=n(r.prototype.options,t,e);this.Parser=r}},,,,,,function(e,t,r){"use strict";var i=r(176);e.exports=imageReference;var n="[";var a="]";var u="!";function imageReference(e){return u+n+(this.encode(e.alt,e)||"")+a+i(e)}},,,,,,function(e,t,r){"use strict";var i=r(495);e.exports=i("remark-lint:no-file-name-consecutive-dashes",noFileNameConsecutiveDashes);var n="Do not use consecutive dashes in a file name";function noFileNameConsecutiveDashes(e,t){if(t.stem&&/-{2,}/.test(t.stem)){t.message(n)}}},,function(e,t,r){"use strict";var i=r(495);var n=r(682);var a=r(839);var u=r(526);e.exports=i("remark-lint:ordered-list-marker-style",orderedListMarkerStyle);var s=a.start;var o={")":true,".":true,null:true};function orderedListMarkerStyle(e,t,r){var i=String(t);r=typeof r!=="string"||r==="consistent"?null:r;if(o[r]!==true){t.fail("Invalid ordered list-item marker style `"+r+"`: use either `'.'` or `')'`")}n(e,"list",visitor);function visitor(e){var n=e.children;var a=e.ordered?n.length:0;var o=-1;var l;var f;while(++o=s&&(!p||p===r)){h+=D;if(l){return true}return e(h)({type:"thematicBreak"})}else{return}}}},,function(e){e.exports=require("assert")},,,,,,,function(e,t,r){"use strict";var i=r(774);var n=r(176);e.exports=linkReference;var a="[";var u="]";var s="shortcut";var o="collapsed";function linkReference(e){var t=this;var r=e.referenceType;var l=t.enterLinkReference(t,e);var f=t.all(e).join("");l();if(r===s||r===o){f=i(f,e.label||e.identifier)}return a+f+u+n(e)}},function(e){"use strict";e.exports=lineBreak;var t="\\";var r="\n";var i=" ";var n=t+r;var a=i+i+r;function lineBreak(){return this.options.commonmark?n:a}},function(e,t,r){"use strict";function _classCallCheck(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}}var i=r(945).Buffer;var n=r(64);function copyBuffer(e,t,r){e.copy(t,r)}e.exports=function(){function BufferList(){_classCallCheck(this,BufferList);this.head=null;this.tail=null;this.length=0}BufferList.prototype.push=function push(e){var t={data:e,next:null};if(this.length>0)this.tail.next=t;else this.head=t;this.tail=t;++this.length};BufferList.prototype.unshift=function unshift(e){var t={data:e,next:this.head};if(this.length===0)this.tail=t;this.head=t;++this.length};BufferList.prototype.shift=function shift(){if(this.length===0)return;var e=this.head.data;if(this.length===1)this.head=this.tail=null;else this.head=this.head.next;--this.length;return e};BufferList.prototype.clear=function clear(){this.head=this.tail=null;this.length=0};BufferList.prototype.join=function join(e){if(this.length===0)return"";var t=this.head;var r=""+t.data;while(t=t.next){r+=e+t.data}return r};BufferList.prototype.concat=function concat(e){if(this.length===0)return i.alloc(0);if(this.length===1)return this.head.data;var t=i.allocUnsafe(e>>>0);var r=this.head;var n=0;while(r){copyBuffer(r.data,t,n);n+=r.data.length;r=r.next}return t};return BufferList}();if(n&&n.inspect&&n.inspect.custom){e.exports.prototype[n.inspect.custom]=function(){var e=n.inspect({length:this.length});return this.constructor.name+" "+e}}},function(e,t,r){"use strict";var i=r(336);var n=r(109);var a=r(694);e.exports=setOptions;function setOptions(e){var t=this;var r=t.options;var u;var s;if(e==null){e={}}else if(typeof e==="object"){e=i(e)}else{throw new Error("Invalid value `"+e+"` for setting `options`")}for(u in a){s=e[u];if(s==null){s=r[u]}if(u!=="blocks"&&typeof s!=="boolean"||u==="blocks"&&typeof s!=="object"){throw new Error("Invalid value `"+s+"` for setting `options."+u+"`")}e[u]=s}t.options=e;t.escape=n(e);return t}},,function(e){var t=Array.prototype.slice;e.exports=co;function co(e){var r=isGeneratorFunction(e);return function(i){var n=this;var a=e;if(r){var u=t.call(arguments),s=u.length;var o=s&&"function"==typeof u[s-1];i=o?u.pop():error;a=e.apply(this,u)}else{i=i||error}next();function exit(e,t){setImmediate(function(){i.call(n,e,t)})}function next(e,r){var i;if(arguments.length>2)r=t.call(arguments,1);if(e){try{i=a.throw(e)}catch(e){return exit(e)}}if(!e){try{i=a.next(r)}catch(e){return exit(e)}}if(i.done)return exit(null,i.value);i.value=toThunk(i.value,n);if("function"==typeof i.value){var u=false;try{i.value.call(n,function(){if(u)return;u=true;next.apply(n,arguments)})}catch(e){setImmediate(function(){if(u)return;u=true;next(e)})}return}next(new TypeError("You may only yield a function, promise, generator, array, or object, "+'but the following was passed: "'+String(i.value)+'"'))}}}function toThunk(e,t){if(isGeneratorFunction(e)){return co(e.call(t))}if(isGenerator(e)){return co(e)}if(isPromise(e)){return promiseToThunk(e)}if("function"==typeof e){return e}if(isObject(e)||Array.isArray(e)){return objectToThunk.call(t,e)}return e}function objectToThunk(e){var t=this;var r=Array.isArray(e);return function(i){var n=Object.keys(e);var a=n.length;var u=r?new Array(a):new e.constructor;var s;if(!a){setImmediate(function(){i(null,u)});return}if(!r){for(var o=0;or){t.splice(0,r);process.nextTick(function(){RES.apply(null,i)})}else{delete n[e]}}})}function slice(e){var t=e.length;var r=[];for(var i=0;ii){o+=" with 1 space, not "+u;if(size(a)=48&&t<=57}},function(e,t,r){"use strict";var i=r(308);var n=r(197);var a=r(25);var u=r(908);var s=r(617);e.exports=encode;encode.escape=escape;var o={}.hasOwnProperty;var l=['"',"'","<",">","&","`"];var f=construct();var c=toExpression(l);var h=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;var p=/[\x01-\t\x0B\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g;function encode(e,t){var r=t||{};var i=r.subset;var n=i?toExpression(i):c;var a=r.escapeOnly;var u=r.omitOptionalSemicolons;e=e.replace(n,function(e,t,i){return one(e,i.charAt(t+1),r)});if(i||a){return e}return e.replace(h,replaceSurrogatePair).replace(p,replaceBmp);function replaceSurrogatePair(e,t,r){return toHexReference((e.charCodeAt(0)-55296)*1024+e.charCodeAt(1)-56320+65536,r.charAt(t+2),u)}function replaceBmp(e,t,i){return one(e,i.charAt(t+1),r)}}function escape(e){return encode(e,{escapeOnly:true,useNamedReferences:true})}function one(e,t,r){var i=r.useShortestReferences;var n=r.omitOptionalSemicolons;var a;var u;if((i||r.useNamedReferences)&&o.call(f,e)){a=toNamed(f[e],t,n,r.attribute)}if(i||!a){u=toHexReference(e.charCodeAt(0),t,n)}if(a&&(!i||a.length/i;function inlineHTML(e,t,r){var n=this;var h=t.length;var p;var v;if(t.charAt(0)!==u||h<3){return}p=t.charAt(1);if(!i(p)&&p!==s&&p!==o&&p!==l){return}v=t.match(a);if(!v){return}if(r){return true}v=v[0];if(!n.inLink&&f.test(v)){n.inLink=true}else if(n.inLink&&c.test(v)){n.inLink=false}return e(v)({type:"html",value:v})}},function(e){e.exports=["md","markdown","mdown","mkdn","mkd","mdwn","mkdown","ron"]},,,,function(e,t,r){"use strict";var i=r(495);e.exports=i("remark-lint:file-extension",fileExtension);function fileExtension(e,t,r){var i=t.extname;r=typeof r==="string"?r:"md";if(i&&i.slice(1)!==r){t.message("Invalid extension: use `"+r+"`")}}},function(e){"use strict";e.exports=factory;var t="\\";function factory(e,r){return unescape;function unescape(i){var n=0;var a=i.indexOf(t);var u=e[r];var s=[];var o;while(a!==-1){s.push(i.slice(n,a));n=a+1;o=i.charAt(n);if(!o||u.indexOf(o)===-1){s.push(t)}a=i.indexOf(t,n+1)}s.push(i.slice(n));return s.join("")}}},,,function(e,t,r){"use strict";const i=r(495);const n=r(682);e.exports=i("remark-lint:prohibited-strings",prohibitedStrings);function testProhibited(e,t){const r=new RegExp(`(\\.|@[a-z0-9/-]*)?(${e.no})(\\.\\w)?`,"g");let i=null;while(i=r.exec(t)){if(!i[1]&&!i[3]){return i[2]}}return false}function prohibitedStrings(e,t,r){n(e,"text",checkText);function checkText(e){const i=e.value;r.forEach(r=>{const n=testProhibited(r,i);if(n){t.message(`Use "${r.yes}" instead of "${n}"`,e)}})}}},,,,,function(e){"use strict";e.exports=hidden;function hidden(e){if(typeof e!=="string"){throw new Error("Expected string")}return e.charAt(0)==="."}},,,,,function(e,t,r){"use strict";var i=r(171);var n=r(426);e.exports=footnoteDefinition;footnoteDefinition.notInList=true;footnoteDefinition.notInBlock=true;var a="\\";var u="\n";var s="\t";var o=" ";var l="[";var f="]";var c="^";var h=":";var p=/^( {4}|\t)?/gm;function footnoteDefinition(e,t,r){var v=this;var d=v.offset;var D;var m;var g;var E;var A;var C;var y;var w;var x;var b;var F;var S;if(!v.options.footnotes){return}D=0;m=t.length;g="";E=e.now();A=E.line;while(D=31||typeof navigator!=="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function formatArgs(t){t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff);if(!this.useColors){return}var r="color: "+this.color;t.splice(1,0,r,"color: inherit");var i=0;var n=0;t[0].replace(/%[a-zA-Z%]/g,function(e){if(e==="%%"){return}i++;if(e==="%c"){n=i}});t.splice(n,0,r)}function log(){var e;return(typeof console==="undefined"?"undefined":_typeof(console))==="object"&&console.log&&(e=console).log.apply(e,arguments)}function save(e){try{if(e){t.storage.setItem("debug",e)}else{t.storage.removeItem("debug")}}catch(e){}}function load(){var e;try{e=t.storage.getItem("debug")}catch(e){}if(!e&&typeof process!=="undefined"&&"env"in process){e=process.env.DEBUG}return e}function localstorage(){try{return localStorage}catch(e){}}e.exports=r(772)(t);var i=e.exports.formatters;i.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},,,,function(e,t,r){var i=r(159);var n=r(589).join;var a=r(281);var u="/etc";var s=process.platform==="win32";var o=s?process.env.USERPROFILE:process.env.HOME;e.exports=function(e,t,l,f){if("string"!==typeof e)throw new Error("rc(name): name *must* be string");if(!l)l=r(359)(process.argv.slice(2));t=("string"===typeof t?i.json(t):t)||{};f=f||i.parse;var c=i.env(e+"_");var h=[t];var p=[];function addConfigFile(e){if(p.indexOf(e)>=0)return;var t=i.file(e);if(t){h.push(f(t));p.push(e)}}if(!s)[n(u,e,"config"),n(u,e+"rc")].forEach(addConfigFile);if(o)[n(o,".config",e,"config"),n(o,".config",e),n(o,"."+e,"config"),n(o,"."+e+"rc")].forEach(addConfigFile);addConfigFile(i.find("."+e+"rc"));if(c.config)addConfigFile(c.config);if(l.config)addConfigFile(l.config);return a.apply(null,h.concat([c,l,p.length?{configs:p,config:p[p.length-1]}:undefined]))}},,function(e,t,r){"use strict";var i=r(495);var n=r(682);var a=r(526);e.exports=i("remark-lint:no-shortcut-reference-link",noShortcutReferenceLink);var u="Use the trailing [] on reference links";function noShortcutReferenceLink(e,t){n(e,"linkReference",visitor);function visitor(e){if(!a(e)&&e.referenceType==="shortcut"){t.message(u,e)}}}},,,,,,,,function(e){e.exports={_from:"remark@^10.0.1",_id:"remark@10.0.1",_inBundle:false,_integrity:"sha512-E6lMuoLIy2TyiokHprMjcWNJ5UxfGQjaMSMhV+f4idM625UjjK4j798+gPs5mfjzDE6vL0oFKVeZM6gZVSVrzQ==",_location:"/remark",_phantomChildren:{},_requested:{type:"range",registry:true,raw:"remark@^10.0.1",name:"remark",escapedName:"remark",rawSpec:"^10.0.1",saveSpec:null,fetchSpec:"^10.0.1"},_requiredBy:["/"],_resolved:"https://registry.npmjs.org/remark/-/remark-10.0.1.tgz",_shasum:"3058076dc41781bf505d8978c291485fe47667df",_spec:"remark@^10.0.1",_where:"/Users/trott/io.js/tools/node-lint-md-cli-rollup",author:{name:"Titus Wormer",email:"tituswormer@gmail.com",url:"https://wooorm.com"},bugs:{url:"https://github.com/remarkjs/remark/issues"},bundleDependencies:false,contributors:[{name:"Titus Wormer",email:"tituswormer@gmail.com",url:"https://wooorm.com"}],dependencies:{"remark-parse":"^6.0.0","remark-stringify":"^6.0.0",unified:"^7.0.0"},deprecated:false,description:"Markdown processor powered by plugins",devDependencies:{tape:"^4.9.1"},files:["index.js"],homepage:"https://remark.js.org",keywords:["markdown","abstract","syntax","tree","ast","parse","stringify","process"],license:"MIT",name:"remark",repository:{type:"git",url:"https://github.com/remarkjs/remark/tree/master/packages/remark"},scripts:{test:"tape test.js"},version:"10.0.1",xo:false}},function(e){e.exports=require("events")},,function(e,t,r){e.exports=globSync;globSync.GlobSync=GlobSync;var i=r(66);var n=r(129);var a=r(620);var u=a.Minimatch;var s=r(327).Glob;var o=r(64);var l=r(589);var f=r(393);var c=r(969);var h=r(922);var p=h.alphasort;var v=h.alphasorti;var d=h.setopts;var D=h.ownProp;var m=h.childrenIgnored;var g=h.isIgnored;function globSync(e,t){if(typeof t==="function"||arguments.length===3)throw new TypeError("callback provided to sync glob\n"+"See: https://github.com/isaacs/node-glob/issues/167");return new GlobSync(e,t).found}function GlobSync(e,t){if(!e)throw new Error("must provide pattern");if(typeof t==="function"||arguments.length===3)throw new TypeError("callback provided to sync glob\n"+"See: https://github.com/isaacs/node-glob/issues/167");if(!(this instanceof GlobSync))return new GlobSync(e,t);d(this,e,t);if(this.noprocess)return this;var r=this.minimatch.set.length;this.matches=new Array(r);for(var i=0;ithis.maxLength)return false;if(!this.stat&&D(this.cache,t)){var n=this.cache[t];if(Array.isArray(n))n="DIR";if(!r||n==="DIR")return n;if(r&&n==="FILE")return false}var a;var u=this.statCache[t];if(!u){var s;try{s=i.lstatSync(t)}catch(e){if(e&&(e.code==="ENOENT"||e.code==="ENOTDIR")){this.statCache[t]=false;return false}}if(s&&s.isSymbolicLink()){try{u=i.statSync(t)}catch(e){u=s}}else{u=s}}this.statCache[t]=u;var n=true;if(u)n=u.isDirectory()?"DIR":"FILE";this.cache[t]=this.cache[t]||n;if(r&&n==="FILE")return false;return n};GlobSync.prototype._mark=function(e){return h.mark(this,e)};GlobSync.prototype._makeAbs=function(e){return h.makeAbs(this,e)}},,,,function(e){"use strict";e.exports=balanced;function balanced(e,t,r){if(e instanceof RegExp)e=maybeMatch(e,r);if(t instanceof RegExp)t=maybeMatch(t,r);var i=range(e,t,r);return i&&{start:i[0],end:i[1],pre:r.slice(0,i[0]),body:r.slice(i[0]+e.length,i[1]),post:r.slice(i[1]+t.length)}}function maybeMatch(e,t){var r=t.match(e);return r?r[0]:null}balanced.range=range;function range(e,t,r){var i,n,a,u,s;var o=r.indexOf(e);var l=r.indexOf(t,o+1);var f=o;if(o>=0&&l>0){i=[];a=r.length;while(f>=0&&!s){if(f==o){i.push(f);o=r.indexOf(e,f+1)}else if(i.length==1){s=[i.pop(),l]}else{n=i.pop();if(n=0?o:l}if(i.length){s=[a,u]}}return s}},,,,function(e,t,r){"use strict";var i=r(659);e.exports=factory;function factory(e,t){var r=e.split(":");var n=r[0];var a=r[1];var u=i(t);if(!a){a=n;n=null}attacher.displayName=e;return attacher;function attacher(e){var t=coerce(a,e);var r=t[0];var i=t[1];var s=r===2;return r?transformer:undefined;function transformer(e,t,r){var o=t.messages.length;u(e,t,i,done);function done(e){var i=t.messages;var u;if(e&&i.indexOf(e)===-1){try{t.fail(e)}catch(e){}}while(o2){throw new Error("Invalid severity `"+n+"` for `"+e+"`, "+"expected 0, 1, or 2")}i[0]=n;return i}},,,,,,,function(e,t,r){"use strict";e.exports=PassThrough;var i=r(955);var n=r(683);n.inherits=r(780);n.inherits(PassThrough,i);function PassThrough(e){if(!(this instanceof PassThrough))return new PassThrough(e);i.call(this,e)}PassThrough.prototype._transform=function(e,t,r){r(null,e)}},function(e,t,r){"use strict";var i=r(353);var n=r(320);e.exports=n;var a=n.prototype;a.message=message;a.info=info;a.fail=fail;a.warn=message;function message(e,t,r){var n=this.path;var a=new i(e,t,r);if(n){a.name=n+":"+a.name;a.file=n}a.fatal=false;this.messages.push(a);return a}function fail(){var e=this.message.apply(this,arguments);e.fatal=true;throw e}function info(){var e=this.message.apply(this,arguments);e.fatal=null;return e}},,,,function(e,t,r){e.exports=r(64).deprecate},,,,function(e){"use strict";e.exports=locate;function locate(e,t){var r=e.indexOf("**",t);var i=e.indexOf("__",t);if(i===-1){return r}if(r===-1){return i}return ii&&e[c+1]!==" ";c=a}}else if(!isPrintable(u)){return j}h=h&&isPlainSafe(u)}o=o||l&&(a-c-1>i&&e[c+1]!==" ")}if(!s&&!o){return h&&!n(e)?I:M}if(r>9&&needIndentIndicator(e)){return j}return o?R:L}function writeScalar(e,t,r,i){e.dump=function(){if(t.length===0){return"''"}if(!e.noCompatMode&&T.indexOf(t)!==-1){return"'"+t+"'"}var a=e.indent*Math.max(1,r);var u=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-a);var s=i||e.flowLevel>-1&&r>=e.flowLevel;function testAmbiguity(t){return testImplicitResolving(e,t)}switch(chooseScalarStyle(t,s,e.indent,u,testAmbiguity)){case I:return t;case M:return"'"+t.replace(/'/g,"''")+"'";case L:return"|"+blockHeader(t,e.indent)+dropEndingNewline(indentString(t,a));case R:return">"+blockHeader(t,e.indent)+dropEndingNewline(indentString(foldString(t,u),a));case j:return'"'+escapeString(t,u)+'"';default:throw new n("impossible error: invalid scalar style")}}()}function blockHeader(e,t){var r=needIndentIndicator(e)?String(t):"";var i=e[e.length-1]==="\n";var n=i&&(e[e.length-2]==="\n"||e==="\n");var a=n?"+":i?"":"-";return r+a+"\n"}function dropEndingNewline(e){return e[e.length-1]==="\n"?e.slice(0,-1):e}function foldString(e,t){var r=/(\n+)([^\n]*)/g;var i=function(){var i=e.indexOf("\n");i=i!==-1?i:e.length;r.lastIndex=i;return foldLine(e.slice(0,i),t)}();var n=e[0]==="\n"||e[0]===" ";var a;var u;while(u=r.exec(e)){var s=u[1],o=u[2];a=o[0]===" ";i+=s+(!n&&!a&&o!==""?"\n":"")+foldLine(o,t);n=a}return i}function foldLine(e,t){if(e===""||e[0]===" ")return e;var r=/ [^ ]/g;var i;var n=0,a,u=0,s=0;var o="";while(i=r.exec(e)){s=i.index;if(s-n>t){a=u>n?u:s;o+="\n"+e.slice(n,a);n=a+1}u=s}o+="\n";if(e.length-n>t&&u>n){o+=e.slice(n,u)+"\n"+e.slice(u+1)}else{o+=e.slice(n)}return o.slice(1)}function escapeString(e){var t="";var r,i;var n;for(var a=0;a=55296&&r<=56319){i=e.charCodeAt(a+1);if(i>=56320&&i<=57343){t+=encodeHex((r-55296)*1024+i-56320+65536);a++;continue}}n=P[r];t+=!n&&isPrintable(r)?e[a]:n||encodeHex(r)}return t}function writeFlowSequence(e,t,r){var i="",n=e.tag,a,u;for(a=0,u=r.length;a1024)f+="? ";f+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" ");if(!writeNode(e,t,l,false,false)){continue}f+=e.dump;i+=f}e.tag=n;e.dump="{"+i+"}"}function writeBlockMapping(e,t,r,i){var a="",u=e.tag,s=Object.keys(r),o,l,c,h,p,v;if(e.sortKeys===true){s.sort()}else if(typeof e.sortKeys==="function"){s.sort(e.sortKeys)}else if(e.sortKeys){throw new n("sortKeys must be a boolean or a function")}for(o=0,l=s.length;o1024;if(p){if(e.dump&&f===e.dump.charCodeAt(0)){v+="?"}else{v+="? "}}v+=e.dump;if(p){v+=generateNextLine(e,t)}if(!writeNode(e,t+1,h,true,p)){continue}if(e.dump&&f===e.dump.charCodeAt(0)){v+=":"}else{v+=": "}v+=e.dump;a+=v}e.tag=u;e.dump=a||"{}"}function detectType(e,t,r){var i,a,u,l,f,c;a=r?e.explicitTypes:e.implicitTypes;for(u=0,l=a.length;u tag resolver accepts not "'+c+'" style')}e.dump=i}return true}}return false}function writeNode(e,t,r,i,a,u){e.tag=null;e.dump=r;if(!detectType(e,r,false)){detectType(e,r,true)}var o=s.call(e.dump);if(i){i=e.flowLevel<0||e.flowLevel>t}var l=o==="[object Object]"||o==="[object Array]",f,c;if(l){f=e.duplicates.indexOf(r);c=f!==-1}if(e.tag!==null&&e.tag!=="?"||c||e.indent!==2&&t>0){a=false}if(c&&e.usedDuplicates[f]){e.dump="*ref_"+f}else{if(l&&c&&!e.usedDuplicates[f]){e.usedDuplicates[f]=true}if(o==="[object Object]"){if(i&&Object.keys(e.dump).length!==0){writeBlockMapping(e,t,e.dump,a);if(c){e.dump="&ref_"+f+e.dump}}else{writeFlowMapping(e,t,e.dump);if(c){e.dump="&ref_"+f+" "+e.dump}}}else if(o==="[object Array]"){var h=e.noArrayIndent&&t>0?t-1:t;if(i&&e.dump.length!==0){writeBlockSequence(e,h,e.dump,a);if(c){e.dump="&ref_"+f+e.dump}}else{writeFlowSequence(e,h,e.dump);if(c){e.dump="&ref_"+f+" "+e.dump}}}else if(o==="[object String]"){if(e.tag!=="?"){writeScalar(e,e.dump,t,u)}}else{if(e.skipInvalid)return false;throw new n("unacceptable kind of an object to dump "+o)}if(e.tag!==null&&e.tag!=="?"){e.dump="!<"+e.tag+"> "+e.dump}}return true}function getDuplicateReferences(e,t){var r=[],i=[],n,a;inspectNode(e,r,i);for(n=0,a=i.length;n=e.length){if(t)t[u]=e;return r(null,e)}o.lastIndex=c;var i=o.exec(e);v=h;h+=i[0];p=v+i[1];c=o.lastIndex;if(f[p]||t&&t[p]===p){return process.nextTick(LOOP)}if(t&&Object.prototype.hasOwnProperty.call(t,p)){return gotResolvedLink(t[p])}return a.lstat(p,gotStat)}function gotStat(e,i){if(e)return r(e);if(!i.isSymbolicLink()){f[p]=true;if(t)t[p]=p;return process.nextTick(LOOP)}if(!n){var u=i.dev.toString(32)+":"+i.ino.toString(32);if(s.hasOwnProperty(u)){return gotTarget(null,s[u],p)}}a.stat(p,function(e){if(e)return r(e);a.readlink(p,function(e,t){if(!n)s[u]=t;gotTarget(e,t)})})}function gotTarget(e,n,a){if(e)return r(e);var u=i.resolve(v,n);if(t)t[a]=u;gotResolvedLink(u)}function gotResolvedLink(t){e=i.resolve(t,e.slice(c));start()}}},,function(e){e.exports=[{long:"help",description:"output usage information",short:"h",type:"boolean",default:false},{long:"version",description:"output version number",short:"v",type:"boolean",default:false},{long:"output",description:"specify output location",short:"o",value:"[path]"},{long:"rc-path",description:"specify configuration file",short:"r",type:"string",value:""},{long:"ignore-path",description:"specify ignore file",short:"i",type:"string",value:""},{long:"setting",description:"specify settings",short:"s",type:"string",value:""},{long:"ext",description:"specify extensions",short:"e",type:"string",value:""},{long:"use",description:"use plugins",short:"u",type:"string",value:""},{long:"watch",description:"watch for changes and reprocess",short:"w",type:"boolean",default:false},{long:"quiet",description:"output only warnings and errors",short:"q",type:"boolean",default:false},{long:"silent",description:"output only errors",short:"S",type:"boolean",default:false},{long:"frail",description:"exit with 1 on warnings",short:"f",type:"boolean",default:false},{long:"tree",description:"specify input and output as syntax tree",short:"t",type:"boolean",default:false},{long:"report",description:"specify reporter",type:"string",value:""},{long:"file-path",description:"specify path to process as",type:"string",value:""},{long:"tree-in",description:"specify input as syntax tree",type:"boolean"},{long:"tree-out",description:"output syntax tree",type:"boolean"},{long:"inspect",description:"output formatted syntax tree",type:"boolean"},{long:"stdout",description:"specify writing to stdout",type:"boolean",truelike:true},{long:"color",description:"specify color in report",type:"boolean",default:true},{long:"config",description:"search for configuration files",type:"boolean",default:true},{long:"ignore",description:"search for ignore files",type:"boolean",default:true}]},,,,function(e,t,r){"use strict";var i=r(495);var n=r(682);var a=r(839);var u=r(526);e.exports=i("remark-lint:hard-break-spaces",hardBreakSpaces);var s="Use two spaces for hard line breaks";function hardBreakSpaces(e,t){var r=String(t);n(e,"break",visitor);function visitor(e){var i;if(!u(e)){i=r.slice(a.start(e).offset,a.end(e).offset).split("\n",1)[0].replace(/\r$/,"");if(i.length>2){t.message(s,e)}}}}},,,,function(e,t,r){"use strict";var i=r(171);e.exports=table;var n="\t";var a="\n";var u=" ";var s="-";var o=":";var l="\\";var f="`";var c="|";var h=1;var p=2;var v="left";var d="center";var D="right";function table(e,t,r){var m=this;var g;var E;var A;var C;var y;var w;var x;var b;var F;var S;var B;var k;var O;var P;var T;var I;var M;var L;var R;var j;var U;var N;var J;var z;if(!m.options.gfm){return}g=0;L=0;w=t.length+1;x=[];while(gN){if(L1){if(F){C+=b.slice(0,b.length-1);b=b.charAt(b.length-1)}else{C+=b;b=""}}I=e.now();e(C)({type:"tableCell",children:m.tokenizeInline(k,I)},y)}e(b+F);b="";k=""}}else{if(b){k+=b;b=""}k+=F;if(F===l&&g!==w-2){k+=R.charAt(g+1);g++}if(F===f){P=1;while(R.charAt(g+1)===F){k+=F;g++;P++}if(!T){T=P}else if(P>=T){T=0}}}O=false;g++}if(!M){e(a+E)}}return U}},function(e,t,r){"use strict";var i=r(211);function resolveJavascriptRegExp(e){if(e===null)return false;if(e.length===0)return false;var t=e,r=/\/([gim]*)$/.exec(e),i="";if(t[0]==="/"){if(r)i=r[1];if(i.length>3)return false;if(t[t.length-i.length-1]!=="/")return false}return true}function constructJavascriptRegExp(e){var t=e,r=/\/([gim]*)$/.exec(e),i="";if(t[0]==="/"){if(r)i=r[1];t=t.slice(1,t.length-i.length-1)}return new RegExp(t,i)}function representJavascriptRegExp(e){var t="/"+e.source+"/";if(e.global)t+="g";if(e.multiline)t+="m";if(e.ignoreCase)t+="i";return t}function isRegExp(e){return Object.prototype.toString.call(e)==="[object RegExp]"}e.exports=new i("tag:yaml.org,2002:js/regexp",{kind:"scalar",resolve:resolveJavascriptRegExp,construct:constructJavascriptRegExp,predicate:isRegExp,represent:representJavascriptRegExp})},,,,,function(e,t,r){"use strict";e.exports.plugins=[r(889),r(767),r(850),[r(890),"tab-size"],r(223),r(127),r(701),[r(382),"."],r(550),r(816),r(33),r(9),r(121),r(476),r(280),r(842)]},,,,function(e){"use strict";e.exports=markdownTable;var t=/\./;var r=/\.[^.]*$/;var i="l";var n="r";var a="c";var u=".";var s="";var o=[i,n,a,u,s];var l=3;var f=":";var c="-";var h="|";var p=" ";var v="\n";function markdownTable(e,r){var d=r||{};var D=d.delimiter;var m=d.start;var g=d.end;var E=d.align;var A=d.stringLength||lengthNoop;var C=0;var y=-1;var w=e.length;var x=[];var b;var F;var S;var B;var k;var O;var P;var T;var I;var M;var L;var R;E=E?E.concat():[];if(D===null||D===undefined){D=p+h+p}if(m===null||m===undefined){m=h+p}if(g===null||g===undefined){g=p+h}while(++yC){C=B.length}while(++Ox[O]){x[O]=P}}}if(typeof E==="string"){E=pad(C,E).split("")}O=-1;while(++Ox[O]){x[O]=T}}}y=-1;while(++yl?M:l}else{M=x[O]}b=E[O];I=b===n||b===s?c:f;I+=pad(M-2,c);I+=b!==i&&b!==s?f:c;F[O]=I}S.splice(1,0,F.join(D))}return m+S.join(g+v+m)+g}function stringify(e){return e===null||e===undefined?"":String(e)}function lengthNoop(e){return String(e).length}function pad(e,t){return new Array(e+1).join(t||p)}function dotindex(e){var t=r.exec(e);return t?t.index+1:e.length}},,,,,function(e,t,r){e.exports=r(688)},,,,,function(e,t,r){"use strict";var i=r(12);e.exports=Writable;function WriteReq(e,t,r){this.chunk=e;this.encoding=t;this.callback=r;this.next=null}function CorkedRequest(e){var t=this;this.next=null;this.entry=null;this.finish=function(){onCorkedFinish(t,e)}}var n=!process.browser&&["v0.10","v0.9."].indexOf(process.version.slice(0,5))>-1?setImmediate:i.nextTick;var a;Writable.WritableState=WritableState;var u=r(683);u.inherits=r(780);var s={deprecate:r(507)};var o=r(569);var l=r(945).Buffer;var f=global.Uint8Array||function(){};function _uint8ArrayToBuffer(e){return l.from(e)}function _isUint8Array(e){return l.isBuffer(e)||e instanceof f}var c=r(972);u.inherits(Writable,o);function nop(){}function WritableState(e,t){a=a||r(98);e=e||{};var i=t instanceof a;this.objectMode=!!e.objectMode;if(i)this.objectMode=this.objectMode||!!e.writableObjectMode;var n=e.highWaterMark;var u=e.writableHighWaterMark;var s=this.objectMode?16:16*1024;if(n||n===0)this.highWaterMark=n;else if(i&&(u||u===0))this.highWaterMark=u;else this.highWaterMark=s;this.highWaterMark=Math.floor(this.highWaterMark);this.finalCalled=false;this.needDrain=false;this.ending=false;this.ended=false;this.finished=false;this.destroyed=false;var o=e.decodeStrings===false;this.decodeStrings=!o;this.defaultEncoding=e.defaultEncoding||"utf8";this.length=0;this.writing=false;this.corked=0;this.sync=true;this.bufferProcessing=false;this.onwrite=function(e){onwrite(t,e)};this.writecb=null;this.writelen=0;this.bufferedRequest=null;this.lastBufferedRequest=null;this.pendingcb=0;this.prefinished=false;this.errorEmitted=false;this.bufferedRequestCount=0;this.corkedRequestsFree=new CorkedRequest(this)}WritableState.prototype.getBuffer=function getBuffer(){var e=this.bufferedRequest;var t=[];while(e){t.push(e);e=e.next}return t};(function(){try{Object.defineProperty(WritableState.prototype,"buffer",{get:s.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer "+"instead.","DEP0003")})}catch(e){}})();var h;if(typeof Symbol==="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]==="function"){h=Function.prototype[Symbol.hasInstance];Object.defineProperty(Writable,Symbol.hasInstance,{value:function(e){if(h.call(this,e))return true;if(this!==Writable)return false;return e&&e._writableState instanceof WritableState}})}else{h=function(e){return e instanceof this}}function Writable(e){a=a||r(98);if(!h.call(Writable,this)&&!(this instanceof a)){return new Writable(e)}this._writableState=new WritableState(e,this);this.writable=true;if(e){if(typeof e.write==="function")this._write=e.write;if(typeof e.writev==="function")this._writev=e.writev;if(typeof e.destroy==="function")this._destroy=e.destroy;if(typeof e.final==="function")this._final=e.final}o.call(this)}Writable.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))};function writeAfterEnd(e,t){var r=new Error("write after end");e.emit("error",r);i.nextTick(t,r)}function validChunk(e,t,r,n){var a=true;var u=false;if(r===null){u=new TypeError("May not write null values to stream")}else if(typeof r!=="string"&&r!==undefined&&!t.objectMode){u=new TypeError("Invalid non-string/buffer chunk")}if(u){e.emit("error",u);i.nextTick(n,u);a=false}return a}Writable.prototype.write=function(e,t,r){var i=this._writableState;var n=false;var a=!i.objectMode&&_isUint8Array(e);if(a&&!l.isBuffer(e)){e=_uint8ArrayToBuffer(e)}if(typeof t==="function"){r=t;t=null}if(a)t="buffer";else if(!t)t=i.defaultEncoding;if(typeof r!=="function")r=nop;if(i.ended)writeAfterEnd(this,r);else if(a||validChunk(this,i,e,r)){i.pendingcb++;n=writeOrBuffer(this,i,a,e,t,r)}return n};Writable.prototype.cork=function(){var e=this._writableState;e.corked++};Writable.prototype.uncork=function(){var e=this._writableState;if(e.corked){e.corked--;if(!e.writing&&!e.corked&&!e.finished&&!e.bufferProcessing&&e.bufferedRequest)clearBuffer(this,e)}};Writable.prototype.setDefaultEncoding=function setDefaultEncoding(e){if(typeof e==="string")e=e.toLowerCase();if(!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+e);this._writableState.defaultEncoding=e;return this};function decodeChunk(e,t,r){if(!e.objectMode&&e.decodeStrings!==false&&typeof t==="string"){t=l.from(t,r)}return t}Object.defineProperty(Writable.prototype,"writableHighWaterMark",{enumerable:false,get:function(){return this._writableState.highWaterMark}});function writeOrBuffer(e,t,r,i,n,a){if(!r){var u=decodeChunk(t,i,n);if(i!==u){r=true;n="buffer";i=u}}var s=t.objectMode?1:i.length;t.length+=s;var o=t.length=b){b=0}}else if(E===v){g++;B+=t.charAt(g)}else if((!b||y)&&E===p){L++}else if((!b||y)&&E===d){if(L){L--}else{if(!A){while(gn){return false}}return check(e,i,r)&&check(e,m)}function isKnown(e,t,r){var i=o?o.indexOf(e)!==-1:true;if(!i){h.warn("Unknown rule: cannot "+t+" `'"+e+"'`",r)}return i}function getState(e){var t=e?D[e]:m;if(t&&t.length!==0){return t[t.length-1].state}if(!e){return!l}if(l){return f.indexOf(e)!==-1}return c.indexOf(e)===-1}function toggle(e,t,r){var i=r?D[r]:m;var n;var a;if(!i){i=[];D[r]=i}a=getState(r);n=t;if(n!==a){i.push({state:n,position:e})}if(!r){for(r in D){toggle(e,t,r)}}}function check(e,t,r){var i=t&&t.length;var n=-1;var a;while(--i>n){a=t[i];if(!a.position||!a.position.line||!a.position.column){continue}if(a.position.line=e){return}if(u){s.push({start:n,end:e});u=false}n=e}}},,function(e){"use strict";e.exports=orderedItems;var t="\n";var r=".";var i=t+t;function orderedItems(e){var n=this;var a=n.visitors.listItem;var u=n.options.incrementListMarker;var s=[];var o=e.start;var l=e.children;var f=l.length;var c=-1;var h;o=o==null?1:o;while(++c1;var p=c;var v=t.path;if(!u(p)){a("Not copying");return i()}p=l(e.cwd,p);a("Copying `%s`",v);s(p,onstatfile);function onstatfile(e,t){if(e){if(e.code!=="ENOENT"||c.charAt(c.length-1)===n.sep){return i(new Error("Cannot read output directory. Error:\n"+e.message))}s(o(p),onstatparent)}else{done(t.isDirectory())}}function onstatparent(e){if(e){i(new Error("Cannot read parent directory. Error:\n"+e.message))}else{done(false)}}function done(e){if(!e&&h){return i(new Error("Cannot write multiple files to single output: "+p))}t[e?"dirname":"path"]=f(t.cwd,p);a("Copying document from %s to %s",v,t.path);i()}}},function(e,t){"use strict";var r="[a-zA-Z_:][a-zA-Z0-9:._-]*";var i="[^\"'=<>`\\u0000-\\u0020]+";var n="'[^']*'";var a='"[^"]*"';var u="(?:"+i+"|"+n+"|"+a+")";var s="(?:\\s+"+r+"(?:\\s*=\\s*"+u+")?)";var o="<[A-Za-z][A-Za-z0-9\\-]*"+s+"*\\s*\\/?>";var l="<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>";var f="\x3c!----\x3e|\x3c!--(?:-?[^>-])(?:-?[^-])*--\x3e";var c="<[?].*?[?]>";var h="]*>";var p="";t.openCloseTag=new RegExp("^(?:"+o+"|"+l+")");t.tag=new RegExp("^(?:"+o+"|"+l+"|"+f+"|"+c+"|"+h+"|"+p+")")},,function(e){e.exports=require("path")},,,,function(e,t,r){"use strict";var i=r(36);var n=r(171);var a=r(511);e.exports=strong;strong.locator=a;var u="\\";var s="*";var o="_";function strong(e,t,r){var a=this;var l=0;var f=t.charAt(l);var c;var h;var p;var v;var d;var D;var m;if(f!==s&&f!==o||t.charAt(++l)!==f){return}h=a.options.pedantic;p=f;d=p+p;D=t.length;l++;v="";f="";if(h&&n(t.charAt(l))){return}while(l0){return parse(e)}else if(r==="number"&&isNaN(e)===false){return t.long?fmtLong(e):fmtShort(e)}throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function parse(e){e=String(e);if(e.length>100){return}var s=/^((?:\d+)?\-?\d?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!s){return}var o=parseFloat(s[1]);var l=(s[2]||"ms").toLowerCase();switch(l){case"years":case"year":case"yrs":case"yr":case"y":return o*u;case"weeks":case"week":case"w":return o*a;case"days":case"day":case"d":return o*n;case"hours":case"hour":case"hrs":case"hr":case"h":return o*i;case"minutes":case"minute":case"mins":case"min":case"m":return o*r;case"seconds":case"second":case"secs":case"sec":case"s":return o*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return o;default:return undefined}}function fmtShort(e){var a=Math.abs(e);if(a>=n){return Math.round(e/n)+"d"}if(a>=i){return Math.round(e/i)+"h"}if(a>=r){return Math.round(e/r)+"m"}if(a>=t){return Math.round(e/t)+"s"}return e+"ms"}function fmtLong(e){var a=Math.abs(e);if(a>=n){return plural(e,a,n,"day")}if(a>=i){return plural(e,a,i,"hour")}if(a>=r){return plural(e,a,r,"minute")}if(a>=t){return plural(e,a,t,"second")}return e+" ms"}function plural(e,t,r,i){var n=t>=r*1.5;return Math.round(e/r)+" "+i+(n?"s":"")}},function(e,t){t.parse=t.decode=decode;t.stringify=t.encode=encode;t.safe=safe;t.unsafe=unsafe;var r=typeof process!=="undefined"&&process.platform==="win32"?"\r\n":"\n";function encode(e,t){var i=[];var n="";if(typeof t==="string"){t={section:t,whitespace:false}}else{t=t||{};t.whitespace=t.whitespace===true}var a=t.whitespace?" = ":"=";Object.keys(e).forEach(function(t,u,s){var o=e[t];if(o&&Array.isArray(o)){o.forEach(function(e){n+=safe(t+"[]")+a+safe(e)+"\n"})}else if(o&&typeof o==="object"){i.push(t)}else{n+=safe(t)+a+safe(o)+r}});if(t.section&&n.length){n="["+safe(t.section)+"]"+r+n}i.forEach(function(i,a,u){var s=dotSplit(i).join("\\.");var o=(t.section?t.section+".":"")+s;var l=encode(e[i],{section:o,whitespace:t.whitespace});if(n.length&&l.length){n+=r}n+=l});return n}function dotSplit(e){return e.replace(/\1/g,"LITERAL\\1LITERAL").replace(/\\\./g,"").split(/\./).map(function(e){return e.replace(/\1/g,"\\.").replace(/\2LITERAL\\1LITERAL\2/g,"")})}function decode(e){var t={};var r=t;var i=null;var n=/^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i;var a=e.split(/[\r\n]+/g);a.forEach(function(e,a,u){if(!e||e.match(/^\s*[;#]/))return;var s=e.match(n);if(!s)return;if(s[1]!==undefined){i=unsafe(s[1]);r=t[i]=t[i]||{};return}var o=unsafe(s[2]);var l=s[3]?unsafe(s[4]):true;switch(l){case"true":case"false":case"null":l=JSON.parse(l)}if(o.length>2&&o.slice(-2)==="[]"){o=o.substring(0,o.length-2);if(!r[o]){r[o]=[]}else if(!Array.isArray(r[o])){r[o]=[r[o]]}}if(Array.isArray(r[o])){r[o].push(l)}else{r[o]=l}});Object.keys(t).filter(function(e,r,i){if(!t[e]||typeof t[e]!=="object"||Array.isArray(t[e])){return false}var n=dotSplit(e);var a=t;var u=n.pop();var s=u.replace(/\\\./g,".");n.forEach(function(e,t,r){if(!a[e]||typeof a[e]!=="object")a[e]={};a=a[e]});if(a===t&&s===u){return false}a[s]=t[e];return true}).forEach(function(e,r,i){delete t[e]});return t}function isQuoted(e){return e.charAt(0)==='"'&&e.slice(-1)==='"'||e.charAt(0)==="'"&&e.slice(-1)==="'"}function safe(e){return typeof e!=="string"||e.match(/[=\r\n]/)||e.match(/^\[/)||e.length>1&&isQuoted(e)||e!==e.trim()?JSON.stringify(e):e.replace(/;/g,"\\;").replace(/#/g,"\\#")}function unsafe(e,t){e=(e||"").trim();if(isQuoted(e)){if(e.charAt(0)==="'"){e=e.substr(1,e.length-2)}try{e=JSON.parse(e)}catch(e){}}else{var r=false;var i="";for(var n=0,a=e.length;n="a"&&e<="z"||e>="A"&&e<="Z"||e==="$"||e==="_"||i.ID_Start.test(e)},isIdContinueChar(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e>="0"&&e<="9"||e==="$"||e==="_"||e==="‌"||e==="‍"||i.ID_Continue.test(e)},isDigit(e){return/[0-9]/.test(e)},isHexDigit(e){return/[0-9A-Fa-f]/.test(e)}}},,function(e){"use strict";e.exports=(e=>{if(Number.isNaN(e)){return false}if(e>=4352&&(e<=4447||e===9001||e===9002||11904<=e&&e<=12871&&e!==12351||12880<=e&&e<=19903||19968<=e&&e<=42182||43360<=e&&e<=43388||44032<=e&&e<=55203||63744<=e&&e<=64255||65040<=e&&e<=65049||65072<=e&&e<=65131||65281<=e&&e<=65376||65504<=e&&e<=65510||110592<=e&&e<=110593||127488<=e&&e<=127569||131072<=e&&e<=262141)){return true}return false})},,,,,,,,,function(e,t,r){"use strict";e.exports.plugins=[r(889),r(560),[r(166),2],[r(112),{checked:"x",unchecked:" "}],r(424),[r(301),"fenced"],r(896),r(137),[r(386),"`"],[r(451),"md"],r(339),[r(284),1],[r(675),"atx"],[r(890),"space"],r(164),r(846),r(667),r(380),r(911),r(758),[r(701),false],r(273),r(926),r(55),r(72),r(522),[r(455),[{no:"End-Of-Life",yes:"End-of-Life"},{no:"End-of-life",yes:"End-of-Life"},{no:"Github",yes:"GitHub"},{no:"Javascript",yes:"JavaScript"},{no:"Node.JS",yes:"Node.js"},{no:"Note that",yes:""},{no:"note that",yes:""},{no:"Rfc",yes:"RFC"},{no:"[Rr][Ff][Cc]\\d+",yes:"RFC "},{no:"rfc",yes:"RFC"},{no:"UNIX",yes:"Unix"},{no:"unix",yes:"Unix"},{no:"v8",yes:"V8"}]],r(467),[r(108),"*"],[r(435),"padded"],r(314),[r(4),"*"]]},,function(e){e.exports=["cent","copy","divide","gt","lt","not","para","times"]},,function(e,t,r){"use strict";e.exports=r(447)},function(e,t,r){e.exports=minimatch;minimatch.Minimatch=Minimatch;var i={sep:"/"};try{i=r(589)}catch(e){}var n=minimatch.GLOBSTAR=Minimatch.GLOBSTAR={};var a=r(348);var u={"!":{open:"(?:(?!(?:",close:"))[^/]*?)"},"?":{open:"(?:",close:")?"},"+":{open:"(?:",close:")+"},"*":{open:"(?:",close:")*"},"@":{open:"(?:",close:")"}};var s="[^/]";var o=s+"*?";var l="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";var f="(?:(?!(?:\\/|^)\\.).)*?";var c=charSet("().*{}+?[]^$\\!");function charSet(e){return e.split("").reduce(function(e,t){e[t]=true;return e},{})}var h=/\/+/;minimatch.filter=filter;function filter(e,t){t=t||{};return function(r,i,n){return minimatch(r,e,t)}}function ext(e,t){e=e||{};t=t||{};var r={};Object.keys(t).forEach(function(e){r[e]=t[e]});Object.keys(e).forEach(function(t){r[t]=e[t]});return r}minimatch.defaults=function(e){if(!e||!Object.keys(e).length)return minimatch;var t=minimatch;var r=function minimatch(r,i,n){return t.minimatch(r,i,ext(e,n))};r.Minimatch=function Minimatch(r,i){return new t.Minimatch(r,ext(e,i))};return r};Minimatch.defaults=function(e){if(!e||!Object.keys(e).length)return Minimatch;return minimatch.defaults(e).Minimatch};function minimatch(e,t,r){if(typeof t!=="string"){throw new TypeError("glob pattern string required")}if(!r)r={};if(!r.nocomment&&t.charAt(0)==="#"){return false}if(t.trim()==="")return e==="";return new Minimatch(t,r).match(e)}function Minimatch(e,t){if(!(this instanceof Minimatch)){return new Minimatch(e,t)}if(typeof e!=="string"){throw new TypeError("glob pattern string required")}if(!t)t={};e=e.trim();if(i.sep!=="/"){e=e.split(i.sep).join("/")}this.options=t;this.set=[];this.pattern=e;this.regexp=null;this.negate=false;this.comment=false;this.empty=false;this.make()}Minimatch.prototype.debug=function(){};Minimatch.prototype.make=make;function make(){if(this._made)return;var e=this.pattern;var t=this.options;if(!t.nocomment&&e.charAt(0)==="#"){this.comment=true;return}if(!e){this.empty=true;return}this.parseNegate();var r=this.globSet=this.braceExpand();if(t.debug)this.debug=console.error;this.debug(this.pattern,r);r=this.globParts=r.map(function(e){return e.split(h)});this.debug(this.pattern,r);r=r.map(function(e,t,r){return e.map(this.parse,this)},this);this.debug(this.pattern,r);r=r.filter(function(e){return e.indexOf(false)===-1});this.debug(this.pattern,r);this.set=r}Minimatch.prototype.parseNegate=parseNegate;function parseNegate(){var e=this.pattern;var t=false;var r=this.options;var i=0;if(r.nonegate)return;for(var n=0,a=e.length;n1024*64){throw new TypeError("pattern is too long")}var r=this.options;if(!r.noglobstar&&e==="**")return n;if(e==="")return"";var i="";var a=!!r.nocase;var l=false;var f=[];var h=[];var v;var d=false;var D=-1;var m=-1;var g=e.charAt(0)==="."?"":r.dot?"(?!(?:^|\\/)\\.{1,2}(?:$|\\/))":"(?!\\.)";var E=this;function clearStateChar(){if(v){switch(v){case"*":i+=o;a=true;break;case"?":i+=s;a=true;break;default:i+="\\"+v;break}E.debug("clearStateChar %j %j",v,i);v=false}}for(var A=0,C=e.length,y;A-1;k--){var O=h[k];var P=i.slice(0,O.reStart);var T=i.slice(O.reStart,O.reEnd-8);var I=i.slice(O.reEnd-8,O.reEnd);var M=i.slice(O.reEnd);I+=M;var L=P.split("(").length-1;var R=M;for(A=0;A=0;u--){a=e[u];if(a)break}for(u=0;u>> no match, partial?",e,c,t,h);if(c===s)return true}return false}var v;if(typeof l==="string"){if(i.nocase){v=f.toLowerCase()===l.toLowerCase()}else{v=f===l}this.debug("string match",l,f,v)}else{v=f.match(l);this.debug("pattern match",l,f,v)}if(!v)return false}if(a===s&&u===o){return true}else if(a===s){return r}else if(u===o){var d=a===s-1&&e[a]==="";return d}throw new Error("wtf?")};function globUnescape(e){return e.replace(/\\(.)/g,"$1")}function regExpEscape(e){return e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}},,,function(e){"use strict";e.exports=function(e){if(typeof e!=="function"){throw new TypeError("Expected a function")}return e.displayName||e.name||(/function ([^\(]+)?\(/.exec(e.toString())||[])[1]||null}},function(e){"use strict";e.exports=(()=>{const e=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"].join("|");return new RegExp(e,"g")})},,,function(e,t,r){"use strict";var i=r(304);var n=r(948);e.exports=fileSystem;function fileSystem(e,t,r){var a=e.files;if(a.length===0){r()}else{n(a,{cwd:t.cwd,extensions:t.extensions,silentlyIgnore:t.silentlyIgnore,ignore:new i({cwd:t.cwd,detectIgnore:t.detectIgnore,ignoreName:t.ignoreName,ignorePath:t.ignorePath})},onfound)}function onfound(i,n){var a=n.files;a.sort(sortAlphabetically);a.forEach(markAsGiven);e.files=a;if(t.out===null||t.out===undefined){t.out=n.oneFileMode}r(i)}function markAsGiven(e){e.data.unifiedEngineGiven=true}function sortAlphabetically(e,t){return e.pathi){i=r}}else{r=1}n=a+1;a=e.indexOf(t,n)}return i}},function(e,t,r){"use strict";var i=r(347)("unified-engine:file-pipeline:stdout");var n=r(928);e.exports=stdout;function stdout(e,t,r,a){if(!t.data.unifiedEngineGiven){i("Ignoring programmatically added file");a()}else if(n(t).fatal||e.output||!e.out){i("Ignoring writing to `streamOut`");a()}else{i("Writing document to `streamOut`");e.streamOut.write(t.toString(),a)}}},,,function(e,t,r){"use strict";var i=r(56);var n=r(503);e.exports=toVFile;function toVFile(e){if(typeof e==="string"||i(e)){e={path:String(e)}}return n(e)}},,,,function(e){(function webpackUniversalModuleDefinition(t,r){if(true)e.exports=r();else{}})(this,function(){return function(e){var t={};function __webpack_require__(r){if(t[r])return t[r].exports;var i=t[r]={exports:{},id:r,loaded:false};e[r].call(i.exports,i,i.exports,__webpack_require__);i.loaded=true;return i.exports}__webpack_require__.m=e;__webpack_require__.c=t;__webpack_require__.p="";return __webpack_require__(0)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:true});var i=r(1);var n=r(3);var a=r(8);var u=r(15);function parse(e,t,r){var u=null;var s=function(e,t){if(r){r(e,t)}if(u){u.visit(e,t)}};var o=typeof r==="function"?s:null;var l=false;if(t){l=typeof t.comment==="boolean"&&t.comment;var f=typeof t.attachComment==="boolean"&&t.attachComment;if(l||f){u=new i.CommentHandler;u.attach=f;t.comment=true;o=s}}var c=false;if(t&&typeof t.sourceType==="string"){c=t.sourceType==="module"}var h;if(t&&typeof t.jsx==="boolean"&&t.jsx){h=new n.JSXParser(e,t,o)}else{h=new a.Parser(e,t,o)}var p=c?h.parseModule():h.parseScript();var v=p;if(l&&u){v.comments=u.comments}if(h.config.tokens){v.tokens=h.tokens}if(h.config.tolerant){v.errors=h.errorHandler.errors}return v}t.parse=parse;function parseModule(e,t,r){var i=t||{};i.sourceType="module";return parse(e,i,r)}t.parseModule=parseModule;function parseScript(e,t,r){var i=t||{};i.sourceType="script";return parse(e,i,r)}t.parseScript=parseScript;function tokenize(e,t,r){var i=new u.Tokenizer(e,t);var n;n=[];try{while(true){var a=i.getNextToken();if(!a){break}if(r){a=r(a)}n.push(a)}}catch(e){i.errorHandler.tolerate(e)}if(i.errorHandler.tolerant){n.errors=i.errors()}return n}t.tokenize=tokenize;var s=r(2);t.Syntax=s.Syntax;t.version="4.0.1"},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:true});var i=r(2);var n=function(){function CommentHandler(){this.attach=false;this.comments=[];this.stack=[];this.leading=[];this.trailing=[]}CommentHandler.prototype.insertInnerComments=function(e,t){if(e.type===i.Syntax.BlockStatement&&e.body.length===0){var r=[];for(var n=this.leading.length-1;n>=0;--n){var a=this.leading[n];if(t.end.offset>=a.start){r.unshift(a.comment);this.leading.splice(n,1);this.trailing.splice(n,1)}}if(r.length){e.innerComments=r}}};CommentHandler.prototype.findTrailingComments=function(e){var t=[];if(this.trailing.length>0){for(var r=this.trailing.length-1;r>=0;--r){var i=this.trailing[r];if(i.start>=e.end.offset){t.unshift(i.comment)}}this.trailing.length=0;return t}var n=this.stack[this.stack.length-1];if(n&&n.node.trailingComments){var a=n.node.trailingComments[0];if(a&&a.range[0]>=e.end.offset){t=n.node.trailingComments;delete n.node.trailingComments}}return t};CommentHandler.prototype.findLeadingComments=function(e){var t=[];var r;while(this.stack.length>0){var i=this.stack[this.stack.length-1];if(i&&i.start>=e.start.offset){r=i.node;this.stack.pop()}else{break}}if(r){var n=r.leadingComments?r.leadingComments.length:0;for(var a=n-1;a>=0;--a){var u=r.leadingComments[a];if(u.range[1]<=e.start.offset){t.unshift(u);r.leadingComments.splice(a,1)}}if(r.leadingComments&&r.leadingComments.length===0){delete r.leadingComments}return t}for(var a=this.leading.length-1;a>=0;--a){var i=this.leading[a];if(i.start<=e.start.offset){t.unshift(i.comment);this.leading.splice(a,1)}}return t};CommentHandler.prototype.visitNode=function(e,t){if(e.type===i.Syntax.Program&&e.body.length>0){return}this.insertInnerComments(e,t);var r=this.findTrailingComments(t);var n=this.findLeadingComments(t);if(n.length>0){e.leadingComments=n}if(r.length>0){e.trailingComments=r}this.stack.push({node:e,start:t.start.offset})};CommentHandler.prototype.visitComment=function(e,t){var r=e.type[0]==="L"?"Line":"Block";var i={type:r,value:e.value};if(e.range){i.range=e.range}if(e.loc){i.loc=e.loc}this.comments.push(i);if(this.attach){var n={comment:{type:r,value:e.value,range:[t.start.offset,t.end.offset]},start:t.start.offset};if(e.loc){n.comment.loc=e.loc}e.type=r;this.leading.push(n);this.trailing.push(n)}};CommentHandler.prototype.visit=function(e,t){if(e.type==="LineComment"){this.visitComment(e,t)}else if(e.type==="BlockComment"){this.visitComment(e,t)}else if(this.attach){this.visitNode(e,t)}};return CommentHandler}();t.CommentHandler=n},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.Syntax={AssignmentExpression:"AssignmentExpression",AssignmentPattern:"AssignmentPattern",ArrayExpression:"ArrayExpression",ArrayPattern:"ArrayPattern",ArrowFunctionExpression:"ArrowFunctionExpression",AwaitExpression:"AwaitExpression",BlockStatement:"BlockStatement",BinaryExpression:"BinaryExpression",BreakStatement:"BreakStatement",CallExpression:"CallExpression",CatchClause:"CatchClause",ClassBody:"ClassBody",ClassDeclaration:"ClassDeclaration",ClassExpression:"ClassExpression",ConditionalExpression:"ConditionalExpression",ContinueStatement:"ContinueStatement",DoWhileStatement:"DoWhileStatement",DebuggerStatement:"DebuggerStatement",EmptyStatement:"EmptyStatement",ExportAllDeclaration:"ExportAllDeclaration",ExportDefaultDeclaration:"ExportDefaultDeclaration",ExportNamedDeclaration:"ExportNamedDeclaration",ExportSpecifier:"ExportSpecifier",ExpressionStatement:"ExpressionStatement",ForStatement:"ForStatement",ForOfStatement:"ForOfStatement",ForInStatement:"ForInStatement",FunctionDeclaration:"FunctionDeclaration",FunctionExpression:"FunctionExpression",Identifier:"Identifier",IfStatement:"IfStatement",ImportDeclaration:"ImportDeclaration",ImportDefaultSpecifier:"ImportDefaultSpecifier",ImportNamespaceSpecifier:"ImportNamespaceSpecifier",ImportSpecifier:"ImportSpecifier",Literal:"Literal",LabeledStatement:"LabeledStatement",LogicalExpression:"LogicalExpression",MemberExpression:"MemberExpression",MetaProperty:"MetaProperty",MethodDefinition:"MethodDefinition",NewExpression:"NewExpression",ObjectExpression:"ObjectExpression",ObjectPattern:"ObjectPattern",Program:"Program",Property:"Property",RestElement:"RestElement",ReturnStatement:"ReturnStatement",SequenceExpression:"SequenceExpression",SpreadElement:"SpreadElement",Super:"Super",SwitchCase:"SwitchCase",SwitchStatement:"SwitchStatement",TaggedTemplateExpression:"TaggedTemplateExpression",TemplateElement:"TemplateElement",TemplateLiteral:"TemplateLiteral",ThisExpression:"ThisExpression",ThrowStatement:"ThrowStatement",TryStatement:"TryStatement",UnaryExpression:"UnaryExpression",UpdateExpression:"UpdateExpression",VariableDeclaration:"VariableDeclaration",VariableDeclarator:"VariableDeclarator",WhileStatement:"WhileStatement",WithStatement:"WithStatement",YieldExpression:"YieldExpression"}},function(e,t,r){"use strict";var i=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)if(t.hasOwnProperty(r))e[r]=t[r]};return function(t,r){e(t,r);function __(){this.constructor=t}t.prototype=r===null?Object.create(r):(__.prototype=r.prototype,new __)}}();Object.defineProperty(t,"__esModule",{value:true});var n=r(4);var a=r(5);var u=r(6);var s=r(7);var o=r(8);var l=r(13);var f=r(14);l.TokenName[100]="JSXIdentifier";l.TokenName[101]="JSXText";function getQualifiedElementName(e){var t;switch(e.type){case u.JSXSyntax.JSXIdentifier:var r=e;t=r.name;break;case u.JSXSyntax.JSXNamespacedName:var i=e;t=getQualifiedElementName(i.namespace)+":"+getQualifiedElementName(i.name);break;case u.JSXSyntax.JSXMemberExpression:var n=e;t=getQualifiedElementName(n.object)+"."+getQualifiedElementName(n.property);break;default:break}return t}var c=function(e){i(JSXParser,e);function JSXParser(t,r,i){return e.call(this,t,r,i)||this}JSXParser.prototype.parsePrimaryExpression=function(){return this.match("<")?this.parseJSXRoot():e.prototype.parsePrimaryExpression.call(this)};JSXParser.prototype.startJSX=function(){this.scanner.index=this.startMarker.index;this.scanner.lineNumber=this.startMarker.line;this.scanner.lineStart=this.startMarker.index-this.startMarker.column};JSXParser.prototype.finishJSX=function(){this.nextToken()};JSXParser.prototype.reenterJSX=function(){this.startJSX();this.expectJSX("}");if(this.config.tokens){this.tokens.pop()}};JSXParser.prototype.createJSXNode=function(){this.collectComments();return{index:this.scanner.index,line:this.scanner.lineNumber,column:this.scanner.index-this.scanner.lineStart}};JSXParser.prototype.createJSXChildNode=function(){return{index:this.scanner.index,line:this.scanner.lineNumber,column:this.scanner.index-this.scanner.lineStart}};JSXParser.prototype.scanXHTMLEntity=function(e){var t="&";var r=true;var i=false;var a=false;var u=false;while(!this.scanner.eof()&&r&&!i){var s=this.scanner.source[this.scanner.index];if(s===e){break}i=s===";";t+=s;++this.scanner.index;if(!i){switch(t.length){case 2:a=s==="#";break;case 3:if(a){u=s==="x";r=u||n.Character.isDecimalDigit(s.charCodeAt(0));a=a&&!u}break;default:r=r&&!(a&&!n.Character.isDecimalDigit(s.charCodeAt(0)));r=r&&!(u&&!n.Character.isHexDigit(s.charCodeAt(0)));break}}}if(r&&i&&t.length>2){var o=t.substr(1,t.length-2);if(a&&o.length>1){t=String.fromCharCode(parseInt(o.substr(1),10))}else if(u&&o.length>2){t=String.fromCharCode(parseInt("0"+o.substr(1),16))}else if(!a&&!u&&f.XHTMLEntities[o]){t=f.XHTMLEntities[o]}}return t};JSXParser.prototype.lexJSX=function(){var e=this.scanner.source.charCodeAt(this.scanner.index);if(e===60||e===62||e===47||e===58||e===61||e===123||e===125){var t=this.scanner.source[this.scanner.index++];return{type:7,value:t,lineNumber:this.scanner.lineNumber,lineStart:this.scanner.lineStart,start:this.scanner.index-1,end:this.scanner.index}}if(e===34||e===39){var r=this.scanner.index;var i=this.scanner.source[this.scanner.index++];var a="";while(!this.scanner.eof()){var u=this.scanner.source[this.scanner.index++];if(u===i){break}else if(u==="&"){a+=this.scanXHTMLEntity(i)}else{a+=u}}return{type:8,value:a,lineNumber:this.scanner.lineNumber,lineStart:this.scanner.lineStart,start:r,end:this.scanner.index}}if(e===46){var s=this.scanner.source.charCodeAt(this.scanner.index+1);var o=this.scanner.source.charCodeAt(this.scanner.index+2);var t=s===46&&o===46?"...":".";var r=this.scanner.index;this.scanner.index+=t.length;return{type:7,value:t,lineNumber:this.scanner.lineNumber,lineStart:this.scanner.lineStart,start:r,end:this.scanner.index}}if(e===96){return{type:10,value:"",lineNumber:this.scanner.lineNumber,lineStart:this.scanner.lineStart,start:this.scanner.index,end:this.scanner.index}}if(n.Character.isIdentifierStart(e)&&e!==92){var r=this.scanner.index;++this.scanner.index;while(!this.scanner.eof()){var u=this.scanner.source.charCodeAt(this.scanner.index);if(n.Character.isIdentifierPart(u)&&u!==92){++this.scanner.index}else if(u===45){++this.scanner.index}else{break}}var l=this.scanner.source.slice(r,this.scanner.index);return{type:100,value:l,lineNumber:this.scanner.lineNumber,lineStart:this.scanner.lineStart,start:r,end:this.scanner.index}}return this.scanner.lex()};JSXParser.prototype.nextJSXToken=function(){this.collectComments();this.startMarker.index=this.scanner.index;this.startMarker.line=this.scanner.lineNumber;this.startMarker.column=this.scanner.index-this.scanner.lineStart;var e=this.lexJSX();this.lastMarker.index=this.scanner.index;this.lastMarker.line=this.scanner.lineNumber;this.lastMarker.column=this.scanner.index-this.scanner.lineStart;if(this.config.tokens){this.tokens.push(this.convertToken(e))}return e};JSXParser.prototype.nextJSXText=function(){this.startMarker.index=this.scanner.index;this.startMarker.line=this.scanner.lineNumber;this.startMarker.column=this.scanner.index-this.scanner.lineStart;var e=this.scanner.index;var t="";while(!this.scanner.eof()){var r=this.scanner.source[this.scanner.index];if(r==="{"||r==="<"){break}++this.scanner.index;t+=r;if(n.Character.isLineTerminator(r.charCodeAt(0))){++this.scanner.lineNumber;if(r==="\r"&&this.scanner.source[this.scanner.index]==="\n"){++this.scanner.index}this.scanner.lineStart=this.scanner.index}}this.lastMarker.index=this.scanner.index;this.lastMarker.line=this.scanner.lineNumber;this.lastMarker.column=this.scanner.index-this.scanner.lineStart;var i={type:101,value:t,lineNumber:this.scanner.lineNumber,lineStart:this.scanner.lineStart,start:e,end:this.scanner.index};if(t.length>0&&this.config.tokens){this.tokens.push(this.convertToken(i))}return i};JSXParser.prototype.peekJSXToken=function(){var e=this.scanner.saveState();this.scanner.scanComments();var t=this.lexJSX();this.scanner.restoreState(e);return t};JSXParser.prototype.expectJSX=function(e){var t=this.nextJSXToken();if(t.type!==7||t.value!==e){this.throwUnexpectedToken(t)}};JSXParser.prototype.matchJSX=function(e){var t=this.peekJSXToken();return t.type===7&&t.value===e};JSXParser.prototype.parseJSXIdentifier=function(){var e=this.createJSXNode();var t=this.nextJSXToken();if(t.type!==100){this.throwUnexpectedToken(t)}return this.finalize(e,new a.JSXIdentifier(t.value))};JSXParser.prototype.parseJSXElementName=function(){var e=this.createJSXNode();var t=this.parseJSXIdentifier();if(this.matchJSX(":")){var r=t;this.expectJSX(":");var i=this.parseJSXIdentifier();t=this.finalize(e,new a.JSXNamespacedName(r,i))}else if(this.matchJSX(".")){while(this.matchJSX(".")){var n=t;this.expectJSX(".");var u=this.parseJSXIdentifier();t=this.finalize(e,new a.JSXMemberExpression(n,u))}}return t};JSXParser.prototype.parseJSXAttributeName=function(){var e=this.createJSXNode();var t;var r=this.parseJSXIdentifier();if(this.matchJSX(":")){var i=r;this.expectJSX(":");var n=this.parseJSXIdentifier();t=this.finalize(e,new a.JSXNamespacedName(i,n))}else{t=r}return t};JSXParser.prototype.parseJSXStringLiteralAttribute=function(){var e=this.createJSXNode();var t=this.nextJSXToken();if(t.type!==8){this.throwUnexpectedToken(t)}var r=this.getTokenRaw(t);return this.finalize(e,new s.Literal(t.value,r))};JSXParser.prototype.parseJSXExpressionAttribute=function(){var e=this.createJSXNode();this.expectJSX("{");this.finishJSX();if(this.match("}")){this.tolerateError("JSX attributes must only be assigned a non-empty expression")}var t=this.parseAssignmentExpression();this.reenterJSX();return this.finalize(e,new a.JSXExpressionContainer(t))};JSXParser.prototype.parseJSXAttributeValue=function(){return this.matchJSX("{")?this.parseJSXExpressionAttribute():this.matchJSX("<")?this.parseJSXElement():this.parseJSXStringLiteralAttribute()};JSXParser.prototype.parseJSXNameValueAttribute=function(){var e=this.createJSXNode();var t=this.parseJSXAttributeName();var r=null;if(this.matchJSX("=")){this.expectJSX("=");r=this.parseJSXAttributeValue()}return this.finalize(e,new a.JSXAttribute(t,r))};JSXParser.prototype.parseJSXSpreadAttribute=function(){var e=this.createJSXNode();this.expectJSX("{");this.expectJSX("...");this.finishJSX();var t=this.parseAssignmentExpression();this.reenterJSX();return this.finalize(e,new a.JSXSpreadAttribute(t))};JSXParser.prototype.parseJSXAttributes=function(){var e=[];while(!this.matchJSX("/")&&!this.matchJSX(">")){var t=this.matchJSX("{")?this.parseJSXSpreadAttribute():this.parseJSXNameValueAttribute();e.push(t)}return e};JSXParser.prototype.parseJSXOpeningElement=function(){var e=this.createJSXNode();this.expectJSX("<");var t=this.parseJSXElementName();var r=this.parseJSXAttributes();var i=this.matchJSX("/");if(i){this.expectJSX("/")}this.expectJSX(">");return this.finalize(e,new a.JSXOpeningElement(t,i,r))};JSXParser.prototype.parseJSXBoundaryElement=function(){var e=this.createJSXNode();this.expectJSX("<");if(this.matchJSX("/")){this.expectJSX("/");var t=this.parseJSXElementName();this.expectJSX(">");return this.finalize(e,new a.JSXClosingElement(t))}var r=this.parseJSXElementName();var i=this.parseJSXAttributes();var n=this.matchJSX("/");if(n){this.expectJSX("/")}this.expectJSX(">");return this.finalize(e,new a.JSXOpeningElement(r,n,i))};JSXParser.prototype.parseJSXEmptyExpression=function(){var e=this.createJSXChildNode();this.collectComments();this.lastMarker.index=this.scanner.index;this.lastMarker.line=this.scanner.lineNumber;this.lastMarker.column=this.scanner.index-this.scanner.lineStart;return this.finalize(e,new a.JSXEmptyExpression)};JSXParser.prototype.parseJSXExpressionContainer=function(){var e=this.createJSXNode();this.expectJSX("{");var t;if(this.matchJSX("}")){t=this.parseJSXEmptyExpression();this.expectJSX("}")}else{this.finishJSX();t=this.parseAssignmentExpression();this.reenterJSX()}return this.finalize(e,new a.JSXExpressionContainer(t))};JSXParser.prototype.parseJSXChildren=function(){var e=[];while(!this.scanner.eof()){var t=this.createJSXChildNode();var r=this.nextJSXText();if(r.start0){var s=this.finalize(e.node,new a.JSXElement(e.opening,e.children,e.closing));e=t[t.length-1];e.children.push(s);t.pop()}else{break}}}return e};JSXParser.prototype.parseJSXElement=function(){var e=this.createJSXNode();var t=this.parseJSXOpeningElement();var r=[];var i=null;if(!t.selfClosing){var n=this.parseComplexJSXElement({node:e,opening:t,closing:i,children:r});r=n.children;i=n.closing}return this.finalize(e,new a.JSXElement(t,r,i))};JSXParser.prototype.parseJSXRoot=function(){if(this.config.tokens){this.tokens.pop()}this.startJSX();var e=this.parseJSXElement();this.finishJSX();return e};JSXParser.prototype.isStartOfExpression=function(){return e.prototype.isStartOfExpression.call(this)||this.match("<")};return JSXParser}(o.Parser);t.JSXParser=c},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r={NonAsciiIdentifierStart:/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]/,NonAsciiIdentifierPart:/[\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B4\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/};t.Character={fromCodePoint:function(e){return e<65536?String.fromCharCode(e):String.fromCharCode(55296+(e-65536>>10))+String.fromCharCode(56320+(e-65536&1023))},isWhiteSpace:function(e){return e===32||e===9||e===11||e===12||e===160||e>=5760&&[5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].indexOf(e)>=0},isLineTerminator:function(e){return e===10||e===13||e===8232||e===8233},isIdentifierStart:function(e){return e===36||e===95||e>=65&&e<=90||e>=97&&e<=122||e===92||e>=128&&r.NonAsciiIdentifierStart.test(t.Character.fromCodePoint(e))},isIdentifierPart:function(e){return e===36||e===95||e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===92||e>=128&&r.NonAsciiIdentifierPart.test(t.Character.fromCodePoint(e))},isDecimalDigit:function(e){return e>=48&&e<=57},isHexDigit:function(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102},isOctalDigit:function(e){return e>=48&&e<=55}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:true});var i=r(6);var n=function(){function JSXClosingElement(e){this.type=i.JSXSyntax.JSXClosingElement;this.name=e}return JSXClosingElement}();t.JSXClosingElement=n;var a=function(){function JSXElement(e,t,r){this.type=i.JSXSyntax.JSXElement;this.openingElement=e;this.children=t;this.closingElement=r}return JSXElement}();t.JSXElement=a;var u=function(){function JSXEmptyExpression(){this.type=i.JSXSyntax.JSXEmptyExpression}return JSXEmptyExpression}();t.JSXEmptyExpression=u;var s=function(){function JSXExpressionContainer(e){this.type=i.JSXSyntax.JSXExpressionContainer;this.expression=e}return JSXExpressionContainer}();t.JSXExpressionContainer=s;var o=function(){function JSXIdentifier(e){this.type=i.JSXSyntax.JSXIdentifier;this.name=e}return JSXIdentifier}();t.JSXIdentifier=o;var l=function(){function JSXMemberExpression(e,t){this.type=i.JSXSyntax.JSXMemberExpression;this.object=e;this.property=t}return JSXMemberExpression}();t.JSXMemberExpression=l;var f=function(){function JSXAttribute(e,t){this.type=i.JSXSyntax.JSXAttribute;this.name=e;this.value=t}return JSXAttribute}();t.JSXAttribute=f;var c=function(){function JSXNamespacedName(e,t){this.type=i.JSXSyntax.JSXNamespacedName;this.namespace=e;this.name=t}return JSXNamespacedName}();t.JSXNamespacedName=c;var h=function(){function JSXOpeningElement(e,t,r){this.type=i.JSXSyntax.JSXOpeningElement;this.name=e;this.selfClosing=t;this.attributes=r}return JSXOpeningElement}();t.JSXOpeningElement=h;var p=function(){function JSXSpreadAttribute(e){this.type=i.JSXSyntax.JSXSpreadAttribute;this.argument=e}return JSXSpreadAttribute}();t.JSXSpreadAttribute=p;var v=function(){function JSXText(e,t){this.type=i.JSXSyntax.JSXText;this.value=e;this.raw=t}return JSXText}();t.JSXText=v},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.JSXSyntax={JSXAttribute:"JSXAttribute",JSXClosingElement:"JSXClosingElement",JSXElement:"JSXElement",JSXEmptyExpression:"JSXEmptyExpression",JSXExpressionContainer:"JSXExpressionContainer",JSXIdentifier:"JSXIdentifier",JSXMemberExpression:"JSXMemberExpression",JSXNamespacedName:"JSXNamespacedName",JSXOpeningElement:"JSXOpeningElement",JSXSpreadAttribute:"JSXSpreadAttribute",JSXText:"JSXText"}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:true});var i=r(2);var n=function(){function ArrayExpression(e){this.type=i.Syntax.ArrayExpression;this.elements=e}return ArrayExpression}();t.ArrayExpression=n;var a=function(){function ArrayPattern(e){this.type=i.Syntax.ArrayPattern;this.elements=e}return ArrayPattern}();t.ArrayPattern=a;var u=function(){function ArrowFunctionExpression(e,t,r){this.type=i.Syntax.ArrowFunctionExpression;this.id=null;this.params=e;this.body=t;this.generator=false;this.expression=r;this.async=false}return ArrowFunctionExpression}();t.ArrowFunctionExpression=u;var s=function(){function AssignmentExpression(e,t,r){this.type=i.Syntax.AssignmentExpression;this.operator=e;this.left=t;this.right=r}return AssignmentExpression}();t.AssignmentExpression=s;var o=function(){function AssignmentPattern(e,t){this.type=i.Syntax.AssignmentPattern;this.left=e;this.right=t}return AssignmentPattern}();t.AssignmentPattern=o;var l=function(){function AsyncArrowFunctionExpression(e,t,r){this.type=i.Syntax.ArrowFunctionExpression;this.id=null;this.params=e;this.body=t;this.generator=false;this.expression=r;this.async=true}return AsyncArrowFunctionExpression}();t.AsyncArrowFunctionExpression=l;var f=function(){function AsyncFunctionDeclaration(e,t,r){this.type=i.Syntax.FunctionDeclaration;this.id=e;this.params=t;this.body=r;this.generator=false;this.expression=false;this.async=true}return AsyncFunctionDeclaration}();t.AsyncFunctionDeclaration=f;var c=function(){function AsyncFunctionExpression(e,t,r){this.type=i.Syntax.FunctionExpression;this.id=e;this.params=t;this.body=r;this.generator=false;this.expression=false;this.async=true}return AsyncFunctionExpression}();t.AsyncFunctionExpression=c;var h=function(){function AwaitExpression(e){this.type=i.Syntax.AwaitExpression;this.argument=e}return AwaitExpression}();t.AwaitExpression=h;var p=function(){function BinaryExpression(e,t,r){var n=e==="||"||e==="&&";this.type=n?i.Syntax.LogicalExpression:i.Syntax.BinaryExpression;this.operator=e;this.left=t;this.right=r}return BinaryExpression}();t.BinaryExpression=p;var v=function(){function BlockStatement(e){this.type=i.Syntax.BlockStatement;this.body=e}return BlockStatement}();t.BlockStatement=v;var d=function(){function BreakStatement(e){this.type=i.Syntax.BreakStatement;this.label=e}return BreakStatement}();t.BreakStatement=d;var D=function(){function CallExpression(e,t){this.type=i.Syntax.CallExpression;this.callee=e;this.arguments=t}return CallExpression}();t.CallExpression=D;var m=function(){function CatchClause(e,t){this.type=i.Syntax.CatchClause;this.param=e;this.body=t}return CatchClause}();t.CatchClause=m;var g=function(){function ClassBody(e){this.type=i.Syntax.ClassBody;this.body=e}return ClassBody}();t.ClassBody=g;var E=function(){function ClassDeclaration(e,t,r){this.type=i.Syntax.ClassDeclaration;this.id=e;this.superClass=t;this.body=r}return ClassDeclaration}();t.ClassDeclaration=E;var A=function(){function ClassExpression(e,t,r){this.type=i.Syntax.ClassExpression;this.id=e;this.superClass=t;this.body=r}return ClassExpression}();t.ClassExpression=A;var C=function(){function ComputedMemberExpression(e,t){this.type=i.Syntax.MemberExpression;this.computed=true;this.object=e;this.property=t}return ComputedMemberExpression}();t.ComputedMemberExpression=C;var y=function(){function ConditionalExpression(e,t,r){this.type=i.Syntax.ConditionalExpression;this.test=e;this.consequent=t;this.alternate=r}return ConditionalExpression}();t.ConditionalExpression=y;var w=function(){function ContinueStatement(e){this.type=i.Syntax.ContinueStatement;this.label=e}return ContinueStatement}();t.ContinueStatement=w;var x=function(){function DebuggerStatement(){this.type=i.Syntax.DebuggerStatement}return DebuggerStatement}();t.DebuggerStatement=x;var b=function(){function Directive(e,t){this.type=i.Syntax.ExpressionStatement;this.expression=e;this.directive=t}return Directive}();t.Directive=b;var F=function(){function DoWhileStatement(e,t){this.type=i.Syntax.DoWhileStatement;this.body=e;this.test=t}return DoWhileStatement}();t.DoWhileStatement=F;var S=function(){function EmptyStatement(){this.type=i.Syntax.EmptyStatement}return EmptyStatement}();t.EmptyStatement=S;var B=function(){function ExportAllDeclaration(e){this.type=i.Syntax.ExportAllDeclaration;this.source=e}return ExportAllDeclaration}();t.ExportAllDeclaration=B;var k=function(){function ExportDefaultDeclaration(e){this.type=i.Syntax.ExportDefaultDeclaration;this.declaration=e}return ExportDefaultDeclaration}();t.ExportDefaultDeclaration=k;var O=function(){function ExportNamedDeclaration(e,t,r){this.type=i.Syntax.ExportNamedDeclaration;this.declaration=e;this.specifiers=t;this.source=r}return ExportNamedDeclaration}();t.ExportNamedDeclaration=O;var P=function(){function ExportSpecifier(e,t){this.type=i.Syntax.ExportSpecifier;this.exported=t;this.local=e}return ExportSpecifier}();t.ExportSpecifier=P;var T=function(){function ExpressionStatement(e){this.type=i.Syntax.ExpressionStatement;this.expression=e}return ExpressionStatement}();t.ExpressionStatement=T;var I=function(){function ForInStatement(e,t,r){this.type=i.Syntax.ForInStatement;this.left=e;this.right=t;this.body=r;this.each=false}return ForInStatement}();t.ForInStatement=I;var M=function(){function ForOfStatement(e,t,r){this.type=i.Syntax.ForOfStatement;this.left=e;this.right=t;this.body=r}return ForOfStatement}();t.ForOfStatement=M;var L=function(){function ForStatement(e,t,r,n){this.type=i.Syntax.ForStatement;this.init=e;this.test=t;this.update=r;this.body=n}return ForStatement}();t.ForStatement=L;var R=function(){function FunctionDeclaration(e,t,r,n){this.type=i.Syntax.FunctionDeclaration;this.id=e;this.params=t;this.body=r;this.generator=n;this.expression=false;this.async=false}return FunctionDeclaration}();t.FunctionDeclaration=R;var j=function(){function FunctionExpression(e,t,r,n){this.type=i.Syntax.FunctionExpression;this.id=e;this.params=t;this.body=r;this.generator=n;this.expression=false;this.async=false}return FunctionExpression}();t.FunctionExpression=j;var U=function(){function Identifier(e){this.type=i.Syntax.Identifier;this.name=e}return Identifier}();t.Identifier=U;var N=function(){function IfStatement(e,t,r){this.type=i.Syntax.IfStatement;this.test=e;this.consequent=t;this.alternate=r}return IfStatement}();t.IfStatement=N;var J=function(){function ImportDeclaration(e,t){this.type=i.Syntax.ImportDeclaration;this.specifiers=e;this.source=t}return ImportDeclaration}();t.ImportDeclaration=J;var z=function(){function ImportDefaultSpecifier(e){this.type=i.Syntax.ImportDefaultSpecifier;this.local=e}return ImportDefaultSpecifier}();t.ImportDefaultSpecifier=z;var X=function(){function ImportNamespaceSpecifier(e){this.type=i.Syntax.ImportNamespaceSpecifier;this.local=e}return ImportNamespaceSpecifier}();t.ImportNamespaceSpecifier=X;var G=function(){function ImportSpecifier(e,t){this.type=i.Syntax.ImportSpecifier;this.local=e;this.imported=t}return ImportSpecifier}();t.ImportSpecifier=G;var q=function(){function LabeledStatement(e,t){this.type=i.Syntax.LabeledStatement;this.label=e;this.body=t}return LabeledStatement}();t.LabeledStatement=q;var W=function(){function Literal(e,t){this.type=i.Syntax.Literal;this.value=e;this.raw=t}return Literal}();t.Literal=W;var _=function(){function MetaProperty(e,t){this.type=i.Syntax.MetaProperty;this.meta=e;this.property=t}return MetaProperty}();t.MetaProperty=_;var V=function(){function MethodDefinition(e,t,r,n,a){this.type=i.Syntax.MethodDefinition;this.key=e;this.computed=t;this.value=r;this.kind=n;this.static=a}return MethodDefinition}();t.MethodDefinition=V;var Y=function(){function Module(e){this.type=i.Syntax.Program;this.body=e;this.sourceType="module"}return Module}();t.Module=Y;var H=function(){function NewExpression(e,t){this.type=i.Syntax.NewExpression;this.callee=e;this.arguments=t}return NewExpression}();t.NewExpression=H;var $=function(){function ObjectExpression(e){this.type=i.Syntax.ObjectExpression;this.properties=e}return ObjectExpression}();t.ObjectExpression=$;var Z=function(){function ObjectPattern(e){this.type=i.Syntax.ObjectPattern;this.properties=e}return ObjectPattern}();t.ObjectPattern=Z;var Q=function(){function Property(e,t,r,n,a,u){this.type=i.Syntax.Property;this.key=t;this.computed=r;this.value=n;this.kind=e;this.method=a;this.shorthand=u}return Property}();t.Property=Q;var K=function(){function RegexLiteral(e,t,r,n){this.type=i.Syntax.Literal;this.value=e;this.raw=t;this.regex={pattern:r,flags:n}}return RegexLiteral}();t.RegexLiteral=K;var ee=function(){function RestElement(e){this.type=i.Syntax.RestElement;this.argument=e}return RestElement}();t.RestElement=ee;var te=function(){function ReturnStatement(e){this.type=i.Syntax.ReturnStatement;this.argument=e}return ReturnStatement}();t.ReturnStatement=te;var re=function(){function Script(e){this.type=i.Syntax.Program;this.body=e;this.sourceType="script"}return Script}();t.Script=re;var ie=function(){function SequenceExpression(e){this.type=i.Syntax.SequenceExpression;this.expressions=e}return SequenceExpression}();t.SequenceExpression=ie;var ne=function(){function SpreadElement(e){this.type=i.Syntax.SpreadElement;this.argument=e}return SpreadElement}();t.SpreadElement=ne;var ae=function(){function StaticMemberExpression(e,t){this.type=i.Syntax.MemberExpression;this.computed=false;this.object=e;this.property=t}return StaticMemberExpression}();t.StaticMemberExpression=ae;var ue=function(){function Super(){this.type=i.Syntax.Super}return Super}();t.Super=ue;var se=function(){function SwitchCase(e,t){this.type=i.Syntax.SwitchCase;this.test=e;this.consequent=t}return SwitchCase}();t.SwitchCase=se;var oe=function(){function SwitchStatement(e,t){this.type=i.Syntax.SwitchStatement;this.discriminant=e;this.cases=t}return SwitchStatement}();t.SwitchStatement=oe;var le=function(){function TaggedTemplateExpression(e,t){this.type=i.Syntax.TaggedTemplateExpression;this.tag=e;this.quasi=t}return TaggedTemplateExpression}();t.TaggedTemplateExpression=le;var fe=function(){function TemplateElement(e,t){this.type=i.Syntax.TemplateElement;this.value=e;this.tail=t}return TemplateElement}();t.TemplateElement=fe;var ce=function(){function TemplateLiteral(e,t){this.type=i.Syntax.TemplateLiteral;this.quasis=e;this.expressions=t}return TemplateLiteral}();t.TemplateLiteral=ce;var he=function(){function ThisExpression(){this.type=i.Syntax.ThisExpression}return ThisExpression}();t.ThisExpression=he;var pe=function(){function ThrowStatement(e){this.type=i.Syntax.ThrowStatement;this.argument=e}return ThrowStatement}();t.ThrowStatement=pe;var ve=function(){function TryStatement(e,t,r){this.type=i.Syntax.TryStatement;this.block=e;this.handler=t;this.finalizer=r}return TryStatement}();t.TryStatement=ve;var de=function(){function UnaryExpression(e,t){this.type=i.Syntax.UnaryExpression;this.operator=e;this.argument=t;this.prefix=true}return UnaryExpression}();t.UnaryExpression=de;var De=function(){function UpdateExpression(e,t,r){this.type=i.Syntax.UpdateExpression;this.operator=e;this.argument=t;this.prefix=r}return UpdateExpression}();t.UpdateExpression=De;var me=function(){function VariableDeclaration(e,t){this.type=i.Syntax.VariableDeclaration;this.declarations=e;this.kind=t}return VariableDeclaration}();t.VariableDeclaration=me;var ge=function(){function VariableDeclarator(e,t){this.type=i.Syntax.VariableDeclarator;this.id=e;this.init=t}return VariableDeclarator}();t.VariableDeclarator=ge;var Ee=function(){function WhileStatement(e,t){this.type=i.Syntax.WhileStatement;this.test=e;this.body=t}return WhileStatement}();t.WhileStatement=Ee;var Ae=function(){function WithStatement(e,t){this.type=i.Syntax.WithStatement;this.object=e;this.body=t}return WithStatement}();t.WithStatement=Ae;var Ce=function(){function YieldExpression(e,t){this.type=i.Syntax.YieldExpression;this.argument=e;this.delegate=t}return YieldExpression}();t.YieldExpression=Ce},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:true});var i=r(9);var n=r(10);var a=r(11);var u=r(7);var s=r(12);var o=r(2);var l=r(13);var f="ArrowParameterPlaceHolder";var c=function(){function Parser(e,t,r){if(t===void 0){t={}}this.config={range:typeof t.range==="boolean"&&t.range,loc:typeof t.loc==="boolean"&&t.loc,source:null,tokens:typeof t.tokens==="boolean"&&t.tokens,comment:typeof t.comment==="boolean"&&t.comment,tolerant:typeof t.tolerant==="boolean"&&t.tolerant};if(this.config.loc&&t.source&&t.source!==null){this.config.source=String(t.source)}this.delegate=r;this.errorHandler=new n.ErrorHandler;this.errorHandler.tolerant=this.config.tolerant;this.scanner=new s.Scanner(e,this.errorHandler);this.scanner.trackComment=this.config.comment;this.operatorPrecedence={")":0,";":0,",":0,"=":0,"]":0,"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":11,"/":11,"%":11};this.lookahead={type:2,value:"",lineNumber:this.scanner.lineNumber,lineStart:0,start:0,end:0};this.hasLineTerminator=false;this.context={isModule:false,await:false,allowIn:true,allowStrictDirective:true,allowYield:true,firstCoverInitializedNameError:null,isAssignmentTarget:false,isBindingElement:false,inFunctionBody:false,inIteration:false,inSwitch:false,labelSet:{},strict:false};this.tokens=[];this.startMarker={index:0,line:this.scanner.lineNumber,column:0};this.lastMarker={index:0,line:this.scanner.lineNumber,column:0};this.nextToken();this.lastMarker={index:this.scanner.index,line:this.scanner.lineNumber,column:this.scanner.index-this.scanner.lineStart}}Parser.prototype.throwError=function(e){var t=[];for(var r=1;r0&&this.delegate){for(var t=0;t>="||e===">>>="||e==="&="||e==="^="||e==="|="};Parser.prototype.isolateCoverGrammar=function(e){var t=this.context.isBindingElement;var r=this.context.isAssignmentTarget;var i=this.context.firstCoverInitializedNameError;this.context.isBindingElement=true;this.context.isAssignmentTarget=true;this.context.firstCoverInitializedNameError=null;var n=e.call(this);if(this.context.firstCoverInitializedNameError!==null){this.throwUnexpectedToken(this.context.firstCoverInitializedNameError)}this.context.isBindingElement=t;this.context.isAssignmentTarget=r;this.context.firstCoverInitializedNameError=i;return n};Parser.prototype.inheritCoverGrammar=function(e){var t=this.context.isBindingElement;var r=this.context.isAssignmentTarget;var i=this.context.firstCoverInitializedNameError;this.context.isBindingElement=true;this.context.isAssignmentTarget=true;this.context.firstCoverInitializedNameError=null;var n=e.call(this);this.context.isBindingElement=this.context.isBindingElement&&t;this.context.isAssignmentTarget=this.context.isAssignmentTarget&&r;this.context.firstCoverInitializedNameError=i||this.context.firstCoverInitializedNameError;return n};Parser.prototype.consumeSemicolon=function(){if(this.match(";")){this.nextToken()}else if(!this.hasLineTerminator){if(this.lookahead.type!==2&&!this.match("}")){this.throwUnexpectedToken(this.lookahead)}this.lastMarker.index=this.startMarker.index;this.lastMarker.line=this.startMarker.line;this.lastMarker.column=this.startMarker.column}};Parser.prototype.parsePrimaryExpression=function(){var e=this.createNode();var t;var r,i;switch(this.lookahead.type){case 3:if((this.context.isModule||this.context.await)&&this.lookahead.value==="await"){this.tolerateUnexpectedToken(this.lookahead)}t=this.matchAsyncFunction()?this.parseFunctionExpression():this.finalize(e,new u.Identifier(this.nextToken().value));break;case 6:case 8:if(this.context.strict&&this.lookahead.octal){this.tolerateUnexpectedToken(this.lookahead,a.Messages.StrictOctalLiteral)}this.context.isAssignmentTarget=false;this.context.isBindingElement=false;r=this.nextToken();i=this.getTokenRaw(r);t=this.finalize(e,new u.Literal(r.value,i));break;case 1:this.context.isAssignmentTarget=false;this.context.isBindingElement=false;r=this.nextToken();i=this.getTokenRaw(r);t=this.finalize(e,new u.Literal(r.value==="true",i));break;case 5:this.context.isAssignmentTarget=false;this.context.isBindingElement=false;r=this.nextToken();i=this.getTokenRaw(r);t=this.finalize(e,new u.Literal(null,i));break;case 10:t=this.parseTemplateLiteral();break;case 7:switch(this.lookahead.value){case"(":this.context.isBindingElement=false;t=this.inheritCoverGrammar(this.parseGroupExpression);break;case"[":t=this.inheritCoverGrammar(this.parseArrayInitializer);break;case"{":t=this.inheritCoverGrammar(this.parseObjectInitializer);break;case"/":case"/=":this.context.isAssignmentTarget=false;this.context.isBindingElement=false;this.scanner.index=this.startMarker.index;r=this.nextRegexToken();i=this.getTokenRaw(r);t=this.finalize(e,new u.RegexLiteral(r.regex,i,r.pattern,r.flags));break;default:t=this.throwUnexpectedToken(this.nextToken())}break;case 4:if(!this.context.strict&&this.context.allowYield&&this.matchKeyword("yield")){t=this.parseIdentifierName()}else if(!this.context.strict&&this.matchKeyword("let")){t=this.finalize(e,new u.Identifier(this.nextToken().value))}else{this.context.isAssignmentTarget=false;this.context.isBindingElement=false;if(this.matchKeyword("function")){t=this.parseFunctionExpression()}else if(this.matchKeyword("this")){this.nextToken();t=this.finalize(e,new u.ThisExpression)}else if(this.matchKeyword("class")){t=this.parseClassExpression()}else{t=this.throwUnexpectedToken(this.nextToken())}}break;default:t=this.throwUnexpectedToken(this.nextToken())}return t};Parser.prototype.parseSpreadElement=function(){var e=this.createNode();this.expect("...");var t=this.inheritCoverGrammar(this.parseAssignmentExpression);return this.finalize(e,new u.SpreadElement(t))};Parser.prototype.parseArrayInitializer=function(){var e=this.createNode();var t=[];this.expect("[");while(!this.match("]")){if(this.match(",")){this.nextToken();t.push(null)}else if(this.match("...")){var r=this.parseSpreadElement();if(!this.match("]")){this.context.isAssignmentTarget=false;this.context.isBindingElement=false;this.expect(",")}t.push(r)}else{t.push(this.inheritCoverGrammar(this.parseAssignmentExpression));if(!this.match("]")){this.expect(",")}}}this.expect("]");return this.finalize(e,new u.ArrayExpression(t))};Parser.prototype.parsePropertyMethod=function(e){this.context.isAssignmentTarget=false;this.context.isBindingElement=false;var t=this.context.strict;var r=this.context.allowStrictDirective;this.context.allowStrictDirective=e.simple;var i=this.isolateCoverGrammar(this.parseFunctionSourceElements);if(this.context.strict&&e.firstRestricted){this.tolerateUnexpectedToken(e.firstRestricted,e.message)}if(this.context.strict&&e.stricted){this.tolerateUnexpectedToken(e.stricted,e.message)}this.context.strict=t;this.context.allowStrictDirective=r;return i};Parser.prototype.parsePropertyMethodFunction=function(){var e=false;var t=this.createNode();var r=this.context.allowYield;this.context.allowYield=true;var i=this.parseFormalParameters();var n=this.parsePropertyMethod(i);this.context.allowYield=r;return this.finalize(t,new u.FunctionExpression(null,i.params,n,e))};Parser.prototype.parsePropertyMethodAsyncFunction=function(){var e=this.createNode();var t=this.context.allowYield;var r=this.context.await;this.context.allowYield=false;this.context.await=true;var i=this.parseFormalParameters();var n=this.parsePropertyMethod(i);this.context.allowYield=t;this.context.await=r;return this.finalize(e,new u.AsyncFunctionExpression(null,i.params,n))};Parser.prototype.parseObjectPropertyKey=function(){var e=this.createNode();var t=this.nextToken();var r;switch(t.type){case 8:case 6:if(this.context.strict&&t.octal){this.tolerateUnexpectedToken(t,a.Messages.StrictOctalLiteral)}var i=this.getTokenRaw(t);r=this.finalize(e,new u.Literal(t.value,i));break;case 3:case 1:case 5:case 4:r=this.finalize(e,new u.Identifier(t.value));break;case 7:if(t.value==="["){r=this.isolateCoverGrammar(this.parseAssignmentExpression);this.expect("]")}else{r=this.throwUnexpectedToken(t)}break;default:r=this.throwUnexpectedToken(t)}return r};Parser.prototype.isPropertyKey=function(e,t){return e.type===o.Syntax.Identifier&&e.name===t||e.type===o.Syntax.Literal&&e.value===t};Parser.prototype.parseObjectProperty=function(e){var t=this.createNode();var r=this.lookahead;var i;var n=null;var s=null;var o=false;var l=false;var f=false;var c=false;if(r.type===3){var h=r.value;this.nextToken();o=this.match("[");c=!this.hasLineTerminator&&h==="async"&&!this.match(":")&&!this.match("(")&&!this.match("*")&&!this.match(",");n=c?this.parseObjectPropertyKey():this.finalize(t,new u.Identifier(h))}else if(this.match("*")){this.nextToken()}else{o=this.match("[");n=this.parseObjectPropertyKey()}var p=this.qualifiedPropertyName(this.lookahead);if(r.type===3&&!c&&r.value==="get"&&p){i="get";o=this.match("[");n=this.parseObjectPropertyKey();this.context.allowYield=false;s=this.parseGetterMethod()}else if(r.type===3&&!c&&r.value==="set"&&p){i="set";o=this.match("[");n=this.parseObjectPropertyKey();s=this.parseSetterMethod()}else if(r.type===7&&r.value==="*"&&p){i="init";o=this.match("[");n=this.parseObjectPropertyKey();s=this.parseGeneratorMethod();l=true}else{if(!n){this.throwUnexpectedToken(this.lookahead)}i="init";if(this.match(":")&&!c){if(!o&&this.isPropertyKey(n,"__proto__")){if(e.value){this.tolerateError(a.Messages.DuplicateProtoProperty)}e.value=true}this.nextToken();s=this.inheritCoverGrammar(this.parseAssignmentExpression)}else if(this.match("(")){s=c?this.parsePropertyMethodAsyncFunction():this.parsePropertyMethodFunction();l=true}else if(r.type===3){var h=this.finalize(t,new u.Identifier(r.value));if(this.match("=")){this.context.firstCoverInitializedNameError=this.lookahead;this.nextToken();f=true;var v=this.isolateCoverGrammar(this.parseAssignmentExpression);s=this.finalize(t,new u.AssignmentPattern(h,v))}else{f=true;s=h}}else{this.throwUnexpectedToken(this.nextToken())}}return this.finalize(t,new u.Property(i,n,o,s,l,f))};Parser.prototype.parseObjectInitializer=function(){var e=this.createNode();this.expect("{");var t=[];var r={value:false};while(!this.match("}")){t.push(this.parseObjectProperty(r));if(!this.match("}")){this.expectCommaSeparator()}}this.expect("}");return this.finalize(e,new u.ObjectExpression(t))};Parser.prototype.parseTemplateHead=function(){i.assert(this.lookahead.head,"Template literal must start with a template head");var e=this.createNode();var t=this.nextToken();var r=t.value;var n=t.cooked;return this.finalize(e,new u.TemplateElement({raw:r,cooked:n},t.tail))};Parser.prototype.parseTemplateElement=function(){if(this.lookahead.type!==10){this.throwUnexpectedToken()}var e=this.createNode();var t=this.nextToken();var r=t.value;var i=t.cooked;return this.finalize(e,new u.TemplateElement({raw:r,cooked:i},t.tail))};Parser.prototype.parseTemplateLiteral=function(){var e=this.createNode();var t=[];var r=[];var i=this.parseTemplateHead();r.push(i);while(!i.tail){t.push(this.parseExpression());i=this.parseTemplateElement();r.push(i)}return this.finalize(e,new u.TemplateLiteral(r,t))};Parser.prototype.reinterpretExpressionAsPattern=function(e){switch(e.type){case o.Syntax.Identifier:case o.Syntax.MemberExpression:case o.Syntax.RestElement:case o.Syntax.AssignmentPattern:break;case o.Syntax.SpreadElement:e.type=o.Syntax.RestElement;this.reinterpretExpressionAsPattern(e.argument);break;case o.Syntax.ArrayExpression:e.type=o.Syntax.ArrayPattern;for(var t=0;t")){this.expect("=>")}e={type:f,params:[],async:false}}else{var t=this.lookahead;var r=[];if(this.match("...")){e=this.parseRestElement(r);this.expect(")");if(!this.match("=>")){this.expect("=>")}e={type:f,params:[e],async:false}}else{var i=false;this.context.isBindingElement=true;e=this.inheritCoverGrammar(this.parseAssignmentExpression);if(this.match(",")){var n=[];this.context.isAssignmentTarget=false;n.push(e);while(this.lookahead.type!==2){if(!this.match(",")){break}this.nextToken();if(this.match(")")){this.nextToken();for(var a=0;a")){this.expect("=>")}this.context.isBindingElement=false;for(var a=0;a")){if(e.type===o.Syntax.Identifier&&e.name==="yield"){i=true;e={type:f,params:[e],async:false}}if(!i){if(!this.context.isBindingElement){this.throwUnexpectedToken(this.lookahead)}if(e.type===o.Syntax.SequenceExpression){for(var a=0;a")){for(var o=0;o0){this.nextToken();this.context.isAssignmentTarget=false;this.context.isBindingElement=false;var n=[e,this.lookahead];var a=t;var s=this.isolateCoverGrammar(this.parseExponentiationExpression);var o=[a,r.value,s];var l=[i];while(true){i=this.binaryPrecedence(this.lookahead);if(i<=0){break}while(o.length>2&&i<=l[l.length-1]){s=o.pop();var f=o.pop();l.pop();a=o.pop();n.pop();var c=this.startNode(n[n.length-1]);o.push(this.finalize(c,new u.BinaryExpression(f,a,s)))}o.push(this.nextToken().value);l.push(i);n.push(this.lookahead);o.push(this.isolateCoverGrammar(this.parseExponentiationExpression))}var h=o.length-1;t=o[h];var p=n.pop();while(h>1){var v=n.pop();var d=p&&p.lineStart;var c=this.startNode(v,d);var f=o[h-1];t=this.finalize(c,new u.BinaryExpression(f,o[h-2],t));h-=2;p=v}}return t};Parser.prototype.parseConditionalExpression=function(){var e=this.lookahead;var t=this.inheritCoverGrammar(this.parseBinaryExpression);if(this.match("?")){this.nextToken();var r=this.context.allowIn;this.context.allowIn=true;var i=this.isolateCoverGrammar(this.parseAssignmentExpression);this.context.allowIn=r;this.expect(":");var n=this.isolateCoverGrammar(this.parseAssignmentExpression);t=this.finalize(this.startNode(e),new u.ConditionalExpression(t,i,n));this.context.isAssignmentTarget=false;this.context.isBindingElement=false}return t};Parser.prototype.checkPatternParam=function(e,t){switch(t.type){case o.Syntax.Identifier:this.validateParam(e,t,t.name);break;case o.Syntax.RestElement:this.checkPatternParam(e,t.argument);break;case o.Syntax.AssignmentPattern:this.checkPatternParam(e,t.left);break;case o.Syntax.ArrayPattern:for(var r=0;r")){this.context.isAssignmentTarget=false;this.context.isBindingElement=false;var n=e.async;var s=this.reinterpretAsCoverFormalsList(e);if(s){if(this.hasLineTerminator){this.tolerateUnexpectedToken(this.lookahead)}this.context.firstCoverInitializedNameError=null;var l=this.context.strict;var c=this.context.allowStrictDirective;this.context.allowStrictDirective=s.simple;var h=this.context.allowYield;var p=this.context.await;this.context.allowYield=true;this.context.await=n;var v=this.startNode(t);this.expect("=>");var d=void 0;if(this.match("{")){var D=this.context.allowIn;this.context.allowIn=true;d=this.parseFunctionSourceElements();this.context.allowIn=D}else{d=this.isolateCoverGrammar(this.parseAssignmentExpression)}var m=d.type!==o.Syntax.BlockStatement;if(this.context.strict&&s.firstRestricted){this.throwUnexpectedToken(s.firstRestricted,s.message)}if(this.context.strict&&s.stricted){this.tolerateUnexpectedToken(s.stricted,s.message)}e=n?this.finalize(v,new u.AsyncArrowFunctionExpression(s.params,d,m)):this.finalize(v,new u.ArrowFunctionExpression(s.params,d,m));this.context.strict=l;this.context.allowStrictDirective=c;this.context.allowYield=h;this.context.await=p}}else{if(this.matchAssign()){if(!this.context.isAssignmentTarget){this.tolerateError(a.Messages.InvalidLHSInAssignment)}if(this.context.strict&&e.type===o.Syntax.Identifier){var g=e;if(this.scanner.isRestrictedWord(g.name)){this.tolerateUnexpectedToken(r,a.Messages.StrictLHSAssignment)}if(this.scanner.isStrictModeReservedWord(g.name)){this.tolerateUnexpectedToken(r,a.Messages.StrictReservedWord)}}if(!this.match("=")){this.context.isAssignmentTarget=false;this.context.isBindingElement=false}else{this.reinterpretExpressionAsPattern(e)}r=this.nextToken();var E=r.value;var A=this.isolateCoverGrammar(this.parseAssignmentExpression);e=this.finalize(this.startNode(t),new u.AssignmentExpression(E,e,A));this.context.firstCoverInitializedNameError=null}}}return e};Parser.prototype.parseExpression=function(){var e=this.lookahead;var t=this.isolateCoverGrammar(this.parseAssignmentExpression);if(this.match(",")){var r=[];r.push(t);while(this.lookahead.type!==2){if(!this.match(",")){break}this.nextToken();r.push(this.isolateCoverGrammar(this.parseAssignmentExpression))}t=this.finalize(this.startNode(e),new u.SequenceExpression(r))}return t};Parser.prototype.parseStatementListItem=function(){var e;this.context.isAssignmentTarget=true;this.context.isBindingElement=true;if(this.lookahead.type===4){switch(this.lookahead.value){case"export":if(!this.context.isModule){this.tolerateUnexpectedToken(this.lookahead,a.Messages.IllegalExportDeclaration)}e=this.parseExportDeclaration();break;case"import":if(!this.context.isModule){this.tolerateUnexpectedToken(this.lookahead,a.Messages.IllegalImportDeclaration)}e=this.parseImportDeclaration();break;case"const":e=this.parseLexicalDeclaration({inFor:false});break;case"function":e=this.parseFunctionDeclaration();break;case"class":e=this.parseClassDeclaration();break;case"let":e=this.isLexicalDeclaration()?this.parseLexicalDeclaration({inFor:false}):this.parseStatement();break;default:e=this.parseStatement();break}}else{e=this.parseStatement()}return e};Parser.prototype.parseBlock=function(){var e=this.createNode();this.expect("{");var t=[];while(true){if(this.match("}")){break}t.push(this.parseStatementListItem())}this.expect("}");return this.finalize(e,new u.BlockStatement(t))};Parser.prototype.parseLexicalBinding=function(e,t){var r=this.createNode();var i=[];var n=this.parsePattern(i,e);if(this.context.strict&&n.type===o.Syntax.Identifier){if(this.scanner.isRestrictedWord(n.name)){this.tolerateError(a.Messages.StrictVarName)}}var s=null;if(e==="const"){if(!this.matchKeyword("in")&&!this.matchContextualKeyword("of")){if(this.match("=")){this.nextToken();s=this.isolateCoverGrammar(this.parseAssignmentExpression)}else{this.throwError(a.Messages.DeclarationMissingInitializer,"const")}}}else if(!t.inFor&&n.type!==o.Syntax.Identifier||this.match("=")){this.expect("=");s=this.isolateCoverGrammar(this.parseAssignmentExpression)}return this.finalize(r,new u.VariableDeclarator(n,s))};Parser.prototype.parseBindingList=function(e,t){var r=[this.parseLexicalBinding(e,t)];while(this.match(",")){this.nextToken();r.push(this.parseLexicalBinding(e,t))}return r};Parser.prototype.isLexicalDeclaration=function(){var e=this.scanner.saveState();this.scanner.scanComments();var t=this.scanner.lex();this.scanner.restoreState(e);return t.type===3||t.type===7&&t.value==="["||t.type===7&&t.value==="{"||t.type===4&&t.value==="let"||t.type===4&&t.value==="yield"};Parser.prototype.parseLexicalDeclaration=function(e){var t=this.createNode();var r=this.nextToken().value;i.assert(r==="let"||r==="const","Lexical declaration must be either let or const");var n=this.parseBindingList(r,e);this.consumeSemicolon();return this.finalize(t,new u.VariableDeclaration(n,r))};Parser.prototype.parseBindingRestElement=function(e,t){var r=this.createNode();this.expect("...");var i=this.parsePattern(e,t);return this.finalize(r,new u.RestElement(i))};Parser.prototype.parseArrayPattern=function(e,t){var r=this.createNode();this.expect("[");var i=[];while(!this.match("]")){if(this.match(",")){this.nextToken();i.push(null)}else{if(this.match("...")){i.push(this.parseBindingRestElement(e,t));break}else{i.push(this.parsePatternWithDefault(e,t))}if(!this.match("]")){this.expect(",")}}}this.expect("]");return this.finalize(r,new u.ArrayPattern(i))};Parser.prototype.parsePropertyPattern=function(e,t){var r=this.createNode();var i=false;var n=false;var a=false;var s;var o;if(this.lookahead.type===3){var l=this.lookahead;s=this.parseVariableIdentifier();var f=this.finalize(r,new u.Identifier(l.value));if(this.match("=")){e.push(l);n=true;this.nextToken();var c=this.parseAssignmentExpression();o=this.finalize(this.startNode(l),new u.AssignmentPattern(f,c))}else if(!this.match(":")){e.push(l);n=true;o=f}else{this.expect(":");o=this.parsePatternWithDefault(e,t)}}else{i=this.match("[");s=this.parseObjectPropertyKey();this.expect(":");o=this.parsePatternWithDefault(e,t)}return this.finalize(r,new u.Property("init",s,i,o,a,n))};Parser.prototype.parseObjectPattern=function(e,t){var r=this.createNode();var i=[];this.expect("{");while(!this.match("}")){i.push(this.parsePropertyPattern(e,t));if(!this.match("}")){this.expect(",")}}this.expect("}");return this.finalize(r,new u.ObjectPattern(i))};Parser.prototype.parsePattern=function(e,t){var r;if(this.match("[")){r=this.parseArrayPattern(e,t)}else if(this.match("{")){r=this.parseObjectPattern(e,t)}else{if(this.matchKeyword("let")&&(t==="const"||t==="let")){this.tolerateUnexpectedToken(this.lookahead,a.Messages.LetInLexicalBinding)}e.push(this.lookahead);r=this.parseVariableIdentifier(t)}return r};Parser.prototype.parsePatternWithDefault=function(e,t){var r=this.lookahead;var i=this.parsePattern(e,t);if(this.match("=")){this.nextToken();var n=this.context.allowYield;this.context.allowYield=true;var a=this.isolateCoverGrammar(this.parseAssignmentExpression);this.context.allowYield=n;i=this.finalize(this.startNode(r),new u.AssignmentPattern(i,a))}return i};Parser.prototype.parseVariableIdentifier=function(e){var t=this.createNode();var r=this.nextToken();if(r.type===4&&r.value==="yield"){if(this.context.strict){this.tolerateUnexpectedToken(r,a.Messages.StrictReservedWord)}else if(!this.context.allowYield){this.throwUnexpectedToken(r)}}else if(r.type!==3){if(this.context.strict&&r.type===4&&this.scanner.isStrictModeReservedWord(r.value)){this.tolerateUnexpectedToken(r,a.Messages.StrictReservedWord)}else{if(this.context.strict||r.value!=="let"||e!=="var"){this.throwUnexpectedToken(r)}}}else if((this.context.isModule||this.context.await)&&r.type===3&&r.value==="await"){this.tolerateUnexpectedToken(r)}return this.finalize(t,new u.Identifier(r.value))};Parser.prototype.parseVariableDeclaration=function(e){var t=this.createNode();var r=[];var i=this.parsePattern(r,"var");if(this.context.strict&&i.type===o.Syntax.Identifier){if(this.scanner.isRestrictedWord(i.name)){this.tolerateError(a.Messages.StrictVarName)}}var n=null;if(this.match("=")){this.nextToken();n=this.isolateCoverGrammar(this.parseAssignmentExpression)}else if(i.type!==o.Syntax.Identifier&&!e.inFor){this.expect("=")}return this.finalize(t,new u.VariableDeclarator(i,n))};Parser.prototype.parseVariableDeclarationList=function(e){var t={inFor:e.inFor};var r=[];r.push(this.parseVariableDeclaration(t));while(this.match(",")){this.nextToken();r.push(this.parseVariableDeclaration(t))}return r};Parser.prototype.parseVariableStatement=function(){var e=this.createNode();this.expectKeyword("var");var t=this.parseVariableDeclarationList({inFor:false});this.consumeSemicolon();return this.finalize(e,new u.VariableDeclaration(t,"var"))};Parser.prototype.parseEmptyStatement=function(){var e=this.createNode();this.expect(";");return this.finalize(e,new u.EmptyStatement)};Parser.prototype.parseExpressionStatement=function(){var e=this.createNode();var t=this.parseExpression();this.consumeSemicolon();return this.finalize(e,new u.ExpressionStatement(t))};Parser.prototype.parseIfClause=function(){if(this.context.strict&&this.matchKeyword("function")){this.tolerateError(a.Messages.StrictFunction)}return this.parseStatement()};Parser.prototype.parseIfStatement=function(){var e=this.createNode();var t;var r=null;this.expectKeyword("if");this.expect("(");var i=this.parseExpression();if(!this.match(")")&&this.config.tolerant){this.tolerateUnexpectedToken(this.nextToken());t=this.finalize(this.createNode(),new u.EmptyStatement)}else{this.expect(")");t=this.parseIfClause();if(this.matchKeyword("else")){this.nextToken();r=this.parseIfClause()}}return this.finalize(e,new u.IfStatement(i,t,r))};Parser.prototype.parseDoWhileStatement=function(){var e=this.createNode();this.expectKeyword("do");var t=this.context.inIteration;this.context.inIteration=true;var r=this.parseStatement();this.context.inIteration=t;this.expectKeyword("while");this.expect("(");var i=this.parseExpression();if(!this.match(")")&&this.config.tolerant){this.tolerateUnexpectedToken(this.nextToken())}else{this.expect(")");if(this.match(";")){this.nextToken()}}return this.finalize(e,new u.DoWhileStatement(r,i))};Parser.prototype.parseWhileStatement=function(){var e=this.createNode();var t;this.expectKeyword("while");this.expect("(");var r=this.parseExpression();if(!this.match(")")&&this.config.tolerant){this.tolerateUnexpectedToken(this.nextToken());t=this.finalize(this.createNode(),new u.EmptyStatement)}else{this.expect(")");var i=this.context.inIteration;this.context.inIteration=true;t=this.parseStatement();this.context.inIteration=i}return this.finalize(e,new u.WhileStatement(r,t))};Parser.prototype.parseForStatement=function(){var e=null;var t=null;var r=null;var i=true;var n,s;var l=this.createNode();this.expectKeyword("for");this.expect("(");if(this.match(";")){this.nextToken()}else{if(this.matchKeyword("var")){e=this.createNode();this.nextToken();var f=this.context.allowIn;this.context.allowIn=false;var c=this.parseVariableDeclarationList({inFor:true});this.context.allowIn=f;if(c.length===1&&this.matchKeyword("in")){var h=c[0];if(h.init&&(h.id.type===o.Syntax.ArrayPattern||h.id.type===o.Syntax.ObjectPattern||this.context.strict)){this.tolerateError(a.Messages.ForInOfLoopInitializer,"for-in")}e=this.finalize(e,new u.VariableDeclaration(c,"var"));this.nextToken();n=e;s=this.parseExpression();e=null}else if(c.length===1&&c[0].init===null&&this.matchContextualKeyword("of")){e=this.finalize(e,new u.VariableDeclaration(c,"var"));this.nextToken();n=e;s=this.parseAssignmentExpression();e=null;i=false}else{e=this.finalize(e,new u.VariableDeclaration(c,"var"));this.expect(";")}}else if(this.matchKeyword("const")||this.matchKeyword("let")){e=this.createNode();var p=this.nextToken().value;if(!this.context.strict&&this.lookahead.value==="in"){e=this.finalize(e,new u.Identifier(p));this.nextToken();n=e;s=this.parseExpression();e=null}else{var f=this.context.allowIn;this.context.allowIn=false;var c=this.parseBindingList(p,{inFor:true});this.context.allowIn=f;if(c.length===1&&c[0].init===null&&this.matchKeyword("in")){e=this.finalize(e,new u.VariableDeclaration(c,p));this.nextToken();n=e;s=this.parseExpression();e=null}else if(c.length===1&&c[0].init===null&&this.matchContextualKeyword("of")){e=this.finalize(e,new u.VariableDeclaration(c,p));this.nextToken();n=e;s=this.parseAssignmentExpression();e=null;i=false}else{this.consumeSemicolon();e=this.finalize(e,new u.VariableDeclaration(c,p))}}}else{var v=this.lookahead;var f=this.context.allowIn;this.context.allowIn=false;e=this.inheritCoverGrammar(this.parseAssignmentExpression);this.context.allowIn=f;if(this.matchKeyword("in")){if(!this.context.isAssignmentTarget||e.type===o.Syntax.AssignmentExpression){this.tolerateError(a.Messages.InvalidLHSInForIn)}this.nextToken();this.reinterpretExpressionAsPattern(e);n=e;s=this.parseExpression();e=null}else if(this.matchContextualKeyword("of")){if(!this.context.isAssignmentTarget||e.type===o.Syntax.AssignmentExpression){this.tolerateError(a.Messages.InvalidLHSInForLoop)}this.nextToken();this.reinterpretExpressionAsPattern(e);n=e;s=this.parseAssignmentExpression();e=null;i=false}else{if(this.match(",")){var d=[e];while(this.match(",")){this.nextToken();d.push(this.isolateCoverGrammar(this.parseAssignmentExpression))}e=this.finalize(this.startNode(v),new u.SequenceExpression(d))}this.expect(";")}}}if(typeof n==="undefined"){if(!this.match(";")){t=this.parseExpression()}this.expect(";");if(!this.match(")")){r=this.parseExpression()}}var D;if(!this.match(")")&&this.config.tolerant){this.tolerateUnexpectedToken(this.nextToken());D=this.finalize(this.createNode(),new u.EmptyStatement)}else{this.expect(")");var m=this.context.inIteration;this.context.inIteration=true;D=this.isolateCoverGrammar(this.parseStatement);this.context.inIteration=m}return typeof n==="undefined"?this.finalize(l,new u.ForStatement(e,t,r,D)):i?this.finalize(l,new u.ForInStatement(n,s,D)):this.finalize(l,new u.ForOfStatement(n,s,D))};Parser.prototype.parseContinueStatement=function(){var e=this.createNode();this.expectKeyword("continue");var t=null;if(this.lookahead.type===3&&!this.hasLineTerminator){var r=this.parseVariableIdentifier();t=r;var i="$"+r.name;if(!Object.prototype.hasOwnProperty.call(this.context.labelSet,i)){this.throwError(a.Messages.UnknownLabel,r.name)}}this.consumeSemicolon();if(t===null&&!this.context.inIteration){this.throwError(a.Messages.IllegalContinue)}return this.finalize(e,new u.ContinueStatement(t))};Parser.prototype.parseBreakStatement=function(){var e=this.createNode();this.expectKeyword("break");var t=null;if(this.lookahead.type===3&&!this.hasLineTerminator){var r=this.parseVariableIdentifier();var i="$"+r.name;if(!Object.prototype.hasOwnProperty.call(this.context.labelSet,i)){this.throwError(a.Messages.UnknownLabel,r.name)}t=r}this.consumeSemicolon();if(t===null&&!this.context.inIteration&&!this.context.inSwitch){this.throwError(a.Messages.IllegalBreak)}return this.finalize(e,new u.BreakStatement(t))};Parser.prototype.parseReturnStatement=function(){if(!this.context.inFunctionBody){this.tolerateError(a.Messages.IllegalReturn)}var e=this.createNode();this.expectKeyword("return");var t=!this.match(";")&&!this.match("}")&&!this.hasLineTerminator&&this.lookahead.type!==2||this.lookahead.type===8||this.lookahead.type===10;var r=t?this.parseExpression():null;this.consumeSemicolon();return this.finalize(e,new u.ReturnStatement(r))};Parser.prototype.parseWithStatement=function(){if(this.context.strict){this.tolerateError(a.Messages.StrictModeWith)}var e=this.createNode();var t;this.expectKeyword("with");this.expect("(");var r=this.parseExpression();if(!this.match(")")&&this.config.tolerant){this.tolerateUnexpectedToken(this.nextToken());t=this.finalize(this.createNode(),new u.EmptyStatement)}else{this.expect(")");t=this.parseStatement()}return this.finalize(e,new u.WithStatement(r,t))};Parser.prototype.parseSwitchCase=function(){var e=this.createNode();var t;if(this.matchKeyword("default")){this.nextToken();t=null}else{this.expectKeyword("case");t=this.parseExpression()}this.expect(":");var r=[];while(true){if(this.match("}")||this.matchKeyword("default")||this.matchKeyword("case")){break}r.push(this.parseStatementListItem())}return this.finalize(e,new u.SwitchCase(t,r))};Parser.prototype.parseSwitchStatement=function(){var e=this.createNode();this.expectKeyword("switch");this.expect("(");var t=this.parseExpression();this.expect(")");var r=this.context.inSwitch;this.context.inSwitch=true;var i=[];var n=false;this.expect("{");while(true){if(this.match("}")){break}var s=this.parseSwitchCase();if(s.test===null){if(n){this.throwError(a.Messages.MultipleDefaultsInSwitch)}n=true}i.push(s)}this.expect("}");this.context.inSwitch=r;return this.finalize(e,new u.SwitchStatement(t,i))};Parser.prototype.parseLabelledStatement=function(){var e=this.createNode();var t=this.parseExpression();var r;if(t.type===o.Syntax.Identifier&&this.match(":")){this.nextToken();var i=t;var n="$"+i.name;if(Object.prototype.hasOwnProperty.call(this.context.labelSet,n)){this.throwError(a.Messages.Redeclaration,"Label",i.name)}this.context.labelSet[n]=true;var s=void 0;if(this.matchKeyword("class")){this.tolerateUnexpectedToken(this.lookahead);s=this.parseClassDeclaration()}else if(this.matchKeyword("function")){var l=this.lookahead;var f=this.parseFunctionDeclaration();if(this.context.strict){this.tolerateUnexpectedToken(l,a.Messages.StrictFunction)}else if(f.generator){this.tolerateUnexpectedToken(l,a.Messages.GeneratorInLegacyContext)}s=f}else{s=this.parseStatement()}delete this.context.labelSet[n];r=new u.LabeledStatement(i,s)}else{this.consumeSemicolon();r=new u.ExpressionStatement(t)}return this.finalize(e,r)};Parser.prototype.parseThrowStatement=function(){var e=this.createNode();this.expectKeyword("throw");if(this.hasLineTerminator){this.throwError(a.Messages.NewlineAfterThrow)}var t=this.parseExpression();this.consumeSemicolon();return this.finalize(e,new u.ThrowStatement(t))};Parser.prototype.parseCatchClause=function(){var e=this.createNode();this.expectKeyword("catch");this.expect("(");if(this.match(")")){this.throwUnexpectedToken(this.lookahead)}var t=[];var r=this.parsePattern(t);var i={};for(var n=0;n0){this.tolerateError(a.Messages.BadGetterArity)}var n=this.parsePropertyMethod(i);this.context.allowYield=r;return this.finalize(e,new u.FunctionExpression(null,i.params,n,t))};Parser.prototype.parseSetterMethod=function(){var e=this.createNode();var t=false;var r=this.context.allowYield;this.context.allowYield=!t;var i=this.parseFormalParameters();if(i.params.length!==1){this.tolerateError(a.Messages.BadSetterArity)}else if(i.params[0]instanceof u.RestElement){this.tolerateError(a.Messages.BadSetterRestParameter)}var n=this.parsePropertyMethod(i);this.context.allowYield=r;return this.finalize(e,new u.FunctionExpression(null,i.params,n,t))};Parser.prototype.parseGeneratorMethod=function(){var e=this.createNode();var t=true;var r=this.context.allowYield;this.context.allowYield=true;var i=this.parseFormalParameters();this.context.allowYield=false;var n=this.parsePropertyMethod(i);this.context.allowYield=r;return this.finalize(e,new u.FunctionExpression(null,i.params,n,t))};Parser.prototype.isStartOfExpression=function(){var e=true;var t=this.lookahead.value;switch(this.lookahead.type){case 7:e=t==="["||t==="("||t==="{"||t==="+"||t==="-"||t==="!"||t==="~"||t==="++"||t==="--"||t==="/"||t==="/=";break;case 4:e=t==="class"||t==="delete"||t==="function"||t==="let"||t==="new"||t==="super"||t==="this"||t==="typeof"||t==="void"||t==="yield";break;default:break}return e};Parser.prototype.parseYieldExpression=function(){var e=this.createNode();this.expectKeyword("yield");var t=null;var r=false;if(!this.hasLineTerminator){var i=this.context.allowYield;this.context.allowYield=false;r=this.match("*");if(r){this.nextToken();t=this.parseAssignmentExpression()}else if(this.isStartOfExpression()){t=this.parseAssignmentExpression()}this.context.allowYield=i}return this.finalize(e,new u.YieldExpression(t,r))};Parser.prototype.parseClassElement=function(e){var t=this.lookahead;var r=this.createNode();var i="";var n=null;var s=null;var o=false;var l=false;var f=false;var c=false;if(this.match("*")){this.nextToken()}else{o=this.match("[");n=this.parseObjectPropertyKey();var h=n;if(h.name==="static"&&(this.qualifiedPropertyName(this.lookahead)||this.match("*"))){t=this.lookahead;f=true;o=this.match("[");if(this.match("*")){this.nextToken()}else{n=this.parseObjectPropertyKey()}}if(t.type===3&&!this.hasLineTerminator&&t.value==="async"){var p=this.lookahead.value;if(p!==":"&&p!=="("&&p!=="*"){c=true;t=this.lookahead;n=this.parseObjectPropertyKey();if(t.type===3&&t.value==="constructor"){this.tolerateUnexpectedToken(t,a.Messages.ConstructorIsAsync)}}}}var v=this.qualifiedPropertyName(this.lookahead);if(t.type===3){if(t.value==="get"&&v){i="get";o=this.match("[");n=this.parseObjectPropertyKey();this.context.allowYield=false;s=this.parseGetterMethod()}else if(t.value==="set"&&v){i="set";o=this.match("[");n=this.parseObjectPropertyKey();s=this.parseSetterMethod()}}else if(t.type===7&&t.value==="*"&&v){i="init";o=this.match("[");n=this.parseObjectPropertyKey();s=this.parseGeneratorMethod();l=true}if(!i&&n&&this.match("(")){i="init";s=c?this.parsePropertyMethodAsyncFunction():this.parsePropertyMethodFunction();l=true}if(!i){this.throwUnexpectedToken(this.lookahead)}if(i==="init"){i="method"}if(!o){if(f&&this.isPropertyKey(n,"prototype")){this.throwUnexpectedToken(t,a.Messages.StaticPrototype)}if(!f&&this.isPropertyKey(n,"constructor")){if(i!=="method"||!l||s&&s.generator){this.throwUnexpectedToken(t,a.Messages.ConstructorSpecialMethod)}if(e.value){this.throwUnexpectedToken(t,a.Messages.DuplicateConstructor)}else{e.value=true}i="constructor"}}return this.finalize(r,new u.MethodDefinition(n,o,s,i,f))};Parser.prototype.parseClassElementList=function(){var e=[];var t={value:false};this.expect("{");while(!this.match("}")){if(this.match(";")){this.nextToken()}else{e.push(this.parseClassElement(t))}}this.expect("}");return e};Parser.prototype.parseClassBody=function(){var e=this.createNode();var t=this.parseClassElementList();return this.finalize(e,new u.ClassBody(t))};Parser.prototype.parseClassDeclaration=function(e){var t=this.createNode();var r=this.context.strict;this.context.strict=true;this.expectKeyword("class");var i=e&&this.lookahead.type!==3?null:this.parseVariableIdentifier();var n=null;if(this.matchKeyword("extends")){this.nextToken();n=this.isolateCoverGrammar(this.parseLeftHandSideExpressionAllowCall)}var a=this.parseClassBody();this.context.strict=r;return this.finalize(t,new u.ClassDeclaration(i,n,a))};Parser.prototype.parseClassExpression=function(){var e=this.createNode();var t=this.context.strict;this.context.strict=true;this.expectKeyword("class");var r=this.lookahead.type===3?this.parseVariableIdentifier():null;var i=null;if(this.matchKeyword("extends")){this.nextToken();i=this.isolateCoverGrammar(this.parseLeftHandSideExpressionAllowCall)}var n=this.parseClassBody();this.context.strict=t;return this.finalize(e,new u.ClassExpression(r,i,n))};Parser.prototype.parseModule=function(){this.context.strict=true;this.context.isModule=true;this.scanner.isModule=true;var e=this.createNode();var t=this.parseDirectivePrologues();while(this.lookahead.type!==2){t.push(this.parseStatementListItem())}return this.finalize(e,new u.Module(t))};Parser.prototype.parseScript=function(){var e=this.createNode();var t=this.parseDirectivePrologues();while(this.lookahead.type!==2){t.push(this.parseStatementListItem())}return this.finalize(e,new u.Script(t))};Parser.prototype.parseModuleSpecifier=function(){var e=this.createNode();if(this.lookahead.type!==8){this.throwError(a.Messages.InvalidModuleSpecifier)}var t=this.nextToken();var r=this.getTokenRaw(t);return this.finalize(e,new u.Literal(t.value,r))};Parser.prototype.parseImportSpecifier=function(){var e=this.createNode();var t;var r;if(this.lookahead.type===3){t=this.parseVariableIdentifier();r=t;if(this.matchContextualKeyword("as")){this.nextToken();r=this.parseVariableIdentifier()}}else{t=this.parseIdentifierName();r=t;if(this.matchContextualKeyword("as")){this.nextToken();r=this.parseVariableIdentifier()}else{this.throwUnexpectedToken(this.nextToken())}}return this.finalize(e,new u.ImportSpecifier(r,t))};Parser.prototype.parseNamedImports=function(){this.expect("{");var e=[];while(!this.match("}")){e.push(this.parseImportSpecifier());if(!this.match("}")){this.expect(",")}}this.expect("}");return e};Parser.prototype.parseImportDefaultSpecifier=function(){var e=this.createNode();var t=this.parseIdentifierName();return this.finalize(e,new u.ImportDefaultSpecifier(t))};Parser.prototype.parseImportNamespaceSpecifier=function(){var e=this.createNode();this.expect("*");if(!this.matchContextualKeyword("as")){this.throwError(a.Messages.NoAsAfterImportNamespace)}this.nextToken();var t=this.parseIdentifierName();return this.finalize(e,new u.ImportNamespaceSpecifier(t))};Parser.prototype.parseImportDeclaration=function(){if(this.context.inFunctionBody){this.throwError(a.Messages.IllegalImportDeclaration)}var e=this.createNode();this.expectKeyword("import");var t;var r=[];if(this.lookahead.type===8){t=this.parseModuleSpecifier()}else{if(this.match("{")){r=r.concat(this.parseNamedImports())}else if(this.match("*")){r.push(this.parseImportNamespaceSpecifier())}else if(this.isIdentifierName(this.lookahead)&&!this.matchKeyword("default")){r.push(this.parseImportDefaultSpecifier());if(this.match(",")){this.nextToken();if(this.match("*")){r.push(this.parseImportNamespaceSpecifier())}else if(this.match("{")){r=r.concat(this.parseNamedImports())}else{this.throwUnexpectedToken(this.lookahead)}}}else{this.throwUnexpectedToken(this.nextToken())}if(!this.matchContextualKeyword("from")){var i=this.lookahead.value?a.Messages.UnexpectedToken:a.Messages.MissingFromClause;this.throwError(i,this.lookahead.value)}this.nextToken();t=this.parseModuleSpecifier()}this.consumeSemicolon();return this.finalize(e,new u.ImportDeclaration(r,t))};Parser.prototype.parseExportSpecifier=function(){var e=this.createNode();var t=this.parseIdentifierName();var r=t;if(this.matchContextualKeyword("as")){this.nextToken();r=this.parseIdentifierName()}return this.finalize(e,new u.ExportSpecifier(t,r))};Parser.prototype.parseExportDeclaration=function(){if(this.context.inFunctionBody){this.throwError(a.Messages.IllegalExportDeclaration)}var e=this.createNode();this.expectKeyword("export");var t;if(this.matchKeyword("default")){this.nextToken();if(this.matchKeyword("function")){var r=this.parseFunctionDeclaration(true);t=this.finalize(e,new u.ExportDefaultDeclaration(r))}else if(this.matchKeyword("class")){var r=this.parseClassDeclaration(true);t=this.finalize(e,new u.ExportDefaultDeclaration(r))}else if(this.matchContextualKeyword("async")){var r=this.matchAsyncFunction()?this.parseFunctionDeclaration(true):this.parseAssignmentExpression();t=this.finalize(e,new u.ExportDefaultDeclaration(r))}else{if(this.matchContextualKeyword("from")){this.throwError(a.Messages.UnexpectedToken,this.lookahead.value)}var r=this.match("{")?this.parseObjectInitializer():this.match("[")?this.parseArrayInitializer():this.parseAssignmentExpression();this.consumeSemicolon();t=this.finalize(e,new u.ExportDefaultDeclaration(r))}}else if(this.match("*")){this.nextToken();if(!this.matchContextualKeyword("from")){var i=this.lookahead.value?a.Messages.UnexpectedToken:a.Messages.MissingFromClause;this.throwError(i,this.lookahead.value)}this.nextToken();var n=this.parseModuleSpecifier();this.consumeSemicolon();t=this.finalize(e,new u.ExportAllDeclaration(n))}else if(this.lookahead.type===4){var r=void 0;switch(this.lookahead.value){case"let":case"const":r=this.parseLexicalDeclaration({inFor:false});break;case"var":case"class":case"function":r=this.parseStatementListItem();break;default:this.throwUnexpectedToken(this.lookahead)}t=this.finalize(e,new u.ExportNamedDeclaration(r,[],null))}else if(this.matchAsyncFunction()){var r=this.parseFunctionDeclaration();t=this.finalize(e,new u.ExportNamedDeclaration(r,[],null))}else{var s=[];var o=null;var l=false;this.expect("{");while(!this.match("}")){l=l||this.matchKeyword("default");s.push(this.parseExportSpecifier());if(!this.match("}")){this.expect(",")}}this.expect("}");if(this.matchContextualKeyword("from")){this.nextToken();o=this.parseModuleSpecifier();this.consumeSemicolon()}else if(l){var i=this.lookahead.value?a.Messages.UnexpectedToken:a.Messages.MissingFromClause;this.throwError(i,this.lookahead.value)}else{this.consumeSemicolon()}t=this.finalize(e,new u.ExportNamedDeclaration(null,s,o))}return t};return Parser}();t.Parser=c},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});function assert(e,t){if(!e){throw new Error("ASSERT: "+t)}}t.assert=assert},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=function(){function ErrorHandler(){this.errors=[];this.tolerant=false}ErrorHandler.prototype.recordError=function(e){this.errors.push(e)};ErrorHandler.prototype.tolerate=function(e){if(this.tolerant){this.recordError(e)}else{throw e}};ErrorHandler.prototype.constructError=function(e,t){var r=new Error(e);try{throw r}catch(e){if(Object.create&&Object.defineProperty){r=Object.create(e);Object.defineProperty(r,"column",{value:t})}}return r};ErrorHandler.prototype.createError=function(e,t,r,i){var n="Line "+t+": "+i;var a=this.constructError(n,r);a.index=e;a.lineNumber=t;a.description=i;return a};ErrorHandler.prototype.throwError=function(e,t,r,i){throw this.createError(e,t,r,i)};ErrorHandler.prototype.tolerateError=function(e,t,r,i){var n=this.createError(e,t,r,i);if(this.tolerant){this.recordError(n)}else{throw n}};return ErrorHandler}();t.ErrorHandler=r},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.Messages={BadGetterArity:"Getter must not have any formal parameters",BadSetterArity:"Setter must have exactly one formal parameter",BadSetterRestParameter:"Setter function argument must not be a rest parameter",ConstructorIsAsync:"Class constructor may not be an async method",ConstructorSpecialMethod:"Class constructor may not be an accessor",DeclarationMissingInitializer:"Missing initializer in %0 declaration",DefaultRestParameter:"Unexpected token =",DuplicateBinding:"Duplicate binding %0",DuplicateConstructor:"A class may only have one constructor",DuplicateProtoProperty:"Duplicate __proto__ fields are not allowed in object literals",ForInOfLoopInitializer:"%0 loop variable declaration may not have an initializer",GeneratorInLegacyContext:"Generator declarations are not allowed in legacy contexts",IllegalBreak:"Illegal break statement",IllegalContinue:"Illegal continue statement",IllegalExportDeclaration:"Unexpected token",IllegalImportDeclaration:"Unexpected token",IllegalLanguageModeDirective:"Illegal 'use strict' directive in function with non-simple parameter list",IllegalReturn:"Illegal return statement",InvalidEscapedReservedWord:"Keyword must not contain escaped characters",InvalidHexEscapeSequence:"Invalid hexadecimal escape sequence",InvalidLHSInAssignment:"Invalid left-hand side in assignment",InvalidLHSInForIn:"Invalid left-hand side in for-in",InvalidLHSInForLoop:"Invalid left-hand side in for-loop",InvalidModuleSpecifier:"Unexpected token",InvalidRegExp:"Invalid regular expression",LetInLexicalBinding:"let is disallowed as a lexically bound name",MissingFromClause:"Unexpected token",MultipleDefaultsInSwitch:"More than one default clause in switch statement",NewlineAfterThrow:"Illegal newline after throw",NoAsAfterImportNamespace:"Unexpected token",NoCatchOrFinally:"Missing catch or finally after try",ParameterAfterRestParameter:"Rest parameter must be last formal parameter",Redeclaration:"%0 '%1' has already been declared",StaticPrototype:"Classes may not have static property named prototype",StrictCatchVariable:"Catch variable may not be eval or arguments in strict mode",StrictDelete:"Delete of an unqualified identifier in strict mode.",StrictFunction:"In strict mode code, functions can only be declared at top level or inside a block",StrictFunctionName:"Function name may not be eval or arguments in strict mode",StrictLHSAssignment:"Assignment to eval or arguments is not allowed in strict mode",StrictLHSPostfix:"Postfix increment/decrement may not have eval or arguments operand in strict mode",StrictLHSPrefix:"Prefix increment/decrement may not have eval or arguments operand in strict mode",StrictModeWith:"Strict mode code may not include a with statement",StrictOctalLiteral:"Octal literals are not allowed in strict mode.",StrictParamDupe:"Strict mode function may not have duplicate parameter names",StrictParamName:"Parameter name eval or arguments is not allowed in strict mode",StrictReservedWord:"Use of future reserved word in strict mode",StrictVarName:"Variable name may not be eval or arguments in strict mode",TemplateOctalLiteral:"Octal literals are not allowed in template strings.",UnexpectedEOS:"Unexpected end of input",UnexpectedIdentifier:"Unexpected identifier",UnexpectedNumber:"Unexpected number",UnexpectedReserved:"Unexpected reserved word",UnexpectedString:"Unexpected string",UnexpectedTemplate:"Unexpected quasi %0",UnexpectedToken:"Unexpected token %0",UnexpectedTokenIllegal:"Unexpected token ILLEGAL",UnknownLabel:"Undefined label '%0'",UnterminatedRegExp:"Invalid regular expression: missing /"}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:true});var i=r(9);var n=r(4);var a=r(11);function hexValue(e){return"0123456789abcdef".indexOf(e.toLowerCase())}function octalValue(e){return"01234567".indexOf(e)}var u=function(){function Scanner(e,t){this.source=e;this.errorHandler=t;this.trackComment=false;this.isModule=false;this.length=e.length;this.index=0;this.lineNumber=e.length>0?1:0;this.lineStart=0;this.curlyStack=[]}Scanner.prototype.saveState=function(){return{index:this.index,lineNumber:this.lineNumber,lineStart:this.lineStart}};Scanner.prototype.restoreState=function(e){this.index=e.index;this.lineNumber=e.lineNumber;this.lineStart=e.lineStart};Scanner.prototype.eof=function(){return this.index>=this.length};Scanner.prototype.throwUnexpectedToken=function(e){if(e===void 0){e=a.Messages.UnexpectedTokenIllegal}return this.errorHandler.throwError(this.index,this.lineNumber,this.index-this.lineStart+1,e)};Scanner.prototype.tolerateUnexpectedToken=function(e){if(e===void 0){e=a.Messages.UnexpectedTokenIllegal}this.errorHandler.tolerateError(this.index,this.lineNumber,this.index-this.lineStart+1,e)};Scanner.prototype.skipSingleLineComment=function(e){var t=[];var r,i;if(this.trackComment){t=[];r=this.index-e;i={start:{line:this.lineNumber,column:this.index-this.lineStart-e},end:{}}}while(!this.eof()){var a=this.source.charCodeAt(this.index);++this.index;if(n.Character.isLineTerminator(a)){if(this.trackComment){i.end={line:this.lineNumber,column:this.index-this.lineStart-1};var u={multiLine:false,slice:[r+e,this.index-1],range:[r,this.index-1],loc:i};t.push(u)}if(a===13&&this.source.charCodeAt(this.index)===10){++this.index}++this.lineNumber;this.lineStart=this.index;return t}}if(this.trackComment){i.end={line:this.lineNumber,column:this.index-this.lineStart};var u={multiLine:false,slice:[r+e,this.index],range:[r,this.index],loc:i};t.push(u)}return t};Scanner.prototype.skipMultiLineComment=function(){var e=[];var t,r;if(this.trackComment){e=[];t=this.index-2;r={start:{line:this.lineNumber,column:this.index-this.lineStart-2},end:{}}}while(!this.eof()){var i=this.source.charCodeAt(this.index);if(n.Character.isLineTerminator(i)){if(i===13&&this.source.charCodeAt(this.index+1)===10){++this.index}++this.lineNumber;++this.index;this.lineStart=this.index}else if(i===42){if(this.source.charCodeAt(this.index+1)===47){this.index+=2;if(this.trackComment){r.end={line:this.lineNumber,column:this.index-this.lineStart};var a={multiLine:true,slice:[t+2,this.index-2],range:[t,this.index],loc:r};e.push(a)}return e}++this.index}else{++this.index}}if(this.trackComment){r.end={line:this.lineNumber,column:this.index-this.lineStart};var a={multiLine:true,slice:[t+2,this.index],range:[t,this.index],loc:r};e.push(a)}this.tolerateUnexpectedToken();return e};Scanner.prototype.scanComments=function(){var e;if(this.trackComment){e=[]}var t=this.index===0;while(!this.eof()){var r=this.source.charCodeAt(this.index);if(n.Character.isWhiteSpace(r)){++this.index}else if(n.Character.isLineTerminator(r)){++this.index;if(r===13&&this.source.charCodeAt(this.index)===10){++this.index}++this.lineNumber;this.lineStart=this.index;t=true}else if(r===47){r=this.source.charCodeAt(this.index+1);if(r===47){this.index+=2;var i=this.skipSingleLineComment(2);if(this.trackComment){e=e.concat(i)}t=true}else if(r===42){this.index+=2;var i=this.skipMultiLineComment();if(this.trackComment){e=e.concat(i)}}else{break}}else if(t&&r===45){if(this.source.charCodeAt(this.index+1)===45&&this.source.charCodeAt(this.index+2)===62){this.index+=3;var i=this.skipSingleLineComment(3);if(this.trackComment){e=e.concat(i)}}else{break}}else if(r===60&&!this.isModule){if(this.source.slice(this.index+1,this.index+4)==="!--"){this.index+=4;var i=this.skipSingleLineComment(4);if(this.trackComment){e=e.concat(i)}}else{break}}else{break}}return e};Scanner.prototype.isFutureReservedWord=function(e){switch(e){case"enum":case"export":case"import":case"super":return true;default:return false}};Scanner.prototype.isStrictModeReservedWord=function(e){switch(e){case"implements":case"interface":case"package":case"private":case"protected":case"public":case"static":case"yield":case"let":return true;default:return false}};Scanner.prototype.isRestrictedWord=function(e){return e==="eval"||e==="arguments"};Scanner.prototype.isKeyword=function(e){switch(e.length){case 2:return e==="if"||e==="in"||e==="do";case 3:return e==="var"||e==="for"||e==="new"||e==="try"||e==="let";case 4:return e==="this"||e==="else"||e==="case"||e==="void"||e==="with"||e==="enum";case 5:return e==="while"||e==="break"||e==="catch"||e==="throw"||e==="const"||e==="yield"||e==="class"||e==="super";case 6:return e==="return"||e==="typeof"||e==="delete"||e==="switch"||e==="export"||e==="import";case 7:return e==="default"||e==="finally"||e==="extends";case 8:return e==="function"||e==="continue"||e==="debugger";case 10:return e==="instanceof";default:return false}};Scanner.prototype.codePointAt=function(e){var t=this.source.charCodeAt(e);if(t>=55296&&t<=56319){var r=this.source.charCodeAt(e+1);if(r>=56320&&r<=57343){var i=t;t=(i-55296)*1024+r-56320+65536}}return t};Scanner.prototype.scanHexEscape=function(e){var t=e==="u"?4:2;var r=0;for(var i=0;i1114111||e!=="}"){this.throwUnexpectedToken()}return n.Character.fromCodePoint(t)};Scanner.prototype.getIdentifier=function(){var e=this.index++;while(!this.eof()){var t=this.source.charCodeAt(this.index);if(t===92){this.index=e;return this.getComplexIdentifier()}else if(t>=55296&&t<57343){this.index=e;return this.getComplexIdentifier()}if(n.Character.isIdentifierPart(t)){++this.index}else{break}}return this.source.slice(e,this.index)};Scanner.prototype.getComplexIdentifier=function(){var e=this.codePointAt(this.index);var t=n.Character.fromCodePoint(e);this.index+=t.length;var r;if(e===92){if(this.source.charCodeAt(this.index)!==117){this.throwUnexpectedToken()}++this.index;if(this.source[this.index]==="{"){++this.index;r=this.scanUnicodeCodePointEscape()}else{r=this.scanHexEscape("u");if(r===null||r==="\\"||!n.Character.isIdentifierStart(r.charCodeAt(0))){this.throwUnexpectedToken()}}t=r}while(!this.eof()){e=this.codePointAt(this.index);if(!n.Character.isIdentifierPart(e)){break}r=n.Character.fromCodePoint(e);t+=r;this.index+=r.length;if(e===92){t=t.substr(0,t.length-1);if(this.source.charCodeAt(this.index)!==117){this.throwUnexpectedToken()}++this.index;if(this.source[this.index]==="{"){++this.index;r=this.scanUnicodeCodePointEscape()}else{r=this.scanHexEscape("u");if(r===null||r==="\\"||!n.Character.isIdentifierPart(r.charCodeAt(0))){this.throwUnexpectedToken()}}t+=r}}return t};Scanner.prototype.octalToDecimal=function(e){var t=e!=="0";var r=octalValue(e);if(!this.eof()&&n.Character.isOctalDigit(this.source.charCodeAt(this.index))){t=true;r=r*8+octalValue(this.source[this.index++]);if("0123".indexOf(e)>=0&&!this.eof()&&n.Character.isOctalDigit(this.source.charCodeAt(this.index))){r=r*8+octalValue(this.source[this.index++])}}return{code:r,octal:t}};Scanner.prototype.scanIdentifier=function(){var e;var t=this.index;var r=this.source.charCodeAt(t)===92?this.getComplexIdentifier():this.getIdentifier();if(r.length===1){e=3}else if(this.isKeyword(r)){e=4}else if(r==="null"){e=5}else if(r==="true"||r==="false"){e=1}else{e=3}if(e!==3&&t+r.length!==this.index){var i=this.index;this.index=t;this.tolerateUnexpectedToken(a.Messages.InvalidEscapedReservedWord);this.index=i}return{type:e,value:r,lineNumber:this.lineNumber,lineStart:this.lineStart,start:t,end:this.index}};Scanner.prototype.scanPunctuator=function(){var e=this.index;var t=this.source[this.index];switch(t){case"(":case"{":if(t==="{"){this.curlyStack.push("{")}++this.index;break;case".":++this.index;if(this.source[this.index]==="."&&this.source[this.index+1]==="."){this.index+=2;t="..."}break;case"}":++this.index;this.curlyStack.pop();break;case")":case";":case",":case"[":case"]":case":":case"?":case"~":++this.index;break;default:t=this.source.substr(this.index,4);if(t===">>>="){this.index+=4}else{t=t.substr(0,3);if(t==="==="||t==="!=="||t===">>>"||t==="<<="||t===">>="||t==="**="){this.index+=3}else{t=t.substr(0,2);if(t==="&&"||t==="||"||t==="=="||t==="!="||t==="+="||t==="-="||t==="*="||t==="/="||t==="++"||t==="--"||t==="<<"||t===">>"||t==="&="||t==="|="||t==="^="||t==="%="||t==="<="||t===">="||t==="=>"||t==="**"){this.index+=2}else{t=this.source[this.index];if("<>=!+-*%&|^/".indexOf(t)>=0){++this.index}}}}}if(this.index===e){this.throwUnexpectedToken()}return{type:7,value:t,lineNumber:this.lineNumber,lineStart:this.lineStart,start:e,end:this.index}};Scanner.prototype.scanHexLiteral=function(e){var t="";while(!this.eof()){if(!n.Character.isHexDigit(this.source.charCodeAt(this.index))){break}t+=this.source[this.index++]}if(t.length===0){this.throwUnexpectedToken()}if(n.Character.isIdentifierStart(this.source.charCodeAt(this.index))){this.throwUnexpectedToken()}return{type:6,value:parseInt("0x"+t,16),lineNumber:this.lineNumber,lineStart:this.lineStart,start:e,end:this.index}};Scanner.prototype.scanBinaryLiteral=function(e){var t="";var r;while(!this.eof()){r=this.source[this.index];if(r!=="0"&&r!=="1"){break}t+=this.source[this.index++]}if(t.length===0){this.throwUnexpectedToken()}if(!this.eof()){r=this.source.charCodeAt(this.index);if(n.Character.isIdentifierStart(r)||n.Character.isDecimalDigit(r)){this.throwUnexpectedToken()}}return{type:6,value:parseInt(t,2),lineNumber:this.lineNumber,lineStart:this.lineStart,start:e,end:this.index}};Scanner.prototype.scanOctalLiteral=function(e,t){var r="";var i=false;if(n.Character.isOctalDigit(e.charCodeAt(0))){i=true;r="0"+this.source[this.index++]}else{++this.index}while(!this.eof()){if(!n.Character.isOctalDigit(this.source.charCodeAt(this.index))){break}r+=this.source[this.index++]}if(!i&&r.length===0){this.throwUnexpectedToken()}if(n.Character.isIdentifierStart(this.source.charCodeAt(this.index))||n.Character.isDecimalDigit(this.source.charCodeAt(this.index))){this.throwUnexpectedToken()}return{type:6,value:parseInt(r,8),octal:i,lineNumber:this.lineNumber,lineStart:this.lineStart,start:t,end:this.index}};Scanner.prototype.isImplicitOctalLiteral=function(){for(var e=this.index+1;e=0){i=i.replace(/\\u\{([0-9a-fA-F]+)\}|\\u([a-fA-F0-9]{4})/g,function(e,t,i){var u=parseInt(t||i,16);if(u>1114111){n.throwUnexpectedToken(a.Messages.InvalidRegExp)}if(u<=65535){return String.fromCharCode(u)}return r}).replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,r)}try{RegExp(i)}catch(e){this.throwUnexpectedToken(a.Messages.InvalidRegExp)}try{return new RegExp(e,t)}catch(e){return null}};Scanner.prototype.scanRegExpBody=function(){var e=this.source[this.index];i.assert(e==="/","Regular expression literal must start with a slash");var t=this.source[this.index++];var r=false;var u=false;while(!this.eof()){e=this.source[this.index++];t+=e;if(e==="\\"){e=this.source[this.index++];if(n.Character.isLineTerminator(e.charCodeAt(0))){this.throwUnexpectedToken(a.Messages.UnterminatedRegExp)}t+=e}else if(n.Character.isLineTerminator(e.charCodeAt(0))){this.throwUnexpectedToken(a.Messages.UnterminatedRegExp)}else if(r){if(e==="]"){r=false}}else{if(e==="/"){u=true;break}else if(e==="["){r=true}}}if(!u){this.throwUnexpectedToken(a.Messages.UnterminatedRegExp)}return t.substr(1,t.length-2)};Scanner.prototype.scanRegExpFlags=function(){var e="";var t="";while(!this.eof()){var r=this.source[this.index];if(!n.Character.isIdentifierPart(r.charCodeAt(0))){break}++this.index;if(r==="\\"&&!this.eof()){r=this.source[this.index];if(r==="u"){++this.index;var i=this.index;var a=this.scanHexEscape("u");if(a!==null){t+=a;for(e+="\\u";i=55296&&e<57343){if(n.Character.isIdentifierStart(this.codePointAt(this.index))){return this.scanIdentifier()}}return this.scanPunctuator()};return Scanner}();t.Scanner=u},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.TokenName={};t.TokenName[1]="Boolean";t.TokenName[2]="";t.TokenName[3]="Identifier";t.TokenName[4]="Keyword";t.TokenName[5]="Null";t.TokenName[6]="Numeric";t.TokenName[7]="Punctuator";t.TokenName[8]="String";t.TokenName[9]="RegularExpression";t.TokenName[10]="Template"},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.XHTMLEntities={quot:'"',amp:"&",apos:"'",gt:">",nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"­",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",fnof:"ƒ",circ:"ˆ",tilde:"˜",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",ensp:" ",emsp:" ",thinsp:" ",zwnj:"‌",zwj:"‍",lrm:"‎",rlm:"‏",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",bull:"•",hellip:"…",permil:"‰",prime:"′",Prime:"″",lsaquo:"‹",rsaquo:"›",oline:"‾",frasl:"⁄",euro:"€",image:"ℑ",weierp:"℘",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦",lang:"⟨",rang:"⟩"}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:true});var i=r(10);var n=r(12);var a=r(13);var u=function(){function Reader(){this.values=[];this.curly=this.paren=-1}Reader.prototype.beforeFunctionExpression=function(e){return["(","{","[","in","typeof","instanceof","new","return","case","delete","throw","void","=","+=","-=","*=","**=","/=","%=","<<=",">>=",">>>=","&=","|=","^=",",","+","-","*","**","/","%","++","--","<<",">>",">>>","&","|","^","!","~","&&","||","?",":","===","==",">=","<=","<",">","!=","!=="].indexOf(e)>=0};Reader.prototype.isRegexStart=function(){var e=this.values[this.values.length-1];var t=e!==null;switch(e){case"this":case"]":t=false;break;case")":var r=this.values[this.paren-1];t=r==="if"||r==="while"||r==="for"||r==="with";break;case"}":t=false;if(this.values[this.curly-3]==="function"){var i=this.values[this.curly-4];t=i?!this.beforeFunctionExpression(i):false}else if(this.values[this.curly-4]==="function"){var i=this.values[this.curly-5];t=i?!this.beforeFunctionExpression(i):true}break;default:break}return t};Reader.prototype.push=function(e){if(e.type===7||e.type===4){if(e.value==="{"){this.curly=this.values.length}else if(e.value==="("){this.paren=this.values.length}this.values.push(e.value)}else{this.values.push(null)}};return Reader}();var s=function(){function Tokenizer(e,t){this.errorHandler=new i.ErrorHandler;this.errorHandler.tolerant=t?typeof t.tolerant==="boolean"&&t.tolerant:false;this.scanner=new n.Scanner(e,this.errorHandler);this.scanner.trackComment=t?typeof t.comment==="boolean"&&t.comment:false;this.trackRange=t?typeof t.range==="boolean"&&t.range:false;this.trackLoc=t?typeof t.loc==="boolean"&&t.loc:false;this.buffer=[];this.reader=new u}Tokenizer.prototype.errors=function(){return this.errorHandler.errors};Tokenizer.prototype.getNextToken=function(){if(this.buffer.length===0){var e=this.scanner.scanComments();if(this.scanner.trackComment){for(var t=0;tt){if(e.charAt(r-1)!==" "){break}r--}return r}},,function(e,t,r){"use strict";var i=r(347)("unified-engine:file-pipeline:stringify");var n=r(928);var a=r(212);e.exports=stringify;function stringify(e,t){var r=e.processor;var u=e.tree;var s;if(n(t).fatal){i("Not compiling failed document");return}if(!e.output&&!e.out&&!e.alwaysStringify){i("Not compiling document without output settings");return}i("Compiling `%s`",t.path);if(e.inspect){if(t.path){t.extname=".txt"}s=a[e.color?"color":"noColor"](u)+"\n"}else if(e.treeOut){if(t.path){t.extname=".json"}s=JSON.stringify(u,null,2)+"\n"}else{s=r.stringify(u,t)}t.contents=s;i("Compiled document")}},,,function(e,t,r){"use strict";const i=r(624);e.exports=(e=>typeof e==="string"?e.replace(i(),""):e)},,function(e,t,r){"use strict";var i=r(260);function Mark(e,t,r,i,n){this.name=e;this.buffer=t;this.position=r;this.line=i;this.column=n}Mark.prototype.getSnippet=function getSnippet(e,t){var r,n,a,u,s;if(!this.buffer)return null;e=e||4;t=t||75;r="";n=this.position;while(n>0&&"\0\r\n…\u2028\u2029".indexOf(this.buffer.charAt(n-1))===-1){n-=1;if(this.position-n>t/2-1){r=" ... ";n+=5;break}}a="";u=this.position;while(ut/2-1){a=" ... ";u-=5;break}}s=this.buffer.slice(n,u);return i.repeat(" ",e)+r+s+a+"\n"+i.repeat(" ",e+this.position-n+r.length)+"^"};Mark.prototype.toString=function toString(e){var t,r="";if(this.name){r+='in "'+this.name+'" '}r+="at line "+(this.line+1)+", column "+(this.column+1);if(!e){t=this.getSnippet();if(t){r+=":\n"+t}}return r};e.exports=Mark},function(e,t,r){var i=r(148);var n=function(){};var a=r(405);e.exports=wrapped;function wrapped(e){function wrap(){var t=i(arguments);var r=t[t.length-1];var u=this;var s=typeof r=="function"?t.pop():n;if(!e){return s.apply(u,[null].concat(t))}if(generator(e)){return a(e).apply(u,t.concat(s))}if(e.length>t.length){try{return e.apply(u,t.concat(s))}catch(e){return s(e)}}return sync(e,s).apply(u,t)}return wrap}function sync(e,t){return function(){var r;try{r=e.apply(this,arguments)}catch(e){return t(e)}if(promise(r)){r.then(function(e){t(null,e)},t)}else{r instanceof Error?t(r):t(null,r)}}}function generator(e){return e&&e.constructor&&"GeneratorFunction"==e.constructor.name}function promise(e){return e&&"function"==typeof e.then}},,,,,,,,function(e,t,r){"use strict";var i=r(495);e.exports=i("remark-lint:no-file-name-articles",noFileNameArticles);function noFileNameArticles(e,t){var r=t.stem&&t.stem.match(/^(the|teh|an?)\b/i);if(r){t.message("Do not start file names with `"+r[0]+"`")}}},,,function(e,t,r){"use strict";var i=r(171);e.exports=newline;var n="\n";function newline(e,t,r){var a=t.charAt(0);var u;var s;var o;var l;if(a!==n){return}if(r){return true}l=1;u=t.length;s=a;o="";while(l{if(typeof e!=="string"||e.length===0){return 0}e=i(e);let t=0;for(let r=0;r=127&&i<=159){continue}if(i>=768&&i<=879){continue}if(i>65535){r++}t+=n(i)?2:1}return t})},,,,function(e){e.exports=require("stream")},,,,function(e){"use strict";e.exports=function isObject(e){return typeof e==="object"&&e!==null}},,function(e,t,r){"use strict";e.exports={position:true,gfm:true,commonmark:false,footnotes:false,pedantic:false,blocks:r(676)}},,,function(e,t,r){"use strict";var i=r(211);var n=Object.prototype.toString;function resolveYamlPairs(e){if(e===null)return true;var t,r,i,a,u,s=e;u=new Array(s.length);for(t=0,r=s.length;t=0){t=t.slice(1)}if(t===".inf"){return r===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY}else if(t===".nan"){return NaN}else if(t.indexOf(":")>=0){t.split(":").forEach(function(e){n.unshift(parseFloat(e,10))});t=0;i=1;n.forEach(function(e){t+=e*i;i*=60});return r*t}return r*parseFloat(t,10)}var u=/^[-+]?[0-9]+e/;function representYamlFloat(e,t){var r;if(isNaN(e)){switch(t){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}}else if(Number.POSITIVE_INFINITY===e){switch(t){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}}else if(Number.NEGATIVE_INFINITY===e){switch(t){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}}else if(i.isNegativeZero(e)){return"-0.0"}r=e.toString(10);return u.test(r)?r.replace("e",".e"):r}function isFloat(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||i.isNegativeZero(e))}e.exports=new n("tag:yaml.org,2002:float",{kind:"scalar",resolve:resolveYamlFloat,construct:constructYamlFloat,predicate:isFloat,represent:representYamlFloat,defaultStyle:"lowercase"})},,function(e,t,r){"use strict";const i=r(947);e.exports=((e,t,r)=>{if(typeof t==="number"){r=t}if(i.has(e.toLowerCase())){t=i.get(e.toLowerCase());const r=e.charAt(0);const n=r===r.toUpperCase();if(n){t=r.toUpperCase()+t.slice(1)}const a=e===e.toUpperCase();if(a){t=t.toUpperCase()}}else if(typeof t!=="string"){t=(e.replace(/(?:s|x|z|ch|sh)$/i,"$&e").replace(/([^aeiou])y$/i,"$1ie")+"s").replace(/i?e?s$/i,t=>{const r=e.slice(-1)===e.slice(-1).toLowerCase();return r?t.toLowerCase():t.toUpperCase()})}return Math.abs(r)===1?e:t})},function(e,t,r){"use strict";var i=r(814);e.exports=pad;var n="\n";var a=" ";var u=4;function pad(e,t){var r=e.split(n);var s=r.length;var o=i(a,t*u);while(s--){if(r[s].length!==0){r[s]=o+r[s]}}return r.join(n)}},,,,function(e){e.exports=function(e,t){return e.replace(/(\\*)(\$([_a-z0-9]+)|\${([_a-z0-9]+)})/gi,function(e,r,i,n,a){if(!(r.length%2)){return r.substring(Math.ceil(r.length/2))+(t[n||a]||"")}else{return r.substring(1)+i}})}},,,,function(e,t,r){"use strict";var i=r(211);var n=Object.prototype.hasOwnProperty;function resolveYamlSet(e){if(e===null)return true;var t,r=e;for(t in r){if(n.call(r,t)){if(r[t]!==null)return false}}return true}function constructYamlSet(e){return e!==null?e:{}}e.exports=new i("tag:yaml.org,2002:set",{kind:"mapping",resolve:resolveYamlSet,construct:constructYamlSet})},function(e){if(typeof Object.create==="function"){e.exports=function inherits(e,t){e.super_=t;e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:false,writable:true,configurable:true}})}}else{e.exports=function inherits(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype;e.prototype=new r;e.prototype.constructor=e}}},,,,,function(e){var t=Object.prototype.toString;var r=typeof Buffer.alloc==="function"&&typeof Buffer.allocUnsafe==="function"&&typeof Buffer.from==="function";function isArrayBuffer(e){return t.call(e).slice(8,-1)==="ArrayBuffer"}function fromArrayBuffer(e,t,i){t>>>=0;var n=e.byteLength-t;if(n<0){throw new RangeError("'offset' is out of bounds")}if(i===undefined){i=n}else{i>>>=0;if(i>n){throw new RangeError("'length' is out of bounds")}}return r?Buffer.from(e.slice(t,t+i)):new Buffer(new Uint8Array(e.slice(t,t+i)))}function fromString(e,t){if(typeof t!=="string"||t===""){t="utf8"}if(!Buffer.isEncoding(t)){throw new TypeError('"encoding" must be a valid string encoding')}return r?Buffer.from(e,t):new Buffer(e,t)}function bufferFrom(e,t,i){if(typeof e==="number"){throw new TypeError('"value" argument must not be a number')}if(isArrayBuffer(e)){return fromArrayBuffer(e,t,i)}if(typeof e==="string"){return fromString(e,t)}return r?Buffer.from(e):new Buffer(e)}e.exports=bufferFrom},,function(e){e.exports={AEli:"Æ",AElig:"Æ",AM:"&",AMP:"&",Aacut:"Á",Aacute:"Á",Abreve:"Ă",Acir:"Â",Acirc:"Â",Acy:"А",Afr:"𝔄",Agrav:"À",Agrave:"À",Alpha:"Α",Amacr:"Ā",And:"⩓",Aogon:"Ą",Aopf:"𝔸",ApplyFunction:"⁡",Arin:"Å",Aring:"Å",Ascr:"𝒜",Assign:"≔",Atild:"Ã",Atilde:"Ã",Aum:"Ä",Auml:"Ä",Backslash:"∖",Barv:"⫧",Barwed:"⌆",Bcy:"Б",Because:"∵",Bernoullis:"ℬ",Beta:"Β",Bfr:"𝔅",Bopf:"𝔹",Breve:"˘",Bscr:"ℬ",Bumpeq:"≎",CHcy:"Ч",COP:"©",COPY:"©",Cacute:"Ć",Cap:"⋒",CapitalDifferentialD:"ⅅ",Cayleys:"ℭ",Ccaron:"Č",Ccedi:"Ç",Ccedil:"Ç",Ccirc:"Ĉ",Cconint:"∰",Cdot:"Ċ",Cedilla:"¸",CenterDot:"·",Cfr:"ℭ",Chi:"Χ",CircleDot:"⊙",CircleMinus:"⊖",CirclePlus:"⊕",CircleTimes:"⊗",ClockwiseContourIntegral:"∲",CloseCurlyDoubleQuote:"”",CloseCurlyQuote:"’",Colon:"∷",Colone:"⩴",Congruent:"≡",Conint:"∯",ContourIntegral:"∮",Copf:"ℂ",Coproduct:"∐",CounterClockwiseContourIntegral:"∳",Cross:"⨯",Cscr:"𝒞",Cup:"⋓",CupCap:"≍",DD:"ⅅ",DDotrahd:"⤑",DJcy:"Ђ",DScy:"Ѕ",DZcy:"Џ",Dagger:"‡",Darr:"↡",Dashv:"⫤",Dcaron:"Ď",Dcy:"Д",Del:"∇",Delta:"Δ",Dfr:"𝔇",DiacriticalAcute:"´",DiacriticalDot:"˙",DiacriticalDoubleAcute:"˝",DiacriticalGrave:"`",DiacriticalTilde:"˜",Diamond:"⋄",DifferentialD:"ⅆ",Dopf:"𝔻",Dot:"¨",DotDot:"⃜",DotEqual:"≐",DoubleContourIntegral:"∯",DoubleDot:"¨",DoubleDownArrow:"⇓",DoubleLeftArrow:"⇐",DoubleLeftRightArrow:"⇔",DoubleLeftTee:"⫤",DoubleLongLeftArrow:"⟸",DoubleLongLeftRightArrow:"⟺",DoubleLongRightArrow:"⟹",DoubleRightArrow:"⇒",DoubleRightTee:"⊨",DoubleUpArrow:"⇑",DoubleUpDownArrow:"⇕",DoubleVerticalBar:"∥",DownArrow:"↓",DownArrowBar:"⤓",DownArrowUpArrow:"⇵",DownBreve:"̑",DownLeftRightVector:"⥐",DownLeftTeeVector:"⥞",DownLeftVector:"↽",DownLeftVectorBar:"⥖",DownRightTeeVector:"⥟",DownRightVector:"⇁",DownRightVectorBar:"⥗",DownTee:"⊤",DownTeeArrow:"↧",Downarrow:"⇓",Dscr:"𝒟",Dstrok:"Đ",ENG:"Ŋ",ET:"Ð",ETH:"Ð",Eacut:"É",Eacute:"É",Ecaron:"Ě",Ecir:"Ê",Ecirc:"Ê",Ecy:"Э",Edot:"Ė",Efr:"𝔈",Egrav:"È",Egrave:"È",Element:"∈",Emacr:"Ē",EmptySmallSquare:"◻",EmptyVerySmallSquare:"▫",Eogon:"Ę",Eopf:"𝔼",Epsilon:"Ε",Equal:"⩵",EqualTilde:"≂",Equilibrium:"⇌",Escr:"ℰ",Esim:"⩳",Eta:"Η",Eum:"Ë",Euml:"Ë",Exists:"∃",ExponentialE:"ⅇ",Fcy:"Ф",Ffr:"𝔉",FilledSmallSquare:"◼",FilledVerySmallSquare:"▪",Fopf:"𝔽",ForAll:"∀",Fouriertrf:"ℱ",Fscr:"ℱ",GJcy:"Ѓ",G:">",GT:">",Gamma:"Γ",Gammad:"Ϝ",Gbreve:"Ğ",Gcedil:"Ģ",Gcirc:"Ĝ",Gcy:"Г",Gdot:"Ġ",Gfr:"𝔊",Gg:"⋙",Gopf:"𝔾",GreaterEqual:"≥",GreaterEqualLess:"⋛",GreaterFullEqual:"≧",GreaterGreater:"⪢",GreaterLess:"≷",GreaterSlantEqual:"⩾",GreaterTilde:"≳",Gscr:"𝒢",Gt:"≫",HARDcy:"Ъ",Hacek:"ˇ",Hat:"^",Hcirc:"Ĥ",Hfr:"ℌ",HilbertSpace:"ℋ",Hopf:"ℍ",HorizontalLine:"─",Hscr:"ℋ",Hstrok:"Ħ",HumpDownHump:"≎",HumpEqual:"≏",IEcy:"Е",IJlig:"IJ",IOcy:"Ё",Iacut:"Í",Iacute:"Í",Icir:"Î",Icirc:"Î",Icy:"И",Idot:"İ",Ifr:"ℑ",Igrav:"Ì",Igrave:"Ì",Im:"ℑ",Imacr:"Ī",ImaginaryI:"ⅈ",Implies:"⇒",Int:"∬",Integral:"∫",Intersection:"⋂",InvisibleComma:"⁣",InvisibleTimes:"⁢",Iogon:"Į",Iopf:"𝕀",Iota:"Ι",Iscr:"ℐ",Itilde:"Ĩ",Iukcy:"І",Ium:"Ï",Iuml:"Ï",Jcirc:"Ĵ",Jcy:"Й",Jfr:"𝔍",Jopf:"𝕁",Jscr:"𝒥",Jsercy:"Ј",Jukcy:"Є",KHcy:"Х",KJcy:"Ќ",Kappa:"Κ",Kcedil:"Ķ",Kcy:"К",Kfr:"𝔎",Kopf:"𝕂",Kscr:"𝒦",LJcy:"Љ",L:"<",LT:"<",Lacute:"Ĺ",Lambda:"Λ",Lang:"⟪",Laplacetrf:"ℒ",Larr:"↞",Lcaron:"Ľ",Lcedil:"Ļ",Lcy:"Л",LeftAngleBracket:"⟨",LeftArrow:"←",LeftArrowBar:"⇤",LeftArrowRightArrow:"⇆",LeftCeiling:"⌈",LeftDoubleBracket:"⟦",LeftDownTeeVector:"⥡",LeftDownVector:"⇃",LeftDownVectorBar:"⥙",LeftFloor:"⌊",LeftRightArrow:"↔",LeftRightVector:"⥎",LeftTee:"⊣",LeftTeeArrow:"↤",LeftTeeVector:"⥚",LeftTriangle:"⊲",LeftTriangleBar:"⧏",LeftTriangleEqual:"⊴",LeftUpDownVector:"⥑",LeftUpTeeVector:"⥠",LeftUpVector:"↿",LeftUpVectorBar:"⥘",LeftVector:"↼",LeftVectorBar:"⥒",Leftarrow:"⇐",Leftrightarrow:"⇔",LessEqualGreater:"⋚",LessFullEqual:"≦",LessGreater:"≶",LessLess:"⪡",LessSlantEqual:"⩽",LessTilde:"≲",Lfr:"𝔏",Ll:"⋘",Lleftarrow:"⇚",Lmidot:"Ŀ",LongLeftArrow:"⟵",LongLeftRightArrow:"⟷",LongRightArrow:"⟶",Longleftarrow:"⟸",Longleftrightarrow:"⟺",Longrightarrow:"⟹",Lopf:"𝕃",LowerLeftArrow:"↙",LowerRightArrow:"↘",Lscr:"ℒ",Lsh:"↰",Lstrok:"Ł",Lt:"≪",Map:"⤅",Mcy:"М",MediumSpace:" ",Mellintrf:"ℳ",Mfr:"𝔐",MinusPlus:"∓",Mopf:"𝕄",Mscr:"ℳ",Mu:"Μ",NJcy:"Њ",Nacute:"Ń",Ncaron:"Ň",Ncedil:"Ņ",Ncy:"Н",NegativeMediumSpace:"​",NegativeThickSpace:"​",NegativeThinSpace:"​",NegativeVeryThinSpace:"​",NestedGreaterGreater:"≫",NestedLessLess:"≪",NewLine:"\n",Nfr:"𝔑",NoBreak:"⁠",NonBreakingSpace:" ",Nopf:"ℕ",Not:"⫬",NotCongruent:"≢",NotCupCap:"≭",NotDoubleVerticalBar:"∦",NotElement:"∉",NotEqual:"≠",NotEqualTilde:"≂̸",NotExists:"∄",NotGreater:"≯",NotGreaterEqual:"≱",NotGreaterFullEqual:"≧̸",NotGreaterGreater:"≫̸",NotGreaterLess:"≹",NotGreaterSlantEqual:"⩾̸",NotGreaterTilde:"≵",NotHumpDownHump:"≎̸",NotHumpEqual:"≏̸",NotLeftTriangle:"⋪",NotLeftTriangleBar:"⧏̸",NotLeftTriangleEqual:"⋬",NotLess:"≮",NotLessEqual:"≰",NotLessGreater:"≸",NotLessLess:"≪̸",NotLessSlantEqual:"⩽̸",NotLessTilde:"≴",NotNestedGreaterGreater:"⪢̸",NotNestedLessLess:"⪡̸",NotPrecedes:"⊀",NotPrecedesEqual:"⪯̸",NotPrecedesSlantEqual:"⋠",NotReverseElement:"∌",NotRightTriangle:"⋫",NotRightTriangleBar:"⧐̸",NotRightTriangleEqual:"⋭",NotSquareSubset:"⊏̸",NotSquareSubsetEqual:"⋢",NotSquareSuperset:"⊐̸",NotSquareSupersetEqual:"⋣",NotSubset:"⊂⃒",NotSubsetEqual:"⊈",NotSucceeds:"⊁",NotSucceedsEqual:"⪰̸",NotSucceedsSlantEqual:"⋡",NotSucceedsTilde:"≿̸",NotSuperset:"⊃⃒",NotSupersetEqual:"⊉",NotTilde:"≁",NotTildeEqual:"≄",NotTildeFullEqual:"≇",NotTildeTilde:"≉",NotVerticalBar:"∤",Nscr:"𝒩",Ntild:"Ñ",Ntilde:"Ñ",Nu:"Ν",OElig:"Œ",Oacut:"Ó",Oacute:"Ó",Ocir:"Ô",Ocirc:"Ô",Ocy:"О",Odblac:"Ő",Ofr:"𝔒",Ograv:"Ò",Ograve:"Ò",Omacr:"Ō",Omega:"Ω",Omicron:"Ο",Oopf:"𝕆",OpenCurlyDoubleQuote:"“",OpenCurlyQuote:"‘",Or:"⩔",Oscr:"𝒪",Oslas:"Ø",Oslash:"Ø",Otild:"Õ",Otilde:"Õ",Otimes:"⨷",Oum:"Ö",Ouml:"Ö",OverBar:"‾",OverBrace:"⏞",OverBracket:"⎴",OverParenthesis:"⏜",PartialD:"∂",Pcy:"П",Pfr:"𝔓",Phi:"Φ",Pi:"Π",PlusMinus:"±",Poincareplane:"ℌ",Popf:"ℙ",Pr:"⪻",Precedes:"≺",PrecedesEqual:"⪯",PrecedesSlantEqual:"≼",PrecedesTilde:"≾",Prime:"″",Product:"∏",Proportion:"∷",Proportional:"∝",Pscr:"𝒫",Psi:"Ψ",QUO:'"',QUOT:'"',Qfr:"𝔔",Qopf:"ℚ",Qscr:"𝒬",RBarr:"⤐",RE:"®",REG:"®",Racute:"Ŕ",Rang:"⟫",Rarr:"↠",Rarrtl:"⤖",Rcaron:"Ř",Rcedil:"Ŗ",Rcy:"Р",Re:"ℜ",ReverseElement:"∋",ReverseEquilibrium:"⇋",ReverseUpEquilibrium:"⥯",Rfr:"ℜ",Rho:"Ρ",RightAngleBracket:"⟩",RightArrow:"→",RightArrowBar:"⇥",RightArrowLeftArrow:"⇄",RightCeiling:"⌉",RightDoubleBracket:"⟧",RightDownTeeVector:"⥝",RightDownVector:"⇂",RightDownVectorBar:"⥕",RightFloor:"⌋",RightTee:"⊢",RightTeeArrow:"↦",RightTeeVector:"⥛",RightTriangle:"⊳",RightTriangleBar:"⧐",RightTriangleEqual:"⊵",RightUpDownVector:"⥏",RightUpTeeVector:"⥜",RightUpVector:"↾",RightUpVectorBar:"⥔",RightVector:"⇀",RightVectorBar:"⥓",Rightarrow:"⇒",Ropf:"ℝ",RoundImplies:"⥰",Rrightarrow:"⇛",Rscr:"ℛ",Rsh:"↱",RuleDelayed:"⧴",SHCHcy:"Щ",SHcy:"Ш",SOFTcy:"Ь",Sacute:"Ś",Sc:"⪼",Scaron:"Š",Scedil:"Ş",Scirc:"Ŝ",Scy:"С",Sfr:"𝔖",ShortDownArrow:"↓",ShortLeftArrow:"←",ShortRightArrow:"→",ShortUpArrow:"↑",Sigma:"Σ",SmallCircle:"∘",Sopf:"𝕊",Sqrt:"√",Square:"□",SquareIntersection:"⊓",SquareSubset:"⊏",SquareSubsetEqual:"⊑",SquareSuperset:"⊐",SquareSupersetEqual:"⊒",SquareUnion:"⊔",Sscr:"𝒮",Star:"⋆",Sub:"⋐",Subset:"⋐",SubsetEqual:"⊆",Succeeds:"≻",SucceedsEqual:"⪰",SucceedsSlantEqual:"≽",SucceedsTilde:"≿",SuchThat:"∋",Sum:"∑",Sup:"⋑",Superset:"⊃",SupersetEqual:"⊇",Supset:"⋑",THOR:"Þ",THORN:"Þ",TRADE:"™",TSHcy:"Ћ",TScy:"Ц",Tab:"\t",Tau:"Τ",Tcaron:"Ť",Tcedil:"Ţ",Tcy:"Т",Tfr:"𝔗",Therefore:"∴",Theta:"Θ",ThickSpace:"  ",ThinSpace:" ",Tilde:"∼",TildeEqual:"≃",TildeFullEqual:"≅",TildeTilde:"≈",Topf:"𝕋",TripleDot:"⃛",Tscr:"𝒯",Tstrok:"Ŧ",Uacut:"Ú",Uacute:"Ú",Uarr:"↟",Uarrocir:"⥉",Ubrcy:"Ў",Ubreve:"Ŭ",Ucir:"Û",Ucirc:"Û",Ucy:"У",Udblac:"Ű",Ufr:"𝔘",Ugrav:"Ù",Ugrave:"Ù",Umacr:"Ū",UnderBar:"_",UnderBrace:"⏟",UnderBracket:"⎵",UnderParenthesis:"⏝",Union:"⋃",UnionPlus:"⊎",Uogon:"Ų",Uopf:"𝕌",UpArrow:"↑",UpArrowBar:"⤒",UpArrowDownArrow:"⇅",UpDownArrow:"↕",UpEquilibrium:"⥮",UpTee:"⊥",UpTeeArrow:"↥",Uparrow:"⇑",Updownarrow:"⇕",UpperLeftArrow:"↖",UpperRightArrow:"↗",Upsi:"ϒ",Upsilon:"Υ",Uring:"Ů",Uscr:"𝒰",Utilde:"Ũ",Uum:"Ü",Uuml:"Ü",VDash:"⊫",Vbar:"⫫",Vcy:"В",Vdash:"⊩",Vdashl:"⫦",Vee:"⋁",Verbar:"‖",Vert:"‖",VerticalBar:"∣",VerticalLine:"|",VerticalSeparator:"❘",VerticalTilde:"≀",VeryThinSpace:" ",Vfr:"𝔙",Vopf:"𝕍",Vscr:"𝒱",Vvdash:"⊪",Wcirc:"Ŵ",Wedge:"⋀",Wfr:"𝔚",Wopf:"𝕎",Wscr:"𝒲",Xfr:"𝔛",Xi:"Ξ",Xopf:"𝕏",Xscr:"𝒳",YAcy:"Я",YIcy:"Ї",YUcy:"Ю",Yacut:"Ý",Yacute:"Ý",Ycirc:"Ŷ",Ycy:"Ы",Yfr:"𝔜",Yopf:"𝕐",Yscr:"𝒴",Yuml:"Ÿ",ZHcy:"Ж",Zacute:"Ź",Zcaron:"Ž",Zcy:"З",Zdot:"Ż",ZeroWidthSpace:"​",Zeta:"Ζ",Zfr:"ℨ",Zopf:"ℤ",Zscr:"𝒵",aacut:"á",aacute:"á",abreve:"ă",ac:"∾",acE:"∾̳",acd:"∿",acir:"â",acirc:"â",acut:"´",acute:"´",acy:"а",aeli:"æ",aelig:"æ",af:"⁡",afr:"𝔞",agrav:"à",agrave:"à",alefsym:"ℵ",aleph:"ℵ",alpha:"α",amacr:"ā",amalg:"⨿",am:"&",amp:"&",and:"∧",andand:"⩕",andd:"⩜",andslope:"⩘",andv:"⩚",ang:"∠",ange:"⦤",angle:"∠",angmsd:"∡",angmsdaa:"⦨",angmsdab:"⦩",angmsdac:"⦪",angmsdad:"⦫",angmsdae:"⦬",angmsdaf:"⦭",angmsdag:"⦮",angmsdah:"⦯",angrt:"∟",angrtvb:"⊾",angrtvbd:"⦝",angsph:"∢",angst:"Å",angzarr:"⍼",aogon:"ą",aopf:"𝕒",ap:"≈",apE:"⩰",apacir:"⩯",ape:"≊",apid:"≋",apos:"'",approx:"≈",approxeq:"≊",arin:"å",aring:"å",ascr:"𝒶",ast:"*",asymp:"≈",asympeq:"≍",atild:"ã",atilde:"ã",aum:"ä",auml:"ä",awconint:"∳",awint:"⨑",bNot:"⫭",backcong:"≌",backepsilon:"϶",backprime:"‵",backsim:"∽",backsimeq:"⋍",barvee:"⊽",barwed:"⌅",barwedge:"⌅",bbrk:"⎵",bbrktbrk:"⎶",bcong:"≌",bcy:"б",bdquo:"„",becaus:"∵",because:"∵",bemptyv:"⦰",bepsi:"϶",bernou:"ℬ",beta:"β",beth:"ℶ",between:"≬",bfr:"𝔟",bigcap:"⋂",bigcirc:"◯",bigcup:"⋃",bigodot:"⨀",bigoplus:"⨁",bigotimes:"⨂",bigsqcup:"⨆",bigstar:"★",bigtriangledown:"▽",bigtriangleup:"△",biguplus:"⨄",bigvee:"⋁",bigwedge:"⋀",bkarow:"⤍",blacklozenge:"⧫",blacksquare:"▪",blacktriangle:"▴",blacktriangledown:"▾",blacktriangleleft:"◂",blacktriangleright:"▸",blank:"␣",blk12:"▒",blk14:"░",blk34:"▓",block:"█",bne:"=⃥",bnequiv:"≡⃥",bnot:"⌐",bopf:"𝕓",bot:"⊥",bottom:"⊥",bowtie:"⋈",boxDL:"╗",boxDR:"╔",boxDl:"╖",boxDr:"╓",boxH:"═",boxHD:"╦",boxHU:"╩",boxHd:"╤",boxHu:"╧",boxUL:"╝",boxUR:"╚",boxUl:"╜",boxUr:"╙",boxV:"║",boxVH:"╬",boxVL:"╣",boxVR:"╠",boxVh:"╫",boxVl:"╢",boxVr:"╟",boxbox:"⧉",boxdL:"╕",boxdR:"╒",boxdl:"┐",boxdr:"┌",boxh:"─",boxhD:"╥",boxhU:"╨",boxhd:"┬",boxhu:"┴",boxminus:"⊟",boxplus:"⊞",boxtimes:"⊠",boxuL:"╛",boxuR:"╘",boxul:"┘",boxur:"└",boxv:"│",boxvH:"╪",boxvL:"╡",boxvR:"╞",boxvh:"┼",boxvl:"┤",boxvr:"├",bprime:"‵",breve:"˘",brvba:"¦",brvbar:"¦",bscr:"𝒷",bsemi:"⁏",bsim:"∽",bsime:"⋍",bsol:"\\",bsolb:"⧅",bsolhsub:"⟈",bull:"•",bullet:"•",bump:"≎",bumpE:"⪮",bumpe:"≏",bumpeq:"≏",cacute:"ć",cap:"∩",capand:"⩄",capbrcup:"⩉",capcap:"⩋",capcup:"⩇",capdot:"⩀",caps:"∩︀",caret:"⁁",caron:"ˇ",ccaps:"⩍",ccaron:"č",ccedi:"ç",ccedil:"ç",ccirc:"ĉ",ccups:"⩌",ccupssm:"⩐",cdot:"ċ",cedi:"¸",cedil:"¸",cemptyv:"⦲",cen:"¢",cent:"¢",centerdot:"·",cfr:"𝔠",chcy:"ч",check:"✓",checkmark:"✓",chi:"χ",cir:"○",cirE:"⧃",circ:"ˆ",circeq:"≗",circlearrowleft:"↺",circlearrowright:"↻",circledR:"®",circledS:"Ⓢ",circledast:"⊛",circledcirc:"⊚",circleddash:"⊝",cire:"≗",cirfnint:"⨐",cirmid:"⫯",cirscir:"⧂",clubs:"♣",clubsuit:"♣",colon:":",colone:"≔",coloneq:"≔",comma:",",commat:"@",comp:"∁",compfn:"∘",complement:"∁",complexes:"ℂ",cong:"≅",congdot:"⩭",conint:"∮",copf:"𝕔",coprod:"∐",cop:"©",copy:"©",copysr:"℗",crarr:"↵",cross:"✗",cscr:"𝒸",csub:"⫏",csube:"⫑",csup:"⫐",csupe:"⫒",ctdot:"⋯",cudarrl:"⤸",cudarrr:"⤵",cuepr:"⋞",cuesc:"⋟",cularr:"↶",cularrp:"⤽",cup:"∪",cupbrcap:"⩈",cupcap:"⩆",cupcup:"⩊",cupdot:"⊍",cupor:"⩅",cups:"∪︀",curarr:"↷",curarrm:"⤼",curlyeqprec:"⋞",curlyeqsucc:"⋟",curlyvee:"⋎",curlywedge:"⋏",curre:"¤",curren:"¤",curvearrowleft:"↶",curvearrowright:"↷",cuvee:"⋎",cuwed:"⋏",cwconint:"∲",cwint:"∱",cylcty:"⌭",dArr:"⇓",dHar:"⥥",dagger:"†",daleth:"ℸ",darr:"↓",dash:"‐",dashv:"⊣",dbkarow:"⤏",dblac:"˝",dcaron:"ď",dcy:"д",dd:"ⅆ",ddagger:"‡",ddarr:"⇊",ddotseq:"⩷",de:"°",deg:"°",delta:"δ",demptyv:"⦱",dfisht:"⥿",dfr:"𝔡",dharl:"⇃",dharr:"⇂",diam:"⋄",diamond:"⋄",diamondsuit:"♦",diams:"♦",die:"¨",digamma:"ϝ",disin:"⋲",div:"÷",divid:"÷",divide:"÷",divideontimes:"⋇",divonx:"⋇",djcy:"ђ",dlcorn:"⌞",dlcrop:"⌍",dollar:"$",dopf:"𝕕",dot:"˙",doteq:"≐",doteqdot:"≑",dotminus:"∸",dotplus:"∔",dotsquare:"⊡",doublebarwedge:"⌆",downarrow:"↓",downdownarrows:"⇊",downharpoonleft:"⇃",downharpoonright:"⇂",drbkarow:"⤐",drcorn:"⌟",drcrop:"⌌",dscr:"𝒹",dscy:"ѕ",dsol:"⧶",dstrok:"đ",dtdot:"⋱",dtri:"▿",dtrif:"▾",duarr:"⇵",duhar:"⥯",dwangle:"⦦",dzcy:"џ",dzigrarr:"⟿",eDDot:"⩷",eDot:"≑",eacut:"é",eacute:"é",easter:"⩮",ecaron:"ě",ecir:"ê",ecirc:"ê",ecolon:"≕",ecy:"э",edot:"ė",ee:"ⅇ",efDot:"≒",efr:"𝔢",eg:"⪚",egrav:"è",egrave:"è",egs:"⪖",egsdot:"⪘",el:"⪙",elinters:"⏧",ell:"ℓ",els:"⪕",elsdot:"⪗",emacr:"ē",empty:"∅",emptyset:"∅",emptyv:"∅",emsp13:" ",emsp14:" ",emsp:" ",eng:"ŋ",ensp:" ",eogon:"ę",eopf:"𝕖",epar:"⋕",eparsl:"⧣",eplus:"⩱",epsi:"ε",epsilon:"ε",epsiv:"ϵ",eqcirc:"≖",eqcolon:"≕",eqsim:"≂",eqslantgtr:"⪖",eqslantless:"⪕",equals:"=",equest:"≟",equiv:"≡",equivDD:"⩸",eqvparsl:"⧥",erDot:"≓",erarr:"⥱",escr:"ℯ",esdot:"≐",esim:"≂",eta:"η",et:"ð",eth:"ð",eum:"ë",euml:"ë",euro:"€",excl:"!",exist:"∃",expectation:"ℰ",exponentiale:"ⅇ",fallingdotseq:"≒",fcy:"ф",female:"♀",ffilig:"ffi",fflig:"ff",ffllig:"ffl",ffr:"𝔣",filig:"fi",fjlig:"fj",flat:"♭",fllig:"fl",fltns:"▱",fnof:"ƒ",fopf:"𝕗",forall:"∀",fork:"⋔",forkv:"⫙",fpartint:"⨍",frac1:"¼",frac12:"½",frac13:"⅓",frac14:"¼",frac15:"⅕",frac16:"⅙",frac18:"⅛",frac23:"⅔",frac25:"⅖",frac3:"¾",frac34:"¾",frac35:"⅗",frac38:"⅜",frac45:"⅘",frac56:"⅚",frac58:"⅝",frac78:"⅞",frasl:"⁄",frown:"⌢",fscr:"𝒻",gE:"≧",gEl:"⪌",gacute:"ǵ",gamma:"γ",gammad:"ϝ",gap:"⪆",gbreve:"ğ",gcirc:"ĝ",gcy:"г",gdot:"ġ",ge:"≥",gel:"⋛",geq:"≥",geqq:"≧",geqslant:"⩾",ges:"⩾",gescc:"⪩",gesdot:"⪀",gesdoto:"⪂",gesdotol:"⪄",gesl:"⋛︀",gesles:"⪔",gfr:"𝔤",gg:"≫",ggg:"⋙",gimel:"ℷ",gjcy:"ѓ",gl:"≷",glE:"⪒",gla:"⪥",glj:"⪤",gnE:"≩",gnap:"⪊",gnapprox:"⪊",gne:"⪈",gneq:"⪈",gneqq:"≩",gnsim:"⋧",gopf:"𝕘",grave:"`",gscr:"ℊ",gsim:"≳",gsime:"⪎",gsiml:"⪐",g:">",gt:">",gtcc:"⪧",gtcir:"⩺",gtdot:"⋗",gtlPar:"⦕",gtquest:"⩼",gtrapprox:"⪆",gtrarr:"⥸",gtrdot:"⋗",gtreqless:"⋛",gtreqqless:"⪌",gtrless:"≷",gtrsim:"≳",gvertneqq:"≩︀",gvnE:"≩︀",hArr:"⇔",hairsp:" ",half:"½",hamilt:"ℋ",hardcy:"ъ",harr:"↔",harrcir:"⥈",harrw:"↭",hbar:"ℏ",hcirc:"ĥ",hearts:"♥",heartsuit:"♥",hellip:"…",hercon:"⊹",hfr:"𝔥",hksearow:"⤥",hkswarow:"⤦",hoarr:"⇿",homtht:"∻",hookleftarrow:"↩",hookrightarrow:"↪",hopf:"𝕙",horbar:"―",hscr:"𝒽",hslash:"ℏ",hstrok:"ħ",hybull:"⁃",hyphen:"‐",iacut:"í",iacute:"í",ic:"⁣",icir:"î",icirc:"î",icy:"и",iecy:"е",iexc:"¡",iexcl:"¡",iff:"⇔",ifr:"𝔦",igrav:"ì",igrave:"ì",ii:"ⅈ",iiiint:"⨌",iiint:"∭",iinfin:"⧜",iiota:"℩",ijlig:"ij",imacr:"ī",image:"ℑ",imagline:"ℐ",imagpart:"ℑ",imath:"ı",imof:"⊷",imped:"Ƶ",in:"∈",incare:"℅",infin:"∞",infintie:"⧝",inodot:"ı",int:"∫",intcal:"⊺",integers:"ℤ",intercal:"⊺",intlarhk:"⨗",intprod:"⨼",iocy:"ё",iogon:"į",iopf:"𝕚",iota:"ι",iprod:"⨼",iques:"¿",iquest:"¿",iscr:"𝒾",isin:"∈",isinE:"⋹",isindot:"⋵",isins:"⋴",isinsv:"⋳",isinv:"∈",it:"⁢",itilde:"ĩ",iukcy:"і",ium:"ï",iuml:"ï",jcirc:"ĵ",jcy:"й",jfr:"𝔧",jmath:"ȷ",jopf:"𝕛",jscr:"𝒿",jsercy:"ј",jukcy:"є",kappa:"κ",kappav:"ϰ",kcedil:"ķ",kcy:"к",kfr:"𝔨",kgreen:"ĸ",khcy:"х",kjcy:"ќ",kopf:"𝕜",kscr:"𝓀",lAarr:"⇚",lArr:"⇐",lAtail:"⤛",lBarr:"⤎",lE:"≦",lEg:"⪋",lHar:"⥢",lacute:"ĺ",laemptyv:"⦴",lagran:"ℒ",lambda:"λ",lang:"⟨",langd:"⦑",langle:"⟨",lap:"⪅",laqu:"«",laquo:"«",larr:"←",larrb:"⇤",larrbfs:"⤟",larrfs:"⤝",larrhk:"↩",larrlp:"↫",larrpl:"⤹",larrsim:"⥳",larrtl:"↢",lat:"⪫",latail:"⤙",late:"⪭",lates:"⪭︀",lbarr:"⤌",lbbrk:"❲",lbrace:"{",lbrack:"[",lbrke:"⦋",lbrksld:"⦏",lbrkslu:"⦍",lcaron:"ľ",lcedil:"ļ",lceil:"⌈",lcub:"{",lcy:"л",ldca:"⤶",ldquo:"“",ldquor:"„",ldrdhar:"⥧",ldrushar:"⥋",ldsh:"↲",le:"≤",leftarrow:"←",leftarrowtail:"↢",leftharpoondown:"↽",leftharpoonup:"↼",leftleftarrows:"⇇",leftrightarrow:"↔",leftrightarrows:"⇆",leftrightharpoons:"⇋",leftrightsquigarrow:"↭",leftthreetimes:"⋋",leg:"⋚",leq:"≤",leqq:"≦",leqslant:"⩽",les:"⩽",lescc:"⪨",lesdot:"⩿",lesdoto:"⪁",lesdotor:"⪃",lesg:"⋚︀",lesges:"⪓",lessapprox:"⪅",lessdot:"⋖",lesseqgtr:"⋚",lesseqqgtr:"⪋",lessgtr:"≶",lesssim:"≲",lfisht:"⥼",lfloor:"⌊",lfr:"𝔩",lg:"≶",lgE:"⪑",lhard:"↽",lharu:"↼",lharul:"⥪",lhblk:"▄",ljcy:"љ",ll:"≪",llarr:"⇇",llcorner:"⌞",llhard:"⥫",lltri:"◺",lmidot:"ŀ",lmoust:"⎰",lmoustache:"⎰",lnE:"≨",lnap:"⪉",lnapprox:"⪉",lne:"⪇",lneq:"⪇",lneqq:"≨",lnsim:"⋦",loang:"⟬",loarr:"⇽",lobrk:"⟦",longleftarrow:"⟵",longleftrightarrow:"⟷",longmapsto:"⟼",longrightarrow:"⟶",looparrowleft:"↫",looparrowright:"↬",lopar:"⦅",lopf:"𝕝",loplus:"⨭",lotimes:"⨴",lowast:"∗",lowbar:"_",loz:"◊",lozenge:"◊",lozf:"⧫",lpar:"(",lparlt:"⦓",lrarr:"⇆",lrcorner:"⌟",lrhar:"⇋",lrhard:"⥭",lrm:"‎",lrtri:"⊿",lsaquo:"‹",lscr:"𝓁",lsh:"↰",lsim:"≲",lsime:"⪍",lsimg:"⪏",lsqb:"[",lsquo:"‘",lsquor:"‚",lstrok:"ł",l:"<",lt:"<",ltcc:"⪦",ltcir:"⩹",ltdot:"⋖",lthree:"⋋",ltimes:"⋉",ltlarr:"⥶",ltquest:"⩻",ltrPar:"⦖",ltri:"◃",ltrie:"⊴",ltrif:"◂",lurdshar:"⥊",luruhar:"⥦",lvertneqq:"≨︀",lvnE:"≨︀",mDDot:"∺",mac:"¯",macr:"¯",male:"♂",malt:"✠",maltese:"✠",map:"↦",mapsto:"↦",mapstodown:"↧",mapstoleft:"↤",mapstoup:"↥",marker:"▮",mcomma:"⨩",mcy:"м",mdash:"—",measuredangle:"∡",mfr:"𝔪",mho:"℧",micr:"µ",micro:"µ",mid:"∣",midast:"*",midcir:"⫰",middo:"·",middot:"·",minus:"−",minusb:"⊟",minusd:"∸",minusdu:"⨪",mlcp:"⫛",mldr:"…",mnplus:"∓",models:"⊧",mopf:"𝕞",mp:"∓",mscr:"𝓂",mstpos:"∾",mu:"μ",multimap:"⊸",mumap:"⊸",nGg:"⋙̸",nGt:"≫⃒",nGtv:"≫̸",nLeftarrow:"⇍",nLeftrightarrow:"⇎",nLl:"⋘̸",nLt:"≪⃒",nLtv:"≪̸",nRightarrow:"⇏",nVDash:"⊯",nVdash:"⊮",nabla:"∇",nacute:"ń",nang:"∠⃒",nap:"≉",napE:"⩰̸",napid:"≋̸",napos:"ʼn",napprox:"≉",natur:"♮",natural:"♮",naturals:"ℕ",nbs:" ",nbsp:" ",nbump:"≎̸",nbumpe:"≏̸",ncap:"⩃",ncaron:"ň",ncedil:"ņ",ncong:"≇",ncongdot:"⩭̸",ncup:"⩂",ncy:"н",ndash:"–",ne:"≠",neArr:"⇗",nearhk:"⤤",nearr:"↗",nearrow:"↗",nedot:"≐̸",nequiv:"≢",nesear:"⤨",nesim:"≂̸",nexist:"∄",nexists:"∄",nfr:"𝔫",ngE:"≧̸",nge:"≱",ngeq:"≱",ngeqq:"≧̸",ngeqslant:"⩾̸",nges:"⩾̸",ngsim:"≵",ngt:"≯",ngtr:"≯",nhArr:"⇎",nharr:"↮",nhpar:"⫲",ni:"∋",nis:"⋼",nisd:"⋺",niv:"∋",njcy:"њ",nlArr:"⇍",nlE:"≦̸",nlarr:"↚",nldr:"‥",nle:"≰",nleftarrow:"↚",nleftrightarrow:"↮",nleq:"≰",nleqq:"≦̸",nleqslant:"⩽̸",nles:"⩽̸",nless:"≮",nlsim:"≴",nlt:"≮",nltri:"⋪",nltrie:"⋬",nmid:"∤",nopf:"𝕟",no:"¬",not:"¬",notin:"∉",notinE:"⋹̸",notindot:"⋵̸",notinva:"∉",notinvb:"⋷",notinvc:"⋶",notni:"∌",notniva:"∌",notnivb:"⋾",notnivc:"⋽",npar:"∦",nparallel:"∦",nparsl:"⫽⃥",npart:"∂̸",npolint:"⨔",npr:"⊀",nprcue:"⋠",npre:"⪯̸",nprec:"⊀",npreceq:"⪯̸",nrArr:"⇏",nrarr:"↛",nrarrc:"⤳̸",nrarrw:"↝̸",nrightarrow:"↛",nrtri:"⋫",nrtrie:"⋭",nsc:"⊁",nsccue:"⋡",nsce:"⪰̸",nscr:"𝓃",nshortmid:"∤",nshortparallel:"∦",nsim:"≁",nsime:"≄",nsimeq:"≄",nsmid:"∤",nspar:"∦",nsqsube:"⋢",nsqsupe:"⋣",nsub:"⊄",nsubE:"⫅̸",nsube:"⊈",nsubset:"⊂⃒",nsubseteq:"⊈",nsubseteqq:"⫅̸",nsucc:"⊁",nsucceq:"⪰̸",nsup:"⊅",nsupE:"⫆̸",nsupe:"⊉",nsupset:"⊃⃒",nsupseteq:"⊉",nsupseteqq:"⫆̸",ntgl:"≹",ntild:"ñ",ntilde:"ñ",ntlg:"≸",ntriangleleft:"⋪",ntrianglelefteq:"⋬",ntriangleright:"⋫",ntrianglerighteq:"⋭",nu:"ν",num:"#",numero:"№",numsp:" ",nvDash:"⊭",nvHarr:"⤄",nvap:"≍⃒",nvdash:"⊬",nvge:"≥⃒",nvgt:">⃒",nvinfin:"⧞",nvlArr:"⤂",nvle:"≤⃒",nvlt:"<⃒",nvltrie:"⊴⃒",nvrArr:"⤃",nvrtrie:"⊵⃒",nvsim:"∼⃒",nwArr:"⇖",nwarhk:"⤣",nwarr:"↖",nwarrow:"↖",nwnear:"⤧",oS:"Ⓢ",oacut:"ó",oacute:"ó",oast:"⊛",ocir:"ô",ocirc:"ô",ocy:"о",odash:"⊝",odblac:"ő",odiv:"⨸",odot:"⊙",odsold:"⦼",oelig:"œ",ofcir:"⦿",ofr:"𝔬",ogon:"˛",ograv:"ò",ograve:"ò",ogt:"⧁",ohbar:"⦵",ohm:"Ω",oint:"∮",olarr:"↺",olcir:"⦾",olcross:"⦻",oline:"‾",olt:"⧀",omacr:"ō",omega:"ω",omicron:"ο",omid:"⦶",ominus:"⊖",oopf:"𝕠",opar:"⦷",operp:"⦹",oplus:"⊕",or:"∨",orarr:"↻",ord:"º",order:"ℴ",orderof:"ℴ",ordf:"ª",ordm:"º",origof:"⊶",oror:"⩖",orslope:"⩗",orv:"⩛",oscr:"ℴ",oslas:"ø",oslash:"ø",osol:"⊘",otild:"õ",otilde:"õ",otimes:"⊗",otimesas:"⨶",oum:"ö",ouml:"ö",ovbar:"⌽",par:"¶",para:"¶",parallel:"∥",parsim:"⫳",parsl:"⫽",part:"∂",pcy:"п",percnt:"%",period:".",permil:"‰",perp:"⊥",pertenk:"‱",pfr:"𝔭",phi:"φ",phiv:"ϕ",phmmat:"ℳ",phone:"☎",pi:"π",pitchfork:"⋔",piv:"ϖ",planck:"ℏ",planckh:"ℎ",plankv:"ℏ",plus:"+",plusacir:"⨣",plusb:"⊞",pluscir:"⨢",plusdo:"∔",plusdu:"⨥",pluse:"⩲",plusm:"±",plusmn:"±",plussim:"⨦",plustwo:"⨧",pm:"±",pointint:"⨕",popf:"𝕡",poun:"£",pound:"£",pr:"≺",prE:"⪳",prap:"⪷",prcue:"≼",pre:"⪯",prec:"≺",precapprox:"⪷",preccurlyeq:"≼",preceq:"⪯",precnapprox:"⪹",precneqq:"⪵",precnsim:"⋨",precsim:"≾",prime:"′",primes:"ℙ",prnE:"⪵",prnap:"⪹",prnsim:"⋨",prod:"∏",profalar:"⌮",profline:"⌒",profsurf:"⌓",prop:"∝",propto:"∝",prsim:"≾",prurel:"⊰",pscr:"𝓅",psi:"ψ",puncsp:" ",qfr:"𝔮",qint:"⨌",qopf:"𝕢",qprime:"⁗",qscr:"𝓆",quaternions:"ℍ",quatint:"⨖",quest:"?",questeq:"≟",quo:'"',quot:'"',rAarr:"⇛",rArr:"⇒",rAtail:"⤜",rBarr:"⤏",rHar:"⥤",race:"∽̱",racute:"ŕ",radic:"√",raemptyv:"⦳",rang:"⟩",rangd:"⦒",range:"⦥",rangle:"⟩",raqu:"»",raquo:"»",rarr:"→",rarrap:"⥵",rarrb:"⇥",rarrbfs:"⤠",rarrc:"⤳",rarrfs:"⤞",rarrhk:"↪",rarrlp:"↬",rarrpl:"⥅",rarrsim:"⥴",rarrtl:"↣",rarrw:"↝",ratail:"⤚",ratio:"∶",rationals:"ℚ",rbarr:"⤍",rbbrk:"❳",rbrace:"}",rbrack:"]",rbrke:"⦌",rbrksld:"⦎",rbrkslu:"⦐",rcaron:"ř",rcedil:"ŗ",rceil:"⌉",rcub:"}",rcy:"р",rdca:"⤷",rdldhar:"⥩",rdquo:"”",rdquor:"”",rdsh:"↳",real:"ℜ",realine:"ℛ",realpart:"ℜ",reals:"ℝ",rect:"▭",re:"®",reg:"®",rfisht:"⥽",rfloor:"⌋",rfr:"𝔯",rhard:"⇁",rharu:"⇀",rharul:"⥬",rho:"ρ",rhov:"ϱ",rightarrow:"→",rightarrowtail:"↣",rightharpoondown:"⇁",rightharpoonup:"⇀",rightleftarrows:"⇄",rightleftharpoons:"⇌",rightrightarrows:"⇉",rightsquigarrow:"↝",rightthreetimes:"⋌",ring:"˚",risingdotseq:"≓",rlarr:"⇄",rlhar:"⇌",rlm:"‏",rmoust:"⎱",rmoustache:"⎱",rnmid:"⫮",roang:"⟭",roarr:"⇾",robrk:"⟧",ropar:"⦆",ropf:"𝕣",roplus:"⨮",rotimes:"⨵",rpar:")",rpargt:"⦔",rppolint:"⨒",rrarr:"⇉",rsaquo:"›",rscr:"𝓇",rsh:"↱",rsqb:"]",rsquo:"’",rsquor:"’",rthree:"⋌",rtimes:"⋊",rtri:"▹",rtrie:"⊵",rtrif:"▸",rtriltri:"⧎",ruluhar:"⥨",rx:"℞",sacute:"ś",sbquo:"‚",sc:"≻",scE:"⪴",scap:"⪸",scaron:"š",sccue:"≽",sce:"⪰",scedil:"ş",scirc:"ŝ",scnE:"⪶",scnap:"⪺",scnsim:"⋩",scpolint:"⨓",scsim:"≿",scy:"с",sdot:"⋅",sdotb:"⊡",sdote:"⩦",seArr:"⇘",searhk:"⤥",searr:"↘",searrow:"↘",sec:"§",sect:"§",semi:";",seswar:"⤩",setminus:"∖",setmn:"∖",sext:"✶",sfr:"𝔰",sfrown:"⌢",sharp:"♯",shchcy:"щ",shcy:"ш",shortmid:"∣",shortparallel:"∥",sh:"­",shy:"­",sigma:"σ",sigmaf:"ς",sigmav:"ς",sim:"∼",simdot:"⩪",sime:"≃",simeq:"≃",simg:"⪞",simgE:"⪠",siml:"⪝",simlE:"⪟",simne:"≆",simplus:"⨤",simrarr:"⥲",slarr:"←",smallsetminus:"∖",smashp:"⨳",smeparsl:"⧤",smid:"∣",smile:"⌣",smt:"⪪",smte:"⪬",smtes:"⪬︀",softcy:"ь",sol:"/",solb:"⧄",solbar:"⌿",sopf:"𝕤",spades:"♠",spadesuit:"♠",spar:"∥",sqcap:"⊓",sqcaps:"⊓︀",sqcup:"⊔",sqcups:"⊔︀",sqsub:"⊏",sqsube:"⊑",sqsubset:"⊏",sqsubseteq:"⊑",sqsup:"⊐",sqsupe:"⊒",sqsupset:"⊐",sqsupseteq:"⊒",squ:"□",square:"□",squarf:"▪",squf:"▪",srarr:"→",sscr:"𝓈",ssetmn:"∖",ssmile:"⌣",sstarf:"⋆",star:"☆",starf:"★",straightepsilon:"ϵ",straightphi:"ϕ",strns:"¯",sub:"⊂",subE:"⫅",subdot:"⪽",sube:"⊆",subedot:"⫃",submult:"⫁",subnE:"⫋",subne:"⊊",subplus:"⪿",subrarr:"⥹",subset:"⊂",subseteq:"⊆",subseteqq:"⫅",subsetneq:"⊊",subsetneqq:"⫋",subsim:"⫇",subsub:"⫕",subsup:"⫓",succ:"≻",succapprox:"⪸",succcurlyeq:"≽",succeq:"⪰",succnapprox:"⪺",succneqq:"⪶",succnsim:"⋩",succsim:"≿",sum:"∑",sung:"♪",sup:"⊃",sup1:"¹",sup2:"²",sup3:"³",supE:"⫆",supdot:"⪾",supdsub:"⫘",supe:"⊇",supedot:"⫄",suphsol:"⟉",suphsub:"⫗",suplarr:"⥻",supmult:"⫂",supnE:"⫌",supne:"⊋",supplus:"⫀",supset:"⊃",supseteq:"⊇",supseteqq:"⫆",supsetneq:"⊋",supsetneqq:"⫌",supsim:"⫈",supsub:"⫔",supsup:"⫖",swArr:"⇙",swarhk:"⤦",swarr:"↙",swarrow:"↙",swnwar:"⤪",szli:"ß",szlig:"ß",target:"⌖",tau:"τ",tbrk:"⎴",tcaron:"ť",tcedil:"ţ",tcy:"т",tdot:"⃛",telrec:"⌕",tfr:"𝔱",there4:"∴",therefore:"∴",theta:"θ",thetasym:"ϑ",thetav:"ϑ",thickapprox:"≈",thicksim:"∼",thinsp:" ",thkap:"≈",thksim:"∼",thor:"þ",thorn:"þ",tilde:"˜",time:"×",times:"×",timesb:"⊠",timesbar:"⨱",timesd:"⨰",tint:"∭",toea:"⤨",top:"⊤",topbot:"⌶",topcir:"⫱",topf:"𝕥",topfork:"⫚",tosa:"⤩",tprime:"‴",trade:"™",triangle:"▵",triangledown:"▿",triangleleft:"◃",trianglelefteq:"⊴",triangleq:"≜",triangleright:"▹",trianglerighteq:"⊵",tridot:"◬",trie:"≜",triminus:"⨺",triplus:"⨹",trisb:"⧍",tritime:"⨻",trpezium:"⏢",tscr:"𝓉",tscy:"ц",tshcy:"ћ",tstrok:"ŧ",twixt:"≬",twoheadleftarrow:"↞",twoheadrightarrow:"↠",uArr:"⇑",uHar:"⥣",uacut:"ú",uacute:"ú",uarr:"↑",ubrcy:"ў",ubreve:"ŭ",ucir:"û",ucirc:"û",ucy:"у",udarr:"⇅",udblac:"ű",udhar:"⥮",ufisht:"⥾",ufr:"𝔲",ugrav:"ù",ugrave:"ù",uharl:"↿",uharr:"↾",uhblk:"▀",ulcorn:"⌜",ulcorner:"⌜",ulcrop:"⌏",ultri:"◸",umacr:"ū",um:"¨",uml:"¨",uogon:"ų",uopf:"𝕦",uparrow:"↑",updownarrow:"↕",upharpoonleft:"↿",upharpoonright:"↾",uplus:"⊎",upsi:"υ",upsih:"ϒ",upsilon:"υ",upuparrows:"⇈",urcorn:"⌝",urcorner:"⌝",urcrop:"⌎",uring:"ů",urtri:"◹",uscr:"𝓊",utdot:"⋰",utilde:"ũ",utri:"▵",utrif:"▴",uuarr:"⇈",uum:"ü",uuml:"ü",uwangle:"⦧",vArr:"⇕",vBar:"⫨",vBarv:"⫩",vDash:"⊨",vangrt:"⦜",varepsilon:"ϵ",varkappa:"ϰ",varnothing:"∅",varphi:"ϕ",varpi:"ϖ",varpropto:"∝",varr:"↕",varrho:"ϱ",varsigma:"ς",varsubsetneq:"⊊︀",varsubsetneqq:"⫋︀",varsupsetneq:"⊋︀",varsupsetneqq:"⫌︀",vartheta:"ϑ",vartriangleleft:"⊲",vartriangleright:"⊳",vcy:"в",vdash:"⊢",vee:"∨",veebar:"⊻",veeeq:"≚",vellip:"⋮",verbar:"|",vert:"|",vfr:"𝔳",vltri:"⊲",vnsub:"⊂⃒",vnsup:"⊃⃒",vopf:"𝕧",vprop:"∝",vrtri:"⊳",vscr:"𝓋",vsubnE:"⫋︀",vsubne:"⊊︀",vsupnE:"⫌︀",vsupne:"⊋︀",vzigzag:"⦚",wcirc:"ŵ",wedbar:"⩟",wedge:"∧",wedgeq:"≙",weierp:"℘",wfr:"𝔴",wopf:"𝕨",wp:"℘",wr:"≀",wreath:"≀",wscr:"𝓌",xcap:"⋂",xcirc:"◯",xcup:"⋃",xdtri:"▽",xfr:"𝔵",xhArr:"⟺",xharr:"⟷",xi:"ξ",xlArr:"⟸",xlarr:"⟵",xmap:"⟼",xnis:"⋻",xodot:"⨀",xopf:"𝕩",xoplus:"⨁",xotime:"⨂",xrArr:"⟹",xrarr:"⟶",xscr:"𝓍",xsqcup:"⨆",xuplus:"⨄",xutri:"△",xvee:"⋁",xwedge:"⋀",yacut:"ý",yacute:"ý",yacy:"я",ycirc:"ŷ",ycy:"ы",ye:"¥",yen:"¥",yfr:"𝔶",yicy:"ї",yopf:"𝕪",yscr:"𝓎",yucy:"ю",yum:"ÿ",yuml:"ÿ",zacute:"ź",zcaron:"ž",zcy:"з",zdot:"ż",zeetrf:"ℨ",zeta:"ζ",zfr:"𝔷",zhcy:"ж",zigrarr:"⇝",zopf:"𝕫",zscr:"𝓏",zwj:"‍",zwnj:"‌"}},function(e,t,r){const i=r(287);const n=r(809);const a={parse:i,stringify:n};e.exports=a},,function(e){"use strict";e.exports=interrupt;function interrupt(e,t,r,i){var n=e.length;var a=-1;var u;var s;while(++a>0},ToUint32:function(e){return e>>>0}}}();var u=Math.LN2,s=Math.abs,o=Math.floor,l=Math.log,f=Math.min,c=Math.pow,h=Math.round;function configureProperties(e){if(v&&p){var t=v(e),r;for(r=0;rn)throw new RangeError("Array too large for polyfill");function makeArrayAccessor(t){p(e,t,{get:function(){return e._getter(t)},set:function(r){e._setter(t,r)},enumerable:true,configurable:false})}var t;for(t=0;t>r}function as_unsigned(e,t){var r=32-t;return e<>>r}function packI8(e){return[e&255]}function unpackI8(e){return as_signed(e[0],8)}function packU8(e){return[e&255]}function unpackU8(e){return as_unsigned(e[0],8)}function packU8Clamped(e){e=h(Number(e));return[e<0?0:e>255?255:e&255]}function packI16(e){return[e>>8&255,e&255]}function unpackI16(e){return as_signed(e[0]<<8|e[1],16)}function packU16(e){return[e>>8&255,e&255]}function unpackU16(e){return as_unsigned(e[0]<<8|e[1],16)}function packI32(e){return[e>>24&255,e>>16&255,e>>8&255,e&255]}function unpackI32(e){return as_signed(e[0]<<24|e[1]<<16|e[2]<<8|e[3],32)}function packU32(e){return[e>>24&255,e>>16&255,e>>8&255,e&255]}function unpackU32(e){return as_unsigned(e[0]<<24|e[1]<<16|e[2]<<8|e[3],32)}function packIEEE754(e,t,r){var i=(1<.5)return t+1;return t%2?t+1:t}if(e!==e){a=(1<=c(2,1-i)){a=f(o(l(e)/u),1023);h=roundToEven(e/c(2,a)*c(2,r));if(h/c(2,r)>=2){a=a+1;h=1}if(a>i){a=(1<>1}}i.reverse();s=i.join("");o=(1<0){return l*c(2,f-o)*(1+h/c(2,r))}else if(h!==0){return l*c(2,-(o-1))*(h/c(2,r))}else{return l<0?-0:0}}function unpackF64(e){return unpackIEEE754(e,11,52)}function packF64(e){return packIEEE754(e,11,52)}function unpackF32(e){return unpackIEEE754(e,8,23)}function packF32(e){return packIEEE754(e,8,23)}(function(){var e=function ArrayBuffer(e){e=a.ToInt32(e);if(e<0)throw new RangeError("ArrayBuffer size is not a small enough positive integer");this.byteLength=e;this._bytes=[];this._bytes.length=e;var t;for(t=0;tthis.buffer.byteLength){throw new RangeError("byteOffset out of range")}if(this.byteOffset%this.BYTES_PER_ELEMENT){throw new RangeError("ArrayBuffer length minus the byteOffset is not a multiple of the element size.")}if(arguments.length<3){this.byteLength=this.buffer.byteLength-this.byteOffset;if(this.byteLength%this.BYTES_PER_ELEMENT){throw new RangeError("length of buffer minus byteOffset not a multiple of the element size")}this.length=this.byteLength/this.BYTES_PER_ELEMENT}else{this.length=a.ToUint32(i);this.byteLength=this.length*this.BYTES_PER_ELEMENT}if(this.byteOffset+this.byteLength>this.buffer.byteLength){throw new RangeError("byteOffset and length reference an area beyond the end of the buffer")}}else{throw new TypeError("Unexpected argument type(s)")}this.constructor=s;configureProperties(this);makeArrayAccessors(this)};s.prototype=new r;s.prototype.BYTES_PER_ELEMENT=t;s.prototype._pack=n;s.prototype._unpack=u;s.BYTES_PER_ELEMENT=t;s.prototype._getter=function(e){if(arguments.length<1)throw new SyntaxError("Not enough arguments");e=a.ToUint32(e);if(e>=this.length){return i}var t=[],r,n;for(r=0,n=this.byteOffset+e*this.BYTES_PER_ELEMENT;r=this.length){return i}var r=this._pack(t),n,u;for(n=0,u=this.byteOffset+e*this.BYTES_PER_ELEMENT;nthis.length){throw new RangeError("Offset plus length of array is out of range")}f=this.byteOffset+n*this.BYTES_PER_ELEMENT;c=r.length*this.BYTES_PER_ELEMENT;if(r.buffer===this.buffer){h=[];for(s=0,o=r.byteOffset;sthis.length){throw new RangeError("Offset plus length of array is out of range")}for(s=0;sr?r:e}e=a.ToInt32(e);t=a.ToInt32(t);if(arguments.length<1){e=0}if(arguments.length<2){t=this.length}if(e<0){e=this.length+e}if(t<0){t=this.length+t}e=clamp(e,0,this.length);t=clamp(t,0,this.length);var r=t-e;if(r<0){r=0}return new this.constructor(this.buffer,this.byteOffset+e*this.BYTES_PER_ELEMENT,r)};return s}var n=makeConstructor(1,packI8,unpackI8);var u=makeConstructor(1,packU8,unpackU8);var s=makeConstructor(1,packU8Clamped,unpackU8);var o=makeConstructor(2,packI16,unpackI16);var l=makeConstructor(2,packU16,unpackU16);var f=makeConstructor(4,packI32,unpackI32);var c=makeConstructor(4,packU32,unpackU32);var h=makeConstructor(4,packF32,unpackF32);var p=makeConstructor(8,packF64,unpackF64);t.Int8Array=t.Int8Array||n;t.Uint8Array=t.Uint8Array||u;t.Uint8ClampedArray=t.Uint8ClampedArray||s;t.Int16Array=t.Int16Array||o;t.Uint16Array=t.Uint16Array||l;t.Int32Array=t.Int32Array||f;t.Uint32Array=t.Uint32Array||c;t.Float32Array=t.Float32Array||h;t.Float64Array=t.Float64Array||p})();(function(){function r(e,t){return a.IsCallable(e.get)?e.get(t):e[t]}var e=function(){var e=new t.Uint16Array([4660]),i=new t.Uint8Array(e.buffer);return r(i,0)===18}();var i=function DataView(e,r,i){if(arguments.length===0){e=new t.ArrayBuffer(0)}else if(!(e instanceof t.ArrayBuffer||a.Class(e)==="ArrayBuffer")){throw new TypeError("TypeError")}this.buffer=e||new t.ArrayBuffer(0);this.byteOffset=a.ToUint32(r);if(this.byteOffset>this.buffer.byteLength){throw new RangeError("byteOffset out of range")}if(arguments.length<3){this.byteLength=this.buffer.byteLength-this.byteOffset}else{this.byteLength=a.ToUint32(i)}if(this.byteOffset+this.byteLength>this.buffer.byteLength){throw new RangeError("byteOffset and length reference an area beyond the end of the buffer")}configureProperties(this)};function makeGetter(i){return function(n,u){n=a.ToUint32(n);if(n+i.BYTES_PER_ELEMENT>this.byteLength){throw new RangeError("Array index out of range")}n+=this.byteOffset;var s=new t.Uint8Array(this.buffer,n,i.BYTES_PER_ELEMENT),o=[],l;for(l=0;lthis.byteLength){throw new RangeError("Array index out of range")}var o=new i([u]),l=new t.Uint8Array(o.buffer),f=[],c,h;for(c=0;c=e.length?e.length:n+r;t.message+=` while parsing near '${i===0?"":"..."}${e.slice(i,a)}${a===e.length?"":"..."}'`}else{t.message+=` while parsing '${e.slice(0,r*2)}'`}throw t}}},,function(e){"use strict";e.exports=function isArrayish(e){if(!e){return false}return e instanceof Array||Array.isArray(e)||e.length>=0&&e.splice instanceof Function}},,,function(e){"use strict";e.exports=strikethrough;var t="~";var r=t+t;function strikethrough(e){return r+this.all(e).join("")+r}},,function(e,t,r){"use strict";var i=r(495);var n=r(704);var a=r(682);var u=r(839);var s=r(526);e.exports=i("remark-lint:no-heading-indent",noHeadingIndent);var o=u.start;function noHeadingIndent(e,t){var r=String(t);var i=r.length;a(e,"heading",visitor);function visitor(e){var a;var u;var l;var f;var c;if(s(e)){return}a=o(e);u=a.offset;l=u-1;while(++l-1&&r.charAt(i)!=="\n"){t.message("Missing newline character at end of file")}}},,,function(e,t,r){"use strict";var i=r(171);var n=r(111);e.exports=strikethrough;strikethrough.locator=n;var a="~";var u="~~";function strikethrough(e,t,r){var n=this;var s="";var o="";var l="";var f="";var c;var h;var p;if(!n.options.gfm||t.charAt(0)!==a||t.charAt(1)!==a||i(t.charAt(2))){return}c=1;h=t.length;p=e.now();p.column+=2;p.offset+=2;while(++c?@[\\\]^`{|}~_]/;function copy(e,t){var r=e.length;var u=t.length;var s=[];var o=0;var l=0;var f;while(l0){r=Math.min(10,Math.floor(r));o=" ".substr(0,r)}}else if(typeof r==="string"){o=r.substr(0,10)}return serializeProperty("",{"":e});function serializeProperty(e,t){let r=t[e];if(r!=null){if(typeof r.toJSON5==="function"){r=r.toJSON5(e)}else if(typeof r.toJSON==="function"){r=r.toJSON(e)}}if(s){r=s.call(t,e,r)}if(r instanceof Number){r=Number(r)}else if(r instanceof String){r=String(r)}else if(r instanceof Boolean){r=r.valueOf()}switch(r){case null:return"null";case true:return"true";case false:return"false"}if(typeof r==="string"){return quoteString(r,false)}if(typeof r==="number"){return String(r)}if(typeof r==="object"){return Array.isArray(r)?serializeArray(r):serializeObject(r)}return undefined}function quoteString(e){const t={"'":.1,'"':.2};const r={"'":"\\'",'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\v":"\\v","\0":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"};let i="";for(const n of e){switch(n){case"'":case'"':t[n]++;i+=n;continue}if(r[n]){i+=r[n];continue}if(n<" "){let e=n.charCodeAt(0).toString(16);i+="\\x"+("00"+e).substring(e.length);continue}i+=n}const n=l||Object.keys(t).reduce((e,r)=>t[e]=0){throw TypeError("Converting circular structure to JSON5")}n.push(e);let t=a;a=a+o;let r=u||Object.keys(e);let i=[];for(const t of r){const r=serializeProperty(t,e);if(r!==undefined){let e=serializeKey(t)+":";if(o!==""){e+=" "}e+=r;i.push(e)}}let s;if(i.length===0){s="{}"}else{let e;if(o===""){e=i.join(",");s="{"+e+"}"}else{let r=",\n"+a;e=i.join(r);s="{\n"+a+e+",\n"+t+"}"}}n.pop();a=t;return s}function serializeKey(e){if(e.length===0){return quoteString(e,true)}const t=String.fromCodePoint(e.codePointAt(0));if(!i.isIdStartChar(t)){return quoteString(e,true)}for(let r=t.length;r=0){throw TypeError("Converting circular structure to JSON5")}n.push(e);let t=a;a=a+o;let r=[];for(let t=0;t=n){return t.substr(0,n)}while(n>t.length&&i>1){if(i&1){t+=e}i>>=1;e+=e}t+=e;t=t.substr(0,n);return t}},,function(e,t,r){"use strict";var i=r(495);var n=r(839);var a=r(526);var u=r(135);var s=r(682);e.exports=i("remark-lint:no-duplicate-definitions",noDuplicateDefinitions);var o="Do not use definitions with the same identifier";function noDuplicateDefinitions(e,t){var r={};s(e,["definition","footnoteDefinition"],validate);function validate(e){var i;var s;if(!a(e)){i=e.identifier;s=r[i];if(s&&s.type){t.message(o+" ("+u(n.start(s))+")",e)}r[i]=e}}}},function(e){"use strict";e.exports=is;function is(e,t,r,i,n){var a=i!==null&&i!==undefined;var u=r!==null&&r!==undefined;var s=convert(e);if(u&&(typeof r!=="number"||r<0||r===Infinity)){throw new Error("Expected positive finite index or child node")}if(a&&(!is(null,i)||!i.children)){throw new Error("Expected parent node")}if(!t||!t.type||typeof t.type!=="string"){return false}if(a!==u){throw new Error("Expected both parent and index")}return Boolean(s.call(n,t,r,i))}function convert(e){if(typeof e==="string"){return typeFactory(e)}if(e===null||e===undefined){return ok}if(typeof e==="object"){return("length"in e?anyFactory:matchesFactory)(e)}if(typeof e==="function"){return e}throw new Error("Expected function, string, or object as test")}function convertAll(e){var t=[];var r=e.length;var i=-1;while(++i=u){v--;break}d+=g}D="";m="";while(++v{t=t||process.argv;const r=e.startsWith("-")?"":e.length===1?"-":"--";const i=t.indexOf(r+e);const n=t.indexOf("--");return i!==-1&&(n===-1?true:i0){s="Remove "+u+" "+n("line",u)+" "+(a>0?"before":"after")+" node";t.message(s,r)}}function visitChild(e,t,r){var i=r[t-1];var n=2;if(i&&!s(i)&&!s(e)){if(i.type==="list"&&e.type==="list"||e.type==="code"&&i.type==="list"&&!e.lang){n++}compare(u.end(i),u.start(e),n)}}}},,function(e,t,r){"use strict";var i=r(123);var n=r(341);var a=r(627);var u=r(406);var s=r(803);var o=r(647);e.exports=i().use(n).use(a).use(u).use(s).use(o)},,function(e,t,r){"use strict";var i=r(495);var n=r(704);var a=r(682);var u=r(839);var s=r(526);e.exports=i("remark-lint:list-item-bullet-indent",listItemBulletIndent);var o=u.start;function listItemBulletIndent(e,t){var r=String(t);a(e,"list",visitor);function visitor(e){e.children.forEach(visitItems)}function visitItems(e){var i;var a;var u;if(!s(e)){i=o(e.children[0]);a=r.slice(o(e).offset,i.offset).match(/^\s*/)[0].length;if(a!==0){u="Incorrect indentation before bullet: remove "+a+" "+n("space",a);t.message(u,{line:i.line,column:i.column-a})}}}}},function(e){e.exports=function(e,t){if(!t)t={};var r=t.hsep===undefined?" ":t.hsep;var i=t.align||[];var n=t.stringLength||function(e){return String(e).length};var a=reduce(e,function(e,t){forEach(t,function(t,r){var i=dotindex(t);if(!e[r]||i>e[r])e[r]=i});return e},[]);var u=map(e,function(e){return map(e,function(e,t){var r=String(e);if(i[t]==="."){var u=dotindex(r);var s=a[t]+(/\./.test(r)?1:2)-(n(r)-u);return r+Array(s).join(" ")}else return r})});var s=reduce(u,function(e,t){forEach(t,function(t,r){var i=n(t);if(!e[r]||i>e[r])e[r]=i});return e},[]);return map(u,function(e){return map(e,function(e,t){var r=s[t]-n(e)||0;var a=Array(Math.max(r+1,1)).join(" ");if(i[t]==="r"||i[t]==="."){return a+e}if(i[t]==="c"){return Array(Math.ceil(r/2+1)).join(" ")+e+Array(Math.floor(r/2+1)).join(" ")}return e+a}).join(r).replace(/\s+$/,"")}).join("\n")};function dotindex(e){var t=/\.[^.]*$/.exec(e);return t?t.index+1:e.length}function reduce(e,t,r){if(e.reduce)return e.reduce(t,r);var i=0;var n=arguments.length>=3?r:e[i++];for(;ir&&a0?"add":"remove")+" "+Math.abs(h)+" "+n("space",h);t.message(p,s)}}}}},,,,,function(e,t,r){"use strict";var i=r(721);e.exports=decodeEntity;var n={}.hasOwnProperty;function decodeEntity(e){return n.call(i,e)?i[e]:false}},function(e,t,r){"use strict";var i=r(495);var n=r(682);var a=r(839);var u=r(526);e.exports=i("remark-lint:definition-spacing",definitionSpacing);var s=/^\s*\[((?:\\[\s\S]|[^[\]])+)]/;var o="Do not use consecutive white-space in definition labels";function definitionSpacing(e,t){var r=String(t);n(e,["definition","footnoteDefinition"],validate);function validate(e){var i=a.start(e).offset;var n=a.end(e).offset;if(!u(e)&&/[ \t\n]{2,}/.test(r.slice(i,n).match(s)[1])){t.message(o,e)}}}},function(e,t,r){"use strict";var i=r(336);var n=r(780);e.exports=unherit;function unherit(e){var t;var r;var a;n(Of,e);n(From,Of);t=Of.prototype;for(r in t){a=t[r];if(a&&typeof a==="object"){t[r]="concat"in a?a.concat():i(a)}}return Of;function From(t){return e.apply(this,t)}function Of(){if(!(this instanceof Of)){return new From(arguments)}return e.apply(this,arguments)}}},function(e){"use strict";const t=e=>{let t=false;let r=false;let i=false;for(let n=0;n{if(!(typeof e==="string"||Array.isArray(e))){throw new TypeError("Expected the input to be `string | string[]`")}r=Object.assign({pascalCase:false},r);const i=e=>r.pascalCase?e.charAt(0).toUpperCase()+e.slice(1):e;if(Array.isArray(e)){e=e.map(e=>e.trim()).filter(e=>e.length).join("-")}else{e=e.trim()}if(e.length===0){return""}if(e.length===1){return r.pascalCase?e.toUpperCase():e.toLowerCase()}const n=e!==e.toLowerCase();if(n){e=t(e)}e=e.replace(/^[_.\- ]+/,"").toLowerCase().replace(/[_.\- ]+(\w|$)/g,(e,t)=>t.toUpperCase()).replace(/\d+(\w|$)/g,e=>e.toUpperCase());return i(e)};e.exports=r;e.exports.default=r},,function(e,t,r){"use strict";var i=r(211);function resolveYamlMerge(e){return e==="<<"||e===null}e.exports=new i("tag:yaml.org,2002:merge",{kind:"scalar",resolve:resolveYamlMerge})},function(e){"use strict";e.exports={gfm:true,commonmark:false,pedantic:false,entities:"false",setext:false,closeAtx:false,looseTable:false,spacedTable:true,paddedTable:true,stringLength:stringLength,incrementListMarker:true,fences:false,fence:"`",bullet:"-",listItemIndent:"tab",rule:"*",ruleSpaces:true,ruleRepetition:3,strong:"*",emphasis:"_"};function stringLength(e){return e.length}},function(e,t,r){"use strict";var i=r(197);var n=r(520);var a=r(439);var u=r(25);var s=r(908);var o=r(895);e.exports=parseEntities;var l={}.hasOwnProperty;var f=String.fromCharCode;var c=Function.prototype;var h={warning:null,reference:null,text:null,warningContext:null,referenceContext:null,textContext:null,position:{},additional:null,attribute:false,nonTerminated:true};var p="named";var v="hexadecimal";var d="decimal";var D={};D[v]=16;D[d]=10;var m={};m[p]=s;m[d]=a;m[v]=u;var g=1;var E=2;var A=3;var C=4;var y=5;var w=6;var x=7;var b={};b[g]="Named character references must be terminated by a semicolon";b[E]="Numeric character references must be terminated by a semicolon";b[A]="Named character references cannot be empty";b[C]="Numeric character references cannot be empty";b[y]="Named character references must be known";b[w]="Numeric character references cannot be disallowed";b[x]="Numeric character references cannot be outside the permissible Unicode range";function parseEntities(e,t){var r={};var i;var n;if(!t){t={}}for(n in h){i=t[n];r[n]=i===null||i===undefined?h[n]:i}if(r.position.indent||r.position.start){r.indent=r.position.indent||[];r.position=r.position.start}return parse(e,r)}function parse(e,t){var r=t.additional;var a=t.nonTerminated;var u=t.text;var h=t.reference;var F=t.warning;var S=t.textContext;var B=t.referenceContext;var k=t.warningContext;var O=t.position;var P=t.indent||[];var T=e.length;var I=0;var M=-1;var L=O.column||1;var R=O.line||1;var j="";var U=[];var N;var J;var z;var X;var G;var q;var W;var _;var V;var Y;var H;var $;var Z;var Q;var K;var ee;var te;var re;var ie;ee=now();_=F?parseError:c;I--;T++;while(++I65535){q-=65536;Y+=f(q>>>(10&1023)|55296);q=56320|q&1023}q=Y+f(q)}}if(!q){X=e.slice(Z-1,ie);j+=X;L+=X.length;I=ie-1}else{flush();ee=now();I=ie-1;L+=ie-Z+1;U.push(q);te=now();te.offset++;if(h){h.call(B,q,{start:ee,end:te},e.slice(Z-1,ie))}ee=te}}}return U.join("");function now(){return{line:R,column:L,offset:I+(O.offset||0)}}function parseError(e,t){var r=now();r.column+=t;r.offset+=t;F.call(k,b[e],r,e)}function at(t){return e.charAt(t)}function flush(){if(j){U.push(j);if(u){u.call(S,j,{start:ee,end:now()})}j=""}}}function prohibited(e){return e>=55296&&e<=57343||e>1114111}function disallowed(e){return e>=1&&e<=8||e===11||e>=13&&e<=31||e>=127&&e<=159||e>=64976&&e<=65007||(e&65535)===65535||(e&65535)===65534}},,,function(e,t,r){"use strict";var i=r(36);var n=r(116);var a=r(171);var u=r(82);e.exports=emphasis;emphasis.locator=u;var s="*";var o="_";var l="\\";function emphasis(e,t,r){var u=this;var f=0;var c=t.charAt(f);var h;var p;var v;var d;var D;var m;var g;if(c!==s&&c!==o){return}p=u.options.pedantic;D=c;v=c;m=t.length;f++;d="";c="";if(p&&a(t.charAt(f))){return}while(f0){if(typeof t!=="string"&&!a.objectMode&&Object.getPrototypeOf(t)!==l.prototype){t=_uint8ArrayToBuffer(t)}if(i){if(a.endEmitted)e.emit("error",new Error("stream.unshift() after end event"));else addChunk(e,a,t,true)}else if(a.ended){e.emit("error",new Error("stream.push() after EOF"))}else{a.reading=false;if(a.decoder&&!r){t=a.decoder.write(t);if(a.objectMode||t.length!==0)addChunk(e,a,t,false);else maybeReadMore(e,a)}else{addChunk(e,a,t,false)}}}else if(!i){a.reading=false}}return needMoreData(a)}function addChunk(e,t,r,i){if(t.flowing&&t.length===0&&!t.sync){e.emit("data",r);e.read(0)}else{t.length+=t.objectMode?1:r.length;if(i)t.buffer.unshift(r);else t.buffer.push(r);if(t.needReadable)emitReadable(e)}maybeReadMore(e,t)}function chunkInvalid(e,t){var r;if(!_isUint8Array(t)&&typeof t!=="string"&&t!==undefined&&!e.objectMode){r=new TypeError("Invalid non-string/buffer chunk")}return r}function needMoreData(e){return!e.ended&&(e.needReadable||e.length=g){e=g}else{e--;e|=e>>>1;e|=e>>>2;e|=e>>>4;e|=e>>>8;e|=e>>>16;e++}return e}function howMuchToRead(e,t){if(e<=0||t.length===0&&t.ended)return 0;if(t.objectMode)return 1;if(e!==e){if(t.flowing&&t.length)return t.buffer.head.data.length;else return t.length}if(e>t.highWaterMark)t.highWaterMark=computeNewHighWaterMark(e);if(e<=t.length)return e;if(!t.ended){t.needReadable=true;return 0}return t.length}Readable.prototype.read=function(e){p("read",e);e=parseInt(e,10);var t=this._readableState;var r=e;if(e!==0)t.emittedReadable=false;if(e===0&&t.needReadable&&(t.length>=t.highWaterMark||t.ended)){p("read: emitReadable",t.length,t.ended);if(t.length===0&&t.ended)endReadable(this);else emitReadable(this);return null}e=howMuchToRead(e,t);if(e===0&&t.ended){if(t.length===0)endReadable(this);return null}var i=t.needReadable;p("need readable",i);if(t.length===0||t.length-e0)n=fromList(e,t);else n=null;if(n===null){t.needReadable=true;e=0}else{t.length-=e}if(t.length===0){if(!t.ended)t.needReadable=true;if(r!==e&&t.ended)endReadable(this)}if(n!==null)this.emit("data",n);return n};function onEofChunk(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();if(r&&r.length){t.buffer.push(r);t.length+=t.objectMode?1:r.length}}t.ended=true;emitReadable(e)}function emitReadable(e){var t=e._readableState;t.needReadable=false;if(!t.emittedReadable){p("emitReadable",t.flowing);t.emittedReadable=true;if(t.sync)i.nextTick(emitReadable_,e);else emitReadable_(e)}}function emitReadable_(e){p("emit readable");e.emit("readable");flow(e)}function maybeReadMore(e,t){if(!t.readingMore){t.readingMore=true;i.nextTick(maybeReadMore_,e,t)}}function maybeReadMore_(e,t){var r=t.length;while(!t.reading&&!t.flowing&&!t.ended&&t.length1&&indexOf(n.pipes,e)!==-1)&&!l){p("false write response, pause",r._readableState.awaitDrain);r._readableState.awaitDrain++;f=true}r.pause()}}function onerror(t){p("onerror",t);unpipe();e.removeListener("error",onerror);if(s(e,"error")===0)e.emit("error",t)}prependListener(e,"error",onerror);function onclose(){e.removeListener("finish",onfinish);unpipe()}e.once("close",onclose);function onfinish(){p("onfinish");e.removeListener("close",onclose);unpipe()}e.once("finish",onfinish);function unpipe(){p("unpipe");r.unpipe(e)}e.emit("pipe",r);if(!n.flowing){p("pipe resume");r.resume()}return e};function pipeOnDrain(e){return function(){var t=e._readableState;p("pipeOnDrain",t.awaitDrain);if(t.awaitDrain)t.awaitDrain--;if(t.awaitDrain===0&&s(e,"data")){t.flowing=true;flow(e)}}}Readable.prototype.unpipe=function(e){var t=this._readableState;var r={hasUnpiped:false};if(t.pipesCount===0)return this;if(t.pipesCount===1){if(e&&e!==t.pipes)return this;if(!e)e=t.pipes;t.pipes=null;t.pipesCount=0;t.flowing=false;if(e)e.emit("unpipe",this,r);return this}if(!e){var i=t.pipes;var n=t.pipesCount;t.pipes=null;t.pipesCount=0;t.flowing=false;for(var a=0;a=t.length){if(t.decoder)r=t.buffer.join("");else if(t.buffer.length===1)r=t.buffer.head.data;else r=t.buffer.concat(t.length);t.buffer.clear()}else{r=fromListPartial(e,t.buffer,t.decoder)}return r}function fromListPartial(e,t,r){var i;if(ea.length?a.length:e;if(u===a.length)n+=a;else n+=a.slice(0,e);e-=u;if(e===0){if(u===a.length){++i;if(r.next)t.head=r.next;else t.head=t.tail=null}else{t.head=r;r.data=a.slice(u)}break}++i}t.length-=i;return n}function copyFromBuffer(e,t){var r=l.allocUnsafe(e);var i=t.head;var n=1;i.data.copy(r);e-=i.data.length;while(i=i.next){var a=i.data;var u=e>a.length?a.length:e;a.copy(r,r.length-e,0,u);e-=u;if(e===0){if(u===a.length){++n;if(i.next)t.head=i.next;else t.head=t.tail=null}else{t.head=i;i.data=a.slice(u)}break}++n}t.length-=n;return r}function endReadable(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');if(!t.endEmitted){t.ended=true;i.nextTick(endReadableNT,t,e)}}function endReadableNT(e,t){if(!e.endEmitted&&e.length===0){e.endEmitted=true;t.readable=false;t.emit("end")}}function indexOf(e,t){for(var r=0,i=e.length;r=f){continue}y="";while(v=2){t.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221]}}catch(e){}t.inspectOpts=Object.keys(process.env).filter(function(e){return/^debug_/i.test(e)}).reduce(function(e,t){var r=t.substring(6).toLowerCase().replace(/_([a-z])/g,function(e,t){return t.toUpperCase()});var i=process.env[t];if(/^(yes|on|true|enabled)$/i.test(i)){i=true}else if(/^(no|off|false|disabled)$/i.test(i)){i=false}else if(i==="null"){i=null}else{i=Number(i)}e[r]=i;return e},{});function useColors(){return"colors"in t.inspectOpts?Boolean(t.inspectOpts.colors):i.isatty(process.stderr.fd)}function formatArgs(t){var r=this.namespace,i=this.useColors;if(i){var n=this.color;var a="[3"+(n<8?n:"8;5;"+n);var u=" ".concat(a,";1m").concat(r," ");t[0]=u+t[0].split("\n").join("\n"+u);t.push(a+"m+"+e.exports.humanize(this.diff)+"")}else{t[0]=getDate()+r+" "+t[0]}}function getDate(){if(t.inspectOpts.hideDate){return""}return(new Date).toISOString()+" "}function log(){return process.stderr.write(n.format.apply(n,arguments)+"\n")}function save(e){if(e){process.env.DEBUG=e}else{delete process.env.DEBUG}}function load(){return process.env.DEBUG}function init(e){e.inspectOpts={};var r=Object.keys(t.inspectOpts);for(var i=0;i=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0"+e.toString(8):"-0"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}})},,,function(e){"use strict";e.exports=locate;function locate(e,t){var r=e.indexOf("[",t);var i=e.indexOf("![",t);if(i===-1){return r}return r1){u=Math.floor(u/l)*l}o[u]=a;s=e.charAt(++a)}return{indent:u,stops:o}}},function(e){"use strict";e.exports=locate;function locate(e,t){return e.indexOf("`",t)}},,function(e,t,r){"use strict";var i=r(495);var n=r(682);var a=r(839);var u=r(526);e.exports=i("remark-lint:unordered-list-marker-style",unorderedListMarkerStyle);var s=a.start;var o={"-":true,"*":true,"+":true,null:true};function unorderedListMarkerStyle(e,t,r){var i=String(t);r=typeof r==="string"&&r!=="consistent"?r:null;if(o[r]!==true){t.fail("Invalid unordered list-item marker style `"+r+"`: use either `'-'`, `'*'`, or `'+'`")}n(e,"list",visitor);function visitor(e){var n=e.children;var a=e.ordered?0:n.length;var o=-1;var l;var f;while(++ot){return{line:r+1,column:t-(e[r-1]||0)+1,offset:t}}}return{}}}function positionToOffsetFactory(e){return positionToOffset;function positionToOffset(t){var r=t&&t.line;var i=t&&t.column;if(!isNaN(r)&&!isNaN(i)&&r-1 in e){return(e[r-2]||0)+i-1||0}return-1}}function indices(e){var t=[];var r=e.indexOf("\n");while(r!==-1){t.push(r+1);r=e.indexOf("\n",r+1)}t.push(e.length+1);return t}},,function(e,t,r){"use strict";var i=r(495);var n=r(682);var a=r(526);var u=r(10);e.exports=i("remark-lint:no-inline-padding",noInlinePadding);function noInlinePadding(e,t){n(e,["emphasis","strong","delete","image","link"],visitor);function visitor(e){var r;if(!a(e)){r=u(e);if(r.charAt(0)===" "||r.charAt(r.length-1)===" "){t.message("Don’t pad `"+e.type+"` with inner spaces",e)}}}}},function(e){"use strict";e.exports=toString;function toString(e){return valueOf(e)||e.children&&e.children.map(toString).join("")||""}function valueOf(e){return(e&&e.value?e.value:e.alt?e.alt:e.title)||""}},,function(e){"use strict";if(!process.version||process.version.indexOf("v0.")===0||process.version.indexOf("v1.")===0&&process.version.indexOf("v1.8.")!==0){e.exports={nextTick:nextTick}}else{e.exports=process}function nextTick(e,t,r,i){if(typeof e!=="function"){throw new TypeError('"callback" argument must be a function')}var n=arguments.length;var a,u;switch(n){case 0:case 1:return process.nextTick(e);case 2:return process.nextTick(function afterTickOne(){e.call(null,t)});case 3:return process.nextTick(function afterTickTwo(){e.call(null,t,r)});case 4:return process.nextTick(function afterTickThree(){e.call(null,t,r,i)});default:a=new Array(n-1);u=0;while(u=97&&t<=102||t>=65&&t<=70||t>=48&&t<=57}},,function(e,t,r){"use strict";var i=r(431);function homedir(){var e=process.env;var t=e.HOME;var r=e.LOGNAME||e.USER||e.LNAME||e.USERNAME;if(process.platform==="win32"){return e.USERPROFILE||e.HOMEDRIVE+e.HOMEPATH||t||null}if(process.platform==="darwin"){return t||(r?"/Users/"+r:null)}if(process.platform==="linux"){return t||(process.getuid()===0?"/root":r?"/home/"+r:null)}return t||null}e.exports=typeof i.homedir==="function"?i.homedir:homedir},,,,,,function(e,t,r){"use strict";var i=r(495);var n=r(682);var a=r(270);var u=r(704);var s=r(839);var o=r(526);e.exports=i("remark-lint:no-heading-content-indent",noHeadingContentIndent);var l=s.start;var f=s.end;function noHeadingContentIndent(e,t){var r=String(t);n(e,"heading",visitor);function visitor(e){var i;var n;var s;var c;var h;var p;var v;var d;var D;var m;if(o(e)){return}i=e.depth;n=e.children;s=a(e,"atx");if(s==="atx"||s==="atx-closed"){h=l(e);d=h.offset;D=r.charAt(d);while(D&&D!=="#"){D=r.charAt(++d)}if(!D){return}d=i+(d-h.offset);c=l(n[0]).column;if(!c){return}v=c-h.column-1-d;if(v){m=(v>0?"Remove":"Add")+" "+Math.abs(v)+" "+u("space",v)+" before this heading’s content";t.message(m,l(n[0]))}}if(s==="atx-closed"){p=f(n[n.length-1]);v=f(e).column-p.column-1-i;if(v){m="Remove "+v+" "+u("space",v)+" after this heading’s content";t.message(m,p)}}}}},function(e,t,r){"use strict";var i=r(336);var n=r(440);var a=r(901);var u=r(360);var s=r(315);e.exports=setOptions;var o={entities:{true:true,false:true,numbers:true,escape:true},bullet:{"*":true,"-":true,"+":true},rule:{"-":true,_:true,"*":true},listItemIndent:{tab:true,mixed:true,1:true},emphasis:{_:true,"*":true},strong:{_:true,"*":true},fence:{"`":true,"~":true}};var l={boolean:validateBoolean,string:validateString,number:validateNumber,function:validateFunction};function setOptions(e){var t=this;var r=t.options;var n;var s;if(e==null){e={}}else if(typeof e==="object"){e=i(e)}else{throw new Error("Invalid value `"+e+"` for setting `options`")}for(s in a){l[typeof a[s]](e,s,r[s],o[s])}n=e.ruleRepetition;if(n&&n<3){raise(n,"options.ruleRepetition")}t.encode=encodeFactory(String(e.entities));t.escape=u(e);t.options=e;return t}function validateBoolean(e,t,r){var i=e[t];if(i==null){i=r}if(typeof i!=="boolean"){raise(i,"options."+t)}e[t]=i}function validateNumber(e,t,r){var i=e[t];if(i==null){i=r}if(isNaN(i)){raise(i,"options."+t)}e[t]=i}function validateString(e,t,r,i){var n=e[t];if(n==null){n=r}n=String(n);if(!(n in i)){raise(n,"options."+t)}e[t]=n}function validateFunction(e,t,r){var i=e[t];if(i==null){i=r}if(typeof i!=="function"){raise(i,"options."+t)}e[t]=i}function encodeFactory(e){var t={};if(e==="false"){return s}if(e==="true"){t.useNamedReferences=true}if(e==="escape"){t.escapeOnly=true;t.useNamedReferences=true}return wrapped;function wrapped(e){return n(e,t)}}function raise(e,t){throw new Error("Invalid value `"+e+"` for setting `"+t+"`")}},,function(e,t){t=e.exports=trim;function trim(e){return e.replace(/^\s*|\s*$/g,"")}t.left=function(e){return e.replace(/^\s*/,"")};t.right=function(e){return e.replace(/\s*$/,"")}},function(e,t,r){"use strict";var i=r(814);e.exports=thematic;var n=" ";function thematic(){var e=this.options;var t=i(e.rule,e.ruleRepetition);return e.ruleSpaces?t.split("").join(n):t}},,,,,function(e,t,r){"use strict";var i=r(315);e.exports=enter;function enter(e,t){var r=e.encode;var n=e.escape;var a=e.enterLink();if(t.referenceType!=="shortcut"&&t.referenceType!=="collapsed"){return a}e.escape=i;e.encode=i;return exit;function exit(){e.encode=r;e.escape=n;a()}}},function(e,t,r){"use strict";var i=r(727);e.exports=new i({include:[r(234)],implicit:[r(633),r(843),r(981),r(702)]})},function(e,t,r){"use strict";var i=r(36);var n=r(814);var a=r(439);var u=r(1);var s=r(235);var o=r(724);e.exports=list;var l="*";var f="_";var c="+";var h="-";var p=".";var v=" ";var d="\n";var D="\t";var m=")";var g="x";var E=4;var A=/\n\n(?!\s*$)/;var C=/^\[([ \t]|x|X)][ \t]/;var y=/^([ \t]*)([*+-]|\d+[.)])( {1,4}(?! )| |\t|$|(?=\n))([^\n]*)/;var w=/^([ \t]*)([*+-]|\d+[.)])([ \t]+)/;var x=/^( {1,4}|\t)?/gm;function list(e,t,r){var n=this;var u=n.options.commonmark;var s=n.options.pedantic;var g=n.blockTokenizers;var A=n.interruptList;var C=0;var y=t.length;var w=null;var x=0;var b;var F;var S;var B;var k;var O;var P;var T;var I;var M;var L;var R;var j;var U;var N;var J;var z;var X;var G=false;var q;var W;var _;var V;while(C=E){return}S=t.charAt(C);if(S===l||S===c||S===h){B=S;F=false}else{F=true;b="";while(C=E){V=true}if(J&&x>=J.indent){V=true}S=t.charAt(C);T=null;if(!V){if(S===l||S===c||S===h){T=S;C++;x++}else{b="";while(C=J.indent||x>E}P=false;C=O}M=t.slice(O,k);I=O===C?M:t.slice(C,k);if(T===l||T===f||T===h){if(g.thematicBreak.call(n,e,M,true)){break}}L=R;R=!P&&!i(I).length;if(V&&J){J.value=J.value.concat(N,M);U=U.concat(N,M);N=[]}else if(P){if(N.length!==0){G=true;J.value.push("");J.trail=N.concat()}J={value:[M],indent:x,trail:[]};j.push(J);U=U.concat(N,M);N=[]}else if(R){if(L&&!u){break}N.push(M)}else{if(L){break}if(o(A,g,n,[e,M,true])){break}J.value=J.value.concat(N,M);U=U.concat(N,M);N=[]}C=k+1}q=e(U.join(d)).reset({type:"list",ordered:F,start:w,spread:G,children:[]});z=n.enterList();X=n.enterBlock();C=-1;y=j.length;while(++C1){t.message(s,e)}}}},function(e){e.exports=function isBuffer(e){return e!=null&&e.constructor!=null&&typeof e.constructor.isBuffer==="function"&&e.constructor.isBuffer(e)}},,,,,,,,function(e){e.exports=require("util")},function(e,t,r){"use strict";var i=r(727);e.exports=i.DEFAULT=new i({include:[r(388)],explicit:[r(875),r(555),r(329)]})},function(e){e.exports=require("fs")},function(e){"use strict";e.exports=function(e){if(typeof e!=="string"){throw new TypeError("Expected a string")}return!/[^0-9a-z\xDF-\xFF]/.test(e.toLowerCase())}},,,,,function(e,t,r){"use strict";var i=r(495);var n=r(7);e.exports=i("remark-lint:no-tabs",noTabs);var a="Use spaces instead of hard-tabs";function noTabs(e,t){var r=String(t);var i=n(t).toPosition;var u=r.indexOf("\t");while(u!==-1){t.message(a,i(u));u=r.indexOf("\t",u+1)}}},function(e){function webpackEmptyContext(e){var t=new Error("Cannot find module '"+e+"'");t.code="MODULE_NOT_FOUND";throw t}webpackEmptyContext.keys=function(){return[]};webpackEmptyContext.resolve=webpackEmptyContext;e.exports=webpackEmptyContext;webpackEmptyContext.id=73},function(e,t,r){"use strict";var i=r(864);var n=r(97);var a=r(503);var u=r(123);var s=r(340);var o=r(951);e.exports=unified().freeze();var l=[].slice;var f={}.hasOwnProperty;var c=u().use(pipelineParse).use(pipelineRun).use(pipelineStringify);function pipelineParse(e,t){t.tree=e.parse(t.file)}function pipelineRun(e,t,r){e.run(t.tree,t.file,done);function done(e,i,n){if(e){r(e)}else{t.tree=i;t.file=n;r()}}}function pipelineStringify(e,t){t.file.contents=e.stringify(t.tree,t.file)}function unified(){var e=[];var t=u();var r={};var h=false;var p=-1;processor.data=data;processor.freeze=freeze;processor.attachers=e;processor.use=use;processor.parse=parse;processor.stringify=stringify;processor.run=run;processor.runSync=runSync;processor.process=process;processor.processSync=processSync;return processor;function processor(){var t=unified();var n=e.length;var a=-1;while(++a{if(typeof e!=="string"){throw new TypeError(`Expected \`fromDir\` to be of type \`string\`, got \`${typeof e}\``)}if(typeof t!=="string"){throw new TypeError(`Expected \`moduleId\` to be of type \`string\`, got \`${typeof t}\``)}try{e=a.realpathSync(e)}catch(t){if(t.code==="ENOENT"){e=i.resolve(e)}else if(r){return null}else{throw t}}const u=i.join(e,"noop.js");const s=()=>n._resolveFilename(t,{id:u,filename:u,paths:n._nodeModulePaths(e)});if(r){try{return s()}catch(e){return null}}return s()};e.exports=((e,t)=>u(e,t));e.exports.silent=((e,t)=>u(e,t,true))},,function(e,t,r){"use strict";var i=r(347)("unified-engine:file-pipeline:configure");var n=r(928);var a=r(623);var u=r(692);var s=r(876);e.exports=configure;function configure(e,t,r,o){var l=e.configuration;var f=e.processor;if(n(t).fatal){return o()}l.load(t.path,handleConfiguration);function handleConfiguration(e,t){var n;var l;var c;var h;var p;var v;if(e){return o(e)}i("Using settings `%j`",t.settings);f.data("settings",t.settings);n=t.plugins;h=n.length;p=-1;i("Using `%d` plugins",h);while(++p>10)+55296,(e-65536&1023)+56320)}var C=new Array(256);var y=new Array(256);for(var w=0;w<256;w++){C[w]=simpleEscapeSequence(w)?1:0;y[w]=simpleEscapeSequence(w)}function State(e,t){this.input=e;this.filename=t["filename"]||null;this.schema=t["schema"]||s;this.onWarning=t["onWarning"]||null;this.legacy=t["legacy"]||false;this.json=t["json"]||false;this.listener=t["listener"]||null;this.implicitTypes=this.schema.compiledImplicit;this.typeMap=this.schema.compiledTypeMap;this.length=e.length;this.position=0;this.line=0;this.lineStart=0;this.lineIndent=0;this.documents=[]}function generateError(e,t){return new n(t,new a(e.filename,e.input,e.position,e.line,e.position-e.lineStart))}function throwError(e,t){throw generateError(e,t)}function throwWarning(e,t){if(e.onWarning){e.onWarning.call(null,generateError(e,t))}}var x={YAML:function handleYamlDirective(e,t,r){var i,n,a;if(e.version!==null){throwError(e,"duplication of %YAML directive")}if(r.length!==1){throwError(e,"YAML directive accepts exactly one argument")}i=/^([0-9]+)\.([0-9]+)$/.exec(r[0]);if(i===null){throwError(e,"ill-formed argument of the YAML directive")}n=parseInt(i[1],10);a=parseInt(i[2],10);if(n!==1){throwError(e,"unacceptable YAML version of the document")}e.version=r[0];e.checkLineBreaks=a<2;if(a!==1&&a!==2){throwWarning(e,"unsupported YAML version of the document")}},TAG:function handleTagDirective(e,t,r){var i,n;if(r.length!==2){throwError(e,"TAG directive accepts exactly two arguments")}i=r[0];n=r[1];if(!E.test(i)){throwError(e,"ill-formed tag handle (first argument) of the TAG directive")}if(o.call(e.tagMap,i)){throwError(e,'there is a previously declared suffix for "'+i+'" tag handle')}if(!A.test(n)){throwError(e,"ill-formed tag prefix (second argument) of the TAG directive")}e.tagMap[i]=n}};function captureSegment(e,t,r,i){var n,a,u,s;if(t1){e.result+=i.repeat("\n",t-1)}}function readPlainScalar(e,t,r){var i,n,a,u,s,o,l,f,c=e.kind,h=e.result,p;p=e.input.charCodeAt(e.position);if(is_WS_OR_EOL(p)||is_FLOW_INDICATOR(p)||p===35||p===38||p===42||p===33||p===124||p===62||p===39||p===34||p===37||p===64||p===96){return false}if(p===63||p===45){n=e.input.charCodeAt(e.position+1);if(is_WS_OR_EOL(n)||r&&is_FLOW_INDICATOR(n)){return false}}e.kind="scalar";e.result="";a=u=e.position;s=false;while(p!==0){if(p===58){n=e.input.charCodeAt(e.position+1);if(is_WS_OR_EOL(n)||r&&is_FLOW_INDICATOR(n)){break}}else if(p===35){i=e.input.charCodeAt(e.position-1);if(is_WS_OR_EOL(i)){break}}else if(e.position===e.lineStart&&testDocumentSeparator(e)||r&&is_FLOW_INDICATOR(p)){break}else if(is_EOL(p)){o=e.line;l=e.lineStart;f=e.lineIndent;skipSeparationSpace(e,false,-1);if(e.lineIndent>=t){s=true;p=e.input.charCodeAt(e.position);continue}else{e.position=u;e.line=o;e.lineStart=l;e.lineIndent=f;break}}if(s){captureSegment(e,a,u,false);writeFoldedLines(e,e.line-o);a=u=e.position;s=false}if(!is_WHITE_SPACE(p)){u=e.position+1}p=e.input.charCodeAt(++e.position)}captureSegment(e,a,u,false);if(e.result){return true}e.kind=c;e.result=h;return false}function readSingleQuotedScalar(e,t){var r,i,n;r=e.input.charCodeAt(e.position);if(r!==39){return false}e.kind="scalar";e.result="";e.position++;i=n=e.position;while((r=e.input.charCodeAt(e.position))!==0){if(r===39){captureSegment(e,i,e.position,true);r=e.input.charCodeAt(++e.position);if(r===39){i=e.position;e.position++;n=e.position}else{return true}}else if(is_EOL(r)){captureSegment(e,i,n,true);writeFoldedLines(e,skipSeparationSpace(e,false,t));i=n=e.position}else if(e.position===e.lineStart&&testDocumentSeparator(e)){throwError(e,"unexpected end of the document within a single quoted scalar")}else{e.position++;n=e.position}}throwError(e,"unexpected end of the stream within a single quoted scalar")}function readDoubleQuotedScalar(e,t){var r,i,n,a,u,s;s=e.input.charCodeAt(e.position);if(s!==34){return false}e.kind="scalar";e.result="";e.position++;r=i=e.position;while((s=e.input.charCodeAt(e.position))!==0){if(s===34){captureSegment(e,r,e.position,true);e.position++;return true}else if(s===92){captureSegment(e,r,e.position,true);s=e.input.charCodeAt(++e.position);if(is_EOL(s)){skipSeparationSpace(e,false,t)}else if(s<256&&C[s]){e.result+=y[s];e.position++}else if((u=escapedHexLen(s))>0){n=u;a=0;for(;n>0;n--){s=e.input.charCodeAt(++e.position);if((u=fromHexCode(s))>=0){a=(a<<4)+u}else{throwError(e,"expected hexadecimal character")}}e.result+=charFromCodepoint(a);e.position++}else{throwError(e,"unknown escape sequence")}r=i=e.position}else if(is_EOL(s)){captureSegment(e,r,i,true);writeFoldedLines(e,skipSeparationSpace(e,false,t));r=i=e.position}else if(e.position===e.lineStart&&testDocumentSeparator(e)){throwError(e,"unexpected end of the document within a double quoted scalar")}else{e.position++;i=e.position}}throwError(e,"unexpected end of the stream within a double quoted scalar")}function readFlowCollection(e,t){var r=true,i,n=e.tag,a,u=e.anchor,s,o,f,c,h,p={},v,d,D,m;m=e.input.charCodeAt(e.position);if(m===91){o=93;h=false;a=[]}else if(m===123){o=125;h=true;a={}}else{return false}if(e.anchor!==null){e.anchorMap[e.anchor]=a}m=e.input.charCodeAt(++e.position);while(m!==0){skipSeparationSpace(e,true,t);m=e.input.charCodeAt(e.position);if(m===o){e.position++;e.tag=n;e.anchor=u;e.kind=h?"mapping":"sequence";e.result=a;return true}else if(!r){throwError(e,"missed comma between flow collection entries")}d=v=D=null;f=c=false;if(m===63){s=e.input.charCodeAt(e.position+1);if(is_WS_OR_EOL(s)){f=c=true;e.position++;skipSeparationSpace(e,true,t)}}i=e.line;composeNode(e,t,l,false,true);d=e.tag;v=e.result;skipSeparationSpace(e,true,t);m=e.input.charCodeAt(e.position);if((c||e.line===i)&&m===58){f=true;m=e.input.charCodeAt(++e.position);skipSeparationSpace(e,true,t);composeNode(e,t,l,false,true);D=e.result}if(h){storeMappingPair(e,a,p,d,v,D)}else if(f){a.push(storeMappingPair(e,null,p,d,v,D))}else{a.push(v)}skipSeparationSpace(e,true,t);m=e.input.charCodeAt(e.position);if(m===44){r=true;m=e.input.charCodeAt(++e.position)}else{r=false}}throwError(e,"unexpected end of the stream within a flow collection")}function readBlockScalar(e,t){var r,n,a=p,u=false,s=false,o=t,l=0,f=false,c,h;h=e.input.charCodeAt(e.position);if(h===124){n=false}else if(h===62){n=true}else{return false}e.kind="scalar";e.result="";while(h!==0){h=e.input.charCodeAt(++e.position);if(h===43||h===45){if(p===a){a=h===43?d:v}else{throwError(e,"repeat of a chomping mode identifier")}}else if((c=fromDecimalCode(h))>=0){if(c===0){throwError(e,"bad explicit indentation width of a block scalar; it cannot be less than one")}else if(!s){o=t+c-1;s=true}else{throwError(e,"repeat of an indentation width identifier")}}else{break}}if(is_WHITE_SPACE(h)){do{h=e.input.charCodeAt(++e.position)}while(is_WHITE_SPACE(h));if(h===35){do{h=e.input.charCodeAt(++e.position)}while(!is_EOL(h)&&h!==0)}}while(h!==0){readLineBreak(e);e.lineIndent=0;h=e.input.charCodeAt(e.position);while((!s||e.lineIndento){o=e.lineIndent}if(is_EOL(h)){l++;continue}if(e.lineIndentt)&&o!==0){throwError(e,"bad indentation of a sequence entry")}else if(e.lineIndentt){if(composeNode(e,t,h,true,n)){if(D){v=e.result}else{d=e.result}}if(!D){storeMappingPair(e,l,c,p,v,d,a,u);p=v=d=null}skipSeparationSpace(e,true,-1);g=e.input.charCodeAt(e.position)}if(e.lineIndent>t&&g!==0){throwError(e,"bad indentation of a mapping entry")}else if(e.lineIndentt){p=1}else if(e.lineIndent===t){p=0}else if(e.lineIndentt){p=1}else if(e.lineIndent===t){p=0}else if(e.lineIndent tag; it should be "'+g.kind+'", not "'+e.kind+'"')}if(!g.resolve(e.result)){throwError(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}else{e.result=g.construct(e.result);if(e.anchor!==null){e.anchorMap[e.anchor]=e.result}}}else{throwError(e,"unknown tag !<"+e.tag+">")}}if(e.listener!==null){e.listener("close",e)}return e.tag!==null||e.anchor!==null||d}function readDocument(e){var t=e.position,r,i,n,a=false,u;e.version=null;e.checkLineBreaks=e.legacy;e.tagMap={};e.anchorMap={};while((u=e.input.charCodeAt(e.position))!==0){skipSeparationSpace(e,true,-1);u=e.input.charCodeAt(e.position);if(e.lineIndent>0||u!==37){break}a=true;u=e.input.charCodeAt(++e.position);r=e.position;while(u!==0&&!is_WS_OR_EOL(u)){u=e.input.charCodeAt(++e.position)}i=e.input.slice(r,e.position);n=[];if(i.length<1){throwError(e,"directive name must not be less than one character in length")}while(u!==0){while(is_WHITE_SPACE(u)){u=e.input.charCodeAt(++e.position)}if(u===35){do{u=e.input.charCodeAt(++e.position)}while(u!==0&&!is_EOL(u));break}if(is_EOL(u))break;r=e.position;while(u!==0&&!is_WS_OR_EOL(u)){u=e.input.charCodeAt(++e.position)}n.push(e.input.slice(r,e.position))}if(u!==0)readLineBreak(e);if(o.call(x,i)){x[i](e,i,n)}else{throwWarning(e,'unknown document directive "'+i+'"')}}skipSeparationSpace(e,true,-1);if(e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45){e.position+=3;skipSeparationSpace(e,true,-1)}else if(a){throwError(e,"directives end mark is expected")}composeNode(e,e.lineIndent-1,h,false,true);skipSeparationSpace(e,true,-1);if(e.checkLineBreaks&&m.test(e.input.slice(t,e.position))){throwWarning(e,"non-ASCII line breaks are interpreted as content")}e.documents.push(e.result);if(e.position===e.lineStart&&testDocumentSeparator(e)){if(e.input.charCodeAt(e.position)===46){e.position+=3;skipSeparationSpace(e,true,-1)}return}if(e.position output."+r,""," # Rewrite all applicable files"," $ "+i+" . -o"].join("\n");return{helpMessage:u,cwd:t.cwd,processor:t.processor,help:n.help,version:n.version,files:n._,filePath:n.filePath,watch:n.watch,extensions:f.length===0?t.extensions:f,output:n.output,out:n.stdout,tree:n.tree,treeIn:n.treeIn,treeOut:n.treeOut,inspect:n.inspect,rcName:t.rcName,packageField:t.packageField,rcPath:n.rcPath,detectConfig:n.config,settings:settings(n.setting),ignoreName:t.ignoreName,ignorePath:n.ignorePath,ignorePatterns:commaSeparated(n.ignorePattern),detectIgnore:n.ignore,pluginPrefix:t.pluginPrefix,plugins:plugins(n.use),reporter:c[0],reporterOptions:c[1],color:n.color,silent:n.silent,quiet:n.quiet,frail:n.frail}}function addEach(e){var t=e.default;l.default[e.long]=t===undefined?null:t;if(e.type in l){l[e.type].push(e.long)}if(e.short){l.alias[e.short]=e.long}}function commaSeparated(e){return flatten(normalize(e).map(splitList))}function plugins(e){var t={};normalize(e).map(splitOptions).forEach(function(e){t[e[0]]=e[1]?parseConfig(e[1],{}):null});return t}function reporter(e){var t=normalize(e).map(splitOptions).map(function(e){return[e[0],e[1]?parseConfig(e[1],{}):null]});return t[t.length-1]||[]}function settings(e){var t={};normalize(e).forEach(function(e){parseConfig(e,t)});return t}function parseConfig(e,t){var r;var i;try{e=toCamelCase(parseJSON(e))}catch(t){i=t.message.replace(/at(?= position)/,"around");throw s("Cannot parse `%s` as JSON: %s",e,i)}for(r in e){t[r]=e[r]}return t}function handleUnknownArgument(e){if(e.charAt(0)!=="-"){return}if(e.charAt(1)==="-"){throw s("Unknown option `%s`, expected:\n%s",e,inspectAll(o))}e.slice(1).split("").forEach(each);function each(e){var t=o.length;var r=-1;var i;while(++r=2,has16m:e>=3}}function supportsColor(e){if(u===false){return 0}if(n("color=16m")||n("color=full")||n("color=truecolor")){return 3}if(n("color=256")){return 2}if(e&&!e.isTTY&&u!==true){return 0}const t=u?1:0;if(process.platform==="win32"){const e=i.release().split(".");if(Number(process.versions.node.split(".")[0])>=8&&Number(e[0])>=10&&Number(e[2])>=10586){return Number(e[2])>=14931?3:2}return 1}if("CI"in a){if(["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI"].some(e=>e in a)||a.CI_NAME==="codeship"){return 1}return t}if("TEAMCITY_VERSION"in a){return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(a.TEAMCITY_VERSION)?1:0}if(a.COLORTERM==="truecolor"){return 3}if("TERM_PROGRAM"in a){const e=parseInt((a.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(a.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(a.TERM)){return 2}if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(a.TERM)){return 1}if("COLORTERM"in a){return 1}if(a.TERM==="dumb"){return t}return t}function getSupportLevel(e){const t=supportsColor(e);return translateLevel(t)}e.exports={supportsColor:getSupportLevel,stdout:getSupportLevel(process.stdout),stderr:getSupportLevel(process.stderr)}},,,function(e,t,r){"use strict";var i=r(347)("unified-engine:file-pipeline:queue");var n=r(928);e.exports=queue;function queue(e,t,r,a){var u=t.history[0];var s=r.complete;var o=true;if(!s){s={};r.complete=s}i("Queueing `%s`",u);s[u]=a;r.valueOf().forEach(each);if(!o){i("Not flushing: some files cannot be flushed");return}r.complete={};r.pipeline.run(r,done);function each(e){var t=e.history[0];if(n(e).fatal){return}if(typeof s[t]==="function"){i("`%s` can be flushed",t)}else{i("Interupting flush: `%s` is not finished",t);o=false}}function done(e){i("Flushing: all files can be flushed");for(u in s){s[u](e)}}}},function(e,t,r){"use strict";var i=r(171);var n=r(426);e.exports=definition;definition.notInList=true;definition.notInBlock=true;var a='"';var u="'";var s="\\";var o="\n";var l="\t";var f=" ";var c="[";var h="]";var p="(";var v=")";var d=":";var D="<";var m=">";function definition(e,t,r){var i=this;var m=i.options.commonmark;var g=0;var E=t.length;var A="";var C;var y;var w;var x;var b;var F;var S;var B;while(g"];var r=t.concat(["~","|"]);var i=r.concat(["\n",'"',"$","%","&","'",",","/",":",";","<","=","?","@","^"]);escapes.default=t;escapes.gfm=r;escapes.commonmark=i;function escapes(e){var n=e||{};if(n.commonmark){return i}return n.gfm?r:t}},,function(e){"use strict";e.exports=locate;function locate(e,t){return e.indexOf("~~",t)}},function(e,t,r){"use strict";var i=r(495);var n=r(7);var a=r(682);var u=r(839);var s=r(526);e.exports=i("remark-lint:checkbox-character-style",checkboxCharacterStyle);var o=u.start;var l=u.end;var f={x:true,X:true};var c={" ":true,"\t":true};var h={true:"checked",false:"unchecked"};function checkboxCharacterStyle(e,t,r){var i=String(t);var u=n(t);r=typeof r==="object"?r:{};if(r.unchecked&&c[r.unchecked]!==true){t.fail("Invalid unchecked checkbox marker `"+r.unchecked+"`: use either `'\\t'`, or `' '`")}if(r.checked&&f[r.checked]!==true){t.fail("Invalid checked checkbox marker `"+r.checked+"`: use either `'x'`, or `'X'`")}a(e,"listItem",visitor);function visitor(e){var n;var a;var f;var c;var p;var v;var d;if(typeof e.checked!=="boolean"||s(e)){return}n=h[e.checked];a=o(e).offset;f=(e.children.length===0?l(e):o(e.children[0])).offset;c=i.slice(a,f).trimRight().slice(0,-1);v=c.charAt(c.length-1);p=r[n];if(p){if(v!==p){d=n.charAt(0).toUpperCase()+n.slice(1)+" checkboxes should use `"+p+"` as a marker";t.message(d,{start:u.toPosition(a+c.length-1),end:u.toPosition(a+c.length)})}}else{r[n]=v}}}},,,,function(e){"use strict";e.exports=wordCharacter;var t=String.fromCharCode;var r=/\w/;function wordCharacter(e){return r.test(typeof e==="number"?t(e):e.charAt(0))}},,,,,function(e,t,r){"use strict";var i=r(495);var n=r(682);var a=r(526);e.exports=i("remark-lint:no-shortcut-reference-image",noShortcutReferenceImage);var u="Use the trailing [] on reference images";function noShortcutReferenceImage(e,t){n(e,"imageReference",visitor);function visitor(e){if(!a(e)&&e.referenceType==="shortcut"){t.message(u,e)}}}},,function(e,t,r){"use strict";var i=r(335);e.exports=trough;trough.wrap=i;var n=[].slice;function trough(){var e=[];var t={};t.run=run;t.use=use;return t;function run(){var t=-1;var r=n.call(arguments,0,-1);var a=arguments[arguments.length-1];if(typeof a!=="function"){throw new Error("Expected function as last argument, not "+a)}next.apply(null,[null].concat(r));function next(u){var s=e[++t];var o=n.call(arguments,0);var l=o.slice(1);var f=r.length;var c=-1;if(u){a(u);return}while(++c"){break}if(v!==" "&&v!=="\t"){t.message(o,d);break}}}}}},,function(e,t,r){e.exports=realpath;realpath.realpath=realpath;realpath.sync=realpathSync;realpath.realpathSync=realpathSync;realpath.monkeypatch=monkeypatch;realpath.unmonkeypatch=unmonkeypatch;var i=r(66);var n=i.realpath;var a=i.realpathSync;var u=process.version;var s=/^v[0-5]\./.test(u);var o=r(544);function newError(e){return e&&e.syscall==="realpath"&&(e.code==="ELOOP"||e.code==="ENOMEM"||e.code==="ENAMETOOLONG")}function realpath(e,t,r){if(s){return n(e,t,r)}if(typeof t==="function"){r=t;t=null}n(e,t,function(i,n){if(newError(i)){o.realpath(e,t,r)}else{r(i,n)}})}function realpathSync(e,t){if(s){return a(e,t)}try{return a(e,t)}catch(r){if(newError(r)){return o.realpathSync(e,t)}else{throw r}}}function monkeypatch(){i.realpath=realpath;i.realpathSync=realpathSync}function unmonkeypatch(){i.realpath=n;i.realpathSync=a}},,,,,,function(e){"use strict";var t={}.hasOwnProperty;e.exports=stringify;function stringify(e){if(!e||typeof e!=="object"){return""}if(t.call(e,"position")||t.call(e,"type")){return position(e.position)}if(t.call(e,"start")||t.call(e,"end")){return position(e)}if(t.call(e,"line")||t.call(e,"column")){return point(e)}return""}function point(e){if(!e||typeof e!=="object"){e={}}return index(e.line)+":"+index(e.column)}function position(e){if(!e||typeof e!=="object"){e={}}return point(e.start)+"-"+point(e.end)}function index(e){return e&&typeof e==="number"?e:1}},,function(e,t,r){"use strict";var i=r(495);var n=r(682);var a=r(839);var u=r(526);e.exports=i("remark-lint:fenced-code-flag",fencedCodeFlag);var s=a.start;var o=a.end;var l=/^ {0,3}([~`])\1{2,}/;var f="Invalid code-language flag";var c="Missing code-language flag";function fencedCodeFlag(e,t,r){var i=String(t);var a=false;var h=[];if(typeof r==="object"&&!("length"in r)){a=Boolean(r.allowEmpty);r=r.flags}if(typeof r==="object"&&"length"in r){h=String(r).split(",")}n(e,"code",visitor);function visitor(e){var r;if(!u(e)){if(e.lang){if(h.length!==0&&h.indexOf(e.lang)===-1){t.message(f,e)}}else{r=i.slice(s(e).offset,o(e).offset);if(!a&&l.test(r)){t.message(c,e)}}}}}},function(e){"use strict";e.exports=alphabetical;function alphabetical(e){var t=typeof e==="string"?e.charCodeAt(0):e;return t>=97&&t<=122||t>=65&&t<=90}},function(e){"use strict";e.exports=locate;var t=["https://","http://","mailto:"];function locate(e,r){var i=t.length;var n=-1;var a=-1;var u;if(!this.options.gfm){return-1}while(++na){i[n-a]=e[n]}return i}},,,,,,,,,function(e,t,r){"use strict";var i=r(211);var n=Object.prototype.hasOwnProperty;var a=Object.prototype.toString;function resolveYamlOmap(e){if(e===null)return true;var t=[],r,i,u,s,o,l=e;for(r=0,i=l.length;r-1){a.splice(u,1)}var s=r;a.forEach(function _buildSubObj(e,r){if(!e||typeof s!=="object")return;if(r===a.length-1)s[e]=t[n];if(s[e]===undefined)s[e]={};s=s[e]})}}return r};var c=t.find=function(){var e=a.join.apply(null,[].slice.call(arguments));function find(e,t){var r=a.join(e,t);try{i.statSync(r);return r}catch(r){if(a.dirname(e)!==e)return find(a.dirname(e),t)}}return find(process.cwd(),e)}},,,,function(e,t,r){"use strict";const i=r(202);const n=r(751);const a=i("JSONError",{fileName:i.append("in %s")});e.exports=((e,t,r)=>{if(typeof t==="string"){r=t;t=null}try{try{return JSON.parse(e,t)}catch(r){n(e,t);throw r}}catch(e){e.message=e.message.replace(/\n/g,"");const t=new a(e);if(r){t.fileName=r}throw t}})},function(e,t,r){"use strict";var i=r(495);var n=r(682);var a=r(839);var u=r(526);e.exports=i("remark-lint:maximum-line-length",maximumLineLength);var s=a.start;var o=a.end;function maximumLineLength(e,t,r){var i=typeof r==="number"&&!isNaN(r)?r:80;var a=String(t);var l=a.split(/\r?\n/);var f=l.length;var c=-1;var h;n(e,["heading","table","code","definition","html","jsx"],ignore);n(e,["link","image","inlineCode"],inline);while(++ci){t.message("Line must be at most "+i+" characters",{line:c+1,column:h+1})}}function inline(e,t,r){var n=r.children[t+1];var a;var l;if(u(e)){return}a=s(e);l=o(e);if(a.column>i||l.column0?"Add":"Remove")+" "+Math.abs(i)+" "+n("space",i)+" between blockquote and content";t.message(a,u.start(e.children[0]))}}else{r=check(e)}}}function check(e){var t=e.children[0];var r=u.start(t).column-u.start(e).column;var i=o(t).match(/^ +/);if(i){r+=i[0].length}return r}},,,,,function(e){"use strict";e.exports=whitespace;var t=String.fromCharCode;var r=/\s/;function whitespace(e){return r.test(typeof e==="number"?t(e):e.charAt(0))}},,,function(e,t,r){"use strict";var i=r(814);var n="\n";var a=" ";var u=":";var s="[";var o="]";var l="^";var f=4;var c=n+n;var h=i(a,f);e.exports=footnoteDefinition;function footnoteDefinition(e){var t=this.all(e).join(c+h);return s+l+(e.label||e.identifier)+o+u+a+t}},function(e){"use strict";e.exports=collapse;function collapse(e){return String(e).replace(/\s+/g," ")}},function(e){"use strict";e.exports=label;var t="[";var r="]";var i="shortcut";var n="collapsed";function label(e){var a=e.referenceType;if(a===i){return""}return t+(a===n?"":e.label||e.identifier)+r}},,,,,function(e,t,r){"use strict";var i=r(814);var n=r(705);e.exports=listItem;var a="\n";var u=" ";var s="[";var o="]";var l="x";var f=Math.ceil;var c=a+a;var h=4;function listItem(e,t,r,p){var v=this;var d=v.options.listItemIndent;var D=p||v.options.bullet;var m=e.spread==null?true:e.spread;var g=e.checked;var E=e.children;var A=E.length;var C=[];var y=-1;var w;var x;var b;while(++y",Iacute:"Í",Icirc:"Î",Igrave:"Ì",Iuml:"Ï",LT:"<",Ntilde:"Ñ",Oacute:"Ó",Ocirc:"Ô",Ograve:"Ò",Oslash:"Ø",Otilde:"Õ",Ouml:"Ö",QUOT:'"',REG:"®",THORN:"Þ",Uacute:"Ú",Ucirc:"Û",Ugrave:"Ù",Uuml:"Ü",Yacute:"Ý",aacute:"á",acirc:"â",acute:"´",aelig:"æ",agrave:"à",amp:"&",aring:"å",atilde:"ã",auml:"ä",brvbar:"¦",ccedil:"ç",cedil:"¸",cent:"¢",copy:"©",curren:"¤",deg:"°",divide:"÷",eacute:"é",ecirc:"ê",egrave:"è",eth:"ð",euml:"ë",frac12:"½",frac14:"¼",frac34:"¾",gt:">",iacute:"í",icirc:"î",iexcl:"¡",igrave:"ì",iquest:"¿",iuml:"ï",laquo:"«",lt:"<",macr:"¯",micro:"µ",middot:"·",nbsp:" ",not:"¬",ntilde:"ñ",oacute:"ó",ocirc:"ô",ograve:"ò",ordf:"ª",ordm:"º",oslash:"ø",otilde:"õ",ouml:"ö",para:"¶",plusmn:"±",pound:"£",quot:'"',raquo:"»",reg:"®",sect:"§",shy:"­",sup1:"¹",sup2:"²",sup3:"³",szlig:"ß",thorn:"þ",times:"×",uacute:"ú",ucirc:"û",ugrave:"ù",uml:"¨",uuml:"ü",yacute:"ý",yen:"¥",yuml:"ÿ"}},,,,,function(e,t,r){"use strict";var i=r(64);var n=r(753);var a=function errorEx(e,t){if(!e||e.constructor!==String){t=e||{};e=Error.name}var r=function ErrorEXError(i){if(!this){return new ErrorEXError(i)}i=i instanceof Error?i.message:i||this.message;Error.call(this,i);Error.captureStackTrace(this,r);this.name=e;Object.defineProperty(this,"message",{configurable:true,enumerable:false,get:function(){var e=i.split(/\r?\n/g);for(var r in t){if(!t.hasOwnProperty(r)){continue}var a=t[r];if("message"in a){e=a.message(this[r],e)||e;if(!n(e)){e=[e]}}}return e.join("\n")},set:function(e){i=e}});var a=null;var u=Object.getOwnPropertyDescriptor(this,"stack");var s=u.get;var o=u.value;delete u.value;delete u.writable;u.set=function(e){a=e};u.get=function(){var e=(a||(s?s.call(this):o)).split(/\r?\n+/g);if(!a){e[0]=this.name+": "+this.message}var r=1;for(var i in t){if(!t.hasOwnProperty(i)){continue}var n=t[i];if("line"in n){var u=n.line(this[i]);if(u){e.splice(r++,0," "+u)}}if("stack"in n){n.stack(this[i],e)}}return e.join("\n")};Object.defineProperty(this,"stack",u)};if(Object.setPrototypeOf){Object.setPrototypeOf(r.prototype,Error.prototype);Object.setPrototypeOf(r,Error)}else{i.inherits(r,Error)}return r};a.append=function(e,t){return{message:function(r,i){r=r||t;if(r){i[0]+=" "+e.replace("%s",r.toString())}return i}}};a.line=function(e,t){return{line:function(r){r=r||t;if(r){return e.replace("%s",r.toString())}return null}}};e.exports=a},,,,,function(e,t,r){"use strict";var i=r(211);e.exports=new i("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}})},,,function(e,t,r){"use strict";var i=r(589);function replaceExt(e,t){if(typeof e!=="string"){return e}if(e.length===0){return e}var r=i.basename(e,i.extname(e))+t;return i.join(i.dirname(e),r)}e.exports=replaceExt},function(e,t,r){"use strict";var i=r(833);var n=["kind","resolve","construct","instanceOf","predicate","represent","defaultStyle","styleAliases"];var a=["scalar","sequence","mapping"];function compileStyleAliases(e){var t={};if(e!==null){Object.keys(e).forEach(function(r){e[r].forEach(function(e){t[String(e)]=r})})}return t}function Type(e,t){t=t||{};Object.keys(t).forEach(function(t){if(n.indexOf(t)===-1){throw new i('Unknown option "'+t+'" is met in definition of "'+e+'" YAML type.')}});this.tag=e;this.kind=t["kind"]||null;this.resolve=t["resolve"]||function(){return true};this.construct=t["construct"]||function(e){return e};this.instanceOf=t["instanceOf"]||null;this.predicate=t["predicate"]||null;this.represent=t["represent"]||null;this.defaultStyle=t["defaultStyle"]||null;this.styleAliases=compileStyleAliases(t["styleAliases"]||null);if(a.indexOf(this.kind)===-1){throw new i('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}}e.exports=Type},function(e,t,r){"use strict";var i=r(876);var n=true;try{n="inspect"in r(64)}catch(e){n=false}e.exports=n?inspect:noColor;inspect.color=inspect;noColor.color=inspect;inspect.noColor=noColor;noColor.noColor=noColor;var a=ansiColor(2,22);var u=ansiColor(33,39);var s=ansiColor(32,39);var o=new RegExp("(?:"+"(?:\\u001b\\[)|"+"\\u009b"+")"+"(?:"+"(?:[0-9]{1,3})?(?:(?:;[0-9]{0,3})*)?[A-M|f-m]"+")|"+"\\u001b[A-M]","g");var l=["type","value","children","position"];function noColor(e,t){return stripColor(inspect(e,t))}function inspect(e,t){var r;var i;var n;var a;if(e&&Boolean(e.length)&&typeof e!=="string"){a=e.length;n=-1;r=[];while(++n|$))/i;var l=/<\/(script|pre|style)>/i;var f=/^/;var h=/^<\?/;var p=/\?>/;var v=/^/;var D=/^/;var g=/^$/;var E=new RegExp(i.source+"\\s*$");function blockHtml(e,t,r){var i=this;var A=i.options.blocks.join("|");var C=new RegExp("^|$))","i");var y=t.length;var w=0;var x;var b;var F;var S;var B;var k;var O;var P=[[o,l,true],[f,c,true],[h,p,true],[v,d,true],[D,m,true],[C,g,true],[E,g,false]];while(w0&&v.indenta){return}if(!m||!l&&u.charAt(c+1)===n){return}f=u.length+1;D="";while(++c0){const t=peek();if(!i.isHexDigit(t)){throw invalidChar(read())}e+=read()}return String.fromCodePoint(parseInt(e,16))}const E={start(){if(f.type==="eof"){throw invalidEOF()}push()},beforePropertyName(){switch(f.type){case"identifier":case"string":c=f.value;a="afterPropertyName";return;case"punctuator":pop();return;case"eof":throw invalidEOF()}},afterPropertyName(){if(f.type==="eof"){throw invalidEOF()}a="beforePropertyValue"},beforePropertyValue(){if(f.type==="eof"){throw invalidEOF()}push()},beforeArrayValue(){if(f.type==="eof"){throw invalidEOF()}if(f.type==="punctuator"&&f.value==="]"){pop();return}push()},afterPropertyValue(){if(f.type==="eof"){throw invalidEOF()}switch(f.value){case",":a="beforePropertyName";return;case"}":pop()}},afterArrayValue(){if(f.type==="eof"){throw invalidEOF()}switch(f.value){case",":a="beforeArrayValue";return;case"]":pop()}},end(){}};function push(){let e;switch(f.type){case"punctuator":switch(f.value){case"{":e={};break;case"[":e=[];break}break;case"null":case"boolean":case"numeric":case"string":e=f.value;break}if(h===undefined){h=e}else{const t=u[u.length-1];if(Array.isArray(t)){t.push(e)}else{t[c]=e}}if(e!==null&&typeof e==="object"){u.push(e);if(Array.isArray(e)){a="beforeArrayValue"}else{a="beforePropertyName"}}else{const e=u[u.length-1];if(e==null){a="end"}else if(Array.isArray(e)){a="afterArrayValue"}else{a="afterPropertyValue"}}}function pop(){u.pop();const e=u[u.length-1];if(e==null){a="end"}else if(Array.isArray(e)){a="afterArrayValue"}else{a="afterPropertyValue"}}function invalidChar(e){if(e===undefined){return syntaxError(`JSON5: invalid end of input at ${o}:${l}`)}return syntaxError(`JSON5: invalid character '${formatChar(e)}' at ${o}:${l}`)}function invalidEOF(){return syntaxError(`JSON5: invalid end of input at ${o}:${l}`)}function invalidIdentifier(){l-=5;return syntaxError(`JSON5: invalid identifier character at ${o}:${l}`)}function separatorChar(e){console.warn(`JSON5: '${formatChar(e)}' in strings is not valid ECMAScript; consider escaping`)}function formatChar(e){const t={"'":"\\'",'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\v":"\\v","\0":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"};if(t[e]){return t[e]}if(e<" "){const t=e.charCodeAt(0).toString(16);return"\\x"+("00"+t).substring(t.length)}return e}function syntaxError(e){const t=new SyntaxError(e);t.lineNumber=o;t.columnNumber=l;return t}},,function(e,t,r){"use strict";var i=r(66);var n=r(589);var a=r(345);var u=r(347)("unified-engine:find-up");var s=r(692);e.exports=FindUp;var o=i.readFile;var l=n.resolve;var f=n.relative;var c=n.join;var h=n.dirname;FindUp.prototype.load=load;function FindUp(e){var t=this;var r=e.filePath;t.cache={};t.cwd=e.cwd;t.detect=e.detect;t.names=e.names;t.create=e.create;if(r){t.givenFilePath=l(e.cwd,r)}}function load(e,t){var r=this;var i=r.cache;var n=r.givenFilePath;var p=r.givenFile;var v=r.names;var d=r.create;var D=r.cwd;var m;if(n){if(p){apply(t,p)}else{p=[t];r.givenFile=p;u("Checking given file `%s`",n);o(n,loadGiven)}return}if(!r.detect){return t()}e=l(D,e);m=h(e);if(m in i){apply(t,i[m])}else{i[m]=[t];find(m)}function loadGiven(e,t){var i=r.givenFile;var s;if(e){s=a("Cannot read given file `%s`\n%s",f(D,n),e.stack);s.code="ENOENT";s.path=e.path;s.syscall=e.syscall}else{try{s=d(t,n);u("Read given file `%s`",n)}catch(e){s=a("Cannot parse given file `%s`\n%s",f(D,n),e.stack);u(e.message)}}p=s;r.givenFile=s;applyAll(i,s)}function find(t){var r=-1;var n=v.length;next();function next(){var a;if(++r{if(e)console.error(e);process.exit(t)})},,,,,,,function(e,t,r){"use strict";var i=r(495);var n=r(682);var a=r(839);var u=r(526);e.exports=i("remark-lint:code-block-style",codeBlockStyle);var s=a.start;var o=a.end;var l={null:true,fenced:true,indented:true};function codeBlockStyle(e,t,r){var i=String(t);r=typeof r==="string"&&r!=="consistent"?r:null;if(l[r]!==true){t.fail("Invalid code block style `"+r+"`: use either `'consistent'`, `'fenced'`, or `'indented'`")}n(e,"code",visitor);function visitor(e){var i=check(e);if(i){if(!r){r=i}else if(r!==i){t.message("Code blocks should be "+r,e)}}}function check(e){var t=s(e).offset;var r=o(e).offset;if(u(e)){return null}return e.lang||/^\s*([~`])\1{2,}/.test(i.slice(t,r))?"fenced":"indented"}}},,,function(e,t,r){"use strict";var i=r(589);var n=r(77);var a=r(289);e.exports=Ignore;Ignore.prototype.check=check;var u=i.dirname;var s=i.relative;var o=i.resolve;function Ignore(e){this.cwd=e.cwd;this.findUp=new a({filePath:e.ignorePath,cwd:e.cwd,detect:e.detectIgnore,names:e.ignoreName?[e.ignoreName]:[],create:create})}function check(e,t){var r=this;r.findUp.load(e,done);function done(i,n){var a;if(i){t(i)}else if(n){a=s(n.filePath,o(r.cwd,e));t(null,a?n.ignores(a):false)}else{t(null,false)}}}function create(e,t){var r=n().add(String(e));r.filePath=u(t);return r}},,,,function(e){e.exports={nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"­",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",fnof:"ƒ",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",bull:"•",hellip:"…",prime:"′",Prime:"″",oline:"‾",frasl:"⁄",weierp:"℘",image:"ℑ",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦",quot:'"',amp:"&",lt:"<",gt:">",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",circ:"ˆ",tilde:"˜",ensp:" ",emsp:" ",thinsp:" ",zwnj:"‌",zwj:"‍",lrm:"‎",rlm:"‏",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",permil:"‰",lsaquo:"‹",rsaquo:"›",euro:"€"}},,,,function(e,t,r){"use strict";var i=r(54);e.exports=enclose;var n="(";var a=")";var u="<";var s=">";var o=/\s/;function enclose(e,t){if(t||e.length===0||o.test(e)||i(e,n)!==i(e,a)){return u+e+s}return e}},,function(e,t,r){"use strict";var i=r(495);var n=r(682);var a=r(839);var u=r(526);e.exports=i("remark-lint:table-pipes",tablePipes);var s=a.start;var o=a.end;var l="Missing initial pipe in table fence";var f="Missing final pipe in table fence";function tablePipes(e,t){var r=String(t);n(e,"table",visitor);function visitor(e){var i=e.children;var n=i.length;var a=-1;var c;var h;var p;var v;var d;var D;while(++a0?parseInt(t):null};for(;i1)return true;for(var a=0;athis.maxLength)return t();if(!this.stat&&m(this.cache,r)){var a=this.cache[r];if(Array.isArray(a))a="DIR";if(!n||a==="DIR")return t(null,a);if(n&&a==="FILE")return t()}var u;var s=this.statCache[r];if(s!==undefined){if(s===false)return t(null,s);else{var o=s.isDirectory()?"DIR":"FILE";if(n&&o==="FILE")return t();else return t(null,o,s)}}var l=this;var f=g("stat\0"+r,lstatcb_);if(f)i.lstat(r,f);function lstatcb_(n,a){if(a&&a.isSymbolicLink()){return i.stat(r,function(i,n){if(i)l._stat2(e,r,null,a,t);else l._stat2(e,r,i,n,t)})}else{l._stat2(e,r,n,a,t)}}};Glob.prototype._stat2=function(e,t,r,i,n){if(r&&(r.code==="ENOENT"||r.code==="ENOTDIR")){this.statCache[t]=false;return n()}var a=e.slice(-1)==="/";this.statCache[t]=i;if(t.slice(-1)==="/"&&i&&!i.isDirectory())return n(null,false,i);var u=true;if(i)u=i.isDirectory()?"DIR":"FILE";this.cache[t]=this.cache[t]||u;if(a&&u==="FILE")return n();return n(null,u,i)}},function(e,t,r){"use strict";var i=r(36);var n=r(439);var a=r(934);var u=r(724);e.exports=paragraph;var s="\t";var o="\n";var l=" ";var f=4;function paragraph(e,t,r){var c=this;var h=c.options;var p=h.commonmark;var v=h.gfm;var d=c.blockTokenizers;var D=c.interruptParagraph;var m=t.indexOf(o);var g=t.length;var E;var A;var C;var y;var w;while(m=f&&C!==o){m=t.indexOf(o,m+1);continue}}A=t.slice(m+1);if(u(D,d,c,[e,A,true])){break}if(d.list.call(c,e,A,true)&&(c.inList||p||v&&!n(i.left(A).charAt(0)))){break}E=m;m=t.indexOf(o,m+1);if(m!==-1&&i(t.slice(E,m))===""){m=E;break}}A=t.slice(0,m);if(i(A)===""){e(A);return null}if(r){return true}w=e.now();A=a(A);return e(A)({type:"paragraph",children:c.tokenizeInline(A,w)})}},function(e,t,r){"use strict";var i;var n;try{var a=i;n=r(644)}catch(e){if(typeof window!=="undefined")n=window.esprima}var u=r(211);function resolveJavascriptFunction(e){if(e===null)return false;try{var t="("+e+")",r=n.parse(t,{range:true});if(r.type!=="Program"||r.body.length!==1||r.body[0].type!=="ExpressionStatement"||r.body[0].expression.type!=="ArrowFunctionExpression"&&r.body[0].expression.type!=="FunctionExpression"){return false}return true}catch(e){return false}}function constructJavascriptFunction(e){var t="("+e+")",r=n.parse(t,{range:true}),i=[],a;if(r.type!=="Program"||r.body.length!==1||r.body[0].type!=="ExpressionStatement"||r.body[0].expression.type!=="ArrowFunctionExpression"&&r.body[0].expression.type!=="FunctionExpression"){throw new Error("Failed to resolve function")}r.body[0].expression.params.forEach(function(e){i.push(e.name)});a=r.body[0].expression.body.range;if(r.body[0].expression.body.type==="BlockStatement"){return new Function(i,t.slice(a[0]+1,a[1]-1))}return new Function(i,"return "+t.slice(a[0],a[1]))}function representJavascriptFunction(e){return e.toString()}function isFunction(e){return Object.prototype.toString.call(e)==="[object Function]"}e.exports=new u("tag:yaml.org,2002:js/function",{kind:"scalar",resolve:resolveJavascriptFunction,construct:constructJavascriptFunction,predicate:isFunction,represent:representJavascriptFunction})},,,function(e,t,r){"use strict";var i=r(171);var n=r(984);var a=r(426);e.exports=reference;reference.locator=n;var u="link";var s="image";var o="footnote";var l="shortcut";var f="collapsed";var c="full";var h=" ";var p="!";var v="[";var d="\\";var D="]";var m="^";function reference(e,t,r){var n=this;var g=n.options.commonmark;var E=t.charAt(0);var A=0;var C=t.length;var y="";var w="";var x=u;var b=l;var F;var S;var B;var k;var O;var P;var T;var I;if(E===p){x=s;w=E;E=t.charAt(++A)}if(E!==v){return}A++;w+=E;P="";if(n.options.footnotes&&t.charAt(A)===m){if(x===s){return}w+=m;A++;x=o}I=0;while(A "+h.destination:""}if(!h.stats.total){p+=p?": ":"";if(h.stored){p+=m.yellow.open+"written"+m.yellow.close}else{p+="no issues found"}}if(p){l.push(p)}}else{g=m[h.label==="error"?"red":"yellow"];E=h.reason;A="";C=E.indexOf("\n");if(C!==-1){A=E.slice(C);E=E.slice(0,C)}l.push(["",padLeft(h.location,e.location),padRight(g.open+h.label+g.close,e.label),padRight(E,e.reason),padRight(h.ruleId,e.ruleId),h.source||""].join(" ").replace(c,"")+A)}}if(a.fatal||a.warn){p=[];if(a.fatal){p.push([m.red.open+f.error+m.red.close,a.fatal,plural(D.true,a.fatal)].join(" "))}if(a.warn){p.push([m.yellow.open+f.warning+m.yellow.close,a.warn,plural(D.false,a.warn)].join(" "))}p=p.join(", ");if(a.total!==a.fatal&&a.total!==a.warn){p=a.total+" messages ("+p+")"}l.push("",p)}return l.join("\n")}function applicable(e,t){var r=e.messages;var i=r.length;var n=-1;var a=[];if(t.silent){while(++n64)continue;if(t<0)return false;i+=6}return i%8===0}function constructYamlBinary(e){var t,r,i=e.replace(/[\r\n=]/g,""),a=i.length,u=s,o=0,l=[];for(t=0;t>16&255);l.push(o>>8&255);l.push(o&255)}o=o<<6|u.indexOf(i.charAt(t))}r=a%4*6;if(r===0){l.push(o>>16&255);l.push(o>>8&255);l.push(o&255)}else if(r===18){l.push(o>>10&255);l.push(o>>2&255)}else if(r===12){l.push(o>>4&255)}if(n){return n.from?n.from(l):new n(l)}return l}function representYamlBinary(e){var t="",r=0,i,n,a=e.length,u=s;for(i=0;i>18&63];t+=u[r>>12&63];t+=u[r>>6&63];t+=u[r&63]}r=(r<<8)+e[i]}n=a%3;if(n===0){t+=u[r>>18&63];t+=u[r>>12&63];t+=u[r>>6&63];t+=u[r&63]}else if(n===2){t+=u[r>>10&63];t+=u[r>>4&63];t+=u[r<<2&63];t+=u[64]}else if(n===1){t+=u[r>>2&63];t+=u[r<<4&63];t+=u[64];t+=u[64]}return t}function isBinary(e){return n&&n.isBuffer(e)}e.exports=new u("tag:yaml.org,2002:binary",{kind:"scalar",resolve:resolveYamlBinary,construct:constructYamlBinary,predicate:isBinary,represent:representYamlBinary})},function(e){"use strict";var t=[].slice;e.exports=wrap;function wrap(e,r){var i;return wrapped;function wrapped(){var r=t.call(arguments,0);var n=e.length>r.length;var a;if(n){r.push(done)}try{a=e.apply(null,r)}catch(e){if(n&&i){throw e}return done(e)}if(!n){if(a&&typeof a.then==="function"){a.then(then,done)}else if(a instanceof Error){done(a)}else{then(a)}}}function done(){if(!i){i=true;r.apply(null,arguments)}}function then(e){done(null,e)}}},function(e){e.exports=extend;var t=Object.prototype.hasOwnProperty;function extend(){var e={};for(var r=0;ri){t.message("Move definitions to the end of the file (after the node at line `"+r+"`)",e)}}else if(r===null){r=i}}}},function(e){var t=Object.prototype.toString;e.exports=isString;function isString(e){return t.call(e)==="[object String]"}},function(e,t,r){"use strict";var i=r(874);e.exports=configure;function configure(e,t){e.configuration=new i(t)}},,,,function(e,t,r){"use strict";var i=r(323);var n=create(Error);e.exports=n;n.eval=create(EvalError);n.range=create(RangeError);n.reference=create(ReferenceError);n.syntax=create(SyntaxError);n.type=create(TypeError);n.uri=create(URIError);n.create=create;function create(e){FormattedError.displayName=e.displayName||e.name;return FormattedError;function FormattedError(t){if(t){t=i.apply(null,arguments)}return new e(t)}}},,function(e,t,r){"use strict";if(typeof process==="undefined"||process.type==="renderer"||process.browser===true||process.__nwjs){e.exports=r(470)}else{e.exports=r(970)}},function(e,t,r){var i=r(20);var n=r(491);e.exports=expandTop;var a="\0SLASH"+Math.random()+"\0";var u="\0OPEN"+Math.random()+"\0";var s="\0CLOSE"+Math.random()+"\0";var o="\0COMMA"+Math.random()+"\0";var l="\0PERIOD"+Math.random()+"\0";function numeric(e){return parseInt(e,10)==e?parseInt(e,10):e.charCodeAt(0)}function escapeBraces(e){return e.split("\\\\").join(a).split("\\{").join(u).split("\\}").join(s).split("\\,").join(o).split("\\.").join(l)}function unescapeBraces(e){return e.split(a).join("\\").split(u).join("{").split(s).join("}").split(o).join(",").split(l).join(".")}function parseCommaParts(e){if(!e)return[""];var t=[];var r=n("{","}",e);if(!r)return e.split(",");var i=r.pre;var a=r.body;var u=r.post;var s=i.split(",");s[s.length-1]+="{"+a+"}";var o=parseCommaParts(u);if(u.length){s[s.length-1]+=o.shift();s.push.apply(s,o)}t.push.apply(t,s);return t}function expandTop(e){if(!e)return[];if(e.substr(0,2)==="{}"){e="\\{\\}"+e.substr(2)}return expand(escapeBraces(e),true).map(unescapeBraces)}function identity(e){return e}function embrace(e){return"{"+e+"}"}function isPadded(e){return/^-?0\d/.test(e)}function lte(e,t){return e<=t}function gte(e,t){return e>=t}function expand(e,t){var r=[];var a=n("{","}",e);if(!a||/\$$/.test(a.pre))return[e];var u=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(a.body);var o=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(a.body);var l=u||o;var f=a.body.indexOf(",")>=0;if(!l&&!f){if(a.post.match(/,.*\}/)){e=a.pre+"{"+a.body+s+a.post;return expand(e)}return[e]}var c;if(l){c=a.body.split(/\.\./)}else{c=parseCommaParts(a.body);if(c.length===1){c=expand(c[0],false).map(embrace);if(c.length===1){var h=a.post.length?expand(a.post,false):[""];return h.map(function(e){return a.pre+c[0]+e})}}}var p=a.pre;var h=a.post.length?expand(a.post,false):[""];var v;if(l){var d=numeric(c[0]);var D=numeric(c[1]);var m=Math.max(c[0].length,c[1].length);var g=c.length==3?Math.abs(numeric(c[2])):1;var E=lte;var A=D0){var b=new Array(x+1).join("0");if(y<0)w="-"+b+w.slice(1);else w=b+w}}}v.push(w)}}else{v=i(c,function(e){return expand(e,false)})}for(var F=0;F>5===6)return 2;else if(e>>4===14)return 3;else if(e>>3===30)return 4;return e>>6===2?-1:-2}function utf8CheckIncomplete(e,t,r){var i=t.length-1;if(i=0){if(n>0)e.lastNeed=n-1;return n}if(--i=0){if(n>0)e.lastNeed=n-2;return n}if(--i=0){if(n>0){if(n===2)n=0;else e.lastNeed=n-3}return n}return 0}function utf8CheckExtraBytes(e,t,r){if((t[0]&192)!==128){e.lastNeed=0;return"�"}if(e.lastNeed>1&&t.length>1){if((t[1]&192)!==128){e.lastNeed=1;return"�"}if(e.lastNeed>2&&t.length>2){if((t[2]&192)!==128){e.lastNeed=2;return"�"}}}}function utf8FillLast(e){var t=this.lastTotal-this.lastNeed;var r=utf8CheckExtraBytes(this,e,t);if(r!==undefined)return r;if(this.lastNeed<=e.length){e.copy(this.lastChar,t,0,this.lastNeed);return this.lastChar.toString(this.encoding,0,this.lastTotal)}e.copy(this.lastChar,t,0,e.length);this.lastNeed-=e.length}function utf8Text(e,t){var r=utf8CheckIncomplete(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var i=e.length-(r-this.lastNeed);e.copy(this.lastChar,0,i);return e.toString("utf8",t,i)}function utf8End(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed)return t+"�";return t}function utf16Text(e,t){if((e.length-t)%2===0){var r=e.toString("utf16le",t);if(r){var i=r.charCodeAt(r.length-1);if(i>=55296&&i<=56319){this.lastNeed=2;this.lastTotal=4;this.lastChar[0]=e[e.length-2];this.lastChar[1]=e[e.length-1];return r.slice(0,-1)}}return r}this.lastNeed=1;this.lastTotal=2;this.lastChar[0]=e[e.length-1];return e.toString("utf16le",t,e.length-1)}function utf16End(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function base64Text(e,t){var r=(e.length-t)%3;if(r===0)return e.toString("base64",t);this.lastNeed=3-r;this.lastTotal=3;if(r===1){this.lastChar[0]=e[e.length-1]}else{this.lastChar[0]=e[e.length-2];this.lastChar[1]=e[e.length-1]}return e.toString("base64",t,e.length-r)}function base64End(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed)return t+this.lastChar.toString("base64",0,3-this.lastNeed);return t}function simpleWrite(e){return e.toString(this.encoding)}function simpleEnd(e){return e&&e.length?this.write(e):""}},,,,function(e,t,r){"use strict";var i=r(186);e.exports=VMessage;function VMessagePrototype(){}VMessagePrototype.prototype=Error.prototype;VMessage.prototype=new VMessagePrototype;var n=VMessage.prototype;n.file="";n.name="";n.reason="";n.message="";n.stack="";n.fatal=null;n.column=null;n.line=null;function VMessage(e,t,r){var n;var a;var u;if(typeof t==="string"){r=t;t=null}n=parseOrigin(r);a=i(t)||"1:1";u={start:{line:null,column:null},end:{line:null,column:null}};if(t&&t.position){t=t.position}if(t){if(t.start){u=t;t=t.start}else{u.start=t}}if(e.stack){this.stack=e.stack;e=e.message}this.message=e;this.name=a;this.reason=e;this.line=t?t.line:null;this.column=t?t.column:null;this.location=u;this.source=n[0];this.ruleId=n[1]}function parseOrigin(e){var t=[null,null];var r;if(typeof e==="string"){r=e.indexOf(":");if(r===-1){t[1]=e}else{t[0]=e.slice(0,r);t[1]=e.slice(r+1)}}return t}},,function(e,t,r){"use strict";var i=r(171);var n=r(902);var a=r(49);e.exports=autoLink;autoLink.locator=a;autoLink.notInLink=true;var u="<";var s=">";var o="@";var l="/";var f="mailto:";var c=f.length;function autoLink(e,t,r){var a=this;var h="";var p=t.length;var v=0;var d="";var D=false;var m="";var g;var E;var A;var C;var y;if(t.charAt(0)!==u){return}v++;h=u;while(v0||H===x&&I.inLink||M&&H===B&&t.charAt(W+1)===B||M&&H===S&&(I.inTable||alignment(t,W))||H===b&&W>0&&W=e.expected){e.emit("done")}}},,function(e,t,r){"use strict";var i=r(897);var n=r(336);var a=r(860);e.exports=parse;parse.Parser=a;function parse(e){var t=this.data("settings");var r=i(a);r.prototype.options=n(r.prototype.options,t,e);this.Parser=r}},,,,,,function(e,t,r){"use strict";var i=r(176);e.exports=imageReference;var n="[";var a="]";var u="!";function imageReference(e){return u+n+(this.encode(e.alt,e)||"")+a+i(e)}},,,,,,function(e,t,r){"use strict";var i=r(495);e.exports=i("remark-lint:no-file-name-consecutive-dashes",noFileNameConsecutiveDashes);var n="Do not use consecutive dashes in a file name";function noFileNameConsecutiveDashes(e,t){if(t.stem&&/-{2,}/.test(t.stem)){t.message(n)}}},,function(e,t,r){"use strict";var i=r(495);var n=r(682);var a=r(839);var u=r(526);e.exports=i("remark-lint:ordered-list-marker-style",orderedListMarkerStyle);var s=a.start;var o={")":true,".":true,null:true};function orderedListMarkerStyle(e,t,r){var i=String(t);r=typeof r!=="string"||r==="consistent"?null:r;if(o[r]!==true){t.fail("Invalid ordered list-item marker style `"+r+"`: use either `'.'` or `')'`")}n(e,"list",visitor);function visitor(e){var n=e.children;var a=e.ordered?n.length:0;var o=-1;var l;var f;while(++o=s&&(!p||p===r)){h+=D;if(l){return true}return e(h)({type:"thematicBreak"})}else{return}}}},,function(e){e.exports=require("assert")},,,,,,,function(e,t,r){"use strict";var i=r(774);var n=r(176);e.exports=linkReference;var a="[";var u="]";var s="shortcut";var o="collapsed";function linkReference(e){var t=this;var r=e.referenceType;var l=t.enterLinkReference(t,e);var f=t.all(e).join("");l();if(r===s||r===o){f=i(f,e.label||e.identifier)}return a+f+u+n(e)}},function(e){"use strict";e.exports=lineBreak;var t="\\";var r="\n";var i=" ";var n=t+r;var a=i+i+r;function lineBreak(){return this.options.commonmark?n:a}},function(e,t,r){"use strict";function _classCallCheck(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}}var i=r(945).Buffer;var n=r(64);function copyBuffer(e,t,r){e.copy(t,r)}e.exports=function(){function BufferList(){_classCallCheck(this,BufferList);this.head=null;this.tail=null;this.length=0}BufferList.prototype.push=function push(e){var t={data:e,next:null};if(this.length>0)this.tail.next=t;else this.head=t;this.tail=t;++this.length};BufferList.prototype.unshift=function unshift(e){var t={data:e,next:this.head};if(this.length===0)this.tail=t;this.head=t;++this.length};BufferList.prototype.shift=function shift(){if(this.length===0)return;var e=this.head.data;if(this.length===1)this.head=this.tail=null;else this.head=this.head.next;--this.length;return e};BufferList.prototype.clear=function clear(){this.head=this.tail=null;this.length=0};BufferList.prototype.join=function join(e){if(this.length===0)return"";var t=this.head;var r=""+t.data;while(t=t.next){r+=e+t.data}return r};BufferList.prototype.concat=function concat(e){if(this.length===0)return i.alloc(0);if(this.length===1)return this.head.data;var t=i.allocUnsafe(e>>>0);var r=this.head;var n=0;while(r){copyBuffer(r.data,t,n);n+=r.data.length;r=r.next}return t};return BufferList}();if(n&&n.inspect&&n.inspect.custom){e.exports.prototype[n.inspect.custom]=function(){var e=n.inspect({length:this.length});return this.constructor.name+" "+e}}},function(e,t,r){"use strict";var i=r(336);var n=r(109);var a=r(694);e.exports=setOptions;function setOptions(e){var t=this;var r=t.options;var u;var s;if(e==null){e={}}else if(typeof e==="object"){e=i(e)}else{throw new Error("Invalid value `"+e+"` for setting `options`")}for(u in a){s=e[u];if(s==null){s=r[u]}if(u!=="blocks"&&typeof s!=="boolean"||u==="blocks"&&typeof s!=="object"){throw new Error("Invalid value `"+s+"` for setting `options."+u+"`")}e[u]=s}t.options=e;t.escape=n(e);return t}},,function(e){var t=Array.prototype.slice;e.exports=co;function co(e){var r=isGeneratorFunction(e);return function(i){var n=this;var a=e;if(r){var u=t.call(arguments),s=u.length;var o=s&&"function"==typeof u[s-1];i=o?u.pop():error;a=e.apply(this,u)}else{i=i||error}next();function exit(e,t){setImmediate(function(){i.call(n,e,t)})}function next(e,r){var i;if(arguments.length>2)r=t.call(arguments,1);if(e){try{i=a.throw(e)}catch(e){return exit(e)}}if(!e){try{i=a.next(r)}catch(e){return exit(e)}}if(i.done)return exit(null,i.value);i.value=toThunk(i.value,n);if("function"==typeof i.value){var u=false;try{i.value.call(n,function(){if(u)return;u=true;next.apply(n,arguments)})}catch(e){setImmediate(function(){if(u)return;u=true;next(e)})}return}next(new TypeError("You may only yield a function, promise, generator, array, or object, "+'but the following was passed: "'+String(i.value)+'"'))}}}function toThunk(e,t){if(isGeneratorFunction(e)){return co(e.call(t))}if(isGenerator(e)){return co(e)}if(isPromise(e)){return promiseToThunk(e)}if("function"==typeof e){return e}if(isObject(e)||Array.isArray(e)){return objectToThunk.call(t,e)}return e}function objectToThunk(e){var t=this;var r=Array.isArray(e);return function(i){var n=Object.keys(e);var a=n.length;var u=r?new Array(a):new e.constructor;var s;if(!a){setImmediate(function(){i(null,u)});return}if(!r){for(var o=0;or){t.splice(0,r);process.nextTick(function(){RES.apply(null,i)})}else{delete n[e]}}})}function slice(e){var t=e.length;var r=[];for(var i=0;ii){o+=" with 1 space, not "+u;if(size(a)=48&&t<=57}},function(e,t,r){"use strict";var i=r(308);var n=r(197);var a=r(25);var u=r(908);var s=r(617);e.exports=encode;encode.escape=escape;var o={}.hasOwnProperty;var l=['"',"'","<",">","&","`"];var f=construct();var c=toExpression(l);var h=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;var p=/[\x01-\t\x0B\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g;function encode(e,t){var r=t||{};var i=r.subset;var n=i?toExpression(i):c;var a=r.escapeOnly;var u=r.omitOptionalSemicolons;e=e.replace(n,function(e,t,i){return one(e,i.charAt(t+1),r)});if(i||a){return e}return e.replace(h,replaceSurrogatePair).replace(p,replaceBmp);function replaceSurrogatePair(e,t,r){return toHexReference((e.charCodeAt(0)-55296)*1024+e.charCodeAt(1)-56320+65536,r.charAt(t+2),u)}function replaceBmp(e,t,i){return one(e,i.charAt(t+1),r)}}function escape(e){return encode(e,{escapeOnly:true,useNamedReferences:true})}function one(e,t,r){var i=r.useShortestReferences;var n=r.omitOptionalSemicolons;var a;var u;if((i||r.useNamedReferences)&&o.call(f,e)){a=toNamed(f[e],t,n,r.attribute)}if(i||!a){u=toHexReference(e.charCodeAt(0),t,n)}if(a&&(!i||a.length/i;function inlineHTML(e,t,r){var n=this;var h=t.length;var p;var v;if(t.charAt(0)!==u||h<3){return}p=t.charAt(1);if(!i(p)&&p!==s&&p!==o&&p!==l){return}v=t.match(a);if(!v){return}if(r){return true}v=v[0];if(!n.inLink&&f.test(v)){n.inLink=true}else if(n.inLink&&c.test(v)){n.inLink=false}return e(v)({type:"html",value:v})}},function(e){e.exports=["md","markdown","mdown","mkdn","mkd","mdwn","mkdown","ron"]},,,,function(e,t,r){"use strict";var i=r(495);e.exports=i("remark-lint:file-extension",fileExtension);function fileExtension(e,t,r){var i=t.extname;r=typeof r==="string"?r:"md";if(i&&i.slice(1)!==r){t.message("Invalid extension: use `"+r+"`")}}},function(e){"use strict";e.exports=factory;var t="\\";function factory(e,r){return unescape;function unescape(i){var n=0;var a=i.indexOf(t);var u=e[r];var s=[];var o;while(a!==-1){s.push(i.slice(n,a));n=a+1;o=i.charAt(n);if(!o||u.indexOf(o)===-1){s.push(t)}a=i.indexOf(t,n+1)}s.push(i.slice(n));return s.join("")}}},,,function(e,t,r){"use strict";const i=r(495);const n=r(682);e.exports=i("remark-lint:prohibited-strings",prohibitedStrings);function testProhibited(e,t){const r=new RegExp(`(\\.|@[a-z0-9/-]*)?\\b(${e.no})\\b(\\.\\w)?`,"g");let i=null;while(i=r.exec(t)){if(!i[1]&&!i[3]){return i[2]}}return false}function prohibitedStrings(e,t,r){n(e,"text",checkText);function checkText(e){const i=e.value;r.forEach(r=>{const n=testProhibited(r,i);if(n){t.message(`Use "${r.yes}" instead of "${n}"`,e)}})}}},,,,,function(e){"use strict";e.exports=hidden;function hidden(e){if(typeof e!=="string"){throw new Error("Expected string")}return e.charAt(0)==="."}},,,,,function(e,t,r){"use strict";var i=r(171);var n=r(426);e.exports=footnoteDefinition;footnoteDefinition.notInList=true;footnoteDefinition.notInBlock=true;var a="\\";var u="\n";var s="\t";var o=" ";var l="[";var f="]";var c="^";var h=":";var p=/^( {4}|\t)?/gm;function footnoteDefinition(e,t,r){var v=this;var d=v.offset;var D;var m;var g;var E;var A;var C;var y;var w;var x;var b;var F;var S;if(!v.options.footnotes){return}D=0;m=t.length;g="";E=e.now();A=E.line;while(D=31||typeof navigator!=="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function formatArgs(t){t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff);if(!this.useColors){return}var r="color: "+this.color;t.splice(1,0,r,"color: inherit");var i=0;var n=0;t[0].replace(/%[a-zA-Z%]/g,function(e){if(e==="%%"){return}i++;if(e==="%c"){n=i}});t.splice(n,0,r)}function log(){var e;return(typeof console==="undefined"?"undefined":_typeof(console))==="object"&&console.log&&(e=console).log.apply(e,arguments)}function save(e){try{if(e){t.storage.setItem("debug",e)}else{t.storage.removeItem("debug")}}catch(e){}}function load(){var e;try{e=t.storage.getItem("debug")}catch(e){}if(!e&&typeof process!=="undefined"&&"env"in process){e=process.env.DEBUG}return e}function localstorage(){try{return localStorage}catch(e){}}e.exports=r(772)(t);var i=e.exports.formatters;i.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},,,,function(e,t,r){var i=r(159);var n=r(589).join;var a=r(281);var u="/etc";var s=process.platform==="win32";var o=s?process.env.USERPROFILE:process.env.HOME;e.exports=function(e,t,l,f){if("string"!==typeof e)throw new Error("rc(name): name *must* be string");if(!l)l=r(359)(process.argv.slice(2));t=("string"===typeof t?i.json(t):t)||{};f=f||i.parse;var c=i.env(e+"_");var h=[t];var p=[];function addConfigFile(e){if(p.indexOf(e)>=0)return;var t=i.file(e);if(t){h.push(f(t));p.push(e)}}if(!s)[n(u,e,"config"),n(u,e+"rc")].forEach(addConfigFile);if(o)[n(o,".config",e,"config"),n(o,".config",e),n(o,"."+e,"config"),n(o,"."+e+"rc")].forEach(addConfigFile);addConfigFile(i.find("."+e+"rc"));if(c.config)addConfigFile(c.config);if(l.config)addConfigFile(l.config);return a.apply(null,h.concat([c,l,p.length?{configs:p,config:p[p.length-1]}:undefined]))}},,function(e,t,r){"use strict";var i=r(495);var n=r(682);var a=r(526);e.exports=i("remark-lint:no-shortcut-reference-link",noShortcutReferenceLink);var u="Use the trailing [] on reference links";function noShortcutReferenceLink(e,t){n(e,"linkReference",visitor);function visitor(e){if(!a(e)&&e.referenceType==="shortcut"){t.message(u,e)}}}},,,,,,,,function(e){e.exports={_from:"remark@^10.0.1",_id:"remark@10.0.1",_inBundle:false,_integrity:"sha512-E6lMuoLIy2TyiokHprMjcWNJ5UxfGQjaMSMhV+f4idM625UjjK4j798+gPs5mfjzDE6vL0oFKVeZM6gZVSVrzQ==",_location:"/remark",_phantomChildren:{},_requested:{type:"range",registry:true,raw:"remark@^10.0.1",name:"remark",escapedName:"remark",rawSpec:"^10.0.1",saveSpec:null,fetchSpec:"^10.0.1"},_requiredBy:["/"],_resolved:"https://registry.npmjs.org/remark/-/remark-10.0.1.tgz",_shasum:"3058076dc41781bf505d8978c291485fe47667df",_spec:"remark@^10.0.1",_where:"/Users/trott/io.js/tools/node-lint-md-cli-rollup",author:{name:"Titus Wormer",email:"tituswormer@gmail.com",url:"https://wooorm.com"},bugs:{url:"https://github.com/remarkjs/remark/issues"},bundleDependencies:false,contributors:[{name:"Titus Wormer",email:"tituswormer@gmail.com",url:"https://wooorm.com"}],dependencies:{"remark-parse":"^6.0.0","remark-stringify":"^6.0.0",unified:"^7.0.0"},deprecated:false,description:"Markdown processor powered by plugins",devDependencies:{tape:"^4.9.1"},files:["index.js"],homepage:"https://remark.js.org",keywords:["markdown","abstract","syntax","tree","ast","parse","stringify","process"],license:"MIT",name:"remark",repository:{type:"git",url:"https://github.com/remarkjs/remark/tree/master/packages/remark"},scripts:{test:"tape test.js"},version:"10.0.1",xo:false}},function(e){e.exports=require("events")},,function(e,t,r){e.exports=globSync;globSync.GlobSync=GlobSync;var i=r(66);var n=r(129);var a=r(620);var u=a.Minimatch;var s=r(327).Glob;var o=r(64);var l=r(589);var f=r(393);var c=r(969);var h=r(922);var p=h.alphasort;var v=h.alphasorti;var d=h.setopts;var D=h.ownProp;var m=h.childrenIgnored;var g=h.isIgnored;function globSync(e,t){if(typeof t==="function"||arguments.length===3)throw new TypeError("callback provided to sync glob\n"+"See: https://github.com/isaacs/node-glob/issues/167");return new GlobSync(e,t).found}function GlobSync(e,t){if(!e)throw new Error("must provide pattern");if(typeof t==="function"||arguments.length===3)throw new TypeError("callback provided to sync glob\n"+"See: https://github.com/isaacs/node-glob/issues/167");if(!(this instanceof GlobSync))return new GlobSync(e,t);d(this,e,t);if(this.noprocess)return this;var r=this.minimatch.set.length;this.matches=new Array(r);for(var i=0;ithis.maxLength)return false;if(!this.stat&&D(this.cache,t)){var n=this.cache[t];if(Array.isArray(n))n="DIR";if(!r||n==="DIR")return n;if(r&&n==="FILE")return false}var a;var u=this.statCache[t];if(!u){var s;try{s=i.lstatSync(t)}catch(e){if(e&&(e.code==="ENOENT"||e.code==="ENOTDIR")){this.statCache[t]=false;return false}}if(s&&s.isSymbolicLink()){try{u=i.statSync(t)}catch(e){u=s}}else{u=s}}this.statCache[t]=u;var n=true;if(u)n=u.isDirectory()?"DIR":"FILE";this.cache[t]=this.cache[t]||n;if(r&&n==="FILE")return false;return n};GlobSync.prototype._mark=function(e){return h.mark(this,e)};GlobSync.prototype._makeAbs=function(e){return h.makeAbs(this,e)}},,,,function(e){"use strict";e.exports=balanced;function balanced(e,t,r){if(e instanceof RegExp)e=maybeMatch(e,r);if(t instanceof RegExp)t=maybeMatch(t,r);var i=range(e,t,r);return i&&{start:i[0],end:i[1],pre:r.slice(0,i[0]),body:r.slice(i[0]+e.length,i[1]),post:r.slice(i[1]+t.length)}}function maybeMatch(e,t){var r=t.match(e);return r?r[0]:null}balanced.range=range;function range(e,t,r){var i,n,a,u,s;var o=r.indexOf(e);var l=r.indexOf(t,o+1);var f=o;if(o>=0&&l>0){i=[];a=r.length;while(f>=0&&!s){if(f==o){i.push(f);o=r.indexOf(e,f+1)}else if(i.length==1){s=[i.pop(),l]}else{n=i.pop();if(n=0?o:l}if(i.length){s=[a,u]}}return s}},,,,function(e,t,r){"use strict";var i=r(659);e.exports=factory;function factory(e,t){var r=e.split(":");var n=r[0];var a=r[1];var u=i(t);if(!a){a=n;n=null}attacher.displayName=e;return attacher;function attacher(e){var t=coerce(a,e);var r=t[0];var i=t[1];var s=r===2;return r?transformer:undefined;function transformer(e,t,r){var o=t.messages.length;u(e,t,i,done);function done(e){var i=t.messages;var u;if(e&&i.indexOf(e)===-1){try{t.fail(e)}catch(e){}}while(o2){throw new Error("Invalid severity `"+n+"` for `"+e+"`, "+"expected 0, 1, or 2")}i[0]=n;return i}},,,,,,,function(e,t,r){"use strict";e.exports=PassThrough;var i=r(955);var n=r(683);n.inherits=r(780);n.inherits(PassThrough,i);function PassThrough(e){if(!(this instanceof PassThrough))return new PassThrough(e);i.call(this,e)}PassThrough.prototype._transform=function(e,t,r){r(null,e)}},function(e,t,r){"use strict";var i=r(353);var n=r(320);e.exports=n;var a=n.prototype;a.message=message;a.info=info;a.fail=fail;a.warn=message;function message(e,t,r){var n=this.path;var a=new i(e,t,r);if(n){a.name=n+":"+a.name;a.file=n}a.fatal=false;this.messages.push(a);return a}function fail(){var e=this.message.apply(this,arguments);e.fatal=true;throw e}function info(){var e=this.message.apply(this,arguments);e.fatal=null;return e}},,,,function(e,t,r){e.exports=r(64).deprecate},,,,function(e){"use strict";e.exports=locate;function locate(e,t){var r=e.indexOf("**",t);var i=e.indexOf("__",t);if(i===-1){return r}if(r===-1){return i}return ii&&e[c+1]!==" ";c=a}}else if(!isPrintable(u)){return j}h=h&&isPlainSafe(u)}o=o||l&&(a-c-1>i&&e[c+1]!==" ")}if(!s&&!o){return h&&!n(e)?I:M}if(r>9&&needIndentIndicator(e)){return j}return o?R:L}function writeScalar(e,t,r,i){e.dump=function(){if(t.length===0){return"''"}if(!e.noCompatMode&&T.indexOf(t)!==-1){return"'"+t+"'"}var a=e.indent*Math.max(1,r);var u=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-a);var s=i||e.flowLevel>-1&&r>=e.flowLevel;function testAmbiguity(t){return testImplicitResolving(e,t)}switch(chooseScalarStyle(t,s,e.indent,u,testAmbiguity)){case I:return t;case M:return"'"+t.replace(/'/g,"''")+"'";case L:return"|"+blockHeader(t,e.indent)+dropEndingNewline(indentString(t,a));case R:return">"+blockHeader(t,e.indent)+dropEndingNewline(indentString(foldString(t,u),a));case j:return'"'+escapeString(t,u)+'"';default:throw new n("impossible error: invalid scalar style")}}()}function blockHeader(e,t){var r=needIndentIndicator(e)?String(t):"";var i=e[e.length-1]==="\n";var n=i&&(e[e.length-2]==="\n"||e==="\n");var a=n?"+":i?"":"-";return r+a+"\n"}function dropEndingNewline(e){return e[e.length-1]==="\n"?e.slice(0,-1):e}function foldString(e,t){var r=/(\n+)([^\n]*)/g;var i=function(){var i=e.indexOf("\n");i=i!==-1?i:e.length;r.lastIndex=i;return foldLine(e.slice(0,i),t)}();var n=e[0]==="\n"||e[0]===" ";var a;var u;while(u=r.exec(e)){var s=u[1],o=u[2];a=o[0]===" ";i+=s+(!n&&!a&&o!==""?"\n":"")+foldLine(o,t);n=a}return i}function foldLine(e,t){if(e===""||e[0]===" ")return e;var r=/ [^ ]/g;var i;var n=0,a,u=0,s=0;var o="";while(i=r.exec(e)){s=i.index;if(s-n>t){a=u>n?u:s;o+="\n"+e.slice(n,a);n=a+1}u=s}o+="\n";if(e.length-n>t&&u>n){o+=e.slice(n,u)+"\n"+e.slice(u+1)}else{o+=e.slice(n)}return o.slice(1)}function escapeString(e){var t="";var r,i;var n;for(var a=0;a=55296&&r<=56319){i=e.charCodeAt(a+1);if(i>=56320&&i<=57343){t+=encodeHex((r-55296)*1024+i-56320+65536);a++;continue}}n=P[r];t+=!n&&isPrintable(r)?e[a]:n||encodeHex(r)}return t}function writeFlowSequence(e,t,r){var i="",n=e.tag,a,u;for(a=0,u=r.length;a1024)f+="? ";f+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" ");if(!writeNode(e,t,l,false,false)){continue}f+=e.dump;i+=f}e.tag=n;e.dump="{"+i+"}"}function writeBlockMapping(e,t,r,i){var a="",u=e.tag,s=Object.keys(r),o,l,c,h,p,v;if(e.sortKeys===true){s.sort()}else if(typeof e.sortKeys==="function"){s.sort(e.sortKeys)}else if(e.sortKeys){throw new n("sortKeys must be a boolean or a function")}for(o=0,l=s.length;o1024;if(p){if(e.dump&&f===e.dump.charCodeAt(0)){v+="?"}else{v+="? "}}v+=e.dump;if(p){v+=generateNextLine(e,t)}if(!writeNode(e,t+1,h,true,p)){continue}if(e.dump&&f===e.dump.charCodeAt(0)){v+=":"}else{v+=": "}v+=e.dump;a+=v}e.tag=u;e.dump=a||"{}"}function detectType(e,t,r){var i,a,u,l,f,c;a=r?e.explicitTypes:e.implicitTypes;for(u=0,l=a.length;u tag resolver accepts not "'+c+'" style')}e.dump=i}return true}}return false}function writeNode(e,t,r,i,a,u){e.tag=null;e.dump=r;if(!detectType(e,r,false)){detectType(e,r,true)}var o=s.call(e.dump);if(i){i=e.flowLevel<0||e.flowLevel>t}var l=o==="[object Object]"||o==="[object Array]",f,c;if(l){f=e.duplicates.indexOf(r);c=f!==-1}if(e.tag!==null&&e.tag!=="?"||c||e.indent!==2&&t>0){a=false}if(c&&e.usedDuplicates[f]){e.dump="*ref_"+f}else{if(l&&c&&!e.usedDuplicates[f]){e.usedDuplicates[f]=true}if(o==="[object Object]"){if(i&&Object.keys(e.dump).length!==0){writeBlockMapping(e,t,e.dump,a);if(c){e.dump="&ref_"+f+e.dump}}else{writeFlowMapping(e,t,e.dump);if(c){e.dump="&ref_"+f+" "+e.dump}}}else if(o==="[object Array]"){var h=e.noArrayIndent&&t>0?t-1:t;if(i&&e.dump.length!==0){writeBlockSequence(e,h,e.dump,a);if(c){e.dump="&ref_"+f+e.dump}}else{writeFlowSequence(e,h,e.dump);if(c){e.dump="&ref_"+f+" "+e.dump}}}else if(o==="[object String]"){if(e.tag!=="?"){writeScalar(e,e.dump,t,u)}}else{if(e.skipInvalid)return false;throw new n("unacceptable kind of an object to dump "+o)}if(e.tag!==null&&e.tag!=="?"){e.dump="!<"+e.tag+"> "+e.dump}}return true}function getDuplicateReferences(e,t){var r=[],i=[],n,a;inspectNode(e,r,i);for(n=0,a=i.length;n=e.length){if(t)t[u]=e;return r(null,e)}o.lastIndex=c;var i=o.exec(e);v=h;h+=i[0];p=v+i[1];c=o.lastIndex;if(f[p]||t&&t[p]===p){return process.nextTick(LOOP)}if(t&&Object.prototype.hasOwnProperty.call(t,p)){return gotResolvedLink(t[p])}return a.lstat(p,gotStat)}function gotStat(e,i){if(e)return r(e);if(!i.isSymbolicLink()){f[p]=true;if(t)t[p]=p;return process.nextTick(LOOP)}if(!n){var u=i.dev.toString(32)+":"+i.ino.toString(32);if(s.hasOwnProperty(u)){return gotTarget(null,s[u],p)}}a.stat(p,function(e){if(e)return r(e);a.readlink(p,function(e,t){if(!n)s[u]=t;gotTarget(e,t)})})}function gotTarget(e,n,a){if(e)return r(e);var u=i.resolve(v,n);if(t)t[a]=u;gotResolvedLink(u)}function gotResolvedLink(t){e=i.resolve(t,e.slice(c));start()}}},,function(e){e.exports=[{long:"help",description:"output usage information",short:"h",type:"boolean",default:false},{long:"version",description:"output version number",short:"v",type:"boolean",default:false},{long:"output",description:"specify output location",short:"o",value:"[path]"},{long:"rc-path",description:"specify configuration file",short:"r",type:"string",value:""},{long:"ignore-path",description:"specify ignore file",short:"i",type:"string",value:""},{long:"setting",description:"specify settings",short:"s",type:"string",value:""},{long:"ext",description:"specify extensions",short:"e",type:"string",value:""},{long:"use",description:"use plugins",short:"u",type:"string",value:""},{long:"watch",description:"watch for changes and reprocess",short:"w",type:"boolean",default:false},{long:"quiet",description:"output only warnings and errors",short:"q",type:"boolean",default:false},{long:"silent",description:"output only errors",short:"S",type:"boolean",default:false},{long:"frail",description:"exit with 1 on warnings",short:"f",type:"boolean",default:false},{long:"tree",description:"specify input and output as syntax tree",short:"t",type:"boolean",default:false},{long:"report",description:"specify reporter",type:"string",value:""},{long:"file-path",description:"specify path to process as",type:"string",value:""},{long:"ignore-pattern",description:"specify ignore patterns",type:"string",value:""},{long:"tree-in",description:"specify input as syntax tree",type:"boolean"},{long:"tree-out",description:"output syntax tree",type:"boolean"},{long:"inspect",description:"output formatted syntax tree",type:"boolean"},{long:"stdout",description:"specify writing to stdout",type:"boolean",truelike:true},{long:"color",description:"specify color in report",type:"boolean",default:true},{long:"config",description:"search for configuration files",type:"boolean",default:true},{long:"ignore",description:"search for ignore files",type:"boolean",default:true}]},,,,function(e,t,r){"use strict";var i=r(495);var n=r(682);var a=r(839);var u=r(526);e.exports=i("remark-lint:hard-break-spaces",hardBreakSpaces);var s="Use two spaces for hard line breaks";function hardBreakSpaces(e,t){var r=String(t);n(e,"break",visitor);function visitor(e){var i;if(!u(e)){i=r.slice(a.start(e).offset,a.end(e).offset).split("\n",1)[0].replace(/\r$/,"");if(i.length>2){t.message(s,e)}}}}},,,,function(e,t,r){"use strict";var i=r(171);e.exports=table;var n="\t";var a="\n";var u=" ";var s="-";var o=":";var l="\\";var f="`";var c="|";var h=1;var p=2;var v="left";var d="center";var D="right";function table(e,t,r){var m=this;var g;var E;var A;var C;var y;var w;var x;var b;var F;var S;var B;var k;var O;var P;var T;var I;var M;var L;var R;var j;var U;var N;var J;var z;if(!m.options.gfm){return}g=0;L=0;w=t.length+1;x=[];while(gN){if(L1){if(F){C+=b.slice(0,b.length-1);b=b.charAt(b.length-1)}else{C+=b;b=""}}I=e.now();e(C)({type:"tableCell",children:m.tokenizeInline(k,I)},y)}e(b+F);b="";k=""}}else{if(b){k+=b;b=""}k+=F;if(F===l&&g!==w-2){k+=R.charAt(g+1);g++}if(F===f){P=1;while(R.charAt(g+1)===F){k+=F;g++;P++}if(!T){T=P}else if(P>=T){T=0}}}O=false;g++}if(!M){e(a+E)}}return U}},function(e,t,r){"use strict";var i=r(211);function resolveJavascriptRegExp(e){if(e===null)return false;if(e.length===0)return false;var t=e,r=/\/([gim]*)$/.exec(e),i="";if(t[0]==="/"){if(r)i=r[1];if(i.length>3)return false;if(t[t.length-i.length-1]!=="/")return false}return true}function constructJavascriptRegExp(e){var t=e,r=/\/([gim]*)$/.exec(e),i="";if(t[0]==="/"){if(r)i=r[1];t=t.slice(1,t.length-i.length-1)}return new RegExp(t,i)}function representJavascriptRegExp(e){var t="/"+e.source+"/";if(e.global)t+="g";if(e.multiline)t+="m";if(e.ignoreCase)t+="i";return t}function isRegExp(e){return Object.prototype.toString.call(e)==="[object RegExp]"}e.exports=new i("tag:yaml.org,2002:js/regexp",{kind:"scalar",resolve:resolveJavascriptRegExp,construct:constructJavascriptRegExp,predicate:isRegExp,represent:representJavascriptRegExp})},,,,,function(e,t,r){"use strict";e.exports.plugins=[r(889),r(767),r(850),[r(890),"tab-size"],r(223),r(127),r(701),[r(382),"."],r(550),r(816),r(33),r(9),r(121),r(476),r(280),r(842)]},,,,function(e){"use strict";e.exports=markdownTable;var t=/\./;var r=/\.[^.]*$/;var i="l";var n="r";var a="c";var u=".";var s="";var o=[i,n,a,u,s];var l=3;var f=":";var c="-";var h="|";var p=" ";var v="\n";function markdownTable(e,r){var d=r||{};var D=d.delimiter;var m=d.start;var g=d.end;var E=d.align;var A=d.stringLength||lengthNoop;var C=0;var y=-1;var w=e.length;var x=[];var b;var F;var S;var B;var k;var O;var P;var T;var I;var M;var L;var R;E=E?E.concat():[];if(D===null||D===undefined){D=p+h+p}if(m===null||m===undefined){m=h+p}if(g===null||g===undefined){g=p+h}while(++yC){C=B.length}while(++Ox[O]){x[O]=P}}}if(typeof E==="string"){E=pad(C,E).split("")}O=-1;while(++Ox[O]){x[O]=T}}}y=-1;while(++yl?M:l}else{M=x[O]}b=E[O];I=b===n||b===s?c:f;I+=pad(M-2,c);I+=b!==i&&b!==s?f:c;F[O]=I}S.splice(1,0,F.join(D))}return m+S.join(g+v+m)+g}function stringify(e){return e===null||e===undefined?"":String(e)}function lengthNoop(e){return String(e).length}function pad(e,t){return new Array(e+1).join(t||p)}function dotindex(e){var t=r.exec(e);return t?t.index+1:e.length}},,,,,function(e,t,r){e.exports=r(688)},,,,,function(e,t,r){"use strict";var i=r(12);e.exports=Writable;function WriteReq(e,t,r){this.chunk=e;this.encoding=t;this.callback=r;this.next=null}function CorkedRequest(e){var t=this;this.next=null;this.entry=null;this.finish=function(){onCorkedFinish(t,e)}}var n=!process.browser&&["v0.10","v0.9."].indexOf(process.version.slice(0,5))>-1?setImmediate:i.nextTick;var a;Writable.WritableState=WritableState;var u=r(683);u.inherits=r(780);var s={deprecate:r(507)};var o=r(569);var l=r(945).Buffer;var f=global.Uint8Array||function(){};function _uint8ArrayToBuffer(e){return l.from(e)}function _isUint8Array(e){return l.isBuffer(e)||e instanceof f}var c=r(972);u.inherits(Writable,o);function nop(){}function WritableState(e,t){a=a||r(98);e=e||{};var i=t instanceof a;this.objectMode=!!e.objectMode;if(i)this.objectMode=this.objectMode||!!e.writableObjectMode;var n=e.highWaterMark;var u=e.writableHighWaterMark;var s=this.objectMode?16:16*1024;if(n||n===0)this.highWaterMark=n;else if(i&&(u||u===0))this.highWaterMark=u;else this.highWaterMark=s;this.highWaterMark=Math.floor(this.highWaterMark);this.finalCalled=false;this.needDrain=false;this.ending=false;this.ended=false;this.finished=false;this.destroyed=false;var o=e.decodeStrings===false;this.decodeStrings=!o;this.defaultEncoding=e.defaultEncoding||"utf8";this.length=0;this.writing=false;this.corked=0;this.sync=true;this.bufferProcessing=false;this.onwrite=function(e){onwrite(t,e)};this.writecb=null;this.writelen=0;this.bufferedRequest=null;this.lastBufferedRequest=null;this.pendingcb=0;this.prefinished=false;this.errorEmitted=false;this.bufferedRequestCount=0;this.corkedRequestsFree=new CorkedRequest(this)}WritableState.prototype.getBuffer=function getBuffer(){var e=this.bufferedRequest;var t=[];while(e){t.push(e);e=e.next}return t};(function(){try{Object.defineProperty(WritableState.prototype,"buffer",{get:s.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer "+"instead.","DEP0003")})}catch(e){}})();var h;if(typeof Symbol==="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]==="function"){h=Function.prototype[Symbol.hasInstance];Object.defineProperty(Writable,Symbol.hasInstance,{value:function(e){if(h.call(this,e))return true;if(this!==Writable)return false;return e&&e._writableState instanceof WritableState}})}else{h=function(e){return e instanceof this}}function Writable(e){a=a||r(98);if(!h.call(Writable,this)&&!(this instanceof a)){return new Writable(e)}this._writableState=new WritableState(e,this);this.writable=true;if(e){if(typeof e.write==="function")this._write=e.write;if(typeof e.writev==="function")this._writev=e.writev;if(typeof e.destroy==="function")this._destroy=e.destroy;if(typeof e.final==="function")this._final=e.final}o.call(this)}Writable.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))};function writeAfterEnd(e,t){var r=new Error("write after end");e.emit("error",r);i.nextTick(t,r)}function validChunk(e,t,r,n){var a=true;var u=false;if(r===null){u=new TypeError("May not write null values to stream")}else if(typeof r!=="string"&&r!==undefined&&!t.objectMode){u=new TypeError("Invalid non-string/buffer chunk")}if(u){e.emit("error",u);i.nextTick(n,u);a=false}return a}Writable.prototype.write=function(e,t,r){var i=this._writableState;var n=false;var a=!i.objectMode&&_isUint8Array(e);if(a&&!l.isBuffer(e)){e=_uint8ArrayToBuffer(e)}if(typeof t==="function"){r=t;t=null}if(a)t="buffer";else if(!t)t=i.defaultEncoding;if(typeof r!=="function")r=nop;if(i.ended)writeAfterEnd(this,r);else if(a||validChunk(this,i,e,r)){i.pendingcb++;n=writeOrBuffer(this,i,a,e,t,r)}return n};Writable.prototype.cork=function(){var e=this._writableState;e.corked++};Writable.prototype.uncork=function(){var e=this._writableState;if(e.corked){e.corked--;if(!e.writing&&!e.corked&&!e.finished&&!e.bufferProcessing&&e.bufferedRequest)clearBuffer(this,e)}};Writable.prototype.setDefaultEncoding=function setDefaultEncoding(e){if(typeof e==="string")e=e.toLowerCase();if(!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+e);this._writableState.defaultEncoding=e;return this};function decodeChunk(e,t,r){if(!e.objectMode&&e.decodeStrings!==false&&typeof t==="string"){t=l.from(t,r)}return t}Object.defineProperty(Writable.prototype,"writableHighWaterMark",{enumerable:false,get:function(){return this._writableState.highWaterMark}});function writeOrBuffer(e,t,r,i,n,a){if(!r){var u=decodeChunk(t,i,n);if(i!==u){r=true;n="buffer";i=u}}var s=t.objectMode?1:i.length;t.length+=s;var o=t.length=b){b=0}}else if(E===v){g++;B+=t.charAt(g)}else if((!b||y)&&E===p){L++}else if((!b||y)&&E===d){if(L){L--}else{if(!A){while(gn){return false}}return check(e,i,r)&&check(e,m)}function isKnown(e,t,r){var i=o?o.indexOf(e)!==-1:true;if(!i){h.warn("Unknown rule: cannot "+t+" `'"+e+"'`",r)}return i}function getState(e){var t=e?D[e]:m;if(t&&t.length!==0){return t[t.length-1].state}if(!e){return!l}if(l){return f.indexOf(e)!==-1}return c.indexOf(e)===-1}function toggle(e,t,r){var i=r?D[r]:m;var n;var a;if(!i){i=[];D[r]=i}a=getState(r);n=t;if(n!==a){i.push({state:n,position:e})}if(!r){for(r in D){toggle(e,t,r)}}}function check(e,t,r){var i=t&&t.length;var n=-1;var a;while(--i>n){a=t[i];if(!a.position||!a.position.line||!a.position.column){continue}if(a.position.line=e){return}if(u){s.push({start:n,end:e});u=false}n=e}}},,function(e){"use strict";e.exports=orderedItems;var t="\n";var r=".";var i=t+t;function orderedItems(e){var n=this;var a=n.visitors.listItem;var u=n.options.incrementListMarker;var s=[];var o=e.start;var l=e.children;var f=l.length;var c=-1;var h;o=o==null?1:o;while(++c1;var p=c;var v=t.path;if(!u(p)){a("Not copying");return i()}p=l(e.cwd,p);a("Copying `%s`",v);s(p,onstatfile);function onstatfile(e,t){if(e){if(e.code!=="ENOENT"||c.charAt(c.length-1)===n.sep){return i(new Error("Cannot read output directory. Error:\n"+e.message))}s(o(p),onstatparent)}else{done(t.isDirectory())}}function onstatparent(e){if(e){i(new Error("Cannot read parent directory. Error:\n"+e.message))}else{done(false)}}function done(e){if(!e&&h){return i(new Error("Cannot write multiple files to single output: "+p))}t[e?"dirname":"path"]=f(t.cwd,p);a("Copying document from %s to %s",v,t.path);i()}}},function(e,t){"use strict";var r="[a-zA-Z_:][a-zA-Z0-9:._-]*";var i="[^\"'=<>`\\u0000-\\u0020]+";var n="'[^']*'";var a='"[^"]*"';var u="(?:"+i+"|"+n+"|"+a+")";var s="(?:\\s+"+r+"(?:\\s*=\\s*"+u+")?)";var o="<[A-Za-z][A-Za-z0-9\\-]*"+s+"*\\s*\\/?>";var l="<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>";var f="\x3c!----\x3e|\x3c!--(?:-?[^>-])(?:-?[^-])*--\x3e";var c="<[?].*?[?]>";var h="]*>";var p="";t.openCloseTag=new RegExp("^(?:"+o+"|"+l+")");t.tag=new RegExp("^(?:"+o+"|"+l+"|"+f+"|"+c+"|"+h+"|"+p+")")},,function(e){e.exports=require("path")},,,,function(e,t,r){"use strict";var i=r(36);var n=r(171);var a=r(511);e.exports=strong;strong.locator=a;var u="\\";var s="*";var o="_";function strong(e,t,r){var a=this;var l=0;var f=t.charAt(l);var c;var h;var p;var v;var d;var D;var m;if(f!==s&&f!==o||t.charAt(++l)!==f){return}h=a.options.pedantic;p=f;d=p+p;D=t.length;l++;v="";f="";if(h&&n(t.charAt(l))){return}while(l0){return parse(e)}else if(r==="number"&&isNaN(e)===false){return t.long?fmtLong(e):fmtShort(e)}throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function parse(e){e=String(e);if(e.length>100){return}var s=/^((?:\d+)?\-?\d?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!s){return}var o=parseFloat(s[1]);var l=(s[2]||"ms").toLowerCase();switch(l){case"years":case"year":case"yrs":case"yr":case"y":return o*u;case"weeks":case"week":case"w":return o*a;case"days":case"day":case"d":return o*n;case"hours":case"hour":case"hrs":case"hr":case"h":return o*i;case"minutes":case"minute":case"mins":case"min":case"m":return o*r;case"seconds":case"second":case"secs":case"sec":case"s":return o*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return o;default:return undefined}}function fmtShort(e){var a=Math.abs(e);if(a>=n){return Math.round(e/n)+"d"}if(a>=i){return Math.round(e/i)+"h"}if(a>=r){return Math.round(e/r)+"m"}if(a>=t){return Math.round(e/t)+"s"}return e+"ms"}function fmtLong(e){var a=Math.abs(e);if(a>=n){return plural(e,a,n,"day")}if(a>=i){return plural(e,a,i,"hour")}if(a>=r){return plural(e,a,r,"minute")}if(a>=t){return plural(e,a,t,"second")}return e+" ms"}function plural(e,t,r,i){var n=t>=r*1.5;return Math.round(e/r)+" "+i+(n?"s":"")}},function(e,t){t.parse=t.decode=decode;t.stringify=t.encode=encode;t.safe=safe;t.unsafe=unsafe;var r=typeof process!=="undefined"&&process.platform==="win32"?"\r\n":"\n";function encode(e,t){var i=[];var n="";if(typeof t==="string"){t={section:t,whitespace:false}}else{t=t||{};t.whitespace=t.whitespace===true}var a=t.whitespace?" = ":"=";Object.keys(e).forEach(function(t,u,s){var o=e[t];if(o&&Array.isArray(o)){o.forEach(function(e){n+=safe(t+"[]")+a+safe(e)+"\n"})}else if(o&&typeof o==="object"){i.push(t)}else{n+=safe(t)+a+safe(o)+r}});if(t.section&&n.length){n="["+safe(t.section)+"]"+r+n}i.forEach(function(i,a,u){var s=dotSplit(i).join("\\.");var o=(t.section?t.section+".":"")+s;var l=encode(e[i],{section:o,whitespace:t.whitespace});if(n.length&&l.length){n+=r}n+=l});return n}function dotSplit(e){return e.replace(/\1/g,"LITERAL\\1LITERAL").replace(/\\\./g,"").split(/\./).map(function(e){return e.replace(/\1/g,"\\.").replace(/\2LITERAL\\1LITERAL\2/g,"")})}function decode(e){var t={};var r=t;var i=null;var n=/^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i;var a=e.split(/[\r\n]+/g);a.forEach(function(e,a,u){if(!e||e.match(/^\s*[;#]/))return;var s=e.match(n);if(!s)return;if(s[1]!==undefined){i=unsafe(s[1]);r=t[i]=t[i]||{};return}var o=unsafe(s[2]);var l=s[3]?unsafe(s[4]):true;switch(l){case"true":case"false":case"null":l=JSON.parse(l)}if(o.length>2&&o.slice(-2)==="[]"){o=o.substring(0,o.length-2);if(!r[o]){r[o]=[]}else if(!Array.isArray(r[o])){r[o]=[r[o]]}}if(Array.isArray(r[o])){r[o].push(l)}else{r[o]=l}});Object.keys(t).filter(function(e,r,i){if(!t[e]||typeof t[e]!=="object"||Array.isArray(t[e])){return false}var n=dotSplit(e);var a=t;var u=n.pop();var s=u.replace(/\\\./g,".");n.forEach(function(e,t,r){if(!a[e]||typeof a[e]!=="object")a[e]={};a=a[e]});if(a===t&&s===u){return false}a[s]=t[e];return true}).forEach(function(e,r,i){delete t[e]});return t}function isQuoted(e){return e.charAt(0)==='"'&&e.slice(-1)==='"'||e.charAt(0)==="'"&&e.slice(-1)==="'"}function safe(e){return typeof e!=="string"||e.match(/[=\r\n]/)||e.match(/^\[/)||e.length>1&&isQuoted(e)||e!==e.trim()?JSON.stringify(e):e.replace(/;/g,"\\;").replace(/#/g,"\\#")}function unsafe(e,t){e=(e||"").trim();if(isQuoted(e)){if(e.charAt(0)==="'"){e=e.substr(1,e.length-2)}try{e=JSON.parse(e)}catch(e){}}else{var r=false;var i="";for(var n=0,a=e.length;n="a"&&e<="z"||e>="A"&&e<="Z"||e==="$"||e==="_"||i.ID_Start.test(e)},isIdContinueChar(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e>="0"&&e<="9"||e==="$"||e==="_"||e==="‌"||e==="‍"||i.ID_Continue.test(e)},isDigit(e){return/[0-9]/.test(e)},isHexDigit(e){return/[0-9A-Fa-f]/.test(e)}}},,function(e){"use strict";e.exports=(e=>{if(Number.isNaN(e)){return false}if(e>=4352&&(e<=4447||e===9001||e===9002||11904<=e&&e<=12871&&e!==12351||12880<=e&&e<=19903||19968<=e&&e<=42182||43360<=e&&e<=43388||44032<=e&&e<=55203||63744<=e&&e<=64255||65040<=e&&e<=65049||65072<=e&&e<=65131||65281<=e&&e<=65376||65504<=e&&e<=65510||110592<=e&&e<=110593||127488<=e&&e<=127569||131072<=e&&e<=262141)){return true}return false})},,,,,,,,,function(e,t,r){"use strict";e.exports.plugins=[r(889),r(560),[r(166),2],[r(112),{checked:"x",unchecked:" "}],r(424),[r(301),"fenced"],r(896),r(137),[r(386),"`"],[r(451),"md"],r(339),[r(284),1],[r(675),"atx"],[r(890),"space"],r(164),r(846),r(667),r(380),r(911),r(758),[r(701),false],r(273),r(926),r(55),r(72),r(522),[r(455),[{no:"End-Of-Life",yes:"End-of-Life"},{no:"End-of-life",yes:"End-of-Life"},{no:"Github",yes:"GitHub"},{no:"[Jj]avascript",yes:"JavaScript"},{no:"Node",yes:"Node.js"},{no:"Node.JS",yes:"Node.js"},{no:"node.js",yes:"Node.js"},{no:"[Nn]ote that",yes:""},{no:"Rfc",yes:"RFC"},{no:"[Rr][Ff][Cc]\\d+",yes:"RFC "},{no:"rfc",yes:"RFC"},{no:"UNIX",yes:"Unix"},{no:"unix",yes:"Unix"},{no:"v8",yes:"V8"}]],r(467),[r(108),"*"],[r(435),"padded"],r(314),[r(4),"*"]]},,function(e){e.exports=["cent","copy","divide","gt","lt","not","para","times"]},,function(e,t,r){"use strict";e.exports=r(447)},function(e,t,r){e.exports=minimatch;minimatch.Minimatch=Minimatch;var i={sep:"/"};try{i=r(589)}catch(e){}var n=minimatch.GLOBSTAR=Minimatch.GLOBSTAR={};var a=r(348);var u={"!":{open:"(?:(?!(?:",close:"))[^/]*?)"},"?":{open:"(?:",close:")?"},"+":{open:"(?:",close:")+"},"*":{open:"(?:",close:")*"},"@":{open:"(?:",close:")"}};var s="[^/]";var o=s+"*?";var l="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";var f="(?:(?!(?:\\/|^)\\.).)*?";var c=charSet("().*{}+?[]^$\\!");function charSet(e){return e.split("").reduce(function(e,t){e[t]=true;return e},{})}var h=/\/+/;minimatch.filter=filter;function filter(e,t){t=t||{};return function(r,i,n){return minimatch(r,e,t)}}function ext(e,t){e=e||{};t=t||{};var r={};Object.keys(t).forEach(function(e){r[e]=t[e]});Object.keys(e).forEach(function(t){r[t]=e[t]});return r}minimatch.defaults=function(e){if(!e||!Object.keys(e).length)return minimatch;var t=minimatch;var r=function minimatch(r,i,n){return t.minimatch(r,i,ext(e,n))};r.Minimatch=function Minimatch(r,i){return new t.Minimatch(r,ext(e,i))};return r};Minimatch.defaults=function(e){if(!e||!Object.keys(e).length)return Minimatch;return minimatch.defaults(e).Minimatch};function minimatch(e,t,r){if(typeof t!=="string"){throw new TypeError("glob pattern string required")}if(!r)r={};if(!r.nocomment&&t.charAt(0)==="#"){return false}if(t.trim()==="")return e==="";return new Minimatch(t,r).match(e)}function Minimatch(e,t){if(!(this instanceof Minimatch)){return new Minimatch(e,t)}if(typeof e!=="string"){throw new TypeError("glob pattern string required")}if(!t)t={};e=e.trim();if(i.sep!=="/"){e=e.split(i.sep).join("/")}this.options=t;this.set=[];this.pattern=e;this.regexp=null;this.negate=false;this.comment=false;this.empty=false;this.make()}Minimatch.prototype.debug=function(){};Minimatch.prototype.make=make;function make(){if(this._made)return;var e=this.pattern;var t=this.options;if(!t.nocomment&&e.charAt(0)==="#"){this.comment=true;return}if(!e){this.empty=true;return}this.parseNegate();var r=this.globSet=this.braceExpand();if(t.debug)this.debug=console.error;this.debug(this.pattern,r);r=this.globParts=r.map(function(e){return e.split(h)});this.debug(this.pattern,r);r=r.map(function(e,t,r){return e.map(this.parse,this)},this);this.debug(this.pattern,r);r=r.filter(function(e){return e.indexOf(false)===-1});this.debug(this.pattern,r);this.set=r}Minimatch.prototype.parseNegate=parseNegate;function parseNegate(){var e=this.pattern;var t=false;var r=this.options;var i=0;if(r.nonegate)return;for(var n=0,a=e.length;n1024*64){throw new TypeError("pattern is too long")}var r=this.options;if(!r.noglobstar&&e==="**")return n;if(e==="")return"";var i="";var a=!!r.nocase;var l=false;var f=[];var h=[];var v;var d=false;var D=-1;var m=-1;var g=e.charAt(0)==="."?"":r.dot?"(?!(?:^|\\/)\\.{1,2}(?:$|\\/))":"(?!\\.)";var E=this;function clearStateChar(){if(v){switch(v){case"*":i+=o;a=true;break;case"?":i+=s;a=true;break;default:i+="\\"+v;break}E.debug("clearStateChar %j %j",v,i);v=false}}for(var A=0,C=e.length,y;A-1;k--){var O=h[k];var P=i.slice(0,O.reStart);var T=i.slice(O.reStart,O.reEnd-8);var I=i.slice(O.reEnd-8,O.reEnd);var M=i.slice(O.reEnd);I+=M;var L=P.split("(").length-1;var R=M;for(A=0;A=0;u--){a=e[u];if(a)break}for(u=0;u>> no match, partial?",e,c,t,h);if(c===s)return true}return false}var v;if(typeof l==="string"){if(i.nocase){v=f.toLowerCase()===l.toLowerCase()}else{v=f===l}this.debug("string match",l,f,v)}else{v=f.match(l);this.debug("pattern match",l,f,v)}if(!v)return false}if(a===s&&u===o){return true}else if(a===s){return r}else if(u===o){var d=a===s-1&&e[a]==="";return d}throw new Error("wtf?")};function globUnescape(e){return e.replace(/\\(.)/g,"$1")}function regExpEscape(e){return e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}},,,function(e){"use strict";e.exports=function(e){if(typeof e!=="function"){throw new TypeError("Expected a function")}return e.displayName||e.name||(/function ([^\(]+)?\(/.exec(e.toString())||[])[1]||null}},function(e){"use strict";e.exports=(()=>{const e=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"].join("|");return new RegExp(e,"g")})},,,function(e,t,r){"use strict";var i=r(304);var n=r(948);e.exports=fileSystem;function fileSystem(e,t,r){var a=e.files;if(a.length===0){r()}else{n(a,{cwd:t.cwd,extensions:t.extensions,silentlyIgnore:t.silentlyIgnore,ignore:new i({cwd:t.cwd,detectIgnore:t.detectIgnore,ignoreName:t.ignoreName,ignorePath:t.ignorePath})},onfound)}function onfound(i,n){var a=n.files;a.sort(sortAlphabetically);a.forEach(markAsGiven);e.files=a;if(t.out===null||t.out===undefined){t.out=n.oneFileMode}r(i)}function markAsGiven(e){e.data.unifiedEngineGiven=true}function sortAlphabetically(e,t){return e.pathi){i=r}}else{r=1}n=a+1;a=e.indexOf(t,n)}return i}},function(e,t,r){"use strict";var i=r(347)("unified-engine:file-pipeline:stdout");var n=r(928);e.exports=stdout;function stdout(e,t,r,a){if(!t.data.unifiedEngineGiven){i("Ignoring programmatically added file");a()}else if(n(t).fatal||e.output||!e.out){i("Ignoring writing to `streamOut`");a()}else{i("Writing document to `streamOut`");e.streamOut.write(t.toString(),a)}}},,,function(e,t,r){"use strict";var i=r(56);var n=r(503);e.exports=toVFile;function toVFile(e){if(typeof e==="string"||i(e)){e={path:String(e)}}return n(e)}},,,,function(e){(function webpackUniversalModuleDefinition(t,r){if(true)e.exports=r();else{}})(this,function(){return function(e){var t={};function __webpack_require__(r){if(t[r])return t[r].exports;var i=t[r]={exports:{},id:r,loaded:false};e[r].call(i.exports,i,i.exports,__webpack_require__);i.loaded=true;return i.exports}__webpack_require__.m=e;__webpack_require__.c=t;__webpack_require__.p="";return __webpack_require__(0)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:true});var i=r(1);var n=r(3);var a=r(8);var u=r(15);function parse(e,t,r){var u=null;var s=function(e,t){if(r){r(e,t)}if(u){u.visit(e,t)}};var o=typeof r==="function"?s:null;var l=false;if(t){l=typeof t.comment==="boolean"&&t.comment;var f=typeof t.attachComment==="boolean"&&t.attachComment;if(l||f){u=new i.CommentHandler;u.attach=f;t.comment=true;o=s}}var c=false;if(t&&typeof t.sourceType==="string"){c=t.sourceType==="module"}var h;if(t&&typeof t.jsx==="boolean"&&t.jsx){h=new n.JSXParser(e,t,o)}else{h=new a.Parser(e,t,o)}var p=c?h.parseModule():h.parseScript();var v=p;if(l&&u){v.comments=u.comments}if(h.config.tokens){v.tokens=h.tokens}if(h.config.tolerant){v.errors=h.errorHandler.errors}return v}t.parse=parse;function parseModule(e,t,r){var i=t||{};i.sourceType="module";return parse(e,i,r)}t.parseModule=parseModule;function parseScript(e,t,r){var i=t||{};i.sourceType="script";return parse(e,i,r)}t.parseScript=parseScript;function tokenize(e,t,r){var i=new u.Tokenizer(e,t);var n;n=[];try{while(true){var a=i.getNextToken();if(!a){break}if(r){a=r(a)}n.push(a)}}catch(e){i.errorHandler.tolerate(e)}if(i.errorHandler.tolerant){n.errors=i.errors()}return n}t.tokenize=tokenize;var s=r(2);t.Syntax=s.Syntax;t.version="4.0.1"},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:true});var i=r(2);var n=function(){function CommentHandler(){this.attach=false;this.comments=[];this.stack=[];this.leading=[];this.trailing=[]}CommentHandler.prototype.insertInnerComments=function(e,t){if(e.type===i.Syntax.BlockStatement&&e.body.length===0){var r=[];for(var n=this.leading.length-1;n>=0;--n){var a=this.leading[n];if(t.end.offset>=a.start){r.unshift(a.comment);this.leading.splice(n,1);this.trailing.splice(n,1)}}if(r.length){e.innerComments=r}}};CommentHandler.prototype.findTrailingComments=function(e){var t=[];if(this.trailing.length>0){for(var r=this.trailing.length-1;r>=0;--r){var i=this.trailing[r];if(i.start>=e.end.offset){t.unshift(i.comment)}}this.trailing.length=0;return t}var n=this.stack[this.stack.length-1];if(n&&n.node.trailingComments){var a=n.node.trailingComments[0];if(a&&a.range[0]>=e.end.offset){t=n.node.trailingComments;delete n.node.trailingComments}}return t};CommentHandler.prototype.findLeadingComments=function(e){var t=[];var r;while(this.stack.length>0){var i=this.stack[this.stack.length-1];if(i&&i.start>=e.start.offset){r=i.node;this.stack.pop()}else{break}}if(r){var n=r.leadingComments?r.leadingComments.length:0;for(var a=n-1;a>=0;--a){var u=r.leadingComments[a];if(u.range[1]<=e.start.offset){t.unshift(u);r.leadingComments.splice(a,1)}}if(r.leadingComments&&r.leadingComments.length===0){delete r.leadingComments}return t}for(var a=this.leading.length-1;a>=0;--a){var i=this.leading[a];if(i.start<=e.start.offset){t.unshift(i.comment);this.leading.splice(a,1)}}return t};CommentHandler.prototype.visitNode=function(e,t){if(e.type===i.Syntax.Program&&e.body.length>0){return}this.insertInnerComments(e,t);var r=this.findTrailingComments(t);var n=this.findLeadingComments(t);if(n.length>0){e.leadingComments=n}if(r.length>0){e.trailingComments=r}this.stack.push({node:e,start:t.start.offset})};CommentHandler.prototype.visitComment=function(e,t){var r=e.type[0]==="L"?"Line":"Block";var i={type:r,value:e.value};if(e.range){i.range=e.range}if(e.loc){i.loc=e.loc}this.comments.push(i);if(this.attach){var n={comment:{type:r,value:e.value,range:[t.start.offset,t.end.offset]},start:t.start.offset};if(e.loc){n.comment.loc=e.loc}e.type=r;this.leading.push(n);this.trailing.push(n)}};CommentHandler.prototype.visit=function(e,t){if(e.type==="LineComment"){this.visitComment(e,t)}else if(e.type==="BlockComment"){this.visitComment(e,t)}else if(this.attach){this.visitNode(e,t)}};return CommentHandler}();t.CommentHandler=n},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.Syntax={AssignmentExpression:"AssignmentExpression",AssignmentPattern:"AssignmentPattern",ArrayExpression:"ArrayExpression",ArrayPattern:"ArrayPattern",ArrowFunctionExpression:"ArrowFunctionExpression",AwaitExpression:"AwaitExpression",BlockStatement:"BlockStatement",BinaryExpression:"BinaryExpression",BreakStatement:"BreakStatement",CallExpression:"CallExpression",CatchClause:"CatchClause",ClassBody:"ClassBody",ClassDeclaration:"ClassDeclaration",ClassExpression:"ClassExpression",ConditionalExpression:"ConditionalExpression",ContinueStatement:"ContinueStatement",DoWhileStatement:"DoWhileStatement",DebuggerStatement:"DebuggerStatement",EmptyStatement:"EmptyStatement",ExportAllDeclaration:"ExportAllDeclaration",ExportDefaultDeclaration:"ExportDefaultDeclaration",ExportNamedDeclaration:"ExportNamedDeclaration",ExportSpecifier:"ExportSpecifier",ExpressionStatement:"ExpressionStatement",ForStatement:"ForStatement",ForOfStatement:"ForOfStatement",ForInStatement:"ForInStatement",FunctionDeclaration:"FunctionDeclaration",FunctionExpression:"FunctionExpression",Identifier:"Identifier",IfStatement:"IfStatement",ImportDeclaration:"ImportDeclaration",ImportDefaultSpecifier:"ImportDefaultSpecifier",ImportNamespaceSpecifier:"ImportNamespaceSpecifier",ImportSpecifier:"ImportSpecifier",Literal:"Literal",LabeledStatement:"LabeledStatement",LogicalExpression:"LogicalExpression",MemberExpression:"MemberExpression",MetaProperty:"MetaProperty",MethodDefinition:"MethodDefinition",NewExpression:"NewExpression",ObjectExpression:"ObjectExpression",ObjectPattern:"ObjectPattern",Program:"Program",Property:"Property",RestElement:"RestElement",ReturnStatement:"ReturnStatement",SequenceExpression:"SequenceExpression",SpreadElement:"SpreadElement",Super:"Super",SwitchCase:"SwitchCase",SwitchStatement:"SwitchStatement",TaggedTemplateExpression:"TaggedTemplateExpression",TemplateElement:"TemplateElement",TemplateLiteral:"TemplateLiteral",ThisExpression:"ThisExpression",ThrowStatement:"ThrowStatement",TryStatement:"TryStatement",UnaryExpression:"UnaryExpression",UpdateExpression:"UpdateExpression",VariableDeclaration:"VariableDeclaration",VariableDeclarator:"VariableDeclarator",WhileStatement:"WhileStatement",WithStatement:"WithStatement",YieldExpression:"YieldExpression"}},function(e,t,r){"use strict";var i=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)if(t.hasOwnProperty(r))e[r]=t[r]};return function(t,r){e(t,r);function __(){this.constructor=t}t.prototype=r===null?Object.create(r):(__.prototype=r.prototype,new __)}}();Object.defineProperty(t,"__esModule",{value:true});var n=r(4);var a=r(5);var u=r(6);var s=r(7);var o=r(8);var l=r(13);var f=r(14);l.TokenName[100]="JSXIdentifier";l.TokenName[101]="JSXText";function getQualifiedElementName(e){var t;switch(e.type){case u.JSXSyntax.JSXIdentifier:var r=e;t=r.name;break;case u.JSXSyntax.JSXNamespacedName:var i=e;t=getQualifiedElementName(i.namespace)+":"+getQualifiedElementName(i.name);break;case u.JSXSyntax.JSXMemberExpression:var n=e;t=getQualifiedElementName(n.object)+"."+getQualifiedElementName(n.property);break;default:break}return t}var c=function(e){i(JSXParser,e);function JSXParser(t,r,i){return e.call(this,t,r,i)||this}JSXParser.prototype.parsePrimaryExpression=function(){return this.match("<")?this.parseJSXRoot():e.prototype.parsePrimaryExpression.call(this)};JSXParser.prototype.startJSX=function(){this.scanner.index=this.startMarker.index;this.scanner.lineNumber=this.startMarker.line;this.scanner.lineStart=this.startMarker.index-this.startMarker.column};JSXParser.prototype.finishJSX=function(){this.nextToken()};JSXParser.prototype.reenterJSX=function(){this.startJSX();this.expectJSX("}");if(this.config.tokens){this.tokens.pop()}};JSXParser.prototype.createJSXNode=function(){this.collectComments();return{index:this.scanner.index,line:this.scanner.lineNumber,column:this.scanner.index-this.scanner.lineStart}};JSXParser.prototype.createJSXChildNode=function(){return{index:this.scanner.index,line:this.scanner.lineNumber,column:this.scanner.index-this.scanner.lineStart}};JSXParser.prototype.scanXHTMLEntity=function(e){var t="&";var r=true;var i=false;var a=false;var u=false;while(!this.scanner.eof()&&r&&!i){var s=this.scanner.source[this.scanner.index];if(s===e){break}i=s===";";t+=s;++this.scanner.index;if(!i){switch(t.length){case 2:a=s==="#";break;case 3:if(a){u=s==="x";r=u||n.Character.isDecimalDigit(s.charCodeAt(0));a=a&&!u}break;default:r=r&&!(a&&!n.Character.isDecimalDigit(s.charCodeAt(0)));r=r&&!(u&&!n.Character.isHexDigit(s.charCodeAt(0)));break}}}if(r&&i&&t.length>2){var o=t.substr(1,t.length-2);if(a&&o.length>1){t=String.fromCharCode(parseInt(o.substr(1),10))}else if(u&&o.length>2){t=String.fromCharCode(parseInt("0"+o.substr(1),16))}else if(!a&&!u&&f.XHTMLEntities[o]){t=f.XHTMLEntities[o]}}return t};JSXParser.prototype.lexJSX=function(){var e=this.scanner.source.charCodeAt(this.scanner.index);if(e===60||e===62||e===47||e===58||e===61||e===123||e===125){var t=this.scanner.source[this.scanner.index++];return{type:7,value:t,lineNumber:this.scanner.lineNumber,lineStart:this.scanner.lineStart,start:this.scanner.index-1,end:this.scanner.index}}if(e===34||e===39){var r=this.scanner.index;var i=this.scanner.source[this.scanner.index++];var a="";while(!this.scanner.eof()){var u=this.scanner.source[this.scanner.index++];if(u===i){break}else if(u==="&"){a+=this.scanXHTMLEntity(i)}else{a+=u}}return{type:8,value:a,lineNumber:this.scanner.lineNumber,lineStart:this.scanner.lineStart,start:r,end:this.scanner.index}}if(e===46){var s=this.scanner.source.charCodeAt(this.scanner.index+1);var o=this.scanner.source.charCodeAt(this.scanner.index+2);var t=s===46&&o===46?"...":".";var r=this.scanner.index;this.scanner.index+=t.length;return{type:7,value:t,lineNumber:this.scanner.lineNumber,lineStart:this.scanner.lineStart,start:r,end:this.scanner.index}}if(e===96){return{type:10,value:"",lineNumber:this.scanner.lineNumber,lineStart:this.scanner.lineStart,start:this.scanner.index,end:this.scanner.index}}if(n.Character.isIdentifierStart(e)&&e!==92){var r=this.scanner.index;++this.scanner.index;while(!this.scanner.eof()){var u=this.scanner.source.charCodeAt(this.scanner.index);if(n.Character.isIdentifierPart(u)&&u!==92){++this.scanner.index}else if(u===45){++this.scanner.index}else{break}}var l=this.scanner.source.slice(r,this.scanner.index);return{type:100,value:l,lineNumber:this.scanner.lineNumber,lineStart:this.scanner.lineStart,start:r,end:this.scanner.index}}return this.scanner.lex()};JSXParser.prototype.nextJSXToken=function(){this.collectComments();this.startMarker.index=this.scanner.index;this.startMarker.line=this.scanner.lineNumber;this.startMarker.column=this.scanner.index-this.scanner.lineStart;var e=this.lexJSX();this.lastMarker.index=this.scanner.index;this.lastMarker.line=this.scanner.lineNumber;this.lastMarker.column=this.scanner.index-this.scanner.lineStart;if(this.config.tokens){this.tokens.push(this.convertToken(e))}return e};JSXParser.prototype.nextJSXText=function(){this.startMarker.index=this.scanner.index;this.startMarker.line=this.scanner.lineNumber;this.startMarker.column=this.scanner.index-this.scanner.lineStart;var e=this.scanner.index;var t="";while(!this.scanner.eof()){var r=this.scanner.source[this.scanner.index];if(r==="{"||r==="<"){break}++this.scanner.index;t+=r;if(n.Character.isLineTerminator(r.charCodeAt(0))){++this.scanner.lineNumber;if(r==="\r"&&this.scanner.source[this.scanner.index]==="\n"){++this.scanner.index}this.scanner.lineStart=this.scanner.index}}this.lastMarker.index=this.scanner.index;this.lastMarker.line=this.scanner.lineNumber;this.lastMarker.column=this.scanner.index-this.scanner.lineStart;var i={type:101,value:t,lineNumber:this.scanner.lineNumber,lineStart:this.scanner.lineStart,start:e,end:this.scanner.index};if(t.length>0&&this.config.tokens){this.tokens.push(this.convertToken(i))}return i};JSXParser.prototype.peekJSXToken=function(){var e=this.scanner.saveState();this.scanner.scanComments();var t=this.lexJSX();this.scanner.restoreState(e);return t};JSXParser.prototype.expectJSX=function(e){var t=this.nextJSXToken();if(t.type!==7||t.value!==e){this.throwUnexpectedToken(t)}};JSXParser.prototype.matchJSX=function(e){var t=this.peekJSXToken();return t.type===7&&t.value===e};JSXParser.prototype.parseJSXIdentifier=function(){var e=this.createJSXNode();var t=this.nextJSXToken();if(t.type!==100){this.throwUnexpectedToken(t)}return this.finalize(e,new a.JSXIdentifier(t.value))};JSXParser.prototype.parseJSXElementName=function(){var e=this.createJSXNode();var t=this.parseJSXIdentifier();if(this.matchJSX(":")){var r=t;this.expectJSX(":");var i=this.parseJSXIdentifier();t=this.finalize(e,new a.JSXNamespacedName(r,i))}else if(this.matchJSX(".")){while(this.matchJSX(".")){var n=t;this.expectJSX(".");var u=this.parseJSXIdentifier();t=this.finalize(e,new a.JSXMemberExpression(n,u))}}return t};JSXParser.prototype.parseJSXAttributeName=function(){var e=this.createJSXNode();var t;var r=this.parseJSXIdentifier();if(this.matchJSX(":")){var i=r;this.expectJSX(":");var n=this.parseJSXIdentifier();t=this.finalize(e,new a.JSXNamespacedName(i,n))}else{t=r}return t};JSXParser.prototype.parseJSXStringLiteralAttribute=function(){var e=this.createJSXNode();var t=this.nextJSXToken();if(t.type!==8){this.throwUnexpectedToken(t)}var r=this.getTokenRaw(t);return this.finalize(e,new s.Literal(t.value,r))};JSXParser.prototype.parseJSXExpressionAttribute=function(){var e=this.createJSXNode();this.expectJSX("{");this.finishJSX();if(this.match("}")){this.tolerateError("JSX attributes must only be assigned a non-empty expression")}var t=this.parseAssignmentExpression();this.reenterJSX();return this.finalize(e,new a.JSXExpressionContainer(t))};JSXParser.prototype.parseJSXAttributeValue=function(){return this.matchJSX("{")?this.parseJSXExpressionAttribute():this.matchJSX("<")?this.parseJSXElement():this.parseJSXStringLiteralAttribute()};JSXParser.prototype.parseJSXNameValueAttribute=function(){var e=this.createJSXNode();var t=this.parseJSXAttributeName();var r=null;if(this.matchJSX("=")){this.expectJSX("=");r=this.parseJSXAttributeValue()}return this.finalize(e,new a.JSXAttribute(t,r))};JSXParser.prototype.parseJSXSpreadAttribute=function(){var e=this.createJSXNode();this.expectJSX("{");this.expectJSX("...");this.finishJSX();var t=this.parseAssignmentExpression();this.reenterJSX();return this.finalize(e,new a.JSXSpreadAttribute(t))};JSXParser.prototype.parseJSXAttributes=function(){var e=[];while(!this.matchJSX("/")&&!this.matchJSX(">")){var t=this.matchJSX("{")?this.parseJSXSpreadAttribute():this.parseJSXNameValueAttribute();e.push(t)}return e};JSXParser.prototype.parseJSXOpeningElement=function(){var e=this.createJSXNode();this.expectJSX("<");var t=this.parseJSXElementName();var r=this.parseJSXAttributes();var i=this.matchJSX("/");if(i){this.expectJSX("/")}this.expectJSX(">");return this.finalize(e,new a.JSXOpeningElement(t,i,r))};JSXParser.prototype.parseJSXBoundaryElement=function(){var e=this.createJSXNode();this.expectJSX("<");if(this.matchJSX("/")){this.expectJSX("/");var t=this.parseJSXElementName();this.expectJSX(">");return this.finalize(e,new a.JSXClosingElement(t))}var r=this.parseJSXElementName();var i=this.parseJSXAttributes();var n=this.matchJSX("/");if(n){this.expectJSX("/")}this.expectJSX(">");return this.finalize(e,new a.JSXOpeningElement(r,n,i))};JSXParser.prototype.parseJSXEmptyExpression=function(){var e=this.createJSXChildNode();this.collectComments();this.lastMarker.index=this.scanner.index;this.lastMarker.line=this.scanner.lineNumber;this.lastMarker.column=this.scanner.index-this.scanner.lineStart;return this.finalize(e,new a.JSXEmptyExpression)};JSXParser.prototype.parseJSXExpressionContainer=function(){var e=this.createJSXNode();this.expectJSX("{");var t;if(this.matchJSX("}")){t=this.parseJSXEmptyExpression();this.expectJSX("}")}else{this.finishJSX();t=this.parseAssignmentExpression();this.reenterJSX()}return this.finalize(e,new a.JSXExpressionContainer(t))};JSXParser.prototype.parseJSXChildren=function(){var e=[];while(!this.scanner.eof()){var t=this.createJSXChildNode();var r=this.nextJSXText();if(r.start0){var s=this.finalize(e.node,new a.JSXElement(e.opening,e.children,e.closing));e=t[t.length-1];e.children.push(s);t.pop()}else{break}}}return e};JSXParser.prototype.parseJSXElement=function(){var e=this.createJSXNode();var t=this.parseJSXOpeningElement();var r=[];var i=null;if(!t.selfClosing){var n=this.parseComplexJSXElement({node:e,opening:t,closing:i,children:r});r=n.children;i=n.closing}return this.finalize(e,new a.JSXElement(t,r,i))};JSXParser.prototype.parseJSXRoot=function(){if(this.config.tokens){this.tokens.pop()}this.startJSX();var e=this.parseJSXElement();this.finishJSX();return e};JSXParser.prototype.isStartOfExpression=function(){return e.prototype.isStartOfExpression.call(this)||this.match("<")};return JSXParser}(o.Parser);t.JSXParser=c},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r={NonAsciiIdentifierStart:/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]/,NonAsciiIdentifierPart:/[\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B4\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/};t.Character={fromCodePoint:function(e){return e<65536?String.fromCharCode(e):String.fromCharCode(55296+(e-65536>>10))+String.fromCharCode(56320+(e-65536&1023))},isWhiteSpace:function(e){return e===32||e===9||e===11||e===12||e===160||e>=5760&&[5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].indexOf(e)>=0},isLineTerminator:function(e){return e===10||e===13||e===8232||e===8233},isIdentifierStart:function(e){return e===36||e===95||e>=65&&e<=90||e>=97&&e<=122||e===92||e>=128&&r.NonAsciiIdentifierStart.test(t.Character.fromCodePoint(e))},isIdentifierPart:function(e){return e===36||e===95||e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===92||e>=128&&r.NonAsciiIdentifierPart.test(t.Character.fromCodePoint(e))},isDecimalDigit:function(e){return e>=48&&e<=57},isHexDigit:function(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102},isOctalDigit:function(e){return e>=48&&e<=55}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:true});var i=r(6);var n=function(){function JSXClosingElement(e){this.type=i.JSXSyntax.JSXClosingElement;this.name=e}return JSXClosingElement}();t.JSXClosingElement=n;var a=function(){function JSXElement(e,t,r){this.type=i.JSXSyntax.JSXElement;this.openingElement=e;this.children=t;this.closingElement=r}return JSXElement}();t.JSXElement=a;var u=function(){function JSXEmptyExpression(){this.type=i.JSXSyntax.JSXEmptyExpression}return JSXEmptyExpression}();t.JSXEmptyExpression=u;var s=function(){function JSXExpressionContainer(e){this.type=i.JSXSyntax.JSXExpressionContainer;this.expression=e}return JSXExpressionContainer}();t.JSXExpressionContainer=s;var o=function(){function JSXIdentifier(e){this.type=i.JSXSyntax.JSXIdentifier;this.name=e}return JSXIdentifier}();t.JSXIdentifier=o;var l=function(){function JSXMemberExpression(e,t){this.type=i.JSXSyntax.JSXMemberExpression;this.object=e;this.property=t}return JSXMemberExpression}();t.JSXMemberExpression=l;var f=function(){function JSXAttribute(e,t){this.type=i.JSXSyntax.JSXAttribute;this.name=e;this.value=t}return JSXAttribute}();t.JSXAttribute=f;var c=function(){function JSXNamespacedName(e,t){this.type=i.JSXSyntax.JSXNamespacedName;this.namespace=e;this.name=t}return JSXNamespacedName}();t.JSXNamespacedName=c;var h=function(){function JSXOpeningElement(e,t,r){this.type=i.JSXSyntax.JSXOpeningElement;this.name=e;this.selfClosing=t;this.attributes=r}return JSXOpeningElement}();t.JSXOpeningElement=h;var p=function(){function JSXSpreadAttribute(e){this.type=i.JSXSyntax.JSXSpreadAttribute;this.argument=e}return JSXSpreadAttribute}();t.JSXSpreadAttribute=p;var v=function(){function JSXText(e,t){this.type=i.JSXSyntax.JSXText;this.value=e;this.raw=t}return JSXText}();t.JSXText=v},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.JSXSyntax={JSXAttribute:"JSXAttribute",JSXClosingElement:"JSXClosingElement",JSXElement:"JSXElement",JSXEmptyExpression:"JSXEmptyExpression",JSXExpressionContainer:"JSXExpressionContainer",JSXIdentifier:"JSXIdentifier",JSXMemberExpression:"JSXMemberExpression",JSXNamespacedName:"JSXNamespacedName",JSXOpeningElement:"JSXOpeningElement",JSXSpreadAttribute:"JSXSpreadAttribute",JSXText:"JSXText"}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:true});var i=r(2);var n=function(){function ArrayExpression(e){this.type=i.Syntax.ArrayExpression;this.elements=e}return ArrayExpression}();t.ArrayExpression=n;var a=function(){function ArrayPattern(e){this.type=i.Syntax.ArrayPattern;this.elements=e}return ArrayPattern}();t.ArrayPattern=a;var u=function(){function ArrowFunctionExpression(e,t,r){this.type=i.Syntax.ArrowFunctionExpression;this.id=null;this.params=e;this.body=t;this.generator=false;this.expression=r;this.async=false}return ArrowFunctionExpression}();t.ArrowFunctionExpression=u;var s=function(){function AssignmentExpression(e,t,r){this.type=i.Syntax.AssignmentExpression;this.operator=e;this.left=t;this.right=r}return AssignmentExpression}();t.AssignmentExpression=s;var o=function(){function AssignmentPattern(e,t){this.type=i.Syntax.AssignmentPattern;this.left=e;this.right=t}return AssignmentPattern}();t.AssignmentPattern=o;var l=function(){function AsyncArrowFunctionExpression(e,t,r){this.type=i.Syntax.ArrowFunctionExpression;this.id=null;this.params=e;this.body=t;this.generator=false;this.expression=r;this.async=true}return AsyncArrowFunctionExpression}();t.AsyncArrowFunctionExpression=l;var f=function(){function AsyncFunctionDeclaration(e,t,r){this.type=i.Syntax.FunctionDeclaration;this.id=e;this.params=t;this.body=r;this.generator=false;this.expression=false;this.async=true}return AsyncFunctionDeclaration}();t.AsyncFunctionDeclaration=f;var c=function(){function AsyncFunctionExpression(e,t,r){this.type=i.Syntax.FunctionExpression;this.id=e;this.params=t;this.body=r;this.generator=false;this.expression=false;this.async=true}return AsyncFunctionExpression}();t.AsyncFunctionExpression=c;var h=function(){function AwaitExpression(e){this.type=i.Syntax.AwaitExpression;this.argument=e}return AwaitExpression}();t.AwaitExpression=h;var p=function(){function BinaryExpression(e,t,r){var n=e==="||"||e==="&&";this.type=n?i.Syntax.LogicalExpression:i.Syntax.BinaryExpression;this.operator=e;this.left=t;this.right=r}return BinaryExpression}();t.BinaryExpression=p;var v=function(){function BlockStatement(e){this.type=i.Syntax.BlockStatement;this.body=e}return BlockStatement}();t.BlockStatement=v;var d=function(){function BreakStatement(e){this.type=i.Syntax.BreakStatement;this.label=e}return BreakStatement}();t.BreakStatement=d;var D=function(){function CallExpression(e,t){this.type=i.Syntax.CallExpression;this.callee=e;this.arguments=t}return CallExpression}();t.CallExpression=D;var m=function(){function CatchClause(e,t){this.type=i.Syntax.CatchClause;this.param=e;this.body=t}return CatchClause}();t.CatchClause=m;var g=function(){function ClassBody(e){this.type=i.Syntax.ClassBody;this.body=e}return ClassBody}();t.ClassBody=g;var E=function(){function ClassDeclaration(e,t,r){this.type=i.Syntax.ClassDeclaration;this.id=e;this.superClass=t;this.body=r}return ClassDeclaration}();t.ClassDeclaration=E;var A=function(){function ClassExpression(e,t,r){this.type=i.Syntax.ClassExpression;this.id=e;this.superClass=t;this.body=r}return ClassExpression}();t.ClassExpression=A;var C=function(){function ComputedMemberExpression(e,t){this.type=i.Syntax.MemberExpression;this.computed=true;this.object=e;this.property=t}return ComputedMemberExpression}();t.ComputedMemberExpression=C;var y=function(){function ConditionalExpression(e,t,r){this.type=i.Syntax.ConditionalExpression;this.test=e;this.consequent=t;this.alternate=r}return ConditionalExpression}();t.ConditionalExpression=y;var w=function(){function ContinueStatement(e){this.type=i.Syntax.ContinueStatement;this.label=e}return ContinueStatement}();t.ContinueStatement=w;var x=function(){function DebuggerStatement(){this.type=i.Syntax.DebuggerStatement}return DebuggerStatement}();t.DebuggerStatement=x;var b=function(){function Directive(e,t){this.type=i.Syntax.ExpressionStatement;this.expression=e;this.directive=t}return Directive}();t.Directive=b;var F=function(){function DoWhileStatement(e,t){this.type=i.Syntax.DoWhileStatement;this.body=e;this.test=t}return DoWhileStatement}();t.DoWhileStatement=F;var S=function(){function EmptyStatement(){this.type=i.Syntax.EmptyStatement}return EmptyStatement}();t.EmptyStatement=S;var B=function(){function ExportAllDeclaration(e){this.type=i.Syntax.ExportAllDeclaration;this.source=e}return ExportAllDeclaration}();t.ExportAllDeclaration=B;var k=function(){function ExportDefaultDeclaration(e){this.type=i.Syntax.ExportDefaultDeclaration;this.declaration=e}return ExportDefaultDeclaration}();t.ExportDefaultDeclaration=k;var O=function(){function ExportNamedDeclaration(e,t,r){this.type=i.Syntax.ExportNamedDeclaration;this.declaration=e;this.specifiers=t;this.source=r}return ExportNamedDeclaration}();t.ExportNamedDeclaration=O;var P=function(){function ExportSpecifier(e,t){this.type=i.Syntax.ExportSpecifier;this.exported=t;this.local=e}return ExportSpecifier}();t.ExportSpecifier=P;var T=function(){function ExpressionStatement(e){this.type=i.Syntax.ExpressionStatement;this.expression=e}return ExpressionStatement}();t.ExpressionStatement=T;var I=function(){function ForInStatement(e,t,r){this.type=i.Syntax.ForInStatement;this.left=e;this.right=t;this.body=r;this.each=false}return ForInStatement}();t.ForInStatement=I;var M=function(){function ForOfStatement(e,t,r){this.type=i.Syntax.ForOfStatement;this.left=e;this.right=t;this.body=r}return ForOfStatement}();t.ForOfStatement=M;var L=function(){function ForStatement(e,t,r,n){this.type=i.Syntax.ForStatement;this.init=e;this.test=t;this.update=r;this.body=n}return ForStatement}();t.ForStatement=L;var R=function(){function FunctionDeclaration(e,t,r,n){this.type=i.Syntax.FunctionDeclaration;this.id=e;this.params=t;this.body=r;this.generator=n;this.expression=false;this.async=false}return FunctionDeclaration}();t.FunctionDeclaration=R;var j=function(){function FunctionExpression(e,t,r,n){this.type=i.Syntax.FunctionExpression;this.id=e;this.params=t;this.body=r;this.generator=n;this.expression=false;this.async=false}return FunctionExpression}();t.FunctionExpression=j;var U=function(){function Identifier(e){this.type=i.Syntax.Identifier;this.name=e}return Identifier}();t.Identifier=U;var N=function(){function IfStatement(e,t,r){this.type=i.Syntax.IfStatement;this.test=e;this.consequent=t;this.alternate=r}return IfStatement}();t.IfStatement=N;var J=function(){function ImportDeclaration(e,t){this.type=i.Syntax.ImportDeclaration;this.specifiers=e;this.source=t}return ImportDeclaration}();t.ImportDeclaration=J;var z=function(){function ImportDefaultSpecifier(e){this.type=i.Syntax.ImportDefaultSpecifier;this.local=e}return ImportDefaultSpecifier}();t.ImportDefaultSpecifier=z;var X=function(){function ImportNamespaceSpecifier(e){this.type=i.Syntax.ImportNamespaceSpecifier;this.local=e}return ImportNamespaceSpecifier}();t.ImportNamespaceSpecifier=X;var G=function(){function ImportSpecifier(e,t){this.type=i.Syntax.ImportSpecifier;this.local=e;this.imported=t}return ImportSpecifier}();t.ImportSpecifier=G;var q=function(){function LabeledStatement(e,t){this.type=i.Syntax.LabeledStatement;this.label=e;this.body=t}return LabeledStatement}();t.LabeledStatement=q;var W=function(){function Literal(e,t){this.type=i.Syntax.Literal;this.value=e;this.raw=t}return Literal}();t.Literal=W;var _=function(){function MetaProperty(e,t){this.type=i.Syntax.MetaProperty;this.meta=e;this.property=t}return MetaProperty}();t.MetaProperty=_;var V=function(){function MethodDefinition(e,t,r,n,a){this.type=i.Syntax.MethodDefinition;this.key=e;this.computed=t;this.value=r;this.kind=n;this.static=a}return MethodDefinition}();t.MethodDefinition=V;var Y=function(){function Module(e){this.type=i.Syntax.Program;this.body=e;this.sourceType="module"}return Module}();t.Module=Y;var H=function(){function NewExpression(e,t){this.type=i.Syntax.NewExpression;this.callee=e;this.arguments=t}return NewExpression}();t.NewExpression=H;var $=function(){function ObjectExpression(e){this.type=i.Syntax.ObjectExpression;this.properties=e}return ObjectExpression}();t.ObjectExpression=$;var Z=function(){function ObjectPattern(e){this.type=i.Syntax.ObjectPattern;this.properties=e}return ObjectPattern}();t.ObjectPattern=Z;var Q=function(){function Property(e,t,r,n,a,u){this.type=i.Syntax.Property;this.key=t;this.computed=r;this.value=n;this.kind=e;this.method=a;this.shorthand=u}return Property}();t.Property=Q;var K=function(){function RegexLiteral(e,t,r,n){this.type=i.Syntax.Literal;this.value=e;this.raw=t;this.regex={pattern:r,flags:n}}return RegexLiteral}();t.RegexLiteral=K;var ee=function(){function RestElement(e){this.type=i.Syntax.RestElement;this.argument=e}return RestElement}();t.RestElement=ee;var te=function(){function ReturnStatement(e){this.type=i.Syntax.ReturnStatement;this.argument=e}return ReturnStatement}();t.ReturnStatement=te;var re=function(){function Script(e){this.type=i.Syntax.Program;this.body=e;this.sourceType="script"}return Script}();t.Script=re;var ie=function(){function SequenceExpression(e){this.type=i.Syntax.SequenceExpression;this.expressions=e}return SequenceExpression}();t.SequenceExpression=ie;var ne=function(){function SpreadElement(e){this.type=i.Syntax.SpreadElement;this.argument=e}return SpreadElement}();t.SpreadElement=ne;var ae=function(){function StaticMemberExpression(e,t){this.type=i.Syntax.MemberExpression;this.computed=false;this.object=e;this.property=t}return StaticMemberExpression}();t.StaticMemberExpression=ae;var ue=function(){function Super(){this.type=i.Syntax.Super}return Super}();t.Super=ue;var se=function(){function SwitchCase(e,t){this.type=i.Syntax.SwitchCase;this.test=e;this.consequent=t}return SwitchCase}();t.SwitchCase=se;var oe=function(){function SwitchStatement(e,t){this.type=i.Syntax.SwitchStatement;this.discriminant=e;this.cases=t}return SwitchStatement}();t.SwitchStatement=oe;var le=function(){function TaggedTemplateExpression(e,t){this.type=i.Syntax.TaggedTemplateExpression;this.tag=e;this.quasi=t}return TaggedTemplateExpression}();t.TaggedTemplateExpression=le;var fe=function(){function TemplateElement(e,t){this.type=i.Syntax.TemplateElement;this.value=e;this.tail=t}return TemplateElement}();t.TemplateElement=fe;var ce=function(){function TemplateLiteral(e,t){this.type=i.Syntax.TemplateLiteral;this.quasis=e;this.expressions=t}return TemplateLiteral}();t.TemplateLiteral=ce;var he=function(){function ThisExpression(){this.type=i.Syntax.ThisExpression}return ThisExpression}();t.ThisExpression=he;var pe=function(){function ThrowStatement(e){this.type=i.Syntax.ThrowStatement;this.argument=e}return ThrowStatement}();t.ThrowStatement=pe;var ve=function(){function TryStatement(e,t,r){this.type=i.Syntax.TryStatement;this.block=e;this.handler=t;this.finalizer=r}return TryStatement}();t.TryStatement=ve;var de=function(){function UnaryExpression(e,t){this.type=i.Syntax.UnaryExpression;this.operator=e;this.argument=t;this.prefix=true}return UnaryExpression}();t.UnaryExpression=de;var De=function(){function UpdateExpression(e,t,r){this.type=i.Syntax.UpdateExpression;this.operator=e;this.argument=t;this.prefix=r}return UpdateExpression}();t.UpdateExpression=De;var me=function(){function VariableDeclaration(e,t){this.type=i.Syntax.VariableDeclaration;this.declarations=e;this.kind=t}return VariableDeclaration}();t.VariableDeclaration=me;var ge=function(){function VariableDeclarator(e,t){this.type=i.Syntax.VariableDeclarator;this.id=e;this.init=t}return VariableDeclarator}();t.VariableDeclarator=ge;var Ee=function(){function WhileStatement(e,t){this.type=i.Syntax.WhileStatement;this.test=e;this.body=t}return WhileStatement}();t.WhileStatement=Ee;var Ae=function(){function WithStatement(e,t){this.type=i.Syntax.WithStatement;this.object=e;this.body=t}return WithStatement}();t.WithStatement=Ae;var Ce=function(){function YieldExpression(e,t){this.type=i.Syntax.YieldExpression;this.argument=e;this.delegate=t}return YieldExpression}();t.YieldExpression=Ce},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:true});var i=r(9);var n=r(10);var a=r(11);var u=r(7);var s=r(12);var o=r(2);var l=r(13);var f="ArrowParameterPlaceHolder";var c=function(){function Parser(e,t,r){if(t===void 0){t={}}this.config={range:typeof t.range==="boolean"&&t.range,loc:typeof t.loc==="boolean"&&t.loc,source:null,tokens:typeof t.tokens==="boolean"&&t.tokens,comment:typeof t.comment==="boolean"&&t.comment,tolerant:typeof t.tolerant==="boolean"&&t.tolerant};if(this.config.loc&&t.source&&t.source!==null){this.config.source=String(t.source)}this.delegate=r;this.errorHandler=new n.ErrorHandler;this.errorHandler.tolerant=this.config.tolerant;this.scanner=new s.Scanner(e,this.errorHandler);this.scanner.trackComment=this.config.comment;this.operatorPrecedence={")":0,";":0,",":0,"=":0,"]":0,"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":11,"/":11,"%":11};this.lookahead={type:2,value:"",lineNumber:this.scanner.lineNumber,lineStart:0,start:0,end:0};this.hasLineTerminator=false;this.context={isModule:false,await:false,allowIn:true,allowStrictDirective:true,allowYield:true,firstCoverInitializedNameError:null,isAssignmentTarget:false,isBindingElement:false,inFunctionBody:false,inIteration:false,inSwitch:false,labelSet:{},strict:false};this.tokens=[];this.startMarker={index:0,line:this.scanner.lineNumber,column:0};this.lastMarker={index:0,line:this.scanner.lineNumber,column:0};this.nextToken();this.lastMarker={index:this.scanner.index,line:this.scanner.lineNumber,column:this.scanner.index-this.scanner.lineStart}}Parser.prototype.throwError=function(e){var t=[];for(var r=1;r0&&this.delegate){for(var t=0;t>="||e===">>>="||e==="&="||e==="^="||e==="|="};Parser.prototype.isolateCoverGrammar=function(e){var t=this.context.isBindingElement;var r=this.context.isAssignmentTarget;var i=this.context.firstCoverInitializedNameError;this.context.isBindingElement=true;this.context.isAssignmentTarget=true;this.context.firstCoverInitializedNameError=null;var n=e.call(this);if(this.context.firstCoverInitializedNameError!==null){this.throwUnexpectedToken(this.context.firstCoverInitializedNameError)}this.context.isBindingElement=t;this.context.isAssignmentTarget=r;this.context.firstCoverInitializedNameError=i;return n};Parser.prototype.inheritCoverGrammar=function(e){var t=this.context.isBindingElement;var r=this.context.isAssignmentTarget;var i=this.context.firstCoverInitializedNameError;this.context.isBindingElement=true;this.context.isAssignmentTarget=true;this.context.firstCoverInitializedNameError=null;var n=e.call(this);this.context.isBindingElement=this.context.isBindingElement&&t;this.context.isAssignmentTarget=this.context.isAssignmentTarget&&r;this.context.firstCoverInitializedNameError=i||this.context.firstCoverInitializedNameError;return n};Parser.prototype.consumeSemicolon=function(){if(this.match(";")){this.nextToken()}else if(!this.hasLineTerminator){if(this.lookahead.type!==2&&!this.match("}")){this.throwUnexpectedToken(this.lookahead)}this.lastMarker.index=this.startMarker.index;this.lastMarker.line=this.startMarker.line;this.lastMarker.column=this.startMarker.column}};Parser.prototype.parsePrimaryExpression=function(){var e=this.createNode();var t;var r,i;switch(this.lookahead.type){case 3:if((this.context.isModule||this.context.await)&&this.lookahead.value==="await"){this.tolerateUnexpectedToken(this.lookahead)}t=this.matchAsyncFunction()?this.parseFunctionExpression():this.finalize(e,new u.Identifier(this.nextToken().value));break;case 6:case 8:if(this.context.strict&&this.lookahead.octal){this.tolerateUnexpectedToken(this.lookahead,a.Messages.StrictOctalLiteral)}this.context.isAssignmentTarget=false;this.context.isBindingElement=false;r=this.nextToken();i=this.getTokenRaw(r);t=this.finalize(e,new u.Literal(r.value,i));break;case 1:this.context.isAssignmentTarget=false;this.context.isBindingElement=false;r=this.nextToken();i=this.getTokenRaw(r);t=this.finalize(e,new u.Literal(r.value==="true",i));break;case 5:this.context.isAssignmentTarget=false;this.context.isBindingElement=false;r=this.nextToken();i=this.getTokenRaw(r);t=this.finalize(e,new u.Literal(null,i));break;case 10:t=this.parseTemplateLiteral();break;case 7:switch(this.lookahead.value){case"(":this.context.isBindingElement=false;t=this.inheritCoverGrammar(this.parseGroupExpression);break;case"[":t=this.inheritCoverGrammar(this.parseArrayInitializer);break;case"{":t=this.inheritCoverGrammar(this.parseObjectInitializer);break;case"/":case"/=":this.context.isAssignmentTarget=false;this.context.isBindingElement=false;this.scanner.index=this.startMarker.index;r=this.nextRegexToken();i=this.getTokenRaw(r);t=this.finalize(e,new u.RegexLiteral(r.regex,i,r.pattern,r.flags));break;default:t=this.throwUnexpectedToken(this.nextToken())}break;case 4:if(!this.context.strict&&this.context.allowYield&&this.matchKeyword("yield")){t=this.parseIdentifierName()}else if(!this.context.strict&&this.matchKeyword("let")){t=this.finalize(e,new u.Identifier(this.nextToken().value))}else{this.context.isAssignmentTarget=false;this.context.isBindingElement=false;if(this.matchKeyword("function")){t=this.parseFunctionExpression()}else if(this.matchKeyword("this")){this.nextToken();t=this.finalize(e,new u.ThisExpression)}else if(this.matchKeyword("class")){t=this.parseClassExpression()}else{t=this.throwUnexpectedToken(this.nextToken())}}break;default:t=this.throwUnexpectedToken(this.nextToken())}return t};Parser.prototype.parseSpreadElement=function(){var e=this.createNode();this.expect("...");var t=this.inheritCoverGrammar(this.parseAssignmentExpression);return this.finalize(e,new u.SpreadElement(t))};Parser.prototype.parseArrayInitializer=function(){var e=this.createNode();var t=[];this.expect("[");while(!this.match("]")){if(this.match(",")){this.nextToken();t.push(null)}else if(this.match("...")){var r=this.parseSpreadElement();if(!this.match("]")){this.context.isAssignmentTarget=false;this.context.isBindingElement=false;this.expect(",")}t.push(r)}else{t.push(this.inheritCoverGrammar(this.parseAssignmentExpression));if(!this.match("]")){this.expect(",")}}}this.expect("]");return this.finalize(e,new u.ArrayExpression(t))};Parser.prototype.parsePropertyMethod=function(e){this.context.isAssignmentTarget=false;this.context.isBindingElement=false;var t=this.context.strict;var r=this.context.allowStrictDirective;this.context.allowStrictDirective=e.simple;var i=this.isolateCoverGrammar(this.parseFunctionSourceElements);if(this.context.strict&&e.firstRestricted){this.tolerateUnexpectedToken(e.firstRestricted,e.message)}if(this.context.strict&&e.stricted){this.tolerateUnexpectedToken(e.stricted,e.message)}this.context.strict=t;this.context.allowStrictDirective=r;return i};Parser.prototype.parsePropertyMethodFunction=function(){var e=false;var t=this.createNode();var r=this.context.allowYield;this.context.allowYield=true;var i=this.parseFormalParameters();var n=this.parsePropertyMethod(i);this.context.allowYield=r;return this.finalize(t,new u.FunctionExpression(null,i.params,n,e))};Parser.prototype.parsePropertyMethodAsyncFunction=function(){var e=this.createNode();var t=this.context.allowYield;var r=this.context.await;this.context.allowYield=false;this.context.await=true;var i=this.parseFormalParameters();var n=this.parsePropertyMethod(i);this.context.allowYield=t;this.context.await=r;return this.finalize(e,new u.AsyncFunctionExpression(null,i.params,n))};Parser.prototype.parseObjectPropertyKey=function(){var e=this.createNode();var t=this.nextToken();var r;switch(t.type){case 8:case 6:if(this.context.strict&&t.octal){this.tolerateUnexpectedToken(t,a.Messages.StrictOctalLiteral)}var i=this.getTokenRaw(t);r=this.finalize(e,new u.Literal(t.value,i));break;case 3:case 1:case 5:case 4:r=this.finalize(e,new u.Identifier(t.value));break;case 7:if(t.value==="["){r=this.isolateCoverGrammar(this.parseAssignmentExpression);this.expect("]")}else{r=this.throwUnexpectedToken(t)}break;default:r=this.throwUnexpectedToken(t)}return r};Parser.prototype.isPropertyKey=function(e,t){return e.type===o.Syntax.Identifier&&e.name===t||e.type===o.Syntax.Literal&&e.value===t};Parser.prototype.parseObjectProperty=function(e){var t=this.createNode();var r=this.lookahead;var i;var n=null;var s=null;var o=false;var l=false;var f=false;var c=false;if(r.type===3){var h=r.value;this.nextToken();o=this.match("[");c=!this.hasLineTerminator&&h==="async"&&!this.match(":")&&!this.match("(")&&!this.match("*")&&!this.match(",");n=c?this.parseObjectPropertyKey():this.finalize(t,new u.Identifier(h))}else if(this.match("*")){this.nextToken()}else{o=this.match("[");n=this.parseObjectPropertyKey()}var p=this.qualifiedPropertyName(this.lookahead);if(r.type===3&&!c&&r.value==="get"&&p){i="get";o=this.match("[");n=this.parseObjectPropertyKey();this.context.allowYield=false;s=this.parseGetterMethod()}else if(r.type===3&&!c&&r.value==="set"&&p){i="set";o=this.match("[");n=this.parseObjectPropertyKey();s=this.parseSetterMethod()}else if(r.type===7&&r.value==="*"&&p){i="init";o=this.match("[");n=this.parseObjectPropertyKey();s=this.parseGeneratorMethod();l=true}else{if(!n){this.throwUnexpectedToken(this.lookahead)}i="init";if(this.match(":")&&!c){if(!o&&this.isPropertyKey(n,"__proto__")){if(e.value){this.tolerateError(a.Messages.DuplicateProtoProperty)}e.value=true}this.nextToken();s=this.inheritCoverGrammar(this.parseAssignmentExpression)}else if(this.match("(")){s=c?this.parsePropertyMethodAsyncFunction():this.parsePropertyMethodFunction();l=true}else if(r.type===3){var h=this.finalize(t,new u.Identifier(r.value));if(this.match("=")){this.context.firstCoverInitializedNameError=this.lookahead;this.nextToken();f=true;var v=this.isolateCoverGrammar(this.parseAssignmentExpression);s=this.finalize(t,new u.AssignmentPattern(h,v))}else{f=true;s=h}}else{this.throwUnexpectedToken(this.nextToken())}}return this.finalize(t,new u.Property(i,n,o,s,l,f))};Parser.prototype.parseObjectInitializer=function(){var e=this.createNode();this.expect("{");var t=[];var r={value:false};while(!this.match("}")){t.push(this.parseObjectProperty(r));if(!this.match("}")){this.expectCommaSeparator()}}this.expect("}");return this.finalize(e,new u.ObjectExpression(t))};Parser.prototype.parseTemplateHead=function(){i.assert(this.lookahead.head,"Template literal must start with a template head");var e=this.createNode();var t=this.nextToken();var r=t.value;var n=t.cooked;return this.finalize(e,new u.TemplateElement({raw:r,cooked:n},t.tail))};Parser.prototype.parseTemplateElement=function(){if(this.lookahead.type!==10){this.throwUnexpectedToken()}var e=this.createNode();var t=this.nextToken();var r=t.value;var i=t.cooked;return this.finalize(e,new u.TemplateElement({raw:r,cooked:i},t.tail))};Parser.prototype.parseTemplateLiteral=function(){var e=this.createNode();var t=[];var r=[];var i=this.parseTemplateHead();r.push(i);while(!i.tail){t.push(this.parseExpression());i=this.parseTemplateElement();r.push(i)}return this.finalize(e,new u.TemplateLiteral(r,t))};Parser.prototype.reinterpretExpressionAsPattern=function(e){switch(e.type){case o.Syntax.Identifier:case o.Syntax.MemberExpression:case o.Syntax.RestElement:case o.Syntax.AssignmentPattern:break;case o.Syntax.SpreadElement:e.type=o.Syntax.RestElement;this.reinterpretExpressionAsPattern(e.argument);break;case o.Syntax.ArrayExpression:e.type=o.Syntax.ArrayPattern;for(var t=0;t")){this.expect("=>")}e={type:f,params:[],async:false}}else{var t=this.lookahead;var r=[];if(this.match("...")){e=this.parseRestElement(r);this.expect(")");if(!this.match("=>")){this.expect("=>")}e={type:f,params:[e],async:false}}else{var i=false;this.context.isBindingElement=true;e=this.inheritCoverGrammar(this.parseAssignmentExpression);if(this.match(",")){var n=[];this.context.isAssignmentTarget=false;n.push(e);while(this.lookahead.type!==2){if(!this.match(",")){break}this.nextToken();if(this.match(")")){this.nextToken();for(var a=0;a")){this.expect("=>")}this.context.isBindingElement=false;for(var a=0;a")){if(e.type===o.Syntax.Identifier&&e.name==="yield"){i=true;e={type:f,params:[e],async:false}}if(!i){if(!this.context.isBindingElement){this.throwUnexpectedToken(this.lookahead)}if(e.type===o.Syntax.SequenceExpression){for(var a=0;a")){for(var o=0;o0){this.nextToken();this.context.isAssignmentTarget=false;this.context.isBindingElement=false;var n=[e,this.lookahead];var a=t;var s=this.isolateCoverGrammar(this.parseExponentiationExpression);var o=[a,r.value,s];var l=[i];while(true){i=this.binaryPrecedence(this.lookahead);if(i<=0){break}while(o.length>2&&i<=l[l.length-1]){s=o.pop();var f=o.pop();l.pop();a=o.pop();n.pop();var c=this.startNode(n[n.length-1]);o.push(this.finalize(c,new u.BinaryExpression(f,a,s)))}o.push(this.nextToken().value);l.push(i);n.push(this.lookahead);o.push(this.isolateCoverGrammar(this.parseExponentiationExpression))}var h=o.length-1;t=o[h];var p=n.pop();while(h>1){var v=n.pop();var d=p&&p.lineStart;var c=this.startNode(v,d);var f=o[h-1];t=this.finalize(c,new u.BinaryExpression(f,o[h-2],t));h-=2;p=v}}return t};Parser.prototype.parseConditionalExpression=function(){var e=this.lookahead;var t=this.inheritCoverGrammar(this.parseBinaryExpression);if(this.match("?")){this.nextToken();var r=this.context.allowIn;this.context.allowIn=true;var i=this.isolateCoverGrammar(this.parseAssignmentExpression);this.context.allowIn=r;this.expect(":");var n=this.isolateCoverGrammar(this.parseAssignmentExpression);t=this.finalize(this.startNode(e),new u.ConditionalExpression(t,i,n));this.context.isAssignmentTarget=false;this.context.isBindingElement=false}return t};Parser.prototype.checkPatternParam=function(e,t){switch(t.type){case o.Syntax.Identifier:this.validateParam(e,t,t.name);break;case o.Syntax.RestElement:this.checkPatternParam(e,t.argument);break;case o.Syntax.AssignmentPattern:this.checkPatternParam(e,t.left);break;case o.Syntax.ArrayPattern:for(var r=0;r")){this.context.isAssignmentTarget=false;this.context.isBindingElement=false;var n=e.async;var s=this.reinterpretAsCoverFormalsList(e);if(s){if(this.hasLineTerminator){this.tolerateUnexpectedToken(this.lookahead)}this.context.firstCoverInitializedNameError=null;var l=this.context.strict;var c=this.context.allowStrictDirective;this.context.allowStrictDirective=s.simple;var h=this.context.allowYield;var p=this.context.await;this.context.allowYield=true;this.context.await=n;var v=this.startNode(t);this.expect("=>");var d=void 0;if(this.match("{")){var D=this.context.allowIn;this.context.allowIn=true;d=this.parseFunctionSourceElements();this.context.allowIn=D}else{d=this.isolateCoverGrammar(this.parseAssignmentExpression)}var m=d.type!==o.Syntax.BlockStatement;if(this.context.strict&&s.firstRestricted){this.throwUnexpectedToken(s.firstRestricted,s.message)}if(this.context.strict&&s.stricted){this.tolerateUnexpectedToken(s.stricted,s.message)}e=n?this.finalize(v,new u.AsyncArrowFunctionExpression(s.params,d,m)):this.finalize(v,new u.ArrowFunctionExpression(s.params,d,m));this.context.strict=l;this.context.allowStrictDirective=c;this.context.allowYield=h;this.context.await=p}}else{if(this.matchAssign()){if(!this.context.isAssignmentTarget){this.tolerateError(a.Messages.InvalidLHSInAssignment)}if(this.context.strict&&e.type===o.Syntax.Identifier){var g=e;if(this.scanner.isRestrictedWord(g.name)){this.tolerateUnexpectedToken(r,a.Messages.StrictLHSAssignment)}if(this.scanner.isStrictModeReservedWord(g.name)){this.tolerateUnexpectedToken(r,a.Messages.StrictReservedWord)}}if(!this.match("=")){this.context.isAssignmentTarget=false;this.context.isBindingElement=false}else{this.reinterpretExpressionAsPattern(e)}r=this.nextToken();var E=r.value;var A=this.isolateCoverGrammar(this.parseAssignmentExpression);e=this.finalize(this.startNode(t),new u.AssignmentExpression(E,e,A));this.context.firstCoverInitializedNameError=null}}}return e};Parser.prototype.parseExpression=function(){var e=this.lookahead;var t=this.isolateCoverGrammar(this.parseAssignmentExpression);if(this.match(",")){var r=[];r.push(t);while(this.lookahead.type!==2){if(!this.match(",")){break}this.nextToken();r.push(this.isolateCoverGrammar(this.parseAssignmentExpression))}t=this.finalize(this.startNode(e),new u.SequenceExpression(r))}return t};Parser.prototype.parseStatementListItem=function(){var e;this.context.isAssignmentTarget=true;this.context.isBindingElement=true;if(this.lookahead.type===4){switch(this.lookahead.value){case"export":if(!this.context.isModule){this.tolerateUnexpectedToken(this.lookahead,a.Messages.IllegalExportDeclaration)}e=this.parseExportDeclaration();break;case"import":if(!this.context.isModule){this.tolerateUnexpectedToken(this.lookahead,a.Messages.IllegalImportDeclaration)}e=this.parseImportDeclaration();break;case"const":e=this.parseLexicalDeclaration({inFor:false});break;case"function":e=this.parseFunctionDeclaration();break;case"class":e=this.parseClassDeclaration();break;case"let":e=this.isLexicalDeclaration()?this.parseLexicalDeclaration({inFor:false}):this.parseStatement();break;default:e=this.parseStatement();break}}else{e=this.parseStatement()}return e};Parser.prototype.parseBlock=function(){var e=this.createNode();this.expect("{");var t=[];while(true){if(this.match("}")){break}t.push(this.parseStatementListItem())}this.expect("}");return this.finalize(e,new u.BlockStatement(t))};Parser.prototype.parseLexicalBinding=function(e,t){var r=this.createNode();var i=[];var n=this.parsePattern(i,e);if(this.context.strict&&n.type===o.Syntax.Identifier){if(this.scanner.isRestrictedWord(n.name)){this.tolerateError(a.Messages.StrictVarName)}}var s=null;if(e==="const"){if(!this.matchKeyword("in")&&!this.matchContextualKeyword("of")){if(this.match("=")){this.nextToken();s=this.isolateCoverGrammar(this.parseAssignmentExpression)}else{this.throwError(a.Messages.DeclarationMissingInitializer,"const")}}}else if(!t.inFor&&n.type!==o.Syntax.Identifier||this.match("=")){this.expect("=");s=this.isolateCoverGrammar(this.parseAssignmentExpression)}return this.finalize(r,new u.VariableDeclarator(n,s))};Parser.prototype.parseBindingList=function(e,t){var r=[this.parseLexicalBinding(e,t)];while(this.match(",")){this.nextToken();r.push(this.parseLexicalBinding(e,t))}return r};Parser.prototype.isLexicalDeclaration=function(){var e=this.scanner.saveState();this.scanner.scanComments();var t=this.scanner.lex();this.scanner.restoreState(e);return t.type===3||t.type===7&&t.value==="["||t.type===7&&t.value==="{"||t.type===4&&t.value==="let"||t.type===4&&t.value==="yield"};Parser.prototype.parseLexicalDeclaration=function(e){var t=this.createNode();var r=this.nextToken().value;i.assert(r==="let"||r==="const","Lexical declaration must be either let or const");var n=this.parseBindingList(r,e);this.consumeSemicolon();return this.finalize(t,new u.VariableDeclaration(n,r))};Parser.prototype.parseBindingRestElement=function(e,t){var r=this.createNode();this.expect("...");var i=this.parsePattern(e,t);return this.finalize(r,new u.RestElement(i))};Parser.prototype.parseArrayPattern=function(e,t){var r=this.createNode();this.expect("[");var i=[];while(!this.match("]")){if(this.match(",")){this.nextToken();i.push(null)}else{if(this.match("...")){i.push(this.parseBindingRestElement(e,t));break}else{i.push(this.parsePatternWithDefault(e,t))}if(!this.match("]")){this.expect(",")}}}this.expect("]");return this.finalize(r,new u.ArrayPattern(i))};Parser.prototype.parsePropertyPattern=function(e,t){var r=this.createNode();var i=false;var n=false;var a=false;var s;var o;if(this.lookahead.type===3){var l=this.lookahead;s=this.parseVariableIdentifier();var f=this.finalize(r,new u.Identifier(l.value));if(this.match("=")){e.push(l);n=true;this.nextToken();var c=this.parseAssignmentExpression();o=this.finalize(this.startNode(l),new u.AssignmentPattern(f,c))}else if(!this.match(":")){e.push(l);n=true;o=f}else{this.expect(":");o=this.parsePatternWithDefault(e,t)}}else{i=this.match("[");s=this.parseObjectPropertyKey();this.expect(":");o=this.parsePatternWithDefault(e,t)}return this.finalize(r,new u.Property("init",s,i,o,a,n))};Parser.prototype.parseObjectPattern=function(e,t){var r=this.createNode();var i=[];this.expect("{");while(!this.match("}")){i.push(this.parsePropertyPattern(e,t));if(!this.match("}")){this.expect(",")}}this.expect("}");return this.finalize(r,new u.ObjectPattern(i))};Parser.prototype.parsePattern=function(e,t){var r;if(this.match("[")){r=this.parseArrayPattern(e,t)}else if(this.match("{")){r=this.parseObjectPattern(e,t)}else{if(this.matchKeyword("let")&&(t==="const"||t==="let")){this.tolerateUnexpectedToken(this.lookahead,a.Messages.LetInLexicalBinding)}e.push(this.lookahead);r=this.parseVariableIdentifier(t)}return r};Parser.prototype.parsePatternWithDefault=function(e,t){var r=this.lookahead;var i=this.parsePattern(e,t);if(this.match("=")){this.nextToken();var n=this.context.allowYield;this.context.allowYield=true;var a=this.isolateCoverGrammar(this.parseAssignmentExpression);this.context.allowYield=n;i=this.finalize(this.startNode(r),new u.AssignmentPattern(i,a))}return i};Parser.prototype.parseVariableIdentifier=function(e){var t=this.createNode();var r=this.nextToken();if(r.type===4&&r.value==="yield"){if(this.context.strict){this.tolerateUnexpectedToken(r,a.Messages.StrictReservedWord)}else if(!this.context.allowYield){this.throwUnexpectedToken(r)}}else if(r.type!==3){if(this.context.strict&&r.type===4&&this.scanner.isStrictModeReservedWord(r.value)){this.tolerateUnexpectedToken(r,a.Messages.StrictReservedWord)}else{if(this.context.strict||r.value!=="let"||e!=="var"){this.throwUnexpectedToken(r)}}}else if((this.context.isModule||this.context.await)&&r.type===3&&r.value==="await"){this.tolerateUnexpectedToken(r)}return this.finalize(t,new u.Identifier(r.value))};Parser.prototype.parseVariableDeclaration=function(e){var t=this.createNode();var r=[];var i=this.parsePattern(r,"var");if(this.context.strict&&i.type===o.Syntax.Identifier){if(this.scanner.isRestrictedWord(i.name)){this.tolerateError(a.Messages.StrictVarName)}}var n=null;if(this.match("=")){this.nextToken();n=this.isolateCoverGrammar(this.parseAssignmentExpression)}else if(i.type!==o.Syntax.Identifier&&!e.inFor){this.expect("=")}return this.finalize(t,new u.VariableDeclarator(i,n))};Parser.prototype.parseVariableDeclarationList=function(e){var t={inFor:e.inFor};var r=[];r.push(this.parseVariableDeclaration(t));while(this.match(",")){this.nextToken();r.push(this.parseVariableDeclaration(t))}return r};Parser.prototype.parseVariableStatement=function(){var e=this.createNode();this.expectKeyword("var");var t=this.parseVariableDeclarationList({inFor:false});this.consumeSemicolon();return this.finalize(e,new u.VariableDeclaration(t,"var"))};Parser.prototype.parseEmptyStatement=function(){var e=this.createNode();this.expect(";");return this.finalize(e,new u.EmptyStatement)};Parser.prototype.parseExpressionStatement=function(){var e=this.createNode();var t=this.parseExpression();this.consumeSemicolon();return this.finalize(e,new u.ExpressionStatement(t))};Parser.prototype.parseIfClause=function(){if(this.context.strict&&this.matchKeyword("function")){this.tolerateError(a.Messages.StrictFunction)}return this.parseStatement()};Parser.prototype.parseIfStatement=function(){var e=this.createNode();var t;var r=null;this.expectKeyword("if");this.expect("(");var i=this.parseExpression();if(!this.match(")")&&this.config.tolerant){this.tolerateUnexpectedToken(this.nextToken());t=this.finalize(this.createNode(),new u.EmptyStatement)}else{this.expect(")");t=this.parseIfClause();if(this.matchKeyword("else")){this.nextToken();r=this.parseIfClause()}}return this.finalize(e,new u.IfStatement(i,t,r))};Parser.prototype.parseDoWhileStatement=function(){var e=this.createNode();this.expectKeyword("do");var t=this.context.inIteration;this.context.inIteration=true;var r=this.parseStatement();this.context.inIteration=t;this.expectKeyword("while");this.expect("(");var i=this.parseExpression();if(!this.match(")")&&this.config.tolerant){this.tolerateUnexpectedToken(this.nextToken())}else{this.expect(")");if(this.match(";")){this.nextToken()}}return this.finalize(e,new u.DoWhileStatement(r,i))};Parser.prototype.parseWhileStatement=function(){var e=this.createNode();var t;this.expectKeyword("while");this.expect("(");var r=this.parseExpression();if(!this.match(")")&&this.config.tolerant){this.tolerateUnexpectedToken(this.nextToken());t=this.finalize(this.createNode(),new u.EmptyStatement)}else{this.expect(")");var i=this.context.inIteration;this.context.inIteration=true;t=this.parseStatement();this.context.inIteration=i}return this.finalize(e,new u.WhileStatement(r,t))};Parser.prototype.parseForStatement=function(){var e=null;var t=null;var r=null;var i=true;var n,s;var l=this.createNode();this.expectKeyword("for");this.expect("(");if(this.match(";")){this.nextToken()}else{if(this.matchKeyword("var")){e=this.createNode();this.nextToken();var f=this.context.allowIn;this.context.allowIn=false;var c=this.parseVariableDeclarationList({inFor:true});this.context.allowIn=f;if(c.length===1&&this.matchKeyword("in")){var h=c[0];if(h.init&&(h.id.type===o.Syntax.ArrayPattern||h.id.type===o.Syntax.ObjectPattern||this.context.strict)){this.tolerateError(a.Messages.ForInOfLoopInitializer,"for-in")}e=this.finalize(e,new u.VariableDeclaration(c,"var"));this.nextToken();n=e;s=this.parseExpression();e=null}else if(c.length===1&&c[0].init===null&&this.matchContextualKeyword("of")){e=this.finalize(e,new u.VariableDeclaration(c,"var"));this.nextToken();n=e;s=this.parseAssignmentExpression();e=null;i=false}else{e=this.finalize(e,new u.VariableDeclaration(c,"var"));this.expect(";")}}else if(this.matchKeyword("const")||this.matchKeyword("let")){e=this.createNode();var p=this.nextToken().value;if(!this.context.strict&&this.lookahead.value==="in"){e=this.finalize(e,new u.Identifier(p));this.nextToken();n=e;s=this.parseExpression();e=null}else{var f=this.context.allowIn;this.context.allowIn=false;var c=this.parseBindingList(p,{inFor:true});this.context.allowIn=f;if(c.length===1&&c[0].init===null&&this.matchKeyword("in")){e=this.finalize(e,new u.VariableDeclaration(c,p));this.nextToken();n=e;s=this.parseExpression();e=null}else if(c.length===1&&c[0].init===null&&this.matchContextualKeyword("of")){e=this.finalize(e,new u.VariableDeclaration(c,p));this.nextToken();n=e;s=this.parseAssignmentExpression();e=null;i=false}else{this.consumeSemicolon();e=this.finalize(e,new u.VariableDeclaration(c,p))}}}else{var v=this.lookahead;var f=this.context.allowIn;this.context.allowIn=false;e=this.inheritCoverGrammar(this.parseAssignmentExpression);this.context.allowIn=f;if(this.matchKeyword("in")){if(!this.context.isAssignmentTarget||e.type===o.Syntax.AssignmentExpression){this.tolerateError(a.Messages.InvalidLHSInForIn)}this.nextToken();this.reinterpretExpressionAsPattern(e);n=e;s=this.parseExpression();e=null}else if(this.matchContextualKeyword("of")){if(!this.context.isAssignmentTarget||e.type===o.Syntax.AssignmentExpression){this.tolerateError(a.Messages.InvalidLHSInForLoop)}this.nextToken();this.reinterpretExpressionAsPattern(e);n=e;s=this.parseAssignmentExpression();e=null;i=false}else{if(this.match(",")){var d=[e];while(this.match(",")){this.nextToken();d.push(this.isolateCoverGrammar(this.parseAssignmentExpression))}e=this.finalize(this.startNode(v),new u.SequenceExpression(d))}this.expect(";")}}}if(typeof n==="undefined"){if(!this.match(";")){t=this.parseExpression()}this.expect(";");if(!this.match(")")){r=this.parseExpression()}}var D;if(!this.match(")")&&this.config.tolerant){this.tolerateUnexpectedToken(this.nextToken());D=this.finalize(this.createNode(),new u.EmptyStatement)}else{this.expect(")");var m=this.context.inIteration;this.context.inIteration=true;D=this.isolateCoverGrammar(this.parseStatement);this.context.inIteration=m}return typeof n==="undefined"?this.finalize(l,new u.ForStatement(e,t,r,D)):i?this.finalize(l,new u.ForInStatement(n,s,D)):this.finalize(l,new u.ForOfStatement(n,s,D))};Parser.prototype.parseContinueStatement=function(){var e=this.createNode();this.expectKeyword("continue");var t=null;if(this.lookahead.type===3&&!this.hasLineTerminator){var r=this.parseVariableIdentifier();t=r;var i="$"+r.name;if(!Object.prototype.hasOwnProperty.call(this.context.labelSet,i)){this.throwError(a.Messages.UnknownLabel,r.name)}}this.consumeSemicolon();if(t===null&&!this.context.inIteration){this.throwError(a.Messages.IllegalContinue)}return this.finalize(e,new u.ContinueStatement(t))};Parser.prototype.parseBreakStatement=function(){var e=this.createNode();this.expectKeyword("break");var t=null;if(this.lookahead.type===3&&!this.hasLineTerminator){var r=this.parseVariableIdentifier();var i="$"+r.name;if(!Object.prototype.hasOwnProperty.call(this.context.labelSet,i)){this.throwError(a.Messages.UnknownLabel,r.name)}t=r}this.consumeSemicolon();if(t===null&&!this.context.inIteration&&!this.context.inSwitch){this.throwError(a.Messages.IllegalBreak)}return this.finalize(e,new u.BreakStatement(t))};Parser.prototype.parseReturnStatement=function(){if(!this.context.inFunctionBody){this.tolerateError(a.Messages.IllegalReturn)}var e=this.createNode();this.expectKeyword("return");var t=!this.match(";")&&!this.match("}")&&!this.hasLineTerminator&&this.lookahead.type!==2||this.lookahead.type===8||this.lookahead.type===10;var r=t?this.parseExpression():null;this.consumeSemicolon();return this.finalize(e,new u.ReturnStatement(r))};Parser.prototype.parseWithStatement=function(){if(this.context.strict){this.tolerateError(a.Messages.StrictModeWith)}var e=this.createNode();var t;this.expectKeyword("with");this.expect("(");var r=this.parseExpression();if(!this.match(")")&&this.config.tolerant){this.tolerateUnexpectedToken(this.nextToken());t=this.finalize(this.createNode(),new u.EmptyStatement)}else{this.expect(")");t=this.parseStatement()}return this.finalize(e,new u.WithStatement(r,t))};Parser.prototype.parseSwitchCase=function(){var e=this.createNode();var t;if(this.matchKeyword("default")){this.nextToken();t=null}else{this.expectKeyword("case");t=this.parseExpression()}this.expect(":");var r=[];while(true){if(this.match("}")||this.matchKeyword("default")||this.matchKeyword("case")){break}r.push(this.parseStatementListItem())}return this.finalize(e,new u.SwitchCase(t,r))};Parser.prototype.parseSwitchStatement=function(){var e=this.createNode();this.expectKeyword("switch");this.expect("(");var t=this.parseExpression();this.expect(")");var r=this.context.inSwitch;this.context.inSwitch=true;var i=[];var n=false;this.expect("{");while(true){if(this.match("}")){break}var s=this.parseSwitchCase();if(s.test===null){if(n){this.throwError(a.Messages.MultipleDefaultsInSwitch)}n=true}i.push(s)}this.expect("}");this.context.inSwitch=r;return this.finalize(e,new u.SwitchStatement(t,i))};Parser.prototype.parseLabelledStatement=function(){var e=this.createNode();var t=this.parseExpression();var r;if(t.type===o.Syntax.Identifier&&this.match(":")){this.nextToken();var i=t;var n="$"+i.name;if(Object.prototype.hasOwnProperty.call(this.context.labelSet,n)){this.throwError(a.Messages.Redeclaration,"Label",i.name)}this.context.labelSet[n]=true;var s=void 0;if(this.matchKeyword("class")){this.tolerateUnexpectedToken(this.lookahead);s=this.parseClassDeclaration()}else if(this.matchKeyword("function")){var l=this.lookahead;var f=this.parseFunctionDeclaration();if(this.context.strict){this.tolerateUnexpectedToken(l,a.Messages.StrictFunction)}else if(f.generator){this.tolerateUnexpectedToken(l,a.Messages.GeneratorInLegacyContext)}s=f}else{s=this.parseStatement()}delete this.context.labelSet[n];r=new u.LabeledStatement(i,s)}else{this.consumeSemicolon();r=new u.ExpressionStatement(t)}return this.finalize(e,r)};Parser.prototype.parseThrowStatement=function(){var e=this.createNode();this.expectKeyword("throw");if(this.hasLineTerminator){this.throwError(a.Messages.NewlineAfterThrow)}var t=this.parseExpression();this.consumeSemicolon();return this.finalize(e,new u.ThrowStatement(t))};Parser.prototype.parseCatchClause=function(){var e=this.createNode();this.expectKeyword("catch");this.expect("(");if(this.match(")")){this.throwUnexpectedToken(this.lookahead)}var t=[];var r=this.parsePattern(t);var i={};for(var n=0;n0){this.tolerateError(a.Messages.BadGetterArity)}var n=this.parsePropertyMethod(i);this.context.allowYield=r;return this.finalize(e,new u.FunctionExpression(null,i.params,n,t))};Parser.prototype.parseSetterMethod=function(){var e=this.createNode();var t=false;var r=this.context.allowYield;this.context.allowYield=!t;var i=this.parseFormalParameters();if(i.params.length!==1){this.tolerateError(a.Messages.BadSetterArity)}else if(i.params[0]instanceof u.RestElement){this.tolerateError(a.Messages.BadSetterRestParameter)}var n=this.parsePropertyMethod(i);this.context.allowYield=r;return this.finalize(e,new u.FunctionExpression(null,i.params,n,t))};Parser.prototype.parseGeneratorMethod=function(){var e=this.createNode();var t=true;var r=this.context.allowYield;this.context.allowYield=true;var i=this.parseFormalParameters();this.context.allowYield=false;var n=this.parsePropertyMethod(i);this.context.allowYield=r;return this.finalize(e,new u.FunctionExpression(null,i.params,n,t))};Parser.prototype.isStartOfExpression=function(){var e=true;var t=this.lookahead.value;switch(this.lookahead.type){case 7:e=t==="["||t==="("||t==="{"||t==="+"||t==="-"||t==="!"||t==="~"||t==="++"||t==="--"||t==="/"||t==="/=";break;case 4:e=t==="class"||t==="delete"||t==="function"||t==="let"||t==="new"||t==="super"||t==="this"||t==="typeof"||t==="void"||t==="yield";break;default:break}return e};Parser.prototype.parseYieldExpression=function(){var e=this.createNode();this.expectKeyword("yield");var t=null;var r=false;if(!this.hasLineTerminator){var i=this.context.allowYield;this.context.allowYield=false;r=this.match("*");if(r){this.nextToken();t=this.parseAssignmentExpression()}else if(this.isStartOfExpression()){t=this.parseAssignmentExpression()}this.context.allowYield=i}return this.finalize(e,new u.YieldExpression(t,r))};Parser.prototype.parseClassElement=function(e){var t=this.lookahead;var r=this.createNode();var i="";var n=null;var s=null;var o=false;var l=false;var f=false;var c=false;if(this.match("*")){this.nextToken()}else{o=this.match("[");n=this.parseObjectPropertyKey();var h=n;if(h.name==="static"&&(this.qualifiedPropertyName(this.lookahead)||this.match("*"))){t=this.lookahead;f=true;o=this.match("[");if(this.match("*")){this.nextToken()}else{n=this.parseObjectPropertyKey()}}if(t.type===3&&!this.hasLineTerminator&&t.value==="async"){var p=this.lookahead.value;if(p!==":"&&p!=="("&&p!=="*"){c=true;t=this.lookahead;n=this.parseObjectPropertyKey();if(t.type===3&&t.value==="constructor"){this.tolerateUnexpectedToken(t,a.Messages.ConstructorIsAsync)}}}}var v=this.qualifiedPropertyName(this.lookahead);if(t.type===3){if(t.value==="get"&&v){i="get";o=this.match("[");n=this.parseObjectPropertyKey();this.context.allowYield=false;s=this.parseGetterMethod()}else if(t.value==="set"&&v){i="set";o=this.match("[");n=this.parseObjectPropertyKey();s=this.parseSetterMethod()}}else if(t.type===7&&t.value==="*"&&v){i="init";o=this.match("[");n=this.parseObjectPropertyKey();s=this.parseGeneratorMethod();l=true}if(!i&&n&&this.match("(")){i="init";s=c?this.parsePropertyMethodAsyncFunction():this.parsePropertyMethodFunction();l=true}if(!i){this.throwUnexpectedToken(this.lookahead)}if(i==="init"){i="method"}if(!o){if(f&&this.isPropertyKey(n,"prototype")){this.throwUnexpectedToken(t,a.Messages.StaticPrototype)}if(!f&&this.isPropertyKey(n,"constructor")){if(i!=="method"||!l||s&&s.generator){this.throwUnexpectedToken(t,a.Messages.ConstructorSpecialMethod)}if(e.value){this.throwUnexpectedToken(t,a.Messages.DuplicateConstructor)}else{e.value=true}i="constructor"}}return this.finalize(r,new u.MethodDefinition(n,o,s,i,f))};Parser.prototype.parseClassElementList=function(){var e=[];var t={value:false};this.expect("{");while(!this.match("}")){if(this.match(";")){this.nextToken()}else{e.push(this.parseClassElement(t))}}this.expect("}");return e};Parser.prototype.parseClassBody=function(){var e=this.createNode();var t=this.parseClassElementList();return this.finalize(e,new u.ClassBody(t))};Parser.prototype.parseClassDeclaration=function(e){var t=this.createNode();var r=this.context.strict;this.context.strict=true;this.expectKeyword("class");var i=e&&this.lookahead.type!==3?null:this.parseVariableIdentifier();var n=null;if(this.matchKeyword("extends")){this.nextToken();n=this.isolateCoverGrammar(this.parseLeftHandSideExpressionAllowCall)}var a=this.parseClassBody();this.context.strict=r;return this.finalize(t,new u.ClassDeclaration(i,n,a))};Parser.prototype.parseClassExpression=function(){var e=this.createNode();var t=this.context.strict;this.context.strict=true;this.expectKeyword("class");var r=this.lookahead.type===3?this.parseVariableIdentifier():null;var i=null;if(this.matchKeyword("extends")){this.nextToken();i=this.isolateCoverGrammar(this.parseLeftHandSideExpressionAllowCall)}var n=this.parseClassBody();this.context.strict=t;return this.finalize(e,new u.ClassExpression(r,i,n))};Parser.prototype.parseModule=function(){this.context.strict=true;this.context.isModule=true;this.scanner.isModule=true;var e=this.createNode();var t=this.parseDirectivePrologues();while(this.lookahead.type!==2){t.push(this.parseStatementListItem())}return this.finalize(e,new u.Module(t))};Parser.prototype.parseScript=function(){var e=this.createNode();var t=this.parseDirectivePrologues();while(this.lookahead.type!==2){t.push(this.parseStatementListItem())}return this.finalize(e,new u.Script(t))};Parser.prototype.parseModuleSpecifier=function(){var e=this.createNode();if(this.lookahead.type!==8){this.throwError(a.Messages.InvalidModuleSpecifier)}var t=this.nextToken();var r=this.getTokenRaw(t);return this.finalize(e,new u.Literal(t.value,r))};Parser.prototype.parseImportSpecifier=function(){var e=this.createNode();var t;var r;if(this.lookahead.type===3){t=this.parseVariableIdentifier();r=t;if(this.matchContextualKeyword("as")){this.nextToken();r=this.parseVariableIdentifier()}}else{t=this.parseIdentifierName();r=t;if(this.matchContextualKeyword("as")){this.nextToken();r=this.parseVariableIdentifier()}else{this.throwUnexpectedToken(this.nextToken())}}return this.finalize(e,new u.ImportSpecifier(r,t))};Parser.prototype.parseNamedImports=function(){this.expect("{");var e=[];while(!this.match("}")){e.push(this.parseImportSpecifier());if(!this.match("}")){this.expect(",")}}this.expect("}");return e};Parser.prototype.parseImportDefaultSpecifier=function(){var e=this.createNode();var t=this.parseIdentifierName();return this.finalize(e,new u.ImportDefaultSpecifier(t))};Parser.prototype.parseImportNamespaceSpecifier=function(){var e=this.createNode();this.expect("*");if(!this.matchContextualKeyword("as")){this.throwError(a.Messages.NoAsAfterImportNamespace)}this.nextToken();var t=this.parseIdentifierName();return this.finalize(e,new u.ImportNamespaceSpecifier(t))};Parser.prototype.parseImportDeclaration=function(){if(this.context.inFunctionBody){this.throwError(a.Messages.IllegalImportDeclaration)}var e=this.createNode();this.expectKeyword("import");var t;var r=[];if(this.lookahead.type===8){t=this.parseModuleSpecifier()}else{if(this.match("{")){r=r.concat(this.parseNamedImports())}else if(this.match("*")){r.push(this.parseImportNamespaceSpecifier())}else if(this.isIdentifierName(this.lookahead)&&!this.matchKeyword("default")){r.push(this.parseImportDefaultSpecifier());if(this.match(",")){this.nextToken();if(this.match("*")){r.push(this.parseImportNamespaceSpecifier())}else if(this.match("{")){r=r.concat(this.parseNamedImports())}else{this.throwUnexpectedToken(this.lookahead)}}}else{this.throwUnexpectedToken(this.nextToken())}if(!this.matchContextualKeyword("from")){var i=this.lookahead.value?a.Messages.UnexpectedToken:a.Messages.MissingFromClause;this.throwError(i,this.lookahead.value)}this.nextToken();t=this.parseModuleSpecifier()}this.consumeSemicolon();return this.finalize(e,new u.ImportDeclaration(r,t))};Parser.prototype.parseExportSpecifier=function(){var e=this.createNode();var t=this.parseIdentifierName();var r=t;if(this.matchContextualKeyword("as")){this.nextToken();r=this.parseIdentifierName()}return this.finalize(e,new u.ExportSpecifier(t,r))};Parser.prototype.parseExportDeclaration=function(){if(this.context.inFunctionBody){this.throwError(a.Messages.IllegalExportDeclaration)}var e=this.createNode();this.expectKeyword("export");var t;if(this.matchKeyword("default")){this.nextToken();if(this.matchKeyword("function")){var r=this.parseFunctionDeclaration(true);t=this.finalize(e,new u.ExportDefaultDeclaration(r))}else if(this.matchKeyword("class")){var r=this.parseClassDeclaration(true);t=this.finalize(e,new u.ExportDefaultDeclaration(r))}else if(this.matchContextualKeyword("async")){var r=this.matchAsyncFunction()?this.parseFunctionDeclaration(true):this.parseAssignmentExpression();t=this.finalize(e,new u.ExportDefaultDeclaration(r))}else{if(this.matchContextualKeyword("from")){this.throwError(a.Messages.UnexpectedToken,this.lookahead.value)}var r=this.match("{")?this.parseObjectInitializer():this.match("[")?this.parseArrayInitializer():this.parseAssignmentExpression();this.consumeSemicolon();t=this.finalize(e,new u.ExportDefaultDeclaration(r))}}else if(this.match("*")){this.nextToken();if(!this.matchContextualKeyword("from")){var i=this.lookahead.value?a.Messages.UnexpectedToken:a.Messages.MissingFromClause;this.throwError(i,this.lookahead.value)}this.nextToken();var n=this.parseModuleSpecifier();this.consumeSemicolon();t=this.finalize(e,new u.ExportAllDeclaration(n))}else if(this.lookahead.type===4){var r=void 0;switch(this.lookahead.value){case"let":case"const":r=this.parseLexicalDeclaration({inFor:false});break;case"var":case"class":case"function":r=this.parseStatementListItem();break;default:this.throwUnexpectedToken(this.lookahead)}t=this.finalize(e,new u.ExportNamedDeclaration(r,[],null))}else if(this.matchAsyncFunction()){var r=this.parseFunctionDeclaration();t=this.finalize(e,new u.ExportNamedDeclaration(r,[],null))}else{var s=[];var o=null;var l=false;this.expect("{");while(!this.match("}")){l=l||this.matchKeyword("default");s.push(this.parseExportSpecifier());if(!this.match("}")){this.expect(",")}}this.expect("}");if(this.matchContextualKeyword("from")){this.nextToken();o=this.parseModuleSpecifier();this.consumeSemicolon()}else if(l){var i=this.lookahead.value?a.Messages.UnexpectedToken:a.Messages.MissingFromClause;this.throwError(i,this.lookahead.value)}else{this.consumeSemicolon()}t=this.finalize(e,new u.ExportNamedDeclaration(null,s,o))}return t};return Parser}();t.Parser=c},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});function assert(e,t){if(!e){throw new Error("ASSERT: "+t)}}t.assert=assert},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=function(){function ErrorHandler(){this.errors=[];this.tolerant=false}ErrorHandler.prototype.recordError=function(e){this.errors.push(e)};ErrorHandler.prototype.tolerate=function(e){if(this.tolerant){this.recordError(e)}else{throw e}};ErrorHandler.prototype.constructError=function(e,t){var r=new Error(e);try{throw r}catch(e){if(Object.create&&Object.defineProperty){r=Object.create(e);Object.defineProperty(r,"column",{value:t})}}return r};ErrorHandler.prototype.createError=function(e,t,r,i){var n="Line "+t+": "+i;var a=this.constructError(n,r);a.index=e;a.lineNumber=t;a.description=i;return a};ErrorHandler.prototype.throwError=function(e,t,r,i){throw this.createError(e,t,r,i)};ErrorHandler.prototype.tolerateError=function(e,t,r,i){var n=this.createError(e,t,r,i);if(this.tolerant){this.recordError(n)}else{throw n}};return ErrorHandler}();t.ErrorHandler=r},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.Messages={BadGetterArity:"Getter must not have any formal parameters",BadSetterArity:"Setter must have exactly one formal parameter",BadSetterRestParameter:"Setter function argument must not be a rest parameter",ConstructorIsAsync:"Class constructor may not be an async method",ConstructorSpecialMethod:"Class constructor may not be an accessor",DeclarationMissingInitializer:"Missing initializer in %0 declaration",DefaultRestParameter:"Unexpected token =",DuplicateBinding:"Duplicate binding %0",DuplicateConstructor:"A class may only have one constructor",DuplicateProtoProperty:"Duplicate __proto__ fields are not allowed in object literals",ForInOfLoopInitializer:"%0 loop variable declaration may not have an initializer",GeneratorInLegacyContext:"Generator declarations are not allowed in legacy contexts",IllegalBreak:"Illegal break statement",IllegalContinue:"Illegal continue statement",IllegalExportDeclaration:"Unexpected token",IllegalImportDeclaration:"Unexpected token",IllegalLanguageModeDirective:"Illegal 'use strict' directive in function with non-simple parameter list",IllegalReturn:"Illegal return statement",InvalidEscapedReservedWord:"Keyword must not contain escaped characters",InvalidHexEscapeSequence:"Invalid hexadecimal escape sequence",InvalidLHSInAssignment:"Invalid left-hand side in assignment",InvalidLHSInForIn:"Invalid left-hand side in for-in",InvalidLHSInForLoop:"Invalid left-hand side in for-loop",InvalidModuleSpecifier:"Unexpected token",InvalidRegExp:"Invalid regular expression",LetInLexicalBinding:"let is disallowed as a lexically bound name",MissingFromClause:"Unexpected token",MultipleDefaultsInSwitch:"More than one default clause in switch statement",NewlineAfterThrow:"Illegal newline after throw",NoAsAfterImportNamespace:"Unexpected token",NoCatchOrFinally:"Missing catch or finally after try",ParameterAfterRestParameter:"Rest parameter must be last formal parameter",Redeclaration:"%0 '%1' has already been declared",StaticPrototype:"Classes may not have static property named prototype",StrictCatchVariable:"Catch variable may not be eval or arguments in strict mode",StrictDelete:"Delete of an unqualified identifier in strict mode.",StrictFunction:"In strict mode code, functions can only be declared at top level or inside a block",StrictFunctionName:"Function name may not be eval or arguments in strict mode",StrictLHSAssignment:"Assignment to eval or arguments is not allowed in strict mode",StrictLHSPostfix:"Postfix increment/decrement may not have eval or arguments operand in strict mode",StrictLHSPrefix:"Prefix increment/decrement may not have eval or arguments operand in strict mode",StrictModeWith:"Strict mode code may not include a with statement",StrictOctalLiteral:"Octal literals are not allowed in strict mode.",StrictParamDupe:"Strict mode function may not have duplicate parameter names",StrictParamName:"Parameter name eval or arguments is not allowed in strict mode",StrictReservedWord:"Use of future reserved word in strict mode",StrictVarName:"Variable name may not be eval or arguments in strict mode",TemplateOctalLiteral:"Octal literals are not allowed in template strings.",UnexpectedEOS:"Unexpected end of input",UnexpectedIdentifier:"Unexpected identifier",UnexpectedNumber:"Unexpected number",UnexpectedReserved:"Unexpected reserved word",UnexpectedString:"Unexpected string",UnexpectedTemplate:"Unexpected quasi %0",UnexpectedToken:"Unexpected token %0",UnexpectedTokenIllegal:"Unexpected token ILLEGAL",UnknownLabel:"Undefined label '%0'",UnterminatedRegExp:"Invalid regular expression: missing /"}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:true});var i=r(9);var n=r(4);var a=r(11);function hexValue(e){return"0123456789abcdef".indexOf(e.toLowerCase())}function octalValue(e){return"01234567".indexOf(e)}var u=function(){function Scanner(e,t){this.source=e;this.errorHandler=t;this.trackComment=false;this.isModule=false;this.length=e.length;this.index=0;this.lineNumber=e.length>0?1:0;this.lineStart=0;this.curlyStack=[]}Scanner.prototype.saveState=function(){return{index:this.index,lineNumber:this.lineNumber,lineStart:this.lineStart}};Scanner.prototype.restoreState=function(e){this.index=e.index;this.lineNumber=e.lineNumber;this.lineStart=e.lineStart};Scanner.prototype.eof=function(){return this.index>=this.length};Scanner.prototype.throwUnexpectedToken=function(e){if(e===void 0){e=a.Messages.UnexpectedTokenIllegal}return this.errorHandler.throwError(this.index,this.lineNumber,this.index-this.lineStart+1,e)};Scanner.prototype.tolerateUnexpectedToken=function(e){if(e===void 0){e=a.Messages.UnexpectedTokenIllegal}this.errorHandler.tolerateError(this.index,this.lineNumber,this.index-this.lineStart+1,e)};Scanner.prototype.skipSingleLineComment=function(e){var t=[];var r,i;if(this.trackComment){t=[];r=this.index-e;i={start:{line:this.lineNumber,column:this.index-this.lineStart-e},end:{}}}while(!this.eof()){var a=this.source.charCodeAt(this.index);++this.index;if(n.Character.isLineTerminator(a)){if(this.trackComment){i.end={line:this.lineNumber,column:this.index-this.lineStart-1};var u={multiLine:false,slice:[r+e,this.index-1],range:[r,this.index-1],loc:i};t.push(u)}if(a===13&&this.source.charCodeAt(this.index)===10){++this.index}++this.lineNumber;this.lineStart=this.index;return t}}if(this.trackComment){i.end={line:this.lineNumber,column:this.index-this.lineStart};var u={multiLine:false,slice:[r+e,this.index],range:[r,this.index],loc:i};t.push(u)}return t};Scanner.prototype.skipMultiLineComment=function(){var e=[];var t,r;if(this.trackComment){e=[];t=this.index-2;r={start:{line:this.lineNumber,column:this.index-this.lineStart-2},end:{}}}while(!this.eof()){var i=this.source.charCodeAt(this.index);if(n.Character.isLineTerminator(i)){if(i===13&&this.source.charCodeAt(this.index+1)===10){++this.index}++this.lineNumber;++this.index;this.lineStart=this.index}else if(i===42){if(this.source.charCodeAt(this.index+1)===47){this.index+=2;if(this.trackComment){r.end={line:this.lineNumber,column:this.index-this.lineStart};var a={multiLine:true,slice:[t+2,this.index-2],range:[t,this.index],loc:r};e.push(a)}return e}++this.index}else{++this.index}}if(this.trackComment){r.end={line:this.lineNumber,column:this.index-this.lineStart};var a={multiLine:true,slice:[t+2,this.index],range:[t,this.index],loc:r};e.push(a)}this.tolerateUnexpectedToken();return e};Scanner.prototype.scanComments=function(){var e;if(this.trackComment){e=[]}var t=this.index===0;while(!this.eof()){var r=this.source.charCodeAt(this.index);if(n.Character.isWhiteSpace(r)){++this.index}else if(n.Character.isLineTerminator(r)){++this.index;if(r===13&&this.source.charCodeAt(this.index)===10){++this.index}++this.lineNumber;this.lineStart=this.index;t=true}else if(r===47){r=this.source.charCodeAt(this.index+1);if(r===47){this.index+=2;var i=this.skipSingleLineComment(2);if(this.trackComment){e=e.concat(i)}t=true}else if(r===42){this.index+=2;var i=this.skipMultiLineComment();if(this.trackComment){e=e.concat(i)}}else{break}}else if(t&&r===45){if(this.source.charCodeAt(this.index+1)===45&&this.source.charCodeAt(this.index+2)===62){this.index+=3;var i=this.skipSingleLineComment(3);if(this.trackComment){e=e.concat(i)}}else{break}}else if(r===60&&!this.isModule){if(this.source.slice(this.index+1,this.index+4)==="!--"){this.index+=4;var i=this.skipSingleLineComment(4);if(this.trackComment){e=e.concat(i)}}else{break}}else{break}}return e};Scanner.prototype.isFutureReservedWord=function(e){switch(e){case"enum":case"export":case"import":case"super":return true;default:return false}};Scanner.prototype.isStrictModeReservedWord=function(e){switch(e){case"implements":case"interface":case"package":case"private":case"protected":case"public":case"static":case"yield":case"let":return true;default:return false}};Scanner.prototype.isRestrictedWord=function(e){return e==="eval"||e==="arguments"};Scanner.prototype.isKeyword=function(e){switch(e.length){case 2:return e==="if"||e==="in"||e==="do";case 3:return e==="var"||e==="for"||e==="new"||e==="try"||e==="let";case 4:return e==="this"||e==="else"||e==="case"||e==="void"||e==="with"||e==="enum";case 5:return e==="while"||e==="break"||e==="catch"||e==="throw"||e==="const"||e==="yield"||e==="class"||e==="super";case 6:return e==="return"||e==="typeof"||e==="delete"||e==="switch"||e==="export"||e==="import";case 7:return e==="default"||e==="finally"||e==="extends";case 8:return e==="function"||e==="continue"||e==="debugger";case 10:return e==="instanceof";default:return false}};Scanner.prototype.codePointAt=function(e){var t=this.source.charCodeAt(e);if(t>=55296&&t<=56319){var r=this.source.charCodeAt(e+1);if(r>=56320&&r<=57343){var i=t;t=(i-55296)*1024+r-56320+65536}}return t};Scanner.prototype.scanHexEscape=function(e){var t=e==="u"?4:2;var r=0;for(var i=0;i1114111||e!=="}"){this.throwUnexpectedToken()}return n.Character.fromCodePoint(t)};Scanner.prototype.getIdentifier=function(){var e=this.index++;while(!this.eof()){var t=this.source.charCodeAt(this.index);if(t===92){this.index=e;return this.getComplexIdentifier()}else if(t>=55296&&t<57343){this.index=e;return this.getComplexIdentifier()}if(n.Character.isIdentifierPart(t)){++this.index}else{break}}return this.source.slice(e,this.index)};Scanner.prototype.getComplexIdentifier=function(){var e=this.codePointAt(this.index);var t=n.Character.fromCodePoint(e);this.index+=t.length;var r;if(e===92){if(this.source.charCodeAt(this.index)!==117){this.throwUnexpectedToken()}++this.index;if(this.source[this.index]==="{"){++this.index;r=this.scanUnicodeCodePointEscape()}else{r=this.scanHexEscape("u");if(r===null||r==="\\"||!n.Character.isIdentifierStart(r.charCodeAt(0))){this.throwUnexpectedToken()}}t=r}while(!this.eof()){e=this.codePointAt(this.index);if(!n.Character.isIdentifierPart(e)){break}r=n.Character.fromCodePoint(e);t+=r;this.index+=r.length;if(e===92){t=t.substr(0,t.length-1);if(this.source.charCodeAt(this.index)!==117){this.throwUnexpectedToken()}++this.index;if(this.source[this.index]==="{"){++this.index;r=this.scanUnicodeCodePointEscape()}else{r=this.scanHexEscape("u");if(r===null||r==="\\"||!n.Character.isIdentifierPart(r.charCodeAt(0))){this.throwUnexpectedToken()}}t+=r}}return t};Scanner.prototype.octalToDecimal=function(e){var t=e!=="0";var r=octalValue(e);if(!this.eof()&&n.Character.isOctalDigit(this.source.charCodeAt(this.index))){t=true;r=r*8+octalValue(this.source[this.index++]);if("0123".indexOf(e)>=0&&!this.eof()&&n.Character.isOctalDigit(this.source.charCodeAt(this.index))){r=r*8+octalValue(this.source[this.index++])}}return{code:r,octal:t}};Scanner.prototype.scanIdentifier=function(){var e;var t=this.index;var r=this.source.charCodeAt(t)===92?this.getComplexIdentifier():this.getIdentifier();if(r.length===1){e=3}else if(this.isKeyword(r)){e=4}else if(r==="null"){e=5}else if(r==="true"||r==="false"){e=1}else{e=3}if(e!==3&&t+r.length!==this.index){var i=this.index;this.index=t;this.tolerateUnexpectedToken(a.Messages.InvalidEscapedReservedWord);this.index=i}return{type:e,value:r,lineNumber:this.lineNumber,lineStart:this.lineStart,start:t,end:this.index}};Scanner.prototype.scanPunctuator=function(){var e=this.index;var t=this.source[this.index];switch(t){case"(":case"{":if(t==="{"){this.curlyStack.push("{")}++this.index;break;case".":++this.index;if(this.source[this.index]==="."&&this.source[this.index+1]==="."){this.index+=2;t="..."}break;case"}":++this.index;this.curlyStack.pop();break;case")":case";":case",":case"[":case"]":case":":case"?":case"~":++this.index;break;default:t=this.source.substr(this.index,4);if(t===">>>="){this.index+=4}else{t=t.substr(0,3);if(t==="==="||t==="!=="||t===">>>"||t==="<<="||t===">>="||t==="**="){this.index+=3}else{t=t.substr(0,2);if(t==="&&"||t==="||"||t==="=="||t==="!="||t==="+="||t==="-="||t==="*="||t==="/="||t==="++"||t==="--"||t==="<<"||t===">>"||t==="&="||t==="|="||t==="^="||t==="%="||t==="<="||t===">="||t==="=>"||t==="**"){this.index+=2}else{t=this.source[this.index];if("<>=!+-*%&|^/".indexOf(t)>=0){++this.index}}}}}if(this.index===e){this.throwUnexpectedToken()}return{type:7,value:t,lineNumber:this.lineNumber,lineStart:this.lineStart,start:e,end:this.index}};Scanner.prototype.scanHexLiteral=function(e){var t="";while(!this.eof()){if(!n.Character.isHexDigit(this.source.charCodeAt(this.index))){break}t+=this.source[this.index++]}if(t.length===0){this.throwUnexpectedToken()}if(n.Character.isIdentifierStart(this.source.charCodeAt(this.index))){this.throwUnexpectedToken()}return{type:6,value:parseInt("0x"+t,16),lineNumber:this.lineNumber,lineStart:this.lineStart,start:e,end:this.index}};Scanner.prototype.scanBinaryLiteral=function(e){var t="";var r;while(!this.eof()){r=this.source[this.index];if(r!=="0"&&r!=="1"){break}t+=this.source[this.index++]}if(t.length===0){this.throwUnexpectedToken()}if(!this.eof()){r=this.source.charCodeAt(this.index);if(n.Character.isIdentifierStart(r)||n.Character.isDecimalDigit(r)){this.throwUnexpectedToken()}}return{type:6,value:parseInt(t,2),lineNumber:this.lineNumber,lineStart:this.lineStart,start:e,end:this.index}};Scanner.prototype.scanOctalLiteral=function(e,t){var r="";var i=false;if(n.Character.isOctalDigit(e.charCodeAt(0))){i=true;r="0"+this.source[this.index++]}else{++this.index}while(!this.eof()){if(!n.Character.isOctalDigit(this.source.charCodeAt(this.index))){break}r+=this.source[this.index++]}if(!i&&r.length===0){this.throwUnexpectedToken()}if(n.Character.isIdentifierStart(this.source.charCodeAt(this.index))||n.Character.isDecimalDigit(this.source.charCodeAt(this.index))){this.throwUnexpectedToken()}return{type:6,value:parseInt(r,8),octal:i,lineNumber:this.lineNumber,lineStart:this.lineStart,start:t,end:this.index}};Scanner.prototype.isImplicitOctalLiteral=function(){for(var e=this.index+1;e=0){i=i.replace(/\\u\{([0-9a-fA-F]+)\}|\\u([a-fA-F0-9]{4})/g,function(e,t,i){var u=parseInt(t||i,16);if(u>1114111){n.throwUnexpectedToken(a.Messages.InvalidRegExp)}if(u<=65535){return String.fromCharCode(u)}return r}).replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,r)}try{RegExp(i)}catch(e){this.throwUnexpectedToken(a.Messages.InvalidRegExp)}try{return new RegExp(e,t)}catch(e){return null}};Scanner.prototype.scanRegExpBody=function(){var e=this.source[this.index];i.assert(e==="/","Regular expression literal must start with a slash");var t=this.source[this.index++];var r=false;var u=false;while(!this.eof()){e=this.source[this.index++];t+=e;if(e==="\\"){e=this.source[this.index++];if(n.Character.isLineTerminator(e.charCodeAt(0))){this.throwUnexpectedToken(a.Messages.UnterminatedRegExp)}t+=e}else if(n.Character.isLineTerminator(e.charCodeAt(0))){this.throwUnexpectedToken(a.Messages.UnterminatedRegExp)}else if(r){if(e==="]"){r=false}}else{if(e==="/"){u=true;break}else if(e==="["){r=true}}}if(!u){this.throwUnexpectedToken(a.Messages.UnterminatedRegExp)}return t.substr(1,t.length-2)};Scanner.prototype.scanRegExpFlags=function(){var e="";var t="";while(!this.eof()){var r=this.source[this.index];if(!n.Character.isIdentifierPart(r.charCodeAt(0))){break}++this.index;if(r==="\\"&&!this.eof()){r=this.source[this.index];if(r==="u"){++this.index;var i=this.index;var a=this.scanHexEscape("u");if(a!==null){t+=a;for(e+="\\u";i=55296&&e<57343){if(n.Character.isIdentifierStart(this.codePointAt(this.index))){return this.scanIdentifier()}}return this.scanPunctuator()};return Scanner}();t.Scanner=u},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.TokenName={};t.TokenName[1]="Boolean";t.TokenName[2]="";t.TokenName[3]="Identifier";t.TokenName[4]="Keyword";t.TokenName[5]="Null";t.TokenName[6]="Numeric";t.TokenName[7]="Punctuator";t.TokenName[8]="String";t.TokenName[9]="RegularExpression";t.TokenName[10]="Template"},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.XHTMLEntities={quot:'"',amp:"&",apos:"'",gt:">",nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"­",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",fnof:"ƒ",circ:"ˆ",tilde:"˜",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",ensp:" ",emsp:" ",thinsp:" ",zwnj:"‌",zwj:"‍",lrm:"‎",rlm:"‏",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",bull:"•",hellip:"…",permil:"‰",prime:"′",Prime:"″",lsaquo:"‹",rsaquo:"›",oline:"‾",frasl:"⁄",euro:"€",image:"ℑ",weierp:"℘",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦",lang:"⟨",rang:"⟩"}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:true});var i=r(10);var n=r(12);var a=r(13);var u=function(){function Reader(){this.values=[];this.curly=this.paren=-1}Reader.prototype.beforeFunctionExpression=function(e){return["(","{","[","in","typeof","instanceof","new","return","case","delete","throw","void","=","+=","-=","*=","**=","/=","%=","<<=",">>=",">>>=","&=","|=","^=",",","+","-","*","**","/","%","++","--","<<",">>",">>>","&","|","^","!","~","&&","||","?",":","===","==",">=","<=","<",">","!=","!=="].indexOf(e)>=0};Reader.prototype.isRegexStart=function(){var e=this.values[this.values.length-1];var t=e!==null;switch(e){case"this":case"]":t=false;break;case")":var r=this.values[this.paren-1];t=r==="if"||r==="while"||r==="for"||r==="with";break;case"}":t=false;if(this.values[this.curly-3]==="function"){var i=this.values[this.curly-4];t=i?!this.beforeFunctionExpression(i):false}else if(this.values[this.curly-4]==="function"){var i=this.values[this.curly-5];t=i?!this.beforeFunctionExpression(i):true}break;default:break}return t};Reader.prototype.push=function(e){if(e.type===7||e.type===4){if(e.value==="{"){this.curly=this.values.length}else if(e.value==="("){this.paren=this.values.length}this.values.push(e.value)}else{this.values.push(null)}};return Reader}();var s=function(){function Tokenizer(e,t){this.errorHandler=new i.ErrorHandler;this.errorHandler.tolerant=t?typeof t.tolerant==="boolean"&&t.tolerant:false;this.scanner=new n.Scanner(e,this.errorHandler);this.scanner.trackComment=t?typeof t.comment==="boolean"&&t.comment:false;this.trackRange=t?typeof t.range==="boolean"&&t.range:false;this.trackLoc=t?typeof t.loc==="boolean"&&t.loc:false;this.buffer=[];this.reader=new u}Tokenizer.prototype.errors=function(){return this.errorHandler.errors};Tokenizer.prototype.getNextToken=function(){if(this.buffer.length===0){var e=this.scanner.scanComments();if(this.scanner.trackComment){for(var t=0;tt){if(e.charAt(r-1)!==" "){break}r--}return r}},,function(e,t,r){"use strict";var i=r(347)("unified-engine:file-pipeline:stringify");var n=r(928);var a=r(212);e.exports=stringify;function stringify(e,t){var r=e.processor;var u=e.tree;var s;if(n(t).fatal){i("Not compiling failed document");return}if(!e.output&&!e.out&&!e.alwaysStringify){i("Not compiling document without output settings");return}i("Compiling `%s`",t.path);if(e.inspect){if(t.path){t.extname=".txt"}s=a[e.color?"color":"noColor"](u)+"\n"}else if(e.treeOut){if(t.path){t.extname=".json"}s=JSON.stringify(u,null,2)+"\n"}else{s=r.stringify(u,t)}t.contents=s;i("Compiled document")}},,,function(e,t,r){"use strict";const i=r(624);e.exports=(e=>typeof e==="string"?e.replace(i(),""):e)},,function(e,t,r){"use strict";var i=r(260);function Mark(e,t,r,i,n){this.name=e;this.buffer=t;this.position=r;this.line=i;this.column=n}Mark.prototype.getSnippet=function getSnippet(e,t){var r,n,a,u,s;if(!this.buffer)return null;e=e||4;t=t||75;r="";n=this.position;while(n>0&&"\0\r\n…\u2028\u2029".indexOf(this.buffer.charAt(n-1))===-1){n-=1;if(this.position-n>t/2-1){r=" ... ";n+=5;break}}a="";u=this.position;while(ut/2-1){a=" ... ";u-=5;break}}s=this.buffer.slice(n,u);return i.repeat(" ",e)+r+s+a+"\n"+i.repeat(" ",e+this.position-n+r.length)+"^"};Mark.prototype.toString=function toString(e){var t,r="";if(this.name){r+='in "'+this.name+'" '}r+="at line "+(this.line+1)+", column "+(this.column+1);if(!e){t=this.getSnippet();if(t){r+=":\n"+t}}return r};e.exports=Mark},function(e,t,r){var i=r(148);var n=function(){};var a=r(405);e.exports=wrapped;function wrapped(e){function wrap(){var t=i(arguments);var r=t[t.length-1];var u=this;var s=typeof r=="function"?t.pop():n;if(!e){return s.apply(u,[null].concat(t))}if(generator(e)){return a(e).apply(u,t.concat(s))}if(e.length>t.length){try{return e.apply(u,t.concat(s))}catch(e){return s(e)}}return sync(e,s).apply(u,t)}return wrap}function sync(e,t){return function(){var r;try{r=e.apply(this,arguments)}catch(e){return t(e)}if(promise(r)){r.then(function(e){t(null,e)},t)}else{r instanceof Error?t(r):t(null,r)}}}function generator(e){return e&&e.constructor&&"GeneratorFunction"==e.constructor.name}function promise(e){return e&&"function"==typeof e.then}},,,,,,,,function(e,t,r){"use strict";var i=r(495);e.exports=i("remark-lint:no-file-name-articles",noFileNameArticles);function noFileNameArticles(e,t){var r=t.stem&&t.stem.match(/^(the|teh|an?)\b/i);if(r){t.message("Do not start file names with `"+r[0]+"`")}}},,,function(e,t,r){"use strict";var i=r(171);e.exports=newline;var n="\n";function newline(e,t,r){var a=t.charAt(0);var u;var s;var o;var l;if(a!==n){return}if(r){return true}l=1;u=t.length;s=a;o="";while(l{if(typeof e!=="string"||e.length===0){return 0}e=i(e);let t=0;for(let r=0;r=127&&i<=159){continue}if(i>=768&&i<=879){continue}if(i>65535){r++}t+=n(i)?2:1}return t})},,,,function(e){e.exports=require("stream")},,,,function(e){"use strict";e.exports=function isObject(e){return typeof e==="object"&&e!==null}},,function(e,t,r){"use strict";e.exports={position:true,gfm:true,commonmark:false,footnotes:false,pedantic:false,blocks:r(676)}},,,function(e,t,r){"use strict";var i=r(211);var n=Object.prototype.toString;function resolveYamlPairs(e){if(e===null)return true;var t,r,i,a,u,s=e;u=new Array(s.length);for(t=0,r=s.length;t=0){t=t.slice(1)}if(t===".inf"){return r===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY}else if(t===".nan"){return NaN}else if(t.indexOf(":")>=0){t.split(":").forEach(function(e){n.unshift(parseFloat(e,10))});t=0;i=1;n.forEach(function(e){t+=e*i;i*=60});return r*t}return r*parseFloat(t,10)}var u=/^[-+]?[0-9]+e/;function representYamlFloat(e,t){var r;if(isNaN(e)){switch(t){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}}else if(Number.POSITIVE_INFINITY===e){switch(t){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}}else if(Number.NEGATIVE_INFINITY===e){switch(t){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}}else if(i.isNegativeZero(e)){return"-0.0"}r=e.toString(10);return u.test(r)?r.replace("e",".e"):r}function isFloat(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||i.isNegativeZero(e))}e.exports=new n("tag:yaml.org,2002:float",{kind:"scalar",resolve:resolveYamlFloat,construct:constructYamlFloat,predicate:isFloat,represent:representYamlFloat,defaultStyle:"lowercase"})},,function(e,t,r){"use strict";const i=r(947);e.exports=((e,t,r)=>{if(typeof t==="number"){r=t}if(i.has(e.toLowerCase())){t=i.get(e.toLowerCase());const r=e.charAt(0);const n=r===r.toUpperCase();if(n){t=r.toUpperCase()+t.slice(1)}const a=e===e.toUpperCase();if(a){t=t.toUpperCase()}}else if(typeof t!=="string"){t=(e.replace(/(?:s|x|z|ch|sh)$/i,"$&e").replace(/([^aeiou])y$/i,"$1ie")+"s").replace(/i?e?s$/i,t=>{const r=e.slice(-1)===e.slice(-1).toLowerCase();return r?t.toLowerCase():t.toUpperCase()})}return Math.abs(r)===1?e:t})},function(e,t,r){"use strict";var i=r(814);e.exports=pad;var n="\n";var a=" ";var u=4;function pad(e,t){var r=e.split(n);var s=r.length;var o=i(a,t*u);while(s--){if(r[s].length!==0){r[s]=o+r[s]}}return r.join(n)}},,,,function(e){e.exports=function(e,t){return e.replace(/(\\*)(\$([_a-z0-9]+)|\${([_a-z0-9]+)})/gi,function(e,r,i,n,a){if(!(r.length%2)){return r.substring(Math.ceil(r.length/2))+(t[n||a]||"")}else{return r.substring(1)+i}})}},,,,function(e,t,r){"use strict";var i=r(211);var n=Object.prototype.hasOwnProperty;function resolveYamlSet(e){if(e===null)return true;var t,r=e;for(t in r){if(n.call(r,t)){if(r[t]!==null)return false}}return true}function constructYamlSet(e){return e!==null?e:{}}e.exports=new i("tag:yaml.org,2002:set",{kind:"mapping",resolve:resolveYamlSet,construct:constructYamlSet})},function(e){if(typeof Object.create==="function"){e.exports=function inherits(e,t){e.super_=t;e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:false,writable:true,configurable:true}})}}else{e.exports=function inherits(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype;e.prototype=new r;e.prototype.constructor=e}}},,,,,function(e){var t=Object.prototype.toString;var r=typeof Buffer.alloc==="function"&&typeof Buffer.allocUnsafe==="function"&&typeof Buffer.from==="function";function isArrayBuffer(e){return t.call(e).slice(8,-1)==="ArrayBuffer"}function fromArrayBuffer(e,t,i){t>>>=0;var n=e.byteLength-t;if(n<0){throw new RangeError("'offset' is out of bounds")}if(i===undefined){i=n}else{i>>>=0;if(i>n){throw new RangeError("'length' is out of bounds")}}return r?Buffer.from(e.slice(t,t+i)):new Buffer(new Uint8Array(e.slice(t,t+i)))}function fromString(e,t){if(typeof t!=="string"||t===""){t="utf8"}if(!Buffer.isEncoding(t)){throw new TypeError('"encoding" must be a valid string encoding')}return r?Buffer.from(e,t):new Buffer(e,t)}function bufferFrom(e,t,i){if(typeof e==="number"){throw new TypeError('"value" argument must not be a number')}if(isArrayBuffer(e)){return fromArrayBuffer(e,t,i)}if(typeof e==="string"){return fromString(e,t)}return r?Buffer.from(e):new Buffer(e)}e.exports=bufferFrom},,function(e){e.exports={AEli:"Æ",AElig:"Æ",AM:"&",AMP:"&",Aacut:"Á",Aacute:"Á",Abreve:"Ă",Acir:"Â",Acirc:"Â",Acy:"А",Afr:"𝔄",Agrav:"À",Agrave:"À",Alpha:"Α",Amacr:"Ā",And:"⩓",Aogon:"Ą",Aopf:"𝔸",ApplyFunction:"⁡",Arin:"Å",Aring:"Å",Ascr:"𝒜",Assign:"≔",Atild:"Ã",Atilde:"Ã",Aum:"Ä",Auml:"Ä",Backslash:"∖",Barv:"⫧",Barwed:"⌆",Bcy:"Б",Because:"∵",Bernoullis:"ℬ",Beta:"Β",Bfr:"𝔅",Bopf:"𝔹",Breve:"˘",Bscr:"ℬ",Bumpeq:"≎",CHcy:"Ч",COP:"©",COPY:"©",Cacute:"Ć",Cap:"⋒",CapitalDifferentialD:"ⅅ",Cayleys:"ℭ",Ccaron:"Č",Ccedi:"Ç",Ccedil:"Ç",Ccirc:"Ĉ",Cconint:"∰",Cdot:"Ċ",Cedilla:"¸",CenterDot:"·",Cfr:"ℭ",Chi:"Χ",CircleDot:"⊙",CircleMinus:"⊖",CirclePlus:"⊕",CircleTimes:"⊗",ClockwiseContourIntegral:"∲",CloseCurlyDoubleQuote:"”",CloseCurlyQuote:"’",Colon:"∷",Colone:"⩴",Congruent:"≡",Conint:"∯",ContourIntegral:"∮",Copf:"ℂ",Coproduct:"∐",CounterClockwiseContourIntegral:"∳",Cross:"⨯",Cscr:"𝒞",Cup:"⋓",CupCap:"≍",DD:"ⅅ",DDotrahd:"⤑",DJcy:"Ђ",DScy:"Ѕ",DZcy:"Џ",Dagger:"‡",Darr:"↡",Dashv:"⫤",Dcaron:"Ď",Dcy:"Д",Del:"∇",Delta:"Δ",Dfr:"𝔇",DiacriticalAcute:"´",DiacriticalDot:"˙",DiacriticalDoubleAcute:"˝",DiacriticalGrave:"`",DiacriticalTilde:"˜",Diamond:"⋄",DifferentialD:"ⅆ",Dopf:"𝔻",Dot:"¨",DotDot:"⃜",DotEqual:"≐",DoubleContourIntegral:"∯",DoubleDot:"¨",DoubleDownArrow:"⇓",DoubleLeftArrow:"⇐",DoubleLeftRightArrow:"⇔",DoubleLeftTee:"⫤",DoubleLongLeftArrow:"⟸",DoubleLongLeftRightArrow:"⟺",DoubleLongRightArrow:"⟹",DoubleRightArrow:"⇒",DoubleRightTee:"⊨",DoubleUpArrow:"⇑",DoubleUpDownArrow:"⇕",DoubleVerticalBar:"∥",DownArrow:"↓",DownArrowBar:"⤓",DownArrowUpArrow:"⇵",DownBreve:"̑",DownLeftRightVector:"⥐",DownLeftTeeVector:"⥞",DownLeftVector:"↽",DownLeftVectorBar:"⥖",DownRightTeeVector:"⥟",DownRightVector:"⇁",DownRightVectorBar:"⥗",DownTee:"⊤",DownTeeArrow:"↧",Downarrow:"⇓",Dscr:"𝒟",Dstrok:"Đ",ENG:"Ŋ",ET:"Ð",ETH:"Ð",Eacut:"É",Eacute:"É",Ecaron:"Ě",Ecir:"Ê",Ecirc:"Ê",Ecy:"Э",Edot:"Ė",Efr:"𝔈",Egrav:"È",Egrave:"È",Element:"∈",Emacr:"Ē",EmptySmallSquare:"◻",EmptyVerySmallSquare:"▫",Eogon:"Ę",Eopf:"𝔼",Epsilon:"Ε",Equal:"⩵",EqualTilde:"≂",Equilibrium:"⇌",Escr:"ℰ",Esim:"⩳",Eta:"Η",Eum:"Ë",Euml:"Ë",Exists:"∃",ExponentialE:"ⅇ",Fcy:"Ф",Ffr:"𝔉",FilledSmallSquare:"◼",FilledVerySmallSquare:"▪",Fopf:"𝔽",ForAll:"∀",Fouriertrf:"ℱ",Fscr:"ℱ",GJcy:"Ѓ",G:">",GT:">",Gamma:"Γ",Gammad:"Ϝ",Gbreve:"Ğ",Gcedil:"Ģ",Gcirc:"Ĝ",Gcy:"Г",Gdot:"Ġ",Gfr:"𝔊",Gg:"⋙",Gopf:"𝔾",GreaterEqual:"≥",GreaterEqualLess:"⋛",GreaterFullEqual:"≧",GreaterGreater:"⪢",GreaterLess:"≷",GreaterSlantEqual:"⩾",GreaterTilde:"≳",Gscr:"𝒢",Gt:"≫",HARDcy:"Ъ",Hacek:"ˇ",Hat:"^",Hcirc:"Ĥ",Hfr:"ℌ",HilbertSpace:"ℋ",Hopf:"ℍ",HorizontalLine:"─",Hscr:"ℋ",Hstrok:"Ħ",HumpDownHump:"≎",HumpEqual:"≏",IEcy:"Е",IJlig:"IJ",IOcy:"Ё",Iacut:"Í",Iacute:"Í",Icir:"Î",Icirc:"Î",Icy:"И",Idot:"İ",Ifr:"ℑ",Igrav:"Ì",Igrave:"Ì",Im:"ℑ",Imacr:"Ī",ImaginaryI:"ⅈ",Implies:"⇒",Int:"∬",Integral:"∫",Intersection:"⋂",InvisibleComma:"⁣",InvisibleTimes:"⁢",Iogon:"Į",Iopf:"𝕀",Iota:"Ι",Iscr:"ℐ",Itilde:"Ĩ",Iukcy:"І",Ium:"Ï",Iuml:"Ï",Jcirc:"Ĵ",Jcy:"Й",Jfr:"𝔍",Jopf:"𝕁",Jscr:"𝒥",Jsercy:"Ј",Jukcy:"Є",KHcy:"Х",KJcy:"Ќ",Kappa:"Κ",Kcedil:"Ķ",Kcy:"К",Kfr:"𝔎",Kopf:"𝕂",Kscr:"𝒦",LJcy:"Љ",L:"<",LT:"<",Lacute:"Ĺ",Lambda:"Λ",Lang:"⟪",Laplacetrf:"ℒ",Larr:"↞",Lcaron:"Ľ",Lcedil:"Ļ",Lcy:"Л",LeftAngleBracket:"⟨",LeftArrow:"←",LeftArrowBar:"⇤",LeftArrowRightArrow:"⇆",LeftCeiling:"⌈",LeftDoubleBracket:"⟦",LeftDownTeeVector:"⥡",LeftDownVector:"⇃",LeftDownVectorBar:"⥙",LeftFloor:"⌊",LeftRightArrow:"↔",LeftRightVector:"⥎",LeftTee:"⊣",LeftTeeArrow:"↤",LeftTeeVector:"⥚",LeftTriangle:"⊲",LeftTriangleBar:"⧏",LeftTriangleEqual:"⊴",LeftUpDownVector:"⥑",LeftUpTeeVector:"⥠",LeftUpVector:"↿",LeftUpVectorBar:"⥘",LeftVector:"↼",LeftVectorBar:"⥒",Leftarrow:"⇐",Leftrightarrow:"⇔",LessEqualGreater:"⋚",LessFullEqual:"≦",LessGreater:"≶",LessLess:"⪡",LessSlantEqual:"⩽",LessTilde:"≲",Lfr:"𝔏",Ll:"⋘",Lleftarrow:"⇚",Lmidot:"Ŀ",LongLeftArrow:"⟵",LongLeftRightArrow:"⟷",LongRightArrow:"⟶",Longleftarrow:"⟸",Longleftrightarrow:"⟺",Longrightarrow:"⟹",Lopf:"𝕃",LowerLeftArrow:"↙",LowerRightArrow:"↘",Lscr:"ℒ",Lsh:"↰",Lstrok:"Ł",Lt:"≪",Map:"⤅",Mcy:"М",MediumSpace:" ",Mellintrf:"ℳ",Mfr:"𝔐",MinusPlus:"∓",Mopf:"𝕄",Mscr:"ℳ",Mu:"Μ",NJcy:"Њ",Nacute:"Ń",Ncaron:"Ň",Ncedil:"Ņ",Ncy:"Н",NegativeMediumSpace:"​",NegativeThickSpace:"​",NegativeThinSpace:"​",NegativeVeryThinSpace:"​",NestedGreaterGreater:"≫",NestedLessLess:"≪",NewLine:"\n",Nfr:"𝔑",NoBreak:"⁠",NonBreakingSpace:" ",Nopf:"ℕ",Not:"⫬",NotCongruent:"≢",NotCupCap:"≭",NotDoubleVerticalBar:"∦",NotElement:"∉",NotEqual:"≠",NotEqualTilde:"≂̸",NotExists:"∄",NotGreater:"≯",NotGreaterEqual:"≱",NotGreaterFullEqual:"≧̸",NotGreaterGreater:"≫̸",NotGreaterLess:"≹",NotGreaterSlantEqual:"⩾̸",NotGreaterTilde:"≵",NotHumpDownHump:"≎̸",NotHumpEqual:"≏̸",NotLeftTriangle:"⋪",NotLeftTriangleBar:"⧏̸",NotLeftTriangleEqual:"⋬",NotLess:"≮",NotLessEqual:"≰",NotLessGreater:"≸",NotLessLess:"≪̸",NotLessSlantEqual:"⩽̸",NotLessTilde:"≴",NotNestedGreaterGreater:"⪢̸",NotNestedLessLess:"⪡̸",NotPrecedes:"⊀",NotPrecedesEqual:"⪯̸",NotPrecedesSlantEqual:"⋠",NotReverseElement:"∌",NotRightTriangle:"⋫",NotRightTriangleBar:"⧐̸",NotRightTriangleEqual:"⋭",NotSquareSubset:"⊏̸",NotSquareSubsetEqual:"⋢",NotSquareSuperset:"⊐̸",NotSquareSupersetEqual:"⋣",NotSubset:"⊂⃒",NotSubsetEqual:"⊈",NotSucceeds:"⊁",NotSucceedsEqual:"⪰̸",NotSucceedsSlantEqual:"⋡",NotSucceedsTilde:"≿̸",NotSuperset:"⊃⃒",NotSupersetEqual:"⊉",NotTilde:"≁",NotTildeEqual:"≄",NotTildeFullEqual:"≇",NotTildeTilde:"≉",NotVerticalBar:"∤",Nscr:"𝒩",Ntild:"Ñ",Ntilde:"Ñ",Nu:"Ν",OElig:"Œ",Oacut:"Ó",Oacute:"Ó",Ocir:"Ô",Ocirc:"Ô",Ocy:"О",Odblac:"Ő",Ofr:"𝔒",Ograv:"Ò",Ograve:"Ò",Omacr:"Ō",Omega:"Ω",Omicron:"Ο",Oopf:"𝕆",OpenCurlyDoubleQuote:"“",OpenCurlyQuote:"‘",Or:"⩔",Oscr:"𝒪",Oslas:"Ø",Oslash:"Ø",Otild:"Õ",Otilde:"Õ",Otimes:"⨷",Oum:"Ö",Ouml:"Ö",OverBar:"‾",OverBrace:"⏞",OverBracket:"⎴",OverParenthesis:"⏜",PartialD:"∂",Pcy:"П",Pfr:"𝔓",Phi:"Φ",Pi:"Π",PlusMinus:"±",Poincareplane:"ℌ",Popf:"ℙ",Pr:"⪻",Precedes:"≺",PrecedesEqual:"⪯",PrecedesSlantEqual:"≼",PrecedesTilde:"≾",Prime:"″",Product:"∏",Proportion:"∷",Proportional:"∝",Pscr:"𝒫",Psi:"Ψ",QUO:'"',QUOT:'"',Qfr:"𝔔",Qopf:"ℚ",Qscr:"𝒬",RBarr:"⤐",RE:"®",REG:"®",Racute:"Ŕ",Rang:"⟫",Rarr:"↠",Rarrtl:"⤖",Rcaron:"Ř",Rcedil:"Ŗ",Rcy:"Р",Re:"ℜ",ReverseElement:"∋",ReverseEquilibrium:"⇋",ReverseUpEquilibrium:"⥯",Rfr:"ℜ",Rho:"Ρ",RightAngleBracket:"⟩",RightArrow:"→",RightArrowBar:"⇥",RightArrowLeftArrow:"⇄",RightCeiling:"⌉",RightDoubleBracket:"⟧",RightDownTeeVector:"⥝",RightDownVector:"⇂",RightDownVectorBar:"⥕",RightFloor:"⌋",RightTee:"⊢",RightTeeArrow:"↦",RightTeeVector:"⥛",RightTriangle:"⊳",RightTriangleBar:"⧐",RightTriangleEqual:"⊵",RightUpDownVector:"⥏",RightUpTeeVector:"⥜",RightUpVector:"↾",RightUpVectorBar:"⥔",RightVector:"⇀",RightVectorBar:"⥓",Rightarrow:"⇒",Ropf:"ℝ",RoundImplies:"⥰",Rrightarrow:"⇛",Rscr:"ℛ",Rsh:"↱",RuleDelayed:"⧴",SHCHcy:"Щ",SHcy:"Ш",SOFTcy:"Ь",Sacute:"Ś",Sc:"⪼",Scaron:"Š",Scedil:"Ş",Scirc:"Ŝ",Scy:"С",Sfr:"𝔖",ShortDownArrow:"↓",ShortLeftArrow:"←",ShortRightArrow:"→",ShortUpArrow:"↑",Sigma:"Σ",SmallCircle:"∘",Sopf:"𝕊",Sqrt:"√",Square:"□",SquareIntersection:"⊓",SquareSubset:"⊏",SquareSubsetEqual:"⊑",SquareSuperset:"⊐",SquareSupersetEqual:"⊒",SquareUnion:"⊔",Sscr:"𝒮",Star:"⋆",Sub:"⋐",Subset:"⋐",SubsetEqual:"⊆",Succeeds:"≻",SucceedsEqual:"⪰",SucceedsSlantEqual:"≽",SucceedsTilde:"≿",SuchThat:"∋",Sum:"∑",Sup:"⋑",Superset:"⊃",SupersetEqual:"⊇",Supset:"⋑",THOR:"Þ",THORN:"Þ",TRADE:"™",TSHcy:"Ћ",TScy:"Ц",Tab:"\t",Tau:"Τ",Tcaron:"Ť",Tcedil:"Ţ",Tcy:"Т",Tfr:"𝔗",Therefore:"∴",Theta:"Θ",ThickSpace:"  ",ThinSpace:" ",Tilde:"∼",TildeEqual:"≃",TildeFullEqual:"≅",TildeTilde:"≈",Topf:"𝕋",TripleDot:"⃛",Tscr:"𝒯",Tstrok:"Ŧ",Uacut:"Ú",Uacute:"Ú",Uarr:"↟",Uarrocir:"⥉",Ubrcy:"Ў",Ubreve:"Ŭ",Ucir:"Û",Ucirc:"Û",Ucy:"У",Udblac:"Ű",Ufr:"𝔘",Ugrav:"Ù",Ugrave:"Ù",Umacr:"Ū",UnderBar:"_",UnderBrace:"⏟",UnderBracket:"⎵",UnderParenthesis:"⏝",Union:"⋃",UnionPlus:"⊎",Uogon:"Ų",Uopf:"𝕌",UpArrow:"↑",UpArrowBar:"⤒",UpArrowDownArrow:"⇅",UpDownArrow:"↕",UpEquilibrium:"⥮",UpTee:"⊥",UpTeeArrow:"↥",Uparrow:"⇑",Updownarrow:"⇕",UpperLeftArrow:"↖",UpperRightArrow:"↗",Upsi:"ϒ",Upsilon:"Υ",Uring:"Ů",Uscr:"𝒰",Utilde:"Ũ",Uum:"Ü",Uuml:"Ü",VDash:"⊫",Vbar:"⫫",Vcy:"В",Vdash:"⊩",Vdashl:"⫦",Vee:"⋁",Verbar:"‖",Vert:"‖",VerticalBar:"∣",VerticalLine:"|",VerticalSeparator:"❘",VerticalTilde:"≀",VeryThinSpace:" ",Vfr:"𝔙",Vopf:"𝕍",Vscr:"𝒱",Vvdash:"⊪",Wcirc:"Ŵ",Wedge:"⋀",Wfr:"𝔚",Wopf:"𝕎",Wscr:"𝒲",Xfr:"𝔛",Xi:"Ξ",Xopf:"𝕏",Xscr:"𝒳",YAcy:"Я",YIcy:"Ї",YUcy:"Ю",Yacut:"Ý",Yacute:"Ý",Ycirc:"Ŷ",Ycy:"Ы",Yfr:"𝔜",Yopf:"𝕐",Yscr:"𝒴",Yuml:"Ÿ",ZHcy:"Ж",Zacute:"Ź",Zcaron:"Ž",Zcy:"З",Zdot:"Ż",ZeroWidthSpace:"​",Zeta:"Ζ",Zfr:"ℨ",Zopf:"ℤ",Zscr:"𝒵",aacut:"á",aacute:"á",abreve:"ă",ac:"∾",acE:"∾̳",acd:"∿",acir:"â",acirc:"â",acut:"´",acute:"´",acy:"а",aeli:"æ",aelig:"æ",af:"⁡",afr:"𝔞",agrav:"à",agrave:"à",alefsym:"ℵ",aleph:"ℵ",alpha:"α",amacr:"ā",amalg:"⨿",am:"&",amp:"&",and:"∧",andand:"⩕",andd:"⩜",andslope:"⩘",andv:"⩚",ang:"∠",ange:"⦤",angle:"∠",angmsd:"∡",angmsdaa:"⦨",angmsdab:"⦩",angmsdac:"⦪",angmsdad:"⦫",angmsdae:"⦬",angmsdaf:"⦭",angmsdag:"⦮",angmsdah:"⦯",angrt:"∟",angrtvb:"⊾",angrtvbd:"⦝",angsph:"∢",angst:"Å",angzarr:"⍼",aogon:"ą",aopf:"𝕒",ap:"≈",apE:"⩰",apacir:"⩯",ape:"≊",apid:"≋",apos:"'",approx:"≈",approxeq:"≊",arin:"å",aring:"å",ascr:"𝒶",ast:"*",asymp:"≈",asympeq:"≍",atild:"ã",atilde:"ã",aum:"ä",auml:"ä",awconint:"∳",awint:"⨑",bNot:"⫭",backcong:"≌",backepsilon:"϶",backprime:"‵",backsim:"∽",backsimeq:"⋍",barvee:"⊽",barwed:"⌅",barwedge:"⌅",bbrk:"⎵",bbrktbrk:"⎶",bcong:"≌",bcy:"б",bdquo:"„",becaus:"∵",because:"∵",bemptyv:"⦰",bepsi:"϶",bernou:"ℬ",beta:"β",beth:"ℶ",between:"≬",bfr:"𝔟",bigcap:"⋂",bigcirc:"◯",bigcup:"⋃",bigodot:"⨀",bigoplus:"⨁",bigotimes:"⨂",bigsqcup:"⨆",bigstar:"★",bigtriangledown:"▽",bigtriangleup:"△",biguplus:"⨄",bigvee:"⋁",bigwedge:"⋀",bkarow:"⤍",blacklozenge:"⧫",blacksquare:"▪",blacktriangle:"▴",blacktriangledown:"▾",blacktriangleleft:"◂",blacktriangleright:"▸",blank:"␣",blk12:"▒",blk14:"░",blk34:"▓",block:"█",bne:"=⃥",bnequiv:"≡⃥",bnot:"⌐",bopf:"𝕓",bot:"⊥",bottom:"⊥",bowtie:"⋈",boxDL:"╗",boxDR:"╔",boxDl:"╖",boxDr:"╓",boxH:"═",boxHD:"╦",boxHU:"╩",boxHd:"╤",boxHu:"╧",boxUL:"╝",boxUR:"╚",boxUl:"╜",boxUr:"╙",boxV:"║",boxVH:"╬",boxVL:"╣",boxVR:"╠",boxVh:"╫",boxVl:"╢",boxVr:"╟",boxbox:"⧉",boxdL:"╕",boxdR:"╒",boxdl:"┐",boxdr:"┌",boxh:"─",boxhD:"╥",boxhU:"╨",boxhd:"┬",boxhu:"┴",boxminus:"⊟",boxplus:"⊞",boxtimes:"⊠",boxuL:"╛",boxuR:"╘",boxul:"┘",boxur:"└",boxv:"│",boxvH:"╪",boxvL:"╡",boxvR:"╞",boxvh:"┼",boxvl:"┤",boxvr:"├",bprime:"‵",breve:"˘",brvba:"¦",brvbar:"¦",bscr:"𝒷",bsemi:"⁏",bsim:"∽",bsime:"⋍",bsol:"\\",bsolb:"⧅",bsolhsub:"⟈",bull:"•",bullet:"•",bump:"≎",bumpE:"⪮",bumpe:"≏",bumpeq:"≏",cacute:"ć",cap:"∩",capand:"⩄",capbrcup:"⩉",capcap:"⩋",capcup:"⩇",capdot:"⩀",caps:"∩︀",caret:"⁁",caron:"ˇ",ccaps:"⩍",ccaron:"č",ccedi:"ç",ccedil:"ç",ccirc:"ĉ",ccups:"⩌",ccupssm:"⩐",cdot:"ċ",cedi:"¸",cedil:"¸",cemptyv:"⦲",cen:"¢",cent:"¢",centerdot:"·",cfr:"𝔠",chcy:"ч",check:"✓",checkmark:"✓",chi:"χ",cir:"○",cirE:"⧃",circ:"ˆ",circeq:"≗",circlearrowleft:"↺",circlearrowright:"↻",circledR:"®",circledS:"Ⓢ",circledast:"⊛",circledcirc:"⊚",circleddash:"⊝",cire:"≗",cirfnint:"⨐",cirmid:"⫯",cirscir:"⧂",clubs:"♣",clubsuit:"♣",colon:":",colone:"≔",coloneq:"≔",comma:",",commat:"@",comp:"∁",compfn:"∘",complement:"∁",complexes:"ℂ",cong:"≅",congdot:"⩭",conint:"∮",copf:"𝕔",coprod:"∐",cop:"©",copy:"©",copysr:"℗",crarr:"↵",cross:"✗",cscr:"𝒸",csub:"⫏",csube:"⫑",csup:"⫐",csupe:"⫒",ctdot:"⋯",cudarrl:"⤸",cudarrr:"⤵",cuepr:"⋞",cuesc:"⋟",cularr:"↶",cularrp:"⤽",cup:"∪",cupbrcap:"⩈",cupcap:"⩆",cupcup:"⩊",cupdot:"⊍",cupor:"⩅",cups:"∪︀",curarr:"↷",curarrm:"⤼",curlyeqprec:"⋞",curlyeqsucc:"⋟",curlyvee:"⋎",curlywedge:"⋏",curre:"¤",curren:"¤",curvearrowleft:"↶",curvearrowright:"↷",cuvee:"⋎",cuwed:"⋏",cwconint:"∲",cwint:"∱",cylcty:"⌭",dArr:"⇓",dHar:"⥥",dagger:"†",daleth:"ℸ",darr:"↓",dash:"‐",dashv:"⊣",dbkarow:"⤏",dblac:"˝",dcaron:"ď",dcy:"д",dd:"ⅆ",ddagger:"‡",ddarr:"⇊",ddotseq:"⩷",de:"°",deg:"°",delta:"δ",demptyv:"⦱",dfisht:"⥿",dfr:"𝔡",dharl:"⇃",dharr:"⇂",diam:"⋄",diamond:"⋄",diamondsuit:"♦",diams:"♦",die:"¨",digamma:"ϝ",disin:"⋲",div:"÷",divid:"÷",divide:"÷",divideontimes:"⋇",divonx:"⋇",djcy:"ђ",dlcorn:"⌞",dlcrop:"⌍",dollar:"$",dopf:"𝕕",dot:"˙",doteq:"≐",doteqdot:"≑",dotminus:"∸",dotplus:"∔",dotsquare:"⊡",doublebarwedge:"⌆",downarrow:"↓",downdownarrows:"⇊",downharpoonleft:"⇃",downharpoonright:"⇂",drbkarow:"⤐",drcorn:"⌟",drcrop:"⌌",dscr:"𝒹",dscy:"ѕ",dsol:"⧶",dstrok:"đ",dtdot:"⋱",dtri:"▿",dtrif:"▾",duarr:"⇵",duhar:"⥯",dwangle:"⦦",dzcy:"џ",dzigrarr:"⟿",eDDot:"⩷",eDot:"≑",eacut:"é",eacute:"é",easter:"⩮",ecaron:"ě",ecir:"ê",ecirc:"ê",ecolon:"≕",ecy:"э",edot:"ė",ee:"ⅇ",efDot:"≒",efr:"𝔢",eg:"⪚",egrav:"è",egrave:"è",egs:"⪖",egsdot:"⪘",el:"⪙",elinters:"⏧",ell:"ℓ",els:"⪕",elsdot:"⪗",emacr:"ē",empty:"∅",emptyset:"∅",emptyv:"∅",emsp13:" ",emsp14:" ",emsp:" ",eng:"ŋ",ensp:" ",eogon:"ę",eopf:"𝕖",epar:"⋕",eparsl:"⧣",eplus:"⩱",epsi:"ε",epsilon:"ε",epsiv:"ϵ",eqcirc:"≖",eqcolon:"≕",eqsim:"≂",eqslantgtr:"⪖",eqslantless:"⪕",equals:"=",equest:"≟",equiv:"≡",equivDD:"⩸",eqvparsl:"⧥",erDot:"≓",erarr:"⥱",escr:"ℯ",esdot:"≐",esim:"≂",eta:"η",et:"ð",eth:"ð",eum:"ë",euml:"ë",euro:"€",excl:"!",exist:"∃",expectation:"ℰ",exponentiale:"ⅇ",fallingdotseq:"≒",fcy:"ф",female:"♀",ffilig:"ffi",fflig:"ff",ffllig:"ffl",ffr:"𝔣",filig:"fi",fjlig:"fj",flat:"♭",fllig:"fl",fltns:"▱",fnof:"ƒ",fopf:"𝕗",forall:"∀",fork:"⋔",forkv:"⫙",fpartint:"⨍",frac1:"¼",frac12:"½",frac13:"⅓",frac14:"¼",frac15:"⅕",frac16:"⅙",frac18:"⅛",frac23:"⅔",frac25:"⅖",frac3:"¾",frac34:"¾",frac35:"⅗",frac38:"⅜",frac45:"⅘",frac56:"⅚",frac58:"⅝",frac78:"⅞",frasl:"⁄",frown:"⌢",fscr:"𝒻",gE:"≧",gEl:"⪌",gacute:"ǵ",gamma:"γ",gammad:"ϝ",gap:"⪆",gbreve:"ğ",gcirc:"ĝ",gcy:"г",gdot:"ġ",ge:"≥",gel:"⋛",geq:"≥",geqq:"≧",geqslant:"⩾",ges:"⩾",gescc:"⪩",gesdot:"⪀",gesdoto:"⪂",gesdotol:"⪄",gesl:"⋛︀",gesles:"⪔",gfr:"𝔤",gg:"≫",ggg:"⋙",gimel:"ℷ",gjcy:"ѓ",gl:"≷",glE:"⪒",gla:"⪥",glj:"⪤",gnE:"≩",gnap:"⪊",gnapprox:"⪊",gne:"⪈",gneq:"⪈",gneqq:"≩",gnsim:"⋧",gopf:"𝕘",grave:"`",gscr:"ℊ",gsim:"≳",gsime:"⪎",gsiml:"⪐",g:">",gt:">",gtcc:"⪧",gtcir:"⩺",gtdot:"⋗",gtlPar:"⦕",gtquest:"⩼",gtrapprox:"⪆",gtrarr:"⥸",gtrdot:"⋗",gtreqless:"⋛",gtreqqless:"⪌",gtrless:"≷",gtrsim:"≳",gvertneqq:"≩︀",gvnE:"≩︀",hArr:"⇔",hairsp:" ",half:"½",hamilt:"ℋ",hardcy:"ъ",harr:"↔",harrcir:"⥈",harrw:"↭",hbar:"ℏ",hcirc:"ĥ",hearts:"♥",heartsuit:"♥",hellip:"…",hercon:"⊹",hfr:"𝔥",hksearow:"⤥",hkswarow:"⤦",hoarr:"⇿",homtht:"∻",hookleftarrow:"↩",hookrightarrow:"↪",hopf:"𝕙",horbar:"―",hscr:"𝒽",hslash:"ℏ",hstrok:"ħ",hybull:"⁃",hyphen:"‐",iacut:"í",iacute:"í",ic:"⁣",icir:"î",icirc:"î",icy:"и",iecy:"е",iexc:"¡",iexcl:"¡",iff:"⇔",ifr:"𝔦",igrav:"ì",igrave:"ì",ii:"ⅈ",iiiint:"⨌",iiint:"∭",iinfin:"⧜",iiota:"℩",ijlig:"ij",imacr:"ī",image:"ℑ",imagline:"ℐ",imagpart:"ℑ",imath:"ı",imof:"⊷",imped:"Ƶ",in:"∈",incare:"℅",infin:"∞",infintie:"⧝",inodot:"ı",int:"∫",intcal:"⊺",integers:"ℤ",intercal:"⊺",intlarhk:"⨗",intprod:"⨼",iocy:"ё",iogon:"į",iopf:"𝕚",iota:"ι",iprod:"⨼",iques:"¿",iquest:"¿",iscr:"𝒾",isin:"∈",isinE:"⋹",isindot:"⋵",isins:"⋴",isinsv:"⋳",isinv:"∈",it:"⁢",itilde:"ĩ",iukcy:"і",ium:"ï",iuml:"ï",jcirc:"ĵ",jcy:"й",jfr:"𝔧",jmath:"ȷ",jopf:"𝕛",jscr:"𝒿",jsercy:"ј",jukcy:"є",kappa:"κ",kappav:"ϰ",kcedil:"ķ",kcy:"к",kfr:"𝔨",kgreen:"ĸ",khcy:"х",kjcy:"ќ",kopf:"𝕜",kscr:"𝓀",lAarr:"⇚",lArr:"⇐",lAtail:"⤛",lBarr:"⤎",lE:"≦",lEg:"⪋",lHar:"⥢",lacute:"ĺ",laemptyv:"⦴",lagran:"ℒ",lambda:"λ",lang:"⟨",langd:"⦑",langle:"⟨",lap:"⪅",laqu:"«",laquo:"«",larr:"←",larrb:"⇤",larrbfs:"⤟",larrfs:"⤝",larrhk:"↩",larrlp:"↫",larrpl:"⤹",larrsim:"⥳",larrtl:"↢",lat:"⪫",latail:"⤙",late:"⪭",lates:"⪭︀",lbarr:"⤌",lbbrk:"❲",lbrace:"{",lbrack:"[",lbrke:"⦋",lbrksld:"⦏",lbrkslu:"⦍",lcaron:"ľ",lcedil:"ļ",lceil:"⌈",lcub:"{",lcy:"л",ldca:"⤶",ldquo:"“",ldquor:"„",ldrdhar:"⥧",ldrushar:"⥋",ldsh:"↲",le:"≤",leftarrow:"←",leftarrowtail:"↢",leftharpoondown:"↽",leftharpoonup:"↼",leftleftarrows:"⇇",leftrightarrow:"↔",leftrightarrows:"⇆",leftrightharpoons:"⇋",leftrightsquigarrow:"↭",leftthreetimes:"⋋",leg:"⋚",leq:"≤",leqq:"≦",leqslant:"⩽",les:"⩽",lescc:"⪨",lesdot:"⩿",lesdoto:"⪁",lesdotor:"⪃",lesg:"⋚︀",lesges:"⪓",lessapprox:"⪅",lessdot:"⋖",lesseqgtr:"⋚",lesseqqgtr:"⪋",lessgtr:"≶",lesssim:"≲",lfisht:"⥼",lfloor:"⌊",lfr:"𝔩",lg:"≶",lgE:"⪑",lhard:"↽",lharu:"↼",lharul:"⥪",lhblk:"▄",ljcy:"љ",ll:"≪",llarr:"⇇",llcorner:"⌞",llhard:"⥫",lltri:"◺",lmidot:"ŀ",lmoust:"⎰",lmoustache:"⎰",lnE:"≨",lnap:"⪉",lnapprox:"⪉",lne:"⪇",lneq:"⪇",lneqq:"≨",lnsim:"⋦",loang:"⟬",loarr:"⇽",lobrk:"⟦",longleftarrow:"⟵",longleftrightarrow:"⟷",longmapsto:"⟼",longrightarrow:"⟶",looparrowleft:"↫",looparrowright:"↬",lopar:"⦅",lopf:"𝕝",loplus:"⨭",lotimes:"⨴",lowast:"∗",lowbar:"_",loz:"◊",lozenge:"◊",lozf:"⧫",lpar:"(",lparlt:"⦓",lrarr:"⇆",lrcorner:"⌟",lrhar:"⇋",lrhard:"⥭",lrm:"‎",lrtri:"⊿",lsaquo:"‹",lscr:"𝓁",lsh:"↰",lsim:"≲",lsime:"⪍",lsimg:"⪏",lsqb:"[",lsquo:"‘",lsquor:"‚",lstrok:"ł",l:"<",lt:"<",ltcc:"⪦",ltcir:"⩹",ltdot:"⋖",lthree:"⋋",ltimes:"⋉",ltlarr:"⥶",ltquest:"⩻",ltrPar:"⦖",ltri:"◃",ltrie:"⊴",ltrif:"◂",lurdshar:"⥊",luruhar:"⥦",lvertneqq:"≨︀",lvnE:"≨︀",mDDot:"∺",mac:"¯",macr:"¯",male:"♂",malt:"✠",maltese:"✠",map:"↦",mapsto:"↦",mapstodown:"↧",mapstoleft:"↤",mapstoup:"↥",marker:"▮",mcomma:"⨩",mcy:"м",mdash:"—",measuredangle:"∡",mfr:"𝔪",mho:"℧",micr:"µ",micro:"µ",mid:"∣",midast:"*",midcir:"⫰",middo:"·",middot:"·",minus:"−",minusb:"⊟",minusd:"∸",minusdu:"⨪",mlcp:"⫛",mldr:"…",mnplus:"∓",models:"⊧",mopf:"𝕞",mp:"∓",mscr:"𝓂",mstpos:"∾",mu:"μ",multimap:"⊸",mumap:"⊸",nGg:"⋙̸",nGt:"≫⃒",nGtv:"≫̸",nLeftarrow:"⇍",nLeftrightarrow:"⇎",nLl:"⋘̸",nLt:"≪⃒",nLtv:"≪̸",nRightarrow:"⇏",nVDash:"⊯",nVdash:"⊮",nabla:"∇",nacute:"ń",nang:"∠⃒",nap:"≉",napE:"⩰̸",napid:"≋̸",napos:"ʼn",napprox:"≉",natur:"♮",natural:"♮",naturals:"ℕ",nbs:" ",nbsp:" ",nbump:"≎̸",nbumpe:"≏̸",ncap:"⩃",ncaron:"ň",ncedil:"ņ",ncong:"≇",ncongdot:"⩭̸",ncup:"⩂",ncy:"н",ndash:"–",ne:"≠",neArr:"⇗",nearhk:"⤤",nearr:"↗",nearrow:"↗",nedot:"≐̸",nequiv:"≢",nesear:"⤨",nesim:"≂̸",nexist:"∄",nexists:"∄",nfr:"𝔫",ngE:"≧̸",nge:"≱",ngeq:"≱",ngeqq:"≧̸",ngeqslant:"⩾̸",nges:"⩾̸",ngsim:"≵",ngt:"≯",ngtr:"≯",nhArr:"⇎",nharr:"↮",nhpar:"⫲",ni:"∋",nis:"⋼",nisd:"⋺",niv:"∋",njcy:"њ",nlArr:"⇍",nlE:"≦̸",nlarr:"↚",nldr:"‥",nle:"≰",nleftarrow:"↚",nleftrightarrow:"↮",nleq:"≰",nleqq:"≦̸",nleqslant:"⩽̸",nles:"⩽̸",nless:"≮",nlsim:"≴",nlt:"≮",nltri:"⋪",nltrie:"⋬",nmid:"∤",nopf:"𝕟",no:"¬",not:"¬",notin:"∉",notinE:"⋹̸",notindot:"⋵̸",notinva:"∉",notinvb:"⋷",notinvc:"⋶",notni:"∌",notniva:"∌",notnivb:"⋾",notnivc:"⋽",npar:"∦",nparallel:"∦",nparsl:"⫽⃥",npart:"∂̸",npolint:"⨔",npr:"⊀",nprcue:"⋠",npre:"⪯̸",nprec:"⊀",npreceq:"⪯̸",nrArr:"⇏",nrarr:"↛",nrarrc:"⤳̸",nrarrw:"↝̸",nrightarrow:"↛",nrtri:"⋫",nrtrie:"⋭",nsc:"⊁",nsccue:"⋡",nsce:"⪰̸",nscr:"𝓃",nshortmid:"∤",nshortparallel:"∦",nsim:"≁",nsime:"≄",nsimeq:"≄",nsmid:"∤",nspar:"∦",nsqsube:"⋢",nsqsupe:"⋣",nsub:"⊄",nsubE:"⫅̸",nsube:"⊈",nsubset:"⊂⃒",nsubseteq:"⊈",nsubseteqq:"⫅̸",nsucc:"⊁",nsucceq:"⪰̸",nsup:"⊅",nsupE:"⫆̸",nsupe:"⊉",nsupset:"⊃⃒",nsupseteq:"⊉",nsupseteqq:"⫆̸",ntgl:"≹",ntild:"ñ",ntilde:"ñ",ntlg:"≸",ntriangleleft:"⋪",ntrianglelefteq:"⋬",ntriangleright:"⋫",ntrianglerighteq:"⋭",nu:"ν",num:"#",numero:"№",numsp:" ",nvDash:"⊭",nvHarr:"⤄",nvap:"≍⃒",nvdash:"⊬",nvge:"≥⃒",nvgt:">⃒",nvinfin:"⧞",nvlArr:"⤂",nvle:"≤⃒",nvlt:"<⃒",nvltrie:"⊴⃒",nvrArr:"⤃",nvrtrie:"⊵⃒",nvsim:"∼⃒",nwArr:"⇖",nwarhk:"⤣",nwarr:"↖",nwarrow:"↖",nwnear:"⤧",oS:"Ⓢ",oacut:"ó",oacute:"ó",oast:"⊛",ocir:"ô",ocirc:"ô",ocy:"о",odash:"⊝",odblac:"ő",odiv:"⨸",odot:"⊙",odsold:"⦼",oelig:"œ",ofcir:"⦿",ofr:"𝔬",ogon:"˛",ograv:"ò",ograve:"ò",ogt:"⧁",ohbar:"⦵",ohm:"Ω",oint:"∮",olarr:"↺",olcir:"⦾",olcross:"⦻",oline:"‾",olt:"⧀",omacr:"ō",omega:"ω",omicron:"ο",omid:"⦶",ominus:"⊖",oopf:"𝕠",opar:"⦷",operp:"⦹",oplus:"⊕",or:"∨",orarr:"↻",ord:"º",order:"ℴ",orderof:"ℴ",ordf:"ª",ordm:"º",origof:"⊶",oror:"⩖",orslope:"⩗",orv:"⩛",oscr:"ℴ",oslas:"ø",oslash:"ø",osol:"⊘",otild:"õ",otilde:"õ",otimes:"⊗",otimesas:"⨶",oum:"ö",ouml:"ö",ovbar:"⌽",par:"¶",para:"¶",parallel:"∥",parsim:"⫳",parsl:"⫽",part:"∂",pcy:"п",percnt:"%",period:".",permil:"‰",perp:"⊥",pertenk:"‱",pfr:"𝔭",phi:"φ",phiv:"ϕ",phmmat:"ℳ",phone:"☎",pi:"π",pitchfork:"⋔",piv:"ϖ",planck:"ℏ",planckh:"ℎ",plankv:"ℏ",plus:"+",plusacir:"⨣",plusb:"⊞",pluscir:"⨢",plusdo:"∔",plusdu:"⨥",pluse:"⩲",plusm:"±",plusmn:"±",plussim:"⨦",plustwo:"⨧",pm:"±",pointint:"⨕",popf:"𝕡",poun:"£",pound:"£",pr:"≺",prE:"⪳",prap:"⪷",prcue:"≼",pre:"⪯",prec:"≺",precapprox:"⪷",preccurlyeq:"≼",preceq:"⪯",precnapprox:"⪹",precneqq:"⪵",precnsim:"⋨",precsim:"≾",prime:"′",primes:"ℙ",prnE:"⪵",prnap:"⪹",prnsim:"⋨",prod:"∏",profalar:"⌮",profline:"⌒",profsurf:"⌓",prop:"∝",propto:"∝",prsim:"≾",prurel:"⊰",pscr:"𝓅",psi:"ψ",puncsp:" ",qfr:"𝔮",qint:"⨌",qopf:"𝕢",qprime:"⁗",qscr:"𝓆",quaternions:"ℍ",quatint:"⨖",quest:"?",questeq:"≟",quo:'"',quot:'"',rAarr:"⇛",rArr:"⇒",rAtail:"⤜",rBarr:"⤏",rHar:"⥤",race:"∽̱",racute:"ŕ",radic:"√",raemptyv:"⦳",rang:"⟩",rangd:"⦒",range:"⦥",rangle:"⟩",raqu:"»",raquo:"»",rarr:"→",rarrap:"⥵",rarrb:"⇥",rarrbfs:"⤠",rarrc:"⤳",rarrfs:"⤞",rarrhk:"↪",rarrlp:"↬",rarrpl:"⥅",rarrsim:"⥴",rarrtl:"↣",rarrw:"↝",ratail:"⤚",ratio:"∶",rationals:"ℚ",rbarr:"⤍",rbbrk:"❳",rbrace:"}",rbrack:"]",rbrke:"⦌",rbrksld:"⦎",rbrkslu:"⦐",rcaron:"ř",rcedil:"ŗ",rceil:"⌉",rcub:"}",rcy:"р",rdca:"⤷",rdldhar:"⥩",rdquo:"”",rdquor:"”",rdsh:"↳",real:"ℜ",realine:"ℛ",realpart:"ℜ",reals:"ℝ",rect:"▭",re:"®",reg:"®",rfisht:"⥽",rfloor:"⌋",rfr:"𝔯",rhard:"⇁",rharu:"⇀",rharul:"⥬",rho:"ρ",rhov:"ϱ",rightarrow:"→",rightarrowtail:"↣",rightharpoondown:"⇁",rightharpoonup:"⇀",rightleftarrows:"⇄",rightleftharpoons:"⇌",rightrightarrows:"⇉",rightsquigarrow:"↝",rightthreetimes:"⋌",ring:"˚",risingdotseq:"≓",rlarr:"⇄",rlhar:"⇌",rlm:"‏",rmoust:"⎱",rmoustache:"⎱",rnmid:"⫮",roang:"⟭",roarr:"⇾",robrk:"⟧",ropar:"⦆",ropf:"𝕣",roplus:"⨮",rotimes:"⨵",rpar:")",rpargt:"⦔",rppolint:"⨒",rrarr:"⇉",rsaquo:"›",rscr:"𝓇",rsh:"↱",rsqb:"]",rsquo:"’",rsquor:"’",rthree:"⋌",rtimes:"⋊",rtri:"▹",rtrie:"⊵",rtrif:"▸",rtriltri:"⧎",ruluhar:"⥨",rx:"℞",sacute:"ś",sbquo:"‚",sc:"≻",scE:"⪴",scap:"⪸",scaron:"š",sccue:"≽",sce:"⪰",scedil:"ş",scirc:"ŝ",scnE:"⪶",scnap:"⪺",scnsim:"⋩",scpolint:"⨓",scsim:"≿",scy:"с",sdot:"⋅",sdotb:"⊡",sdote:"⩦",seArr:"⇘",searhk:"⤥",searr:"↘",searrow:"↘",sec:"§",sect:"§",semi:";",seswar:"⤩",setminus:"∖",setmn:"∖",sext:"✶",sfr:"𝔰",sfrown:"⌢",sharp:"♯",shchcy:"щ",shcy:"ш",shortmid:"∣",shortparallel:"∥",sh:"­",shy:"­",sigma:"σ",sigmaf:"ς",sigmav:"ς",sim:"∼",simdot:"⩪",sime:"≃",simeq:"≃",simg:"⪞",simgE:"⪠",siml:"⪝",simlE:"⪟",simne:"≆",simplus:"⨤",simrarr:"⥲",slarr:"←",smallsetminus:"∖",smashp:"⨳",smeparsl:"⧤",smid:"∣",smile:"⌣",smt:"⪪",smte:"⪬",smtes:"⪬︀",softcy:"ь",sol:"/",solb:"⧄",solbar:"⌿",sopf:"𝕤",spades:"♠",spadesuit:"♠",spar:"∥",sqcap:"⊓",sqcaps:"⊓︀",sqcup:"⊔",sqcups:"⊔︀",sqsub:"⊏",sqsube:"⊑",sqsubset:"⊏",sqsubseteq:"⊑",sqsup:"⊐",sqsupe:"⊒",sqsupset:"⊐",sqsupseteq:"⊒",squ:"□",square:"□",squarf:"▪",squf:"▪",srarr:"→",sscr:"𝓈",ssetmn:"∖",ssmile:"⌣",sstarf:"⋆",star:"☆",starf:"★",straightepsilon:"ϵ",straightphi:"ϕ",strns:"¯",sub:"⊂",subE:"⫅",subdot:"⪽",sube:"⊆",subedot:"⫃",submult:"⫁",subnE:"⫋",subne:"⊊",subplus:"⪿",subrarr:"⥹",subset:"⊂",subseteq:"⊆",subseteqq:"⫅",subsetneq:"⊊",subsetneqq:"⫋",subsim:"⫇",subsub:"⫕",subsup:"⫓",succ:"≻",succapprox:"⪸",succcurlyeq:"≽",succeq:"⪰",succnapprox:"⪺",succneqq:"⪶",succnsim:"⋩",succsim:"≿",sum:"∑",sung:"♪",sup:"⊃",sup1:"¹",sup2:"²",sup3:"³",supE:"⫆",supdot:"⪾",supdsub:"⫘",supe:"⊇",supedot:"⫄",suphsol:"⟉",suphsub:"⫗",suplarr:"⥻",supmult:"⫂",supnE:"⫌",supne:"⊋",supplus:"⫀",supset:"⊃",supseteq:"⊇",supseteqq:"⫆",supsetneq:"⊋",supsetneqq:"⫌",supsim:"⫈",supsub:"⫔",supsup:"⫖",swArr:"⇙",swarhk:"⤦",swarr:"↙",swarrow:"↙",swnwar:"⤪",szli:"ß",szlig:"ß",target:"⌖",tau:"τ",tbrk:"⎴",tcaron:"ť",tcedil:"ţ",tcy:"т",tdot:"⃛",telrec:"⌕",tfr:"𝔱",there4:"∴",therefore:"∴",theta:"θ",thetasym:"ϑ",thetav:"ϑ",thickapprox:"≈",thicksim:"∼",thinsp:" ",thkap:"≈",thksim:"∼",thor:"þ",thorn:"þ",tilde:"˜",time:"×",times:"×",timesb:"⊠",timesbar:"⨱",timesd:"⨰",tint:"∭",toea:"⤨",top:"⊤",topbot:"⌶",topcir:"⫱",topf:"𝕥",topfork:"⫚",tosa:"⤩",tprime:"‴",trade:"™",triangle:"▵",triangledown:"▿",triangleleft:"◃",trianglelefteq:"⊴",triangleq:"≜",triangleright:"▹",trianglerighteq:"⊵",tridot:"◬",trie:"≜",triminus:"⨺",triplus:"⨹",trisb:"⧍",tritime:"⨻",trpezium:"⏢",tscr:"𝓉",tscy:"ц",tshcy:"ћ",tstrok:"ŧ",twixt:"≬",twoheadleftarrow:"↞",twoheadrightarrow:"↠",uArr:"⇑",uHar:"⥣",uacut:"ú",uacute:"ú",uarr:"↑",ubrcy:"ў",ubreve:"ŭ",ucir:"û",ucirc:"û",ucy:"у",udarr:"⇅",udblac:"ű",udhar:"⥮",ufisht:"⥾",ufr:"𝔲",ugrav:"ù",ugrave:"ù",uharl:"↿",uharr:"↾",uhblk:"▀",ulcorn:"⌜",ulcorner:"⌜",ulcrop:"⌏",ultri:"◸",umacr:"ū",um:"¨",uml:"¨",uogon:"ų",uopf:"𝕦",uparrow:"↑",updownarrow:"↕",upharpoonleft:"↿",upharpoonright:"↾",uplus:"⊎",upsi:"υ",upsih:"ϒ",upsilon:"υ",upuparrows:"⇈",urcorn:"⌝",urcorner:"⌝",urcrop:"⌎",uring:"ů",urtri:"◹",uscr:"𝓊",utdot:"⋰",utilde:"ũ",utri:"▵",utrif:"▴",uuarr:"⇈",uum:"ü",uuml:"ü",uwangle:"⦧",vArr:"⇕",vBar:"⫨",vBarv:"⫩",vDash:"⊨",vangrt:"⦜",varepsilon:"ϵ",varkappa:"ϰ",varnothing:"∅",varphi:"ϕ",varpi:"ϖ",varpropto:"∝",varr:"↕",varrho:"ϱ",varsigma:"ς",varsubsetneq:"⊊︀",varsubsetneqq:"⫋︀",varsupsetneq:"⊋︀",varsupsetneqq:"⫌︀",vartheta:"ϑ",vartriangleleft:"⊲",vartriangleright:"⊳",vcy:"в",vdash:"⊢",vee:"∨",veebar:"⊻",veeeq:"≚",vellip:"⋮",verbar:"|",vert:"|",vfr:"𝔳",vltri:"⊲",vnsub:"⊂⃒",vnsup:"⊃⃒",vopf:"𝕧",vprop:"∝",vrtri:"⊳",vscr:"𝓋",vsubnE:"⫋︀",vsubne:"⊊︀",vsupnE:"⫌︀",vsupne:"⊋︀",vzigzag:"⦚",wcirc:"ŵ",wedbar:"⩟",wedge:"∧",wedgeq:"≙",weierp:"℘",wfr:"𝔴",wopf:"𝕨",wp:"℘",wr:"≀",wreath:"≀",wscr:"𝓌",xcap:"⋂",xcirc:"◯",xcup:"⋃",xdtri:"▽",xfr:"𝔵",xhArr:"⟺",xharr:"⟷",xi:"ξ",xlArr:"⟸",xlarr:"⟵",xmap:"⟼",xnis:"⋻",xodot:"⨀",xopf:"𝕩",xoplus:"⨁",xotime:"⨂",xrArr:"⟹",xrarr:"⟶",xscr:"𝓍",xsqcup:"⨆",xuplus:"⨄",xutri:"△",xvee:"⋁",xwedge:"⋀",yacut:"ý",yacute:"ý",yacy:"я",ycirc:"ŷ",ycy:"ы",ye:"¥",yen:"¥",yfr:"𝔶",yicy:"ї",yopf:"𝕪",yscr:"𝓎",yucy:"ю",yum:"ÿ",yuml:"ÿ",zacute:"ź",zcaron:"ž",zcy:"з",zdot:"ż",zeetrf:"ℨ",zeta:"ζ",zfr:"𝔷",zhcy:"ж",zigrarr:"⇝",zopf:"𝕫",zscr:"𝓏",zwj:"‍",zwnj:"‌"}},function(e,t,r){const i=r(287);const n=r(809);const a={parse:i,stringify:n};e.exports=a},,function(e){"use strict";e.exports=interrupt;function interrupt(e,t,r,i){var n=e.length;var a=-1;var u;var s;while(++a>0},ToUint32:function(e){return e>>>0}}}();var u=Math.LN2,s=Math.abs,o=Math.floor,l=Math.log,f=Math.min,c=Math.pow,h=Math.round;function configureProperties(e){if(v&&p){var t=v(e),r;for(r=0;rn)throw new RangeError("Array too large for polyfill");function makeArrayAccessor(t){p(e,t,{get:function(){return e._getter(t)},set:function(r){e._setter(t,r)},enumerable:true,configurable:false})}var t;for(t=0;t>r}function as_unsigned(e,t){var r=32-t;return e<>>r}function packI8(e){return[e&255]}function unpackI8(e){return as_signed(e[0],8)}function packU8(e){return[e&255]}function unpackU8(e){return as_unsigned(e[0],8)}function packU8Clamped(e){e=h(Number(e));return[e<0?0:e>255?255:e&255]}function packI16(e){return[e>>8&255,e&255]}function unpackI16(e){return as_signed(e[0]<<8|e[1],16)}function packU16(e){return[e>>8&255,e&255]}function unpackU16(e){return as_unsigned(e[0]<<8|e[1],16)}function packI32(e){return[e>>24&255,e>>16&255,e>>8&255,e&255]}function unpackI32(e){return as_signed(e[0]<<24|e[1]<<16|e[2]<<8|e[3],32)}function packU32(e){return[e>>24&255,e>>16&255,e>>8&255,e&255]}function unpackU32(e){return as_unsigned(e[0]<<24|e[1]<<16|e[2]<<8|e[3],32)}function packIEEE754(e,t,r){var i=(1<.5)return t+1;return t%2?t+1:t}if(e!==e){a=(1<=c(2,1-i)){a=f(o(l(e)/u),1023);h=roundToEven(e/c(2,a)*c(2,r));if(h/c(2,r)>=2){a=a+1;h=1}if(a>i){a=(1<>1}}i.reverse();s=i.join("");o=(1<0){return l*c(2,f-o)*(1+h/c(2,r))}else if(h!==0){return l*c(2,-(o-1))*(h/c(2,r))}else{return l<0?-0:0}}function unpackF64(e){return unpackIEEE754(e,11,52)}function packF64(e){return packIEEE754(e,11,52)}function unpackF32(e){return unpackIEEE754(e,8,23)}function packF32(e){return packIEEE754(e,8,23)}(function(){var e=function ArrayBuffer(e){e=a.ToInt32(e);if(e<0)throw new RangeError("ArrayBuffer size is not a small enough positive integer");this.byteLength=e;this._bytes=[];this._bytes.length=e;var t;for(t=0;tthis.buffer.byteLength){throw new RangeError("byteOffset out of range")}if(this.byteOffset%this.BYTES_PER_ELEMENT){throw new RangeError("ArrayBuffer length minus the byteOffset is not a multiple of the element size.")}if(arguments.length<3){this.byteLength=this.buffer.byteLength-this.byteOffset;if(this.byteLength%this.BYTES_PER_ELEMENT){throw new RangeError("length of buffer minus byteOffset not a multiple of the element size")}this.length=this.byteLength/this.BYTES_PER_ELEMENT}else{this.length=a.ToUint32(i);this.byteLength=this.length*this.BYTES_PER_ELEMENT}if(this.byteOffset+this.byteLength>this.buffer.byteLength){throw new RangeError("byteOffset and length reference an area beyond the end of the buffer")}}else{throw new TypeError("Unexpected argument type(s)")}this.constructor=s;configureProperties(this);makeArrayAccessors(this)};s.prototype=new r;s.prototype.BYTES_PER_ELEMENT=t;s.prototype._pack=n;s.prototype._unpack=u;s.BYTES_PER_ELEMENT=t;s.prototype._getter=function(e){if(arguments.length<1)throw new SyntaxError("Not enough arguments");e=a.ToUint32(e);if(e>=this.length){return i}var t=[],r,n;for(r=0,n=this.byteOffset+e*this.BYTES_PER_ELEMENT;r=this.length){return i}var r=this._pack(t),n,u;for(n=0,u=this.byteOffset+e*this.BYTES_PER_ELEMENT;nthis.length){throw new RangeError("Offset plus length of array is out of range")}f=this.byteOffset+n*this.BYTES_PER_ELEMENT;c=r.length*this.BYTES_PER_ELEMENT;if(r.buffer===this.buffer){h=[];for(s=0,o=r.byteOffset;sthis.length){throw new RangeError("Offset plus length of array is out of range")}for(s=0;sr?r:e}e=a.ToInt32(e);t=a.ToInt32(t);if(arguments.length<1){e=0}if(arguments.length<2){t=this.length}if(e<0){e=this.length+e}if(t<0){t=this.length+t}e=clamp(e,0,this.length);t=clamp(t,0,this.length);var r=t-e;if(r<0){r=0}return new this.constructor(this.buffer,this.byteOffset+e*this.BYTES_PER_ELEMENT,r)};return s}var n=makeConstructor(1,packI8,unpackI8);var u=makeConstructor(1,packU8,unpackU8);var s=makeConstructor(1,packU8Clamped,unpackU8);var o=makeConstructor(2,packI16,unpackI16);var l=makeConstructor(2,packU16,unpackU16);var f=makeConstructor(4,packI32,unpackI32);var c=makeConstructor(4,packU32,unpackU32);var h=makeConstructor(4,packF32,unpackF32);var p=makeConstructor(8,packF64,unpackF64);t.Int8Array=t.Int8Array||n;t.Uint8Array=t.Uint8Array||u;t.Uint8ClampedArray=t.Uint8ClampedArray||s;t.Int16Array=t.Int16Array||o;t.Uint16Array=t.Uint16Array||l;t.Int32Array=t.Int32Array||f;t.Uint32Array=t.Uint32Array||c;t.Float32Array=t.Float32Array||h;t.Float64Array=t.Float64Array||p})();(function(){function r(e,t){return a.IsCallable(e.get)?e.get(t):e[t]}var e=function(){var e=new t.Uint16Array([4660]),i=new t.Uint8Array(e.buffer);return r(i,0)===18}();var i=function DataView(e,r,i){if(arguments.length===0){e=new t.ArrayBuffer(0)}else if(!(e instanceof t.ArrayBuffer||a.Class(e)==="ArrayBuffer")){throw new TypeError("TypeError")}this.buffer=e||new t.ArrayBuffer(0);this.byteOffset=a.ToUint32(r);if(this.byteOffset>this.buffer.byteLength){throw new RangeError("byteOffset out of range")}if(arguments.length<3){this.byteLength=this.buffer.byteLength-this.byteOffset}else{this.byteLength=a.ToUint32(i)}if(this.byteOffset+this.byteLength>this.buffer.byteLength){throw new RangeError("byteOffset and length reference an area beyond the end of the buffer")}configureProperties(this)};function makeGetter(i){return function(n,u){n=a.ToUint32(n);if(n+i.BYTES_PER_ELEMENT>this.byteLength){throw new RangeError("Array index out of range")}n+=this.byteOffset;var s=new t.Uint8Array(this.buffer,n,i.BYTES_PER_ELEMENT),o=[],l;for(l=0;lthis.byteLength){throw new RangeError("Array index out of range")}var o=new i([u]),l=new t.Uint8Array(o.buffer),f=[],c,h;for(c=0;c=e.length?e.length:n+r;t.message+=` while parsing near '${i===0?"":"..."}${e.slice(i,a)}${a===e.length?"":"..."}'`}else{t.message+=` while parsing '${e.slice(0,r*2)}'`}throw t}}},,function(e){"use strict";e.exports=function isArrayish(e){if(!e){return false}return e instanceof Array||Array.isArray(e)||e.length>=0&&e.splice instanceof Function}},,,function(e){"use strict";e.exports=strikethrough;var t="~";var r=t+t;function strikethrough(e){return r+this.all(e).join("")+r}},,function(e,t,r){"use strict";var i=r(495);var n=r(704);var a=r(682);var u=r(839);var s=r(526);e.exports=i("remark-lint:no-heading-indent",noHeadingIndent);var o=u.start;function noHeadingIndent(e,t){var r=String(t);var i=r.length;a(e,"heading",visitor);function visitor(e){var a;var u;var l;var f;var c;if(s(e)){return}a=o(e);u=a.offset;l=u-1;while(++l-1&&r.charAt(i)!=="\n"){t.message("Missing newline character at end of file")}}},,,function(e,t,r){"use strict";var i=r(171);var n=r(111);e.exports=strikethrough;strikethrough.locator=n;var a="~";var u="~~";function strikethrough(e,t,r){var n=this;var s="";var o="";var l="";var f="";var c;var h;var p;if(!n.options.gfm||t.charAt(0)!==a||t.charAt(1)!==a||i(t.charAt(2))){return}c=1;h=t.length;p=e.now();p.column+=2;p.offset+=2;while(++c?@[\\\]^`{|}~_]/;function copy(e,t){var r=e.length;var u=t.length;var s=[];var o=0;var l=0;var f;while(l0){r=Math.min(10,Math.floor(r));o=" ".substr(0,r)}}else if(typeof r==="string"){o=r.substr(0,10)}return serializeProperty("",{"":e});function serializeProperty(e,t){let r=t[e];if(r!=null){if(typeof r.toJSON5==="function"){r=r.toJSON5(e)}else if(typeof r.toJSON==="function"){r=r.toJSON(e)}}if(s){r=s.call(t,e,r)}if(r instanceof Number){r=Number(r)}else if(r instanceof String){r=String(r)}else if(r instanceof Boolean){r=r.valueOf()}switch(r){case null:return"null";case true:return"true";case false:return"false"}if(typeof r==="string"){return quoteString(r,false)}if(typeof r==="number"){return String(r)}if(typeof r==="object"){return Array.isArray(r)?serializeArray(r):serializeObject(r)}return undefined}function quoteString(e){const t={"'":.1,'"':.2};const r={"'":"\\'",'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\v":"\\v","\0":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"};let n="";for(let a=0;at[e]=0){throw TypeError("Converting circular structure to JSON5")}n.push(e);let t=a;a=a+o;let r=u||Object.keys(e);let i=[];for(const t of r){const r=serializeProperty(t,e);if(r!==undefined){let e=serializeKey(t)+":";if(o!==""){e+=" "}e+=r;i.push(e)}}let s;if(i.length===0){s="{}"}else{let e;if(o===""){e=i.join(",");s="{"+e+"}"}else{let r=",\n"+a;e=i.join(r);s="{\n"+a+e+",\n"+t+"}"}}n.pop();a=t;return s}function serializeKey(e){if(e.length===0){return quoteString(e,true)}const t=String.fromCodePoint(e.codePointAt(0));if(!i.isIdStartChar(t)){return quoteString(e,true)}for(let r=t.length;r=0){throw TypeError("Converting circular structure to JSON5")}n.push(e);let t=a;a=a+o;let r=[];for(let t=0;t=n){return t.substr(0,n)}while(n>t.length&&i>1){if(i&1){t+=e}i>>=1;e+=e}t+=e;t=t.substr(0,n);return t}},,function(e,t,r){"use strict";var i=r(495);var n=r(839);var a=r(526);var u=r(135);var s=r(682);e.exports=i("remark-lint:no-duplicate-definitions",noDuplicateDefinitions);var o="Do not use definitions with the same identifier";function noDuplicateDefinitions(e,t){var r={};s(e,["definition","footnoteDefinition"],validate);function validate(e){var i;var s;if(!a(e)){i=e.identifier;s=r[i];if(s&&s.type){t.message(o+" ("+u(n.start(s))+")",e)}r[i]=e}}}},function(e){"use strict";e.exports=is;function is(e,t,r,i,n){var a=i!==null&&i!==undefined;var u=r!==null&&r!==undefined;var s=convert(e);if(u&&(typeof r!=="number"||r<0||r===Infinity)){throw new Error("Expected positive finite index or child node")}if(a&&(!is(null,i)||!i.children)){throw new Error("Expected parent node")}if(!t||!t.type||typeof t.type!=="string"){return false}if(a!==u){throw new Error("Expected both parent and index")}return Boolean(s.call(n,t,r,i))}function convert(e){if(typeof e==="string"){return typeFactory(e)}if(e===null||e===undefined){return ok}if(typeof e==="object"){return("length"in e?anyFactory:matchesFactory)(e)}if(typeof e==="function"){return e}throw new Error("Expected function, string, or object as test")}function convertAll(e){var t=[];var r=e.length;var i=-1;while(++i=u){v--;break}d+=g}D="";m="";while(++v{t=t||process.argv;const r=e.startsWith("-")?"":e.length===1?"-":"--";const i=t.indexOf(r+e);const n=t.indexOf("--");return i!==-1&&(n===-1?true:i0){s="Remove "+u+" "+n("line",u)+" "+(a>0?"before":"after")+" node";t.message(s,r)}}function visitChild(e,t,r){var i=r[t-1];var n=2;if(i&&!s(i)&&!s(e)){if(i.type==="list"&&e.type==="list"||e.type==="code"&&i.type==="list"&&!e.lang){n++}compare(u.end(i),u.start(e),n)}}}},,function(e,t,r){"use strict";var i=r(123);var n=r(341);var a=r(627);var u=r(406);var s=r(803);var o=r(647);e.exports=i().use(n).use(a).use(u).use(s).use(o)},,function(e,t,r){"use strict";var i=r(495);var n=r(704);var a=r(682);var u=r(839);var s=r(526);e.exports=i("remark-lint:list-item-bullet-indent",listItemBulletIndent);var o=u.start;function listItemBulletIndent(e,t){var r=String(t);a(e,"list",visitor);function visitor(e){e.children.forEach(visitItems)}function visitItems(e){var i;var a;var u;if(!s(e)){i=o(e.children[0]);a=r.slice(o(e).offset,i.offset).match(/^\s*/)[0].length;if(a!==0){u="Incorrect indentation before bullet: remove "+a+" "+n("space",a);t.message(u,{line:i.line,column:i.column-a})}}}}},function(e){e.exports=function(e,t){if(!t)t={};var r=t.hsep===undefined?" ":t.hsep;var i=t.align||[];var n=t.stringLength||function(e){return String(e).length};var a=reduce(e,function(e,t){forEach(t,function(t,r){var i=dotindex(t);if(!e[r]||i>e[r])e[r]=i});return e},[]);var u=map(e,function(e){return map(e,function(e,t){var r=String(e);if(i[t]==="."){var u=dotindex(r);var s=a[t]+(/\./.test(r)?1:2)-(n(r)-u);return r+Array(s).join(" ")}else return r})});var s=reduce(u,function(e,t){forEach(t,function(t,r){var i=n(t);if(!e[r]||i>e[r])e[r]=i});return e},[]);return map(u,function(e){return map(e,function(e,t){var r=s[t]-n(e)||0;var a=Array(Math.max(r+1,1)).join(" ");if(i[t]==="r"||i[t]==="."){return a+e}if(i[t]==="c"){return Array(Math.ceil(r/2+1)).join(" ")+e+Array(Math.floor(r/2+1)).join(" ")}return e+a}).join(r).replace(/\s+$/,"")}).join("\n")};function dotindex(e){var t=/\.[^.]*$/.exec(e);return t?t.index+1:e.length}function reduce(e,t,r){if(e.reduce)return e.reduce(t,r);var i=0;var n=arguments.length>=3?r:e[i++];for(;ir&&a0?"add":"remove")+" "+Math.abs(h)+" "+n("space",h);t.message(p,s)}}}}},,,,,function(e,t,r){"use strict";var i=r(721);e.exports=decodeEntity;var n={}.hasOwnProperty;function decodeEntity(e){return n.call(i,e)?i[e]:false}},function(e,t,r){"use strict";var i=r(495);var n=r(682);var a=r(839);var u=r(526);e.exports=i("remark-lint:definition-spacing",definitionSpacing);var s=/^\s*\[((?:\\[\s\S]|[^[\]])+)]/;var o="Do not use consecutive white-space in definition labels";function definitionSpacing(e,t){var r=String(t);n(e,["definition","footnoteDefinition"],validate);function validate(e){var i=a.start(e).offset;var n=a.end(e).offset;if(!u(e)&&/[ \t\n]{2,}/.test(r.slice(i,n).match(s)[1])){t.message(o,e)}}}},function(e,t,r){"use strict";var i=r(336);var n=r(780);e.exports=unherit;function unherit(e){var t;var r;var a;n(Of,e);n(From,Of);t=Of.prototype;for(r in t){a=t[r];if(a&&typeof a==="object"){t[r]="concat"in a?a.concat():i(a)}}return Of;function From(t){return e.apply(this,t)}function Of(){if(!(this instanceof Of)){return new From(arguments)}return e.apply(this,arguments)}}},function(e){"use strict";const t=e=>{let t=false;let r=false;let i=false;for(let n=0;n{if(!(typeof e==="string"||Array.isArray(e))){throw new TypeError("Expected the input to be `string | string[]`")}r=Object.assign({pascalCase:false},r);const i=e=>r.pascalCase?e.charAt(0).toUpperCase()+e.slice(1):e;if(Array.isArray(e)){e=e.map(e=>e.trim()).filter(e=>e.length).join("-")}else{e=e.trim()}if(e.length===0){return""}if(e.length===1){return r.pascalCase?e.toUpperCase():e.toLowerCase()}const n=e!==e.toLowerCase();if(n){e=t(e)}e=e.replace(/^[_.\- ]+/,"").toLowerCase().replace(/[_.\- ]+(\w|$)/g,(e,t)=>t.toUpperCase()).replace(/\d+(\w|$)/g,e=>e.toUpperCase());return i(e)};e.exports=r;e.exports.default=r},,function(e,t,r){"use strict";var i=r(211);function resolveYamlMerge(e){return e==="<<"||e===null}e.exports=new i("tag:yaml.org,2002:merge",{kind:"scalar",resolve:resolveYamlMerge})},function(e){"use strict";e.exports={gfm:true,commonmark:false,pedantic:false,entities:"false",setext:false,closeAtx:false,looseTable:false,spacedTable:true,paddedTable:true,stringLength:stringLength,incrementListMarker:true,fences:false,fence:"`",bullet:"-",listItemIndent:"tab",rule:"*",ruleSpaces:true,ruleRepetition:3,strong:"*",emphasis:"_"};function stringLength(e){return e.length}},function(e,t,r){"use strict";var i=r(197);var n=r(520);var a=r(439);var u=r(25);var s=r(908);var o=r(895);e.exports=parseEntities;var l={}.hasOwnProperty;var f=String.fromCharCode;var c=Function.prototype;var h={warning:null,reference:null,text:null,warningContext:null,referenceContext:null,textContext:null,position:{},additional:null,attribute:false,nonTerminated:true};var p="named";var v="hexadecimal";var d="decimal";var D={};D[v]=16;D[d]=10;var m={};m[p]=s;m[d]=a;m[v]=u;var g=1;var E=2;var A=3;var C=4;var y=5;var w=6;var x=7;var b={};b[g]="Named character references must be terminated by a semicolon";b[E]="Numeric character references must be terminated by a semicolon";b[A]="Named character references cannot be empty";b[C]="Numeric character references cannot be empty";b[y]="Named character references must be known";b[w]="Numeric character references cannot be disallowed";b[x]="Numeric character references cannot be outside the permissible Unicode range";function parseEntities(e,t){var r={};var i;var n;if(!t){t={}}for(n in h){i=t[n];r[n]=i===null||i===undefined?h[n]:i}if(r.position.indent||r.position.start){r.indent=r.position.indent||[];r.position=r.position.start}return parse(e,r)}function parse(e,t){var r=t.additional;var a=t.nonTerminated;var u=t.text;var h=t.reference;var F=t.warning;var S=t.textContext;var B=t.referenceContext;var k=t.warningContext;var O=t.position;var P=t.indent||[];var T=e.length;var I=0;var M=-1;var L=O.column||1;var R=O.line||1;var j="";var U=[];var N;var J;var z;var X;var G;var q;var W;var _;var V;var Y;var H;var $;var Z;var Q;var K;var ee;var te;var re;var ie;ee=now();_=F?parseError:c;I--;T++;while(++I65535){q-=65536;Y+=f(q>>>(10&1023)|55296);q=56320|q&1023}q=Y+f(q)}}if(!q){X=e.slice(Z-1,ie);j+=X;L+=X.length;I=ie-1}else{flush();ee=now();I=ie-1;L+=ie-Z+1;U.push(q);te=now();te.offset++;if(h){h.call(B,q,{start:ee,end:te},e.slice(Z-1,ie))}ee=te}}}return U.join("");function now(){return{line:R,column:L,offset:I+(O.offset||0)}}function parseError(e,t){var r=now();r.column+=t;r.offset+=t;F.call(k,b[e],r,e)}function at(t){return e.charAt(t)}function flush(){if(j){U.push(j);if(u){u.call(S,j,{start:ee,end:now()})}j=""}}}function prohibited(e){return e>=55296&&e<=57343||e>1114111}function disallowed(e){return e>=1&&e<=8||e===11||e>=13&&e<=31||e>=127&&e<=159||e>=64976&&e<=65007||(e&65535)===65535||(e&65535)===65534}},,,function(e,t,r){"use strict";var i=r(36);var n=r(116);var a=r(171);var u=r(82);e.exports=emphasis;emphasis.locator=u;var s="*";var o="_";var l="\\";function emphasis(e,t,r){var u=this;var f=0;var c=t.charAt(f);var h;var p;var v;var d;var D;var m;var g;if(c!==s&&c!==o){return}p=u.options.pedantic;D=c;v=c;m=t.length;f++;d="";c="";if(p&&a(t.charAt(f))){return}while(f0){if(typeof t!=="string"&&!a.objectMode&&Object.getPrototypeOf(t)!==l.prototype){t=_uint8ArrayToBuffer(t)}if(i){if(a.endEmitted)e.emit("error",new Error("stream.unshift() after end event"));else addChunk(e,a,t,true)}else if(a.ended){e.emit("error",new Error("stream.push() after EOF"))}else{a.reading=false;if(a.decoder&&!r){t=a.decoder.write(t);if(a.objectMode||t.length!==0)addChunk(e,a,t,false);else maybeReadMore(e,a)}else{addChunk(e,a,t,false)}}}else if(!i){a.reading=false}}return needMoreData(a)}function addChunk(e,t,r,i){if(t.flowing&&t.length===0&&!t.sync){e.emit("data",r);e.read(0)}else{t.length+=t.objectMode?1:r.length;if(i)t.buffer.unshift(r);else t.buffer.push(r);if(t.needReadable)emitReadable(e)}maybeReadMore(e,t)}function chunkInvalid(e,t){var r;if(!_isUint8Array(t)&&typeof t!=="string"&&t!==undefined&&!e.objectMode){r=new TypeError("Invalid non-string/buffer chunk")}return r}function needMoreData(e){return!e.ended&&(e.needReadable||e.length=g){e=g}else{e--;e|=e>>>1;e|=e>>>2;e|=e>>>4;e|=e>>>8;e|=e>>>16;e++}return e}function howMuchToRead(e,t){if(e<=0||t.length===0&&t.ended)return 0;if(t.objectMode)return 1;if(e!==e){if(t.flowing&&t.length)return t.buffer.head.data.length;else return t.length}if(e>t.highWaterMark)t.highWaterMark=computeNewHighWaterMark(e);if(e<=t.length)return e;if(!t.ended){t.needReadable=true;return 0}return t.length}Readable.prototype.read=function(e){p("read",e);e=parseInt(e,10);var t=this._readableState;var r=e;if(e!==0)t.emittedReadable=false;if(e===0&&t.needReadable&&(t.length>=t.highWaterMark||t.ended)){p("read: emitReadable",t.length,t.ended);if(t.length===0&&t.ended)endReadable(this);else emitReadable(this);return null}e=howMuchToRead(e,t);if(e===0&&t.ended){if(t.length===0)endReadable(this);return null}var i=t.needReadable;p("need readable",i);if(t.length===0||t.length-e0)n=fromList(e,t);else n=null;if(n===null){t.needReadable=true;e=0}else{t.length-=e}if(t.length===0){if(!t.ended)t.needReadable=true;if(r!==e&&t.ended)endReadable(this)}if(n!==null)this.emit("data",n);return n};function onEofChunk(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();if(r&&r.length){t.buffer.push(r);t.length+=t.objectMode?1:r.length}}t.ended=true;emitReadable(e)}function emitReadable(e){var t=e._readableState;t.needReadable=false;if(!t.emittedReadable){p("emitReadable",t.flowing);t.emittedReadable=true;if(t.sync)i.nextTick(emitReadable_,e);else emitReadable_(e)}}function emitReadable_(e){p("emit readable");e.emit("readable");flow(e)}function maybeReadMore(e,t){if(!t.readingMore){t.readingMore=true;i.nextTick(maybeReadMore_,e,t)}}function maybeReadMore_(e,t){var r=t.length;while(!t.reading&&!t.flowing&&!t.ended&&t.length1&&indexOf(n.pipes,e)!==-1)&&!l){p("false write response, pause",r._readableState.awaitDrain);r._readableState.awaitDrain++;f=true}r.pause()}}function onerror(t){p("onerror",t);unpipe();e.removeListener("error",onerror);if(s(e,"error")===0)e.emit("error",t)}prependListener(e,"error",onerror);function onclose(){e.removeListener("finish",onfinish);unpipe()}e.once("close",onclose);function onfinish(){p("onfinish");e.removeListener("close",onclose);unpipe()}e.once("finish",onfinish);function unpipe(){p("unpipe");r.unpipe(e)}e.emit("pipe",r);if(!n.flowing){p("pipe resume");r.resume()}return e};function pipeOnDrain(e){return function(){var t=e._readableState;p("pipeOnDrain",t.awaitDrain);if(t.awaitDrain)t.awaitDrain--;if(t.awaitDrain===0&&s(e,"data")){t.flowing=true;flow(e)}}}Readable.prototype.unpipe=function(e){var t=this._readableState;var r={hasUnpiped:false};if(t.pipesCount===0)return this;if(t.pipesCount===1){if(e&&e!==t.pipes)return this;if(!e)e=t.pipes;t.pipes=null;t.pipesCount=0;t.flowing=false;if(e)e.emit("unpipe",this,r);return this}if(!e){var i=t.pipes;var n=t.pipesCount;t.pipes=null;t.pipesCount=0;t.flowing=false;for(var a=0;a=t.length){if(t.decoder)r=t.buffer.join("");else if(t.buffer.length===1)r=t.buffer.head.data;else r=t.buffer.concat(t.length);t.buffer.clear()}else{r=fromListPartial(e,t.buffer,t.decoder)}return r}function fromListPartial(e,t,r){var i;if(ea.length?a.length:e;if(u===a.length)n+=a;else n+=a.slice(0,e);e-=u;if(e===0){if(u===a.length){++i;if(r.next)t.head=r.next;else t.head=t.tail=null}else{t.head=r;r.data=a.slice(u)}break}++i}t.length-=i;return n}function copyFromBuffer(e,t){var r=l.allocUnsafe(e);var i=t.head;var n=1;i.data.copy(r);e-=i.data.length;while(i=i.next){var a=i.data;var u=e>a.length?a.length:e;a.copy(r,r.length-e,0,u);e-=u;if(e===0){if(u===a.length){++n;if(i.next)t.head=i.next;else t.head=t.tail=null}else{t.head=i;i.data=a.slice(u)}break}++n}t.length-=n;return r}function endReadable(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');if(!t.endEmitted){t.ended=true;i.nextTick(endReadableNT,t,e)}}function endReadableNT(e,t){if(!e.endEmitted&&e.length===0){e.endEmitted=true;t.readable=false;t.emit("end")}}function indexOf(e,t){for(var r=0,i=e.length;r=f){continue}y="";while(v=2){t.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221]}}catch(e){}t.inspectOpts=Object.keys(process.env).filter(function(e){return/^debug_/i.test(e)}).reduce(function(e,t){var r=t.substring(6).toLowerCase().replace(/_([a-z])/g,function(e,t){return t.toUpperCase()});var i=process.env[t];if(/^(yes|on|true|enabled)$/i.test(i)){i=true}else if(/^(no|off|false|disabled)$/i.test(i)){i=false}else if(i==="null"){i=null}else{i=Number(i)}e[r]=i;return e},{});function useColors(){return"colors"in t.inspectOpts?Boolean(t.inspectOpts.colors):i.isatty(process.stderr.fd)}function formatArgs(t){var r=this.namespace,i=this.useColors;if(i){var n=this.color;var a="[3"+(n<8?n:"8;5;"+n);var u=" ".concat(a,";1m").concat(r," ");t[0]=u+t[0].split("\n").join("\n"+u);t.push(a+"m+"+e.exports.humanize(this.diff)+"")}else{t[0]=getDate()+r+" "+t[0]}}function getDate(){if(t.inspectOpts.hideDate){return""}return(new Date).toISOString()+" "}function log(){return process.stderr.write(n.format.apply(n,arguments)+"\n")}function save(e){if(e){process.env.DEBUG=e}else{delete process.env.DEBUG}}function load(){return process.env.DEBUG}function init(e){e.inspectOpts={};var r=Object.keys(t.inspectOpts);for(var i=0;i=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0"+e.toString(8):"-0"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}})},,,function(e){"use strict";e.exports=locate;function locate(e,t){var r=e.indexOf("[",t);var i=e.indexOf("![",t);if(i===-1){return r}return rGold Sponsors

    Shopify Salesforce Badoo Airbnb Facebook Open Source

    Silver Sponsors

    AMP Project

    Bronze Sponsors

    -

    Bugsnag Stability Monitoring Crosswordsolver Codacy Mixpanel VPS Server Free Icons by Icons8 UI UX Design Agencies clay Discord ThemeIsle TekHattan Marfeel Fire Stick Tricks JSHeroes

    +

    UI UX Design Agencies EduBirdie Crosswordsolver Codacy Mixpanel VPS Server Free Icons by Icons8 Bugsnag Stability Monitoring clay Discord ThemeIsle TekHattan Marfeel Fire Stick Tricks JSHeroes

    ## Technology Sponsors diff --git a/tools/node_modules/eslint/lib/cli-engine/file-enumerator.js b/tools/node_modules/eslint/lib/cli-engine/file-enumerator.js index 700f8009cf88f2..b5a082b71a6bc8 100644 --- a/tools/node_modules/eslint/lib/cli-engine/file-enumerator.js +++ b/tools/node_modules/eslint/lib/cli-engine/file-enumerator.js @@ -375,9 +375,6 @@ class FileEnumerator { * @private */ *_iterateFilesRecursive(directoryPath, options) { - if (this._isIgnoredFile(directoryPath + path.sep, options)) { - return; - } debug(`Enter the directory: ${directoryPath}`); const { configArrayFactory, extensionRegExp } = internalSlotsMap.get(this); @@ -426,7 +423,20 @@ class FileEnumerator { // Dive into the sub directory. } else if (options.recursive && stat && stat.isDirectory()) { - yield* this._iterateFilesRecursive(filePath, options); + if (!config) { + config = configArrayFactory.getConfigArrayForFile( + filePath, + { ignoreNotFoundError: true } + ); + } + const ignored = this._isIgnoredFile( + filePath + path.sep, + { ...options, config } + ); + + if (!ignored) { + yield* this._iterateFilesRecursive(filePath, options); + } } } diff --git a/tools/node_modules/eslint/lib/rules/no-unexpected-multiline.js b/tools/node_modules/eslint/lib/rules/no-unexpected-multiline.js index 8026e1722236ff..eb72008a2947e7 100644 --- a/tools/node_modules/eslint/lib/rules/no-unexpected-multiline.js +++ b/tools/node_modules/eslint/lib/rules/no-unexpected-multiline.js @@ -74,6 +74,14 @@ module.exports = { if (node.tag.loc.end.line === node.quasi.loc.start.line) { return; } + + // handle generics type parameters on template tags + const tokenBefore = sourceCode.getTokenBefore(node.quasi); + + if (tokenBefore.loc.end.line === node.quasi.loc.start.line) { + return; + } + context.report({ node, loc: node.loc.start, messageId: "taggedTemplate" }); }, diff --git a/tools/node_modules/eslint/lib/source-code/source-code.js b/tools/node_modules/eslint/lib/source-code/source-code.js index 20b442f2367203..30b4e9ab5c26e3 100644 --- a/tools/node_modules/eslint/lib/source-code/source-code.js +++ b/tools/node_modules/eslint/lib/source-code/source-code.js @@ -90,6 +90,56 @@ function nodesOrTokensOverlap(first, second) { (second.range[0] <= first.range[0] && second.range[1] >= first.range[0]); } +/** + * Determines if two nodes or tokens have at least one whitespace character + * between them. Order does not matter. Returns false if the given nodes or + * tokens overlap. + * @param {SourceCode} sourceCode The source code object. + * @param {ASTNode|Token} first The first node or token to check between. + * @param {ASTNode|Token} second The second node or token to check between. + * @param {boolean} checkInsideOfJSXText If `true` is present, check inside of JSXText tokens for backward compatibility. + * @returns {boolean} True if there is a whitespace character between + * any of the tokens found between the two given nodes or tokens. + * @public + */ +function isSpaceBetween(sourceCode, first, second, checkInsideOfJSXText) { + if (nodesOrTokensOverlap(first, second)) { + return false; + } + + const [startingNodeOrToken, endingNodeOrToken] = first.range[1] <= second.range[0] + ? [first, second] + : [second, first]; + const firstToken = sourceCode.getLastToken(startingNodeOrToken) || startingNodeOrToken; + const finalToken = sourceCode.getFirstToken(endingNodeOrToken) || endingNodeOrToken; + let currentToken = firstToken; + + while (currentToken !== finalToken) { + const nextToken = sourceCode.getTokenAfter(currentToken, { includeComments: true }); + + if ( + currentToken.range[1] !== nextToken.range[0] || + + /* + * For backward compatibility, check speces in JSXText. + * https://github.com/eslint/eslint/issues/12614 + */ + ( + checkInsideOfJSXText && + nextToken !== finalToken && + nextToken.type === "JSXText" && + /\s/u.test(nextToken.value) + ) + ) { + return true; + } + + currentToken = nextToken; + } + + return false; +} + //------------------------------------------------------------------------------ // Public Interface //------------------------------------------------------------------------------ @@ -433,42 +483,24 @@ class SourceCode extends TokenStore { * @public */ isSpaceBetween(first, second) { - if (nodesOrTokensOverlap(first, second)) { - return false; - } - - const [startingNodeOrToken, endingNodeOrToken] = first.range[1] <= second.range[0] - ? [first, second] - : [second, first]; - const firstToken = this.getLastToken(startingNodeOrToken) || startingNodeOrToken; - const finalToken = this.getFirstToken(endingNodeOrToken) || endingNodeOrToken; - let currentToken = firstToken; - - while (currentToken !== finalToken) { - const nextToken = this.getTokenAfter(currentToken, { includeComments: true }); - - if (currentToken.range[1] !== nextToken.range[0]) { - return true; - } - - currentToken = nextToken; - } - - return false; + return isSpaceBetween(this, first, second, false); } /** * Determines if two nodes or tokens have at least one whitespace character * between them. Order does not matter. Returns false if the given nodes or * tokens overlap. - * @param {...ASTNode|Token} args The nodes or tokens to check between. + * For backward compatibility, this method returns true if there are + * `JSXText` tokens that contain whitespaces between the two. + * @param {ASTNode|Token} first The first node or token to check between. + * @param {ASTNode|Token} second The second node or token to check between. * @returns {boolean} True if there is a whitespace character between * any of the tokens found between the two given nodes or tokens. * @deprecated in favor of isSpaceBetween(). * @public */ - isSpaceBetweenTokens(...args) { - return this.isSpaceBetween(...args); + isSpaceBetweenTokens(first, second) { + return isSpaceBetween(this, first, second, true); } /** diff --git a/tools/node_modules/eslint/package.json b/tools/node_modules/eslint/package.json index 5fbc11817b879d..0abd303e051b44 100644 --- a/tools/node_modules/eslint/package.json +++ b/tools/node_modules/eslint/package.json @@ -153,5 +153,5 @@ "test:cli": "mocha", "webpack": "node Makefile.js webpack" }, - "version": "6.7.1" + "version": "6.7.2" } \ No newline at end of file diff --git a/tools/snapshot/README.md b/tools/snapshot/README.md new file mode 100644 index 00000000000000..34dc574d56cc30 --- /dev/null +++ b/tools/snapshot/README.md @@ -0,0 +1,42 @@ +# Node.js startup snapshot builder + +This is the V8 startup snapshot builder of Node.js. Not to be confused with +V8's own snapshot builder, which builds a snapshot containing JavaScript +builtins, this builds a snapshot containing Node.js builtins that can be +deserialized on top of V8's own startup snapshot. When Node.js is launched, +instead of executing code to bootstrap, it can deserialize the context from +an embedded snapshot, which readily contains the result of the bootstrap, so +that Node.js can start up faster. + +Currently only the main context of the main Node.js instance supports snapshot +deserialization, and the snapshot does not yet cover the entire bootstrap +process. Work is being done to expand the support. + +## How it's built and used + +The snapshot builder is built with the `node_mksnapshot` target in `node.gyp` +when `node_use_node_snapshot` is set to true, which is currently done by +default. + +In the default build of the Node.js executable, to embed a V8 startup snapshot +into the Node.js executable, `libnode` is first built with these unresolved +symbols: + +- `node::NodeMainInstance::GetEmbeddedSnapshotBlob` +- `node::NodeMainInstance::GetIsolateDataIndexes` + +Then the `node_mksnapshot` executable is built with C++ files in this +directory, as well as `src/node_snapshot_stub.cc` which defines the unresolved +symbols. + +`node_mksnapshot` is run to generate a C++ file +`<(SHARED_INTERMEDIATE_DIR)/node_snapshot.cc` that is similar to +`src/node_snapshot_stub.cc` in structure, but contains the snapshot data +written as static char array literals. Then `libnode` is built with +`node_snapshot.cc` to produce the final Node.js executable with the snapshot +data embedded. + +For debugging, Node.js can be built without Node.js's own snapshot if +`--without-node-snapshot` is passed to `configure`. A Node.js executable +with Node.js snapshot embedded can also be launched without deserializing +from it if the command line argument `--no-node-snapshot` is passed. diff --git a/tools/utils.py b/tools/utils.py index dd5ce3fcb629a4..014f3ac8667d02 100644 --- a/tools/utils.py +++ b/tools/utils.py @@ -63,6 +63,10 @@ def GuessOS(): return 'solaris' elif id == 'NetBSD': return 'netbsd' + elif id == 'DragonFly': + # Doing so on purpose as they are pretty close + # minus few features + return 'freebsd' elif id == 'AIX': return 'aix' else: