diff --git a/.github/workflows/c.yml b/.github/workflows/c.yml new file mode 100644 index 0000000..b766299 --- /dev/null +++ b/.github/workflows/c.yml @@ -0,0 +1,237 @@ +name: c + +on: + push: + branches: [main] + # The fuzz job: weekly, or by hand. + schedule: + - cron: "41 3 * * 1" + workflow_dispatch: + pull_request: + paths: + - "c/**" + - "spec/**" + # test_primitives reads the R0 primitives dumped from JS there. + - "rust/tests/data/**" + # The compare job diffs the library against the built JS package. + - "js/src/**" + - "scripts/compare-ports.mjs" + - "scripts/fuzz-ports.mjs" + - "scripts/lib/ports.mjs" + - ".github/workflows/c.yml" + +permissions: + contents: read + +env: + CI: "true" + +jobs: + lint: + if: github.event_name != 'schedule' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 + - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 + with: + node-version: 24 + - name: Codegen is up to date + run: | + node c/scripts/gen_data.mjs --check + node c/scripts/gen_unicode.mjs --check + # The Unicode tables come from the same derivation as Go's: the committed samples must agree. + - name: Unicode sample matches the Go port's + run: cmp c/tests/data/unicode/cases.jsonl go/testdata/unicode/cases.jsonl + # R0 hazards: locale-dependent and unstable calls are banned from the library. + - name: No locale-dependent or unstable calls in src/ + run: | + bad=$(grep -nE '#include |\b(qsort|strtod|strtof|strtold|atof|strtol|strtoul|atoi|setlocale|localeconv|sprintf|snprintf|printf|fprintf|isalpha|isdigit|isspace|isupper|islower|tolower|toupper)\s*\(' c/src/*.c c/src/*.h \ + | grep -vE '^[^:]+:[0-9]+:[[:space:]]*(/\*|\*|//)' || true) + if [ -n "$bad" ]; then echo "$bad"; exit 1; fi + # Generated files (data_gen.*, unicode_gen.*) are left as the generators write them. + - name: clang-format + run: | + pipx install clang-format==19.1.7 + git ls-files 'c/*.c' 'c/*.h' 'c/*.cpp' 'c/*.hpp' | grep -vE '_gen\.(c|h)$' \ + | xargs clang-format --dry-run --Werror + - name: Amalgamation (duplicate file-local names fail here) + run: node c/scripts/amalgamate.mjs --out "$RUNNER_TEMP/amal" + + test: + if: github.event_name != 'schedule' + strategy: + fail-fast: false + matrix: + include: + - { name: linux-gcc, os: ubuntu-latest, cc: gcc, cxx: g++ } + - { name: linux-clang, os: ubuntu-latest, cc: clang, cxx: clang++ } + - { name: linux-arm64, os: ubuntu-24.04-arm, cc: gcc, cxx: g++ } + - { name: linux-shared, os: ubuntu-latest, cc: gcc, cxx: g++, shared: "ON" } + - { name: macos, os: macos-latest, cc: clang, cxx: clang++ } + - { name: windows-msvc, os: windows-latest } + # The DLL: dllexport, the import library, and the examples and C++ tests linking it. + - { name: windows-msvc-shared, os: windows-latest, shared: "ON" } + name: test (${{ matrix.name }}) + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 + - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0 + - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 + with: + node-version: 24 + cache: pnpm + # The schema test validates every fixture output with the ajv the JS package has. + - run: pnpm install --frozen-lockfile + - name: Configure + shell: bash + env: + CC: ${{ matrix.cc }} + CXX: ${{ matrix.cxx }} + run: | + cmake -S c -B build -DCMAKE_BUILD_TYPE=Release -DTRACKPARSE_WERROR=ON \ + -DTRACKPARSE_SHARED=${{ matrix.shared || 'OFF' }} + - run: cmake --build build --config Release -j4 + - name: Test + run: ctest --test-dir build -C Release --output-on-failure -j2 + - name: Conformance report + shell: bash + run: | + bin=build/trackparse-fixtures + [ -x "$bin" ] || bin=build/Release/trackparse-fixtures.exe + TRACKPARSE_REPORT=1 "$bin" spec/fixtures/handwritten/*.json spec/fixtures/generated/*.json | tail -5 + + # 32-bit x86 (SSE2 math, FLT_EVAL_METHOD 0) and the oldest supported toolchain. + old-and-32bit: + if: github.event_name != 'schedule' + runs-on: ubuntu-22.04 + strategy: + fail-fast: false + matrix: + include: + - { name: m32, cc: gcc, flags: "-m32", pkgs: "gcc-multilib g++-multilib" } + - { name: gcc-9-cmake-3.16, cc: gcc-9, cxx: g++-9, pkgs: "gcc-9 g++-9", cmake: "3.16.8" } + name: test (${{ matrix.name }}) + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 + - run: sudo apt-get update && sudo apt-get install -y ${{ matrix.pkgs }} + - name: CMake ${{ matrix.cmake || 'default' }} + if: matrix.cmake + run: pipx install "cmake==${{ matrix.cmake }}" && cmake --version + - name: Configure, build, test + env: + CC: ${{ matrix.cc }} + CXX: ${{ matrix.cxx || 'g++' }} + CFLAGS: ${{ matrix.flags }} + CXXFLAGS: ${{ matrix.flags }} + LDFLAGS: ${{ matrix.flags }} + run: | + cmake -S c -B build -DCMAKE_BUILD_TYPE=Release -DTRACKPARSE_WERROR=ON + cmake --build build -j4 + # ctest --test-dir needs CTest 3.20; 3.16 would ignore it and find no tests. + cd build && ctest --output-on-failure -j2 -LE consumer + + sanitize: + if: github.event_name != 'schedule' + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - { name: asan-ubsan-gcc, cc: gcc, cxx: g++, opt: "-DTRACKPARSE_SANITIZE=ON" } + - { name: asan-ubsan-clang, cc: clang, cxx: clang++, opt: "-DTRACKPARSE_SANITIZE=ON" } + - { name: tsan, cc: clang, cxx: clang++, opt: "-DTRACKPARSE_SANITIZE_THREAD=ON" } + # MemorySanitizer with an uninstrumented libc++ would report false positives in the C++ + # tests, so they are left out (-LE cpp is not enough: they would not even build). + - { name: msan, cc: clang, cxx: clang++, opt: "-DTRACKPARSE_SANITIZE_MEMORY=ON", target: "--target trackparse-fixtures test_api test_properties test_oom test_rt test_num" , tests: "-R '^(fixtures|api|properties|oom|rt|num)$'" } + name: sanitize (${{ matrix.name }}) + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 + - name: Configure, build, test + env: + CC: ${{ matrix.cc }} + CXX: ${{ matrix.cxx }} + run: | + cmake -S c -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo -DTRACKPARSE_WERROR=ON ${{ matrix.opt }} + cmake --build build -j4 ${{ matrix.target }} + ctest --test-dir build --output-on-failure -j2 -LE consumer ${{ matrix.tests }} + + valgrind-and-locale: + if: github.event_name != 'schedule' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 + - name: Install valgrind and the test locales + run: | + sudo apt-get update && sudo apt-get install -y valgrind locales + sudo locale-gen de_DE.UTF-8 tr_TR.UTF-8 + - name: Build + run: | + cmake -S c -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo -DTRACKPARSE_WERROR=ON + cmake --build build -j4 + - name: Locale (German decimal comma, Turkish dotless i) + run: | + for loc in de_DE.UTF-8 tr_TR.UTF-8; do + LC_ALL=$loc ctest --test-dir build --output-on-failure -R 'locale|fixtures|api' + done + - name: Valgrind (handwritten fixtures, API tests, properties in short mode) + env: + TRACKPARSE_SHORT: "1" + TRACKPARSE_SLOWDOWN: "40" + run: | + valgrind --error-exitcode=1 --leak-check=full --errors-for-leak-kinds=definite,indirect \ + build/trackparse-fixtures spec/fixtures/handwritten/*.json + (cd c && valgrind --error-exitcode=1 --leak-check=full --errors-for-leak-kinds=definite,indirect \ + ../build/test_api) + (cd c && valgrind --error-exitcode=1 --leak-check=full --errors-for-leak-kinds=definite,indirect \ + ../build/test_properties) + + compare: + if: github.event_name != 'schedule' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 + - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0 + - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 + with: + node-version: 24 + cache: pnpm + - run: pnpm install --frozen-lockfile + - run: pnpm --filter trackparse build + - name: Every fixture, full output, C against JS + run: node scripts/compare-ports.mjs --only=c + - name: Random differential run, C against JS + run: node scripts/fuzz-ports.mjs --only=c --n=50000 --lists=10000 + + fuzz: + if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + target: [parse, parse_artists, format, parse_tracklist, apply_edits, wire] + name: fuzz (${{ matrix.target }}) + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 + - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 + with: + node-version: 24 + - name: Build the fuzz target + env: + CC: clang + CXX: clang++ + run: | + cmake -S c -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo -DTRACKPARSE_FUZZ=ON -DTRACKPARSE_BUILD_TESTS=OFF + cmake --build build -j4 --target fuzz_${{ matrix.target }} + - name: Seed corpus from the fixtures + run: node c/scripts/fuzz_corpus.mjs "$RUNNER_TEMP/corpus" + - name: Fuzz for 10 minutes + run: | + mkdir -p crashes + corpus="$RUNNER_TEMP/corpus/${{ matrix.target }}" + mkdir -p "$corpus" + build/fuzz_${{ matrix.target }} -max_total_time=600 -timeout=30 -artifact_prefix=crashes/ "$corpus" + - if: failure() + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + with: + name: crashes-${{ matrix.target }} + path: crashes/ diff --git a/.github/workflows/pr-title.yml b/.github/workflows/pr-title.yml index 470d4bf..ff7544a 100644 --- a/.github/workflows/pr-title.yml +++ b/.github/workflows/pr-title.yml @@ -37,6 +37,7 @@ jobs: python rust go + c site ci deps diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 05be868..7f9c706 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,7 +4,8 @@ name: release # Merging that PR tags js-vX.Y.Z / spec-vX.Y.Z / python-vX.Y.Z / rust-vX.Y.Z / go/vX.Y.Z, creates # the GitHub Releases, and publishes to npm, PyPI and (once enabled) crates.io. The Go module has # no registry upload: the go/vX.Y.Z tag is the release, and publish-go only checks it through the -# Go module proxy. +# Go module proxy. The C library has no registry either: publish-c attaches a source tarball and an +# amalgamation to the c-vX.Y.Z GitHub Release. on: push: @@ -23,6 +24,10 @@ on: description: "Re-run the Go module checks for an existing go release tag (e.g. go/v0.6.0). Leave empty for a normal release-please run." required: false default: "" + c_tag: + description: "Re-build and attach the C release files for an existing c release tag (e.g. c-v0.7.0). Leave empty for a normal release-please run." + required: false + default: "" permissions: {} @@ -50,6 +55,9 @@ jobs: go_release_created: ${{ steps.release.outputs['go--release_created'] }} go_tag_name: ${{ steps.release.outputs['go--tag_name'] }} go_version: ${{ steps.release.outputs['go--version'] }} + c_release_created: ${{ steps.release.outputs['c--release_created'] }} + c_tag_name: ${{ steps.release.outputs['c--tag_name'] }} + c_version: ${{ steps.release.outputs['c--version'] }} steps: - uses: googleapis/release-please-action@v4 id: release @@ -482,3 +490,169 @@ jobs: } > "$RUNNER_TEMP/notes.md" # The npm release (js-vX.Y.Z) stays "Latest"; don't touch that flag here. gh release edit "$TAG" --notes-file "$RUNNER_TEMP/notes.md" + + publish-c: + needs: release-please + if: needs.release-please.outputs.c_release_created == 'true' || (github.event_name == 'workflow_dispatch' && inputs.c_tag != '') + runs-on: ubuntu-latest + environment: + name: c + url: https://github.com/${{ github.repository }}/releases + permissions: + contents: write # upload release files, edit the notes + id-token: write # build provenance attestation + attestations: write + steps: + - name: Resolve the release tag + id: tag + env: + RELEASED_TAG: ${{ needs.release-please.outputs.c_tag_name }} + RELEASED_VERSION: ${{ needs.release-please.outputs.c_version }} + INPUT_TAG: ${{ inputs.c_tag }} + run: | + if [ -n "$INPUT_TAG" ]; then + tag="$INPUT_TAG" + else + tag="$RELEASED_TAG" + fi + if ! printf '%s' "$tag" | grep -Eq '^c-v[0-9]+\.[0-9]+\.[0-9]+$'; then + echo "the c tag must look like c-vX.Y.Z, got '$tag'" >&2 + exit 1 + fi + version="${tag#c-v}" + if [ -z "$INPUT_TAG" ] && [ "$version" != "$RELEASED_VERSION" ]; then + echo "tag $tag does not match the released version $RELEASED_VERSION" >&2 + exit 1 + fi + echo "tag=$tag" >> "$GITHUB_OUTPUT" + echo "version=$version" >> "$GITHUB_OUTPUT" + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 + with: + ref: ${{ steps.tag.outputs.tag }} + - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 + with: + node-version: 24 + + - name: Verify versions are in sync + env: + TAG_VERSION: ${{ steps.tag.outputs.version }} + run: | + c_version=$(cat c/VERSION) + c_cmake=$(sed -n 's/^project(trackparse VERSION \([0-9.]*\) .*/\1/p' c/CMakeLists.txt) + c_header=$(sed -n 's/^#define TRACKPARSE_VERSION "\([^"]*\)".*/\1/p' c/include/trackparse.h) + c_spec=$(sed -n 's/^#define TP_SPEC_VERSION "\([^"]*\)".*/\1/p' c/src/data_gen.h) + spec_version=$(cat spec/VERSION) + echo "c=$c_version cmake=$c_cmake header=$c_header spec-macro=$c_spec spec=$spec_version tag=$TAG_VERSION" + for v in "$c_version" "$c_cmake" "$c_header" "$c_spec" "$spec_version"; do + test "$v" = "$TAG_VERSION" + done + node c/scripts/gen_data.mjs --check + node c/scripts/gen_unicode.mjs --check + + - name: Test from the repository + run: | + cmake -S c -B build -DCMAKE_BUILD_TYPE=Release -DTRACKPARSE_WERROR=ON + cmake --build build -j4 + ctest --test-dir build --output-on-failure + + # The tarball holds c/ alone plus the generated amalgamation, so it builds without Node and + # without the rest of the repository; the fixture tests skip there (no ../spec). + - name: Build the release files + id: files + env: + VERSION: ${{ steps.tag.outputs.version }} + run: | + out="$RUNNER_TEMP/out" + name="trackparse-c-$VERSION" + mkdir -p "$out" "$RUNNER_TEMP/stage" + git archive --format=tar --prefix="$name/" HEAD:c | tar -x -C "$RUNNER_TEMP/stage" + node c/scripts/amalgamate.mjs --out "$RUNNER_TEMP/stage/$name/dist" + tar -C "$RUNNER_TEMP/stage" -czf "$out/$name.tar.gz" "$name" + mkdir -p "$RUNNER_TEMP/amal/$name-amalgamation" + cp "$RUNNER_TEMP/stage/$name/dist/"* "$RUNNER_TEMP/amal/$name-amalgamation/" + cp c/LICENSE "$RUNNER_TEMP/amal/$name-amalgamation/" + (cd "$RUNNER_TEMP/amal" && zip -qr "$out/$name-amalgamation.zip" "$name-amalgamation") + (cd "$out" && sha256sum "$name.tar.gz" "$name-amalgamation.zip" > SHA256SUMS) + cat "$out/SHA256SUMS" + echo "out=$out" >> "$GITHUB_OUTPUT" + echo "name=$name" >> "$GITHUB_OUTPUT" + + - name: Build and test the tarball alone, then install it and build an example against it + env: + OUT: ${{ steps.files.outputs.out }} + NAME: ${{ steps.files.outputs.name }} + run: | + cd "$RUNNER_TEMP" + rm -rf check && mkdir check && tar -xzf "$OUT/$NAME.tar.gz" -C check + cmake -S "check/$NAME" -B check/build -DCMAKE_BUILD_TYPE=Release -DTRACKPARSE_WERROR=ON + cmake --build check/build -j4 + ctest --test-dir check/build --output-on-failure + cmake --install check/build --prefix "$RUNNER_TEMP/prefix" + cat > check/main.c <<'EOF' + #include + #include + int main(void) { + trackparse_track *t = trackparse_parse("Noisia - Stigma (2015)", TRACKPARSE_NUL_TERMINATED); + if (!t) return 1; + printf("%s %s %s %d\n", trackparse_spec_version(), t->artists[0].name.ptr, t->title.ptr, *t->year); + trackparse_track_free(t); + return 0; + } + EOF + export PKG_CONFIG_PATH="$RUNNER_TEMP/prefix/lib/pkgconfig:$RUNNER_TEMP/prefix/lib64/pkgconfig" + cc -std=c11 check/main.c $(pkg-config --cflags --libs trackparse) -o check/main + got=$(LD_LIBRARY_PATH="$RUNNER_TEMP/prefix/lib:$RUNNER_TEMP/prefix/lib64" ./check/main) + want="${NAME#trackparse-c-} Noisia Stigma 2015" + echo "got: $got" + echo "want: $want" + test "$got" = "$want" + # The amalgamation alone, as a user who copies the files would build it. + unzip -q "$OUT/$NAME-amalgamation.zip" -d amal-check + cc -std=c11 -O2 -Wall -Wextra -Werror -DTRACKPARSE_STATIC -I"amal-check/$NAME-amalgamation" \ + check/main.c "amal-check/$NAME-amalgamation/trackparse.c" -lm -lpthread -o check/main-amal + ./check/main-amal + + - uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2 + with: + subject-path: | + ${{ steps.files.outputs.out }}/*.tar.gz + ${{ steps.files.outputs.out }}/*.zip + + - name: Upload the files and add install notes to the GitHub Release + env: + GH_TOKEN: ${{ github.token }} + TAG: ${{ steps.tag.outputs.tag }} + VERSION: ${{ steps.tag.outputs.version }} + OUT: ${{ steps.files.outputs.out }} + NAME: ${{ steps.files.outputs.name }} + run: | + # Release files are permanent: package managers pin their hashes. Never replace one. + existing=$(gh release view "$TAG" --json assets --jq '.assets[].name') + for f in "$OUT/$NAME.tar.gz" "$OUT/$NAME-amalgamation.zip" "$OUT/SHA256SUMS"; do + if printf '%s\n' "$existing" | grep -qx "$(basename "$f")"; then + echo "$(basename "$f") is already attached; keeping it" + else + gh release upload "$TAG" "$f" + fi + done + sha=$(sed -n "s/ $NAME.tar.gz\$//p" "$OUT/SHA256SUMS") + url="https://github.com/${GITHUB_REPOSITORY}/releases/download/${TAG}/${NAME}.tar.gz" + highlights=".github/release-notes/${VERSION}.md" + { + if [ -f "$highlights" ]; then cat "$highlights"; echo; fi + gh release view "$TAG" --json body --jq .body + echo + echo "### Install" + echo + echo '```cmake' + echo 'include(FetchContent)' + echo 'FetchContent_Declare(trackparse' + echo " URL ${url}" + echo " URL_HASH SHA256=${sha})" + echo 'FetchContent_MakeAvailable(trackparse)' + echo 'target_link_libraries(app PRIVATE trackparse::trackparse)' + echo '```' + echo + echo "Or copy \`trackparse.c\`, \`trackparse.h\` and \`trackparse.hpp\` from ${NAME}-amalgamation.zip. Implements spec ${VERSION} ([SPEC.md](https://github.com/${GITHUB_REPOSITORY}/blob/${TAG}/spec/SPEC.md))." + } > "$RUNNER_TEMP/notes.md" + gh release edit "$TAG" --notes-file "$RUNNER_TEMP/notes.md" diff --git a/.github/workflows/spec.yml b/.github/workflows/spec.yml index b7bef30..900ee20 100644 --- a/.github/workflows/spec.yml +++ b/.github/workflows/spec.yml @@ -12,6 +12,10 @@ on: - "python/pyproject.toml" - "rust/Cargo.toml" - "go/data_gen.go" + - "c/VERSION" + - "c/CMakeLists.txt" + - "c/include/trackparse.h" + - "c/src/data_gen.h" - "pnpm-lock.yaml" - "pnpm-workspace.yaml" - "package.json" @@ -36,15 +40,21 @@ jobs: run: pnpm --filter @trackparse/fixture-gen test - name: Port data codegen is up to date run: pnpm --filter trackparse gen:data:check - - name: js, python, rust, go and spec versions are linked + - name: js, python, rust, go, c and spec versions are linked run: | js_version=$(node -p "require('./js/package.json').version") py_version=$(python3 -c 'import tomllib; print(tomllib.load(open("python/pyproject.toml", "rb"))["project"]["version"])') rs_version=$(python3 -c 'import tomllib; print(tomllib.load(open("rust/Cargo.toml", "rb"))["package"]["version"])') go_version=$(sed -n 's/^const SpecVersion = "\([^"]*\)".*/\1/p' go/data_gen.go) + c_version=$(cat c/VERSION) + c_cmake=$(sed -n 's/^project(trackparse VERSION \([0-9.]*\) .*/\1/p' c/CMakeLists.txt) + c_header=$(sed -n 's/^#define TRACKPARSE_VERSION "\([^"]*\)".*/\1/p' c/include/trackparse.h) + c_parts=$(sed -n 's/^#define TRACKPARSE_VERSION_\(MAJOR\|MINOR\|PATCH\) \([0-9]*\).*/\2/p' c/include/trackparse.h | paste -sd.) + c_spec=$(sed -n 's/^#define TP_SPEC_VERSION "\([^"]*\)".*/\1/p' c/src/data_gen.h) spec_version=$(cat spec/VERSION) - echo "js=$js_version python=$py_version rust=$rs_version go=$go_version spec=$spec_version" + echo "js=$js_version python=$py_version rust=$rs_version go=$go_version c=$c_version/$c_cmake/$c_header/$c_parts/$c_spec spec=$spec_version" test "$js_version" = "$spec_version" test "$py_version" = "$spec_version" test "$rs_version" = "$spec_version" test "$go_version" = "$spec_version" + for v in "$c_version" "$c_cmake" "$c_header" "$c_parts" "$c_spec"; do test "$v" = "$spec_version"; done diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 5ad9f4f..688923d 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -3,5 +3,6 @@ "spec": "0.6.1", "python": "0.6.1", "rust": "0.6.1", - "go": "0.6.1" + "go": "0.6.1", + "c": "0.6.1" } diff --git a/AGENTS.md b/AGENTS.md index ff042bb..69e0620 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -158,20 +158,90 @@ go/ Go module `github.com/4matic/trackparse/go`, package ` artist_cases.json (git-ignored: dump_artist_cases.mjs writes it; the tests skip without it, CI writes it and requires it), fuzz/ (failing fuzz inputs land here) +c/ C11 library `libtrackparse` plus a header-only C++17 wrapper (GCC, Clang, + MSVC; no dependencies beyond libc, libm and the system's threads; a + release-please component, tagged c-vX.Y.Z, released as files attached + to the GitHub Release: no registry) + include/trackparse.h the whole public C API with doc comments; TRACKPARSE_VERSION and + _MAJOR/_MINOR/_PATCH carry the x-release-please markers + include/trackparse.hpp header-only C++17 wrapper (namespace trackparse: move-only owners, + string_view, optional, chained option builders; throws only bad_alloc) + src/rt.h, src/rt.c the internal runtime: arenas and out-of-memory scopes (setjmp/longjmp), + tp_str, runes, TP_VEC vectors, tp_buf, tp_map, tp_sort_stable, tp_once, + and the TP_PRIVATE / TP_PRIVATE_DATA linkage macros + src/internal.h every internal type and prototype, one section per Go file + src/PORTING.md Go file to C file map and the translation rules (integer widths, nil and + empty, slices, maps, closures, names that deviate) + src/*.c one file per go/*.go file, same rule IDs in comments: parser, normalize, + mode, scanner, prefix, classify, separator, artists, credits, title, + assemble, format, words, digits, tables, context, options, types + src/tl_*.c one file per go/tl_*.go file + src/trackparse.c the public functions: input sanitizing (WHATWG), scopes, result blocks, + option handles + src/json.c the JSON writer (JSON.stringify's bytes) + src/num.c correctly rounded decimal to double, JS Number#toString, half-up rounding, + all by hand (no strtod, no float printf) + src/unicode.c L and Lu (R0.6), JS toLowerCase (R0.4), NFC/NFD (R1) over the generated tables + src/data_gen.h, .c GENERATED from spec/data + spec/VERSION (never edit); TP_SPEC_VERSION in + data_gen.h carries the x-release-please-version marker + src/unicode_gen.h, .c GENERATED from Node with the derivation of go/unicode_gen.go (never edit) + wire/ the JSON door, a static library that is never installed: json_read.c (the + JSON reader), wire.c (every function with loose JSON arguments), + wire_line.c (one JSONL case in, one JSON result out) + tools/dump.c C side of compare-ports and fuzz-ports (JSONL in, JSON out, through wire/), + built as trackparse-dump + tests/ runner.c + match.c (every shared fixture and the conformance report; the + `schema` test checks its TRACKPARSE_OUTPUT file), test_match.c, + test_rt.c, test_num.c (numbers against Node), test_unicode.c, + test_primitives.c (R0 values from rust/tests/data/primitives.json), + test_api.c, test_properties.c (SPEC invariants, R13.11, time ceilings), + test_threads.c (16 threads against a sequential run), test_locale.c, + test_oom.c (allocation failure at every n), test_bench.c (benchmarks, not + a CTest test), test_cpp.cpp (the wrapper in C++17 and C++20), + hardening.c (the generator and checks shared with fuzz/), data/ + (numbers_sample.jsonl, unicode/), skip.json (only ever shrinks) + fuzz/ libFuzzer targets: fuzz_parse, fuzz_parse_artists, fuzz_format, + fuzz_parse_tracklist, fuzz_apply_edits, fuzz_wire + examples/ basic.c, options.c, tracklist.c, json.c, cpp.cpp, each with a .expected + file that CTest compares its output with + cmake/ hardening.cmake (properties, threads, locale, oom, bench, the fuzz targets, + the TSan and MSan options), package.cmake (the installed library, built + from the amalgamation; install rules, CMake package, pkg-config, the C++ + tests, examples, exports and consumer checks), check_exports.cmake, + consumer_check.cmake, run_example.cmake, trackparseConfig.cmake.in + scripts/gen_data.mjs codegen for src/data_gen.* (--check for CI) + scripts/gen_unicode.mjs codegen for src/unicode_gen.* and the sample tests/data/unicode/ (--check + for CI), through unicode_derive.mjs (a copy of Go's derivation; c_lit.mjs + writes the C literals) + scripts/amalgamate.mjs writes dist/trackparse.c, .h and .hpp (git-ignored): one translation unit + with every internal name static; fails when two files define the same + file-local name + scripts/fuzz_corpus.mjs the seed corpus of fuzz/ from every fixture input + scripts/dump_numbers.mjs number cases from Node for test_num (the committed sample is --n 2000) + scripts/validate_outputs.mjs the `schema` test: the runner's outputs against spec/schema, with + the ajv of js/ + CMakeLists.txt project(trackparse VERSION X.Y.Z) # x-release-please-version; the options + TRACKPARSE_WERROR, _SANITIZE, _FUZZ, _BUILD_TESTS (_SHARED, _INSTALL in + package.cmake; _SANITIZE_THREAD, _SANITIZE_MEMORY in hardening.cmake) + VERSION the component's version file (release-type simple) + LICENSE a copy of the root MIT license: the tarball and the amalgamation hold only c/ + trackparse.pc.in the pkg-config template site/ documentation site + playground (Astro + Starlight, GitHub Pages) astro.config.mjs base /trackparse, sidebar - src/content/docs/ the pages (Markdown/MDX, JS + Python + Rust + Go tabs on every example); + src/content/docs/ the pages (Markdown/MDX, JS + Python + Rust + Go + C tabs on every example); reference/spec.md is generated from spec/SPEC.md src/components/ HeroDemo, Playground (runs js/ in the browser), Install (the install switch), Features, Compare, Stats, SocialIcons src/lib/ trackview.ts (highlight + field rendering), icons.ts (Lucide SVG strings), lang.ts (one language choice for docs tabs, install switch, playground) scripts/sync-spec.mjs copies spec/SPEC.md into the docs at build time -scripts/compare-ports.mjs every fixture through js/dist, the Python port, the Rust crate and the Go - module, diffs the full outputs (parseTracklist and applyEdits included); - --only=python, --only=rust or --only=go for one port +scripts/compare-ports.mjs every fixture through js/dist, the Python port, the Rust crate, the Go + module and the C library, diffs the full outputs (parseTracklist and + applyEdits included); --only=python, --only=rust, --only=go or --only=c + for one port. C runs c/build/trackparse-dump, rebuilt (Release, tests off) + when a source is newer; without a `cmake` on PATH it runs `uvx cmake` scripts/fuzz-ports.mjs random differential run: single tracks and tracklists with edits through - all four ports (--n, --lists, --seed, --only=go|rust|python, --out) + all five ports (--n, --lists, --seed, --only=go|rust|python|c, --out) scripts/lib/ports.mjs runners and the JSON diff shared by compare-ports and fuzz-ports scripts/corpus-check.mjs R13 against a private tracklist corpus (JSONL in spec/corpus/), via js/dist scripts/dump_py.py Python side of compare-ports (JSONL in, to_dict() JSON out) @@ -183,15 +253,22 @@ scripts/dump_py.py Python side of compare-ports (JSONL in, to_dict() JSON no-require greps, go test -race on stable and 1.22, the full Unicode sweep on stable; compare: Go vs built JS; module-zip: go/ alone, as the proxy serves it; fuzz: each target, weekly and by hand), + c.yml (codegen drift, the Unicode sample against Go's, the bans grep, + clang-format, the amalgamation; ctest with -Werror on GCC, Clang, ARM64, + shared, macOS, MSVC, 32-bit x86, GCC 9 with CMake 3.16; ASan + UBSan on + GCC and Clang, TSan, MSan; Valgrind and the de_DE / tr_TR locales; + compare: C vs built JS on every fixture and 50,000 random tracks; fuzz: + each libFuzzer target, weekly and by hand), spec.yml (fixture validation, generated/codegen drift, generator tests, - js/python/rust/go/spec version link), release.yml (release-please + npm, - PyPI and crates.io publish, Go tag checks through the module proxy), + js/python/rust/go/c/spec version link), release.yml (release-please + npm, + PyPI and crates.io publish, Go tag checks through the module proxy, C + tarball and amalgamation on the GitHub Release), pages.yml (build site/, deploy to GitHub Pages), pr-title.yml (conventional PR titles) .github/release-notes/ optional hand-written highlights prepended to a GitHub Release release-please-config.json, .release-please-manifest.json release automation (never hand-edit the manifest) -js/CHANGELOG.md, spec/CHANGELOG.md, python/CHANGELOG.md, rust/CHANGELOG.md, go/CHANGELOG.md - generated by release-please +js/CHANGELOG.md, spec/CHANGELOG.md, python/CHANGELOG.md, rust/CHANGELOG.md, go/CHANGELOG.md, +c/CHANGELOG.md generated by release-please ``` ## Golden rule @@ -202,7 +279,8 @@ js/CHANGELOG.md, spec/CHANGELOG.md, python/CHANGELOG.md, rust/CHANGELOG.md, go/C fixture change, it is a bug fix; if an existing `expected` changes, it is a behaviour change. - Never hand-edit `spec/fixtures/generated/**`, `js/src/data.generated.ts`, `python/src/trackparse/_data.py`, `rust/src/data.rs`, `rust/src/unicode_tables.rs`, - `go/data_gen.go` or `go/unicode_gen.go`. Regenerate them. + `go/data_gen.go`, `go/unicode_gen.go`, `c/src/data_gen.*` or `c/src/unicode_gen.*`. Regenerate + them. - Word lists live **only** in `spec/data/`. Ports compile them into source with codegen; never copy a list into port code by hand, never hard-code a keyword in a scanner. - The fixtures, not any one implementation, are the source of truth. When SPEC.md and a fixture @@ -228,18 +306,20 @@ js/CHANGELOG.md, spec/CHANGELOG.md, python/CHANGELOG.md, rust/CHANGELOG.md, go/C ambiguous, reject it in `model.ts` (`problem()`) instead of guessing. Then `pnpm gen:fixtures` and commit the output. 4. **Codegen.** If `spec/data` or `spec/VERSION` changed: `pnpm gen:data`, in `python/` - `uv run python scripts/gen_data.py`, in `rust/` `node scripts/gen_data.mjs`, and in `go/` - `node scripts/gen_data.mjs`. -5. **Implementation.** Change every port (JS, Python, Rust and Go). Cite rule IDs in comments. + `uv run python scripts/gen_data.py`, in `rust/` `node scripts/gen_data.mjs`, in `go/` + `node scripts/gen_data.mjs`, and in `c/` `node scripts/gen_data.mjs`. +5. **Implementation.** Change every port (JS, Python, Rust, Go and C). Cite rule IDs in comments. + The C change usually mirrors the Go diff file for file (`c/src/PORTING.md`). 6. **Conformance.** `pnpm test` and `pnpm conformance` must be green: 100% of fixtures, schema-valid output, property tests passing, `pnpm gen:check` clean. Same for Python (`uv run pytest`, `uv run python scripts/conformance.py`), Rust (`cargo test`, and the report with - `TRACKPARSE_REPORT=1`) and Go (`go test ./...`, and the report with - `TRACKPARSE_REPORT=1 go test -run TestFixtures -v`), then `node scripts/compare-ports.mjs` must - report 0 differences. + `TRACKPARSE_REPORT=1`), Go (`go test ./...`, and the report with + `TRACKPARSE_REPORT=1 go test -run TestFixtures -v`) and C (`ctest` in a build directory, and + the report with `TRACKPARSE_REPORT=1 /trackparse-fixtures spec/fixtures/*/*.json`), then + `node scripts/compare-ports.mjs` must report 0 differences. 7. **Docs.** Update the site pages and README sections that describe the rule (see [Documentation site and READMEs](#documentation-site-and-readmes)), with JavaScript, Python, - Rust and Go examples whose outputs you ran, and `pnpm docs:build` green. + Rust, Go and C examples whose outputs you ran, and `pnpm docs:build` green. 8. **Commit message.** Conventional commits; the message *is* the changelog entry (see [Versioning and release](#versioning-and-release)). Any change to an existing `expected` value is a behaviour change and must be a `feat` (or carry `!`), never a `fix`/`chore`. Don't touch @@ -256,7 +336,8 @@ Every port must produce byte-identical output. The full text is SPEC.md R0; in s and combining marks. The second, R0.6 "uppercase letter" used only by R6.10, is category Lu: JS `/\p{Lu}/u`, Python `unicodedata.category(c) == "Lu"`. Go's `unicode.IsLetter` and `IsUpper` are category L and Lu, but of Go's Unicode version, so the Go port uses tables generated from - Node instead.) + Node instead. C's `isalpha` and `isupper` follow the locale and know only one byte; the C port + generates the same tables as Go, with the same derivation.) - **Explicit whitespace set** (R0.2): U+0009–U+000D, U+0020, U+0085, U+00A0, U+1680, U+2000–U+200A, U+2028, U+2029, U+202F, U+205F, U+3000. Never use a language's `\s` or `trim()` semantics without checking they match. @@ -267,8 +348,8 @@ Every port must produce byte-identical output. The full text is SPEC.md R0; in s - *Digit* means ASCII `0`–`9` only. - **Total** (R0.8): any string returns a ParsedTrack. Never throw or panic, including on bad options. No backtracking blowups: a 10,000-code-point input takes tens of milliseconds at most in - JS, Rust and Go and well under a second in Python (the suites enforce 1 s in JS and Python, 2 s - in Rust and Go). + JS, Rust, Go and C and well under a second in Python (the suites enforce 1 s in JS and Python, 2 s + in Rust, Go and C). In C, running out of memory is the one failure: the call returns `NULL`. ## Commands @@ -330,13 +411,38 @@ Go (run inside `go/`; Go 1.22 or newer, Node for the codegen): | `pnpm --filter trackparse build && node scripts/dump_artist_cases.mjs` | Write `testdata/artist_cases.json` (2.3 MB, git-ignored) for the artist-side tests; without it they skip, and `TRACKPARSE_REQUIRE_ARTIST_CASES=1` (set in CI) makes that a failure | | `TRACKPARSE_UNICODE_FULL=1 go test -run TestUnicodeFull` | The full NFC/NFD and lowercase sweep against Node (about 20 s; CI runs it on stable). The committed sample in `testdata/unicode/` is a small subset | -Cross-port check, from the repo root (needs `uv`, `cargo` and `go`): +C (run inside `c/`; CMake 3.16 or newer and a C11 compiler, C++17 for the wrapper tests, Node for +the codegen, the amalgamation and the `schema` test). This machine has no `cmake` install: run +`uvx cmake` (and `uvx cmake --build`, `uvx --from cmake ctest`) wherever the table says `cmake`: + +| Command | What it does | +|---|---| +| `cmake -S . -B build-` · `cmake --build build- -j4` · `ctest --test-dir build- --output-on-failure` | Configure (RelWithDebInfo by default), build and run every test: fixtures, schema, match, rt, num, unicode, primitives, api, properties, threads, locale, oom, cpp17, cpp20, example_*, exports, and the `consumer` checks (install, find_package, pkg-config, amalgamation, FetchContent; `-LE consumer` skips them, they are the slow part). Use a directory of your own: `c/build` belongs to compare-ports (below) | +| `TRACKPARSE_REPORT=1 build-/trackparse-fixtures ../spec/fixtures/*/*.json` | Pass rate per fixture file and per rule ID | +| `TRACKPARSE_ONLY= build-/trackparse-fixtures ../spec/fixtures/*/*.json` | Only the cases whose id or file name contains the text | +| `cmake -S . -B build-asan -DTRACKPARSE_SANITIZE=ON` | Everything under ASan + UBSan (`-fno-sanitize-recover=all`) | +| `cmake -S . -B build-tsan -DTRACKPARSE_SANITIZE_THREAD=ON` | ThreadSanitizer, for `threads`; it cannot be combined with another sanitizer option | +| `CC=clang CXX=clang++ cmake -S . -B build-msan -DTRACKPARSE_SANITIZE_MEMORY=ON`, then `cmake --build build-msan --target trackparse-fixtures test_api test_properties test_oom test_rt test_num` and `ctest --test-dir build-msan -R '^(fixtures\|api\|properties\|oom\|rt\|num)$'` | MemorySanitizer (Clang). Only the C programs: the C++ targets would need an instrumented libc++ | +| `CC=clang CXX=clang++ cmake -S . -B build-fuzz -DTRACKPARSE_FUZZ=ON -DTRACKPARSE_BUILD_TESTS=OFF` · `cmake --build build-fuzz --target fuzz_parse` · `node scripts/fuzz_corpus.mjs corpus` · `build-fuzz/fuzz_parse -max_total_time=60 corpus/parse` | Fuzz one libFuzzer target (parse, parse_artists, format, parse_tracklist, apply_edits, wire), seeded from every fixture input; crashes land as `crash-*` files in the working directory | +| `node scripts/gen_data.mjs` · `node scripts/gen_unicode.mjs` | Regenerate `src/data_gen.*` / `src/unicode_gen.*` (and `tests/data/unicode/`); `--check` fails if stale. CI also `cmp`s the sample with `go/testdata/unicode/cases.jsonl` | +| `node scripts/amalgamate.mjs --out ` | Write `trackparse.c`, `.h`, `.hpp` (default `c/dist`); fails on a file-local name defined in two files | +| `git ls-files '*.c' '*.h' '*.cpp' '*.hpp' \| grep -vE '_gen\.(c\|h)$' \| xargs uvx clang-format==19.1.7 --dry-run --Werror` | The format check CI runs (clang-format 19.1.7, the pinned version; `-i` instead of `--dry-run --Werror` fixes). Generated files are left as the generators write them | +| `build-/test_bench [-benchtime ] [--fixtures ../spec/fixtures/*/*.json]` | Benchmarks printed like `go test -bench` (ns/op, allocs/op), the 10k inputs, tracklists and the scaling ratios. Not a CTest test; use a Release build | +| `TRACKPARSE_SHORT=1 valgrind --error-exitcode=1 --leak-check=full --errors-for-leak-kinds=definite,indirect build-/test_properties` | What the Valgrind job runs (also on `trackparse-fixtures` with the handwritten files and on `test_api`); `TRACKPARSE_SLOWDOWN=40` widens the ceilings | +| `TRACKPARSE_UNICODE_FULL=1 ctest --test-dir build- -R unicode` | The full NFC/NFD and lowercase sweep against Node (runs `gen_unicode.mjs --cases`; not in CI) | +| `build-/trackparse-dump < cases.jsonl` | The JSON door on JSONL (what compare-ports and fuzz-ports run) | + +Cross-port check, from the repo root (needs `uv`, `cargo`, `go`, and CMake with a C compiler): ```sh -pnpm --filter trackparse build && node scripts/compare-ports.mjs # four ports; must print "differences: 0" -node scripts/compare-ports.mjs --only=go # one port against JS (or python, rust) +pnpm --filter trackparse build && node scripts/compare-ports.mjs # five ports; must print "differences: 0" +node scripts/compare-ports.mjs --only=go # one port against JS (or python, rust, c) ``` +For C, compare-ports and fuzz-ports configure `c/build` (Release, `TRACKPARSE_BUILD_TESTS=OFF`) +the first time and rebuild `trackparse-dump` there when a file in `c/src`, `c/wire`, `c/tools` or +`c/include` is newer than the binary. Keep test builds out of `c/build`. + Corpus check for R13 changes, when you have the private corpus (JSONL, one object per tracklist with `title` and `track_list`, kept in the git-ignored `spec/corpus/`): @@ -355,6 +461,7 @@ Run a single fixture case (tests are named by case id): pnpm --filter trackparse exec vitest run test/fixtures.test.ts -t "brackets-version-001" cd python && uv run pytest tests/test_fixtures.py -k "brackets-version-001" cd go && TRACKPARSE_ONLY=brackets-version-001 go test -run TestFixtures -v +cd c && TRACKPARSE_ONLY=brackets-version-001 build-/trackparse-fixtures ../spec/fixtures/*/*.json ``` Before pushing, mirror CI: `pnpm lint && pnpm --filter trackparse typecheck && pnpm test && @@ -366,7 +473,15 @@ uv run mypy --strict src && uv run pytest && uv build`, and in `rust/` cargo clippy --all-targets --all-features -- -D warnings && cargo test && cargo test --all-features`, and in `go/` `node scripts/gen_data.mjs --check && node scripts/gen_unicode.mjs --check && test -z "$(gofmt -l .)" && go vet ./... && go vet -tags trackparse_wire ./... && go run honnef.co/go/tools/cmd/staticcheck@2026.2.2 ./... && -go test -race ./...`. +go test -race ./...`, and in `c/` +`node scripts/gen_data.mjs --check && node scripts/gen_unicode.mjs --check && +cmp tests/data/unicode/cases.jsonl ../go/testdata/unicode/cases.jsonl`, the clang-format check +from the table, the bans grep of `c.yml` (its "No locale-dependent or unstable calls" step, run from +the root), `node scripts/amalgamate.mjs --out /tmp/amal`, then +`cmake -S . -B build-ci -DTRACKPARSE_WERROR=ON && cmake --build build-ci -j4 && +ctest --test-dir build-ci --output-on-failure`, and the same `ctest -LE consumer` in an ASan build +(`-DTRACKPARSE_SANITIZE=ON`). MSVC, macOS, ARM64, 32-bit x86, TSan, MSan and Valgrind only run in +CI unless you set them up. ## Fixture authoring @@ -388,7 +503,7 @@ Format and matcher: [`spec/fixtures/README.md`](spec/fixtures/README.md). Schema (see [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md)). - Defaults (`fn`, `options`) go in the file's `defaults`; options merge shallowly per case. - `js/test/skip.json` (and `python/tests/skip.json`, `rust/tests/skip.json`, - `go/testdata/skip.json`) is for port-specific gaps only, keyed by case id with a reason. It can only + `go/testdata/skip.json`, `c/tests/skip.json`) is for port-specific gaps only, keyed by case id with a reason. It can only shrink: a skip-listed case that passes fails the run. Shared "known wrong" belongs in `xfail`. ## Documentation site and READMEs @@ -403,14 +518,14 @@ PR: |---|---| | a rule's behaviour (R1–R12) | the guide for that area (`guides/what-it-understands`, `artists`, `versions`, `junk-and-flags`, `modes`, `formatting`), the root README tables | | tracklists (R13) | `guides/tracklists`, `guides/editing-tracklists`, `reference/tracklist`, `reference/warnings` | -| a function, option, field or type | `reference/parse`, `reference/options`, `reference/functions` or `reference/tracklist`; the API sections of `js/README.md`, `python/README.md`, `rust/README.md` and `go/README.md`, and the Go doc comments and `go/example_test.go` | +| a function, option, field or type | `reference/parse`, `reference/options`, `reference/functions` or `reference/tracklist`; the API sections of `js/README.md`, `python/README.md`, `rust/README.md`, `go/README.md` and `c/README.md`, the Go doc comments and `go/example_test.go`, the comments in `c/include/trackparse.h`, the C++ wrapper `trackparse.hpp` and `c/examples/` (each with its `.expected` output) | | a warning code | `reference/warnings` | | fixture counts, file counts, the size budget | `components/Stats.astro`, `index.mdx`, `start/introduction`, `project/testing`, `project/ports`, the root README "At a glance" and "How it's tested" | | a port, a command, CI or the release flow | `project/ports`, `project/contributing`, `project/testing` ("Run it yourself") | | `spec/SPEC.md` | nothing by hand: `reference/spec` is generated from it at build time | -**Every code example is in four languages.** There are no per-language pages. Each example on the -site is four synced tabs, in the order JavaScript, Python, Rust, Go: +**Every code example is in five languages.** There are no per-language pages. Each example on the +site is five synced tabs, in the order JavaScript, Python, Rust, Go, C: ````mdx @@ -441,6 +556,15 @@ parse("Noisia - Stigma (2015)").year; // Some(2015) fmt.Println(*trackparse.Parse("Noisia - Stigma (2015)").Year) // 2015 ``` + + + +```c +trackparse_track *t = trackparse_parse("Noisia - Stigma (2015)", TRACKPARSE_NUL_TERMINATED); +printf("%d\n", *t->year); // 2015 +trackparse_track_free(t); +``` + ```` @@ -464,21 +588,41 @@ fmt.Println(*trackparse.Parse("Noisia - Stigma (2015)").Year) // 2015 `["Chase" "Status"]`), `%+v` for structs and slices of structs (`[{Raw:HD Kind:quality}]`), and `json.Marshal` when the page is about the JSON form. Don't print a pointer field without `*`: `%+v` writes its address. +- Write the C version in C terms: statements from inside a `main`, with `#include ` + in the first block of a page that shows includes. Strings go in with `TRACKPARSE_NUL_TERMINATED` + as the length; the `_with` functions take option handles built with setters + (`trackparse_parse_options_new()`, `trackparse_parse_options_set_mode(o, TRACKPARSE_MODE_YOUTUBE)`, + `_add_known_artist`), and every result and handle is freed with its own `_free` in the same + block. Fields are snake_case (`full_title`, `type_name`, `explicit_`), arrays are a pointer and + a `_count` (`t->artists_count`, `list->count` / `list->items` for `trackparse_artists`), and + nullable fields are pointers (`*t->year`, `e->time ? … : …`). Every output is printed with + `printf` and written as a `//` comment after it, one comment line per output line: `%s` on + `.ptr`, `%d` for ints, `%g` for seconds, `%zu` for counts, `%lld` for edit line numbers, and the + enum's `trackparse__name()` for roles, modes, warnings and codes (`trackparse_role_name(a->role)` + prints `featured`). Use `trackparse_track_to_json` when the page is about the JSON form. Leave + out the `NULL` checks (`start/getting-started` and `c/README.md` say once to check for it in + real code); a variable declared in one block (`t`, `list`) + is reassigned in a later one on the same page. Type listings (`typedef struct … {…}`) go in + their own block with the field comments of the header. The C++ wrapper has no tab: its examples + live in `c/README.md` and `c/examples/cpp.cpp`. - Run every example and paste the real output; never write an output by hand. For Rust, a scratch cargo project that depends on the crate by path (`trackparse = { path = "…/rust" }`) is enough. For Go, a scratch module with `go mod edit -replace=github.com/4matic/trackparse/go=…/go` and - `GOFLAGS=-mod=mod`. Language-specific + `GOFLAGS=-mod=mod`. For C, the amalgamation (`node c/scripts/amalgamate.mjs --out `) + compiled next to the program is enough. Language-specific notes (typing, `to_dict()`, `TypeError`) go on the page they concern, not on a separate page. - The playground and the landing demo import `js/` directly, so they follow the code automatically; check them in a browser when the output shape changes. The playground's code panels generate - JS, Python, Rust and Go (`code()` and `listCode()` in `Playground.astro`): when an option or an - edit changes, update all four generators and compile a generated Rust and Go snippet. + JS, Python, Rust, Go and C (`trackCode()` and `listCode()` in `site/src/lib/codegen.ts`, laid out + as each language's formatter writes it, plus `apiUrl()` for the API links): when an option or an + edit changes, update all five generators and compile a generated Rust, Go and C snippet. **READMEs link to the site.** Each README section opens with a `**Docs:**` line that links the matching site pages (`README.md`, `js/README.md`, `python/README.md`, `rust/README.md`, -`go/README.md`, `spec/fixtures/README.md`, `spec/generator/README.md`). Add one for a new section, and fix the links +`go/README.md`, `c/README.md`, `spec/fixtures/README.md`, `spec/generator/README.md`). Add one for a new section, and fix the links when a page or heading moves. Use full `https://4matic.github.io/trackparse/...` URLs: npm, PyPI, -crates.io and pkg.go.dev render the package READMEs where relative links break. +crates.io and pkg.go.dev render the package READMEs where relative links break, and the C README +is read from the release tarball and on GitHub. **Link the first mention.** In each section of a README or a site page, link the first mention of a rule, option, field, warning or function to the place that explains it, and only the first: @@ -494,6 +638,10 @@ a rule, option, field, warning or function to the place that explains it, and on `…/tracklist/enum.Edit.html`, `…/struct.ParsedTrack.html#method.to_json`) and pkg.go.dev anchors (`https://pkg.go.dev/github.com/4matic/trackparse/go#ParseWith`, `#Track.MarshalJSON`). Check the anchor on the live page; pkg.go.dev ids are the identifier, `Type.Method` for methods. + C has no hosted API reference yet: link the header on GitHub + (`https://github.com/4matic/trackparse/blob/main/c/include/trackparse.h`, no line anchor, + since lines move) once per page, at the first C name, and the site reference pages for the + rest. The playground's C links (`C_REF` in `codegen.ts`) point at the site's reference. Give an example a prefilled playground link when seeing the whole output helps ("try it", "open this list in the playground"). The hash is `#track=` with optional `mode`, `splitAnd`, @@ -520,27 +668,31 @@ Each of these was written wrong at least once and caught in review. Check them w | Don't write | Write instead, and why | |---|---| -| "linear time" | Hand-written scanners, no regex backtracking. The R9.2 dedup in JS and Python is quadratic on thousands of repeated `feat.` credits (Rust and Go are near-linear). | -| "under 100 ms" for every port | True for JS (10 to 70 ms on 10,000 code points) and Rust (under 20 ms, release build). Python takes 40 to 170 ms. The suites enforce 1 s (JS, Python) and 2 s (Rust). Go: 3 to 7 ms (`go test -bench Parse10k` in `go/`, on an i7-4770S, Go 1.24, with other jobs running; JS on the same inputs 4 to 18 ms), ceiling 2 s. So "at most tens of milliseconds" holds for JS, Rust and Go, not Python. A 10,000-line tracklist: Go 0.33 to 0.38 s, JS 0.8 to 0.9 s. | +| "linear time" | Hand-written scanners, no regex backtracking. The R9.2 dedup in JS and Python is quadratic on thousands of repeated `feat.` credits (Rust, Go and C are near-linear). In every port a long `knownArtists` name is slow on a long input (see Known gaps). | +| "under 100 ms" for every port | True for JS (10 to 70 ms on 10,000 code points) and Rust (under 20 ms, release build). Python takes 40 to 170 ms. The suites enforce 1 s (JS, Python) and 2 s (Rust). Go: 3 to 7 ms (`go test -bench Parse10k` in `go/`, on an i7-4770S, Go 1.24, with other jobs running; JS on the same inputs 4 to 18 ms), ceiling 2 s. C: 1.4 to 5.7 ms (`test_bench` from a CMake Release build, GCC 9 at `-O3`, same i7-4770S, load average 6 from other jobs), ceiling 2 s. So "at most tens of milliseconds" holds for JS, Rust, Go and C, not Python. A 10,000-line tracklist: Go 0.33 to 0.38 s, C 0.34 to 0.39 s, JS 0.8 to 0.9 s. | | "identical output for any input" | Identical on every fixture input. The Rust crate takes NFC from `unicode-normalization` (Unicode 18), Node 24 has Unicode 17, so 32 new combining marks can be ordered differently. Link `project/ports/#what-the-rust-port-taught`. | -| "zero dependencies" for the project | Zero in JS, Python and Go (the Go tables are generated from Node, not taken from `golang.org/x/text`). Rust has one, `unicode-normalization`. | +| "zero dependencies" for the project | Zero in JS, Python and Go (the Go tables are generated from Node, not taken from `golang.org/x/text`). Rust has one, `unicode-normalization`. C needs only the C standard library, `libm` and the system's threads (pthreads, or Windows SRW locks); C++ is needed only for the wrapper's tests. | +| "on vcpkg / Conan", "install the C library with a package manager" | No package manager carries it. FetchContent from the release tarball, the amalgamation, or an install from source with `find_package` and pkg-config, all three from the first C release, 0.7.0. | +| "no recursion" for C | One recursive function, the JSON writer `tp_json_write`, bounded by the reader's `TP_JSON_MAX_DEPTH` (200). The pipeline has none. | | a size in mixed units | Core: about 18 kB gzip. Tracklist entry: about 8.4 KiB (8,606 B), budget 9 KiB. Re-measure with `pnpm --filter trackparse build && pnpm --filter trackparse size`. | -| every suite checks "no word goes missing" | Only `rust/tests/properties.rs` and `go/properties_test.go` have that test today. | +| every suite checks "no word goes missing" | Only `rust/tests/properties.rs`, `go/properties_test.go` and `c/tests/test_properties.c` (the check is in `c/tests/hardening.c`) have that test today. | | "Neuropunk" on the site | "a private corpus of real podcast tracklists". Fixture file names and `source` values keep the name; the site and READMEs don't. | Numbers that appear in many files (grep all of them when one changes): fixture counts (13,130 = 1,203 handwritten + 11,927 generated), test counts (vitest 1,352, pytest 1,342), CI matrices -(Node 22/24 + 18/20, Python 3.9 to 3.14, Rust stable + 1.74, Go stable + 1.22), the 27 version types, the sizes +(Node 22/24 + 18/20, Python 3.9 to 3.14, Rust stable + 1.74, Go stable + 1.22, C: GCC, Clang, +ARM64, shared, macOS, MSVC, 32-bit x86 and GCC 9 with CMake 3.16), the 27 version types, the sizes above. `spec/generator/README.md` links the site anchor `#generated-11927-cases`, which changes with the count. ### Checking examples and links - **Run every block, in every language.** A harness that extracts the fenced `js` / `python` / - `rust` / `go` blocks per file, runs them and compares each `expr // output` line takes minutes to + `rust` / `go` / `c` blocks per file, runs them and compares each `expr // output` line takes minutes to write and has caught every wrong output so far. JS runs against `js/dist` after a build, Python with `uv run python`, Rust in a scratch cargo project with a path dependency - (`features = ["serde"]`, plus `serde_json`), Go in a scratch module with a `replace` to `go/`. + (`features = ["serde"]`, plus `serde_json`), Go in a scratch module with a `replace` to `go/`, + C compiled against the amalgamation (below). - **Rust blocks must compile as written, in page order.** A bare `value;` moves a non-`Copy` value, so a later line that uses it fails (E0382, E0507). Borrow instead: `&track.artists;`, `&list.warnings;`, `&parse(…).versions[0];`. Type listings (`pub struct …`) go in their own block, @@ -551,6 +703,15 @@ with the count. run them, in page order; a variable declared with `:=` in one block is reassigned with `=` in a later one on the same page. The pkg.go.dev examples are `Example` functions in `go/example_test.go` with an `// Output:` block, so `go test` checks them. +- **C blocks are statements too.** Concatenate a page's `c` blocks in page order into one + `int main(void) { … return 0; }` with ``, `` and `` included + (skip the type listings and drop a repeated `#include` line), compile it with + `cc -std=c11 -ffp-contract=off -I page.c /trackparse.c -lm -pthread`, run it, and + compare its stdout line by line with the `//` comments that follow the `printf` calls. A block + that redeclares a variable an earlier block declared fails to compile, which is the point: + later blocks reassign. Build with `-fsanitize=address,undefined` to catch a missing `_free` or a + read through a `NULL` the example forgot. The README examples run the same way, and + `c/examples/` is built and compared by CTest (`example_*`). - **Python examples need their imports** (`from trackparse import ParsedTrack`). Functions that take a string raise `TypeError` on other input; `format_track` and `all_artists` take a `ParsedTrack` unchecked. @@ -594,31 +755,67 @@ with the count. `test_ten_thousand_lines_are_fast` in the Python suite can fail on a busy machine. Re-run it alone before believing it. - A reviewer should run the examples, not read them. Ask for file, line and the concrete fix. +- What worked for the C port: header first. One session wrote the runtime (`c/src/rt.h`), the + public header and `c/src/internal.h` with every internal type and prototype (one section per Go + file) plus `c/src/PORTING.md` with the translation rules, and the harness (runner, dump tool, + compare-ports runner) so the conformance report worked as a progress bar. Then agents worked in + parallel tracks by area (artist side, title side, tracklists, API) against those fixed + prototypes, each owning its `.c` files and changing no header without asking. Then a reviewer + that ran compare-ports, the fuzz-ports run and the sanitizer builds, and a fixer. +- Agents in the same tree each use their own CMake build directory (`c/build-`); the + build trees are git-ignored. `c/build` belongs to compare-ports and fuzz-ports, which configure + it with tests off and rebuild only `trackparse-dump`: don't run test builds there, and don't + delete it while another agent's compare run is going. +- Timings from a sanitizer build are several times those of a Release build (8.7 s against 2.5 s + on the `knownArtists` reproducer under Known gaps); benchmark only a Release build + (`test_bench` warns when it was built with sanitizers). ## Known gaps (not yet fixed) -- R9.2 dedup is quadratic in JS and Python on thousands of repeated credits (Rust and Go are +- R9.2 dedup is quadratic in JS and Python on thousands of repeated credits (Rust, Go and C are near-linear). +- `knownArtists` is slow with a long name on a long input, in every port: at each start position + `matchKnownAt` (R7.3a, `js/src/context.ts`) builds the dedup key of every slice that ends at a + boundary inside the `2 * longest + 8` window, so the cost grows with the input length times + about the square of the window. The reproducer is + `{"fn":"parseArtists","input":<"a feat. B & C (x) - " repeated 500 times, 10,000 code points>, + "options":{"knownArtists":[]}}` through each dump tool. Measured on + the i7-4770S under load: C 2.3 to 4.1 s (Release, 5 MB peak memory), Rust 1.9 s, Go 4.2 s, + JS 5.3 to 7.2 s, all with the same output. Half the input halves the time. (C peaked at 1 GB + here until `tp_match_known_at` gave each candidate key back with `tp_arena_mark` / + `tp_arena_release`.) - `format(track, { feat: "nope" })` drops the featured artists in JS and Python (and in Go, which - matches JS: `FormatOptions{Feat: "nope"}`) instead of falling - back to the default, unlike other bad options. Needs a spec decision and a fixture first. -- `format(track, { featMarker: null })` writes the literal marker `null` in JS, Rust and Go; - Python falls back to the input's marker (found by `scripts/fuzz-ports.mjs`). Needs a spec - decision and a fixture. + matches JS: `FormatOptions{Feat: "nope"}`, and in C's JSON door, which matches JS too) instead of + falling back to the default, unlike other bad options. The typed C setter takes an enum, so a + C program cannot ask for it. Needs a spec decision and a fixture first. +- `format(track, { featMarker: null })` writes the literal marker `null` in JS, Rust, Go and C's + JSON door; Python falls back to the input's marker (found by `scripts/fuzz-ports.mjs`). The + typed C API has no way to pass null. Needs a spec decision and a fixture. - R13.9.5: `insert` next to a bare CR can merge the new line with an empty LF line on re-read (`"\r\r\n\n\r"`, insert after 2 gives 4 lines). All ports agree; no fixture pins it yet. - Python tracklist types have `to_dict()` but no `from_dict()`; `ParsedTrack` has both. -- JS and Python do not test invariant 6 ("no word goes missing"); only Rust and Go do. +- JS and Python do not test invariant 6 ("no word goes missing"); only Rust, Go and C do. +- C has no `trackparse_apply_edits_with`. JS `applyEdits(text, edits, options)`, Python's keyword + options, Rust `apply_edits_with` and Go `ApplyEditsWith` accept tracklist options and ignore them + (R13.10: edits do not depend on them), so nothing is lost, but the C API is not symmetric with + `trackparse_parse_tracklist_with`. Adding it later is ABI compatible. +- The C library has no hosted API reference (the plan's Doxygen pages were not built): docs link + the header on GitHub. - The npm, PyPI and crates.io publish jobs use actions by tag (only the crates.io auth action is pinned by SHA); the Go job and `go.yml` pin every action by SHA. -- The playground's Rust and Go snippets are whole programs, the JS and Python ones are bare +- The playground's Rust, Go and C snippets are whole programs, the JS and Python ones are bare expressions. +- The C full Unicode sweep (`TRACKPARSE_UNICODE_FULL=1`) is not in CI, while Go's is. CI checks + the C tables with `gen_unicode.mjs --check` and the committed sample (equal to Go's, `cmp` in + `c.yml`), so C's own normalization and lowercasing code meets every code point only when someone + runs the sweep by hand. ## Porting guide (Rust, Go, others) -A port is done when it passes every fixture and every invariant. The Python, Rust and Go ports are -done and are good second references next to JS: their modules map one to one onto `js/src`. -Checklist: +A port is done when it passes every fixture and every invariant. The Python, Rust, Go and C ports +are done and are good second references next to JS: the Python, Rust and Go modules map one to one +onto `js/src`, and the C files onto the Go files (`c/src/PORTING.md`). A port to a language without +garbage collection or generics should start from the C port. Checklist: 1. **Codegen from `spec/data` and `spec/VERSION`** into a source file (like `js/scripts/gen-data.ts`), with a `--check` mode wired into CI. Expose `SPEC_VERSION`. @@ -635,14 +832,17 @@ Checklist: file against the fixture schema, each output against `parsed-track.schema.json` (or `tracklist.schema.json` for `fn: "parseTracklist"`; `applyEdits` cases also check `text`), honour `status` (pass / xfail / ambiguous), and keep a port-local skip list that can only shrink. -6. **Property tests** for the SPEC invariants (Hypothesis for Python; the Rust crate and the Go - module use a small seeded generator of their own, to stay free of dev dependencies; Go adds - `go test -fuzz` targets). +6. **Property tests** for the SPEC invariants (Hypothesis for Python; the Rust crate, the Go + module and the C library use a small seeded generator of their own, to stay free of dev + dependencies; Go adds `go test -fuzz` targets, C libFuzzer targets). 7. **API** idiomatic for the language but equivalent: Python `parse`, `parse_artists`, `format_track`, `normalize` (snake_case fields are fine only if the JSON output keeps the spec's keys); Rust with `serde` behind a feature flag and `unicode-normalization` as the only required dependency; Go with exported fields, option structs whose zero value is the default (a pointer - where the zero value is also a real setting), and `MarshalJSON` writing the spec's JSON. + where the zero value is also a real setting), and `MarshalJSON` writing the spec's JSON; C + with read-only result structs in one block per result, opaque option handles with setters (so + "not set" and "set to zero" differ), enums plus `_name()` functions and the name strings for + keyword-made values, and `_to_json` writing the spec's JSON. 8. **Conformance report** script and a CI workflow mirroring `js.yml`. 9. **Cross-port diff.** Extend `scripts/compare-ports.mjs` (or write the same thing) so every fixture's full output is compared with JS, not only the fields the fixture asserts. @@ -730,6 +930,88 @@ port started, the rest by compare-ports and the differential run against JS: - **Rounding.** Half up is `math.Floor(v*10^d + 0.5)`. `math.Round` differs on values such as `0.49999999999999994` and on negatives. +Hazards the C port ran into. Some were planned for before the port started, the rest were found by the +sanitizers, the 32-bit, ARM64 and MSVC builds, the amalgamation, compare-ports and fuzz-ports: + +- **FMA contraction.** GCC in GNU mode defaults to `-ffp-contract=fast`, so + `floor(v * 10^d + 0.5)` can become a fused multiply-add (ARM64, or x86 with FMA) and round + differently. GCC also ignores `#pragma STDC FP_CONTRACT OFF`. CMake passes `-ffp-contract=off` + (`/fp:precise` on MSVC), `num.c` sets the pragma for Clang and `fp_contract(off)` for MSVC, and + `tp_half_up_units` stores the product in a `volatile` before the add (as `tl_times.c` does for + its scaled whole seconds), so an amalgamation compiled without the flag rounds the same. +- **Locale.** `strtod`, `printf("%g")`, `isalpha` and `tolower` follow `LC_NUMERIC` / `LC_CTYPE`: + a German locale writes `3167,5`, a Turkish one lowercases `I` to dotless `ı`. `src/` has no + ``, no `strto*` / `ato*`, no `printf` family and no `setlocale` (the bans grep in + `c.yml`; comments are exempt). `test_locale` compares every fixture output after + `setlocale(LC_ALL, "")` and under `de_DE.UTF-8` / `tr_TR.UTF-8` with the `C` locale's. +- **Numbers by hand.** No C function writes JavaScript's shortest round-trip digits, and `strtod` + is out (locale). `num.c` parses decimal strings to the correctly rounded double (a fast path + when the digits fit in 2^53 and the power of ten is exact, exact big-integer arithmetic + otherwise, the dropped digits as one sticky digit) and writes `Number#toString` (shortest + digits, then JS's exponent rules: `1e+21`, `5e-324`, `-0` as `0`). `test_num` checks both + against Node (`scripts/dump_numbers.mjs`; the committed sample is 2,000 cases, run it with a + larger `--n` after touching `num.c`). +- **x87 excess precision.** 32-bit x86 without SSE2 computes in 80 bits (`FLT_EVAL_METHOD == 2`) + and double-rounds. `num.c` has an `#error` unless `FLT_EVAL_METHOD` is 0, CMake adds + `-msse2 -mfpmath=sse` on 32-bit x86, and CI has an `-m32` job. +- **`char` signedness.** `char` is signed on x86 and unsigned on ARM. Every byte the pipeline + inspects is `unsigned char`; ARM64 CI catches a slip. +- **`qsort` is not stable.** `tp_sort_stable` (a merge sort) everywhere; the bans grep rejects + `qsort(`. +- **Out of memory with `setjmp` / `longjmp`, not sticky arenas.** The plan had arenas that stay + failed and a pipeline that finishes on empty data. What shipped: each public call opens a + `tp_scope` (an arena plus a `jmp_buf`), `tp_alloc` never returns `NULL` and `longjmp`s to the + scope when the system allocator fails, and the scope frees the arena and returns `NULL`. So the + pipeline has no `NULL` checks and no `free`, and must never hold anything but arena memory (no + `malloc`, no `FILE *`). Scratch memory is not freed within a call, except where a loop + builds throwaway values: `tp_arena_mark` / `tp_arena_release` rewind the arena (the + `knownArtists` search in `context.c` peaked at 1 GB without it). A function that calls `setjmp` must keep no + local that changes between `setjmp` and the `longjmp` (GCC's `-Wclobbered`): put the armed body + in a function of its own, or make the local `volatile` (`void *volatile built` in + `tp_once_get`). Setters build what they add under a scope and commit only when every allocation + succeeded. `test_oom` fails the n-th allocation for every n on about 50 inputs, also with the + default tables not built yet ("cold"), and checks the result or `NULL` and that every block is + freed. +- **Result blocks in two passes.** Each result is one allocation that its `_free` releases: the + same fill code runs once to measure (its writes land in the scratch arena) and once into a block + of exactly that size. Nothing in a result points into another result or into the input. +- **Lazy tables without `pthread_once`.** `PTHREAD_ONCE_INIT` is not all-zero bytes everywhere + (macOS), and a table build that ran out of memory must be retried by a later call. `tp_once_get` + uses one process-wide mutex (an SRW lock on Windows) to read and publish the value, runs the + build outside the lock, and lets the loser of a race free its arena. `test_threads` runs under + ThreadSanitizer in CI. +- **One translation unit.** The installed library is built from the amalgamation, where + `TP_PRIVATE` is `static`, so only `trackparse_*` leaves even a static library (the `exports` test + checks with `nm`, CI with the shared build too). Consequences: two files may not define the same + file-local name, struct tag or typedef (`amalgamate.mjs` fails and names both files); unused + static functions need `TP_UNUSED` (and MSVC's C4505 is off there); and the generated tables use + `TP_PRIVATE_DATA`, because a `static` tentative declaration in a header needs the complete type, + so the arrays are declared with their `_N` sizes. +- **Source charset and trigraphs.** MSVC reads source files in the system code page, so every + generated string and every non-ASCII literal is a `\xNN` escape (and the build passes `/utf-8` + anyway). A hex escape swallows the hex digits after it, so `c_lit.mjs` splits the literal + (`"\xc3" "a"`). GCC in ISO mode (`-std=c11`) reads trigraphs, and the data has `??` (the + unknown tokens `?`, `??`, `???`), so `c_lit.mjs` writes every `?` as `\?`. +- **C++ keywords in a C header.** The header is also compiled as C++ (by the wrapper and by C++ + users), so no name may be a C++ keyword: the flag is `explicit_`, the wrapper's enum values are + `auto_`, and its delete edit is `delete_line()`. +- **Name clashes inside the API.** `trackparse_version` is the type of a track's version, so the + library's version function is `trackparse_library_version()`; check a new function name + against the type names first. +- **Unicode tables shared with Go.** `unicode_derive.mjs` is a copy of the derivation in + `go/scripts/gen_unicode.mjs`; both generators write the same sample, and `c.yml` `cmp`s + `c/tests/data/unicode/cases.jsonl` with `go/testdata/unicode/cases.jsonl`. Change both together. +- **Typed edits to loose ones.** Go turns a typed edit into its JSON form and parses it back; C + has no JSON reader in the library, so `tp_edit_json` builds that value directly: a NaN or + infinite `seconds` becomes null (`edit-invalid`, as `JSON.stringify` would make it), `-0` + becomes `0`, and `lines` is present only when `has_lines` is set. +- **32-bit widths.** Go's `int` is `ptrdiff_t`, the JS-number edit fields are `int64_t`; they + differ on 32-bit, so every mix needs a cast, and `-Wconversion` with `-Werror` on the `-m32` job + holds the line. +- **Sanitizer combinations.** ThreadSanitizer cannot run with ASan, and MemorySanitizer needs an + instrumented C++ standard library for the C++ targets, so TSan and MSan are separate CMake + options and the MSan job builds the C programs only. + R13 (tracklists) notes for a new port: - **Two passes per text.** First a cheap *probe* per line: the R13.2 time scan, then R1, R2 and R4 @@ -755,8 +1037,9 @@ R13 (tracklists) notes for a new port: hazard above does not apply here. - **Time ceilings.** R13.11 asks for linear time; each port's suite picks its own 10,000-line ceilings: `parseTracklist` JS 3 s, Python 15 s; `applyEdits` (shift + sort, 2,000 edits) JS 1 s, - Python 2 s / 5 s; Go 3 s and 1 s, ten times that under `-race` (`go/bench_test.go`). The Rust - ceilings are in `rust/tests/tracklist_properties.rs`. + Python 2 s / 5 s; Go 3 s and 1 s, ten times that under `-race` (`go/bench_test.go`); C 3 s and + 1 s, ten times that in a sanitizer build or with `TRACKPARSE_SLOWDOWN=` + (`c/tests/test_properties.c`). The Rust ceilings are in `rust/tests/tracklist_properties.rs`. ## Versioning and release @@ -765,17 +1048,18 @@ Releases are automated with [release-please](https://github.com/googleapis/relea 1. Feature PRs are **rebase-merged**, so every commit lands on `main` and becomes its own changelog line: each commit message must be a conventional commit, and so must the PR title (`pr-title.yml` enforces the title). Release PRs (`chore: release main`) are squash-merged. Types: `feat`, `fix`, `perf`, `revert`, `docs` (shown in the changelog) and `refactor`, - `test`, `build`, `ci`, `chore` (hidden). Scopes: `js`, `python`, `rust`, `go`, `spec`, `generator`, `fixtures`, `site`, `ci`, `deps`… + `test`, `build`, `ci`, `chore` (hidden). Scopes: `js`, `python`, `rust`, `go`, `c`, `spec`, `generator`, `fixtures`, `site`, `ci`, `deps`… 2. On every push to `main`, `release.yml` updates a **release PR** (`chore: release main`) that bumps `js/package.json`, `spec/VERSION`, `SPEC_VERSION` in `js/src/data.generated.ts`, the - Python, Rust and Go version files (below), and writes `js/CHANGELOG.md` / `spec/CHANGELOG.md` / - `python/CHANGELOG.md` / `rust/CHANGELOG.md` / `go/CHANGELOG.md`. + Python, Rust, Go and C version files (below), and writes `js/CHANGELOG.md` / `spec/CHANGELOG.md` / + `python/CHANGELOG.md` / `rust/CHANGELOG.md` / `go/CHANGELOG.md` / `c/CHANGELOG.md`. 3. **Merging the release PR** creates tags `js-vX.Y.Z`, `spec-vX.Y.Z`, `python-vX.Y.Z`, - `rust-vX.Y.Z` and `go/vX.Y.Z`, GitHub Releases with the changelog as notes, then publishes + `rust-vX.Y.Z`, `go/vX.Y.Z` and `c-vX.Y.Z`, GitHub Releases with the changelog as notes, then publishes `trackparse` to npm and to PyPI via trusted publishing (OIDC, no stored token), attaches the tarball / wheel + sdist and appends install instructions to each release. The crates.io job (`publish-crates`) runs only when the repository variable `CRATES_PUBLISH` is `true` (see - below). The Go module needs no upload: the tag is the release (see below). For a bigger + below). The Go module needs no upload: the tag is the release (see below). The C library has + no registry: `publish-c` attaches its files to the GitHub Release (see below). For a bigger release, add `.github/release-notes/X.Y.Z.md` beforehand: it is prepended to the notes. Version rules: @@ -789,8 +1073,9 @@ Version rules: `python/pyproject.toml`, `__version__` in `python/src/trackparse/__init__.py`, `SPEC_VERSION` in `python/src/trackparse/_data.py` and the package's own entry in `python/uv.lock`, and writes `python/CHANGELOG.md`. Merging it tags `python-vX.Y.Z` and publishes to PyPI via trusted publishing (environment `pypi`), with the wheel - and sdist attached to the release. `spec.yml` checks that all five versions match (js, spec, - python, rust, go). + and sdist attached to the release. `spec.yml` checks that all six versions match (js, spec, + python, rust, go, c; for c it reads `c/VERSION`, `CMakeLists.txt`, `TRACKPARSE_VERSION`, the + `_MAJOR` / `_MINOR` / `_PATCH` macros and `TP_SPEC_VERSION`). - `rust` is **linked** as well: a release-please component (`release-type: rust`) in the same `linked-versions` group. The release PR bumps `rust/Cargo.toml` (the line marked `x-release-please-version`) and `SPEC_VERSION` in `rust/src/data.rs`, and writes @@ -825,16 +1110,40 @@ Version rules: checksum database keep the tag's content forever, even if the tag is deleted or moved. Never move or re-create a `go/v…` tag. A bad version can only be marked with a `retract` directive in `go/go.mod`, released in a new version. +- `c` is **linked** as well: a release-please component (`release-type: simple`, + `version-file: VERSION`, so `c/VERSION`) in the same `linked-versions` group, with `extra-files` + `CMakeLists.txt` (the `project(trackparse VERSION …)` line marked `x-release-please-version`), + `include/trackparse.h` (`TRACKPARSE_VERSION` with `x-release-please-version`, and + `TRACKPARSE_VERSION_MAJOR` / `_MINOR` / `_PATCH` with `x-release-please-major` / `-minor` / + `-patch`) and `src/data_gen.h` (`TP_SPEC_VERSION`, which `c/scripts/gen_data.mjs` writes with the + marker, so `--check` stays clean after the bump). The release PR writes `c/CHANGELOG.md`, and + merging it tags `c-vX.Y.Z` (the default `-` separator). The first C release is 0.7.0. The + manifest starts C at the linked 0.6.1, so expect its first changelog to link a `c-v0.6.1` tag + that never existed, as Go's and Rust's first entries did, and to list every commit under `c/`. +- **C publishing is files on the GitHub Release.** The `publish-c` job in `release.yml` + (environment `c`, every action pinned by SHA) checks out the tag, checks that `c/VERSION`, the + CMake version, `TRACKPARSE_VERSION`, `TP_SPEC_VERSION`, `spec/VERSION` and the tag agree and that + both codegen `--check`s pass, runs the CMake build and `ctest` from the repository, then builds + `trackparse-c-X.Y.Z.tar.gz` (`git archive` of `c/` plus the amalgamation in `dist/`, so it + builds without Node and without `../spec`, where the fixture tests skip) and + `trackparse-c-X.Y.Z-amalgamation.zip` (`trackparse.c`, `.h`, `.hpp`, `LICENSE`), writes + `SHA256SUMS`, builds and tests the tarball alone, installs it and builds a program with + pkg-config, builds the amalgamation alone with `-Wall -Wextra -Werror`, attests build + provenance, uploads the three files and appends a FetchContent snippet with the tarball's hash + to the release notes. **Release files are permanent**: package recipes and FetchContent users + pin the tarball's hash, so the job never replaces a file that is already attached, and a bad + release gets a new patch version, never a re-upload. - **A publish job failed after the tags were created?** Fix the cause on `main` with a hidden commit type (`ci`/`chore`, so no new release), then re-run publishing for the existing tag: `gh workflow run release.yml -f python_tag=python-vX.Y.Z` (PyPI) or `-f rust_tag=rust-vX.Y.Z` (crates.io) or `-f go_tag=go/vX.Y.Z` (the Go checks, proxy request - and release notes; the module itself was published by the tag). The npm job always republishes from a fresh release; a + and release notes; the module itself was published by the tag) or `-f c_tag=c-vX.Y.Z` (builds + the C files again and uploads only the ones that are missing). The npm job always republishes from a fresh release; a failed npm publish needs the same treatment by hand. - **Things the 0.5.0 and 0.6.0 releases taught:** - The release PR is opened with `GITHUB_TOKEN`, so no CI runs on it and GitHub shows it as `UNSTABLE`. That is expected; `main` was green when it was generated. - - A `docs:` commit under `js/`, `python/`, `rust/` or `go/` (a package README) opens a release PR. A + - A `docs:` commit under `js/`, `python/`, `rust/`, `go/` or `c/` (a package README) opens a release PR. A commit that touches only the root README, `AGENTS.md`, `site/` or `.github/` does not. - A component's first changelog lists every commit that ever touched its folder, because there is no earlier tag to start from. @@ -874,8 +1183,22 @@ Version rules: `init()` except `wire_hook.go`, which only `-tags trackparse_wire` builds. Go has no lint against indexing, so look up code points with `at()` (it returns -1 out of range). Every exported identifier has a doc comment; examples are `Example` functions with `// Output:`. -- Public types in `js/src/types.ts`, `python/src/trackparse/types.py`, `rust/src/types.rs` and - `go/types.go` mirror the schemas; change them together. +- C: C11 (`CMAKE_C_EXTENSIONS OFF`), clang-format 19.1.7 (`c/.clang-format`, 100 columns) on every + file except the generated `_gen.c` / `_gen.h`, and warning-free under `-Wall -Wextra -Wpedantic + -Wshadow -Wconversion -Wno-sign-conversion` (MSVC `/W4`), with `-Werror` / `/WX` in CI. The bans + grep in `c.yml` keeps ``, `qsort`, `strto*`, `ato*`, the `printf` family, `setlocale` + and `localeconv` out of `src/`. Every internal function and global is `TP_PRIVATE` (or `static`), + generated tables `TP_PRIVATE_DATA`; file-local names are unique across `src/` (the amalgamation + shares one scope). Memory in `src/` comes from `tp_alloc` only (no `malloc` or `free` in the + pipeline); look up code points with `at()`-style helpers that return `TP_NORUNE` (-1) out of + range; no recursion except the depth-bounded JSON writer. Public names start with `trackparse_` + / `TRACKPARSE_` and are never C++ keywords; every public declaration has a doc comment in + `trackparse.h`, and a new result field is appended at the end of its struct (ABI). No `assert` or + `exit` in the library, and out of memory returns `NULL`; the one `abort` is `tp_alloc` called + outside an armed scope, which is a bug in the library, not an input. +- Public types in `js/src/types.ts`, `python/src/trackparse/types.py`, `rust/src/types.rs`, + `go/types.go` and `c/include/trackparse.h` (plus the wrapper `trackparse.hpp`) mirror the schemas; + change them together. - No `throw` (or panic) on any input path. Bad options fall back to defaults. ## Definition of done @@ -892,10 +1215,14 @@ Version rules: - [ ] Go: `gen_data.mjs --check`, `gen_unicode.mjs --check`, `gofmt -l` empty, `go vet`, staticcheck and `go test -race ./...` pass; the `TRACKPARSE_REPORT=1` report is 100%; `go/testdata/skip.json` did not grow -- [ ] `node scripts/compare-ports.mjs` reports 0 differences (all four ports) +- [ ] C: `gen_data.mjs --check`, `gen_unicode.mjs --check`, clang-format 19.1.7 and the bans grep + clean, the amalgamation writes, `ctest` passes with `-DTRACKPARSE_WERROR=ON` and again + under `-DTRACKPARSE_SANITIZE=ON`; the `TRACKPARSE_REPORT=1` report is 100%; + `c/tests/skip.json` did not grow +- [ ] `node scripts/compare-ports.mjs` reports 0 differences (all five ports) - [ ] `pnpm --filter trackparse size` and `check:package` pass - [ ] R13 changes: `node scripts/corpus-check.mjs` passes when you have the corpus - [ ] Conventional commits and PR title; `feat` if any fixture expectation changed - [ ] Site pages (`site/src/content/docs`) and READMEs updated in the same PR, examples in - JavaScript, Python, Rust and Go tabs with real output, `**Docs:**` links still pointing at existing + JavaScript, Python, Rust, Go and C tabs with real output, `**Docs:**` links still pointing at existing pages, `pnpm docs:build` passes diff --git a/README.md b/README.md index 27b2717..ef540e4 100644 --- a/README.md +++ b/README.md @@ -10,11 +10,13 @@ [![docs.rs](https://img.shields.io/docsrs/trackparse?logo=docsdotrs&logoColor=white)](https://docs.rs/trackparse) [![Go module](https://img.shields.io/github/v/tag/4matic/trackparse?filter=go%2Fv*&label=go%20module&logo=go&logoColor=white&color=00add8)](https://pkg.go.dev/github.com/4matic/trackparse/go?tab=versions) [![Go Reference](https://pkg.go.dev/badge/github.com/4matic/trackparse/go.svg)](https://pkg.go.dev/github.com/4matic/trackparse/go) +[![C library](https://img.shields.io/github/v/tag/4matic/trackparse?filter=c-v*&label=c%20library&logo=c&logoColor=white&color=a8b9cc)](https://github.com/4matic/trackparse/releases)
[![js](https://img.shields.io/github/actions/workflow/status/4matic/trackparse/js.yml?branch=main&label=js&logo=github)](https://github.com/4matic/trackparse/actions/workflows/js.yml) [![python](https://img.shields.io/github/actions/workflow/status/4matic/trackparse/python.yml?branch=main&label=python&logo=github)](https://github.com/4matic/trackparse/actions/workflows/python.yml) [![rust](https://img.shields.io/github/actions/workflow/status/4matic/trackparse/rust.yml?branch=main&label=rust&logo=github)](https://github.com/4matic/trackparse/actions/workflows/rust.yml) [![go](https://img.shields.io/github/actions/workflow/status/4matic/trackparse/go.yml?branch=main&label=go&logo=github)](https://github.com/4matic/trackparse/actions/workflows/go.yml) +[![c](https://img.shields.io/github/actions/workflow/status/4matic/trackparse/c.yml?branch=main&label=c&logo=github)](https://github.com/4matic/trackparse/actions/workflows/c.yml) [![spec](https://img.shields.io/github/actions/workflow/status/4matic/trackparse/spec.yml?branch=main&label=spec&logo=github)](https://github.com/4matic/trackparse/actions/workflows/spec.yml)
[![fixtures](https://img.shields.io/badge/fixtures-13%2C130%20passing-2ea44f)](#how-its-tested) @@ -43,11 +45,12 @@ goes into a field, and anything it doesn't recognize stays in the title, word fo It comes as an [npm package](https://www.npmjs.com/package/trackparse), a [PyPI package](https://pypi.org/project/trackparse/), a -[Rust crate](https://crates.io/crates/trackparse) and a -[Go module](https://pkg.go.dev/github.com/4matic/trackparse/go), all named `trackparse`. +[Rust crate](https://crates.io/crates/trackparse), a +[Go module](https://pkg.go.dev/github.com/4matic/trackparse/go) and a +[C library](c/README.md) with a C++ header, all named `trackparse`. One [spec](spec/SPEC.md) and one set of [fixtures](spec/fixtures/README.md) define the behaviour. -The four pass the same fixtures and give the same output on every fixture input. The example below -is JavaScript; [Quick start](#quick-start) has the same calls in Python, Rust and Go. You can +The five pass the same fixtures and give the same output on every fixture input. The example below +is JavaScript; [Quick start](#quick-start) has the same calls in Python, Rust, Go and C. You can [try this string in the playground](https://4matic.github.io/trackparse/playground/#track=01.%20Wilkinson%20ft.%20Becky%20Hill%20%26%20Tom%20Cane%20-%20Afterglow%20%28Sub%20Focus%20VIP%20Remix%29%20%5BOfficial%20Video%5D), or any other. @@ -107,8 +110,8 @@ Every key is always present ([field reference](https://4matic.github.io/trackpar [JSON Schema](spec/schema/parsed-track.schema.json)). When a guess was involved, `warnings` says which one. Python's [`to_dict()`](https://4matic.github.io/trackparse/reference/parse/#serializing-to-json), Rust's [`to_json()`](https://docs.rs/trackparse/latest/trackparse/struct.ParsedTrack.html#method.to_json) -and Go's [`MarshalJSON`](https://pkg.go.dev/github.com/4matic/trackparse/go#Track.MarshalJSON) -give this same JSON. +Go's [`MarshalJSON`](https://pkg.go.dev/github.com/4matic/trackparse/go#Track.MarshalJSON) +and C's [`trackparse_track_to_json`](c/README.md#json) give this same JSON. @@ -118,17 +121,18 @@ give this same JSON. | Number | What it means | |---|---| -| **13,130** shared fixtures | [1,203 written by hand](https://4matic.github.io/trackparse/project/testing/#handwritten-1203-cases), [11,927 generated](https://4matic.github.io/trackparse/project/testing/#generated-11927-cases) from combinations. 100% pass in JS, Python, Rust and Go, nothing skipped. | +| **13,130** shared fixtures | [1,203 written by hand](https://4matic.github.io/trackparse/project/testing/#handwritten-1203-cases), [11,927 generated](https://4matic.github.io/trackparse/project/testing/#generated-11927-cases) from combinations. 100% pass in JS, Python, Rust, Go and C, nothing skipped. | | **1,239** of them on tracklists | 303 handwritten, 936 generated. They cover line splitting, times, bullets and Markdown, warnings and edits | | **1,352** JS tests | Every fixture, a schema check on every output, property-based tests of the [spec invariants](https://4matic.github.io/trackparse/reference/spec/#invariants), API tests | | **27** version types | [Remix, VIP, bootleg, extended, radio, original, live, remaster, sped up and more](https://4matic.github.io/trackparse/guides/versions/#the-27-types) | -| **0** dependencies in JS, Python and Go | The Rust crate has one, `unicode-normalization`. The JS package is ESM + CJS with TypeScript types, about 18 kB gzipped. `trackparse/tracklist` adds about 8.4 KiB, only if you import it | +| **0** dependencies in JS, Python, Go and C | The Rust crate has one, `unicode-normalization`. The C library needs only libc, `libm` and threads. The JS package is ESM + CJS with TypeScript types, about 18 kB gzipped. `trackparse/tracklist` adds about 8.4 KiB, only if you import it | | **Node 18+** | CI runs the full suite on 22 and 24, and every fixture against the built package on 18 and 20 | | **Python 3.9+** | 1,342 pytest tests on 3.9 to 3.14, plus every fixture against the built wheel. Output is byte-identical to JS | | **Rust 1.74+** | Every fixture, the tracklist invariants and the typed API tests on stable and on 1.74. Output is byte-identical to JS on every fixture and on about 790,000 random inputs | | **Go 1.22+** | Every fixture, the spec invariants and the examples with `go test -race` on 1.22 and on the latest stable. Output is byte-identical to JS on every fixture and on about 790,000 random inputs | +| **C11, C++17** | Every fixture, the spec invariants, threads, locales and allocation failure at every step with GCC, Clang (x86-64, ARM64, 32-bit), Apple Clang and MSVC, under AddressSanitizer, UBSan, ThreadSanitizer and MemorySanitizer, plus libFuzzer targets. A header-only C++17 wrapper on top. Output is byte-identical to JS on every fixture | | **5,031** real tracklist lines | 117 podcast tracklists the tracklist rules were [checked against](https://4matic.github.io/trackparse/project/testing/#real-tracklists). Every line round-trips byte for byte | -| **1** spec | [`spec/SPEC.md`](spec/SPEC.md) defines the behaviour ([on the site](https://4matic.github.io/trackparse/reference/spec/)). The four packages share its version number and are released together | +| **1** spec | [`spec/SPEC.md`](spec/SPEC.md) defines the behaviour ([on the site](https://4matic.github.io/trackparse/reference/spec/)). The five packages share its version number and are released together | ## Install @@ -163,11 +167,24 @@ package is `trackparse`. go get github.com/4matic/trackparse/go@latest ``` +C and C++ ([library README](c/README.md)). C11 (C++17 for the wrapper `trackparse.hpp`), no +dependencies beyond libc, `libm` and threads. Each release attaches a source tarball for CMake and +a single-file amalgamation to its [GitHub Release](https://github.com/4matic/trackparse/releases) +(tags `c-vX.Y.Z`, from 0.7.0): + +```cmake +include(FetchContent) +FetchContent_Declare(trackparse + URL https://github.com/4matic/trackparse/releases/download/c-v0.7.0/trackparse-c-0.7.0.tar.gz) +FetchContent_MakeAvailable(trackparse) +target_link_libraries(app PRIVATE trackparse::trackparse) +``` + ## Quick start **Docs:** [Getting started](https://4matic.github.io/trackparse/start/getting-started/) · [Introduction](https://4matic.github.io/trackparse/start/introduction/) -The four examples parse the same strings with [`parse`](https://4matic.github.io/trackparse/reference/parse/), +The five examples parse the same strings with [`parse`](https://4matic.github.io/trackparse/reference/parse/), [`parseArtists`](https://4matic.github.io/trackparse/reference/functions/#parseartistsinput-options) and [`format`](https://4matic.github.io/trackparse/reference/functions/#formattrack-options). The comments show what each expression evaluates to. @@ -309,15 +326,74 @@ field that must be told apart from its zero value is a pointer, set with [`trackparse.Ptr`](https://pkg.go.dev/github.com/4matic/trackparse/go#Ptr)), passed to the `With` form of a function: `trackparse.ParseWith(s, trackparse.ParseOptions{KnownArtists: []string{"Chase & Status"}})`. The full Go API is in [`go/README.md`](go/README.md#api) and on [pkg.go.dev](https://pkg.go.dev/github.com/4matic/trackparse/go). +### C + +Results are read-only structs that own all their memory; free each with its `_free` function. +Strings are a pointer and a length (`trackparse_str`), also NUL-terminated. Fields that can be +`null` are pointers, arrays a pointer and a count. Input is UTF-8 with a byte length, or +`TRACKPARSE_NUL_TERMINATED`. The only failure is running out of memory, reported as `NULL`. + +```c +#include +#include + +trackparse_track *track = + trackparse_parse("Noisia feat. Foreign Beggars - Shellshock", TRACKPARSE_NUL_TERMINATED); +for (size_t i = 0; i < track->artists_count; i++) { + const trackparse_artist *a = &track->artists[i]; + printf("%s %s\n", a->name.ptr, trackparse_role_name(a->role)); +} +// Noisia primary +// Foreign Beggars featured + +trackparse_track *queen = trackparse_parse("Queen - Bohemian Rhapsody (Live at Wembley 1986)", + TRACKPARSE_NUL_TERMINATED); +const trackparse_version *v = &queen->versions[0]; +printf("%s %s %s %d\n", v->type_name.ptr, v->raw.ptr, v->descriptor->ptr, *v->year); +// live Live at Wembley 1986 at Wembley 1986 +trackparse_track_free(queen); + +trackparse_artists *credits = trackparse_parse_artists( + "Sub Focus, Wilkinson & Dimension feat. Kojo", TRACKPARSE_NUL_TERMINATED); +for (size_t i = 0; i < credits->count; i++) + printf("%s:%s\n", credits->items[i].name.ptr, trackparse_role_name(credits->items[i].role)); +// Sub Focus:primary +// Wilkinson:primary +// Dimension:primary +// Kojo:featured +trackparse_artists_free(credits); + +trackparse_track *afterglow = trackparse_parse( + "Wilkinson ft. Becky Hill - Afterglow (Sub Focus Remix)", TRACKPARSE_NUL_TERMINATED); +trackparse_format_options *f = trackparse_format_options_new(); +trackparse_format_options_set_feat(f, TRACKPARSE_FEAT_TITLE); +trackparse_format_options_set_joiners(f, TRACKPARSE_JOINERS_CANONICAL); +trackparse_string *s = trackparse_format_with(afterglow, f); +printf("%s\n", s->str.ptr); +// Wilkinson - Afterglow (feat. Becky Hill) (Sub Focus Remix) +trackparse_string_free(s); +trackparse_format_options_free(f); +trackparse_track_free(afterglow); + +trackparse_track_free(track); +``` + +Options are opaque objects filled by setters +([`trackparse_parse_options`](https://github.com/4matic/trackparse/blob/main/c/include/trackparse.h)), passed to the `_with` form of a function: +`trackparse_parse_options_add_known_artist(o, "Chase & Status", TRACKPARSE_NUL_TERMINATED)`, then +`trackparse_parse_with(s, len, o)`. `trackparse_track_to_json` writes the bytes `JSON.stringify` +writes. The full C API, memory rules and the C++ wrapper are in [`c/README.md`](c/README.md#api). + Every example on the [documentation site](https://4matic.github.io/trackparse/) has JavaScript, -Python, Rust and Go tabs. +Python, Rust, Go and C tabs. > [!TIP] > `&` is a joiner, so `Chase & Status` comes out as two artists. There's no built-in artist > database. Pass the names you know instead: `parse(s, { knownArtists: ["Chase & Status"] })` in > JS, `parse(s, known_artists=["Chase & Status"])` in Python, > `parse_with(s, &ParseOptions::new().known_artists(["Chase & Status"]))` in Rust, -> `ParseWith(s, ParseOptions{KnownArtists: []string{"Chase & Status"}})` in Go. +> `ParseWith(s, ParseOptions{KnownArtists: []string{"Chase & Status"}})` in Go, +> `trackparse_parse_options_add_known_artist(o, "Chase & Status", TRACKPARSE_NUL_TERMINATED)` in C. > See [knownArtists](https://4matic.github.io/trackparse/guides/artists/#knownartists). ## What it understands @@ -325,7 +401,7 @@ Python, Rust and Go tabs. **Docs:** [What it understands](https://4matic.github.io/trackparse/guides/what-it-understands/) · [Artists and credits](https://4matic.github.io/trackparse/guides/artists/) · [Versions and remixes](https://4matic.github.io/trackparse/guides/versions/) · [Junk, flags and prefixes](https://4matic.github.io/trackparse/guides/junk-and-flags/) These are real outputs of `parse(input)` with default options, unless noted. They are the same in -all four languages. Each input opens in the [playground](https://4matic.github.io/trackparse/playground/) with that string filled +all five languages. Each input opens in the [playground](https://4matic.github.io/trackparse/playground/) with that string filled in, so you can see the full output or change the string. | Input | Artists | Title | Versions / other | @@ -366,7 +442,8 @@ in, so you can see the full output or change the string. Mixes and podcasts come with a tracklist: a block of text, one track per line, usually with a start time in front. The tracklist module reads the whole block: `trackparse/tracklist` in JavaScript, `trackparse.tracklist` in Python, [`trackparse::tracklist`](https://docs.rs/trackparse/latest/trackparse/tracklist/index.html) in Rust, and -[`ParseTracklist`](https://pkg.go.dev/github.com/4matic/trackparse/go#ParseTracklist) in the main Go package. Each line gets its +[`ParseTracklist`](https://pkg.go.dev/github.com/4matic/trackparse/go#ParseTracklist) in the main Go package, and +[`trackparse_parse_tracklist`](c/README.md#tracklists-and-edits) in C. Each line gets its [kind](https://4matic.github.io/trackparse/guides/tracklists/#line-kinds), its [time](https://4matic.github.io/trackparse/guides/tracklists/#times) and a full [`ParsedTrack`](https://4matic.github.io/trackparse/reference/parse/#parsedtrack). The list as a whole gets [checks with line numbers](https://4matic.github.io/trackparse/reference/warnings/#tracklist-warnings), and [edits](https://4matic.github.io/trackparse/guides/editing-tracklists/) @@ -449,8 +526,8 @@ hour, so it became `01:00:16` to match the list's other hour times, and the edit (missing line, line without a time, `NaN`) changes nothing and warns `edit-invalid`. Neither function throws. -Python, Rust and Go have the same two functions. Here `text` is the tracklist from the JavaScript -example. In Python an edit is a plain dict with the same keys as in JS: +Python, Rust, Go and C have the same two functions. Here `text` is the tracklist from the +JavaScript example. In Python an edit is a plain dict with the same keys as in JS: ```python from trackparse.tracklist import apply_edits, parse_tracklist @@ -494,6 +571,27 @@ w := result.Warnings[0] fmt.Println(w.Code, w.Edit, *w.Line) // style-upgraded 1 5 ``` +In C the edits are an edit list filled by `trackparse_edits_*` calls, and seconds are `double`: + +```c +trackparse_tracklist *list = trackparse_parse_tracklist(text, TRACKPARSE_NUL_TERMINATED); +const trackparse_suggestion *fix = list->warnings[1].suggestion; +printf("%d %s %g\n", fix->line, fix->raw.ptr, fix->seconds); // 8 01:11:02 4262 + +trackparse_edits *edits = trackparse_edits_new(); +trackparse_edits_set_time(edits, fix->line, fix->seconds); +trackparse_edits_shift_from(edits, 45, 5); +trackparse_edit_result *result = trackparse_apply_edits(text, TRACKPARSE_NUL_TERMINATED, edits); +for (size_t i = 0; i < result->changed_count; i++) printf("%lld ", result->changed[i]); +printf("\n"); // 5 6 7 8 9 +const trackparse_edit_warning *w = &result->warnings[0]; +printf("%s %zu %lld\n", trackparse_edit_warning_code_name(w->code), w->edit, *w->line); +// style-upgraded 1 5 +trackparse_edit_result_free(result); +trackparse_edits_free(edits); +trackparse_tracklist_free(list); +``` + Lists pasted from Discord, Reddit, Telegram or YouTube comments often keep their list bullets and Markdown. `* 14:21 Artist - Title`, `**[**14:21**] 10. Artist - Title**` and `[14:21] **Artist** - _Title_` all read like the plain line; the decoration stays in `raw` and @@ -512,7 +610,7 @@ track string doesn't get that benefit of the doubt, so `parse()` sometimes reads dash as a version or a genre. `parseTracklist` parses each line with [`mode: "tracklist"`](https://4matic.github.io/trackparse/guides/modes/#tracklist-mode), which trusts the first spaced dash ([R13.6](https://4matic.github.io/trackparse/reference/spec/#r136-tracklist-mode)). You can ask `parse()` for it too (`mode="tracklist"` in Python, -`ModeOption::Tracklist` in Rust, `ModeTracklist` in Go). These are real lines from a podcast archive: +`ModeOption::Tracklist` in Rust, `ModeTracklist` in Go, `TRACKPARSE_MODE_TRACKLIST` in C). These are real lines from a podcast archive: | Line | `parse(line)` | In a tracklist | |---|---|---| @@ -539,12 +637,12 @@ of the list uses spaced dashes ([R6.10](https://4matic.github.io/trackparse/refe The fixtures in [`spec/fixtures`](spec/fixtures) are the source of truth ([format and matching rules](spec/fixtures/README.md)). The spec says what should happen, the fixtures pin it down, and every port has to pass all of them. The JS and Python packages, the -Rust crate and the Go module all do: **13,130 of 13,130**, with empty skip lists, in CI on every -push. +Rust crate, the Go module and the C library all do: **13,130 of 13,130**, with empty skip lists, in +CI on every push. Passing a fixture only checks the fields the case asserts ([matching rules](spec/fixtures/README.md#matching-semantics-match-partial)), so [`scripts/compare-ports.mjs`](scripts/compare-ports.mjs) also runs every fixture input through all -four ports and diffs the complete outputs, tracklists and edits included. Result: 0 differences, +five ports and diffs the complete outputs, tracklists and edits included. Result: 0 differences, byte for byte. [`scripts/fuzz-ports.mjs`](scripts/fuzz-ports.mjs) does the same with random input. The Rust crate and the Go module were each compared with JS on about 500,000 random single-track cases and 290,000 random tracklists with edits: 0 differences @@ -599,17 +697,19 @@ line; the expected tracks are the plain lines' tracks. Each port also checks the [invariants from the spec](https://4matic.github.io/trackparse/reference/spec/#invariants) on thousands of random strings. The JS suite uses [fast-check](https://github.com/dubzzz/fast-check), the Python suite -[Hypothesis](https://hypothesis.works), and the Rust crate and the Go module small seeded -generators of their own, so they need no extra dev dependency. The Go module also has fuzz -targets for `go test -fuzz`. The invariants: +[Hypothesis](https://hypothesis.works), and the Rust crate, the Go module and the C library small +seeded generators of their own, so they need no extra dev dependency. The Go module also has fuzz +targets for `go test -fuzz`, and the C library libFuzzer targets. The C suite also runs under +AddressSanitizer, UBSan, ThreadSanitizer and MemorySanitizer, fails every allocation in turn, and +compares the output under German and Turkish locales with the `C` locale's. The invariants: - it never throws or panics, on any input; - 10,000-code-point inputs built from repeated blocks finish inside a time limit (one second in the - JS and Python suites, two in Rust and Go), which catches anything that blows up on long input; + JS and Python suites, two in Rust, Go and C), which catches anything that blows up on long input; - `normalize` is idempotent; - whitespace, dash and zero-width noise don't change the result; - every output validates against the schema; -- no word of the input goes missing (the Rust and Go suites); +- no word of the input goes missing (the Rust, Go and C suites); - `parse(format(parse(s)))` round-trips. For tracklists, on random multi-line text and random edit lists @@ -618,7 +718,7 @@ For tracklists, on random multi-line text and random edit lists - `raw + eol` over all entries gives the input back, and `lead + time + gap + rest` gives `raw`; - `applyEdits(t, [])` returns `t`, and an edit never touches a line it doesn't name; - `shift(+s)` then `shift(-s)` restores the text when nothing was clamped or upgraded; -- 10,000 lines parse inside each suite's ceiling (3 s in JS and Go); +- 10,000 lines parse inside each suite's ceiling (3 s in JS, Go and C); - a one-line list gives the same track as `parse()` in tracklist mode on its text without Markdown emphasis or a leading `w/`; - Markdown emphasis around a time or a track line gives the same kind, time and track as the plain @@ -652,9 +752,10 @@ pnpm conformance # pass rate per fixture file and per spec rule (cd python && uv run pytest) # the same fixtures and invariants in Python (cd rust && cargo test) # and in Rust (cd go && go test ./...) # and in Go +(cd c && cmake -S . -B build && cmake --build build && ctest --test-dir build) # and in C pnpm --filter trackparse build -node scripts/compare-ports.mjs # all four ports on every fixture; must print "differences: 0" +node scripts/compare-ports.mjs # all five ports on every fixture; must print "differences: 0" node scripts/fuzz-ports.mjs # the same diff on random tracks and tracklists with edits node scripts/corpus-check.mjs spec/corpus/.jsonl # only if you have the corpus ``` @@ -665,22 +766,23 @@ Every other command is in [AGENTS.md](AGENTS.md#commands). **Docs:** [parse and ParsedTrack](https://4matic.github.io/trackparse/reference/parse/) · [Options](https://4matic.github.io/trackparse/reference/options/) · [Other functions](https://4matic.github.io/trackparse/reference/functions/) · [Tracklist API](https://4matic.github.io/trackparse/reference/tracklist/) · [Warnings](https://4matic.github.io/trackparse/reference/warnings/) -The four packages have the same functions: +The five packages have the same functions: -| JavaScript | Python | Rust | Go | -|---|---|---|---| -| [`parse(input, options?)`](https://4matic.github.io/trackparse/reference/parse/) | `parse(input, **options)` | [`parse(input)`](https://docs.rs/trackparse/latest/trackparse/fn.parse.html), [`parse_with(input, &options)`](https://docs.rs/trackparse/latest/trackparse/fn.parse_with.html) | [`Parse(input)`](https://pkg.go.dev/github.com/4matic/trackparse/go#Parse), [`ParseWith(input, options)`](https://pkg.go.dev/github.com/4matic/trackparse/go#ParseWith) | -| [`parseArtists(input, options?)`](https://4matic.github.io/trackparse/reference/functions/#parseartistsinput-options) | `parse_artists(input, **options)` | [`parse_artists(input)`](https://docs.rs/trackparse/latest/trackparse/fn.parse_artists.html), [`parse_artists_with(input, &options)`](https://docs.rs/trackparse/latest/trackparse/fn.parse_artists_with.html) | [`ParseArtists(input)`](https://pkg.go.dev/github.com/4matic/trackparse/go#ParseArtists), [`ParseArtistsWith(input, options)`](https://pkg.go.dev/github.com/4matic/trackparse/go#ParseArtistsWith) | -| [`format(track, options?)`](https://4matic.github.io/trackparse/reference/functions/#formattrack-options) | `format_track(track, **options)` | [`format_track(&track)`](https://docs.rs/trackparse/latest/trackparse/fn.format_track.html), [`format_track_with(&track, &options)`](https://docs.rs/trackparse/latest/trackparse/fn.format_track_with.html) | [`Format(track)`](https://pkg.go.dev/github.com/4matic/trackparse/go#Format), [`FormatWith(track, options)`](https://pkg.go.dev/github.com/4matic/trackparse/go#FormatWith) | -| [`normalize(input)`](https://4matic.github.io/trackparse/reference/functions/#normalizeinput) | `normalize(input)` | [`normalize(input)`](https://docs.rs/trackparse/latest/trackparse/fn.normalize.html) | [`Normalize(input)`](https://pkg.go.dev/github.com/4matic/trackparse/go#Normalize) | -| [`allArtists(track)`](https://4matic.github.io/trackparse/reference/functions/#allartiststrack) | `all_artists(track)` | [`all_artists(&track)`](https://docs.rs/trackparse/latest/trackparse/fn.all_artists.html) | [`AllArtists(track)`](https://pkg.go.dev/github.com/4matic/trackparse/go#AllArtists) | -| [`createParser(options)`](https://4matic.github.io/trackparse/reference/functions/#createparseroptions) | `create_parser(**options)` | [`Parser::new(&options)`](https://docs.rs/trackparse/latest/trackparse/struct.Parser.html) | [`NewParser(options)`](https://pkg.go.dev/github.com/4matic/trackparse/go#NewParser) | -| [`SPEC_VERSION`](https://4matic.github.io/trackparse/reference/functions/#spec_version) | `SPEC_VERSION` | [`SPEC_VERSION`](https://docs.rs/trackparse/latest/trackparse/constant.SPEC_VERSION.html) | [`SpecVersion`](https://pkg.go.dev/github.com/4matic/trackparse/go#SpecVersion) | -| [`parseTracklist`](https://4matic.github.io/trackparse/reference/tracklist/#parsetracklisttext-options), [`applyEdits`](https://4matic.github.io/trackparse/reference/tracklist/#applyeditstext-edits-options) from `trackparse/tracklist` | `parse_tracklist`, `apply_edits` from `trackparse.tracklist` | [`parse_tracklist(_with)`](https://docs.rs/trackparse/latest/trackparse/tracklist/fn.parse_tracklist.html), [`apply_edits(_with)`](https://docs.rs/trackparse/latest/trackparse/tracklist/fn.apply_edits.html) from [`trackparse::tracklist`](https://docs.rs/trackparse/latest/trackparse/tracklist/index.html) | [`ParseTracklist(With)`](https://pkg.go.dev/github.com/4matic/trackparse/go#ParseTracklist), [`ApplyEdits(With)`](https://pkg.go.dev/github.com/4matic/trackparse/go#ApplyEdits) in the same package | +| JavaScript | Python | Rust | Go | C | +|---|---|---|---|---| +| [`parse(input, options?)`](https://4matic.github.io/trackparse/reference/parse/) | `parse(input, **options)` | [`parse(input)`](https://docs.rs/trackparse/latest/trackparse/fn.parse.html), [`parse_with(input, &options)`](https://docs.rs/trackparse/latest/trackparse/fn.parse_with.html) | [`Parse(input)`](https://pkg.go.dev/github.com/4matic/trackparse/go#Parse), [`ParseWith(input, options)`](https://pkg.go.dev/github.com/4matic/trackparse/go#ParseWith) | `trackparse_parse(s, len)`, `trackparse_parse_with(s, len, options)` | +| [`parseArtists(input, options?)`](https://4matic.github.io/trackparse/reference/functions/#parseartistsinput-options) | `parse_artists(input, **options)` | [`parse_artists(input)`](https://docs.rs/trackparse/latest/trackparse/fn.parse_artists.html), [`parse_artists_with(input, &options)`](https://docs.rs/trackparse/latest/trackparse/fn.parse_artists_with.html) | [`ParseArtists(input)`](https://pkg.go.dev/github.com/4matic/trackparse/go#ParseArtists), [`ParseArtistsWith(input, options)`](https://pkg.go.dev/github.com/4matic/trackparse/go#ParseArtistsWith) | `trackparse_parse_artists(s, len)`, `trackparse_parse_artists_with(s, len, options)` | +| [`format(track, options?)`](https://4matic.github.io/trackparse/reference/functions/#formattrack-options) | `format_track(track, **options)` | [`format_track(&track)`](https://docs.rs/trackparse/latest/trackparse/fn.format_track.html), [`format_track_with(&track, &options)`](https://docs.rs/trackparse/latest/trackparse/fn.format_track_with.html) | [`Format(track)`](https://pkg.go.dev/github.com/4matic/trackparse/go#Format), [`FormatWith(track, options)`](https://pkg.go.dev/github.com/4matic/trackparse/go#FormatWith) | `trackparse_format(track)`, `trackparse_format_with(track, options)` | +| [`normalize(input)`](https://4matic.github.io/trackparse/reference/functions/#normalizeinput) | `normalize(input)` | [`normalize(input)`](https://docs.rs/trackparse/latest/trackparse/fn.normalize.html) | [`Normalize(input)`](https://pkg.go.dev/github.com/4matic/trackparse/go#Normalize) | `trackparse_normalize(s, len)` | +| [`allArtists(track)`](https://4matic.github.io/trackparse/reference/functions/#allartiststrack) | `all_artists(track)` | [`all_artists(&track)`](https://docs.rs/trackparse/latest/trackparse/fn.all_artists.html) | [`AllArtists(track)`](https://pkg.go.dev/github.com/4matic/trackparse/go#AllArtists) | `trackparse_all_artists(track)` | +| [`createParser(options)`](https://4matic.github.io/trackparse/reference/functions/#createparseroptions) | `create_parser(**options)` | [`Parser::new(&options)`](https://docs.rs/trackparse/latest/trackparse/struct.Parser.html) | [`NewParser(options)`](https://pkg.go.dev/github.com/4matic/trackparse/go#NewParser) | `trackparse_parser_new(options)` | +| [`SPEC_VERSION`](https://4matic.github.io/trackparse/reference/functions/#spec_version) | `SPEC_VERSION` | [`SPEC_VERSION`](https://docs.rs/trackparse/latest/trackparse/constant.SPEC_VERSION.html) | [`SpecVersion`](https://pkg.go.dev/github.com/4matic/trackparse/go#SpecVersion) | `trackparse_spec_version()` | +| [`parseTracklist`](https://4matic.github.io/trackparse/reference/tracklist/#parsetracklisttext-options), [`applyEdits`](https://4matic.github.io/trackparse/reference/tracklist/#applyeditstext-edits-options) from `trackparse/tracklist` | `parse_tracklist`, `apply_edits` from `trackparse.tracklist` | [`parse_tracklist(_with)`](https://docs.rs/trackparse/latest/trackparse/tracklist/fn.parse_tracklist.html), [`apply_edits(_with)`](https://docs.rs/trackparse/latest/trackparse/tracklist/fn.apply_edits.html) from [`trackparse::tracklist`](https://docs.rs/trackparse/latest/trackparse/tracklist/index.html) | [`ParseTracklist(With)`](https://pkg.go.dev/github.com/4matic/trackparse/go#ParseTracklist), [`ApplyEdits(With)`](https://pkg.go.dev/github.com/4matic/trackparse/go#ApplyEdits) in the same package | `trackparse_parse_tracklist(_with)`, `trackparse_apply_edits` in the same header | The JavaScript names link to the [API reference](https://4matic.github.io/trackparse/reference/parse/), which shows every language, Python included, in tabs. The Rust and Go names link to [docs.rs](https://docs.rs/trackparse) -and [pkg.go.dev](https://pkg.go.dev/github.com/4matic/trackparse/go). +and [pkg.go.dev](https://pkg.go.dev/github.com/4matic/trackparse/go). The C functions are declared, +with comments, in [`trackparse.h`](https://github.com/4matic/trackparse/blob/main/c/include/trackparse.h). The tables below use the JavaScript names, which are also the keys of the JSON output. In Python and Rust, options and fields are snake_case (`knownArtists` is `known_artists`, `fullTitle` is @@ -688,12 +790,16 @@ and Rust, options and fields are snake_case (`knownArtists` is `known_artists`, structs with `Vec` and `Option`, the fixed sets of names are enums (`VersionType::Remix`, `JunkKind::Video`), and `Version.type` is the field `version_type`. Go results are structs with exported CamelCase fields (`FullTitle`, `Version.Type`), pointers where the JSON has `null`, and -typed string constants for the fixed sets (`trackparse.VersionTypeRemix`). Each package README -lists its own signatures and types: [JavaScript](js/README.md#api), [Python](python/README.md#api), -[Rust](rust/README.md#api), [Go](go/README.md#api). +typed string constants for the fixed sets (`trackparse.VersionTypeRemix`). C results are +read-only structs with snake_case fields (`full_title`), a pointer and a count for each array, +pointers where the JSON has `null`, and enums for the fixed sets (`TRACKPARSE_VERSION_REMIX`) +next to the spec name as a string (`type_name`). Each package README lists its own signatures and +types: [JavaScript](js/README.md#api), [Python](python/README.md#api), [Rust](rust/README.md#api), +[Go](go/README.md#api), [C](c/README.md#api). -No function throws or panics on any string, and bad options fall back to the defaults. The one -exception is Python, which raises `TypeError` when the input is not a `str`. +No function throws or panics on any string, and bad options fall back to the defaults. The +exceptions: Python raises `TypeError` when the input is not a `str`, and the C functions return +`NULL` when memory runs out. ### `parse(input, options?)` → `ParsedTrack` @@ -764,7 +870,9 @@ JavaScript takes an options object, Python takes keyword arguments [`ParseOptions`](https://docs.rs/trackparse/latest/trackparse/struct.ParseOptions.html) (`parse_with(s, &ParseOptions::new().mode(ModeOption::Youtube).uploader("Daft Punk"))`), and Go takes a struct whose zero value is the default, [`ParseOptions`](https://pkg.go.dev/github.com/4matic/trackparse/go#ParseOptions) -(`ParseWith(s, ParseOptions{Mode: ModeYouTube, Uploader: "Daft Punk"})`). The rules for options are +(`ParseWith(s, ParseOptions{Mode: ModeYouTube, Uploader: "Daft Punk"})`), and C fills an opaque +`trackparse_parse_options` with setters (`trackparse_parse_options_set_mode(o, +TRACKPARSE_MODE_YOUTUBE)`) and passes it to `trackparse_parse_with`. The rules for options are [R12](https://4matic.github.io/trackparse/reference/spec/#r12-options) in the spec. ### Other functions @@ -841,7 +949,7 @@ fmt.Println(parser.Parse("Chase & Status x Camo & Krooked - Track (Alix Perez Re **Docs:** [Tracklist API](https://4matic.github.io/trackparse/reference/tracklist/) · [Warnings](https://4matic.github.io/trackparse/reference/warnings/) · [Editing tracklists](https://4matic.github.io/trackparse/guides/editing-tracklists/) Import from `trackparse/tracklist` (Python: `trackparse.tracklist`, Rust: `trackparse::tracklist`, -Go: the main package). +Go: the main package, C: `trackparse.h`). In JavaScript it's a separate entry, so code that only parses single tracks never loads it. The JSON shape is fixed by [`spec/schema/tracklist.schema.json`](spec/schema/tracklist.schema.json). @@ -946,6 +1054,11 @@ are built with [`SetTime(line, seconds)`](https://pkg.go.dev/github.com/4matic/t (unknown) and an audio of length 0 are different values, and `Mode: trackparse.ModeAuto` parses each line in auto mode ([details](go/README.md#pointer-fields-and-ptr)). +C has `trackparse_parse_tracklist_with`, which takes a `trackparse_tracklist_options` +(`trackparse_tracklist_options_set_audio_seconds(o, 3600)`), and edit lists filled with +`trackparse_edits_set_time`, `_shift`, `_shift_from`, `_shift_lines`, `_sort_by_time`, +`_set_rest`, `_insert` and `_delete` ([details](c/README.md#tracklists-and-edits)). + More on the options: [Tracklist options](https://4matic.github.io/trackparse/reference/options/#tracklist-options). ## How it works @@ -956,7 +1069,7 @@ The parser is a fixed pipeline of hand-written scanners over code points ([R0 portability](https://4matic.github.io/trackparse/reference/spec/#r0-portability)). It uses no regexes with lookaround or backreferences and nothing backtracks, so long input can't make it hang: each port's tests parse 10,000-code-point inputs under a time limit. Writing it this way is also what lets the -Python, Rust and Go ports give the same output as JavaScript. +Python, Rust, Go and C ports give the same output as JavaScript. ```mermaid flowchart LR @@ -993,18 +1106,21 @@ spaced dashes. The checks run last, over the finished entries. | Python | [`trackparse`](https://pypi.org/project/trackparse/) on PyPI | Python 3.9+, no dependencies | [reference](https://4matic.github.io/trackparse/reference/parse/) | [python/README.md](python/README.md) | [python/CHANGELOG.md](python/CHANGELOG.md) | | Rust | [`trackparse`](https://crates.io/crates/trackparse) on crates.io | Rust 1.74+, `unicode-normalization`, optional `serde` feature | [docs.rs](https://docs.rs/trackparse) | [rust/README.md](rust/README.md) | [rust/CHANGELOG.md](rust/CHANGELOG.md) | | Go | [`github.com/4matic/trackparse/go`](https://pkg.go.dev/github.com/4matic/trackparse/go) | Go 1.22+, no dependencies | [pkg.go.dev](https://pkg.go.dev/github.com/4matic/trackparse/go) | [go/README.md](go/README.md) | [go/CHANGELOG.md](go/CHANGELOG.md) | +| C / C++ | `trackparse-c-X.Y.Z.tar.gz` and an amalgamation on [GitHub Releases](https://github.com/4matic/trackparse/releases) | C11 (C++17 for `trackparse.hpp`), CMake 3.16+ or any build system for the amalgamation, no dependencies beyond libc, `libm` and threads | [trackparse.h](c/include/trackparse.h) | [c/README.md](c/README.md) | [c/CHANGELOG.md](c/CHANGELOG.md) | -The JavaScript package is the reference implementation. All four pass 13,130 of 13,130 fixtures, -and the Python, Rust and Go output is byte-identical to JavaScript on every fixture input. Go +The JavaScript package is the reference implementation. All five pass 13,130 of 13,130 fixtures, +and the Python, Rust, Go and C output is byte-identical to JavaScript on every fixture input. Go releases are the tags `go/vX.Y.Z`, which the Go module proxy serves -([versions](https://pkg.go.dev/github.com/4matic/trackparse/go?tab=versions)). +([versions](https://pkg.go.dev/github.com/4matic/trackparse/go?tab=versions)). C releases are the +tags `c-vX.Y.Z`, with the source tarball, the amalgamation and `SHA256SUMS` attached to the GitHub +Release. The spec and the packages share one version number and are released together, so the same version means the same spec and the same fixtures in every language. The one known difference outside the fixtures is a [Unicode version note](https://4matic.github.io/trackparse/project/ports/#what-the-rust-port-taught) -for the Rust crate. The Go module generates its Unicode tables from Node, so it doesn't have that -difference ([what the Go port taught](https://4matic.github.io/trackparse/project/ports/#what-the-go-port-taught)). +for the Rust crate. The Go module and the C library generate their Unicode tables from Node, so +they don't have that difference ([what the Go port taught](https://4matic.github.io/trackparse/project/ports/#what-the-go-port-taught)). Changes to the rules and the fixtures are in [spec/CHANGELOG.md](spec/CHANGELOG.md). Want another language? Start with @@ -1047,7 +1163,7 @@ Not there yet: doesn't yet learn names from its other lines. - Warnings for gaps or overlaps between consecutive tracklist times. -These limits are the same in all four packages, since they come from the spec. To see what the +These limits are the same in all five packages, since they come from the spec. To see what the parser does with a string today, paste it into the [playground](https://4matic.github.io/trackparse/playground/). @@ -1059,14 +1175,14 @@ The most useful bug report is an input string plus the output you expected, file [issue](https://github.com/4matic/trackparse/issues). It usually becomes a fixture as is. Behaviour changes start in the spec: a rule in [SPEC.md](spec/SPEC.md), a fixture that pins it -([fixture format](spec/fixtures/README.md)), then the code in all four ports (`js/`, `python/`, -`rust/`, `go/`). A change is done when every port passes every fixture and +([fixture format](spec/fixtures/README.md)), then the code in all five ports (`js/`, `python/`, +`rust/`, `go/`, `c/`). A change is done when every port passes every fixture and `node scripts/compare-ports.mjs` prints `differences: 0`. [AGENTS.md](AGENTS.md) has the repo map, the workflow and every command. The documentation site lives in [`site/`](site) (Astro + Starlight, `pnpm docs` to run it locally) -and deploys to GitHub Pages on every push to `main`. Its examples have JavaScript, Python, Rust and -Go tabs, and a change to behaviour updates them in the same pull request. +and deploys to GitHub Pages on every push to `main`. Its examples have JavaScript, Python, Rust, Go +and C tabs, and a change to behaviour updates them in the same pull request. ## License diff --git a/c/.clang-format b/c/.clang-format new file mode 100644 index 0000000..4f43394 --- /dev/null +++ b/c/.clang-format @@ -0,0 +1,35 @@ +# The style of c/ (C11 sources, the C++ header and tests): 2-space indent, 100 columns, braces +# on the same line, `T *p`, case labels at the switch's level, includes left in written order. +# Meant for clang-format 13 or newer (--dry-run --Werror) over src/, include/, tests/, tools/, +# wire/, examples/ and fuzz/; leave out the generated src/data_gen.* and src/unicode_gen.*. +--- +Language: Cpp +BasedOnStyle: LLVM +IndentWidth: 2 +ContinuationIndentWidth: 4 +ColumnLimit: 100 +UseTab: Never +BreakBeforeBraces: Attach +PointerAlignment: Right +DerivePointerAlignment: false +IndentCaseLabels: false +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: WithoutElse +AllowShortLoopsOnASingleLine: true +AllowShortBlocksOnASingleLine: Never +AllowShortCaseLabelsOnASingleLine: false +AlignAfterOpenBracket: Align +AlignEscapedNewlines: Right +AlignTrailingComments: true +BinPackArguments: true +BinPackParameters: true +Cpp11BracedListStyle: true +SpaceAfterCStyleCast: false +SortIncludes: Never +IncludeBlocks: Preserve +ReflowComments: true +MaxEmptyLinesToKeep: 1 +KeepEmptyLinesAtTheStartOfBlocks: false +FixNamespaceComments: true +NamespaceIndentation: None +Standard: c++17 diff --git a/c/.gitignore b/c/.gitignore new file mode 100644 index 0000000..729e4df --- /dev/null +++ b/c/.gitignore @@ -0,0 +1,6 @@ +# CMake build trees (c/build, c/build-, ...) +build*/ +# amalgamation output (scripts/amalgamate.mjs) +dist/ +# local test data, never committed +tests/data/*.local.* diff --git a/c/CMakeLists.txt b/c/CMakeLists.txt new file mode 100644 index 0000000..a01d5a8 --- /dev/null +++ b/c/CMakeLists.txt @@ -0,0 +1,213 @@ +# The C port of trackparse. See PLAN.md (repo root) and AGENTS.md. +# +# cmake -S c -B c/build -DCMAKE_BUILD_TYPE=Release +# cmake --build c/build +# ctest --test-dir c/build --output-on-failure +# +# Options: +# TRACKPARSE_WERROR warnings are errors (default ON when the CI environment variable is set) +# TRACKPARSE_SANITIZE build everything with AddressSanitizer + UndefinedBehaviorSanitizer +# TRACKPARSE_FUZZ libFuzzer targets in fuzz/ (Clang); see cmake/hardening.cmake +# TRACKPARSE_BUILD_TESTS the test programs and CTest entries (default ON at top level) +# TRACKPARSE_SHARED build the installed library shared (default BUILD_SHARED_LIBS) +# TRACKPARSE_INSTALL install rules (default ON at top level); see cmake/package.cmake +cmake_minimum_required(VERSION 3.16) + +project(trackparse VERSION 0.6.1 LANGUAGES C) # x-release-please-version + +set(CMAKE_C_STANDARD 11) +set(CMAKE_C_STANDARD_REQUIRED ON) +set(CMAKE_C_EXTENSIONS OFF) +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) + +# Only as the top-level project: under FetchContent the parent decides the build type. +if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR AND NOT CMAKE_BUILD_TYPE + AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Build type" FORCE) +endif() + +if(DEFINED ENV{CI}) + set(trackparse_werror_default ON) +else() + set(trackparse_werror_default OFF) +endif() +option(TRACKPARSE_WERROR "Treat warnings as errors" ${trackparse_werror_default}) +option(TRACKPARSE_SANITIZE "Build with -fsanitize=address,undefined" OFF) +option(TRACKPARSE_FUZZ "Build the libFuzzer targets (Clang)" OFF) +# Tests only by default when trackparse is the top-level project (not under FetchContent). +if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) + set(trackparse_tests_default ON) +else() + set(trackparse_tests_default OFF) +endif() +option(TRACKPARSE_BUILD_TESTS "Build the tests and register them with CTest" ${trackparse_tests_default}) +# C++ is needed only for the wrapper's tests and the C++ example; users of the library need none. +if(TRACKPARSE_BUILD_TESTS) + enable_language(CXX) +endif() + +get_filename_component(TRACKPARSE_REPO_DIR "${CMAKE_CURRENT_SOURCE_DIR}/.." ABSOLUTE) +set(TRACKPARSE_SPEC_DIR "${TRACKPARSE_REPO_DIR}/spec") + +# --------------------------------------------------------------------------------------------- +# Compiler flags shared by every target + +add_library(trackparse_flags INTERFACE) +if(MSVC) + # /fp:precise: no contraction into FMA (PLAN.md hazard 1). /utf-8: hazard 12. + target_compile_options(trackparse_flags INTERFACE /W4 /fp:precise /utf-8) + target_compile_definitions(trackparse_flags INTERFACE _CRT_SECURE_NO_WARNINGS) + if(TRACKPARSE_WERROR) + target_compile_options(trackparse_flags INTERFACE /WX) + endif() +else() + # -ffp-contract=off: GCC's GNU-mode default is fast, which can fuse floor(v * p + 0.5) into an + # FMA and change the rounding (PLAN.md hazard 1). + target_compile_options(trackparse_flags INTERFACE + -ffp-contract=off + -Wall -Wextra -Wpedantic -Wshadow + $<$:-Wconversion -Wno-sign-conversion>) + if(TRACKPARSE_WERROR) + target_compile_options(trackparse_flags INTERFACE -Werror) + endif() + if(TRACKPARSE_SANITIZE) + target_compile_options(trackparse_flags INTERFACE + -fsanitize=address,undefined -fno-sanitize-recover=all -fno-omit-frame-pointer) + target_link_options(trackparse_flags INTERFACE -fsanitize=address,undefined) + endif() + # 32-bit x86 without SSE2 computes in 80-bit x87 registers (PLAN.md hazard 5). + if(CMAKE_SIZEOF_VOID_P EQUAL 4 AND CMAKE_SYSTEM_PROCESSOR MATCHES "^(i.86|x86|X86|AMD64|x86_64)$") + target_compile_options(trackparse_flags INTERFACE -msse2 -mfpmath=sse) + endif() +endif() + +find_package(Threads) + +# --------------------------------------------------------------------------------------------- +# trackparse_internal: every src/*.c as separate translation units (TP_PRIVATE empty), for the +# tests, the wire library and the tools. Never installed. + +file(GLOB TRACKPARSE_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/*.c") +add_library(trackparse_internal STATIC ${TRACKPARSE_SOURCES}) +target_include_directories(trackparse_internal PUBLIC + "${CMAKE_CURRENT_SOURCE_DIR}/include" "${CMAKE_CURRENT_SOURCE_DIR}/src") +target_compile_definitions(trackparse_internal PUBLIC TRACKPARSE_STATIC TRACKPARSE_BUILDING) +target_link_libraries(trackparse_internal PUBLIC trackparse_flags) +if(Threads_FOUND) + target_link_libraries(trackparse_internal PUBLIC Threads::Threads) +endif() +if(UNIX) + target_link_libraries(trackparse_internal PUBLIC m) +endif() + +# --------------------------------------------------------------------------------------------- +# trackparse_wire: the JSON door (wire/*.c). wire_stub.c answers null to everything until +# wire.c exists, then it is left out. + +file(GLOB TRACKPARSE_WIRE_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/wire/*.c") +if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/wire/wire.c") + list(REMOVE_ITEM TRACKPARSE_WIRE_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/wire/wire_stub.c") +endif() +add_library(trackparse_wire STATIC ${TRACKPARSE_WIRE_SOURCES}) +target_include_directories(trackparse_wire PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/wire") +target_link_libraries(trackparse_wire PUBLIC trackparse_internal) + +# --------------------------------------------------------------------------------------------- +# Tools + +add_executable(trackparse-dump tools/dump.c) +target_link_libraries(trackparse-dump PRIVATE trackparse_wire) + +# The installed library `trackparse` (built from the amalgamation), install() rules, +# trackparseConfig.cmake, trackparse.pc, the C++ wrapper tests and the consumer checks are in +# cmake/package.cmake, included at the end. +# --------------------------------------------------------------------------------------------- + +if(TRACKPARSE_FUZZ) + # libFuzzer targets in fuzz/ (parse, parse_artists, format, parse_tracklist, apply_edits, wire), + # defined in cmake/hardening.cmake; scripts/fuzz_corpus.mjs seeds them from the fixture inputs. + # Clang only. Every target gets coverage instrumentation and ASan + UBSan; the fuzz programs + # add libFuzzer's main. + if(NOT CMAKE_C_COMPILER_ID MATCHES "Clang") + message(FATAL_ERROR "TRACKPARSE_FUZZ needs Clang (libFuzzer)") + endif() + target_compile_options(trackparse_flags INTERFACE + -fsanitize=fuzzer-no-link,address,undefined -fno-sanitize-recover=all -fno-omit-frame-pointer) + target_link_options(trackparse_flags INTERFACE -fsanitize=address,undefined) + if(NOT TRACKPARSE_BUILD_TESTS) + include(cmake/hardening.cmake) + endif() +endif() + +# --------------------------------------------------------------------------------------------- +# Tests + +if(TRACKPARSE_BUILD_TESTS) + enable_testing() + + # Every test program gets the source and repo paths, so it can find its data. + function(trackparse_test_program name) + add_executable(${name} ${ARGN}) + target_link_libraries(${name} PRIVATE trackparse_wire) + target_compile_definitions(${name} PRIVATE + "TRACKPARSE_SOURCE_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}\"" + "TRACKPARSE_REPO_DIR=\"${TRACKPARSE_REPO_DIR}\"") + endfunction() + + # The matcher and the JSON reader. + trackparse_test_program(test_match tests/test_match.c tests/match.c) + add_test(NAME match COMMAND test_match) + + # Unit tests written alongside the runtime and the primitives; each is registered once its + # source exists. + foreach(t test_rt test_num test_unicode test_primitives test_api) + if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests/${t}.c") + trackparse_test_program(${t} tests/${t}.c) + string(REPLACE "test_" "" test_name ${t}) + # The tests read their data relative to c/. + add_test(NAME ${test_name} COMMAND ${t} WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") + set_tests_properties(${test_name} PROPERTIES SKIP_RETURN_CODE 77) + endif() + endforeach() + + # The fixture runner over every shared fixture file. Without ../spec (the release tarball holds + # only c/) it gets no files and reports the test as skipped (exit 77). + trackparse_test_program(trackparse-fixtures tests/runner.c tests/match.c) + target_compile_definitions(trackparse-fixtures PRIVATE + "TP_SKIP_JSON=\"${CMAKE_CURRENT_SOURCE_DIR}/tests/skip.json\"") + set(TRACKPARSE_FIXTURE_FILES "") + if(EXISTS "${TRACKPARSE_SPEC_DIR}/fixtures") + file(GLOB TRACKPARSE_FIXTURE_FILES CONFIGURE_DEPENDS + "${TRACKPARSE_SPEC_DIR}/fixtures/handwritten/*.json" + "${TRACKPARSE_SPEC_DIR}/fixtures/generated/*.json") + list(SORT TRACKPARSE_FIXTURE_FILES) + endif() + set(TRACKPARSE_OUTPUTS "${CMAKE_CURRENT_BINARY_DIR}/fixture-outputs.jsonl") + add_test(NAME fixtures COMMAND trackparse-fixtures ${TRACKPARSE_FIXTURE_FILES}) + set_tests_properties(fixtures PROPERTIES + SKIP_RETURN_CODE 77 + ENVIRONMENT "TRACKPARSE_OUTPUT=${TRACKPARSE_OUTPUTS}" + FIXTURES_SETUP trackparse_outputs) + + # Schema validation of every output, with the ajv the JS package already has. Runs after the + # fixtures test and only when it passed (FIXTURES_REQUIRED). + find_program(TRACKPARSE_NODE node) + if(TRACKPARSE_NODE AND TRACKPARSE_FIXTURE_FILES + AND EXISTS "${TRACKPARSE_REPO_DIR}/js/node_modules/ajv") + add_test(NAME schema + COMMAND "${TRACKPARSE_NODE}" "${CMAKE_CURRENT_SOURCE_DIR}/scripts/validate_outputs.mjs" + "${TRACKPARSE_OUTPUTS}") + set_tests_properties(schema PROPERTIES FIXTURES_REQUIRED trackparse_outputs) + endif() +endif() + +# Hardening: properties, threads, locale, bench, OOM sweep, fuzz targets (cmake/hardening.cmake). +if(TRACKPARSE_BUILD_TESTS) + include(cmake/hardening.cmake OPTIONAL) +endif() + +# Packaging: the installed library built from the amalgamation, install rules, the C++ header +# tests (cmake/package.cmake). +include(cmake/package.cmake OPTIONAL) diff --git a/c/LICENSE b/c/LICENSE new file mode 100644 index 0000000..4384c06 --- /dev/null +++ b/c/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 Maksim Maksimov + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/c/README.md b/c/README.md new file mode 100644 index 0000000..f6bb3f8 --- /dev/null +++ b/c/README.md @@ -0,0 +1,860 @@ +# trackparse for C and C++ + +[![tests](https://img.shields.io/github/actions/workflow/status/4matic/trackparse/c.yml?branch=main&label=tests&logo=github)](https://github.com/4matic/trackparse/actions/workflows/c.yml) +[![release](https://img.shields.io/github/v/tag/4matic/trackparse?filter=c-v*&label=release&logo=c&color=a8b9cc)](https://github.com/4matic/trackparse/releases) +[![C11](https://img.shields.io/badge/C-11-a8b9cc)](https://github.com/4matic/trackparse/blob/main/c/include/trackparse.h) +[![C++17](https://img.shields.io/badge/C%2B%2B-17-00599c)](https://github.com/4matic/trackparse/blob/main/c/include/trackparse.hpp) +[![license](https://img.shields.io/badge/license-MIT-blue)](https://github.com/4matic/trackparse/blob/main/c/LICENSE) + +**[Documentation](https://4matic.github.io/trackparse/)** · **[Getting started](https://4matic.github.io/trackparse/start/getting-started/)** · **[Playground](https://4matic.github.io/trackparse/playground/)** · **[Header](https://github.com/4matic/trackparse/blob/main/c/include/trackparse.h)** · **[Changelog](https://github.com/4matic/trackparse/blob/main/c/CHANGELOG.md)** + +**Turn messy track names into structured data: who made it, who's featured, who remixed it, and +what's just noise.** + +```text +01. Wilkinson ft. Becky Hill & Tom Cane - Afterglow (Sub Focus VIP Remix) [Official Video] +``` + +Most title parsers split that into `"Wilkinson ft. Becky Hill & Tom Cane"` and +`"Afterglow (Sub Focus VIP Remix)"` and stop. Others "clean" it and throw the feat and the remix +away. trackparse keeps all of it. Everything it recognizes goes into a field, and anything it +doesn't recognize stays in the title, word for word +([try it in the playground](https://4matic.github.io/trackparse/playground/#track=01.%20Wilkinson%20ft.%20Becky%20Hill%20%26%20Tom%20Cane%20-%20Afterglow%20%28Sub%20Focus%20VIP%20Remix%29%20%5BOfficial%20Video%5D)). + +This is the C port of [trackparse](https://github.com/4matic/trackparse), with a header-only C++17 +wrapper. Its behaviour is defined by a [shared spec](https://4matic.github.io/trackparse/reference/spec/) +and pinned by [13,130 fixtures](https://4matic.github.io/trackparse/project/testing/). It passes +all of them, and for every fixture input its output is byte-identical to the +[JavaScript, Python, Rust and Go packages](#other-languages). + +- C11 for the library, C++17 for [`trackparse.hpp`](#c-wrapper); GCC, Clang and MSVC +- No dependencies beyond the C standard library, `libm` and the system's threads (pthreads, or + Windows' own locks) +- No regular expressions, and nothing to initialize before the first call +- Every function is total: any input gives a result, and the only failure is running out of + memory, reported as `NULL` ([Out of memory](#out-of-memory)) +- The output does not depend on the compiler, the CPU or the process locale + +## Install + +**Docs:** [Getting started](https://4matic.github.io/trackparse/start/getting-started/) + +There is no package registry for C. Each release attaches two files to its +[GitHub Release](https://github.com/4matic/trackparse/releases) (tags `c-vX.Y.Z`, the first is +`c-v0.7.0`), with a `SHA256SUMS` file next to them: + +- `trackparse-c-X.Y.Z.tar.gz`: this folder, for CMake; +- `trackparse-c-X.Y.Z-amalgamation.zip`: `trackparse.c`, `trackparse.h` and `trackparse.hpp`, to + copy into a project. + +Release files are never replaced: a fix is a new version, so a pinned hash keeps working. + +### CMake FetchContent + +```cmake +include(FetchContent) +FetchContent_Declare(trackparse + URL https://github.com/4matic/trackparse/releases/download/c-v0.7.0/trackparse-c-0.7.0.tar.gz + URL_HASH SHA256=) +FetchContent_MakeAvailable(trackparse) + +target_link_libraries(app PRIVATE trackparse::trackparse) +``` + +`trackparse::trackparse` is a static library unless `BUILD_SHARED_LIBS` (or `TRACKPARSE_SHARED`) +is on. Under FetchContent the tests, the install rules and the warning flags of this project are +off, and the tarball builds without Node: it ships the amalgamation in `dist/`. + +### The amalgamation + +`trackparse.c` is the whole library in one file, sqlite style: every internal name is `static`, +so nothing but `trackparse_*` leaves the object file. Add it to your build next to the headers: + +```sh +cc -std=c11 -O2 -ffp-contract=off -c trackparse.c +cc -std=c11 -O2 -I. app.c trackparse.o -lm -pthread -o app +c++ -std=c++17 -O2 -I. app.cpp trackparse.o -lm -pthread -o app # with trackparse.hpp +``` + +`-ffp-contract=off` (MSVC: `/fp:precise`) keeps the compiler from fusing a multiply and an add, +which would round some edited tracklist times differently. The file also sets +`#pragma STDC FP_CONTRACT OFF` for the compilers that honour it (GCC ignores it) and rounds that +product through a `volatile`, so a build without the flag gives the same times. On Windows, define `TRACKPARSE_STATIC` in the files that include +the header, or it declares DLL imports. On 32-bit x86, compile with `-msse2 -mfpmath=sse`: the +library refuses to build with x87 arithmetic. + +### From source + +```sh +git clone https://github.com/4matic/trackparse +cmake -S trackparse/c -B build -DCMAKE_BUILD_TYPE=Release +cmake --build build +cmake --install build --prefix /usr/local +``` + +This installs `libtrackparse`, both headers, a CMake package and a pkg-config file: + +```cmake +find_package(trackparse 0.7 CONFIG REQUIRED) +target_link_libraries(app PRIVATE trackparse::trackparse) +``` + +```sh +cc app.c $(pkg-config --cflags --libs trackparse) -o app +``` + +Building from git needs Node (`scripts/amalgamate.mjs` writes the amalgamation); the release +tarball does not. `-DTRACKPARSE_SHARED=ON` builds a shared library. While the version is 0.x its +soname carries the minor version (`libtrackparse.so.0.7`): there is no ABI promise before 1.0. + +## Quick start + +**Docs:** [Getting started](https://4matic.github.io/trackparse/start/getting-started/) + +```c +#include +#include + +int main(void) { + trackparse_track *t = trackparse_parse( + "01. Wilkinson ft. Becky Hill & Tom Cane - Afterglow (Sub Focus VIP Remix) [Official Video]", + TRACKPARSE_NUL_TERMINATED); + if (t == NULL) return 1; /* out of memory, the only failure */ + + for (size_t i = 0; i < t->artists_count; i++) { + const trackparse_artist *a = &t->artists[i]; + printf("%s (%s)\n", a->name.ptr, trackparse_role_name(a->role)); + } + // Wilkinson (primary) + // Becky Hill (featured) + // Tom Cane (featured) + + printf("%s\n", t->title.ptr); // Afterglow + printf("%s\n", t->full_title.ptr); // Afterglow (Sub Focus VIP Remix) + const trackparse_version *v = &t->versions[0]; + printf("%s %s %s\n", v->type_name.ptr, v->artists[0].name.ptr, v->modifiers[0].ptr); + // remix Sub Focus vip + printf("%s %s\n", t->junk[0].raw.ptr, t->junk[0].kind_name.ptr); // Official Video video + printf("%d %s\n", t->position->number, trackparse_mode_name(t->mode)); // 1 youtube + + trackparse_format_options *f = trackparse_format_options_new(); + trackparse_format_options_set_joiners(f, TRACKPARSE_JOINERS_CANONICAL); + trackparse_string *s = trackparse_format_with(t, f); + if (s != NULL) printf("%s\n", s->str.ptr); + // Wilkinson feat. Becky Hill & Tom Cane - Afterglow (Sub Focus VIP Remix) + + trackparse_string_free(s); + trackparse_format_options_free(f); + trackparse_track_free(t); + return 0; +} +``` + +The other examples below are statements from inside a `main` like this one, and they leave out +the `NULL` checks to stay short. The +[playground](https://4matic.github.io/trackparse/playground/) writes a whole C program for any +input and options you pick (choose **C** above its code panel). + +## API + +**Docs:** [Other functions](https://4matic.github.io/trackparse/reference/functions/) · [`trackparse.h`](https://github.com/4matic/trackparse/blob/main/c/include/trackparse.h) + +```text +trackparse_track *trackparse_parse(s, len) trackparse_parse_with(s, len, options) +trackparse_artists *trackparse_parse_artists(s, len) trackparse_parse_artists_with(s, len, options) +trackparse_string *trackparse_format(track) trackparse_format_with(track, format_options) +trackparse_string *trackparse_normalize(s, len) +trackparse_artists *trackparse_all_artists(track) +trackparse_parser *trackparse_parser_new(options) trackparse_parser_parse(parser, s, len) + trackparse_parser_parse_artists(parser, s, len) +trackparse_tracklist *trackparse_parse_tracklist(s, len) trackparse_parse_tracklist_with(s, len, options) +trackparse_edit_result *trackparse_apply_edits(s, len, edits) +trackparse_string *trackparse_track_to_json(track) (and _artists_, _tracklist_, _edit_result_to_json) +const char *trackparse_library_version(void) trackparse_spec_version(void) +``` + +The header is the reference: every type, function and enum value has a comment there. The names +follow the other ports (`parse_artists`, `full_title`, `known_artist`), with the `trackparse_` +prefix on functions and types and `TRACKPARSE_` on macros and enum values. + +### Strings: UTF-8 and explicit lengths + +Every string argument is UTF-8 given as a pointer and a length in bytes. Pass +`TRACKPARSE_NUL_TERMINATED` as the length to have the library call `strlen`. An explicit length +lets you pass a slice of a larger buffer, and lets U+0000 through, which is real input for the +spec. + +Strings in results are `trackparse_str { const char *ptr; size_t len; }`. They are also +NUL-terminated, so `printf("%s")` works for any text that has no U+0000 in it. + +```c +/* An explicit length: the input may hold U+0000, or not be NUL-terminated at all. */ +const char buf[] = "Noisia - Stigma (VIP)ignored"; +trackparse_track *t = trackparse_parse(buf, 21); +printf("%s | %s\n", t->title.ptr, t->full_title.ptr); // Stigma | Stigma (VIP) +trackparse_track_free(t); + +/* Invalid UTF-8: one U+FFFD per maximal ill-formed subpart (the WHATWG rule). */ +t = trackparse_parse("Noisia - Sti\377gma\342\202", TRACKPARSE_NUL_TERMINATED); +printf("%s (%zu bytes)\n", t->title.ptr, t->title.len); // Sti�gma� (12 bytes) +trackparse_track_free(t); + +const char in[] = "Noisia - Sti\0gma"; +t = trackparse_parse(in, sizeof in - 1); +printf("%zu %zu\n", t->title.len, strlen(t->title.ptr)); // 7 3 +trackparse_track_free(t); +``` + +Invalid UTF-8 is read as `TextDecoder` reads it in JavaScript and `String::from_utf8_lossy` in +Rust, so the C library, the Rust crate and the Go module read the same bytes as the same text, +and every output string is valid UTF-8. + +### `trackparse_parse` and parse options + +**Docs:** [parse and ParsedTrack](https://4matic.github.io/trackparse/reference/parse/) · [Options](https://4matic.github.io/trackparse/reference/options/) + +`trackparse_parse` runs [rules R1 to R9](https://4matic.github.io/trackparse/reference/spec/#r1-normalization) +of the spec on one track string. `trackparse_parse_with` takes a `trackparse_parse_options`, an +opaque object built with setters. An option you never set keeps its default, and `NULL` options +are all defaults. + +| Setter | Default | | +|---|---|---| +| [`_set_mode`](https://4matic.github.io/trackparse/guides/modes/) | `TRACKPARSE_MODE_AUTO` | `_CLEAN`, `_YOUTUBE`, `_FILENAME`, `_TRACKLIST`, or `_AUTO` to detect from the string. See [Modes](#modes) | +| [`_set_uploader`](https://4matic.github.io/trackparse/guides/modes/#the-uploader-fallback) | none | YouTube channel name, used as the artist when there's no separator (`- Topic` and `VEVO` are dropped) | +| [`_add_known_artist`](https://4matic.github.io/trackparse/guides/artists/#knownartists) | none | A name that is never split; call it once per name. There is no built-in list | +| [`_set_split_and`](https://4matic.github.io/trackparse/guides/artists/#and-is-special) | `TRACKPARSE_SPLIT_AND_AUTO` | `_AUTO` splits on `and` only after a comma (`A, B and C`), so `Simon and Garfunkel` stays whole. Also `_ALWAYS`, `_NEVER` | +| [`_add_version_head`](https://4matic.github.io/trackparse/guides/versions/#your-own-words), `_add_descriptor`, `_add_genre`, `_add_junk`, `_add_feat_marker` | none | Extra vocabulary ([`keywords`](https://4matic.github.io/trackparse/reference/options/#keywords)), added to the built-in lists | + +Each setter's full name starts with `trackparse_parse_options`. Setters copy what they are given, +so the strings you pass can go away right after the call. They return `false` only when out of +memory. A value out of range falls back to the default, as a bad option does in every port. + +```c +trackparse_parse_options *o = trackparse_parse_options_new(); +trackparse_parse_options_set_mode(o, TRACKPARSE_MODE_YOUTUBE); +trackparse_parse_options_set_uploader(o, "NoisiaVEVO", TRACKPARSE_NUL_TERMINATED); +trackparse_track *t = + trackparse_parse_with("Stigma (Official Video)", TRACKPARSE_NUL_TERMINATED, o); +printf("%s - %s\n", t->artists[0].name.ptr, t->title.ptr); // Noisia - Stigma +trackparse_track_free(t); +trackparse_parse_options_free(o); + +o = trackparse_parse_options_new(); +trackparse_parse_options_add_known_artist(o, "Chase & Status", TRACKPARSE_NUL_TERMINATED); +trackparse_parse_options_set_split_and(o, TRACKPARSE_SPLIT_AND_ALWAYS); +trackparse_parse_options_add_version_head(o, "rerub", TRACKPARSE_NUL_TERMINATED, "remix", + TRACKPARSE_NUL_TERMINATED); +t = trackparse_parse_with("Chase & Status and Bou - Baddadan (Alix Perez Rerub)", + TRACKPARSE_NUL_TERMINATED, o); +for (size_t i = 0; i < t->artists_count; i++) printf("%s\n", t->artists[i].name.ptr); +// Chase & Status +// Bou +printf("%s %s\n", t->versions[0].type_name.ptr, t->versions[0].artists[0].name.ptr); +// remix Alix Perez +trackparse_track_free(t); +trackparse_parse_options_free(o); +``` + +The version type of `_add_version_head` and the junk kind of `_add_junk` are spec names +(`"remix"`, `"label"`), so a vocabulary can bring names of its own. A version's `type` is then +`TRACKPARSE_VERSION_VERSION` and a junk's `kind` `TRACKPARSE_JUNK_OTHER`, and `type_name` / +`kind_name` hold the name you gave. Each enum has `trackparse__name()` for its spec name +and, for the three that options take, `_from_name()`. + +### `trackparse_track` + +**Docs:** [ParsedTrack fields](https://4matic.github.io/trackparse/reference/parse/#parsedtrack) + +| Field | Type | | +|---|---|---| +| `input` | `trackparse_str` | The input as given (after UTF-8 repair) | +| `mode` | `trackparse_mode` | The mode used; never `_AUTO` | +| `position`, `timestamp` | pointer or `NULL` | `{raw, number}`, `{raw, seconds}` | +| `artists`, `artists_count` | `const trackparse_artist *` | `{name, role, joiner, source}`; `joiner` is `NULL` for the first | +| `title`, `full_title` | `trackparse_str` | The title, and the title with its versions | +| `versions`, `versions_count` | `const trackparse_version *` | `{type, type_name, raw, artists, modifiers, descriptor, year, unknown_artist, delimiter}` | +| `year` | `const int *` | `NULL` when there is none | +| `flags` | `trackparse_flags` | `{explicit_, clean, unknown_artist, unknown_title}` (`explicit` is a C++ keyword) | +| `junk`, `junk_count` | `const trackparse_junk *` | `{raw, kind, kind_name}` | +| `warnings`, `warnings_count` | `const trackparse_warning *` | See [Warnings](#warnings) | + +Nullable fields are pointers that are `NULL` when the value is absent, as in the Go port. Arrays +are a pointer and a count. + +### JSON + +**Docs:** [Serializing to JSON](https://4matic.github.io/trackparse/reference/parse/#serializing-to-json) + +`trackparse_track_to_json`, `trackparse_artists_to_json`, `trackparse_tracklist_to_json` and +`trackparse_edit_result_to_json` return the bytes `JSON.stringify` writes for the same result in +JavaScript, with the spec's camelCase keys: + +```c +trackparse_track *t = trackparse_parse( + "Wilkinson ft. Becky Hill - Afterglow (Sub Focus VIP Remix) [HD]", TRACKPARSE_NUL_TERMINATED); +trackparse_string *json = trackparse_track_to_json(t); +if (json != NULL) printf("%s\n", json->str.ptr); +trackparse_string_free(json); +trackparse_track_free(t); +``` + +
+Output + +```json +{"input":"Wilkinson ft. Becky Hill - Afterglow (Sub Focus VIP Remix) [HD]","mode":"youtube","position":null,"timestamp":null,"artists":[{"name":"Wilkinson","role":"primary","joiner":null,"source":"artist"},{"name":"Becky Hill","role":"featured","joiner":"ft.","source":"artist"}],"title":"Afterglow","fullTitle":"Afterglow (Sub Focus VIP Remix)","versions":[{"type":"remix","raw":"Sub Focus VIP Remix","artists":[{"name":"Sub Focus","role":"remixer","joiner":null,"source":"version"}],"modifiers":["vip"],"descriptor":null,"year":null,"unknownArtist":false,"delimiter":"("}],"year":null,"flags":{"explicit":false,"clean":false,"unknownArtist":false,"unknownTitle":false},"junk":[{"raw":"HD","kind":"quality"}],"warnings":[]} +``` + +
+ +The library writes JSON but does not read it; there is no `from_json`. + +### `trackparse_parse_artists`, `trackparse_normalize`, `trackparse_all_artists` + +**Docs:** [parseArtists](https://4matic.github.io/trackparse/reference/functions/#parseartistsinput-options) · [normalize](https://4matic.github.io/trackparse/reference/functions/#normalizeinput) · [allArtists](https://4matic.github.io/trackparse/reference/functions/#allartiststrack) + +```c +trackparse_artists *list = + trackparse_parse_artists("Camo & Krooked feat. Ayah Marar", TRACKPARSE_NUL_TERMINATED); +for (size_t i = 0; i < list->count; i++) + printf("%s %s\n", list->items[i].name.ptr, trackparse_role_name(list->items[i].role)); +// Camo primary +// Krooked primary +// Ayah Marar featured +trackparse_artists_free(list); + +trackparse_string *n = trackparse_normalize("Noisia – Stigma", TRACKPARSE_NUL_TERMINATED); +printf("%s\n", n->str.ptr); // Noisia - Stigma +trackparse_string_free(n); + +trackparse_track *t = + trackparse_parse("Noisia - Stigma (Phace & Misanthrop Remix)", TRACKPARSE_NUL_TERMINATED); +trackparse_artists *all = trackparse_all_artists(t); +for (size_t i = 0; i < all->count; i++) + printf("%s %s\n", all->items[i].name.ptr, trackparse_source_name(all->items[i].source)); +// Noisia artist +// Phace version +// Misanthrop version +trackparse_artists_free(all); +trackparse_track_free(t); + +printf("%d\n", strcmp(TRACKPARSE_VERSION, trackparse_library_version()) == 0); // 1 +``` + +[`trackparse_normalize`](https://4matic.github.io/trackparse/reference/spec/#r1-normalization) is +the Unicode cleanup every function runs first. `TRACKPARSE_VERSION` is the version of the header, +`trackparse_library_version()` that of the linked library (they differ when a shared library was +replaced), and `trackparse_spec_version()` the spec version, which is the same number: all ports +and the spec are released together. + +### `trackparse_format` + +**Docs:** [format](https://4matic.github.io/trackparse/reference/functions/#formattrack-options) · [Formatting](https://4matic.github.io/trackparse/guides/formatting/) + +Writes a parsed track back as `Artists - Title (Versions)`. `trackparse_format_options` has +`_set_feat` (`TRACKPARSE_FEAT_SOURCE`, `_ARTIST`, `_TITLE`, `_OMIT`), `_set_feat_marker` (`""` is +a valid marker; unset keeps the input's), `_set_joiners` (`TRACKPARSE_JOINERS_ORIGINAL`, +`_CANONICAL`), `_set_versions` (`TRACKPARSE_VERSIONS_ALL`, `_NONE`), `_set_omit_producers` and +`_set_position`. The [quick start](#quick-start) has an example. + +### `trackparse_parser` + +**Docs:** [createParser](https://4matic.github.io/trackparse/reference/functions/#createparseroptions) + +`trackparse_parse_with` builds the word tables for its options on every call. A parser builds them +once. It copies the options, so they can be freed right away, and it never changes afterwards. + +```c +trackparse_parse_options *o = trackparse_parse_options_new(); +trackparse_parse_options_add_known_artist(o, "Camo & Krooked", TRACKPARSE_NUL_TERMINATED); +trackparse_parser *p = trackparse_parser_new(o); +trackparse_parse_options_free(o); /* the parser keeps a copy */ + +const char *inputs[] = {"Camo & Krooked - Kallisto", "Camo & Krooked x Mefjus - Ember"}; +for (size_t i = 0; i < 2; i++) { + trackparse_track *t = trackparse_parser_parse(p, inputs[i], TRACKPARSE_NUL_TERMINATED); + printf("%zu artists, %s\n", t->artists_count, t->artists[0].name.ptr); + trackparse_track_free(t); +} +// 1 artists, Camo & Krooked +// 2 artists, Camo & Krooked +trackparse_parser_free(p); +``` + +## Memory ownership + +Every result is one block that owns everything it points to: strings, arrays, nested tracks. +Free it with the `_free` function of its type, and nothing else: + +| Returned by | Free with | +|---|---| +| `trackparse_parse`, `_parse_with`, `_parser_parse` | `trackparse_track_free` | +| `trackparse_parse_artists`, `_parse_artists_with`, `_parser_parse_artists`, `_all_artists` | `trackparse_artists_free` | +| `trackparse_format`, `_format_with`, `_normalize`, every `_to_json` | `trackparse_string_free` | +| `trackparse_parse_tracklist`, `_parse_tracklist_with` | `trackparse_tracklist_free` | +| `trackparse_apply_edits` | `trackparse_edit_result_free` | +| `trackparse_parser_new` | `trackparse_parser_free` | +| `trackparse_*_options_new`, `trackparse_edits_new` | the matching `_free` | + +Results never point into each other or into your input, so they can be freed in any order: + +```c +trackparse_track *t = trackparse_parse("Noisia - Stigma (2015)", TRACKPARSE_NUL_TERMINATED); +trackparse_string *s = trackparse_format(t); +trackparse_track_free(t); /* s has its own memory: it stays valid */ +printf("%s\n", s->str.ptr); // Noisia - Stigma +trackparse_string_free(s); +trackparse_track_free(NULL); /* every _free accepts NULL */ +``` + +Result structs are read-only. Only the library allocates them, so a later version can append +fields without breaking programs built against an earlier one. + +## Thread safety + +Every function except `trackparse_set_allocator` can be called from any number of threads at +once. A `trackparse_parser` is +immutable once created and can be shared between threads without a lock. Options and edit lists +are plain objects: don't change one while another thread reads it. + +The default word tables are built on first use, behind a lock, and kept for the life of the +process. A leak checker lists them as still reachable, not as leaks. + +## Out of memory + +Running out of memory is the only way a call can fail. A function that returns a pointer returns +`NULL`, a setter returns `false` and leaves the option unchanged, and nothing leaks: the work is +done in arenas that are freed as a whole. A test fails the n-th allocation for every n that a set +of inputs reaches and checks exactly that. + +`trackparse_set_allocator` replaces `malloc`, `realloc` and `free` for the whole process. Call it +once, before any other function: + +```c +#include +#include +#include + +static size_t live; /* blocks currently allocated */ + +static void *my_malloc(size_t size, void *user) { + (void)user; + void *p = malloc(size); + if (p != NULL) live++; + return p; +} +static void my_free(void *p, void *user) { + (void)user; + if (p != NULL) live--; + free(p); +} + +int main(void) { + /* Once, before any other call. realloc_fn may be NULL. */ + trackparse_allocator a = {my_malloc, NULL, my_free, NULL}; + trackparse_set_allocator(&a); + + /* The first call builds the default word tables, which stay for the life of the process. */ + trackparse_track_free(trackparse_parse("", 0)); + size_t before = live; + + trackparse_track *t = trackparse_parse("Noisia - Stigma", TRACKPARSE_NUL_TERMINATED); + printf("%zu\n", live - before); // 1: a result is one block + trackparse_track_free(t); + printf("%zu\n", live - before); // 0 + return 0; +} +``` + +## Modes + +**Docs:** [Modes](https://4matic.github.io/trackparse/guides/modes/) · [R2 in the spec](https://4matic.github.io/trackparse/reference/spec/#r2-mode-prelude) + +| Mode | For | Adds | +|---|---|---| +| `TRACKPARSE_MODE_CLEAN` | Store metadata, tags | Only a spaced dash separates artist and title | +| [`TRACKPARSE_MODE_YOUTUBE`](https://4matic.github.io/trackparse/guides/modes/#youtube-mode) | Video titles, scrobbles | Pipe segments, `"Title" by Artist`, `Artist: "Title"`, unspaced dashes, trailing junk, uploader fallback | +| [`TRACKPARSE_MODE_FILENAME`](https://4matic.github.io/trackparse/guides/modes/#filename-mode) | Files | Strips the extension, `_` becomes a space, `01-Track` numbering | +| [`TRACKPARSE_MODE_AUTO`](https://4matic.github.io/trackparse/guides/modes/#how-auto-decides) | Anything | Filename for known extensions, YouTube when it sees junk, pipes or platform suffixes, clean otherwise | +| [`TRACKPARSE_MODE_TRACKLIST`](https://4matic.github.io/trackparse/guides/modes/#tracklist-mode) | One line of a tracklist | The first spaced dash always separates; `_-_` too. Never picked by auto | + +```c +trackparse_parse_options *youtube = trackparse_parse_options_new(); +trackparse_parse_options_set_mode(youtube, TRACKPARSE_MODE_YOUTUBE); +trackparse_track *t = + trackparse_parse_with("\"Numb\" by Linkin Park", TRACKPARSE_NUL_TERMINATED, youtube); +printf("%s / %s %s\n", t->artists[0].name.ptr, t->title.ptr, + trackparse_warning_name(t->warnings[0])); +// Linkin Park / Numb bySplit +trackparse_track_free(t); + +t = trackparse_parse("07_Burial_-_Archangel.mp3", TRACKPARSE_NUL_TERMINATED); +printf("%s %s %s %d\n", trackparse_mode_name(t->mode), t->artists[0].name.ptr, t->title.ptr, + t->position->number); +// filename Burial Archangel 7 +trackparse_track_free(t); + +trackparse_parse_options_set_uploader(youtube, "Porter Robinson", TRACKPARSE_NUL_TERMINATED); +t = trackparse_parse_with("Shelter", TRACKPARSE_NUL_TERMINATED, youtube); +printf("%s\n", t->artists[0].name.ptr); // Porter Robinson +trackparse_track_free(t); +trackparse_parse_options_free(youtube); +``` + +## Warnings + +**Docs:** [Warnings](https://4matic.github.io/trackparse/reference/warnings/) + +The parser never fails, but it says when it had to guess. `warnings` is empty when every decision +was unambiguous. The values are `TRACKPARSE_WARNING_NO_SEPARATOR`, `_AMBIGUOUS_SEPARATOR`, +`_UNSPACED_DASH_SPLIT`, `_ASYMMETRIC_DASH_SPLIT`, `_BY_SPLIT`, `_QUOTED_TITLE_SPLIT`, +`_AMBIGUOUS_MIX_CREDIT` and `_UNBALANCED_BRACKETS`; `trackparse_warning_name` gives the JSON +name, and the [warnings reference](https://4matic.github.io/trackparse/reference/warnings/#track-warnings) +explains each one. + +```c +trackparse_track *t = trackparse_parse("Around the World", TRACKPARSE_NUL_TERMINATED); +printf("%zu %s %s\n", t->artists_count, t->title.ptr, trackparse_warning_name(t->warnings[0])); +// 0 Around the World noSeparator +printf("%d\n", t->warnings[0] == TRACKPARSE_WARNING_NO_SEPARATOR); // 1 +trackparse_track_free(t); + +t = trackparse_parse("Noisia - Stigma (VIP", TRACKPARSE_NUL_TERMINATED); +printf("%s\n", trackparse_warning_name(t->warnings[0])); // unbalancedBrackets +trackparse_track_free(t); +``` + +## Tracklists and edits + +**Docs:** [Tracklists](https://4matic.github.io/trackparse/guides/tracklists/) · [Editing tracklists](https://4matic.github.io/trackparse/guides/editing-tracklists/) · [Tracklist API](https://4matic.github.io/trackparse/reference/tracklist/) · [Warnings](https://4matic.github.io/trackparse/reference/warnings/#tracklist-warnings) + +`trackparse_parse_tracklist` parses a whole tracklist, one entry per line, and checks it. Each +entry keeps its line exactly as written plus its own line ending (`eol`), so the entries joined +give back the input, CRLF or not. + +```c +const char *text = "Hour 2\r\n" + "48:20 Noisia - Stigma\r\n" + "52:47 Mefjus & Kasra - Bandwagon (Phace Remix)\r\n" + "56:05 Black Sun Empire - ID\r\n" + "59:31 Alix Perez - Fade Away\r\n" + "01:03:10 Interview with Hybris\r\n" + "01:07:44 Imanu - Sacrifice\r\n" + "00:11:02 Current Value feat. Teddy Killerz - Payload\r\n" /* 01:11:02 */ + "01:15:36 Hybris - Spinning Top"; + +trackparse_tracklist *list = trackparse_parse_tracklist(text, TRACKPARSE_NUL_TERMINATED); +if (list == NULL) return 1; + +for (size_t i = 0; i < list->entries_count; i++) { + const trackparse_entry *e = &list->entries[i]; + printf("%d %s%s%s\n", e->line, trackparse_entry_kind_name(e->kind), e->time ? " " : "", + e->time ? e->time->raw.ptr : ""); +} +// 1 header +// 2 track 48:20 +// 3 track 52:47 +// 4 track 56:05 +// 5 track 59:31 +// 6 marker 01:03:10 +// 7 track 01:07:44 +// 8 track 00:11:02 +// 9 track 01:15:36 + +const trackparse_entry *e = &list->entries[2]; +printf("%g %s | %s\n", e->time->seconds, e->parts.rest.ptr, e->track->title.ptr); +// 3167 Mefjus & Kasra - Bandwagon (Phace Remix) | Bandwagon +printf("%d\n", list->entries[3].track->flags.unknown_title); // 1 (the ID) + +for (size_t i = 0; i < list->warnings_count; i++) { + const trackparse_tracklist_warning *w = &list->warnings[i]; + printf("%s %d %s\n", trackparse_tracklist_warning_code_name(w->code), w->line, + trackparse_severity_name(w->severity)); + if (w->suggestion) + printf(" suggestion: %d %s %g\n", w->suggestion->line, w->suggestion->raw.ptr, + w->suggestion->seconds); +} +// no-start-at-zero 2 info +// time-out-of-order 8 warning +// suggestion: 8 01:11:02 4262 + +const trackparse_stats *s = &list->stats; +printf("%d %d %d %d %g %g\n", s->lines, s->tracks, s->markers, s->timed, *s->first_time, + *s->last_time); +// 9 7 1 8 2900 4536 +trackparse_tracklist_free(list); +``` + +The [suggestion](https://4matic.github.io/trackparse/reference/warnings/#suggestions) exists +because exactly one time, one digit away from `00:11:02`, fits between its neighbours. With +several candidates or none, `suggestion` is `NULL`. +[Open this list in the playground](https://4matic.github.io/trackparse/playground/#list=Hour%202%0A48%3A20%20Noisia%20-%20Stigma%0A52%3A47%20Mefjus%20%26%20Kasra%20-%20Bandwagon%20%28Phace%20Remix%29%0A56%3A05%20Black%20Sun%20Empire%20-%20ID%0A59%3A31%20Alix%20Perez%20-%20Fade%20Away%0A01%3A03%3A10%20Interview%20with%20Hybris%0A01%3A07%3A44%20Imanu%20-%20Sacrifice%0A00%3A11%3A02%20Current%20Value%20feat.%20Teddy%20Killerz%20-%20Payload%0A01%3A15%3A36%20Hybris%20-%20Spinning%20Top). + +`trackparse_apply_edits` takes an edit list and rewrites only the lines the edits name. Build the +list with `trackparse_edits_set_time(e, line, seconds)`, `_shift(e, seconds)` (every timed +line), `_shift_from(e, seconds, from)`, `_shift_lines(e, seconds, lines, count)`, +`_sort_by_time(e)`, `_set_rest(e, line, rest, len)`, `_insert(e, after, text, len)` (`after` 0 +inserts at the top) and `_delete(e, line)`. Lines are 1-based, and the edits apply in order. + +```c +const char *text = "48:20 Noisia - Stigma\r\n" + "59:31 Alix Perez - Fade Away\r\n" + "00:03:10 Imanu - Sacrifice\r\n"; + +trackparse_edits *edits = trackparse_edits_new(); +trackparse_edits_set_time(edits, 3, 3790); +trackparse_edits_shift_from(edits, 45, 2); +trackparse_edit_result *r = trackparse_apply_edits(text, TRACKPARSE_NUL_TERMINATED, edits); +trackparse_edits_free(edits); + +fputs(r->text.ptr, stdout); +// 48:20 Noisia - Stigma +// 01:00:16 Alix Perez - Fade Away +// 01:03:55 Imanu - Sacrifice +for (size_t i = 0; i < r->changed_count; i++) printf("changed %lld\n", r->changed[i]); +// changed 2 +// changed 3 +const trackparse_edit_warning *w = &r->warnings[0]; +printf("%s %zu %lld\n", trackparse_edit_warning_code_name(w->code), w->edit, *w->line); +// style-upgraded 1 2 +trackparse_edit_result_free(r); + +edits = trackparse_edits_new(); +trackparse_edits_delete(edits, 9); +r = trackparse_apply_edits(text, TRACKPARSE_NUL_TERMINATED, edits); +printf("%s %d\n", trackparse_edit_warning_code_name(r->warnings[0].code), + strcmp(r->text.ptr, text) == 0); +// edit-invalid 1 +trackparse_edit_result_free(r); +trackparse_edits_free(edits); +``` + +A rewritten time keeps its line's style: `48:20` stays `MM:SS`, and a time that crosses the hour +gets hours, with a `style-upgraded` warning. A time pushed below zero stops at zero and warns +`time-clamped`. A bad edit changes nothing and warns `edit-invalid` +([edit warnings](https://4matic.github.io/trackparse/reference/warnings/#edit-warnings)). + +`trackparse_tracklist_options` ([options](https://4matic.github.io/trackparse/reference/options/#tracklist-options)) +has the parse options' setters (`_set_mode` defaults to `TRACKPARSE_MODE_TRACKLIST` here), plus +`_set_audio_seconds` (the length of the mix; it enables `time-after-audio-end`, and 0 is a valid +length) and `_add_marker_word`: + +```c +trackparse_tracklist_options *o = trackparse_tracklist_options_new(); +trackparse_tracklist_options_set_audio_seconds(o, 3600); +trackparse_tracklist *list = + trackparse_parse_tracklist_with("00:00 A - B\n1:02:03 C - D", TRACKPARSE_NUL_TERMINATED, o); +printf("%s %d\n", trackparse_tracklist_warning_code_name(list->warnings[0].code), + list->warnings[0].line); +// time-after-audio-end 2 +trackparse_tracklist_free(list); +trackparse_tracklist_options_free(o); +``` + +| Result | Fields | +|---|---| +| `trackparse_tracklist` | `spec_version`, `entries`, `warnings`, `stats` | +| `trackparse_entry` | `line` (1-based), `kind` (`TRACKPARSE_ENTRY_TRACK`, `_MARKER`, `_HEADER`, `_LINK`, `_NOTE`, `_BLANK`), `eol`, `raw`, `parts`, `time` (or `NULL`), `track` (or `NULL`), `layered` | +| `trackparse_parts` | `lead`, `time`, `gap`, `rest`: joined they give `raw` | +| `trackparse_tracklist_warning` | `code`, `line`, `severity` (`TRACKPARSE_SEVERITY_INFO` or `_WARNING`), `suggestion` (or `NULL`) | +| `trackparse_stats` | `lines`, `tracks`, `markers`, `timed`, `first_time` and `last_time` (`const double *`) | +| `trackparse_edit_result` | `text`, `changed` (`long long` line numbers), `warnings` (`{code, edit, line}`; `line` is `const long long *`) | + +Times are `double` seconds: a time may have a fraction (`12:34.5`). Tracklist warning codes are +`TRACKPARSE_TL_TIME_MISSING` to `TRACKPARSE_TL_LINE_UNPARSED`, edit warnings +`TRACKPARSE_EDIT_WARNING_EDIT_INVALID`, `_TIME_CLAMPED` and `_STYLE_UPGRADED`. The rules are in +[R13 of the spec](https://4matic.github.io/trackparse/reference/spec/#r13-tracklists). + +## C++ wrapper + +**Docs:** [Other functions](https://4matic.github.io/trackparse/reference/functions/) · [`trackparse.hpp`](https://github.com/4matic/trackparse/blob/main/c/include/trackparse.hpp) + +`trackparse.hpp` is a header-only C++17 layer over the same library: no second implementation, +the same output. It is installed and shipped next to `trackparse.h`, and links against the same +`trackparse::trackparse` target. + +- Results (`track`, `artists`, `tracklist`, `edit_result`), `parser` and the option builders are + move-only owners that free their C object in the destructor. +- Strings are `std::string_view`, nullable fields `std::optional`, arrays ranges with `begin`, + `end`, `size` and `operator[]`. Views borrow from their owner and are valid while it lives. +- Option builders chain: `parse_options{}.mode(mode::youtube).known_artist("Chase & Status")`. +- The enums are `enum class` (`trackparse::role::featured`), and `trackparse::name(value)` gives + the spec name. +- The only exception is `std::bad_alloc`, when the library runs out of memory. Built with + `-fno-exceptions`, the wrapper calls `std::abort()` instead. + +```cpp +#include +#include + +int main() { + auto t = trackparse::parse("Wilkinson ft. Becky Hill - Afterglow (Sub Focus VIP Remix) [HD]"); + for (const auto &a : t.artists()) { + std::cout << a.name() << " (" << trackparse::name(a.role()) << ")\n"; + } + // Wilkinson (primary) + // Becky Hill (featured) + std::cout << t.title() << '\n'; // Afterglow + auto v = t.versions()[0]; + std::cout << v.type_name() << ' ' << v.artists()[0].name() << '\n'; // remix Sub Focus + std::cout << t.year().has_value() << '\n'; // 0 + std::cout << t.format(trackparse::format_options{}.feat(trackparse::feat::title)) << '\n'; + // Wilkinson - Afterglow (ft. Becky Hill) (Sub Focus VIP Remix) + + // Options chain. A parser keeps them for many calls and can be shared between threads. + trackparse::parser p(trackparse::parse_options{} + .mode(trackparse::mode::youtube) + .known_artists({"Chase & Status", "Camo & Krooked"})); + auto t2 = p.parse("Chase & Status x Camo & Krooked - Track [Official Video]"); + std::cout << t2.artists().size() << ' ' << t2.junk()[0].kind_name() << '\n'; // 2 video + + // Tracklists and edits. + std::string text = "0:00 Noisia - Stigma\n4:20 Mefjus - Sinkhole\n9:45 Phace - Psycho"; + auto list = trackparse::parse_tracklist(text, trackparse::tracklist_options{}.audio_seconds(500)); + for (const auto &w : list.warnings()) { + std::cout << trackparse::name(w.code()) << " on line " << w.line() << '\n'; + } + // time-after-audio-end on line 3 + auto r = trackparse::apply_edits(text, trackparse::edits{}.shift_from(30, 2)); + std::cout << r.text() << '\n'; + // 0:00 Noisia - Stigma + // 4:50 Mefjus - Sinkhole + // 10:15 Phace - Psycho + + std::cout << trackparse::parse_artists("Camo & Krooked feat. Ayah Marar").to_json() << '\n'; + // [{"name":"Camo","role":"primary","joiner":null,"source":"artist"},{"name":"Krooked",... +} +``` + +Every owner has `c_ptr()` for the C object underneath, and `track::release()` hands the C result +over to code that frees it with `trackparse_track_free`. The wrapper is tested with GCC, Clang and +MSVC in C++17 and C++20. + +## Building and testing + +**Docs:** [How it's tested](https://4matic.github.io/trackparse/project/testing/) · [Ports](https://4matic.github.io/trackparse/project/ports/) + +From `c/` in the [repository](https://github.com/4matic/trackparse) (CMake 3.16 or later; Node +for the codegen scripts, the amalgamation and the schema check): + +```sh +cmake -S . -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo +cmake --build build +ctest --test-dir build --output-on-failure +TRACKPARSE_REPORT=1 ./build/trackparse-fixtures ../spec/fixtures/*/*.json # pass rate per file and rule +node scripts/gen_data.mjs --check # spec/data codegen is up to date +node scripts/gen_unicode.mjs --check # Unicode tables are up to date +``` + +What `ctest` runs: + +- `fixtures`: all 13,130 shared fixtures (1,203 written by hand, the rest generated from the + rules), with an empty skip list. `schema` then checks every output against the JSON Schema with + the validator of the JavaScript package. +- `match`, `rt`, `api`: the fixture matcher and the JSON reader, the internal runtime (arenas, + strings, vectors, the stable sort), and the public C API, ownership and `NULL` handling. +- `primitives`, `unicode`, `num`: the R0 primitives, the Unicode tables (letters, uppercase, the + lowercase mapping, NFC and NFD) and the number code (decimal to double, JavaScript's number + formatting, half-up rounding), each against values dumped from Node. +- `properties`: the spec's invariants on seeded random input, among them that no word of the + input goes missing, and the tracklist round trips of R13.11, with time ceilings for 10,000 code + points and 10,000 lines. +- `threads`: 16 threads against a sequential run. `locale`: every output after + `setlocale(LC_ALL, "")` and under `de_DE.UTF-8` and `tr_TR.UTF-8` (when installed) equals the + `C` locale's. `oom`: the n-th allocation fails, for every n, on about 50 inputs across the API. +- `cpp17`, `cpp20`, `example_*`, `exports`: the C++ wrapper, the programs in + [`examples/`](https://github.com/4matic/trackparse/tree/main/c/examples) against their expected + output, and a check that the library exports only `trackparse_*`. Tests labelled `consumer` + install the library and build the examples with `find_package`, pkg-config, the amalgamation and + FetchContent. + +Sanitizers and fuzzing are CMake options: + +```sh +cmake -S . -B build-asan -DTRACKPARSE_SANITIZE=ON # AddressSanitizer + UBSan +cmake -S . -B build-tsan -DTRACKPARSE_SANITIZE_THREAD=ON # ThreadSanitizer +CC=clang CXX=clang++ cmake -S . -B build-msan -DTRACKPARSE_SANITIZE_MEMORY=ON +cmake --build build-msan --target trackparse-fixtures test_api test_properties test_oom +CC=clang CXX=clang++ cmake -S . -B build-fuzz -DTRACKPARSE_FUZZ=ON -DTRACKPARSE_BUILD_TESTS=OFF +cmake --build build-fuzz # libFuzzer targets fuzz_* +node scripts/fuzz_corpus.mjs corpus # seed corpus from the fixture inputs +./build-fuzz/fuzz_parse -max_total_time=60 corpus/parse +``` + +Under a sanitizer the property tests run a quarter of their cases and the time ceilings are ten +times wider. MemorySanitizer builds only the C programs: the C++ tests would need an instrumented +libc++. There is a libFuzzer target for each of `parse`, `parse_artists`, `format`, +`parse_tracklist` and `apply_edits` (`fuzz_parse` and so on) and one for the JSON reader the tests +use (`fuzz_wire`). + +CI ([`c.yml`](https://github.com/4matic/trackparse/blob/main/.github/workflows/c.yml)) builds and +tests with GCC and Clang on Linux x86-64, GCC on ARM64 and on 32-bit x86, GCC 9 with CMake 3.16, a +shared-library build, Apple Clang on macOS and MSVC on Windows. It also runs the suite under +ASan + UBSan (GCC and Clang), ThreadSanitizer, MemorySanitizer and Valgrind, under German and +Turkish locales, and fuzzes every target for ten minutes once a week. +[`scripts/compare-ports.mjs`](https://github.com/4matic/trackparse/blob/main/scripts/compare-ports.mjs) +runs every fixture input through the JavaScript package and this library (built as +`trackparse-dump`) and compares the complete JSON output, every field of it, not only the ones a +fixture asserts. + +Files mirror the JavaScript reference one to one (`src/scanner.c` is `scanner.ts`, `src/tl_parse.c` +is `tracklist/parse.ts`, and so on) and cite the same spec rule IDs. Behaviour changes start in +the spec, not here: see [AGENTS.md](https://github.com/4matic/trackparse/blob/main/AGENTS.md). + +## Performance + +There are no regular expressions, so there is no regex backtracking. On an Intel i7-4770S with +GCC 9 (a CMake Release build, `-O3`), with other programs running: 1 to 6 ms for 10,000 code points +of one repeated block (the blocks of the other ports' time ceilings), and 0.34 to 0.39 s for a +10,000-line tracklist (`build/test_bench` prints these). The Go port takes 3 to 7 ms and 0.33 to 0.38 s for the same +kinds of input on the same machine. + +## Unicode version + +The Unicode facts the rules need (letters, uppercase letters, the lowercase mapping, and the NFC +and NFD tables) are generated from Node 24, which has Unicode 17, and compiled into the library, +as in the Go port. The C library, the JavaScript package and the Go module give the same bytes +for any input. The Rust crate takes NFC from `unicode-normalization` (Unicode 18), so 32 newer +combining marks can come out in another order there +([what the Rust port taught](https://4matic.github.io/trackparse/project/ports/#what-the-rust-port-taught)). + +## Versioning + +**Changelog:** [c/CHANGELOG.md](https://github.com/4matic/trackparse/blob/main/c/CHANGELOG.md) + +The library version is the spec version. All five ports and the spec are released together and +share one version number; C releases are tagged `c-vX.Y.Z`. While it is 0.x, a release that +changes the output for some input bumps the minor version, and a patch release only fixes bugs. +The shared library makes no ABI promise before 1.0. + +## Other languages + +**Docs:** [Ports](https://4matic.github.io/trackparse/project/ports/) + +| Language | Package | Install | Docs | +|---|---|---|---| +| JavaScript / TypeScript | [trackparse on npm](https://www.npmjs.com/package/trackparse) | `npm install trackparse` | [README](https://github.com/4matic/trackparse/blob/main/js/README.md) · [API](https://4matic.github.io/trackparse/reference/parse/) | +| Python | [trackparse on PyPI](https://pypi.org/project/trackparse/) | `pip install trackparse` | [README](https://github.com/4matic/trackparse/blob/main/python/README.md) · [API](https://4matic.github.io/trackparse/reference/parse/) | +| Rust | [trackparse on crates.io](https://crates.io/crates/trackparse) | `cargo add trackparse` | [README](https://github.com/4matic/trackparse/blob/main/rust/README.md) · [API on docs.rs](https://docs.rs/trackparse) | +| Go | [github.com/4matic/trackparse/go](https://pkg.go.dev/github.com/4matic/trackparse/go) | `go get github.com/4matic/trackparse/go` | [README](https://github.com/4matic/trackparse/blob/main/go/README.md) · [API on pkg.go.dev](https://pkg.go.dev/github.com/4matic/trackparse/go) | + +All of them implement one spec, pass the same fixtures and return identical JSON for every +fixture input, so you can parse in one language and read the result in another. + +## Limitations + +**Docs:** [Limitations and roadmap](https://4matic.github.io/trackparse/project/roadmap/) + +- `trackparse_parse` takes one track string. Whole tracklists go through + `trackparse_parse_tracklist`, which reads start times only: no durations, trailing times or + time ranges. +- Catalog numbers, key and BPM are not fields. They stay in the title. +- There is no artist database. Add known artists for names that contain a joiner + (`Earth, Wind & Fire`). +- No package manager carries the library yet: use FetchContent, the amalgamation or an install + from source. + +## License + +[MIT](https://github.com/4matic/trackparse/blob/main/c/LICENSE) diff --git a/c/VERSION b/c/VERSION new file mode 100644 index 0000000..ee6cdce --- /dev/null +++ b/c/VERSION @@ -0,0 +1 @@ +0.6.1 diff --git a/c/cmake/check_exports.cmake b/c/cmake/check_exports.cmake new file mode 100644 index 0000000..301fd55 --- /dev/null +++ b/c/cmake/check_exports.cmake @@ -0,0 +1,55 @@ +# Fails when LIBRARY defines a global symbol whose name does not start with trackparse_. +# cmake -DLIBRARY=... -DNM=... -DSHARED=ON|OFF -DAPPLE=1|"" -P check_exports.cmake +# Prints "SKIP:" (the test's skip pattern) where there is no nm, or for a DLL. +if(NOT NM OR LIBRARY MATCHES "\\.(dll|lib)$") + message("SKIP: no nm, or a Windows library (the Windows DLL is built and linked by CI's windows-msvc-shared job)") + return() +endif() +if(SHARED AND NOT APPLE) + set(args -D --defined-only) +elseif(APPLE) + set(args -g -U) +else() + set(args -g --defined-only) +endif() +execute_process(COMMAND "${NM}" ${args} "${LIBRARY}" RESULT_VARIABLE rc OUTPUT_VARIABLE out + ERROR_VARIABLE err) +if(NOT rc EQUAL 0) + message(FATAL_ERROR "${NM} ${args} ${LIBRARY} failed: ${err}") +endif() +string(REPLACE "\n" ";" lines "${out}") +set(count 0) +set(bad "") +foreach(line IN LISTS lines) + # "address type name"; skip archive member headers ("file.o:") and empty lines. + if(NOT line MATCHES "^[0-9A-Fa-f]* *([A-Za-z]) ([^ ]+)$") + continue() + endif() + set(type "${CMAKE_MATCH_1}") + set(name "${CMAKE_MATCH_2}") + if(type STREQUAL "U" OR type STREQUAL "w" OR type STREQUAL "v") + continue() + endif() + if(APPLE) + string(REGEX REPLACE "^_" "" name "${name}") + endif() + # Linker-made symbols, what a sanitizer build adds, and the i386 PIC thunks GCC emits. + if(name MATCHES "^(_init|_fini|_edata|_end|__bss_start|_DYNAMIC|_GLOBAL_OFFSET_TABLE_)$" + OR name MATCHES "^_*(asan|ubsan|tsan|msan|sancov|sanitizer)_" + OR name MATCHES "^__x86\\.get_pc_thunk\\.") + continue() + endif() + if(name MATCHES "^trackparse_") + math(EXPR count "${count} + 1") + else() + list(APPEND bad "${type} ${name}") + endif() +endforeach() +if(bad) + string(REPLACE ";" "\n " bad "${bad}") + message(FATAL_ERROR "${LIBRARY} exports symbols outside trackparse_*:\n ${bad}") +endif() +if(count EQUAL 0) + message(FATAL_ERROR "${LIBRARY}: no trackparse_* symbols found (nm output:\n${out})") +endif() +message(STATUS "${LIBRARY}: ${count} symbols, all trackparse_*") diff --git a/c/cmake/consumer_check.cmake b/c/cmake/consumer_check.cmake new file mode 100644 index 0000000..bbc5ca7 --- /dev/null +++ b/c/cmake/consumer_check.cmake @@ -0,0 +1,211 @@ +# consumer_check.cmake: builds and runs the examples the way a user of the library would. +# Run by the consumer_* tests (cmake/package.cmake); each example's output must match +# examples/.expected. +# +# cmake -DMODE= -DSOURCE_DIR= -DWORK_DIR=... -DPREFIX=... -DAMALGAMATION_C=... +# -DGENERATOR=... -DC_COMPILER=... -DCXX_COMPILER=... -DCONFIG=... -DSHARED=ON|OFF +# [-DBUILD_DIR=...] -P consumer_check.cmake +# +# MODE: +# install cmake --install BUILD_DIR into PREFIX (fresh) +# find_package examples/ as a CMake project, find_package(trackparse) from PREFIX +# pkg_config each example compiled by hand with `pkg-config --cflags --libs trackparse` +# amalgamation the amalgamation alone: trackparse.c compiled with the strict warning set, +# as a program part and as a shared-library object, then each example +# compiled by hand against it +# amalgamation_cmake examples/ as a CMake project that compiles trackparse.c in +# fetchcontent examples/ as a CMake project with FetchContent(SOURCE_DIR c/) +# +# Output "SKIP: ..." makes the test count as skipped. + +cmake_minimum_required(VERSION 3.16) + +set(examples basic options tracklist json) +set(work "${WORK_DIR}/${MODE}") +get_filename_component(amalgamation_dir "${AMALGAMATION_C}" DIRECTORY) + +if(C_COMPILER MATCHES "(^|[/\\\\])(cl|clang-cl)(\\.exe)?$") + set(msvc_like ON) +else() + set(msvc_like OFF) +endif() + +function(run) + execute_process(COMMAND ${ARGN} RESULT_VARIABLE rc OUTPUT_VARIABLE out ERROR_VARIABLE err) + if(NOT rc EQUAL 0) + string(REPLACE ";" " " cmd "${ARGN}") + message(FATAL_ERROR "failed (${rc}): ${cmd}\n${out}\n${err}") + endif() +endfunction() + +function(check_output program name) + set(launcher "") + if(WIN32) + # Windows finds a DLL next to the program or on PATH: add every folder that holds one of ours + # (the install prefix's bin/, a FetchContent build folder). + file(GLOB_RECURSE dlls "${WORK_DIR}/*trackparse*.dll" "${PREFIX}/*trackparse*.dll") + set(dirs "") + foreach(dll IN LISTS dlls) + get_filename_component(dir "${dll}" DIRECTORY) + file(TO_NATIVE_PATH "${dir}" dir) + list(APPEND dirs "${dir}") + endforeach() + if(dirs) + list(REMOVE_DUPLICATES dirs) + string(REPLACE ";" "\\;" path "${dirs};$ENV{PATH}") + set(launcher "${CMAKE_COMMAND}" -E env "PATH=${path}") + endif() + endif() + execute_process(COMMAND ${launcher} "${program}" RESULT_VARIABLE rc OUTPUT_VARIABLE out + ERROR_VARIABLE err) + if(NOT rc EQUAL 0) + message(FATAL_ERROR "${program} exited with ${rc}\n${err}") + endif() + file(READ "${SOURCE_DIR}/examples/${name}.expected" expected) + string(REPLACE "\r\n" "\n" out "${out}") + string(REPLACE "\r\n" "\n" expected "${expected}") + if(NOT out STREQUAL expected) + message(FATAL_ERROR "${MODE}: ${name} output differs from examples/${name}.expected:\n${out}") + endif() +endfunction() + +# Configure, build and run examples/ as a project of its own. +function(cmake_project) + file(REMOVE_RECURSE "${work}") + set(args -S "${SOURCE_DIR}/examples" -B "${work}" -G "${GENERATOR}" + "-DCMAKE_C_COMPILER=${C_COMPILER}" "-DCMAKE_CXX_COMPILER=${CXX_COMPILER}" ${ARGN}) + if(CONFIG) + list(APPEND args "-DCMAKE_BUILD_TYPE=${CONFIG}") + endif() + run("${CMAKE_COMMAND}" ${args}) + if(CONFIG) + run("${CMAKE_COMMAND}" --build "${work}" --config "${CONFIG}") + else() + run("${CMAKE_COMMAND}" --build "${work}") + endif() + foreach(name IN LISTS examples ITEMS cpp) + set(exe "") + foreach(candidate "${work}/${name}" "${work}/${name}.exe" "${work}/${CONFIG}/${name}.exe") + if(EXISTS "${candidate}" AND NOT IS_DIRECTORY "${candidate}") + set(exe "${candidate}") + break() + endif() + endforeach() + if(NOT exe) + message(FATAL_ERROR "${MODE}: no ${name} program in ${work}") + endif() + check_output("${exe}" ${name}) + endforeach() +endfunction() + +set(strict_c -std=c11 -Wall -Wextra -Wpedantic -Wshadow -Wconversion -Wno-sign-conversion -Werror) +set(strict_cxx -std=c++17 -Wall -Wextra -Wpedantic -Wshadow -Werror) + +if(MODE STREQUAL "install") + file(REMOVE_RECURSE "${PREFIX}") + if(CONFIG) + run("${CMAKE_COMMAND}" --install "${BUILD_DIR}" --prefix "${PREFIX}" --config "${CONFIG}") + else() + run("${CMAKE_COMMAND}" --install "${BUILD_DIR}" --prefix "${PREFIX}") + endif() + foreach(f include/trackparse.h include/trackparse.hpp) + if(NOT EXISTS "${PREFIX}/${f}") + message(FATAL_ERROR "install: ${f} is missing") + endif() + endforeach() + file(GLOB_RECURSE configs "${PREFIX}/*/trackparseConfig.cmake") + file(GLOB_RECURSE pcs "${PREFIX}/*/trackparse.pc") + if(NOT configs OR NOT pcs) + message(FATAL_ERROR "install: trackparseConfig.cmake or trackparse.pc is missing") + endif() + +elseif(MODE STREQUAL "find_package") + cmake_project(-DTRACKPARSE_EXAMPLES_FROM=package "-DCMAKE_PREFIX_PATH=${PREFIX}") + +elseif(MODE STREQUAL "pkg_config") + find_program(pkg_config NAMES pkg-config pkgconf) + if(NOT pkg_config OR msvc_like) + message("SKIP: no pkg-config, or an MSVC-style compiler") + return() + endif() + file(GLOB_RECURSE pcs "${PREFIX}/*/pkgconfig/trackparse.pc") + list(GET pcs 0 pc) + get_filename_component(pcdir "${pc}" DIRECTORY) + set(ENV{PKG_CONFIG_PATH} "${pcdir}") + set(ENV{PKG_CONFIG_LIBDIR} "${pcdir}") + set(static "") + if(NOT SHARED) + set(static --static) + endif() + execute_process(COMMAND "${pkg_config}" --cflags trackparse OUTPUT_VARIABLE cflags + RESULT_VARIABLE rc1 OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND "${pkg_config}" ${static} --libs trackparse OUTPUT_VARIABLE libs + RESULT_VARIABLE rc2 OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND "${pkg_config}" --variable=libdir trackparse OUTPUT_VARIABLE libdir + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT rc1 EQUAL 0 OR NOT rc2 EQUAL 0) + message(FATAL_ERROR "pkg-config does not know trackparse (${pcdir})") + endif() + separate_arguments(cflags UNIX_COMMAND "${cflags}") + separate_arguments(libs UNIX_COMMAND "${libs}") + set(rpath "") + if(SHARED) + set(rpath "-Wl,-rpath,${libdir}") + endif() + file(REMOVE_RECURSE "${work}") + file(MAKE_DIRECTORY "${work}") + foreach(name IN LISTS examples) + run("${C_COMPILER}" ${strict_c} ${cflags} "${SOURCE_DIR}/examples/${name}.c" + -o "${work}/${name}" ${libs} ${rpath}) + check_output("${work}/${name}" ${name}) + endforeach() + run("${CXX_COMPILER}" ${strict_cxx} ${cflags} "${SOURCE_DIR}/examples/cpp.cpp" + -o "${work}/cpp" ${libs} ${rpath}) + check_output("${work}/cpp" cpp) + +elseif(MODE STREQUAL "amalgamation") + if(msvc_like) + message("SKIP: plain compiler commands are written for GCC and Clang (see amalgamation_cmake)") + return() + endif() + if(NOT EXISTS "${AMALGAMATION_C}") + message(FATAL_ERROR "no amalgamation at ${AMALGAMATION_C} (build the library first)") + endif() + file(REMOVE_RECURSE "${work}") + file(MAKE_DIRECTORY "${work}") + # Copy the three files somewhere alone, so nothing else in c/ can be picked up. + foreach(f trackparse.c trackparse.h trackparse.hpp) + file(COPY "${amalgamation_dir}/${f}" DESTINATION "${work}/dist") + endforeach() + set(dist "${work}/dist") + set(libs -lm) + if(NOT APPLE) + list(APPEND libs -pthread) + endif() + # As part of a program, and as a shared library object (exports only, -fvisibility=hidden). + run("${C_COMPILER}" ${strict_c} -ffp-contract=off -O2 -c "${dist}/trackparse.c" + -o "${work}/trackparse.o") + run("${C_COMPILER}" ${strict_c} -ffp-contract=off -O2 -fPIC -fvisibility=hidden + -DTRACKPARSE_BUILDING -c "${dist}/trackparse.c" -o "${work}/trackparse_pic.o") + foreach(name IN LISTS examples) + run("${C_COMPILER}" ${strict_c} -DTRACKPARSE_STATIC "-I${dist}" + "${SOURCE_DIR}/examples/${name}.c" "${work}/trackparse.o" -o "${work}/${name}" ${libs}) + check_output("${work}/${name}" ${name}) + endforeach() + run("${CXX_COMPILER}" ${strict_cxx} -DTRACKPARSE_STATIC "-I${dist}" + "${SOURCE_DIR}/examples/cpp.cpp" "${work}/trackparse.o" -o "${work}/cpp" ${libs}) + check_output("${work}/cpp" cpp) + +elseif(MODE STREQUAL "amalgamation_cmake") + if(NOT EXISTS "${AMALGAMATION_C}") + message(FATAL_ERROR "no amalgamation at ${AMALGAMATION_C} (build the library first)") + endif() + cmake_project(-DTRACKPARSE_EXAMPLES_FROM=amalgamation "-DTRACKPARSE_SOURCE=${amalgamation_dir}") + +elseif(MODE STREQUAL "fetchcontent") + cmake_project(-DTRACKPARSE_EXAMPLES_FROM=fetchcontent "-DTRACKPARSE_SOURCE=${SOURCE_DIR}" + "-DTRACKPARSE_SHARED=${SHARED}") + +else() + message(FATAL_ERROR "consumer_check.cmake: unknown MODE ${MODE}") +endif() diff --git a/c/cmake/hardening.cmake b/c/cmake/hardening.cmake new file mode 100644 index 0000000..cb13c33 --- /dev/null +++ b/c/cmake/hardening.cmake @@ -0,0 +1,104 @@ +# hardening.cmake: the hardening tests and the fuzz targets (PLAN.md step 8). Included from +# CMakeLists.txt when TRACKPARSE_BUILD_TESTS or TRACKPARSE_FUZZ is on. +# +# properties SPEC invariants and R13.11 on seeded inputs, and the time ceilings +# threads 16 threads against a sequential run (run it under TRACKPARSE_SANITIZE_THREAD) +# locale outputs under setlocale(LC_ALL, "") and de_DE / tr_TR equal the "C" locale's +# oom the n-th allocation fails, for every n, on ~50 inputs across the API +# test_bench not a test: ns per call, printed like go test -bench (run it by hand) +# fuzz_* libFuzzer targets (TRACKPARSE_FUZZ, Clang) +# +# Options added here: +# TRACKPARSE_SANITIZE_THREAD build everything with ThreadSanitizer (not with TRACKPARSE_SANITIZE) +# TRACKPARSE_SANITIZE_MEMORY build everything with MemorySanitizer (Clang). The C programs run +# against the uninstrumented glibc (MSan intercepts what they call); +# the C++ targets would need an instrumented libc++, so build the C +# targets only (cmake --build ... --target test_properties ...) +# +# A build with any sanitizer (or the fuzz flags) defines TRACKPARSE_SANITIZED for the hardening +# programs: they then run fewer property cases and widen the time ceilings ten times. + +option(TRACKPARSE_SANITIZE_THREAD "Build with -fsanitize=thread" OFF) +option(TRACKPARSE_SANITIZE_MEMORY "Build with -fsanitize=memory (Clang)" OFF) + +if(NOT MSVC) + if(TRACKPARSE_SANITIZE_THREAD) + if(TRACKPARSE_SANITIZE OR TRACKPARSE_SANITIZE_MEMORY OR TRACKPARSE_FUZZ) + message(FATAL_ERROR "TRACKPARSE_SANITIZE_THREAD cannot be combined with another sanitizer") + endif() + target_compile_options(trackparse_flags INTERFACE -fsanitize=thread -fno-omit-frame-pointer) + target_link_options(trackparse_flags INTERFACE -fsanitize=thread) + endif() + if(TRACKPARSE_SANITIZE_MEMORY) + if(NOT CMAKE_C_COMPILER_ID MATCHES "Clang") + message(FATAL_ERROR "TRACKPARSE_SANITIZE_MEMORY needs Clang") + endif() + if(TRACKPARSE_SANITIZE OR TRACKPARSE_FUZZ) + message(FATAL_ERROR "TRACKPARSE_SANITIZE_MEMORY cannot be combined with ASan") + endif() + target_compile_options(trackparse_flags INTERFACE + -fsanitize=memory -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer) + target_link_options(trackparse_flags INTERFACE -fsanitize=memory) + endif() +endif() + +set(TRACKPARSE_SANITIZED OFF) +if(TRACKPARSE_SANITIZE OR TRACKPARSE_SANITIZE_THREAD OR TRACKPARSE_SANITIZE_MEMORY + OR TRACKPARSE_FUZZ) + set(TRACKPARSE_SANITIZED ON) +endif() + +# The generator, the checks, the fixture loader (tests/hardening.c), shared by the tests and the +# fuzz targets. +add_library(trackparse_hardening STATIC tests/hardening.c) +target_link_libraries(trackparse_hardening PUBLIC trackparse_wire) +if(TRACKPARSE_SANITIZED) + target_compile_definitions(trackparse_hardening PUBLIC TRACKPARSE_SANITIZED) +endif() + +if(TRACKPARSE_BUILD_TESTS) + function(trackparse_hardening_program name) + trackparse_test_program(${name} ${ARGN}) + target_link_libraries(${name} PRIVATE trackparse_hardening) + endfunction() + + trackparse_hardening_program(test_properties tests/test_properties.c) + add_test(NAME properties COMMAND test_properties WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") + set_tests_properties(properties PROPERTIES TIMEOUT 3000) + + # The fixture files are the inputs of threads, locale, oom and the bench (no spec/: the + # programs fall back to a few inputs of their own, or skip). + trackparse_hardening_program(test_threads tests/test_threads.c) + if(Threads_FOUND) + target_link_libraries(test_threads PRIVATE Threads::Threads) + endif() + add_test(NAME threads COMMAND test_threads ${TRACKPARSE_FIXTURE_FILES}) + set_tests_properties(threads PROPERTIES TIMEOUT 3000) + + trackparse_hardening_program(test_locale tests/test_locale.c) + add_test(NAME locale COMMAND test_locale ${TRACKPARSE_FIXTURE_FILES}) + set_tests_properties(locale PROPERTIES SKIP_RETURN_CODE 77 TIMEOUT 3000) + + trackparse_hardening_program(test_oom tests/test_oom.c) + add_test(NAME oom COMMAND test_oom ${TRACKPARSE_FIXTURE_FILES}) + set_tests_properties(oom PROPERTIES TIMEOUT 3000) + + # Not registered with CTest: test_bench [--fixtures ...], or TRACKPARSE_BENCH=1 ctest + # -R bench (registered only then, so a plain ctest never runs it). + trackparse_hardening_program(test_bench tests/test_bench.c) + if(DEFINED ENV{TRACKPARSE_BENCH}) + add_test(NAME bench COMMAND test_bench --fixtures ${TRACKPARSE_FIXTURE_FILES}) + endif() +endif() + +# libFuzzer targets: one per public function, and the JSON door. CMakeLists.txt sets the +# coverage and sanitizer flags for every target when TRACKPARSE_FUZZ is on; these add libFuzzer's +# main. Run one: ./fuzz_parse -max_total_time=60 corpus/parse +# (scripts/fuzz_corpus.mjs writes the seed corpus from the fixture inputs). +if(TRACKPARSE_FUZZ) + foreach(t parse parse_artists format parse_tracklist apply_edits wire) + add_executable(fuzz_${t} fuzz/fuzz_${t}.c) + target_link_libraries(fuzz_${t} PRIVATE trackparse_hardening) + target_link_options(fuzz_${t} PRIVATE -fsanitize=fuzzer) + endforeach() +endif() diff --git a/c/cmake/package.cmake b/c/cmake/package.cmake new file mode 100644 index 0000000..13cd530 --- /dev/null +++ b/c/cmake/package.cmake @@ -0,0 +1,298 @@ +# package.cmake: the installed library, its install rules and the consumer checks. +# Included at the end of c/CMakeLists.txt. +# +# The library `trackparse` (alias trackparse::trackparse) is built from the amalgamation: one +# translation unit in which every internal name is static, so nothing but trackparse_* leaves +# the object file, static or shared. Where the amalgamation comes from: +# - a git checkout (the repo's .git is present) with Node: generated into the build tree by +# scripts/amalgamate.mjs, and regenerated when a source changes; +# - otherwise dist/trackparse.c, which the release tarball ships (no Node needed); +# - TRACKPARSE_AMALGAMATION_DIR: a folder holding trackparse.c, to use that one instead. +# +# Options: +# TRACKPARSE_SHARED build libtrackparse as a shared library (default: BUILD_SHARED_LIBS) +# TRACKPARSE_INSTALL install rules (default ON when trackparse is the top-level project) + +include(GNUInstallDirs) +include(CMakePackageConfigHelpers) + +if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) + set(trackparse_is_top_level ON) +else() + set(trackparse_is_top_level OFF) +endif() + +option(TRACKPARSE_SHARED "Build libtrackparse as a shared library" ${BUILD_SHARED_LIBS}) +option(TRACKPARSE_INSTALL "Generate the install rules" ${trackparse_is_top_level}) +set(TRACKPARSE_AMALGAMATION_DIR "" CACHE PATH + "A folder with a ready trackparse.c amalgamation (empty: generate it or use dist/)") + +# The internal build (tests, wire, dump) is not something a FetchContent user wants to build. +if(NOT trackparse_is_top_level) + foreach(t trackparse_internal trackparse_wire trackparse-dump) + if(TARGET ${t}) + set_target_properties(${t} PROPERTIES EXCLUDE_FROM_ALL ON) + endif() + endforeach() +endif() + +# --------------------------------------------------------------------------------------------- +# The amalgamation + +find_program(TRACKPARSE_NODE_EXECUTABLE node) +file(GLOB trackparse_amalgamation_inputs CONFIGURE_DEPENDS + "${CMAKE_CURRENT_SOURCE_DIR}/src/*.c" "${CMAKE_CURRENT_SOURCE_DIR}/src/*.h") +list(APPEND trackparse_amalgamation_inputs + "${CMAKE_CURRENT_SOURCE_DIR}/include/trackparse.h" + "${CMAKE_CURRENT_SOURCE_DIR}/include/trackparse.hpp" + "${CMAKE_CURRENT_SOURCE_DIR}/scripts/amalgamate.mjs") + +if(TRACKPARSE_AMALGAMATION_DIR) + set(TRACKPARSE_AMALGAMATION_C "${TRACKPARSE_AMALGAMATION_DIR}/trackparse.c") + set(trackparse_amalgamation_how "TRACKPARSE_AMALGAMATION_DIR") +elseif(EXISTS "${TRACKPARSE_REPO_DIR}/.git" AND TRACKPARSE_NODE_EXECUTABLE) + set(TRACKPARSE_AMALGAMATION_C "${CMAKE_CURRENT_BINARY_DIR}/amalgamation/trackparse.c") + set(trackparse_amalgamation_how "generated with Node") + add_custom_command( + OUTPUT "${TRACKPARSE_AMALGAMATION_C}" + COMMAND "${TRACKPARSE_NODE_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/scripts/amalgamate.mjs" + --out "${CMAKE_CURRENT_BINARY_DIR}/amalgamation" + DEPENDS ${trackparse_amalgamation_inputs} + COMMENT "Writing the amalgamation (scripts/amalgamate.mjs)" + VERBATIM) +elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/dist/trackparse.c") + set(TRACKPARSE_AMALGAMATION_C "${CMAKE_CURRENT_SOURCE_DIR}/dist/trackparse.c") + set(trackparse_amalgamation_how "dist/") +else() + message(FATAL_ERROR + "trackparse: no amalgamation. Building from git needs Node (scripts/amalgamate.mjs writes " + "it); the release tarball ships dist/trackparse.c.") +endif() +message(STATUS "trackparse: library from the amalgamation (${trackparse_amalgamation_how})") + +# --------------------------------------------------------------------------------------------- +# The library + +if(TRACKPARSE_SHARED) + add_library(trackparse SHARED "${TRACKPARSE_AMALGAMATION_C}") +else() + add_library(trackparse STATIC "${TRACKPARSE_AMALGAMATION_C}") + # Without it the header declares DLL imports on Windows; elsewhere it changes nothing. + target_compile_definitions(trackparse PUBLIC TRACKPARSE_STATIC) +endif() +add_library(trackparse::trackparse ALIAS trackparse) + +target_include_directories(trackparse PUBLIC + "$" + "$") +target_compile_definitions(trackparse PRIVATE TRACKPARSE_BUILDING) +target_compile_features(trackparse PUBLIC c_std_11) + +# The flags the results depend on (PLAN.md hazards 1, 5 and 12), always. The warning flags of +# trackparse_flags (and -Werror under CI) only when trackparse is the top-level project, so a +# consumer's newer compiler cannot break its build. +if(trackparse_is_top_level) + # BUILD_INTERFACE: a build-only dependency, so the export set does not need trackparse_flags. + target_link_libraries(trackparse PRIVATE "$") + # A sanitizer or fuzz build instruments the library, so whatever links it in this build tree + # (examples, the C++ tests) needs the same link options. + target_link_options(trackparse INTERFACE + "$>") +elseif(MSVC) + target_compile_options(trackparse PRIVATE /fp:precise /utf-8) + target_compile_definitions(trackparse PRIVATE _CRT_SECURE_NO_WARNINGS) +else() + target_compile_options(trackparse PRIVATE -ffp-contract=off) + if(CMAKE_SIZEOF_VOID_P EQUAL 4 AND CMAKE_SYSTEM_PROCESSOR MATCHES "^(i.86|x86|X86|AMD64|x86_64)$") + target_compile_options(trackparse PRIVATE -msse2 -mfpmath=sse) + endif() +endif() + +# Shared library version: no ABI promise while 0.x, so the soname carries the minor version +# (libtrackparse.so.0.6); from 1.0 the major version. +if(PROJECT_VERSION_MAJOR EQUAL 0) + set(trackparse_soversion "0.${PROJECT_VERSION_MINOR}") +else() + set(trackparse_soversion "${PROJECT_VERSION_MAJOR}") +endif() +set_target_properties(trackparse PROPERTIES + C_VISIBILITY_PRESET hidden + VISIBILITY_INLINES_HIDDEN ON + VERSION "${PROJECT_VERSION}" + SOVERSION "${trackparse_soversion}" + EXPORT_NAME trackparse) + +find_package(Threads REQUIRED) +target_link_libraries(trackparse PRIVATE Threads::Threads) +set(trackparse_pc_libs_private "") +if(CMAKE_USE_PTHREADS_INIT OR CMAKE_THREAD_LIBS_INIT) + set(trackparse_pc_libs_private "${CMAKE_THREAD_LIBS_INIT}") +endif() +if(UNIX) + target_link_libraries(trackparse PRIVATE m) + string(APPEND trackparse_pc_libs_private " -lm") +endif() +string(STRIP "${trackparse_pc_libs_private}" trackparse_pc_libs_private) + +# --------------------------------------------------------------------------------------------- +# Install: lib, headers, CMake package, pkg-config file + +if(TRACKPARSE_INSTALL) + set(TRACKPARSE_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/trackparse" CACHE STRING + "Where trackparseConfig.cmake is installed") + + install(TARGETS trackparse EXPORT trackparseTargets + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" NAMELINK_COMPONENT Development + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") + install(FILES + "${CMAKE_CURRENT_SOURCE_DIR}/include/trackparse.h" + "${CMAKE_CURRENT_SOURCE_DIR}/include/trackparse.hpp" + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") + install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE" DESTINATION "${CMAKE_INSTALL_DOCDIR}") + + install(EXPORT trackparseTargets + NAMESPACE trackparse:: + FILE trackparseTargets.cmake + DESTINATION "${TRACKPARSE_INSTALL_CMAKEDIR}") + + set(TRACKPARSE_CONFIG_STATIC OFF) + if(NOT TRACKPARSE_SHARED) + set(TRACKPARSE_CONFIG_STATIC ON) + endif() + configure_package_config_file( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/trackparseConfig.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/trackparseConfig.cmake" + INSTALL_DESTINATION "${TRACKPARSE_INSTALL_CMAKEDIR}") + # 0.x: a minor release may break the API, so only the same minor version is compatible. + if(PROJECT_VERSION_MAJOR EQUAL 0) + set(trackparse_compat SameMinorVersion) + else() + set(trackparse_compat SameMajorVersion) + endif() + write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/trackparseConfigVersion.cmake" + VERSION "${PROJECT_VERSION}" + COMPATIBILITY ${trackparse_compat}) + install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/trackparseConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/trackparseConfigVersion.cmake" + DESTINATION "${TRACKPARSE_INSTALL_CMAKEDIR}") + + # pkg-config. With relative install dirs, prefix is found from the .pc file's own place + # (${pcfiledir}), so `cmake --install --prefix` and a moved tree both work. + if(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}") + set(trackparse_pc_prefix "${CMAKE_INSTALL_PREFIX}") + else() + file(RELATIVE_PATH trackparse_pc_up "/prefix/${CMAKE_INSTALL_LIBDIR}/pkgconfig" "/prefix") + string(REGEX REPLACE "/$" "" trackparse_pc_up "${trackparse_pc_up}") + set(trackparse_pc_prefix "\${pcfiledir}/${trackparse_pc_up}") + endif() + foreach(d LIBDIR INCLUDEDIR) + if(IS_ABSOLUTE "${CMAKE_INSTALL_${d}}") + set(trackparse_pc_${d} "${CMAKE_INSTALL_${d}}") + else() + set(trackparse_pc_${d} "\${prefix}/${CMAKE_INSTALL_${d}}") + endif() + endforeach() + if(TRACKPARSE_SHARED) + set(trackparse_pc_cflags "") + else() + set(trackparse_pc_cflags " -DTRACKPARSE_STATIC") + endif() + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/trackparse.pc.in" + "${CMAKE_CURRENT_BINARY_DIR}/trackparse.pc" @ONLY) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/trackparse.pc" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") +endif() + +# --------------------------------------------------------------------------------------------- +# Tests: the C++ wrapper, the examples, the exported symbols, and the consumer checks + +if(TRACKPARSE_BUILD_TESTS AND trackparse_is_top_level) + # The C++ wrapper, against the installed library target, in C++17 and C++20. + foreach(std 17 20) + if(std EQUAL 20 AND NOT "cxx_std_20" IN_LIST CMAKE_CXX_COMPILE_FEATURES) + continue() + endif() + add_executable(test_cpp${std} tests/test_cpp.cpp) + target_link_libraries(test_cpp${std} PRIVATE trackparse::trackparse) + set_target_properties(test_cpp${std} PROPERTIES CXX_STANDARD ${std} CXX_STANDARD_REQUIRED ON + CXX_EXTENSIONS OFF) + if(MSVC) + target_compile_options(test_cpp${std} PRIVATE /W4 /utf-8 $<$:/WX>) + else() + target_compile_options(test_cpp${std} PRIVATE -Wall -Wextra -Wpedantic -Wshadow + $<$:-Werror>) + endif() + add_test(NAME cpp${std} COMMAND test_cpp${std}) + endforeach() + + # The examples, built against the library target; each output must match its .expected. + set(trackparse_examples basic options tracklist json cpp) + foreach(example IN LISTS trackparse_examples) + if(example STREQUAL "cpp") + add_executable(example_${example} examples/${example}.cpp) + else() + add_executable(example_${example} examples/${example}.c) + endif() + target_link_libraries(example_${example} PRIVATE trackparse::trackparse) + add_test(NAME example_${example} + COMMAND "${CMAKE_COMMAND}" "-DPROGRAM=$" + "-DEXPECTED=${CMAKE_CURRENT_SOURCE_DIR}/examples/${example}.expected" + -P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/run_example.cmake") + set_tests_properties(example_${example} PROPERTIES LABELS examples) + endforeach() + + # Only trackparse_* may leave the library (nm; skipped where there is none). + find_program(TRACKPARSE_NM_EXECUTABLE NAMES nm llvm-nm) + add_test(NAME exports + COMMAND "${CMAKE_COMMAND}" "-DLIBRARY=$" + "-DNM=${TRACKPARSE_NM_EXECUTABLE}" + "-DSHARED=${TRACKPARSE_SHARED}" "-DAPPLE=${APPLE}" + -P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/check_exports.cmake") + set_tests_properties(exports PROPERTIES SKIP_REGULAR_EXPRESSION "SKIP:") + + # Consumer checks (label "consumer"): install into a prefix under the build tree, then build + # the examples from it with find_package and with pkg-config; build them from the amalgamation + # alone, with plain compiler commands and with CMake; and as a FetchContent dependency. + set(trackparse_consumer_dir "${CMAKE_CURRENT_BINARY_DIR}/consumer") + set(trackparse_prefix "${trackparse_consumer_dir}/prefix") + set(trackparse_consumer_args + "-DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}" + "-DWORK_DIR=${trackparse_consumer_dir}" + "-DPREFIX=${trackparse_prefix}" + "-DAMALGAMATION_C=${TRACKPARSE_AMALGAMATION_C}" + "-DGENERATOR=${CMAKE_GENERATOR}" + "-DC_COMPILER=${CMAKE_C_COMPILER}" + "-DCXX_COMPILER=${CMAKE_CXX_COMPILER}" + "-DCONFIG=$" + "-DSHARED=${TRACKPARSE_SHARED}") + if(TRACKPARSE_INSTALL) + add_test(NAME consumer_install + COMMAND "${CMAKE_COMMAND}" -DMODE=install "-DBUILD_DIR=${CMAKE_BINARY_DIR}" + ${trackparse_consumer_args} + -P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/consumer_check.cmake") + set_tests_properties(consumer_install PROPERTIES FIXTURES_SETUP trackparse_installed) + foreach(how find_package pkg_config) + add_test(NAME consumer_${how} + COMMAND "${CMAKE_COMMAND}" "-DMODE=${how}" ${trackparse_consumer_args} + -P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/consumer_check.cmake") + set_tests_properties(consumer_${how} PROPERTIES FIXTURES_REQUIRED trackparse_installed) + endforeach() + endif() + foreach(how amalgamation amalgamation_cmake fetchcontent) + add_test(NAME consumer_${how} + COMMAND "${CMAKE_COMMAND}" "-DMODE=${how}" ${trackparse_consumer_args} + -P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/consumer_check.cmake") + endforeach() + set(trackparse_consumer_tests consumer_amalgamation consumer_amalgamation_cmake + consumer_fetchcontent) + if(TRACKPARSE_INSTALL) + list(APPEND trackparse_consumer_tests + consumer_install consumer_find_package consumer_pkg_config) + endif() + set_tests_properties(${trackparse_consumer_tests} PROPERTIES + LABELS consumer SKIP_REGULAR_EXPRESSION "SKIP:" TIMEOUT 900) +endif() diff --git a/c/cmake/run_example.cmake b/c/cmake/run_example.cmake new file mode 100644 index 0000000..0482125 --- /dev/null +++ b/c/cmake/run_example.cmake @@ -0,0 +1,14 @@ +# Runs PROGRAM and compares its standard output with the file EXPECTED (line ends normalized). +# cmake -DPROGRAM=... -DEXPECTED=... -P run_example.cmake +execute_process(COMMAND "${PROGRAM}" RESULT_VARIABLE rc OUTPUT_VARIABLE out ERROR_VARIABLE err) +if(NOT rc EQUAL 0) + message(FATAL_ERROR "${PROGRAM} exited with ${rc}\n${err}") +endif() +file(READ "${EXPECTED}" expected) +string(REPLACE "\r\n" "\n" out "${out}") +string(REPLACE "\r\n" "\n" expected "${expected}") +if(NOT out STREQUAL expected) + get_filename_component(name "${EXPECTED}" NAME) + file(WRITE "${PROGRAM}.actual" "${out}") + message(FATAL_ERROR "output differs from ${name}; got (also in ${PROGRAM}.actual):\n${out}") +endif() diff --git a/c/cmake/trackparseConfig.cmake.in b/c/cmake/trackparseConfig.cmake.in new file mode 100644 index 0000000..e279ae1 --- /dev/null +++ b/c/cmake/trackparseConfig.cmake.in @@ -0,0 +1,19 @@ +# trackparseConfig.cmake: find_package(trackparse) support. Provides trackparse::trackparse. +# +# find_package(trackparse CONFIG REQUIRED) +# target_link_libraries(app PRIVATE trackparse::trackparse) +# +# trackparse_SHARED tells whether the installed library is shared. + +@PACKAGE_INIT@ + +set(trackparse_SHARED @TRACKPARSE_SHARED@) + +# A static libtrackparse needs the thread library (and libm) at link time. +if(NOT trackparse_SHARED) + include(CMakeFindDependencyMacro) + find_dependency(Threads) +endif() + +include("${CMAKE_CURRENT_LIST_DIR}/trackparseTargets.cmake") +check_required_components(trackparse) diff --git a/c/examples/CMakeLists.txt b/c/examples/CMakeLists.txt new file mode 100644 index 0000000..6d1774a --- /dev/null +++ b/c/examples/CMakeLists.txt @@ -0,0 +1,52 @@ +# The examples as a consumer builds them: a project of its own that finds trackparse one of three +# ways. The consumer checks (cmake/package.cmake, ctest -L consumer) configure it with each. +# +# TRACKPARSE_EXAMPLES_FROM=package find_package(trackparse CONFIG) from an installed copy +# (set CMAKE_PREFIX_PATH to the install prefix) +# TRACKPARSE_EXAMPLES_FROM=fetchcontent FetchContent from TRACKPARSE_SOURCE (the c/ folder or +# an unpacked release tarball) +# TRACKPARSE_EXAMPLES_FROM=amalgamation dist/trackparse.c compiled in, from TRACKPARSE_SOURCE +# (a folder holding trackparse.c, .h and .hpp) +cmake_minimum_required(VERSION 3.16) +project(trackparse_examples LANGUAGES C CXX) + +set(CMAKE_C_STANDARD 11) +set(CMAKE_C_STANDARD_REQUIRED ON) +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +set(TRACKPARSE_EXAMPLES_FROM "package" CACHE STRING "package, fetchcontent or amalgamation") +set(TRACKPARSE_SOURCE "" CACHE PATH "The trackparse source (fetchcontent, amalgamation)") + +if(TRACKPARSE_EXAMPLES_FROM STREQUAL "package") + find_package(trackparse CONFIG REQUIRED) +elseif(TRACKPARSE_EXAMPLES_FROM STREQUAL "fetchcontent") + include(FetchContent) + # A real project gives URL and URL_HASH of the release tarball instead of SOURCE_DIR. + FetchContent_Declare(trackparse SOURCE_DIR "${TRACKPARSE_SOURCE}") + FetchContent_MakeAvailable(trackparse) +elseif(TRACKPARSE_EXAMPLES_FROM STREQUAL "amalgamation") + add_library(trackparse STATIC "${TRACKPARSE_SOURCE}/trackparse.c") + target_include_directories(trackparse PUBLIC "${TRACKPARSE_SOURCE}") + target_compile_definitions(trackparse PUBLIC TRACKPARSE_STATIC) + if(MSVC) + target_compile_options(trackparse PRIVATE /fp:precise /utf-8) + else() + target_compile_options(trackparse PRIVATE -ffp-contract=off) + endif() + find_package(Threads REQUIRED) + target_link_libraries(trackparse PRIVATE Threads::Threads) + if(UNIX) + target_link_libraries(trackparse PRIVATE m) + endif() + add_library(trackparse::trackparse ALIAS trackparse) +else() + message(FATAL_ERROR "TRACKPARSE_EXAMPLES_FROM: unknown value ${TRACKPARSE_EXAMPLES_FROM}") +endif() + +foreach(example basic options tracklist json) + add_executable(${example} ${example}.c) + target_link_libraries(${example} PRIVATE trackparse::trackparse) +endforeach() +add_executable(cpp cpp.cpp) +target_link_libraries(cpp PRIVATE trackparse::trackparse) diff --git a/c/examples/basic.c b/c/examples/basic.c new file mode 100644 index 0000000..5652708 --- /dev/null +++ b/c/examples/basic.c @@ -0,0 +1,40 @@ +/* basic.c: parse one track string and print what was found. + * + * cc -std=c11 basic.c -ltrackparse (or with the amalgamation: basic.c trackparse.c -lm) + */ +#include + +#include + +/* trackparse_str is a pointer and a length; it is also NUL-terminated. */ +#define STR(s) (int)(s).len, (s).ptr + +int main(void) { + const char *input = + "Chase & Status feat. Plan B - End Credits (Sub Focus Remix) [Official Video]"; + trackparse_track *t = trackparse_parse(input, TRACKPARSE_NUL_TERMINATED); + if (t == NULL) return 1; /* out of memory, the only failure */ + + printf("title: %.*s\n", STR(t->title)); + printf("full title: %.*s\n", STR(t->full_title)); + for (size_t i = 0; i < t->artists_count; i++) { + const trackparse_artist *a = &t->artists[i]; + printf("artist: %.*s (%s)\n", STR(a->name), trackparse_role_name(a->role)); + } + for (size_t i = 0; i < t->versions_count; i++) { + const trackparse_version *v = &t->versions[i]; + printf("version: %.*s, type %.*s\n", STR(v->raw), STR(v->type_name)); + } + for (size_t i = 0; i < t->junk_count; i++) { + printf("junk: %.*s (%.*s)\n", STR(t->junk[i].raw), STR(t->junk[i].kind_name)); + } + printf("year: %s\n", t->year ? "yes" : "none"); + trackparse_track_free(t); + + /* Nullable fields are pointers. */ + t = trackparse_parse("Noisia - Stigma (2015)", TRACKPARSE_NUL_TERMINATED); + if (t == NULL) return 1; + if (t->year) printf("year: %d\n", *t->year); + trackparse_track_free(t); + return 0; +} diff --git a/c/examples/basic.expected b/c/examples/basic.expected new file mode 100644 index 0000000..10d79da --- /dev/null +++ b/c/examples/basic.expected @@ -0,0 +1,9 @@ +title: End Credits +full title: End Credits (Sub Focus Remix) +artist: Chase (primary) +artist: Status (primary) +artist: Plan B (featured) +version: Sub Focus Remix, type remix +junk: Official Video (video) +year: none +year: 2015 diff --git a/c/examples/cpp.cpp b/c/examples/cpp.cpp new file mode 100644 index 0000000..eddb9f0 --- /dev/null +++ b/c/examples/cpp.cpp @@ -0,0 +1,33 @@ +// cpp.cpp: the C++17 wrapper (trackparse.hpp). +#include + +#include + +int main() { + auto t = trackparse::parse("Noisia - Stigma (2015)"); // owns the C result + std::cout << t.title() << '\n'; // std::string_view + if (auto y = t.year()) std::cout << *y << '\n'; // std::optional + for (const auto &a : t.artists()) { + std::cout << a.name() << " (" << trackparse::name(a.role()) << ")\n"; + } + + // Options chain; a parser keeps them for many calls. + trackparse::parser p(trackparse::parse_options{}.known_artist("Chase & Status")); + auto t2 = p.parse("Chase & Status x Bou - Baddadan (Extended Mix)"); + for (const auto &a : t2.artists()) std::cout << a.name() << '\n'; + for (const auto &v : t2.versions()) std::cout << v.raw() << ": " << v.type_name() << '\n'; + auto no_versions = trackparse::format_options{}.versions(trackparse::versions::none); + std::cout << trackparse::format(t2, no_versions) << '\n'; + + // Tracklists and edits. + const char *text = "0:00 Noisia - Stigma\n4:20 Mefjus - Sinkhole\n"; + auto list = trackparse::parse_tracklist(text, trackparse::tracklist_options{}.audio_seconds(600)); + for (const auto &e : list.entries()) { + if (auto track = e.track()) std::cout << e.line() << ": " << track->title() << '\n'; + } + auto r = + trackparse::apply_edits(text, trackparse::edits{}.shift(30).set_rest(2, "Mefjus - Pivot")); + std::cout << r.text(); + std::cout << trackparse::parse_artists("Camo & Krooked feat. Ayah Marar").to_json() << '\n'; + return 0; +} diff --git a/c/examples/cpp.expected b/c/examples/cpp.expected new file mode 100644 index 0000000..6d948b5 --- /dev/null +++ b/c/examples/cpp.expected @@ -0,0 +1,12 @@ +Stigma +2015 +Noisia (primary) +Chase & Status +Bou +Extended Mix: extended +Chase & Status x Bou - Baddadan +1: Stigma +2: Sinkhole +0:30 Noisia - Stigma +4:50 Mefjus - Pivot +[{"name":"Camo","role":"primary","joiner":null,"source":"artist"},{"name":"Krooked","role":"primary","joiner":"&","source":"artist"},{"name":"Ayah Marar","role":"featured","joiner":"feat.","source":"artist"}] diff --git a/c/examples/json.c b/c/examples/json.c new file mode 100644 index 0000000..279d59e --- /dev/null +++ b/c/examples/json.c @@ -0,0 +1,39 @@ +/* json.c: results as JSON, the bytes JavaScript's JSON.stringify writes. */ +#include + +#include + +#define NT TRACKPARSE_NUL_TERMINATED + +static int print_json(const char *label, trackparse_string *json) { + if (json == NULL) return 1; + printf("%s: %s\n", label, json->str.ptr); + trackparse_string_free(json); + return 0; +} + +int main(void) { + trackparse_track *t = trackparse_parse("01. Noisia - Stigma (2015) [HD]", NT); + if (t == NULL || print_json("track", trackparse_track_to_json(t))) return 1; + trackparse_track_free(t); + + trackparse_artists *a = trackparse_parse_artists("Camo & Krooked feat. Ayah Marar", NT); + if (a == NULL || print_json("artists", trackparse_artists_to_json(a))) return 1; + trackparse_artists_free(a); + + const char *text = "0:00 Noisia - Stigma\n4:20 Mefjus - Sinkhole"; + trackparse_tracklist *l = trackparse_parse_tracklist(text, NT); + if (l == NULL || print_json("tracklist", trackparse_tracklist_to_json(l))) return 1; + trackparse_tracklist_free(l); + + trackparse_edits *e = trackparse_edits_new(); + if (e == NULL) return 1; + trackparse_edits_shift(e, 90.5); + trackparse_edit_result *r = trackparse_apply_edits(text, NT, e); + trackparse_edits_free(e); + if (r == NULL || print_json("edit result", trackparse_edit_result_to_json(r))) return 1; + trackparse_edit_result_free(r); + + printf("library %s, spec %s\n", trackparse_library_version(), trackparse_spec_version()); + return 0; +} diff --git a/c/examples/json.expected b/c/examples/json.expected new file mode 100644 index 0000000..792c19d --- /dev/null +++ b/c/examples/json.expected @@ -0,0 +1,5 @@ +track: {"input":"01. Noisia - Stigma (2015) [HD]","mode":"youtube","position":{"raw":"01","number":1},"timestamp":null,"artists":[{"name":"Noisia","role":"primary","joiner":null,"source":"artist"}],"title":"Stigma","fullTitle":"Stigma","versions":[],"year":2015,"flags":{"explicit":false,"clean":false,"unknownArtist":false,"unknownTitle":false},"junk":[{"raw":"HD","kind":"quality"}],"warnings":[]} +artists: [{"name":"Camo","role":"primary","joiner":null,"source":"artist"},{"name":"Krooked","role":"primary","joiner":"&","source":"artist"},{"name":"Ayah Marar","role":"featured","joiner":"feat.","source":"artist"}] +tracklist: {"specVersion":"0.6.1","entries":[{"line":1,"kind":"track","eol":"\n","raw":"0:00 Noisia - Stigma","parts":{"lead":"","time":"0:00","gap":" ","rest":"Noisia - Stigma"},"time":{"raw":"0:00","seconds":0},"track":{"input":"Noisia - Stigma","mode":"tracklist","position":null,"timestamp":null,"artists":[{"name":"Noisia","role":"primary","joiner":null,"source":"artist"}],"title":"Stigma","fullTitle":"Stigma","versions":[],"year":null,"flags":{"explicit":false,"clean":false,"unknownArtist":false,"unknownTitle":false},"junk":[],"warnings":[]},"layered":false},{"line":2,"kind":"track","eol":"","raw":"4:20 Mefjus - Sinkhole","parts":{"lead":"","time":"4:20","gap":" ","rest":"Mefjus - Sinkhole"},"time":{"raw":"4:20","seconds":260},"track":{"input":"Mefjus - Sinkhole","mode":"tracklist","position":null,"timestamp":null,"artists":[{"name":"Mefjus","role":"primary","joiner":null,"source":"artist"}],"title":"Sinkhole","fullTitle":"Sinkhole","versions":[],"year":null,"flags":{"explicit":false,"clean":false,"unknownArtist":false,"unknownTitle":false},"junk":[],"warnings":[]},"layered":false}],"warnings":[],"stats":{"lines":2,"tracks":2,"markers":0,"timed":2,"firstTime":0,"lastTime":260}} +edit result: {"text":"1:31 Noisia - Stigma\n5:51 Mefjus - Sinkhole","changed":[1,2],"warnings":[]} +library 0.6.1, spec 0.6.1 diff --git a/c/examples/options.c b/c/examples/options.c new file mode 100644 index 0000000..34692bb --- /dev/null +++ b/c/examples/options.c @@ -0,0 +1,63 @@ +/* options.c: parse options, a reusable parser, and format options. */ +#include + +#include + +#define STR(s) (int)(s).len, (s).ptr +#define NT TRACKPARSE_NUL_TERMINATED + +static void print_artists(const trackparse_track *t) { + for (size_t i = 0; i < t->artists_count; i++) { + printf("%s%.*s", i ? " | " : " artists: ", STR(t->artists[i].name)); + } + printf("\n"); +} + +int main(void) { + /* A YouTube title: the uploader's name is a hint for the artist. */ + trackparse_parse_options *o = trackparse_parse_options_new(); + if (o == NULL) return 1; + trackparse_parse_options_set_mode(o, TRACKPARSE_MODE_YOUTUBE); + trackparse_parse_options_set_uploader(o, "Noisia", NT); + trackparse_track *t = trackparse_parse_with("Stigma (Official Video) HD", NT, o); + if (t == NULL) return 1; + printf("youtube: %.*s\n", STR(t->title)); + print_artists(t); + trackparse_track_free(t); + trackparse_parse_options_free(o); + + /* known artists keep a name with a joiner in it together. A parser compiles the options once + * and can be shared between threads. */ + o = trackparse_parse_options_new(); + if (o == NULL) return 1; + trackparse_parse_options_add_known_artist(o, "Chase & Status", NT); + trackparse_parser *p = trackparse_parser_new(o); + trackparse_parse_options_free(o); /* the parser keeps its own copy */ + if (p == NULL) return 1; + const char *inputs[] = {"Chase & Status - Baddadan", "Chase & Status x Bou - Baddadan"}; + for (size_t i = 0; i < sizeof inputs / sizeof inputs[0]; i++) { + t = trackparse_parser_parse(p, inputs[i], NT); + if (t == NULL) return 1; + printf("parser: %s\n", inputs[i]); + print_artists(t); + trackparse_track_free(t); + } + trackparse_parser_free(p); + + /* Format a track back, with the featured artists moved to the title. */ + t = trackparse_parse("Sub Focus feat. Kele - Turn It Around (VIP)", NT); + trackparse_format_options *f = trackparse_format_options_new(); + if (t == NULL || f == NULL) return 1; + trackparse_format_options_set_feat(f, TRACKPARSE_FEAT_TITLE); + trackparse_format_options_set_feat_marker(f, "ft.", NT); + trackparse_string *s = trackparse_format(t); + trackparse_string *s2 = trackparse_format_with(t, f); + if (s == NULL || s2 == NULL) return 1; + printf("format: %s\n", s->str.ptr); + printf("format_with: %s\n", s2->str.ptr); + trackparse_string_free(s); + trackparse_string_free(s2); + trackparse_format_options_free(f); + trackparse_track_free(t); + return 0; +} diff --git a/c/examples/options.expected b/c/examples/options.expected new file mode 100644 index 0000000..2c98408 --- /dev/null +++ b/c/examples/options.expected @@ -0,0 +1,8 @@ +youtube: Stigma + artists: Noisia +parser: Chase & Status - Baddadan + artists: Chase & Status +parser: Chase & Status x Bou - Baddadan + artists: Chase & Status | Bou +format: Sub Focus feat. Kele - Turn It Around (VIP) +format_with: Sub Focus - Turn It Around (ft. Kele) (VIP) diff --git a/c/examples/tracklist.c b/c/examples/tracklist.c new file mode 100644 index 0000000..7490b22 --- /dev/null +++ b/c/examples/tracklist.c @@ -0,0 +1,63 @@ +/* tracklist.c: parse a timed tracklist, then edit it. */ +#include + +#include + +#define STR(s) (int)(s).len, (s).ptr +#define NT TRACKPARSE_NUL_TERMINATED + +static const char *text = "Tracklist:\n" + "00:00 Noisia - Stigma\n" + "03:10 Phace & Misanthrop - Desert Orgy\n" + "02:45 Mefjus - Sinkhole (VIP)\n" + "09:30 June Miller - Drop That\n"; + +int main(void) { + trackparse_tracklist_options *o = trackparse_tracklist_options_new(); + if (o == NULL) return 1; + trackparse_tracklist_options_set_audio_seconds(o, 540); /* a 9-minute mix */ + trackparse_tracklist *list = trackparse_parse_tracklist_with(text, NT, o); + trackparse_tracklist_options_free(o); + if (list == NULL) return 1; + + for (size_t i = 0; i < list->entries_count; i++) { + const trackparse_entry *e = &list->entries[i]; + printf("%d %s", e->line, trackparse_entry_kind_name(e->kind)); + if (e->time) printf(" @%.*s", STR(e->time->raw)); + if (e->track) { + printf(" title=%.*s", STR(e->track->title)); + for (size_t j = 0; j < e->track->artists_count; j++) { + printf(" artist=%.*s", STR(e->track->artists[j].name)); + } + } + printf("\n"); + } + for (size_t i = 0; i < list->warnings_count; i++) { + const trackparse_tracklist_warning *w = &list->warnings[i]; + printf("warning: %s on line %d (%s)\n", trackparse_tracklist_warning_code_name(w->code), + w->line, trackparse_severity_name(w->severity)); + } + printf("stats: %d lines, %d tracks, %d timed\n", list->stats.lines, list->stats.tracks, + list->stats.timed); + trackparse_tracklist_free(list); + + /* Fix the out-of-order time, rename a track, and insert a line. */ + trackparse_edits *e = trackparse_edits_new(); + if (e == NULL) return 1; + trackparse_edits_set_time(e, 4, 400); + trackparse_edits_set_rest(e, 5, "June Miller - Drop That (VIP)", NT); + trackparse_edits_insert(e, 5, "12:00 ID - ID", NT); + trackparse_edit_result *r = trackparse_apply_edits(text, NT, e); + trackparse_edits_free(e); + if (r == NULL) return 1; + printf("--- edited\n%.*s", STR(r->text)); + printf("--- changed lines:"); + for (size_t i = 0; i < r->changed_count; i++) printf(" %lld", r->changed[i]); + printf("\n"); + for (size_t i = 0; i < r->warnings_count; i++) { + printf("edit warning: %s (edit %zu)\n", trackparse_edit_warning_code_name(r->warnings[i].code), + r->warnings[i].edit); + } + trackparse_edit_result_free(r); + return 0; +} diff --git a/c/examples/tracklist.expected b/c/examples/tracklist.expected new file mode 100644 index 0000000..47bed40 --- /dev/null +++ b/c/examples/tracklist.expected @@ -0,0 +1,16 @@ +1 header +2 track @00:00 title=Stigma artist=Noisia +3 track @03:10 title=Desert Orgy artist=Phace artist=Misanthrop +4 track @02:45 title=Sinkhole artist=Mefjus +5 track @09:30 title=Drop That artist=June Miller +warning: time-out-of-order on line 4 (warning) +warning: time-after-audio-end on line 5 (warning) +stats: 5 lines, 4 tracks, 4 timed +--- edited +Tracklist: +00:00 Noisia - Stigma +03:10 Phace & Misanthrop - Desert Orgy +06:40 Mefjus - Sinkhole (VIP) +09:30 June Miller - Drop That (VIP) +12:00 ID - ID +--- changed lines: 4 5 6 diff --git a/c/fuzz/fuzz_apply_edits.c b/c/fuzz/fuzz_apply_edits.c new file mode 100644 index 0000000..fffe8a1 --- /dev/null +++ b/c/fuzz/fuzz_apply_edits.c @@ -0,0 +1,54 @@ +/* fuzz_apply_edits.c: libFuzzer target for apply_edits (go/fuzz_test.go FuzzApplyEdits). + * + * Input: 8 bytes of generator seed and 4 bytes of text length (both little-endian), the text, + * then the edits: used as a JSON edit list when they are JSON, else they seed a random loose + * edit list (hz_loose_edits). Checks R13.11 invariants 2 to 4 on the text and on a timed list + * drawn from the seed: any edit list returns a sound result, no edits is the identity, edits + * stay local, insert and delete keep the other lines, shift round trips, sort is sorted and + * idempotent. */ +#include "../tests/hardening.h" +#include "../wire/json_read.h" + +typedef struct arg { + tp_str text; + tp_str edits; + uint64_t seed; +} arg; + +static void body(void *p) { + const arg *a = (const arg *)p; + hz_rng r = hz_rng_new(a->seed); + tp_json loose; + tp_str list; + if (!tp_json_parse(a->edits, &loose)) { + hz_rng g = hz_rng_new(hz_fnv1a(a->edits.p, a->edits.n) ^ a->seed); + loose = hz_loose_edits(&g); + } + hz_check_loose_edits(a->text, loose); + hz_check_identity(a->text); + hz_check_locality(a->text, &r); + hz_check_insert_delete(a->text, &r); + (void)hz_check_shift_round_trip(a->text, &r); + hz_check_sort(a->text); + /* The same checks on a timed list drawn from the seed, where most edits apply. */ + list = hz_timed_list(&r); + hz_check_locality(list, &r); + (void)hz_check_shift_round_trip(list, &r); +} + +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + arg a; + size_t len = 0, rest; + a.seed = 0; + for (size_t i = 0; i < 8 && i < size; i++) a.seed |= (uint64_t)data[i] << (8 * i); + for (size_t i = 0; i < 4 && 8 + i < size; i++) len |= (size_t)data[8 + i] << (8 * i); + rest = size > 12 ? size - 12 : 0; + if (len > rest) len = rest; + a.text.p = size > 12 ? (const char *)data + 12 : ""; + a.text.n = len; + a.edits.p = a.text.p + len; + a.edits.n = rest - len; + hz_scoped(body, &a); + return 0; +} diff --git a/c/fuzz/fuzz_format.c b/c/fuzz/fuzz_format.c new file mode 100644 index 0000000..5b0546e --- /dev/null +++ b/c/fuzz/fuzz_format.c @@ -0,0 +1,37 @@ +/* fuzz_format.c: libFuzzer target for format (go/fuzz_test.go FuzzFormat). + * + * Input: 8 bytes of generator seed (little-endian; missing bytes are 0), then the string. Formats + * the parse of the string with the default options and with options drawn from the seed, takes + * all_artists, then runs every track-shaped invariant (3, 6, 7, 8) on a track drawn from the + * seed (hz_check_shaped_track). */ +#include "../tests/hardening.h" + +typedef struct arg { + tp_str s; + uint64_t seed; +} arg; + +static void body(void *p) { + const arg *a = (const arg *)p; + hz_rng r = hz_rng_new(a->seed); + tp_parse_options o = hz_fuzz_parse_options(hz_below(&r, HZ_FUZZ_PARSE_OPTIONS)); + tp_track track = tp_api_parse_with(a->s, &o); + tp_format_options fo; + (void)tp_api_format(&track); + fo = hz_format_options_from(&r, a->s); + (void)tp_api_format_with(&track, &fo); + (void)tp_api_all_artists(&track); + hz_check_shaped_track(&r); +} + +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + arg a; + size_t k = size < 8 ? size : 8; + a.seed = 0; + for (size_t i = 0; i < k; i++) a.seed |= (uint64_t)data[i] << (8 * i); + a.s.p = size > 8 ? (const char *)data + 8 : ""; + a.s.n = size > 8 ? size - 8 : 0; + hz_scoped(body, &a); + return 0; +} diff --git a/c/fuzz/fuzz_parse.c b/c/fuzz/fuzz_parse.c new file mode 100644 index 0000000..7e57690 --- /dev/null +++ b/c/fuzz/fuzz_parse.c @@ -0,0 +1,38 @@ +/* fuzz_parse.c: libFuzzer target for parse (go/fuzz_test.go FuzzParse). + * + * Input: one byte choosing an option set (hz_fuzz_parse_options), then the string, any bytes + * (invalid UTF-8 included: the API reads it with the WHATWG replacement rule). Checks invariants + * 1, 2, 4 and 5 in every mode (hz_check_track_totality), the public API against the internal + * one, and parse_with against a parser with the same options. */ +#include "../tests/hardening.h" + +typedef struct arg { + tp_str s; + int set; +} arg; + +static void body(void *p) { + const arg *a = (const arg *)p; + tp_parse_options o = hz_fuzz_parse_options(a->set); + tp_str clean = tp_sanitize(a->s), x, y; + tp_track track, again; + hz_check_track_totality(a->s); + hz_check_public(a->s); + track = tp_api_parse_with(a->s, &o); + if (!tp_str_eq(track.input, clean)) hz_fail("%s: input %s", hz_q(a->s), hz_q(track.input)); + hz_check_artist_hygiene(a->s, &track.artists); + again = tp_parser_parse(tp_new_parser(&o), a->s); + x = tp_track_json(&track); + y = tp_track_json(&again); + if (!tp_str_eq(x, y)) hz_fail("%s: ParseWith and Parser differ:\n%s\n%s", hz_q(a->s), x.p, y.p); +} + +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + arg a; + a.set = size ? data[0] : 0; + a.s.p = size ? (const char *)data + 1 : ""; + a.s.n = size ? size - 1 : 0; + hz_scoped(body, &a); + return 0; +} diff --git a/c/fuzz/fuzz_parse_artists.c b/c/fuzz/fuzz_parse_artists.c new file mode 100644 index 0000000..d3963cb --- /dev/null +++ b/c/fuzz/fuzz_parse_artists.c @@ -0,0 +1,52 @@ +/* fuzz_parse_artists.c: libFuzzer target for parse_artists (go/fuzz_test.go FuzzParseArtists). + * + * Input: one byte choosing an option set, then the string. Checks invariant 5 (names non-empty, + * trimmed, no duplicate dedup keys), that every artist comes from the artist side, and that the + * public function gives the internal JSON. */ +#include "../include/trackparse.h" +#include "../tests/hardening.h" + +typedef struct arg { + tp_str s; + int set; +} arg; + +static void check(tp_str s, tp_artist_vec artists) { + hz_check_artist_hygiene(s, &artists); + for (size_t i = 0; i < artists.n; i++) { + if (!tp_str_eq(artists.p[i].source, TP_SOURCE_ARTIST)) { + hz_fail("%s: source %s", hz_q(s), hz_q(artists.p[i].source)); + } + } +} + +static void body(void *p) { + const arg *a = (const arg *)p; + tp_parse_options o = hz_fuzz_parse_options(a->set); + tp_artist_vec plain = tp_api_parse_artists(a->s); + trackparse_artists *pub = trackparse_parse_artists(a->s.n ? a->s.p : "", a->s.n); + trackparse_string *j; + check(a->s, plain); + check(a->s, tp_api_parse_artists_with(a->s, &o)); + if (!pub) hz_fail("trackparse_parse_artists returned NULL"); + j = trackparse_artists_to_json(pub); + if (!j) hz_fail("trackparse_artists_to_json returned NULL"); + { + tp_str want = tp_artists_json(plain), got; + got.p = j->str.ptr; + got.n = j->str.len; + if (!tp_str_eq(got, want)) hz_fail("%s: public %s, internal %s", hz_q(a->s), got.p, want.p); + } + trackparse_string_free(j); + trackparse_artists_free(pub); +} + +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + arg a; + a.set = size ? data[0] : 0; + a.s.p = size ? (const char *)data + 1 : ""; + a.s.n = size ? size - 1 : 0; + hz_scoped(body, &a); + return 0; +} diff --git a/c/fuzz/fuzz_parse_tracklist.c b/c/fuzz/fuzz_parse_tracklist.c new file mode 100644 index 0000000..e76d48f --- /dev/null +++ b/c/fuzz/fuzz_parse_tracklist.c @@ -0,0 +1,45 @@ +/* fuzz_parse_tracklist.c: libFuzzer target for parse_tracklist (go/fuzz_test.go + * FuzzParseTracklist). + * + * Input: 8 bytes of generator seed (little-endian), then the text. Checks R13.11 invariants 1 + * and 2 with the default options and with an option set drawn from the seed, invariant 5 on the + * text as one line, invariant 6 on a time and rest drawn from the seed, and the public tracklist + * and edit functions against the internal ones. */ +#include "../tests/hardening.h" + +typedef struct arg { + tp_str text; + uint64_t seed; +} arg; + +static void body(void *p) { + const arg *a = (const arg *)p; + hz_rng r = hz_rng_new(a->seed); + tp_tracklist_options none, o; + tp_str style, t, rest; + int seconds, frac; + memset(&none, 0, sizeof none); + hz_check_tracklist(a->text, &none); + o = hz_fuzz_tracklist_options(hz_below(&r, HZ_FUZZ_TRACKLIST_OPTIONS)); + hz_check_tracklist(a->text, &o); + (void)hz_check_one_line(a->text); + style = hz_time_styles[hz_below(&r, (int)hz_time_styles_n)]; + seconds = hz_below(&r, 3600); + frac = hz_below(&r, 1000); + t = hz_write_time(style, seconds, frac); + rest = hz_emphasis_rests[hz_below(&r, (int)hz_emphasis_rests_n)]; + hz_check_emphasis(t, rest); + hz_check_public_tracklist(a->text); +} + +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + arg a; + size_t k = size < 8 ? size : 8; + a.seed = 0; + for (size_t i = 0; i < k; i++) a.seed |= (uint64_t)data[i] << (8 * i); + a.text.p = size > 8 ? (const char *)data + 8 : ""; + a.text.n = size > 8 ? size - 8 : 0; + hz_scoped(body, &a); + return 0; +} diff --git a/c/fuzz/fuzz_wire.c b/c/fuzz/fuzz_wire.c new file mode 100644 index 0000000..fdc99cf --- /dev/null +++ b/c/fuzz/fuzz_wire.c @@ -0,0 +1,27 @@ +/* fuzz_wire.c: libFuzzer target for the JSON door (tp_wire_line), what the dump tool runs for + * compare-ports and fuzz-ports. + * + * Input: one JSONL case line {"fn","input","options","formatOptions","edits"}, any bytes. The + * JSON reader and every function behind loose JSON options must return: the output is JSON the + * reader reads back, and the same line gives the same bytes twice. */ +#include "../tests/hardening.h" +#include "../wire/json_read.h" +#include "../wire/wire.h" + +static void body(void *p) { + const tp_str *line = (const tp_str *)p; + tp_str out = tp_wire_line(*line), again; + tp_json v; + if (!tp_json_parse(out, &v)) hz_fail("%s: invalid JSON output %s", hz_q(*line), hz_q(out)); + again = tp_wire_line(*line); + if (!tp_str_eq(out, again)) hz_fail("%s: two runs differ:\n%s\n%s", hz_q(*line), out.p, again.p); +} + +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + tp_str line; + line.p = size ? (const char *)data : ""; + line.n = size; + hz_scoped(body, &line); + return 0; +} diff --git a/c/include/trackparse.h b/c/include/trackparse.h new file mode 100644 index 0000000..46a15f9 --- /dev/null +++ b/c/include/trackparse.h @@ -0,0 +1,599 @@ +/** + * @file trackparse.h + * @brief Turn messy track names into structured data: artists with roles, remixes and versions, + * junk, and whole tracklists. One spec, the same output as the JavaScript, Python, Rust and Go + * packages. + * + * Documentation: https://4matic.github.io/trackparse/ + * + * Conventions: + * - Input text is UTF-8 given as a pointer and a byte length. Pass TRACKPARSE_NUL_TERMINATED as + * the length to use strlen(). Invalid UTF-8 is replaced with U+FFFD per maximal ill-formed + * subpart (the WHATWG rule, as in the Rust and Go ports). An explicit length lets U+0000 in. + * - Every function is total: any input gives a result. The only failure is running out of + * memory, reported as NULL (or false). + * - Results are read-only and own all their memory; free each with its _free function. Strings + * in results are trackparse_str: a pointer and a length, also NUL-terminated. + * - Nullable fields are pointers that are NULL when the value is absent. + * - ABI: while the version is 0.x, a minor release may add fields to the result structs. Results + * the library returns are always safe to read. A struct the caller fills in by hand and passes + * to trackparse_format, trackparse_all_artists or a _to_json function must be built against + * the header of the library it runs with. + * - Option objects are opaque. Their setters copy what they are given. Bad values fall back to + * the defaults, as in every port. A NULL options pointer means the defaults. + * - All functions are thread-safe. A trackparse_parser is immutable once created and can be + * shared between threads. The default word tables are built on first use and kept for the + * life of the process (a leak checker reports them as still reachable). + */ +#ifndef TRACKPARSE_H +#define TRACKPARSE_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* ------------------------------------------------------------------------------------------ */ +/* Version and linkage */ + +/** The library version this header belongs to. */ +#define TRACKPARSE_VERSION "0.6.1" /* x-release-please-version */ +#define TRACKPARSE_VERSION_MAJOR 0 /* x-release-please-major */ +#define TRACKPARSE_VERSION_MINOR 6 /* x-release-please-minor */ +#define TRACKPARSE_VERSION_PATCH 1 /* x-release-please-patch */ + +#if defined(TRACKPARSE_STATIC) || defined(TRACKPARSE_AMALGAMATION) +#define TRACKPARSE_API +#elif defined(_WIN32) +#ifdef TRACKPARSE_BUILDING +#define TRACKPARSE_API __declspec(dllexport) +#else +#define TRACKPARSE_API __declspec(dllimport) +#endif +#elif defined(__GNUC__) || defined(__clang__) +#define TRACKPARSE_API __attribute__((visibility("default"))) +#else +#define TRACKPARSE_API +#endif + +/** Pass as a length to mean "the string is NUL-terminated". */ +#define TRACKPARSE_NUL_TERMINATED SIZE_MAX + +/** The version of the linked library ("X.Y.Z"), which can differ from TRACKPARSE_VERSION when a + * shared library is replaced. */ +TRACKPARSE_API const char *trackparse_library_version(void); +/** The spec version the library implements (spec/VERSION), "X.Y.Z". */ +TRACKPARSE_API const char *trackparse_spec_version(void); + +/** A UTF-8 string in a result: ptr[len] is always '\0'. */ +typedef struct trackparse_str { + const char *ptr; + size_t len; +} trackparse_str; + +/** Replace the allocator for the whole process. Call it before any other function, at most + * once; NULL restores malloc/realloc/free. realloc_fn may be NULL. */ +typedef struct trackparse_allocator { + void *(*malloc_fn)(size_t size, void *user); + void *(*realloc_fn)(void *ptr, size_t size, void *user); + void (*free_fn)(void *ptr, void *user); + void *user; +} trackparse_allocator; +TRACKPARSE_API void trackparse_set_allocator(const trackparse_allocator *allocator); + +/* ------------------------------------------------------------------------------------------ */ +/* Enumerations. Each has _name() (the spec's string, as in JSON) and _from_name() (returns */ +/* false for an unknown name). */ + +/** R2: how the input was written. */ +typedef enum trackparse_mode { + TRACKPARSE_MODE_AUTO, /**< options only: detect (the default) */ + TRACKPARSE_MODE_CLEAN, + TRACKPARSE_MODE_YOUTUBE, + TRACKPARSE_MODE_FILENAME, + TRACKPARSE_MODE_TRACKLIST +} trackparse_mode; + +typedef enum trackparse_role { + TRACKPARSE_ROLE_PRIMARY, + TRACKPARSE_ROLE_FEATURED, + TRACKPARSE_ROLE_REMIXER, + TRACKPARSE_ROLE_PRODUCER +} trackparse_role; + +/** Where an artist was found. */ +typedef enum trackparse_source { + TRACKPARSE_SOURCE_ARTIST, + TRACKPARSE_SOURCE_TITLE, + TRACKPARSE_SOURCE_VERSION +} trackparse_source; + +/** The 27 version types. keywords can add other names: see trackparse_version.type_name. */ +typedef enum trackparse_version_type { + TRACKPARSE_VERSION_REMIX, + TRACKPARSE_VERSION_BOOTLEG, + TRACKPARSE_VERSION_VIP, + TRACKPARSE_VERSION_EDIT, + TRACKPARSE_VERSION_FLIP, + TRACKPARSE_VERSION_REFIX, + TRACKPARSE_VERSION_REWORK, + TRACKPARSE_VERSION_MASHUP, + TRACKPARSE_VERSION_BLEND, + TRACKPARSE_VERSION_DUB, + TRACKPARSE_VERSION_MIX, + TRACKPARSE_VERSION_EXTENDED, + TRACKPARSE_VERSION_RADIO, + TRACKPARSE_VERSION_CLUB, + TRACKPARSE_VERSION_ORIGINAL, + TRACKPARSE_VERSION_INSTRUMENTAL, + TRACKPARSE_VERSION_ACAPELLA, + TRACKPARSE_VERSION_LIVE, + TRACKPARSE_VERSION_ACOUSTIC, + TRACKPARSE_VERSION_REMASTER, + TRACKPARSE_VERSION_DEMO, + TRACKPARSE_VERSION_REPRISE, + TRACKPARSE_VERSION_COVER, + TRACKPARSE_VERSION_VERSION, /**< also used for names keywords introduced */ + TRACKPARSE_VERSION_SPED_UP, + TRACKPARSE_VERSION_SLOWED, + TRACKPARSE_VERSION_NIGHTCORE +} trackparse_version_type; + +typedef enum trackparse_delimiter { + TRACKPARSE_DELIMITER_PAREN, /**< "(" */ + TRACKPARSE_DELIMITER_BRACKET, /**< "[" */ + TRACKPARSE_DELIMITER_BRACE, /**< "{" */ + TRACKPARSE_DELIMITER_DASH /**< "-" */ +} trackparse_delimiter; + +/** Junk kinds. keywords can add other names: see trackparse_junk.kind_name. */ +typedef enum trackparse_junk_kind { + TRACKPARSE_JUNK_VIDEO, + TRACKPARSE_JUNK_AUDIO, + TRACKPARSE_JUNK_LYRICS, + TRACKPARSE_JUNK_QUALITY, + TRACKPARSE_JUNK_PROMO, + TRACKPARSE_JUNK_PLATFORM, + TRACKPARSE_JUNK_LABEL, + TRACKPARSE_JUNK_GENRE, + TRACKPARSE_JUNK_OTHER /**< also used for names keywords introduced */ +} trackparse_junk_kind; + +/** Track warnings (reference/warnings, "track warnings"). */ +typedef enum trackparse_warning { + TRACKPARSE_WARNING_NO_SEPARATOR, + TRACKPARSE_WARNING_AMBIGUOUS_SEPARATOR, + TRACKPARSE_WARNING_UNSPACED_DASH_SPLIT, + TRACKPARSE_WARNING_ASYMMETRIC_DASH_SPLIT, + TRACKPARSE_WARNING_BY_SPLIT, + TRACKPARSE_WARNING_QUOTED_TITLE_SPLIT, + TRACKPARSE_WARNING_AMBIGUOUS_MIX_CREDIT, + TRACKPARSE_WARNING_UNBALANCED_BRACKETS +} trackparse_warning; + +typedef enum trackparse_entry_kind { + TRACKPARSE_ENTRY_TRACK, + TRACKPARSE_ENTRY_MARKER, + TRACKPARSE_ENTRY_HEADER, + TRACKPARSE_ENTRY_LINK, + TRACKPARSE_ENTRY_NOTE, + TRACKPARSE_ENTRY_BLANK +} trackparse_entry_kind; + +typedef enum trackparse_eol { + TRACKPARSE_EOL_LF, /**< "\n" */ + TRACKPARSE_EOL_CRLF, /**< "\r\n" */ + TRACKPARSE_EOL_CR, /**< "\r" */ + TRACKPARSE_EOL_NONE /**< "" (the last line) */ +} trackparse_eol; + +/** Tracklist warnings (reference/warnings, "tracklist warnings"). */ +typedef enum trackparse_tracklist_warning_code { + TRACKPARSE_TL_TIME_MISSING, + TRACKPARSE_TL_TIME_OUT_OF_ORDER, + TRACKPARSE_TL_TIME_DUPLICATE, + TRACKPARSE_TL_NO_START_AT_ZERO, + TRACKPARSE_TL_TIME_AFTER_AUDIO_END, + TRACKPARSE_TL_INVALID_TIME, + TRACKPARSE_TL_POSITION_GAP, + TRACKPARSE_TL_POSITION_DUPLICATE, + TRACKPARSE_TL_LINE_UNPARSED +} trackparse_tracklist_warning_code; + +typedef enum trackparse_severity { + TRACKPARSE_SEVERITY_INFO, + TRACKPARSE_SEVERITY_WARNING +} trackparse_severity; + +typedef enum trackparse_edit_op { + TRACKPARSE_EDIT_SET_TIME, + TRACKPARSE_EDIT_SHIFT, + TRACKPARSE_EDIT_SORT_BY_TIME, + TRACKPARSE_EDIT_SET_REST, + TRACKPARSE_EDIT_INSERT, + TRACKPARSE_EDIT_DELETE +} trackparse_edit_op; + +/** Edit warnings (reference/warnings, "edit warnings"). */ +typedef enum trackparse_edit_warning_code { + TRACKPARSE_EDIT_WARNING_EDIT_INVALID, + TRACKPARSE_EDIT_WARNING_TIME_CLAMPED, + TRACKPARSE_EDIT_WARNING_STYLE_UPGRADED +} trackparse_edit_warning_code; + +/** R12 splitAnd. */ +typedef enum trackparse_split_and { + TRACKPARSE_SPLIT_AND_AUTO, + TRACKPARSE_SPLIT_AND_ALWAYS, + TRACKPARSE_SPLIT_AND_NEVER +} trackparse_split_and; + +/** R11 feat placement. */ +typedef enum trackparse_feat { + TRACKPARSE_FEAT_SOURCE, + TRACKPARSE_FEAT_ARTIST, + TRACKPARSE_FEAT_TITLE, + TRACKPARSE_FEAT_OMIT +} trackparse_feat; + +typedef enum trackparse_joiners { + TRACKPARSE_JOINERS_ORIGINAL, + TRACKPARSE_JOINERS_CANONICAL +} trackparse_joiners; +typedef enum trackparse_versions { + TRACKPARSE_VERSIONS_ALL, + TRACKPARSE_VERSIONS_NONE +} trackparse_versions; + +/* Number of values in each enum, for loops over all of them. */ +#define TRACKPARSE_MODE_COUNT 5 +#define TRACKPARSE_ROLE_COUNT 4 +#define TRACKPARSE_SOURCE_COUNT 3 +#define TRACKPARSE_VERSION_TYPE_COUNT 27 +#define TRACKPARSE_DELIMITER_COUNT 4 +#define TRACKPARSE_JUNK_KIND_COUNT 9 +#define TRACKPARSE_WARNING_COUNT 8 +#define TRACKPARSE_ENTRY_KIND_COUNT 6 +#define TRACKPARSE_EOL_COUNT 4 +#define TRACKPARSE_TRACKLIST_WARNING_CODE_COUNT 9 +#define TRACKPARSE_SEVERITY_COUNT 2 +#define TRACKPARSE_EDIT_OP_COUNT 6 +#define TRACKPARSE_EDIT_WARNING_CODE_COUNT 3 + +/* The spec name of each value ("remix", "noSeparator", "time-out-of-order"...), or "" for a + * value out of range. trackparse_eol_name returns the line ending itself ("\n", "\r\n", "\r", + * ""), so raw + eol rebuilds a line. */ +TRACKPARSE_API const char *trackparse_mode_name(trackparse_mode v); +TRACKPARSE_API const char *trackparse_role_name(trackparse_role v); +TRACKPARSE_API const char *trackparse_source_name(trackparse_source v); +TRACKPARSE_API const char *trackparse_version_type_name(trackparse_version_type v); +TRACKPARSE_API const char *trackparse_delimiter_name(trackparse_delimiter v); +TRACKPARSE_API const char *trackparse_junk_kind_name(trackparse_junk_kind v); +TRACKPARSE_API const char *trackparse_warning_name(trackparse_warning v); +TRACKPARSE_API const char *trackparse_entry_kind_name(trackparse_entry_kind v); +TRACKPARSE_API const char *trackparse_eol_name(trackparse_eol v); +TRACKPARSE_API const char * +trackparse_tracklist_warning_code_name(trackparse_tracklist_warning_code v); +TRACKPARSE_API const char *trackparse_severity_name(trackparse_severity v); +TRACKPARSE_API const char *trackparse_edit_op_name(trackparse_edit_op v); +TRACKPARSE_API const char *trackparse_edit_warning_code_name(trackparse_edit_warning_code v); + +/* Look a value up by its spec name (len may be TRACKPARSE_NUL_TERMINATED). */ +TRACKPARSE_API bool trackparse_mode_from_name(const char *name, size_t len, trackparse_mode *out); +TRACKPARSE_API bool trackparse_version_type_from_name(const char *name, size_t len, + trackparse_version_type *out); +TRACKPARSE_API bool trackparse_junk_kind_from_name(const char *name, size_t len, + trackparse_junk_kind *out); + +/* ------------------------------------------------------------------------------------------ */ +/* Parsed track (parsed-track.schema.json) */ + +typedef struct trackparse_artist { + trackparse_str name; + trackparse_role role; + /** The text that joined this artist to the previous one (" & ", ", "...); NULL for the first. */ + const trackparse_str *joiner; + trackparse_source source; +} trackparse_artist; + +typedef struct trackparse_version { + trackparse_version_type type; + /** The type's spec name; differs from trackparse_version_type_name(type) only for names that + * options.keywords introduced. */ + trackparse_str type_name; + trackparse_str raw; + const trackparse_artist *artists; + size_t artists_count; + const trackparse_str *modifiers; + size_t modifiers_count; + const trackparse_str *descriptor; + const int *year; + bool unknown_artist; + trackparse_delimiter delimiter; +} trackparse_version; + +typedef struct trackparse_junk { + trackparse_str raw; + trackparse_junk_kind kind; + /** The kind's spec name (see trackparse_version.type_name). */ + trackparse_str kind_name; +} trackparse_junk; + +typedef struct trackparse_flags { + bool explicit_; /**< "explicit" in JSON (explicit is a C++ keyword) */ + bool clean; + bool unknown_artist; + bool unknown_title; +} trackparse_flags; + +typedef struct trackparse_position { + trackparse_str raw; + int number; +} trackparse_position; + +typedef struct trackparse_timestamp { + trackparse_str raw; + int seconds; +} trackparse_timestamp; + +/** The result of trackparse_parse. */ +typedef struct trackparse_track { + trackparse_str input; + trackparse_mode mode; + const trackparse_position *position; + const trackparse_timestamp *timestamp; + const trackparse_artist *artists; + size_t artists_count; + trackparse_str title; + trackparse_str full_title; + const trackparse_version *versions; + size_t versions_count; + const int *year; + trackparse_flags flags; + const trackparse_junk *junk; + size_t junk_count; + const trackparse_warning *warnings; + size_t warnings_count; +} trackparse_track; + +/** A list of artists (the result of trackparse_parse_artists). */ +typedef struct trackparse_artists { + const trackparse_artist *items; + size_t count; +} trackparse_artists; + +/* ------------------------------------------------------------------------------------------ */ +/* Options */ + +typedef struct trackparse_parse_options trackparse_parse_options; +typedef struct trackparse_format_options trackparse_format_options; +typedef struct trackparse_tracklist_options trackparse_tracklist_options; + +TRACKPARSE_API trackparse_parse_options *trackparse_parse_options_new(void); +TRACKPARSE_API void trackparse_parse_options_free(trackparse_parse_options *o); +/* Setters return false only when out of memory (the option is then unchanged). */ +TRACKPARSE_API bool trackparse_parse_options_set_mode(trackparse_parse_options *o, + trackparse_mode mode); +TRACKPARSE_API bool trackparse_parse_options_set_uploader(trackparse_parse_options *o, + const char *s, size_t len); +TRACKPARSE_API bool trackparse_parse_options_add_known_artist(trackparse_parse_options *o, + const char *s, size_t len); +TRACKPARSE_API bool trackparse_parse_options_set_split_and(trackparse_parse_options *o, + trackparse_split_and v); +/* R12 keywords: extra vocabulary. type and kind are spec names, so new names are possible. */ +TRACKPARSE_API bool trackparse_parse_options_add_version_head(trackparse_parse_options *o, + const char *key, size_t key_len, + const char *type, size_t type_len); +TRACKPARSE_API bool trackparse_parse_options_add_descriptor(trackparse_parse_options *o, + const char *s, size_t len); +TRACKPARSE_API bool trackparse_parse_options_add_genre(trackparse_parse_options *o, const char *s, + size_t len); +TRACKPARSE_API bool trackparse_parse_options_add_junk(trackparse_parse_options *o, + const char *phrase, size_t phrase_len, + const char *kind, size_t kind_len); +TRACKPARSE_API bool trackparse_parse_options_add_feat_marker(trackparse_parse_options *o, + const char *s, size_t len); + +TRACKPARSE_API trackparse_format_options *trackparse_format_options_new(void); +TRACKPARSE_API void trackparse_format_options_free(trackparse_format_options *o); +TRACKPARSE_API bool trackparse_format_options_set_feat(trackparse_format_options *o, + trackparse_feat v); +/** The marker written before featured artists; "" is a valid marker. Unset: the input's. */ +TRACKPARSE_API bool trackparse_format_options_set_feat_marker(trackparse_format_options *o, + const char *s, size_t len); +TRACKPARSE_API bool trackparse_format_options_set_joiners(trackparse_format_options *o, + trackparse_joiners v); +TRACKPARSE_API bool trackparse_format_options_set_versions(trackparse_format_options *o, + trackparse_versions v); +TRACKPARSE_API bool trackparse_format_options_set_omit_producers(trackparse_format_options *o, + bool v); +TRACKPARSE_API bool trackparse_format_options_set_position(trackparse_format_options *o, bool v); + +TRACKPARSE_API trackparse_tracklist_options *trackparse_tracklist_options_new(void); +TRACKPARSE_API void trackparse_tracklist_options_free(trackparse_tracklist_options *o); +/** Default for tracklists: TRACKPARSE_MODE_TRACKLIST. */ +TRACKPARSE_API bool trackparse_tracklist_options_set_mode(trackparse_tracklist_options *o, + trackparse_mode mode); +TRACKPARSE_API bool trackparse_tracklist_options_add_known_artist(trackparse_tracklist_options *o, + const char *s, size_t len); +TRACKPARSE_API bool trackparse_tracklist_options_set_split_and(trackparse_tracklist_options *o, + trackparse_split_and v); +TRACKPARSE_API bool trackparse_tracklist_options_add_version_head(trackparse_tracklist_options *o, + const char *key, size_t key_len, + const char *type, + size_t type_len); +TRACKPARSE_API bool trackparse_tracklist_options_add_descriptor(trackparse_tracklist_options *o, + const char *s, size_t len); +TRACKPARSE_API bool trackparse_tracklist_options_add_genre(trackparse_tracklist_options *o, + const char *s, size_t len); +TRACKPARSE_API bool trackparse_tracklist_options_add_junk(trackparse_tracklist_options *o, + const char *phrase, size_t phrase_len, + const char *kind, size_t kind_len); +TRACKPARSE_API bool trackparse_tracklist_options_add_feat_marker(trackparse_tracklist_options *o, + const char *s, size_t len); +/** The audio length in seconds, for time-after-audio-end; 0 is a valid length. Unset: none. */ +TRACKPARSE_API bool trackparse_tracklist_options_set_audio_seconds(trackparse_tracklist_options *o, + double seconds); +TRACKPARSE_API bool trackparse_tracklist_options_add_marker_word(trackparse_tracklist_options *o, + const char *s, size_t len); + +/* ------------------------------------------------------------------------------------------ */ +/* Single tracks */ + +/** R1-R9: parse one track string. NULL only when out of memory. */ +TRACKPARSE_API trackparse_track *trackparse_parse(const char *s, size_t len); +TRACKPARSE_API trackparse_track *trackparse_parse_with(const char *s, size_t len, + const trackparse_parse_options *o); +TRACKPARSE_API void trackparse_track_free(trackparse_track *t); + +/** R10: parse an artist string ("A feat. B & C") into artists. */ +TRACKPARSE_API trackparse_artists *trackparse_parse_artists(const char *s, size_t len); +TRACKPARSE_API trackparse_artists *trackparse_parse_artists_with(const char *s, size_t len, + const trackparse_parse_options *o); +TRACKPARSE_API void trackparse_artists_free(trackparse_artists *a); + +/** A string the caller owns (format, normalize, JSON). */ +typedef struct trackparse_string { + trackparse_str str; +} trackparse_string; +TRACKPARSE_API void trackparse_string_free(trackparse_string *s); + +/** R11: write a parsed track back as "Artists - Title (Versions)". */ +TRACKPARSE_API trackparse_string *trackparse_format(const trackparse_track *t); +TRACKPARSE_API trackparse_string *trackparse_format_with(const trackparse_track *t, + const trackparse_format_options *o); +/** R1: the normalized form of a string. */ +TRACKPARSE_API trackparse_string *trackparse_normalize(const char *s, size_t len); +/** Every artist of a track: the artist side, then each version's, in order. */ +TRACKPARSE_API trackparse_artists *trackparse_all_artists(const trackparse_track *t); + +/** A parser that keeps its options and their tables, for many calls. Immutable, thread-safe. */ +typedef struct trackparse_parser trackparse_parser; +TRACKPARSE_API trackparse_parser *trackparse_parser_new(const trackparse_parse_options *o); +TRACKPARSE_API void trackparse_parser_free(trackparse_parser *p); +TRACKPARSE_API trackparse_track *trackparse_parser_parse(const trackparse_parser *p, const char *s, + size_t len); +TRACKPARSE_API trackparse_artists *trackparse_parser_parse_artists(const trackparse_parser *p, + const char *s, size_t len); + +/* ------------------------------------------------------------------------------------------ */ +/* Tracklists (R13, tracklist.schema.json) */ + +typedef struct trackparse_parts { + trackparse_str lead; + trackparse_str time; + trackparse_str gap; + trackparse_str rest; +} trackparse_parts; + +typedef struct trackparse_tracklist_time { + trackparse_str raw; + double seconds; +} trackparse_tracklist_time; + +typedef struct trackparse_entry { + int line; + trackparse_entry_kind kind; + trackparse_eol eol; + trackparse_str raw; + trackparse_parts parts; + const trackparse_tracklist_time *time; + const trackparse_track *track; + bool layered; +} trackparse_entry; + +typedef struct trackparse_suggestion { + int line; + trackparse_str raw; + double seconds; +} trackparse_suggestion; + +typedef struct trackparse_tracklist_warning { + trackparse_tracklist_warning_code code; + int line; + trackparse_severity severity; + const trackparse_suggestion *suggestion; +} trackparse_tracklist_warning; + +typedef struct trackparse_stats { + int lines; + int tracks; + int markers; + int timed; + const double *first_time; + const double *last_time; +} trackparse_stats; + +typedef struct trackparse_tracklist { + trackparse_str spec_version; + const trackparse_entry *entries; + size_t entries_count; + const trackparse_tracklist_warning *warnings; + size_t warnings_count; + trackparse_stats stats; +} trackparse_tracklist; + +TRACKPARSE_API trackparse_tracklist *trackparse_parse_tracklist(const char *s, size_t len); +TRACKPARSE_API trackparse_tracklist * +trackparse_parse_tracklist_with(const char *s, size_t len, const trackparse_tracklist_options *o); +TRACKPARSE_API void trackparse_tracklist_free(trackparse_tracklist *t); + +/** A list of R13.9 edits, applied in order. */ +typedef struct trackparse_edits trackparse_edits; +TRACKPARSE_API trackparse_edits *trackparse_edits_new(void); +TRACKPARSE_API void trackparse_edits_free(trackparse_edits *e); +/* Each returns false only when out of memory. Lines are 1-based. */ +TRACKPARSE_API bool trackparse_edits_set_time(trackparse_edits *e, long long line, double seconds); +/** Shift every timed line. */ +TRACKPARSE_API bool trackparse_edits_shift(trackparse_edits *e, double seconds); +/** Shift the timed lines from `from` on. */ +TRACKPARSE_API bool trackparse_edits_shift_from(trackparse_edits *e, double seconds, + long long from); +/** Shift the listed lines. */ +TRACKPARSE_API bool trackparse_edits_shift_lines(trackparse_edits *e, double seconds, + const long long *lines, size_t count); +TRACKPARSE_API bool trackparse_edits_sort_by_time(trackparse_edits *e); +TRACKPARSE_API bool trackparse_edits_set_rest(trackparse_edits *e, long long line, const char *rest, + size_t len); +/** Insert text as a new line after `after` (0: at the top). */ +TRACKPARSE_API bool trackparse_edits_insert(trackparse_edits *e, long long after, const char *text, + size_t len); +TRACKPARSE_API bool trackparse_edits_delete(trackparse_edits *e, long long line); + +typedef struct trackparse_edit_warning { + trackparse_edit_warning_code code; + /** The index of the edit in the list (0-based). */ + size_t edit; + /** The line the warning is about, when there is one. */ + const long long *line; +} trackparse_edit_warning; + +typedef struct trackparse_edit_result { + trackparse_str text; + const long long *changed; + size_t changed_count; + const trackparse_edit_warning *warnings; + size_t warnings_count; +} trackparse_edit_result; + +/** R13.9: apply edits to a tracklist text. Lines not named stay byte for byte. */ +TRACKPARSE_API trackparse_edit_result *trackparse_apply_edits(const char *s, size_t len, + const trackparse_edits *e); +TRACKPARSE_API void trackparse_edit_result_free(trackparse_edit_result *r); + +/* ------------------------------------------------------------------------------------------ */ +/* JSON: the bytes JavaScript's JSON.stringify writes for the same result */ + +TRACKPARSE_API trackparse_string *trackparse_track_to_json(const trackparse_track *t); +TRACKPARSE_API trackparse_string *trackparse_artists_to_json(const trackparse_artists *a); +TRACKPARSE_API trackparse_string *trackparse_tracklist_to_json(const trackparse_tracklist *t); +TRACKPARSE_API trackparse_string *trackparse_edit_result_to_json(const trackparse_edit_result *r); + +#ifdef __cplusplus +} +#endif + +#endif /* TRACKPARSE_H */ diff --git a/c/include/trackparse.hpp b/c/include/trackparse.hpp new file mode 100644 index 0000000..493b072 --- /dev/null +++ b/c/include/trackparse.hpp @@ -0,0 +1,1160 @@ +/** + * @file trackparse.hpp + * @brief Header-only C++17 wrapper over the trackparse C API (trackparse.h). + * + * Documentation: https://4matic.github.io/trackparse/ + * + * - Owners (track, artists, tracklist, edit_result, parser and the option builders) are + * move-only and free their C object in the destructor. A moved-from owner must not be read. + * - Views (track_view, artist_view, version_view, entry_view...) borrow from an owner and are + * valid while it lives. Strings are std::string_view, nullable fields std::optional, arrays + * iterable spans (begin/end, size, operator[]). + * - Option builders chain: parse_options{}.mode(mode::youtube).known_artist("Chase & Status"). + * - The only exception thrown is std::bad_alloc, when the library runs out of memory (the C + * functions return NULL). Without exceptions (-fno-exceptions) that calls std::abort(). + */ +#ifndef TRACKPARSE_HPP +#define TRACKPARSE_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "trackparse.h" + +namespace trackparse { + +/* ------------------------------------------------------------------------------------------ */ +/* Version */ + +/** The version of the header (TRACKPARSE_VERSION). */ +inline constexpr std::string_view header_version = TRACKPARSE_VERSION; +/** The version of the linked library (can differ from header_version with a shared library). */ +inline std::string_view library_version() { return trackparse_library_version(); } +/** The spec version the library implements. */ +inline std::string_view spec_version() { return trackparse_spec_version(); } + +namespace detail { + +[[noreturn]] inline void out_of_memory() { +#if defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND) + throw std::bad_alloc(); +#else + std::abort(); +#endif +} + +template T *check(T *p) { + if (p == nullptr) out_of_memory(); + return p; +} + +inline void check(bool ok) { + if (!ok) out_of_memory(); +} + +inline std::string_view sv(const trackparse_str &s) { return std::string_view(s.ptr, s.len); } + +inline std::optional opt(const trackparse_str *s) { + if (s == nullptr) return std::nullopt; + return sv(*s); +} + +template std::optional opt(const T *v) { + if (v == nullptr) return std::nullopt; + return *v; +} + +/* A string the library allocated, copied into a std::string. */ +inline std::string take(trackparse_string *s) { + struct guard { + trackparse_string *s; + ~guard() { trackparse_string_free(s); } + } g{check(s)}; + return std::string(g.s->str.ptr, g.s->str.len); +} + +} // namespace detail + +/* ------------------------------------------------------------------------------------------ */ +/* Enumerations: the values of the C enums, with name() and *_from_name() */ + +enum class mode : int { + auto_ = TRACKPARSE_MODE_AUTO, /**< options only: detect (the default) */ + clean = TRACKPARSE_MODE_CLEAN, + youtube = TRACKPARSE_MODE_YOUTUBE, + filename = TRACKPARSE_MODE_FILENAME, + tracklist = TRACKPARSE_MODE_TRACKLIST +}; + +enum class role : int { + primary = TRACKPARSE_ROLE_PRIMARY, + featured = TRACKPARSE_ROLE_FEATURED, + remixer = TRACKPARSE_ROLE_REMIXER, + producer = TRACKPARSE_ROLE_PRODUCER +}; + +enum class source : int { + artist = TRACKPARSE_SOURCE_ARTIST, + title = TRACKPARSE_SOURCE_TITLE, + version = TRACKPARSE_SOURCE_VERSION +}; + +enum class version_type : int { + remix = TRACKPARSE_VERSION_REMIX, + bootleg = TRACKPARSE_VERSION_BOOTLEG, + vip = TRACKPARSE_VERSION_VIP, + edit = TRACKPARSE_VERSION_EDIT, + flip = TRACKPARSE_VERSION_FLIP, + refix = TRACKPARSE_VERSION_REFIX, + rework = TRACKPARSE_VERSION_REWORK, + mashup = TRACKPARSE_VERSION_MASHUP, + blend = TRACKPARSE_VERSION_BLEND, + dub = TRACKPARSE_VERSION_DUB, + mix = TRACKPARSE_VERSION_MIX, + extended = TRACKPARSE_VERSION_EXTENDED, + radio = TRACKPARSE_VERSION_RADIO, + club = TRACKPARSE_VERSION_CLUB, + original = TRACKPARSE_VERSION_ORIGINAL, + instrumental = TRACKPARSE_VERSION_INSTRUMENTAL, + acapella = TRACKPARSE_VERSION_ACAPELLA, + live = TRACKPARSE_VERSION_LIVE, + acoustic = TRACKPARSE_VERSION_ACOUSTIC, + remaster = TRACKPARSE_VERSION_REMASTER, + demo = TRACKPARSE_VERSION_DEMO, + reprise = TRACKPARSE_VERSION_REPRISE, + cover = TRACKPARSE_VERSION_COVER, + version = TRACKPARSE_VERSION_VERSION, /**< also used for names keywords introduced */ + sped_up = TRACKPARSE_VERSION_SPED_UP, + slowed = TRACKPARSE_VERSION_SLOWED, + nightcore = TRACKPARSE_VERSION_NIGHTCORE +}; + +enum class delimiter : int { + paren = TRACKPARSE_DELIMITER_PAREN, + bracket = TRACKPARSE_DELIMITER_BRACKET, + brace = TRACKPARSE_DELIMITER_BRACE, + dash = TRACKPARSE_DELIMITER_DASH +}; + +enum class junk_kind : int { + video = TRACKPARSE_JUNK_VIDEO, + audio = TRACKPARSE_JUNK_AUDIO, + lyrics = TRACKPARSE_JUNK_LYRICS, + quality = TRACKPARSE_JUNK_QUALITY, + promo = TRACKPARSE_JUNK_PROMO, + platform = TRACKPARSE_JUNK_PLATFORM, + label = TRACKPARSE_JUNK_LABEL, + genre = TRACKPARSE_JUNK_GENRE, + other = TRACKPARSE_JUNK_OTHER /**< also used for names keywords introduced */ +}; + +/** Track warnings. */ +enum class warning : int { + no_separator = TRACKPARSE_WARNING_NO_SEPARATOR, + ambiguous_separator = TRACKPARSE_WARNING_AMBIGUOUS_SEPARATOR, + unspaced_dash_split = TRACKPARSE_WARNING_UNSPACED_DASH_SPLIT, + asymmetric_dash_split = TRACKPARSE_WARNING_ASYMMETRIC_DASH_SPLIT, + by_split = TRACKPARSE_WARNING_BY_SPLIT, + quoted_title_split = TRACKPARSE_WARNING_QUOTED_TITLE_SPLIT, + ambiguous_mix_credit = TRACKPARSE_WARNING_AMBIGUOUS_MIX_CREDIT, + unbalanced_brackets = TRACKPARSE_WARNING_UNBALANCED_BRACKETS +}; + +enum class entry_kind : int { + track = TRACKPARSE_ENTRY_TRACK, + marker = TRACKPARSE_ENTRY_MARKER, + header = TRACKPARSE_ENTRY_HEADER, + link = TRACKPARSE_ENTRY_LINK, + note = TRACKPARSE_ENTRY_NOTE, + blank = TRACKPARSE_ENTRY_BLANK +}; + +enum class eol : int { + lf = TRACKPARSE_EOL_LF, + crlf = TRACKPARSE_EOL_CRLF, + cr = TRACKPARSE_EOL_CR, + none = TRACKPARSE_EOL_NONE +}; + +enum class tracklist_warning_code : int { + time_missing = TRACKPARSE_TL_TIME_MISSING, + time_out_of_order = TRACKPARSE_TL_TIME_OUT_OF_ORDER, + time_duplicate = TRACKPARSE_TL_TIME_DUPLICATE, + no_start_at_zero = TRACKPARSE_TL_NO_START_AT_ZERO, + time_after_audio_end = TRACKPARSE_TL_TIME_AFTER_AUDIO_END, + invalid_time = TRACKPARSE_TL_INVALID_TIME, + position_gap = TRACKPARSE_TL_POSITION_GAP, + position_duplicate = TRACKPARSE_TL_POSITION_DUPLICATE, + line_unparsed = TRACKPARSE_TL_LINE_UNPARSED +}; + +enum class severity : int { + info = TRACKPARSE_SEVERITY_INFO, + warning = TRACKPARSE_SEVERITY_WARNING +}; + +enum class edit_warning_code : int { + edit_invalid = TRACKPARSE_EDIT_WARNING_EDIT_INVALID, + time_clamped = TRACKPARSE_EDIT_WARNING_TIME_CLAMPED, + style_upgraded = TRACKPARSE_EDIT_WARNING_STYLE_UPGRADED +}; + +enum class split_and : int { + auto_ = TRACKPARSE_SPLIT_AND_AUTO, + always = TRACKPARSE_SPLIT_AND_ALWAYS, + never = TRACKPARSE_SPLIT_AND_NEVER +}; + +/** Where format() writes featured artists. */ +enum class feat : int { + source = TRACKPARSE_FEAT_SOURCE, + artist = TRACKPARSE_FEAT_ARTIST, + title = TRACKPARSE_FEAT_TITLE, + omit = TRACKPARSE_FEAT_OMIT +}; + +enum class joiners : int { + original = TRACKPARSE_JOINERS_ORIGINAL, + canonical = TRACKPARSE_JOINERS_CANONICAL +}; + +enum class versions : int { all = TRACKPARSE_VERSIONS_ALL, none = TRACKPARSE_VERSIONS_NONE }; + +/** The spec name of a value ("youtube", "noSeparator", "time-out-of-order", "\r\n"...). */ +inline std::string_view name(trackparse::mode v) { + return trackparse_mode_name(static_cast(v)); +} +inline std::string_view name(trackparse::role v) { + return trackparse_role_name(static_cast(v)); +} +inline std::string_view name(trackparse::source v) { + return trackparse_source_name(static_cast(v)); +} +inline std::string_view name(trackparse::version_type v) { + return trackparse_version_type_name(static_cast(v)); +} +inline std::string_view name(trackparse::delimiter v) { + return trackparse_delimiter_name(static_cast(v)); +} +inline std::string_view name(trackparse::junk_kind v) { + return trackparse_junk_kind_name(static_cast(v)); +} +inline std::string_view name(trackparse::warning v) { + return trackparse_warning_name(static_cast(v)); +} +inline std::string_view name(trackparse::entry_kind v) { + return trackparse_entry_kind_name(static_cast(v)); +} +inline std::string_view name(trackparse::eol v) { + return trackparse_eol_name(static_cast(v)); +} +inline std::string_view name(trackparse::tracklist_warning_code v) { + return trackparse_tracklist_warning_code_name(static_cast(v)); +} +inline std::string_view name(trackparse::severity v) { + return trackparse_severity_name(static_cast(v)); +} +inline std::string_view name(trackparse::edit_warning_code v) { + return trackparse_edit_warning_code_name(static_cast(v)); +} + +/** Look a value up by its spec name. */ +inline std::optional mode_from_name(std::string_view s) { + trackparse_mode v; + if (!trackparse_mode_from_name(s.data(), s.size(), &v)) return std::nullopt; + return static_cast(v); +} +inline std::optional version_type_from_name(std::string_view s) { + trackparse_version_type v; + if (!trackparse_version_type_from_name(s.data(), s.size(), &v)) return std::nullopt; + return static_cast(v); +} +inline std::optional junk_kind_from_name(std::string_view s) { + trackparse_junk_kind v; + if (!trackparse_junk_kind_from_name(s.data(), s.size(), &v)) return std::nullopt; + return static_cast(v); +} + +/* ------------------------------------------------------------------------------------------ */ +/* span: a borrowed array of C items, read through a view type */ + +namespace detail { +struct str_conv { + static std::string_view apply(const trackparse_str &s) { return sv(s); } +}; +template struct enum_conv { + static E apply(const C &v) { return static_cast(v); } +}; +template struct same_conv { + static T apply(const T &v) { return v; } +}; +template struct view_conv { + static V apply(const C &c) { return V(&c); } +}; +} // namespace detail + +/** A read-only array of `count` C items, iterated as values of type V. */ +template > class span { +public: + using value_type = V; + using size_type = std::size_t; + + class iterator { + public: + using iterator_category = std::input_iterator_tag; + using value_type = V; + using difference_type = std::ptrdiff_t; + using pointer = void; + using reference = V; + + iterator() = default; + explicit iterator(const C *p) : p_(p) {} + V operator*() const { return Conv::apply(*p_); } + iterator &operator++() { + ++p_; + return *this; + } + iterator operator++(int) { + iterator r = *this; + ++p_; + return r; + } + friend bool operator==(iterator a, iterator b) { return a.p_ == b.p_; } + friend bool operator!=(iterator a, iterator b) { return a.p_ != b.p_; } + + private: + const C *p_ = nullptr; + }; + + span() = default; + span(const C *items, std::size_t count) : items_(items), count_(items ? count : 0) {} + + iterator begin() const { return iterator(items_); } + iterator end() const { return iterator(items_ + count_); } + std::size_t size() const { return count_; } + bool empty() const { return count_ == 0; } + /** No bounds check, like std::vector::operator[]. */ + V operator[](std::size_t i) const { return Conv::apply(items_[i]); } + V front() const { return Conv::apply(items_[0]); } + V back() const { return Conv::apply(items_[count_ - 1]); } + /** The C array. */ + const C *data() const { return items_; } + +private: + const C *items_ = nullptr; + std::size_t count_ = 0; +}; + +/* ------------------------------------------------------------------------------------------ */ +/* Parsed track views */ + +class artist_view { +public: + explicit artist_view(const trackparse_artist *a) : a_(a) {} + std::string_view name() const { return detail::sv(a_->name); } + trackparse::role role() const { return static_cast(a_->role); } + /** The text that joined this artist to the previous one; nullopt for the first. */ + std::optional joiner() const { return detail::opt(a_->joiner); } + trackparse::source source() const { return static_cast(a_->source); } + const trackparse_artist *c_ptr() const { return a_; } + +private: + const trackparse_artist *a_; +}; + +using artist_span = span; +using string_span = span; + +class version_view { +public: + explicit version_view(const trackparse_version *v) : v_(v) {} + trackparse::version_type type() const { return static_cast(v_->type); } + /** The spec name of the type, also for names options keywords introduced. */ + std::string_view type_name() const { return detail::sv(v_->type_name); } + std::string_view raw() const { return detail::sv(v_->raw); } + artist_span artists() const { return artist_span(v_->artists, v_->artists_count); } + string_span modifiers() const { return string_span(v_->modifiers, v_->modifiers_count); } + std::optional descriptor() const { return detail::opt(v_->descriptor); } + std::optional year() const { return detail::opt(v_->year); } + bool unknown_artist() const { return v_->unknown_artist; } + trackparse::delimiter delimiter() const { + return static_cast(v_->delimiter); + } + const trackparse_version *c_ptr() const { return v_; } + +private: + const trackparse_version *v_; +}; + +class junk_view { +public: + explicit junk_view(const trackparse_junk *j) : j_(j) {} + std::string_view raw() const { return detail::sv(j_->raw); } + trackparse::junk_kind kind() const { return static_cast(j_->kind); } + /** The spec name of the kind, also for names options keywords introduced. */ + std::string_view kind_name() const { return detail::sv(j_->kind_name); } + const trackparse_junk *c_ptr() const { return j_; } + +private: + const trackparse_junk *j_; +}; + +/** The flags of a track. "explicit" is a C++ keyword, hence explicit_(). */ +class flags_view { +public: + explicit flags_view(const trackparse_flags *f) : f_(f) {} + bool explicit_() const { return f_->explicit_; } + bool clean() const { return f_->clean; } + bool unknown_artist() const { return f_->unknown_artist; } + bool unknown_title() const { return f_->unknown_title; } + +private: + const trackparse_flags *f_; +}; + +struct position { + std::string_view raw; + int number; +}; + +struct timestamp { + std::string_view raw; + int seconds; +}; + +using version_span = span; +using junk_span = span; +using warning_span = span>; + +class format_options; +class artists; +class track; + +/** A parsed track, borrowed (from a track, or from a tracklist entry). */ +class track_view { +public: + explicit track_view(const trackparse_track *t) : t_(t) {} + track_view(const track_view &) = default; + track_view &operator=(const track_view &) = default; + /** A view of a temporary track would dangle at once: keep the track in a variable. */ + track_view(track &&) = delete; + std::string_view input() const { return detail::sv(t_->input); } + trackparse::mode mode() const { return static_cast(t_->mode); } + std::optional position() const { + if (t_->position == nullptr) return std::nullopt; + return trackparse::position{detail::sv(t_->position->raw), t_->position->number}; + } + std::optional timestamp() const { + if (t_->timestamp == nullptr) return std::nullopt; + return trackparse::timestamp{detail::sv(t_->timestamp->raw), t_->timestamp->seconds}; + } + artist_span artists() const { return artist_span(t_->artists, t_->artists_count); } + std::string_view title() const { return detail::sv(t_->title); } + std::string_view full_title() const { return detail::sv(t_->full_title); } + version_span versions() const { return version_span(t_->versions, t_->versions_count); } + std::optional year() const { return detail::opt(t_->year); } + flags_view flags() const { return flags_view(&t_->flags); } + junk_span junk() const { return junk_span(t_->junk, t_->junk_count); } + warning_span warnings() const { return warning_span(t_->warnings, t_->warnings_count); } + + /** The JSON.stringify bytes of the track. */ + std::string to_json() const { return detail::take(trackparse_track_to_json(t_)); } + /** R11: "Artists - Title (Versions)". */ + std::string format() const { return detail::take(trackparse_format(t_)); } + std::string format(const format_options &o) const; + /** Every artist: the artist side, then each version's. */ + trackparse::artists all_artists() const; + + const trackparse_track *c_ptr() const { return t_; } + +protected: + const trackparse_track *t_; +}; + +/** The result of parse(): owns the C trackparse_track. Move-only. */ +class track : public track_view { +public: + /** Takes ownership; throws std::bad_alloc on NULL. */ + explicit track(trackparse_track *t) : track_view(detail::check(t)) {} + track(track &&o) noexcept : track_view(o.t_) { o.t_ = nullptr; } + track &operator=(track &&o) noexcept { + if (this != &o) { + trackparse_track_free(const_cast(t_)); + t_ = o.t_; + o.t_ = nullptr; + } + return *this; + } + track(const track &) = delete; + track &operator=(const track &) = delete; + ~track() { trackparse_track_free(const_cast(t_)); } + + /** Gives up ownership: free the result with trackparse_track_free. */ + trackparse_track *release() { + auto p = const_cast(t_); + t_ = nullptr; + return p; + } +}; + +/** A list of artists (parse_artists, all_artists). Move-only. */ +class artists { +public: + explicit artists(trackparse_artists *a) : a_(detail::check(a)) {} + artists(artists &&o) noexcept : a_(o.a_) { o.a_ = nullptr; } + artists &operator=(artists &&o) noexcept { + if (this != &o) { + trackparse_artists_free(a_); + a_ = o.a_; + o.a_ = nullptr; + } + return *this; + } + artists(const artists &) = delete; + artists &operator=(const artists &) = delete; + ~artists() { trackparse_artists_free(a_); } + + artist_span items() const { return artist_span(a_->items, a_->count); } + artist_span::iterator begin() const { return items().begin(); } + artist_span::iterator end() const { return items().end(); } + std::size_t size() const { return a_->count; } + bool empty() const { return a_->count == 0; } + artist_view operator[](std::size_t i) const { return items()[i]; } + std::string to_json() const { return detail::take(trackparse_artists_to_json(a_)); } + const trackparse_artists *c_ptr() const { return a_; } + +private: + trackparse_artists *a_; +}; + +inline trackparse::artists track_view::all_artists() const { + return trackparse::artists(trackparse_all_artists(t_)); +} + +/* ------------------------------------------------------------------------------------------ */ +/* Options (move-only builders; setters chain on lvalues and on temporaries) */ + +/** Options for parse(), parse_artists() and parser (R12). */ +class parse_options { +public: + parse_options() : o_(detail::check(trackparse_parse_options_new())) {} + parse_options(parse_options &&o) noexcept : o_(o.o_) { o.o_ = nullptr; } + parse_options &operator=(parse_options &&o) noexcept { + if (this != &o) { + trackparse_parse_options_free(o_); + o_ = o.o_; + o.o_ = nullptr; + } + return *this; + } + parse_options(const parse_options &) = delete; + parse_options &operator=(const parse_options &) = delete; + ~parse_options() { trackparse_parse_options_free(o_); } + + parse_options &mode(trackparse::mode v) & { + detail::check(trackparse_parse_options_set_mode(o_, static_cast(v))); + return *this; + } + parse_options &&mode(trackparse::mode v) && { return std::move(mode(v)); } + + parse_options &uploader(std::string_view s) & { + detail::check(trackparse_parse_options_set_uploader(o_, s.data(), s.size())); + return *this; + } + parse_options &&uploader(std::string_view s) && { return std::move(uploader(s)); } + + parse_options &known_artist(std::string_view s) & { + detail::check(trackparse_parse_options_add_known_artist(o_, s.data(), s.size())); + return *this; + } + parse_options &&known_artist(std::string_view s) && { return std::move(known_artist(s)); } + + /** Adds every name of a container of strings. */ + template parse_options &known_artists(const Names &names) & { + for (const auto &n : names) known_artist(std::string_view(n)); + return *this; + } + template parse_options &&known_artists(const Names &names) && { + return std::move(known_artists(names)); + } + parse_options &known_artists(std::initializer_list names) & { + for (auto n : names) known_artist(n); + return *this; + } + parse_options &&known_artists(std::initializer_list names) && { + return std::move(known_artists(names)); + } + + parse_options &split_and(trackparse::split_and v) & { + detail::check(trackparse_parse_options_set_split_and(o_, static_cast(v))); + return *this; + } + parse_options &&split_and(trackparse::split_and v) && { return std::move(split_and(v)); } + + /** keywords.versionHeads: `key` names a version of `type` (a spec name; new names allowed). */ + parse_options &version_head(std::string_view key, std::string_view type) & { + detail::check(trackparse_parse_options_add_version_head(o_, key.data(), key.size(), type.data(), + type.size())); + return *this; + } + parse_options &&version_head(std::string_view key, std::string_view type) && { + return std::move(version_head(key, type)); + } + parse_options &version_head(std::string_view key, trackparse::version_type type) & { + return version_head(key, trackparse::name(type)); + } + parse_options &&version_head(std::string_view key, trackparse::version_type type) && { + return std::move(version_head(key, type)); + } + + parse_options &descriptor(std::string_view s) & { + detail::check(trackparse_parse_options_add_descriptor(o_, s.data(), s.size())); + return *this; + } + parse_options &&descriptor(std::string_view s) && { return std::move(descriptor(s)); } + + parse_options &genre(std::string_view s) & { + detail::check(trackparse_parse_options_add_genre(o_, s.data(), s.size())); + return *this; + } + parse_options &&genre(std::string_view s) && { return std::move(genre(s)); } + + /** keywords.junk: `phrase` is junk of `kind` (a spec name; new names allowed). */ + parse_options &junk(std::string_view phrase, std::string_view kind) & { + detail::check(trackparse_parse_options_add_junk(o_, phrase.data(), phrase.size(), kind.data(), + kind.size())); + return *this; + } + parse_options &&junk(std::string_view phrase, std::string_view kind) && { + return std::move(junk(phrase, kind)); + } + parse_options &junk(std::string_view phrase, trackparse::junk_kind kind) & { + return junk(phrase, trackparse::name(kind)); + } + parse_options &&junk(std::string_view phrase, trackparse::junk_kind kind) && { + return std::move(junk(phrase, kind)); + } + + parse_options &feat_marker(std::string_view s) & { + detail::check(trackparse_parse_options_add_feat_marker(o_, s.data(), s.size())); + return *this; + } + parse_options &&feat_marker(std::string_view s) && { return std::move(feat_marker(s)); } + + const trackparse_parse_options *c_ptr() const { return o_; } + +private: + trackparse_parse_options *o_; +}; + +/** Options for format() (R11). */ +class format_options { +public: + format_options() : o_(detail::check(trackparse_format_options_new())) {} + format_options(format_options &&o) noexcept : o_(o.o_) { o.o_ = nullptr; } + format_options &operator=(format_options &&o) noexcept { + if (this != &o) { + trackparse_format_options_free(o_); + o_ = o.o_; + o.o_ = nullptr; + } + return *this; + } + format_options(const format_options &) = delete; + format_options &operator=(const format_options &) = delete; + ~format_options() { trackparse_format_options_free(o_); } + + format_options &feat(trackparse::feat v) & { + detail::check(trackparse_format_options_set_feat(o_, static_cast(v))); + return *this; + } + format_options &&feat(trackparse::feat v) && { return std::move(feat(v)); } + + /** The marker written before featured artists ("" is a valid marker). */ + format_options &feat_marker(std::string_view s) & { + detail::check(trackparse_format_options_set_feat_marker(o_, s.data(), s.size())); + return *this; + } + format_options &&feat_marker(std::string_view s) && { return std::move(feat_marker(s)); } + + format_options &joiners(trackparse::joiners v) & { + detail::check(trackparse_format_options_set_joiners(o_, static_cast(v))); + return *this; + } + format_options &&joiners(trackparse::joiners v) && { return std::move(joiners(v)); } + + format_options &versions(trackparse::versions v) & { + detail::check(trackparse_format_options_set_versions(o_, static_cast(v))); + return *this; + } + format_options &&versions(trackparse::versions v) && { return std::move(versions(v)); } + + format_options &omit_producers(bool v) & { + detail::check(trackparse_format_options_set_omit_producers(o_, v)); + return *this; + } + format_options &&omit_producers(bool v) && { return std::move(omit_producers(v)); } + + format_options &position(bool v) & { + detail::check(trackparse_format_options_set_position(o_, v)); + return *this; + } + format_options &&position(bool v) && { return std::move(position(v)); } + + const trackparse_format_options *c_ptr() const { return o_; } + +private: + trackparse_format_options *o_; +}; + +inline std::string track_view::format(const format_options &o) const { + return detail::take(trackparse_format_with(t_, o.c_ptr())); +} + +/** Options for parse_tracklist() (R13.10). */ +class tracklist_options { +public: + tracklist_options() : o_(detail::check(trackparse_tracklist_options_new())) {} + tracklist_options(tracklist_options &&o) noexcept : o_(o.o_) { o.o_ = nullptr; } + tracklist_options &operator=(tracklist_options &&o) noexcept { + if (this != &o) { + trackparse_tracklist_options_free(o_); + o_ = o.o_; + o.o_ = nullptr; + } + return *this; + } + tracklist_options(const tracklist_options &) = delete; + tracklist_options &operator=(const tracklist_options &) = delete; + ~tracklist_options() { trackparse_tracklist_options_free(o_); } + + /** Default for tracklists: mode::tracklist. */ + tracklist_options &mode(trackparse::mode v) & { + detail::check(trackparse_tracklist_options_set_mode(o_, static_cast(v))); + return *this; + } + tracklist_options &&mode(trackparse::mode v) && { return std::move(mode(v)); } + + tracklist_options &known_artist(std::string_view s) & { + detail::check(trackparse_tracklist_options_add_known_artist(o_, s.data(), s.size())); + return *this; + } + tracklist_options &&known_artist(std::string_view s) && { return std::move(known_artist(s)); } + + template tracklist_options &known_artists(const Names &names) & { + for (const auto &n : names) known_artist(std::string_view(n)); + return *this; + } + template tracklist_options &&known_artists(const Names &names) && { + return std::move(known_artists(names)); + } + tracklist_options &known_artists(std::initializer_list names) & { + for (auto n : names) known_artist(n); + return *this; + } + tracklist_options &&known_artists(std::initializer_list names) && { + return std::move(known_artists(names)); + } + + tracklist_options &split_and(trackparse::split_and v) & { + detail::check( + trackparse_tracklist_options_set_split_and(o_, static_cast(v))); + return *this; + } + tracklist_options &&split_and(trackparse::split_and v) && { return std::move(split_and(v)); } + + tracklist_options &version_head(std::string_view key, std::string_view type) & { + detail::check(trackparse_tracklist_options_add_version_head(o_, key.data(), key.size(), + type.data(), type.size())); + return *this; + } + tracklist_options &&version_head(std::string_view key, std::string_view type) && { + return std::move(version_head(key, type)); + } + tracklist_options &version_head(std::string_view key, trackparse::version_type type) & { + return version_head(key, trackparse::name(type)); + } + tracklist_options &&version_head(std::string_view key, trackparse::version_type type) && { + return std::move(version_head(key, type)); + } + + tracklist_options &descriptor(std::string_view s) & { + detail::check(trackparse_tracklist_options_add_descriptor(o_, s.data(), s.size())); + return *this; + } + tracklist_options &&descriptor(std::string_view s) && { return std::move(descriptor(s)); } + + tracklist_options &genre(std::string_view s) & { + detail::check(trackparse_tracklist_options_add_genre(o_, s.data(), s.size())); + return *this; + } + tracklist_options &&genre(std::string_view s) && { return std::move(genre(s)); } + + tracklist_options &junk(std::string_view phrase, std::string_view kind) & { + detail::check(trackparse_tracklist_options_add_junk(o_, phrase.data(), phrase.size(), + kind.data(), kind.size())); + return *this; + } + tracklist_options &&junk(std::string_view phrase, std::string_view kind) && { + return std::move(junk(phrase, kind)); + } + tracklist_options &junk(std::string_view phrase, trackparse::junk_kind kind) & { + return junk(phrase, trackparse::name(kind)); + } + tracklist_options &&junk(std::string_view phrase, trackparse::junk_kind kind) && { + return std::move(junk(phrase, kind)); + } + + tracklist_options &feat_marker(std::string_view s) & { + detail::check(trackparse_tracklist_options_add_feat_marker(o_, s.data(), s.size())); + return *this; + } + tracklist_options &&feat_marker(std::string_view s) && { return std::move(feat_marker(s)); } + + /** The audio length in seconds, for time-after-audio-end (0 is a valid length). */ + tracklist_options &audio_seconds(double v) & { + detail::check(trackparse_tracklist_options_set_audio_seconds(o_, v)); + return *this; + } + tracklist_options &&audio_seconds(double v) && { return std::move(audio_seconds(v)); } + + tracklist_options &marker_word(std::string_view s) & { + detail::check(trackparse_tracklist_options_add_marker_word(o_, s.data(), s.size())); + return *this; + } + tracklist_options &&marker_word(std::string_view s) && { return std::move(marker_word(s)); } + + const trackparse_tracklist_options *c_ptr() const { return o_; } + +private: + trackparse_tracklist_options *o_; +}; + +/* ------------------------------------------------------------------------------------------ */ +/* Single tracks */ + +/** R1-R9: parse one track string. */ +inline track parse(std::string_view s) { return track(trackparse_parse(s.data(), s.size())); } +inline track parse(std::string_view s, const parse_options &o) { + return track(trackparse_parse_with(s.data(), s.size(), o.c_ptr())); +} + +/** R10: parse an artist string ("A feat. B & C"). */ +inline artists parse_artists(std::string_view s) { + return artists(trackparse_parse_artists(s.data(), s.size())); +} +inline artists parse_artists(std::string_view s, const parse_options &o) { + return artists(trackparse_parse_artists_with(s.data(), s.size(), o.c_ptr())); +} + +/** R11: write a parsed track back as "Artists - Title (Versions)". */ +inline std::string format(const track_view &t) { return t.format(); } +inline std::string format(const track_view &t, const format_options &o) { return t.format(o); } + +/** R1: the normalized form of a string. */ +inline std::string normalize(std::string_view s) { + return detail::take(trackparse_normalize(s.data(), s.size())); +} + +/** Every artist of a track: the artist side, then each version's, in order. */ +inline artists all_artists(const track_view &t) { return t.all_artists(); } + +/** A parser that keeps its options and compiled tables, for many calls. Immutable and safe to + * share between threads. Move-only. */ +class parser { +public: + /** A parser with the default options. */ + parser() : p_(detail::check(trackparse_parser_new(nullptr))) {} + explicit parser(const parse_options &o) : p_(detail::check(trackparse_parser_new(o.c_ptr()))) {} + parser(parser &&o) noexcept : p_(o.p_) { o.p_ = nullptr; } + parser &operator=(parser &&o) noexcept { + if (this != &o) { + trackparse_parser_free(p_); + p_ = o.p_; + o.p_ = nullptr; + } + return *this; + } + parser(const parser &) = delete; + parser &operator=(const parser &) = delete; + ~parser() { trackparse_parser_free(p_); } + + track parse(std::string_view s) const { + return track(trackparse_parser_parse(p_, s.data(), s.size())); + } + trackparse::artists parse_artists(std::string_view s) const { + return trackparse::artists(trackparse_parser_parse_artists(p_, s.data(), s.size())); + } + const trackparse_parser *c_ptr() const { return p_; } + +private: + trackparse_parser *p_; +}; + +/* ------------------------------------------------------------------------------------------ */ +/* Tracklists (R13) */ + +struct parts { + std::string_view lead; + std::string_view time; + std::string_view gap; + std::string_view rest; +}; + +struct tracklist_time { + std::string_view raw; + double seconds; +}; + +struct suggestion { + int line; + std::string_view raw; + double seconds; +}; + +class entry_view { +public: + explicit entry_view(const trackparse_entry *e) : e_(e) {} + int line() const { return e_->line; } + entry_kind kind() const { return static_cast(e_->kind); } + trackparse::eol eol() const { return static_cast(e_->eol); } + std::string_view raw() const { return detail::sv(e_->raw); } + trackparse::parts parts() const { + return trackparse::parts{detail::sv(e_->parts.lead), detail::sv(e_->parts.time), + detail::sv(e_->parts.gap), detail::sv(e_->parts.rest)}; + } + std::optional time() const { + if (e_->time == nullptr) return std::nullopt; + return tracklist_time{detail::sv(e_->time->raw), e_->time->seconds}; + } + std::optional track() const { + if (e_->track == nullptr) return std::nullopt; + return track_view(e_->track); + } + bool layered() const { return e_->layered; } + const trackparse_entry *c_ptr() const { return e_; } + +private: + const trackparse_entry *e_; +}; + +class tracklist_warning_view { +public: + explicit tracklist_warning_view(const trackparse_tracklist_warning *w) : w_(w) {} + tracklist_warning_code code() const { return static_cast(w_->code); } + int line() const { return w_->line; } + trackparse::severity severity() const { return static_cast(w_->severity); } + std::optional suggestion() const { + if (w_->suggestion == nullptr) return std::nullopt; + return trackparse::suggestion{w_->suggestion->line, detail::sv(w_->suggestion->raw), + w_->suggestion->seconds}; + } + const trackparse_tracklist_warning *c_ptr() const { return w_; } + +private: + const trackparse_tracklist_warning *w_; +}; + +struct stats { + int lines; + int tracks; + int markers; + int timed; + std::optional first_time; + std::optional last_time; +}; + +using entry_span = span; +using tracklist_warning_span = span; + +/** The result of parse_tracklist(). Move-only. */ +class tracklist { +public: + explicit tracklist(trackparse_tracklist *t) : t_(detail::check(t)) {} + tracklist(tracklist &&o) noexcept : t_(o.t_) { o.t_ = nullptr; } + tracklist &operator=(tracklist &&o) noexcept { + if (this != &o) { + trackparse_tracklist_free(t_); + t_ = o.t_; + o.t_ = nullptr; + } + return *this; + } + tracklist(const tracklist &) = delete; + tracklist &operator=(const tracklist &) = delete; + ~tracklist() { trackparse_tracklist_free(t_); } + + std::string_view spec_version() const { return detail::sv(t_->spec_version); } + entry_span entries() const { return entry_span(t_->entries, t_->entries_count); } + tracklist_warning_span warnings() const { + return tracklist_warning_span(t_->warnings, t_->warnings_count); + } + trackparse::stats stats() const { + const trackparse_stats &s = t_->stats; + return trackparse::stats{ + s.lines, s.tracks, s.markers, s.timed, detail::opt(s.first_time), detail::opt(s.last_time)}; + } + std::string to_json() const { return detail::take(trackparse_tracklist_to_json(t_)); } + const trackparse_tracklist *c_ptr() const { return t_; } + +private: + trackparse_tracklist *t_; +}; + +inline tracklist parse_tracklist(std::string_view s) { + return tracklist(trackparse_parse_tracklist(s.data(), s.size())); +} +inline tracklist parse_tracklist(std::string_view s, const tracklist_options &o) { + return tracklist(trackparse_parse_tracklist_with(s.data(), s.size(), o.c_ptr())); +} + +/** A list of R13.9 edits, applied in order. Lines are 1-based. Move-only. */ +class edits { +public: + edits() : e_(detail::check(trackparse_edits_new())) {} + edits(edits &&o) noexcept : e_(o.e_) { o.e_ = nullptr; } + edits &operator=(edits &&o) noexcept { + if (this != &o) { + trackparse_edits_free(e_); + e_ = o.e_; + o.e_ = nullptr; + } + return *this; + } + edits(const edits &) = delete; + edits &operator=(const edits &) = delete; + ~edits() { trackparse_edits_free(e_); } + + edits &set_time(long long line, double seconds) & { + detail::check(trackparse_edits_set_time(e_, line, seconds)); + return *this; + } + edits &&set_time(long long line, double seconds) && { return std::move(set_time(line, seconds)); } + + /** Shift every timed line. */ + edits &shift(double seconds) & { + detail::check(trackparse_edits_shift(e_, seconds)); + return *this; + } + edits &&shift(double seconds) && { return std::move(shift(seconds)); } + + /** Shift the timed lines from `from` on. */ + edits &shift_from(double seconds, long long from) & { + detail::check(trackparse_edits_shift_from(e_, seconds, from)); + return *this; + } + edits &&shift_from(double seconds, long long from) && { + return std::move(shift_from(seconds, from)); + } + + /** Shift the listed lines. */ + edits &shift_lines(double seconds, const long long *lines, std::size_t count) & { + detail::check(trackparse_edits_shift_lines(e_, seconds, lines, count)); + return *this; + } + edits &&shift_lines(double seconds, const long long *lines, std::size_t count) && { + return std::move(shift_lines(seconds, lines, count)); + } + edits &shift_lines(double seconds, std::initializer_list lines) & { + return shift_lines(seconds, lines.begin(), lines.size()); + } + edits &&shift_lines(double seconds, std::initializer_list lines) && { + return std::move(shift_lines(seconds, lines)); + } + + edits &sort_by_time() & { + detail::check(trackparse_edits_sort_by_time(e_)); + return *this; + } + edits &&sort_by_time() && { return std::move(sort_by_time()); } + + edits &set_rest(long long line, std::string_view rest) & { + detail::check(trackparse_edits_set_rest(e_, line, rest.data(), rest.size())); + return *this; + } + edits &&set_rest(long long line, std::string_view rest) && { + return std::move(set_rest(line, rest)); + } + + /** Insert `text` as a new line after `after` (0: at the top). */ + edits &insert(long long after, std::string_view text) & { + detail::check(trackparse_edits_insert(e_, after, text.data(), text.size())); + return *this; + } + edits &&insert(long long after, std::string_view text) && { + return std::move(insert(after, text)); + } + + /** The delete edit ("delete" is a C++ keyword). */ + edits &delete_line(long long line) & { + detail::check(trackparse_edits_delete(e_, line)); + return *this; + } + edits &&delete_line(long long line) && { return std::move(delete_line(line)); } + + const trackparse_edits *c_ptr() const { return e_; } + +private: + trackparse_edits *e_; +}; + +class edit_warning_view { +public: + explicit edit_warning_view(const trackparse_edit_warning *w) : w_(w) {} + edit_warning_code code() const { return static_cast(w_->code); } + /** The index of the edit in the list (0-based). */ + std::size_t edit() const { return w_->edit; } + std::optional line() const { return detail::opt(w_->line); } + const trackparse_edit_warning *c_ptr() const { return w_; } + +private: + const trackparse_edit_warning *w_; +}; + +using line_span = span>; +using edit_warning_span = span; + +/** The result of apply_edits(). Move-only. */ +class edit_result { +public: + explicit edit_result(trackparse_edit_result *r) : r_(detail::check(r)) {} + edit_result(edit_result &&o) noexcept : r_(o.r_) { o.r_ = nullptr; } + edit_result &operator=(edit_result &&o) noexcept { + if (this != &o) { + trackparse_edit_result_free(r_); + r_ = o.r_; + o.r_ = nullptr; + } + return *this; + } + edit_result(const edit_result &) = delete; + edit_result &operator=(const edit_result &) = delete; + ~edit_result() { trackparse_edit_result_free(r_); } + + std::string_view text() const { return detail::sv(r_->text); } + /** The lines that changed, in the new text. */ + line_span changed() const { return line_span(r_->changed, r_->changed_count); } + edit_warning_span warnings() const { return edit_warning_span(r_->warnings, r_->warnings_count); } + std::string to_json() const { return detail::take(trackparse_edit_result_to_json(r_)); } + const trackparse_edit_result *c_ptr() const { return r_; } + +private: + trackparse_edit_result *r_; +}; + +/** R13.9: apply edits to a tracklist text. Lines not named stay byte for byte. */ +inline edit_result apply_edits(std::string_view s, const edits &e) { + return edit_result(trackparse_apply_edits(s.data(), s.size(), e.c_ptr())); +} + +} // namespace trackparse + +#endif /* TRACKPARSE_HPP */ diff --git a/c/scripts/amalgamate.mjs b/c/scripts/amalgamate.mjs new file mode 100644 index 0000000..c6294f5 --- /dev/null +++ b/c/scripts/amalgamate.mjs @@ -0,0 +1,269 @@ +#!/usr/bin/env node +// amalgamate.mjs: writes the single-file distribution of the C library (sqlite style). +// +// node c/scripts/amalgamate.mjs [--out DIR] (default: c/dist) +// +// DIR/trackparse.c every c/src/*.c and the internal headers they include, in dependency order, +// in one translation unit with TRACKPARSE_AMALGAMATION defined, so every +// internal function and table (TP_PRIVATE, TP_PRIVATE_DATA) is static and no +// symbol but the public trackparse_* API leaves the object file. +// DIR/trackparse.h a copy of c/include/trackparse.h +// DIR/trackparse.hpp a copy of c/include/trackparse.hpp (when it exists) +// +// wire/ (the JSON door) is not part of it. Node is needed to write the amalgamation, never to +// build it: the release tarball ships dist/trackparse.c and CMake uses it when present. +// +// Checks, each a failure (exit 1) with a message naming the files: +// - every file-scope name a .c file keeps to itself (static functions and variables, typedef +// names, struct/union/enum tags) is defined in one file only, since the amalgamation puts +// them all in one scope; +// - every `#include "..."` resolves to a file under c/src (or the public header). +// Macros a .c file defines are #undef'd at the end of that file in the amalgamation, so they +// cannot leak into the next one. + +import { + copyFileSync, + existsSync, + mkdirSync, + readdirSync, + readFileSync, + writeFileSync, +} from "node:fs"; +import { dirname, join, resolve } from "node:path"; +import { fileURLToPath } from "node:url"; + +const here = dirname(fileURLToPath(import.meta.url)); +const cDir = resolve(here, ".."); +const srcDir = join(cDir, "src"); +const includeDir = join(cDir, "include"); + +let outDir = join(cDir, "dist"); +const args = process.argv.slice(2); +for (let i = 0; i < args.length; i++) { + if (args[i] === "--out" && i + 1 < args.length) outDir = resolve(args[++i]); + else if (args[i].startsWith("--out=")) outDir = resolve(args[i].slice(6)); + else { + console.error(`amalgamate.mjs: unknown argument ${args[i]}\nusage: amalgamate.mjs [--out DIR]`); + process.exit(2); + } +} + +const problems = []; +const read = (p) => readFileSync(p, "utf8").replace(/\r\n/g, "\n"); +const includeRe = /^\s*#\s*include\s+"([^"]+)"\s*$/; + +// The order of the .c files does not matter for correctness (every shared declaration is in a +// header that comes first), so it is alphabetical, except rt.c goes last: it includes +// on Windows, whose macros must not reach the pipeline files. +const cFiles = readdirSync(srcDir) + .filter((f) => f.endsWith(".c")) + .sort((a, b) => (a === "rt.c") - (b === "rt.c") || (a < b ? -1 : a > b ? 1 : 0)); + +// --------------------------------------------------------------------------------------------- +// Headers: inlined once each, at their first include, depth first (so a header's own includes +// come before it). + +const emitted = new Set(); +const headerMacros = new Set(); +const out = []; + +function emitHeader(name, from) { + if (name === "trackparse.h") return; // the public header is included once, at the top + if (emitted.has(name)) return; + const path = join(srcDir, name); + if (!existsSync(path)) { + problems.push(`${from}: #include "${name}" is not a file in c/src`); + return; + } + emitted.add(name); + const lines = read(path).split("\n"); + if (lines.at(-1) === "") lines.pop(); + for (const line of lines) { + const d = /^\s*#\s*define\s+([A-Za-z_]\w*)/.exec(line); + if (d) headerMacros.add(d[1]); + } + const body = []; + for (const line of lines) { + const m = includeRe.exec(line); + if (m) { + // Nested headers go before this one (the recursion appends them to `out` before this + // header's body); leave a marker where the include was. + emitHeader(m[1], name); + body.push(`/* #include "${m[1]}" (inlined above) */`); + } else { + body.push(line); + } + } + out.push(`/* ${"=".repeat(88)} */`, `/* src/${name} */`, "", ...body, ""); +} + +// --------------------------------------------------------------------------------------------- +// File-local names of each .c file, for the duplicate check. + +// Removes comments and string/char literals (keeping line breaks), so the scan below sees code. +function stripCode(text) { + let r = ""; + let i = 0; + while (i < text.length) { + const c = text[i]; + const n = text[i + 1]; + if (c === "/" && n === "*") { + const end = text.indexOf("*/", i + 2); + const stop = end < 0 ? text.length : end + 2; + r += text.slice(i, stop).replace(/[^\n]/g, " "); + i = stop; + } else if (c === "/" && n === "/") { + while (i < text.length && text[i] !== "\n") i++; + } else if (c === '"' || c === "'") { + r += c; + i++; + while (i < text.length && text[i] !== c && text[i] !== "\n") { + if (text[i] === "\\") i++; + i++; + } + r += c; + i++; + } else { + r += c; + i++; + } + } + return r; +} + +function localNames(text) { + const code = stripCode(text); + const names = new Set(); + // File-scope statics start at column 0. Take everything up to the first "(", "[", "=", ";" or + // "{" (joining continuation lines), and the last identifier before it is the name. + const lines = code.split("\n"); + for (let i = 0; i < lines.length; i++) { + if (!/^static\b/.test(lines[i])) continue; + let decl = lines[i]; + for (let j = i + 1; !/[([=;{]/.test(decl) && j < lines.length; j++) decl += ` ${lines[j]}`; + const head = decl.split(/[([=;{]/)[0]; + // A function pointer variable: static T (*name)(...) + const fp = /^static[^(]*$/.test(head) && /\(\s*\*\s*([A-Za-z_]\w*)\s*\)/.exec(decl); + const ids = head.match(/[A-Za-z_]\w*/g) || []; + const name = fp && decl.indexOf("(*") === head.length ? fp[1] : ids.at(-1); + if (name && name !== "static") names.add(name); + } + // Tags and typedef names. + for (const m of code.matchAll(/^(?:typedef\s+)?(?:struct|union|enum)\s+([A-Za-z_]\w*)\s*\{/gm)) { + names.add(`tag ${m[1]}`); + } + // typedef ... ; at brace depth 0: the name is the function pointer's or the last identifier + // outside the braces. + for (const m of code.matchAll(/^typedef\b/gm)) { + let depth = 0; + let outside = ""; + let i = m.index + 7; + for (; i < code.length; i++) { + const c = code[i]; + if (c === "{") depth++; + else if (c === "}") depth--; + else if (c === ";" && depth === 0) break; + else if (depth === 0) outside += c; + } + const fp = /\(\s*\*\s*([A-Za-z_]\w*)\s*\)/.exec(outside); + const ids = fp ? [fp[1]] : outside.replace(/\([^)]*\)/g, " ").match(/[A-Za-z_]\w*/g) || []; + if (ids.length) names.add(ids.at(-1)); + } + return names; +} + +function definedMacros(text) { + const names = []; + for (const line of text.split("\n")) { + const d = /^\s*#\s*define\s+([A-Za-z_]\w*)/.exec(line); + if (d && !names.includes(d[1])) names.push(d[1]); + } + return names; +} + +// --------------------------------------------------------------------------------------------- + +// The library version, from the public header (c/ alone, as in the release tarball, has no spec/). +const publicHeader = read(join(includeDir, "trackparse.h")); +const versionMatch = /#define TRACKPARSE_VERSION "([^"]+)"/.exec(publicHeader); +if (!versionMatch) problems.push("include/trackparse.h: no TRACKPARSE_VERSION"); +const version = versionMatch ? versionMatch[1] : "?"; +const header = [ + "/* trackparse.c: the trackparse C library in one file (the amalgamation).", + ` * Version ${version}. https://4matic.github.io/trackparse/`, + " *", + " * Code generated by c/scripts/amalgamate.mjs from c/src. DO NOT EDIT: change c/src and", + " * regenerate.", + " *", + " * Use: compile this file with your program, next to trackparse.h (C11; on GCC and Clang also", + " * -ffp-contract=off, on MSVC /fp:precise /utf-8). Define TRACKPARSE_STATIC (or", + " * TRACKPARSE_AMALGAMATION) for every file that includes trackparse.h, or at least on Windows,", + " * where the header otherwise declares the functions as DLL imports. To build a shared library", + " * from this file define TRACKPARSE_BUILDING instead and compile with -fvisibility=hidden: only", + " * the trackparse_* functions are exported.", + " *", + " * Every internal function and table is static here (TP_PRIVATE). Link with -lm and, outside", + " * Windows, -pthread. */", + "", + "/* Not building a library: the API needs no import or export decoration. */", + "#if !defined(TRACKPARSE_BUILDING) && !defined(TRACKPARSE_STATIC)", + "#define TRACKPARSE_STATIC", + "#endif", + "/* The public header first, so TRACKPARSE_API keeps its library meaning (export when building", + " * a shared library); then TRACKPARSE_AMALGAMATION makes the internals static (rt.h). */", + '#include "trackparse.h"', + "#ifndef TRACKPARSE_AMALGAMATION", + "#define TRACKPARSE_AMALGAMATION 1", + "#endif", + "", +]; +out.push(...header); + +const owners = new Map(); // name -> first file +for (const file of cFiles) { + const text = read(join(srcDir, file)); + for (const name of localNames(text)) { + if (owners.has(name)) { + problems.push( + `file-local name "${name.replace(/^tag /, "struct/enum tag ")}" is defined in both ` + + `src/${owners.get(name)} and src/${file}: rename one (the amalgamation is one scope)`, + ); + } else { + owners.set(name, file); + } + } + const lines = text.split("\n"); + if (lines.at(-1) === "") lines.pop(); + const body = []; + for (const line of lines) { + const m = includeRe.exec(line); + if (m) { + if (m[1] !== "trackparse.h") emitHeader(m[1], file); + body.push(`/* #include "${m[1]}" (inlined above) */`); + } else { + body.push(line); + } + } + const undefs = definedMacros(text) + .filter((n) => !headerMacros.has(n)) + .map((n) => `#undef ${n}`); + // Headers this file pulled in are already in `out`; its body follows them. + out.push(`/* ${"=".repeat(88)} */`, `/* src/${file} */`, "", ...body, ""); + if (undefs.length) out.push(`/* end of src/${file}: its macros stay local */`, ...undefs, ""); +} + +if (problems.length) { + console.error(`amalgamate.mjs: ${problems.length} problem(s):`); + for (const p of problems) console.error(` ${p}`); + process.exit(1); +} + +mkdirSync(outDir, { recursive: true }); +writeFileSync(join(outDir, "trackparse.c"), `${out.join("\n")}\n`); +copyFileSync(join(includeDir, "trackparse.h"), join(outDir, "trackparse.h")); +const hpp = join(includeDir, "trackparse.hpp"); +if (existsSync(hpp)) copyFileSync(hpp, join(outDir, "trackparse.hpp")); +console.log( + `amalgamate.mjs: ${join(outDir, "trackparse.c")} (${cFiles.length} source files, ` + + `${emitted.size} headers)`, +); diff --git a/c/scripts/c_lit.mjs b/c/scripts/c_lit.mjs new file mode 100644 index 0000000..945f66f --- /dev/null +++ b/c/scripts/c_lit.mjs @@ -0,0 +1,79 @@ +// Helpers shared by the C code generators (gen_data.mjs, gen_unicode.mjs). + +/** The UTF-8 bytes of a string (or of an array of code points). */ +export function utf8(s) { + const text = Array.isArray(s) ? String.fromCodePoint(...s) : s; + return [...Buffer.from(text, "utf8")]; +} + +const isHex = (b) => (b >= 0x30 && b <= 0x39) || (b >= 0x41 && b <= 0x46) || (b >= 0x61 && b <= 0x66); + +/** + * A C string literal of the UTF-8 bytes of s, ASCII only: printable ASCII as is, everything else + * as \xNN (MSVC reads sources in the system code page). A hex escape followed by a hex digit is + * split into two literals ("\xc3" "a"), since C hex escapes take every hex digit that follows. + * '?' is escaped so no trigraph can form (-std=c11 reads trigraphs). + */ +export function cStr(s) { + const bytes = utf8(s); + let out = '"'; + let afterHex = false; + for (const b of bytes) { + if (b === 0x22 || b === 0x5c || b === 0x3f) { + out += `\\${String.fromCharCode(b)}`; + afterHex = false; + } else if (b >= 0x20 && b < 0x7f) { + if (afterHex && isHex(b)) out += '" "'; + out += String.fromCharCode(b); + afterHex = false; + } else { + out += `\\x${b.toString(16).padStart(2, "0")}`; + afterHex = true; + } + } + return `${out}"`; +} + +/** A constant tp_str initializer: {"abc", 3}. */ +export function cTpStr(s) { + return `{${cStr(s)}, ${utf8(s).length}}`; +} + +/** camelCase or kebab-case to snake_case. */ +export function snake(s) { + return s + .replace(/([a-z0-9])([A-Z])/g, "$1_$2") + .replace(/[-]/g, "_") + .toLowerCase(); +} + +/** The linkage macro the generated headers declare their arrays with. */ +export const PRIVATE_DATA = [ + "/* Linkage of generated tables. A declaration needs the complete type: the amalgamation makes", + " * these static, and a static tentative declaration must have a complete type. In the", + " * separate-files build they are extern, so the header declares and data_gen.c / unicode_gen.c", + " * define. */", + "#ifndef TP_PRIVATE_DATA", + "#ifdef TRACKPARSE_AMALGAMATION", + "#define TP_PRIVATE_DATA static", + "#else", + "#define TP_PRIVATE_DATA extern", + "#endif", + "#endif", +]; + +/** Write or check one generated file. Returns true when it is stale (check) or was written. */ +export function emitFile(fs, path, content, check, label) { + let current = ""; + try { + current = fs.readFileSync(path, "utf8"); + } catch {} + if (current === content) return false; + if (check) { + console.error(`${label} is stale: run node ${process.argv[1].replace(/.*\/c\//, "c/")}`); + } else { + fs.writeFileSync(path, content); + console.log(`wrote ${path}`); + } + return true; +} diff --git a/c/scripts/dump_numbers.mjs b/c/scripts/dump_numbers.mjs new file mode 100644 index 0000000..151fd04 --- /dev/null +++ b/c/scripts/dump_numbers.mjs @@ -0,0 +1,166 @@ +#!/usr/bin/env node +// dump_numbers.mjs: number cases from Node for c/tests/test_num.c (src/num.c). +// +// node c/scripts/dump_numbers.mjs [--n 1000000] [--seed 1] [--out file.jsonl] +// +// Writes JSONL, one case per line, half of each kind: +// {"s":"","v":"","b":""} +// {"d":"","s":""} +// The strings follow the grammar tp_parse_number accepts (see src/num.c). The mix: random bit +// patterns, subnormals, powers of ten and their neighbours, integers, exact halfway points between +// neighbouring doubles (and one unit above and below in a far digit), long digit strings, short +// decimals like the R13.2 times, and exponent forms. +// The committed sample c/tests/data/numbers_sample.jsonl is --n 2000 --seed 1. + +import { createWriteStream } from "node:fs"; + +const args = process.argv.slice(2); +const opt = (name, def) => { + const i = args.indexOf(`--${name}`); + return i >= 0 && i + 1 < args.length ? args[i + 1] : def; +}; +const N = Number(opt("n", "1000000")); +const out = opt("out", null); +let seed = BigInt(opt("seed", "1")) || 1n; + +// xorshift64*, deterministic across runs. +const M64 = (1n << 64n) - 1n; +function next64() { + seed ^= seed >> 12n; + seed ^= (seed << 25n) & M64; + seed ^= seed >> 27n; + return (seed * 2685821657736338717n) & M64; +} +const rand = (n) => Number(next64() % BigInt(n)); + +const buf = new DataView(new ArrayBuffer(8)); +const toBits = (d) => { + buf.setFloat64(0, d); + return buf.getBigUint64(0); +}; +const fromBits = (b) => { + buf.setBigUint64(0, b); + return buf.getFloat64(0); +}; +const hex = (b) => b.toString(16).padStart(16, "0"); + +const digits = (n, lead = true) => { + let s = lead ? String(1 + rand(9)) : String(rand(10)); + for (let i = 1; i < n; i++) s += String(rand(10)); + return s; +}; + +// Exact decimal of m * 2^e (m, e BigInt), as an integer digit string and a power-of-ten exponent. +function exactDecimal(m, e) { + if (e >= 0n) return { d: (m << e).toString(), p: 0 }; + const k = -e; + return { d: (m * 5n ** k).toString(), p: -Number(k) }; +} +const sci = ({ d, p }) => { + // d * 10^p as a plain or exponent string, chosen at random. + const t = d.replace(/^0+/, "") || "0"; + if (rand(2) === 0) return `${t}e${p}`; + if (p >= 0) return t + "0".repeat(p); + const k = -p; + if (k >= t.length) return `0.${"0".repeat(k - t.length)}${t}`; + return `${t.slice(0, t.length - k)}.${t.slice(t.length - k)}`; +}; + +function randomDouble() { + switch (rand(8)) { + case 0: + case 1: + return fromBits(next64()); + case 2: + return fromBits(next64() & ((1n << 52n) - 1n)); // subnormal + case 3: + return 10 ** (rand(650) - 325) * (rand(2) ? 1 : -1); + case 4: + return fromBits(toBits(10 ** (rand(620) - 310)) + BigInt(rand(5)) - 2n); + case 5: + return rand(2 ** 30) * 2 ** (rand(40) - 20); + case 6: + return Number(digits(1 + rand(17))) / 10 ** rand(25); + default: { + const pick = [0, -0, 5e-324, 1e21, 1e-7, 1e-6, 1e20, 9007199254740992, 1.7976931348623157e308, + 2.2250738585072014e-308, 123456789012345680000, 0.1, 1 / 3, NaN, Infinity, -Infinity]; + return pick[rand(pick.length)]; + } + } +} + +function randomString() { + const sign = ["", "", "", "-", "+"][rand(5)]; + switch (rand(9)) { + case 0: { + // Halfway point between a finite double and its successor (up to 767 significant digits). + let b = next64() & ((1n << 63n) - 1n); + if (rand(3) === 0) b &= (1n << 54n) - 1n; // subnormals and the smallest normals + if (b >= 0x7fefffffffffffffn) b = 0x7fe0000000000000n; + const be = b >> 52n; + const f = b & ((1n << 52n) - 1n); + const m = be === 0n ? f : f | (1n << 52n); + const e = be === 0n ? -1074n : be - 1075n; + const ex = exactDecimal(2n * m + 1n, e - 1n); + const tweak = rand(3); + if (tweak !== 0) { + // One unit far below the last digit, up or down: no longer a tie. + const extra = 3 + rand(20); + let d = BigInt(ex.d) * 10n ** BigInt(extra); + d += tweak === 1 ? 1n : -1n; + return sign + sci({ d: d.toString(), p: ex.p - extra }); + } + return sign + sci(ex); + } + case 1: + return sign + digits(1 + rand(4)) + "." + digits(1 + rand(25), false); // times, R13.2 + case 2: + return sign + digits(1 + rand(40)) + "." + digits(rand(40), false); + case 3: + return sign + "0." + "0".repeat(rand(330)) + digits(1 + rand(30)); + case 4: + return sign + digits(1 + rand(20)) + ["e", "E"][rand(2)] + ["", "+", "-"][rand(3)] + + String(rand(400)).padStart(1 + rand(3), "0"); + case 5: + return sign + digits(100 + rand(1200)) + (rand(2) ? `e-${rand(1400)}` : ""); + case 6: { + // A double's shortest digits with noise appended. + const d = Math.abs(randomDouble()); + if (!Number.isFinite(d) || d === 0) return `${sign}0.0`; + let s = String(d); + if (!s.includes("e") && !s.includes(".")) s += "."; + const [mant, ex] = s.split("e"); + return sign + mant + digits(rand(30), false) + (ex === undefined ? "" : `e${ex}`); + } + case 7: { + const forms = ["0", "00", "007", "1.", ".5", "0.0", "1e21", "1e-7", "1e308", "1e309", + "2e-324", "3e-324", "1e-400", "4.9406564584124654e-324", "2.4703282292062327e-324", + "2.4703282292062328e-324", "1.7976931348623158e308", "1.7976931348623159e308", + "9007199254740993", "3167.12345678901234567890", ".0e5", "0e999999999999", + "1e-999999999999", "123456789012345678901234567890e-30"]; + return sign + forms[rand(forms.length)]; + } + default: + return sign + digits(1 + rand(25)) + "e" + String(rand(700) - 350); + } +} + +const stream = out ? createWriteStream(out) : process.stdout; +let pending = []; +const flush = () => { + if (pending.length) stream.write(`${pending.join("\n")}\n`); + pending = []; +}; +for (let i = 0; i < N; i++) { + if (i % 2 === 0) { + const s = randomString(); + const v = Number(s); + pending.push(JSON.stringify({ s, v: String(v), b: hex(toBits(v)) })); + } else { + const d = randomDouble(); + pending.push(JSON.stringify({ d: hex(toBits(d)), s: String(d) })); + } + if (pending.length >= 10000) flush(); +} +flush(); +if (out) stream.end(); diff --git a/c/scripts/fuzz_corpus.mjs b/c/scripts/fuzz_corpus.mjs new file mode 100644 index 0000000..5f36a17 --- /dev/null +++ b/c/scripts/fuzz_corpus.mjs @@ -0,0 +1,89 @@ +// fuzz_corpus.mjs: the seed corpus of the libFuzzer targets in c/fuzz/, from every shared fixture +// input (as go/fuzz_test.go seeds its targets). +// +// node c/scripts/fuzz_corpus.mjs +// +// Writes // files in each target's input encoding: +// parse, parse_artists one option-set byte, then the input +// format, parse_tracklist 8 bytes of seed (little-endian), then the input +// apply_edits 8 bytes of seed, 4 bytes of text length, the text, the edits JSON +// wire the case as one JSONL line (what compare-ports sends to the dump tool) +// Then, for example: c/build-fuzz/fuzz_parse -max_total_time=60 /parse +import { createHash } from "node:crypto"; +import { mkdirSync, readdirSync, readFileSync, writeFileSync } from "node:fs"; +import { dirname, join } from "node:path"; +import { fileURLToPath } from "node:url"; + +const here = dirname(fileURLToPath(import.meta.url)); +const fixtures = join(here, "..", "..", "spec", "fixtures"); +const out = process.argv[2]; +if (!out) { + console.error("usage: node c/scripts/fuzz_corpus.mjs "); + process.exit(2); +} + +const cases = []; +for (const sub of ["handwritten", "generated"]) { + for (const name of readdirSync(join(fixtures, sub)).sort()) { + if (!name.endsWith(".json")) continue; + const data = JSON.parse(readFileSync(join(fixtures, sub, name), "utf8")); + if (!Array.isArray(data.cases)) continue; + const defaults = data.defaults ?? {}; + for (const c of data.cases) { + cases.push({ + fn: c.fn ?? defaults.fn ?? "parse", + input: c.input ?? "", + options: { ...(defaults.options ?? {}), ...(c.options ?? {}) }, + formatOptions: { ...(defaults.formatOptions ?? {}), ...(c.formatOptions ?? {}) }, + edits: c.edits ?? [], + }); + } + } +} + +const written = {}; +function write(target, bytes) { + const dir = join(out, target); + if (!written[target]) { + mkdirSync(dir, { recursive: true }); + written[target] = new Set(); + } + const name = createHash("sha1").update(bytes).digest("hex"); + if (written[target].has(name)) return; + written[target].add(name); + writeFileSync(join(dir, name), bytes); +} + +const u64 = (n) => { + const b = Buffer.alloc(8); + b.writeBigUInt64LE(BigInt(n)); + return b; +}; +const u32 = (n) => { + const b = Buffer.alloc(4); + b.writeUInt32LE(n); + return b; +}; + +cases.forEach((c, i) => { + const input = Buffer.from(c.input, "utf8"); + if (["parse", "format", "normalize", "parseArtists"].includes(c.fn)) { + write("parse", Buffer.concat([Buffer.from([i % 256]), input])); + } + if (["parseArtists", "parse"].includes(c.fn)) { + write("parse_artists", Buffer.concat([Buffer.from([i % 256]), input])); + } + if (["format", "parse"].includes(c.fn)) write("format", Buffer.concat([u64(i), input])); + if (["parseTracklist", "applyEdits"].includes(c.fn)) { + write("parse_tracklist", Buffer.concat([u64(i), input])); + } + if (c.fn === "applyEdits" || c.fn === "parseTracklist") { + const edits = Buffer.from(JSON.stringify(c.fn === "applyEdits" ? c.edits : []), "utf8"); + write("apply_edits", Buffer.concat([u64(i), u32(input.length), input, edits])); + } + write("wire", Buffer.from(JSON.stringify(c), "utf8")); +}); + +for (const [target, set] of Object.entries(written)) { + console.log(`${target}: ${set.size} seeds`); +} diff --git a/c/scripts/gen_data.mjs b/c/scripts/gen_data.mjs new file mode 100644 index 0000000..b318824 --- /dev/null +++ b/c/scripts/gen_data.mjs @@ -0,0 +1,119 @@ +#!/usr/bin/env node +// Compiles spec/data/*.json and spec/VERSION into src/data_gen.h and src/data_gen.c: one C array +// per key of each data file, in file order, so no JSON is parsed at run time. The C twin of +// go/scripts/gen_data.mjs (same names, snake_case: dataFeatMarkersMarkers is +// tp_data_feat_markers_markers). +// +// node c/scripts/gen_data.mjs write the files +// node c/scripts/gen_data.mjs --check exit 1 if a committed file is stale +// +// Shapes: a string array becomes `const tp_str x[N]`, an object of strings `const tp_data_kv +// x[N]` (file order; JS Object.entries order is applied at run time by tables.c), an array of +// joiner objects `const tp_data_joiner x[N]`, a string a TP_S(...) macro. Each array has a +// TP_DATA_..._N count macro. Any other shape is an error: extend this script first. +import * as fs from "node:fs"; +import { dirname, join, resolve } from "node:path"; +import { fileURLToPath } from "node:url"; +import { PRIVATE_DATA, cStr, cTpStr, emitFile, snake } from "./c_lit.mjs"; + +const here = dirname(fileURLToPath(import.meta.url)); +const specDir = resolve(here, "../../spec"); +const dataDir = join(specDir, "data"); +const srcDir = resolve(here, "../src"); + +const JOINER_KEYS = ["raw", "canonical", "kind", "caseSensitive"]; +const GENERATED = "/* Code generated by c/scripts/gen_data.mjs from spec/data and spec/VERSION. DO NOT EDIT. */"; + +/** `a b` on one line when it fits in 100 columns, else b on a continuation line. */ +const wrap = (a, b) => (a.length + 1 + b.length <= 100 ? `${a} ${b}` : `${a}\n ${b}`); + +function fail(where, why) { + console.error(`gen_data.mjs: ${where}: ${why}; extend c/scripts/gen_data.mjs`); + process.exit(2); +} + +function render() { + const version = fs.readFileSync(join(specDir, "VERSION"), "utf8").trim(); + const h = [ + GENERATED, + "#ifndef TP_DATA_GEN_H", + "#define TP_DATA_GEN_H", + "", + '#include "rt.h"', + "", + ...PRIVATE_DATA, + "", + "/* The version of the spec this library implements. */", + `#define TP_SPEC_VERSION ${cStr(version)} /* x-release-please-version */`, + "", + "/* One entry of a JSON object in spec/data, in file order. */", + "typedef struct tp_data_kv {", + " tp_str key;", + " tp_str value;", + "} tp_data_kv;", + "", + "/* One entry of spec/data/joiners.json. */", + "typedef struct tp_data_joiner {", + " tp_str raw;", + " tp_str canonical;", + " tp_str kind;", + " bool case_sensitive;", + "} tp_data_joiner;", + ]; + const c = [GENERATED, '#include "data_gen.h"']; + for (const file of fs.readdirSync(dataDir).filter((f) => f.endsWith(".json")).sort()) { + const data = JSON.parse(fs.readFileSync(join(dataDir, file), "utf8")); + const stem = file.slice(0, -5); + for (const [key, v] of Object.entries(data)) { + if (key === "$comment") continue; + const name = `tp_data_${snake(stem)}_${snake(key)}`; + const count = `${name.toUpperCase()}_N`; + const where = `spec/data/${file} ${key}`; + const array = (type, items) => { + if (items.length === 0) fail(where, "empty list (a C array cannot be empty)"); + h.push("", `/* ${key} in spec/data/${file}. */`); + h.push(`#define ${count} ${items.length}`); + h.push(wrap(`TP_PRIVATE_DATA const ${type}`, `${name}[${count}];`)); + c.push("", wrap(`TP_PRIVATE const ${type}`, `${name}[${count}] = {`)); + for (const item of items) c.push(` ${item},`); + c.push("};"); + }; + if (typeof v === "string") { + h.push("", `/* ${key} in spec/data/${file}. */`); + h.push(`#define ${name.toUpperCase()} TP_S(${cStr(v)})`); + } else if (Array.isArray(v) && v.every((x) => typeof x === "string")) { + array("tp_str", v.map(cTpStr)); + } else if (Array.isArray(v) && v.every((x) => x && typeof x === "object" && !Array.isArray(x))) { + const items = v.map((x) => { + for (const [k, fv] of Object.entries(x)) { + if (!JOINER_KEYS.includes(k)) fail(where, `unknown key ${k}`); + if (k === "caseSensitive" ? typeof fv !== "boolean" : typeof fv !== "string") { + fail(where, `${k} has the wrong type`); + } + } + const s = (k) => cTpStr(x[k] ?? ""); + return `{${s("raw")}, ${s("canonical")}, ${s("kind")}, ${x.caseSensitive ? "true" : "false"}}`; + }); + array("tp_data_joiner", items); + } else if (v && typeof v === "object" && !Array.isArray(v)) { + const items = []; + for (const [k, x] of Object.entries(v)) { + if (k === "$comment") continue; + if (typeof x !== "string") fail(where, `value of ${k} is not a string`); + items.push(`{${cTpStr(k)}, ${cTpStr(x)}}`); + } + array("tp_data_kv", items); + } else { + fail(where, "unsupported shape"); + } + } + } + h.push("", "#endif /* TP_DATA_GEN_H */"); + return { h: `${h.join("\n")}\n`, c: `${c.join("\n")}\n` }; +} + +const check = process.argv.includes("--check"); +const out = render(); +let stale = emitFile(fs, join(srcDir, "data_gen.h"), out.h, check, "c/src/data_gen.h"); +stale = emitFile(fs, join(srcDir, "data_gen.c"), out.c, check, "c/src/data_gen.c") || stale; +if (check && stale) process.exit(1); diff --git a/c/scripts/gen_unicode.mjs b/c/scripts/gen_unicode.mjs new file mode 100644 index 0000000..f2c84af --- /dev/null +++ b/c/scripts/gen_unicode.mjs @@ -0,0 +1,204 @@ +#!/usr/bin/env node +// Writes c/src/unicode_gen.h and c/src/unicode_gen.c: the Unicode tables of the C port, all taken +// from the JS reference engine (Node), so the library's Unicode version is Node's, never the C +// library's or the platform's. The same tables as go/unicode_gen.go (the derivation is shared +// with go/scripts/gen_unicode.mjs through unicode_derive.mjs; its header comment explains the +// combining class ranks): +// +// - general categories L and Lu (SPEC R0.6): /\p{L}/u and /\p{Lu}/u, as range tables; +// - String.prototype.toLowerCase() (R0.4 dedup key): runs of code points with a common delta, +// the multi-code-point results, and the properties Cased and Case_Ignorable that the +// final-sigma rule reads; +// - String.prototype.normalize("NFC" | "NFD") (R1, R0.4): full canonical decompositions, +// canonical combining class ranks, composition pairs and the NFC quick-check sets. Hangul +// syllables are left to the algorithm in unicode.c. +// +// node c/scripts/gen_unicode.mjs write the tables and the test sample +// node c/scripts/gen_unicode.mjs --check exit 1 if any of them is stale +// node c/scripts/gen_unicode.mjs --cases write the exhaustive cases to /cases.jsonl +import * as fs from "node:fs"; +import { dirname, join, resolve } from "node:path"; +import { fileURLToPath } from "node:url"; +import { PRIVATE_DATA, cStr, cTpStr } from "./c_lit.mjs"; +import { UNICODE, cases, tables } from "./unicode_derive.mjs"; + +const here = dirname(fileURLToPath(import.meta.url)); +const cDir = resolve(here, ".."); + +const hex = (n) => `0x${n.toString(16)}`; +const GENERATED = [ + "/* Code generated by c/scripts/gen_unicode.mjs; DO NOT EDIT.", + " * Run `node c/scripts/gen_unicode.mjs` to regenerate.", + " *", + " * Tables taken from the JS reference engine (Node), so the Unicode version is Node's and not", + " * the platform's: categories L and Lu (R0.6), toLowerCase() (R0.4) and NFC/NFD (R1, R0.4).", + " * The method behind the combining class ranks is described in c/scripts/unicode_derive.mjs", + " * and go/scripts/gen_unicode.mjs. */", + `/* Unicode ${UNICODE} */`, +]; + +/** Initializer elements, as many to a line as fit in 100 columns (at most `perLine`). */ +function rows(items, perLine) { + const lines = []; + let line = []; + const width = (l) => 2 + l.reduce((w, x) => w + x.length + 2, 0) - 1; + for (const item of items) { + if (line.length > 0 && (line.length === perLine || width([...line, item]) > 100)) { + lines.push(` ${line.join(", ")},`); + line = []; + } + line.push(item); + } + if (line.length > 0) lines.push(` ${line.join(", ")},`); + return lines.join("\n"); +} + +function render(t) { + const h = [ + ...GENERATED, + "#ifndef TP_UNICODE_GEN_H", + "#define TP_UNICODE_GEN_H", + "", + '#include "unicode.h"', + "", + ...PRIVATE_DATA, + "", + "/* The Unicode version of Node's tables these were generated from. */", + `#define TP_UNICODE_VERSION ${cStr(UNICODE)}`, + ]; + const c = [...GENERATED, '#include "unicode_gen.h"']; + const table = (type, name, doc, items, perLine) => { + const count = `${name.toUpperCase()}_N`; + h.push("", `/* ${name}: ${doc} */`, `#define ${count} ${items.length}`); + h.push(`TP_PRIVATE_DATA const ${type} ${name}[${count}];`); + c.push("", `TP_PRIVATE const ${type} ${name}[${count}] = {`, rows(items, perLine), "};"); + }; + const ranges = (name, doc, rs) => + table("tp_uni_range", name, doc, rs.map(([a, b]) => `{${hex(a)}, ${hex(b)}}`), 6); + + const { runs, multi } = t.lower; + const n = t.norm; + ranges("tp_uni_letter", "general category L (Lu, Ll, Lt, Lm, Lo), JS /\\p{L}/u.", t.letter); + ranges("tp_uni_upper", "general category Lu, JS /\\p{Lu}/u.", t.upper); + ranges("tp_uni_cased", "property Cased, read by the final-sigma rule.", t.cased); + ranges("tp_uni_case_ignorable", "property Case_Ignorable, read by the final-sigma rule.", t.ignorable); + table( + "tp_lower_run", + "tp_uni_lower", + "JS toLowerCase() of one code point. Every first + k*step <= last maps\n * to itself plus delta. Sorted by first, no overlaps.", + runs.map((r) => `{${hex(r.first)}, ${hex(r.last)}, ${r.step}, ${r.delta}}`), + 4, + ); + table( + "tp_lower_multi", + "tp_uni_lower_multi", + "code points whose lowercase is several code points (UTF-8). Sorted.", + multi.map(([cp, to]) => `{${hex(cp)}, ${cTpStr(to)}}`), + 3, + ); + table( + "tp_ccc_range", + "tp_uni_ccc", + "canonical combining class ranks of the code points that are their own NFD; 0\n * when absent. Ranks keep the order and equality of the classes, which is all normalization\n * uses.", + n.cccRanges.map(([a, b, r]) => `{${hex(a)}, ${hex(b)}, ${r}}`), + 5, + ); + // Decompositions: offsets into one pool of code points. + const pool = []; + const entries = []; + for (const [cp, d] of n.decomp) { + entries.push(`{${hex(cp)}, ${pool.length}, ${d.length}}`); + pool.push(...d); + } + if (pool.length > 0xffff) throw new Error("decomposition pool does not fit uint16_t offsets"); + table( + "tp_decomp_entry", + "tp_uni_decomp", + "full canonical decomposition (NFD) of every code point that has one, except\n * the Hangul syllables: tp_uni_decomp_pool[off .. off+len). Sorted by code point.", + entries, + 5, + ); + table("tp_rune", "tp_uni_decomp_pool", "the code points of tp_uni_decomp.", pool.map(hex), 10); + table( + "tp_compose_pair", + "tp_uni_compose", + "canonical composition pairs (first, second) -> primary composite, without\n * the Hangul syllables and the composition exclusions. Sorted by first, then second.", + n.pairs.map(([a, b, x]) => `{${hex(a)}, ${hex(b)}, ${hex(x)}}`), + 4, + ); + ranges("tp_uni_nfc_no", "code points that NFC changes on their own (NFC_Quick_Check=No).", n.nfcNo); + ranges( + "tp_uni_compose_second", + "code points that can compose with what precedes them\n * (NFC_Quick_Check=Maybe).", + n.second, + ); + h.push( + "", + "/* Every code point below it is a starter that neither normalization form changes and that", + " * never composes with what precedes it. */", + `#define TP_UNI_QUICK_MIN ${hex(n.quickMin)}`, + "", + "#endif /* TP_UNICODE_GEN_H */", + ); + return { h: `${h.join("\n")}\n`, c: `${c.join("\n")}\n` }; +} + +const args = process.argv.slice(2); +const casesAt = args.indexOf("--cases"); +if (casesAt >= 0) { + const dir = args[casesAt + 1]; + if (!dir) throw new Error("--cases needs a directory"); + fs.mkdirSync(dir, { recursive: true }); + const lines = []; + let bytes = 0; + const path = join(dir, "cases.jsonl"); + fs.writeFileSync(path, ""); + for (const line of cases(tables(), true)) { + lines.push(line); + bytes += line.length; + if (bytes > 1 << 22) { + fs.writeFileSync(path, `${lines.join("\n")}\n`, { flag: "a" }); + lines.length = 0; + bytes = 0; + } + } + fs.writeFileSync(path, `${lines.join("\n")}\n`, { flag: "a" }); + fs.writeFileSync(join(dir, "unicode-version.txt"), `${UNICODE}\n`); + console.log(`wrote ${path}`); +} else { + const check = args.includes("--check"); + const t = tables(); + const out = render(t); + let stale = false; + const emit = (rel, content) => { + const path = join(cDir, rel); + let current = ""; + try { + current = fs.readFileSync(path, "utf8"); + } catch {} + if (check) { + // The tables depend on Node's Unicode version: only compare like with like. + let gen = ""; + try { + gen = fs.readFileSync(join(cDir, "src", "unicode_gen.h"), "utf8"); + } catch {} + const other = gen.match(/^\/\* Unicode (\S+) \*\/$/m); + if (other && other[1] !== UNICODE) { + console.log(`c/${rel}: skipped (Unicode ${UNICODE} here)`); + return; + } + if (current !== content) { + console.error(`c/${rel} is stale: run node c/scripts/gen_unicode.mjs`); + stale = true; + } + } else if (current !== content) { + fs.mkdirSync(dirname(path), { recursive: true }); + fs.writeFileSync(path, content); + console.log(`wrote ${path}`); + } + }; + emit("src/unicode_gen.h", out.h); + emit("src/unicode_gen.c", out.c); + emit("tests/data/unicode/cases.jsonl", `${[...cases(t, false)].join("\n")}\n`); + if (stale) process.exit(1); +} diff --git a/c/scripts/unicode_derive.mjs b/c/scripts/unicode_derive.mjs new file mode 100644 index 0000000..0c645a9 --- /dev/null +++ b/c/scripts/unicode_derive.mjs @@ -0,0 +1,306 @@ +// The Unicode derivation shared by c/scripts/gen_unicode.mjs: every table taken from the JS +// reference engine (Node), and the test cases. A copy of the derivation in +// go/scripts/gen_unicode.mjs (read its header comment for the method behind the combining class +// ranks); keep the two in step, so the Go and C ports carry the same tables and the committed +// samples (go/testdata/unicode, c/tests/data/unicode) are the same file. + +export const UNICODE = process.versions.unicode; + +export const S_BASE = 0xac00; +export const S_COUNT = 11172; +export const isSurrogate = (cp) => cp >= 0xd800 && cp <= 0xdfff; +const isHangulSyllable = (cp) => cp >= S_BASE && cp < S_BASE + S_COUNT; +export const chr = (cp) => String.fromCodePoint(cp); +export const cps = (s) => [...s].map((c) => c.codePointAt(0)); +export const NFD = (s) => s.normalize("NFD"); +export const NFC = (s) => s.normalize("NFC"); + +export function* scalars() { + for (let cp = 0; cp < 0x110000; cp++) if (!isSurrogate(cp)) yield cp; +} + +/** Inclusive ranges of the code points for which `test` holds. */ +function rangesOf(test) { + const out = []; + let start = -1; + for (let cp = 0; cp <= 0x110000; cp++) { + const hit = cp < 0x110000 && !isSurrogate(cp) && test(cp); + if (hit && start < 0) start = cp; + if (!hit && start >= 0) { + out.push([start, cp - 1]); + start = -1; + } + } + return out; +} +const regexRanges = (re) => rangesOf((cp) => re.test(chr(cp))); + +/** toLowerCase() of each code point that changes, as in rust/scripts/gen_data.mjs. */ +function lowercase() { + const runs = []; + const multi = []; + let run = null; + for (const cp of scalars()) { + const lower = cps(chr(cp).toLowerCase()); + if (lower.length === 1 && lower[0] === cp) continue; + if (lower.length !== 1) { + multi.push([cp, lower]); + run = null; // a run must not step over a code point of the other table + continue; + } + const delta = lower[0] - cp; + if (run && run.delta === delta && (run.step === 0 ? cp - run.last <= 2 : cp - run.last === run.step)) { + run.step = cp - run.last; + run.last = cp; + } else { + run = { first: cp, last: cp, step: 0, delta }; + runs.push(run); + } + } + for (const r of runs) if (r.step === 0) r.step = 1; + return { runs, multi }; +} + +/** The normalization tables (see the header comment for the method). */ +function normalization() { + const decomp = []; // [cp, [full NFD]] for non-Hangul code points that decompose + const stable = []; // code points with NFD(c) == c + for (const cp of scalars()) { + if (isHangulSyllable(cp)) continue; + const s = chr(cp); + const d = NFD(s); + if (d !== s) decomp.push([cp, cps(d)]); + else stable.push(cp); + } + + // Combining class ranks. + const P1 = "\u0334"; + const P240 = "\u0345"; + if (NFD(P240 + P1) !== P1 + P240) throw new Error("probe order: expected ccc(U+0334) < ccc(U+0345)"); + const nonStarters = stable.filter((cp) => { + const s = chr(cp); + return NFD(s + P1) === P1 + s || NFD(P240 + s) === s + P240; + }); + // cmp < 0 when a has the smaller class. + const cmp = (a, b) => { + const sa = chr(a); + const sb = chr(b); + if (NFD(sb + sa) === sa + sb) return -1; + if (NFD(sa + sb) === sb + sa) return 1; + return 0; + }; + const sorted = [...nonStarters].sort((a, b) => cmp(a, b) || a - b); + const rank = new Map(); + let r = 0; + for (let i = 0; i < sorted.length; i++) { + if (i === 0 || cmp(sorted[i - 1], sorted[i]) !== 0) r++; + rank.set(sorted[i], r); + } + if (r > 255) throw new Error("more than 255 classes"); + if (rank.get(0x334) !== 1 || rank.get(0x345) !== r) throw new Error("probes are not the extreme classes"); + const ccc = (cp) => rank.get(cp) ?? 0; + const cccRanges = []; + for (const cp of [...rank.keys()].sort((a, b) => a - b)) { + const last = cccRanges[cccRanges.length - 1]; + if (last && last[1] === cp - 1 && last[2] === ccc(cp)) last[1] = cp; + else cccRanges.push([cp, cp, ccc(cp)]); + } + + // Composition pairs and the NFC quick-check sets. + const nfcNo = new Set(); + const pairs = []; + for (const cp of scalars()) if (NFC(chr(cp)) !== chr(cp)) nfcNo.add(cp); + for (const [cp, d] of decomp) { + if (nfcNo.has(cp)) continue; + // A decomposable code point that NFC keeps starts with a starter: the quick check gives it + // class 0. + if (ccc(d[0]) !== 0) throw new Error(`U+${cp.toString(16)}: NFC-stable but starts with a non-starter`); + const last = d[d.length - 1]; + const first = cps(NFC(String.fromCodePoint(...d.slice(0, -1)))); + if (first.length !== 1 || NFC(chr(first[0]) + chr(last)) !== chr(cp)) { + throw new Error(`U+${cp.toString(16)}: no composition pair`); + } + pairs.push([first[0], last, cp]); + } + pairs.sort((a, b) => a[0] - b[0] || a[1] - b[1]); + const second = new Set(pairs.map((p) => p[1])); + for (let v = 0x1161; v <= 0x1175; v++) second.add(v); // Hangul V and T (algorithmic) + for (let t = 0x11a8; t <= 0x11c2; t++) second.add(t); + + const quickMin = Math.min(decomp[0][0], cccRanges[0][0], ...nfcNo, ...second); + return { + decomp, + cccRanges, + rank, + nonStarters: sorted.sort((a, b) => a - b), + pairs, + nfcNo: rangesOf((cp) => nfcNo.has(cp)), + second: rangesOf((cp) => second.has(cp)), + quickMin, + }; +} + +export function tables() { + return { + letter: regexRanges(/^\p{L}$/u), + upper: regexRanges(/^\p{Lu}$/u), + cased: regexRanges(/^\p{Cased}$/u), + ignorable: regexRanges(/^\p{Case_Ignorable}$/u), + lower: lowercase(), + norm: normalization(), + }; +} + +// --------------------------------------------------------------------------- +// Test cases: one JSON object per line, {"g": group, "s": input, "c": NFC, "d": NFD, +// "l": toLowerCase, "k": category bits (1 = \p{L}, 2 = \p{Lu}, single code points only)}. +// "c", "d" and "l" are left out when equal to "s". + +/** mulberry32: a small seeded PRNG, so the committed sample is reproducible. */ +function prng(seed) { + let a = seed >>> 0; + return () => { + a = (a + 0x6d2b79f5) >>> 0; + let t = a; + t = Math.imul(t ^ (t >>> 15), t | 1); + t ^= t + Math.imul(t ^ (t >>> 7), t | 61); + return ((t ^ (t >>> 14)) >>> 0) / 4294967296; + }; +} + +function caseLine(g, s, single) { + const o = { g, s }; + const c = NFC(s); + const d = NFD(s); + const l = s.toLowerCase(); + if (c !== s) o.c = c; + if (d !== s) o.d = d; + if (l !== s) o.l = l; + if (single) o.k = (/^\p{L}$/u.test(s) ? 1 : 0) | (/^\p{Lu}$/u.test(s) ? 2 : 0); + return JSON.stringify(o); +} + +export function* cases(t, full) { + const rnd = prng(0x7a11 + (full ? 1 : 0)); + const pick = (arr) => arr[Math.floor(rnd() * arr.length)]; + const int = (lo, hi) => lo + Math.floor(rnd() * (hi - lo + 1)); + const n = t.norm; + const marks = n.nonStarters; + const decompCps = n.decomp.map((e) => e[0]); + const lowerCps = [...t.lower.runs.flatMap((r) => [r.first, r.last]), ...t.lower.multi.map((m) => m[0])]; + + // Single code points: all of them, or the interesting ones plus a stride. + if (full) { + for (const cp of scalars()) yield caseLine("single", chr(cp), true); + } else { + // The committed sample is shipped in the module zip, so it stays small (under 300 KB): every + // range boundary of the tables, and every SAMPLE-th entry of the per-code-point lists. + const SAMPLE = 8; + const every = (list) => list.filter((_, i) => i % SAMPLE === 0); + const set = new Set([...every(decompCps), ...every(marks), ...every(lowerCps), ...every(n.pairs.map((p) => p[1]))]); + for (const [a, b] of [...t.letter, ...t.upper, ...n.nfcNo, ...t.cased, ...t.ignorable]) { + set.add(a); + set.add(b); + } + for (const cp of scalars()) if (cp % 4999 === 0) set.add(cp); + for (let cp = S_BASE; cp < S_BASE + S_COUNT; cp += 997) set.add(cp); + for (const cp of [...set].sort((a, b) => a - b)) if (!isSurrogate(cp)) yield caseLine("single", chr(cp), true); + } + + // Ordered pairs of non-starters, bare and after a starter. + const bases = ["a", "e", "o", "A", "u", "\u03b1", "\u03c9", "\u0438", "\u0b47", "\u1100", "\u05d0", "\u0627", "\u3099"]; + if (full) { + let i = 0; + for (const x of marks) { + for (const y of marks) { + const xy = chr(x) + chr(y); + yield caseLine("pair", xy); + yield caseLine("pair+base", bases[i++ % bases.length] + xy); + } + } + } else { + for (let i = 0; i < 500; i++) yield caseLine("pair+base", pick(bases) + chr(pick(marks)) + chr(pick(marks))); + } + + // Composition: every pair, blocked and unblocked by a mark in between, and the composite plus + // marks. + // (The sample takes one of the three forms per pair, in turn.) + for (const [i, [a, b, c]] of n.pairs.entries()) { + if (full || i % 3 === 0) yield caseLine("compose", chr(a) + chr(b)); + if (full || i % 3 === 1) yield caseLine("compose", chr(a) + chr(pick(marks)) + chr(b)); + if (full || i % 3 === 2) yield caseLine("compose", chr(c) + chr(pick(marks))); + } + + // Starter + mark + mark triples (starters that decompose or compose are the interesting ones). + const starters = [...decompCps.filter((cp) => !n.nfcNo.some(([lo, hi]) => cp >= lo && cp <= hi)), ...n.pairs.map((p) => p[0])]; + const triples = full ? 200000 : 400; + for (let i = 0; i < triples; i++) yield caseLine("triple", chr(pick(starters)) + chr(pick(marks)) + chr(pick(marks))); + + // Hangul: L+V, LV+T for the whole conjoining jamo blocks, syllables followed by T, and longer + // jamo runs. + const L = []; + const V = []; + const T = []; + for (let cp = 0x1100; cp <= 0x115f; cp++) L.push(cp); + for (let cp = 0x1160; cp <= 0x11a7; cp++) V.push(cp); + for (let cp = 0x11a8; cp <= 0x11ff; cp++) T.push(cp); + for (let cp = 0xa960; cp <= 0xa97c; cp++) L.push(cp); + for (let cp = 0xd7b0; cp <= 0xd7c6; cp++) V.push(cp); + for (let cp = 0xd7cb; cp <= 0xd7fb; cp++) T.push(cp); + T.push(0x11a7); // T base itself must not compose + const lv = []; + for (let s = S_BASE; s < S_BASE + S_COUNT; s += 28) lv.push(s); + if (full) { + for (const l of L) for (const v of V) yield caseLine("hangul", chr(l) + chr(v)); + for (const s of lv) for (const t2 of T) yield caseLine("hangul", chr(s) + chr(t2)); + for (let s = S_BASE; s < S_BASE + S_COUNT; s++) yield caseLine("hangul", chr(s) + chr(pick(T))); + } else { + for (let i = 0; i < 150; i++) yield caseLine("hangul", chr(pick(L)) + chr(pick(V))); + for (let i = 0; i < 150; i++) yield caseLine("hangul", chr(pick(lv)) + chr(pick(T))); + } + const jamo = [...L, ...V, ...T, 0x302e, 0x0301]; + for (let i = 0; i < (full ? 50000 : 100); i++) { + let s = ""; + for (let k = int(2, 6); k > 0; k--) s += chr(pick(jamo)); + yield caseLine("hangul", s); + } + + // Final sigma. + const sigma = [ + "\u03a3", "A\u03a3", "\u03a3A", "A\u03a3A", "\u039f\u0394\u039f\u03a3", "\u039f\u0394\u039f\u03a3 A", + "A\u03a3.", "A.\u03a3", "A\u03a3.A", "A\u03a3'", "A'\u03a3", "A\u03a3\u0301", "A\u0301\u03a3", + "A\u03a3\u0345", "A\u0345\u03a3", "\u03a3\u03a3", "A\u03a3\u03a3", "A\u03a3\u03a3A", "1\u03a3", + "A1\u03a3", "\u02b0\u03a3", "A\u02b0\u03a3", "A\u03a3\u02b0", "A\u00ad\u03a3", "A\u03a3\u00ad", + "A\u03a3\u00adB", "\u0130\u03a3", "a\u03a3 b\u03a3", "\u1f00\u03a3", "\u24b6\u03a3", "A\u03a3\u24b6", + "\ud801\udc00\u03a3", "A\u200d\u03a3", "A\u03a3\u200d", "A\u03a3\ufe0f", "A:\u03a3:", "A\u03a3:B", + ]; + for (const s of sigma) yield caseLine("sigma", s); + const sigmaPool = ["\u03a3", "\u03a3", "A", "a", "1", " ", ".", "'", ":", "\u0301", "\u0345", "\u02b0", "\u00ad", "\u24b6", "\u0130", "\u200d"]; + for (let i = 0; i < (full ? 50000 : 300); i++) { + let s = ""; + for (let k = int(1, 8); k > 0; k--) s += pick(sigmaPool); + yield caseLine("sigma", s); + } + + // Random strings. + const span = (lo, hi) => () => int(lo, hi); + const pools = [ + span(0x20, 0x7e), span(0x20, 0x7e), span(0x20, 0x7e), span(0x9, 0xd), + span(0xa0, 0x24f), span(0x1e00, 0x1eff), + span(0x370, 0x3ff), span(0x1f00, 0x1fff), () => 0x3a3, + span(0x400, 0x52f), + span(S_BASE, S_BASE + S_COUNT - 1), span(0x1100, 0x11ff), span(0x3130, 0x318f), + span(0x300, 0x36f), span(0x300, 0x36f), () => pick(marks), () => pick(marks), + span(0x1f300, 0x1faff), () => 0x200d, () => 0xfe0f, span(0x1f3fb, 0x1f3ff), + span(0x4e00, 0x9fff), span(0xf900, 0xfaff), span(0x2f800, 0x2fa1f), span(0x3040, 0x30ff), + () => pick(decompCps), () => pick(lowerCps), () => pick(starters), + ]; + for (let i = 0; i < (full ? 200000 : 300); i++) { + const cpsOut = []; + for (let k = int(1, 24); k > 0; k--) { + const cp = pick(pools)(); + if (!isSurrogate(cp)) cpsOut.push(cp); + } + yield caseLine("random", String.fromCodePoint(...cpsOut)); + } +} diff --git a/c/scripts/validate_outputs.mjs b/c/scripts/validate_outputs.mjs new file mode 100644 index 0000000..b141d09 --- /dev/null +++ b/c/scripts/validate_outputs.mjs @@ -0,0 +1,97 @@ +#!/usr/bin/env node +// Validates the C fixture runner's outputs against spec/schema, as the schema checks of the other +// ports' runners do (go/fixtures_test.go checkSchema, js/test/fixtures.test.ts). The C port has no +// JSON Schema validator of its own: the runner writes every output as JSONL and this script +// checks it with the ajv that the JS package already has. +// +// TRACKPARSE_OUTPUT=c/build/fixture-outputs.jsonl c/build/trackparse-fixtures spec/fixtures/*/*.json +// node c/scripts/validate_outputs.mjs c/build/fixture-outputs.jsonl +// +// Each line is {"id", "fn", "output"}. parse: parsed-track.schema.json; parseArtists: an array +// of $defs/artist; format and normalize: a string; parseTracklist: tracklist.schema.json; +// applyEdits: tracklist.schema.json#/$defs/editResult. Unknown fns fail. Exits 1 on any invalid +// output (the first 20 are printed), 2 on bad usage. CTest runs it as the `schema` test. + +import { readFileSync } from "node:fs"; +import { createRequire } from "node:module"; +import { dirname, join, resolve } from "node:path"; +import { fileURLToPath } from "node:url"; + +const root = resolve(dirname(fileURLToPath(import.meta.url)), "..", ".."); +const file = process.argv[2]; +if (!file) { + console.error("usage: node c/scripts/validate_outputs.mjs "); + process.exit(2); +} + +// ajv is a dev dependency of js/ (and spec/generator); resolve it from there. +const require = createRequire(join(root, "js", "package.json")); +const Ajv2020 = require("ajv/dist/2020.js").default ?? require("ajv/dist/2020.js"); + +const ajv = new Ajv2020({ allErrors: true, strict: false }); +const load = (name) => JSON.parse(readFileSync(join(root, "spec", "schema", name), "utf8")); +const trackSchema = load("parsed-track.schema.json"); +const tracklistSchema = load("tracklist.schema.json"); +ajv.addSchema(trackSchema); +ajv.addSchema(tracklistSchema); +const validators = { + track: ajv.getSchema(trackSchema.$id), + artist: ajv.getSchema(`${trackSchema.$id}#/$defs/artist`), + tracklist: ajv.getSchema(tracklistSchema.$id), + editResult: ajv.getSchema(`${tracklistSchema.$id}#/$defs/editResult`), +}; +for (const [name, v] of Object.entries(validators)) { + if (!v) { + console.error(`validate_outputs: cannot resolve the ${name} schema`); + process.exit(2); + } +} + +/** Everything wrong with one output, or null. */ +function problemOf(fn, out) { + const check = (v, value, label) => (v(value) ? null : `${label}: ${ajv.errorsText(v.errors)}`); + switch (fn) { + case "parse": + return check(validators.track, out, "parse"); + case "parseArtists": + if (!Array.isArray(out)) return "parseArtists: not an array"; + for (const a of out) { + const p = check(validators.artist, a, "parseArtists"); + if (p) return p; + } + return null; + case "format": + case "normalize": + return typeof out === "string" ? null : `${fn}: not a string`; + case "parseTracklist": + return check(validators.tracklist, out, "parseTracklist"); + case "applyEdits": + return check(validators.editResult, out, "applyEdits"); + } + return `unknown fn ${JSON.stringify(fn)}`; +} + +const lines = readFileSync(file, "utf8").split("\n").filter((l) => l.trim() !== ""); +const bad = []; +for (const [k, line] of lines.entries()) { + let rec; + try { + rec = JSON.parse(line); + } catch (err) { + bad.push(`line ${k + 1}: not JSON (${err.message})`); + continue; + } + const p = problemOf(rec.fn, rec.output); + if (p) bad.push(`${rec.id}: ${p}`); +} + +if (lines.length === 0) { + console.error(`validate_outputs: ${file} has no outputs`); + process.exit(1); +} +if (bad.length > 0) { + console.log(`${bad.length} of ${lines.length} outputs violate the schema; first ones:`); + for (const b of bad.slice(0, 20)) console.log(` ${b}`); + process.exit(1); +} +console.log(`schema: ${lines.length} outputs valid`); diff --git a/c/src/PORTING.md b/c/src/PORTING.md new file mode 100644 index 0000000..bc25eec --- /dev/null +++ b/c/src/PORTING.md @@ -0,0 +1,212 @@ +# Porting notes for c/src + +The C port translates `go/*.go` file by file. Every internal type and prototype is in +`internal.h` (one section per Go file). The runtime is in `rt.h`, and the primitives are in +`words.h`, `unicode.h`, `digits.h`, `data_gen.h` and `unicode_gen.h`. This file maps the Go files +to C files and lists the translation decisions that every `.c` file must follow. The rules in +`c-brief.md` still apply. This file only adds to them. + +## Go file -> C file -> internal.h section + +The track column is a suggestion. The coordinator assigns the real owners. + +| Go file | C file | internal.h section | Track | +|---|---|---|---| +| types.go | types.c | types.go | API | +| options.go | options.c | options.go | API | +| context.go | context.c | context.go | artist side | +| tables.go | tables.c | tables.go | artist side | +| normalize.go | normalize.c | normalize.go | title side | +| mode.go | mode.c | mode.go | title side | +| prefix.go | prefix.c | prefix.go | title side | +| scanner.go | scanner.c | scanner.go | title side | +| credits.go | credits.c | credits.go (placed before classify) | artist side | +| classify.go | classify.c | classify.go | artist side | +| separator.go | separator.c | separator.go | title side | +| artists.go | artists.c | artists.go | artist side | +| title.go | title.c | title.go | title side | +| assemble.go | assemble.c | assemble.go | title side | +| parser.go | parser.c | parser.go | title side | +| format.go | format.c | format.go | title side | +| tl_options.go | tl_options.c | tl_options.go | tracklist | +| tl_split.go | tl_split.c | tl_split.go | tracklist | +| tl_times.go | tl_times.c | tl_times.go | tracklist | +| tl_emphasis.go | tl_emphasis.c | tl_emphasis.go | tracklist | +| tl_kinds.go | tl_kinds.c | tl_kinds.go | tracklist | +| tl_positions.go | tl_positions.c | tl_positions.go | tracklist | +| tl_warnings.go | tl_warnings.c | tl_warnings.go | tracklist | +| tl_parse.go | tl_parse.c | tl_parse.go | tracklist | +| tl_edits.go | tl_edits.c | tl_edits.go | tracklist | +| json.go (writer half) | json.c | json.go, writer half | API | +| json.go (reader half) | ../wire/json_read.c | wire/json_read.h | wire | +| wire.go | ../wire/wire.c | wire.go (+ wire/wire.h) | wire | +| trackparse.go | trackparse.c | trackparse.go | API | +| words.go, unicode.go, digits.go | words.c, unicode.c, digits.c | words.h, unicode.h, digits.h | primitives | +| data_gen.go, unicode_gen.go | data_gen.c, unicode_gen.c | data_gen.h, unicode_gen.h | codegen | + +## Integer widths + +- Go `int` is `ptrdiff_t`, as in words.h. This covers indices, offsets, lengths, counts, years, + position numbers, seconds and line numbers. Go `[]int` is `tp_idxvec` (`TP_VEC(ptrdiff_t)`, + declared in internal.h). Go `[][]int` is `tp_idxvec_vec`. +- Go `int64` is `int64_t`, and Go `[]int64` is rt.h's `tp_intvec`. +- Exception: the edit fields that are JS numbers in the public API (`long long`) are `int64_t`, + or `tp_intvec` for lists. These are `tp_edit.line`, `after`, `from` and `lines`, + `tp_edit_warning.line` and `changed` in both edit results. `tp_saturating_int` returns + `int64_t`, which is what Go's 64-bit `int` gives. +- Convert explicitly between `ptrdiff_t` and `size_t`, for example `(ptrdiff_t)v.n` and + `(size_t)i`. Comparing a signed and an unsigned value warns under `-Wextra`. The code must also + build warning-free on 32-bit, where `int64_t` and `ptrdiff_t` differ, so never mix + `int64_t` and `ptrdiff_t` without a cast. +- Go `uint8` enums are C enums. + +## Typed strings + +`Mode`, `Role`, `Source`, `VersionType`, `Delimiter`, `JunkKind`, `Warning`, `EntryKind`, `Eol`, +`WarningCode`, `Severity`, `EditOp`, `EditWarningCode`, `SplitAnd`, `FeatPlacement`, +`JoinerStyle` and `VersionsOption` are all `tp_str`. Each has a reading typedef (`tp_role`, and +so on) and `TP_S()` constants (`TP_ROLE_PRIMARY`). Compare them with `tp_str_eq`. They stay +strings because keywords can introduce any version type or junk kind. `TP_S` is a compound +literal, so it is not a constant expression. In a `static const` table, write `{"remix", 5}`. + +## nil and empty + +- The JSON writer writes a vector as `[]` whether its `p` is NULL or not. So Go's + `if x == nil { x = []T{} }` (parser.go `runArtists` and `finish`, and types.go `result`) needs + no C code. +- Exactly one slice nil-check reaches the output: `Edit.Lines`. A nil `Lines` means "not + given"; an empty `Lines` means "shift no line". C has `bool has_lines` for this. Never test + `lines.p`. +- Nullable Go pointers are `const T *` into the arena, and NULL is nil. To set one, allocate it: + `int64_t *y = tp_alloc(sizeof *y); *y = v;`. +- Public results (API track): it is the API's decision whether a zero-length array has + `items == NULL`. The pipeline never depends on it. + +## Slices and aliasing + +Copying a `TP_VEC` header shares its storage, as copying a Go slice header does. Where Go +builds a new slice (`slices.Concat`, `slices.Clone`, `append([]T(nil), ...)`), build a new +vector with `tp_clone` / `tp_append`. Never append to a vector that you received unless the Go +code appends to that same slice. Go's `append` on a slice with spare capacity aliases, and C +must alias in the same places, which is only where Go does. + +`tp_credit_lists.entries` deliberately shares storage with the caller's entries (assemble.go). + +## Maps + +Never iterate a map on a path that reaches the output. + +- `groupMap` (`map[int]*group`) is `tp_group_map`, a vector sorted by `pos`. `tp_scan` adds + groups in strictly ascending opener offset. Look groups up with `tp_group_map_get` (binary + search). +- The removal sets (`map[int]struct{}` from `extractGroups` and `parseArtistSide`) are an + ascending `tp_idxvec`. Both are filled in `tp_groups_of` order, which is ascending. + `tp_remove_groups` checks membership with `tp_sorted_has`. +- `creditLists.heaps` (`map[int][]int`) is `tp_idxvec_vec`, indexed by list id. Ids run from 0 + to `ctx.list_seq - 1`. Grow the vector on demand. +- `tables.tightJoiners` (`map[string]string`) is `tp_kv_vec`. `tp_tables_tight_joiner` + searches from the end, so a repeated raw key resolves to its last value, as a Go map + assignment does. +- Local lookup maps (`seen` and `index` in classify, assemble, format and options, and the + `runIndex` in `buildTables`) are a local `tp_map` whose value is an index into a vector. + +## Closures and generics + +Go closures become `static` helpers in their `.c` file. Where a closure captures state, pass that +state in a small context struct: + +- options.go: `resolveFormatJSON`'s `get`. +- tables.go: `buildTables`' `note(key, patch)`. Make it a helper that returns the `tp_run_info *` + for a key (creating it in the context struct's keys, index and infos), then set the field at + the call site. +- mode.go: `splitYoutubePipes`' `pushOther`. +- scanner.go: `scan`'s `offsetAt`. This one is public: `tp_offsets` + `tp_offset_at`, because + `tp_add_group` takes it. +- title.go: `extractUnbracketedCredits`' `nextGroupAt`. +- format.go: `allArtists`' `add`. +- tl_times.go: `scanTime`'s `followsTime`. +- tl_kinds.go: `markerWords`' `flush`. +- tl_positions.go: `confirmPositions`' `isCandidate` and `adjacent`. +- tl_warnings.go: `tracklistWarnings`' `add`. +- tl_edits.go: `commonEol`'s `isTop`. + +Go generics: + +- `clamped[T]` becomes `tp_clamped_runes` and `tp_clamped_ints`. +- `byPos[T]` becomes `tp_by_pos_versions`, `_credits`, `_years` and `_junk`. They sort in place + with `tp_sort_stable`, comparing `pos` as Go's `cmp.Compare` does. +- `phraseTable[V]` values are `const void *`, as in words.h: NULL for `struct{}`, + `const tp_str *` for string tables and `const tp_run_info *` for `run_words`. +- `Ptr[T]` has no C counterpart. + +Package-level `var` slices (`explicitFlags`, `cleanFlags`, `andLike`) are `static const` arrays +in their `.c` file. + +## sync.OnceValue + +`sharedEngine`, `defaultTables`, `tlHeaderWords`, `tlLayeredWords` and `tlMarkerTable` are +`tp_shared_engine()`, `tp_default_tables()`, `tp_tl_header_words()`, `tp_tl_layered_words()` +and `tp_tl_marker_table()`. Each one uses `tp_once_get`. When that returns NULL (out of memory +while building), build the value into the current arena and return that. Everything the build +function allocates must come from `tp_alloc` inside the build, so it lands in the once's private +arena. + +## Edits: typed to loose + +Go `ApplyEdits` turns each typed `Edit` into a `jsonValue` through its JSON text +(`jsonOf` = `parseJSON(marshal(e))`). The library has no JSON reader, so `tp_edit_json` builds +the same value directly: + +- Keys and order are as in `tp_edit_write`, with only the fields of the op. `lines` is present + only when `has_lines` is set, and `from` only when it is non-NULL. +- Strings are passed through `tp_sanitize`. +- Integers become `(double)` values. +- A NaN or infinite `seconds` becomes a JSON null (`JSON.stringify` writes null, and the edit + then becomes `edit-invalid`). A `-0` becomes `+0`, because it is written as `0`. + +`tp_apply_edits` (tl_edits.c) takes `const tp_json *edits, size_t count`. The wire door passes +the array's elements, and the typed API passes `tp_edit_json` of each edit. The result is a +`tp_raw_edit_result`. `tp_raw_edit_result_result` types it. + +## Calling conventions + +- Go passes a struct by value or by pointer, and the C prototype does the same. Results are + returned by value. The exceptions are heap-like objects (`tp_engine`, `tp_ctx`, + `tp_credit_lists`, `tp_work_line`, `tp_parser`, `tp_tables`), which come back as `tp_alloc` + pointers. +- A Go `(T, bool)` return becomes `bool f(..., T *out)`, and `out` is written only on true. + Functions whose comment says "always written" are the `(A, B)` form: `tp_scan`'s + `*unbalanced`, `tp_peel_suffixes`' `*peeled` and `tp_split_youtube_pipes`' `*pipe_title`. +- `ctx` is always `tp_ctx *` (mutable: warnings and the list id). Tables are + `const tp_tables *`. The engine is `const tp_engine *`. +- Offsets in `pos` fields and `skel.pos` are absolute UTF-16 units, as computed by `tp_scan`. + Indices into `tp_runes` are code points. + +## Names that deviate from the plain convention + +- `tp_api_*` is used for the trackparse.go functions (`Parse`, `ParseWith`, `ParseArtists`, + `ParseArtistsWith`, `Format`, `FormatWith`, `Normalize`, `AllArtists`, `ParseTracklist`, + `ParseTracklistWith`, `ApplyEdits`, `ApplyEditsWith`), because `tp_normalize`, + `tp_parse_tracklist`, `tp_apply_edits` and `tp_all_artists` are already the internal + functions. The `Parser` methods keep their names (`tp_new_parser`, `tp_parser_parse`...). +- `tp_edit_set_time`, `tp_edit_shift`, ... `tp_edit_delete` are Go's `SetTime` ... `Delete`. + rt.h's `tp_insert` macro would swallow a function named `tp_insert`. +- The private `featMode` enum values are `TP_FEAT_MODE_SOURCE` and so on, because + `TP_FEAT_SOURCE` is the `FeatPlacement` string. +- Fields named `explicit` are `explicit_`, matching the public header (C++ keyword). +- Engine and ctx methods: `tp_engine_new`, `tp_engine_new_ctx`, `tp_engine_stage`, + `tp_engine_run`, `tp_engine_run_artists`, `tp_engine_probe`, `tp_ctx_warn`, and + `tp_line_probe_finish` (for `(p *lineProbe) finish`). Package `finish` is `tp_finish`. +- `marshal(v)` is one function per type: `tp_track_json`, `tp_artists_json`, + `tp_tracklist_json`, `tp_edit_result_json`, `tp_raw_edit_result_json` and `tp_string_json`. +- The credits.go section comes before classify.go, because `tp_classification` holds a + `tp_list_result` by value. +- C additions with no Go function: `tp_name_index`, `tp_tables_tight_joiner`, `tp_data_strs`, + `tp_group_map_put` / `_get`, `tp_offsets` / `tp_offset_at`, `tp_sorted_has`, `tp_jw_new`, + `tp_jw_done`, `tp_jw_opt_int64`, `tp_json_get_string` (Go `getString`) and `tp_edit_json` + (Go `jsonOf`). + +## Recursion + +The only recursive function is `tp_json_write`. Its depth is bounded by the reader's +`TP_JSON_MAX_DEPTH` (200) and, for `tp_edit_json` values, by 2. diff --git a/c/src/artists.c b/c/src/artists.c new file mode 100644 index 0000000..4ef8bad --- /dev/null +++ b/c/src/artists.c @@ -0,0 +1,133 @@ +/* artists.c: R7, the artist side (go/artists.go). The list splitting is credits.c. */ +#include "internal.h" + +/* findFeatMarker is R7.2: the leftmost unbracketed feat marker at or after from, with a space (or + * placeholder) on its left and a space on its right. */ +TP_PRIVATE bool tp_find_feat_marker(const tp_skel *s, tp_ctx *c, ptrdiff_t from, + tp_feat_marker *out) { + tp_word_span_vec spans = tp_word_spans(s->text); + tp_strvec words = tp_span_texts(spans); + for (size_t i = 0; i < spans.n; i++) { + tp_word_span span = spans.p[i]; + tp_rune b; + tp_phrase_match m; + ptrdiff_t last_index; + tp_word_span last; + if (span.start < from) continue; + b = tp_before(s->text, span.start); + if (b != ' ' && b != TP_PH) continue; + if (!tp_phrase_table_match_at(c->t->feat_markers, words, (ptrdiff_t)i, &m)) continue; + last_index = (ptrdiff_t)i + m.length - 1; + if (last_index < 0 || last_index >= (ptrdiff_t)spans.n) continue; + last = spans.p[last_index]; + if (tp_at(s->text, last.end) != ' ') continue; + out->start = span.start; + out->end = last.end; + out->marker = tp_runes_str(tp_sub(s->text, span.start, last.end)); + return true; + } + return false; +} + +static int by_credit_pos(const void *a, const void *b, void *ctx) { + ptrdiff_t pa = ((const tp_credit *)a)->pos, pb = ((const tp_credit *)b)->pos; + (void)ctx; + return pa < pb ? -1 : (pa > pb ? 1 : 0); +} + +static void take_list(tp_artist_side_result *result, const tp_list_result *l) { + tp_append(result->credits, l->credits); + tp_append(result->years, l->years); + if (l->unknown) result->unknown_artist = true; +} + +/* parseArtistSide is R7.1 to R7.5 over an artist-side skeleton. */ +TP_PRIVATE tp_artist_side_result tp_parse_artist_side(const tp_skel *side, tp_ctx *c) { + tp_artist_side_result result; + tp_idxvec removed = {0}; /* ascending: groupsOf order */ + tp_indexed_group_vec groups = tp_groups_of(side); + tp_skel text, main_skel; + tp_feat_marker feat; + bool has_feat; + tp_list_options opts; + tp_list_result main_list; + memset(&result, 0, sizeof result); + + /* R7.1 */ + for (size_t i = 0; i < groups.n; i++) { + const tp_group *g = groups.p[i].group; + tp_site st; + tp_classification cl; + st.source = TP_SOURCE_ARTIST; + st.delimiter = g->open; + st.pos = g->pos; + cl = tp_classify(g->inner, st, c); + switch (cl.kind) { + case TP_CLASS_FEAT: + case TP_CLASS_PRODUCER: + take_list(&result, &cl.list); + break; + case TP_CLASS_FLAG: + if (cl.flag == TP_FLAG_EXPLICIT) { + result.explicit_ = true; + } else { + result.clean = true; + } + break; + case TP_CLASS_YEAR: { + tp_positioned_year y; + y.year = cl.year; + y.pos = g->pos; + tp_push(result.years, y); + break; + } + case TP_CLASS_JUNK: { + tp_positioned_junk j; + j.raw = g->inner; + j.kind = cl.junk; + j.pos = g->pos; + tp_push(result.junk, j); + break; + } + case TP_CLASS_UNKNOWN: + case TP_CLASS_VERSIONS: + default: + /* Versions and unknown groups stay in the names. */ + continue; + } + tp_push(removed, g->pos); + } + text = tp_remove_groups(side, removed); + + /* R7.2 */ + has_feat = tp_find_feat_marker(&text, c, 0, &feat); + if (has_feat) { + tp_skel head = tp_slice_skel(&text, 0, feat.start); + main_skel = tp_trim_skel(&head); + } else { + main_skel = tp_trim_skel(&text); + } + memset(&opts, 0, sizeof opts); + opts.role = TP_ROLE_PRIMARY; + opts.source = TP_SOURCE_ARTIST; + opts.split_with = true; + main_list = tp_split_credits(&main_skel, &opts, c); + take_list(&result, &main_list); + if (has_feat) { + tp_skel rest = tp_slice_from(&text, feat.end); + tp_skel trimmed = tp_trim_skel(&rest); + tp_str *marker = tp_alloc(sizeof *marker); + tp_list_result featured; + *marker = feat.marker; + memset(&opts, 0, sizeof opts); + opts.role = TP_ROLE_FEATURED; + opts.source = TP_SOURCE_ARTIST; + opts.lead = marker; + opts.feat_markers_join = true; + featured = tp_split_credits(&trimmed, &opts, c); + take_list(&result, &featured); + } + /* Stable, like the JS sort. */ + tp_sort_stable(result.credits.p, result.credits.n, sizeof *result.credits.p, by_credit_pos, NULL); + return result; +} diff --git a/c/src/assemble.c b/c/src/assemble.c new file mode 100644 index 0000000..d226211 --- /dev/null +++ b/c/src/assemble.c @@ -0,0 +1,200 @@ +/* assemble.c: R9 assembly and dedup (go/assemble.go, js/src/assemble.ts). */ +#include "internal.h" + +/* precedence is the R9.2 role order: a later duplicate with a higher one upgrades the kept + * entry. */ +TP_PRIVATE ptrdiff_t tp_precedence(tp_role role) { + if (tp_str_eq(role, TP_ROLE_PRIMARY)) return 2; + if (tp_str_eq(role, TP_ROLE_FEATURED)) return 1; + return 0; +} + +/* toArtist is the public form of a credit. */ +TP_PRIVATE tp_artist tp_to_artist(tp_credit c) { + tp_artist a; + a.name = c.name; + a.role = c.role; + a.joiner = c.joiner; + a.source = c.source; + return a; +} + +/* The heap of list (Go l.heaps[list]), grown on demand. List ids are 0..ctx.list_seq-1; a + * negative id (never produced) gets no heap. */ +static tp_idxvec *heap_of(tp_credit_lists *l, ptrdiff_t list) { + if (list < 0) return NULL; + if ((size_t)list >= l->heaps.n) { + size_t k = (size_t)list + 1 - l->heaps.n; + (void)tp_push_n(l->heaps, k); + } + return &l->heaps.p[list]; +} + +/* creditLists holds the remaining names of each credit list, so "the list's first remaining + * name" and "the next one" are cheap and dedup stays near-linear (O(n log n)) on inputs with + * thousands of duplicate credits. Each list is a min-heap of entry indexes with lazy deletion. + */ +TP_PRIVATE tp_credit_lists *tp_new_credit_lists(tp_dedup_entry_vec entries) { + tp_credit_lists *l = tp_alloc(sizeof *l); + l->entries = entries; + for (size_t i = 0; i < entries.n; i++) { + tp_credit_lists_insert(l, entries.p[i].list, (ptrdiff_t)i); + } + return l; +} + +/* member reports whether entry x is a remaining name of list. */ +TP_PRIVATE bool tp_credit_lists_member(const tp_credit_lists *l, ptrdiff_t list, ptrdiff_t x) { + return x >= 0 && x < (ptrdiff_t)l->entries.n && l->entries.p[x].alive && + l->entries.p[x].list == list; +} + +/* insert puts entry e on the heap of list. */ +TP_PRIVATE void tp_credit_lists_insert(tp_credit_lists *l, ptrdiff_t list, ptrdiff_t e) { + tp_idxvec *h = heap_of(l, list); + if (h == NULL) return; + tp_push(*h, e); + /* Sift up. */ + for (size_t i = h->n - 1; i > 0;) { + size_t p = (i - 1) / 2; + if (h->p[p] <= h->p[i]) break; + ptrdiff_t tmp = h->p[p]; + h->p[p] = h->p[i]; + h->p[i] = tmp; + i = p; + } +} + +/* pop removes the smallest index of list's heap. */ +TP_PRIVATE void tp_credit_lists_pop(tp_credit_lists *l, ptrdiff_t list) { + tp_idxvec *h = heap_of(l, list); + if (h == NULL || h->n == 0) return; + h->p[0] = h->p[h->n - 1]; + h->n--; + /* Sift down. */ + for (size_t i = 0;;) { + size_t a = 2 * i + 1, b = 2 * i + 2, m = i; + if (a < h->n && h->p[a] < h->p[m]) m = a; + if (b < h->n && h->p[b] < h->p[m]) m = b; + if (m == i) break; + ptrdiff_t tmp = h->p[m]; + h->p[m] = h->p[i]; + h->p[i] = tmp; + i = m; + } +} + +/* first is the smallest remaining index of list after dropping stale heap entries, or -1. */ +TP_PRIVATE ptrdiff_t tp_credit_lists_first(tp_credit_lists *l, ptrdiff_t list) { + for (;;) { + tp_idxvec *h = heap_of(l, list); + if (h == NULL || h->n == 0) return -1; + if (tp_credit_lists_member(l, list, h->p[0])) return h->p[0]; + tp_credit_lists_pop(l, list); + } +} + +/* heir is the entry that follows e in list when e is the list's first remaining name, else -1. + * It must only be called when e is about to leave list: it takes e off the heap. */ +TP_PRIVATE ptrdiff_t tp_credit_lists_heir(tp_credit_lists *l, ptrdiff_t list, ptrdiff_t e) { + if (tp_credit_lists_first(l, list) != e) return -1; + for (;;) { + tp_idxvec *h = heap_of(l, list); + if (h == NULL || h->n == 0) return -1; + ptrdiff_t x = h->p[0]; + if (x != e && tp_credit_lists_member(l, list, x)) return x; + tp_credit_lists_pop(l, list); + } +} + +/* passJoiner is R7.6: entry e leaves its list. If it was the list's first remaining name, the + * next remaining name of that list takes joiner. */ +TP_PRIVATE void tp_credit_lists_pass_joiner(tp_credit_lists *l, ptrdiff_t e, const tp_str *joiner) { + if (e < 0 || e >= (ptrdiff_t)l->entries.n) return; + ptrdiff_t next = tp_credit_lists_heir(l, l->entries.p[e].list, e); + if (next >= 0) l->entries.p[next].a.joiner = joiner; +} + +/* dedupKeyOf is the R9.2 key: producers are a separate credit class, deduped only among + * themselves. */ +TP_PRIVATE tp_str tp_dedup_key_of(const tp_artist *a) { + tp_str cls = tp_str_eq(a->role, TP_ROLE_PRODUCER) ? TP_S("p:") : TP_S("c:"); + return tp_concat(cls, tp_dedup_key(a->name)); +} + +/* dedupArtists is R9.2: keep the first occurrence. A later lower/equal-precedence duplicate is + * removed (R7.6 joiner inheritance); a later higher-precedence duplicate (role upgrade) gives the + * kept entry its role, joiner and source, and the kept entry moves into that occurrence's list. */ +TP_PRIVATE tp_artist_vec tp_dedup_artists(tp_credit_vec credits) { + tp_dedup_entry_vec entries = {0}; + if (credits.n > 0) (void)tp_push_n(entries, credits.n); + for (size_t i = 0; i < credits.n; i++) { + entries.p[i].a = tp_to_artist(credits.p[i]); + entries.p[i].list = credits.p[i].list; + entries.p[i].alive = true; + } + tp_credit_lists *lists = tp_new_credit_lists(entries); + tp_map index = {0}; + for (size_t i = 0; i < entries.n; i++) { + tp_dedup_entry *e = &entries.p[i]; + tp_str key = tp_dedup_key_of(&e->a); + int64_t k64; + if (!tp_map_get(&index, key, &k64)) { + tp_map_put(&index, key, (int64_t)i); + continue; + } + ptrdiff_t k = (ptrdiff_t)k64; + tp_dedup_entry *kept = &entries.p[k]; + if (tp_precedence(e->a.role) > tp_precedence(kept->a.role)) { + tp_credit_lists_pass_joiner(lists, k, kept->a.joiner); + kept->a.role = e->a.role; + kept->a.joiner = e->a.joiner; + kept->a.source = e->a.source; + kept->list = e->list; + tp_credit_lists_insert(lists, e->list, k); + } else { + tp_credit_lists_pass_joiner(lists, (ptrdiff_t)i, e->a.joiner); + } + e->alive = false; + } + tp_artist_vec out = {0}; + for (size_t i = 0; i < entries.n; i++) { + if (entries.p[i].alive) tp_push(out, entries.p[i].a); + } + return out; +} + +/* toVersion is the public form of a version draft. Version types are strings, so a type added + * through keywords.versionHeads reaches the output as given. */ +TP_PRIVATE tp_version tp_to_version(tp_version_draft v) { + tp_version out; + memset(&out, 0, sizeof out); + for (size_t i = 0; i < v.artists.n; i++) tp_push(out.artists, tp_to_artist(v.artists.p[i])); + tp_clone(out.modifiers, v.modifiers); + out.type = v.vtype; + out.raw = v.raw; + out.descriptor = v.descriptor; + out.year = v.year; + out.unknown_artist = v.unknown_artist; + out.delimiter = v.delimiter; + return out; +} + +/* renderVersion is R9.4: a version rendered with its delimiter. */ +TP_PRIVATE tp_str tp_render_version(tp_str raw, tp_delimiter delimiter) { + if (tp_str_eq(delimiter, TP_DELIMITER_PAREN)) return tp_concat3(TP_S("("), raw, TP_S(")")); + if (tp_str_eq(delimiter, TP_DELIMITER_SQUARE)) return tp_concat3(TP_S("["), raw, TP_S("]")); + if (tp_str_eq(delimiter, TP_DELIMITER_CURLY)) return tp_concat3(TP_S("{"), raw, TP_S("}")); + return tp_concat(TP_S("- "), raw); +} + +/* fullTitleOf is R9.4: the title followed by its versions as written, empty pieces skipped. */ +TP_PRIVATE tp_str tp_full_title_of(tp_str title, tp_version_vec versions) { + tp_strvec pieces = {0}; + if (title.n > 0) tp_push(pieces, title); + for (size_t i = 0; i < versions.n; i++) { + tp_str s = tp_render_version(versions.p[i].raw, versions.p[i].delimiter); + if (s.n > 0) tp_push(pieces, s); + } + return tp_join(pieces, TP_S(" ")); +} diff --git a/c/src/classify.c b/c/src/classify.c new file mode 100644 index 0000000..8ded558 --- /dev/null +++ b/c/src/classify.c @@ -0,0 +1,524 @@ +/* classify.c: R5, classification of a group's inner text (also used for dash suffixes and pipe + * segments) (go/classify.go). */ +#include "internal.h" + +static const tp_str explicit_flags[] = { + {"explicit", 8}, {"explicit version", 16}, {"dirty", 5}, {"dirty version", 13}}; +static const tp_str clean_flags[] = {{"clean", 5}, {"clean version", 13}, {"radio clean", 11}}; + +static tp_classification class_of(tp_class_kind kind) { + tp_classification out; + memset(&out, 0, sizeof out); + out.kind = kind; + return out; +} + +static const tp_str *classify_str_ptr(tp_str s) { + tp_str *p = tp_alloc(sizeof *p); + *p = s; + return p; +} + +static const ptrdiff_t *int_ptr(ptrdiff_t v) { + ptrdiff_t *p = tp_alloc(sizeof *p); + *p = v; + return p; +} + +/* words[a:b] as a read-only view (cap == length, so an append copies). */ +static tp_strvec words_view(tp_strvec words, ptrdiff_t a, ptrdiff_t b) { + tp_strvec v; + v.p = words.p + a; + v.n = (size_t)(b - a); + v.cap = v.n; + return v; +} + +/* classify is R5 on inner (already trimmed and whitespace-collapsed). */ +TP_PRIVATE tp_classification tp_classify(tp_str inner, tp_site s, tp_ctx *c) { + tp_strvec words = tp_split_words(inner); + tp_str kind; + tp_classification credit; + tp_flag f; + tp_version_draft_vec versions; + if (words.n == 0) return class_of(TP_CLASS_UNKNOWN); + if (tp_junk_kind_of(words, c, &kind)) { + tp_classification out = class_of(TP_CLASS_JUNK); + out.junk = kind; + return out; + } + if (tp_feat_or_producer(inner, s, c, &credit)) return credit; + if (tp_flag_of(words, &f)) { + tp_classification out = class_of(TP_CLASS_FLAG); + out.flag = f; + return out; + } + if (words.n == 1 && tp_is_all_digits(words.p[0])) { + int year; + if (tp_year_of(words.p[0], &year)) { + tp_classification out = class_of(TP_CLASS_YEAR); + out.year = (ptrdiff_t)year; + return out; + } + } + if (tp_multi_version(inner, s, c, &versions) || tp_single_version(inner, s, c, &versions)) { + tp_classification out = class_of(TP_CLASS_VERSIONS); + out.versions = versions; + return out; + } + return class_of(TP_CLASS_UNKNOWN); +} + +/* ------------------------------------------------------------------------------------------ */ +/* R5.1 Junk */ + +/* junkKindOf is R5.1: the junk kind if the whole word list is junk vocabulary. */ +TP_PRIVATE bool tp_junk_kind_of(tp_strvec words, tp_ctx *c, tp_str *kind) { + const tp_tables *t = c->t; + tp_str first_kind = TP_EMPTY; + bool found = false; + ptrdiff_t n = (ptrdiff_t)words.n; + ptrdiff_t i = 0; + while (i < n) { + tp_str w = words.p[i]; + tp_phrase_match m; + int year; + bool is_year; + if (tp_phrase_table_match_at(t->junk_or_genre, words, i, &m)) { + if (!found) { + first_kind = *(const tp_str *)m.value; + found = true; + } + i += m.length; + continue; + } + /* R5.1: connectors and year words may sit between junk phrases: Official Video 2015. */ + is_year = tp_year_of(w, &year); + if (tp_word_set_has(&t->junk_connectors, w) || + tp_word_set_has(&t->junk_connectors, tp_word_key(w)) || is_year) { + i++; + continue; + } + found = false; + break; + } + /* JS truthiness: an empty kind (possible through keywords.junk) does not count. */ + if (found && first_kind.n != 0) { + *kind = first_kind; + return true; + } + if (n >= 2 && tp_in_vocab(words.p[n - 1], &t->label_suffixes)) { + *kind = TP_JUNK_KIND_LABEL; + return true; + } + return false; +} + +/* ------------------------------------------------------------------------------------------ */ +/* R5.2 Feat, R5.3 Producer */ + +TP_PRIVATE bool tp_feat_or_producer(tp_str inner, tp_site s, tp_ctx *c, tp_classification *out) { + const tp_tables *t = c->t; + tp_runes text = tp_runes_of(inner); + tp_word_span_vec spans = tp_word_spans(text); + tp_strvec words = tp_span_texts(spans); + ptrdiff_t nwords = (ptrdiff_t)words.n; + ptrdiff_t feat_len = 0, n; + bool bracket_only = false; + tp_phrase_match m, prod; + if (tp_phrase_table_match_at(t->feat_markers, words, 0, &m)) { + feat_len = m.length; + } else if (tp_phrase_table_match_at(t->bracket_only_feat, words, 0, &m)) { + feat_len = m.length; + bracket_only = true; + } + if (feat_len > 0 && nwords > feat_len) { + bool stop = bracket_only && feat_len < nwords && tp_in_vocab(words.p[feat_len], &t->stopwords); + if (!stop) { + tp_list_result r; + if (!tp_credits_after(text, spans, feat_len, TP_ROLE_FEATURED, s, c, &r)) return false; + *out = class_of(TP_CLASS_FEAT); + out->list = r; + return true; + } + } + if (!tp_phrase_table_match_at(t->producer_markers, words, 0, &prod)) return false; + n = prod.length; + if (n < nwords && tp_str_eq(tp_word_key(words.p[n]), TP_S("by"))) n++; + if (nwords > n) { + tp_list_result r; + if (!tp_credits_after(text, spans, n, TP_ROLE_PRODUCER, s, c, &r)) return false; + *out = class_of(TP_CLASS_PRODUCER); + out->list = r; + return true; + } + return false; +} + +TP_PRIVATE bool tp_credits_after(tp_runes inner, tp_word_span_vec spans, ptrdiff_t marker_words, + tp_role role, tp_site s, tp_ctx *c, tp_list_result *out) { + tp_word_span first, last_marker, first_name; + tp_list_options opts; + ptrdiff_t base; + if (spans.n == 0 || marker_words < 1 || marker_words >= (ptrdiff_t)spans.n) return false; + first = spans.p[0]; + last_marker = spans.p[marker_words - 1]; + first_name = spans.p[marker_words]; + memset(&opts, 0, sizeof opts); + opts.role = role; + opts.source = s.source; + opts.lead = classify_str_ptr(tp_runes_str(tp_sub(inner, first.start, last_marker.end))); + opts.split_with = false; + opts.feat_markers_join = tp_str_eq(role, TP_ROLE_FEATURED); + /* Offsets are UTF-16 units (see the scanner). */ + base = s.pos + 1 + tp_utf16_len(tp_sub(inner, 0, first_name.start)); + *out = tp_list_from_text(tp_tail(inner, first_name.start), base, c, &opts); + return true; +} + +/* listFromText splits a plain string (nested brackets protected by a fresh scan) as a credit + * list. */ +TP_PRIVATE tp_list_result tp_list_from_text(tp_runes text, ptrdiff_t base, tp_ctx *c, + const tp_list_options *opts) { + bool unbalanced; + tp_skel s = tp_scan(text, base, &unbalanced); + return tp_split_credits(&s, opts, c); +} + +/* ------------------------------------------------------------------------------------------ */ +/* R5.4 Flag */ + +TP_PRIVATE bool tp_flag_of(tp_strvec words, tp_flag *out) { + tp_strvec keys = {0}; + tp_str key; + for (size_t i = 0; i < words.n; i++) tp_push(keys, tp_word_key(words.p[i])); + key = tp_join(keys, TP_S(" ")); + for (size_t i = 0; i < TP_COUNT(explicit_flags); i++) { + if (tp_str_eq(key, explicit_flags[i])) { + *out = TP_FLAG_EXPLICIT; + return true; + } + } + for (size_t i = 0; i < TP_COUNT(clean_flags); i++) { + if (tp_str_eq(key, clean_flags[i])) { + *out = TP_FLAG_CLEAN; + return true; + } + } + return false; +} + +/* ------------------------------------------------------------------------------------------ */ +/* R5.6 Multi-version */ + +/* splitMultiParts splits at top-level " / " or "; " (outside nested brackets). */ +TP_PRIVATE tp_strvec tp_split_multi_parts(tp_runes inner) { + tp_runes_vec parts = {0}; + tp_strvec out = {0}; + ptrdiff_t depth = 0, start = 0; + for (ptrdiff_t i = 0; i < (ptrdiff_t)inner.n; i++) { + tp_rune ch = inner.p[i]; + if (ch == '(' || ch == '[' || ch == '{') { + depth++; + } else if ((ch == ')' || ch == ']' || ch == '}') && depth > 0) { + depth--; + } else if (depth == 0 && ch == '/' && tp_before(inner, i) == ' ' && + tp_at(inner, i + 1) == ' ') { + tp_push(parts, tp_sub(inner, start, i - 1)); + start = i + 2; + } else if (depth == 0 && ch == ';' && tp_at(inner, i + 1) == ' ') { + tp_push(parts, tp_sub(inner, start, i)); + start = i + 2; + } + } + tp_push(parts, tp_tail(inner, start)); + for (size_t i = 0; i < parts.n; i++) tp_push(out, tp_js_trim(tp_runes_str(parts.p[i]))); + return out; +} + +TP_PRIVATE bool tp_multi_version(tp_str inner, tp_site s, tp_ctx *c, tp_version_draft_vec *out) { + tp_strvec parts = tp_split_multi_parts(tp_runes_of(inner)); + tp_version_draft_vec all = {0}; + if (parts.n < 2) return false; + for (size_t i = 0; i < parts.n; i++) { + tp_version_draft_vec vs; + if (parts.p[i].n == 0) return false; + if (!tp_single_version(parts.p[i], s, c, &vs)) return false; + tp_append(all, vs); + } + *out = all; + return true; +} + +/* ------------------------------------------------------------------------------------------ */ +/* R5.7 Version */ + +static tp_version_draft_vec one_version(tp_version_draft v) { + tp_version_draft_vec out = {0}; + tp_push(out, v); + return out; +} + +TP_PRIVATE bool tp_single_version(tp_str raw, tp_site s, tp_ctx *c, tp_version_draft_vec *out) { + tp_runes text = tp_runes_of(raw); + tp_word_span_vec spans = tp_word_spans(text); + tp_strvec words = tp_span_texts(spans); + tp_version_draft v; + if (tp_head_by(raw, text, spans, words, s, c, &v) || tp_head_scan(raw, words, s, c, &v) || + tp_prefix_form(raw, words, s, c, &v)) { + *out = one_version(v); + return true; + } + return false; +} + +TP_PRIVATE tp_version_draft tp_base_version(tp_str raw, tp_str vtype, tp_site s) { + tp_version_draft v; + memset(&v, 0, sizeof v); + v.vtype = vtype; + v.raw = raw; + v.delimiter = s.delimiter; + v.pos = s.pos; + return v; +} + +TP_PRIVATE tp_list_options tp_remixer_opts(void) { + tp_list_options o; + memset(&o, 0, sizeof o); + o.role = TP_ROLE_REMIXER; + o.source = TP_SOURCE_VERSION; + return o; +} + +/* dedupRemixers is R9.2 for remixers: deduped within their own version only. */ +TP_PRIVATE tp_credit_vec tp_dedup_remixers(tp_credit_vec credits) { + tp_map seen; + tp_credit_vec out = {0}; + memset(&seen, 0, sizeof seen); + for (size_t i = 0; i < credits.n; i++) { + tp_str key = tp_dedup_key(credits.p[i].name); + if (tp_map_has(&seen, key)) continue; + tp_map_put(&seen, key, 0); + tp_push(out, credits.p[i]); + } + return out; +} + +TP_PRIVATE void tp_set_credits(tp_version_draft *v, tp_runes text, tp_site s, tp_ctx *c) { + tp_list_options opts = tp_remixer_opts(); + tp_list_result r = tp_list_from_text(text, s.pos, c, &opts); + v->artists = tp_dedup_remixers(r.credits); + if (r.unknown) v->unknown_artist = true; + /* R7.5: a dropped year-only name sets the version's year if it is still null. */ + if (r.years.n > 0 && v->year == NULL) v->year = int_ptr(r.years.p[0].year); +} + +/* headBy is R5.7.1: Remix by Skrillex. */ +TP_PRIVATE bool tp_head_by(tp_str raw, tp_runes text, tp_word_span_vec spans, tp_strvec words, + tp_site s, tp_ctx *c, tp_version_draft *out) { + tp_phrase_match head; + tp_str by; + tp_word_span rest; + tp_version_draft v; + if (!tp_phrase_table_match_at(c->t->heads, words, 0, &head) || + head.length + 1 >= (ptrdiff_t)spans.n || head.length >= (ptrdiff_t)words.n) { + return false; + } + by = words.p[head.length]; + rest = spans.p[head.length + 1]; + if (!tp_str_eq(tp_word_key(by), TP_S("by"))) return false; + v = tp_base_version(raw, *(const tp_str *)head.value, s); + tp_set_credits(&v, tp_tail(text, rest.start), s, c); + *out = v; + return true; +} + +/* collectRun walks left from end collecting the modifier run (R5.7.2). */ +TP_PRIVATE tp_run_item_vec tp_collect_run(tp_strvec words, ptrdiff_t end, tp_ctx *c) { + tp_run_item_vec items = {0}; + ptrdiff_t j = end; + while (j > 0) { + tp_phrase_match m; + tp_run_item item; + int year; + memset(&item, 0, sizeof item); + if (tp_phrase_table_match_ending(c->t->run_words, words, j, &m)) { + item.start = j - m.length; + item.end = j; + item.info = *(const tp_run_info *)m.value; + tp_push(items, item); + j -= m.length; + continue; + } + if (!tp_year_of(words.p[j - 1], &year)) break; + item.start = j - 1; + item.end = j; + item.year = int_ptr((ptrdiff_t)year); + tp_push(items, item); + j--; + } + if (items.n > 1) { + for (size_t a = 0, b = items.n - 1; a < b; a++, b--) { + tp_run_item tmp = items.p[a]; + items.p[a] = items.p[b]; + items.p[b] = tmp; + } + } + return items; +} + +/* truthyName is a JS truthiness test on an optional type name: NULL and "" do not count. */ +TP_PRIVATE bool tp_truthy_name(const tp_str *s, tp_str *out) { + if (s == NULL || s->n == 0) return false; + *out = *s; + return true; +} + +/* headScan is R5.7.2: Extended VIP Mix, Skrillex Remix, Taylor's Version. */ +TP_PRIVATE bool tp_head_scan(tp_str raw, tp_strvec words, tp_site s, tp_ctx *c, + tp_version_draft *out) { + const tp_tables *t = c->t; + tp_phrase_match head; + tp_str head_type, vtype, left_capable = TP_EMPTY, nearest_type = TP_EMPTY; + ptrdiff_t head_start, credit_end, left, type_item = -1, nearest_head = -1; + tp_run_item_vec run; + tp_strvec credit_words, descriptors = {0}; + bool generic, via_mix = false, left_ok = false, nearest_ok = false; + tp_version_draft v; + + if (!tp_phrase_table_match_ending(t->heads, words, (ptrdiff_t)words.n, &head)) return false; + head_type = *(const tp_str *)head.value; + head_start = (ptrdiff_t)words.n - head.length; + run = tp_collect_run(words, head_start, c); + credit_end = head_start; + if (run.n > 0) credit_end = run.p[0].start; + credit_words = words_view(words, 0, credit_end); + left = (ptrdiff_t)run.n - 1; /* -1: no run */ + + /* R5.7.2 type resolution. Generic = canonical type mix/edit/version, any spelling. */ + generic = tp_word_set_has(&t->generic_head_types, head_type); + vtype = head_type; + if (generic) nearest_head = tp_nearest_non_generic_head(run, c); + if (left >= 0) left_ok = tp_truthy_name(run.p[left].info.type_capable, &left_capable); + if (nearest_head >= 0) nearest_ok = tp_truthy_name(run.p[nearest_head].info.head, &nearest_type); + if (generic && left_ok) { + vtype = left_capable; + type_item = left; + } else if (nearest_ok) { + /* 2011 Remastered Version: remaster */ + vtype = nearest_type; + type_item = nearest_head; + } else if (tp_str_eq(head_type, TP_S("mix")) && credit_words.n > 0) { + vtype = TP_S("remix"); + via_mix = true; + } + v = tp_base_version(raw, vtype, s); + + for (size_t i = 0; i < run.n; i++) { + const tp_run_item *item = &run.p[i]; + const tp_str *modifier; + if (item->year != NULL) { + if (v.year == NULL) v.year = int_ptr(*item->year); + continue; + } + modifier = item->info.type_capable; + if (modifier == NULL) modifier = item->info.descriptor; + if (modifier != NULL) { + if ((ptrdiff_t)i != type_item && !tp_contains_string(v.modifiers, *modifier)) { + tp_push(v.modifiers, *modifier); + } + } else if (item->info.genre) { + tp_push(descriptors, tp_join(words_view(words, item->start, item->end), TP_S(" "))); + } + } + + if (credit_words.n > 0) { + tp_str credit = tp_join(credit_words, TP_S(" ")); + tp_str last_word = tp_ascii_lower(tp_last(credit_words)); + if (tp_is_unknown_token(credit, t)) { + v.unknown_artist = true; + } else if (tp_str_eq(vtype, TP_S("version")) || tp_str_eq(vtype, TP_S("cover")) || + tp_is_all_junk_phrases(credit_words, c)) { + /* R5.7.2: Japanese Version, Taylor's Version, Adele Cover, Video Edit. */ + tp_strvec d = {0}; + tp_push(d, credit); + tp_append(d, descriptors); + descriptors = d; + } else { + tp_runes name = tp_runes_of(credit); + size_t n; + if (tp_has_suffix(last_word, TP_S("'s"))) name.n = name.n >= 2 ? name.n - 2 : 0; + tp_set_credits(&v, name, s, c); + n = v.artists.n; + if (via_mix && n > 0 && tp_split_words(v.artists.p[n - 1].name).n >= 3) { + v.ambiguous_mix = true; + } + } + } + if (descriptors.n > 0) v.descriptor = classify_str_ptr(tp_join(descriptors, TP_S(" "))); + *out = v; + return true; +} + +/* containsString reports whether list holds s. */ +TP_PRIVATE bool tp_contains_string(tp_strvec list, tp_str s) { + for (size_t i = 0; i < list.n; i++) { + if (tp_str_eq(list.p[i], s)) return true; + } + return false; +} + +/* nearestNonGenericHead is R5.7.2 type rule 2: the index of the non-generic head in the run + * nearest the (generic) head, or -1. */ +TP_PRIVATE ptrdiff_t tp_nearest_non_generic_head(tp_run_item_vec run, tp_ctx *c) { + for (ptrdiff_t i = (ptrdiff_t)run.n - 1; i >= 0; i--) { + const tp_str *h = run.p[i].info.head; + if (h != NULL && !tp_word_set_has(&c->t->generic_head_types, *h)) return i; + } + return -1; +} + +/* isAllJunkPhrases is R5.7.2: the credit span is made entirely of junk phrases (Video in Video + * Edit). */ +TP_PRIVATE bool tp_is_all_junk_phrases(tp_strvec words, tp_ctx *c) { + ptrdiff_t i = 0; + while (i < (ptrdiff_t)words.n) { + tp_phrase_match m; + if (!tp_phrase_table_match_at(c->t->junk_phrases, words, i, &m)) return false; + i += m.length; + } + return words.n > 0; +} + +/* prefixForm is R5.7.3: Live at Wembley 1986, Remastered 2015, Sped Up. */ +TP_PRIVATE bool tp_prefix_form(tp_str raw, tp_strvec words, tp_site s, tp_ctx *c, + tp_version_draft *out) { + tp_phrase_match m; + tp_version_draft v; + tp_strvec rest = {0}, tail; + if (!tp_phrase_table_match_at(c->t->prefix_forms, words, 0, &m)) return false; + v = tp_base_version(raw, *(const tp_str *)m.value, s); + v.prefix_form = true; + tail = tp_tail_words(words, m.length); + for (size_t i = 0; i < tail.n; i++) { + tp_str w = tail.p[i]; + if (v.year == NULL) { + int year; + if (tp_year_of(w, &year)) { + v.year = int_ptr((ptrdiff_t)year); + continue; + } + } + tp_push(rest, w); + } + if (rest.n > 0) v.descriptor = classify_str_ptr(tp_join(rest, TP_S(" "))); + *out = v; + return true; +} + +/* tailWords is words[from:], or empty when from is past the end. */ +TP_PRIVATE tp_strvec tp_tail_words(tp_strvec words, ptrdiff_t from) { + tp_strvec none = {0}; + if (from < 0 || from >= (ptrdiff_t)words.n) return none; + return words_view(words, from, (ptrdiff_t)words.n); +} diff --git a/c/src/context.c b/c/src/context.c new file mode 100644 index 0000000..a5fdf88 --- /dev/null +++ b/c/src/context.c @@ -0,0 +1,98 @@ +/* context.c: the per-call parse context and the engine that holds what is computed once per + * Parser (go/context.go). */ +#include "internal.h" + +TP_PRIVATE tp_engine *tp_engine_new(tp_resolved_options o) { + tp_engine *e = tp_alloc(sizeof *e); + ptrdiff_t max_len = 0; + e->known_keys = tp_known_keys_of(o.known_artists, &max_len); + e->opts = o; + e->t = tp_tables_for(o.keywords); + e->known_max_len = max_len; + return e; +} + +static void *build_shared_engine(void) { + tp_resolved_options o; + memset(&o, 0, sizeof o); + return tp_engine_new(o); +} + +static tp_once shared_engine_once = TP_ONCE_INIT; + +/* sharedEngine is the engine behind Parse and ParseArtists without options. */ +TP_PRIVATE const tp_engine *tp_shared_engine(void) { + const tp_engine *e = tp_once_get(&shared_engine_once, build_shared_engine); + if (e == NULL) e = build_shared_engine(); + return e; +} + +TP_PRIVATE tp_ctx *tp_engine_new_ctx(const tp_engine *e) { + tp_ctx *c = tp_alloc(sizeof *c); + c->t = e->t; + c->known_keys = &e->known_keys; + c->known_max_len = e->known_max_len; + c->split_and = e->opts.split_and; + return c; +} + +/* knownKeysOf is the knownArtists part of a context: the dedup keys and the longest entry in + * UTF-16 units. */ +TP_PRIVATE tp_word_set tp_known_keys_of(tp_strvec known, ptrdiff_t *max_len) { + tp_word_set keys; + memset(&keys, 0, sizeof keys); + *max_len = 0; + for (size_t i = 0; i < known.n; i++) { + tp_str key = tp_dedup_key(known.p[i]); + ptrdiff_t n; + if (key.n != 0) tp_word_set_add(&keys, key); + n = tp_utf16_len_string(known.p[i]); + if (n > *max_len) *max_len = n; + } + return keys; +} + +TP_PRIVATE void tp_ctx_warn(tp_ctx *c, tp_warning w) { + if (tp_strvec_has(c->warnings, w)) return; + tp_push(c->warnings, w); +} + +/* matchKnownAt is R7.3a: the length (in code points) of the longest knownArtists entry matching + * text at start (dedup-key comparison), followed by the end, whitespace, "," or ";" (or extra, + * unless it is TP_NORUNE: R4.2 also accepts "-", so 3 Doors Down-Kryptonite is protected). 0 when + * none matches. The search window is 2 * longest + 8 UTF-16 units, exactly as in the JS + * reference. */ +TP_PRIVATE ptrdiff_t tp_match_known_at(tp_runes text, ptrdiff_t start, tp_ctx *c, tp_rune extra) { + ptrdiff_t n = (ptrdiff_t)text.n; + ptrdiff_t budget, limit, used; + if (c->known_keys == NULL || c->known_keys->m.n == 0 || start < 0) return 0; + budget = c->known_max_len * 2 + 8; + limit = start; + used = 0; + while (limit < n) { + ptrdiff_t w = text.p[limit] >= 0x10000 ? 2 : 1; + if (used + w > budget) break; + used += w; + limit++; + } + for (ptrdiff_t end = limit; end > start; end--) { + tp_rune next = tp_at(text, end); + bool boundary = end == n || next == ',' || next == ';' || tp_is_whitespace(next) || + (extra != TP_NORUNE && next == extra); + if (boundary) { + /* The key only answers yes or no: give its memory back at once. Without this a long + * input with a long known artist keeps every key (C port only; the GC ports free them). */ + tp_mark mark = tp_arena_mark(); + bool hit = + tp_word_set_has(c->known_keys, tp_dedup_key(tp_runes_str(tp_sub(text, start, end)))); + tp_arena_release(mark); + if (hit) return end - start; + } + } + return 0; +} + +TP_PRIVATE bool tp_is_known_artist(tp_str text, tp_ctx *c) { + return c->known_keys != NULL && c->known_keys->m.n > 0 && + tp_word_set_has(c->known_keys, tp_dedup_key(text)); +} diff --git a/c/src/credits.c b/c/src/credits.c new file mode 100644 index 0000000..f7fe325 --- /dev/null +++ b/c/src/credits.c @@ -0,0 +1,217 @@ +/* credits.c: R7.3 to R7.5, splitting a credit list into names (go/credits.go). */ +#include "internal.h" + +static const tp_str and_like[] = {{"&", 1}, {"and", 3}, {"+", 1}}; + +/* wordAt is the end of the word that starts at start. */ +TP_PRIVATE ptrdiff_t tp_word_at(tp_runes text, ptrdiff_t start) { + ptrdiff_t end = start; + while (end < (ptrdiff_t)text.n && !tp_is_whitespace(text.p[end])) end++; + return end; +} + +/* nextWord is the word after a joiner; a tight joiner (, ;) ends it, since the name ends there. */ +TP_PRIVATE tp_str tp_next_word(tp_runes text, ptrdiff_t from) { + ptrdiff_t n = (ptrdiff_t)text.n; + ptrdiff_t a = from, b; + while (a < n && tp_is_whitespace(text.p[a])) a++; + b = a; + while (b < n && !tp_is_whitespace(text.p[b]) && text.p[b] != ',' && text.p[b] != ';') b++; + return tp_runes_str(tp_sub(text, a, b)); +} + +/* findJoiner is R7.3b: the leftmost joiner occurrence at or after from, honouring the guards. */ +TP_PRIVATE bool tp_find_joiner(tp_runes text, ptrdiff_t from, bool split_at_comma, + const tp_list_options *opts, tp_ctx *c, tp_joiner_hit *out) { + ptrdiff_t n = (ptrdiff_t)text.n; + for (ptrdiff_t p = from > 0 ? from : 0; p < n; p++) { + tp_rune ch = text.p[p]; + ptrdiff_t end; + tp_str word; + if (ch == ',' || ch == ';') { + if (ch == ',' && tp_is_digit(tp_before(text, p)) && tp_is_digit(tp_at(text, p + 1))) { + continue; /* 1,000 */ + } + out->start = p; + out->end = p + 1; + out->raw = tp_runes_str(tp_sub(text, p, p + 1)); + return true; + } + if (p == 0 || tp_before(text, p) != ' ' || tp_is_whitespace(ch)) continue; + end = tp_word_at(text, p); + if (end >= n || text.p[end] != ' ') continue; /* spaced joiners need a space after */ + word = tp_runes_str(tp_sub(text, p, end)); + if (tp_is_spaced_joiner(word, text, end, split_at_comma, opts, c)) { + out->start = p; + out->end = end; + out->raw = word; + return true; + } + } + return false; +} + +TP_PRIVATE bool tp_is_spaced_joiner(tp_str word, tp_runes text, ptrdiff_t end, bool split_at_comma, + const tp_list_options *opts, tp_ctx *c) { + if (opts->feat_markers_join) { + tp_strvec one; + tp_phrase_match m; + one.p = &word; + one.n = 1; + one.cap = 1; + if (tp_phrase_table_match_at(c->t->feat_markers, one, 0, &m)) return true; + } + for (size_t i = 0; i < c->t->spaced_joiners.n; i++) { + const tp_spaced_joiner *j = &c->t->spaced_joiners.p[i]; + bool matches = j->case_sensitive ? tp_str_eq(word, j->raw) : tp_word_matches(word, j->raw); + if (!matches) continue; + if (tp_str_eq(j->raw, TP_S("with")) && !opts->split_with) return false; + if (j->is_and) { + if (c->split_and == TP_SPLIT_NEVER) return false; + if (c->split_and == TP_SPLIT_AUTO && !split_at_comma) return false; + } + if (tp_contains_string(tp_data_strs(and_like, TP_COUNT(and_like)), j->raw) && + tp_in_vocab(tp_next_word(text, end), &c->t->no_split_before)) { + return false; + } + return true; + } + return false; +} + +/* cleanName is R7.4: clean one raw name. */ +TP_PRIVATE tp_str tp_clean_name(tp_str raw) { + tp_runes name = tp_runes_of(tp_collapse_spaces(raw)); + tp_str s; + ptrdiff_t space; + size_t n = name.n; + if (n >= 2) { + tp_rune first = name.p[0]; + if ((first == '"' || first == '\'') && name.p[n - 1] == first) { + name = tp_runes_of(tp_collapse_runes(tp_runes_slice(name, 1, n - 1))); + } + } + s = tp_runes_str(name); + while (tp_has_suffix(s, TP_S(",")) || tp_has_suffix(s, TP_S(";"))) { + s = tp_js_trim_end(tp_str_slice(s, 0, s.n - 1)); + } + space = tp_index_byte(s, ' '); + if (space > 0 && tp_str_eq(tp_word_key(tp_str_slice(s, 0, (size_t)space)), TP_S("by"))) { + s = tp_str_slice(s, (size_t)space + 1, s.n); + } + return tp_collapse_spaces(s); +} + +/* unwrapList is R7.4: strip one pair of wrapping quotes from the whole list (no other such quote + * inside). */ +TP_PRIVATE tp_skel tp_unwrap_list(const tp_skel *list) { + tp_skel t = tp_trim_skel(list); + ptrdiff_t n = (ptrdiff_t)t.text.n; + tp_rune q; + ptrdiff_t next = -1; + tp_skel inner; + if (n < 2) return t; + q = t.text.p[0]; + if ((q != '"' && q != '\'') || t.text.p[n - 1] != q) return t; + /* indexOf(q, 1): the next such quote must be the last character. */ + for (ptrdiff_t i = 1; i < n; i++) { + if (t.text.p[i] == q) { + next = i; + break; + } + } + if (next != n - 1) return t; + inner = tp_slice_skel(&t, 1, n - 1); + return tp_trim_skel(&inner); +} + +/* splitCredits is R7.3: split input into credits. */ +TP_PRIVATE tp_list_result tp_split_credits(const tp_skel *input, const tp_list_options *opts, + tp_ctx *c) { + tp_skel list = tp_unwrap_list(input); /* R7.4: "Camo & Krooked" */ + tp_runes text = list.text; + ptrdiff_t n = (ptrdiff_t)text.n; + tp_raw_name_vec raw = {0}; + const tp_str *joiner = opts->lead; + bool split_at_comma = false; + ptrdiff_t start = 0; + while (start <= n) { + ptrdiff_t known, end, pos; + tp_joiner_hit hit = {0}; + bool found; + tp_skel piece; + tp_raw_name r; + tp_str *j; + while (start < n && tp_is_whitespace(text.p[start])) start++; + known = tp_match_known_at(text, start, c, '-'); /* R7.3a */ + found = tp_find_joiner(text, start + known, split_at_comma, opts, c, &hit); + end = found ? hit.start : n; + piece = tp_slice_skel(&list, start, end); + pos = 0; + if (start < (ptrdiff_t)list.pos.n) { + pos = list.pos.p[start]; + } else if (list.pos.n > 0) { + pos = tp_last(list.pos); + } + r.name = tp_clean_name(tp_render_skel(&piece)); + r.joiner = joiner; + r.pos = pos; + tp_push(raw, r); + joiner = NULL; + if (!found) break; + if (tp_str_eq(hit.raw, TP_S(",")) || tp_str_eq(hit.raw, TP_S(";"))) { + split_at_comma = true; /* R7.3: and after a tight joiner */ + } + start = hit.end; + j = tp_alloc(sizeof *j); + *j = hit.raw; + joiner = j; + } + return tp_finish_names(raw, opts, c); +} + +/* finishNames is the R7.4 empty drops and the R7.5 year/unknown drops. R7.6: the first survivor + * takes the lead joiner (NULL, or the feat/producer marker). */ +TP_PRIVATE tp_list_result tp_finish_names(tp_raw_name_vec raw, const tp_list_options *opts, + tp_ctx *c) { + tp_raw_name_vec named = {0}, kept = {0}; + size_t count; + tp_list_result out; + ptrdiff_t list; + memset(&out, 0, sizeof out); + for (size_t i = 0; i < raw.n; i++) { + if (raw.p[i].name.n != 0) tp_push(named, raw.p[i]); + } + count = named.n; + for (size_t i = 0; i < named.n; i++) { + tp_raw_name r = named.p[i]; + if (tp_is_unknown_token(r.name, c->t)) { + out.unknown = true; + continue; + } + if (tp_is_all_digits(r.name) && count > 1) { + int year; + if (tp_year_of(r.name, &year)) { + tp_positioned_year y; + y.year = (ptrdiff_t)year; + y.pos = r.pos; + tp_push(out.years, y); + continue; + } + } + tp_push(kept, r); + } + list = c->list_seq; + c->list_seq++; + for (size_t i = 0; i < kept.n; i++) { + tp_credit cr; + cr.name = kept.p[i].name; + cr.role = opts->role; + cr.joiner = i == 0 ? opts->lead : kept.p[i].joiner; + cr.source = opts->source; + cr.pos = kept.p[i].pos; + cr.list = list; + tp_push(out.credits, cr); + } + return out; +} diff --git a/c/src/data_gen.c b/c/src/data_gen.c new file mode 100644 index 0000000..27180c0 --- /dev/null +++ b/c/src/data_gen.c @@ -0,0 +1,482 @@ +/* Code generated by c/scripts/gen_data.mjs from spec/data and spec/VERSION. DO NOT EDIT. */ +#include "data_gen.h" + +TP_PRIVATE const tp_str tp_data_descriptors_descriptors[TP_DATA_DESCRIPTORS_DESCRIPTORS_N] = { + {"radio", 5}, + {"extended", 8}, + {"club", 4}, + {"original", 8}, + {"instrumental", 12}, + {"dub", 3}, + {"vip", 3}, + {"acoustic", 8}, + {"live", 4}, + {"demo", 4}, + {"vocal", 5}, + {"clean", 5}, + {"dirty", 5}, + {"explicit", 8}, + {"short", 5}, + {"long", 4}, + {"full", 4}, + {"album", 5}, + {"single", 6}, + {"alternate", 9}, + {"alt", 3}, + {"alternative", 11}, + {"main", 4}, + {"special", 7}, + {"bonus", 5}, + {"deluxe", 6}, + {"mono", 4}, + {"stereo", 6}, + {"new", 3}, + {"official", 8}, + {"orchestral", 10}, + {"piano", 5}, + {"unplugged", 9}, + {"12\"", 3}, + {"7\"", 2}, + {"12''", 4}, + {"7''", 3}, + {"12 inch", 7}, + {"7 inch", 6}, + {"re", 2}, + {"final", 5}, + {"second", 6}, + {"2nd", 3}, + {"3rd", 3}, +}; + +TP_PRIVATE const tp_str tp_data_extensions_extensions[TP_DATA_EXTENSIONS_EXTENSIONS_N] = { + {"mp3", 3}, + {"flac", 4}, + {"wav", 3}, + {"m4a", 3}, + {"ogg", 3}, + {"opus", 4}, + {"aac", 3}, + {"aiff", 4}, + {"aif", 3}, + {"wma", 3}, + {"alac", 4}, + {"mp4", 3}, + {"webm", 4}, + {"mkv", 3}, +}; + +TP_PRIVATE const tp_str tp_data_feat_markers_markers[TP_DATA_FEAT_MARKERS_MARKERS_N] = { + {"feat.", 5}, + {"feat", 4}, + {"ft.", 3}, + {"ft", 2}, + {"featuring", 9}, + {"feat:", 5}, + {"ft:", 3}, +}; + +TP_PRIVATE const tp_str tp_data_feat_markers_bracket_only[TP_DATA_FEAT_MARKERS_BRACKET_ONLY_N] = { + {"with", 4}, + {"w/", 2}, +}; + +TP_PRIVATE const tp_str tp_data_feat_markers_producer[TP_DATA_FEAT_MARKERS_PRODUCER_N] = { + {"prod.", 5}, + {"prod", 4}, + {"produced", 8}, + {"prod.by", 7}, + {"prod:", 5}, +}; + +TP_PRIVATE const tp_str tp_data_feat_markers_title_markers[TP_DATA_FEAT_MARKERS_TITLE_MARKERS_N] = { + {"feat.", 5}, + {"ft.", 3}, + {"featuring", 9}, +}; + +TP_PRIVATE const tp_str + tp_data_feat_markers_title_producer[TP_DATA_FEAT_MARKERS_TITLE_PRODUCER_N] = { + {"prod.", 5}, + {"prod. by", 8}, + {"produced by", 11}, + {"prod.by", 7}, +}; + +TP_PRIVATE const tp_str tp_data_genres_genres[TP_DATA_GENRES_GENRES_N] = { + {"d'n'b", 5}, + {"dnb", 3}, + {"d&b", 3}, + {"d & b", 5}, + {"drum & bass", 11}, + {"drum&bass", 9}, + {"drum and bass", 13}, + {"drum n bass", 11}, + {"drum 'n' bass", 13}, + {"drum'n'bass", 11}, + {"neurofunk", 9}, + {"neuro", 5}, + {"liquid", 6}, + {"liquid funk", 11}, + {"jump up", 7}, + {"jump-up", 7}, + {"jungle", 6}, + {"halftime", 8}, + {"dancefloor", 10}, + {"dubstep", 7}, + {"riddim", 6}, + {"brostep", 7}, + {"trap", 4}, + {"future bass", 11}, + {"house", 5}, + {"deep house", 10}, + {"tech house", 10}, + {"progressive house", 17}, + {"electro house", 13}, + {"techno", 6}, + {"trance", 6}, + {"psytrance", 9}, + {"psy", 3}, + {"hardstyle", 9}, + {"hardcore", 8}, + {"breaks", 6}, + {"breakbeat", 9}, + {"garage", 6}, + {"uk garage", 9}, + {"ukg", 3}, + {"2step", 5}, + {"2-step", 6}, + {"grime", 5}, + {"bass", 4}, + {"bass house", 10}, + {"edm", 3}, + {"electronic", 10}, + {"idm", 3}, + {"synthwave", 9}, + {"phonk", 5}, + {"hip hop", 7}, + {"hip-hop", 7}, + {"rap", 3}, + {"pop", 3}, + {"rock", 4}, + {"metal", 5}, + {"ambient", 7}, + {"chillout", 8}, + {"lofi", 4}, + {"lo-fi", 5}, +}; + +TP_PRIVATE const tp_str tp_data_header_words_words[TP_DATA_HEADER_WORDS_WORDS_N] = { + {"tracklist", 9}, + {"setlist", 7}, + {"playlist", 8}, + {"part", 4}, + {"hour", 4}, + {"cd", 2}, + {"disc", 4}, + {"side", 4}, + {"chapter", 7}, + {"segment", 7}, + {"set", 3}, +}; + +TP_PRIVATE const tp_data_joiner tp_data_joiners_spaced[TP_DATA_JOINERS_SPACED_N] = { + {{"&", 1}, {"&", 1}, {"", 0}, false}, + {{"and", 3}, {"&", 1}, {"and", 3}, false}, + {{"x", 1}, {"x", 1}, {"", 0}, true}, + {{"\xc3\x97", 2}, {"x", 1}, {"", 0}, false}, + {{"vs.", 3}, {"vs.", 3}, {"", 0}, false}, + {{"vs", 2}, {"vs.", 3}, {"", 0}, false}, + {{"versus", 6}, {"vs.", 3}, {"", 0}, false}, + {{"/", 1}, {"/", 1}, {"", 0}, false}, + {{"+", 1}, {"+", 1}, {"", 0}, false}, + {{"with", 4}, {"with", 4}, {"", 0}, false}, + {{"meets", 5}, {"meets", 5}, {"", 0}, false}, + {{"pres.", 5}, {"pres.", 5}, {"", 0}, false}, + {{"presents", 8}, {"pres.", 5}, {"", 0}, false}, + {{"b2b", 3}, {"b2b", 3}, {"", 0}, false}, +}; + +TP_PRIVATE const tp_data_joiner tp_data_joiners_tight[TP_DATA_JOINERS_TIGHT_N] = { + {{",", 1}, {",", 1}, {"", 0}, false}, + {{";", 1}, {",", 1}, {"", 0}, false}, +}; + +TP_PRIVATE const tp_data_kv tp_data_junk_phrases[TP_DATA_JUNK_PHRASES_N] = { + {{"official video", 14}, {"video", 5}}, + {{"official music video", 20}, {"video", 5}}, + {{"music video", 11}, {"video", 5}}, + {{"official video clip", 19}, {"video", 5}}, + {{"video clip", 10}, {"video", 5}}, + {{"official clip", 13}, {"video", 5}}, + {{"clip officiel", 13}, {"video", 5}}, + {{"official hd video", 17}, {"video", 5}}, + {{"official 4k video", 17}, {"video", 5}}, + {{"official mv", 11}, {"video", 5}}, + {{"mv", 2}, {"video", 5}}, + {{"m/v", 3}, {"video", 5}}, + {{"video", 5}, {"video", 5}}, + {{"official visualizer", 19}, {"video", 5}}, + {{"official visualiser", 19}, {"video", 5}}, + {{"visualizer", 10}, {"video", 5}}, + {{"visualiser", 10}, {"video", 5}}, + {{"audio visualizer", 16}, {"video", 5}}, + {{"official animated video", 23}, {"video", 5}}, + {{"animated video", 14}, {"video", 5}}, + {{"live video", 10}, {"video", 5}}, + {{"official live video", 19}, {"video", 5}}, + {{"performance video", 17}, {"video", 5}}, + {{"official performance video", 26}, {"video", 5}}, + {{"official audio", 14}, {"audio", 5}}, + {{"audio", 5}, {"audio", 5}}, + {{"audio only", 10}, {"audio", 5}}, + {{"full audio", 10}, {"audio", 5}}, + {{"official lyric video", 20}, {"lyrics", 6}}, + {{"official lyrics video", 21}, {"lyrics", 6}}, + {{"lyric video", 11}, {"lyrics", 6}}, + {{"lyrics video", 12}, {"lyrics", 6}}, + {{"lyrics", 6}, {"lyrics", 6}}, + {{"lyric", 5}, {"lyrics", 6}}, + {{"with lyrics", 11}, {"lyrics", 6}}, + {{"lyrics on screen", 16}, {"lyrics", 6}}, + {{"letra", 5}, {"lyrics", 6}}, + {{"hd", 2}, {"quality", 7}}, + {{"hq", 2}, {"quality", 7}}, + {{"uhd", 3}, {"quality", 7}}, + {{"4k", 2}, {"quality", 7}}, + {{"8k", 2}, {"quality", 7}}, + {{"1080p", 5}, {"quality", 7}}, + {{"720p", 4}, {"quality", 7}}, + {{"480p", 4}, {"quality", 7}}, + {{"high quality", 12}, {"quality", 7}}, + {{"full hd", 7}, {"quality", 7}}, + {{"free download", 13}, {"promo", 5}}, + {{"free dl", 7}, {"promo", 5}}, + {{"out now", 7}, {"promo", 5}}, + {{"premiere", 8}, {"promo", 5}}, + {{"exclusive", 9}, {"promo", 5}}, + {{"preview", 7}, {"promo", 5}}, + {{"teaser", 6}, {"promo", 5}}, + {{"snippet", 7}, {"promo", 5}}, + {{"new song", 8}, {"promo", 5}}, + {{"available now", 13}, {"promo", 5}}, + {{"ncs release", 11}, {"label", 5}}, + {{"monstercat release", 18}, {"label", 5}}, + {{"official", 8}, {"other", 5}}, +}; + +TP_PRIVATE const tp_str tp_data_junk_connectors[TP_DATA_JUNK_CONNECTORS_N] = { + {"-", 1}, + {"|", 1}, + {"/", 1}, + {"&", 1}, + {"+", 1}, + {",", 1}, +}; + +TP_PRIVATE const tp_str tp_data_junk_label_suffixes[TP_DATA_JUNK_LABEL_SUFFIXES_N] = { + {"release", 7}, + {"records", 7}, + {"recordings", 10}, +}; + +TP_PRIVATE const tp_str tp_data_layered_words_words[TP_DATA_LAYERED_WORDS_WORDS_N] = { + {"w/", 2}, +}; + +TP_PRIVATE const tp_str tp_data_marker_words_words[TP_DATA_MARKER_WORDS_WORDS_N] = { + {"intro", 5}, + {"outro", 5}, + {"break", 5}, + {"interlude", 9}, + {"intermission", 12}, + {"jingle", 6}, + {"ad", 2}, + {"advert", 6}, + {"advertisement", 13}, + {"talk", 4}, + {"interview", 9}, + {"speech", 6}, + {"announcement", 12}, + {"shoutout", 8}, + {"shout-out", 9}, + {"pause", 5}, + {"start", 5}, + {"end", 3}, + {"silence", 7}, + {"applause", 8}, + {"skit", 4}, +}; + +TP_PRIVATE const tp_str tp_data_no_split_before_words[TP_DATA_NO_SPLIT_BEFORE_WORDS_N] = { + {"sons", 4}, + {"daughters", 9}, + {"friends", 7}, + {"co", 2}, + {"co.", 3}, + {"company", 7}, + {"his", 3}, + {"her", 3}, + {"their", 5}, + {"orchestra", 9}, +}; + +TP_PRIVATE const tp_str tp_data_platform_suffixes_suffixes[TP_DATA_PLATFORM_SUFFIXES_SUFFIXES_N] = { + {" - YouTube Music", 16}, + {" - YouTube", 10}, + {" | Free Listening on SoundCloud", 31}, + {" - SoundCloud", 13}, + {" | SoundCloud", 13}, + {" - Topic", 8}, + {" | Bandcamp", 11}, + {" - Bandcamp", 11}, +}; + +TP_PRIVATE const tp_str tp_data_stopwords_words[TP_DATA_STOPWORDS_WORDS_N] = { + {"you", 3}, + {"me", 2}, + {"him", 3}, + {"her", 3}, + {"us", 2}, + {"them", 4}, + {"it", 2}, + {"i", 1}, + {"love", 4}, + {"my", 2}, + {"your", 4}, + {"our", 3}, + {"the", 3}, + {"a", 1}, + {"an", 2}, + {"this", 4}, + {"that", 4}, + {"myself", 6}, + {"yourself", 8}, + {"everyone", 8}, + {"everybody", 9}, + {"somebody", 8}, + {"someone", 7}, + {"nobody", 6}, + {"nothing", 7}, + {"all", 3}, + {"night", 5}, + {"side", 4}, + {"day", 3}, +}; + +TP_PRIVATE const tp_str + tp_data_unknown_tokens_case_sensitive[TP_DATA_UNKNOWN_TOKENS_CASE_SENSITIVE_N] = { + {"ID", 2}, + {"IDs", 3}, + {"ID\?", 3}, +}; + +TP_PRIVATE const tp_str + tp_data_unknown_tokens_case_insensitive[TP_DATA_UNKNOWN_TOKENS_CASE_INSENSITIVE_N] = { + {"unknown", 7}, + {"unknown artist", 14}, + {"unknown title", 13}, + {"untitled", 8}, + {"\?", 1}, + {"\?\?", 2}, + {"\?\?\?", 3}, +}; + +TP_PRIVATE const tp_data_kv tp_data_version_keywords_heads[TP_DATA_VERSION_KEYWORDS_HEADS_N] = { + {{"remix", 5}, {"remix", 5}}, + {{"rmx", 3}, {"remix", 5}}, + {{"mix", 3}, {"mix", 3}}, + {{"bootleg", 7}, {"bootleg", 7}}, + {{"vip", 3}, {"vip", 3}}, + {{"edit", 4}, {"edit", 4}}, + {{"re-edit", 7}, {"edit", 4}}, + {{"reedit", 6}, {"edit", 4}}, + {{"flip", 4}, {"flip", 4}}, + {{"refix", 5}, {"refix", 5}}, + {{"rework", 6}, {"rework", 6}}, + {{"re-work", 7}, {"rework", 6}}, + {{"mashup", 6}, {"mashup", 6}}, + {{"mash-up", 7}, {"mashup", 6}}, + {{"mash up", 7}, {"mashup", 6}}, + {{"blend", 5}, {"blend", 5}}, + {{"dub", 3}, {"dub", 3}}, + {{"version", 7}, {"version", 7}}, + {{"ver", 3}, {"version", 7}}, + {{"remaster", 8}, {"remaster", 8}}, + {{"remastered", 10}, {"remaster", 8}}, + {{"cover", 5}, {"cover", 5}}, + {{"reprise", 7}, {"reprise", 7}}, +}; + +TP_PRIVATE const tp_str + tp_data_version_keywords_generic_heads[TP_DATA_VERSION_KEYWORDS_GENERIC_HEADS_N] = { + {"mix", 3}, + {"edit", 4}, + {"version", 7}, +}; + +TP_PRIVATE const tp_data_kv + tp_data_version_keywords_type_capable_modifiers[TP_DATA_VERSION_KEYWORDS_TYPE_CAPABLE_MODIFIERS_N] = { + {{"radio", 5}, {"radio", 5}}, + {{"extended", 8}, {"extended", 8}}, + {{"club", 4}, {"club", 4}}, + {{"original", 8}, {"original", 8}}, + {{"instrumental", 12}, {"instrumental", 12}}, + {{"dub", 3}, {"dub", 3}}, + {{"vip", 3}, {"vip", 3}}, + {{"acoustic", 8}, {"acoustic", 8}}, + {{"live", 4}, {"live", 4}}, + {{"acapella", 8}, {"acapella", 8}}, + {{"a cappella", 10}, {"acapella", 8}}, + {{"a capella", 9}, {"acapella", 8}}, + {{"acappella", 9}, {"acapella", 8}}, + {{"demo", 4}, {"demo", 4}}, +}; + +TP_PRIVATE const tp_data_kv + tp_data_version_keywords_prefix_forms[TP_DATA_VERSION_KEYWORDS_PREFIX_FORMS_N] = { + {{"live", 4}, {"live", 4}}, + {{"remastered", 10}, {"remaster", 8}}, + {{"remaster", 8}, {"remaster", 8}}, + {{"acoustic", 8}, {"acoustic", 8}}, + {{"instrumental", 12}, {"instrumental", 12}}, + {{"acapella", 8}, {"acapella", 8}}, + {{"a cappella", 10}, {"acapella", 8}}, + {{"demo", 4}, {"demo", 4}}, + {{"sped up", 7}, {"spedUp", 6}}, + {{"speed up", 8}, {"spedUp", 6}}, + {{"slowed + reverb", 15}, {"slowed", 6}}, + {{"slowed & reverb", 15}, {"slowed", 6}}, + {{"slowed and reverb", 17}, {"slowed", 6}}, + {{"slowed", 6}, {"slowed", 6}}, + {{"nightcore", 9}, {"nightcore", 9}}, +}; + +TP_PRIVATE const tp_str tp_data_version_keywords_types[TP_DATA_VERSION_KEYWORDS_TYPES_N] = { + {"remix", 5}, + {"bootleg", 7}, + {"vip", 3}, + {"edit", 4}, + {"flip", 4}, + {"refix", 5}, + {"rework", 6}, + {"mashup", 6}, + {"blend", 5}, + {"dub", 3}, + {"mix", 3}, + {"extended", 8}, + {"radio", 5}, + {"club", 4}, + {"original", 8}, + {"instrumental", 12}, + {"acapella", 8}, + {"live", 4}, + {"acoustic", 8}, + {"remaster", 8}, + {"demo", 4}, + {"reprise", 7}, + {"cover", 5}, + {"version", 7}, + {"spedUp", 6}, + {"slowed", 6}, + {"nightcore", 9}, +}; diff --git a/c/src/data_gen.h b/c/src/data_gen.h new file mode 100644 index 0000000..ef40b60 --- /dev/null +++ b/c/src/data_gen.h @@ -0,0 +1,154 @@ +/* Code generated by c/scripts/gen_data.mjs from spec/data and spec/VERSION. DO NOT EDIT. */ +#ifndef TP_DATA_GEN_H +#define TP_DATA_GEN_H + +#include "rt.h" + +/* Linkage of generated tables. A declaration needs the complete type: the amalgamation makes + * these static, and a static tentative declaration must have a complete type. In the + * separate-files build they are extern, so the header declares and data_gen.c / unicode_gen.c + * define. */ +#ifndef TP_PRIVATE_DATA +#ifdef TRACKPARSE_AMALGAMATION +#define TP_PRIVATE_DATA static +#else +#define TP_PRIVATE_DATA extern +#endif +#endif + +/* The version of the spec this library implements. */ +#define TP_SPEC_VERSION "0.6.1" /* x-release-please-version */ + +/* One entry of a JSON object in spec/data, in file order. */ +typedef struct tp_data_kv { + tp_str key; + tp_str value; +} tp_data_kv; + +/* One entry of spec/data/joiners.json. */ +typedef struct tp_data_joiner { + tp_str raw; + tp_str canonical; + tp_str kind; + bool case_sensitive; +} tp_data_joiner; + +/* descriptors in spec/data/descriptors.json. */ +#define TP_DATA_DESCRIPTORS_DESCRIPTORS_N 44 +TP_PRIVATE_DATA const tp_str tp_data_descriptors_descriptors[TP_DATA_DESCRIPTORS_DESCRIPTORS_N]; + +/* extensions in spec/data/extensions.json. */ +#define TP_DATA_EXTENSIONS_EXTENSIONS_N 14 +TP_PRIVATE_DATA const tp_str tp_data_extensions_extensions[TP_DATA_EXTENSIONS_EXTENSIONS_N]; + +/* markers in spec/data/feat-markers.json. */ +#define TP_DATA_FEAT_MARKERS_MARKERS_N 7 +TP_PRIVATE_DATA const tp_str tp_data_feat_markers_markers[TP_DATA_FEAT_MARKERS_MARKERS_N]; + +/* bracketOnly in spec/data/feat-markers.json. */ +#define TP_DATA_FEAT_MARKERS_BRACKET_ONLY_N 2 +TP_PRIVATE_DATA const tp_str tp_data_feat_markers_bracket_only[TP_DATA_FEAT_MARKERS_BRACKET_ONLY_N]; + +/* producer in spec/data/feat-markers.json. */ +#define TP_DATA_FEAT_MARKERS_PRODUCER_N 5 +TP_PRIVATE_DATA const tp_str tp_data_feat_markers_producer[TP_DATA_FEAT_MARKERS_PRODUCER_N]; + +/* titleMarkers in spec/data/feat-markers.json. */ +#define TP_DATA_FEAT_MARKERS_TITLE_MARKERS_N 3 +TP_PRIVATE_DATA const tp_str + tp_data_feat_markers_title_markers[TP_DATA_FEAT_MARKERS_TITLE_MARKERS_N]; + +/* titleProducer in spec/data/feat-markers.json. */ +#define TP_DATA_FEAT_MARKERS_TITLE_PRODUCER_N 4 +TP_PRIVATE_DATA const tp_str + tp_data_feat_markers_title_producer[TP_DATA_FEAT_MARKERS_TITLE_PRODUCER_N]; + +/* producerBy in spec/data/feat-markers.json. */ +#define TP_DATA_FEAT_MARKERS_PRODUCER_BY TP_S("by") + +/* genres in spec/data/genres.json. */ +#define TP_DATA_GENRES_GENRES_N 60 +TP_PRIVATE_DATA const tp_str tp_data_genres_genres[TP_DATA_GENRES_GENRES_N]; + +/* words in spec/data/header-words.json. */ +#define TP_DATA_HEADER_WORDS_WORDS_N 11 +TP_PRIVATE_DATA const tp_str tp_data_header_words_words[TP_DATA_HEADER_WORDS_WORDS_N]; + +/* spaced in spec/data/joiners.json. */ +#define TP_DATA_JOINERS_SPACED_N 14 +TP_PRIVATE_DATA const tp_data_joiner tp_data_joiners_spaced[TP_DATA_JOINERS_SPACED_N]; + +/* tight in spec/data/joiners.json. */ +#define TP_DATA_JOINERS_TIGHT_N 2 +TP_PRIVATE_DATA const tp_data_joiner tp_data_joiners_tight[TP_DATA_JOINERS_TIGHT_N]; + +/* featCanonical in spec/data/joiners.json. */ +#define TP_DATA_JOINERS_FEAT_CANONICAL TP_S("feat.") + +/* phrases in spec/data/junk.json. */ +#define TP_DATA_JUNK_PHRASES_N 60 +TP_PRIVATE_DATA const tp_data_kv tp_data_junk_phrases[TP_DATA_JUNK_PHRASES_N]; + +/* connectors in spec/data/junk.json. */ +#define TP_DATA_JUNK_CONNECTORS_N 6 +TP_PRIVATE_DATA const tp_str tp_data_junk_connectors[TP_DATA_JUNK_CONNECTORS_N]; + +/* labelSuffixes in spec/data/junk.json. */ +#define TP_DATA_JUNK_LABEL_SUFFIXES_N 3 +TP_PRIVATE_DATA const tp_str tp_data_junk_label_suffixes[TP_DATA_JUNK_LABEL_SUFFIXES_N]; + +/* words in spec/data/layered-words.json. */ +#define TP_DATA_LAYERED_WORDS_WORDS_N 1 +TP_PRIVATE_DATA const tp_str tp_data_layered_words_words[TP_DATA_LAYERED_WORDS_WORDS_N]; + +/* words in spec/data/marker-words.json. */ +#define TP_DATA_MARKER_WORDS_WORDS_N 21 +TP_PRIVATE_DATA const tp_str tp_data_marker_words_words[TP_DATA_MARKER_WORDS_WORDS_N]; + +/* words in spec/data/no-split-before.json. */ +#define TP_DATA_NO_SPLIT_BEFORE_WORDS_N 10 +TP_PRIVATE_DATA const tp_str tp_data_no_split_before_words[TP_DATA_NO_SPLIT_BEFORE_WORDS_N]; + +/* suffixes in spec/data/platform-suffixes.json. */ +#define TP_DATA_PLATFORM_SUFFIXES_SUFFIXES_N 8 +TP_PRIVATE_DATA const tp_str + tp_data_platform_suffixes_suffixes[TP_DATA_PLATFORM_SUFFIXES_SUFFIXES_N]; + +/* words in spec/data/stopwords.json. */ +#define TP_DATA_STOPWORDS_WORDS_N 29 +TP_PRIVATE_DATA const tp_str tp_data_stopwords_words[TP_DATA_STOPWORDS_WORDS_N]; + +/* caseSensitive in spec/data/unknown-tokens.json. */ +#define TP_DATA_UNKNOWN_TOKENS_CASE_SENSITIVE_N 3 +TP_PRIVATE_DATA const tp_str + tp_data_unknown_tokens_case_sensitive[TP_DATA_UNKNOWN_TOKENS_CASE_SENSITIVE_N]; + +/* caseInsensitive in spec/data/unknown-tokens.json. */ +#define TP_DATA_UNKNOWN_TOKENS_CASE_INSENSITIVE_N 7 +TP_PRIVATE_DATA const tp_str + tp_data_unknown_tokens_case_insensitive[TP_DATA_UNKNOWN_TOKENS_CASE_INSENSITIVE_N]; + +/* heads in spec/data/version-keywords.json. */ +#define TP_DATA_VERSION_KEYWORDS_HEADS_N 23 +TP_PRIVATE_DATA const tp_data_kv tp_data_version_keywords_heads[TP_DATA_VERSION_KEYWORDS_HEADS_N]; + +/* genericHeads in spec/data/version-keywords.json. */ +#define TP_DATA_VERSION_KEYWORDS_GENERIC_HEADS_N 3 +TP_PRIVATE_DATA const tp_str + tp_data_version_keywords_generic_heads[TP_DATA_VERSION_KEYWORDS_GENERIC_HEADS_N]; + +/* typeCapableModifiers in spec/data/version-keywords.json. */ +#define TP_DATA_VERSION_KEYWORDS_TYPE_CAPABLE_MODIFIERS_N 14 +TP_PRIVATE_DATA const tp_data_kv + tp_data_version_keywords_type_capable_modifiers[TP_DATA_VERSION_KEYWORDS_TYPE_CAPABLE_MODIFIERS_N]; + +/* prefixForms in spec/data/version-keywords.json. */ +#define TP_DATA_VERSION_KEYWORDS_PREFIX_FORMS_N 15 +TP_PRIVATE_DATA const tp_data_kv + tp_data_version_keywords_prefix_forms[TP_DATA_VERSION_KEYWORDS_PREFIX_FORMS_N]; + +/* types in spec/data/version-keywords.json. */ +#define TP_DATA_VERSION_KEYWORDS_TYPES_N 27 +TP_PRIVATE_DATA const tp_str tp_data_version_keywords_types[TP_DATA_VERSION_KEYWORDS_TYPES_N]; + +#endif /* TP_DATA_GEN_H */ diff --git a/c/src/digits.c b/c/src/digits.c new file mode 100644 index 0000000..49aaf4f --- /dev/null +++ b/c/src/digits.c @@ -0,0 +1,33 @@ +/* digits.c: ASCII digit scanning shared by R4.1 (prefix.c) and the tracklist time scanner (R13.2) + * (go/digits.go). */ +#include "digits.h" + +#include "words.h" + +TP_PRIVATE ptrdiff_t tp_digit_run(tp_runes s, ptrdiff_t from) { + ptrdiff_t i = from; + while (tp_is_digit(tp_at(s, i))) i++; + return i - from; +} + +TP_PRIVATE int64_t tp_digits_value(tp_runes s) { + const int64_t limit = (int64_t)1 << 40; + int64_t n = 0; + for (size_t i = 0; i < s.n; i++) { + int64_t d = 0; + if (tp_is_digit(s.p[i])) d = s.p[i] - '0'; + n = n * 10 + d; + if (n > limit) n = limit; + } + return n; +} + +TP_PRIVATE bool tp_two_digits_up_to_59(tp_runes s, ptrdiff_t i, int *out) { + *out = 0; + if (!tp_is_digit(tp_at(s, i)) || !tp_is_digit(tp_at(s, i + 1)) || tp_is_digit(tp_at(s, i + 2))) { + return false; + } + int n = (int)tp_digits_value(tp_sub(s, i, i + 2)); + *out = n; + return n <= 59; +} diff --git a/c/src/digits.h b/c/src/digits.h new file mode 100644 index 0000000..f4992d0 --- /dev/null +++ b/c/src/digits.h @@ -0,0 +1,16 @@ +/* digits.h: ASCII digit scanning shared by R4.1 (prefix.c) and the tracklist time scanner (R13.2) + * (go/digits.go). */ +#ifndef TP_DIGITS_H +#define TP_DIGITS_H + +#include "rt.h" + +/* The length of the run of ASCII digits starting at from (0 out of range). */ +TP_PRIVATE ptrdiff_t tp_digit_run(tp_runes s, ptrdiff_t from); +/* The value of a run of ASCII digits, saturating at 2^40 (callers pass at most a few digits). + * Other code points count as 0. */ +TP_PRIVATE int64_t tp_digits_value(tp_runes s); +/* The value of exactly two digits at i (not followed by a third) when it is at most 59. */ +TP_PRIVATE bool tp_two_digits_up_to_59(tp_runes s, ptrdiff_t i, int *out); + +#endif /* TP_DIGITS_H */ diff --git a/c/src/format.c b/c/src/format.c new file mode 100644 index 0000000..708cf72 --- /dev/null +++ b/c/src/format.c @@ -0,0 +1,192 @@ +/* format.c: R11 render a parsed track back to a string, and allArtists (go/format.go, + * js/src/format.ts). R11 always reads the default tables: keyword options are parse options and + * do not reach it. */ +#include "internal.h" + +/* isFeatMarker reports whether raw, as one word, is a feat marker. */ +TP_PRIVATE bool tp_is_feat_marker(tp_str raw, const tp_tables *t) { + tp_str one[1]; + one[0] = raw; + tp_strvec w; + w.p = one; + w.n = 1; + w.cap = 1; + tp_phrase_match m; + if (tp_phrase_table_match_at(t->feat_markers, w, 0, &m)) return true; + return tp_phrase_table_match_at(t->bracket_only_feat, w, 0, &m); +} + +/* canonicalJoiner is R11.5: map a raw joiner to its canonical form through data/joiners.json; + * feat markers become feat_canonical. A featured list's lead marker is always a feat marker + * (with becomes feat.), while between names the joiner table wins (Sigala with Ella Eyre keeps + * with). */ +TP_PRIVATE tp_str tp_canonical_joiner(tp_str raw, const tp_tables *t, bool feat_lead) { + if (feat_lead && tp_is_feat_marker(raw, t)) return t->feat_canonical; + tp_str tight; + if (tp_tables_tight_joiner(t, raw, &tight)) return tight; + for (size_t i = 0; i < t->spaced_joiners.n; i++) { + const tp_spaced_joiner *j = &t->spaced_joiners.p[i]; + bool matches = tp_str_eq(raw, j->raw); + if (!j->case_sensitive) matches = tp_word_matches(raw, j->raw); + if (matches) return j->canonical; + } + if (tp_is_feat_marker(raw, t)) return t->feat_canonical; + return raw; +} + +/* joinSep is R11.1: " " + joiner + " "; tight joiners as the raw character + " "; a missing + * joiner as &. */ +TP_PRIVATE tp_str tp_join_sep(const tp_str *joiner, const tp_resolved_format *o, + const tp_tables *t) { + tp_str j = TP_S("&"); + if (joiner != NULL) { + j = *joiner; + if (o->canonical) j = tp_canonical_joiner(j, t, false); + } + tp_str tight; + if (tp_tables_tight_joiner(t, j, &tight)) return tp_concat(j, TP_S(" ")); + return tp_concat3(TP_S(" "), j, TP_S(" ")); +} + +/* joinNames is the names of one credit list joined by their own joiners (the first joiner is + * not rendered). */ +TP_PRIVATE tp_str tp_join_names(tp_artist_ptr_vec list, const tp_resolved_format *o, + const tp_tables *t) { + tp_buf b = {0}; + for (size_t i = 0; i < list.n; i++) { + if (i > 0) tp_buf_str(&b, tp_join_sep(list.p[i]->joiner, o, t)); + tp_buf_str(&b, list.p[i]->name); + } + return tp_buf_done(&b); +} + +/* leadMarker is the marker in front of a featured list. */ +TP_PRIVATE tp_str tp_lead_marker(const tp_artist *first, const tp_resolved_format *o, + const tp_tables *t, tp_str fallback) { + if (o->feat_marker != NULL) return *o->feat_marker; + tp_str raw = fallback; + if (first->joiner != NULL) raw = *first->joiner; + if (o->canonical) return tp_canonical_joiner(raw, t, true); + return raw; +} + +/* withRole is the artists of track with role, in order. */ +TP_PRIVATE tp_artist_ptr_vec tp_with_role(tp_artist_vec artists, tp_role role) { + tp_artist_ptr_vec out = {0}; + for (size_t i = 0; i < artists.n; i++) { + if (tp_str_eq(artists.p[i].role, role)) tp_push(out, (const tp_artist *)&artists.p[i]); + } + return out; +} + +/* formatTrack is R11: track rendered back to a string with the resolved format options. */ +TP_PRIVATE tp_str tp_format_track(const tp_track *track, tp_resolved_format o) { + const tp_tables *t = tp_default_tables(); + tp_artist_ptr_vec primaries = tp_with_role(track->artists, TP_ROLE_PRIMARY); + tp_artist_ptr_vec featured = tp_with_role(track->artists, TP_ROLE_FEATURED); + tp_artist_ptr_vec producers = tp_with_role(track->artists, TP_ROLE_PRODUCER); + + tp_artist_ptr_vec artist_feat = {0}, title_feat = {0}; + switch (o.feat) { + case TP_FEAT_MODE_SOURCE: + for (size_t i = 0; i < featured.n; i++) { + if (tp_str_eq(featured.p[i]->source, TP_SOURCE_ARTIST)) { + tp_push(artist_feat, featured.p[i]); + } else { + tp_push(title_feat, featured.p[i]); + } + } + break; + case TP_FEAT_MODE_ARTIST: + artist_feat = featured; + break; + case TP_FEAT_MODE_TITLE: + title_feat = featured; + break; + case TP_FEAT_MODE_OMIT: + break; + } + + /* R11.1 / R11.2 */ + tp_str artist_part = tp_join_names(primaries, &o, t); + if (artist_feat.n > 0) { + tp_str lead = tp_lead_marker(artist_feat.p[0], &o, t, t->feat_canonical); + tp_str names = tp_join_names(artist_feat, &o, t); + if (artist_part.n == 0) { + artist_part = tp_concat3(lead, TP_S(" "), names); + } else { + tp_buf b = {0}; + tp_buf_str(&b, artist_part); + tp_buf_byte(&b, ' '); + tp_buf_str(&b, lead); + tp_buf_byte(&b, ' '); + tp_buf_str(&b, names); + artist_part = tp_buf_done(&b); + } + } + + /* R11.3 */ + tp_strvec pieces = {0}; + if (track->title.n > 0) tp_push(pieces, track->title); + if (title_feat.n > 0) { + tp_str lead = tp_lead_marker(title_feat.p[0], &o, t, t->feat_canonical); + tp_buf b = {0}; + tp_buf_byte(&b, '('); + tp_buf_str(&b, lead); + tp_buf_byte(&b, ' '); + tp_buf_str(&b, tp_join_names(title_feat, &o, t)); + tp_buf_byte(&b, ')'); + tp_push(pieces, tp_buf_done(&b)); + } + if (o.versions) { + for (size_t i = 0; i < track->versions.n; i++) { + tp_push(pieces, tp_render_version(track->versions.p[i].raw, track->versions.p[i].delimiter)); + } + } + if (producers.n > 0 && o.producers) { + tp_str marker = TP_S("prod."); + if (producers.p[0]->joiner != NULL) marker = *producers.p[0]->joiner; + tp_buf b = {0}; + tp_buf_byte(&b, '('); + tp_buf_str(&b, marker); + tp_buf_byte(&b, ' '); + tp_buf_str(&b, tp_join_names(producers, &o, t)); + tp_buf_byte(&b, ')'); + tp_push(pieces, tp_buf_done(&b)); + } + tp_str title_part = tp_join(pieces, TP_S(" ")); + + /* R11.4 */ + tp_str result = title_part; + if (artist_part.n > 0) result = tp_concat3(artist_part, TP_S(" - "), title_part); + if (o.position && track->position != NULL) { + result = tp_concat3(track->position->raw, TP_S(". "), result); + } + return result; +} + +/* Go closure add of allArtists. */ +typedef struct all_artists_state { + tp_map seen; + tp_artist_vec out; +} all_artists_state; + +static void add_artist(all_artists_state *s, tp_artist a) { + tp_str key = tp_dedup_key(a.name); + if (tp_map_has(&s->seen, key)) return; + tp_map_put(&s->seen, key, 1); + tp_push(s->out, a); +} + +/* allArtists is every credited name: the track's artists plus every version's remixers, + * deduplicated by the R0.4 key, first occurrence kept. */ +TP_PRIVATE tp_artist_vec tp_all_artists(const tp_track *track) { + all_artists_state s; + memset(&s, 0, sizeof s); + for (size_t i = 0; i < track->artists.n; i++) add_artist(&s, track->artists.p[i]); + for (size_t v = 0; v < track->versions.n; v++) { + const tp_version *ver = &track->versions.p[v]; + for (size_t i = 0; i < ver->artists.n; i++) add_artist(&s, ver->artists.p[i]); + } + return s.out; +} diff --git a/c/src/internal.h b/c/src/internal.h new file mode 100644 index 0000000..df8ccdf --- /dev/null +++ b/c/src/internal.h @@ -0,0 +1,2016 @@ +/* internal.h: every internal type, constant and function of the C port. + * + * One section per Go file (go/.go -> c/src/.c), in pipeline order. Each prototype + * keeps the Go doc comment (shortened) and the rule IDs. Names follow c-brief.md: Go fooBar -> + * tp_foo_bar, method (t *T) m -> tp_T_m(T *t, ...), constants -> TP_UPPER_CASE. See PORTING.md + * for the translation decisions every .c file must follow (int widths, nil slices, closures, + * maps, ownership). + * + * Not here: the runtime (rt.h), the R0 primitives and phrase tables (words.h), Unicode + * (unicode.h, unicode_gen.h), digit runs (digits.h), the generated data (data_gen.h), the JSON + * reader (wire/json_read.h) and the JSON door entry points (wire/wire.h). + * + * Conventions used throughout this header: + * - Go int is ptrdiff_t (as in words.h), Go []int is tp_idxvec, Go int64 is int64_t. Exception: + * the JS-number fields of edits and edit results (tp_edit line/after/from/lines, the edit + * warning line, changed) are int64_t / tp_intvec, the public API's long long. Cast explicitly + * between ptrdiff_t and size_t (a vector's n). + * - Go typed strings (Mode, Role, VersionType...) are tp_str, named by a typedef for reading + * (tp_mode, tp_role...), with the values as TP_S() constants compared with tp_str_eq. TP_S is + * a compound literal: in a static initializer write {"remix", 5} instead. + * - Nullable Go pointers (*int, *string, *float64, *T) are const pointers into the arena; NULL + * is Go nil. + * - (T, bool) -> bool f(..., T *out); (A, B) -> A f(..., B *out). out is written only when the + * result is true, unless the comment says otherwise. + * - Go passes a struct by value or by pointer; the C prototypes do the same. + */ +#ifndef TP_INTERNAL_H +#define TP_INTERNAL_H + +#include "rt.h" + +#include "data_gen.h" +#include "digits.h" +#include "unicode.h" +#include "unicode_gen.h" +#include "words.h" + +/* ============================================================================================ */ +/* Forward declarations and slice types (Go []T -> tp_T_vec), grouped by the Go file of T. */ +/* A TP_VEC only needs T declared, so every vector type is available to every section. */ + +/* types.go */ +typedef struct tp_artist tp_artist; +typedef struct tp_version tp_version; +typedef struct tp_junk tp_junk; +typedef struct tp_flags tp_flags; +typedef struct tp_position tp_position; +typedef struct tp_timestamp tp_timestamp; +typedef struct tp_track tp_track; +typedef struct tp_parts tp_parts; +typedef struct tp_tracklist_time tp_tracklist_time; +typedef struct tp_entry tp_entry; +typedef struct tp_suggestion tp_suggestion; +typedef struct tp_tracklist_warning tp_tracklist_warning; +typedef struct tp_stats tp_stats; +typedef struct tp_tracklist tp_tracklist; +typedef struct tp_edit tp_edit; +typedef struct tp_edit_warning tp_edit_warning; +typedef struct tp_edit_result tp_edit_result; +typedef struct tp_raw_edit_warning tp_raw_edit_warning; +typedef struct tp_raw_edit_result tp_raw_edit_result; +typedef TP_VEC(tp_artist) tp_artist_vec; +typedef TP_VEC(const tp_artist *) tp_artist_ptr_vec; /* Go []*Artist (format.go) */ +typedef TP_VEC(tp_version) tp_version_vec; +typedef TP_VEC(tp_junk) tp_junk_vec; +typedef TP_VEC(tp_entry) tp_entry_vec; +typedef TP_VEC(tp_tracklist_warning) tp_tracklist_warning_vec; +typedef TP_VEC(tp_edit) tp_edit_vec; +typedef TP_VEC(tp_edit_warning) tp_edit_warning_vec; +typedef TP_VEC(tp_raw_edit_warning) tp_raw_edit_warning_vec; + +/* Builtin element types not in rt.h. */ +typedef TP_VEC(bool) tp_bool_vec; /* Go []bool */ +typedef TP_VEC(tp_runes) tp_runes_vec; /* Go [][]rune */ +typedef TP_VEC(ptrdiff_t) tp_idxvec; /* Go []int (rt.h's tp_intvec is Go []int64) */ +typedef TP_VEC(tp_idxvec) tp_idxvec_vec; /* Go [][]int (creditLists heaps) */ + +/* options.go */ +typedef struct tp_version_head tp_version_head; +typedef struct tp_junk_phrase tp_junk_phrase; +typedef struct tp_keywords tp_keywords; +typedef struct tp_parse_options tp_parse_options; +typedef struct tp_format_options tp_format_options; +typedef struct tp_tracklist_options tp_tracklist_options; +typedef struct tp_requested_mode tp_requested_mode; +typedef struct tp_kv tp_kv; +typedef struct tp_keyword_lists tp_keyword_lists; +typedef struct tp_resolved_options tp_resolved_options; +typedef struct tp_resolved_format tp_resolved_format; +typedef struct tp_resolved_tracklist tp_resolved_tracklist; +typedef TP_VEC(tp_version_head) tp_version_head_vec; +typedef TP_VEC(tp_junk_phrase) tp_junk_phrase_vec; +typedef TP_VEC(tp_kv) tp_kv_vec; + +/* context.go */ +typedef struct tp_engine tp_engine; +typedef struct tp_ctx tp_ctx; + +/* tables.go */ +typedef struct tp_spaced_joiner tp_spaced_joiner; +typedef struct tp_run_info tp_run_info; +typedef struct tp_tables tp_tables; +typedef TP_VEC(tp_spaced_joiner) tp_spaced_joiner_vec; + +/* mode.go */ +typedef struct tp_positioned_junk tp_positioned_junk; +typedef struct tp_piece tp_piece; +typedef struct tp_prelude_result tp_prelude_result; +typedef TP_VEC(tp_positioned_junk) tp_positioned_junk_vec; + +/* prefix.go */ +typedef struct tp_prefix_result tp_prefix_result; +typedef struct tp_time_match tp_time_match; + +/* scanner.go */ +typedef struct tp_group tp_group; +typedef struct tp_group_map tp_group_map; +typedef struct tp_skel tp_skel; +typedef struct tp_offsets tp_offsets; +typedef struct tp_indexed_group tp_indexed_group; +typedef struct tp_segment tp_segment; +typedef TP_VEC(const tp_group *) tp_group_ptr_vec; +typedef TP_VEC(tp_indexed_group) tp_indexed_group_vec; +typedef TP_VEC(tp_segment) tp_segment_vec; + +/* credits.go */ +typedef struct tp_credit tp_credit; +typedef struct tp_positioned_year tp_positioned_year; +typedef struct tp_list_options tp_list_options; +typedef struct tp_list_result tp_list_result; +typedef struct tp_joiner_hit tp_joiner_hit; +typedef struct tp_raw_name tp_raw_name; +typedef TP_VEC(tp_credit) tp_credit_vec; +typedef TP_VEC(tp_positioned_year) tp_positioned_year_vec; +typedef TP_VEC(tp_raw_name) tp_raw_name_vec; + +/* classify.go */ +typedef struct tp_version_draft tp_version_draft; +typedef struct tp_classification tp_classification; +typedef struct tp_site tp_site; +typedef struct tp_run_item tp_run_item; +typedef TP_VEC(tp_version_draft) tp_version_draft_vec; +typedef TP_VEC(tp_run_item) tp_run_item_vec; + +/* separator.go */ +typedef struct tp_peeled tp_peeled; +typedef struct tp_separator_result tp_separator_result; +typedef struct tp_separator_input tp_separator_input; +typedef struct tp_split_parts tp_split_parts; +typedef TP_VEC(tp_peeled) tp_peeled_vec; + +/* artists.go */ +typedef struct tp_artist_side_result tp_artist_side_result; +typedef struct tp_feat_marker tp_feat_marker; + +/* title.go */ +typedef struct tp_extracted tp_extracted; +typedef struct tp_title_side_result tp_title_side_result; +typedef struct tp_marker_hit tp_marker_hit; +typedef TP_VEC(tp_marker_hit) tp_marker_hit_vec; + +/* assemble.go */ +typedef struct tp_dedup_entry tp_dedup_entry; +typedef struct tp_credit_lists tp_credit_lists; +typedef TP_VEC(tp_dedup_entry) tp_dedup_entry_vec; + +/* parser.go */ +typedef struct tp_staged tp_staged; +typedef struct tp_line_probe tp_line_probe; + +/* tl_split.go */ +typedef struct tp_tl_line tp_tl_line; +typedef TP_VEC(tp_tl_line) tp_tl_line_vec; + +/* tl_times.go */ +typedef struct tp_time_style tp_time_style; +typedef struct tp_time_scan tp_time_scan; +typedef struct tp_time_shape tp_time_shape; +typedef struct tp_formatted_time tp_formatted_time; + +/* tl_positions.go */ +typedef struct tp_bare_candidate tp_bare_candidate; + +/* tl_warnings.go */ +typedef struct tp_warning_input tp_warning_input; +typedef struct tp_digit_slot tp_digit_slot; +typedef struct tp_digit_change tp_digit_change; +typedef struct tp_time_digits tp_time_digits; +typedef struct tp_timed_entry tp_timed_entry; +typedef TP_VEC(tp_digit_slot) tp_digit_slot_vec; +typedef TP_VEC(tp_digit_change) tp_digit_change_vec; +typedef TP_VEC(tp_timed_entry) tp_timed_entry_vec; + +/* tl_parse.go */ +typedef struct tp_tl_row tp_tl_row; +typedef TP_VEC(tp_tl_row) tp_tl_row_vec; + +/* tl_edits.go */ +typedef struct tp_work_line tp_work_line; +typedef struct tp_edit_ctx tp_edit_ctx; +typedef struct tp_retimed tp_retimed; +typedef struct tp_touched tp_touched; +typedef struct tp_time_block tp_time_block; +typedef TP_VEC(tp_work_line *) tp_work_line_ptr_vec; +typedef TP_VEC(tp_retimed) tp_retimed_vec; +typedef TP_VEC(tp_time_block) tp_time_block_vec; + +/* json.go */ +typedef struct tp_jw tp_jw; + +/* trackparse.go */ +typedef struct tp_parser tp_parser; + +/* ============================================================================================ */ +/* types.go: the result types (mirror parsed-track.schema.json and tracklist.schema.json) */ + +/* Mode is the mode a string is parsed in (R2). In a track: clean, youtube, filename or + * tracklist, never auto. In options, auto asks the parser to pick one, and "" means the + * option's default (auto for a parse, tracklist for a tracklist). Any other string behaves as + * JS does with an unknown mode: no youtube detection, filenames still detected. */ +typedef tp_str tp_mode; +#define TP_MODE_AUTO TP_S("auto") +#define TP_MODE_CLEAN TP_S("clean") +#define TP_MODE_YOUTUBE TP_S("youtube") +#define TP_MODE_FILENAME TP_S("filename") +#define TP_MODE_TRACKLIST TP_S("tracklist") +/* The modes a track can have (not auto), in the spec's order. A new arena vector per call. */ +TP_PRIVATE tp_strvec tp_all_modes(void); + +/* Role is what an artist did on the track (R7). */ +typedef tp_str tp_role; +#define TP_ROLE_PRIMARY TP_S("primary") +#define TP_ROLE_FEATURED TP_S("featured") +#define TP_ROLE_REMIXER TP_S("remixer") +#define TP_ROLE_PRODUCER TP_S("producer") +TP_PRIVATE tp_strvec tp_all_roles(void); + +/* Source is where in the string an artist was found. */ +typedef tp_str tp_source; +#define TP_SOURCE_ARTIST TP_S("artist") +#define TP_SOURCE_TITLE TP_S("title") +#define TP_SOURCE_VERSION TP_S("version") +TP_PRIVATE tp_strvec tp_all_sources(void); + +/* VersionType is the type of a version (R5). A version head added through keywords can carry + * any string, which the output keeps as given. */ +typedef tp_str tp_version_type; +#define TP_VERSION_TYPE_REMIX TP_S("remix") +#define TP_VERSION_TYPE_BOOTLEG TP_S("bootleg") +#define TP_VERSION_TYPE_VIP TP_S("vip") +#define TP_VERSION_TYPE_EDIT TP_S("edit") +#define TP_VERSION_TYPE_FLIP TP_S("flip") +#define TP_VERSION_TYPE_REFIX TP_S("refix") +#define TP_VERSION_TYPE_REWORK TP_S("rework") +#define TP_VERSION_TYPE_MASHUP TP_S("mashup") +#define TP_VERSION_TYPE_BLEND TP_S("blend") +#define TP_VERSION_TYPE_DUB TP_S("dub") +#define TP_VERSION_TYPE_MIX TP_S("mix") +#define TP_VERSION_TYPE_EXTENDED TP_S("extended") +#define TP_VERSION_TYPE_RADIO TP_S("radio") +#define TP_VERSION_TYPE_CLUB TP_S("club") +#define TP_VERSION_TYPE_ORIGINAL TP_S("original") +#define TP_VERSION_TYPE_INSTRUMENTAL TP_S("instrumental") +#define TP_VERSION_TYPE_ACAPELLA TP_S("acapella") +#define TP_VERSION_TYPE_LIVE TP_S("live") +#define TP_VERSION_TYPE_ACOUSTIC TP_S("acoustic") +#define TP_VERSION_TYPE_REMASTER TP_S("remaster") +#define TP_VERSION_TYPE_DEMO TP_S("demo") +#define TP_VERSION_TYPE_REPRISE TP_S("reprise") +#define TP_VERSION_TYPE_COVER TP_S("cover") +#define TP_VERSION_TYPE_VERSION TP_S("version") +#define TP_VERSION_TYPE_SPED_UP TP_S("spedUp") +#define TP_VERSION_TYPE_SLOWED TP_S("slowed") +#define TP_VERSION_TYPE_NIGHTCORE TP_S("nightcore") +/* The 27 version types of the spec, in the spec's order. */ +TP_PRIVATE tp_strvec tp_all_version_types(void); + +/* Delimiter is how a version was written: in a bracket group, or after a dash. */ +typedef tp_str tp_delimiter; +#define TP_DELIMITER_PAREN TP_S("(") +#define TP_DELIMITER_SQUARE TP_S("[") +#define TP_DELIMITER_CURLY TP_S("{") +#define TP_DELIMITER_DASH TP_S("-") +TP_PRIVATE tp_strvec tp_all_delimiters(void); + +/* JunkKind is what kind of noise a junk fragment is (R5). keywords can add any string. */ +typedef tp_str tp_junk_kind; +#define TP_JUNK_KIND_VIDEO TP_S("video") +#define TP_JUNK_KIND_AUDIO TP_S("audio") +#define TP_JUNK_KIND_LYRICS TP_S("lyrics") +#define TP_JUNK_KIND_QUALITY TP_S("quality") +#define TP_JUNK_KIND_PROMO TP_S("promo") +#define TP_JUNK_KIND_PLATFORM TP_S("platform") +#define TP_JUNK_KIND_LABEL TP_S("label") +#define TP_JUNK_KIND_GENRE TP_S("genre") +#define TP_JUNK_KIND_OTHER TP_S("other") +TP_PRIVATE tp_strvec tp_all_junk_kinds(void); + +/* Warning is a warning of the single-track parser. */ +typedef tp_str tp_warning; +#define TP_WARNING_NO_SEPARATOR TP_S("noSeparator") +#define TP_WARNING_AMBIGUOUS_SEPARATOR TP_S("ambiguousSeparator") +#define TP_WARNING_UNSPACED_DASH_SPLIT TP_S("unspacedDashSplit") +#define TP_WARNING_ASYMMETRIC_DASH_SPLIT TP_S("asymmetricDashSplit") +#define TP_WARNING_BY_SPLIT TP_S("bySplit") +#define TP_WARNING_QUOTED_TITLE_SPLIT TP_S("quotedTitleSplit") +#define TP_WARNING_AMBIGUOUS_MIX_CREDIT TP_S("ambiguousMixCredit") +#define TP_WARNING_UNBALANCED_BRACKETS TP_S("unbalancedBrackets") +TP_PRIVATE tp_strvec tp_all_warnings(void); + +/* EntryKind is what a line of a tracklist is (R13.3). */ +typedef tp_str tp_entry_kind; +#define TP_ENTRY_KIND_TRACK TP_S("track") +#define TP_ENTRY_KIND_MARKER TP_S("marker") +#define TP_ENTRY_KIND_HEADER TP_S("header") +#define TP_ENTRY_KIND_LINK TP_S("link") +#define TP_ENTRY_KIND_NOTE TP_S("note") +#define TP_ENTRY_KIND_BLANK TP_S("blank") +TP_PRIVATE tp_strvec tp_all_entry_kinds(void); + +/* Eol is the line terminator that followed a line (R13.1.1); NONE is "" (last line). */ +typedef tp_str tp_eol; +#define TP_EOL_LF TP_S("\n") +#define TP_EOL_CRLF TP_S("\r\n") +#define TP_EOL_CR TP_S("\r") +#define TP_EOL_NONE TP_S("") +TP_PRIVATE tp_strvec tp_all_eols(void); + +/* WarningCode is the code of a tracklist warning (R13.7), in the table order of the spec. */ +typedef tp_str tp_warning_code; +#define TP_WARNING_CODE_TIME_MISSING TP_S("time-missing") +#define TP_WARNING_CODE_TIME_OUT_OF_ORDER TP_S("time-out-of-order") +#define TP_WARNING_CODE_TIME_DUPLICATE TP_S("time-duplicate") +#define TP_WARNING_CODE_NO_START_AT_ZERO TP_S("no-start-at-zero") +#define TP_WARNING_CODE_TIME_AFTER_AUDIO_END TP_S("time-after-audio-end") +#define TP_WARNING_CODE_INVALID_TIME TP_S("invalid-time") +#define TP_WARNING_CODE_POSITION_GAP TP_S("position-gap") +#define TP_WARNING_CODE_POSITION_DUPLICATE TP_S("position-duplicate") +#define TP_WARNING_CODE_LINE_UNPARSED TP_S("line-unparsed") +TP_PRIVATE tp_strvec tp_all_warning_codes(void); + +/* Severity is how serious a tracklist warning is. */ +typedef tp_str tp_severity; +#define TP_SEVERITY_INFO TP_S("info") +#define TP_SEVERITY_WARNING TP_S("warning") +TP_PRIVATE tp_strvec tp_all_severities(void); + +/* EditOp names the operation of an edit (R13.9). */ +typedef tp_str tp_edit_op; +#define TP_EDIT_OP_SET_TIME TP_S("set-time") +#define TP_EDIT_OP_SHIFT TP_S("shift") +#define TP_EDIT_OP_SORT_BY_TIME TP_S("sort-by-time") +#define TP_EDIT_OP_SET_REST TP_S("set-rest") +#define TP_EDIT_OP_INSERT TP_S("insert") +#define TP_EDIT_OP_DELETE TP_S("delete") +TP_PRIVATE tp_strvec tp_all_edit_ops(void); + +/* EditWarningCode is the code of an edit warning (R13.9). */ +typedef tp_str tp_edit_warning_code; +#define TP_EDIT_WARNING_CODE_EDIT_INVALID TP_S("edit-invalid") +#define TP_EDIT_WARNING_CODE_TIME_CLAMPED TP_S("time-clamped") +#define TP_EDIT_WARNING_CODE_STYLE_UPGRADED TP_S("style-upgraded") +TP_PRIVATE tp_strvec tp_all_edit_warning_codes(void); + +/* C addition (no Go counterpart): the index of name in names, or -1. The public API maps the + * internal strings to its enums with it (mind tp_all_modes having no auto). */ +TP_PRIVATE ptrdiff_t tp_name_index(tp_strvec names, tp_str name); + +/* Artist is one credited artist. */ +struct tp_artist { + tp_str name; /* as written, trimmed */ + tp_role role; + const tp_str *joiner; /* raw joiner or marker before the name; NULL for the first of a list */ + tp_source source; +}; + +/* Version is one version of the track: a remix, an edit, a live take, a remaster (R5, R8). */ +struct tp_version { + tp_version_type type; + tp_str raw; /* without its brackets */ + tp_artist_vec artists; /* role remixer; empty without a credit */ + tp_strvec modifiers; /* other version words, lowercase keys */ + const tp_str *descriptor; + const ptrdiff_t *year; + bool unknown_artist; /* the credit is a placeholder (ID, Unknown) */ + tp_delimiter delimiter; +}; + +/* Junk is a fragment that says nothing about the track (extracted, not deleted). */ +struct tp_junk { + tp_str raw; + tp_junk_kind kind; +}; + +/* Flags are yes/no facts about the track. explicit_ is "explicit" in JSON. */ +struct tp_flags { + bool explicit_; + bool clean; + bool unknown_artist; + bool unknown_title; +}; + +/* Position is a track number in front of the string (R4.2). */ +struct tp_position { + tp_str raw; + ptrdiff_t number; +}; + +/* Timestamp is a cue time in front of a single track string (R4.1), in whole seconds. */ +struct tp_timestamp { + tp_str raw; + ptrdiff_t seconds; +}; + +/* Track is the result of parse: everything recognized in one track string. */ +struct tp_track { + tp_str input; + tp_mode mode; /* never auto */ + const tp_position *position; + const tp_timestamp *timestamp; + tp_artist_vec artists; /* primary, featured, producer; remixers are in versions */ + tp_str title; + tp_str full_title; + tp_version_vec versions; + const ptrdiff_t *year; + tp_flags flags; + tp_junk_vec junk; + tp_strvec warnings; /* tp_warning values */ +}; + +/* Parts is a line cut into lead + time + gap + rest, which join back to it (R13.1.3). */ +struct tp_parts { + tp_str lead; + tp_str time; + tp_str gap; + tp_str rest; +}; + +/* TracklistTime is the time of a tracklist line (R13.2.5); seconds may carry a fraction. */ +struct tp_tracklist_time { + tp_str raw; + double seconds; +}; + +/* Entry is one line of a tracklist. */ +struct tp_entry { + ptrdiff_t line; /* 1-based */ + tp_entry_kind kind; + tp_eol eol; + tp_str raw; /* never normalized */ + tp_parts parts; + const tp_tracklist_time *time; + const tp_track *track; /* track and marker entries */ + bool layered; /* R13.13 */ +}; + +/* Suggestion is a fix for a time-out-of-order warning that changes one or two digits (R13.7). */ +struct tp_suggestion { + ptrdiff_t line; + tp_str raw; + double seconds; +}; + +/* TracklistWarning is a warning about a tracklist (R13.7). */ +struct tp_tracklist_warning { + tp_warning_code code; + ptrdiff_t line; + tp_severity severity; + const tp_suggestion *suggestion; +}; + +/* Stats are counts over a tracklist. */ +struct tp_stats { + ptrdiff_t lines; + ptrdiff_t tracks; + ptrdiff_t markers; + ptrdiff_t timed; + const double *first_time; + const double *last_time; +}; + +/* Tracklist is the result of parseTracklist (R13.1.2: raw + eol joined is the text). */ +struct tp_tracklist { + tp_str spec_version; + tp_entry_vec entries; + tp_tracklist_warning_vec warnings; /* ordered by line */ + tp_stats stats; +}; + +/* Edit is one edit of a tracklist text (R13.9); each operation reads only its own fields. */ +struct tp_edit { + tp_edit_op op; + int64_t line; /* set-time, set-rest, delete */ + double seconds; /* set-time: the new time; shift: the amount */ + bool has_lines; /* Go Lines != nil: lines was given (it may be empty: shifts no line) */ + tp_intvec lines; /* shift only these lines */ + const int64_t *from; /* shift from this line on; NULL: not given */ + tp_str rest; /* set-rest */ + int64_t after; /* insert after this line; 0: at the start */ + tp_str text; /* insert, without a terminator */ +}; + +/* EditWarning is a warning about one edit. */ +struct tp_edit_warning { + tp_edit_warning_code code; + ptrdiff_t edit; /* index into the edits */ + const int64_t *line; /* see tp_saturating_int */ +}; + +/* EditResult is the result of applyEdits. */ +struct tp_edit_result { + tp_str text; + tp_intvec changed; /* final line numbers of written lines; sorted, unique */ + tp_edit_warning_vec warnings; +}; + +/* rawEditWarning is an edit warning with the line as the JS reference holds it: any number an + * invalid edit carried (possibly negative or fractional behind the JSON door). */ +struct tp_raw_edit_warning { + tp_edit_warning_code code; + ptrdiff_t edit; + const double *line; +}; + +/* rawEditResult is the result of tp_apply_edits before it is typed or written as JSON. */ +struct tp_raw_edit_result { + tp_str text; + tp_intvec changed; + tp_raw_edit_warning_vec warnings; +}; + +/* result is the typed form (lines saturate to int64). */ +TP_PRIVATE tp_edit_result tp_raw_edit_result_result(const tp_raw_edit_result *r); +/* saturatingInt converts a float to int64 (Go int on 64-bit), clamping to the range (NaN gives + * 0). */ +TP_PRIVATE int64_t tp_saturating_int(double f); + +/* ============================================================================================ */ +/* options.go: typed options, the resolved forms, and the typed and JSON resolvers (R12, R0.8) */ + +/* SplitAnd is when the word "and" splits a credit list (R7.3); "" means auto. In parse options + * any other string behaves as always; in tracklist options as auto. */ +typedef tp_str tp_split_and; +#define TP_SPLIT_AND_AUTO TP_S("auto") +#define TP_SPLIT_AND_ALWAYS TP_S("always") +#define TP_SPLIT_AND_NEVER TP_S("never") + +/* FeatPlacement is where format writes featured artists (R11.2); "" means source. Any other + * string places them nowhere. */ +typedef tp_str tp_feat_placement; +#define TP_FEAT_SOURCE TP_S("source") +#define TP_FEAT_ARTIST TP_S("artist") +#define TP_FEAT_TITLE TP_S("title") +#define TP_FEAT_OMIT TP_S("omit") + +/* JoinerStyle (R11.5); "" and unknown mean original. */ +typedef tp_str tp_joiner_style; +#define TP_JOINERS_ORIGINAL TP_S("original") +#define TP_JOINERS_CANONICAL TP_S("canonical") + +/* VersionsOption (R11.3); "" means all, any other string none. */ +typedef tp_str tp_versions_option; +#define TP_VERSIONS_ALL TP_S("all") +#define TP_VERSIONS_NONE TP_S("none") + +/* VersionHead is an extra version head word and its version type. */ +struct tp_version_head { + tp_str key; + tp_version_type type; +}; + +/* JunkPhrase is an extra junk phrase and its kind. */ +struct tp_junk_phrase { + tp_str phrase; + tp_junk_kind kind; +}; + +/* Keywords is extra vocabulary (R12). The two JS maps are ordered vectors: a repeated key keeps + * its first place and takes the last value; integer-like keys first (tp_js_entries). */ +struct tp_keywords { + tp_version_head_vec version_heads; + tp_strvec descriptors; + tp_strvec genres; + tp_junk_phrase_vec junk; + tp_strvec feat_markers; +}; + +/* isEmpty reports whether k adds no word, so the default tables can be shared. */ +TP_PRIVATE bool tp_keywords_is_empty(const tp_keywords *k); + +/* ParseOptions (R12): the zero value is what parse uses. */ +struct tp_parse_options { + tp_mode mode; /* "" means auto */ + tp_str uploader; /* R6.8; "" means none */ + tp_strvec known_artists; /* R7.3a */ + tp_split_and split_and; + tp_keywords keywords; +}; + +/* FormatOptions (R11): the zero value is what format uses. */ +struct tp_format_options { + tp_feat_placement feat; + const tp_str *feat_marker; /* NULL: the input's marker; pointer to "": an empty marker */ + tp_joiner_style joiners; + tp_versions_option versions; + bool omit_producers; /* JS producers: false */ + bool position; +}; + +/* TracklistOptions (R13.10): the zero value is what parseTracklist uses. */ +struct tp_tracklist_options { + tp_mode mode; /* "" means tracklist; auto picks a mode per line */ + tp_strvec known_artists; + tp_split_and split_and; + tp_keywords keywords; + const double *audio_seconds; /* NULL, negative, non-finite: unknown; pointer to 0 is 0 */ + tp_strvec marker_words; /* R13.3 */ +}; + +/* The edit constructors (Go SetTime, Shift, ...). Renamed with tp_edit_ because rt.h has a + * tp_insert macro. */ +/* SetTime rewrites the time of line, keeping its written style (R13.9.2). */ +TP_PRIVATE tp_edit tp_edit_set_time(int64_t line, double seconds); +/* Shift adds seconds to every timed line. */ +TP_PRIVATE tp_edit tp_edit_shift(double seconds); +/* ShiftFrom adds seconds to every timed line from line from on. */ +TP_PRIVATE tp_edit tp_edit_shift_from(double seconds, int64_t from); +/* ShiftLines adds seconds to the given lines only (has_lines is true even for count 0). */ +TP_PRIVATE tp_edit tp_edit_shift_lines(double seconds, const int64_t *lines, size_t count); +/* SortByTime sorts the timed lines stably, each with the untimed lines after it (R13.9.4). */ +TP_PRIVATE tp_edit tp_edit_sort_by_time(void); +/* SetRest replaces everything after the time and gap of line. */ +TP_PRIVATE tp_edit tp_edit_set_rest(int64_t line, tp_str rest); +/* Insert inserts text as a new line after line after (0: at the start). */ +TP_PRIVATE tp_edit tp_edit_insert(int64_t after, tp_str text); +/* Delete removes line. */ +TP_PRIVATE tp_edit tp_edit_delete(int64_t line); + +/* requestKind is how options.mode reached the pipeline. */ +typedef enum tp_request_kind { + TP_REQUEST_AUTO, /* missing, null or "auto" */ + TP_REQUEST_MODE, /* one of the four mode names */ + TP_REQUEST_OTHER /* anything else: JS skips the R2.1 youtube detection, still detects + filenames */ +} tp_request_kind; + +/* requestedMode is options.mode as the pipeline sees it; mode is set for TP_REQUEST_MODE only. */ +struct tp_requested_mode { + tp_request_kind kind; + tp_mode mode; +}; + +/* splitAndMode is options.splitAnd as the pipeline sees it. */ +typedef enum tp_split_and_mode { TP_SPLIT_AUTO, TP_SPLIT_ALWAYS, TP_SPLIT_NEVER } tp_split_and_mode; + +/* kv is one key/value pair of an options object, in JS Object.entries order. */ +struct tp_kv { + tp_str key; + tp_str value; +}; + +/* keywordLists is options.keywords with the maps in JS Object.entries order. Types and kinds + * stay strings: JS passes any string through to the output. */ +struct tp_keyword_lists { + tp_kv_vec version_heads; + tp_strvec descriptors; + tp_strvec genres; + tp_kv_vec junk; + tp_strvec feat_markers; +}; + +/* resolvedOptions are parse options after the R0.8 fallbacks. The zero value is the default. */ +struct tp_resolved_options { + tp_requested_mode mode; + tp_str uploader; /* R6.8; "" means none */ + tp_strvec known_artists; + tp_split_and_mode split_and; + const tp_keyword_lists *keywords; /* NULL for the default tables */ +}; + +/* featMode is options.feat as R11 reads it. Prefixed TP_FEAT_MODE_ (deviation): TP_FEAT_SOURCE + * is already the FeatPlacement string. */ +typedef enum tp_feat_mode { + TP_FEAT_MODE_SOURCE, + TP_FEAT_MODE_ARTIST, + TP_FEAT_MODE_TITLE, + TP_FEAT_MODE_OMIT /* also any unknown value: featured artists placed nowhere */ +} tp_feat_mode; + +/* resolvedFormat are format options after the fallbacks. */ +struct tp_resolved_format { + tp_feat_mode feat; + const tp_str *feat_marker; /* NULL: keep the input's marker */ + bool canonical; + bool versions; + bool producers; + bool position; +}; + +/* resolvedTracklist are tracklist options after the R13.10 fallbacks. */ +struct tp_resolved_tracklist { + tp_resolved_options parse; /* the per-line parse */ + const double *audio_seconds; /* NULL when unknown */ + tp_strvec marker_words; +}; + +/* modeByName is a mode for one of the four names of a parsed mode. */ +TP_PRIVATE bool tp_mode_by_name(tp_str name, tp_mode *out); +/* requestFor is the R2 request for a mode name given as a string. */ +TP_PRIVATE tp_requested_mode tp_request_for(tp_str name); +/* parseSplitAnd: anything but auto and never (or missing) behaves as always in JS. */ +TP_PRIVATE tp_split_and_mode tp_parse_split_and(tp_str name); +/* tracklistSplitAnd: only always and never count. */ +TP_PRIVATE tp_split_and_mode tp_tracklist_split_and(tp_str name); +/* tracklistRequest: a mode name or auto; anything else means tracklist. */ +TP_PRIVATE tp_requested_mode tp_tracklist_request(tp_str name); +/* arrayIndex reports whether key is a canonical array index ("0", "17"; not "01"). */ +TP_PRIVATE bool tp_array_index(tp_str key, uint64_t *out); +/* jsEntries is the Object.entries order of an object built from pairs: a repeated key keeps its + * first place and takes the last value; integer-like keys first ascending, then insertion. */ +TP_PRIVATE tp_kv_vec tp_js_entries(tp_kv_vec pairs); +/* sanitizeAll is tp_sanitize over a list (a fresh vector, never the caller's). */ +TP_PRIVATE tp_strvec tp_sanitize_all(tp_strvec list); +/* resolveKeywords is the typed keywords; NULL when they add nothing. */ +TP_PRIVATE const tp_keyword_lists *tp_resolve_keywords(const tp_keywords *k); +/* resolveParse is the typed door to resolvedOptions. o NULL is the zero value. */ +TP_PRIVATE tp_resolved_options tp_resolve_parse(const tp_parse_options *o); +/* resolveFormat is the typed door to resolvedFormat. o NULL is the zero value. */ +TP_PRIVATE tp_resolved_format tp_resolve_format(const tp_format_options *o); +/* audio is the R13.10 audio length: NULL unless given, finite and not negative. */ +TP_PRIVATE const double *tp_audio(const double *seconds); +/* resolveTracklist is the typed door to resolvedTracklist. o NULL is the zero value. */ +TP_PRIVATE tp_resolved_tracklist tp_resolve_tracklist(const tp_tracklist_options *o); +/* stringList is an option list as JS reads it at run time (R0.8): only an array's strings. */ +TP_PRIVATE tp_strvec tp_string_list(tp_json v, bool ok); +/* stringEntries is an option map as JS reads it: a plain object's string values, in + * Object.entries order. */ +TP_PRIVATE tp_kv_vec tp_string_entries(tp_json v, bool ok); +/* keywordsJSON is options.keywords from loose JSON (a plain object only). */ +TP_PRIVATE const tp_keyword_lists *tp_keywords_json(tp_json v); +/* resolveParseJSON is the JSON door to resolvedOptions, with the JS fallbacks. */ +TP_PRIVATE tp_resolved_options tp_resolve_parse_json(tp_json o); +/* truthy is JS truthiness of a JSON value. */ +TP_PRIVATE bool tp_truthy(tp_json v); +/* jsString is JS String(value), what a template literal does with a non-string featMarker. */ +TP_PRIVATE tp_str tp_js_string(tp_json v); +/* resolveFormatJSON is the JSON door to resolvedFormat (`??` for missing and null). Its Go + * closure get becomes a static helper. */ +TP_PRIVATE tp_resolved_format tp_resolve_format_json(tp_json o); +/* jsNumber is a JS number view of a JSON value: true only for a number (a bool is not one). The + * value may be NaN or infinite. */ +TP_PRIVATE bool tp_js_number(tp_json v, bool present, double *out); +/* resolveTracklistJSON is the JSON door to resolvedTracklist; uploader is not a tracklist + * option. */ +TP_PRIVATE tp_resolved_tracklist tp_resolve_tracklist_json(tp_json o); + +/* ============================================================================================ */ +/* context.go: the engine (built once per Parser) and the per-call ctx */ + +/* engine is resolved options with the tables and knownArtists keys built once. Read-only after + * tp_engine_new, so safe for concurrent use; every call makes its own ctx. */ +struct tp_engine { + tp_resolved_options opts; + const tp_tables *t; + tp_word_set known_keys; + ptrdiff_t known_max_len; /* longest knownArtists entry, in UTF-16 units */ +}; + +/* ctx is the state of one parse. */ +struct tp_ctx { + const tp_tables *t; + const tp_word_set *known_keys; /* the engine's */ + ptrdiff_t known_max_len; /* UTF-16 units; bounds the R7.3a search */ + tp_split_and_mode split_and; + tp_strvec warnings; /* tp_warning values, each once */ + ptrdiff_t list_seq; /* R7.6: the next credit list id (ids start at 0) */ +}; + +/* newEngine builds the tables and known keys for o, in the current arena. */ +TP_PRIVATE tp_engine *tp_engine_new(tp_resolved_options o); +/* sharedEngine is the engine behind parse and parseArtists without options (tp_once_get; built + * into the current arena when the once-build ran out of memory). */ +TP_PRIVATE const tp_engine *tp_shared_engine(void); +/* newCtx is a fresh per-call context. */ +TP_PRIVATE tp_ctx *tp_engine_new_ctx(const tp_engine *e); +/* knownKeysOf is the dedup keys of known and the longest entry in UTF-16 units (*max_len). */ +TP_PRIVATE tp_word_set tp_known_keys_of(tp_strvec known, ptrdiff_t *max_len); +/* warn adds w once. */ +TP_PRIVATE void tp_ctx_warn(tp_ctx *c, tp_warning w); +/* matchKnownAt is R7.3a: the length (code points) of the longest knownArtists entry matching + * text at start (dedup-key comparison), followed by the end, whitespace, "," or ";" (or extra, + * unless TP_NORUNE). 0 when none. Window: 2 * longest + 8 UTF-16 units, as in JS. */ +TP_PRIVATE ptrdiff_t tp_match_known_at(tp_runes text, ptrdiff_t start, tp_ctx *c, tp_rune extra); +/* isKnownArtist reports whether text is a knownArtists entry (dedup-key comparison). */ +TP_PRIVATE bool tp_is_known_artist(tp_str text, tp_ctx *c); + +/* ============================================================================================ */ +/* tables.go: the vocabulary tables (R12) */ + +/* spacedJoiner is one spaced joiner of joiners.json (R7.3). */ +struct tp_spaced_joiner { + tp_str raw; + tp_str canonical; + bool is_and; + bool case_sensitive; +}; + +/* runInfo is the category of a word in the R5.7.2 modifier run. NULL / false is not set (JS + * undefined). Phrase-table values of tables.run_words are const tp_run_info *. */ +struct tp_run_info { + const tp_str *type_capable; + const tp_str *descriptor; + bool genre; + const tp_str *head; +}; + +/* tables are the vocabulary the pipeline reads. Phrase-table values: NULL for the set-like + * ones (Go struct{}), const tp_str * for the string ones, const tp_run_info * for run_words. */ +struct tp_tables { + const tp_phrase_table *feat_markers; + const tp_phrase_table *bracket_only_feat; + const tp_phrase_table *producer_markers; + const tp_phrase_table *title_feat_markers; /* R8.3, plus keywords.featMarkers */ + const tp_phrase_table *title_producer_markers; /* R8.3 */ + const tp_phrase_table *junk_or_genre; /* string: R5.1 tokenizer vocabulary */ + const tp_phrase_table *junk_phrases; /* string: R8.4 */ + tp_word_set junk_connectors; + tp_word_set label_suffixes; + const tp_phrase_table *heads; /* string */ + tp_word_set generic_head_types; + const tp_phrase_table *run_words; /* run_info: R5.7.2 */ + const tp_phrase_table *prefix_forms; /* string */ + tp_spaced_joiner_vec spaced_joiners; + /* Go map tightJoiners (raw -> canonical) as pairs; look up with tp_tables_tight_joiner. */ + tp_kv_vec tight_joiners; + tp_str feat_canonical; + tp_word_set no_split_before; + tp_word_set stopwords; + tp_word_set unknown_case_sensitive; + tp_word_set unknown_case_insensitive; + tp_word_set extensions; + tp_strvec platform_suffixes; /* by UTF-16 length, longest first (stable) */ +}; + +/* C addition: the Go map lookup t.tightJoiners[raw]. A later pair with the same raw wins, as a + * Go map assignment does. */ +TP_PRIVATE bool tp_tables_tight_joiner(const tp_tables *t, tp_str raw, tp_str *canonical); +/* C addition: a read-only tp_strvec view of a generated data array (cap == n, so appending to it + * copies, as a Go append to a full slice does). */ +TP_PRIVATE tp_strvec tp_data_strs(const tp_str *p, size_t n); +/* lowerKeys is JS `asciiLower(s).trim()` of each entry, empty ones dropped. */ +TP_PRIVATE tp_strvec tp_lower_keys(tp_strvec list); +/* dataEntries are the pairs of a data object in JS Object.entries order. */ +TP_PRIVATE tp_kv_vec tp_data_entries(const tp_data_kv *list, size_t n); +/* markerTable is a set-like phrase table of base plus extra. */ +TP_PRIVATE const tp_phrase_table *tp_marker_table(tp_strvec base, tp_strvec extra); +/* kindTable is a phrase table of string values over several entry lists (Go variadic). */ +TP_PRIVATE const tp_phrase_table *tp_kind_table(const tp_kv_vec *entries, size_t count); +/* buildTables compiles the tables; kw NULL means no extra words. The Go closure note becomes a + * static helper over a context struct (run keys, index map, infos). */ +TP_PRIVATE tp_tables *tp_build_tables(const tp_keyword_lists *kw); +/* defaultTables are the tables without keywords, built once (tp_once_get, with the current-arena + * fallback). */ +TP_PRIVATE const tp_tables *tp_default_tables(void); +/* tablesFor is the default tables when kw is NULL, else fresh tables with the extra words. */ +TP_PRIVATE const tp_tables *tp_tables_for(const tp_keyword_lists *kw); +/* isUnknownToken is R7.5 / R8.6: an unknown placeholder name (ID, ???, Untitled...). */ +TP_PRIVATE bool tp_is_unknown_token(tp_str text, const tp_tables *t); + +/* ============================================================================================ */ +/* normalize.go: R1 */ + +/* isRemoved is R1.2: the invisible characters removed outright (ZWNJ, ZWJ kept; U+E000 is the + * R3.4 placeholder, so it can never occur in input). */ +TP_PRIVATE bool tp_is_removed(tp_rune r); +/* mapRune is R1.3 brackets, R1.4 quotes and R1.5 dashes to ASCII. false for a removed + * character. */ +TP_PRIVATE bool tp_map_rune(tp_rune r, tp_rune *out); +/* collapseSpacedDashRuns is the second half of R1.5: a run of two or more "-" with whitespace on + * both sides becomes one "-". */ +TP_PRIVATE tp_runes tp_collapse_spaced_dash_runs(tp_runes t); +/* normalize is R1 on a track string. It is idempotent. */ +TP_PRIVATE tp_str tp_normalize(tp_str input); + +/* ============================================================================================ */ +/* mode.go: R2 */ + +/* positionedJunk is a junk fragment with its absolute offset (R9 orders junk by it). */ +struct tp_positioned_junk { + tp_str raw; + tp_junk_kind kind; /* keywords.junk values pass through as given */ + ptrdiff_t pos; +}; + +/* piece is a contiguous piece of the normalized string and its absolute offset. */ +struct tp_piece { + tp_runes text; + ptrdiff_t base; +}; + +/* preludeResult is the outcome of R2. */ +struct tp_prelude_result { + tp_mode mode; + tp_piece working; /* R2.4 step 2 or 4, or the artist piece of "artist | title" */ + const tp_piece *pipe_title; /* R2.4 step 3: the title piece; NULL otherwise */ + tp_positioned_junk_vec junk; +}; + +/* asciiLowerRunes lowercases A-Z only. */ +TP_PRIVATE tp_runes tp_ascii_lower_runes(tp_runes t); +/* hasRuneSuffix reports whether t ends with suffix. */ +TP_PRIVATE bool tp_has_rune_suffix(tp_runes t, tp_runes suffix); +/* runeIndex is the first index of r in t, or -1. */ +TP_PRIVATE ptrdiff_t tp_rune_index(tp_runes t, tp_rune r); +/* lastRuneIndex is the last index of r in t, or -1. */ +TP_PRIVATE ptrdiff_t tp_last_rune_index(tp_runes t, tp_rune r); +/* stripPlatformSuffixes is R2.2: strip trailing platform suffixes (longest first, repeatedly), + * appending each to junk. */ +TP_PRIVATE tp_runes tp_strip_platform_suffixes(tp_runes s, tp_ctx *c, tp_positioned_junk_vec *junk); +/* hasExtension reports whether s ends in a known file extension (R2.3). */ +TP_PRIVATE bool tp_has_extension(tp_runes s, tp_ctx *c); +/* splitPipes splits a skeleton at top-level " | " and " || " into trimmed segments (R2.4). */ +TP_PRIVATE tp_segment_vec tp_split_pipes(tp_skel sk); +/* trailingJunkPhrase is the R8.4 test: text ends with an unbracketed junk phrase (genres + * excluded): the code-point index where it starts (*start) and its kind (*kind). */ +TP_PRIVATE bool tp_trailing_junk_phrase(tp_runes text, tp_ctx *c, ptrdiff_t *start, tp_str *kind); +/* junkTextKind is the R5.1 junk kind of a whole text, if it is junk. */ +TP_PRIVATE bool tp_junk_text_kind(tp_str text, tp_ctx *c, tp_str *kind); +/* looksLikeYoutube is the R2.1 youtube signals besides platform suffixes. */ +TP_PRIVATE bool tp_looks_like_youtube(tp_skel sk, tp_ctx *c); +/* prelude is R2 on the normalized string. */ +TP_PRIVATE tp_prelude_result tp_prelude(tp_str normalized, tp_requested_mode requested, tp_ctx *c); +/* pieceOf is the rendered text of a segment with its absolute offset. */ +TP_PRIVATE tp_piece tp_piece_of(tp_segment seg); +/* splitYoutubePipes is R2.4: the working piece, and the title piece (*pipe_title, NULL when + * none; always written). The Go closure pushOther becomes a static helper. */ +TP_PRIVATE tp_piece tp_split_youtube_pipes(tp_skel sk, tp_ctx *c, tp_positioned_junk_vec *junk, + const tp_piece **pipe_title); + +/* ============================================================================================ */ +/* prefix.go: R4 */ + +/* prefixResult is the input after R4. */ +struct tp_prefix_result { + tp_runes rest; + ptrdiff_t base; /* absolute offset of rest */ + const tp_timestamp *timestamp; + const tp_position *position; +}; + +/* timeMatch is a time at the start of a prefix. */ +struct tp_time_match { + tp_str raw; + ptrdiff_t seconds; + ptrdiff_t end; +}; + +/* matchTime is H:MM:SS, HH:MM:SS, M:SS or MM:SS starting at from (R4.1). */ +TP_PRIVATE bool tp_match_time(tp_runes s, ptrdiff_t from, tp_time_match *out); +/* skipSpaceAndDash skips, after a prefix, one space and then an optional "- " (spaced dash). */ +TP_PRIVATE ptrdiff_t tp_skip_space_and_dash(tp_runes s, ptrdiff_t from); +/* matchTimestamp is R4.1: the timestamp (*ts) and the index where the rest starts (*rest). */ +TP_PRIVATE bool tp_match_timestamp(tp_runes s, tp_timestamp *ts, ptrdiff_t *rest); +/* containsSpacedDash reports whether the skeleton of s has a spaced dash. */ +TP_PRIVATE bool tp_contains_spaced_dash(tp_runes s); +/* matchPosition is R4.2: the end index of the position prefix. Forms (a), (b), (c), then (d) + * and (e). */ +TP_PRIVATE bool tp_match_position(tp_runes s, tp_mode mode, ptrdiff_t *end); +/* stripPrefixes is R4 on text, whose first code point sits at absolute offset base. */ +TP_PRIVATE tp_prefix_result tp_strip_prefixes(tp_runes text, ptrdiff_t base, tp_mode mode, + tp_ctx *c); + +/* ============================================================================================ */ +/* scanner.go: R3 */ + +/* ph is the R3.4 placeholder code point. R1.2 removes it from input. */ +#define TP_PH ((tp_rune)0xE000) + +/* group is one top-level bracket group (R3.1). */ +struct tp_group { + tp_delimiter open; + tp_str inner; /* R3.5: trimmed and whitespace-collapsed */ + tp_str raw; /* exactly as written, brackets included */ + ptrdiff_t pos; /* absolute offset of the opener */ +}; + +/* groupMap holds the groups of one scan by the offset of their opener (Go map[int]*group). Only + * looked up, never iterated; shared read-only by every slice of the skeleton. tp_scan adds the + * groups in strictly ascending pos, so the C form is a sorted vector with binary search. */ +struct tp_group_map { + tp_group_ptr_vec groups; /* ascending pos */ +}; +/* C addition: add g; g->pos must be greater than every pos already in m. */ +TP_PRIVATE void tp_group_map_put(tp_group_map *m, const tp_group *g); +/* C addition: the group whose opener is at pos, or NULL (Go groups[pos]). */ +TP_PRIVATE const tp_group *tp_group_map_get(const tp_group_map *m, ptrdiff_t pos); + +/* skel is a skeleton: text with each top-level group replaced by TP_PH, and the absolute offset + * of every code point (pos.n == text.n). */ +struct tp_skel { + tp_runes text; + tp_idxvec pos; + const tp_group_map *groups; +}; + +/* C form of the Go closure offsetAt in scan: the absolute offset of every code point plus one + * entry for the end; out of range gives end. */ +struct tp_offsets { + tp_idxvec at; + ptrdiff_t end; +}; +TP_PRIVATE ptrdiff_t tp_offset_at(const tp_offsets *o, ptrdiff_t i); + +/* closerOf is the closing bracket for an opener, or TP_NORUNE. */ +TP_PRIVATE tp_rune tp_closer_of(tp_rune r); +/* delimiterOf is the version delimiter of an opener. */ +TP_PRIVATE tp_delimiter tp_delimiter_of(tp_rune r); +/* scan is R3.1 to R3.5 on s, whose first code point sits at absolute offset base. *unbalanced + * is R3.3 (always written). */ +TP_PRIVATE tp_skel tp_scan(tp_runes s, ptrdiff_t base, bool *unbalanced); +/* addGroup records the group s[start:end] (closed: end includes the closer). */ +TP_PRIVATE void tp_add_group(tp_runes s, ptrdiff_t start, ptrdiff_t end, bool closed, + const tp_offsets *offsets, tp_group_map *groups); +/* clamped is t[a:b] with both ends clamped (JS slice with non-negative bounds). Go generic: + * one function per element type used. No copy. */ +TP_PRIVATE tp_runes tp_clamped_runes(tp_runes t, ptrdiff_t a, ptrdiff_t b); +TP_PRIVATE tp_idxvec tp_clamped_ints(tp_idxvec t, ptrdiff_t a, ptrdiff_t b); +/* len is the number of code points. */ +TP_PRIVATE ptrdiff_t tp_skel_len(const tp_skel *s); +/* isEmpty reports whether the skeleton has no code points. */ +TP_PRIVATE bool tp_skel_is_empty(const tp_skel *s); +/* sliceSkel is s[start:end], clamped. Text and offsets copied, groups shared. */ +TP_PRIVATE tp_skel tp_slice_skel(const tp_skel *s, ptrdiff_t start, ptrdiff_t end); +/* sliceFrom is s[start:]. */ +TP_PRIVATE tp_skel tp_slice_from(const tp_skel *s, ptrdiff_t start); +/* trimSkel removes R0.2 whitespace at both ends. */ +TP_PRIVATE tp_skel tp_trim_skel(const tp_skel *s); +/* concatSkel is a followed by b (the groups of a). */ +TP_PRIVATE tp_skel tp_concat_skel(const tp_skel *a, const tp_skel *b); +/* groupAt is the group behind the placeholder at index, or NULL. */ +TP_PRIVATE const tp_group *tp_group_at(const tp_skel *s, ptrdiff_t index); + +/* indexedGroup is a group with the index of its placeholder. */ +struct tp_indexed_group { + ptrdiff_t index; + const tp_group *group; +}; + +/* groupsOf is the groups of the skeleton, left to right. */ +TP_PRIVATE tp_indexed_group_vec tp_groups_of(const tp_skel *s); +/* hasGroup reports whether the skeleton holds a placeholder. */ +TP_PRIVATE bool tp_has_group(const tp_skel *s); +/* renderSkel substitutes the groups back (R3.4 reassembly). Whitespace is not touched. */ +TP_PRIVATE tp_str tp_render_skel(const tp_skel *s); +/* startPos is the absolute offset of the first code point, or fallback when empty. */ +TP_PRIVATE ptrdiff_t tp_start_pos(const tp_skel *s, ptrdiff_t fallback); +/* removeGroups removes the placeholders of the groups at the given offsets. Go takes a + * map[int]struct{}; C takes the offsets sorted ascending (tp_extract_groups and + * tp_parse_artist_side produce them in groupsOf order) and binary-searches them. */ +TP_PRIVATE tp_skel tp_remove_groups(const tp_skel *s, tp_idxvec remove); +/* C addition: whether the ascending vector v holds x (binary search). */ +TP_PRIVATE bool tp_sorted_has(tp_idxvec v, ptrdiff_t x); +/* isSpacedDashAt is R6.1: "-" with a space immediately on both sides. */ +TP_PRIVATE bool tp_is_spaced_dash_at(tp_runes t, ptrdiff_t i); +/* hasSpacedDash reports whether t has a spaced dash. */ +TP_PRIVATE bool tp_has_spaced_dash(tp_runes t); + +/* segment is a trimmed piece of a skeleton and its range inside the parent. */ +struct tp_segment { + tp_skel skel; + ptrdiff_t start; + ptrdiff_t end; +}; + +/* trimmedSegment is s[start:end] trimmed of R0.2 whitespace. */ +TP_PRIVATE tp_segment tp_trimmed_segment(const tp_skel *s, ptrdiff_t start, ptrdiff_t end); +/* splitAtSpacedDashes is R6.1 / R8.2: split at every spaced dash into trimmed segments. With + * allow_leading, a string starting with "- " yields an empty first segment (R6.3). */ +TP_PRIVATE tp_segment_vec tp_split_at_spaced_dashes(const tp_skel *s, bool allow_leading); + +/* ============================================================================================ */ +/* credits.go: R7.3 to R7.6 credit lists (before classify.go here: its types are needed there) */ + +/* credit is an artist credit plus its absolute offset (UTF-16 units), for ordering (R9.1). */ +struct tp_credit { + tp_str name; + tp_role role; + const tp_str *joiner; + tp_source source; + ptrdiff_t pos; + ptrdiff_t list; /* the credit list id (R7.6 joiner inheritance in R9.2), from ctx.list_seq */ +}; + +/* positionedYear is a year with its absolute offset (R9.6: the first in text order). */ +struct tp_positioned_year { + ptrdiff_t year; + ptrdiff_t pos; +}; + +/* listOptions are how one credit list is split. */ +struct tp_list_options { + tp_role role; + tp_source source; + const tp_str *lead; /* joiner of the first name: NULL, or the marker as written */ + bool split_with; /* R7.3: "with" splits only in the main artist-side list */ + bool feat_markers_join; /* R7.2: later feat markers are joiners in a featured list */ +}; + +/* listResult is a split credit list. */ +struct tp_list_result { + tp_credit_vec credits; + bool unknown; /* R7.5: an unknown token was dropped */ + tp_positioned_year_vec years; /* R7.5: dropped year-only names */ +}; + +/* joinerHit is a joiner found in a list: its code-point span and its text as written. */ +struct tp_joiner_hit { + ptrdiff_t start; + ptrdiff_t end; + tp_str raw; +}; + +/* rawName is a name before the R7.4 / R7.5 drops. */ +struct tp_raw_name { + tp_str name; + const tp_str *joiner; + ptrdiff_t pos; +}; + +/* (Go var andLike = {"&", "and", "+"} is a static array in credits.c.) */ + +/* wordAt is the end of the word that starts at start. */ +TP_PRIVATE ptrdiff_t tp_word_at(tp_runes text, ptrdiff_t start); +/* nextWord is the word after a joiner; a tight joiner (, ;) ends it. */ +TP_PRIVATE tp_str tp_next_word(tp_runes text, ptrdiff_t from); +/* findJoiner is R7.3b: the leftmost joiner at or after from, honouring the guards. */ +TP_PRIVATE bool tp_find_joiner(tp_runes text, ptrdiff_t from, bool split_at_comma, + const tp_list_options *opts, tp_ctx *c, tp_joiner_hit *out); +TP_PRIVATE bool tp_is_spaced_joiner(tp_str word, tp_runes text, ptrdiff_t end, bool split_at_comma, + const tp_list_options *opts, tp_ctx *c); +/* cleanName is R7.4: clean one raw name. */ +TP_PRIVATE tp_str tp_clean_name(tp_str raw); +/* unwrapList is R7.4: strip one pair of wrapping quotes from the whole list. */ +TP_PRIVATE tp_skel tp_unwrap_list(const tp_skel *list); +/* splitCredits is R7.3: split input into credits. */ +TP_PRIVATE tp_list_result tp_split_credits(const tp_skel *input, const tp_list_options *opts, + tp_ctx *c); +/* finishNames is the R7.4 empty drops and the R7.5 year/unknown drops. R7.6: the first survivor + * takes the lead joiner. Takes a new list id from c->list_seq. */ +TP_PRIVATE tp_list_result tp_finish_names(tp_raw_name_vec raw, const tp_list_options *opts, + tp_ctx *c); + +/* ============================================================================================ */ +/* classify.go: R5 */ + +/* versionDraft is a version as R5 found it, before R9 orders and assembles it. */ +struct tp_version_draft { + tp_version_type vtype; /* keywords.versionHeads values pass through as given */ + tp_str raw; + tp_credit_vec artists; + tp_strvec modifiers; + const tp_str *descriptor; + const ptrdiff_t *year; + bool unknown_artist; /* R7.5: the credit was an unknown token */ + tp_delimiter delimiter; + ptrdiff_t pos; + bool ambiguous_mix; /* R5.7.2 ambiguousMixCredit; emitted only when the version is used */ + bool prefix_form; /* R5.7.3 recognized it (R6.2 condition (ii) does not apply) */ +}; + +/* flag is an R5.4 flag. */ +typedef enum tp_flag { TP_FLAG_EXPLICIT, TP_FLAG_CLEAN } tp_flag; + +/* classKind is the kind of a classification. */ +typedef enum tp_class_kind { + TP_CLASS_UNKNOWN, + TP_CLASS_JUNK, + TP_CLASS_FEAT, + TP_CLASS_PRODUCER, + TP_CLASS_FLAG, + TP_CLASS_YEAR, + TP_CLASS_VERSIONS +} tp_class_kind; + +/* classification is the result of R5. Only the fields of its kind are set. */ +struct tp_classification { + tp_class_kind kind; + tp_junk_kind junk; /* TP_CLASS_JUNK */ + tp_list_result list; /* TP_CLASS_FEAT, TP_CLASS_PRODUCER */ + tp_flag flag; /* TP_CLASS_FLAG */ + ptrdiff_t year; /* TP_CLASS_YEAR */ + tp_version_draft_vec versions; /* TP_CLASS_VERSIONS */ +}; + +/* site is where the classified text sits: credits' source, versions' delimiter, absolute offset + * (UTF-16 units). */ +struct tp_site { + tp_source source; + tp_delimiter delimiter; + ptrdiff_t pos; +}; + +/* runItem is one entry of the R5.7.2 modifier run: a run word (info) or a year. */ +struct tp_run_item { + ptrdiff_t start; + ptrdiff_t end; + tp_run_info info; + const ptrdiff_t *year; +}; + +/* (Go vars explicitFlags and cleanFlags are static arrays in classify.c.) */ + +/* classify is R5 on inner (already trimmed and whitespace-collapsed). */ +TP_PRIVATE tp_classification tp_classify(tp_str inner, tp_site s, tp_ctx *c); +/* junkKindOf is R5.1: the junk kind if the whole word list is junk vocabulary. */ +TP_PRIVATE bool tp_junk_kind_of(tp_strvec words, tp_ctx *c, tp_str *kind); +TP_PRIVATE bool tp_feat_or_producer(tp_str inner, tp_site s, tp_ctx *c, tp_classification *out); +TP_PRIVATE bool tp_credits_after(tp_runes inner, tp_word_span_vec spans, ptrdiff_t marker_words, + tp_role role, tp_site s, tp_ctx *c, tp_list_result *out); +/* listFromText splits a plain string (nested brackets protected by a fresh scan) as a credit + * list. */ +TP_PRIVATE tp_list_result tp_list_from_text(tp_runes text, ptrdiff_t base, tp_ctx *c, + const tp_list_options *opts); +TP_PRIVATE bool tp_flag_of(tp_strvec words, tp_flag *out); +/* splitMultiParts splits at top-level " / " or "; " (outside nested brackets). */ +TP_PRIVATE tp_strvec tp_split_multi_parts(tp_runes inner); +TP_PRIVATE bool tp_multi_version(tp_str inner, tp_site s, tp_ctx *c, tp_version_draft_vec *out); +TP_PRIVATE bool tp_single_version(tp_str raw, tp_site s, tp_ctx *c, tp_version_draft_vec *out); +TP_PRIVATE tp_version_draft tp_base_version(tp_str raw, tp_str vtype, tp_site s); +TP_PRIVATE tp_list_options tp_remixer_opts(void); +/* dedupRemixers is R9.2 for remixers: deduped within their own version only. */ +TP_PRIVATE tp_credit_vec tp_dedup_remixers(tp_credit_vec credits); +TP_PRIVATE void tp_set_credits(tp_version_draft *v, tp_runes text, tp_site s, tp_ctx *c); +/* headBy is R5.7.1: Remix by Skrillex. */ +TP_PRIVATE bool tp_head_by(tp_str raw, tp_runes text, tp_word_span_vec spans, tp_strvec words, + tp_site s, tp_ctx *c, tp_version_draft *out); +/* collectRun walks left from end collecting the modifier run (R5.7.2). */ +TP_PRIVATE tp_run_item_vec tp_collect_run(tp_strvec words, ptrdiff_t end, tp_ctx *c); +/* truthyName is a JS truthiness test on an optional type name: NULL and "" do not count. */ +TP_PRIVATE bool tp_truthy_name(const tp_str *s, tp_str *out); +/* headScan is R5.7.2: Extended VIP Mix, Skrillex Remix, Taylor's Version. */ +TP_PRIVATE bool tp_head_scan(tp_str raw, tp_strvec words, tp_site s, tp_ctx *c, + tp_version_draft *out); +/* containsString reports whether list holds s. */ +TP_PRIVATE bool tp_contains_string(tp_strvec list, tp_str s); +/* nearestNonGenericHead is R5.7.2 type rule 2: index of the non-generic head in the run nearest + * the (generic) head, or -1. */ +TP_PRIVATE ptrdiff_t tp_nearest_non_generic_head(tp_run_item_vec run, tp_ctx *c); +/* isAllJunkPhrases is R5.7.2: the credit span is made entirely of junk phrases. */ +TP_PRIVATE bool tp_is_all_junk_phrases(tp_strvec words, tp_ctx *c); +/* prefixForm is R5.7.3: Live at Wembley 1986, Remastered 2015, Sped Up. */ +TP_PRIVATE bool tp_prefix_form(tp_str raw, tp_strvec words, tp_site s, tp_ctx *c, + tp_version_draft *out); +/* tailWords is words[from:], or empty when from is past the end. */ +TP_PRIVATE tp_strvec tp_tail_words(tp_strvec words, ptrdiff_t from); + +/* ============================================================================================ */ +/* separator.go: R6 */ + +/* peeled is a dash suffix taken off by R6.2 or R8.2; cls is junk, flag, year or versions. */ +struct tp_peeled { + tp_classification cls; + tp_str raw; + ptrdiff_t pos; +}; + +/* separatorResult is the outcome of R6. */ +struct tp_separator_result { + const tp_skel *artist; + tp_skel title; + bool split; /* a separator split the string (R6.3 to R6.7): R8.2 peels without conditions */ + tp_peeled_vec peeled; +}; + +/* separatorInput is what R6 reads. */ +struct tp_separator_input { + tp_skel skel; + tp_mode mode; + const tp_skel *uploader; /* R6.8 fallback artist, or NULL */ + bool list_context; /* R13.4.2 (tracklist module only): enables the R6.10 tight dash */ +}; + +/* splitParts is an artist side (NULL when empty) and a title side. */ +struct tp_split_parts { + const tp_skel *artist; + tp_skel title; +}; + +/* classifySegment is the R6.2 classification of a bare dash segment: placeholders make it + * Unknown. */ +TP_PRIVATE tp_classification tp_classify_segment(tp_skel seg, tp_ctx *c); +/* isPeelable reports whether R6.2 / R8.2 can peel a classification. */ +TP_PRIVATE bool tp_is_peelable(tp_classification cls); +/* peelSuffixes is R6.2 / R8.2: peel classifiable suffixes off the right end. relaxed drops + * conditions (i) to (iv). Returns the remaining segments; *peeled gets the suffixes, left to + * right (always written). */ +TP_PRIVATE tp_segment_vec tp_peel_suffixes(tp_segment_vec segments, bool relaxed, tp_ctx *c, + tp_peeled_vec *peeled); +/* nonEmpty is the trimmed skeleton, or NULL when it is empty. */ +TP_PRIVATE const tp_skel *tp_non_empty(tp_skel s); +/* splitAt cuts s around [cut_start, cut_end). */ +TP_PRIVATE tp_split_parts tp_split_at(tp_skel s, ptrdiff_t cut_start, ptrdiff_t cut_end); +/* resultOf is a separator result for split parts. */ +TP_PRIVATE tp_separator_result tp_result_of(tp_split_parts parts, tp_peeled_vec p); +/* firstDashSplit is R6.3: the first segment is the artist side, the rest (up to the last kept + * one) the title. */ +TP_PRIVATE bool tp_first_dash_split(tp_skel sk, tp_segment_vec segments, tp_split_parts *out); +/* findSeparator is R6. */ +TP_PRIVATE tp_separator_result tp_find_separator(tp_separator_input in, tp_ctx *c); +/* tracklistSeparator is R6.10, tracklist mode: the first spaced dash always separates; without + * one: R6.4, then the first "_-_", then (list context only) the last tight letter-Uppercase + * dash; both of these warn unspacedDashSplit. */ +TP_PRIVATE tp_separator_result tp_tracklist_separator(tp_skel sk, tp_segment_vec segments, + bool list_context, tp_ctx *c); +/* underscoreDash is the index of the first "_-_". */ +TP_PRIVATE bool tp_underscore_dash(tp_runes t, ptrdiff_t *out); +/* tightUpperDash is R6.10: the last "-" with a letter (R0.6) left and Lu right. */ +TP_PRIVATE bool tp_tight_upper_dash(tp_runes t, ptrdiff_t *out); +/* splitWithoutSpacedDash is R6.4 to R6.7. */ +TP_PRIVATE bool tp_split_without_spaced_dash(tp_skel s, tp_mode mode, tp_ctx *c, + tp_split_parts *out); +/* asymmetricDash is R6.4: the first "-" with a space on exactly one side. */ +TP_PRIVATE bool tp_asymmetric_dash(tp_runes t, ptrdiff_t *out); +/* quotedTitle is R6.5: Artist "Title" (extra). */ +TP_PRIVATE bool tp_quoted_title(tp_skel s, tp_split_parts *out); +/* bySplit is R6.6: index of the space before the last usable " by " (right side non-empty and + * not a single stopword). */ +TP_PRIVATE bool tp_by_split(tp_skel s, tp_ctx *c, ptrdiff_t *out); +/* unspacedDash is R6.7: the chosen unspaced dash index ("Jay-Z-Numb"). */ +TP_PRIVATE bool tp_unspaced_dash(tp_skel s, tp_ctx *c, ptrdiff_t *out); +/* renderPrefix is the rendered text of s[:end]. */ +TP_PRIVATE tp_str tp_render_prefix(const tp_skel *s, ptrdiff_t end); + +/* ============================================================================================ */ +/* artists.go: R7.1, R7.2 (the list splitting is credits.go) */ + +/* artistSideResult is what R7 found on the artist side. */ +struct tp_artist_side_result { + tp_credit_vec credits; + tp_positioned_junk_vec junk; + tp_positioned_year_vec years; + bool unknown_artist; + bool explicit_; /* R7.1: artist-side Flag groups */ + bool clean; +}; + +/* featMarker is an unbracketed feat marker: its code-point span and its text as written. */ +struct tp_feat_marker { + ptrdiff_t start; + ptrdiff_t end; + tp_str marker; +}; + +/* findFeatMarker is R7.2: the leftmost unbracketed feat marker at or after from, with a space + * (or placeholder) on its left and a space on its right. */ +TP_PRIVATE bool tp_find_feat_marker(const tp_skel *s, tp_ctx *c, ptrdiff_t from, + tp_feat_marker *out); +/* parseArtistSide is R7.1 to R7.5 over an artist-side skeleton. */ +TP_PRIVATE tp_artist_side_result tp_parse_artist_side(const tp_skel *side, tp_ctx *c); + +/* ============================================================================================ */ +/* title.go: R8 */ + +/* extracted is everything the title side (and R6.2 peeling) can extract. */ +struct tp_extracted { + tp_credit_vec credits; + tp_version_draft_vec versions; + tp_positioned_junk_vec junk; + tp_positioned_year_vec years; + bool explicit_; + bool clean; + bool unknown_artist; +}; + +/* setFlag records an Explicit or Clean flag. */ +TP_PRIVATE void tp_extracted_set_flag(tp_extracted *out, tp_flag f); +/* addPeeled records R6.2 / R8.2 peeled dash suffixes. */ +TP_PRIVATE void tp_add_peeled(tp_extracted *out, tp_peeled_vec list); + +/* titleSideResult is the title and whether it is an unknown placeholder (R8.6). */ +struct tp_title_side_result { + tp_str title; + bool unknown_title; +}; + +/* parseTitleSide is R8. relaxed: an artist side was split off (R8.2 peels without conditions). */ +TP_PRIVATE tp_title_side_result tp_parse_title_side(tp_skel input, bool relaxed, bool youtube, + tp_extracted *out, tp_ctx *c); +/* extractGroups is R8.1: classify every group. Returns the offsets of the groups to remove, + * ascending (Go map[int]struct{}; see tp_remove_groups). */ +TP_PRIVATE tp_idxvec tp_extract_groups(tp_skel sk, tp_extracted *out, tp_ctx *c); + +/* markerHit is an R8.3 marker in the title. */ +struct tp_marker_hit { + ptrdiff_t start; + ptrdiff_t end; + tp_str marker; + tp_role role; +}; + +/* titleMarkers are the R8.3 markers, left to right, each with a space on both sides. */ +TP_PRIVATE tp_marker_hit_vec tp_title_markers(tp_skel sk, tp_ctx *c); +/* extractUnbracketedCredits is R8.3: "Title feat. X" and "Title prod. by Y" become credits, + * removed from the title. The Go closure nextGroupAt becomes a static helper. */ +TP_PRIVATE tp_skel tp_extract_unbracketed_credits(tp_skel input, tp_extracted *out, tp_ctx *c); +/* stripTrailingJunk is R8.4: strip trailing unbracketed junk phrases (optionally after a lone + * "-" or "|"); linear (word spans computed once, walked backwards). */ +TP_PRIVATE tp_skel tp_strip_trailing_junk(tp_skel input, tp_extracted *out, tp_ctx *c); +/* isLoneEdge reports whether a word is a lone "-" or "|". */ +TP_PRIVATE bool tp_is_lone_edge(tp_str word); +/* stripLoneEdges removes lone "-" and "|" words at both ends of a space-separated string. */ +TP_PRIVATE tp_str tp_strip_lone_edges(tp_str s); +/* cleanupTitle is R8.5. */ +TP_PRIVATE tp_str tp_cleanup_title(tp_str raw); + +/* ============================================================================================ */ +/* assemble.go: R9 */ + +/* precedence is the R9.2 role order: a later duplicate with a higher one upgrades the kept + * entry. */ +TP_PRIVATE ptrdiff_t tp_precedence(tp_role role); +/* toArtist is the public form of a credit. */ +TP_PRIVATE tp_artist tp_to_artist(tp_credit c); + +/* dedupEntry is one credit during R9.2. */ +struct tp_dedup_entry { + tp_artist a; + ptrdiff_t list; + bool alive; +}; + +/* creditLists holds the remaining names of each credit list (a min-heap of entry indexes per + * list, lazy deletion), so dedup stays near-linear. entries shares its storage with the caller's + * vector (as the Go slice does): dedupArtists mutates entries and the lists see it. Go map + * heaps[list] is a vector indexed by list id (ids are 0..ctx.list_seq-1), grown on demand. */ +struct tp_credit_lists { + tp_dedup_entry_vec entries; + tp_idxvec_vec heaps; +}; + +/* newCreditLists indexes the lists of entries. */ +TP_PRIVATE tp_credit_lists *tp_new_credit_lists(tp_dedup_entry_vec entries); +/* member reports whether entry x is a remaining name of list. */ +TP_PRIVATE bool tp_credit_lists_member(const tp_credit_lists *l, ptrdiff_t list, ptrdiff_t x); +/* insert puts entry e on the heap of list. */ +TP_PRIVATE void tp_credit_lists_insert(tp_credit_lists *l, ptrdiff_t list, ptrdiff_t e); +/* pop removes the smallest index of list's heap. */ +TP_PRIVATE void tp_credit_lists_pop(tp_credit_lists *l, ptrdiff_t list); +/* first is the smallest remaining index of list after dropping stale heap entries, or -1. */ +TP_PRIVATE ptrdiff_t tp_credit_lists_first(tp_credit_lists *l, ptrdiff_t list); +/* heir is the entry after e in list when e is the list's first remaining name, else -1. Only + * when e is about to leave list: it takes e off the heap. */ +TP_PRIVATE ptrdiff_t tp_credit_lists_heir(tp_credit_lists *l, ptrdiff_t list, ptrdiff_t e); +/* passJoiner is R7.6: entry e leaves its list; if it was the first remaining name, the next one + * takes joiner. */ +TP_PRIVATE void tp_credit_lists_pass_joiner(tp_credit_lists *l, ptrdiff_t e, const tp_str *joiner); +/* dedupKeyOf is the R9.2 key: producers are a separate class, deduped among themselves. */ +TP_PRIVATE tp_str tp_dedup_key_of(const tp_artist *a); +/* dedupArtists is R9.2: keep the first occurrence; R7.6 joiner inheritance; role upgrades. */ +TP_PRIVATE tp_artist_vec tp_dedup_artists(tp_credit_vec credits); +/* toVersion is the public form of a version draft. */ +TP_PRIVATE tp_version tp_to_version(tp_version_draft v); +/* renderVersion is R9.4: a version rendered with its delimiter. */ +TP_PRIVATE tp_str tp_render_version(tp_str raw, tp_delimiter delimiter); +/* fullTitleOf is R9.4: the title followed by its versions as written, empty pieces skipped. */ +TP_PRIVATE tp_str tp_full_title_of(tp_str title, tp_version_vec versions); + +/* ============================================================================================ */ +/* parser.go: the pipeline R1 -> R2 -> R4 -> R3/R6 -> R7 -> R8 -> R9, R10, and the probe */ + +/* uploaderBase is the offset used for uploader text, so it sorts before everything else. */ +#define TP_UPLOADER_BASE ((ptrdiff_t)-1000000000) + +/* staged is the R1, R2 and R4 stage of run, kept so the tracklist probe's work is not redone. */ +struct tp_staged { + const tp_engine *e; + tp_ctx *c; + tp_prelude_result pre; + tp_track track; + const tp_skel *working; /* after R4; NULL when empty after R1 (R9.5: track is final) */ +}; + +/* lineProbe is facts about a line's prefix and separator search (R13.4.2, R13.5). */ +struct tp_line_probe { + bool position; /* R4.2 took a position */ + bool spaced_dash; /* the skeleton R6 searches (after R2 and R4) has a spaced dash (R6.1) */ + bool empty; /* empty after R1 */ + tp_staged staged; +}; + +/* skelOf scans a piece and trims it, warning on unbalanced brackets (R3.3). */ +TP_PRIVATE tp_skel tp_skel_of(tp_piece p, tp_ctx *c); +/* uploaderSkel is R6.8: the uploader minus a trailing " - Topic" and "VEVO", or NULL. */ +TP_PRIVATE const tp_skel *tp_uploader_skel(tp_str uploader); +/* emptyTrack is the R9.5 result for an input empty after R1, and the start of every result. */ +TP_PRIVATE tp_track tp_empty_track(tp_str input, tp_mode mode); +/* stage runs R1, R2 and R4. */ +TP_PRIVATE tp_staged tp_engine_stage(const tp_engine *e, tp_str input); +/* run is R1 to R9 on one (already sanitized) input; list_context is the R13.4.2 flag (R6.10, + * tracklist mode only). */ +TP_PRIVATE tp_track tp_engine_run(const tp_engine *e, tp_str input, bool list_context); +/* runArtists is R10 on one (already sanitized) input. */ +TP_PRIVATE tp_artist_vec tp_engine_run_artists(const tp_engine *e, tp_str input); +/* probe is R1, R2 and R4 only, as run does them. tp_line_probe_finish completes the parse. */ +TP_PRIVATE tp_line_probe tp_engine_probe(const tp_engine *e, tp_str input); +/* finish is the parse of the probed input (R6 to R9). Call it once per probe: the probe's ctx + * (warnings) is consumed. */ +TP_PRIVATE tp_track tp_line_probe_finish(tp_line_probe *p, bool list_context); +/* byPos sorts items by offset, stably, in place (Go generic: one per element type used). */ +TP_PRIVATE tp_version_draft_vec tp_by_pos_versions(tp_version_draft_vec items); +TP_PRIVATE tp_credit_vec tp_by_pos_credits(tp_credit_vec items); +TP_PRIVATE tp_positioned_year_vec tp_by_pos_years(tp_positioned_year_vec items); +TP_PRIVATE tp_positioned_junk_vec tp_by_pos_junk(tp_positioned_junk_vec items); +/* finish is R6 to R9 on a staged input. */ +TP_PRIVATE tp_track tp_finish(tp_staged st, bool list_context); + +/* ============================================================================================ */ +/* format.go: R11 and allArtists */ + +/* isFeatMarker reports whether raw, as one word, is a feat marker. */ +TP_PRIVATE bool tp_is_feat_marker(tp_str raw, const tp_tables *t); +/* canonicalJoiner is R11.5: map a raw joiner to its canonical form (joiners.json); feat markers + * become featCanonical. A featured list's lead marker is always a feat marker. */ +TP_PRIVATE tp_str tp_canonical_joiner(tp_str raw, const tp_tables *t, bool feat_lead); +/* joinSep is R11.1: " " + joiner + " "; tight joiners as the raw character + " "; a missing + * joiner as &. */ +TP_PRIVATE tp_str tp_join_sep(const tp_str *joiner, const tp_resolved_format *o, + const tp_tables *t); +/* joinNames is the names of one credit list joined by their own joiners. */ +TP_PRIVATE tp_str tp_join_names(tp_artist_ptr_vec list, const tp_resolved_format *o, + const tp_tables *t); +/* leadMarker is the marker in front of a featured list. */ +TP_PRIVATE tp_str tp_lead_marker(const tp_artist *first, const tp_resolved_format *o, + const tp_tables *t, tp_str fallback); +/* withRole is the artists of track with role, in order (pointers into artists). */ +TP_PRIVATE tp_artist_ptr_vec tp_with_role(tp_artist_vec artists, tp_role role); +/* formatTrack is R11: track rendered back to a string with the resolved options (default + * tables). */ +TP_PRIVATE tp_str tp_format_track(const tp_track *track, tp_resolved_format o); +/* allArtists is every credited name: the artists plus every version's remixers, deduplicated by + * the R0.4 key, first kept. The Go closure add becomes a static helper. */ +TP_PRIVATE tp_artist_vec tp_all_artists(const tp_track *track); + +/* ============================================================================================ */ +/* tl_options.go: R13.10 number views */ + +/* jsInteger is a JS number that Number.isInteger accepts. */ +TP_PRIVATE bool tp_js_integer(tp_json v, bool present, double *out); +/* jsFinite is a JS number that Number.isFinite accepts. */ +TP_PRIVATE bool tp_js_finite(tp_json v, bool present, double *out); + +/* ============================================================================================ */ +/* tl_split.go: R13.1 */ + +/* tlLine is one line of a tracklist text: the line without its terminator, and the terminator. */ +struct tp_tl_line { + tp_str raw; + tp_eol eol; +}; + +/* splitLines is R13.1.1: split at LF, CRLF and CR only. A trailing empty segment after the final + * terminator is not a line; "" has no lines. R13.1.2: raw + eol joined is the text. */ +TP_PRIVATE tp_tl_line_vec tp_split_lines(tp_str text); +/* hasLineBreak reports a line break inside a single-line value (R13.9.5, R13.9.6). */ +TP_PRIVATE bool tp_has_line_break(tp_str s); + +/* ============================================================================================ */ +/* tl_times.go: R13.2 and the R13.9.2 time writer */ + +/* maxSafeInteger is JS Number.MAX_SAFE_INTEGER. */ +#define TP_MAX_SAFE_INTEGER 9007199254740991.0 + +/* timeStyle is the written shape of a time, kept by edits (R13.9.2). */ +struct tp_time_style { + bool hours; + ptrdiff_t hour_width; /* digits written for the hours (minimum width), 0 without hours */ + ptrdiff_t minute_width; /* digits written for the minutes (minimum width) */ + bool long_minutes; /* a two-part time already at 60 minutes or more */ + tp_rune frac_sep; /* '.' or ',' with a fraction, else TP_NORUNE */ + ptrdiff_t frac_digits; +}; + +/* timeScan is what R13.2 finds at the start of a line. */ +struct tp_time_scan { + tp_parts parts; + const tp_tracklist_time *time; + const tp_time_style *style; + bool invalid; /* R13.2.4: a digits:digits shape after the lead that fails R13.2.2 */ + tp_str text; /* R13.12: rest without its paired emphasis markers */ +}; + +/* timeShape is a digits(:digits)+ run: the digit runs between the colons (2 or more) and the + * index past it. */ +struct tp_time_shape { + tp_runes_vec parts; + ptrdiff_t end; +}; + +/* formattedTime is a time written by formatTime. */ +struct tp_formatted_time { + tp_str raw; + bool upgraded; +}; + +/* isGapSeparator is an R13.2.3 separator after the time. */ +TP_PRIVATE bool tp_is_gap_separator(tp_rune r); +/* skipWhitespace is the index past the R0.2 whitespace at from. */ +TP_PRIVATE ptrdiff_t tp_skip_whitespace(tp_runes s, ptrdiff_t from); +/* isBullet is an R13.2.1 bullet. */ +TP_PRIVATE bool tp_is_bullet(tp_rune r); +/* untimed is R13.1.3 / R13.2.1: a line without a time (lead: optional bullet). */ +TP_PRIVATE tp_time_scan tp_untimed(tp_runes raw, bool invalid); +/* closingRun is R13.2.3: the index past a closing run for an opening run of open, or from. */ +TP_PRIVATE ptrdiff_t tp_closing_run(tp_runes raw, ptrdiff_t from, tp_rune open); +/* secondsOf is whole.frac read as one decimal literal (JS Number(), correctly rounded: + * tp_parse_number). */ +TP_PRIVATE double tp_seconds_of(ptrdiff_t whole, tp_str frac); +/* shapeAt is R13.2.4: the maximal digits(:digits)+ run at from. */ +TP_PRIVATE bool tp_shape_at(tp_runes s, ptrdiff_t from, tp_time_shape *out); +/* shapeSeconds is the R13.2.2 validity test: the whole seconds of A:B or A:B:C. */ +TP_PRIVATE bool tp_shape_seconds(tp_runes_vec parts, ptrdiff_t *out); +/* startsWithAt reports whether s has word at from. */ +TP_PRIVATE bool tp_starts_with_at(tp_runes s, ptrdiff_t from, tp_str word); +/* scanTime is R13.2: the lead, time and gap at the start of a line; the rest is everything + * after. The Go closure followsTime becomes a static helper. */ +TP_PRIVATE tp_time_scan tp_scan_time(tp_str line); +/* pad writes n with at least width digits. */ +TP_PRIVATE tp_str tp_pad(int64_t n, ptrdiff_t width); +/* formatTime is R13.9.2: seconds (finite, not negative) written in style, rounded half up to + * the fraction precision (tp_round_half_up). false when it cannot be a valid R13.2.2 time. */ +TP_PRIVATE bool tp_format_time(double seconds, const tp_time_style *style, bool one_digit_hours, + tp_formatted_time *out); + +/* ============================================================================================ */ +/* tl_emphasis.go: R13.12 */ + +/* runLength is the length of the maximal run of '*' or '_' at from (0 when none). */ +TP_PRIVATE ptrdiff_t tp_run_length(tp_runes s, ptrdiff_t from); +/* emphasisRun is R13.2.1 / R13.2.3: the length of an emphasis run at from (1 or 2), else 0. */ +TP_PRIVATE ptrdiff_t tp_emphasis_run(tp_runes s, ptrdiff_t from); +/* isEmphasisOuter is the R13.12.2 outer side. */ +TP_PRIVATE bool tp_is_emphasis_outer(tp_rune r); +/* isEmphasisInner is the R13.12.2 inner side: not R0.2 whitespace. */ +TP_PRIVATE bool tp_is_emphasis_inner(tp_rune r); +/* emphasisStack is the stack of a run ('*', '**', '_', '__'); -1 for others. */ +TP_PRIVATE ptrdiff_t tp_emphasis_stack(tp_rune ch, ptrdiff_t n); +/* markRange sets marked[from:from+n], clamped (writes through the shared storage). */ +TP_PRIVATE void tp_mark_range(tp_bool_vec marked, ptrdiff_t from, ptrdiff_t n); +/* withoutMarkers is R13.12: raw[from:] without its emphasis markers; open is a lead run the gap + * left open (R13.12.4), or TP_NORUNE. */ +TP_PRIVATE tp_str tp_without_markers(tp_runes raw, ptrdiff_t from, tp_rune open); + +/* ============================================================================================ */ +/* tl_kinds.go: R13.3, R13.13 */ + +/* Go sync.OnceValue vars tlHeaderWords, tlLayeredWords, tlMarkerTable (tp_once_get, with the + * current-arena fallback). */ +TP_PRIVATE const tp_word_set *tp_tl_header_words(void); +TP_PRIVATE const tp_word_set *tp_tl_layered_words(void); +TP_PRIVATE const tp_phrase_table *tp_tl_marker_table(void); +/* buildMarkerTable is data/marker-words.json plus extra, split into words as the track part is + * (R13.3). */ +TP_PRIVATE const tp_phrase_table *tp_build_marker_table(tp_strvec extra); +/* markerTableFor is the marker table with options.markerWords; the default built once. */ +TP_PRIVATE const tp_phrase_table *tp_marker_table_for(tp_strvec extra); +/* isMarkerBreak splits marker words: '/', '-' and R0.2 whitespace. */ +TP_PRIVATE bool tp_is_marker_break(tp_rune r); +/* isMarkerBracket is one of ()[]{}. */ +TP_PRIVATE bool tp_is_marker_bracket(tp_rune r); +/* markerWords is R13.3: split on R0.2 whitespace, '/' and '-', strip leading and trailing + * ()[]{} from each piece, drop empty ones. The Go closure flush becomes a static helper. */ +TP_PRIVATE tp_strvec tp_marker_words(tp_str text); +/* layeredPrefix is R13.13: the length (code points) of a layered prefix, or 0. */ +TP_PRIVATE ptrdiff_t tp_layered_prefix(tp_runes text); +/* isBlank is R13.3.1: the line is only R0.2 whitespace. */ +TP_PRIVATE bool tp_is_blank(tp_str raw); +/* trimWS trims R0.2 whitespace from both ends. */ +TP_PRIVATE tp_runes tp_trim_ws(tp_str s); +/* isLink is R13.3.3: starts with http://, https:// or www. (ASCII case-insensitive). */ +TP_PRIVATE bool tp_is_link(tp_str rest); +/* isHeader is R13.3.3: ends with ':', or is a header word plus at most one more word. */ +TP_PRIVATE bool tp_is_header(tp_str rest); +/* hasMarkerWord is R13.3: any marker word (or multi-word entry) among the track part's words. */ +TP_PRIVATE bool tp_has_marker_word(tp_str track_part, const tp_phrase_table *markers); +/* hasSeparator is R13.3: not empty after R1, no noSeparator warning, and a non-empty artist side + * (a primary artist or flags.unknown_artist). */ +TP_PRIVATE bool tp_has_separator(const tp_track *t, bool empty); + +/* ============================================================================================ */ +/* tl_positions.go: R13.5 */ + +/* bareCandidate is a leading number that may be a position. */ +struct tp_bare_candidate { + tp_str raw; + ptrdiff_t number; + tp_str stripped; /* the track part without the digits and the following space */ +}; + +/* findBareCandidate is R13.5: 1 to 3 ASCII digits and a U+0020 at the start, where R4.2 took no + * position, with a non-blank remainder. NULL when none. */ +TP_PRIVATE const tp_bare_candidate *tp_find_bare_candidate(tp_str rest, bool position_taken); +/* confirmPositions is R13.5: candidate i is a position when the nearest preceding or following + * candidate line also has a bare number N - 1 or N + 1. bare: -1 for none. Linear. The Go + * closures isCandidate and adjacent become static helpers. */ +TP_PRIVATE tp_bool_vec tp_confirm_positions(tp_idxvec bare, tp_bool_vec candidate_line); + +/* ============================================================================================ */ +/* tl_warnings.go: R13.7 */ + +/* warningInput is what tracklistWarnings reads, one slot per entry. */ +struct tp_warning_input { + tp_entry_vec entries; + tp_idxvec positions; /* R4.2 / R13.5 position number of each entry's track, or -1 */ + tp_bool_vec invalid; /* R13.2.4 */ + tp_bool_vec unparsed; /* R13.7 line-unparsed */ + const double *audio_seconds; /* NULL when unknown */ +}; + +/* digitSlot is one digit of a time that the search may change. */ +struct tp_digit_slot { + ptrdiff_t at; /* index of the digit in the raw time */ + ptrdiff_t field; + int64_t place; + int64_t digit; +}; + +/* digitChange is one digit change: the slot and its new digit. */ +struct tp_digit_change { + tp_digit_slot slot; + int64_t digit; +}; + +/* searchOutcome is the result of one line's digit search. */ +typedef enum tp_search_outcome { TP_SEARCH_NONE, TP_SEARCH_ONE, TP_SEARCH_MANY } tp_search_outcome; + +/* timeDigits is a raw time taken apart for the search. */ +struct tp_time_digits { + tp_runes raw; + tp_str frac; + tp_intvec values; /* Go []int64 */ + const double *lo; + const double *hi; +}; + +/* timedEntry is a timed entry: its line number and time. */ +struct tp_timed_entry { + ptrdiff_t line; + const tp_tracklist_time *time; +}; + +/* valueWith is the value with changes applied, when it is a valid time inside the bounds. */ +TP_PRIVATE bool tp_time_digits_value_with(const tp_time_digits *d, tp_digit_change_vec changes, + double *out); +/* render is the raw time with changes applied. */ +TP_PRIVATE tp_str tp_time_digits_render(const tp_time_digits *d, tp_digit_change_vec changes); +/* searchTime is the R13.7 suggestion search on one raw time: change 1, then 2 digits (not + * fraction digits); keep valid times with lo < t < hi (each bound when present); only the + * smallest change count with any candidate counts. *found is written for TP_SEARCH_ONE. */ +TP_PRIVATE tp_search_outcome tp_search_time(tp_str raw_time, const double *lo, const double *hi, + tp_tracklist_time *found); +/* suggestFix is the R13.7 suggestion for the out-of-order timed entry k: its own time between + * its neighbours first; only when that finds no candidate at all, the previous timed entry's + * time between the one before it and entry k. NULL when none. */ +TP_PRIVATE const tp_suggestion *tp_suggest_fix(tp_timed_entry_vec times, ptrdiff_t k); +/* warningRank is the table order of R13.7 (a switch, not a lookup). */ +TP_PRIVATE ptrdiff_t tp_warning_rank(tp_warning_code code); +/* flagAt is list[i], false out of range. */ +TP_PRIVATE bool tp_flag_at(tp_bool_vec list, ptrdiff_t i); +/* tracklistWarnings is R13.7. The Go closure add becomes a static helper. */ +TP_PRIVATE tp_tracklist_warning_vec tp_tracklist_warnings(const tp_warning_input *in); + +/* ============================================================================================ */ +/* tl_parse.go: R13.1 to R13.8 */ + +/* tlRow is one line on its way to an entry. */ +struct tp_tl_row { + tp_tl_line line; + tp_time_scan scan; + tp_str text; /* R13.4.1: rest without emphasis markers (R13.12) and layered prefix (R13.13) */ + bool layered; /* R13.13 */ + bool blank; + bool candidate; /* R13.4.2: the line has a time or a spaced dash */ + bool dash; + bool probed; + tp_line_probe probe; + const tp_bare_candidate *bare; + const tp_track *track; + bool separated; /* R13.3: the track part has a separator */ + bool marker; /* R13.3: the track part has a marker word */ +}; + +/* parseTracklist is R13.1 to R13.8 on one (already sanitized) text. */ +TP_PRIVATE tp_tracklist tp_parse_tracklist(tp_str text, tp_resolved_tracklist o); +/* kindOf is R13.3. */ +TP_PRIVATE tp_entry_kind tp_kind_of(const tp_tl_row *r); +/* statsOf counts the entries. */ +TP_PRIVATE tp_stats tp_stats_of(tp_entry_vec entries); + +/* ============================================================================================ */ +/* tl_edits.go: R13.9 */ + +/* workLine is one line of the text being edited. */ +struct tp_work_line { + tp_str raw; + tp_eol eol; + bool changed; /* an edit wrote the line (R13.9.1) */ + tp_time_scan scan; /* tp_scan_time(raw), kept in step with raw */ +}; + +/* editCtx is the edit state. Every edit validates before it mutates, so an invalid edit + * (R13.9.6) only drops the warnings it added. */ +struct tp_edit_ctx { + tp_work_line_ptr_vec lines; + ptrdiff_t index; /* the edit being applied */ + tp_raw_edit_warning_vec warnings; + ptrdiff_t one_digit; /* times with one-digit hours (R13.9.2) */ + ptrdiff_t wide_hours; /* times with wider hours */ + ptrdiff_t eols[3]; /* lines ending with LF, CRLF, CR (R13.9.5) */ +}; + +/* retimed is a line rewritten for a new time. */ +struct tp_retimed { + ptrdiff_t index; + tp_str raw; + bool clamped; + bool upgraded; +}; + +/* touched are the lines whose neighbourhood canonical must check after an edit; all means every + * line (sort-by-time). */ +struct tp_touched { + bool all; + tp_idxvec lines; +}; + +/* timeBlock is a timed line plus the untimed lines after it. */ +struct tp_time_block { + double seconds; + ptrdiff_t from; + ptrdiff_t to; +}; + +TP_PRIVATE tp_work_line *tp_new_work_line(tp_str raw, tp_eol eol, bool changed); +/* eolSlot is the index of eol in edit_ctx.eols, -1 for none. */ +TP_PRIVATE ptrdiff_t tp_eol_slot(tp_eol eol); +/* countHours adds (by = 1) or removes (by = -1) a time from the hour-width counts (R13.9.2). */ +TP_PRIVATE void tp_edit_ctx_count_hours(tp_edit_ctx *c, const tp_time_scan *s, ptrdiff_t by); +TP_PRIVATE void tp_edit_ctx_count_eol(tp_edit_ctx *c, tp_eol eol, ptrdiff_t by); +/* countLine is a line entering (by = 1) or leaving (by = -1) the text. */ +TP_PRIVATE void tp_edit_ctx_count_line(tp_edit_ctx *c, const tp_work_line *l, ptrdiff_t by); +TP_PRIVATE void tp_edit_ctx_set_eol(tp_edit_ctx *c, tp_work_line *l, tp_eol eol); +TP_PRIVATE void tp_edit_ctx_set_raw(tp_edit_ctx *c, tp_work_line *l, tp_str raw); +TP_PRIVATE void tp_edit_ctx_warn(tp_edit_ctx *c, tp_edit_warning_code code, const double *line); +/* lineIndex is the 0-based index of an existing 1-based line number. */ +TP_PRIVATE bool tp_edit_ctx_line_index(const tp_edit_ctx *c, tp_json v, bool present, + ptrdiff_t *out); +/* oneDigitHours is R13.9.2: do the text's times with hours all use one-digit hours (and is there + * at least one)? */ +TP_PRIVATE bool tp_edit_ctx_one_digit_hours(const tp_edit_ctx *c); +/* singleLine is a string without a line break. */ +TP_PRIVATE bool tp_single_line(tp_json v, bool present, tp_str *out); +/* retime is R13.9.2 / R13.9.3: the rewritten line for a new value; false when it cannot be + * written. */ +TP_PRIVATE bool tp_edit_ctx_retime(tp_edit_ctx *c, ptrdiff_t index, double value, bool one_digit, + tp_retimed *out); +TP_PRIVATE void tp_edit_ctx_commit(tp_edit_ctx *c, tp_retimed_vec changes); +TP_PRIVATE bool tp_edit_ctx_set_time(tp_edit_ctx *c, tp_json edit, tp_touched *out); +TP_PRIVATE bool tp_edit_ctx_shift(tp_edit_ctx *c, tp_json edit, tp_touched *out); +/* sortByTime is R13.9.4: a stable sort of the blocks (tp_sort_stable). */ +TP_PRIVATE tp_touched tp_edit_ctx_sort_by_time(tp_edit_ctx *c); +TP_PRIVATE bool tp_edit_ctx_set_rest(tp_edit_ctx *c, tp_json edit, tp_touched *out); +/* commonEol is R13.9.5: the most common non-empty eol (ties: first seen in line order), "\n" if + * none. The Go closure isTop becomes a static helper. */ +TP_PRIVATE tp_eol tp_edit_ctx_common_eol(const tp_edit_ctx *c); +TP_PRIVATE bool tp_edit_ctx_insert(tp_edit_ctx *c, tp_json edit, tp_touched *out); +TP_PRIVATE bool tp_edit_ctx_remove(tp_edit_ctx *c, tp_json edit, tp_touched *out); +/* mergeAt joins a "\r" line followed by an empty "\n" line into one CRLF line. */ +TP_PRIVATE void tp_edit_ctx_merge_at(tp_edit_ctx *c, ptrdiff_t k); +/* canonical is R13.9.5: keep the work lines equal to what splitLines(join(lines)) would give, + * checking only the neighbourhood of touched lines (and the end); all checks every line. */ +TP_PRIVATE void tp_edit_ctx_canonical(tp_edit_ctx *c, tp_touched t); +/* applyOne applies one edit; false when it is invalid (R13.9.6). */ +TP_PRIVATE bool tp_edit_ctx_apply_one(tp_edit_ctx *c, tp_json edit, tp_touched *out); +/* invalidLine is R13.9.6: the edit's integer line, else its integer after, else NULL. */ +TP_PRIVATE const double *tp_invalid_line(tp_json edit); +/* applyEdits is R13.9 on one (already sanitized) text: apply edits (loose JSON objects) in + * order. Never fails: an invalid edit changes nothing and warns edit-invalid. */ +TP_PRIVATE tp_raw_edit_result tp_apply_edits(tp_str text, const tp_json *edits, size_t count); + +/* ============================================================================================ */ +/* json.go, writer half (src/json.c): JSON.stringify bytes. The reader half is wire/json_read.c */ + +/* appendJSString appends s as JSON.stringify writes a string: only ", \ and code points below + * U+0020 escaped, with \b \f \n \r \t. Invalid UTF-8 is replaced as tp_sanitize does. */ +TP_PRIVATE void tp_append_js_string(tp_buf *b, tp_str s); +/* appendJSNumber appends n as Number#toString writes it (tp_buf_number); NaN and the infinities + * as null, as JSON.stringify does. */ +TP_PRIVATE void tp_append_js_number(tp_buf *b, double n); + +/* jw is a small streaming writer for JSON objects and arrays. */ +struct tp_jw { + tp_buf b; + bool first; /* right after an opening brace or bracket */ +}; + +/* C addition: a writer ready for one value (first = true, as marshal starts it). */ +TP_PRIVATE tp_jw tp_jw_new(void); +/* C addition: the text written so far. */ +TP_PRIVATE tp_str tp_jw_done(tp_jw *w); +TP_PRIVATE void tp_jw_sep(tp_jw *w); +TP_PRIVATE void tp_jw_open(tp_jw *w, char c); +TP_PRIVATE void tp_jw_close(tp_jw *w, char c); +/* key writes an object key; the value that follows must not call sep again. */ +TP_PRIVATE void tp_jw_key(tp_jw *w, tp_str k); +TP_PRIVATE void tp_jw_str(tp_jw *w, tp_str s); +TP_PRIVATE void tp_jw_num(tp_jw *w, double n); +TP_PRIVATE void tp_jw_integer(tp_jw *w, int64_t n); /* written as the double (double)n */ +TP_PRIVATE void tp_jw_null(tp_jw *w); +TP_PRIVATE void tp_jw_boolean(tp_jw *w, bool v); +TP_PRIVATE void tp_jw_opt_str(tp_jw *w, const tp_str *s); +TP_PRIVATE void tp_jw_opt_int(tp_jw *w, const ptrdiff_t *n); +/* C addition: optInt for the int64_t edit-warning line. */ +TP_PRIVATE void tp_jw_opt_int64(tp_jw *w, const int64_t *n); +TP_PRIVATE void tp_jw_opt_num(tp_jw *w, const double *n); +TP_PRIVATE void tp_jw_strings(tp_jw *w, tp_strvec list); +TP_PRIVATE void tp_jw_ints(tp_jw *w, tp_intvec list); /* edit lines, changed */ + +/* The JSON forms: camelCase keys in the schema's order, every key present. A vector is written + * as [] whether or not it was ever allocated (Go nil and empty are the same here). */ +TP_PRIVATE void tp_artist_write(const tp_artist *a, tp_jw *w); +TP_PRIVATE void tp_write_artists(tp_jw *w, tp_artist_vec list); +TP_PRIVATE void tp_version_write(const tp_version *v, tp_jw *w); +TP_PRIVATE void tp_junk_write(const tp_junk *j, tp_jw *w); +TP_PRIVATE void tp_flags_write(const tp_flags *f, tp_jw *w); +TP_PRIVATE void tp_position_write(const tp_position *p, tp_jw *w); +TP_PRIVATE void tp_timestamp_write(const tp_timestamp *t, tp_jw *w); +TP_PRIVATE void tp_track_write(const tp_track *t, tp_jw *w); +TP_PRIVATE void tp_parts_write(const tp_parts *p, tp_jw *w); +TP_PRIVATE void tp_tracklist_time_write(const tp_tracklist_time *t, tp_jw *w); +TP_PRIVATE void tp_entry_write(const tp_entry *e, tp_jw *w); +TP_PRIVATE void tp_suggestion_write(const tp_suggestion *s, tp_jw *w); +TP_PRIVATE void tp_tracklist_warning_write(const tp_tracklist_warning *x, tp_jw *w); +TP_PRIVATE void tp_stats_write(const tp_stats *s, tp_jw *w); +TP_PRIVATE void tp_tracklist_write(const tp_tracklist *t, tp_jw *w); +/* Edit: only the fields of its operation ({"op":"set-time","line":3,"seconds":90}); lines only + * when has_lines, from only when non-NULL. */ +TP_PRIVATE void tp_edit_write(const tp_edit *e, tp_jw *w); +TP_PRIVATE void tp_edit_warning_write(const tp_edit_warning *x, tp_jw *w); +TP_PRIVATE void tp_edit_result_write(const tp_edit_result *r, tp_jw *w); +TP_PRIVATE void tp_raw_edit_result_write(const tp_raw_edit_result *r, tp_jw *w); +/* jsonValue.write. Recursive: depth is bounded by TP_JSON_MAX_DEPTH of the reader (200) or by + * the builder (tp_edit_json: 2). */ +TP_PRIVATE void tp_json_write(const tp_json *v, tp_jw *w); + +/* marshal (Go takes the writer interface; C has one per type): compact JSON text. */ +TP_PRIVATE tp_str tp_track_json(const tp_track *t); +TP_PRIVATE tp_str tp_artists_json(tp_artist_vec list); +TP_PRIVATE tp_str tp_tracklist_json(const tp_tracklist *t); +TP_PRIVATE tp_str tp_edit_result_json(const tp_edit_result *r); +TP_PRIVATE tp_str tp_raw_edit_result_json(const tp_raw_edit_result *r); +TP_PRIVATE tp_str tp_string_json(tp_str s); + +/* jsonValue.getString: the string at key, or false. (jsonValue.get is tp_json_get in rt.h.) */ +TP_PRIVATE bool tp_json_get_string(tp_json v, tp_str key, tp_str *out); +/* jsonOf(&edit): the edit's JSON value, exactly what reading tp_edit_write's text back gives, + * built directly (the library has no reader): strings tp_sanitize'd, line/after/from/lines as + * doubles, a NaN or infinite seconds as null, -0 as 0, keys in tp_edit_write's order. */ +TP_PRIVATE tp_json tp_edit_json(const tp_edit *e); + +/* ============================================================================================ */ +/* wire.go (wire/wire.c): the JSON door. tp_wire_call itself is declared in wire/wire.h, and + * artistList.write / wireString.write are static helpers of wire.c (declared here they would be + * static-but-undefined in the amalgamation, which leaves wire/ out). */ + +/* ============================================================================================ */ +/* trackparse.go: the public functions over internal types (src/trackparse.c). Each sanitizes */ +/* its string input (tp_sanitize). Prefixed tp_api_ (deviation): tp_normalize, */ +/* tp_parse_tracklist, tp_apply_edits and tp_all_artists already name the internal functions. */ + +/* Parse parses one track string with the default options. */ +TP_PRIVATE tp_track tp_api_parse(tp_str input); +/* ParseWith parses with options (R12); tables compiled per call. o NULL: defaults. */ +TP_PRIVATE tp_track tp_api_parse_with(tp_str input, const tp_parse_options *o); +/* ParseArtists splits an artist credit string into artists (R10). */ +TP_PRIVATE tp_artist_vec tp_api_parse_artists(tp_str input); +TP_PRIVATE tp_artist_vec tp_api_parse_artists_with(tp_str input, const tp_parse_options *o); +/* Format renders a parsed track back to a string (R11) with the default options. */ +TP_PRIVATE tp_str tp_api_format(const tp_track *t); +TP_PRIVATE tp_str tp_api_format_with(const tp_track *t, const tp_format_options *o); +/* Normalize is R1 on sanitized input. */ +TP_PRIVATE tp_str tp_api_normalize(tp_str input); +/* AllArtists is every artist of the track, remixers included, without duplicates. */ +TP_PRIVATE tp_artist_vec tp_api_all_artists(const tp_track *t); + +/* Parser parses with fixed options, compiled once; safe for concurrent use. A NULL parser or a + * NULL e uses the shared engine. */ +struct tp_parser { + const tp_engine *e; +}; + +/* NewParser compiles options (R12) into a parser, in the current arena. */ +TP_PRIVATE tp_parser *tp_new_parser(const tp_parse_options *o); +TP_PRIVATE const tp_engine *tp_parser_engine(const tp_parser *p); +TP_PRIVATE tp_track tp_parser_parse(const tp_parser *p, tp_str input); +TP_PRIVATE tp_artist_vec tp_parser_parse_artists(const tp_parser *p, tp_str input); +/* ParseTracklist parses a multi-line tracklist (R13). */ +TP_PRIVATE tp_tracklist tp_api_parse_tracklist(tp_str text); +TP_PRIVATE tp_tracklist tp_api_parse_tracklist_with(tp_str text, const tp_tracklist_options *o); +/* ApplyEdits applies edits in order, each to the previous result (R13.9), through each edit's + * JSON form (tp_edit_json), then types the result (tp_raw_edit_result_result). */ +TP_PRIVATE tp_edit_result tp_api_apply_edits(tp_str text, const tp_edit *edits, size_t count); +/* ApplyEditsWith: options accepted for symmetry (R13.10); edits do not depend on them. */ +TP_PRIVATE tp_edit_result tp_api_apply_edits_with(tp_str text, const tp_edit *edits, size_t count, + const tp_tracklist_options *o); + +#endif /* TP_INTERNAL_H */ diff --git a/c/src/json.c b/c/src/json.c new file mode 100644 index 0000000..cb0a3e8 --- /dev/null +++ b/c/src/json.c @@ -0,0 +1,647 @@ +/* json.c: the writer half of go/json.go. Bytes equal to JavaScript's JSON.stringify for every + * output type, plus the edit's JSON value (Go jsonOf) built directly, since the library has no + * JSON reader (wire/json_read.c is the reader half). */ +#include "internal.h" + +/* -------------------------------------------------------------------------------------------- */ +/* Writer */ + +/* appendJSString appends s as JSON.stringify writes a string: only ", \ and the code points + * below U+0020 are escaped, with the short forms \b \f \n \r \t. Bytes that are not valid UTF-8 + * are replaced as the API replaces them (tp_sanitize). After that every byte of a multi-byte + * sequence is >= 0x80, so escaping byte by byte is escaping rune by rune. */ +TP_PRIVATE void tp_append_js_string(tp_buf *b, tp_str s) { + static const char hex[] = "0123456789abcdef"; + size_t i, run = 0; + s = tp_sanitize(s); + tp_buf_byte(b, '"'); + for (i = 0; i < s.n; i++) { + unsigned char c = (unsigned char)s.p[i]; + const char *esc = NULL; + if (c >= 0x20 && c != '"' && c != '\\') continue; + if (i > run) tp_buf_bytes(b, s.p + run, i - run); + run = i + 1; + switch (c) { + case '"': + esc = "\\\""; + break; + case '\\': + esc = "\\\\"; + break; + case '\n': + esc = "\\n"; + break; + case '\r': + esc = "\\r"; + break; + case '\t': + esc = "\\t"; + break; + case '\b': + esc = "\\b"; + break; + case '\f': + esc = "\\f"; + break; + default: + break; + } + if (esc != NULL) { + tp_buf_cstr(b, esc); + } else { + char u[6]; + u[0] = '\\'; + u[1] = 'u'; + u[2] = '0'; + u[3] = '0'; + u[4] = hex[c >> 4]; + u[5] = hex[c & 0xf]; + tp_buf_bytes(b, u, sizeof u); + } + } + if (s.n > run) tp_buf_bytes(b, s.p + run, s.n - run); + tp_buf_byte(b, '"'); +} + +/* appendJSNumber appends n as Number#toString writes it (shortest round-trip digits, exponent + * form from 1e21 and below 1e-6, -0 as 0); NaN and the infinities as null, as JSON.stringify. */ +TP_PRIVATE void tp_append_js_number(tp_buf *b, double n) { + if (tp_is_nan(n) || tp_is_inf(n)) { + tp_buf_cstr(b, "null"); + return; + } + tp_buf_number(b, n); +} + +TP_PRIVATE tp_jw tp_jw_new(void) { + tp_jw w; + memset(&w, 0, sizeof w); + w.first = true; + return w; +} + +TP_PRIVATE tp_str tp_jw_done(tp_jw *w) { return tp_buf_done(&w->b); } + +TP_PRIVATE void tp_jw_sep(tp_jw *w) { + if (!w->first) tp_buf_byte(&w->b, ','); + w->first = false; +} + +TP_PRIVATE void tp_jw_open(tp_jw *w, char c) { + tp_jw_sep(w); + tp_buf_byte(&w->b, c); + w->first = true; +} + +TP_PRIVATE void tp_jw_close(tp_jw *w, char c) { + tp_buf_byte(&w->b, c); + w->first = false; +} + +/* key writes an object key; the value that follows must not call sep again. */ +TP_PRIVATE void tp_jw_key(tp_jw *w, tp_str k) { + tp_jw_sep(w); + tp_append_js_string(&w->b, k); + tp_buf_byte(&w->b, ':'); + w->first = true; +} + +TP_PRIVATE void tp_jw_str(tp_jw *w, tp_str s) { + tp_jw_sep(w); + tp_append_js_string(&w->b, s); +} + +TP_PRIVATE void tp_jw_num(tp_jw *w, double n) { + tp_jw_sep(w); + tp_append_js_number(&w->b, n); +} + +TP_PRIVATE void tp_jw_integer(tp_jw *w, int64_t n) { + tp_jw_sep(w); + tp_append_js_number(&w->b, (double)n); +} + +TP_PRIVATE void tp_jw_null(tp_jw *w) { + tp_jw_sep(w); + tp_buf_cstr(&w->b, "null"); +} + +TP_PRIVATE void tp_jw_boolean(tp_jw *w, bool v) { + tp_jw_sep(w); + tp_buf_cstr(&w->b, v ? "true" : "false"); +} + +TP_PRIVATE void tp_jw_opt_str(tp_jw *w, const tp_str *s) { + if (s == NULL) { + tp_jw_null(w); + } else { + tp_jw_str(w, *s); + } +} + +TP_PRIVATE void tp_jw_opt_int(tp_jw *w, const ptrdiff_t *n) { + if (n == NULL) { + tp_jw_null(w); + } else { + tp_jw_integer(w, (int64_t)*n); + } +} + +TP_PRIVATE void tp_jw_opt_int64(tp_jw *w, const int64_t *n) { + if (n == NULL) { + tp_jw_null(w); + } else { + tp_jw_integer(w, *n); + } +} + +TP_PRIVATE void tp_jw_opt_num(tp_jw *w, const double *n) { + if (n == NULL) { + tp_jw_null(w); + } else { + tp_jw_num(w, *n); + } +} + +TP_PRIVATE void tp_jw_strings(tp_jw *w, tp_strvec list) { + size_t i; + tp_jw_open(w, '['); + for (i = 0; i < list.n; i++) tp_jw_str(w, list.p[i]); + tp_jw_close(w, ']'); +} + +TP_PRIVATE void tp_jw_ints(tp_jw *w, tp_intvec list) { + size_t i; + tp_jw_open(w, '['); + for (i = 0; i < list.n; i++) tp_jw_integer(w, list.p[i]); + tp_jw_close(w, ']'); +} + +/* -------------------------------------------------------------------------------------------- */ +/* The result types. Keys in the schema's order, every key present, empty vectors as []. */ + +#define KEY(w, k) tp_jw_key((w), TP_S(k)) + +TP_PRIVATE void tp_artist_write(const tp_artist *a, tp_jw *w) { + tp_jw_open(w, '{'); + KEY(w, "name"); + tp_jw_str(w, a->name); + KEY(w, "role"); + tp_jw_str(w, a->role); + KEY(w, "joiner"); + tp_jw_opt_str(w, a->joiner); + KEY(w, "source"); + tp_jw_str(w, a->source); + tp_jw_close(w, '}'); +} + +TP_PRIVATE void tp_write_artists(tp_jw *w, tp_artist_vec list) { + size_t i; + tp_jw_open(w, '['); + for (i = 0; i < list.n; i++) tp_artist_write(&list.p[i], w); + tp_jw_close(w, ']'); +} + +TP_PRIVATE void tp_version_write(const tp_version *v, tp_jw *w) { + tp_jw_open(w, '{'); + KEY(w, "type"); + tp_jw_str(w, v->type); + KEY(w, "raw"); + tp_jw_str(w, v->raw); + KEY(w, "artists"); + tp_write_artists(w, v->artists); + KEY(w, "modifiers"); + tp_jw_strings(w, v->modifiers); + KEY(w, "descriptor"); + tp_jw_opt_str(w, v->descriptor); + KEY(w, "year"); + tp_jw_opt_int(w, v->year); + KEY(w, "unknownArtist"); + tp_jw_boolean(w, v->unknown_artist); + KEY(w, "delimiter"); + tp_jw_str(w, v->delimiter); + tp_jw_close(w, '}'); +} + +TP_PRIVATE void tp_junk_write(const tp_junk *j, tp_jw *w) { + tp_jw_open(w, '{'); + KEY(w, "raw"); + tp_jw_str(w, j->raw); + KEY(w, "kind"); + tp_jw_str(w, j->kind); + tp_jw_close(w, '}'); +} + +TP_PRIVATE void tp_flags_write(const tp_flags *f, tp_jw *w) { + tp_jw_open(w, '{'); + KEY(w, "explicit"); + tp_jw_boolean(w, f->explicit_); + KEY(w, "clean"); + tp_jw_boolean(w, f->clean); + KEY(w, "unknownArtist"); + tp_jw_boolean(w, f->unknown_artist); + KEY(w, "unknownTitle"); + tp_jw_boolean(w, f->unknown_title); + tp_jw_close(w, '}'); +} + +TP_PRIVATE void tp_position_write(const tp_position *p, tp_jw *w) { + tp_jw_open(w, '{'); + KEY(w, "raw"); + tp_jw_str(w, p->raw); + KEY(w, "number"); + tp_jw_integer(w, (int64_t)p->number); + tp_jw_close(w, '}'); +} + +TP_PRIVATE void tp_timestamp_write(const tp_timestamp *t, tp_jw *w) { + tp_jw_open(w, '{'); + KEY(w, "raw"); + tp_jw_str(w, t->raw); + KEY(w, "seconds"); + tp_jw_integer(w, (int64_t)t->seconds); + tp_jw_close(w, '}'); +} + +TP_PRIVATE void tp_track_write(const tp_track *t, tp_jw *w) { + size_t i; + tp_jw_open(w, '{'); + KEY(w, "input"); + tp_jw_str(w, t->input); + KEY(w, "mode"); + tp_jw_str(w, t->mode); + KEY(w, "position"); + if (t->position == NULL) { + tp_jw_null(w); + } else { + tp_position_write(t->position, w); + } + KEY(w, "timestamp"); + if (t->timestamp == NULL) { + tp_jw_null(w); + } else { + tp_timestamp_write(t->timestamp, w); + } + KEY(w, "artists"); + tp_write_artists(w, t->artists); + KEY(w, "title"); + tp_jw_str(w, t->title); + KEY(w, "fullTitle"); + tp_jw_str(w, t->full_title); + KEY(w, "versions"); + tp_jw_open(w, '['); + for (i = 0; i < t->versions.n; i++) tp_version_write(&t->versions.p[i], w); + tp_jw_close(w, ']'); + KEY(w, "year"); + tp_jw_opt_int(w, t->year); + KEY(w, "flags"); + tp_flags_write(&t->flags, w); + KEY(w, "junk"); + tp_jw_open(w, '['); + for (i = 0; i < t->junk.n; i++) tp_junk_write(&t->junk.p[i], w); + tp_jw_close(w, ']'); + KEY(w, "warnings"); + tp_jw_strings(w, t->warnings); + tp_jw_close(w, '}'); +} + +TP_PRIVATE void tp_parts_write(const tp_parts *p, tp_jw *w) { + tp_jw_open(w, '{'); + KEY(w, "lead"); + tp_jw_str(w, p->lead); + KEY(w, "time"); + tp_jw_str(w, p->time); + KEY(w, "gap"); + tp_jw_str(w, p->gap); + KEY(w, "rest"); + tp_jw_str(w, p->rest); + tp_jw_close(w, '}'); +} + +TP_PRIVATE void tp_tracklist_time_write(const tp_tracklist_time *t, tp_jw *w) { + tp_jw_open(w, '{'); + KEY(w, "raw"); + tp_jw_str(w, t->raw); + KEY(w, "seconds"); + tp_jw_num(w, t->seconds); + tp_jw_close(w, '}'); +} + +TP_PRIVATE void tp_entry_write(const tp_entry *e, tp_jw *w) { + tp_jw_open(w, '{'); + KEY(w, "line"); + tp_jw_integer(w, (int64_t)e->line); + KEY(w, "kind"); + tp_jw_str(w, e->kind); + KEY(w, "eol"); + tp_jw_str(w, e->eol); + KEY(w, "raw"); + tp_jw_str(w, e->raw); + KEY(w, "parts"); + tp_parts_write(&e->parts, w); + KEY(w, "time"); + if (e->time == NULL) { + tp_jw_null(w); + } else { + tp_tracklist_time_write(e->time, w); + } + KEY(w, "track"); + if (e->track == NULL) { + tp_jw_null(w); + } else { + tp_track_write(e->track, w); + } + KEY(w, "layered"); + tp_jw_boolean(w, e->layered); + tp_jw_close(w, '}'); +} + +TP_PRIVATE void tp_suggestion_write(const tp_suggestion *s, tp_jw *w) { + tp_jw_open(w, '{'); + KEY(w, "line"); + tp_jw_integer(w, (int64_t)s->line); + KEY(w, "raw"); + tp_jw_str(w, s->raw); + KEY(w, "seconds"); + tp_jw_num(w, s->seconds); + tp_jw_close(w, '}'); +} + +TP_PRIVATE void tp_tracklist_warning_write(const tp_tracklist_warning *x, tp_jw *w) { + tp_jw_open(w, '{'); + KEY(w, "code"); + tp_jw_str(w, x->code); + KEY(w, "line"); + tp_jw_integer(w, (int64_t)x->line); + KEY(w, "severity"); + tp_jw_str(w, x->severity); + KEY(w, "suggestion"); + if (x->suggestion == NULL) { + tp_jw_null(w); + } else { + tp_suggestion_write(x->suggestion, w); + } + tp_jw_close(w, '}'); +} + +TP_PRIVATE void tp_stats_write(const tp_stats *s, tp_jw *w) { + tp_jw_open(w, '{'); + KEY(w, "lines"); + tp_jw_integer(w, (int64_t)s->lines); + KEY(w, "tracks"); + tp_jw_integer(w, (int64_t)s->tracks); + KEY(w, "markers"); + tp_jw_integer(w, (int64_t)s->markers); + KEY(w, "timed"); + tp_jw_integer(w, (int64_t)s->timed); + KEY(w, "firstTime"); + tp_jw_opt_num(w, s->first_time); + KEY(w, "lastTime"); + tp_jw_opt_num(w, s->last_time); + tp_jw_close(w, '}'); +} + +TP_PRIVATE void tp_tracklist_write(const tp_tracklist *t, tp_jw *w) { + size_t i; + tp_jw_open(w, '{'); + KEY(w, "specVersion"); + tp_jw_str(w, t->spec_version); + KEY(w, "entries"); + tp_jw_open(w, '['); + for (i = 0; i < t->entries.n; i++) tp_entry_write(&t->entries.p[i], w); + tp_jw_close(w, ']'); + KEY(w, "warnings"); + tp_jw_open(w, '['); + for (i = 0; i < t->warnings.n; i++) tp_tracklist_warning_write(&t->warnings.p[i], w); + tp_jw_close(w, ']'); + KEY(w, "stats"); + tp_stats_write(&t->stats, w); + tp_jw_close(w, '}'); +} + +TP_PRIVATE void tp_edit_write(const tp_edit *e, tp_jw *w) { + tp_jw_open(w, '{'); + KEY(w, "op"); + tp_jw_str(w, e->op); + if (tp_str_eq(e->op, TP_EDIT_OP_SET_TIME)) { + KEY(w, "line"); + tp_jw_integer(w, e->line); + KEY(w, "seconds"); + tp_jw_num(w, e->seconds); + } else if (tp_str_eq(e->op, TP_EDIT_OP_SHIFT)) { + KEY(w, "seconds"); + tp_jw_num(w, e->seconds); + if (e->has_lines) { + KEY(w, "lines"); + tp_jw_ints(w, e->lines); + } + if (e->from != NULL) { + KEY(w, "from"); + tp_jw_integer(w, *e->from); + } + } else if (tp_str_eq(e->op, TP_EDIT_OP_SET_REST)) { + KEY(w, "line"); + tp_jw_integer(w, e->line); + KEY(w, "rest"); + tp_jw_str(w, e->rest); + } else if (tp_str_eq(e->op, TP_EDIT_OP_INSERT)) { + KEY(w, "after"); + tp_jw_integer(w, e->after); + KEY(w, "text"); + tp_jw_str(w, e->text); + } else if (tp_str_eq(e->op, TP_EDIT_OP_DELETE)) { + KEY(w, "line"); + tp_jw_integer(w, e->line); + } + tp_jw_close(w, '}'); +} + +TP_PRIVATE void tp_edit_warning_write(const tp_edit_warning *x, tp_jw *w) { + tp_jw_open(w, '{'); + KEY(w, "code"); + tp_jw_str(w, x->code); + KEY(w, "edit"); + tp_jw_integer(w, (int64_t)x->edit); + KEY(w, "line"); + tp_jw_opt_int64(w, x->line); + tp_jw_close(w, '}'); +} + +TP_PRIVATE void tp_edit_result_write(const tp_edit_result *r, tp_jw *w) { + size_t i; + tp_jw_open(w, '{'); + KEY(w, "text"); + tp_jw_str(w, r->text); + KEY(w, "changed"); + tp_jw_ints(w, r->changed); + KEY(w, "warnings"); + tp_jw_open(w, '['); + for (i = 0; i < r->warnings.n; i++) tp_edit_warning_write(&r->warnings.p[i], w); + tp_jw_close(w, ']'); + tp_jw_close(w, '}'); +} + +TP_PRIVATE void tp_raw_edit_result_write(const tp_raw_edit_result *r, tp_jw *w) { + size_t i; + tp_jw_open(w, '{'); + KEY(w, "text"); + tp_jw_str(w, r->text); + KEY(w, "changed"); + tp_jw_ints(w, r->changed); + KEY(w, "warnings"); + tp_jw_open(w, '['); + for (i = 0; i < r->warnings.n; i++) { + const tp_raw_edit_warning *x = &r->warnings.p[i]; + tp_jw_open(w, '{'); + KEY(w, "code"); + tp_jw_str(w, x->code); + KEY(w, "edit"); + tp_jw_integer(w, (int64_t)x->edit); + KEY(w, "line"); + tp_jw_opt_num(w, x->line); + tp_jw_close(w, '}'); + } + tp_jw_close(w, ']'); + tp_jw_close(w, '}'); +} + +/* jsonValue.write. Recursive: the depth is bounded by the reader (TP_JSON_MAX_DEPTH) or by the + * builder (tp_edit_json: 2). */ +TP_PRIVATE void tp_json_write(const tp_json *v, tp_jw *w) { + size_t i; + switch (v->kind) { + case TP_JSON_NULL: + tp_jw_null(w); + break; + case TP_JSON_BOOL: + tp_jw_boolean(w, v->b); + break; + case TP_JSON_NUMBER: + tp_jw_num(w, v->num); + break; + case TP_JSON_STRING: + tp_jw_str(w, v->str); + break; + case TP_JSON_ARRAY: + tp_jw_open(w, '['); + for (i = 0; i < v->arr_n; i++) tp_json_write(&v->arr[i], w); + tp_jw_close(w, ']'); + break; + case TP_JSON_OBJECT: + tp_jw_open(w, '{'); + for (i = 0; i < v->obj_n; i++) { + tp_jw_key(w, v->obj[i].key); + tp_json_write(&v->obj[i].val, w); + } + tp_jw_close(w, '}'); + break; + } +} + +/* -------------------------------------------------------------------------------------------- */ +/* marshal, one per type */ + +TP_PRIVATE tp_str tp_track_json(const tp_track *t) { + tp_jw w = tp_jw_new(); + tp_track_write(t, &w); + return tp_jw_done(&w); +} + +TP_PRIVATE tp_str tp_artists_json(tp_artist_vec list) { + tp_jw w = tp_jw_new(); + tp_write_artists(&w, list); + return tp_jw_done(&w); +} + +TP_PRIVATE tp_str tp_tracklist_json(const tp_tracklist *t) { + tp_jw w = tp_jw_new(); + tp_tracklist_write(t, &w); + return tp_jw_done(&w); +} + +TP_PRIVATE tp_str tp_edit_result_json(const tp_edit_result *r) { + tp_jw w = tp_jw_new(); + tp_edit_result_write(r, &w); + return tp_jw_done(&w); +} + +TP_PRIVATE tp_str tp_raw_edit_result_json(const tp_raw_edit_result *r) { + tp_jw w = tp_jw_new(); + tp_raw_edit_result_write(r, &w); + return tp_jw_done(&w); +} + +TP_PRIVATE tp_str tp_string_json(tp_str s) { + tp_jw w = tp_jw_new(); + tp_jw_str(&w, s); + return tp_jw_done(&w); +} + +/* -------------------------------------------------------------------------------------------- */ +/* JSON values */ + +/* getString is the string at key, or false. */ +TP_PRIVATE bool tp_json_get_string(tp_json v, tp_str key, tp_str *out) { + tp_json x; + if (!tp_json_get(v, key, &x) || x.kind != TP_JSON_STRING) return false; + *out = x.str; + return true; +} + +typedef TP_VEC(tp_json_member) member_vec; + +static void member(member_vec *m, const char *key, tp_json v) { + tp_json_member x; + x.key = tp_str_c(key); + x.val = v; + tp_push(*m, x); +} + +/* A number as reading its JSON text back gives it: NaN and the infinities are written as null, + * and -0 is written as 0. Finite values round-trip exactly (shortest round-trip digits). */ +static tp_json number_value(double n) { + if (tp_is_nan(n) || tp_is_inf(n)) return tp_json_null(); + if (n == 0) return tp_json_num(0.0); + return tp_json_num(n); +} + +/* An integer field: written as the double (double)n, read back as that double. */ +static tp_json integer_value(int64_t n) { return number_value((double)n); } + +/* jsonOf(&edit): the edit's JSON value, exactly what reading tp_edit_write's text back gives + * (Go goes through the text), built directly: strings tp_sanitize'd, the integer fields as + * doubles, a NaN or infinite seconds as null, -0 as 0, keys in tp_edit_write's order. */ +TP_PRIVATE tp_json tp_edit_json(const tp_edit *e) { + member_vec m = {0, 0, 0}; + tp_json out = tp_json_null(); + member(&m, "op", tp_json_str(tp_sanitize(e->op))); + if (tp_str_eq(e->op, TP_EDIT_OP_SET_TIME)) { + member(&m, "line", integer_value(e->line)); + member(&m, "seconds", number_value(e->seconds)); + } else if (tp_str_eq(e->op, TP_EDIT_OP_SHIFT)) { + member(&m, "seconds", number_value(e->seconds)); + if (e->has_lines) { + tp_json arr = tp_json_null(); + tp_json *items = (tp_json *)tp_alloc_array(e->lines.n, sizeof *items); + size_t i; + for (i = 0; i < e->lines.n; i++) items[i] = integer_value(e->lines.p[i]); + arr.kind = TP_JSON_ARRAY; + arr.arr = items; + arr.arr_n = e->lines.n; + member(&m, "lines", arr); + } + if (e->from != NULL) member(&m, "from", integer_value(*e->from)); + } else if (tp_str_eq(e->op, TP_EDIT_OP_SET_REST)) { + member(&m, "line", integer_value(e->line)); + member(&m, "rest", tp_json_str(tp_sanitize(e->rest))); + } else if (tp_str_eq(e->op, TP_EDIT_OP_INSERT)) { + member(&m, "after", integer_value(e->after)); + member(&m, "text", tp_json_str(tp_sanitize(e->text))); + } else if (tp_str_eq(e->op, TP_EDIT_OP_DELETE)) { + member(&m, "line", integer_value(e->line)); + } + out.kind = TP_JSON_OBJECT; + out.obj = m.p != NULL ? m.p : (const tp_json_member *)tp_alloc(0); + out.obj_n = m.n; + return out; +} diff --git a/c/src/mode.c b/c/src/mode.c new file mode 100644 index 0000000..7afbec9 --- /dev/null +++ b/c/src/mode.c @@ -0,0 +1,282 @@ +/* mode.c: R2 mode resolution, platform suffixes, filename handling and youtube pipes + * (go/mode.go, js/src/mode.ts). */ +#include "internal.h" + +/* asciiLowerRunes lowercases A-Z only. */ +TP_PRIVATE tp_runes tp_ascii_lower_runes(tp_runes t) { + tp_rune *out = tp_alloc_array(t.n, sizeof *out); + for (size_t i = 0; i < t.n; i++) { + tp_rune r = t.p[i]; + if (r >= 'A' && r <= 'Z') r += 'a' - 'A'; + out[i] = r; + } + return (tp_runes){out, t.n}; +} + +/* hasRuneSuffix reports whether t ends with suffix. */ +TP_PRIVATE bool tp_has_rune_suffix(tp_runes t, tp_runes suffix) { + if (suffix.n > t.n) return false; + size_t off = t.n - suffix.n; + for (size_t i = 0; i < suffix.n; i++) { + if (t.p[off + i] != suffix.p[i]) return false; + } + return true; +} + +/* runeIndex is the first index of r in t, or -1. */ +TP_PRIVATE ptrdiff_t tp_rune_index(tp_runes t, tp_rune r) { + for (size_t i = 0; i < t.n; i++) { + if (t.p[i] == r) return (ptrdiff_t)i; + } + return -1; +} + +/* lastRuneIndex is the last index of r in t, or -1. */ +TP_PRIVATE ptrdiff_t tp_last_rune_index(tp_runes t, tp_rune r) { + for (ptrdiff_t i = (ptrdiff_t)t.n - 1; i >= 0; i--) { + if (t.p[i] == r) return i; + } + return -1; +} + +/* stripPlatformSuffixes is R2.2: strip trailing platform suffixes (longest first, repeatedly). */ +TP_PRIVATE tp_runes tp_strip_platform_suffixes(tp_runes s, tp_ctx *c, + tp_positioned_junk_vec *junk) { + tp_runes text = tp_runes_clone(s); + for (bool stripped = true; stripped;) { + stripped = false; + tp_runes lower = tp_ascii_lower_runes(text); + for (size_t k = 0; k < c->t->platform_suffixes.n; k++) { + tp_runes suffix_lower = tp_runes_of(tp_ascii_lower(c->t->platform_suffixes.p[k])); + if (!tp_has_rune_suffix(lower, suffix_lower)) continue; + ptrdiff_t start = (ptrdiff_t)text.n - (ptrdiff_t)suffix_lower.n; + tp_positioned_junk j; + j.raw = tp_runes_str(tp_tail(text, start + 3)); + j.kind = TP_JUNK_KIND_PLATFORM; + j.pos = tp_utf16_len(tp_sub(text, 0, start)) + 3; + tp_push(*junk, j); + text = tp_sub(text, 0, start); + stripped = true; + break; + } + } + return text; +} + +/* hasExtension reports whether s ends in a known file extension (R2.3). */ +TP_PRIVATE bool tp_has_extension(tp_runes s, tp_ctx *c) { + ptrdiff_t dot = tp_last_rune_index(s, '.'); + if (dot < 0) return false; + return tp_word_set_has(&c->t->extensions, tp_ascii_lower(tp_runes_str(tp_tail(s, dot + 1)))); +} + +typedef struct pipe_cut { + ptrdiff_t a, b; +} pipe_cut; +typedef TP_VEC(pipe_cut) pipe_cut_vec; + +/* splitPipes splits a skeleton at top-level " | " and " || " separators into trimmed segments + * (R2.4). */ +TP_PRIVATE tp_segment_vec tp_split_pipes(tp_skel sk) { + tp_runes t = sk.text; + ptrdiff_t n = (ptrdiff_t)t.n; + pipe_cut_vec cuts = {0}; + for (ptrdiff_t i = 1; i < n; i++) { + if (tp_before(t, i) == ' ' && tp_at(t, i) == '|') { + ptrdiff_t bars = 1; + if (tp_at(t, i + 1) == '|') bars = 2; + if (tp_at(t, i + bars) == ' ') { + pipe_cut k = {i - 1, i + bars + 1}; + tp_push(cuts, k); + i += bars; + } + } + } + pipe_cut last = {n, n}; + tp_push(cuts, last); + tp_segment_vec segments = {0}; + ptrdiff_t start = 0; + for (size_t ci = 0; ci < cuts.n; ci++) { + pipe_cut k = cuts.p[ci]; + ptrdiff_t s = start, e = k.a; + while (s < e && tp_at(t, s) == ' ') s++; + while (e > s && tp_before(t, e) == ' ') e--; + tp_segment seg; + seg.skel = tp_slice_skel(&sk, s, e); + seg.start = s; + seg.end = e; + tp_push(segments, seg); + start = k.b; + } + return segments; +} + +/* trailingJunkPhrase is the R8.4 test: the text ends with an unbracketed junk phrase (genres + * excluded). It gives the code-point index where the phrase starts and its kind. */ +TP_PRIVATE bool tp_trailing_junk_phrase(tp_runes text, tp_ctx *c, ptrdiff_t *start, tp_str *kind) { + tp_word_span_vec spans = tp_word_spans(text); + tp_strvec words = tp_span_texts(spans); + tp_phrase_match m; + if (!tp_phrase_table_match_ending(c->t->junk_phrases, words, (ptrdiff_t)spans.n, &m)) { + return false; + } + ptrdiff_t first = (ptrdiff_t)spans.n - m.length; + if (first < 0 || first >= (ptrdiff_t)spans.n) return false; + *start = spans.p[first].start; + *kind = *(const tp_str *)m.value; + return true; +} + +/* junkTextKind is the R5.1 junk kind of a whole text, if it is junk. */ +TP_PRIVATE bool tp_junk_text_kind(tp_str text, tp_ctx *c, tp_str *kind) { + tp_strvec words = tp_split_words(text); + if (words.n == 0) return false; + return tp_junk_kind_of(words, c, kind); +} + +/* looksLikeYoutube is the R2.1 youtube signals besides platform suffixes. */ +TP_PRIVATE bool tp_looks_like_youtube(tp_skel sk, tp_ctx *c) { + if (tp_split_pipes(sk).n > 1) return true; + tp_indexed_group_vec groups = tp_groups_of(&sk); + for (size_t i = 0; i < groups.n; i++) { + tp_str kind; + if (tp_junk_text_kind(groups.p[i].group->inner, c, &kind) && !tp_str_eq(kind, TP_S("genre"))) { + return true; + } + } + ptrdiff_t start; + tp_str kind; + return tp_trailing_junk_phrase(sk.text, c, &start, &kind); +} + +/* prelude is R2 on the normalized string. */ +TP_PRIVATE tp_prelude_result tp_prelude(tp_str normalized, tp_requested_mode requested, tp_ctx *c) { + tp_positioned_junk_vec junk = {0}; + tp_runes text = tp_strip_platform_suffixes(tp_runes_of(normalized), c, &junk); + bool had_platform = junk.n > 0; + + tp_mode mode; + if (requested.kind == TP_REQUEST_MODE) { + mode = requested.mode; /* R13.6: tracklist is explicit only; R2.3 and R2.4 do not run. */ + } else if (tp_has_extension(text, c)) { + mode = TP_MODE_FILENAME; + } else { + mode = TP_MODE_CLEAN; + } + + if (tp_str_eq(mode, TP_MODE_FILENAME)) { + /* R2.3: strip the extension, trim, then "_" becomes a space when there is no space. */ + if (tp_has_extension(text, c)) { + ptrdiff_t dot = tp_last_rune_index(text, '.'); + if (dot >= 0) text = tp_sub(text, 0, dot); + } + text = tp_js_trim_runes(text); + if (tp_rune_index(text, ' ') < 0 && tp_rune_index(text, '_') >= 0) { + tp_rune *spaced = tp_alloc_array(text.n, sizeof *spaced); + for (size_t i = 0; i < text.n; i++) { + tp_rune r = text.p[i]; + if (r == '_') r = ' '; + spaced[i] = r; + } + text = tp_js_trim_runes((tp_runes){spaced, text.n}); + } + } + + bool unbalanced; + tp_skel sk = tp_scan(text, 0, &unbalanced); + if (unbalanced) tp_ctx_warn(c, TP_WARNING_UNBALANCED_BRACKETS); + if (requested.kind == TP_REQUEST_AUTO && tp_str_eq(mode, TP_MODE_CLEAN) && + (had_platform || tp_looks_like_youtube(sk, c))) { + mode = TP_MODE_YOUTUBE; + } + + tp_prelude_result res; + memset(&res, 0, sizeof res); + res.mode = mode; + if (!tp_str_eq(mode, TP_MODE_YOUTUBE)) { + res.working.text = text; + res.working.base = 0; + res.junk = junk; + return res; + } + const tp_piece *pipe_title; + res.working = tp_split_youtube_pipes(sk, c, &junk, &pipe_title); + res.pipe_title = pipe_title; + res.junk = junk; + return res; +} + +/* pieceOf is the rendered text of a segment with its absolute offset. */ +TP_PRIVATE tp_piece tp_piece_of(tp_segment seg) { + tp_piece p; + p.text = tp_runes_of(tp_render_skel(&seg.skel)); + p.base = tp_start_pos(&seg.skel, 0); + return p; +} + +/* Go closure pushOther of splitYoutubePipes: every remaining segment but keep becomes "other" + * junk. */ +static void push_other(tp_segment_vec remaining, ptrdiff_t keep, tp_positioned_junk_vec *junk) { + for (size_t i = 0; i < remaining.n; i++) { + if ((ptrdiff_t)i == keep) continue; + tp_positioned_junk j; + j.raw = tp_collapse_spaces(tp_render_skel(&remaining.p[i].skel)); + j.kind = TP_JUNK_KIND_OTHER; + j.pos = tp_start_pos(&remaining.p[i].skel, 0); + tp_push(*junk, j); + } +} + +/* splitYoutubePipes is R2.4. */ +TP_PRIVATE tp_piece tp_split_youtube_pipes(tp_skel sk, tp_ctx *c, tp_positioned_junk_vec *junk, + const tp_piece **pipe_title) { + *pipe_title = NULL; + tp_segment_vec segments = tp_split_pipes(sk); + if (segments.n <= 1) { + tp_piece p; + p.text = tp_runes_of(tp_render_skel(&sk)); + p.base = 0; + return p; + } + + tp_segment_vec remaining = {0}; + for (size_t i = 0; i < segments.n; i++) { + tp_segment seg = segments.p[i]; + tp_str text = tp_collapse_spaces(tp_render_skel(&seg.skel)); + /* R2.4 step 1: a segment with a spaced dash is an artist/title candidate, never junk. */ + tp_str kind = TP_EMPTY; + bool is_junk = false; + if (!tp_has_spaced_dash(seg.skel.text)) is_junk = tp_junk_text_kind(text, c, &kind); + if (is_junk && kind.n > 0) { + tp_positioned_junk j; + j.raw = text; + j.kind = kind; + j.pos = tp_start_pos(&seg.skel, 0); + tp_push(*junk, j); + } else if (text.n > 0) { + tp_push(remaining, seg); + } + } + + for (size_t i = 0; i < remaining.n; i++) { + if (tp_has_spaced_dash(remaining.p[i].skel.text)) { + push_other(remaining, (ptrdiff_t)i, junk); + return tp_piece_of(remaining.p[i]); + } + } + if (remaining.n == 2) { + tp_ctx_warn(c, TP_WARNING_AMBIGUOUS_SEPARATOR); + tp_piece *title = tp_alloc(sizeof *title); + *title = tp_piece_of(remaining.p[1]); + *pipe_title = title; + return tp_piece_of(remaining.p[0]); + } + if (remaining.n > 0) { + push_other(remaining, 0, junk); + return tp_piece_of(remaining.p[0]); + } + /* Every segment was junk: nothing left to parse. */ + tp_piece empty; + memset(&empty, 0, sizeof empty); + return empty; +} diff --git a/c/src/normalize.c b/c/src/normalize.c new file mode 100644 index 0000000..1b0d3dd --- /dev/null +++ b/c/src/normalize.c @@ -0,0 +1,120 @@ +/* normalize.c: R1 normalization (go/normalize.go, js/src/normalize.ts). */ +#include "internal.h" + +/* isRemoved is R1.2: the invisible characters removed outright. ZWNJ and ZWJ (U+200C, U+200D) + * are kept (ZWJ emoji). U+E000 is reserved as the R3.4 group placeholder, so it can never occur + * in input. */ +TP_PRIVATE bool tp_is_removed(tp_rune r) { + switch (r) { + case 0x200b: + case 0x2060: + case 0xfeff: + case 0x00ad: + case TP_PH: + return true; + default: + return false; + } +} + +/* mapRune is R1.3 brackets, R1.4 quotes and R1.5 dashes to ASCII. false for a removed + * character. */ +TP_PRIVATE bool tp_map_rune(tp_rune r, tp_rune *out) { + if (tp_is_removed(r)) return false; + if (r >= 0x2010 && r <= 0x2015) { /* R1.5 */ + *out = '-'; + return true; + } + switch (r) { + case 0xff08: + *out = '('; + return true; + case 0xff09: + *out = ')'; + return true; + case 0xff3b: + case 0x3010: + case 0x3014: + *out = '['; + return true; + case 0xff3d: + case 0x3011: + case 0x3015: + *out = ']'; + return true; + case 0xff5b: + *out = '{'; + return true; + case 0xff5d: + *out = '}'; + return true; + case 0x201c: + case 0x201d: + case 0x201e: + case 0x00ab: + case 0x00bb: + case 0x300c: + case 0x300d: + case 0x300e: + case 0x300f: + case 0xff02: + *out = '"'; + return true; + case 0x2018: + case 0x2019: + case 0x201a: + case 0x0060: + case 0x00b4: + *out = '\''; + return true; + case 0x2212: + case 0xfe58: + case 0xfe63: + case 0xff0d: + *out = '-'; + return true; + default: + *out = r; + return true; + } +} + +/* collapseSpacedDashRuns is the second half of R1.5: a run of two or more "-" with whitespace on + * both sides becomes one "-". */ +TP_PRIVATE tp_runes tp_collapse_spaced_dash_runs(tp_runes t) { + tp_runevec out = {0}; + ptrdiff_t n = (ptrdiff_t)t.n; + ptrdiff_t i = 0; + while (i < n) { + tp_rune r = t.p[i]; + if (r != '-') { + tp_push(out, r); + i++; + continue; + } + ptrdiff_t j = i; + while (tp_at(t, j) == '-') j++; + bool spaced = j - i >= 2 && tp_is_whitespace(tp_before(t, i)) && tp_is_whitespace(tp_at(t, j)); + if (spaced) { + tp_push(out, (tp_rune)'-'); + } else { + for (ptrdiff_t k = i; k < j; k++) tp_push(out, (tp_rune)'-'); + } + i = j; + } + return tp_runevec_view(out); +} + +/* normalize is R1 on a track string. It is idempotent. */ +TP_PRIVATE tp_str tp_normalize(tp_str input) { + tp_runes src = tp_runes_of(tp_nfc(input)); + tp_runevec mapped = {0}; + for (size_t i = 0; i < src.n; i++) { + tp_rune m; + if (tp_map_rune(src.p[i], &m)) tp_push(mapped, m); + } + /* R1.6: every whitespace code point becomes one space, runs collapsed, trimmed. R1.8: removing + * invisibles can leave a decomposed sequence behind; compose again so that normalize stays + * idempotent. */ + return tp_nfc(tp_collapse_runes(tp_collapse_spaced_dash_runs(tp_runevec_view(mapped)))); +} diff --git a/c/src/num.c b/c/src/num.c new file mode 100644 index 0000000..180f0cf --- /dev/null +++ b/c/src/num.c @@ -0,0 +1,562 @@ +/* num.c: exact, locale-independent numbers (rt.h "Numbers"). + * + * - tp_parse_number: decimal string to the correctly rounded double, for any digit count, without + * strtod (locale, PLAN.md hazard 2 and 4). + * - tp_buf_number: JS Number#toString (shortest round-trip digits, closest of those, ties to an + * even digit, as V8's bignum-dtoa), without printf (hazard 3). + * - tp_half_up_units / tp_round_half_up: floor(v * scale + 0.5) as Go formatTime and JS + * times.ts compute it, with no fused multiply-add (hazard 1). + * + * Accepted grammar of tp_parse_number (the strings Go hands strconv.ParseFloat: go/tl_times.go + * secondsOf gives ".", go/json.go number() gives any run of [0-9+-.eE]): + * + * number = [ "+" | "-" ] mantissa [ exponent ] + * mantissa = digit+ [ "." digit* ] | "." digit+ + * exponent = ( "e" | "E" ) [ "+" | "-" ] digit+ + * + * digit is ASCII 0-9, any count, leading zeros allowed ("007", "1.", ".5", "+1e+007"). Nothing + * else: no whitespace, no empty string (JS Number("") is 0, ParseFloat fails), no "Infinity", + * "NaN", hex or underscores (ParseFloat takes some of them, but no caller can pass them). On this + * set JS Number() and Go ParseFloat agree: both are correctly rounded (ties to even); a value too + * large gives +-Infinity (Go: with ErrRange, which go/json.go accepts) and a value too small gives + * +-0. The result keeps the sign, so "-0" is -0. + */ +#include + +#include "rt.h" + +/* FMA contraction would fuse v * scale + 0.5 (PLAN.md hazard 1). The pragma is standard C, but + * GCC ignores it (and defaults to -ffp-contract=fast in GNU mode), so the build also passes + * -ffp-contract=off (MSVC: /fp:precise), and tp_half_up_units rounds the product through a + * volatile so even a build without the flag cannot fuse it. */ +#if defined(__clang__) || (!defined(__GNUC__) && !defined(_MSC_VER)) +#pragma STDC FP_CONTRACT OFF +#elif defined(_MSC_VER) +#pragma fp_contract(off) +#endif + +/* x87 excess precision would make the fast path double-round (PLAN.md hazard 5). */ +#if !defined(FLT_EVAL_METHOD) || FLT_EVAL_METHOD != 0 +#error "trackparse needs FLT_EVAL_METHOD == 0 (on 32-bit x86: -msse2 -mfpmath=sse)" +#endif + +/* -------------------------------------------------------------------------------------------- */ +/* Bits */ + +static uint64_t num_bits(double v) { + uint64_t u; + memcpy(&u, &v, sizeof u); + return u; +} + +static double num_of_bits(uint64_t u) { + double v; + memcpy(&v, &u, sizeof v); + return v; +} + +TP_PRIVATE bool tp_is_nan(double v) { return v != v; } + +TP_PRIVATE bool tp_is_inf(double v) { + return (num_bits(v) & ~(UINT64_C(1) << 63)) == UINT64_C(0x7FF0000000000000); +} + +TP_PRIVATE double tp_nan(void) { return num_of_bits(UINT64_C(0x7FF8000000000000)); } + +TP_PRIVATE double tp_inf(int sign) { + return num_of_bits(sign < 0 ? UINT64_C(0xFFF0000000000000) : UINT64_C(0x7FF0000000000000)); +} + +static const double num_pow10[23] = {1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, + 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, + 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22}; + +/* -------------------------------------------------------------------------------------------- */ +/* Rounding */ + +TP_PRIVATE double tp_floor(double v) { + double t; + if (!(v < 4503599627370496.0 && v > -4503599627370496.0)) return v; /* NaN, inf, integers */ + if (v == 0) return v; /* keeps -0 */ + t = (double)(int64_t)v; /* toward zero */ + if (t > v) t -= 1.0; + return t; +} + +TP_PRIVATE double tp_half_up_units(double v, double scale) { + /* Separate statements and a volatile: the product is rounded to a double before the add. */ + volatile double product = v * scale; + double sum = product + 0.5; + return tp_floor(sum); +} + +TP_PRIVATE double tp_round_half_up(double v, int digits) { + double scale; + if (digits < 0) digits = 0; + if (digits > 20) digits = 20; + scale = num_pow10[digits]; + return tp_half_up_units(v, scale) / scale; +} + +/* -------------------------------------------------------------------------------------------- */ +/* Big unsigned integers (fixed capacity; the callers bound the sizes) */ + +/* Parsing needs about 3,800 bits (800 digits over 10^1125, shifted), formatting about 1,200. */ +#define NUM_BIG_LIMBS 160 + +typedef struct num_big { + uint32_t d[NUM_BIG_LIMBS]; /* little endian */ + size_t n; /* used limbs, no leading zero limb */ +} num_big; + +static void num_big_trim(num_big *a) { + while (a->n > 0 && a->d[a->n - 1] == 0) a->n--; +} + +static void num_big_set(num_big *a, uint64_t v) { + a->n = 0; + while (v != 0) { + a->d[a->n++] = (uint32_t)v; + v >>= 32; + } +} + +static void num_big_copy(num_big *dst, const num_big *src) { + dst->n = src->n; + if (src->n) memcpy(dst->d, src->d, src->n * sizeof(uint32_t)); +} + +/* a = a * m + add */ +static void num_big_mul_add(num_big *a, uint32_t m, uint32_t add) { + uint64_t carry = add; + size_t i; + for (i = 0; i < a->n; i++) { + uint64_t t = (uint64_t)a->d[i] * m + carry; + a->d[i] = (uint32_t)t; + carry = t >> 32; + } + if (carry != 0 && a->n < NUM_BIG_LIMBS) a->d[a->n++] = (uint32_t)carry; +} + +static void num_big_mul_pow10(num_big *a, int64_t e) { + static const uint32_t small[10] = {1, 10, 100, 1000, 10000, + 100000, 1000000, 10000000, 100000000, 1000000000}; + while (e >= 9) { + num_big_mul_add(a, 1000000000u, 0); + e -= 9; + } + if (e > 0) num_big_mul_add(a, small[e], 0); +} + +static void num_big_shl(num_big *a, uint64_t bits) { + size_t limbs = (size_t)(bits / 32), i; + unsigned s = (unsigned)(bits % 32); + if (a->n == 0 || a->n >= NUM_BIG_LIMBS) return; + /* Unreachable by the callers' bounds; keeps the writes inside d (and shows GCC the bound). */ + if (limbs > NUM_BIG_LIMBS - 1 - a->n) limbs = NUM_BIG_LIMBS - 1 - a->n; + if (s == 0) { + for (i = a->n; i > 0; i--) a->d[i - 1 + limbs] = a->d[i - 1]; + a->n += limbs; + } else { + a->d[a->n + limbs] = 0; + for (i = a->n; i > 0; i--) { + a->d[i + limbs] |= a->d[i - 1] >> (32 - s); + a->d[i - 1 + limbs] = a->d[i - 1] << s; + } + a->n += limbs + 1; + } + for (i = 0; i < limbs; i++) a->d[i] = 0; + num_big_trim(a); +} + +static int num_big_cmp(const num_big *a, const num_big *b) { + size_t i; + if (a->n != b->n) return a->n < b->n ? -1 : 1; + for (i = a->n; i > 0; i--) { + if (a->d[i - 1] != b->d[i - 1]) return a->d[i - 1] < b->d[i - 1] ? -1 : 1; + } + return 0; +} + +/* a -= b, a >= b */ +static void num_big_sub(num_big *a, const num_big *b) { + uint64_t borrow = 0; + size_t i; + for (i = 0; i < a->n; i++) { + uint64_t bi = i < b->n ? b->d[i] : 0; + uint64_t t = (uint64_t)a->d[i] - bi - borrow; + a->d[i] = (uint32_t)t; + borrow = (t >> 63) & 1; + } + num_big_trim(a); +} + +/* out = a + b */ +static void num_big_add(num_big *out, const num_big *a, const num_big *b) { + const num_big *l = a->n >= b->n ? a : b, *s = a->n >= b->n ? b : a; + uint64_t carry = 0; + size_t i; + for (i = 0; i < l->n; i++) { + uint64_t t = (uint64_t)l->d[i] + (i < s->n ? s->d[i] : 0) + carry; + out->d[i] = (uint32_t)t; + carry = t >> 32; + } + out->n = l->n; + if (carry && out->n < NUM_BIG_LIMBS) out->d[out->n++] = (uint32_t)carry; +} + +static int64_t num_big_bitlen(const num_big *a) { + uint32_t top; + int64_t bits; + if (a->n == 0) return 0; + top = a->d[a->n - 1]; + bits = (int64_t)(a->n - 1) * 32; + while (top != 0) { + bits++; + top >>= 1; + } + return bits; +} + +/* -------------------------------------------------------------------------------------------- */ +/* Parsing */ + +/* Significant digits kept; any digit past them only breaks ties, so a nonzero tail becomes one + * extra "1" digit. Exact halfway points between doubles have at most 767 significant digits. */ +#define NUM_MAX_DIGITS 800 + +static bool num_is_digit(unsigned char c) { return c >= '0' && c <= '9'; } + +/* The exact value digits * 10^e (digits: nd ASCII digits, the first nonzero) as a double. */ +static double num_decimal_to_double(const char *digits, size_t nd, int64_t e) { + num_big num, den; + int64_t e2, t, sh, i; + uint64_t q = 0, raw; + size_t at; + int c; + /* Magnitude bounds: the value lies in [10^(nd+e-1), 10^(nd+e)). */ + if ((int64_t)nd + e > 310) return tp_inf(1); + if ((int64_t)nd + e < -330) return 0.0; + if (nd <= 15 && e >= -22 && e <= 22) { + /* Fast path: the digits and the power of ten are exact doubles, so one IEEE operation gives + * the correctly rounded result. */ + uint64_t m = 0; + double d; + for (at = 0; at < nd; at++) m = m * 10 + (uint64_t)(digits[at] - '0'); + d = (double)m; + return e >= 0 ? d * num_pow10[e] : d / num_pow10[-e]; + } + num_big_set(&num, 0); + for (at = 0; at < nd;) { + uint32_t chunk = 0, mul = 1; + size_t k; + for (k = 0; k < 9 && at < nd; k++, at++) { + chunk = chunk * 10 + (uint32_t)(digits[at] - '0'); + mul *= 10; + } + num_big_mul_add(&num, mul, chunk); + } + num_big_set(&den, 1); + if (e >= 0) { + num_big_mul_pow10(&num, e); + } else { + num_big_mul_pow10(&den, -e); + } + /* Scale so that 1 <= num / den < 2; the value is that ratio times 2^e2. */ + e2 = num_big_bitlen(&num) - num_big_bitlen(&den); + if (e2 >= 0) { + num_big_shl(&den, (uint64_t)e2); + } else { + num_big_shl(&num, (uint64_t)-e2); + } + if (num_big_cmp(&num, &den) < 0) { + num_big_shl(&num, 1); + e2--; + } + if (e2 > 1023) return tp_inf(1); + /* The result is q * 2^(t - 52) with t the binary exponent (or -1022 for subnormals). */ + t = e2 > -1022 ? e2 : -1022; + sh = e2 - t + 52; + if (sh < 0) { + if (sh < -1) return 0.0; + q = num_big_cmp(&num, &den) == 0 ? 0 : 1; /* r / 2 with r in [1, 2): a tie only at r == 1 */ + } else { + num_big_sub(&num, &den); + q = 1; + for (i = 0; i < sh; i++) { + num_big_shl(&num, 1); + q <<= 1; + if (num_big_cmp(&num, &den) >= 0) { + num_big_sub(&num, &den); + q |= 1; + } + } + num_big_shl(&num, 1); + c = num_big_cmp(&num, &den); + if (c > 0 || (c == 0 && (q & 1))) q++; + } + /* For t == -1022 the bits are q itself (subnormal, or the smallest normals); a carry into + * 2^53 moves to the next exponent, and past the largest one to infinity. */ + raw = ((uint64_t)(t + 1022) << 52) + q; + if (raw >= UINT64_C(0x7FF0000000000000)) return tp_inf(1); + return num_of_bits(raw); +} + +TP_PRIVATE bool tp_parse_number(tp_str s, double *out) { + const unsigned char *p = (const unsigned char *)s.p; + size_t i = 0, n = s.n, nd = 0, mant_digits = 0; + int64_t point = 0; /* significant-stream digits before the decimal point */ + int64_t exp10 = 0, e; + bool neg = false, seen_sig = false, sticky = false; + char digits[NUM_MAX_DIGITS + 1]; + double v; + if (i < n && (p[i] == '+' || p[i] == '-')) { + neg = p[i] == '-'; + i++; + } + for (; i < n && num_is_digit(p[i]); i++) { + mant_digits++; + if (p[i] != '0') seen_sig = true; + if (!seen_sig) continue; + point++; + if (nd < NUM_MAX_DIGITS) { + digits[nd++] = (char)p[i]; + } else if (p[i] != '0') { + sticky = true; + } + } + if (i < n && p[i] == '.') { + i++; + for (; i < n && num_is_digit(p[i]); i++) { + mant_digits++; + if (p[i] != '0') seen_sig = true; + if (!seen_sig) { + point--; + continue; + } + if (nd < NUM_MAX_DIGITS) { + digits[nd++] = (char)p[i]; + } else if (p[i] != '0') { + sticky = true; + } + } + } + if (mant_digits == 0) return false; + if (i < n && (p[i] == 'e' || p[i] == 'E')) { + bool eneg = false; + size_t start; + i++; + if (i < n && (p[i] == '+' || p[i] == '-')) { + eneg = p[i] == '-'; + i++; + } + start = i; + for (; i < n && num_is_digit(p[i]); i++) { + if (exp10 < 100000000) exp10 = exp10 * 10 + (p[i] - '0'); /* saturates far past the range */ + } + if (i == start) return false; + if (eneg) exp10 = -exp10; + } + if (i != n) return false; + if (nd == 0) { + *out = neg ? -0.0 : 0.0; + return true; + } + /* value = digits * 10^e, with the dropped digits (if any) as one trailing sticky "1". */ + e = exp10 + point - (int64_t)nd; + if (sticky) { + digits[nd++] = '1'; + e--; + } else { + while (nd > 1 && digits[nd - 1] == '0') { + nd--; + e++; + } + } + v = num_decimal_to_double(digits, nd, e); + *out = neg ? -v : v; + return true; +} + +/* -------------------------------------------------------------------------------------------- */ +/* Formatting */ + +static int64_t num_floor_div(int64_t a, int64_t b) { + int64_t q = a / b; + if ((a % b != 0) && ((a < 0) != (b < 0))) q--; + return q; +} + +/* Shortest digits of v (finite, > 0) by Steele & White / Burger & Dybvig free-format generation + * on exact num_big integers, with V8's final digit choice (nearer, ties to an even digit). Returns + * the digit count; the value is 0.digits * 10^point. */ +static size_t num_shortest_digits(double v, char out[32], int *point) { + uint64_t bits = num_bits(v), f = bits & ((UINT64_C(1) << 52) - 1); + int be = (int)((bits >> 52) & 0x7FF), e, k; + bool lower_closer, even; + num_big r, s, mp, mm, tmp; + size_t nd = 0; + int64_t x, bl; + if (be == 0) { + e = -1074; + } else { + f |= UINT64_C(1) << 52; + e = be - 1075; + } + lower_closer = f == (UINT64_C(1) << 52) && be > 1; + even = (f & 1) == 0; /* round-half-even reading: the bounds are inclusive */ + num_big_set(&r, f); + if (e >= 0) { + num_big_set(&mp, 1); + num_big_shl(&mp, (uint64_t)e); + num_big_copy(&mm, &mp); + if (!lower_closer) { + num_big_shl(&r, (uint64_t)e + 1); + num_big_set(&s, 2); + } else { + num_big_shl(&r, (uint64_t)e + 2); + num_big_set(&s, 4); + num_big_shl(&mp, 1); + } + } else { + num_big_set(&mm, 1); + if (!lower_closer) { + num_big_shl(&r, 1); + num_big_set(&s, 1); + num_big_shl(&s, (uint64_t)(1 - e)); + num_big_set(&mp, 1); + } else { + num_big_shl(&r, 2); + num_big_set(&s, 1); + num_big_shl(&s, (uint64_t)(2 - e)); + num_big_set(&mp, 2); + } + } + /* Estimate k = ceil(log10 v) from floor(log2 v); the loops below correct it. */ + bl = 0; + { + uint64_t t = f; + while (t) { + bl++; + t >>= 1; + } + } + x = e + bl - 1; + k = (int)(num_floor_div(x * 78913, 262144) + 1); + if (k >= 0) { + num_big_mul_pow10(&s, k); + } else { + num_big_mul_pow10(&r, -k); + num_big_mul_pow10(&mp, -k); + num_big_mul_pow10(&mm, -k); + } + for (;;) { /* too small: high reaches 1 */ + int c; + num_big_add(&tmp, &r, &mp); + c = num_big_cmp(&tmp, &s); + if (even ? c >= 0 : c > 0) { + num_big_mul_add(&s, 10, 0); + k++; + continue; + } + break; + } + for (;;) { /* too large: 10 * high still below 1 */ + int c; + num_big_add(&tmp, &r, &mp); + num_big_mul_add(&tmp, 10, 0); + c = num_big_cmp(&tmp, &s); + if (even ? c < 0 : c <= 0) { + num_big_mul_add(&r, 10, 0); + num_big_mul_add(&mp, 10, 0); + num_big_mul_add(&mm, 10, 0); + k--; + continue; + } + break; + } + *point = k; + while (nd < 30) { + int d = 0, c1, c2; + bool low, high; + num_big_mul_add(&r, 10, 0); + num_big_mul_add(&mp, 10, 0); + num_big_mul_add(&mm, 10, 0); + while (num_big_cmp(&r, &s) >= 0) { + num_big_sub(&r, &s); + d++; + } + c1 = num_big_cmp(&r, &mm); + num_big_add(&tmp, &r, &mp); + c2 = num_big_cmp(&tmp, &s); + low = even ? c1 <= 0 : c1 < 0; + high = even ? c2 >= 0 : c2 > 0; + if (!low && !high) { + out[nd++] = (char)('0' + d); + continue; + } + if (low && high) { + int c; + num_big_add(&tmp, &r, &r); + c = num_big_cmp(&tmp, &s); + if (c > 0 || (c == 0 && (d & 1))) d++; + } else if (high) { + d++; + } + out[nd++] = (char)('0' + d); + break; + } + return nd; +} + +TP_PRIVATE void tp_buf_number(tp_buf *b, double v) { + char digits[32]; + size_t k, i; + int point; + if (tp_is_nan(v)) { + tp_buf_cstr(b, "NaN"); + return; + } + if (tp_is_inf(v)) { + tp_buf_cstr(b, v < 0 ? "-Infinity" : "Infinity"); + return; + } + if (v == 0) { + tp_buf_byte(b, '0'); + return; + } + if (v < 0) { + tp_buf_byte(b, '-'); + v = -v; + } + k = num_shortest_digits(v, digits, &point); + /* ECMA-262 Number::toString: the value is 0.digits * 10^point. */ + if ((int)k <= point && point <= 21) { + tp_buf_bytes(b, digits, k); + for (i = 0; i < (size_t)point - k; i++) tp_buf_byte(b, '0'); + } else if (0 < point && point <= 21) { + tp_buf_bytes(b, digits, (size_t)point); + tp_buf_byte(b, '.'); + tp_buf_bytes(b, digits + point, k - (size_t)point); + } else if (-6 < point && point <= 0) { + tp_buf_bytes(b, "0.", 2); + for (i = 0; i < (size_t)-point; i++) tp_buf_byte(b, '0'); + tp_buf_bytes(b, digits, k); + } else { + int e = point - 1; + tp_buf_byte(b, digits[0]); + if (k > 1) { + tp_buf_byte(b, '.'); + tp_buf_bytes(b, digits + 1, k - 1); + } + tp_buf_byte(b, 'e'); + tp_buf_byte(b, e >= 0 ? '+' : '-'); + tp_buf_int(b, e < 0 ? -e : e); + } +} + +TP_PRIVATE tp_str tp_number_str(double v) { + tp_buf b = {0, 0, 0}; + tp_buf_number(&b, v); + return tp_buf_done(&b); +} diff --git a/c/src/options.c b/c/src/options.c new file mode 100644 index 0000000..e344532 --- /dev/null +++ b/c/src/options.c @@ -0,0 +1,542 @@ +/* options.c: R12 options (go/options.go): the edit constructors, the resolved forms the pipeline + * reads, and the two doors to them: the typed structs (tp_resolve_parse, ...) and loose JSON + * (tp_resolve_parse_json, ...), which applies exactly the fallbacks of the JS reference (a bad + * value means the default, R0.8). Resolution never fails. */ +#include "internal.h" + +/* isEmpty reports whether k adds no word, so the default tables can be shared. */ +TP_PRIVATE bool tp_keywords_is_empty(const tp_keywords *k) { + return k->version_heads.n == 0 && k->descriptors.n == 0 && k->genres.n == 0 && k->junk.n == 0 && + k->feat_markers.n == 0; +} + +/* -------------------------------------------------------------------------------------------- */ +/* Edit constructors */ + +static tp_edit edit_of(tp_str op) { + tp_edit e; + memset(&e, 0, sizeof e); + e.op = op; + e.rest = TP_EMPTY; + e.text = TP_EMPTY; + return e; +} + +/* SetTime rewrites the time of line, keeping its written style (R13.9.2). */ +TP_PRIVATE tp_edit tp_edit_set_time(int64_t line, double seconds) { + tp_edit e = edit_of(TP_EDIT_OP_SET_TIME); + e.line = line; + e.seconds = seconds; + return e; +} + +/* Shift adds seconds to every timed line. */ +TP_PRIVATE tp_edit tp_edit_shift(double seconds) { + tp_edit e = edit_of(TP_EDIT_OP_SHIFT); + e.seconds = seconds; + return e; +} + +/* ShiftFrom adds seconds to every timed line from line from on. */ +TP_PRIVATE tp_edit tp_edit_shift_from(double seconds, int64_t from) { + tp_edit e = edit_of(TP_EDIT_OP_SHIFT); + int64_t *f = (int64_t *)tp_alloc(sizeof *f); + *f = from; + e.seconds = seconds; + e.from = f; + return e; +} + +/* ShiftLines adds seconds to the given lines only (Go append([]int{}, lines...): never nil). */ +TP_PRIVATE tp_edit tp_edit_shift_lines(double seconds, const int64_t *lines, size_t count) { + tp_edit e = edit_of(TP_EDIT_OP_SHIFT); + size_t i; + e.seconds = seconds; + e.has_lines = true; + for (i = 0; i < count; i++) tp_push(e.lines, lines[i]); + return e; +} + +/* SortByTime sorts the timed lines stably, each with the untimed lines after it (R13.9.4). */ +TP_PRIVATE tp_edit tp_edit_sort_by_time(void) { return edit_of(TP_EDIT_OP_SORT_BY_TIME); } + +/* SetRest replaces everything after the time and gap of line. */ +TP_PRIVATE tp_edit tp_edit_set_rest(int64_t line, tp_str rest) { + tp_edit e = edit_of(TP_EDIT_OP_SET_REST); + e.line = line; + e.rest = rest; + return e; +} + +/* Insert inserts text as a new line after line after (0: at the start). */ +TP_PRIVATE tp_edit tp_edit_insert(int64_t after, tp_str text) { + tp_edit e = edit_of(TP_EDIT_OP_INSERT); + e.after = after; + e.text = text; + return e; +} + +/* Delete removes line. */ +TP_PRIVATE tp_edit tp_edit_delete(int64_t line) { + tp_edit e = edit_of(TP_EDIT_OP_DELETE); + e.line = line; + return e; +} + +/* -------------------------------------------------------------------------------------------- */ +/* Resolved forms */ + +/* modeByName is a mode for one of the four names of a parsed mode. */ +TP_PRIVATE bool tp_mode_by_name(tp_str name, tp_mode *out) { + if (tp_str_eq(name, TP_MODE_CLEAN) || tp_str_eq(name, TP_MODE_YOUTUBE) || + tp_str_eq(name, TP_MODE_FILENAME) || tp_str_eq(name, TP_MODE_TRACKLIST)) { + *out = name; + return true; + } + return false; +} + +static tp_requested_mode request(tp_request_kind kind, tp_mode mode) { + tp_requested_mode r; + r.kind = kind; + r.mode = mode; + return r; +} + +/* requestFor is the R2 request for a mode name given as a string. */ +TP_PRIVATE tp_requested_mode tp_request_for(tp_str name) { + tp_mode m; + if (tp_str_eq(name, TP_S("auto"))) return request(TP_REQUEST_AUTO, TP_EMPTY); + if (tp_mode_by_name(name, &m)) return request(TP_REQUEST_MODE, m); + return request(TP_REQUEST_OTHER, TP_EMPTY); +} + +/* parseSplitAnd is options.splitAnd of a parse: anything but auto and never (or missing) + * behaves as always in JS. */ +TP_PRIVATE tp_split_and_mode tp_parse_split_and(tp_str name) { + if (tp_str_eq(name, TP_S("auto"))) return TP_SPLIT_AUTO; + if (tp_str_eq(name, TP_S("never"))) return TP_SPLIT_NEVER; + return TP_SPLIT_ALWAYS; +} + +/* tracklistSplitAnd is options.splitAnd of a tracklist: only always and never count. */ +TP_PRIVATE tp_split_and_mode tp_tracklist_split_and(tp_str name) { + if (tp_str_eq(name, TP_S("always"))) return TP_SPLIT_ALWAYS; + if (tp_str_eq(name, TP_S("never"))) return TP_SPLIT_NEVER; + return TP_SPLIT_AUTO; +} + +/* tracklistRequest is options.mode of a tracklist: a mode name or auto; anything else means + * tracklist. */ +TP_PRIVATE tp_requested_mode tp_tracklist_request(tp_str name) { + tp_mode m; + if (tp_str_eq(name, TP_S("auto"))) return request(TP_REQUEST_AUTO, TP_EMPTY); + if (tp_mode_by_name(name, &m)) return request(TP_REQUEST_MODE, m); + return request(TP_REQUEST_MODE, TP_MODE_TRACKLIST); +} + +/* arrayIndex reports whether key is a canonical array index ("0", "17"; not "01"), which JS + * lists first among an object's keys, in ascending order. */ +TP_PRIVATE bool tp_array_index(tp_str key, uint64_t *out) { + uint64_t n = 0; + size_t i; + if (key.n == 0 || key.n > 10) return false; + if (key.n > 1 && key.p[0] == '0') return false; + for (i = 0; i < key.n; i++) { + unsigned char c = (unsigned char)key.p[i]; + if (c < '0' || c > '9') return false; + n = n * 10 + (uint64_t)(c - '0'); + } + if (n > 0xfffffffeu) return false; + *out = n; + return true; +} + +typedef struct indexed_kv { + uint64_t n; + tp_kv p; +} indexed_kv; +typedef TP_VEC(indexed_kv) indexed_kv_vec; + +static int by_index(const void *a, const void *b, void *ctx) { + uint64_t x = ((const indexed_kv *)a)->n, y = ((const indexed_kv *)b)->n; + (void)ctx; + return x < y ? -1 : x > y ? 1 : 0; +} + +/* jsEntries is the Object.entries order of an object built from pairs: a repeated key keeps its + * first place and takes the last value; integer-like keys come first in ascending order, then + * the others in insertion order. Go sorts the (unique) integer keys by insertion; a stable sort + * gives the same order. */ +TP_PRIVATE tp_kv_vec tp_js_entries(tp_kv_vec pairs) { + tp_kv_vec unique = {0, 0, 0}, rest = {0, 0, 0}, out = {0, 0, 0}; + indexed_kv_vec ints = {0, 0, 0}; + tp_map index; + size_t i; + memset(&index, 0, sizeof index); + for (i = 0; i < pairs.n; i++) { + int64_t at; + if (tp_map_get(&index, pairs.p[i].key, &at)) { + unique.p[at].value = pairs.p[i].value; + continue; + } + tp_map_put(&index, pairs.p[i].key, (int64_t)unique.n); + tp_push(unique, pairs.p[i]); + } + for (i = 0; i < unique.n; i++) { + uint64_t n; + if (tp_array_index(unique.p[i].key, &n)) { + indexed_kv x; + x.n = n; + x.p = unique.p[i]; + tp_push(ints, x); + } else { + tp_push(rest, unique.p[i]); + } + } + if (ints.n > 1) tp_sort_stable(ints.p, ints.n, sizeof *ints.p, by_index, NULL); + for (i = 0; i < ints.n; i++) tp_push(out, ints.p[i].p); + tp_append(out, rest); + return out; +} + +/* sanitizeAll is tp_sanitize over a list (a fresh vector, never the caller's). */ +TP_PRIVATE tp_strvec tp_sanitize_all(tp_strvec list) { + tp_strvec out = {0, 0, 0}; + size_t i; + if (list.n == 0) return out; + out.p = (tp_str *)tp_alloc_array(list.n, sizeof *out.p); + out.n = out.cap = list.n; + for (i = 0; i < list.n; i++) out.p[i] = tp_sanitize(list.p[i]); + return out; +} + +static tp_kv kv_of(tp_str key, tp_str value) { + tp_kv p; + p.key = key; + p.value = value; + return p; +} + +/* resolveKeywords is the typed keywords; NULL when they add nothing. */ +TP_PRIVATE const tp_keyword_lists *tp_resolve_keywords(const tp_keywords *k) { + tp_kv_vec heads = {0, 0, 0}, junk = {0, 0, 0}; + tp_keyword_lists *out; + size_t i; + if (tp_keywords_is_empty(k)) return NULL; + for (i = 0; i < k->version_heads.n; i++) { + const tp_version_head *h = &k->version_heads.p[i]; + tp_push(heads, kv_of(tp_sanitize(h->key), tp_sanitize(h->type))); + } + for (i = 0; i < k->junk.n; i++) { + const tp_junk_phrase *j = &k->junk.p[i]; + tp_push(junk, kv_of(tp_sanitize(j->phrase), tp_sanitize(j->kind))); + } + out = (tp_keyword_lists *)tp_alloc(sizeof *out); + out->version_heads = tp_js_entries(heads); + out->descriptors = tp_sanitize_all(k->descriptors); + out->genres = tp_sanitize_all(k->genres); + out->junk = tp_js_entries(junk); + out->feat_markers = tp_sanitize_all(k->feat_markers); + return out; +} + +/* resolveParse is the typed door to resolvedOptions. o NULL is the zero value. */ +TP_PRIVATE tp_resolved_options tp_resolve_parse(const tp_parse_options *o) { + tp_resolved_options r; + memset(&r, 0, sizeof r); + r.uploader = TP_EMPTY; + if (o == NULL) return r; + r.uploader = tp_sanitize(o->uploader); + r.known_artists = tp_sanitize_all(o->known_artists); + r.keywords = tp_resolve_keywords(&o->keywords); + if (o->mode.n != 0) r.mode = tp_request_for(o->mode); + if (o->split_and.n != 0) r.split_and = tp_parse_split_and(o->split_and); + return r; +} + +/* resolveFormat is the typed door to resolvedFormat. o NULL is the zero value. */ +TP_PRIVATE tp_resolved_format tp_resolve_format(const tp_format_options *o) { + tp_resolved_format r; + tp_str feat; + memset(&r, 0, sizeof r); + if (o == NULL) { + r.feat = TP_FEAT_MODE_SOURCE; + r.versions = true; + r.producers = true; + return r; + } + r.canonical = tp_str_eq(o->joiners, TP_JOINERS_CANONICAL); + r.versions = o->versions.n == 0 || tp_str_eq(o->versions, TP_VERSIONS_ALL); + r.producers = !o->omit_producers; + r.position = o->position; + feat = o->feat; + if (feat.n == 0 || tp_str_eq(feat, TP_FEAT_SOURCE)) { + r.feat = TP_FEAT_MODE_SOURCE; + } else if (tp_str_eq(feat, TP_FEAT_ARTIST)) { + r.feat = TP_FEAT_MODE_ARTIST; + } else if (tp_str_eq(feat, TP_FEAT_TITLE)) { + r.feat = TP_FEAT_MODE_TITLE; + } else { + r.feat = TP_FEAT_MODE_OMIT; + } + if (o->feat_marker != NULL) { + tp_str *m = (tp_str *)tp_alloc(sizeof *m); + *m = tp_sanitize(*o->feat_marker); + r.feat_marker = m; + } + return r; +} + +/* audio is the R13.10 audio length: NULL unless given, finite and not negative. */ +TP_PRIVATE const double *tp_audio(const double *seconds) { + double v, *out; + if (seconds == NULL) return NULL; + v = *seconds; + if (tp_is_nan(v) || tp_is_inf(v) || v < 0) return NULL; + out = (double *)tp_alloc(sizeof *out); + *out = v; + return out; +} + +/* resolveTracklist is the typed door to resolvedTracklist. o NULL is the zero value. */ +TP_PRIVATE tp_resolved_tracklist tp_resolve_tracklist(const tp_tracklist_options *o) { + tp_resolved_tracklist r; + memset(&r, 0, sizeof r); + r.parse.uploader = TP_EMPTY; + r.parse.mode = request(TP_REQUEST_MODE, TP_MODE_TRACKLIST); + if (o == NULL) { + r.parse.split_and = TP_SPLIT_AUTO; + return r; + } + r.parse.known_artists = tp_sanitize_all(o->known_artists); + r.parse.keywords = tp_resolve_keywords(&o->keywords); + r.audio_seconds = tp_audio(o->audio_seconds); + r.marker_words = tp_sanitize_all(o->marker_words); + if (o->mode.n != 0) r.parse.mode = tp_tracklist_request(o->mode); + r.parse.split_and = tp_tracklist_split_and(o->split_and); + return r; +} + +/* -------------------------------------------------------------------------------------------- */ +/* The JSON door (wire/): loose values with the JS fallbacks. */ + +/* stringList is an option list as JS reads it at run time (R0.8): only an array's strings + * count. */ +TP_PRIVATE tp_strvec tp_string_list(tp_json v, bool ok) { + tp_strvec out = {0, 0, 0}; + size_t i; + if (!ok || v.kind != TP_JSON_ARRAY) return out; + for (i = 0; i < v.arr_n; i++) { + if (v.arr[i].kind == TP_JSON_STRING) tp_push(out, v.arr[i].str); + } + return out; +} + +/* stringEntries is an option map as JS reads it at run time (R0.8): only a plain object's + * string values count, in Object.entries order. */ +TP_PRIVATE tp_kv_vec tp_string_entries(tp_json v, bool ok) { + tp_kv_vec pairs = {0, 0, 0}; + size_t i; + if (!ok || v.kind != TP_JSON_OBJECT) return pairs; + for (i = 0; i < v.obj_n; i++) { + const tp_json_member *m = &v.obj[i]; + if (m->val.kind == TP_JSON_STRING) tp_push(pairs, kv_of(m->key, m->val.str)); + } + /* The reader already merged repeated keys; jsEntries only reorders integer-like keys. */ + return tp_js_entries(pairs); +} + +/* Go v.get(key) as the (value, ok) pair the list readers take. */ +static tp_json get(tp_json v, const char *key, bool *ok) { + tp_json out = tp_json_null(); + *ok = tp_json_get(v, tp_str_c(key), &out); + return out; +} + +/* keywordsJSON is options.keywords from loose JSON (a plain object only). Never NULL, even when + * it adds nothing (Go returns a non-nil pointer: fresh tables). */ +TP_PRIVATE const tp_keyword_lists *tp_keywords_json(tp_json v) { + tp_keyword_lists *k = (tp_keyword_lists *)tp_alloc(sizeof *k); + tp_json x; + bool ok; + x = get(v, "versionHeads", &ok); + k->version_heads = tp_string_entries(x, ok); + x = get(v, "descriptors", &ok); + k->descriptors = tp_string_list(x, ok); + x = get(v, "genres", &ok); + k->genres = tp_string_list(x, ok); + x = get(v, "junk", &ok); + k->junk = tp_string_entries(x, ok); + x = get(v, "featMarkers", &ok); + k->feat_markers = tp_string_list(x, ok); + return k; +} + +/* resolveParseJSON is the JSON door to resolvedOptions, with the JS fallbacks. */ +TP_PRIVATE tp_resolved_options tp_resolve_parse_json(tp_json o) { + tp_resolved_options r; + tp_json m; + bool ok; + memset(&r, 0, sizeof r); + r.uploader = TP_EMPTY; + if (o.kind != TP_JSON_OBJECT) return r; /* safeOptions: not an object */ + /* `options.mode ?? "auto"` */ + if (tp_json_get(o, TP_S("mode"), &m) && m.kind != TP_JSON_NULL) { + if (m.kind == TP_JSON_STRING) { + r.mode = tp_request_for(m.str); + } else { + r.mode = request(TP_REQUEST_OTHER, TP_EMPTY); + } + } + /* `options.splitAnd ?? "auto"` */ + if (tp_json_get(o, TP_S("splitAnd"), &m) && m.kind != TP_JSON_NULL) { + if (m.kind == TP_JSON_STRING) { + r.split_and = tp_parse_split_and(m.str); + } else { + r.split_and = TP_SPLIT_ALWAYS; + } + } + /* `options.keywords ? ... : baseTables`, then isRecord: only a plain object adds words. */ + if (tp_json_get(o, TP_S("keywords"), &m) && m.kind == TP_JSON_OBJECT) { + r.keywords = tp_keywords_json(m); + } + if (tp_json_get(o, TP_S("uploader"), &m) && m.kind == TP_JSON_STRING) r.uploader = m.str; + m = get(o, "knownArtists", &ok); + r.known_artists = tp_string_list(m, ok); + return r; +} + +/* truthy is JS truthiness of a JSON value. */ +TP_PRIVATE bool tp_truthy(tp_json v) { + switch (v.kind) { + case TP_JSON_NULL: + return false; + case TP_JSON_BOOL: + return v.b; + case TP_JSON_NUMBER: + return v.num != 0 && !tp_is_nan(v.num); + case TP_JSON_STRING: + return v.str.n != 0; + default: + return true; + } +} + +/* jsString into a builder. Recursive over nested arrays only; the depth is bounded by the + * reader's TP_JSON_MAX_DEPTH. */ +static void js_string_to(tp_buf *b, tp_json v) { + size_t i; + switch (v.kind) { + case TP_JSON_NULL: + tp_buf_cstr(b, "null"); + return; + case TP_JSON_BOOL: + tp_buf_cstr(b, v.b ? "true" : "false"); + return; + case TP_JSON_NUMBER: + /* Number#toString: NaN, Infinity and -Infinity included. */ + tp_buf_number(b, v.num); + return; + case TP_JSON_STRING: + tp_buf_str(b, v.str); + return; + case TP_JSON_ARRAY: + /* Array.prototype.join: null elements are empty. */ + for (i = 0; i < v.arr_n; i++) { + if (i > 0) tp_buf_byte(b, ','); + if (v.arr[i].kind != TP_JSON_NULL) js_string_to(b, v.arr[i]); + } + return; + default: + tp_buf_cstr(b, "[object Object]"); + return; + } +} + +/* jsString is JS String(value), what a template literal does with a non-string featMarker. */ +TP_PRIVATE tp_str tp_js_string(tp_json v) { + tp_buf b; + if (v.kind == TP_JSON_STRING) return v.str; + memset(&b, 0, sizeof b); + js_string_to(&b, v); + return tp_buf_done(&b); +} + +/* The Go closure get of resolveFormatJSON: the value at key, missing and null alike false + * (`??`). */ +static bool get_set(tp_json o, const char *key, tp_json *out) { + tp_json v; + if (!tp_json_get(o, tp_str_c(key), &v) || v.kind == TP_JSON_NULL) return false; + *out = v; + return true; +} + +static bool is_string(tp_json v, const char *s) { + return v.kind == TP_JSON_STRING && tp_str_eq_c(v.str, s); +} + +/* resolveFormatJSON is the JSON door to resolvedFormat (`??` for missing and null). */ +TP_PRIVATE tp_resolved_format tp_resolve_format_json(tp_json o) { + tp_resolved_format r; + tp_json v; + memset(&r, 0, sizeof r); + r.feat = TP_FEAT_MODE_SOURCE; + r.versions = true; + r.producers = true; + if (get_set(o, "feat", &v)) { + if (is_string(v, "source")) { + r.feat = TP_FEAT_MODE_SOURCE; + } else if (is_string(v, "artist")) { + r.feat = TP_FEAT_MODE_ARTIST; + } else if (is_string(v, "title")) { + r.feat = TP_FEAT_MODE_TITLE; + } else { + r.feat = TP_FEAT_MODE_OMIT; + } + } + /* `o.featMarker !== undefined`: an explicit null is rendered as "null". */ + if (tp_json_get(o, TP_S("featMarker"), &v)) { + tp_str *m = (tp_str *)tp_alloc(sizeof *m); + *m = tp_js_string(v); + r.feat_marker = m; + } + if (get_set(o, "joiners", &v)) r.canonical = is_string(v, "canonical"); + if (get_set(o, "versions", &v)) r.versions = is_string(v, "all"); + if (get_set(o, "producers", &v)) r.producers = tp_truthy(v); + if (get_set(o, "position", &v)) r.position = tp_truthy(v); + return r; +} + +/* jsNumber is a JS number view of a JSON value: true only for a number (a bool is not one). The + * value may be NaN or infinite; callers apply their own checks. */ +TP_PRIVATE bool tp_js_number(tp_json v, bool present, double *out) { + if (!present || v.kind != TP_JSON_NUMBER) return false; + *out = v.num; + return true; +} + +/* resolveTracklistJSON is the JSON door to resolvedTracklist. mode, splitAnd, knownArtists and + * keywords are passed on only when well-formed; uploader is not a tracklist option. */ +TP_PRIVATE tp_resolved_tracklist tp_resolve_tracklist_json(tp_json o) { + tp_resolved_tracklist r; + tp_json m; + bool ok; + double n; + memset(&r, 0, sizeof r); + r.parse = tp_resolve_parse_json(o); + r.parse.uploader = TP_EMPTY; + r.parse.mode = request(TP_REQUEST_MODE, TP_MODE_TRACKLIST); + if (tp_json_get(o, TP_S("mode"), &m) && m.kind == TP_JSON_STRING) { + r.parse.mode = tp_tracklist_request(m.str); + } + r.parse.split_and = TP_SPLIT_AUTO; + if (tp_json_get(o, TP_S("splitAnd"), &m) && m.kind == TP_JSON_STRING) { + r.parse.split_and = tp_tracklist_split_and(m.str); + } + m = get(o, "audioSeconds", &ok); + if (tp_js_number(m, ok, &n)) r.audio_seconds = tp_audio(&n); + m = get(o, "markerWords", &ok); + r.marker_words = tp_string_list(m, ok); + return r; +} diff --git a/c/src/parser.c b/c/src/parser.c new file mode 100644 index 0000000..d2016ea --- /dev/null +++ b/c/src/parser.c @@ -0,0 +1,224 @@ +/* parser.c: the pipeline R1, R2, R4, R3/R6, R7, R8, R9, plus R10 runArtists (go/parser.go, + * js/src/parser.ts). The engine itself (options, tables, known keys) is in context.c. */ +#include "internal.h" + +/* skelOf scans a piece and trims it, warning on unbalanced brackets (R3.3). */ +TP_PRIVATE tp_skel tp_skel_of(tp_piece p, tp_ctx *c) { + bool unbalanced; + tp_skel sk = tp_scan(p.text, p.base, &unbalanced); + if (unbalanced) tp_ctx_warn(c, TP_WARNING_UNBALANCED_BRACKETS); + return tp_trim_skel(&sk); +} + +/* uploaderSkel is R6.8: the uploader minus a trailing " - Topic" and "VEVO", or NULL. */ +TP_PRIVATE const tp_skel *tp_uploader_skel(tp_str uploader) { + if (uploader.n == 0) return NULL; + tp_str u = tp_normalize(uploader); + if (tp_has_suffix(u, TP_S(" - Topic"))) u = tp_trim_suffix(u, TP_S(" - Topic")); + if (tp_has_suffix(u, TP_S("VEVO"))) u = tp_js_trim_end(tp_trim_suffix(u, TP_S("VEVO"))); + if (u.n == 0) return NULL; + bool unbalanced; + tp_skel *sk = tp_alloc(sizeof *sk); + *sk = tp_scan(tp_runes_of(u), TP_UPLOADER_BASE, &unbalanced); + return sk; +} + +/* emptyTrack is the R9.5 result for an input that is empty after R1, and the start of every + * other result. (Empty vectors are written as [] whatever their pointer.) */ +TP_PRIVATE tp_track tp_empty_track(tp_str input, tp_mode mode) { + tp_track t; + memset(&t, 0, sizeof t); + t.input = input; + t.mode = mode; + return t; +} + +/* stage runs R1, R2 and R4. */ +TP_PRIVATE tp_staged tp_engine_stage(const tp_engine *e, tp_str input) { + tp_staged st; + memset(&st, 0, sizeof st); + tp_ctx *c = tp_engine_new_ctx(e); + tp_str norm = tp_normalize(input); + tp_prelude_result pre = tp_prelude(norm, e->opts.mode, c); + tp_track track = tp_empty_track(input, pre.mode); + st.e = e; + st.c = c; + st.pre = pre; + if (norm.n == 0) { /* R9.5 */ + st.track = track; + return st; + } + + /* R4 */ + tp_prefix_result prefix = tp_strip_prefixes(pre.working.text, pre.working.base, pre.mode, c); + track.timestamp = prefix.timestamp; + track.position = prefix.position; + tp_piece p; + p.text = prefix.rest; + p.base = prefix.base; + tp_skel *working = tp_alloc(sizeof *working); + *working = tp_skel_of(p, c); + st.track = track; + st.working = working; + return st; +} + +/* run is R1 to R9 on one (already sanitized) input; list_context is the R13.4.2 flag that only + * matters in tracklist mode (R6.10). */ +TP_PRIVATE tp_track tp_engine_run(const tp_engine *e, tp_str input, bool list_context) { + return tp_finish(tp_engine_stage(e, input), list_context); +} + +/* runArtists is R10 on one (already sanitized) input. */ +TP_PRIVATE tp_artist_vec tp_engine_run_artists(const tp_engine *e, tp_str input) { + tp_ctx *c = tp_engine_new_ctx(e); + tp_str norm = tp_normalize(input); + tp_artist_vec none = {0}; + if (norm.n == 0) return none; + bool unbalanced; + tp_skel sk = tp_scan(tp_runes_of(norm), 0, &unbalanced); + tp_artist_side_result side = tp_parse_artist_side(&sk, c); + tp_artist_vec artists = tp_dedup_artists(side.credits); + for (size_t i = 0; i < artists.n; i++) artists.p[i].source = TP_SOURCE_ARTIST; + return artists; +} + +/* probe is R1, R2 and R4 only, as run does them: no artist or title parsing. finish completes + * the parse from the same stage, so a probed line is not normalized twice. */ +TP_PRIVATE tp_line_probe tp_engine_probe(const tp_engine *e, tp_str input) { + tp_staged st = tp_engine_stage(e, input); + tp_line_probe p; + p.position = st.track.position != NULL; + p.spaced_dash = st.pre.pipe_title == NULL && st.working != NULL && + tp_split_at_spaced_dashes(st.working, true).n >= 2; + p.empty = st.working == NULL; + p.staged = st; + return p; +} + +/* finish is the parse of the probed input (R6 to R9 only). Call it once per probe: the probe's + * per-call state (warnings) is consumed. */ +TP_PRIVATE tp_track tp_line_probe_finish(tp_line_probe *p, bool list_context) { + return tp_finish(p->staged, list_context); +} + +/* byPos sorts items by offset, stably (like the JS sort). Go cmp.Compare on ints. */ +static int cmp_pos(ptrdiff_t a, ptrdiff_t b) { return (a > b) - (a < b); } + +static int cmp_version(const void *a, const void *b, void *ctx) { + (void)ctx; + return cmp_pos(((const tp_version_draft *)a)->pos, ((const tp_version_draft *)b)->pos); +} +static int cmp_credit(const void *a, const void *b, void *ctx) { + (void)ctx; + return cmp_pos(((const tp_credit *)a)->pos, ((const tp_credit *)b)->pos); +} +static int cmp_year(const void *a, const void *b, void *ctx) { + (void)ctx; + return cmp_pos(((const tp_positioned_year *)a)->pos, ((const tp_positioned_year *)b)->pos); +} +static int cmp_junk(const void *a, const void *b, void *ctx) { + (void)ctx; + return cmp_pos(((const tp_positioned_junk *)a)->pos, ((const tp_positioned_junk *)b)->pos); +} + +TP_PRIVATE tp_version_draft_vec tp_by_pos_versions(tp_version_draft_vec items) { + if (items.n > 1) tp_sort_stable(items.p, items.n, sizeof *items.p, cmp_version, NULL); + return items; +} +TP_PRIVATE tp_credit_vec tp_by_pos_credits(tp_credit_vec items) { + if (items.n > 1) tp_sort_stable(items.p, items.n, sizeof *items.p, cmp_credit, NULL); + return items; +} +TP_PRIVATE tp_positioned_year_vec tp_by_pos_years(tp_positioned_year_vec items) { + if (items.n > 1) tp_sort_stable(items.p, items.n, sizeof *items.p, cmp_year, NULL); + return items; +} +TP_PRIVATE tp_positioned_junk_vec tp_by_pos_junk(tp_positioned_junk_vec items) { + if (items.n > 1) tp_sort_stable(items.p, items.n, sizeof *items.p, cmp_junk, NULL); + return items; +} + +/* finish is R6 to R9 on a staged input. */ +TP_PRIVATE tp_track tp_finish(tp_staged st, bool list_context) { + tp_ctx *c = st.c; + tp_prelude_result pre = st.pre; + tp_track track = st.track; + if (st.working == NULL) return track; + tp_skel working = *st.working; + + tp_extracted out; + memset(&out, 0, sizeof out); + const tp_skel *artist_skel = NULL; + tp_skel title_skel; + bool relaxed; + if (pre.pipe_title != NULL) { + /* R2.4 step 3: "artist | title", R6 skipped. */ + title_skel = tp_skel_of(*pre.pipe_title, c); + if (!tp_skel_is_empty(&working)) artist_skel = st.working; + relaxed = artist_skel != NULL; + } else { + tp_separator_input in; + in.skel = working; + in.mode = pre.mode; + in.uploader = tp_uploader_skel(st.e->opts.uploader); + in.list_context = list_context; + tp_separator_result sep = tp_find_separator(in, c); + tp_add_peeled(&out, sep.peeled); + artist_skel = sep.artist; + title_skel = sep.title; + relaxed = sep.split; + } + + tp_artist_side_result artist_side; + memset(&artist_side, 0, sizeof artist_side); + if (artist_skel != NULL) artist_side = tp_parse_artist_side(artist_skel, c); + tp_title_side_result title_side = + tp_parse_title_side(title_skel, relaxed, tp_str_eq(pre.mode, TP_MODE_YOUTUBE), &out, c); + + /* R9 */ + tp_version_draft_vec versions = tp_by_pos_versions(out.versions); + for (size_t i = 0; i < versions.n; i++) { + if (versions.p[i].ambiguous_mix) { + tp_ctx_warn(c, TP_WARNING_AMBIGUOUS_MIX_CREDIT); + break; + } + } + tp_credit_vec credits = {0}; + tp_append(credits, artist_side.credits); + tp_credit_vec title_credits = tp_by_pos_credits(out.credits); + tp_append(credits, title_credits); + track.artists = tp_dedup_artists(credits); + track.title = title_side.title; + memset(&track.versions, 0, sizeof track.versions); + for (size_t i = 0; i < versions.n; i++) tp_push(track.versions, tp_to_version(versions.p[i])); + track.full_title = tp_full_title_of(track.title, track.versions); + /* R9.6: the first year in text order. */ + tp_positioned_year_vec years = {0}; + tp_append(years, artist_side.years); + tp_append(years, out.years); + years = tp_by_pos_years(years); + if (years.n > 0) { + ptrdiff_t *y = tp_alloc(sizeof *y); + *y = years.p[0].year; + track.year = y; + } + track.flags.explicit_ = out.explicit_ || artist_side.explicit_; + track.flags.clean = out.clean || artist_side.clean; + track.flags.unknown_artist = artist_side.unknown_artist || out.unknown_artist; + track.flags.unknown_title = title_side.unknown_title; + tp_positioned_junk_vec junk = {0}; + tp_append(junk, pre.junk); + tp_append(junk, artist_side.junk); + tp_append(junk, out.junk); + junk = tp_by_pos_junk(junk); + memset(&track.junk, 0, sizeof track.junk); + for (size_t i = 0; i < junk.n; i++) { + tp_junk j; + j.raw = junk.p[i].raw; + j.kind = junk.p[i].kind; + tp_push(track.junk, j); + } + tp_clone(track.warnings, c->warnings); + return track; +} diff --git a/c/src/prefix.c b/c/src/prefix.c new file mode 100644 index 0000000..a7ae21b --- /dev/null +++ b/c/src/prefix.c @@ -0,0 +1,150 @@ +/* prefix.c: R4 leading timestamp and track-position prefixes (go/prefix.go, js/src/prefix.ts). */ +#include "internal.h" + +/* matchTime is H:MM:SS, HH:MM:SS, M:SS or MM:SS starting at from (R4.1). */ +TP_PRIVATE bool tp_match_time(tp_runes s, ptrdiff_t from, tp_time_match *out) { + ptrdiff_t lead = tp_digit_run(s, from); + if (lead < 1 || lead > 2 || tp_at(s, from + lead) != ':') return false; + ptrdiff_t first = (ptrdiff_t)tp_digits_value(tp_sub(s, from, from + lead)); + int mid; + if (!tp_two_digits_up_to_59(s, from + lead + 1, &mid)) return false; + ptrdiff_t after_mid = from + lead + 3; + if (tp_at(s, after_mid) == ':') { + int sec; + if (tp_two_digits_up_to_59(s, after_mid + 1, &sec)) { + ptrdiff_t end = after_mid + 3; + out->raw = tp_runes_str(tp_sub(s, from, end)); + out->seconds = first * 3600 + (ptrdiff_t)mid * 60 + (ptrdiff_t)sec; + out->end = end; + return true; + } + } + if (lead == 2 && first > 59) return false; /* MM is 00-59 */ + out->raw = tp_runes_str(tp_sub(s, from, after_mid)); + out->seconds = first * 60 + (ptrdiff_t)mid; + out->end = after_mid; + return true; +} + +/* skipSpaceAndDash skips, after a prefix, one space and then an optional "- " (spaced dash). */ +TP_PRIVATE ptrdiff_t tp_skip_space_and_dash(tp_runes s, ptrdiff_t from) { + ptrdiff_t i = from; + if (tp_at(s, i) == ' ') i++; + if (tp_at(s, i) == '-' && tp_at(s, i + 1) == ' ') i += 2; + return i; +} + +/* matchTimestamp is R4.1: the timestamp and the index where the rest starts. */ +TP_PRIVATE bool tp_match_timestamp(tp_runes s, tp_timestamp *ts, ptrdiff_t *rest) { + tp_rune closer = TP_NORUNE; + switch (tp_at(s, 0)) { + case '[': + closer = ']'; + break; + case '(': + closer = ')'; + break; + default: + break; + } + ptrdiff_t from = closer != TP_NORUNE ? 1 : 0; + tp_time_match t; + if (!tp_match_time(s, from, &t)) return false; + ptrdiff_t end = t.end; + if (closer != TP_NORUNE) { + if (tp_at(s, end) != closer) return false; + end++; + } + if (end < (ptrdiff_t)s.n && tp_at(s, end) != ' ') return false; + ts->raw = t.raw; + ts->seconds = t.seconds; + *rest = tp_skip_space_and_dash(s, end); + return true; +} + +/* containsSpacedDash reports whether the skeleton of s has a spaced dash. */ +TP_PRIVATE bool tp_contains_spaced_dash(tp_runes s) { + bool unbalanced; + tp_skel sk = tp_scan(s, 0, &unbalanced); + return tp_has_spaced_dash(sk.text); +} + +/* matchPosition is R4.2: the end index of the position prefix. Forms are tried (a), (b), (c), + * then (d) and (e). */ +TP_PRIVATE bool tp_match_position(tp_runes s, tp_mode mode, ptrdiff_t *end) { + ptrdiff_t n = tp_digit_run(s, 0); + if (n < 1 || n > 3) return false; + tp_rune c = tp_at(s, n); + bool zero_padded = tp_at(s, 0) == '0' && n >= 2; + bool filename = tp_str_eq(mode, TP_MODE_FILENAME); + /* (a) "01. ", "1) " */ + if ((c == '.' || c == ')') && (tp_at(s, n + 1) == ' ' || n + 1 == (ptrdiff_t)s.n)) { + *end = tp_skip_space_and_dash(s, n + 1); + return true; + } + /* (b) "01 ": a position in every mode. */ + if (zero_padded && c == ' ') { + *end = tp_skip_space_and_dash(s, n); + return true; + } + /* (c) "3 - Artist - Title"; in filename mode "N - " is always a position ("311 - Amber.mp3"). */ + if (c == ' ' && tp_at(s, n + 1) == '-' && tp_at(s, n + 2) == ' ') { + if (filename || tp_contains_spaced_dash(tp_tail(s, n + 3))) { + *end = n + 3; + return true; + } + return false; + } + if (filename) { + /* (e) "01-Track", "03_name", "01.Track" */ + if ((c == '-' || c == '_' || c == '.') && tp_at(s, n + 1) != TP_NORUNE && + tp_at(s, n + 1) != ' ') { + *end = n + 1; + return true; + } + /* (e) "3 My Song.mp3": only when the remainder has no spaced dash. */ + if (c == ' ' && !tp_contains_spaced_dash(tp_tail(s, n + 1))) { + *end = tp_skip_space_and_dash(s, n); + return true; + } + } + /* (d) "2 Unlimited", "50 Cent": never a position outside filename mode. */ + return false; +} + +/* stripPrefixes is R4 on text, whose first code point sits at absolute offset base. */ +TP_PRIVATE tp_prefix_result tp_strip_prefixes(tp_runes text, ptrdiff_t base, tp_mode mode, + tp_ctx *c) { + tp_runes rest = text; + ptrdiff_t offset = base; + const tp_timestamp *timestamp = NULL; + const tp_position *position = NULL; + + tp_timestamp ts; + ptrdiff_t end; + if (tp_match_timestamp(rest, &ts, &end)) { + tp_timestamp *p = tp_alloc(sizeof *p); + *p = ts; + timestamp = p; + offset += tp_utf16_len(tp_sub(rest, 0, end)); + rest = tp_tail(rest, end); + } + /* R7.3a: a known artist that starts with digits is not a position. */ + if (tp_match_known_at(rest, 0, c, '-') == 0) { + if (tp_match_position(rest, mode, &end) && end < (ptrdiff_t)rest.n) { + tp_runes digits = tp_sub(rest, 0, tp_digit_run(rest, 0)); + tp_position *p = tp_alloc(sizeof *p); + p->raw = tp_runes_str(digits); + p->number = (ptrdiff_t)tp_digits_value(digits); + position = p; + offset += tp_utf16_len(tp_sub(rest, 0, end)); + rest = tp_tail(rest, end); + } + } + tp_prefix_result r; + r.rest = rest; + r.base = offset; + r.timestamp = timestamp; + r.position = position; + return r; +} diff --git a/c/src/rt.c b/c/src/rt.c new file mode 100644 index 0000000..0235ff2 --- /dev/null +++ b/c/src/rt.c @@ -0,0 +1,1002 @@ +/* rt.c: the runtime declared in rt.h (allocator hook, arenas, scopes, once, strings, runes, + * vectors, byte builders, the string map, the stable sort and the tp_json helpers). + * Numbers live in num.c. */ +#include "rt.h" + +#include + +#if defined(_WIN32) +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#ifndef NOMINMAX +#define NOMINMAX +#endif +#include +#else +#include +#endif + +/* -------------------------------------------------------------------------------------------- */ +/* Allocator hook */ + +static tp_allocator rt_allocator; /* zero: malloc/free */ + +TP_PRIVATE void tp_set_allocator(const tp_allocator *a) { + if (a == NULL || a->malloc_fn == NULL || a->free_fn == NULL) { + memset(&rt_allocator, 0, sizeof rt_allocator); + } else { + rt_allocator = *a; + } +} + +TP_PRIVATE void *tp_sys_malloc(size_t size) { + if (size == 0) size = 1; + if (rt_allocator.malloc_fn != NULL) return rt_allocator.malloc_fn(size, rt_allocator.user); + return malloc(size); +} + +TP_PRIVATE void tp_sys_free(void *ptr) { + if (ptr == NULL) return; + if (rt_allocator.free_fn != NULL) { + rt_allocator.free_fn(ptr, rt_allocator.user); + } else { + free(ptr); + } +} + +/* -------------------------------------------------------------------------------------------- */ +/* Arenas */ + +/* A chunk: this header, then the data (TP_ALIGN-aligned). */ +typedef struct tp_chunk { + struct tp_chunk *next; + size_t cap; /* data bytes */ + size_t used; /* end of the last allocation (not rounded up, so tp_realloc can test it exactly) */ + size_t pad_; +} tp_chunk; + +#define TP_CHUNK_HDR ((sizeof(tp_chunk) + TP_ALIGN - 1) / TP_ALIGN * TP_ALIGN) +#define TP_CHUNK_FIRST ((size_t)64 * 1024) +#define TP_CHUNK_MAX ((size_t)8 * 1024 * 1024) + +struct tp_arena { + tp_chunk *head; /* the chunk small allocations come from; others follow */ + size_t next_size; /* data size of the next regular chunk */ + size_t bytes; /* taken from the system allocator, this struct included */ +}; + +static TP_TLS tp_arena *rt_cur; +static TP_TLS jmp_buf *rt_jmp; + +static unsigned char *rt_chunk_data(tp_chunk *c) { return (unsigned char *)c + TP_CHUNK_HDR; } + +TP_PRIVATE tp_arena *tp_arena_new(void) { + tp_arena *a = (tp_arena *)tp_sys_malloc(sizeof *a); + if (a == NULL) return NULL; + a->head = NULL; + a->next_size = TP_CHUNK_FIRST; + a->bytes = sizeof *a; + return a; +} + +TP_PRIVATE void tp_arena_free(tp_arena *a) { + tp_chunk *c; + if (a == NULL) return; + c = a->head; + while (c != NULL) { + tp_chunk *next = c->next; + tp_sys_free(c); + c = next; + } + if (rt_cur == a) rt_cur = NULL; + tp_sys_free(a); +} + +TP_PRIVATE size_t tp_arena_bytes(const tp_arena *a) { return a == NULL ? 0 : a->bytes; } + +TP_PRIVATE TP_NORETURN void tp_oom(void) { + if (rt_jmp != NULL) longjmp(*rt_jmp, 1); + abort(); /* tp_alloc outside an armed scope: a bug in the caller */ +} + +TP_PRIVATE size_t tp_size_add(size_t a, size_t b) { + if (a > SIZE_MAX - b) tp_oom(); + return a + b; +} + +TP_PRIVATE size_t tp_size_mul(size_t a, size_t b) { + if (a != 0 && b > SIZE_MAX / a) tp_oom(); + return a * b; +} + +static size_t rt_align_up(size_t n) { return tp_size_add(n, TP_ALIGN - 1) / TP_ALIGN * TP_ALIGN; } + +static tp_chunk *rt_chunk_new(tp_arena *a, size_t data) { + tp_chunk *c = (tp_chunk *)tp_sys_malloc(tp_size_add(TP_CHUNK_HDR, data)); + if (c == NULL) tp_oom(); + c->next = NULL; + c->cap = data; + c->used = 0; + a->bytes += TP_CHUNK_HDR + data; + return c; +} + +/* n bytes (not zeroed) from arena a. */ +static void *rt_arena_take(tp_arena *a, size_t n) { + tp_chunk *c = a->head; + size_t at; + if (c != NULL) { + at = rt_align_up(c->used); + if (at <= c->cap && c->cap - at >= n) { + c->used = at + n; + return rt_chunk_data(c) + at; + } + } + if (n > a->next_size / 4) { + /* A large block gets its own chunk, kept behind the head so the head keeps serving. */ + tp_chunk *big = rt_chunk_new(a, rt_align_up(n)); + big->used = n; + if (c == NULL) { + a->head = big; + } else { + big->next = c->next; + c->next = big; + } + return rt_chunk_data(big); + } + c = rt_chunk_new(a, a->next_size); + if (a->next_size < TP_CHUNK_MAX) a->next_size *= 2; + c->next = a->head; + a->head = c; + c->used = n; + return rt_chunk_data(c); +} + +TP_PRIVATE void *tp_alloc(size_t n) { + void *p; + if (rt_cur == NULL) tp_oom(); + p = rt_arena_take(rt_cur, n); + memset(p, 0, n); + return p; +} + +TP_PRIVATE void *tp_alloc_array(size_t n, size_t size) { return tp_alloc(tp_size_mul(n, size)); } + +TP_PRIVATE void *tp_realloc(void *p, size_t old_size, size_t new_size) { + void *q; + if (p == NULL || old_size == 0) return tp_alloc(new_size); + if (rt_cur != NULL && rt_cur->head != NULL) { + /* The last allocation of the head chunk grows in place. */ + tp_chunk *c = rt_cur->head; + unsigned char *d = rt_chunk_data(c); + if ((unsigned char *)p >= d && (unsigned char *)p <= d + c->used && + (unsigned char *)p + old_size == d + c->used) { + size_t at = (size_t)((unsigned char *)p - d); + if (new_size <= old_size) return p; + if (c->cap - at >= new_size) { + memset(d + c->used, 0, new_size - old_size); + c->used = at + new_size; + return p; + } + } + } + q = tp_alloc(new_size); + memcpy(q, p, old_size < new_size ? old_size : new_size); + return q; +} + +TP_PRIVATE tp_mark tp_arena_mark(void) { + tp_mark m; + m.arena = rt_cur; + m.head = rt_cur != NULL ? rt_cur->head : NULL; + m.head_next = m.head != NULL ? ((tp_chunk *)m.head)->next : NULL; + m.head_used = m.head != NULL ? ((tp_chunk *)m.head)->used : 0; + m.next_size = rt_cur != NULL ? rt_cur->next_size : 0; + return m; +} + +static void rt_chunk_drop(tp_arena *a, tp_chunk *c) { + a->bytes -= TP_CHUNK_HDR + c->cap; + tp_sys_free(c); +} + +TP_PRIVATE void tp_arena_release(tp_mark m) { + tp_arena *a = (tp_arena *)m.arena; + tp_chunk *old = (tp_chunk *)m.head; + tp_chunk *c; + if (a == NULL) return; + a->next_size = m.next_size; /* chunks taken in the region do not grow later ones */ + /* New heads (and the large chunks put behind them) sit in front of the old head. */ + c = a->head; + while (c != NULL && c != old) { + tp_chunk *next = c->next; + rt_chunk_drop(a, c); + c = next; + } + a->head = old; + if (old == NULL) return; + /* Large chunks taken while the old head was still the head sit right behind it. */ + c = old->next; + while (c != NULL && c != (tp_chunk *)m.head_next) { + tp_chunk *next = c->next; + rt_chunk_drop(a, c); + c = next; + } + old->next = (tp_chunk *)m.head_next; + old->used = m.head_used; +} + +TP_PRIVATE tp_arena *tp_arena_use(tp_arena *a) { + tp_arena *prev = rt_cur; + rt_cur = a; + return prev; +} + +TP_PRIVATE tp_arena *tp_arena_current(void) { return rt_cur; } + +/* -------------------------------------------------------------------------------------------- */ +/* Scopes */ + +TP_PRIVATE bool tp_scope_open(tp_scope *s) { + s->arena = tp_arena_new(); + if (s->arena == NULL) return false; + s->saved_arena = rt_cur; + s->saved_jmp = rt_jmp; + rt_cur = s->arena; + return true; +} + +TP_PRIVATE void tp_scope_arm(tp_scope *s) { rt_jmp = &s->jmp; } + +TP_PRIVATE void tp_scope_close(tp_scope *s) { + rt_cur = s->saved_arena; + rt_jmp = s->saved_jmp; +} + +TP_PRIVATE void tp_scope_abort(tp_scope *s) { + rt_cur = s->saved_arena; + rt_jmp = s->saved_jmp; + tp_arena_free(s->arena); + s->arena = NULL; +} + +/* -------------------------------------------------------------------------------------------- */ +/* Once */ + +/* Not pthread_once: PTHREAD_ONCE_INIT is not all-zero bytes everywhere (macOS), and a build that + * ran out of memory must be retried by a later call. Instead a process-wide lock guards the + * published value, and build() runs outside the lock (it may call tp_once_get for another table). + * Two threads may both build; the first to publish wins and the other frees its arena, which is + * harmless because build() is pure. once->opaque is unused. */ +#if defined(_WIN32) +static SRWLOCK rt_once_mutex = SRWLOCK_INIT; +static void rt_once_lock(void) { AcquireSRWLockExclusive(&rt_once_mutex); } +static void rt_once_unlock(void) { ReleaseSRWLockExclusive(&rt_once_mutex); } +#else +static pthread_mutex_t rt_once_mutex = PTHREAD_MUTEX_INITIALIZER; +static void rt_once_lock(void) { (void)pthread_mutex_lock(&rt_once_mutex); } +static void rt_once_unlock(void) { (void)pthread_mutex_unlock(&rt_once_mutex); } +#endif + +TP_PRIVATE void *tp_once_get(tp_once *once, void *(*build)(void)) { + void *v; + tp_scope s; + void *volatile built = NULL; +#if defined(__GNUC__) || defined(__clang__) + /* Fast path: an acquire load pairs with the release store below, so a reader that sees the + * pointer sees the table built behind it. */ + v = __atomic_load_n(&once->value, __ATOMIC_ACQUIRE); +#else + rt_once_lock(); + v = once->value; + rt_once_unlock(); +#endif + if (v != NULL) return v; + if (!tp_scope_open(&s)) return NULL; + if (setjmp(s.jmp) != 0) { + tp_scope_abort(&s); + return NULL; + } + tp_scope_arm(&s); + built = build(); + tp_scope_close(&s); + if (built == NULL) { + tp_arena_free(s.arena); + return NULL; + } + rt_once_lock(); + v = once->value; + if (v == NULL) { +#if defined(__GNUC__) || defined(__clang__) + __atomic_store_n(&once->value, built, __ATOMIC_RELEASE); +#else + once->value = built; +#endif + once->opaque[0] = s.arena; /* kept forever */ + v = built; + } + rt_once_unlock(); + if (v != built) tp_arena_free(s.arena); + return v; +} + +/* -------------------------------------------------------------------------------------------- */ +/* Strings */ + +TP_PRIVATE tp_str tp_str_c(const char *s) { + tp_str r; + if (s == NULL) return TP_EMPTY; + r.p = s; + r.n = strlen(s); + return r; +} + +TP_PRIVATE tp_str tp_str_copy(const char *p, size_t n) { + char *d = (char *)tp_alloc(tp_size_add(n, 1)); + tp_str r; + if (n) memcpy(d, p, n); + r.p = d; + r.n = n; + return r; +} + +TP_PRIVATE const char *tp_str_cstr(tp_str s) { return tp_str_copy(s.p, s.n).p; } + +TP_PRIVATE bool tp_str_eq(tp_str a, tp_str b) { + return a.n == b.n && (a.n == 0 || memcmp(a.p, b.p, a.n) == 0); +} + +TP_PRIVATE bool tp_str_eq_c(tp_str a, const char *b) { return tp_str_eq(a, tp_str_c(b)); } + +TP_PRIVATE int tp_str_cmp(tp_str a, tp_str b) { + size_t n = a.n < b.n ? a.n : b.n; + int c = n ? memcmp(a.p, b.p, n) : 0; + if (c != 0) return c < 0 ? -1 : 1; + if (a.n == b.n) return 0; + return a.n < b.n ? -1 : 1; +} + +TP_PRIVATE tp_str tp_str_slice(tp_str s, size_t from, size_t to) { + tp_str r; + if (to > s.n) to = s.n; + if (from > to) from = to; + r.p = s.p + from; + r.n = to - from; + return r; +} + +TP_PRIVATE bool tp_has_prefix(tp_str s, tp_str prefix) { + return s.n >= prefix.n && (prefix.n == 0 || memcmp(s.p, prefix.p, prefix.n) == 0); +} + +TP_PRIVATE bool tp_has_suffix(tp_str s, tp_str suffix) { + return s.n >= suffix.n && + (suffix.n == 0 || memcmp(s.p + s.n - suffix.n, suffix.p, suffix.n) == 0); +} + +TP_PRIVATE tp_str tp_trim_prefix(tp_str s, tp_str prefix) { + return tp_has_prefix(s, prefix) ? tp_str_slice(s, prefix.n, s.n) : s; +} + +TP_PRIVATE tp_str tp_trim_suffix(tp_str s, tp_str suffix) { + return tp_has_suffix(s, suffix) ? tp_str_slice(s, 0, s.n - suffix.n) : s; +} + +TP_PRIVATE ptrdiff_t tp_index(tp_str s, tp_str sub) { + size_t i; + if (sub.n == 0) return 0; + if (sub.n > s.n) return -1; + for (i = 0; i + sub.n <= s.n; i++) { + const void *hit = memchr(s.p + i, (unsigned char)sub.p[0], s.n - sub.n + 1 - i); + if (hit == NULL) return -1; + i = (size_t)((const char *)hit - s.p); + if (memcmp(s.p + i, sub.p, sub.n) == 0) return (ptrdiff_t)i; + } + return -1; +} + +TP_PRIVATE ptrdiff_t tp_index_byte(tp_str s, unsigned char c) { + const void *hit = s.n ? memchr(s.p, c, s.n) : NULL; + return hit == NULL ? -1 : (ptrdiff_t)((const char *)hit - s.p); +} + +TP_PRIVATE ptrdiff_t tp_last_index_byte(tp_str s, unsigned char c) { + size_t i = s.n; + while (i > 0) { + i--; + if ((unsigned char)s.p[i] == c) return (ptrdiff_t)i; + } + return -1; +} + +TP_PRIVATE bool tp_contains(tp_str s, tp_str sub) { return tp_index(s, sub) >= 0; } + +TP_PRIVATE bool tp_contains_rune(tp_str s, int32_t r) { + size_t i = 0; + while (i < s.n) { + size_t len; + tp_rune c = tp_decode_rune(tp_str_slice(s, i, s.n), &len); + if (c == r) return true; + i += len; + } + return false; +} + +TP_PRIVATE bool tp_contains_any(tp_str s, tp_str chars) { + size_t i = 0; + while (i < chars.n) { + size_t len; + tp_rune c = tp_decode_rune(tp_str_slice(chars, i, chars.n), &len); + if (tp_contains_rune(s, c)) return true; + i += len; + } + return false; +} + +TP_PRIVATE tp_str tp_concat(tp_str a, tp_str b) { + char *d = (char *)tp_alloc(tp_size_add(tp_size_add(a.n, b.n), 1)); + tp_str r; + if (a.n) memcpy(d, a.p, a.n); + if (b.n) memcpy(d + a.n, b.p, b.n); + r.p = d; + r.n = a.n + b.n; + return r; +} + +TP_PRIVATE tp_str tp_concat3(tp_str a, tp_str b, tp_str c) { + size_t n = tp_size_add(tp_size_add(a.n, b.n), c.n); + char *d = (char *)tp_alloc(tp_size_add(n, 1)); + tp_str r; + if (a.n) memcpy(d, a.p, a.n); + if (b.n) memcpy(d + a.n, b.p, b.n); + if (c.n) memcpy(d + a.n + b.n, c.p, c.n); + r.p = d; + r.n = n; + return r; +} + +TP_PRIVATE tp_str tp_repeat(tp_str s, size_t count) { + size_t n = tp_size_mul(s.n, count), i; + char *d = (char *)tp_alloc(tp_size_add(n, 1)); + tp_str r; + for (i = 0; i < count && s.n; i++) memcpy(d + i * s.n, s.p, s.n); + r.p = d; + r.n = n; + return r; +} + +/* strings.ReplaceAll; an empty old inserts with before every rune and at the end. */ +TP_PRIVATE tp_str tp_replace_all(tp_str s, tp_str old, tp_str with) { + tp_buf b = {0, 0, 0}; + size_t i = 0; + if (old.n == 0) { + tp_buf_str(&b, with); + while (i < s.n) { + size_t len; + (void)tp_decode_rune(tp_str_slice(s, i, s.n), &len); + tp_buf_bytes(&b, s.p + i, len); + tp_buf_str(&b, with); + i += len; + } + return tp_buf_done(&b); + } + for (;;) { + ptrdiff_t at = tp_index(tp_str_slice(s, i, s.n), old); + if (at < 0) break; + tp_buf_bytes(&b, s.p + i, (size_t)at); + tp_buf_str(&b, with); + i += (size_t)at + old.n; + } + if (i == 0) return s; + tp_buf_bytes(&b, s.p + i, s.n - i); + return tp_buf_done(&b); +} + +TP_PRIVATE tp_str tp_itoa(int64_t v) { + char tmp[24]; + size_t n = 0; + uint64_t u = v < 0 ? (uint64_t)0 - (uint64_t)v : (uint64_t)v; + char out[24]; + size_t k = 0; + do { + tmp[n++] = (char)('0' + (int)(u % 10)); + u /= 10; + } while (u != 0); + if (v < 0) out[k++] = '-'; + while (n > 0) out[k++] = tmp[--n]; + return tp_str_copy(out, k); +} + +TP_PRIVATE bool tp_atoi(tp_str s, int64_t *out) { + size_t i = 0; + bool neg = false; + uint64_t u = 0, limit; + if (s.n == 0) return false; + if (s.p[0] == '-' || s.p[0] == '+') { + neg = s.p[0] == '-'; + i = 1; + if (s.n == 1) return false; + } + limit = neg ? (uint64_t)INT64_MAX + 1 : (uint64_t)INT64_MAX; + for (; i < s.n; i++) { + unsigned char c = (unsigned char)s.p[i]; + unsigned d; + if (c < '0' || c > '9') return false; + d = (unsigned)(c - '0'); + if (u > (limit - d) / 10) return false; + u = u * 10 + d; + } + if (neg) { + *out = u == (uint64_t)INT64_MAX + 1 ? INT64_MIN : -(int64_t)u; + } else { + *out = (int64_t)u; + } + return true; +} + +/* -------------------------------------------------------------------------------------------- */ +/* UTF-8 and runes */ + +/* Decode one rune at the start of p[0..n) with Go's rules: an invalid or truncated sequence, an + * overlong form, a surrogate or a value above U+10FFFF gives (U+FFFD, 1). n > 0. */ +static tp_rune rt_decode(const unsigned char *p, size_t n, size_t *len) { + unsigned c = p[0]; + tp_rune r; + if (c < 0x80) { + *len = 1; + return (tp_rune)c; + } + if (c >= 0xC2 && c <= 0xDF) { + if (n >= 2 && (p[1] & 0xC0) == 0x80) { + *len = 2; + return (tp_rune)(((c & 0x1Fu) << 6) | (p[1] & 0x3Fu)); + } + } else if (c >= 0xE0 && c <= 0xEF) { + unsigned lo = c == 0xE0 ? 0xA0 : 0x80, hi = c == 0xED ? 0x9F : 0xBF; + if (n >= 3 && p[1] >= lo && p[1] <= hi && (p[2] & 0xC0) == 0x80) { + *len = 3; + r = (tp_rune)(((c & 0x0Fu) << 12) | ((p[1] & 0x3Fu) << 6) | (p[2] & 0x3Fu)); + return r; + } + } else if (c >= 0xF0 && c <= 0xF4) { + unsigned lo = c == 0xF0 ? 0x90 : 0x80, hi = c == 0xF4 ? 0x8F : 0xBF; + if (n >= 4 && p[1] >= lo && p[1] <= hi && (p[2] & 0xC0) == 0x80 && (p[3] & 0xC0) == 0x80) { + *len = 4; + r = (tp_rune)(((c & 0x07u) << 18) | ((p[1] & 0x3Fu) << 12) | ((p[2] & 0x3Fu) << 6) | + (p[3] & 0x3Fu)); + return r; + } + } + *len = 1; + return 0xFFFD; +} + +TP_PRIVATE bool tp_utf8_valid(tp_str s) { + const unsigned char *p = (const unsigned char *)s.p; + size_t i = 0; + while (i < s.n) { + size_t len; + tp_rune r = rt_decode(p + i, s.n - i, &len); + if (r == 0xFFFD && len == 1) { + /* U+FFFD itself is three bytes; a one-byte result is an error. */ + return false; + } + i += len; + } + return true; +} + +TP_PRIVATE tp_rune tp_decode_rune(tp_str s, size_t *len) { + if (s.n == 0) { + *len = 0; + return TP_NORUNE; + } + return rt_decode((const unsigned char *)s.p, s.n, len); +} + +TP_PRIVATE tp_rune tp_decode_last_rune(tp_str s, size_t *len) { + const unsigned char *p = (const unsigned char *)s.p; + size_t end = s.n, start, lim, l; + tp_rune r; + if (end == 0) { + *len = 0; + return TP_NORUNE; + } + if (p[end - 1] < 0x80) { + *len = 1; + return (tp_rune)p[end - 1]; + } + /* Go: back up over at most 3 continuation bytes to a start byte. */ + lim = end >= 4 ? end - 4 : 0; + start = end - 1; + while (start > lim && (p[start] & 0xC0) == 0x80) start--; + r = rt_decode(p + start, end - start, &l); + if (start + l != end) { + *len = 1; + return 0xFFFD; + } + *len = l; + return r; +} + +TP_PRIVATE size_t tp_utf8_encode(char out[4], tp_rune r) { + uint32_t u = (uint32_t)r; + if (r < 0 || u > 0x10FFFF || (u >= 0xD800 && u <= 0xDFFF)) u = 0xFFFD; + if (u < 0x80) { + out[0] = (char)u; + return 1; + } + if (u < 0x800) { + out[0] = (char)(0xC0 | (u >> 6)); + out[1] = (char)(0x80 | (u & 0x3F)); + return 2; + } + if (u < 0x10000) { + out[0] = (char)(0xE0 | (u >> 12)); + out[1] = (char)(0x80 | ((u >> 6) & 0x3F)); + out[2] = (char)(0x80 | (u & 0x3F)); + return 3; + } + out[0] = (char)(0xF0 | (u >> 18)); + out[1] = (char)(0x80 | ((u >> 12) & 0x3F)); + out[2] = (char)(0x80 | ((u >> 6) & 0x3F)); + out[3] = (char)(0x80 | (u & 0x3F)); + return 4; +} + +TP_PRIVATE size_t tp_rune_count(tp_str s) { + size_t i = 0, count = 0; + while (i < s.n) { + size_t len; + (void)rt_decode((const unsigned char *)s.p + i, s.n - i, &len); + i += len; + count++; + } + return count; +} + +TP_PRIVATE tp_runes tp_runes_of(tp_str s) { + tp_runes out; + tp_rune *d = (tp_rune *)tp_alloc_array(s.n, sizeof(tp_rune)); /* runes <= bytes */ + size_t i = 0, k = 0; + while (i < s.n) { + size_t len; + d[k++] = rt_decode((const unsigned char *)s.p + i, s.n - i, &len); + i += len; + } + out.p = d; + out.n = k; + return out; +} + +TP_PRIVATE tp_str tp_runes_str(tp_runes r) { + tp_buf b = {0, 0, 0}; + tp_buf_runes(&b, r); + return tp_buf_done(&b); +} + +TP_PRIVATE tp_runes tp_runes_slice(tp_runes r, size_t from, size_t to) { + tp_runes out; + if (to > r.n) to = r.n; + if (from > to) from = to; + out.p = r.p + from; + out.n = to - from; + return out; +} + +TP_PRIVATE tp_runes tp_runes_clone(tp_runes r) { + tp_runes out; + tp_rune *d = (tp_rune *)tp_alloc_array(r.n, sizeof(tp_rune)); + if (r.n) memcpy(d, r.p, r.n * sizeof(tp_rune)); + out.p = d; + out.n = r.n; + return out; +} + +TP_PRIVATE bool tp_runes_eq(tp_runes a, tp_runes b) { + return a.n == b.n && (a.n == 0 || memcmp(a.p, b.p, a.n * sizeof(tp_rune)) == 0); +} + +/* -------------------------------------------------------------------------------------------- */ +/* Vectors */ + +TP_PRIVATE void tp_vec_grow_(void *pp, size_t *cap, size_t need, size_t elem) { + void *p; + size_t newcap; + if (need <= *cap) return; + newcap = *cap < 4 ? 4 : tp_size_mul(*cap, 2); + if (newcap < need) newcap = need; + memcpy(&p, pp, sizeof p); + p = tp_realloc(p, tp_size_mul(*cap, elem), tp_size_mul(newcap, elem)); + memcpy(pp, &p, sizeof p); + *cap = newcap; +} + +TP_PRIVATE void tp_vec_push_n_(void *pp, size_t *n, size_t *cap, size_t k, size_t elem) { + size_t need = tp_size_add(*n, k); + void *p; + memcpy(&p, pp, sizeof p); + /* Storage even for k == 0, so &v.p[n] is never an offset from NULL. */ + if (need > *cap || p == NULL) tp_vec_grow_(pp, cap, need > *cap ? need : *cap + 1, elem); + memcpy(&p, pp, sizeof p); + if (k) memset((unsigned char *)p + *n * elem, 0, k * elem); + *n = need; +} + +TP_PRIVATE tp_runes tp_runevec_view(tp_runevec v) { + tp_runes r; + r.p = v.p; + r.n = v.n; + return r; +} + +TP_PRIVATE tp_str tp_join(tp_strvec parts, tp_str sep) { + tp_buf b = {0, 0, 0}; + size_t i; + if (parts.n == 0) return TP_EMPTY; + if (parts.n == 1) return parts.p[0]; + for (i = 0; i < parts.n; i++) { + if (i) tp_buf_str(&b, sep); + tp_buf_str(&b, parts.p[i]); + } + return tp_buf_done(&b); +} + +TP_PRIVATE tp_strvec tp_split(tp_str s, tp_str sep) { + tp_strvec out = {0, 0, 0}; + size_t i = 0; + if (sep.n == 0) { /* Go: one element per rune */ + while (i < s.n) { + size_t len; + (void)tp_decode_rune(tp_str_slice(s, i, s.n), &len); + tp_push(out, tp_str_slice(s, i, i + len)); + i += len; + } + return out; + } + for (;;) { + ptrdiff_t at = tp_index(tp_str_slice(s, i, s.n), sep); + if (at < 0) break; + tp_push(out, tp_str_slice(s, i, i + (size_t)at)); + i += (size_t)at + sep.n; + } + tp_push(out, tp_str_slice(s, i, s.n)); + return out; +} + +TP_PRIVATE bool tp_strvec_eq(tp_strvec a, tp_strvec b) { + size_t i; + if (a.n != b.n) return false; + for (i = 0; i < a.n; i++) { + if (!tp_str_eq(a.p[i], b.p[i])) return false; + } + return true; +} + +TP_PRIVATE bool tp_strvec_has(tp_strvec v, tp_str s) { + size_t i; + for (i = 0; i < v.n; i++) { + if (tp_str_eq(v.p[i], s)) return true; + } + return false; +} + +/* -------------------------------------------------------------------------------------------- */ +/* Byte builder */ + +/* Room for k more bytes plus a NUL. */ +static void rt_buf_reserve(tp_buf *b, size_t k) { + size_t need = tp_size_add(tp_size_add(b->n, k), 1); + size_t newcap; + if (need <= b->cap) return; + newcap = b->cap < 32 ? 32 : tp_size_mul(b->cap, 2); + if (newcap < need) newcap = need; + b->p = (char *)tp_realloc(b->p, b->cap, newcap); + b->cap = newcap; +} + +TP_PRIVATE void tp_buf_byte(tp_buf *b, char c) { + rt_buf_reserve(b, 1); + b->p[b->n++] = c; +} + +TP_PRIVATE void tp_buf_bytes(tp_buf *b, const char *p, size_t n) { + if (n == 0) return; + rt_buf_reserve(b, n); + memcpy(b->p + b->n, p, n); + b->n += n; +} + +TP_PRIVATE void tp_buf_str(tp_buf *b, tp_str s) { tp_buf_bytes(b, s.p, s.n); } + +TP_PRIVATE void tp_buf_cstr(tp_buf *b, const char *s) { tp_buf_str(b, tp_str_c(s)); } + +TP_PRIVATE void tp_buf_rune(tp_buf *b, tp_rune r) { + char tmp[4]; + size_t n = tp_utf8_encode(tmp, r); + tp_buf_bytes(b, tmp, n); +} + +TP_PRIVATE void tp_buf_runes(tp_buf *b, tp_runes r) { + size_t i; + rt_buf_reserve(b, r.n); /* at least one byte each */ + for (i = 0; i < r.n; i++) tp_buf_rune(b, r.p[i]); +} + +TP_PRIVATE void tp_buf_int(tp_buf *b, int64_t v) { tp_buf_str(b, tp_itoa(v)); } + +/* The returned string keeps its NUL: cap is set to n, so the next append copies into a new block + * (tp_realloc only grows in place when the old size it is given ends the last allocation, and + * the real block is at least n + 1 bytes). */ +TP_PRIVATE tp_str tp_buf_done(tp_buf *b) { + tp_str r; + if (b->n == 0) return TP_EMPTY; + rt_buf_reserve(b, 0); + b->p[b->n] = '\0'; + r.p = b->p; + r.n = b->n; + b->cap = b->n; + return r; +} + +/* -------------------------------------------------------------------------------------------- */ +/* String map: open addressing, linear probing, FNV-1a */ + +struct tp_map_slot { + tp_str key; + int64_t value; + uint64_t hash; /* 0: empty (real hashes have bit 0 set) */ +}; + +static uint64_t rt_map_hash(tp_str s) { + uint64_t h = UINT64_C(14695981039346656037); + size_t i; + for (i = 0; i < s.n; i++) { + h ^= (unsigned char)s.p[i]; + h *= UINT64_C(1099511628211); + } + return h | 1u; +} + +static struct tp_map_slot *rt_map_find(const tp_map *m, tp_str key, uint64_t h) { + size_t mask = m->cap - 1, i = (size_t)(h ^ (h >> 29)) & mask; + for (;;) { + struct tp_map_slot *s = &m->slots[i]; + if (s->hash == 0 || (s->hash == h && tp_str_eq(s->key, key))) return s; + i = (i + 1) & mask; + } +} + +static void rt_map_grow(tp_map *m) { + size_t old_cap = m->cap, i; + struct tp_map_slot *old = m->slots; + m->cap = old_cap ? tp_size_mul(old_cap, 2) : 16; + m->slots = (struct tp_map_slot *)tp_alloc_array(m->cap, sizeof *m->slots); + for (i = 0; i < old_cap; i++) { + if (old[i].hash != 0) *rt_map_find(m, old[i].key, old[i].hash) = old[i]; + } +} + +TP_PRIVATE void tp_map_put(tp_map *m, tp_str key, int64_t value) { + uint64_t h = rt_map_hash(key); + struct tp_map_slot *s; + if (m->cap == 0 || (m->n + 1) * 2 > m->cap) rt_map_grow(m); + s = rt_map_find(m, key, h); + if (s->hash == 0) { + s->hash = h; + s->key = key; + m->n++; + } + s->value = value; +} + +TP_PRIVATE bool tp_map_get(const tp_map *m, tp_str key, int64_t *value) { + struct tp_map_slot *s; + if (m->cap == 0) return false; + s = rt_map_find(m, key, rt_map_hash(key)); + if (s->hash == 0) return false; + if (value != NULL) *value = s->value; + return true; +} + +TP_PRIVATE bool tp_map_has(const tp_map *m, tp_str key) { return tp_map_get(m, key, NULL); } + +/* -------------------------------------------------------------------------------------------- */ +/* Stable sort: insertion sort on runs of 8, then bottom-up merges (no recursion) */ + +TP_PRIVATE void tp_sort_stable(void *base, size_t count, size_t size, + int (*cmp)(const void *a, const void *b, void *ctx), void *ctx) { + unsigned char *a = (unsigned char *)base, *tmp, *src, *dst; + unsigned char *hold; + size_t run = 8, i, width; + if (count < 2 || size == 0) return; + hold = (unsigned char *)tp_alloc(size); + for (i = 0; i < count; i += run) { + size_t end = i + run < count ? i + run : count, j; + for (j = i + 1; j < end; j++) { + size_t k = j; + if (cmp(a + (j - 1) * size, a + j * size, ctx) <= 0) continue; + memcpy(hold, a + j * size, size); + while (k > i && cmp(a + (k - 1) * size, hold, ctx) > 0) { + memcpy(a + k * size, a + (k - 1) * size, size); + k--; + } + memcpy(a + k * size, hold, size); + } + } + if (count <= run) return; + tmp = (unsigned char *)tp_alloc_array(count, size); + src = a; + dst = tmp; + for (width = run; width count / 2 ? count : width * 2) { + size_t lo; + for (lo = 0; lo < count; lo += 2 * width) { + size_t mid = lo + width < count ? lo + width : count; + size_t hi = mid + width < count ? mid + width : count; + size_t l = lo, r = mid, o = lo; + while (l < mid && r < hi) { + if (cmp(src + r * size, src + l * size, ctx) < 0) { + memcpy(dst + o * size, src + r * size, size); + r++; + } else { + memcpy(dst + o * size, src + l * size, size); + l++; + } + o++; + } + if (l < mid) memcpy(dst + o * size, src + l * size, (mid - l) * size); + if (r < hi) memcpy(dst + o * size + (mid - l) * size, src + r * size, (hi - r) * size); + } + { + unsigned char *t = src; + src = dst; + dst = t; + } + } + if (src != a) memcpy(a, src, count * size); +} + +/* -------------------------------------------------------------------------------------------- */ +/* JSON values */ + +TP_PRIVATE tp_json tp_json_null(void) { + tp_json v; + memset(&v, 0, sizeof v); + v.kind = TP_JSON_NULL; + v.str = TP_EMPTY; + return v; +} + +TP_PRIVATE tp_json tp_json_bool(bool b) { + tp_json v = tp_json_null(); + v.kind = TP_JSON_BOOL; + v.b = b; + return v; +} + +TP_PRIVATE tp_json tp_json_num(double n) { + tp_json v = tp_json_null(); + v.kind = TP_JSON_NUMBER; + v.num = n; + return v; +} + +TP_PRIVATE tp_json tp_json_str(tp_str s) { + tp_json v = tp_json_null(); + v.kind = TP_JSON_STRING; + v.str = s; + return v; +} + +TP_PRIVATE bool tp_json_get(tp_json v, tp_str key, tp_json *out) { + size_t i; + if (v.kind != TP_JSON_OBJECT) return false; + for (i = 0; i < v.obj_n; i++) { + if (tp_str_eq(v.obj[i].key, key)) { + if (out != NULL) *out = v.obj[i].val; + return true; + } + } + return false; +} diff --git a/c/src/rt.h b/c/src/rt.h new file mode 100644 index 0000000..5e99f86 --- /dev/null +++ b/c/src/rt.h @@ -0,0 +1,433 @@ +/* rt.h: the internal runtime every src/ file builds on. + * + * The C port is a file-by-file translation of the Go port (the go/ files), which mirrors js/src. + * This header gives C the pieces of Go the pipeline uses: strings (tp_str), rune slices + * (tp_runes), growable vectors (TP_VEC), byte builders (tp_buf), string-keyed maps (tp_map), a + * stable sort, and memory that never needs freeing inside the pipeline. + * + * Memory model + * ------------ + * Every allocation inside a public call comes from the *current arena* (thread-local). The public + * entry point (src/trackparse.c) opens a scope: a fresh arena plus a jmp_buf. Allocation never + * returns NULL: when the system allocator fails, tp_alloc longjmps back to the scope, which frees + * the arena and returns NULL to the caller. So pipeline code never checks for NULL and never + * calls free; everything dies with the arena. Pipeline code must not hold resources other than + * arena memory (no FILE*, no malloc), so a longjmp can never leak. + * + * All memory from tp_alloc is zeroed (Go zero values) and aligned to TP_ALIGN. + * + * Linkage + * ------- + * Every non-static internal function and global is declared TP_PRIVATE. The installed library is + * built from the amalgamation (one translation unit, TP_PRIVATE = static), so no internal symbol + * is ever visible to users, even in a static library. Tests and wire/ use the separate-files + * build, where TP_PRIVATE is empty. + * + * Determinism rules (AGENTS.md, PLAN.md hazards) + * ----------------------------------------------- + * - No , no strtod/atof/strtol, no printf-family on floats, no locale-dependent call. + * - No qsort: use tp_sort_stable. + * - Never iterate a tp_map for anything that reaches the output; keep ordered vectors for that. + * - Bytes are unsigned char when inspected; runes are int32_t; TP_NORUNE (-1) means "out of range". + * - No recursion in src/ unless its depth is bounded by a small constant. + */ +#ifndef TP_RT_H +#define TP_RT_H + +#include +#include +#include +#include +#include + +/* In the amalgamation (scripts/amalgamate.mjs) every internal name is static, and a given + * configuration may never call some of them: the unused attribute keeps GCC and Clang quiet + * about that, and MSVC's matching /W4 warning (C4505, unreferenced function removed) is turned + * off for the amalgamation. TP_PRIVATE_DATA declares a generated table in data_gen.h / + * unicode_gen.h (their own fallback definition is guarded by #ifndef, so this one wins). */ +#if defined(__GNUC__) || defined(__clang__) +#define TP_UNUSED __attribute__((unused)) +#else +#define TP_UNUSED +#endif +#if defined(_MSC_VER) +/* 4324: tp_scope holds a jmp_buf, which MSVC aligns to 16 and then reports the padding. */ +#pragma warning(disable : 4324) +#endif +#if defined(TRACKPARSE_AMALGAMATION) && defined(_MSC_VER) +/* 4505: unreferenced static function; 4132: a const object declared before its definition + * (TP_PRIVATE_DATA in the generated headers). */ +#pragma warning(disable : 4505 4132) +#endif +#ifdef TRACKPARSE_AMALGAMATION +#define TP_PRIVATE static TP_UNUSED +#define TP_PRIVATE_DATA static TP_UNUSED +#else +#define TP_PRIVATE +#define TP_PRIVATE_DATA extern +#endif + +#if defined(_MSC_VER) +#define TP_TLS __declspec(thread) +#elif defined(__GNUC__) || defined(__clang__) +#define TP_TLS __thread +#else +#define TP_TLS _Thread_local +#endif + +#if defined(__GNUC__) || defined(__clang__) +#define TP_NORETURN __attribute__((noreturn)) +#elif defined(_MSC_VER) +#define TP_NORETURN __declspec(noreturn) +#else +#define TP_NORETURN +#endif + +#define TP_ALIGN 16 +#define TP_NORUNE ((tp_rune) - 1) +#define TP_COUNT(a) (sizeof(a) / sizeof((a)[0])) + +/* -------------------------------------------------------------------------------------------- */ +/* Allocator hook and arenas */ + +typedef struct tp_allocator { + void *(*malloc_fn)(size_t size, void *user); + void *(*realloc_fn)(void *ptr, size_t size, void *user); + void (*free_fn)(void *ptr, void *user); + void *user; +} tp_allocator; + +/* The process-wide allocator (trackparse_set_allocator writes it). Defaults to malloc/free. */ +TP_PRIVATE void *tp_sys_malloc(size_t size); /* NULL on failure, never longjmps */ +TP_PRIVATE void tp_sys_free(void *ptr); +TP_PRIVATE void tp_set_allocator(const tp_allocator *a); + +typedef struct tp_arena tp_arena; + +/* A new empty arena, or NULL when the system allocator fails (never longjmps). */ +TP_PRIVATE tp_arena *tp_arena_new(void); +TP_PRIVATE void tp_arena_free(tp_arena *a); +/* Bytes taken from the system allocator so far (for tests and the bench). */ +TP_PRIVATE size_t tp_arena_bytes(const tp_arena *a); + +/* A scope makes an arena current and catches out-of-memory. Pattern (the only place that may + * call setjmp is the public entry point): + * + * tp_scope s; + * if (!tp_scope_open(&s)) return NULL; // could not even create the arena + * if (setjmp(s.jmp) != 0) { tp_scope_abort(&s); return NULL; } // out of memory + * tp_scope_arm(&s); + * ... pipeline code: tp_alloc never fails ... + * tp_scope_close(&s); // restores the previous arena; s.arena stays + * // alive, the caller owns or frees it + * + * Variables written after setjmp and read in the abort branch must be volatile. Scopes nest + * (a scope saves and restores the previous arena and handler). + */ +typedef struct tp_scope { + tp_arena *arena; + tp_arena *saved_arena; + jmp_buf *saved_jmp; + jmp_buf jmp; +} tp_scope; + +TP_PRIVATE bool tp_scope_open(tp_scope *s); +TP_PRIVATE void tp_scope_arm(tp_scope *s); +TP_PRIVATE void tp_scope_close(tp_scope *s); +/* After the longjmp: restore, free s->arena. */ +TP_PRIVATE void tp_scope_abort(tp_scope *s); +/* Make another arena current inside an armed scope (used to build a result into its own arena + * while scratch data lives in the scope's). Returns the previous one. */ +TP_PRIVATE tp_arena *tp_arena_use(tp_arena *a); +TP_PRIVATE tp_arena *tp_arena_current(void); + +/* Mark the current arena and later release everything allocated after the mark: chunks taken + * since are freed and the head chunk is rewound. Nothing allocated after the mark may be used + * after the release (results of a lookup that only answer yes or no, for example). Marks nest + * like a stack. */ +typedef struct tp_mark { + void *arena; + void *head; + void *head_next; + size_t head_used; + size_t next_size; +} tp_mark; +TP_PRIVATE tp_mark tp_arena_mark(void); +TP_PRIVATE void tp_arena_release(tp_mark m); + +/* Zeroed, TP_ALIGN-aligned memory from the current arena. Longjmps on failure. n == 0 returns a + * valid non-NULL pointer. */ +TP_PRIVATE void *tp_alloc(size_t n); +/* Checked n * size (longjmps on overflow, like an allocation failure). */ +TP_PRIVATE void *tp_alloc_array(size_t n, size_t size); +/* Grow an arena block: copies min(old, n) bytes into a new block; the old one is abandoned. */ +TP_PRIVATE void *tp_realloc(void *p, size_t old_size, size_t new_size); +TP_PRIVATE TP_NORETURN void tp_oom(void); +/* Size arithmetic that longjmps on overflow. */ +TP_PRIVATE size_t tp_size_add(size_t a, size_t b); +TP_PRIVATE size_t tp_size_mul(size_t a, size_t b); + +/* Run build() once per process and cache its result (built into a private arena that lives + * forever). Thread-safe. Returns NULL if building ran out of memory; callers then build into the + * current arena instead. Used for the default tables (Go's sync.OnceValue). */ +typedef struct tp_once { + void *opaque[2]; /* platform once-control storage, zero-initialized */ + void *value; +} tp_once; +#define TP_ONCE_INIT {{0, 0}, 0} +TP_PRIVATE void *tp_once_get(tp_once *once, void *(*build)(void)); + +/* -------------------------------------------------------------------------------------------- */ +/* Strings (Go string): UTF-8 bytes, not NUL-terminated in general, never mutated after creation */ + +typedef struct tp_str { + const char *p; + size_t n; +} tp_str; + +#define TP_S(lit) ((tp_str){(lit), sizeof(lit) - 1}) +#define TP_EMPTY ((tp_str){"", 0}) +/* printf("%.*s", TP_FMT(s)) for debugging only; never in output paths. */ +#define TP_FMT(s) (int)(s).n, (s).p + +TP_PRIVATE tp_str tp_str_c(const char *nul_terminated); /* view, no copy */ +TP_PRIVATE tp_str tp_str_copy(const char *p, size_t n); /* arena copy, NUL-terminated */ +TP_PRIVATE const char *tp_str_cstr(tp_str s); /* arena copy with a trailing NUL */ +TP_PRIVATE bool tp_str_eq(tp_str a, tp_str b); +TP_PRIVATE bool tp_str_eq_c(tp_str a, const char *b); +TP_PRIVATE int tp_str_cmp(tp_str a, tp_str b); /* bytewise, like Go's < on strings */ +TP_PRIVATE tp_str tp_str_slice(tp_str s, size_t from, size_t to); /* byte offsets, clamped */ +TP_PRIVATE bool tp_has_prefix(tp_str s, tp_str prefix); +TP_PRIVATE bool tp_has_suffix(tp_str s, tp_str suffix); +TP_PRIVATE tp_str tp_trim_prefix(tp_str s, tp_str prefix); +TP_PRIVATE tp_str tp_trim_suffix(tp_str s, tp_str suffix); +/* Byte index of the first / last occurrence, or -1. */ +TP_PRIVATE ptrdiff_t tp_index(tp_str s, tp_str sub); +TP_PRIVATE ptrdiff_t tp_index_byte(tp_str s, unsigned char c); +TP_PRIVATE ptrdiff_t tp_last_index_byte(tp_str s, unsigned char c); +TP_PRIVATE bool tp_contains(tp_str s, tp_str sub); +TP_PRIVATE bool tp_contains_rune(tp_str s, int32_t r); +TP_PRIVATE bool tp_contains_any(tp_str s, tp_str chars); /* any rune of chars */ +TP_PRIVATE tp_str tp_concat(tp_str a, tp_str b); +TP_PRIVATE tp_str tp_concat3(tp_str a, tp_str b, tp_str c); +TP_PRIVATE tp_str tp_repeat(tp_str s, size_t count); +TP_PRIVATE tp_str tp_replace_all(tp_str s, tp_str old, tp_str with); +TP_PRIVATE tp_str tp_itoa(int64_t v); /* strconv.Itoa / FormatInt base 10 */ +/* strconv.Atoi on ASCII digits with an optional leading '-' or '+'; false on anything else or on + * overflow of int64. */ +TP_PRIVATE bool tp_atoi(tp_str s, int64_t *out); +TP_PRIVATE bool tp_utf8_valid(tp_str s); + +/* -------------------------------------------------------------------------------------------- */ +/* Runes (Go rune / []rune) */ + +typedef int32_t tp_rune; + +/* A read-only rune slice (Go []rune used as a view). */ +typedef struct tp_runes { + const tp_rune *p; + size_t n; +} tp_runes; + +/* Decode UTF-8 (the input must be valid: the API sanitizes first; invalid bytes give U+FFFD). */ +TP_PRIVATE tp_runes tp_runes_of(tp_str s); +TP_PRIVATE tp_str tp_runes_str(tp_runes r); /* encode to an arena string */ +TP_PRIVATE tp_runes tp_runes_slice(tp_runes r, size_t from, size_t to); /* clamped, no copy */ +TP_PRIVATE tp_runes tp_runes_clone(tp_runes r); +TP_PRIVATE bool tp_runes_eq(tp_runes a, tp_runes b); +TP_PRIVATE size_t tp_rune_count(tp_str s); /* utf8.RuneCountInString */ +/* utf8.DecodeRuneInString / DecodeLastRuneInString on valid UTF-8: the rune and its byte length + * (TP_NORUNE, 0 on an empty string). */ +TP_PRIVATE tp_rune tp_decode_rune(tp_str s, size_t *len); +TP_PRIVATE tp_rune tp_decode_last_rune(tp_str s, size_t *len); +TP_PRIVATE size_t tp_utf8_encode(char out[4], tp_rune r); /* r must be a valid scalar */ + +/* -------------------------------------------------------------------------------------------- */ +/* Vectors (Go slices you append to) */ + +/* Declare a vector type: typedef TP_VEC(tp_str) tp_strvec; + * The zero value is an empty vector. Elements live in the current arena. Passing a vector by + * value copies the header (like a Go slice header): appending to the copy does not change the + * original's length, exactly as in Go. */ +#define TP_VEC(T) \ + struct { \ + T *p; \ + size_t n; \ + size_t cap; \ + } + +/* Grow the vector whose element pointer is at pp (the address of a T *; read and written with + * memcpy, so no T ** to void ** aliasing) to hold at least need elements. */ +TP_PRIVATE void tp_vec_grow_(void *pp, size_t *cap, size_t need, size_t elem); +/* Grow by k zeroed elements (zeroed even when the slots held earlier elements). */ +TP_PRIVATE void tp_vec_push_n_(void *pp, size_t *n, size_t *cap, size_t k, size_t elem); + +/* Append one element (an expression of the element type). */ +#define tp_push(v, x) \ + do { \ + if ((v).n == (v).cap) tp_vec_grow_(&(v).p, &(v).cap, (v).n + 1, sizeof *(v).p); \ + (v).p[(v).n++] = (x); \ + } while (0) + +/* Make room for k more elements and return a pointer to the first new one (zeroed). k is + * evaluated twice: it must have no side effects. */ +#define tp_push_n(v, k) \ + (tp_vec_push_n_(&(v).p, &(v).n, &(v).cap, (k), sizeof *(v).p), &(v).p[(v).n - (k)]) + +/* Append all elements of another vector of the same type. */ +#define tp_append(v, w) \ + do { \ + size_t tp_k_ = (w).n; \ + if (tp_k_) { \ + if ((v).n + tp_k_ > (v).cap) tp_vec_grow_(&(v).p, &(v).cap, (v).n + tp_k_, sizeof *(v).p); \ + memcpy(&(v).p[(v).n], (w).p, tp_k_ * sizeof *(v).p); \ + (v).n += tp_k_; \ + } \ + } while (0) + +/* Insert x at index i (0 <= i <= n). */ +#define tp_insert(v, i, x) \ + do { \ + size_t tp_i_ = (i); \ + if ((v).n == (v).cap) tp_vec_grow_(&(v).p, &(v).cap, (v).n + 1, sizeof *(v).p); \ + memmove(&(v).p[tp_i_ + 1], &(v).p[tp_i_], ((v).n - tp_i_) * sizeof *(v).p); \ + (v).p[tp_i_] = (x); \ + (v).n++; \ + } while (0) + +/* Remove elements [i, j). */ +#define tp_remove(v, i, j) \ + do { \ + size_t tp_a_ = (i), tp_b_ = (j); \ + memmove(&(v).p[tp_a_], &(v).p[tp_b_], ((v).n - tp_b_) * sizeof *(v).p); \ + (v).n -= tp_b_ - tp_a_; \ + } while (0) + +/* A copy with its own storage (slices.Clone). Use: tp_clone(dst, src). */ +#define tp_clone(dst, src) \ + do { \ + (dst).n = (dst).cap = 0; \ + (dst).p = NULL; \ + tp_append(dst, src); \ + } while (0) + +#define tp_last(v) ((v).p[(v).n - 1]) + +/* Common vector types. */ +typedef TP_VEC(tp_str) tp_strvec; +typedef TP_VEC(tp_rune) tp_runevec; +typedef TP_VEC(int64_t) tp_intvec; +typedef TP_VEC(double) tp_numvec; + +TP_PRIVATE tp_runes tp_runevec_view(tp_runevec v); +TP_PRIVATE tp_str tp_join(tp_strvec parts, tp_str sep); /* strings.Join */ +TP_PRIVATE tp_strvec tp_split(tp_str s, tp_str sep); /* strings.Split (sep non-empty) */ +TP_PRIVATE bool tp_strvec_eq(tp_strvec a, tp_strvec b); +TP_PRIVATE bool tp_strvec_has(tp_strvec v, tp_str s); + +/* -------------------------------------------------------------------------------------------- */ +/* Byte builder (strings.Builder / []byte append) */ + +typedef struct tp_buf { + char *p; + size_t n; + size_t cap; +} tp_buf; + +TP_PRIVATE void tp_buf_byte(tp_buf *b, char c); +TP_PRIVATE void tp_buf_bytes(tp_buf *b, const char *p, size_t n); +TP_PRIVATE void tp_buf_str(tp_buf *b, tp_str s); +TP_PRIVATE void tp_buf_cstr(tp_buf *b, const char *s); +TP_PRIVATE void tp_buf_rune(tp_buf *b, tp_rune r); /* UTF-8 encode */ +TP_PRIVATE void tp_buf_runes(tp_buf *b, tp_runes r); +TP_PRIVATE void tp_buf_int(tp_buf *b, int64_t v); +/* The contents as a string (NUL-terminated; the builder may keep appending afterwards, which does + * not change the returned string). */ +TP_PRIVATE tp_str tp_buf_done(tp_buf *b); + +/* -------------------------------------------------------------------------------------------- */ +/* String-keyed hash map (Go map[string]V for lookups only) */ + +/* Values are int64_t (store an index into a vector for anything bigger). Never iterate a map on + * a path that reaches the output: keep an ordered vector next to it instead. Keys are not + * copied: they must outlive the map (arena strings or static data). */ +typedef struct tp_map { + struct tp_map_slot *slots; + size_t cap; /* power of two, 0 when empty */ + size_t n; +} tp_map; + +TP_PRIVATE void tp_map_put(tp_map *m, tp_str key, int64_t value); /* insert or overwrite */ +TP_PRIVATE bool tp_map_get(const tp_map *m, tp_str key, int64_t *value); +TP_PRIVATE bool tp_map_has(const tp_map *m, tp_str key); + +/* -------------------------------------------------------------------------------------------- */ +/* Sorting */ + +/* Stable merge sort (slices.SortStableFunc). cmp returns <0, 0, >0. Scratch from the arena. */ +TP_PRIVATE void tp_sort_stable(void *base, size_t count, size_t size, + int (*cmp)(const void *a, const void *b, void *ctx), void *ctx); + +/* -------------------------------------------------------------------------------------------- */ +/* Numbers (src/num.c): locale-independent, exact */ + +/* JS Number(s) for the JSON number grammar and for plain decimal strings ("12", "3.25", "1e21", + * "-0.5"): the correctly rounded double. false when s is not such a number. */ +TP_PRIVATE bool tp_parse_number(tp_str s, double *out); +/* JS Number#toString (String(n)): shortest round-trip digits, "1e+21", "1e-7", "-0" as "0", + * "NaN", "Infinity", "-Infinity". */ +TP_PRIVATE void tp_buf_number(tp_buf *b, double v); +TP_PRIVATE tp_str tp_number_str(double v); +/* floor(v * 10^digits + 0.5) / 10^digits, computed without FMA contraction; digits 0..20. */ +TP_PRIVATE double tp_round_half_up(double v, int digits); +/* floor(v * scale + 0.5): the "units" of R13.9.2 (Go formatTime, JS Math.floor(s * scale + 0.5)), + * with the product rounded to a double before the add (no FMA). */ +TP_PRIVATE double tp_half_up_units(double v, double scale); +/* math.Floor / Math.floor, exact, without libm (-0 and non-finite values pass through). */ +TP_PRIVATE double tp_floor(double v); +TP_PRIVATE bool tp_is_nan(double v); +TP_PRIVATE bool tp_is_inf(double v); +TP_PRIVATE double tp_nan(void); +TP_PRIVATE double tp_inf(int sign); + +/* -------------------------------------------------------------------------------------------- */ +/* JSON values (Go jsonValue in go/json.go). The library uses them for edits and the loose JSON */ +/* options of the wire door; the reader that parses JSON text lives in wire/json_read.c. */ + +typedef enum tp_json_kind { + TP_JSON_NULL, /* the zero value */ + TP_JSON_BOOL, + TP_JSON_NUMBER, + TP_JSON_STRING, + TP_JSON_ARRAY, + TP_JSON_OBJECT +} tp_json_kind; + +typedef struct tp_json tp_json; +typedef struct tp_json_member tp_json_member; + +struct tp_json { + tp_json_kind kind; + bool b; + double num; + tp_str str; /* valid UTF-8; lone surrogate escapes became U+FFFD */ + const tp_json *arr; /* kind == ARRAY */ + size_t arr_n; + const tp_json_member *obj; /* kind == OBJECT, in document order; a repeated key keeps its first + place and the last value (JS object semantics) */ + size_t obj_n; +}; + +struct tp_json_member { + tp_str key; + tp_json val; +}; + +TP_PRIVATE tp_json tp_json_null(void); +TP_PRIVATE tp_json tp_json_bool(bool b); +TP_PRIVATE tp_json tp_json_num(double n); +TP_PRIVATE tp_json tp_json_str(tp_str s); +/* Object lookup (Go jsonValue.get): false when v is not an object or has no such key. */ +TP_PRIVATE bool tp_json_get(tp_json v, tp_str key, tp_json *out); + +#endif /* TP_RT_H */ diff --git a/c/src/scanner.c b/c/src/scanner.c new file mode 100644 index 0000000..d73cd02 --- /dev/null +++ b/c/src/scanner.c @@ -0,0 +1,340 @@ +/* scanner.c: R3 top-level group scanner and skeleton (go/scanner.go, js/src/scanner.ts). + * + * A skel is a skeleton (code points) plus, for every code point, its absolute offset in the + * normalized input. Offsets are in UTF-16 units, as in the JS reference, so every "order of + * appearance" comparison gives the same answer. Groups are looked up by the offset of their + * placeholder, so any slice of a skeleton still knows which groups it contains. + */ +#include "internal.h" + +TP_PRIVATE void tp_group_map_put(tp_group_map *m, const tp_group *g) { tp_push(m->groups, g); } + +TP_PRIVATE const tp_group *tp_group_map_get(const tp_group_map *m, ptrdiff_t pos) { + if (m == NULL) return NULL; /* a nil Go map */ + size_t lo = 0, hi = m->groups.n; + while (lo < hi) { + size_t mid = lo + (hi - lo) / 2; + ptrdiff_t p = m->groups.p[mid]->pos; + if (p == pos) return m->groups.p[mid]; + if (p < pos) { + lo = mid + 1; + } else { + hi = mid; + } + } + return NULL; +} + +TP_PRIVATE ptrdiff_t tp_offset_at(const tp_offsets *o, ptrdiff_t i) { + if (i >= 0 && i < (ptrdiff_t)o->at.n) return o->at.p[i]; + return o->end; +} + +/* closerOf is the closing bracket for an opener, or TP_NORUNE. */ +TP_PRIVATE tp_rune tp_closer_of(tp_rune r) { + switch (r) { + case '(': + return ')'; + case '[': + return ']'; + case '{': + return '}'; + default: + return TP_NORUNE; + } +} + +/* delimiterOf is the version delimiter of an opener. */ +TP_PRIVATE tp_delimiter tp_delimiter_of(tp_rune r) { + switch (r) { + case '[': + return TP_DELIMITER_SQUARE; + case '{': + return TP_DELIMITER_CURLY; + default: + return TP_DELIMITER_PAREN; + } +} + +/* scan is R3.1 to R3.5 on s, whose first code point sits at absolute offset base. *unbalanced is + * R3.3. */ +TP_PRIVATE tp_skel tp_scan(tp_runes s, ptrdiff_t base, bool *unbalanced) { + /* The absolute offset of every code point, plus one entry for the end of the string. */ + tp_offsets offsets; + memset(&offsets, 0, sizeof offsets); + ptrdiff_t off = base; + for (size_t i = 0; i < s.n; i++) { + tp_push(offsets.at, off); + if (s.p[i] >= 0x10000) { + off += 2; + } else { + off++; + } + } + tp_push(offsets.at, off); + offsets.end = off; + + tp_runevec text = {0}; + tp_idxvec pos = {0}; + tp_group_map *groups = tp_alloc(sizeof *groups); + tp_runevec stack = {0}; + ptrdiff_t group_start = 0; + for (size_t ui = 0; ui < s.n; ui++) { + ptrdiff_t i = (ptrdiff_t)ui; + tp_rune r = s.p[ui]; + if (stack.n == 0) { + tp_rune closer = tp_closer_of(r); + if (closer != TP_NORUNE) { + tp_push(stack, closer); + group_start = i; + } else { + tp_push(text, r); + tp_push(pos, tp_offset_at(&offsets, i)); + } + continue; + } + tp_rune closer = tp_closer_of(r); + if (closer != TP_NORUNE) { + tp_push(stack, closer); + } else if (tp_last(stack) == r) { + stack.n--; + if (stack.n == 0) { + tp_add_group(s, group_start, i + 1, true, &offsets, groups); + tp_push(text, TP_PH); + tp_push(pos, tp_offset_at(&offsets, group_start)); + } + } + /* R3.2: a non-matching closer is literal text inside the group. */ + } + *unbalanced = stack.n > 0; + if (*unbalanced) { + /* R3.3: the group runs to the end of the string. */ + tp_add_group(s, group_start, (ptrdiff_t)s.n, false, &offsets, groups); + tp_push(text, TP_PH); + tp_push(pos, tp_offset_at(&offsets, group_start)); + } + tp_skel sk; + sk.text = tp_runevec_view(text); + sk.pos = pos; + sk.groups = groups; + return sk; +} + +/* addGroup records the group s[start:end] (closed: end includes the closer). */ +TP_PRIVATE void tp_add_group(tp_runes s, ptrdiff_t start, ptrdiff_t end, bool closed, + const tp_offsets *offsets, tp_group_map *groups) { + ptrdiff_t inner_end = closed ? end - 1 : end; + ptrdiff_t p = tp_offset_at(offsets, start); + tp_group *g = tp_alloc(sizeof *g); + g->open = tp_delimiter_of(tp_at(s, start)); + g->inner = tp_collapse_runes(tp_sub(s, start + 1, inner_end)); + g->raw = tp_runes_str(tp_sub(s, start, end)); + g->pos = p; + tp_group_map_put(groups, g); +} + +/* --------------------------------------------------------------------------------------------- */ +/* Skeleton operations */ + +static void clamp_bounds(size_t n, ptrdiff_t *a, ptrdiff_t *b) { + if (*b > (ptrdiff_t)n) *b = (ptrdiff_t)n; + if (*b < 0) *b = 0; + if (*a > *b) *a = *b; + if (*a < 0) *a = 0; +} + +/* clamped is t[a:b] with both ends clamped to the slice (JS slice with non-negative bounds). */ +TP_PRIVATE tp_runes tp_clamped_runes(tp_runes t, ptrdiff_t a, ptrdiff_t b) { + clamp_bounds(t.n, &a, &b); + tp_runes out = {t.p ? t.p + a : NULL, (size_t)(b - a)}; + return out; +} + +TP_PRIVATE tp_idxvec tp_clamped_ints(tp_idxvec t, ptrdiff_t a, ptrdiff_t b) { + clamp_bounds(t.n, &a, &b); + tp_idxvec out; + out.p = t.p ? t.p + a : NULL; + out.n = (size_t)(b - a); + out.cap = out.n; /* appending to the view copies */ + return out; +} + +/* len is the number of code points. */ +TP_PRIVATE ptrdiff_t tp_skel_len(const tp_skel *s) { return (ptrdiff_t)s->text.n; } + +/* isEmpty reports whether the skeleton has no code points. */ +TP_PRIVATE bool tp_skel_is_empty(const tp_skel *s) { return s->text.n == 0; } + +/* sliceSkel is s[start:end], clamped. The text and offsets are copied, the groups shared. */ +TP_PRIVATE tp_skel tp_slice_skel(const tp_skel *s, ptrdiff_t start, ptrdiff_t end) { + tp_skel out; + out.text = tp_runes_clone(tp_clamped_runes(s->text, start, end)); + tp_idxvec view = tp_clamped_ints(s->pos, start, end); + tp_clone(out.pos, view); + out.groups = s->groups; + return out; +} + +/* sliceFrom is s[start:]. */ +TP_PRIVATE tp_skel tp_slice_from(const tp_skel *s, ptrdiff_t start) { + return tp_slice_skel(s, start, (ptrdiff_t)s->text.n); +} + +/* trimSkel removes R0.2 whitespace at both ends. */ +TP_PRIVATE tp_skel tp_trim_skel(const tp_skel *s) { + ptrdiff_t a = 0, b = (ptrdiff_t)s->text.n; + while (a < b && tp_is_whitespace(tp_at(s->text, a))) a++; + while (b > a && tp_is_whitespace(tp_before(s->text, b))) b--; + return tp_slice_skel(s, a, b); +} + +/* concatSkel is a followed by b (the groups of a). */ +TP_PRIVATE tp_skel tp_concat_skel(const tp_skel *a, const tp_skel *b) { + size_t n = tp_size_add(a->text.n, b->text.n); + tp_rune *text = tp_alloc_array(n, sizeof *text); + if (a->text.n) memcpy(text, a->text.p, a->text.n * sizeof *text); + if (b->text.n) memcpy(text + a->text.n, b->text.p, b->text.n * sizeof *text); + tp_skel out; + out.text = (tp_runes){text, n}; + memset(&out.pos, 0, sizeof out.pos); + tp_append(out.pos, a->pos); + tp_append(out.pos, b->pos); + out.groups = a->groups; + return out; +} + +/* groupAt is the group behind the placeholder at index, or NULL. */ +TP_PRIVATE const tp_group *tp_group_at(const tp_skel *s, ptrdiff_t index) { + if (tp_at(s->text, index) != TP_PH || index < 0 || index >= (ptrdiff_t)s->pos.n) return NULL; + return tp_group_map_get(s->groups, s->pos.p[index]); +} + +/* groupsOf is the groups of the skeleton, left to right. */ +TP_PRIVATE tp_indexed_group_vec tp_groups_of(const tp_skel *s) { + tp_indexed_group_vec out = {0}; + for (size_t i = 0; i < s->text.n; i++) { + const tp_group *g = tp_group_at(s, (ptrdiff_t)i); + if (g != NULL) { + tp_indexed_group ig; + ig.index = (ptrdiff_t)i; + ig.group = g; + tp_push(out, ig); + } + } + return out; +} + +/* hasGroup reports whether the skeleton holds a placeholder. */ +TP_PRIVATE bool tp_has_group(const tp_skel *s) { + for (size_t i = 0; i < s->text.n; i++) { + if (s->text.p[i] == TP_PH) return true; + } + return false; +} + +/* renderSkel substitutes the groups back (R3.4 reassembly). Whitespace is not touched. */ +TP_PRIVATE tp_str tp_render_skel(const tp_skel *s) { + tp_buf b = {0}; + for (size_t i = 0; i < s->text.n; i++) { + const tp_group *g = tp_group_at(s, (ptrdiff_t)i); + if (g != NULL) { + tp_buf_str(&b, g->raw); + } else { + tp_buf_rune(&b, s->text.p[i]); + } + } + return tp_buf_done(&b); +} + +/* startPos is the absolute offset of the first code point, or fallback for an empty skeleton. */ +TP_PRIVATE ptrdiff_t tp_start_pos(const tp_skel *s, ptrdiff_t fallback) { + if (s->pos.n == 0) return fallback; + return s->pos.p[0]; +} + +TP_PRIVATE bool tp_sorted_has(tp_idxvec v, ptrdiff_t x) { + size_t lo = 0, hi = v.n; + while (lo < hi) { + size_t mid = lo + (hi - lo) / 2; + if (v.p[mid] == x) return true; + if (v.p[mid] < x) { + lo = mid + 1; + } else { + hi = mid; + } + } + return false; +} + +/* removeGroups removes the placeholders of the groups at the given offsets (ascending). */ +TP_PRIVATE tp_skel tp_remove_groups(const tp_skel *s, tp_idxvec remove) { + if (remove.n == 0) return *s; + tp_runevec text = {0}; + tp_idxvec pos = {0}; + for (size_t i = 0; i < s->text.n; i++) { + if (i >= s->pos.n) break; + tp_rune r = s->text.p[i]; + ptrdiff_t p = s->pos.p[i]; + if (r == TP_PH && tp_sorted_has(remove, p)) continue; + tp_push(text, r); + tp_push(pos, p); + } + tp_skel out; + out.text = tp_runevec_view(text); + out.pos = pos; + out.groups = s->groups; + return out; +} + +/* isSpacedDashAt is R6.1: "-" with a space immediately on both sides. */ +TP_PRIVATE bool tp_is_spaced_dash_at(tp_runes t, ptrdiff_t i) { + return tp_at(t, i) == '-' && tp_before(t, i) == ' ' && tp_at(t, i + 1) == ' '; +} + +/* hasSpacedDash reports whether t has a spaced dash. */ +TP_PRIVATE bool tp_has_spaced_dash(tp_runes t) { + for (ptrdiff_t i = 1; i + 1 < (ptrdiff_t)t.n; i++) { + if (tp_is_spaced_dash_at(t, i)) return true; + } + return false; +} + +/* trimmedSegment is s[start:end] trimmed of R0.2 whitespace. */ +TP_PRIVATE tp_segment tp_trimmed_segment(const tp_skel *s, ptrdiff_t start, ptrdiff_t end) { + ptrdiff_t a = start; + ptrdiff_t b = end; + if (b < start) b = start; + while (a < b && tp_is_whitespace(tp_at(s->text, a))) a++; + while (b > a && tp_is_whitespace(tp_before(s->text, b))) b--; + tp_segment seg; + seg.skel = tp_slice_skel(s, a, b); + seg.start = a; + seg.end = b; + return seg; +} + +/* splitAtSpacedDashes is R6.1 / R8.2: split a skeleton at every spaced dash into trimmed + * segments. With allow_leading, a string starting with "- " yields an empty first segment + * (R6.3). */ +TP_PRIVATE tp_segment_vec tp_split_at_spaced_dashes(const tp_skel *s, bool allow_leading) { + tp_segment_vec segments = {0}; + tp_runes t = s->text; + ptrdiff_t start = 0; + if (allow_leading && tp_at(t, 0) == '-' && tp_at(t, 1) == ' ') { + tp_segment seg; + seg.skel = tp_slice_skel(s, 0, 0); + seg.start = 0; + seg.end = 0; + tp_push(segments, seg); + start = 2; + } + ptrdiff_t i = start > 1 ? start : 1; + for (; i + 1 < (ptrdiff_t)t.n; i++) { + if (tp_is_spaced_dash_at(t, i)) { + tp_push(segments, tp_trimmed_segment(s, start, i - 1)); + start = i + 2; + } + } + tp_push(segments, tp_trimmed_segment(s, start, (ptrdiff_t)t.n)); + return segments; +} diff --git a/c/src/separator.c b/c/src/separator.c new file mode 100644 index 0000000..8e62739 --- /dev/null +++ b/c/src/separator.c @@ -0,0 +1,362 @@ +/* separator.c: R6 artist/title separator, including the R6.2 suffix peeling shared with R8.2 + * (go/separator.go, js/src/separator.ts). */ +#include "internal.h" + +/* classifySegment is the R6.2 classification of a bare dash segment: placeholders make it + * Unknown. */ +TP_PRIVATE tp_classification tp_classify_segment(tp_skel seg, tp_ctx *c) { + if (tp_has_group(&seg)) { + tp_classification cls; + memset(&cls, 0, sizeof cls); + cls.kind = TP_CLASS_UNKNOWN; + return cls; + } + tp_str text = tp_collapse_runes(seg.text); + tp_site s; + s.source = TP_SOURCE_TITLE; + s.delimiter = TP_DELIMITER_DASH; + s.pos = tp_start_pos(&seg, 0); + return tp_classify(text, s, c); +} + +/* isPeelable reports whether R6.2 / R8.2 can peel a classification. */ +TP_PRIVATE bool tp_is_peelable(tp_classification cls) { + switch (cls.kind) { + case TP_CLASS_JUNK: + case TP_CLASS_FLAG: + case TP_CLASS_YEAR: + case TP_CLASS_VERSIONS: + return true; + default: + return false; + } +} + +/* peelSuffixes is R6.2 / R8.2: peel classifiable suffixes off the right end. relaxed drops + * conditions (i) to (iv) (R8.2 with an artist side). It gives the remaining segments and the + * peeled suffixes, left to right. */ +TP_PRIVATE tp_segment_vec tp_peel_suffixes(tp_segment_vec segments, bool relaxed, tp_ctx *c, + tp_peeled_vec *peeled) { + tp_segment_vec remaining = segments; + tp_peeled_vec out = {0}; + while (remaining.n >= 2) { + tp_segment last = tp_last(remaining); + tp_classification cls = tp_classify_segment(last.skel, c); + if (!tp_is_peelable(cls)) break; + tp_strvec words = tp_split_words_runes(last.skel.text); + /* (ii) does not apply to prefix-form versions ("Andy C b2b Hedex - Live at Printworks"). */ + bool prefix_form = false; + if (cls.kind == TP_CLASS_VERSIONS) { + prefix_form = true; + for (size_t i = 0; i < cls.versions.n; i++) { + if (!cls.versions.p[i].prefix_form) { + prefix_form = false; + break; + } + } + } + bool has_year = false; + for (size_t i = 0; i < words.n; i++) { + int y; + if (tp_year_of(words.p[i], &y)) { + has_year = true; + break; + } + } + bool ok = relaxed || remaining.n > 2 || (words.n >= 2 && !prefix_form) || has_year || + cls.kind == TP_CLASS_JUNK; + if (!ok) break; + tp_peeled p; + p.cls = cls; + p.raw = tp_collapse_runes(last.skel.text); + p.pos = tp_start_pos(&last.skel, 0); + tp_push(out, p); + remaining.n--; + } + /* Left to right. */ + if (out.n > 1) { + for (size_t i = 0, j = out.n - 1; i < j; i++, j--) { + tp_peeled tmp = out.p[i]; + out.p[i] = out.p[j]; + out.p[j] = tmp; + } + } + *peeled = out; + return remaining; +} + +/* nonEmpty is the trimmed skeleton, or NULL when it is empty. */ +TP_PRIVATE const tp_skel *tp_non_empty(tp_skel s) { + tp_skel t = tp_trim_skel(&s); + if (tp_skel_is_empty(&t)) return NULL; + tp_skel *p = tp_alloc(sizeof *p); + *p = t; + return p; +} + +/* splitAt cuts s around [cut_start, cut_end). */ +TP_PRIVATE tp_split_parts tp_split_at(tp_skel s, ptrdiff_t cut_start, ptrdiff_t cut_end) { + tp_skel right = tp_slice_from(&s, cut_end); + tp_split_parts parts; + parts.artist = tp_non_empty(tp_slice_skel(&s, 0, cut_start)); + parts.title = tp_trim_skel(&right); + return parts; +} + +/* resultOf is a separator result for split parts. */ +TP_PRIVATE tp_separator_result tp_result_of(tp_split_parts parts, tp_peeled_vec p) { + tp_separator_result r; + r.artist = parts.artist; + r.title = parts.title; + r.split = parts.artist != NULL; + r.peeled = p; + return r; +} + +/* firstDashSplit is R6.3: the first segment is the artist side, the rest (up to the last kept + * one) the title. */ +TP_PRIVATE bool tp_first_dash_split(tp_skel sk, tp_segment_vec segments, tp_split_parts *out) { + if (segments.n < 2) return false; + tp_segment first = segments.p[0], second = segments.p[1], last = tp_last(segments); + const tp_skel *artist = NULL; + if (!tp_skel_is_empty(&first.skel)) { + tp_skel *a = tp_alloc(sizeof *a); + *a = first.skel; + artist = a; + } + out->artist = artist; + out->title = tp_slice_skel(&sk, second.start, last.end); + return true; +} + +/* findSeparator is R6. */ +TP_PRIVATE tp_separator_result tp_find_separator(tp_separator_input in, tp_ctx *c) { + tp_skel sk = in.skel; + tp_mode mode = in.mode; + tp_segment_vec segments = tp_split_at_spaced_dashes(&sk, true); + if (tp_str_eq(mode, TP_MODE_TRACKLIST)) { + return tp_tracklist_separator(sk, segments, in.list_context, c); + } + tp_peeled_vec p; + tp_segment_vec remaining = tp_peel_suffixes(segments, false, c, &p); + + /* R6.3 */ + tp_split_parts parts; + if (tp_first_dash_split(sk, remaining, &parts)) return tp_result_of(parts, p); + + tp_skel rest = tp_slice_skel(&sk, 0, 0); + if (remaining.n > 0) rest = remaining.p[0].skel; + tp_split_parts other; + if (tp_split_without_spaced_dash(rest, mode, c, &other)) return tp_result_of(other, p); + + /* R6.8: the uploader fallback does not warn noSeparator. */ + const tp_skel *artist = NULL; + if (tp_str_eq(mode, TP_MODE_YOUTUBE)) artist = in.uploader; + if (!tp_skel_is_empty(&rest) && artist == NULL) tp_ctx_warn(c, TP_WARNING_NO_SEPARATOR); + tp_separator_result r; + r.artist = artist; + r.title = rest; + r.split = false; + r.peeled = p; + return r; +} + +/* tracklistSeparator is R6.10, tracklist mode. The first spaced dash always separates (no R6.2 + * peeling; R8.2 still peels later suffixes on the title side). Without one: R6.4, then the + * first "_-_", then (list context only) the last tight "letter-Uppercase" dash; both of these + * warn unspacedDashSplit. */ +TP_PRIVATE tp_separator_result tp_tracklist_separator(tp_skel sk, tp_segment_vec segments, + bool list_context, tp_ctx *c) { + tp_peeled_vec none = {0}; + tp_split_parts parts; + if (tp_first_dash_split(sk, segments, &parts)) return tp_result_of(parts, none); + tp_skel rest = tp_slice_skel(&sk, 0, 0); + if (segments.n > 0) rest = segments.p[0].skel; + ptrdiff_t at; + if (tp_asymmetric_dash(rest.text, &at)) { + tp_ctx_warn(c, TP_WARNING_ASYMMETRIC_DASH_SPLIT); + return tp_result_of(tp_split_at(rest, at, at + 1), none); + } + if (tp_underscore_dash(rest.text, &at)) { + tp_ctx_warn(c, TP_WARNING_UNSPACED_DASH_SPLIT); + return tp_result_of(tp_split_at(rest, at, at + 3), none); + } + if (list_context) { + if (tp_tight_upper_dash(rest.text, &at)) { + tp_ctx_warn(c, TP_WARNING_UNSPACED_DASH_SPLIT); + return tp_result_of(tp_split_at(rest, at, at + 1), none); + } + } + if (!tp_skel_is_empty(&rest)) tp_ctx_warn(c, TP_WARNING_NO_SEPARATOR); + tp_separator_result r; + memset(&r, 0, sizeof r); + r.title = rest; + return r; +} + +/* underscoreDash is the index of the first "_-_". */ +TP_PRIVATE bool tp_underscore_dash(tp_runes t, ptrdiff_t *out) { + for (size_t i = 0; i + 2 < t.n; i++) { + if (t.p[i] == '_' && t.p[i + 1] == '-' && t.p[i + 2] == '_') { + *out = (ptrdiff_t)i; + return true; + } + } + return false; +} + +/* tightUpperDash is R6.10: the last "-" with a letter (R0.6) on its left and an uppercase letter + * (Lu) on its right, as in R6.7 ("Jay-Z-Numb" gives "Jay-Z" and "Numb"). */ +TP_PRIVATE bool tp_tight_upper_dash(tp_runes t, ptrdiff_t *out) { + for (ptrdiff_t i = (ptrdiff_t)t.n - 2; i >= 1; i--) { + if (tp_at(t, i) == '-' && tp_is_letter_before(t, i) && tp_is_upper_at(t, i + 1)) { + *out = i; + return true; + } + } + return false; +} + +/* splitWithoutSpacedDash is R6.4 to R6.7. */ +TP_PRIVATE bool tp_split_without_spaced_dash(tp_skel s, tp_mode mode, tp_ctx *c, + tp_split_parts *out) { + ptrdiff_t at; + if (tp_asymmetric_dash(s.text, &at)) { + tp_ctx_warn(c, TP_WARNING_ASYMMETRIC_DASH_SPLIT); + *out = tp_split_at(s, at, at + 1); + return true; + } + bool youtube = tp_str_eq(mode, TP_MODE_YOUTUBE); + if (youtube) { + tp_split_parts quoted; + if (tp_quoted_title(s, "ed)) { + tp_ctx_warn(c, TP_WARNING_QUOTED_TITLE_SPLIT); + *out = quoted; + return true; + } + ptrdiff_t by; + if (tp_by_split(s, c, &by)) { + tp_ctx_warn(c, TP_WARNING_BY_SPLIT); + tp_split_parts lr = tp_split_at(s, by, by + 4); + const tp_skel *artist = NULL; + if (!tp_skel_is_empty(&lr.title)) { + tp_skel *right = tp_alloc(sizeof *right); + *right = lr.title; + artist = right; + } + tp_skel title = s; + if (lr.artist != NULL) title = *lr.artist; + out->artist = artist; + out->title = title; + return true; + } + } + if (youtube || tp_str_eq(mode, TP_MODE_FILENAME)) { + ptrdiff_t dash; + if (tp_unspaced_dash(s, c, &dash)) { + tp_ctx_warn(c, TP_WARNING_UNSPACED_DASH_SPLIT); + *out = tp_split_at(s, dash, dash + 1); + return true; + } + } + return false; +} + +/* asymmetricDash is R6.4: the first "-" with a space on exactly one side. */ +TP_PRIVATE bool tp_asymmetric_dash(tp_runes t, ptrdiff_t *out) { + for (ptrdiff_t i = 1; i + 1 < (ptrdiff_t)t.n; i++) { + if (tp_at(t, i) == '-' && + tp_is_whitespace(tp_before(t, i)) != tp_is_whitespace(tp_at(t, i + 1))) { + *out = i; + return true; + } + } + return false; +} + +/* quotedTitle is R6.5: Artist "Title" (extra). */ +TP_PRIVATE bool tp_quoted_title(tp_skel s, tp_split_parts *out) { + tp_runes t = s.text; + ptrdiff_t open = tp_rune_index(t, '"'); + if (open <= 0) return false; + ptrdiff_t rel = tp_rune_index(tp_tail(t, open + 1), '"'); + if (rel < 0) return false; + ptrdiff_t close_at = rel + open + 1; + tp_skel left = tp_slice_skel(&s, 0, open); + tp_skel artist = tp_trim_skel(&left); + tp_rune last = tp_at(artist.text, tp_skel_len(&artist) - 1); + if (last == ':' || last == '-') { + tp_skel shorter = tp_slice_skel(&artist, 0, tp_skel_len(&artist) - 1); + artist = tp_trim_skel(&shorter); + } + tp_skel quoted = tp_slice_skel(&s, open + 1, close_at); + tp_skel after = tp_slice_from(&s, close_at + 1); + tp_skel joined = tp_concat_skel("ed, &after); + tp_skel title = tp_trim_skel(&joined); + const tp_skel *a = NULL; + if (!tp_skel_is_empty(&artist)) { + tp_skel *p = tp_alloc(sizeof *p); + *p = artist; + a = p; + } + out->artist = a; + out->title = title; + return true; +} + +/* bySplit is R6.6: the index of the space before the last usable " by ". The right side must be + * non-empty and not a single stopword ("Stand by Me"). */ +TP_PRIVATE bool tp_by_split(tp_skel s, tp_ctx *c, ptrdiff_t *out) { + static const char ph_utf8[] = "\xEE\x80\x80"; /* Go string(ph) */ + tp_str ph = {ph_utf8, sizeof ph_utf8 - 1}; + tp_runes t = s.text; + /* Candidates right to left; index 0 is never one (i > 0 in the JS loop). */ + for (ptrdiff_t i = (ptrdiff_t)t.n - 4; i > 0; i--) { + if (tp_at(t, i) != ' ' || tp_at(t, i + 1) != 'b' || tp_at(t, i + 2) != 'y' || + tp_at(t, i + 3) != ' ') { + continue; + } + /* Placeholder-only words (groups such as "(Official Video)") don't count here. */ + tp_strvec words = tp_split_words_runes(tp_tail(t, i + 4)); + tp_strvec right = {0}; + for (size_t k = 0; k < words.n; k++) { + if (tp_str_eq(words.p[k], ph)) continue; + tp_push(right, words.p[k]); + } + bool single_stopword = right.n == 1 && tp_in_vocab(right.p[0], &c->t->stopwords); + if (right.n > 0 && !single_stopword) { + *out = i; + return true; + } + } + return false; +} + +/* unspacedDash is R6.7: the chosen unspaced dash index ("Jay-Z-Numb"). */ +TP_PRIVATE bool tp_unspaced_dash(tp_skel s, tp_ctx *c, ptrdiff_t *out) { + tp_runes t = s.text; + ptrdiff_t last = 0; + bool found = false; + bool has_known = c->known_keys != NULL && c->known_keys->m.n > 0; + for (ptrdiff_t i = 1; i + 1 < (ptrdiff_t)t.n; i++) { + if (tp_at(t, i) != '-' || tp_is_whitespace(tp_before(t, i)) || + tp_is_whitespace(tp_at(t, i + 1))) { + continue; + } + if (!(tp_at(t, i + 1) == '"' || tp_is_letter_at(t, i + 1))) continue; + if (has_known && tp_is_known_artist(tp_render_prefix(&s, i), c)) { + *out = i; + return true; + } + last = i; + found = true; + } + if (found) *out = last; + return found; +} + +/* renderPrefix is the rendered text of s[:end]. */ +TP_PRIVATE tp_str tp_render_prefix(const tp_skel *s, ptrdiff_t end) { + tp_skel head = tp_slice_skel(s, 0, end); + return tp_render_skel(&head); +} diff --git a/c/src/tables.c b/c/src/tables.c new file mode 100644 index 0000000..0d96ed3 --- /dev/null +++ b/c/src/tables.c @@ -0,0 +1,250 @@ +/* tables.c: vocabulary tables compiled from spec/data (data_gen.c), optionally extended by + * options.keywords (R12) (go/tables.go). + * + * The default tables are built once and shared; tables with keywords are built per Parser. + * Tables are read-only after building, so they are safe for concurrent use. The maps in them are + * only looked up, never iterated. */ +#include "internal.h" + +TP_PRIVATE bool tp_tables_tight_joiner(const tp_tables *t, tp_str raw, tp_str *canonical) { + for (size_t i = t->tight_joiners.n; i > 0; i--) { + if (tp_str_eq(t->tight_joiners.p[i - 1].key, raw)) { + *canonical = t->tight_joiners.p[i - 1].value; + return true; + } + } + return false; +} + +TP_PRIVATE tp_strvec tp_data_strs(const tp_str *p, size_t n) { + tp_strvec v; + /* Read-only view: cap == n, so any append copies first and never writes p. */ + memcpy(&v.p, &p, sizeof v.p); + v.n = n; + v.cap = n; + return v; +} + +/* lowerKeys is JS `asciiLower(s).trim()` of each entry, empty ones dropped. */ +TP_PRIVATE tp_strvec tp_lower_keys(tp_strvec list) { + tp_strvec out = {0}; + for (size_t i = 0; i < list.n; i++) { + tp_str k = tp_js_trim(tp_ascii_lower(list.p[i])); + if (k.n != 0) tp_push(out, k); + } + return out; +} + +/* dataEntries are the pairs of a data object in JS Object.entries order. */ +TP_PRIVATE tp_kv_vec tp_data_entries(const tp_data_kv *list, size_t n) { + tp_kv_vec pairs = {0}; + tp_kv *dst = tp_push_n(pairs, n); + for (size_t i = 0; i < n; i++) { + dst[i].key = list[i].key; + dst[i].value = list[i].value; + } + return tp_js_entries(pairs); +} + +/* markerTable is a set-like phrase table of base plus extra. */ +TP_PRIVATE const tp_phrase_table *tp_marker_table(tp_strvec base, tp_strvec extra) { + tp_phrase_table *t = tp_new_phrase_table(); + for (size_t i = 0; i < base.n; i++) tp_phrase_table_add(t, base.p[i], NULL); + for (size_t i = 0; i < extra.n; i++) tp_phrase_table_add(t, extra.p[i], NULL); + return t; +} + +static const tp_str *tables_str_ptr(tp_str s) { + tp_str *p = tp_alloc(sizeof *p); + *p = s; + return p; +} + +/* kindTable is a phrase table of string values. */ +TP_PRIVATE const tp_phrase_table *tp_kind_table(const tp_kv_vec *entries, size_t count) { + tp_phrase_table *t = tp_new_phrase_table(); + for (size_t l = 0; l < count; l++) { + for (size_t i = 0; i < entries[l].n; i++) { + tp_phrase_table_add(t, entries[l].p[i].key, tables_str_ptr(entries[l].p[i].value)); + } + } + return t; +} + +/* The state of the Go closure note: a JS Map in insertion order (the first note of a key fixes + * its place, later notes merge into it). */ +typedef TP_VEC(tp_run_info) run_info_vec; +typedef struct run_notes { + tp_strvec keys; + tp_map index; + run_info_vec infos; +} run_notes; + +/* note: the run info of key, created on first use. Valid until the next note. */ +static tp_run_info *note(run_notes *r, tp_str key) { + tp_str k = tp_js_trim(tp_ascii_lower(key)); + int64_t i; + if (!tp_map_get(&r->index, k, &i)) { + tp_run_info zero; + memset(&zero, 0, sizeof zero); + i = (int64_t)r->infos.n; + tp_map_put(&r->index, k, i); + tp_push(r->keys, k); + tp_push(r->infos, zero); + } + return &r->infos.p[(size_t)i]; +} + +static tp_word_set word_set(const tp_str *words, size_t n) { + tp_word_set s; + memset(&s, 0, sizeof s); + tp_word_set_add_all(&s, words, n); + return s; +} + +static int by_utf16_len_desc(const void *a, const void *b, void *ctx) { + ptrdiff_t la = tp_utf16_len_string(*(const tp_str *)a); + ptrdiff_t lb = tp_utf16_len_string(*(const tp_str *)b); + (void)ctx; + return lb < la ? -1 : (lb > la ? 1 : 0); +} + +TP_PRIVATE tp_tables *tp_build_tables(const tp_keyword_lists *kw) { + tp_keyword_lists none; + tp_tables *t = tp_alloc(sizeof *t); + tp_strvec extra_feat, genres, descriptors, suffixes; + tp_kv_vec junk_entries, genre_entries = {0}, head_entries, both[2], prefix_entries; + run_notes notes; + tp_phrase_table *run_words; + tp_strvec empty = {0}; + + if (kw == NULL) { + memset(&none, 0, sizeof none); + kw = &none; + } + extra_feat = tp_lower_keys(kw->feat_markers); + + junk_entries = tp_data_entries(tp_data_junk_phrases, TP_DATA_JUNK_PHRASES_N); + tp_append(junk_entries, kw->junk); + tp_clone(genres, tp_data_strs(tp_data_genres_genres, TP_DATA_GENRES_GENRES_N)); + { + tp_strvec extra = tp_lower_keys(kw->genres); + tp_append(genres, extra); + } + for (size_t i = 0; i < genres.n; i++) { + tp_kv e; + e.key = genres.p[i]; + e.value = TP_JUNK_KIND_GENRE; + tp_push(genre_entries, e); + } + + head_entries = tp_data_entries(tp_data_version_keywords_heads, TP_DATA_VERSION_KEYWORDS_HEADS_N); + tp_append(head_entries, kw->version_heads); + + memset(¬es, 0, sizeof notes); + { + tp_kv_vec capable = tp_data_entries(tp_data_version_keywords_type_capable_modifiers, + TP_DATA_VERSION_KEYWORDS_TYPE_CAPABLE_MODIFIERS_N); + for (size_t i = 0; i < capable.n; i++) { + note(¬es, capable.p[i].key)->type_capable = tables_str_ptr(capable.p[i].value); + } + } + tp_clone(descriptors, + tp_data_strs(tp_data_descriptors_descriptors, TP_DATA_DESCRIPTORS_DESCRIPTORS_N)); + { + tp_strvec extra = tp_lower_keys(kw->descriptors); + tp_append(descriptors, extra); + } + for (size_t i = 0; i < descriptors.n; i++) { + tp_str d = descriptors.p[i]; + const tp_str *value = tables_str_ptr(tp_js_trim(tp_ascii_lower(d))); + note(¬es, d)->descriptor = value; + } + for (size_t i = 0; i < genres.n; i++) note(¬es, genres.p[i])->genre = true; + for (size_t i = 0; i < head_entries.n; i++) { + note(¬es, head_entries.p[i].key)->head = tables_str_ptr(head_entries.p[i].value); + } + run_words = tp_new_phrase_table(); + for (size_t i = 0; i < notes.keys.n; i++) { + /* The infos vector no longer grows, so its elements are stable. */ + tp_phrase_table_add(run_words, notes.keys.p[i], ¬es.infos.p[i]); + } + + for (size_t i = 0; i < TP_DATA_JOINERS_SPACED_N; i++) { + const tp_data_joiner *j = &tp_data_joiners_spaced[i]; + tp_spaced_joiner s; + s.raw = j->raw; + s.canonical = j->canonical; + s.is_and = tp_str_eq(j->kind, TP_S("and")); + s.case_sensitive = j->case_sensitive; + tp_push(t->spaced_joiners, s); + } + for (size_t i = 0; i < TP_DATA_JOINERS_TIGHT_N; i++) { + tp_kv e; + e.key = tp_data_joiners_tight[i].raw; + e.value = tp_data_joiners_tight[i].canonical; + tp_push(t->tight_joiners, e); + } + tp_clone(suffixes, + tp_data_strs(tp_data_platform_suffixes_suffixes, TP_DATA_PLATFORM_SUFFIXES_SUFFIXES_N)); + /* JS sorts by UTF-16 length, longest first; the sort is stable. */ + tp_sort_stable(suffixes.p, suffixes.n, sizeof *suffixes.p, by_utf16_len_desc, NULL); + + t->feat_markers = tp_marker_table( + tp_data_strs(tp_data_feat_markers_markers, TP_DATA_FEAT_MARKERS_MARKERS_N), extra_feat); + t->bracket_only_feat = tp_marker_table( + tp_data_strs(tp_data_feat_markers_bracket_only, TP_DATA_FEAT_MARKERS_BRACKET_ONLY_N), empty); + t->producer_markers = tp_marker_table( + tp_data_strs(tp_data_feat_markers_producer, TP_DATA_FEAT_MARKERS_PRODUCER_N), empty); + t->title_feat_markers = tp_marker_table( + tp_data_strs(tp_data_feat_markers_title_markers, TP_DATA_FEAT_MARKERS_TITLE_MARKERS_N), + extra_feat); + t->title_producer_markers = tp_marker_table( + tp_data_strs(tp_data_feat_markers_title_producer, TP_DATA_FEAT_MARKERS_TITLE_PRODUCER_N), + empty); + both[0] = junk_entries; /* junk first: it wins over a genre */ + both[1] = genre_entries; + t->junk_or_genre = tp_kind_table(both, 2); + t->junk_phrases = tp_kind_table(&junk_entries, 1); + t->junk_connectors = word_set(tp_data_junk_connectors, TP_DATA_JUNK_CONNECTORS_N); + t->label_suffixes = word_set(tp_data_junk_label_suffixes, TP_DATA_JUNK_LABEL_SUFFIXES_N); + t->heads = tp_kind_table(&head_entries, 1); + t->generic_head_types = + word_set(tp_data_version_keywords_generic_heads, TP_DATA_VERSION_KEYWORDS_GENERIC_HEADS_N); + t->run_words = run_words; + prefix_entries = tp_data_entries(tp_data_version_keywords_prefix_forms, + TP_DATA_VERSION_KEYWORDS_PREFIX_FORMS_N); + t->prefix_forms = tp_kind_table(&prefix_entries, 1); + t->feat_canonical = TP_DATA_JOINERS_FEAT_CANONICAL; + t->no_split_before = word_set(tp_data_no_split_before_words, TP_DATA_NO_SPLIT_BEFORE_WORDS_N); + t->stopwords = word_set(tp_data_stopwords_words, TP_DATA_STOPWORDS_WORDS_N); + t->unknown_case_sensitive = + word_set(tp_data_unknown_tokens_case_sensitive, TP_DATA_UNKNOWN_TOKENS_CASE_SENSITIVE_N); + t->unknown_case_insensitive = + word_set(tp_data_unknown_tokens_case_insensitive, TP_DATA_UNKNOWN_TOKENS_CASE_INSENSITIVE_N); + t->extensions = word_set(tp_data_extensions_extensions, TP_DATA_EXTENSIONS_EXTENSIONS_N); + t->platform_suffixes = suffixes; + return t; +} + +static void *build_default_tables(void) { return tp_build_tables(NULL); } + +static tp_once default_tables_once = TP_ONCE_INIT; + +/* defaultTables are the tables without keywords, built once. */ +TP_PRIVATE const tp_tables *tp_default_tables(void) { + const tp_tables *t = tp_once_get(&default_tables_once, build_default_tables); + if (t == NULL) t = tp_build_tables(NULL); + return t; +} + +TP_PRIVATE const tp_tables *tp_tables_for(const tp_keyword_lists *kw) { + if (kw == NULL) return tp_default_tables(); + return tp_build_tables(kw); +} + +/* isUnknownToken is R7.5 / R8.6: an unknown placeholder name (ID, ???, Untitled...). */ +TP_PRIVATE bool tp_is_unknown_token(tp_str text, const tp_tables *t) { + return tp_word_set_has(&t->unknown_case_sensitive, text) || + tp_word_set_has(&t->unknown_case_insensitive, tp_ascii_lower(text)); +} diff --git a/c/src/title.c b/c/src/title.c new file mode 100644 index 0000000..3c3a253 --- /dev/null +++ b/c/src/title.c @@ -0,0 +1,323 @@ +/* title.c: R8 the title side (go/title.go, js/src/title.ts). */ +#include "internal.h" + +/* setFlag records an Explicit or Clean flag. */ +TP_PRIVATE void tp_extracted_set_flag(tp_extracted *out, tp_flag f) { + switch (f) { + case TP_FLAG_EXPLICIT: + out->explicit_ = true; + break; + case TP_FLAG_CLEAN: + out->clean = true; + break; + } +} + +/* addPeeled records R6.2 / R8.2 peeled dash suffixes. */ +TP_PRIVATE void tp_add_peeled(tp_extracted *out, tp_peeled_vec list) { + for (size_t i = 0; i < list.n; i++) { + const tp_peeled *p = &list.p[i]; + switch (p->cls.kind) { + case TP_CLASS_VERSIONS: + tp_append(out->versions, p->cls.versions); + break; + case TP_CLASS_JUNK: { + tp_positioned_junk j; + j.raw = p->raw; + j.kind = p->cls.junk; + j.pos = p->pos; + tp_push(out->junk, j); + break; + } + case TP_CLASS_FLAG: + tp_extracted_set_flag(out, p->cls.flag); + break; + case TP_CLASS_YEAR: { + tp_positioned_year y; + y.year = p->cls.year; + y.pos = p->pos; + tp_push(out->years, y); + break; + } + default: + break; + } + } +} + +/* parseTitleSide is R8. relaxed: an artist side was split off (R8.2 peels without conditions). */ +TP_PRIVATE tp_title_side_result tp_parse_title_side(tp_skel input, bool relaxed, bool youtube, + tp_extracted *out, tp_ctx *c) { + tp_idxvec removed = tp_extract_groups(input, out, c); /* R8.1 */ + + /* R8.2 */ + tp_segment_vec segments = tp_split_at_spaced_dashes(&input, false); + tp_peeled_vec p; + tp_segment_vec remaining = tp_peel_suffixes(segments, relaxed, c, &p); + tp_add_peeled(out, p); + ptrdiff_t last_kept_end = 0; + if (remaining.n > 0) last_kept_end = tp_last(remaining).end; + tp_skel sk = tp_slice_skel(&input, 0, last_kept_end); + + sk = tp_extract_unbracketed_credits(sk, out, c); /* R8.3 */ + sk = tp_remove_groups(&sk, removed); + if (youtube) sk = tp_strip_trailing_junk(sk, out, c); /* R8.4 */ + + tp_title_side_result r; + r.title = tp_cleanup_title(tp_render_skel(&sk)); /* R8.5 */ + r.unknown_title = r.title.n > 0 && tp_is_unknown_token(r.title, c->t); /* R8.6 */ + return r; +} + +/* extractGroups is R8.1: classify every group. It gives the offsets of the groups to remove, + * ascending. */ +TP_PRIVATE tp_idxvec tp_extract_groups(tp_skel sk, tp_extracted *out, tp_ctx *c) { + tp_idxvec removed = {0}; + tp_indexed_group_vec groups = tp_groups_of(&sk); + for (size_t i = 0; i < groups.n; i++) { + const tp_group *g = groups.p[i].group; + tp_site s; + s.source = TP_SOURCE_TITLE; + s.delimiter = g->open; + s.pos = g->pos; + tp_classification cls = tp_classify(g->inner, s, c); + switch (cls.kind) { + case TP_CLASS_VERSIONS: + tp_append(out->versions, cls.versions); + break; + case TP_CLASS_JUNK: { + tp_positioned_junk j; + j.raw = g->inner; + j.kind = cls.junk; + j.pos = g->pos; + tp_push(out->junk, j); + break; + } + case TP_CLASS_FLAG: + tp_extracted_set_flag(out, cls.flag); + break; + case TP_CLASS_YEAR: { + tp_positioned_year y; + y.year = cls.year; + y.pos = g->pos; + tp_push(out->years, y); + break; + } + case TP_CLASS_FEAT: + case TP_CLASS_PRODUCER: + tp_append(out->credits, cls.list.credits); + tp_append(out->years, cls.list.years); + if (cls.list.unknown) out->unknown_artist = true; + break; + default: + continue; + } + /* A set (Go map[int]struct{}), kept ascending for tp_sorted_has. */ + size_t k = removed.n; + while (k > 0 && removed.p[k - 1] > g->pos) k--; + if (k > 0 && removed.p[k - 1] == g->pos) continue; + tp_insert(removed, k, g->pos); + } + return removed; +} + +/* titleMarkers are the R8.3 markers, left to right, each with a space on both sides: feat + * markers from title_feat_markers ("feat.", "ft.", "featuring"; undotted feat and ft stay text) + * and producer markers from title_producer_markers ("prod.", "prod. by", "produced by", + * "prod.by"). */ +TP_PRIVATE tp_marker_hit_vec tp_title_markers(tp_skel sk, tp_ctx *c) { + tp_word_span_vec spans = tp_word_spans(sk.text); + tp_strvec words = tp_span_texts(spans); + tp_marker_hit_vec hits = {0}; + ptrdiff_t n = (ptrdiff_t)spans.n; + for (ptrdiff_t i = 0; i < n;) { + tp_word_span span = spans.p[i]; + ptrdiff_t step = i + 1; + if (tp_before(sk.text, span.start) != ' ') { + i = step; + continue; + } + tp_role role; + ptrdiff_t last_index = 0; + tp_phrase_match m; + if (tp_phrase_table_match_at(c->t->title_feat_markers, words, i, &m)) { + role = TP_ROLE_FEATURED; + last_index = i + m.length - 1; + } else if (tp_phrase_table_match_at(c->t->title_producer_markers, words, i, &m)) { + role = TP_ROLE_PRODUCER; + last_index = i + m.length - 1; + } else { + i = step; + continue; + } + if (last_index < 0 || last_index >= n) { + i = step; + continue; + } + tp_word_span last = spans.p[last_index]; + if (tp_at(sk.text, last.end) != ' ') { + i = step; + continue; + } + tp_marker_hit h; + h.start = span.start; + h.end = last.end; + h.marker = tp_runes_str(tp_sub(sk.text, span.start, last.end)); + h.role = role; + tp_push(hits, h); + i = last_index + 1; + } + return hits; +} + +/* Go closure nextGroupAt of extractUnbracketedCredits. */ +static ptrdiff_t next_group_at(const ptrdiff_t *next_group, ptrdiff_t n, ptrdiff_t k) { + if (k >= 0 && k <= n) return next_group[k]; + return n; +} + +typedef struct credit_cut { + ptrdiff_t start, end; +} credit_cut; +typedef TP_VEC(credit_cut) credit_cut_vec; + +/* extractUnbracketedCredits is R8.3: "Title feat. X" and "Title prod. by Y" become credits, + * removed from the title. A list runs to the next placeholder, the next marker of the other + * kind, or the end; later feat markers inside a featured list are joiners (R7.2). */ +TP_PRIVATE tp_skel tp_extract_unbracketed_credits(tp_skel input, tp_extracted *out, tp_ctx *c) { + tp_marker_hit_vec markers = tp_title_markers(input, c); + if (markers.n == 0) return input; + /* indexOf(PH, from) for every from, computed once so many markers stay linear (R0.8). */ + ptrdiff_t n = (ptrdiff_t)input.text.n; + ptrdiff_t *next_group = tp_alloc_array((size_t)n + 1, sizeof *next_group); + next_group[n] = n; + for (ptrdiff_t k = n - 1; k >= 0; k--) { + next_group[k] = input.text.p[k] == TP_PH ? k : next_group[k + 1]; + } + credit_cut_vec cuts = {0}; + ptrdiff_t count = (ptrdiff_t)markers.n; + for (ptrdiff_t i = 0; i < count;) { + tp_marker_hit hit = markers.p[i]; + ptrdiff_t list_end = next_group_at(next_group, n, hit.end); + for (ptrdiff_t k = i + 1; k < count; k++) { + const tp_marker_hit *m = &markers.p[k]; + if (!tp_str_eq(m->role, hit.role) && m->start >= hit.end) { + if (m->start < list_end) list_end = m->start; + break; + } + } + tp_skel part = tp_slice_skel(&input, hit.end, list_end); + tp_skel list = tp_trim_skel(&part); + if (!tp_skel_is_empty(&list)) { + tp_str *marker = tp_alloc(sizeof *marker); + *marker = hit.marker; + tp_list_options opts; + memset(&opts, 0, sizeof opts); + opts.role = hit.role; + opts.source = TP_SOURCE_TITLE; + opts.lead = marker; + opts.split_with = false; + opts.feat_markers_join = tp_str_eq(hit.role, TP_ROLE_FEATURED); + tp_list_result r = tp_split_credits(&list, &opts, c); + tp_append(out->credits, r.credits); + tp_append(out->years, r.years); + if (r.unknown) out->unknown_artist = true; + credit_cut k = {hit.start, list_end}; + tp_push(cuts, k); + } else { + list_end = hit.end; + } + while (i < count && markers.p[i].start < list_end) i++; + } + /* The cuts are disjoint and ascending: remove them in one pass. */ + tp_runevec text = {0}; + tp_idxvec pos = {0}; + ptrdiff_t from = 0; + for (size_t ci = 0; ci < cuts.n; ci++) { + credit_cut k = cuts.p[ci]; + ptrdiff_t start = k.start < n ? k.start : n; + if (start < from) start = from; + tp_runes tr = tp_clamped_runes(input.text, from, start); + if (tr.n) memcpy(tp_push_n(text, tr.n), tr.p, tr.n * sizeof *tr.p); + tp_idxvec pr = tp_clamped_ints(input.pos, from, start); + tp_append(pos, pr); + ptrdiff_t e = k.end < n ? k.end : n; + if (e > from) from = e; + } + tp_runes tr = tp_clamped_runes(input.text, from, n); + if (tr.n) memcpy(tp_push_n(text, tr.n), tr.p, tr.n * sizeof *tr.p); + tp_idxvec pr = tp_clamped_ints(input.pos, from, (ptrdiff_t)input.pos.n); + tp_append(pos, pr); + tp_skel res; + res.text = tp_runevec_view(text); + res.pos = pos; + res.groups = input.groups; + return res; +} + +/* stripTrailingJunk is R8.4: strip trailing unbracketed junk phrases (optionally after a lone "-" + * or "|"). Word spans are computed once and walked backwards, so repeated junk stays linear + * (R0.8). */ +TP_PRIVATE tp_skel tp_strip_trailing_junk(tp_skel input, tp_extracted *out, tp_ctx *c) { + tp_skel sk = tp_trim_skel(&input); + tp_word_span_vec spans = tp_word_spans(sk.text); + tp_strvec words = tp_span_texts(spans); + ptrdiff_t nspans = (ptrdiff_t)spans.n; + ptrdiff_t end = nspans; /* words still in the title */ + for (;;) { + tp_phrase_match m; + if (!tp_phrase_table_match_ending(c->t->junk_phrases, words, end, &m)) break; + ptrdiff_t first = end - (m.length < end ? m.length : end); + ptrdiff_t keep = first; + if (keep > 0 && tp_is_lone_edge(words.p[keep - 1])) keep--; + if (keep == 0) break; /* never strip the whole title */ + ptrdiff_t from = 0; + if (first < nspans) from = spans.p[first].start; + ptrdiff_t to = (ptrdiff_t)sk.text.n; + if (end >= 1 && end - 1 < nspans) to = spans.p[end - 1].end; + ptrdiff_t p = 0; + if (from < (ptrdiff_t)sk.pos.n) p = sk.pos.p[from]; + tp_positioned_junk j; + j.raw = tp_collapse_runes(tp_sub(sk.text, from, to)); + j.kind = *(const tp_str *)m.value; + j.pos = p; + tp_push(out->junk, j); + end = keep; + } + if (end == nspans) return sk; + ptrdiff_t cut_at = 0; + if (end >= 1 && end - 1 < nspans) cut_at = spans.p[end - 1].end; + tp_skel kept = tp_slice_skel(&sk, 0, cut_at); + return tp_trim_skel(&kept); +} + +/* isLoneEdge reports whether a word is a lone "-" or "|". */ +TP_PRIVATE bool tp_is_lone_edge(tp_str word) { + return tp_str_eq(word, TP_S("-")) || tp_str_eq(word, TP_S("|")); +} + +/* stripLoneEdges removes lone "-" and "|" words at both ends of a space-separated string. */ +TP_PRIVATE tp_str tp_strip_lone_edges(tp_str s) { + tp_strvec words = tp_split(s, TP_S(" ")); + size_t a = 0, b = words.n; + while (a < b && tp_is_lone_edge(words.p[a])) a++; + while (b > a && tp_is_lone_edge(words.p[b - 1])) b--; + tp_strvec mid; + mid.p = words.p + a; + mid.n = b - a; + mid.cap = mid.n; + return tp_join(mid, TP_S(" ")); +} + +/* cleanupTitle is R8.5. */ +TP_PRIVATE tp_str tp_cleanup_title(tp_str raw) { + tp_str title = tp_strip_lone_edges(tp_collapse_spaces(raw)); + tp_runes t = tp_runes_of(title); + if (t.n >= 2) { + tp_rune q = t.p[0], last = t.p[t.n - 1]; + if ((q == '"' || q == '\'') && last == q) { + return tp_strip_lone_edges(tp_collapse_runes(tp_sub(t, 1, (ptrdiff_t)t.n - 1))); + } + } + return title; +} diff --git a/c/src/tl_edits.c b/c/src/tl_edits.c new file mode 100644 index 0000000..5d164d5 --- /dev/null +++ b/c/src/tl_edits.c @@ -0,0 +1,509 @@ +/* tl_edits.c: R13.9, applyEdits (go/tl_edits.go). Edits apply in order, each to the result of + * the previous one. + * + * Edits are read as loose JSON objects with the number rules of the JS reference (a bool is not + * a number; null, NaN and infinities are invalid). Typed edits are turned into that form first + * (tp_edit_json), so both doors share one code path. */ +#include "internal.h" + +/* An absent key reads as the zero (null) value, as Go's get returns jsonValue{}. */ +static tp_json tl_get(tp_json v, const char *key, bool *present) { + tp_json out = tp_json_null(); + *present = tp_json_get(v, tp_str_c(key), &out); + if (!*present) out = tp_json_null(); + return out; +} + +TP_PRIVATE tp_work_line *tp_new_work_line(tp_str raw, tp_eol eol, bool changed) { + tp_work_line *l = tp_alloc(sizeof *l); + l->raw = raw; + l->eol = eol; + l->changed = changed; + l->scan = tp_scan_time(raw); + return l; +} + +/* eolSlot is the index of eol in edit_ctx.eols, -1 for none. */ +TP_PRIVATE ptrdiff_t tp_eol_slot(tp_eol eol) { + if (tp_str_eq(eol, TP_EOL_LF)) return 0; + if (tp_str_eq(eol, TP_EOL_CRLF)) return 1; + if (tp_str_eq(eol, TP_EOL_CR)) return 2; + return -1; +} + +/* countHours adds (by = 1) or removes (by = -1) a time from the hour-width counts (R13.9.2). */ +TP_PRIVATE void tp_edit_ctx_count_hours(tp_edit_ctx *c, const tp_time_scan *s, ptrdiff_t by) { + if (s->style == NULL || !s->style->hours) return; + if (s->style->hour_width == 1) { + c->one_digit += by; + } else { + c->wide_hours += by; + } +} + +TP_PRIVATE void tp_edit_ctx_count_eol(tp_edit_ctx *c, tp_eol eol, ptrdiff_t by) { + ptrdiff_t k = tp_eol_slot(eol); + if (k >= 0) c->eols[k] += by; +} + +/* countLine is a line entering (by = 1) or leaving (by = -1) the text. */ +TP_PRIVATE void tp_edit_ctx_count_line(tp_edit_ctx *c, const tp_work_line *l, ptrdiff_t by) { + tp_edit_ctx_count_hours(c, &l->scan, by); + tp_edit_ctx_count_eol(c, l->eol, by); +} + +TP_PRIVATE void tp_edit_ctx_set_eol(tp_edit_ctx *c, tp_work_line *l, tp_eol eol) { + tp_edit_ctx_count_eol(c, l->eol, -1); + l->eol = eol; + l->changed = true; + tp_edit_ctx_count_eol(c, eol, 1); +} + +TP_PRIVATE void tp_edit_ctx_set_raw(tp_edit_ctx *c, tp_work_line *l, tp_str raw) { + tp_edit_ctx_count_hours(c, &l->scan, -1); + l->raw = raw; + l->scan = tp_scan_time(raw); + l->changed = true; + tp_edit_ctx_count_hours(c, &l->scan, 1); +} + +/* line is copied into the arena (Go's &line escapes to the heap). */ +TP_PRIVATE void tp_edit_ctx_warn(tp_edit_ctx *c, tp_edit_warning_code code, const double *line) { + tp_raw_edit_warning w; + w.code = code; + w.edit = c->index; + w.line = NULL; + if (line) { + double *p = tp_alloc(sizeof *p); + *p = *line; + w.line = p; + } + tp_push(c->warnings, w); +} + +/* lineIndex is the 0-based index of an existing 1-based line number. */ +TP_PRIVATE bool tp_edit_ctx_line_index(const tp_edit_ctx *c, tp_json v, bool present, + ptrdiff_t *out) { + double n; + if (!tp_js_integer(v, present, &n) || n < 1 || n > (double)c->lines.n) return false; + *out = (ptrdiff_t)n - 1; + return true; +} + +/* oneDigitHours is R13.9.2: do the text's times with hours all use one-digit hours (and is there + * at least one)? */ +TP_PRIVATE bool tp_edit_ctx_one_digit_hours(const tp_edit_ctx *c) { + return c->one_digit > 0 && c->wide_hours == 0; +} + +/* singleLine is a string without a line break. */ +TP_PRIVATE bool tp_single_line(tp_json v, bool present, tp_str *out) { + if (!present || v.kind != TP_JSON_STRING || tp_has_line_break(v.str)) return false; + *out = v.str; + return true; +} + +/* retime is R13.9.2 / R13.9.3: the rewritten line for a new value; false when it cannot be + * written. */ +TP_PRIVATE bool tp_edit_ctx_retime(tp_edit_ctx *c, ptrdiff_t index, double value, bool one_digit, + tp_retimed *out) { + const tp_time_scan *s; + const tp_parts *p; + bool clamped; + tp_formatted_time f; + tp_buf b = {0}; + if (index < 0 || index >= (ptrdiff_t)c->lines.n) return false; + s = &c->lines.p[index]->scan; + if (s->style == NULL || s->time == NULL) return false; + clamped = value < 0; + if (clamped) value = 0; + if (!tp_format_time(value, s->style, one_digit, &f)) return false; + p = &s->parts; + tp_buf_str(&b, p->lead); + tp_buf_str(&b, f.raw); + tp_buf_str(&b, p->gap); + tp_buf_str(&b, p->rest); + out->index = index; + out->raw = tp_buf_done(&b); + out->clamped = clamped; + out->upgraded = f.upgraded; + return true; +} + +TP_PRIVATE void tp_edit_ctx_commit(tp_edit_ctx *c, tp_retimed_vec changes) { + for (size_t k = 0; k < changes.n; k++) { + const tp_retimed *ch = &changes.p[k]; + double line = (double)(ch->index + 1); + tp_edit_ctx_set_raw(c, c->lines.p[ch->index], ch->raw); + if (ch->clamped) tp_edit_ctx_warn(c, TP_EDIT_WARNING_CODE_TIME_CLAMPED, &line); + if (ch->upgraded) tp_edit_ctx_warn(c, TP_EDIT_WARNING_CODE_STYLE_UPGRADED, &line); + } +} + +TP_PRIVATE bool tp_edit_ctx_set_time(tp_edit_ctx *c, tp_json edit, tp_touched *out) { + bool present; + tp_json v; + ptrdiff_t index; + double value; + tp_retimed change; + tp_retimed_vec changes = {0}; + v = tl_get(edit, "line", &present); + if (!tp_edit_ctx_line_index(c, v, present, &index)) return false; + v = tl_get(edit, "seconds", &present); + if (!tp_js_finite(v, present, &value)) return false; + if (!tp_edit_ctx_retime(c, index, value, tp_edit_ctx_one_digit_hours(c), &change)) return false; + tp_push(changes, change); + tp_edit_ctx_commit(c, changes); + memset(out, 0, sizeof *out); /* a timed line is never empty and keeps its eol */ + return true; +} + +static int tl_idx_cmp(const void *a, const void *b, void *ctx) { + ptrdiff_t x = *(const ptrdiff_t *)a, y = *(const ptrdiff_t *)b; + (void)ctx; + return x < y ? -1 : x > y ? 1 : 0; +} + +/* slices.Sort + slices.Compact on an index list, in place. */ +static void tl_sort_compact(tp_idxvec *v) { + size_t w = 0; + if (v->n < 2) return; + tp_sort_stable(v->p, v->n, sizeof *v->p, tl_idx_cmp, NULL); + for (size_t r = 0; r < v->n; r++) { + if (w == 0 || v->p[w - 1] != v->p[r]) v->p[w++] = v->p[r]; + } + v->n = w; +} + +TP_PRIVATE bool tp_edit_ctx_shift(tp_edit_ctx *c, tp_json edit, tp_touched *out) { + bool present, one_digit; + tp_json v; + double delta; + tp_idxvec targets = {0}; + tp_retimed_vec changes = {0}; + v = tl_get(edit, "seconds", &present); + if (!tp_js_finite(v, present, &delta)) return false; + v = tl_get(edit, "lines", &present); + if (present) { + if (v.kind != TP_JSON_ARRAY) return false; + for (size_t k = 0; k < v.arr_n; k++) { + ptrdiff_t i; + if (!tp_edit_ctx_line_index(c, v.arr[k], true, &i)) return false; + tp_push(targets, i); + } + tl_sort_compact(&targets); + } else { + ptrdiff_t from = 0; + v = tl_get(edit, "from", &present); + if (present && !tp_edit_ctx_line_index(c, v, true, &from)) return false; + for (ptrdiff_t i = from; i < (ptrdiff_t)c->lines.n; i++) tp_push(targets, i); + } + one_digit = tp_edit_ctx_one_digit_hours(c); + for (size_t k = 0; k < targets.n; k++) { + ptrdiff_t i = targets.p[k]; + const tp_tracklist_time *t = c->lines.p[i]->scan.time; + tp_retimed change; + if (t == NULL) continue; + if (!tp_edit_ctx_retime(c, i, t->seconds + delta, one_digit, &change)) return false; + tp_push(changes, change); + } + tp_edit_ctx_commit(c, changes); + memset(out, 0, sizeof *out); + return true; +} + +/* cmp.Compare on float64: NaN sorts before every other value and equals itself. */ +static int tl_block_cmp(const void *a, const void *b, void *ctx) { + double x = ((const tp_time_block *)a)->seconds, y = ((const tp_time_block *)b)->seconds; + bool xn = tp_is_nan(x), yn = tp_is_nan(y); + (void)ctx; + if (xn || yn) return xn && yn ? 0 : xn ? -1 : 1; + return x < y ? -1 : x > y ? 1 : 0; +} + +/* sortByTime is R13.9.4: a stable sort of the blocks. */ +TP_PRIVATE tp_touched tp_edit_ctx_sort_by_time(tp_edit_ctx *c) { + tp_touched t; + ptrdiff_t first = -1, n = (ptrdiff_t)c->lines.n; + tp_time_block_vec blocks = {0}; + tp_idxvec order = {0}; + tp_work_line_ptr_vec old = c->lines, lines = {0}; + memset(&t, 0, sizeof t); + for (ptrdiff_t i = 0; i < n; i++) { + if (c->lines.p[i]->scan.time != NULL) { + first = i; + break; + } + } + if (first < 0) return t; + for (ptrdiff_t i = first; i < n; i++) { + const tp_tracklist_time *tm = c->lines.p[i]->scan.time; + if (tm) { + tp_time_block b; + b.seconds = tm->seconds; + b.from = i; + b.to = i + 1; + tp_push(blocks, b); + } else if (blocks.n > 0) { + tp_last(blocks).to = i + 1; + } + } + /* Stable: equal times keep their order. */ + tp_sort_stable(blocks.p, blocks.n, sizeof *blocks.p, tl_block_cmp, NULL); + for (ptrdiff_t i = 0; i < first; i++) tp_push(order, i); + for (size_t k = 0; k < blocks.n; k++) { + for (ptrdiff_t i = blocks.p[k].from; i < blocks.p[k].to; i++) tp_push(order, i); + } + for (size_t slot = 0; slot < order.n; slot++) { + ptrdiff_t src = order.p[slot]; + const tp_work_line *l; + tp_work_line *nl; + if (src < 0 || src >= (ptrdiff_t)old.n || slot >= old.n) continue; + l = old.p[src]; + nl = tp_alloc(sizeof *nl); + nl->raw = l->raw; + nl->eol = old.p[slot]->eol; /* eol values stay in their slots */ + nl->changed = l->changed || src != (ptrdiff_t)slot; + nl->scan = l->scan; + tp_push(lines, nl); + } + c->lines = lines; + t.all = true; + return t; +} + +TP_PRIVATE bool tp_edit_ctx_set_rest(tp_edit_ctx *c, tp_json edit, tp_touched *out) { + bool present, spaced = false; + tp_json v; + ptrdiff_t index; + tp_str rest; + tp_work_line *l; + tp_parts p; + tp_buf b = {0}; + v = tl_get(edit, "line", &present); + if (!tp_edit_ctx_line_index(c, v, present, &index)) return false; + v = tl_get(edit, "rest", &present); + if (!tp_single_line(v, present, &rest)) return false; + l = c->lines.p[index]; + p = l->scan.parts; + /* R13.9 set-rest: a non-empty rest after a time is preceded by whitespace; a gap that does not + * end with R0.2 whitespace ("", "]", ")") gets one space. */ + if (p.gap.n > 0) { + size_t len; + spaced = tp_is_whitespace(tp_decode_last_rune(p.gap, &len)); + } + tp_buf_str(&b, p.lead); + tp_buf_str(&b, p.time); + tp_buf_str(&b, p.gap); + if (p.time.n > 0 && !spaced && rest.n > 0) tp_buf_byte(&b, ' '); + tp_buf_str(&b, rest); + tp_edit_ctx_set_raw(c, l, tp_buf_done(&b)); + memset(out, 0, sizeof *out); + tp_push(out->lines, index); + return true; +} + +/* Go commonEol's closure isTop. */ +static bool tl_is_top(const tp_edit_ctx *c, tp_eol eol, ptrdiff_t best) { + ptrdiff_t k = tp_eol_slot(eol); + return k >= 0 && c->eols[k] == best; +} + +/* commonEol is R13.9.5: the most common non-empty eol (ties: the one seen first in line order), + * "\n" if none. The counts are kept up to date; only a tie needs a look at the lines. */ +TP_PRIVATE tp_eol tp_edit_ctx_common_eol(const tp_edit_ctx *c) { + ptrdiff_t best = c->eols[0]; + tp_eol all[3]; + tp_eol top = TP_EOL_LF; + int ntop = 0; + if (c->eols[1] > best) best = c->eols[1]; + if (c->eols[2] > best) best = c->eols[2]; + if (best <= 0) return TP_EOL_LF; + all[0] = TP_EOL_LF; + all[1] = TP_EOL_CRLF; + all[2] = TP_EOL_CR; + for (int k = 0; k < 3; k++) { + if (tl_is_top(c, all[k], best)) { + if (ntop == 0) top = all[k]; + ntop++; + } + } + if (ntop == 1) return top; + for (size_t i = 0; i < c->lines.n; i++) { + if (tl_is_top(c, c->lines.p[i]->eol, best)) return c->lines.p[i]->eol; + } + return TP_EOL_LF; +} + +TP_PRIVATE bool tp_edit_ctx_insert(tp_edit_ctx *c, tp_json edit, tp_touched *out) { + bool present; + tp_json v; + double after; + tp_str text; + ptrdiff_t pos, count = (ptrdiff_t)c->lines.n; + tp_eol eol, line_eol; + tp_work_line *line; + v = tl_get(edit, "after", &present); + if (!tp_js_integer(v, present, &after) || after < 0 || after > (double)count) return false; + v = tl_get(edit, "text", &present); + if (!tp_single_line(v, present, &text)) return false; + pos = (ptrdiff_t)after; + eol = tp_edit_ctx_common_eol(c); + /* R13.9.5: inserting into an empty text keeps it without a trailing newline. */ + line_eol = count == 0 ? TP_EOL_NONE : eol; + line = tp_new_work_line(text, line_eol, true); + if (pos == count && count > 0 && tp_str_eq(c->lines.p[count - 1]->eol, TP_EOL_NONE)) { + tp_edit_ctx_set_eol(c, c->lines.p[count - 1], eol); + line->eol = TP_EOL_NONE; + } + tp_edit_ctx_count_line(c, line, 1); + tp_insert(c->lines, (size_t)pos, line); + memset(out, 0, sizeof *out); + tp_push(out->lines, pos); + return true; +} + +TP_PRIVATE bool tp_edit_ctx_remove(tp_edit_ctx *c, tp_json edit, tp_touched *out) { + bool present; + tp_json v; + ptrdiff_t index, count; + tp_work_line *gone; + v = tl_get(edit, "line", &present); + if (!tp_edit_ctx_line_index(c, v, present, &index)) return false; + gone = c->lines.p[index]; + tp_remove(c->lines, (size_t)index, (size_t)index + 1); + tp_edit_ctx_count_line(c, gone, -1); + count = (ptrdiff_t)c->lines.n; + if (index == count && count > 0 && !tp_str_eq(c->lines.p[count - 1]->eol, gone->eol)) { + /* R13.9.5: the deleted last line's eol moves up */ + tp_edit_ctx_set_eol(c, c->lines.p[count - 1], gone->eol); + } + memset(out, 0, sizeof *out); + tp_push(out->lines, index); + return true; +} + +/* mergeAt joins a "\r" line followed by an empty "\n" line into one CRLF line, as a re-split + * would read them. */ +TP_PRIVATE void tp_edit_ctx_merge_at(tp_edit_ctx *c, ptrdiff_t k) { + tp_work_line *prev, *next; + if (k < 0 || k + 1 >= (ptrdiff_t)c->lines.n) return; + prev = c->lines.p[k]; + next = c->lines.p[k + 1]; + if (!tp_str_eq(prev->eol, TP_EOL_CR) || next->raw.n != 0 || !tp_str_eq(next->eol, TP_EOL_LF)) { + return; + } + tp_edit_ctx_set_eol(c, prev, TP_EOL_CRLF); + tp_remove(c->lines, (size_t)k + 1, (size_t)k + 2); + tp_edit_ctx_count_line(c, next, -1); +} + +/* canonical is R13.9.5: keep the work lines equal to what splitLines(join(lines)) would give. A + * "\r" followed by an empty "\n" line reads back as one CRLF, and an empty last line without eol + * is not a line. The lines are canonical before each edit, so only the neighbourhood of the + * lines the edit touched (and the end) is checked; all checks every line. */ +TP_PRIVATE void tp_edit_ctx_canonical(tp_edit_ctx *c, tp_touched t) { + ptrdiff_t count = (ptrdiff_t)c->lines.n; + /* Descending, so a merge at k never moves a pair still to be checked. */ + tp_idxvec starts = {0}; + if (t.all) { + for (ptrdiff_t k = count - 2; k >= 0; k--) tp_push(starts, k); + } else { + tp_push(starts, count - 2); + for (size_t k = 0; k < t.lines.n; k++) { + tp_push(starts, t.lines.p[k] - 1); + tp_push(starts, t.lines.p[k]); + } + tl_sort_compact(&starts); + for (size_t a = 0, b = starts.n; a + 1 < b; a++, b--) { + ptrdiff_t x = starts.p[a]; + starts.p[a] = starts.p[b - 1]; + starts.p[b - 1] = x; + } + } + for (size_t k = 0; k < starts.n; k++) tp_edit_ctx_merge_at(c, starts.p[k]); + if (c->lines.n > 0) { + tp_work_line *last = tp_last(c->lines); + if (last->raw.n == 0 && tp_str_eq(last->eol, TP_EOL_NONE)) { + c->lines.n--; + tp_edit_ctx_count_line(c, last, -1); + } + } +} + +/* applyOne applies one edit; false when it is invalid (R13.9.6). */ +TP_PRIVATE bool tp_edit_ctx_apply_one(tp_edit_ctx *c, tp_json edit, tp_touched *out) { + tp_str op = TP_EMPTY; + if (edit.kind != TP_JSON_OBJECT) return false; + (void)tp_json_get_string(edit, TP_S("op"), &op); + if (tp_str_eq(op, TP_EDIT_OP_SET_TIME)) return tp_edit_ctx_set_time(c, edit, out); + if (tp_str_eq(op, TP_EDIT_OP_SHIFT)) return tp_edit_ctx_shift(c, edit, out); + if (tp_str_eq(op, TP_EDIT_OP_SORT_BY_TIME)) { + *out = tp_edit_ctx_sort_by_time(c); + return true; + } + if (tp_str_eq(op, TP_EDIT_OP_SET_REST)) return tp_edit_ctx_set_rest(c, edit, out); + if (tp_str_eq(op, TP_EDIT_OP_INSERT)) return tp_edit_ctx_insert(c, edit, out); + if (tp_str_eq(op, TP_EDIT_OP_DELETE)) return tp_edit_ctx_remove(c, edit, out); + return false; +} + +/* invalidLine is R13.9.6: the line of an edit-invalid warning is the edit's integer line, else + * its integer after, else none. */ +TP_PRIVATE const double *tp_invalid_line(tp_json edit) { + static const char *const keys[2] = {"line", "after"}; + for (size_t k = 0; k < 2; k++) { + bool present; + tp_json v = tl_get(edit, keys[k], &present); + double n; + if (tp_js_integer(v, present, &n)) { + double *p = tp_alloc(sizeof *p); + *p = n; + return p; + } + } + return NULL; +} + +/* applyEdits is R13.9 on one (already sanitized) text: apply edits (loose JSON objects) in + * order. Never fails (R13.9.6): an invalid edit changes nothing and warns edit-invalid. */ +TP_PRIVATE tp_raw_edit_result tp_apply_edits(tp_str text, const tp_json *edits, size_t count) { + tp_raw_edit_result r; + tp_edit_ctx *c; + tp_tl_line_vec split; + tp_buf b = {0}; + memset(&r, 0, sizeof r); + if (count == 0) { + r.text = text; + return r; + } + c = tp_alloc(sizeof *c); + split = tp_split_lines(text); + for (size_t i = 0; i < split.n; i++) { + tp_work_line *line = tp_new_work_line(split.p[i].raw, split.p[i].eol, false); + tp_edit_ctx_count_line(c, line, 1); + tp_push(c->lines, line); + } + for (size_t i = 0; i < count; i++) { + size_t before = c->warnings.n; + tp_touched t; + memset(&t, 0, sizeof t); + c->index = (ptrdiff_t)i; + /* Validation fails before any mutation, so the lines need no rollback (R13.9.6). */ + if (tp_edit_ctx_apply_one(c, edits[i], &t)) { + tp_edit_ctx_canonical(c, t); + } else { + c->warnings.n = before; + tp_edit_ctx_warn(c, TP_EDIT_WARNING_CODE_EDIT_INVALID, tp_invalid_line(edits[i])); + } + } + for (size_t i = 0; i < c->lines.n; i++) { + const tp_work_line *l = c->lines.p[i]; + if (l->changed) tp_push(r.changed, (int64_t)i + 1); + tp_buf_str(&b, l->raw); + tp_buf_str(&b, l->eol); + } + r.text = tp_buf_done(&b); + r.warnings = c->warnings; + return r; +} diff --git a/c/src/tl_emphasis.c b/c/src/tl_emphasis.c new file mode 100644 index 0000000..ebae3b3 --- /dev/null +++ b/c/src/tl_emphasis.c @@ -0,0 +1,115 @@ +/* tl_emphasis.c: R13.12, Markdown emphasis markers in a tracklist line (go/tl_emphasis.go). */ +#include "internal.h" + +/* runLength is the length of the maximal run of '*' or '_' at from (0 when there is none). */ +TP_PRIVATE ptrdiff_t tp_run_length(tp_runes s, ptrdiff_t from) { + tp_rune ch = tp_at(s, from); + ptrdiff_t j = from; + if (ch != '*' && ch != '_') return 0; + while (tp_at(s, j) == ch) j++; + return j - from; +} + +/* emphasisRun is R13.2.1 / R13.2.3: the length of an emphasis run at from (a maximal run of 1 or + * 2 '*' or '_'), else 0. It is used next to the time, where runs are read by position rather + * than by pairing. */ +TP_PRIVATE ptrdiff_t tp_emphasis_run(tp_runes s, ptrdiff_t from) { + ptrdiff_t n = tp_run_length(s, from); + return n <= 2 ? n : 0; +} + +/* isEmphasisOuter is the R13.12.2 outer side: the line edge, R0.2 whitespace, a bracket, or a '*' + * / '_' of another run. */ +TP_PRIVATE bool tp_is_emphasis_outer(tp_rune r) { + switch (r) { + case TP_NORUNE: + case '[': + case ']': + case '(': + case ')': + case '*': + case '_': + return true; + default: + return tp_is_whitespace(r); + } +} + +/* isEmphasisInner is the R13.12.2 inner side: a character that is not R0.2 whitespace. */ +TP_PRIVATE bool tp_is_emphasis_inner(tp_rune r) { return r != TP_NORUNE && !tp_is_whitespace(r); } + +/* emphasisStack is the stack of a run: one each for '*', '**', '_' and '__'; -1 for longer runs + * and other characters. */ +TP_PRIVATE ptrdiff_t tp_emphasis_stack(tp_rune ch, ptrdiff_t n) { + if (ch == '*' && n == 1) return 0; + if (ch == '*' && n == 2) return 1; + if (ch == '_' && n == 1) return 2; + if (ch == '_' && n == 2) return 3; + return -1; +} + +/* markRange sets marked[from:from+n], clamped. */ +TP_PRIVATE void tp_mark_range(tp_bool_vec marked, ptrdiff_t from, ptrdiff_t n) { + for (ptrdiff_t k = from; k < from + n && k < (ptrdiff_t)marked.n; k++) { + if (k >= 0) marked.p[k] = true; + } +} + +/* withoutMarkers is R13.12: raw[from:] (the line's rest) without its emphasis markers. A run of 1 + * or 2 '*' or '_' closes when the character before it is an inner side and the one after it an + * outer side, and opens the other way round. A closer pairs with the nearest opener of the same + * characters; that opener and every opener after it leave the stack. One stack per run ('*', + * '**', '_', '__') keeps this linear. Runs before from (lead and gap) never pair, except that + * open, a lead run the gap left open (R13.12.4), pairs with a closing run of the same character + * at the end of the line. open is TP_NORUNE when there is none. */ +TP_PRIVATE tp_str tp_without_markers(tp_runes raw, ptrdiff_t from, tp_rune open) { + ptrdiff_t len = (ptrdiff_t)raw.n; + tp_bool_vec marked = {0}; + tp_idxvec stacks[4]; + tp_buf out = {0}; + memset(stacks, 0, sizeof stacks); + if (len > 0) (void)tp_push_n(marked, raw.n); + if (from < 0) from = 0; + for (ptrdiff_t i = from; i < len;) { + ptrdiff_t n = tp_run_length(raw, i); + ptrdiff_t own, opener = -1; + tp_rune prev, next; + if (n < 1) n = 1; + own = tp_emphasis_stack(tp_at(raw, i), n); + prev = tp_before(raw, i); + next = tp_at(raw, i + n); + if (own >= 0 && tp_is_emphasis_inner(prev) && tp_is_emphasis_outer(next)) { + if (stacks[own].n > 0) { + opener = tp_last(stacks[own]); + stacks[own].n--; + } + } + if (opener >= 0) { + tp_mark_range(marked, opener, n); + tp_mark_range(marked, i, n); + for (size_t s = 0; s < 4; s++) { + while (stacks[s].n > 0 && tp_last(stacks[s]) > opener) stacks[s].n--; + } + } else if (own >= 0 && tp_is_emphasis_outer(prev) && tp_is_emphasis_inner(next)) { + tp_push(stacks[own], i); + } + i += n; + } + /* R13.12.4: the last run of the line, after which there is only R0.2 whitespace. */ + if (open != TP_NORUNE) { + ptrdiff_t end = len, start; + while (end > from && tp_is_whitespace(tp_before(raw, end))) end--; + start = end; + while (start > from && tp_before(raw, start) == open) start--; + if (end - start <= 2 && start > from && tp_is_emphasis_inner(tp_before(raw, start))) { + for (ptrdiff_t k = start; k < end; k++) { + if (marked.p[k]) break; + marked.p[k] = true; + } + } + } + for (ptrdiff_t k = from; k < len; k++) { + if (!marked.p[k]) tp_buf_rune(&out, raw.p[k]); + } + return tp_buf_done(&out); +} diff --git a/c/src/tl_kinds.c b/c/src/tl_kinds.c new file mode 100644 index 0000000..4ba4738 --- /dev/null +++ b/c/src/tl_kinds.c @@ -0,0 +1,186 @@ +/* tl_kinds.c: R13.3 line kinds, R13.4.2 candidate lines and the R13.13 layered prefix + * (go/tl_kinds.go). */ +#include "internal.h" + +static void *tl_build_header_words(void) { + tp_word_set *s = tp_alloc(sizeof *s); + tp_word_set_add_all(s, tp_data_header_words_words, TP_DATA_HEADER_WORDS_WORDS_N); + return s; +} + +static void *tl_build_layered_words(void) { + tp_word_set *s = tp_alloc(sizeof *s); + tp_word_set_add_all(s, tp_data_layered_words_words, TP_DATA_LAYERED_WORDS_WORDS_N); + return s; +} + +static void *tl_build_default_markers(void) { + tp_strvec none = {0}; + /* The table is built in this once's arena; the cast drops const for the void * interface. */ + return (void *)(uintptr_t)tp_build_marker_table(none); +} + +static tp_once tl_header_once = TP_ONCE_INIT; +static tp_once tl_layered_once = TP_ONCE_INIT; +static tp_once tl_marker_once = TP_ONCE_INIT; + +TP_PRIVATE const tp_word_set *tp_tl_header_words(void) { + void *v = tp_once_get(&tl_header_once, tl_build_header_words); + return v ? v : tl_build_header_words(); +} + +TP_PRIVATE const tp_word_set *tp_tl_layered_words(void) { + void *v = tp_once_get(&tl_layered_once, tl_build_layered_words); + return v ? v : tl_build_layered_words(); +} + +TP_PRIVATE const tp_phrase_table *tp_tl_marker_table(void) { + void *v = tp_once_get(&tl_marker_once, tl_build_default_markers); + return v ? v : tl_build_default_markers(); +} + +/* buildMarkerTable is data/marker-words.json plus extra. Entries are split into words the same + * way as the track part (R13.3), so shout-out matches the words shout, out. */ +TP_PRIVATE const tp_phrase_table *tp_build_marker_table(tp_strvec extra) { + tp_phrase_table *t = tp_new_phrase_table(); + for (size_t k = 0; k < TP_DATA_MARKER_WORDS_WORDS_N; k++) { + tp_phrase_table_add(t, tp_join(tp_marker_words(tp_data_marker_words_words[k]), TP_S(" ")), + NULL); + } + for (size_t k = 0; k < extra.n; k++) { + tp_phrase_table_add(t, tp_join(tp_marker_words(extra.p[k]), TP_S(" ")), NULL); + } + return t; +} + +/* markerTableFor is the marker table with options.markerWords (R13.10); the default table is + * built once. */ +TP_PRIVATE const tp_phrase_table *tp_marker_table_for(tp_strvec extra) { + if (extra.n == 0) return tp_tl_marker_table(); + return tp_build_marker_table(extra); +} + +/* isMarkerBreak splits marker words: '/', '-' and R0.2 whitespace. */ +TP_PRIVATE bool tp_is_marker_break(tp_rune r) { + return r == '/' || r == '-' || tp_is_whitespace(r); +} + +/* isMarkerBracket is one of ()[]{}. */ +TP_PRIVATE bool tp_is_marker_bracket(tp_rune r) { + switch (r) { + case '(': + case ')': + case '[': + case ']': + case '{': + case '}': + return true; + default: + return false; + } +} + +/* Go markerWords' closure flush: the piece current[a:b] without leading and trailing brackets, + * appended to out when not empty. */ +static void tl_flush_marker_word(tp_strvec *out, tp_runes current) { + size_t a = 0, b = current.n; + while (a < b && tp_is_marker_bracket(current.p[a])) a++; + while (b > a && tp_is_marker_bracket(current.p[b - 1])) b--; + if (b > a) tp_push(*out, tp_runes_str(tp_runes_slice(current, a, b))); +} + +/* markerWords is R13.3: split on R0.2 whitespace, '/' and '-', then strip leading and trailing + * ()[]{} from each piece; empty pieces are dropped. Word keys (R0.3) apply on matching. */ +TP_PRIVATE tp_strvec tp_marker_words(tp_str text) { + tp_strvec out = {0}; + tp_runes t = tp_runes_of(text); + size_t start = 0; + for (size_t k = 0; k < t.n; k++) { + if (tp_is_marker_break(t.p[k])) { + tl_flush_marker_word(&out, tp_runes_slice(t, start, k)); + start = k + 1; + } + } + tl_flush_marker_word(&out, tp_runes_slice(t, start, t.n)); + return out; +} + +/* layeredPrefix is R13.13: the length (in code points) of a layered prefix at the start of the + * line text: R0.2 whitespace, a word of data/layered-words.json (word key, R0.3), then R0.2 + * whitespace, with more text after it. 0 when there is none. */ +TP_PRIVATE ptrdiff_t tp_layered_prefix(tp_runes text) { + ptrdiff_t len = (ptrdiff_t)text.n; + ptrdiff_t i = tp_skip_whitespace(text, 0); + ptrdiff_t j = i; + while (j < len && !tp_is_whitespace(text.p[j])) j++; + if (j == i || j == len || !tp_in_vocab(tp_runes_str(tp_sub(text, i, j)), tp_tl_layered_words())) { + return 0; + } + j = tp_skip_whitespace(text, j); + return j < len ? j : 0; +} + +/* isBlank is R13.3.1: the line is only R0.2 whitespace. */ +TP_PRIVATE bool tp_is_blank(tp_str raw) { + tp_str s = raw; + while (s.n > 0) { + size_t len; + tp_rune r = tp_decode_rune(s, &len); + if (!tp_is_whitespace(r)) return false; + if (len == 0) break; + s = tp_str_slice(s, len, s.n); + } + return true; +} + +/* trimWS trims R0.2 whitespace from both ends. */ +TP_PRIVATE tp_runes tp_trim_ws(tp_str s) { + tp_runes t = tp_runes_of(s); + size_t a = 0, b = t.n; + while (a < b && tp_is_whitespace(t.p[a])) a++; + while (b > a && tp_is_whitespace(t.p[b - 1])) b--; + return tp_runes_slice(t, a, b); +} + +/* isLink is R13.3.3: the text starts with http://, https:// or www. (ASCII case-insensitive). */ +TP_PRIVATE bool tp_is_link(tp_str rest) { + tp_str t = tp_ascii_lower(tp_runes_str(tp_sub(tp_trim_ws(rest), 0, 8))); + return tp_has_prefix(t, TP_S("http://")) || tp_has_prefix(t, TP_S("https://")) || + tp_has_prefix(t, TP_S("www.")); +} + +/* isHeader is R13.3.3: the text ends with ':', or is a header word followed by at most one more + * word. */ +TP_PRIVATE bool tp_is_header(tp_str rest) { + tp_runes t = tp_trim_ws(rest); + tp_strvec words; + if (t.n > 0 && t.p[t.n - 1] == ':') return true; + words = tp_split_words_runes(t); + return words.n > 0 && words.n <= 2 && tp_in_vocab(words.p[0], tp_tl_header_words()); +} + +/* hasMarkerWord is R13.3: any marker word (or multi-word entry) among the track part's marker + * words. */ +TP_PRIVATE bool tp_has_marker_word(tp_str track_part, const tp_phrase_table *markers) { + tp_strvec words = tp_marker_words(track_part); + for (size_t i = 0; i < words.n; i++) { + tp_phrase_match m; + if (tp_phrase_table_match_at(markers, words, (ptrdiff_t)i, &m)) return true; + } + return false; +} + +/* hasSeparator is R13.3: the track part has a separator. It is not empty after R1 (empty), its + * parse did not warn noSeparator, and the artist side is not empty (at least one primary + * artist, or flags.unknown_artist). */ +TP_PRIVATE bool tp_has_separator(const tp_track *t, bool empty) { + if (empty) return false; + for (size_t i = 0; i < t->warnings.n; i++) { + if (tp_str_eq(t->warnings.p[i], TP_WARNING_NO_SEPARATOR)) return false; + } + if (t->flags.unknown_artist) return true; + for (size_t i = 0; i < t->artists.n; i++) { + if (tp_str_eq(t->artists.p[i].role, TP_ROLE_PRIMARY)) return true; + } + return false; +} diff --git a/c/src/tl_options.c b/c/src/tl_options.c new file mode 100644 index 0000000..05f8573 --- /dev/null +++ b/c/src/tl_options.c @@ -0,0 +1,23 @@ +/* tl_options.c: the JS number tests the edits (R13.9) apply to loose JSON values + * (go/tl_options.go). + * + * R13.10 tracklist options are resolved in options.c (tp_resolve_tracklist, + * tp_resolve_tracklist_json, tp_js_number). */ +#include "internal.h" + +/* Number.isInteger without libm: finite and equal to its floor. */ +static bool tl_is_whole(double n) { return !tp_is_nan(n) && !tp_is_inf(n) && n == tp_floor(n); } + +TP_PRIVATE bool tp_js_integer(tp_json v, bool present, double *out) { + double n; + if (!tp_js_number(v, present, &n) || !tl_is_whole(n)) return false; + *out = n; + return true; +} + +TP_PRIVATE bool tp_js_finite(tp_json v, bool present, double *out) { + double n; + if (!tp_js_number(v, present, &n) || tp_is_nan(n) || tp_is_inf(n)) return false; + *out = n; + return true; +} diff --git a/c/src/tl_parse.c b/c/src/tl_parse.c new file mode 100644 index 0000000..3640154 --- /dev/null +++ b/c/src/tl_parse.c @@ -0,0 +1,168 @@ +/* tl_parse.c: R13.1 to R13.8, parseTracklist (go/tl_parse.go, js/src/tracklist/parse.ts). */ +#include "internal.h" + +/* parseTracklist is R13.1 to R13.8 on one (already sanitized) text. */ +TP_PRIVATE tp_tracklist tp_parse_tracklist(tp_str text, tp_resolved_tracklist o) { + const tp_phrase_table *markers = tp_marker_table_for(o.marker_words); + const tp_engine *e = tp_engine_new(o.parse); + tp_tl_line_vec lines; + tp_tl_row *rows; + size_t nrows; + ptrdiff_t candidates = 0, dashes = 0; + bool list_context; + tp_idxvec bare_numbers = {0}; + tp_bool_vec candidate_lines = {0}; + tp_bool_vec confirmed; + tp_entry_vec entries = {0}; + tp_idxvec positions = {0}; + tp_bool_vec invalid = {0}, unparsed = {0}; + tp_warning_input in; + tp_tracklist out; + + /* R13.2 time scan. R13.4.2: a candidate line has a time or a spaced dash in the skeleton R6 + * searches (after R2 and R4); the probe runs R1, R2 and R4 (R13.4.1). */ + lines = tp_split_lines(text); + nrows = lines.n; + rows = tp_alloc_array(nrows, sizeof *rows); + for (size_t i = 0; i < nrows; i++) { + tp_tl_row *r = &rows[i]; + tp_runes scanned; + ptrdiff_t layered = 0; + r->line = lines.p[i]; + r->scan = tp_scan_time(r->line.raw); + r->blank = tp_is_blank(r->line.raw); + scanned = tp_runes_of(r->scan.text); + if (!r->blank) layered = tp_layered_prefix(scanned); + r->text = tp_runes_str(tp_tail(scanned, layered)); + r->layered = layered > 0; + if (r->blank) continue; + r->probe = tp_engine_probe(e, r->text); /* R13.4.1 */ + r->probed = true; + r->dash = r->probe.spaced_dash; + r->candidate = r->scan.time != NULL || r->dash; + /* R13.5 / R13.13.3: a layered line never has a bare position. */ + if (!r->layered) r->bare = tp_find_bare_candidate(r->text, r->probe.position); + if (r->candidate) { + candidates++; + if (r->dash) dashes++; + } + } + list_context = candidates > 0 && 2 * dashes >= candidates; + + /* R13.5: confirmed bare positions are removed before parsing. R13.4.1: one parse per line. + * R13.13.3: layered lines are not neighbours for the R13.5 search. */ + for (size_t i = 0; i < nrows; i++) { + tp_push(bare_numbers, rows[i].bare ? rows[i].bare->number : -1); + tp_push(candidate_lines, rows[i].candidate && !rows[i].layered); + } + confirmed = tp_confirm_positions(bare_numbers, candidate_lines); + for (size_t i = 0; i < nrows; i++) { + tp_tl_row *r = &rows[i]; + const tp_bare_candidate *bare = NULL; + tp_str input; + tp_line_probe *probe; + tp_track *track; + if (!r->probed) continue; + if (tp_flag_at(confirmed, (ptrdiff_t)i)) bare = r->bare; + /* The probe already ran R1, R2 and R4; finish completes the parse from it. A line that + * loses a bare position is probed again on the stripped text, so each probe is finished + * exactly once. */ + input = r->text; + probe = &r->probe; + if (bare) { + input = bare->stripped; + probe = tp_alloc(sizeof *probe); + *probe = tp_engine_probe(e, input); + } + r->marker = tp_has_marker_word(input, markers); + track = tp_alloc(sizeof *track); + /* R13.4.2: the R6.10 tight dash only on timed lines without a marker word. */ + *track = tp_line_probe_finish(probe, list_context && r->scan.time != NULL && !r->marker); + if (bare) { + tp_position *p = tp_alloc(sizeof *p); + p->raw = bare->raw; + p->number = bare->number; + track->position = p; + } + r->separated = tp_has_separator(track, probe->empty); + r->track = track; + } + + /* R13.3 */ + for (size_t i = 0; i < nrows; i++) { + const tp_tl_row *r = &rows[i]; + tp_entry_kind kind = tp_kind_of(r); + const tp_track *track = NULL; + tp_entry en; + if (tp_str_eq(kind, TP_ENTRY_KIND_TRACK) || tp_str_eq(kind, TP_ENTRY_KIND_MARKER)) { + track = r->track; + } + tp_push(positions, track && track->position ? track->position->number : -1); + tp_push(invalid, r->scan.invalid); + /* R13.7 line-unparsed: a track entry whose track part has no separator (R13.3). */ + tp_push(unparsed, tp_str_eq(kind, TP_ENTRY_KIND_TRACK) && !r->separated); + memset(&en, 0, sizeof en); + en.line = (ptrdiff_t)i + 1; + en.kind = kind; + en.eol = r->line.eol; + en.raw = r->line.raw; + en.parts = r->scan.parts; + en.time = r->scan.time; + en.track = track; + en.layered = r->layered; + tp_push(entries, en); + } + + memset(&in, 0, sizeof in); + in.entries = entries; + in.positions = positions; + in.invalid = invalid; + in.unparsed = unparsed; + in.audio_seconds = o.audio_seconds; + memset(&out, 0, sizeof out); + out.spec_version = TP_S(TP_SPEC_VERSION); + out.entries = entries; + out.warnings = tp_tracklist_warnings(&in); + out.stats = tp_stats_of(entries); + return out; +} + +/* kindOf is R13.3. */ +TP_PRIVATE tp_entry_kind tp_kind_of(const tp_tl_row *r) { + bool marker; + if (r->blank || r->track == NULL) return TP_ENTRY_KIND_BLANK; + marker = !r->separated && r->marker; + if (r->scan.time != NULL) return marker ? TP_ENTRY_KIND_MARKER : TP_ENTRY_KIND_TRACK; + if (tp_is_link(r->text)) return TP_ENTRY_KIND_LINK; + if (tp_is_header(r->text)) return TP_ENTRY_KIND_HEADER; + if (marker) return TP_ENTRY_KIND_MARKER; + if (r->separated) return TP_ENTRY_KIND_TRACK; + return TP_ENTRY_KIND_NOTE; +} + +/* statsOf counts the entries. */ +TP_PRIVATE tp_stats tp_stats_of(tp_entry_vec entries) { + tp_stats s; + memset(&s, 0, sizeof s); + s.lines = (ptrdiff_t)entries.n; + for (size_t i = 0; i < entries.n; i++) { + const tp_entry *e = &entries.p[i]; + if (tp_str_eq(e->kind, TP_ENTRY_KIND_TRACK)) { + s.tracks++; + } else if (tp_str_eq(e->kind, TP_ENTRY_KIND_MARKER)) { + s.markers++; + } + if (e->time) { + double *last = tp_alloc(sizeof *last); + s.timed++; + *last = e->time->seconds; + if (s.first_time == NULL) { + double *first = tp_alloc(sizeof *first); + *first = e->time->seconds; + s.first_time = first; + } + s.last_time = last; + } + } + return s; +} diff --git a/c/src/tl_positions.c b/c/src/tl_positions.c new file mode 100644 index 0000000..b418be7 --- /dev/null +++ b/c/src/tl_positions.c @@ -0,0 +1,69 @@ +/* tl_positions.c: R13.5, bare positions (go/tl_positions.go). */ +#include "internal.h" + +/* findBareCandidate is R13.5: a track part starting with 1 to 3 ASCII digits and a space (U+0020 + * only), where R4.2 took no position (position_taken), is a bare candidate. The remainder must + * not be empty or only R0.2 whitespace. */ +TP_PRIVATE const tp_bare_candidate *tp_find_bare_candidate(tp_str rest, bool position_taken) { + tp_runes t, stripped, digits; + ptrdiff_t n; + bool blank = true; + tp_bare_candidate *c; + if (position_taken) return NULL; + t = tp_runes_of(rest); + n = tp_digit_run(t, 0); + if (n < 1 || n > 3 || tp_at(t, n) != ' ') return NULL; + stripped = tp_tail(t, n + 1); + for (size_t k = 0; k < stripped.n; k++) { + if (!tp_is_whitespace(stripped.p[k])) { + blank = false; + break; + } + } + if (blank) return NULL; + digits = tp_sub(t, 0, n); + c = tp_alloc(sizeof *c); + c->raw = tp_runes_str(digits); + c->number = (ptrdiff_t)tp_digits_value(digits); + c->stripped = tp_runes_str(stripped); + return c; +} + +/* Go confirmPositions' closure isCandidate. */ +static bool tl_is_candidate(tp_bool_vec candidate_line, ptrdiff_t i) { + return i >= 0 && i < (ptrdiff_t)candidate_line.n && candidate_line.p[i]; +} + +/* Go confirmPositions' closure adjacent: line j has a bare number next to b. */ +static bool tl_adjacent(tp_idxvec bare, ptrdiff_t b, ptrdiff_t j) { + ptrdiff_t o; + if (j < 0 || j >= (ptrdiff_t)bare.n || bare.p[j] < 0) return false; + o = bare.p[j]; + return o + 1 == b || o == b + 1; +} + +/* confirmPositions is R13.5: candidate i is a position when the nearest preceding or the nearest + * following candidate line (R13.4.2, candidate_line) also has a bare candidate equal to N - 1 or + * N + 1. bare holds each line's bare number, or -1 for none. Linear time. */ +TP_PRIVATE tp_bool_vec tp_confirm_positions(tp_idxvec bare, tp_bool_vec candidate_line) { + ptrdiff_t n = (ptrdiff_t)bare.n, last; + ptrdiff_t *prev = tp_alloc_array(bare.n, sizeof *prev); + ptrdiff_t *next = tp_alloc_array(bare.n, sizeof *next); + tp_bool_vec out = {0}; + last = -1; + for (ptrdiff_t i = 0; i < n; i++) { + prev[i] = last; + if (tl_is_candidate(candidate_line, i)) last = i; + } + last = -1; + for (ptrdiff_t i = n - 1; i >= 0; i--) { + next[i] = last; + if (tl_is_candidate(candidate_line, i)) last = i; + } + for (ptrdiff_t i = 0; i < n; i++) { + ptrdiff_t b = bare.p[i]; + bool v = b >= 0 && (tl_adjacent(bare, b, prev[i]) || tl_adjacent(bare, b, next[i])); + tp_push(out, v); + } + return out; +} diff --git a/c/src/tl_split.c b/c/src/tl_split.c new file mode 100644 index 0000000..46c4c49 --- /dev/null +++ b/c/src/tl_split.c @@ -0,0 +1,44 @@ +/* tl_split.c: R13.1, the line split (LF, CRLF and CR only) with the lossless guarantee + * (go/tl_split.go). */ +#include "internal.h" + +/* R13.1.1: split at LF, CRLF and CR. U+2028, U+2029, U+0085 and the other R0.2 characters are + * not line breaks. A trailing empty segment after the final terminator is not a line, and "" has + * no lines. R13.1.2: the lines' raw + eol, joined, are the text. */ +TP_PRIVATE tp_tl_line_vec tp_split_lines(tp_str text) { + tp_tl_line_vec lines = {0}; + size_t start = 0; + /* LF and CR are ASCII and never part of a multi-byte sequence, so every cut is at a character + * boundary. */ + for (size_t i = 0; i < text.n; i++) { + unsigned char ch = (unsigned char)text.p[i]; + if (ch == '\n') { + tp_tl_line l = {tp_str_slice(text, start, i), TP_EOL_LF}; + tp_push(lines, l); + start = i + 1; + } else if (ch == '\r') { + if (i + 1 < text.n && text.p[i + 1] == '\n') { + tp_tl_line l = {tp_str_slice(text, start, i), TP_EOL_CRLF}; + tp_push(lines, l); + i++; + } else { + tp_tl_line l = {tp_str_slice(text, start, i), TP_EOL_CR}; + tp_push(lines, l); + } + start = i + 1; + } + } + if (start < text.n) { + tp_tl_line l = {tp_str_slice(text, start, text.n), TP_EOL_NONE}; + tp_push(lines, l); + } + return lines; +} + +/* hasLineBreak reports a line break inside a single-line value (R13.9.5, R13.9.6). */ +TP_PRIVATE bool tp_has_line_break(tp_str s) { + for (size_t i = 0; i < s.n; i++) { + if (s.p[i] == '\n' || s.p[i] == '\r') return true; + } + return false; +} diff --git a/c/src/tl_times.c b/c/src/tl_times.c new file mode 100644 index 0000000..f40bc09 --- /dev/null +++ b/c/src/tl_times.c @@ -0,0 +1,354 @@ +/* tl_times.c: R13.2, the tracklist time scanner (separate from R4.1), and R13.9.2 time + * formatting (go/tl_times.go). */ +#include "internal.h" + +/* isGapSeparator is an R13.2.3 separator after the time. */ +TP_PRIVATE bool tp_is_gap_separator(tp_rune r) { + switch (r) { + case '-': + case 0x2013: /* – */ + case 0x2014: /* — */ + case '|': + case '.': + case ':': + return true; + default: + return false; + } +} + +/* skipWhitespace is the index past the R0.2 whitespace at from. */ +TP_PRIVATE ptrdiff_t tp_skip_whitespace(tp_runes s, ptrdiff_t from) { + ptrdiff_t i = from; + while (tp_is_whitespace(tp_at(s, i))) i++; + return i; +} + +/* isBullet is an R13.2.1 bullet (before a time, or alone on a line without one). */ +TP_PRIVATE bool tp_is_bullet(tp_rune r) { + switch (r) { + case '-': + case 0x2013: /* – */ + case 0x2014: /* — */ + case '*': + case 0x2022: /* • */ + return true; + default: + return false; + } +} + +/* untimed is R13.1.3 / R13.2.1: a line without a time. lead holds an optional bullet: R0.2 + * whitespace, one of - – — * •, then at least one R0.2 whitespace (all of it); rest is the + * remainder. */ +TP_PRIVATE tp_time_scan tp_untimed(tp_runes raw, bool invalid) { + ptrdiff_t start = tp_skip_whitespace(raw, 0); + ptrdiff_t lead = 0; + tp_time_scan s; + if (tp_is_bullet(tp_at(raw, start)) && tp_is_whitespace(tp_at(raw, start + 1))) { + lead = tp_skip_whitespace(raw, start + 1); + } + memset(&s, 0, sizeof s); + s.parts.lead = tp_runes_str(tp_sub(raw, 0, lead)); + s.parts.time = TP_EMPTY; + s.parts.gap = TP_EMPTY; + s.parts.rest = tp_runes_str(tp_tail(raw, lead)); + s.invalid = invalid; + s.text = tp_without_markers(raw, lead, TP_NORUNE); + return s; +} + +/* closingRun is R13.2.3: the index past a closing run for an opening run of open (the same + * character, 1 or 2 long), or from when there is none. */ +TP_PRIVATE ptrdiff_t tp_closing_run(tp_runes raw, ptrdiff_t from, tp_rune open) { + if (open != TP_NORUNE && tp_at(raw, from) == open) return from + tp_emphasis_run(raw, from); + return from; +} + +/* secondsOf is whole.frac read as one decimal literal, so every port gets the same double (JS + * Number(), correctly rounded). */ +TP_PRIVATE double tp_seconds_of(ptrdiff_t whole, tp_str frac) { + double v; + if (frac.n == 0) return (double)whole; + if (!tp_parse_number(tp_concat3(tp_itoa((int64_t)whole), TP_S("."), frac), &v)) { + return (double)whole; + } + return v; +} + +/* shapeAt is R13.2.4: the maximal digits(:digits)+ run at from. */ +TP_PRIVATE bool tp_shape_at(tp_runes s, ptrdiff_t from, tp_time_shape *out) { + ptrdiff_t na = tp_digit_run(s, from); + tp_time_shape shape; + if (na == 0 || tp_at(s, from + na) != ':' || !tp_is_digit(tp_at(s, from + na + 1))) { + return false; + } + memset(&shape, 0, sizeof shape); + tp_push(shape.parts, tp_sub(s, from, from + na)); + shape.end = from + na; + while (tp_at(s, shape.end) == ':' && tp_is_digit(tp_at(s, shape.end + 1))) { + ptrdiff_t n = tp_digit_run(s, shape.end + 1); + tp_push(shape.parts, tp_sub(s, shape.end + 1, shape.end + 1 + n)); + shape.end += 1 + n; + } + *out = shape; + return true; +} + +/* shapeSeconds is the R13.2.2 validity test: the whole seconds of A:B or A:B:C (no other part + * count). */ +TP_PRIVATE bool tp_shape_seconds(tp_runes_vec parts, ptrdiff_t *out) { + if (parts.n == 3) { + tp_runes a = parts.p[0], b = parts.p[1], c = parts.p[2]; + int64_t m, sec; + if (a.n == 0 || a.n > 2 || b.n != 2 || c.n != 2) return false; + m = tp_digits_value(b); + sec = tp_digits_value(c); + if (m > 59 || sec > 59) return false; + *out = (ptrdiff_t)(tp_digits_value(a) * 3600 + m * 60 + sec); + return true; + } + if (parts.n == 2) { + tp_runes a = parts.p[0], b = parts.p[1]; + int64_t sec; + if (a.n == 0 || a.n > 3 || b.n != 2) return false; + sec = tp_digits_value(b); + if (sec > 59) return false; + *out = (ptrdiff_t)(tp_digits_value(a) * 60 + sec); + return true; + } + return false; +} + +/* startsWithAt reports whether s has word at from. */ +TP_PRIVATE bool tp_starts_with_at(tp_runes s, ptrdiff_t from, tp_str word) { + tp_runes w = tp_runes_of(word); + tp_runes got = tp_sub(s, from, from + (ptrdiff_t)w.n); + if (got.n != w.n) return false; + for (size_t k = 0; k < w.n; k++) { + if (got.p[k] != w.p[k]) return false; + } + return true; +} + +/* Go scanTime's closure followsTime: the end, R0.2 whitespace or a gap separator at k. */ +static bool tl_follows_time(tp_runes raw, ptrdiff_t k) { + return k >= (ptrdiff_t)raw.n || tp_is_whitespace(tp_at(raw, k)) || + tp_is_gap_separator(tp_at(raw, k)); +} + +/* scanTime is R13.2: the lead, time and gap at the start of a line; the rest is everything + * after. */ +TP_PRIVATE tp_time_scan tp_scan_time(tp_str line) { + tp_runes raw = tp_runes_of(line); + ptrdiff_t i, n, lead_end, whole, j, time_end; + tp_rune outer_open = TP_NORUNE, closer = TP_NORUNE, inner_open = TP_NORUNE, next; + tp_rune frac_sep = TP_NORUNE, open = TP_NORUNE, sep; + tp_str frac = TP_EMPTY, time_raw; + tp_time_shape shape; + tp_runes first = {0}, second = {0}; + bool hours, long_minutes; + tp_time_style *style; + tp_tracklist_time *tt; + tp_time_scan out; + + /* R13.2.1 lead: whitespace, an optional bullet, an optional emphasis run, an optional '[' or + * '(', then (after a bracket) another optional emphasis run. A run counts only when the next + * character is a bracket (first run) or a digit. */ + i = tp_skip_whitespace(raw, 0); + if (tp_is_bullet(tp_at(raw, i)) && tp_is_whitespace(tp_at(raw, i + 1))) { + i = tp_skip_whitespace(raw, i + 1); + } + n = tp_emphasis_run(raw, i); + next = tp_at(raw, i + n); + if (n > 0 && (next == '[' || next == '(' || tp_is_digit(next))) { + outer_open = tp_at(raw, i); + i += n; + } + switch (tp_at(raw, i)) { + case '[': + closer = ']'; + break; + case '(': + closer = ')'; + break; + default: + break; + } + if (closer != TP_NORUNE) { + i++; + n = tp_emphasis_run(raw, i); + if (n > 0 && tp_is_digit(tp_at(raw, i + n))) { + inner_open = tp_at(raw, i); + i += n; + } + } + lead_end = i; + + /* R13.2.2 time */ + if (!tp_shape_at(raw, i, &shape)) return tp_untimed(raw, false); + if (!tp_shape_seconds(shape.parts, &whole)) return tp_untimed(raw, true); /* R13.2.4 */ + j = shape.end; + sep = tp_at(raw, j); + if (sep == '.' || sep == ',') { + ptrdiff_t fn = tp_digit_run(raw, j + 1); + if (fn >= 1 && fn <= 3) { + frac_sep = sep; + frac = tp_runes_str(tp_sub(raw, j + 1, j + 1 + fn)); + j += 1 + fn; + } + } + time_end = j; + + /* R13.2.3 gap: closing runs for the lead's runs (the same character), around the closing + * bracket. R13.12.4: a lead run the gap leaves open may pair with a run at the end of the + * line. */ + if (closer != TP_NORUNE) { + ptrdiff_t k = tp_closing_run(raw, j, inner_open); + if (k == j) open = inner_open; + j = k; + if (tp_at(raw, j) != closer) return tp_untimed(raw, false); + j++; + k = tp_closing_run(raw, j, outer_open); + if (k > j && tl_follows_time(raw, k)) { + j = k; + } else if (outer_open != TP_NORUNE) { + open = outer_open; + } + } else { + ptrdiff_t k = tp_closing_run(raw, j, outer_open); + if (k == j) open = outer_open; + j = k; + if (!tl_follows_time(raw, j)) return tp_untimed(raw, false); + } + j = tp_skip_whitespace(raw, j); + if (tp_is_gap_separator(tp_at(raw, j))) j = tp_skip_whitespace(raw, j + 1); + if (tp_starts_with_at(raw, j, TP_S("==>"))) { + j = tp_skip_whitespace(raw, j + 3); + } else if (tp_starts_with_at(raw, j, TP_S("=>"))) { + j = tp_skip_whitespace(raw, j + 2); + } + + time_raw = tp_runes_str(tp_sub(raw, lead_end, time_end)); + hours = shape.parts.n == 3; + if (shape.parts.n > 0) first = shape.parts.p[0]; + if (shape.parts.n > 1) second = shape.parts.p[1]; + /* R13.9.2 long-minute style: two parts with 60 minutes or more. */ + long_minutes = !hours && tp_digits_value(first) >= 60; + style = tp_alloc(sizeof *style); + style->hours = hours; + style->long_minutes = long_minutes; + style->frac_sep = frac_sep; + style->frac_digits = (ptrdiff_t)frac.n; /* ASCII digits: bytes are code points */ + if (hours) { + style->hour_width = (ptrdiff_t)first.n; + style->minute_width = (ptrdiff_t)second.n; + } else if (long_minutes) { + /* R13.9.2: a long-minute time's minimum minute width is min(width, 2), so it never keeps 3 + * minute digits once it is short again (125:30 minus 7000 s gives 08:50). */ + style->minute_width = first.n < 2 ? (ptrdiff_t)first.n : 2; + } else { + style->minute_width = (ptrdiff_t)first.n; + } + tt = tp_alloc(sizeof *tt); + tt->raw = time_raw; + tt->seconds = tp_seconds_of(whole, frac); + + memset(&out, 0, sizeof out); + out.parts.lead = tp_runes_str(tp_sub(raw, 0, lead_end)); + out.parts.time = time_raw; + out.parts.gap = tp_runes_str(tp_sub(raw, time_end, j)); + out.parts.rest = tp_runes_str(tp_tail(raw, j)); + out.time = tt; + out.style = style; + out.text = tp_without_markers(raw, j, open); + return out; +} + +/* pad writes n with at least width digits. */ +TP_PRIVATE tp_str tp_pad(int64_t n, ptrdiff_t width) { + tp_str s = tp_itoa(n); + if ((ptrdiff_t)s.n >= width) return s; + return tp_concat(tp_repeat(TP_S("0"), (size_t)(width - (ptrdiff_t)s.n)), s); +} + +/* Joins a, ":", b (and ":", c when c is non-NULL), then frac. */ +static tp_str tl_join_time(tp_str a, tp_str b, const tp_str *c, tp_str frac) { + tp_buf buf = {0}; + tp_buf_str(&buf, a); + tp_buf_byte(&buf, ':'); + tp_buf_str(&buf, b); + if (c) { + tp_buf_byte(&buf, ':'); + tp_buf_str(&buf, *c); + } + tp_buf_str(&buf, frac); + return tp_buf_done(&buf); +} + +/* formatTime is R13.9.2: seconds (finite, not negative) written in style. Values are rounded + * half up to the fraction precision (floor(v * 10^d + 0.5), never a library round, and with no + * FMA: tp_half_up_units). A value of an hour or more without hours is upgraded to HH:MM:SS + * (H:MM:SS when one_digit_hours), except in long-minute style. false when the value cannot be + * written as a valid R13.2.2 time (100 hours or more, more than 999 long-style minutes). */ +TP_PRIVATE bool tp_format_time(double seconds, const tp_time_style *style, bool one_digit_hours, + tp_formatted_time *out) { + double scale = 1000.0, units, abs_units, whole_f; + volatile double whole_scaled; + int64_t frac_units, whole, sec; + tp_str frac = TP_EMPTY; + switch (style->frac_digits) { + case 0: + scale = 1; + break; + case 1: + scale = 10; + break; + case 2: + scale = 100; + break; + default: + break; + } + /* The same double arithmetic as the JS reference; integers only after the range check. */ + units = tp_half_up_units(seconds, scale); + abs_units = units < 0 ? -units : units; + if (tp_is_nan(units) || tp_is_inf(units) || abs_units > TP_MAX_SAFE_INTEGER || units < 0) { + return false; + } + whole_f = tp_floor(units / scale); + whole_scaled = whole_f * scale; /* rounded before the subtraction (no FMA) */ + frac_units = (int64_t)(units - whole_scaled); + /* The written time must stay valid under R13.2.2 (hours are 1 or 2 digits). */ + if (whole_f >= 100.0 * 3600.0) return false; + whole = (int64_t)whole_f; + if (style->frac_sep != TP_NORUNE && style->frac_digits > 0) { + tp_buf b = {0}; + tp_buf_rune(&b, style->frac_sep); + tp_buf_str(&b, tp_pad(frac_units, style->frac_digits)); + frac = tp_buf_done(&b); + } + sec = whole % 60; + memset(out, 0, sizeof *out); + if (style->hours) { + int64_t h = whole / 3600, m = (whole % 3600) / 60; + tp_str s = tp_pad(sec, 2); + out->raw = tl_join_time(tp_pad(h, style->hour_width), tp_pad(m, style->minute_width), &s, frac); + return true; + } + if (style->long_minutes) { + int64_t m = whole / 60; + if (m > 999) return false; /* R13.2.2: two-part minutes are 1 to 3 digits */ + out->raw = tl_join_time(tp_pad(m, style->minute_width), tp_pad(sec, 2), NULL, frac); + return true; + } + if (whole >= 3600) { + int64_t h = whole / 3600, m = (whole % 3600) / 60; + tp_str s = tp_pad(sec, 2); + out->raw = tl_join_time(tp_pad(h, one_digit_hours ? 1 : 2), tp_pad(m, 2), &s, frac); + out->upgraded = true; + return true; + } + out->raw = tl_join_time(tp_pad(whole / 60, style->minute_width), tp_pad(sec, 2), NULL, frac); + return true; +} diff --git a/c/src/tl_warnings.c b/c/src/tl_warnings.c new file mode 100644 index 0000000..3390885 --- /dev/null +++ b/c/src/tl_warnings.c @@ -0,0 +1,326 @@ +/* tl_warnings.c: R13.7, tracklist warnings and the time-out-of-order suggestion search + * (go/tl_warnings.go). */ +#include "internal.h" + +/* valueWith is the value with changes applied, when it is a valid time inside the bounds. */ +TP_PRIVATE bool tp_time_digits_value_with(const tp_time_digits *d, tp_digit_change_vec changes, + double *out) { + /* A time has at most three fields; the copy stays on the stack (the search calls this up to + * about 1,800 times per line). */ + int64_t buf[4]; + int64_t *v = buf; + size_t nv = d->values.n; + int64_t mult[3] = {60, 1, 0}; + int64_t whole = 0; + double t; + if (nv > TP_COUNT(buf)) v = tp_alloc_array(nv, sizeof *v); + if (nv > 0) memcpy(v, d->values.p, nv * sizeof *v); + for (size_t k = 0; k < changes.n; k++) { + const tp_digit_change *c = &changes.p[k]; + if (c->slot.field >= 0 && c->slot.field < (ptrdiff_t)nv) { + v[c->slot.field] += (c->digit - c->slot.digit) * c->slot.place; + } + } + if (nv == 3) { + mult[0] = 3600; + mult[1] = 60; + mult[2] = 1; + } + for (size_t f = 0; f < nv; f++) { + int64_t m = 0; + if (f > 0 && v[f] > 59) return false; + if (f < TP_COUNT(mult)) m = mult[f]; + whole += v[f] * m; + } + if (whole < 0 || whole > (((int64_t)1 << 32) - 1)) return false; + t = tp_seconds_of((ptrdiff_t)whole, d->frac); + if ((d->lo == NULL || *d->lo < t) && (d->hi == NULL || t < *d->hi)) { + *out = t; + return true; + } + return false; +} + +/* render is the raw time with changes applied. */ +TP_PRIVATE tp_str tp_time_digits_render(const tp_time_digits *d, tp_digit_change_vec changes) { + tp_runes c = tp_runes_clone(d->raw); + tp_rune *out = (tp_rune *)(uintptr_t)c.p; /* our own copy */ + for (size_t k = 0; k < changes.n; k++) { + const tp_digit_change *ch = &changes.p[k]; + if (ch->slot.at >= 0 && ch->slot.at < (ptrdiff_t)c.n && ch->digit >= 0 && ch->digit <= 9) { + out[ch->slot.at] = (tp_rune)('0' + ch->digit); + } + } + return tp_runes_str(c); +} + +/* searchTime is the R13.7 suggestion search on one raw time: change 1, then 2 digits (fraction + * digits excluded); keep the candidates that are valid times (R13.2.2: fields after the first at + * most 59) with lo < t (when lo exists) and t < hi (when hi exists). Only the smallest number of + * changes with any candidate counts. Bounded and arithmetic: at most 7 digits, 9 * 7 + 81 * 21 + * candidates. */ +TP_PRIVATE tp_search_outcome tp_search_time(tp_str raw_time, const double *lo, const double *hi, + tp_tracklist_time *found_time) { + tp_runes raw = tp_runes_of(raw_time); + size_t frac_start = raw.n; + tp_str frac; + tp_intvec values = {0}; + tp_digit_slot_vec slots = {0}; + int64_t place = 1; + ptrdiff_t field = -1; + tp_time_digits digits; + tp_digit_change found[2]; + size_t found_n = 0; /* Go found == nil when 0 */ + ptrdiff_t count = 0; + double dummy; + + for (size_t i = 0; i < raw.n; i++) { + if (raw.p[i] == '.' || raw.p[i] == ',') { + frac_start = i; + break; + } + } + frac = tp_runes_str(tp_tail(raw, (ptrdiff_t)frac_start + 1)); + tp_push(values, 0); + for (size_t i = 0; i < frac_start; i++) { + tp_rune ch = raw.p[i]; + if (ch == ':') { + tp_push(values, 0); + } else if (tp_is_digit(ch)) { + int64_t d = (int64_t)(ch - '0'); + size_t f = values.n - 1; + tp_digit_slot s; + values.p[f] = values.p[f] * 10 + d; + s.at = (ptrdiff_t)i; + s.field = (ptrdiff_t)f; + s.place = 0; + s.digit = d; + tp_push(slots, s); + } + } + /* The place value of each digit inside its field. */ + for (size_t k = slots.n; k-- > 0;) { + if (slots.p[k].field != field) { + field = slots.p[k].field; + place = 1; + } + slots.p[k].place = place; + place *= 10; + } + digits.raw = raw; + digits.frac = frac; + digits.values = values; + digits.lo = lo; + digits.hi = hi; + + for (size_t x = 0; x < slots.n; x++) { + for (int64_t d = 0; d <= 9; d++) { + tp_digit_change change[1]; + tp_digit_change_vec cv; + if (d == slots.p[x].digit) continue; + change[0].slot = slots.p[x]; + change[0].digit = d; + cv.p = change; + cv.n = cv.cap = 1; + if (tp_time_digits_value_with(&digits, cv, &dummy)) { + count++; + found[0] = change[0]; + found_n = 1; + } + } + } + if (count == 0) { + for (size_t x = 0; x < slots.n && count < 2; x++) { + for (size_t y = x + 1; y < slots.n && count < 2; y++) { + tp_digit_slot a = slots.p[x], b = slots.p[y]; + for (int64_t da = 0; da <= 9 && count < 2; da++) { + if (da == a.digit) continue; + for (int64_t db = 0; db <= 9; db++) { + tp_digit_change change[2]; + tp_digit_change_vec cv; + if (db == b.digit) continue; + change[0].slot = a; + change[0].digit = da; + change[1].slot = b; + change[1].digit = db; + cv.p = change; + cv.n = cv.cap = 2; + if (tp_time_digits_value_with(&digits, cv, &dummy)) { + count++; + found[0] = change[0]; + found[1] = change[1]; + found_n = 2; + if (count >= 2) break; /* Go: break pairs (the outer loops test count < 2) */ + } + } + } + } + } + } + if (found_n > 0 && count == 1) { + tp_digit_change_vec fv; + double seconds; + fv.p = found; + fv.n = fv.cap = found_n; + if (!tp_time_digits_value_with(&digits, fv, &seconds)) return TP_SEARCH_NONE; + found_time->raw = tp_time_digits_render(&digits, fv); + found_time->seconds = seconds; + return TP_SEARCH_ONE; + } + if (found_n > 0 && count > 1) return TP_SEARCH_MANY; + return TP_SEARCH_NONE; +} + +/* suggestFix is the R13.7 suggestion for the out-of-order timed entry k (an index into times): + * search its own time between its neighbours first; only when that finds no candidate at all, + * search the previous timed entry's time between the one before it and entry k. */ +TP_PRIVATE const tp_suggestion *tp_suggest_fix(tp_timed_entry_vec times, ptrdiff_t k) { + tp_timed_entry cur, prev; + const double *next = NULL, *lo = NULL; + tp_tracklist_time t; + tp_search_outcome outcome; + tp_suggestion *s; + if (k < 1 || k >= (ptrdiff_t)times.n) return NULL; + cur = times.p[k]; + prev = times.p[k - 1]; + if (k + 1 < (ptrdiff_t)times.n) next = ×.p[k + 1].time->seconds; + outcome = tp_search_time(cur.time->raw, &prev.time->seconds, next, &t); + if (outcome == TP_SEARCH_ONE) { + s = tp_alloc(sizeof *s); + s->line = cur.line; + s->raw = t.raw; + s->seconds = t.seconds; + return s; + } + if (outcome == TP_SEARCH_MANY) return NULL; + if (k >= 2) lo = ×.p[k - 2].time->seconds; + if (tp_search_time(prev.time->raw, lo, &cur.time->seconds, &t) == TP_SEARCH_ONE) { + s = tp_alloc(sizeof *s); + s->line = prev.line; + s->raw = t.raw; + s->seconds = t.seconds; + return s; + } + return NULL; +} + +/* warningRank is the table order of R13.7; the warnings of one line are emitted in this order. + * It is a chain of comparisons, not a lookup in tp_all_warning_codes, so no caller can change + * the order. */ +TP_PRIVATE ptrdiff_t tp_warning_rank(tp_warning_code code) { + if (tp_str_eq(code, TP_WARNING_CODE_TIME_MISSING)) return 0; + if (tp_str_eq(code, TP_WARNING_CODE_TIME_OUT_OF_ORDER)) return 1; + if (tp_str_eq(code, TP_WARNING_CODE_TIME_DUPLICATE)) return 2; + if (tp_str_eq(code, TP_WARNING_CODE_NO_START_AT_ZERO)) return 3; + if (tp_str_eq(code, TP_WARNING_CODE_TIME_AFTER_AUDIO_END)) return 4; + if (tp_str_eq(code, TP_WARNING_CODE_INVALID_TIME)) return 5; + if (tp_str_eq(code, TP_WARNING_CODE_POSITION_GAP)) return 6; + if (tp_str_eq(code, TP_WARNING_CODE_POSITION_DUPLICATE)) return 7; + if (tp_str_eq(code, TP_WARNING_CODE_LINE_UNPARSED)) return 8; + return 9; +} + +/* flagAt is list[i], false out of range. */ +TP_PRIVATE bool tp_flag_at(tp_bool_vec list, ptrdiff_t i) { + return i >= 0 && i < (ptrdiff_t)list.n && list.p[i]; +} + +typedef TP_VEC(tp_tracklist_warning_vec) tl_warning_lines; + +/* Go tracklistWarnings' closure add. */ +static void tl_add(tl_warning_lines *per_line, const tp_entry_vec *entries, ptrdiff_t i, + tp_warning_code code, const tp_suggestion *suggestion) { + tp_tracklist_warning w; + if (i < 0 || i >= (ptrdiff_t)entries->n) return; + w.code = code; + w.line = entries->p[i].line; + w.severity = + tp_str_eq(code, TP_WARNING_CODE_NO_START_AT_ZERO) ? TP_SEVERITY_INFO : TP_SEVERITY_WARNING; + w.suggestion = suggestion; + tp_push(per_line->p[i], w); +} + +static int tl_rank_cmp(const void *a, const void *b, void *ctx) { + const tp_tracklist_warning *x = a, *y = b; + ptrdiff_t d = tp_warning_rank(x->code) - tp_warning_rank(y->code); + (void)ctx; + return d < 0 ? -1 : d > 0 ? 1 : 0; +} + +/* tracklistWarnings is R13.7. */ +TP_PRIVATE tp_tracklist_warning_vec tp_tracklist_warnings(const tp_warning_input *in) { + const tp_entry_vec *entries = &in->entries; + ptrdiff_t n = (ptrdiff_t)entries->n; + tl_warning_lines per_line = {0}; + tp_idxvec timed_idx = {0}; + tp_timed_entry_vec times = {0}; + const double *prev = NULL; + ptrdiff_t prev_pos = -1; + tp_tracklist_warning_vec out = {0}; + + if (n > 0) (void)tp_push_n(per_line, entries->n); + for (ptrdiff_t i = 0; i < n; i++) { + const tp_tracklist_time *t = entries->p[i].time; + if (t) { + tp_timed_entry te; + te.line = entries->p[i].line; + te.time = t; + tp_push(timed_idx, i); + tp_push(times, te); + } + } + + for (ptrdiff_t i = 0; i < n; i++) { + const tp_entry *e = &entries->p[i]; + /* R13.13.3: an untimed layered line plays over the previous track, at its time. */ + if (tp_str_eq(e->kind, TP_ENTRY_KIND_TRACK) && e->time == NULL && !e->layered && times.n > 0) { + tl_add(&per_line, entries, i, TP_WARNING_CODE_TIME_MISSING, NULL); + } + if (tp_flag_at(in->invalid, i)) + tl_add(&per_line, entries, i, TP_WARNING_CODE_INVALID_TIME, NULL); + if (tp_flag_at(in->unparsed, i)) { + tl_add(&per_line, entries, i, TP_WARNING_CODE_LINE_UNPARSED, NULL); + } + } + + for (size_t k = 0; k < timed_idx.n; k++) { + ptrdiff_t i = timed_idx.p[k]; + double t = times.p[k].time->seconds; + if (prev == NULL) { + if (t != 0) tl_add(&per_line, entries, i, TP_WARNING_CODE_NO_START_AT_ZERO, NULL); + } else if (t < *prev) { + tl_add(&per_line, entries, i, TP_WARNING_CODE_TIME_OUT_OF_ORDER, + tp_suggest_fix(times, (ptrdiff_t)k)); + } else if (t == *prev) { + tl_add(&per_line, entries, i, TP_WARNING_CODE_TIME_DUPLICATE, NULL); + } + if (in->audio_seconds != NULL && t > *in->audio_seconds) { + tl_add(&per_line, entries, i, TP_WARNING_CODE_TIME_AFTER_AUDIO_END, NULL); + } + prev = ×.p[k].time->seconds; + } + + for (ptrdiff_t i = 0; i < n; i++) { + ptrdiff_t pos; + if (!tp_str_eq(entries->p[i].kind, TP_ENTRY_KIND_TRACK) || i >= (ptrdiff_t)in->positions.n || + in->positions.p[i] < 0) { + continue; + } + pos = in->positions.p[i]; + if (prev_pos >= 0) { + if (pos == prev_pos) { + tl_add(&per_line, entries, i, TP_WARNING_CODE_POSITION_DUPLICATE, NULL); + } else if (prev_pos + 1 != pos) { + tl_add(&per_line, entries, i, TP_WARNING_CODE_POSITION_GAP, NULL); + } + } + prev_pos = pos; + } + + for (size_t i = 0; i < per_line.n; i++) { + tp_tracklist_warning_vec ws = per_line.p[i]; + if (ws.n > 1) tp_sort_stable(ws.p, ws.n, sizeof *ws.p, tl_rank_cmp, NULL); + tp_append(out, ws); + } + return out; +} diff --git a/c/src/trackparse.c b/c/src/trackparse.c new file mode 100644 index 0000000..ae27b00 --- /dev/null +++ b/c/src/trackparse.c @@ -0,0 +1,1686 @@ +/* trackparse.c: the public C API (include/trackparse.h) and the internal functions of + * go/trackparse.go (tp_api_*, the Parser). + * + * Every public function that returns a result: + * 1. opens a tp_scope (a scratch arena plus the out-of-memory jump), reads its string input + * (TRACKPARSE_NUL_TERMINATED means strlen; NULL means ""), sanitizes it (tp_sanitize), and + * runs the internal pipeline in the scratch arena; + * 2. builds the public result into ONE block from the system allocator, in two passes over the + * same fill code: the first pass measures (its writes land in the scratch arena), the second + * fills a block of exactly that size. The block starts with a hidden RB_HDR-byte header; the + * result struct follows it, then every array and string the result points to. _free frees + * the block; + * 3. frees the scratch arena. On out of memory it frees the scratch arena and the block (if one + * was taken) and returns NULL. + * + * Option handles and edit lists hold the internal typed options in their own arena; setters + * build what they add in that arena under a scope and commit it only when every allocation + * succeeded, so a setter that runs out of memory leaves the handle unchanged. A parser holds its + * engine (the resolved options and the compiled tables) in its own arena, with deep copies of + * every option string, so it does not depend on the options handle it was made from. */ +#include + +#include "trackparse.h" +#include "internal.h" + +/* ============================================================================================ */ +/* go/trackparse.go */ + +/* Parse parses one track string with the default options. */ +TP_PRIVATE tp_track tp_api_parse(tp_str input) { + return tp_engine_run(tp_shared_engine(), tp_sanitize(input), false); +} + +/* ParseWith parses with options (R12); tables compiled per call. o NULL: defaults. */ +TP_PRIVATE tp_track tp_api_parse_with(tp_str input, const tp_parse_options *o) { + return tp_parser_parse(tp_new_parser(o), input); +} + +/* ParseArtists splits an artist credit string into artists (R10). */ +TP_PRIVATE tp_artist_vec tp_api_parse_artists(tp_str input) { + return tp_engine_run_artists(tp_shared_engine(), tp_sanitize(input)); +} + +TP_PRIVATE tp_artist_vec tp_api_parse_artists_with(tp_str input, const tp_parse_options *o) { + return tp_parser_parse_artists(tp_new_parser(o), input); +} + +/* Format renders a parsed track back to a string (R11) with the default options. */ +TP_PRIVATE tp_str tp_api_format(const tp_track *t) { + return tp_format_track(t, tp_resolve_format(NULL)); +} + +TP_PRIVATE tp_str tp_api_format_with(const tp_track *t, const tp_format_options *o) { + return tp_format_track(t, tp_resolve_format(o)); +} + +/* Normalize is R1 on sanitized input. */ +TP_PRIVATE tp_str tp_api_normalize(tp_str input) { return tp_normalize(tp_sanitize(input)); } + +/* AllArtists is every artist of the track, remixers included, without duplicates. */ +TP_PRIVATE tp_artist_vec tp_api_all_artists(const tp_track *t) { return tp_all_artists(t); } + +/* NewParser compiles options (R12) into a parser, in the current arena. */ +TP_PRIVATE tp_parser *tp_new_parser(const tp_parse_options *o) { + tp_parser *p = (tp_parser *)tp_alloc(sizeof *p); + p->e = tp_engine_new(tp_resolve_parse(o)); + return p; +} + +TP_PRIVATE const tp_engine *tp_parser_engine(const tp_parser *p) { + if (p == NULL || p->e == NULL) return tp_shared_engine(); + return p->e; +} + +TP_PRIVATE tp_track tp_parser_parse(const tp_parser *p, tp_str input) { + return tp_engine_run(tp_parser_engine(p), tp_sanitize(input), false); +} + +TP_PRIVATE tp_artist_vec tp_parser_parse_artists(const tp_parser *p, tp_str input) { + return tp_engine_run_artists(tp_parser_engine(p), tp_sanitize(input)); +} + +/* ParseTracklist parses a multi-line tracklist (R13). */ +TP_PRIVATE tp_tracklist tp_api_parse_tracklist(tp_str text) { + return tp_parse_tracklist(tp_sanitize(text), tp_resolve_tracklist(NULL)); +} + +TP_PRIVATE tp_tracklist tp_api_parse_tracklist_with(tp_str text, const tp_tracklist_options *o) { + return tp_parse_tracklist(tp_sanitize(text), tp_resolve_tracklist(o)); +} + +/* ApplyEdits applies edits in order, each to the previous result (R13.9), through each edit's + * JSON form (which also sanitizes its strings: typed and loose edits share one code path). */ +TP_PRIVATE tp_edit_result tp_api_apply_edits(tp_str text, const tp_edit *edits, size_t count) { + tp_json *loose = (tp_json *)tp_alloc_array(count, sizeof *loose); + tp_raw_edit_result r; + size_t i; + for (i = 0; i < count; i++) loose[i] = tp_edit_json(&edits[i]); + r = tp_apply_edits(tp_sanitize(text), loose, count); + return tp_raw_edit_result_result(&r); +} + +/* ApplyEditsWith: the options are accepted for symmetry (R13.10); edits do not depend on them. */ +TP_PRIVATE tp_edit_result tp_api_apply_edits_with(tp_str text, const tp_edit *edits, size_t count, + const tp_tracklist_options *o) { + (void)o; + return tp_api_apply_edits(text, edits, count); +} + +/* ============================================================================================ */ +/* Versions and the allocator */ + +TRACKPARSE_API const char *trackparse_library_version(void) { return TRACKPARSE_VERSION; } + +TRACKPARSE_API const char *trackparse_spec_version(void) { return TP_SPEC_VERSION; } + +TRACKPARSE_API void trackparse_set_allocator(const trackparse_allocator *allocator) { + tp_allocator a; + if (allocator == NULL) { + tp_set_allocator(NULL); + return; + } + a.malloc_fn = allocator->malloc_fn; + a.realloc_fn = allocator->realloc_fn; + a.free_fn = allocator->free_fn; + a.user = allocator->user; + tp_set_allocator(&a); +} + +/* ============================================================================================ */ +/* Enumerations */ + +static const char *const mode_names[] = {"auto", "clean", "youtube", "filename", "tracklist"}; +static const char *const role_names[] = {"primary", "featured", "remixer", "producer"}; +static const char *const source_names[] = {"artist", "title", "version"}; +static const char *const version_type_names[] = { + "remix", "bootleg", "vip", "edit", "flip", "refix", "rework", + "mashup", "blend", "dub", "mix", "extended", "radio", "club", + "original", "instrumental", "acapella", "live", "acoustic", "remaster", "demo", + "reprise", "cover", "version", "spedUp", "slowed", "nightcore"}; +static const char *const delimiter_names[] = {"(", "[", "{", "-"}; +static const char *const junk_kind_names[] = {"video", "audio", "lyrics", "quality", "promo", + "platform", "label", "genre", "other"}; +static const char *const warning_names[] = { + "noSeparator", "ambiguousSeparator", "unspacedDashSplit", "asymmetricDashSplit", + "bySplit", "quotedTitleSplit", "ambiguousMixCredit", "unbalancedBrackets"}; +static const char *const entry_kind_names[] = {"track", "marker", "header", + "link", "note", "blank"}; +static const char *const eol_names[] = {"\n", "\r\n", "\r", ""}; +static const char *const tl_warning_names[] = { + "time-missing", "time-out-of-order", "time-duplicate", + "no-start-at-zero", "time-after-audio-end", "invalid-time", + "position-gap", "position-duplicate", "line-unparsed"}; +static const char *const severity_names[] = {"info", "warning"}; +static const char *const edit_op_names[] = {"set-time", "shift", "sort-by-time", + "set-rest", "insert", "delete"}; +static const char *const edit_warning_names[] = {"edit-invalid", "time-clamped", "style-upgraded"}; + +/* The name of value v in a table, "" out of range. */ +static const char *name_at(const char *const *names, size_t n, size_t v) { + return v < n ? names[v] : ""; +} + +#define NAME_OF(table, v) name_at((table), TP_COUNT(table), (size_t)(v)) + +/* The index of s in a table, or -1. */ +static int index_of(const char *const *names, size_t n, tp_str s) { + size_t i; + for (i = 0; i < n; i++) { + if (tp_str_eq_c(s, names[i])) return (int)i; + } + return -1; +} + +#define INDEX_OF(table, s) index_of((table), TP_COUNT(table), (s)) + +TRACKPARSE_API const char *trackparse_mode_name(trackparse_mode v) { + return NAME_OF(mode_names, v); +} +TRACKPARSE_API const char *trackparse_role_name(trackparse_role v) { + return NAME_OF(role_names, v); +} +TRACKPARSE_API const char *trackparse_source_name(trackparse_source v) { + return NAME_OF(source_names, v); +} +TRACKPARSE_API const char *trackparse_version_type_name(trackparse_version_type v) { + return NAME_OF(version_type_names, v); +} +TRACKPARSE_API const char *trackparse_delimiter_name(trackparse_delimiter v) { + return NAME_OF(delimiter_names, v); +} +TRACKPARSE_API const char *trackparse_junk_kind_name(trackparse_junk_kind v) { + return NAME_OF(junk_kind_names, v); +} +TRACKPARSE_API const char *trackparse_warning_name(trackparse_warning v) { + return NAME_OF(warning_names, v); +} +TRACKPARSE_API const char *trackparse_entry_kind_name(trackparse_entry_kind v) { + return NAME_OF(entry_kind_names, v); +} +TRACKPARSE_API const char *trackparse_eol_name(trackparse_eol v) { return NAME_OF(eol_names, v); } +TRACKPARSE_API const char * +trackparse_tracklist_warning_code_name(trackparse_tracklist_warning_code v) { + return NAME_OF(tl_warning_names, v); +} +TRACKPARSE_API const char *trackparse_severity_name(trackparse_severity v) { + return NAME_OF(severity_names, v); +} +TRACKPARSE_API const char *trackparse_edit_op_name(trackparse_edit_op v) { + return NAME_OF(edit_op_names, v); +} +TRACKPARSE_API const char *trackparse_edit_warning_code_name(trackparse_edit_warning_code v) { + return NAME_OF(edit_warning_names, v); +} + +/* String input: NULL is "", TRACKPARSE_NUL_TERMINATED is strlen. Never a NULL pointer, so the + * pipeline never hands NULL to memcpy. */ +static tp_str in_str(const char *s, size_t len) { + tp_str r; + if (s == NULL) return TP_EMPTY; + if (len == TRACKPARSE_NUL_TERMINATED) len = strlen(s); + r.p = s; + r.n = len; + return r; +} + +static int from_name(const char *const *names, size_t n, const char *name, size_t len) { + if (name == NULL) return -1; + return index_of(names, n, in_str(name, len)); +} + +TRACKPARSE_API bool trackparse_mode_from_name(const char *name, size_t len, trackparse_mode *out) { + int i = from_name(mode_names, TP_COUNT(mode_names), name, len); + if (i < 0) return false; + if (out != NULL) *out = (trackparse_mode)i; + return true; +} + +TRACKPARSE_API bool trackparse_version_type_from_name(const char *name, size_t len, + trackparse_version_type *out) { + int i = from_name(version_type_names, TP_COUNT(version_type_names), name, len); + if (i < 0) return false; + if (out != NULL) *out = (trackparse_version_type)i; + return true; +} + +TRACKPARSE_API bool trackparse_junk_kind_from_name(const char *name, size_t len, + trackparse_junk_kind *out) { + int i = from_name(junk_kind_names, TP_COUNT(junk_kind_names), name, len); + if (i < 0) return false; + if (out != NULL) *out = (trackparse_junk_kind)i; + return true; +} + +/* ============================================================================================ */ +/* Guarded calls and result blocks */ + +/* The hidden header in front of every result struct. */ +#define RB_HDR 16 +/* Alignment of every array and struct in a block (strings are byte-aligned). */ +#define RB_ALIGN 8 + +/* A result block being built. base NULL: the measuring pass (allocations come from the scratch + * arena and only used counts). */ +typedef struct rb { + char *base; + size_t used; + size_t cap; +} rb; + +static void *rb_take(rb *b, size_t n, size_t align) { + size_t at = tp_size_add(b->used, align - 1) & ~(align - 1); + b->used = tp_size_add(at, n); + if (b->base == NULL) return tp_alloc(n); + if (b->used > b->cap) tp_oom(); /* cannot happen: both passes take the same sizes */ + return b->base + at; +} + +static void *rb_alloc(rb *b, size_t n) { return rb_take(b, n, RB_ALIGN); } + +/* An array of count elements, NULL for 0. */ +static void *rb_array(rb *b, size_t count, size_t size) { + if (count == 0) return NULL; + return rb_alloc(b, tp_size_mul(count, size)); +} + +/* A NUL-terminated copy ("" is the static empty string). */ +static trackparse_str rb_str(rb *b, tp_str s) { + trackparse_str r; + char *d; + if (s.n == 0) { + r.ptr = ""; + r.len = 0; + return r; + } + d = (char *)rb_take(b, tp_size_add(s.n, 1), 1); + memcpy(d, s.p, s.n); + d[s.n] = '\0'; + r.ptr = d; + r.len = s.n; + return r; +} + +/* The state of one guarded call. It lives in the frame of the public function, not in the frame + * that calls setjmp, so its contents are well defined after the out-of-memory longjmp. */ +typedef struct call { + rb b; + void *result; +} call; + +typedef void (*work_fn)(call *c, void *arg); + +/* Run work inside a scope: true when it finished, false when it ran out of memory (the scratch + * arena and any result block are then freed). */ +static bool guarded(call *c, work_fn work, void *arg) { + tp_scope s; + memset(c, 0, sizeof *c); + if (!tp_scope_open(&s)) return false; + if (setjmp(s.jmp) != 0) { + tp_scope_abort(&s); + tp_sys_free(c->b.base); + c->b.base = NULL; + c->result = NULL; + return false; + } + tp_scope_arm(&s); + work(c, arg); + tp_scope_close(&s); + tp_arena_free(s.arena); + return true; +} + +static void *guarded_result(work_fn work, void *arg) { + call c; + if (!guarded(&c, work, arg)) return NULL; + return c.result; +} + +typedef void (*fill_fn)(rb *b, void *top, const void *src); + +/* The result block for src: measure, take the block, fill it. Sets c->result. */ +static void rb_build(call *c, size_t top_size, fill_fn fill, const void *src) { + rb *b = &c->b; + void *top; + char *block; + size_t total; + b->base = NULL; + b->cap = 0; + b->used = RB_HDR; + top = rb_alloc(b, top_size); + fill(b, top, src); + total = b->used; + block = (char *)tp_sys_malloc(total); + if (block == NULL) tp_oom(); + memset(block, 0, total); + memcpy(block, "trackparse", 10); /* the hidden header: a tag for debuggers */ + b->base = block; + b->cap = total; + b->used = RB_HDR; + top = rb_alloc(b, top_size); + fill(b, top, src); + b->base = NULL; /* owned by the result now */ + c->result = top; +} + +/* The block of a result. */ +static void free_result(const void *p) { + if (p != NULL) tp_sys_free((char *)p - RB_HDR); +} + +static int to_int(ptrdiff_t v) { + if (v > INT_MAX) return INT_MAX; + if (v < INT_MIN) return INT_MIN; + return (int)v; +} + +/* ============================================================================================ */ +/* Internal results -> public results */ + +static void fill_artist(rb *b, trackparse_artist *out, const tp_artist *a) { + int i; + out->name = rb_str(b, a->name); + i = INDEX_OF(role_names, a->role); + out->role = (trackparse_role)(i < 0 ? 0 : i); + out->joiner = NULL; + if (a->joiner != NULL) { + trackparse_str *j = (trackparse_str *)rb_alloc(b, sizeof *j); + *j = rb_str(b, *a->joiner); + out->joiner = j; + } + i = INDEX_OF(source_names, a->source); + out->source = (trackparse_source)(i < 0 ? 0 : i); +} + +static const trackparse_artist *fill_artist_list(rb *b, tp_artist_vec list) { + trackparse_artist *items = (trackparse_artist *)rb_array(b, list.n, sizeof *items); + size_t i; + for (i = 0; i < list.n; i++) fill_artist(b, &items[i], &list.p[i]); + return items; +} + +static const int *rb_int(rb *b, const ptrdiff_t *v) { + int *p; + if (v == NULL) return NULL; + p = (int *)rb_alloc(b, sizeof *p); + *p = to_int(*v); + return p; +} + +static void fill_version(rb *b, trackparse_version *out, const tp_version *v) { + trackparse_str *mods; + size_t i; + int k = INDEX_OF(version_type_names, v->type); + /* A type that keywords introduced is "version" in the enum; type_name keeps it. */ + out->type = k < 0 ? TRACKPARSE_VERSION_VERSION : (trackparse_version_type)k; + out->type_name = rb_str(b, v->type); + out->raw = rb_str(b, v->raw); + out->artists = fill_artist_list(b, v->artists); + out->artists_count = v->artists.n; + mods = (trackparse_str *)rb_array(b, v->modifiers.n, sizeof *mods); + for (i = 0; i < v->modifiers.n; i++) mods[i] = rb_str(b, v->modifiers.p[i]); + out->modifiers = mods; + out->modifiers_count = v->modifiers.n; + out->descriptor = NULL; + if (v->descriptor != NULL) { + trackparse_str *d = (trackparse_str *)rb_alloc(b, sizeof *d); + *d = rb_str(b, *v->descriptor); + out->descriptor = d; + } + out->year = rb_int(b, v->year); + out->unknown_artist = v->unknown_artist; + k = INDEX_OF(delimiter_names, v->delimiter); + out->delimiter = (trackparse_delimiter)(k < 0 ? 0 : k); +} + +static void fill_track(rb *b, trackparse_track *out, const tp_track *t) { + trackparse_version *versions; + trackparse_junk *junk; + trackparse_warning *warnings; + size_t i; + int k; + out->input = rb_str(b, t->input); + k = INDEX_OF(mode_names, t->mode); + out->mode = (trackparse_mode)(k < 0 ? 0 : k); + out->position = NULL; + if (t->position != NULL) { + trackparse_position *p = (trackparse_position *)rb_alloc(b, sizeof *p); + p->raw = rb_str(b, t->position->raw); + p->number = to_int(t->position->number); + out->position = p; + } + out->timestamp = NULL; + if (t->timestamp != NULL) { + trackparse_timestamp *p = (trackparse_timestamp *)rb_alloc(b, sizeof *p); + p->raw = rb_str(b, t->timestamp->raw); + p->seconds = to_int(t->timestamp->seconds); + out->timestamp = p; + } + out->artists = fill_artist_list(b, t->artists); + out->artists_count = t->artists.n; + out->title = rb_str(b, t->title); + out->full_title = rb_str(b, t->full_title); + versions = (trackparse_version *)rb_array(b, t->versions.n, sizeof *versions); + for (i = 0; i < t->versions.n; i++) fill_version(b, &versions[i], &t->versions.p[i]); + out->versions = versions; + out->versions_count = t->versions.n; + out->year = rb_int(b, t->year); + out->flags.explicit_ = t->flags.explicit_; + out->flags.clean = t->flags.clean; + out->flags.unknown_artist = t->flags.unknown_artist; + out->flags.unknown_title = t->flags.unknown_title; + junk = (trackparse_junk *)rb_array(b, t->junk.n, sizeof *junk); + for (i = 0; i < t->junk.n; i++) { + const tp_junk *j = &t->junk.p[i]; + k = INDEX_OF(junk_kind_names, j->kind); + junk[i].raw = rb_str(b, j->raw); + junk[i].kind = k < 0 ? TRACKPARSE_JUNK_OTHER : (trackparse_junk_kind)k; + junk[i].kind_name = rb_str(b, j->kind); + } + out->junk = junk; + out->junk_count = t->junk.n; + warnings = (trackparse_warning *)rb_array(b, t->warnings.n, sizeof *warnings); + for (i = 0; i < t->warnings.n; i++) { + k = INDEX_OF(warning_names, t->warnings.p[i]); + warnings[i] = (trackparse_warning)(k < 0 ? 0 : k); + } + out->warnings = warnings; + out->warnings_count = t->warnings.n; +} + +static void fill_track_top(rb *b, void *top, const void *src) { + fill_track(b, (trackparse_track *)top, (const tp_track *)src); +} + +static void fill_artists_top(rb *b, void *top, const void *src) { + trackparse_artists *out = (trackparse_artists *)top; + const tp_artist_vec *list = (const tp_artist_vec *)src; + out->items = fill_artist_list(b, *list); + out->count = list->n; +} + +static void fill_string_top(rb *b, void *top, const void *src) { + ((trackparse_string *)top)->str = rb_str(b, *(const tp_str *)src); +} + +static const double *rb_double(rb *b, const double *v) { + double *p; + if (v == NULL) return NULL; + p = (double *)rb_alloc(b, sizeof *p); + *p = *v; + return p; +} + +static void fill_tracklist_top(rb *b, void *top, const void *src) { + trackparse_tracklist *out = (trackparse_tracklist *)top; + const tp_tracklist *l = (const tp_tracklist *)src; + trackparse_entry *entries; + trackparse_tracklist_warning *warnings; + size_t i; + int k; + out->spec_version = rb_str(b, l->spec_version); + entries = (trackparse_entry *)rb_array(b, l->entries.n, sizeof *entries); + for (i = 0; i < l->entries.n; i++) { + const tp_entry *e = &l->entries.p[i]; + trackparse_entry *x = &entries[i]; + x->line = to_int(e->line); + k = INDEX_OF(entry_kind_names, e->kind); + x->kind = (trackparse_entry_kind)(k < 0 ? 0 : k); + k = INDEX_OF(eol_names, e->eol); + x->eol = (trackparse_eol)(k < 0 ? 0 : k); + x->raw = rb_str(b, e->raw); + x->parts.lead = rb_str(b, e->parts.lead); + x->parts.time = rb_str(b, e->parts.time); + x->parts.gap = rb_str(b, e->parts.gap); + x->parts.rest = rb_str(b, e->parts.rest); + x->time = NULL; + if (e->time != NULL) { + trackparse_tracklist_time *t = (trackparse_tracklist_time *)rb_alloc(b, sizeof *t); + t->raw = rb_str(b, e->time->raw); + t->seconds = e->time->seconds; + x->time = t; + } + x->track = NULL; + if (e->track != NULL) { + trackparse_track *t = (trackparse_track *)rb_alloc(b, sizeof *t); + fill_track(b, t, e->track); + x->track = t; + } + x->layered = e->layered; + } + out->entries = entries; + out->entries_count = l->entries.n; + warnings = (trackparse_tracklist_warning *)rb_array(b, l->warnings.n, sizeof *warnings); + for (i = 0; i < l->warnings.n; i++) { + const tp_tracklist_warning *w = &l->warnings.p[i]; + trackparse_tracklist_warning *x = &warnings[i]; + k = INDEX_OF(tl_warning_names, w->code); + x->code = (trackparse_tracklist_warning_code)(k < 0 ? 0 : k); + x->line = to_int(w->line); + k = INDEX_OF(severity_names, w->severity); + x->severity = (trackparse_severity)(k < 0 ? 0 : k); + x->suggestion = NULL; + if (w->suggestion != NULL) { + trackparse_suggestion *s = (trackparse_suggestion *)rb_alloc(b, sizeof *s); + s->line = to_int(w->suggestion->line); + s->raw = rb_str(b, w->suggestion->raw); + s->seconds = w->suggestion->seconds; + x->suggestion = s; + } + } + out->warnings = warnings; + out->warnings_count = l->warnings.n; + out->stats.lines = to_int(l->stats.lines); + out->stats.tracks = to_int(l->stats.tracks); + out->stats.markers = to_int(l->stats.markers); + out->stats.timed = to_int(l->stats.timed); + out->stats.first_time = rb_double(b, l->stats.first_time); + out->stats.last_time = rb_double(b, l->stats.last_time); +} + +static void fill_edit_result_top(rb *b, void *top, const void *src) { + trackparse_edit_result *out = (trackparse_edit_result *)top; + const tp_edit_result *r = (const tp_edit_result *)src; + long long *changed; + trackparse_edit_warning *warnings; + size_t i; + out->text = rb_str(b, r->text); + changed = (long long *)rb_array(b, r->changed.n, sizeof *changed); + for (i = 0; i < r->changed.n; i++) changed[i] = (long long)r->changed.p[i]; + out->changed = changed; + out->changed_count = r->changed.n; + warnings = (trackparse_edit_warning *)rb_array(b, r->warnings.n, sizeof *warnings); + for (i = 0; i < r->warnings.n; i++) { + const tp_edit_warning *w = &r->warnings.p[i]; + int k = INDEX_OF(edit_warning_names, w->code); + warnings[i].code = (trackparse_edit_warning_code)(k < 0 ? 0 : k); + warnings[i].edit = w->edit < 0 ? 0 : (size_t)w->edit; + warnings[i].line = NULL; + if (w->line != NULL) { + long long *n = (long long *)rb_alloc(b, sizeof *n); + *n = (long long)*w->line; + warnings[i].line = n; + } + } + out->warnings = warnings; + out->warnings_count = r->warnings.n; +} + +/* ============================================================================================ */ +/* Public results -> internal values (format, all_artists, *_to_json). A C caller may build a */ +/* result by hand: NULL arrays count as empty, NULL strings as "", out-of-range enums as "". */ + +static tp_str int_str(trackparse_str s) { + tp_str r; + if (s.ptr == NULL) return TP_EMPTY; + r.p = s.ptr; + r.n = s.len; + return tp_sanitize(r); +} + +static const tp_str *int_opt_str(const trackparse_str *s) { + tp_str *p; + if (s == NULL) return NULL; + p = (tp_str *)tp_alloc(sizeof *p); + *p = int_str(*s); + return p; +} + +static const ptrdiff_t *int_opt_int(const int *v) { + ptrdiff_t *p; + if (v == NULL) return NULL; + p = (ptrdiff_t *)tp_alloc(sizeof *p); + *p = (ptrdiff_t)*v; + return p; +} + +static const double *int_opt_double(const double *v) { + double *p; + if (v == NULL) return NULL; + p = (double *)tp_alloc(sizeof *p); + *p = *v; + return p; +} + +#define INT_NAME(table, v) tp_str_c(NAME_OF(table, v)) +/* The count of an array, 0 when its pointer is NULL. */ +#define COUNT(items, count) ((items) == NULL ? (size_t)0 : (count)) + +static tp_artist int_artist(const trackparse_artist *a) { + tp_artist r; + r.name = int_str(a->name); + r.role = INT_NAME(role_names, a->role); + r.joiner = int_opt_str(a->joiner); + r.source = INT_NAME(source_names, a->source); + return r; +} + +static tp_artist_vec int_artist_list(const trackparse_artist *items, size_t count) { + tp_artist_vec v = {0, 0, 0}; + size_t i, n = COUNT(items, count); + for (i = 0; i < n; i++) tp_push(v, int_artist(&items[i])); + return v; +} + +static tp_version int_version(const trackparse_version *v) { + tp_version r; + size_t i, n; + memset(&r, 0, sizeof r); + /* type_name is what a library result carries; a hand-built version may leave it unset. */ + r.type = v->type_name.ptr != NULL ? int_str(v->type_name) : INT_NAME(version_type_names, v->type); + r.raw = int_str(v->raw); + r.artists = int_artist_list(v->artists, v->artists_count); + n = COUNT(v->modifiers, v->modifiers_count); + for (i = 0; i < n; i++) tp_push(r.modifiers, int_str(v->modifiers[i])); + r.descriptor = int_opt_str(v->descriptor); + r.year = int_opt_int(v->year); + r.unknown_artist = v->unknown_artist; + r.delimiter = INT_NAME(delimiter_names, v->delimiter); + return r; +} + +static tp_track int_track(const trackparse_track *t) { + tp_track r; + size_t i, n; + memset(&r, 0, sizeof r); + r.input = int_str(t->input); + r.mode = INT_NAME(mode_names, t->mode); + if (t->position != NULL) { + tp_position *p = (tp_position *)tp_alloc(sizeof *p); + p->raw = int_str(t->position->raw); + p->number = (ptrdiff_t)t->position->number; + r.position = p; + } + if (t->timestamp != NULL) { + tp_timestamp *p = (tp_timestamp *)tp_alloc(sizeof *p); + p->raw = int_str(t->timestamp->raw); + p->seconds = (ptrdiff_t)t->timestamp->seconds; + r.timestamp = p; + } + r.artists = int_artist_list(t->artists, t->artists_count); + r.title = int_str(t->title); + r.full_title = int_str(t->full_title); + n = COUNT(t->versions, t->versions_count); + for (i = 0; i < n; i++) tp_push(r.versions, int_version(&t->versions[i])); + r.year = int_opt_int(t->year); + r.flags.explicit_ = t->flags.explicit_; + r.flags.clean = t->flags.clean; + r.flags.unknown_artist = t->flags.unknown_artist; + r.flags.unknown_title = t->flags.unknown_title; + n = COUNT(t->junk, t->junk_count); + for (i = 0; i < n; i++) { + const trackparse_junk *j = &t->junk[i]; + tp_junk x; + x.raw = int_str(j->raw); + x.kind = j->kind_name.ptr != NULL ? int_str(j->kind_name) : INT_NAME(junk_kind_names, j->kind); + tp_push(r.junk, x); + } + n = COUNT(t->warnings, t->warnings_count); + for (i = 0; i < n; i++) tp_push(r.warnings, INT_NAME(warning_names, t->warnings[i])); + return r; +} + +/* The empty track a NULL track pointer stands for. */ +static tp_track int_track_or_empty(const trackparse_track *t) { + trackparse_track empty; + if (t != NULL) return int_track(t); + memset(&empty, 0, sizeof empty); + empty.mode = TRACKPARSE_MODE_CLEAN; + return int_track(&empty); +} + +static tp_tracklist int_tracklist(const trackparse_tracklist *l) { + tp_tracklist r; + size_t i, n; + memset(&r, 0, sizeof r); + r.spec_version = int_str(l->spec_version); + n = COUNT(l->entries, l->entries_count); + for (i = 0; i < n; i++) { + const trackparse_entry *e = &l->entries[i]; + tp_entry x; + memset(&x, 0, sizeof x); + x.line = (ptrdiff_t)e->line; + x.kind = INT_NAME(entry_kind_names, e->kind); + x.eol = INT_NAME(eol_names, e->eol); + x.raw = int_str(e->raw); + x.parts.lead = int_str(e->parts.lead); + x.parts.time = int_str(e->parts.time); + x.parts.gap = int_str(e->parts.gap); + x.parts.rest = int_str(e->parts.rest); + if (e->time != NULL) { + tp_tracklist_time *t = (tp_tracklist_time *)tp_alloc(sizeof *t); + t->raw = int_str(e->time->raw); + t->seconds = e->time->seconds; + x.time = t; + } + if (e->track != NULL) { + tp_track *t = (tp_track *)tp_alloc(sizeof *t); + *t = int_track(e->track); + x.track = t; + } + x.layered = e->layered; + tp_push(r.entries, x); + } + n = COUNT(l->warnings, l->warnings_count); + for (i = 0; i < n; i++) { + const trackparse_tracklist_warning *w = &l->warnings[i]; + tp_tracklist_warning x; + x.code = INT_NAME(tl_warning_names, w->code); + x.line = (ptrdiff_t)w->line; + x.severity = INT_NAME(severity_names, w->severity); + x.suggestion = NULL; + if (w->suggestion != NULL) { + tp_suggestion *s = (tp_suggestion *)tp_alloc(sizeof *s); + s->line = (ptrdiff_t)w->suggestion->line; + s->raw = int_str(w->suggestion->raw); + s->seconds = w->suggestion->seconds; + x.suggestion = s; + } + tp_push(r.warnings, x); + } + r.stats.lines = (ptrdiff_t)l->stats.lines; + r.stats.tracks = (ptrdiff_t)l->stats.tracks; + r.stats.markers = (ptrdiff_t)l->stats.markers; + r.stats.timed = (ptrdiff_t)l->stats.timed; + r.stats.first_time = int_opt_double(l->stats.first_time); + r.stats.last_time = int_opt_double(l->stats.last_time); + return r; +} + +static tp_edit_result int_edit_result(const trackparse_edit_result *e) { + tp_edit_result r; + size_t i, n; + memset(&r, 0, sizeof r); + r.text = int_str(e->text); + n = COUNT(e->changed, e->changed_count); + for (i = 0; i < n; i++) tp_push(r.changed, (int64_t)e->changed[i]); + n = COUNT(e->warnings, e->warnings_count); + for (i = 0; i < n; i++) { + const trackparse_edit_warning *w = &e->warnings[i]; + tp_edit_warning x; + x.code = INT_NAME(edit_warning_names, w->code); + x.edit = w->edit > (size_t)PTRDIFF_MAX ? PTRDIFF_MAX : (ptrdiff_t)w->edit; + x.line = NULL; + if (w->line != NULL) { + int64_t *p = (int64_t *)tp_alloc(sizeof *p); + *p = (int64_t)*w->line; + x.line = p; + } + tp_push(r.warnings, x); + } + return r; +} + +/* ============================================================================================ */ +/* Options */ + +struct trackparse_parse_options { + tp_arena *arena; /* NULL until a setter needs memory */ + tp_parse_options o; +}; + +struct trackparse_format_options { + tp_arena *arena; + tp_format_options o; +}; + +struct trackparse_tracklist_options { + tp_arena *arena; + tp_tracklist_options o; +}; + +/* A zeroed handle from the system allocator. */ +static void *handle_new(size_t size) { + void *p = tp_sys_malloc(size); + if (p != NULL) memset(p, 0, size); + return p; +} + +static void init_keywords(tp_keywords *k) { memset(k, 0, sizeof *k); } + +typedef void (*mutate_fn)(void *arg); + +/* Run fn with *arena current, under a scope: false when it ran out of memory. fn must commit + * its change only after its last allocation, so a failure leaves the handle as it was. */ +static bool mutate(tp_arena **arena, mutate_fn fn, void *arg) { + tp_scope s; + if (*arena == NULL) { + *arena = tp_arena_new(); + if (*arena == NULL) return false; + } + if (!tp_scope_open(&s)) return false; + if (setjmp(s.jmp) != 0) { + tp_scope_abort(&s); + return false; + } + tp_scope_arm(&s); + tp_arena_use(*arena); + fn(arg); + tp_scope_close(&s); + tp_arena_free(s.arena); + return true; +} + +/* Setter arguments. */ +typedef struct set_arg { + tp_str *str; /* set a string */ + const tp_str **pstr; /* set a nullable string */ + tp_strvec *list; /* append a string */ + tp_version_head_vec *heads; + tp_junk_phrase_vec *junk; + const double **num; /* set a nullable number */ + tp_str a, b; + double value; +} set_arg; + +static void do_set_str(void *p) { + set_arg *x = (set_arg *)p; + *x->str = tp_str_copy(x->a.p, x->a.n); +} + +static void do_set_pstr(void *p) { + set_arg *x = (set_arg *)p; + tp_str *s = (tp_str *)tp_alloc(sizeof *s); + *s = tp_str_copy(x->a.p, x->a.n); + *x->pstr = s; +} + +static void do_add_str(void *p) { + set_arg *x = (set_arg *)p; + tp_strvec v = *x->list; + tp_push(v, tp_str_copy(x->a.p, x->a.n)); + *x->list = v; +} + +static void do_add_head(void *p) { + set_arg *x = (set_arg *)p; + tp_version_head_vec v = *x->heads; + tp_version_head h; + h.key = tp_str_copy(x->a.p, x->a.n); + h.type = tp_str_copy(x->b.p, x->b.n); + tp_push(v, h); + *x->heads = v; +} + +static void do_add_junk(void *p) { + set_arg *x = (set_arg *)p; + tp_junk_phrase_vec v = *x->junk; + tp_junk_phrase j; + j.phrase = tp_str_copy(x->a.p, x->a.n); + j.kind = tp_str_copy(x->b.p, x->b.n); + tp_push(v, j); + *x->junk = v; +} + +static void do_set_num(void *p) { + set_arg *x = (set_arg *)p; + double *d = (double *)tp_alloc(sizeof *d); + *d = x->value; + *x->num = d; +} + +static set_arg arg_of(tp_str a, tp_str b) { + set_arg x; + memset(&x, 0, sizeof x); + x.a = a; + x.b = b; + return x; +} + +static bool set_string(tp_arena **arena, tp_str *field, const char *s, size_t len) { + set_arg x = arg_of(in_str(s, len), TP_EMPTY); + x.str = field; + return mutate(arena, do_set_str, &x); +} + +static bool add_string(tp_arena **arena, tp_strvec *list, const char *s, size_t len) { + set_arg x = arg_of(in_str(s, len), TP_EMPTY); + x.list = list; + return mutate(arena, do_add_str, &x); +} + +static bool add_head(tp_arena **arena, tp_keywords *k, const char *key, size_t key_len, + const char *type, size_t type_len) { + set_arg x = arg_of(in_str(key, key_len), in_str(type, type_len)); + x.heads = &k->version_heads; + return mutate(arena, do_add_head, &x); +} + +static bool add_junk(tp_arena **arena, tp_keywords *k, const char *phrase, size_t phrase_len, + const char *kind, size_t kind_len) { + set_arg x = arg_of(in_str(phrase, phrase_len), in_str(kind, kind_len)); + x.junk = &k->junk; + return mutate(arena, do_add_junk, &x); +} + +/* The option string of an enum value; "" (the default) for a value out of range. */ +static tp_str mode_option(trackparse_mode m) { return tp_str_c(NAME_OF(mode_names, m)); } + +static tp_str split_and_option(trackparse_split_and v) { + static const char *const names[] = {"auto", "always", "never"}; + return tp_str_c(NAME_OF(names, v)); +} + +/* Parse options */ + +TRACKPARSE_API trackparse_parse_options *trackparse_parse_options_new(void) { + trackparse_parse_options *o = (trackparse_parse_options *)handle_new(sizeof *o); + if (o == NULL) return NULL; + o->o.mode = TP_EMPTY; + o->o.uploader = TP_EMPTY; + o->o.split_and = TP_EMPTY; + init_keywords(&o->o.keywords); + return o; +} + +TRACKPARSE_API void trackparse_parse_options_free(trackparse_parse_options *o) { + if (o == NULL) return; + tp_arena_free(o->arena); + tp_sys_free(o); +} + +TRACKPARSE_API bool trackparse_parse_options_set_mode(trackparse_parse_options *o, + trackparse_mode mode) { + if (o == NULL) return true; + o->o.mode = mode_option(mode); + return true; +} + +TRACKPARSE_API bool trackparse_parse_options_set_uploader(trackparse_parse_options *o, + const char *s, size_t len) { + if (o == NULL) return true; + return set_string(&o->arena, &o->o.uploader, s, len); +} + +TRACKPARSE_API bool trackparse_parse_options_add_known_artist(trackparse_parse_options *o, + const char *s, size_t len) { + if (o == NULL) return true; + return add_string(&o->arena, &o->o.known_artists, s, len); +} + +TRACKPARSE_API bool trackparse_parse_options_set_split_and(trackparse_parse_options *o, + trackparse_split_and v) { + if (o == NULL) return true; + o->o.split_and = split_and_option(v); + return true; +} + +TRACKPARSE_API bool trackparse_parse_options_add_version_head(trackparse_parse_options *o, + const char *key, size_t key_len, + const char *type, size_t type_len) { + if (o == NULL) return true; + return add_head(&o->arena, &o->o.keywords, key, key_len, type, type_len); +} + +TRACKPARSE_API bool trackparse_parse_options_add_descriptor(trackparse_parse_options *o, + const char *s, size_t len) { + if (o == NULL) return true; + return add_string(&o->arena, &o->o.keywords.descriptors, s, len); +} + +TRACKPARSE_API bool trackparse_parse_options_add_genre(trackparse_parse_options *o, const char *s, + size_t len) { + if (o == NULL) return true; + return add_string(&o->arena, &o->o.keywords.genres, s, len); +} + +TRACKPARSE_API bool trackparse_parse_options_add_junk(trackparse_parse_options *o, + const char *phrase, size_t phrase_len, + const char *kind, size_t kind_len) { + if (o == NULL) return true; + return add_junk(&o->arena, &o->o.keywords, phrase, phrase_len, kind, kind_len); +} + +TRACKPARSE_API bool trackparse_parse_options_add_feat_marker(trackparse_parse_options *o, + const char *s, size_t len) { + if (o == NULL) return true; + return add_string(&o->arena, &o->o.keywords.feat_markers, s, len); +} + +/* Format options */ + +TRACKPARSE_API trackparse_format_options *trackparse_format_options_new(void) { + trackparse_format_options *o = (trackparse_format_options *)handle_new(sizeof *o); + if (o == NULL) return NULL; + o->o.feat = TP_EMPTY; + o->o.joiners = TP_EMPTY; + o->o.versions = TP_EMPTY; + return o; +} + +TRACKPARSE_API void trackparse_format_options_free(trackparse_format_options *o) { + if (o == NULL) return; + tp_arena_free(o->arena); + tp_sys_free(o); +} + +TRACKPARSE_API bool trackparse_format_options_set_feat(trackparse_format_options *o, + trackparse_feat v) { + static const char *const names[] = {"source", "artist", "title", "omit"}; + if (o == NULL) return true; + o->o.feat = tp_str_c(NAME_OF(names, v)); + return true; +} + +TRACKPARSE_API bool trackparse_format_options_set_feat_marker(trackparse_format_options *o, + const char *s, size_t len) { + set_arg x; + if (o == NULL) return true; + x = arg_of(in_str(s, len), TP_EMPTY); + x.pstr = &o->o.feat_marker; + return mutate(&o->arena, do_set_pstr, &x); +} + +TRACKPARSE_API bool trackparse_format_options_set_joiners(trackparse_format_options *o, + trackparse_joiners v) { + static const char *const names[] = {"original", "canonical"}; + if (o == NULL) return true; + o->o.joiners = tp_str_c(NAME_OF(names, v)); + return true; +} + +TRACKPARSE_API bool trackparse_format_options_set_versions(trackparse_format_options *o, + trackparse_versions v) { + static const char *const names[] = {"all", "none"}; + if (o == NULL) return true; + o->o.versions = tp_str_c(NAME_OF(names, v)); + return true; +} + +TRACKPARSE_API bool trackparse_format_options_set_omit_producers(trackparse_format_options *o, + bool v) { + if (o == NULL) return true; + o->o.omit_producers = v; + return true; +} + +TRACKPARSE_API bool trackparse_format_options_set_position(trackparse_format_options *o, bool v) { + if (o == NULL) return true; + o->o.position = v; + return true; +} + +/* Tracklist options */ + +TRACKPARSE_API trackparse_tracklist_options *trackparse_tracklist_options_new(void) { + trackparse_tracklist_options *o = (trackparse_tracklist_options *)handle_new(sizeof *o); + if (o == NULL) return NULL; + o->o.mode = TP_EMPTY; + o->o.split_and = TP_EMPTY; + init_keywords(&o->o.keywords); + return o; +} + +TRACKPARSE_API void trackparse_tracklist_options_free(trackparse_tracklist_options *o) { + if (o == NULL) return; + tp_arena_free(o->arena); + tp_sys_free(o); +} + +TRACKPARSE_API bool trackparse_tracklist_options_set_mode(trackparse_tracklist_options *o, + trackparse_mode mode) { + if (o == NULL) return true; + o->o.mode = mode_option(mode); + return true; +} + +TRACKPARSE_API bool trackparse_tracklist_options_add_known_artist(trackparse_tracklist_options *o, + const char *s, size_t len) { + if (o == NULL) return true; + return add_string(&o->arena, &o->o.known_artists, s, len); +} + +TRACKPARSE_API bool trackparse_tracklist_options_set_split_and(trackparse_tracklist_options *o, + trackparse_split_and v) { + if (o == NULL) return true; + o->o.split_and = split_and_option(v); + return true; +} + +TRACKPARSE_API bool trackparse_tracklist_options_add_version_head(trackparse_tracklist_options *o, + const char *key, size_t key_len, + const char *type, + size_t type_len) { + if (o == NULL) return true; + return add_head(&o->arena, &o->o.keywords, key, key_len, type, type_len); +} + +TRACKPARSE_API bool trackparse_tracklist_options_add_descriptor(trackparse_tracklist_options *o, + const char *s, size_t len) { + if (o == NULL) return true; + return add_string(&o->arena, &o->o.keywords.descriptors, s, len); +} + +TRACKPARSE_API bool trackparse_tracklist_options_add_genre(trackparse_tracklist_options *o, + const char *s, size_t len) { + if (o == NULL) return true; + return add_string(&o->arena, &o->o.keywords.genres, s, len); +} + +TRACKPARSE_API bool trackparse_tracklist_options_add_junk(trackparse_tracklist_options *o, + const char *phrase, size_t phrase_len, + const char *kind, size_t kind_len) { + if (o == NULL) return true; + return add_junk(&o->arena, &o->o.keywords, phrase, phrase_len, kind, kind_len); +} + +TRACKPARSE_API bool trackparse_tracklist_options_add_feat_marker(trackparse_tracklist_options *o, + const char *s, size_t len) { + if (o == NULL) return true; + return add_string(&o->arena, &o->o.keywords.feat_markers, s, len); +} + +TRACKPARSE_API bool trackparse_tracklist_options_set_audio_seconds(trackparse_tracklist_options *o, + double seconds) { + set_arg x; + if (o == NULL) return true; + x = arg_of(TP_EMPTY, TP_EMPTY); + x.num = &o->o.audio_seconds; + x.value = seconds; + return mutate(&o->arena, do_set_num, &x); +} + +TRACKPARSE_API bool trackparse_tracklist_options_add_marker_word(trackparse_tracklist_options *o, + const char *s, size_t len) { + if (o == NULL) return true; + return add_string(&o->arena, &o->o.marker_words, s, len); +} + +/* ============================================================================================ */ +/* Single tracks */ + +typedef struct parse_arg { + tp_str input; + const tp_parse_options *o; /* with: compiled per call (NULL: defaults) */ + const tp_parser *p; /* a parser's engine, or NULL */ + bool with; +} parse_arg; + +static void work_parse(call *c, void *arg) { + const parse_arg *a = (const parse_arg *)arg; + tp_track t; + if (a->p != NULL) { + t = tp_parser_parse(a->p, a->input); + } else if (a->with) { + t = tp_api_parse_with(a->input, a->o); + } else { + t = tp_api_parse(a->input); + } + rb_build(c, sizeof(trackparse_track), fill_track_top, &t); +} + +static void work_parse_artists(call *c, void *arg) { + const parse_arg *a = (const parse_arg *)arg; + tp_artist_vec list; + if (a->p != NULL) { + list = tp_parser_parse_artists(a->p, a->input); + } else if (a->with) { + list = tp_api_parse_artists_with(a->input, a->o); + } else { + list = tp_api_parse_artists(a->input); + } + rb_build(c, sizeof(trackparse_artists), fill_artists_top, &list); +} + +static parse_arg parse_arg_of(const char *s, size_t len) { + parse_arg a; + memset(&a, 0, sizeof a); + a.input = in_str(s, len); + return a; +} + +TRACKPARSE_API trackparse_track *trackparse_parse(const char *s, size_t len) { + parse_arg a = parse_arg_of(s, len); + return (trackparse_track *)guarded_result(work_parse, &a); +} + +TRACKPARSE_API trackparse_track *trackparse_parse_with(const char *s, size_t len, + const trackparse_parse_options *o) { + parse_arg a = parse_arg_of(s, len); + a.with = o != NULL; + a.o = o != NULL ? &o->o : NULL; + return (trackparse_track *)guarded_result(work_parse, &a); +} + +TRACKPARSE_API void trackparse_track_free(trackparse_track *t) { free_result(t); } + +TRACKPARSE_API trackparse_artists *trackparse_parse_artists(const char *s, size_t len) { + parse_arg a = parse_arg_of(s, len); + return (trackparse_artists *)guarded_result(work_parse_artists, &a); +} + +TRACKPARSE_API trackparse_artists * +trackparse_parse_artists_with(const char *s, size_t len, const trackparse_parse_options *o) { + parse_arg a = parse_arg_of(s, len); + a.with = o != NULL; + a.o = o != NULL ? &o->o : NULL; + return (trackparse_artists *)guarded_result(work_parse_artists, &a); +} + +TRACKPARSE_API void trackparse_artists_free(trackparse_artists *a) { free_result(a); } + +TRACKPARSE_API void trackparse_string_free(trackparse_string *s) { free_result(s); } + +static void build_string(call *c, tp_str s) { + rb_build(c, sizeof(trackparse_string), fill_string_top, &s); +} + +typedef struct format_arg { + const trackparse_track *t; + const tp_format_options *o; +} format_arg; + +static void work_format(call *c, void *arg) { + const format_arg *a = (const format_arg *)arg; + tp_track t = int_track_or_empty(a->t); + build_string(c, a->o != NULL ? tp_api_format_with(&t, a->o) : tp_api_format(&t)); +} + +TRACKPARSE_API trackparse_string *trackparse_format(const trackparse_track *t) { + format_arg a; + a.t = t; + a.o = NULL; + return (trackparse_string *)guarded_result(work_format, &a); +} + +TRACKPARSE_API trackparse_string *trackparse_format_with(const trackparse_track *t, + const trackparse_format_options *o) { + format_arg a; + a.t = t; + a.o = o != NULL ? &o->o : NULL; + return (trackparse_string *)guarded_result(work_format, &a); +} + +static void work_normalize(call *c, void *arg) { + build_string(c, tp_api_normalize(*(const tp_str *)arg)); +} + +TRACKPARSE_API trackparse_string *trackparse_normalize(const char *s, size_t len) { + tp_str in = in_str(s, len); + return (trackparse_string *)guarded_result(work_normalize, &in); +} + +static void work_all_artists(call *c, void *arg) { + tp_track t = int_track_or_empty((const trackparse_track *)arg); + tp_artist_vec list = tp_api_all_artists(&t); + rb_build(c, sizeof(trackparse_artists), fill_artists_top, &list); +} + +TRACKPARSE_API trackparse_artists *trackparse_all_artists(const trackparse_track *t) { + return (trackparse_artists *)guarded_result(work_all_artists, (void *)(uintptr_t)t); +} + +/* Parser */ + +struct trackparse_parser { + tp_arena *arena; /* the engine, its tables and copies of the option strings */ + tp_parser p; +}; + +static tp_str copy_str(tp_str s) { return tp_str_copy(s.p, s.n); } + +static tp_strvec copy_list(tp_strvec v) { + tp_strvec out = {0, 0, 0}; + size_t i; + for (i = 0; i < v.n; i++) tp_push(out, copy_str(v.p[i])); + return out; +} + +/* A deep copy of o in the current arena: the tables keep pointers to the keyword strings. */ +static tp_parse_options copy_parse_options(const tp_parse_options *o) { + tp_parse_options r; + size_t i; + memset(&r, 0, sizeof r); + r.mode = copy_str(o->mode); + r.uploader = copy_str(o->uploader); + r.known_artists = copy_list(o->known_artists); + r.split_and = copy_str(o->split_and); + for (i = 0; i < o->keywords.version_heads.n; i++) { + tp_version_head h; + h.key = copy_str(o->keywords.version_heads.p[i].key); + h.type = copy_str(o->keywords.version_heads.p[i].type); + tp_push(r.keywords.version_heads, h); + } + r.keywords.descriptors = copy_list(o->keywords.descriptors); + r.keywords.genres = copy_list(o->keywords.genres); + for (i = 0; i < o->keywords.junk.n; i++) { + tp_junk_phrase j; + j.phrase = copy_str(o->keywords.junk.p[i].phrase); + j.kind = copy_str(o->keywords.junk.p[i].kind); + tp_push(r.keywords.junk, j); + } + r.keywords.feat_markers = copy_list(o->keywords.feat_markers); + return r; +} + +typedef struct parser_arg { + trackparse_parser *p; + const tp_parse_options *o; +} parser_arg; + +static void do_parser_new(void *arg) { + parser_arg *a = (parser_arg *)arg; + if (a->o != NULL) { + tp_parse_options copy = copy_parse_options(a->o); + a->p->p = *tp_new_parser(©); + } else { + a->p->p = *tp_new_parser(NULL); + } +} + +TRACKPARSE_API trackparse_parser *trackparse_parser_new(const trackparse_parse_options *o) { + trackparse_parser *p = (trackparse_parser *)handle_new(sizeof *p); + parser_arg a; + if (p == NULL) return NULL; + a.p = p; + a.o = o != NULL ? &o->o : NULL; + if (!mutate(&p->arena, do_parser_new, &a)) { + trackparse_parser_free(p); + return NULL; + } + return p; +} + +TRACKPARSE_API void trackparse_parser_free(trackparse_parser *p) { + if (p == NULL) return; + tp_arena_free(p->arena); + tp_sys_free(p); +} + +TRACKPARSE_API trackparse_track *trackparse_parser_parse(const trackparse_parser *p, const char *s, + size_t len) { + parse_arg a = parse_arg_of(s, len); + if (p != NULL) a.p = &p->p; + return (trackparse_track *)guarded_result(work_parse, &a); +} + +TRACKPARSE_API trackparse_artists *trackparse_parser_parse_artists(const trackparse_parser *p, + const char *s, size_t len) { + parse_arg a = parse_arg_of(s, len); + if (p != NULL) a.p = &p->p; + return (trackparse_artists *)guarded_result(work_parse_artists, &a); +} + +/* ============================================================================================ */ +/* Tracklists and edits */ + +typedef struct tracklist_arg { + tp_str text; + const tp_tracklist_options *o; +} tracklist_arg; + +static void work_tracklist(call *c, void *arg) { + const tracklist_arg *a = (const tracklist_arg *)arg; + tp_tracklist l = + a->o != NULL ? tp_api_parse_tracklist_with(a->text, a->o) : tp_api_parse_tracklist(a->text); + rb_build(c, sizeof(trackparse_tracklist), fill_tracklist_top, &l); +} + +TRACKPARSE_API trackparse_tracklist *trackparse_parse_tracklist(const char *s, size_t len) { + tracklist_arg a; + a.text = in_str(s, len); + a.o = NULL; + return (trackparse_tracklist *)guarded_result(work_tracklist, &a); +} + +TRACKPARSE_API trackparse_tracklist * +trackparse_parse_tracklist_with(const char *s, size_t len, const trackparse_tracklist_options *o) { + tracklist_arg a; + a.text = in_str(s, len); + a.o = o != NULL ? &o->o : NULL; + return (trackparse_tracklist *)guarded_result(work_tracklist, &a); +} + +TRACKPARSE_API void trackparse_tracklist_free(trackparse_tracklist *t) { free_result(t); } + +struct trackparse_edits { + tp_arena *arena; + tp_edit_vec v; +}; + +TRACKPARSE_API trackparse_edits *trackparse_edits_new(void) { + return (trackparse_edits *)handle_new(sizeof(trackparse_edits)); +} + +TRACKPARSE_API void trackparse_edits_free(trackparse_edits *e) { + if (e == NULL) return; + tp_arena_free(e->arena); + tp_sys_free(e); +} + +/* What one edit constructor needs. */ +typedef struct edit_arg { + tp_edit_vec *v; + int kind; /* index into edit_op_names; 1 with has_from / has_lines for the shift forms */ + int64_t line; + double seconds; + bool has_from; + bool has_lines; + const long long *lines; + size_t count; + tp_str text; +} edit_arg; + +static void do_add_edit(void *arg) { + edit_arg *a = (edit_arg *)arg; + tp_edit_vec v = *a->v; + tp_edit e; + switch (a->kind) { + case TRACKPARSE_EDIT_SET_TIME: + e = tp_edit_set_time(a->line, a->seconds); + break; + case TRACKPARSE_EDIT_SHIFT: + if (a->has_lines) { + int64_t *lines = (int64_t *)tp_alloc_array(a->count, sizeof *lines); + size_t i; + for (i = 0; i < a->count; i++) lines[i] = (int64_t)a->lines[i]; + e = tp_edit_shift_lines(a->seconds, lines, a->count); + } else if (a->has_from) { + e = tp_edit_shift_from(a->seconds, a->line); + } else { + e = tp_edit_shift(a->seconds); + } + break; + case TRACKPARSE_EDIT_SORT_BY_TIME: + e = tp_edit_sort_by_time(); + break; + case TRACKPARSE_EDIT_SET_REST: + e = tp_edit_set_rest(a->line, copy_str(a->text)); + break; + case TRACKPARSE_EDIT_INSERT: + e = tp_edit_insert(a->line, copy_str(a->text)); + break; + default: + e = tp_edit_delete(a->line); + break; + } + tp_push(v, e); + *a->v = v; +} + +static edit_arg edit_arg_of(trackparse_edits *e, int kind) { + edit_arg a; + memset(&a, 0, sizeof a); + a.v = &e->v; + a.kind = kind; + a.text = TP_EMPTY; + return a; +} + +TRACKPARSE_API bool trackparse_edits_set_time(trackparse_edits *e, long long line, double seconds) { + edit_arg a; + if (e == NULL) return true; + a = edit_arg_of(e, TRACKPARSE_EDIT_SET_TIME); + a.line = (int64_t)line; + a.seconds = seconds; + return mutate(&e->arena, do_add_edit, &a); +} + +TRACKPARSE_API bool trackparse_edits_shift(trackparse_edits *e, double seconds) { + edit_arg a; + if (e == NULL) return true; + a = edit_arg_of(e, TRACKPARSE_EDIT_SHIFT); + a.seconds = seconds; + return mutate(&e->arena, do_add_edit, &a); +} + +TRACKPARSE_API bool trackparse_edits_shift_from(trackparse_edits *e, double seconds, + long long from) { + edit_arg a; + if (e == NULL) return true; + a = edit_arg_of(e, TRACKPARSE_EDIT_SHIFT); + a.seconds = seconds; + a.has_from = true; + a.line = (int64_t)from; + return mutate(&e->arena, do_add_edit, &a); +} + +TRACKPARSE_API bool trackparse_edits_shift_lines(trackparse_edits *e, double seconds, + const long long *lines, size_t count) { + edit_arg a; + if (e == NULL) return true; + a = edit_arg_of(e, TRACKPARSE_EDIT_SHIFT); + a.seconds = seconds; + a.has_lines = true; + a.lines = lines; + a.count = lines != NULL ? count : 0; + return mutate(&e->arena, do_add_edit, &a); +} + +TRACKPARSE_API bool trackparse_edits_sort_by_time(trackparse_edits *e) { + edit_arg a; + if (e == NULL) return true; + a = edit_arg_of(e, TRACKPARSE_EDIT_SORT_BY_TIME); + return mutate(&e->arena, do_add_edit, &a); +} + +TRACKPARSE_API bool trackparse_edits_set_rest(trackparse_edits *e, long long line, const char *rest, + size_t len) { + edit_arg a; + if (e == NULL) return true; + a = edit_arg_of(e, TRACKPARSE_EDIT_SET_REST); + a.line = (int64_t)line; + a.text = in_str(rest, len); + return mutate(&e->arena, do_add_edit, &a); +} + +TRACKPARSE_API bool trackparse_edits_insert(trackparse_edits *e, long long after, const char *text, + size_t len) { + edit_arg a; + if (e == NULL) return true; + a = edit_arg_of(e, TRACKPARSE_EDIT_INSERT); + a.line = (int64_t)after; + a.text = in_str(text, len); + return mutate(&e->arena, do_add_edit, &a); +} + +TRACKPARSE_API bool trackparse_edits_delete(trackparse_edits *e, long long line) { + edit_arg a; + if (e == NULL) return true; + a = edit_arg_of(e, TRACKPARSE_EDIT_DELETE); + a.line = (int64_t)line; + return mutate(&e->arena, do_add_edit, &a); +} + +typedef struct apply_arg { + tp_str text; + const trackparse_edits *e; +} apply_arg; + +static void work_apply(call *c, void *arg) { + const apply_arg *a = (const apply_arg *)arg; + const tp_edit *edits = a->e != NULL ? a->e->v.p : NULL; + size_t n = a->e != NULL ? a->e->v.n : 0; + tp_edit_result r = tp_api_apply_edits_with(a->text, edits, n, NULL); + rb_build(c, sizeof(trackparse_edit_result), fill_edit_result_top, &r); +} + +TRACKPARSE_API trackparse_edit_result *trackparse_apply_edits(const char *s, size_t len, + const trackparse_edits *e) { + apply_arg a; + a.text = in_str(s, len); + a.e = e; + return (trackparse_edit_result *)guarded_result(work_apply, &a); +} + +TRACKPARSE_API void trackparse_edit_result_free(trackparse_edit_result *r) { free_result(r); } + +/* ============================================================================================ */ +/* JSON */ + +static void work_track_json(call *c, void *arg) { + const trackparse_track *t = (const trackparse_track *)arg; + tp_track x; + if (t == NULL) { + build_string(c, TP_S("null")); + return; + } + x = int_track(t); + build_string(c, tp_track_json(&x)); +} + +static void work_artists_json(call *c, void *arg) { + const trackparse_artists *a = (const trackparse_artists *)arg; + if (a == NULL) { + build_string(c, TP_S("null")); + return; + } + build_string(c, tp_artists_json(int_artist_list(a->items, a->count))); +} + +static void work_tracklist_json(call *c, void *arg) { + const trackparse_tracklist *l = (const trackparse_tracklist *)arg; + tp_tracklist x; + if (l == NULL) { + build_string(c, TP_S("null")); + return; + } + x = int_tracklist(l); + build_string(c, tp_tracklist_json(&x)); +} + +static void work_edit_result_json(call *c, void *arg) { + const trackparse_edit_result *r = (const trackparse_edit_result *)arg; + tp_edit_result x; + if (r == NULL) { + build_string(c, TP_S("null")); + return; + } + x = int_edit_result(r); + build_string(c, tp_edit_result_json(&x)); +} + +/* The arguments are read only; the casts drop const for the generic work signature. */ +#define ARG(p) ((void *)(uintptr_t)(p)) + +TRACKPARSE_API trackparse_string *trackparse_track_to_json(const trackparse_track *t) { + return (trackparse_string *)guarded_result(work_track_json, ARG(t)); +} + +TRACKPARSE_API trackparse_string *trackparse_artists_to_json(const trackparse_artists *a) { + return (trackparse_string *)guarded_result(work_artists_json, ARG(a)); +} + +TRACKPARSE_API trackparse_string *trackparse_tracklist_to_json(const trackparse_tracklist *t) { + return (trackparse_string *)guarded_result(work_tracklist_json, ARG(t)); +} + +TRACKPARSE_API trackparse_string *trackparse_edit_result_to_json(const trackparse_edit_result *r) { + return (trackparse_string *)guarded_result(work_edit_result_json, ARG(r)); +} + +/* The _COUNT macros in trackparse.h must follow the enums. */ +_Static_assert(TRACKPARSE_MODE_TRACKLIST + 1 == TRACKPARSE_MODE_COUNT, "mode count"); +_Static_assert(TRACKPARSE_ROLE_PRODUCER + 1 == TRACKPARSE_ROLE_COUNT, "role count"); +_Static_assert(TRACKPARSE_SOURCE_VERSION + 1 == TRACKPARSE_SOURCE_COUNT, "source count"); +_Static_assert(TRACKPARSE_VERSION_NIGHTCORE + 1 == TRACKPARSE_VERSION_TYPE_COUNT, "version count"); +_Static_assert(TRACKPARSE_DELIMITER_DASH + 1 == TRACKPARSE_DELIMITER_COUNT, "delimiter count"); +_Static_assert(TRACKPARSE_JUNK_OTHER + 1 == TRACKPARSE_JUNK_KIND_COUNT, "junk count"); +_Static_assert(TRACKPARSE_WARNING_UNBALANCED_BRACKETS + 1 == TRACKPARSE_WARNING_COUNT, "warnings"); +_Static_assert(TRACKPARSE_ENTRY_BLANK + 1 == TRACKPARSE_ENTRY_KIND_COUNT, "entry count"); +_Static_assert(TRACKPARSE_EOL_NONE + 1 == TRACKPARSE_EOL_COUNT, "eol count"); +_Static_assert(TRACKPARSE_TL_LINE_UNPARSED + 1 == TRACKPARSE_TRACKLIST_WARNING_CODE_COUNT, "codes"); +_Static_assert(TRACKPARSE_SEVERITY_WARNING + 1 == TRACKPARSE_SEVERITY_COUNT, "severity count"); +_Static_assert(TRACKPARSE_EDIT_DELETE + 1 == TRACKPARSE_EDIT_OP_COUNT, "edit op count"); +_Static_assert(TRACKPARSE_EDIT_WARNING_STYLE_UPGRADED + 1 == TRACKPARSE_EDIT_WARNING_CODE_COUNT, + "edit warning count"); diff --git a/c/src/types.c b/c/src/types.c new file mode 100644 index 0000000..04c04d0 --- /dev/null +++ b/c/src/types.c @@ -0,0 +1,142 @@ +/* types.c: the result types (go/types.go). The structs themselves are in internal.h; this file + * has the All* lists of the typed strings, the C name lookup, and the typing of raw edit + * results. */ +#include "internal.h" + +/* A new arena vector holding the n names of a static table (Go: a fresh slice per call). */ +static tp_strvec names_of(const tp_str *names, size_t n) { + tp_strvec v = {0, 0, 0}; + size_t i; + for (i = 0; i < n; i++) tp_push(v, names[i]); + return v; +} + +#define TP_NAMES(table) names_of((table), TP_COUNT(table)) + +static const tp_str modes[] = {{"clean", 5}, {"youtube", 7}, {"filename", 8}, {"tracklist", 9}}; + +/* AllModes: the modes a track can have, in the spec's order. */ +TP_PRIVATE tp_strvec tp_all_modes(void) { return TP_NAMES(modes); } + +static const tp_str roles[] = {{"primary", 7}, {"featured", 8}, {"remixer", 7}, {"producer", 8}}; + +/* AllRoles: every Role, in the spec's order. */ +TP_PRIVATE tp_strvec tp_all_roles(void) { return TP_NAMES(roles); } + +static const tp_str sources[] = {{"artist", 6}, {"title", 5}, {"version", 7}}; + +/* AllSources: every Source, in the spec's order. */ +TP_PRIVATE tp_strvec tp_all_sources(void) { return TP_NAMES(sources); } + +static const tp_str version_types[] = { + {"remix", 5}, {"bootleg", 7}, {"vip", 3}, {"edit", 4}, {"flip", 4}, + {"refix", 5}, {"rework", 6}, {"mashup", 6}, {"blend", 5}, {"dub", 3}, + {"mix", 3}, {"extended", 8}, {"radio", 5}, {"club", 4}, {"original", 8}, + {"instrumental", 12}, {"acapella", 8}, {"live", 4}, {"acoustic", 8}, {"remaster", 8}, + {"demo", 4}, {"reprise", 7}, {"cover", 5}, {"version", 7}, {"spedUp", 6}, + {"slowed", 6}, {"nightcore", 9}}; + +/* AllVersionTypes: the 27 version types of the spec, in the spec's order. */ +TP_PRIVATE tp_strvec tp_all_version_types(void) { return TP_NAMES(version_types); } + +static const tp_str delimiters[] = {{"(", 1}, {"[", 1}, {"{", 1}, {"-", 1}}; + +/* AllDelimiters: every Delimiter, in the spec's order. */ +TP_PRIVATE tp_strvec tp_all_delimiters(void) { return TP_NAMES(delimiters); } + +static const tp_str junk_kinds[] = {{"video", 5}, {"audio", 5}, {"lyrics", 6}, + {"quality", 7}, {"promo", 5}, {"platform", 8}, + {"label", 5}, {"genre", 5}, {"other", 5}}; + +/* AllJunkKinds: the junk kinds of the spec, in the spec's order. */ +TP_PRIVATE tp_strvec tp_all_junk_kinds(void) { return TP_NAMES(junk_kinds); } + +static const tp_str warnings[] = {{"noSeparator", 11}, + {"ambiguousSeparator", 18}, + {"unspacedDashSplit", 17}, + {"asymmetricDashSplit", 19}, + {"bySplit", 7}, + {"quotedTitleSplit", 16}, + {"ambiguousMixCredit", 18}, + {"unbalancedBrackets", 18}}; + +/* AllWarnings: every Warning, in the spec's order. */ +TP_PRIVATE tp_strvec tp_all_warnings(void) { return TP_NAMES(warnings); } + +static const tp_str entry_kinds[] = {{"track", 5}, {"marker", 6}, {"header", 6}, + {"link", 4}, {"note", 4}, {"blank", 5}}; + +/* AllEntryKinds: every EntryKind, in the spec's order. */ +TP_PRIVATE tp_strvec tp_all_entry_kinds(void) { return TP_NAMES(entry_kinds); } + +static const tp_str eols[] = {{"\n", 1}, {"\r\n", 2}, {"\r", 1}, {"", 0}}; + +/* AllEols: every Eol, in the spec's order. */ +TP_PRIVATE tp_strvec tp_all_eols(void) { return TP_NAMES(eols); } + +static const tp_str warning_codes[] = { + {"time-missing", 12}, {"time-out-of-order", 17}, {"time-duplicate", 14}, + {"no-start-at-zero", 16}, {"time-after-audio-end", 20}, {"invalid-time", 12}, + {"position-gap", 12}, {"position-duplicate", 18}, {"line-unparsed", 13}}; + +/* AllWarningCodes: every WarningCode, in the spec's order. */ +TP_PRIVATE tp_strvec tp_all_warning_codes(void) { return TP_NAMES(warning_codes); } + +static const tp_str severities[] = {{"info", 4}, {"warning", 7}}; + +/* AllSeverities: every Severity, in the spec's order. */ +TP_PRIVATE tp_strvec tp_all_severities(void) { return TP_NAMES(severities); } + +static const tp_str edit_ops[] = {{"set-time", 8}, {"shift", 5}, {"sort-by-time", 12}, + {"set-rest", 8}, {"insert", 6}, {"delete", 6}}; + +/* AllEditOps: every EditOp, in the spec's order. */ +TP_PRIVATE tp_strvec tp_all_edit_ops(void) { return TP_NAMES(edit_ops); } + +static const tp_str edit_warning_codes[] = { + {"edit-invalid", 12}, {"time-clamped", 12}, {"style-upgraded", 14}}; + +/* AllEditWarningCodes: every EditWarningCode, in the spec's order. */ +TP_PRIVATE tp_strvec tp_all_edit_warning_codes(void) { return TP_NAMES(edit_warning_codes); } + +/* C addition: the index of name in names, or -1. */ +TP_PRIVATE ptrdiff_t tp_name_index(tp_strvec names, tp_str name) { + size_t i; + for (i = 0; i < names.n; i++) { + if (tp_str_eq(names.p[i], name)) return (ptrdiff_t)i; + } + return -1; +} + +/* result is the typed form. Typed edits carry integer lines, so every line is a whole number in + * range; the conversion saturates anyway. A nil changed is written as [] either way. */ +TP_PRIVATE tp_edit_result tp_raw_edit_result_result(const tp_raw_edit_result *r) { + tp_edit_result out; + size_t i; + memset(&out, 0, sizeof out); + out.text = r->text; + out.changed = r->changed; + for (i = 0; i < r->warnings.n; i++) { + const tp_raw_edit_warning *w = &r->warnings.p[i]; + tp_edit_warning ew; + ew.code = w->code; + ew.edit = w->edit; + ew.line = NULL; + if (w->line != NULL) { + int64_t *n = (int64_t *)tp_alloc(sizeof *n); + *n = tp_saturating_int(*w->line); + ew.line = n; + } + tp_push(out.warnings, ew); + } + return out; +} + +/* saturatingInt converts a float to int64 (Go int on 64-bit), clamping to the range (NaN gives + * 0). 9223372036854775808.0 is float64(maxInt): 2^63. */ +TP_PRIVATE int64_t tp_saturating_int(double f) { + if (tp_is_nan(f)) return 0; + if (f >= 9223372036854775808.0) return INT64_MAX; + if (f <= -9223372036854775808.0) return INT64_MIN; + return (int64_t)f; +} diff --git a/c/src/unicode.c b/c/src/unicode.c new file mode 100644 index 0000000..3dcd9ef --- /dev/null +++ b/c/src/unicode.c @@ -0,0 +1,409 @@ +/* unicode.c: Unicode lookups over the generated tables in unicode_gen.c (go/unicode.go). + * + * General categories (R0.6), JS toLowerCase() (R0.4) and NFC/NFD (R1, R0.4). The tables come + * from Node, the reference engine, so the results do not depend on the platform. Every function + * is total: invalid UTF-8 is read as U+FFFD per bad byte, as Go's `for range` does. + */ +#include "unicode.h" + +#include "unicode_gen.h" + +#define TP_RUNE_ERROR ((tp_rune)0xfffd) + +/* Go's utf8.DecodeRuneInString / DecodeLastRuneInString on p[0..n) (rt.c has Go's rules: an + * ill-formed byte is U+FFFD of length 1). n > 0. */ +static tp_rune dec(const char *p, size_t n, size_t *size) { + tp_str s = {p, n}; + return tp_decode_rune(s, size); +} + +static tp_rune dec_last(const char *p, size_t n, size_t *size) { + tp_str s = {p, n}; + return tp_decode_last_rune(s, size); +} + +/* ------------------------------------------------------------------------------------------ */ +/* Categories */ + +TP_PRIVATE bool tp_uni_in_ranges(const tp_uni_range *table, size_t n, tp_rune r) { + size_t lo = 0, hi = n; + while (lo < hi) { + size_t m = lo + (hi - lo) / 2; + if (r < table[m].lo) { + hi = m; + } else if (r > table[m].hi) { + lo = m + 1; + } else { + return true; + } + } + return false; +} + +#define TP_IN(table, r) tp_uni_in_ranges(table, TP_COUNT(table), r) + +TP_PRIVATE bool tp_is_letter(tp_rune r) { + if (r < 0x80) return (r | 0x20) >= 'a' && (r | 0x20) <= 'z'; + return TP_IN(tp_uni_letter, r); +} + +TP_PRIVATE bool tp_is_upper_letter(tp_rune r) { + if (r < 0x80) return r >= 'A' && r <= 'Z'; + return TP_IN(tp_uni_upper, r); +} + +/* ------------------------------------------------------------------------------------------ */ +/* R0.4: JS String.prototype.toLowerCase(). */ + +/* Appends the lowercase of one code point out of context. */ +static void append_lower(tp_buf *out, tp_rune r) { + if (r < 0x80) { + if (r >= 'A' && r <= 'Z') r += 'a' - 'A'; + tp_buf_byte(out, (char)r); + return; + } + /* The last run that starts at or before r. */ + size_t lo = 0, hi = TP_COUNT(tp_uni_lower); + while (lo < hi) { + size_t m = lo + (hi - lo) / 2; + if (tp_uni_lower[m].first <= r) { + lo = m + 1; + } else { + hi = m; + } + } + if (lo > 0) { + const tp_lower_run *e = &tp_uni_lower[lo - 1]; + if (r <= e->last && (r - e->first) % (tp_rune)e->step == 0) { + tp_buf_rune(out, r + e->delta); + return; + } + } + lo = 0; + hi = TP_COUNT(tp_uni_lower_multi); + while (lo < hi) { + size_t m = lo + (hi - lo) / 2; + if (tp_uni_lower_multi[m].cp < r) { + lo = m + 1; + } else { + hi = m; + } + } + if (lo < TP_COUNT(tp_uni_lower_multi) && tp_uni_lower_multi[lo].cp == r) { + tp_buf_str(out, tp_uni_lower_multi[lo].to); + return; + } + tp_buf_rune(out, r); +} + +/* The final-sigma rule's "a cased letter precedes", looking back through case-ignorable code + * points. A code point that is both cased and case-ignorable (U+0345, modifier letters) is + * skipped, as in ICU, which is what JS engines run. */ +static bool cased_before(const char *p, size_t n) { + while (n > 0) { + size_t size; + tp_rune r = dec_last(p, n, &size); + if (!TP_IN(tp_uni_case_ignorable, r)) return TP_IN(tp_uni_cased, r); + n -= size; + } + return false; +} + +/* cased_before looking forward. */ +static bool cased_after(const char *p, size_t n) { + for (size_t i = 0; i < n;) { + size_t size; + tp_rune r = dec(p + i, n - i, &size); + if (!TP_IN(tp_uni_case_ignorable, r)) return TP_IN(tp_uni_cased, r); + i += size; + } + return false; +} + +TP_PRIVATE tp_str tp_js_to_lower(tp_str s) { + bool ascii = true, upper = false; + for (size_t i = 0; i < s.n; i++) { + unsigned char c = (unsigned char)s.p[i]; + if (c >= 0x80) { + ascii = false; + break; + } + if (c >= 'A' && c <= 'Z') upper = true; + } + if (ascii && !upper) return s; + tp_buf out = {0}; + if (ascii) { + for (size_t i = 0; i < s.n; i++) { + char c = s.p[i]; + if (c >= 'A' && c <= 'Z') c = (char)(c + ('a' - 'A')); + tp_buf_byte(&out, c); + } + return tp_buf_done(&out); + } + for (size_t i = 0; i < s.n;) { + size_t size; + tp_rune r = dec(s.p + i, s.n - i, &size); + if (r != 0x3a3) { + append_lower(&out, r); + } else if (cased_before(s.p, i) && !cased_after(s.p + i + 2, s.n - i - 2)) { + /* U+03A3 is U+03C2 after a cased letter when no cased letter follows (Final_Sigma). */ + tp_buf_rune(&out, 0x3c2); + } else { + tp_buf_rune(&out, 0x3c3); + } + i += size; + } + return tp_buf_done(&out); +} + +/* ------------------------------------------------------------------------------------------ */ +/* R1, R0.4: canonical normalization (Unicode Standard Annex #15), identical to JS */ +/* String.prototype.normalize("NFC") and normalize("NFD"). */ + +/* Hangul syllables, decomposed and composed algorithmically (Unicode 3.12). */ +#define HANGUL_S_BASE 0xac00 +#define HANGUL_L_BASE 0x1100 +#define HANGUL_V_BASE 0x1161 +#define HANGUL_T_BASE 0x11a7 +#define HANGUL_L_COUNT 19 +#define HANGUL_V_COUNT 21 +#define HANGUL_T_COUNT 28 +#define HANGUL_N_COUNT (HANGUL_V_COUNT * HANGUL_T_COUNT) +#define HANGUL_S_COUNT (HANGUL_L_COUNT * HANGUL_N_COUNT) + +TP_PRIVATE uint8_t tp_combining_class(tp_rune r) { + if (r < TP_UNI_QUICK_MIN) return 0; + size_t lo = 0, hi = TP_COUNT(tp_uni_ccc); + while (lo < hi) { + size_t m = lo + (hi - lo) / 2; + if (r < tp_uni_ccc[m].lo) { + hi = m; + } else if (r > tp_uni_ccc[m].hi) { + lo = m + 1; + } else { + return tp_uni_ccc[m].rank; + } + } + return 0; +} + +/* The full canonical decomposition of r from the table, or NULL when r has none (Hangul + * syllables are handled by the caller). */ +static const tp_decomp_entry *uni_decomposition(tp_rune r) { + if (r < TP_UNI_QUICK_MIN) return NULL; + size_t lo = 0, hi = TP_COUNT(tp_uni_decomp); + while (lo < hi) { + size_t m = lo + (hi - lo) / 2; + if (tp_uni_decomp[m].cp < r) { + lo = m + 1; + } else { + hi = m; + } + } + if (lo < TP_COUNT(tp_uni_decomp) && tp_uni_decomp[lo].cp == r) return &tp_uni_decomp[lo]; + return NULL; +} + +static bool is_hangul_syllable(tp_rune r) { + return r >= HANGUL_S_BASE && r < HANGUL_S_BASE + HANGUL_S_COUNT; +} + +/* The primary composite of a + b, if there is one. */ +static bool compose_two(tp_rune a, tp_rune b, tp_rune *out) { + /* Hangul: L + V -> LV, LV + T -> LVT. */ + if (a >= HANGUL_L_BASE && a < HANGUL_L_BASE + HANGUL_L_COUNT && b >= HANGUL_V_BASE && + b < HANGUL_V_BASE + HANGUL_V_COUNT) { + *out = HANGUL_S_BASE + + ((a - HANGUL_L_BASE) * HANGUL_V_COUNT + (b - HANGUL_V_BASE)) * HANGUL_T_COUNT; + return true; + } + if (is_hangul_syllable(a) && (a - HANGUL_S_BASE) % HANGUL_T_COUNT == 0 && b > HANGUL_T_BASE && + b < HANGUL_T_BASE + HANGUL_T_COUNT) { + *out = a + (b - HANGUL_T_BASE); + return true; + } + size_t lo = 0, hi = TP_COUNT(tp_uni_compose); + while (lo < hi) { + size_t m = lo + (hi - lo) / 2; + const tp_compose_pair *e = &tp_uni_compose[m]; + if (e->first < a || (e->first == a && e->second < b)) { + lo = m + 1; + } else { + hi = m; + } + } + if (lo < TP_COUNT(tp_uni_compose) && tp_uni_compose[lo].first == a && + tp_uni_compose[lo].second == b) { + *out = tp_uni_compose[lo].composite; + return true; + } + return false; +} + +static bool uni_is_ascii(tp_str s) { + for (size_t i = 0; i < s.n; i++) { + if ((unsigned char)s.p[i] >= 0x80) return false; + } + return true; +} + +/* Whether s is already NFD: valid UTF-8, nothing that decomposes and the non-starters in + * canonical order. */ +static bool nfd_quick(tp_str s) { + uint8_t last = 0; + for (size_t i = 0; i < s.n;) { + tp_rune r = (unsigned char)s.p[i]; + size_t size = 1; + if (r >= 0x80) { + r = dec(s.p + i, s.n - i, &size); + if (r == TP_RUNE_ERROR && size == 1) return false; + } + i += size; + if (r < TP_UNI_QUICK_MIN) { + last = 0; + continue; + } + if (is_hangul_syllable(r) || uni_decomposition(r) != NULL) return false; + uint8_t cc = tp_combining_class(r); + if (cc != 0 && last > cc) return false; + last = cc; + } + return true; +} + +/* The NFC quick check of UAX #15 section 9, with Maybe treated as No: true only when s is + * certainly NFC. */ +static bool nfc_quick(tp_str s) { + uint8_t last = 0; + for (size_t i = 0; i < s.n;) { + tp_rune r = (unsigned char)s.p[i]; + size_t size = 1; + if (r >= 0x80) { + r = dec(s.p + i, s.n - i, &size); + if (r == TP_RUNE_ERROR && size == 1) return false; + } + i += size; + if (r < TP_UNI_QUICK_MIN) { + last = 0; + continue; + } + if (TP_IN(tp_uni_nfc_no, r) || TP_IN(tp_uni_compose_second, r)) return false; + uint8_t cc = tp_combining_class(r); + if (cc != 0 && last > cc) return false; + last = cc; + } + return true; +} + +static int cmp_ccc(const void *a, const void *b, void *ctx) { + (void)ctx; + int ca = tp_combining_class(*(const tp_rune *)a); + int cb = tp_combining_class(*(const tp_rune *)b); + return ca - cb; +} + +/* The canonical ordering algorithm: each run of non-starters is sorted by combining class, + * stably. */ +static void canonical_order(tp_rune *buf, size_t n) { + for (size_t i = 0; i < n;) { + if (tp_combining_class(buf[i]) == 0) { + i++; + continue; + } + size_t j = i + 1; + while (j < n && tp_combining_class(buf[j]) != 0) j++; + tp_rune *run = buf + i; + size_t len = j - i; + if (len <= 8) { + /* Insertion sort: stable, and runs are almost always short. */ + for (size_t k = 1; k < len; k++) { + tp_rune x = run[k]; + uint8_t cx = tp_combining_class(x); + size_t m = k; + while (m > 0 && tp_combining_class(run[m - 1]) > cx) { + run[m] = run[m - 1]; + m--; + } + run[m] = x; + } + } else { + tp_sort_stable(run, len, sizeof(tp_rune), cmp_ccc, NULL); + } + i = j; + } +} + +/* The canonical decomposition of s in canonical order (NFD as runes). */ +static tp_runevec nfd_runes(tp_str s) { + tp_runevec buf = {0}; + for (size_t i = 0; i < s.n;) { + size_t size; + tp_rune r = dec(s.p + i, s.n - i, &size); + i += size; + if (r < TP_UNI_QUICK_MIN) { + tp_push(buf, r); + } else if (is_hangul_syllable(r)) { + tp_rune si = r - HANGUL_S_BASE; + tp_push(buf, HANGUL_L_BASE + si / HANGUL_N_COUNT); + tp_push(buf, HANGUL_V_BASE + (si % HANGUL_N_COUNT) / HANGUL_T_COUNT); + tp_rune t = si % HANGUL_T_COUNT; + if (t != 0) tp_push(buf, HANGUL_T_BASE + t); + } else { + const tp_decomp_entry *d = uni_decomposition(r); + if (d != NULL) { + for (size_t k = 0; k < d->len; k++) tp_push(buf, tp_uni_decomp_pool[d->off + k]); + } else { + tp_push(buf, r); + } + } + } + canonical_order(buf.p, buf.n); + return buf; +} + +/* The canonical composition algorithm on decomposed, canonically ordered runes, in place; returns + * the length of the composed prefix. */ +static size_t canonical_compose(tp_rune *buf, size_t n) { + ptrdiff_t starter = -1; /* index in the output of the last starter, -1 before the first */ + uint8_t last = 0; + size_t w = 0; + for (size_t i = 0; i < n; i++) { + tp_rune c = buf[i]; + if (c < TP_UNI_QUICK_MIN) { + /* A starter that composes with nothing before it. */ + starter = (ptrdiff_t)w; + last = 0; + buf[w++] = c; + continue; + } + uint8_t cc = tp_combining_class(c); + if (starter >= 0) { + /* c is blocked from the starter when something sits between them whose class is 0 or not + * lower than c's. */ + if ((ptrdiff_t)w - 1 == starter || (last != 0 && last < cc)) { + tp_rune p; + if (compose_two(buf[starter], c, &p)) { + buf[starter] = p; + continue; + } + } + } + if (cc == 0) starter = (ptrdiff_t)w; + last = cc; + buf[w++] = c; + } + return w; +} + +TP_PRIVATE tp_str tp_nfd(tp_str s) { + if (uni_is_ascii(s) || nfd_quick(s)) return s; + tp_runevec buf = nfd_runes(s); + return tp_runes_str((tp_runes){buf.p, buf.n}); +} + +TP_PRIVATE tp_str tp_nfc(tp_str s) { + if (uni_is_ascii(s) || nfc_quick(s)) return s; + tp_runevec buf = nfd_runes(s); + size_t n = canonical_compose(buf.p, buf.n); + return tp_runes_str((tp_runes){buf.p, n}); +} diff --git a/c/src/unicode.h b/c/src/unicode.h new file mode 100644 index 0000000..b97c758 --- /dev/null +++ b/c/src/unicode.h @@ -0,0 +1,71 @@ +/* unicode.h: Unicode lookups over the generated tables in unicode_gen.c (go/unicode.go). + * + * General categories (R0.6), JS toLowerCase() (R0.4) and NFC/NFD (R1, R0.4). The tables come + * from Node, the reference engine, so the results depend neither on the platform nor on the C + * library. Never use , or towlower here. + * + * Every function is total: invalid UTF-8 is read as one U+FFFD per bad byte, as Go's `for range` + * does (rt.c's tp_decode_rune), and nothing fails. Results are arena strings, or the input itself + * when nothing changes. + */ +#ifndef TP_UNICODE_H +#define TP_UNICODE_H + +#include "rt.h" + +/* An inclusive range of code points. */ +typedef struct tp_uni_range { + tp_rune lo, hi; +} tp_uni_range; + +/* Maps first, first+step, ..., up to last, each to itself plus delta. */ +typedef struct tp_lower_run { + tp_rune first, last; + uint8_t step; + int32_t delta; +} tp_lower_run; + +/* A code point whose lowercase is several code points (UTF-8). */ +typedef struct tp_lower_multi { + tp_rune cp; + tp_str to; +} tp_lower_multi; + +/* The combining class rank of an inclusive range of code points. */ +typedef struct tp_ccc_range { + tp_rune lo, hi; + uint8_t rank; +} tp_ccc_range; + +/* The full canonical decomposition of one code point: tp_uni_decomp_pool[off .. off+len). */ +typedef struct tp_decomp_entry { + tp_rune cp; + uint16_t off; + uint8_t len; +} tp_decomp_entry; + +/* A canonical composition: first + second -> composite. */ +typedef struct tp_compose_pair { + tp_rune first, second, composite; +} tp_compose_pair; + +/* Whether r is in one of the sorted, disjoint ranges. */ +TP_PRIVATE bool tp_uni_in_ranges(const tp_uni_range *table, size_t n, tp_rune r); + +/* R0.6 letter test: general category L, as JS /\p{L}/u. */ +TP_PRIVATE bool tp_is_letter(tp_rune r); +/* R6.10 uppercase test: general category Lu, as JS /\p{Lu}/u. */ +TP_PRIVATE bool tp_is_upper_letter(tp_rune r); + +/* JS toLowerCase() (R0.4), with the Final_Sigma rule. */ +TP_PRIVATE tp_str tp_js_to_lower(tp_str s); + +/* JS s.normalize("NFD") / normalize("NFC"). They return s itself, without allocating, when s is + * already in that form. */ +TP_PRIVATE tp_str tp_nfd(tp_str s); +TP_PRIVATE tp_str tp_nfc(tp_str s); + +/* The canonical combining class rank of r (0 for starters). */ +TP_PRIVATE uint8_t tp_combining_class(tp_rune r); + +#endif /* TP_UNICODE_H */ diff --git a/c/src/unicode_gen.c b/c/src/unicode_gen.c new file mode 100644 index 0000000..c52fab5 --- /dev/null +++ b/c/src/unicode_gen.c @@ -0,0 +1,1682 @@ +/* Code generated by c/scripts/gen_unicode.mjs; DO NOT EDIT. + * Run `node c/scripts/gen_unicode.mjs` to regenerate. + * + * Tables taken from the JS reference engine (Node), so the Unicode version is Node's and not + * the platform's: categories L and Lu (R0.6), toLowerCase() (R0.4) and NFC/NFD (R1, R0.4). + * The method behind the combining class ranks is described in c/scripts/unicode_derive.mjs + * and go/scripts/gen_unicode.mjs. */ +/* Unicode 17.0 */ +#include "unicode_gen.h" + +TP_PRIVATE const tp_uni_range tp_uni_letter[TP_UNI_LETTER_N] = { + {0x41, 0x5a}, {0x61, 0x7a}, {0xaa, 0xaa}, {0xb5, 0xb5}, {0xba, 0xba}, {0xc0, 0xd6}, + {0xd8, 0xf6}, {0xf8, 0x2c1}, {0x2c6, 0x2d1}, {0x2e0, 0x2e4}, {0x2ec, 0x2ec}, {0x2ee, 0x2ee}, + {0x370, 0x374}, {0x376, 0x377}, {0x37a, 0x37d}, {0x37f, 0x37f}, {0x386, 0x386}, {0x388, 0x38a}, + {0x38c, 0x38c}, {0x38e, 0x3a1}, {0x3a3, 0x3f5}, {0x3f7, 0x481}, {0x48a, 0x52f}, {0x531, 0x556}, + {0x559, 0x559}, {0x560, 0x588}, {0x5d0, 0x5ea}, {0x5ef, 0x5f2}, {0x620, 0x64a}, {0x66e, 0x66f}, + {0x671, 0x6d3}, {0x6d5, 0x6d5}, {0x6e5, 0x6e6}, {0x6ee, 0x6ef}, {0x6fa, 0x6fc}, {0x6ff, 0x6ff}, + {0x710, 0x710}, {0x712, 0x72f}, {0x74d, 0x7a5}, {0x7b1, 0x7b1}, {0x7ca, 0x7ea}, {0x7f4, 0x7f5}, + {0x7fa, 0x7fa}, {0x800, 0x815}, {0x81a, 0x81a}, {0x824, 0x824}, {0x828, 0x828}, {0x840, 0x858}, + {0x860, 0x86a}, {0x870, 0x887}, {0x889, 0x88f}, {0x8a0, 0x8c9}, {0x904, 0x939}, {0x93d, 0x93d}, + {0x950, 0x950}, {0x958, 0x961}, {0x971, 0x980}, {0x985, 0x98c}, {0x98f, 0x990}, {0x993, 0x9a8}, + {0x9aa, 0x9b0}, {0x9b2, 0x9b2}, {0x9b6, 0x9b9}, {0x9bd, 0x9bd}, {0x9ce, 0x9ce}, {0x9dc, 0x9dd}, + {0x9df, 0x9e1}, {0x9f0, 0x9f1}, {0x9fc, 0x9fc}, {0xa05, 0xa0a}, {0xa0f, 0xa10}, {0xa13, 0xa28}, + {0xa2a, 0xa30}, {0xa32, 0xa33}, {0xa35, 0xa36}, {0xa38, 0xa39}, {0xa59, 0xa5c}, {0xa5e, 0xa5e}, + {0xa72, 0xa74}, {0xa85, 0xa8d}, {0xa8f, 0xa91}, {0xa93, 0xaa8}, {0xaaa, 0xab0}, {0xab2, 0xab3}, + {0xab5, 0xab9}, {0xabd, 0xabd}, {0xad0, 0xad0}, {0xae0, 0xae1}, {0xaf9, 0xaf9}, {0xb05, 0xb0c}, + {0xb0f, 0xb10}, {0xb13, 0xb28}, {0xb2a, 0xb30}, {0xb32, 0xb33}, {0xb35, 0xb39}, {0xb3d, 0xb3d}, + {0xb5c, 0xb5d}, {0xb5f, 0xb61}, {0xb71, 0xb71}, {0xb83, 0xb83}, {0xb85, 0xb8a}, {0xb8e, 0xb90}, + {0xb92, 0xb95}, {0xb99, 0xb9a}, {0xb9c, 0xb9c}, {0xb9e, 0xb9f}, {0xba3, 0xba4}, {0xba8, 0xbaa}, + {0xbae, 0xbb9}, {0xbd0, 0xbd0}, {0xc05, 0xc0c}, {0xc0e, 0xc10}, {0xc12, 0xc28}, {0xc2a, 0xc39}, + {0xc3d, 0xc3d}, {0xc58, 0xc5a}, {0xc5c, 0xc5d}, {0xc60, 0xc61}, {0xc80, 0xc80}, {0xc85, 0xc8c}, + {0xc8e, 0xc90}, {0xc92, 0xca8}, {0xcaa, 0xcb3}, {0xcb5, 0xcb9}, {0xcbd, 0xcbd}, {0xcdc, 0xcde}, + {0xce0, 0xce1}, {0xcf1, 0xcf2}, {0xd04, 0xd0c}, {0xd0e, 0xd10}, {0xd12, 0xd3a}, {0xd3d, 0xd3d}, + {0xd4e, 0xd4e}, {0xd54, 0xd56}, {0xd5f, 0xd61}, {0xd7a, 0xd7f}, {0xd85, 0xd96}, {0xd9a, 0xdb1}, + {0xdb3, 0xdbb}, {0xdbd, 0xdbd}, {0xdc0, 0xdc6}, {0xe01, 0xe30}, {0xe32, 0xe33}, {0xe40, 0xe46}, + {0xe81, 0xe82}, {0xe84, 0xe84}, {0xe86, 0xe8a}, {0xe8c, 0xea3}, {0xea5, 0xea5}, {0xea7, 0xeb0}, + {0xeb2, 0xeb3}, {0xebd, 0xebd}, {0xec0, 0xec4}, {0xec6, 0xec6}, {0xedc, 0xedf}, {0xf00, 0xf00}, + {0xf40, 0xf47}, {0xf49, 0xf6c}, {0xf88, 0xf8c}, {0x1000, 0x102a}, {0x103f, 0x103f}, + {0x1050, 0x1055}, {0x105a, 0x105d}, {0x1061, 0x1061}, {0x1065, 0x1066}, {0x106e, 0x1070}, + {0x1075, 0x1081}, {0x108e, 0x108e}, {0x10a0, 0x10c5}, {0x10c7, 0x10c7}, {0x10cd, 0x10cd}, + {0x10d0, 0x10fa}, {0x10fc, 0x1248}, {0x124a, 0x124d}, {0x1250, 0x1256}, {0x1258, 0x1258}, + {0x125a, 0x125d}, {0x1260, 0x1288}, {0x128a, 0x128d}, {0x1290, 0x12b0}, {0x12b2, 0x12b5}, + {0x12b8, 0x12be}, {0x12c0, 0x12c0}, {0x12c2, 0x12c5}, {0x12c8, 0x12d6}, {0x12d8, 0x1310}, + {0x1312, 0x1315}, {0x1318, 0x135a}, {0x1380, 0x138f}, {0x13a0, 0x13f5}, {0x13f8, 0x13fd}, + {0x1401, 0x166c}, {0x166f, 0x167f}, {0x1681, 0x169a}, {0x16a0, 0x16ea}, {0x16f1, 0x16f8}, + {0x1700, 0x1711}, {0x171f, 0x1731}, {0x1740, 0x1751}, {0x1760, 0x176c}, {0x176e, 0x1770}, + {0x1780, 0x17b3}, {0x17d7, 0x17d7}, {0x17dc, 0x17dc}, {0x1820, 0x1878}, {0x1880, 0x1884}, + {0x1887, 0x18a8}, {0x18aa, 0x18aa}, {0x18b0, 0x18f5}, {0x1900, 0x191e}, {0x1950, 0x196d}, + {0x1970, 0x1974}, {0x1980, 0x19ab}, {0x19b0, 0x19c9}, {0x1a00, 0x1a16}, {0x1a20, 0x1a54}, + {0x1aa7, 0x1aa7}, {0x1b05, 0x1b33}, {0x1b45, 0x1b4c}, {0x1b83, 0x1ba0}, {0x1bae, 0x1baf}, + {0x1bba, 0x1be5}, {0x1c00, 0x1c23}, {0x1c4d, 0x1c4f}, {0x1c5a, 0x1c7d}, {0x1c80, 0x1c8a}, + {0x1c90, 0x1cba}, {0x1cbd, 0x1cbf}, {0x1ce9, 0x1cec}, {0x1cee, 0x1cf3}, {0x1cf5, 0x1cf6}, + {0x1cfa, 0x1cfa}, {0x1d00, 0x1dbf}, {0x1e00, 0x1f15}, {0x1f18, 0x1f1d}, {0x1f20, 0x1f45}, + {0x1f48, 0x1f4d}, {0x1f50, 0x1f57}, {0x1f59, 0x1f59}, {0x1f5b, 0x1f5b}, {0x1f5d, 0x1f5d}, + {0x1f5f, 0x1f7d}, {0x1f80, 0x1fb4}, {0x1fb6, 0x1fbc}, {0x1fbe, 0x1fbe}, {0x1fc2, 0x1fc4}, + {0x1fc6, 0x1fcc}, {0x1fd0, 0x1fd3}, {0x1fd6, 0x1fdb}, {0x1fe0, 0x1fec}, {0x1ff2, 0x1ff4}, + {0x1ff6, 0x1ffc}, {0x2071, 0x2071}, {0x207f, 0x207f}, {0x2090, 0x209c}, {0x2102, 0x2102}, + {0x2107, 0x2107}, {0x210a, 0x2113}, {0x2115, 0x2115}, {0x2119, 0x211d}, {0x2124, 0x2124}, + {0x2126, 0x2126}, {0x2128, 0x2128}, {0x212a, 0x212d}, {0x212f, 0x2139}, {0x213c, 0x213f}, + {0x2145, 0x2149}, {0x214e, 0x214e}, {0x2183, 0x2184}, {0x2c00, 0x2ce4}, {0x2ceb, 0x2cee}, + {0x2cf2, 0x2cf3}, {0x2d00, 0x2d25}, {0x2d27, 0x2d27}, {0x2d2d, 0x2d2d}, {0x2d30, 0x2d67}, + {0x2d6f, 0x2d6f}, {0x2d80, 0x2d96}, {0x2da0, 0x2da6}, {0x2da8, 0x2dae}, {0x2db0, 0x2db6}, + {0x2db8, 0x2dbe}, {0x2dc0, 0x2dc6}, {0x2dc8, 0x2dce}, {0x2dd0, 0x2dd6}, {0x2dd8, 0x2dde}, + {0x2e2f, 0x2e2f}, {0x3005, 0x3006}, {0x3031, 0x3035}, {0x303b, 0x303c}, {0x3041, 0x3096}, + {0x309d, 0x309f}, {0x30a1, 0x30fa}, {0x30fc, 0x30ff}, {0x3105, 0x312f}, {0x3131, 0x318e}, + {0x31a0, 0x31bf}, {0x31f0, 0x31ff}, {0x3400, 0x4dbf}, {0x4e00, 0xa48c}, {0xa4d0, 0xa4fd}, + {0xa500, 0xa60c}, {0xa610, 0xa61f}, {0xa62a, 0xa62b}, {0xa640, 0xa66e}, {0xa67f, 0xa69d}, + {0xa6a0, 0xa6e5}, {0xa717, 0xa71f}, {0xa722, 0xa788}, {0xa78b, 0xa7dc}, {0xa7f1, 0xa801}, + {0xa803, 0xa805}, {0xa807, 0xa80a}, {0xa80c, 0xa822}, {0xa840, 0xa873}, {0xa882, 0xa8b3}, + {0xa8f2, 0xa8f7}, {0xa8fb, 0xa8fb}, {0xa8fd, 0xa8fe}, {0xa90a, 0xa925}, {0xa930, 0xa946}, + {0xa960, 0xa97c}, {0xa984, 0xa9b2}, {0xa9cf, 0xa9cf}, {0xa9e0, 0xa9e4}, {0xa9e6, 0xa9ef}, + {0xa9fa, 0xa9fe}, {0xaa00, 0xaa28}, {0xaa40, 0xaa42}, {0xaa44, 0xaa4b}, {0xaa60, 0xaa76}, + {0xaa7a, 0xaa7a}, {0xaa7e, 0xaaaf}, {0xaab1, 0xaab1}, {0xaab5, 0xaab6}, {0xaab9, 0xaabd}, + {0xaac0, 0xaac0}, {0xaac2, 0xaac2}, {0xaadb, 0xaadd}, {0xaae0, 0xaaea}, {0xaaf2, 0xaaf4}, + {0xab01, 0xab06}, {0xab09, 0xab0e}, {0xab11, 0xab16}, {0xab20, 0xab26}, {0xab28, 0xab2e}, + {0xab30, 0xab5a}, {0xab5c, 0xab69}, {0xab70, 0xabe2}, {0xac00, 0xd7a3}, {0xd7b0, 0xd7c6}, + {0xd7cb, 0xd7fb}, {0xf900, 0xfa6d}, {0xfa70, 0xfad9}, {0xfb00, 0xfb06}, {0xfb13, 0xfb17}, + {0xfb1d, 0xfb1d}, {0xfb1f, 0xfb28}, {0xfb2a, 0xfb36}, {0xfb38, 0xfb3c}, {0xfb3e, 0xfb3e}, + {0xfb40, 0xfb41}, {0xfb43, 0xfb44}, {0xfb46, 0xfbb1}, {0xfbd3, 0xfd3d}, {0xfd50, 0xfd8f}, + {0xfd92, 0xfdc7}, {0xfdf0, 0xfdfb}, {0xfe70, 0xfe74}, {0xfe76, 0xfefc}, {0xff21, 0xff3a}, + {0xff41, 0xff5a}, {0xff66, 0xffbe}, {0xffc2, 0xffc7}, {0xffca, 0xffcf}, {0xffd2, 0xffd7}, + {0xffda, 0xffdc}, {0x10000, 0x1000b}, {0x1000d, 0x10026}, {0x10028, 0x1003a}, {0x1003c, 0x1003d}, + {0x1003f, 0x1004d}, {0x10050, 0x1005d}, {0x10080, 0x100fa}, {0x10280, 0x1029c}, + {0x102a0, 0x102d0}, {0x10300, 0x1031f}, {0x1032d, 0x10340}, {0x10342, 0x10349}, + {0x10350, 0x10375}, {0x10380, 0x1039d}, {0x103a0, 0x103c3}, {0x103c8, 0x103cf}, + {0x10400, 0x1049d}, {0x104b0, 0x104d3}, {0x104d8, 0x104fb}, {0x10500, 0x10527}, + {0x10530, 0x10563}, {0x10570, 0x1057a}, {0x1057c, 0x1058a}, {0x1058c, 0x10592}, + {0x10594, 0x10595}, {0x10597, 0x105a1}, {0x105a3, 0x105b1}, {0x105b3, 0x105b9}, + {0x105bb, 0x105bc}, {0x105c0, 0x105f3}, {0x10600, 0x10736}, {0x10740, 0x10755}, + {0x10760, 0x10767}, {0x10780, 0x10785}, {0x10787, 0x107b0}, {0x107b2, 0x107ba}, + {0x10800, 0x10805}, {0x10808, 0x10808}, {0x1080a, 0x10835}, {0x10837, 0x10838}, + {0x1083c, 0x1083c}, {0x1083f, 0x10855}, {0x10860, 0x10876}, {0x10880, 0x1089e}, + {0x108e0, 0x108f2}, {0x108f4, 0x108f5}, {0x10900, 0x10915}, {0x10920, 0x10939}, + {0x10940, 0x10959}, {0x10980, 0x109b7}, {0x109be, 0x109bf}, {0x10a00, 0x10a00}, + {0x10a10, 0x10a13}, {0x10a15, 0x10a17}, {0x10a19, 0x10a35}, {0x10a60, 0x10a7c}, + {0x10a80, 0x10a9c}, {0x10ac0, 0x10ac7}, {0x10ac9, 0x10ae4}, {0x10b00, 0x10b35}, + {0x10b40, 0x10b55}, {0x10b60, 0x10b72}, {0x10b80, 0x10b91}, {0x10c00, 0x10c48}, + {0x10c80, 0x10cb2}, {0x10cc0, 0x10cf2}, {0x10d00, 0x10d23}, {0x10d4a, 0x10d65}, + {0x10d6f, 0x10d85}, {0x10e80, 0x10ea9}, {0x10eb0, 0x10eb1}, {0x10ec2, 0x10ec7}, + {0x10f00, 0x10f1c}, {0x10f27, 0x10f27}, {0x10f30, 0x10f45}, {0x10f70, 0x10f81}, + {0x10fb0, 0x10fc4}, {0x10fe0, 0x10ff6}, {0x11003, 0x11037}, {0x11071, 0x11072}, + {0x11075, 0x11075}, {0x11083, 0x110af}, {0x110d0, 0x110e8}, {0x11103, 0x11126}, + {0x11144, 0x11144}, {0x11147, 0x11147}, {0x11150, 0x11172}, {0x11176, 0x11176}, + {0x11183, 0x111b2}, {0x111c1, 0x111c4}, {0x111da, 0x111da}, {0x111dc, 0x111dc}, + {0x11200, 0x11211}, {0x11213, 0x1122b}, {0x1123f, 0x11240}, {0x11280, 0x11286}, + {0x11288, 0x11288}, {0x1128a, 0x1128d}, {0x1128f, 0x1129d}, {0x1129f, 0x112a8}, + {0x112b0, 0x112de}, {0x11305, 0x1130c}, {0x1130f, 0x11310}, {0x11313, 0x11328}, + {0x1132a, 0x11330}, {0x11332, 0x11333}, {0x11335, 0x11339}, {0x1133d, 0x1133d}, + {0x11350, 0x11350}, {0x1135d, 0x11361}, {0x11380, 0x11389}, {0x1138b, 0x1138b}, + {0x1138e, 0x1138e}, {0x11390, 0x113b5}, {0x113b7, 0x113b7}, {0x113d1, 0x113d1}, + {0x113d3, 0x113d3}, {0x11400, 0x11434}, {0x11447, 0x1144a}, {0x1145f, 0x11461}, + {0x11480, 0x114af}, {0x114c4, 0x114c5}, {0x114c7, 0x114c7}, {0x11580, 0x115ae}, + {0x115d8, 0x115db}, {0x11600, 0x1162f}, {0x11644, 0x11644}, {0x11680, 0x116aa}, + {0x116b8, 0x116b8}, {0x11700, 0x1171a}, {0x11740, 0x11746}, {0x11800, 0x1182b}, + {0x118a0, 0x118df}, {0x118ff, 0x11906}, {0x11909, 0x11909}, {0x1190c, 0x11913}, + {0x11915, 0x11916}, {0x11918, 0x1192f}, {0x1193f, 0x1193f}, {0x11941, 0x11941}, + {0x119a0, 0x119a7}, {0x119aa, 0x119d0}, {0x119e1, 0x119e1}, {0x119e3, 0x119e3}, + {0x11a00, 0x11a00}, {0x11a0b, 0x11a32}, {0x11a3a, 0x11a3a}, {0x11a50, 0x11a50}, + {0x11a5c, 0x11a89}, {0x11a9d, 0x11a9d}, {0x11ab0, 0x11af8}, {0x11bc0, 0x11be0}, + {0x11c00, 0x11c08}, {0x11c0a, 0x11c2e}, {0x11c40, 0x11c40}, {0x11c72, 0x11c8f}, + {0x11d00, 0x11d06}, {0x11d08, 0x11d09}, {0x11d0b, 0x11d30}, {0x11d46, 0x11d46}, + {0x11d60, 0x11d65}, {0x11d67, 0x11d68}, {0x11d6a, 0x11d89}, {0x11d98, 0x11d98}, + {0x11db0, 0x11ddb}, {0x11ee0, 0x11ef2}, {0x11f02, 0x11f02}, {0x11f04, 0x11f10}, + {0x11f12, 0x11f33}, {0x11fb0, 0x11fb0}, {0x12000, 0x12399}, {0x12480, 0x12543}, + {0x12f90, 0x12ff0}, {0x13000, 0x1342f}, {0x13441, 0x13446}, {0x13460, 0x143fa}, + {0x14400, 0x14646}, {0x16100, 0x1611d}, {0x16800, 0x16a38}, {0x16a40, 0x16a5e}, + {0x16a70, 0x16abe}, {0x16ad0, 0x16aed}, {0x16b00, 0x16b2f}, {0x16b40, 0x16b43}, + {0x16b63, 0x16b77}, {0x16b7d, 0x16b8f}, {0x16d40, 0x16d6c}, {0x16e40, 0x16e7f}, + {0x16ea0, 0x16eb8}, {0x16ebb, 0x16ed3}, {0x16f00, 0x16f4a}, {0x16f50, 0x16f50}, + {0x16f93, 0x16f9f}, {0x16fe0, 0x16fe1}, {0x16fe3, 0x16fe3}, {0x16ff2, 0x16ff3}, + {0x17000, 0x18cd5}, {0x18cff, 0x18d1e}, {0x18d80, 0x18df2}, {0x1aff0, 0x1aff3}, + {0x1aff5, 0x1affb}, {0x1affd, 0x1affe}, {0x1b000, 0x1b122}, {0x1b132, 0x1b132}, + {0x1b150, 0x1b152}, {0x1b155, 0x1b155}, {0x1b164, 0x1b167}, {0x1b170, 0x1b2fb}, + {0x1bc00, 0x1bc6a}, {0x1bc70, 0x1bc7c}, {0x1bc80, 0x1bc88}, {0x1bc90, 0x1bc99}, + {0x1d400, 0x1d454}, {0x1d456, 0x1d49c}, {0x1d49e, 0x1d49f}, {0x1d4a2, 0x1d4a2}, + {0x1d4a5, 0x1d4a6}, {0x1d4a9, 0x1d4ac}, {0x1d4ae, 0x1d4b9}, {0x1d4bb, 0x1d4bb}, + {0x1d4bd, 0x1d4c3}, {0x1d4c5, 0x1d505}, {0x1d507, 0x1d50a}, {0x1d50d, 0x1d514}, + {0x1d516, 0x1d51c}, {0x1d51e, 0x1d539}, {0x1d53b, 0x1d53e}, {0x1d540, 0x1d544}, + {0x1d546, 0x1d546}, {0x1d54a, 0x1d550}, {0x1d552, 0x1d6a5}, {0x1d6a8, 0x1d6c0}, + {0x1d6c2, 0x1d6da}, {0x1d6dc, 0x1d6fa}, {0x1d6fc, 0x1d714}, {0x1d716, 0x1d734}, + {0x1d736, 0x1d74e}, {0x1d750, 0x1d76e}, {0x1d770, 0x1d788}, {0x1d78a, 0x1d7a8}, + {0x1d7aa, 0x1d7c2}, {0x1d7c4, 0x1d7cb}, {0x1df00, 0x1df1e}, {0x1df25, 0x1df2a}, + {0x1e030, 0x1e06d}, {0x1e100, 0x1e12c}, {0x1e137, 0x1e13d}, {0x1e14e, 0x1e14e}, + {0x1e290, 0x1e2ad}, {0x1e2c0, 0x1e2eb}, {0x1e4d0, 0x1e4eb}, {0x1e5d0, 0x1e5ed}, + {0x1e5f0, 0x1e5f0}, {0x1e6c0, 0x1e6de}, {0x1e6e0, 0x1e6e2}, {0x1e6e4, 0x1e6e5}, + {0x1e6e7, 0x1e6ed}, {0x1e6f0, 0x1e6f4}, {0x1e6fe, 0x1e6ff}, {0x1e7e0, 0x1e7e6}, + {0x1e7e8, 0x1e7eb}, {0x1e7ed, 0x1e7ee}, {0x1e7f0, 0x1e7fe}, {0x1e800, 0x1e8c4}, + {0x1e900, 0x1e943}, {0x1e94b, 0x1e94b}, {0x1ee00, 0x1ee03}, {0x1ee05, 0x1ee1f}, + {0x1ee21, 0x1ee22}, {0x1ee24, 0x1ee24}, {0x1ee27, 0x1ee27}, {0x1ee29, 0x1ee32}, + {0x1ee34, 0x1ee37}, {0x1ee39, 0x1ee39}, {0x1ee3b, 0x1ee3b}, {0x1ee42, 0x1ee42}, + {0x1ee47, 0x1ee47}, {0x1ee49, 0x1ee49}, {0x1ee4b, 0x1ee4b}, {0x1ee4d, 0x1ee4f}, + {0x1ee51, 0x1ee52}, {0x1ee54, 0x1ee54}, {0x1ee57, 0x1ee57}, {0x1ee59, 0x1ee59}, + {0x1ee5b, 0x1ee5b}, {0x1ee5d, 0x1ee5d}, {0x1ee5f, 0x1ee5f}, {0x1ee61, 0x1ee62}, + {0x1ee64, 0x1ee64}, {0x1ee67, 0x1ee6a}, {0x1ee6c, 0x1ee72}, {0x1ee74, 0x1ee77}, + {0x1ee79, 0x1ee7c}, {0x1ee7e, 0x1ee7e}, {0x1ee80, 0x1ee89}, {0x1ee8b, 0x1ee9b}, + {0x1eea1, 0x1eea3}, {0x1eea5, 0x1eea9}, {0x1eeab, 0x1eebb}, {0x20000, 0x2a6df}, + {0x2a700, 0x2b81d}, {0x2b820, 0x2cead}, {0x2ceb0, 0x2ebe0}, {0x2ebf0, 0x2ee5d}, + {0x2f800, 0x2fa1d}, {0x30000, 0x3134a}, {0x31350, 0x33479}, +}; + +TP_PRIVATE const tp_uni_range tp_uni_upper[TP_UNI_UPPER_N] = { + {0x41, 0x5a}, {0xc0, 0xd6}, {0xd8, 0xde}, {0x100, 0x100}, {0x102, 0x102}, {0x104, 0x104}, + {0x106, 0x106}, {0x108, 0x108}, {0x10a, 0x10a}, {0x10c, 0x10c}, {0x10e, 0x10e}, {0x110, 0x110}, + {0x112, 0x112}, {0x114, 0x114}, {0x116, 0x116}, {0x118, 0x118}, {0x11a, 0x11a}, {0x11c, 0x11c}, + {0x11e, 0x11e}, {0x120, 0x120}, {0x122, 0x122}, {0x124, 0x124}, {0x126, 0x126}, {0x128, 0x128}, + {0x12a, 0x12a}, {0x12c, 0x12c}, {0x12e, 0x12e}, {0x130, 0x130}, {0x132, 0x132}, {0x134, 0x134}, + {0x136, 0x136}, {0x139, 0x139}, {0x13b, 0x13b}, {0x13d, 0x13d}, {0x13f, 0x13f}, {0x141, 0x141}, + {0x143, 0x143}, {0x145, 0x145}, {0x147, 0x147}, {0x14a, 0x14a}, {0x14c, 0x14c}, {0x14e, 0x14e}, + {0x150, 0x150}, {0x152, 0x152}, {0x154, 0x154}, {0x156, 0x156}, {0x158, 0x158}, {0x15a, 0x15a}, + {0x15c, 0x15c}, {0x15e, 0x15e}, {0x160, 0x160}, {0x162, 0x162}, {0x164, 0x164}, {0x166, 0x166}, + {0x168, 0x168}, {0x16a, 0x16a}, {0x16c, 0x16c}, {0x16e, 0x16e}, {0x170, 0x170}, {0x172, 0x172}, + {0x174, 0x174}, {0x176, 0x176}, {0x178, 0x179}, {0x17b, 0x17b}, {0x17d, 0x17d}, {0x181, 0x182}, + {0x184, 0x184}, {0x186, 0x187}, {0x189, 0x18b}, {0x18e, 0x191}, {0x193, 0x194}, {0x196, 0x198}, + {0x19c, 0x19d}, {0x19f, 0x1a0}, {0x1a2, 0x1a2}, {0x1a4, 0x1a4}, {0x1a6, 0x1a7}, {0x1a9, 0x1a9}, + {0x1ac, 0x1ac}, {0x1ae, 0x1af}, {0x1b1, 0x1b3}, {0x1b5, 0x1b5}, {0x1b7, 0x1b8}, {0x1bc, 0x1bc}, + {0x1c4, 0x1c4}, {0x1c7, 0x1c7}, {0x1ca, 0x1ca}, {0x1cd, 0x1cd}, {0x1cf, 0x1cf}, {0x1d1, 0x1d1}, + {0x1d3, 0x1d3}, {0x1d5, 0x1d5}, {0x1d7, 0x1d7}, {0x1d9, 0x1d9}, {0x1db, 0x1db}, {0x1de, 0x1de}, + {0x1e0, 0x1e0}, {0x1e2, 0x1e2}, {0x1e4, 0x1e4}, {0x1e6, 0x1e6}, {0x1e8, 0x1e8}, {0x1ea, 0x1ea}, + {0x1ec, 0x1ec}, {0x1ee, 0x1ee}, {0x1f1, 0x1f1}, {0x1f4, 0x1f4}, {0x1f6, 0x1f8}, {0x1fa, 0x1fa}, + {0x1fc, 0x1fc}, {0x1fe, 0x1fe}, {0x200, 0x200}, {0x202, 0x202}, {0x204, 0x204}, {0x206, 0x206}, + {0x208, 0x208}, {0x20a, 0x20a}, {0x20c, 0x20c}, {0x20e, 0x20e}, {0x210, 0x210}, {0x212, 0x212}, + {0x214, 0x214}, {0x216, 0x216}, {0x218, 0x218}, {0x21a, 0x21a}, {0x21c, 0x21c}, {0x21e, 0x21e}, + {0x220, 0x220}, {0x222, 0x222}, {0x224, 0x224}, {0x226, 0x226}, {0x228, 0x228}, {0x22a, 0x22a}, + {0x22c, 0x22c}, {0x22e, 0x22e}, {0x230, 0x230}, {0x232, 0x232}, {0x23a, 0x23b}, {0x23d, 0x23e}, + {0x241, 0x241}, {0x243, 0x246}, {0x248, 0x248}, {0x24a, 0x24a}, {0x24c, 0x24c}, {0x24e, 0x24e}, + {0x370, 0x370}, {0x372, 0x372}, {0x376, 0x376}, {0x37f, 0x37f}, {0x386, 0x386}, {0x388, 0x38a}, + {0x38c, 0x38c}, {0x38e, 0x38f}, {0x391, 0x3a1}, {0x3a3, 0x3ab}, {0x3cf, 0x3cf}, {0x3d2, 0x3d4}, + {0x3d8, 0x3d8}, {0x3da, 0x3da}, {0x3dc, 0x3dc}, {0x3de, 0x3de}, {0x3e0, 0x3e0}, {0x3e2, 0x3e2}, + {0x3e4, 0x3e4}, {0x3e6, 0x3e6}, {0x3e8, 0x3e8}, {0x3ea, 0x3ea}, {0x3ec, 0x3ec}, {0x3ee, 0x3ee}, + {0x3f4, 0x3f4}, {0x3f7, 0x3f7}, {0x3f9, 0x3fa}, {0x3fd, 0x42f}, {0x460, 0x460}, {0x462, 0x462}, + {0x464, 0x464}, {0x466, 0x466}, {0x468, 0x468}, {0x46a, 0x46a}, {0x46c, 0x46c}, {0x46e, 0x46e}, + {0x470, 0x470}, {0x472, 0x472}, {0x474, 0x474}, {0x476, 0x476}, {0x478, 0x478}, {0x47a, 0x47a}, + {0x47c, 0x47c}, {0x47e, 0x47e}, {0x480, 0x480}, {0x48a, 0x48a}, {0x48c, 0x48c}, {0x48e, 0x48e}, + {0x490, 0x490}, {0x492, 0x492}, {0x494, 0x494}, {0x496, 0x496}, {0x498, 0x498}, {0x49a, 0x49a}, + {0x49c, 0x49c}, {0x49e, 0x49e}, {0x4a0, 0x4a0}, {0x4a2, 0x4a2}, {0x4a4, 0x4a4}, {0x4a6, 0x4a6}, + {0x4a8, 0x4a8}, {0x4aa, 0x4aa}, {0x4ac, 0x4ac}, {0x4ae, 0x4ae}, {0x4b0, 0x4b0}, {0x4b2, 0x4b2}, + {0x4b4, 0x4b4}, {0x4b6, 0x4b6}, {0x4b8, 0x4b8}, {0x4ba, 0x4ba}, {0x4bc, 0x4bc}, {0x4be, 0x4be}, + {0x4c0, 0x4c1}, {0x4c3, 0x4c3}, {0x4c5, 0x4c5}, {0x4c7, 0x4c7}, {0x4c9, 0x4c9}, {0x4cb, 0x4cb}, + {0x4cd, 0x4cd}, {0x4d0, 0x4d0}, {0x4d2, 0x4d2}, {0x4d4, 0x4d4}, {0x4d6, 0x4d6}, {0x4d8, 0x4d8}, + {0x4da, 0x4da}, {0x4dc, 0x4dc}, {0x4de, 0x4de}, {0x4e0, 0x4e0}, {0x4e2, 0x4e2}, {0x4e4, 0x4e4}, + {0x4e6, 0x4e6}, {0x4e8, 0x4e8}, {0x4ea, 0x4ea}, {0x4ec, 0x4ec}, {0x4ee, 0x4ee}, {0x4f0, 0x4f0}, + {0x4f2, 0x4f2}, {0x4f4, 0x4f4}, {0x4f6, 0x4f6}, {0x4f8, 0x4f8}, {0x4fa, 0x4fa}, {0x4fc, 0x4fc}, + {0x4fe, 0x4fe}, {0x500, 0x500}, {0x502, 0x502}, {0x504, 0x504}, {0x506, 0x506}, {0x508, 0x508}, + {0x50a, 0x50a}, {0x50c, 0x50c}, {0x50e, 0x50e}, {0x510, 0x510}, {0x512, 0x512}, {0x514, 0x514}, + {0x516, 0x516}, {0x518, 0x518}, {0x51a, 0x51a}, {0x51c, 0x51c}, {0x51e, 0x51e}, {0x520, 0x520}, + {0x522, 0x522}, {0x524, 0x524}, {0x526, 0x526}, {0x528, 0x528}, {0x52a, 0x52a}, {0x52c, 0x52c}, + {0x52e, 0x52e}, {0x531, 0x556}, {0x10a0, 0x10c5}, {0x10c7, 0x10c7}, {0x10cd, 0x10cd}, + {0x13a0, 0x13f5}, {0x1c89, 0x1c89}, {0x1c90, 0x1cba}, {0x1cbd, 0x1cbf}, {0x1e00, 0x1e00}, + {0x1e02, 0x1e02}, {0x1e04, 0x1e04}, {0x1e06, 0x1e06}, {0x1e08, 0x1e08}, {0x1e0a, 0x1e0a}, + {0x1e0c, 0x1e0c}, {0x1e0e, 0x1e0e}, {0x1e10, 0x1e10}, {0x1e12, 0x1e12}, {0x1e14, 0x1e14}, + {0x1e16, 0x1e16}, {0x1e18, 0x1e18}, {0x1e1a, 0x1e1a}, {0x1e1c, 0x1e1c}, {0x1e1e, 0x1e1e}, + {0x1e20, 0x1e20}, {0x1e22, 0x1e22}, {0x1e24, 0x1e24}, {0x1e26, 0x1e26}, {0x1e28, 0x1e28}, + {0x1e2a, 0x1e2a}, {0x1e2c, 0x1e2c}, {0x1e2e, 0x1e2e}, {0x1e30, 0x1e30}, {0x1e32, 0x1e32}, + {0x1e34, 0x1e34}, {0x1e36, 0x1e36}, {0x1e38, 0x1e38}, {0x1e3a, 0x1e3a}, {0x1e3c, 0x1e3c}, + {0x1e3e, 0x1e3e}, {0x1e40, 0x1e40}, {0x1e42, 0x1e42}, {0x1e44, 0x1e44}, {0x1e46, 0x1e46}, + {0x1e48, 0x1e48}, {0x1e4a, 0x1e4a}, {0x1e4c, 0x1e4c}, {0x1e4e, 0x1e4e}, {0x1e50, 0x1e50}, + {0x1e52, 0x1e52}, {0x1e54, 0x1e54}, {0x1e56, 0x1e56}, {0x1e58, 0x1e58}, {0x1e5a, 0x1e5a}, + {0x1e5c, 0x1e5c}, {0x1e5e, 0x1e5e}, {0x1e60, 0x1e60}, {0x1e62, 0x1e62}, {0x1e64, 0x1e64}, + {0x1e66, 0x1e66}, {0x1e68, 0x1e68}, {0x1e6a, 0x1e6a}, {0x1e6c, 0x1e6c}, {0x1e6e, 0x1e6e}, + {0x1e70, 0x1e70}, {0x1e72, 0x1e72}, {0x1e74, 0x1e74}, {0x1e76, 0x1e76}, {0x1e78, 0x1e78}, + {0x1e7a, 0x1e7a}, {0x1e7c, 0x1e7c}, {0x1e7e, 0x1e7e}, {0x1e80, 0x1e80}, {0x1e82, 0x1e82}, + {0x1e84, 0x1e84}, {0x1e86, 0x1e86}, {0x1e88, 0x1e88}, {0x1e8a, 0x1e8a}, {0x1e8c, 0x1e8c}, + {0x1e8e, 0x1e8e}, {0x1e90, 0x1e90}, {0x1e92, 0x1e92}, {0x1e94, 0x1e94}, {0x1e9e, 0x1e9e}, + {0x1ea0, 0x1ea0}, {0x1ea2, 0x1ea2}, {0x1ea4, 0x1ea4}, {0x1ea6, 0x1ea6}, {0x1ea8, 0x1ea8}, + {0x1eaa, 0x1eaa}, {0x1eac, 0x1eac}, {0x1eae, 0x1eae}, {0x1eb0, 0x1eb0}, {0x1eb2, 0x1eb2}, + {0x1eb4, 0x1eb4}, {0x1eb6, 0x1eb6}, {0x1eb8, 0x1eb8}, {0x1eba, 0x1eba}, {0x1ebc, 0x1ebc}, + {0x1ebe, 0x1ebe}, {0x1ec0, 0x1ec0}, {0x1ec2, 0x1ec2}, {0x1ec4, 0x1ec4}, {0x1ec6, 0x1ec6}, + {0x1ec8, 0x1ec8}, {0x1eca, 0x1eca}, {0x1ecc, 0x1ecc}, {0x1ece, 0x1ece}, {0x1ed0, 0x1ed0}, + {0x1ed2, 0x1ed2}, {0x1ed4, 0x1ed4}, {0x1ed6, 0x1ed6}, {0x1ed8, 0x1ed8}, {0x1eda, 0x1eda}, + {0x1edc, 0x1edc}, {0x1ede, 0x1ede}, {0x1ee0, 0x1ee0}, {0x1ee2, 0x1ee2}, {0x1ee4, 0x1ee4}, + {0x1ee6, 0x1ee6}, {0x1ee8, 0x1ee8}, {0x1eea, 0x1eea}, {0x1eec, 0x1eec}, {0x1eee, 0x1eee}, + {0x1ef0, 0x1ef0}, {0x1ef2, 0x1ef2}, {0x1ef4, 0x1ef4}, {0x1ef6, 0x1ef6}, {0x1ef8, 0x1ef8}, + {0x1efa, 0x1efa}, {0x1efc, 0x1efc}, {0x1efe, 0x1efe}, {0x1f08, 0x1f0f}, {0x1f18, 0x1f1d}, + {0x1f28, 0x1f2f}, {0x1f38, 0x1f3f}, {0x1f48, 0x1f4d}, {0x1f59, 0x1f59}, {0x1f5b, 0x1f5b}, + {0x1f5d, 0x1f5d}, {0x1f5f, 0x1f5f}, {0x1f68, 0x1f6f}, {0x1fb8, 0x1fbb}, {0x1fc8, 0x1fcb}, + {0x1fd8, 0x1fdb}, {0x1fe8, 0x1fec}, {0x1ff8, 0x1ffb}, {0x2102, 0x2102}, {0x2107, 0x2107}, + {0x210b, 0x210d}, {0x2110, 0x2112}, {0x2115, 0x2115}, {0x2119, 0x211d}, {0x2124, 0x2124}, + {0x2126, 0x2126}, {0x2128, 0x2128}, {0x212a, 0x212d}, {0x2130, 0x2133}, {0x213e, 0x213f}, + {0x2145, 0x2145}, {0x2183, 0x2183}, {0x2c00, 0x2c2f}, {0x2c60, 0x2c60}, {0x2c62, 0x2c64}, + {0x2c67, 0x2c67}, {0x2c69, 0x2c69}, {0x2c6b, 0x2c6b}, {0x2c6d, 0x2c70}, {0x2c72, 0x2c72}, + {0x2c75, 0x2c75}, {0x2c7e, 0x2c80}, {0x2c82, 0x2c82}, {0x2c84, 0x2c84}, {0x2c86, 0x2c86}, + {0x2c88, 0x2c88}, {0x2c8a, 0x2c8a}, {0x2c8c, 0x2c8c}, {0x2c8e, 0x2c8e}, {0x2c90, 0x2c90}, + {0x2c92, 0x2c92}, {0x2c94, 0x2c94}, {0x2c96, 0x2c96}, {0x2c98, 0x2c98}, {0x2c9a, 0x2c9a}, + {0x2c9c, 0x2c9c}, {0x2c9e, 0x2c9e}, {0x2ca0, 0x2ca0}, {0x2ca2, 0x2ca2}, {0x2ca4, 0x2ca4}, + {0x2ca6, 0x2ca6}, {0x2ca8, 0x2ca8}, {0x2caa, 0x2caa}, {0x2cac, 0x2cac}, {0x2cae, 0x2cae}, + {0x2cb0, 0x2cb0}, {0x2cb2, 0x2cb2}, {0x2cb4, 0x2cb4}, {0x2cb6, 0x2cb6}, {0x2cb8, 0x2cb8}, + {0x2cba, 0x2cba}, {0x2cbc, 0x2cbc}, {0x2cbe, 0x2cbe}, {0x2cc0, 0x2cc0}, {0x2cc2, 0x2cc2}, + {0x2cc4, 0x2cc4}, {0x2cc6, 0x2cc6}, {0x2cc8, 0x2cc8}, {0x2cca, 0x2cca}, {0x2ccc, 0x2ccc}, + {0x2cce, 0x2cce}, {0x2cd0, 0x2cd0}, {0x2cd2, 0x2cd2}, {0x2cd4, 0x2cd4}, {0x2cd6, 0x2cd6}, + {0x2cd8, 0x2cd8}, {0x2cda, 0x2cda}, {0x2cdc, 0x2cdc}, {0x2cde, 0x2cde}, {0x2ce0, 0x2ce0}, + {0x2ce2, 0x2ce2}, {0x2ceb, 0x2ceb}, {0x2ced, 0x2ced}, {0x2cf2, 0x2cf2}, {0xa640, 0xa640}, + {0xa642, 0xa642}, {0xa644, 0xa644}, {0xa646, 0xa646}, {0xa648, 0xa648}, {0xa64a, 0xa64a}, + {0xa64c, 0xa64c}, {0xa64e, 0xa64e}, {0xa650, 0xa650}, {0xa652, 0xa652}, {0xa654, 0xa654}, + {0xa656, 0xa656}, {0xa658, 0xa658}, {0xa65a, 0xa65a}, {0xa65c, 0xa65c}, {0xa65e, 0xa65e}, + {0xa660, 0xa660}, {0xa662, 0xa662}, {0xa664, 0xa664}, {0xa666, 0xa666}, {0xa668, 0xa668}, + {0xa66a, 0xa66a}, {0xa66c, 0xa66c}, {0xa680, 0xa680}, {0xa682, 0xa682}, {0xa684, 0xa684}, + {0xa686, 0xa686}, {0xa688, 0xa688}, {0xa68a, 0xa68a}, {0xa68c, 0xa68c}, {0xa68e, 0xa68e}, + {0xa690, 0xa690}, {0xa692, 0xa692}, {0xa694, 0xa694}, {0xa696, 0xa696}, {0xa698, 0xa698}, + {0xa69a, 0xa69a}, {0xa722, 0xa722}, {0xa724, 0xa724}, {0xa726, 0xa726}, {0xa728, 0xa728}, + {0xa72a, 0xa72a}, {0xa72c, 0xa72c}, {0xa72e, 0xa72e}, {0xa732, 0xa732}, {0xa734, 0xa734}, + {0xa736, 0xa736}, {0xa738, 0xa738}, {0xa73a, 0xa73a}, {0xa73c, 0xa73c}, {0xa73e, 0xa73e}, + {0xa740, 0xa740}, {0xa742, 0xa742}, {0xa744, 0xa744}, {0xa746, 0xa746}, {0xa748, 0xa748}, + {0xa74a, 0xa74a}, {0xa74c, 0xa74c}, {0xa74e, 0xa74e}, {0xa750, 0xa750}, {0xa752, 0xa752}, + {0xa754, 0xa754}, {0xa756, 0xa756}, {0xa758, 0xa758}, {0xa75a, 0xa75a}, {0xa75c, 0xa75c}, + {0xa75e, 0xa75e}, {0xa760, 0xa760}, {0xa762, 0xa762}, {0xa764, 0xa764}, {0xa766, 0xa766}, + {0xa768, 0xa768}, {0xa76a, 0xa76a}, {0xa76c, 0xa76c}, {0xa76e, 0xa76e}, {0xa779, 0xa779}, + {0xa77b, 0xa77b}, {0xa77d, 0xa77e}, {0xa780, 0xa780}, {0xa782, 0xa782}, {0xa784, 0xa784}, + {0xa786, 0xa786}, {0xa78b, 0xa78b}, {0xa78d, 0xa78d}, {0xa790, 0xa790}, {0xa792, 0xa792}, + {0xa796, 0xa796}, {0xa798, 0xa798}, {0xa79a, 0xa79a}, {0xa79c, 0xa79c}, {0xa79e, 0xa79e}, + {0xa7a0, 0xa7a0}, {0xa7a2, 0xa7a2}, {0xa7a4, 0xa7a4}, {0xa7a6, 0xa7a6}, {0xa7a8, 0xa7a8}, + {0xa7aa, 0xa7ae}, {0xa7b0, 0xa7b4}, {0xa7b6, 0xa7b6}, {0xa7b8, 0xa7b8}, {0xa7ba, 0xa7ba}, + {0xa7bc, 0xa7bc}, {0xa7be, 0xa7be}, {0xa7c0, 0xa7c0}, {0xa7c2, 0xa7c2}, {0xa7c4, 0xa7c7}, + {0xa7c9, 0xa7c9}, {0xa7cb, 0xa7cc}, {0xa7ce, 0xa7ce}, {0xa7d0, 0xa7d0}, {0xa7d2, 0xa7d2}, + {0xa7d4, 0xa7d4}, {0xa7d6, 0xa7d6}, {0xa7d8, 0xa7d8}, {0xa7da, 0xa7da}, {0xa7dc, 0xa7dc}, + {0xa7f5, 0xa7f5}, {0xff21, 0xff3a}, {0x10400, 0x10427}, {0x104b0, 0x104d3}, {0x10570, 0x1057a}, + {0x1057c, 0x1058a}, {0x1058c, 0x10592}, {0x10594, 0x10595}, {0x10c80, 0x10cb2}, + {0x10d50, 0x10d65}, {0x118a0, 0x118bf}, {0x16e40, 0x16e5f}, {0x16ea0, 0x16eb8}, + {0x1d400, 0x1d419}, {0x1d434, 0x1d44d}, {0x1d468, 0x1d481}, {0x1d49c, 0x1d49c}, + {0x1d49e, 0x1d49f}, {0x1d4a2, 0x1d4a2}, {0x1d4a5, 0x1d4a6}, {0x1d4a9, 0x1d4ac}, + {0x1d4ae, 0x1d4b5}, {0x1d4d0, 0x1d4e9}, {0x1d504, 0x1d505}, {0x1d507, 0x1d50a}, + {0x1d50d, 0x1d514}, {0x1d516, 0x1d51c}, {0x1d538, 0x1d539}, {0x1d53b, 0x1d53e}, + {0x1d540, 0x1d544}, {0x1d546, 0x1d546}, {0x1d54a, 0x1d550}, {0x1d56c, 0x1d585}, + {0x1d5a0, 0x1d5b9}, {0x1d5d4, 0x1d5ed}, {0x1d608, 0x1d621}, {0x1d63c, 0x1d655}, + {0x1d670, 0x1d689}, {0x1d6a8, 0x1d6c0}, {0x1d6e2, 0x1d6fa}, {0x1d71c, 0x1d734}, + {0x1d756, 0x1d76e}, {0x1d790, 0x1d7a8}, {0x1d7ca, 0x1d7ca}, {0x1e900, 0x1e921}, +}; + +TP_PRIVATE const tp_uni_range tp_uni_cased[TP_UNI_CASED_N] = { + {0x41, 0x5a}, {0x61, 0x7a}, {0xaa, 0xaa}, {0xb5, 0xb5}, {0xba, 0xba}, {0xc0, 0xd6}, + {0xd8, 0xf6}, {0xf8, 0x1ba}, {0x1bc, 0x1bf}, {0x1c4, 0x293}, {0x296, 0x2b8}, {0x2c0, 0x2c1}, + {0x2e0, 0x2e4}, {0x345, 0x345}, {0x370, 0x373}, {0x376, 0x377}, {0x37a, 0x37d}, {0x37f, 0x37f}, + {0x386, 0x386}, {0x388, 0x38a}, {0x38c, 0x38c}, {0x38e, 0x3a1}, {0x3a3, 0x3f5}, {0x3f7, 0x481}, + {0x48a, 0x52f}, {0x531, 0x556}, {0x560, 0x588}, {0x10a0, 0x10c5}, {0x10c7, 0x10c7}, + {0x10cd, 0x10cd}, {0x10d0, 0x10fa}, {0x10fc, 0x10ff}, {0x13a0, 0x13f5}, {0x13f8, 0x13fd}, + {0x1c80, 0x1c8a}, {0x1c90, 0x1cba}, {0x1cbd, 0x1cbf}, {0x1d00, 0x1dbf}, {0x1e00, 0x1f15}, + {0x1f18, 0x1f1d}, {0x1f20, 0x1f45}, {0x1f48, 0x1f4d}, {0x1f50, 0x1f57}, {0x1f59, 0x1f59}, + {0x1f5b, 0x1f5b}, {0x1f5d, 0x1f5d}, {0x1f5f, 0x1f7d}, {0x1f80, 0x1fb4}, {0x1fb6, 0x1fbc}, + {0x1fbe, 0x1fbe}, {0x1fc2, 0x1fc4}, {0x1fc6, 0x1fcc}, {0x1fd0, 0x1fd3}, {0x1fd6, 0x1fdb}, + {0x1fe0, 0x1fec}, {0x1ff2, 0x1ff4}, {0x1ff6, 0x1ffc}, {0x2071, 0x2071}, {0x207f, 0x207f}, + {0x2090, 0x209c}, {0x2102, 0x2102}, {0x2107, 0x2107}, {0x210a, 0x2113}, {0x2115, 0x2115}, + {0x2119, 0x211d}, {0x2124, 0x2124}, {0x2126, 0x2126}, {0x2128, 0x2128}, {0x212a, 0x212d}, + {0x212f, 0x2134}, {0x2139, 0x2139}, {0x213c, 0x213f}, {0x2145, 0x2149}, {0x214e, 0x214e}, + {0x2160, 0x217f}, {0x2183, 0x2184}, {0x24b6, 0x24e9}, {0x2c00, 0x2ce4}, {0x2ceb, 0x2cee}, + {0x2cf2, 0x2cf3}, {0x2d00, 0x2d25}, {0x2d27, 0x2d27}, {0x2d2d, 0x2d2d}, {0xa640, 0xa66d}, + {0xa680, 0xa69d}, {0xa722, 0xa787}, {0xa78b, 0xa78e}, {0xa790, 0xa7dc}, {0xa7f1, 0xa7f6}, + {0xa7f8, 0xa7fa}, {0xab30, 0xab5a}, {0xab5c, 0xab69}, {0xab70, 0xabbf}, {0xfb00, 0xfb06}, + {0xfb13, 0xfb17}, {0xff21, 0xff3a}, {0xff41, 0xff5a}, {0x10400, 0x1044f}, {0x104b0, 0x104d3}, + {0x104d8, 0x104fb}, {0x10570, 0x1057a}, {0x1057c, 0x1058a}, {0x1058c, 0x10592}, + {0x10594, 0x10595}, {0x10597, 0x105a1}, {0x105a3, 0x105b1}, {0x105b3, 0x105b9}, + {0x105bb, 0x105bc}, {0x10780, 0x10780}, {0x10783, 0x10785}, {0x10787, 0x107b0}, + {0x107b2, 0x107ba}, {0x10c80, 0x10cb2}, {0x10cc0, 0x10cf2}, {0x10d50, 0x10d65}, + {0x10d70, 0x10d85}, {0x118a0, 0x118df}, {0x16e40, 0x16e7f}, {0x16ea0, 0x16eb8}, + {0x16ebb, 0x16ed3}, {0x1d400, 0x1d454}, {0x1d456, 0x1d49c}, {0x1d49e, 0x1d49f}, + {0x1d4a2, 0x1d4a2}, {0x1d4a5, 0x1d4a6}, {0x1d4a9, 0x1d4ac}, {0x1d4ae, 0x1d4b9}, + {0x1d4bb, 0x1d4bb}, {0x1d4bd, 0x1d4c3}, {0x1d4c5, 0x1d505}, {0x1d507, 0x1d50a}, + {0x1d50d, 0x1d514}, {0x1d516, 0x1d51c}, {0x1d51e, 0x1d539}, {0x1d53b, 0x1d53e}, + {0x1d540, 0x1d544}, {0x1d546, 0x1d546}, {0x1d54a, 0x1d550}, {0x1d552, 0x1d6a5}, + {0x1d6a8, 0x1d6c0}, {0x1d6c2, 0x1d6da}, {0x1d6dc, 0x1d6fa}, {0x1d6fc, 0x1d714}, + {0x1d716, 0x1d734}, {0x1d736, 0x1d74e}, {0x1d750, 0x1d76e}, {0x1d770, 0x1d788}, + {0x1d78a, 0x1d7a8}, {0x1d7aa, 0x1d7c2}, {0x1d7c4, 0x1d7cb}, {0x1df00, 0x1df09}, + {0x1df0b, 0x1df1e}, {0x1df25, 0x1df2a}, {0x1e030, 0x1e06d}, {0x1e900, 0x1e943}, + {0x1f130, 0x1f149}, {0x1f150, 0x1f169}, {0x1f170, 0x1f189}, +}; + +TP_PRIVATE const tp_uni_range tp_uni_case_ignorable[TP_UNI_CASE_IGNORABLE_N] = { + {0x27, 0x27}, {0x2e, 0x2e}, {0x3a, 0x3a}, {0x5e, 0x5e}, {0x60, 0x60}, {0xa8, 0xa8}, + {0xad, 0xad}, {0xaf, 0xaf}, {0xb4, 0xb4}, {0xb7, 0xb8}, {0x2b0, 0x36f}, {0x374, 0x375}, + {0x37a, 0x37a}, {0x384, 0x385}, {0x387, 0x387}, {0x483, 0x489}, {0x559, 0x559}, {0x55f, 0x55f}, + {0x591, 0x5bd}, {0x5bf, 0x5bf}, {0x5c1, 0x5c2}, {0x5c4, 0x5c5}, {0x5c7, 0x5c7}, {0x5f4, 0x5f4}, + {0x600, 0x605}, {0x610, 0x61a}, {0x61c, 0x61c}, {0x640, 0x640}, {0x64b, 0x65f}, {0x670, 0x670}, + {0x6d6, 0x6dd}, {0x6df, 0x6e8}, {0x6ea, 0x6ed}, {0x70f, 0x70f}, {0x711, 0x711}, {0x730, 0x74a}, + {0x7a6, 0x7b0}, {0x7eb, 0x7f5}, {0x7fa, 0x7fa}, {0x7fd, 0x7fd}, {0x816, 0x82d}, {0x859, 0x85b}, + {0x888, 0x888}, {0x890, 0x891}, {0x897, 0x89f}, {0x8c9, 0x902}, {0x93a, 0x93a}, {0x93c, 0x93c}, + {0x941, 0x948}, {0x94d, 0x94d}, {0x951, 0x957}, {0x962, 0x963}, {0x971, 0x971}, {0x981, 0x981}, + {0x9bc, 0x9bc}, {0x9c1, 0x9c4}, {0x9cd, 0x9cd}, {0x9e2, 0x9e3}, {0x9fe, 0x9fe}, {0xa01, 0xa02}, + {0xa3c, 0xa3c}, {0xa41, 0xa42}, {0xa47, 0xa48}, {0xa4b, 0xa4d}, {0xa51, 0xa51}, {0xa70, 0xa71}, + {0xa75, 0xa75}, {0xa81, 0xa82}, {0xabc, 0xabc}, {0xac1, 0xac5}, {0xac7, 0xac8}, {0xacd, 0xacd}, + {0xae2, 0xae3}, {0xafa, 0xaff}, {0xb01, 0xb01}, {0xb3c, 0xb3c}, {0xb3f, 0xb3f}, {0xb41, 0xb44}, + {0xb4d, 0xb4d}, {0xb55, 0xb56}, {0xb62, 0xb63}, {0xb82, 0xb82}, {0xbc0, 0xbc0}, {0xbcd, 0xbcd}, + {0xc00, 0xc00}, {0xc04, 0xc04}, {0xc3c, 0xc3c}, {0xc3e, 0xc40}, {0xc46, 0xc48}, {0xc4a, 0xc4d}, + {0xc55, 0xc56}, {0xc62, 0xc63}, {0xc81, 0xc81}, {0xcbc, 0xcbc}, {0xcbf, 0xcbf}, {0xcc6, 0xcc6}, + {0xccc, 0xccd}, {0xce2, 0xce3}, {0xd00, 0xd01}, {0xd3b, 0xd3c}, {0xd41, 0xd44}, {0xd4d, 0xd4d}, + {0xd62, 0xd63}, {0xd81, 0xd81}, {0xdca, 0xdca}, {0xdd2, 0xdd4}, {0xdd6, 0xdd6}, {0xe31, 0xe31}, + {0xe34, 0xe3a}, {0xe46, 0xe4e}, {0xeb1, 0xeb1}, {0xeb4, 0xebc}, {0xec6, 0xec6}, {0xec8, 0xece}, + {0xf18, 0xf19}, {0xf35, 0xf35}, {0xf37, 0xf37}, {0xf39, 0xf39}, {0xf71, 0xf7e}, {0xf80, 0xf84}, + {0xf86, 0xf87}, {0xf8d, 0xf97}, {0xf99, 0xfbc}, {0xfc6, 0xfc6}, {0x102d, 0x1030}, + {0x1032, 0x1037}, {0x1039, 0x103a}, {0x103d, 0x103e}, {0x1058, 0x1059}, {0x105e, 0x1060}, + {0x1071, 0x1074}, {0x1082, 0x1082}, {0x1085, 0x1086}, {0x108d, 0x108d}, {0x109d, 0x109d}, + {0x10fc, 0x10fc}, {0x135d, 0x135f}, {0x1712, 0x1714}, {0x1732, 0x1733}, {0x1752, 0x1753}, + {0x1772, 0x1773}, {0x17b4, 0x17b5}, {0x17b7, 0x17bd}, {0x17c6, 0x17c6}, {0x17c9, 0x17d3}, + {0x17d7, 0x17d7}, {0x17dd, 0x17dd}, {0x180b, 0x180f}, {0x1843, 0x1843}, {0x1885, 0x1886}, + {0x18a9, 0x18a9}, {0x1920, 0x1922}, {0x1927, 0x1928}, {0x1932, 0x1932}, {0x1939, 0x193b}, + {0x1a17, 0x1a18}, {0x1a1b, 0x1a1b}, {0x1a56, 0x1a56}, {0x1a58, 0x1a5e}, {0x1a60, 0x1a60}, + {0x1a62, 0x1a62}, {0x1a65, 0x1a6c}, {0x1a73, 0x1a7c}, {0x1a7f, 0x1a7f}, {0x1aa7, 0x1aa7}, + {0x1ab0, 0x1add}, {0x1ae0, 0x1aeb}, {0x1b00, 0x1b03}, {0x1b34, 0x1b34}, {0x1b36, 0x1b3a}, + {0x1b3c, 0x1b3c}, {0x1b42, 0x1b42}, {0x1b6b, 0x1b73}, {0x1b80, 0x1b81}, {0x1ba2, 0x1ba5}, + {0x1ba8, 0x1ba9}, {0x1bab, 0x1bad}, {0x1be6, 0x1be6}, {0x1be8, 0x1be9}, {0x1bed, 0x1bed}, + {0x1bef, 0x1bf1}, {0x1c2c, 0x1c33}, {0x1c36, 0x1c37}, {0x1c78, 0x1c7d}, {0x1cd0, 0x1cd2}, + {0x1cd4, 0x1ce0}, {0x1ce2, 0x1ce8}, {0x1ced, 0x1ced}, {0x1cf4, 0x1cf4}, {0x1cf8, 0x1cf9}, + {0x1d2c, 0x1d6a}, {0x1d78, 0x1d78}, {0x1d9b, 0x1dff}, {0x1fbd, 0x1fbd}, {0x1fbf, 0x1fc1}, + {0x1fcd, 0x1fcf}, {0x1fdd, 0x1fdf}, {0x1fed, 0x1fef}, {0x1ffd, 0x1ffe}, {0x200b, 0x200f}, + {0x2018, 0x2019}, {0x2024, 0x2024}, {0x2027, 0x2027}, {0x202a, 0x202e}, {0x2060, 0x2064}, + {0x2066, 0x206f}, {0x2071, 0x2071}, {0x207f, 0x207f}, {0x2090, 0x209c}, {0x20d0, 0x20f0}, + {0x2c7c, 0x2c7d}, {0x2cef, 0x2cf1}, {0x2d6f, 0x2d6f}, {0x2d7f, 0x2d7f}, {0x2de0, 0x2dff}, + {0x2e2f, 0x2e2f}, {0x3005, 0x3005}, {0x302a, 0x302d}, {0x3031, 0x3035}, {0x303b, 0x303b}, + {0x3099, 0x309e}, {0x30fc, 0x30fe}, {0xa015, 0xa015}, {0xa4f8, 0xa4fd}, {0xa60c, 0xa60c}, + {0xa66f, 0xa672}, {0xa674, 0xa67d}, {0xa67f, 0xa67f}, {0xa69c, 0xa69f}, {0xa6f0, 0xa6f1}, + {0xa700, 0xa721}, {0xa770, 0xa770}, {0xa788, 0xa78a}, {0xa7f1, 0xa7f4}, {0xa7f8, 0xa7f9}, + {0xa802, 0xa802}, {0xa806, 0xa806}, {0xa80b, 0xa80b}, {0xa825, 0xa826}, {0xa82c, 0xa82c}, + {0xa8c4, 0xa8c5}, {0xa8e0, 0xa8f1}, {0xa8ff, 0xa8ff}, {0xa926, 0xa92d}, {0xa947, 0xa951}, + {0xa980, 0xa982}, {0xa9b3, 0xa9b3}, {0xa9b6, 0xa9b9}, {0xa9bc, 0xa9bd}, {0xa9cf, 0xa9cf}, + {0xa9e5, 0xa9e6}, {0xaa29, 0xaa2e}, {0xaa31, 0xaa32}, {0xaa35, 0xaa36}, {0xaa43, 0xaa43}, + {0xaa4c, 0xaa4c}, {0xaa70, 0xaa70}, {0xaa7c, 0xaa7c}, {0xaab0, 0xaab0}, {0xaab2, 0xaab4}, + {0xaab7, 0xaab8}, {0xaabe, 0xaabf}, {0xaac1, 0xaac1}, {0xaadd, 0xaadd}, {0xaaec, 0xaaed}, + {0xaaf3, 0xaaf4}, {0xaaf6, 0xaaf6}, {0xab5b, 0xab5f}, {0xab69, 0xab6b}, {0xabe5, 0xabe5}, + {0xabe8, 0xabe8}, {0xabed, 0xabed}, {0xfb1e, 0xfb1e}, {0xfbb2, 0xfbc2}, {0xfe00, 0xfe0f}, + {0xfe13, 0xfe13}, {0xfe20, 0xfe2f}, {0xfe52, 0xfe52}, {0xfe55, 0xfe55}, {0xfeff, 0xfeff}, + {0xff07, 0xff07}, {0xff0e, 0xff0e}, {0xff1a, 0xff1a}, {0xff3e, 0xff3e}, {0xff40, 0xff40}, + {0xff70, 0xff70}, {0xff9e, 0xff9f}, {0xffe3, 0xffe3}, {0xfff9, 0xfffb}, {0x101fd, 0x101fd}, + {0x102e0, 0x102e0}, {0x10376, 0x1037a}, {0x10780, 0x10785}, {0x10787, 0x107b0}, + {0x107b2, 0x107ba}, {0x10a01, 0x10a03}, {0x10a05, 0x10a06}, {0x10a0c, 0x10a0f}, + {0x10a38, 0x10a3a}, {0x10a3f, 0x10a3f}, {0x10ae5, 0x10ae6}, {0x10d24, 0x10d27}, + {0x10d4e, 0x10d4e}, {0x10d69, 0x10d6d}, {0x10d6f, 0x10d6f}, {0x10eab, 0x10eac}, + {0x10ec5, 0x10ec5}, {0x10efa, 0x10eff}, {0x10f46, 0x10f50}, {0x10f82, 0x10f85}, + {0x11001, 0x11001}, {0x11038, 0x11046}, {0x11070, 0x11070}, {0x11073, 0x11074}, + {0x1107f, 0x11081}, {0x110b3, 0x110b6}, {0x110b9, 0x110ba}, {0x110bd, 0x110bd}, + {0x110c2, 0x110c2}, {0x110cd, 0x110cd}, {0x11100, 0x11102}, {0x11127, 0x1112b}, + {0x1112d, 0x11134}, {0x11173, 0x11173}, {0x11180, 0x11181}, {0x111b6, 0x111be}, + {0x111c9, 0x111cc}, {0x111cf, 0x111cf}, {0x1122f, 0x11231}, {0x11234, 0x11234}, + {0x11236, 0x11237}, {0x1123e, 0x1123e}, {0x11241, 0x11241}, {0x112df, 0x112df}, + {0x112e3, 0x112ea}, {0x11300, 0x11301}, {0x1133b, 0x1133c}, {0x11340, 0x11340}, + {0x11366, 0x1136c}, {0x11370, 0x11374}, {0x113bb, 0x113c0}, {0x113ce, 0x113ce}, + {0x113d0, 0x113d0}, {0x113d2, 0x113d2}, {0x113e1, 0x113e2}, {0x11438, 0x1143f}, + {0x11442, 0x11444}, {0x11446, 0x11446}, {0x1145e, 0x1145e}, {0x114b3, 0x114b8}, + {0x114ba, 0x114ba}, {0x114bf, 0x114c0}, {0x114c2, 0x114c3}, {0x115b2, 0x115b5}, + {0x115bc, 0x115bd}, {0x115bf, 0x115c0}, {0x115dc, 0x115dd}, {0x11633, 0x1163a}, + {0x1163d, 0x1163d}, {0x1163f, 0x11640}, {0x116ab, 0x116ab}, {0x116ad, 0x116ad}, + {0x116b0, 0x116b5}, {0x116b7, 0x116b7}, {0x1171d, 0x1171d}, {0x1171f, 0x1171f}, + {0x11722, 0x11725}, {0x11727, 0x1172b}, {0x1182f, 0x11837}, {0x11839, 0x1183a}, + {0x1193b, 0x1193c}, {0x1193e, 0x1193e}, {0x11943, 0x11943}, {0x119d4, 0x119d7}, + {0x119da, 0x119db}, {0x119e0, 0x119e0}, {0x11a01, 0x11a0a}, {0x11a33, 0x11a38}, + {0x11a3b, 0x11a3e}, {0x11a47, 0x11a47}, {0x11a51, 0x11a56}, {0x11a59, 0x11a5b}, + {0x11a8a, 0x11a96}, {0x11a98, 0x11a99}, {0x11b60, 0x11b60}, {0x11b62, 0x11b64}, + {0x11b66, 0x11b66}, {0x11c30, 0x11c36}, {0x11c38, 0x11c3d}, {0x11c3f, 0x11c3f}, + {0x11c92, 0x11ca7}, {0x11caa, 0x11cb0}, {0x11cb2, 0x11cb3}, {0x11cb5, 0x11cb6}, + {0x11d31, 0x11d36}, {0x11d3a, 0x11d3a}, {0x11d3c, 0x11d3d}, {0x11d3f, 0x11d45}, + {0x11d47, 0x11d47}, {0x11d90, 0x11d91}, {0x11d95, 0x11d95}, {0x11d97, 0x11d97}, + {0x11dd9, 0x11dd9}, {0x11ef3, 0x11ef4}, {0x11f00, 0x11f01}, {0x11f36, 0x11f3a}, + {0x11f40, 0x11f40}, {0x11f42, 0x11f42}, {0x11f5a, 0x11f5a}, {0x13430, 0x13440}, + {0x13447, 0x13455}, {0x1611e, 0x16129}, {0x1612d, 0x1612f}, {0x16af0, 0x16af4}, + {0x16b30, 0x16b36}, {0x16b40, 0x16b43}, {0x16d40, 0x16d42}, {0x16d6b, 0x16d6c}, + {0x16f4f, 0x16f4f}, {0x16f8f, 0x16f9f}, {0x16fe0, 0x16fe1}, {0x16fe3, 0x16fe4}, + {0x16ff2, 0x16ff3}, {0x1aff0, 0x1aff3}, {0x1aff5, 0x1affb}, {0x1affd, 0x1affe}, + {0x1bc9d, 0x1bc9e}, {0x1bca0, 0x1bca3}, {0x1cf00, 0x1cf2d}, {0x1cf30, 0x1cf46}, + {0x1d167, 0x1d169}, {0x1d173, 0x1d182}, {0x1d185, 0x1d18b}, {0x1d1aa, 0x1d1ad}, + {0x1d242, 0x1d244}, {0x1da00, 0x1da36}, {0x1da3b, 0x1da6c}, {0x1da75, 0x1da75}, + {0x1da84, 0x1da84}, {0x1da9b, 0x1da9f}, {0x1daa1, 0x1daaf}, {0x1e000, 0x1e006}, + {0x1e008, 0x1e018}, {0x1e01b, 0x1e021}, {0x1e023, 0x1e024}, {0x1e026, 0x1e02a}, + {0x1e030, 0x1e06d}, {0x1e08f, 0x1e08f}, {0x1e130, 0x1e13d}, {0x1e2ae, 0x1e2ae}, + {0x1e2ec, 0x1e2ef}, {0x1e4eb, 0x1e4ef}, {0x1e5ee, 0x1e5ef}, {0x1e6e3, 0x1e6e3}, + {0x1e6e6, 0x1e6e6}, {0x1e6ee, 0x1e6ef}, {0x1e6f5, 0x1e6f5}, {0x1e6ff, 0x1e6ff}, + {0x1e8d0, 0x1e8d6}, {0x1e944, 0x1e94b}, {0x1f3fb, 0x1f3ff}, {0xe0001, 0xe0001}, + {0xe0020, 0xe007f}, {0xe0100, 0xe01ef}, +}; + +TP_PRIVATE const tp_lower_run tp_uni_lower[TP_UNI_LOWER_N] = { + {0x41, 0x5a, 1, 32}, {0xc0, 0xd6, 1, 32}, {0xd8, 0xde, 1, 32}, {0x100, 0x12e, 2, 1}, + {0x132, 0x136, 2, 1}, {0x139, 0x147, 2, 1}, {0x14a, 0x176, 2, 1}, {0x178, 0x178, 1, -121}, + {0x179, 0x17d, 2, 1}, {0x181, 0x181, 1, 210}, {0x182, 0x184, 2, 1}, {0x186, 0x186, 1, 206}, + {0x187, 0x187, 1, 1}, {0x189, 0x18a, 1, 205}, {0x18b, 0x18b, 1, 1}, {0x18e, 0x18e, 1, 79}, + {0x18f, 0x18f, 1, 202}, {0x190, 0x190, 1, 203}, {0x191, 0x191, 1, 1}, {0x193, 0x193, 1, 205}, + {0x194, 0x194, 1, 207}, {0x196, 0x196, 1, 211}, {0x197, 0x197, 1, 209}, {0x198, 0x198, 1, 1}, + {0x19c, 0x19c, 1, 211}, {0x19d, 0x19d, 1, 213}, {0x19f, 0x19f, 1, 214}, {0x1a0, 0x1a4, 2, 1}, + {0x1a6, 0x1a6, 1, 218}, {0x1a7, 0x1a7, 1, 1}, {0x1a9, 0x1a9, 1, 218}, {0x1ac, 0x1ac, 1, 1}, + {0x1ae, 0x1ae, 1, 218}, {0x1af, 0x1af, 1, 1}, {0x1b1, 0x1b2, 1, 217}, {0x1b3, 0x1b5, 2, 1}, + {0x1b7, 0x1b7, 1, 219}, {0x1b8, 0x1b8, 1, 1}, {0x1bc, 0x1bc, 1, 1}, {0x1c4, 0x1c4, 1, 2}, + {0x1c5, 0x1c5, 1, 1}, {0x1c7, 0x1c7, 1, 2}, {0x1c8, 0x1c8, 1, 1}, {0x1ca, 0x1ca, 1, 2}, + {0x1cb, 0x1db, 2, 1}, {0x1de, 0x1ee, 2, 1}, {0x1f1, 0x1f1, 1, 2}, {0x1f2, 0x1f4, 2, 1}, + {0x1f6, 0x1f6, 1, -97}, {0x1f7, 0x1f7, 1, -56}, {0x1f8, 0x21e, 2, 1}, {0x220, 0x220, 1, -130}, + {0x222, 0x232, 2, 1}, {0x23a, 0x23a, 1, 10795}, {0x23b, 0x23b, 1, 1}, {0x23d, 0x23d, 1, -163}, + {0x23e, 0x23e, 1, 10792}, {0x241, 0x241, 1, 1}, {0x243, 0x243, 1, -195}, {0x244, 0x244, 1, 69}, + {0x245, 0x245, 1, 71}, {0x246, 0x24e, 2, 1}, {0x370, 0x372, 2, 1}, {0x376, 0x376, 1, 1}, + {0x37f, 0x37f, 1, 116}, {0x386, 0x386, 1, 38}, {0x388, 0x38a, 1, 37}, {0x38c, 0x38c, 1, 64}, + {0x38e, 0x38f, 1, 63}, {0x391, 0x3a1, 1, 32}, {0x3a3, 0x3ab, 1, 32}, {0x3cf, 0x3cf, 1, 8}, + {0x3d8, 0x3ee, 2, 1}, {0x3f4, 0x3f4, 1, -60}, {0x3f7, 0x3f7, 1, 1}, {0x3f9, 0x3f9, 1, -7}, + {0x3fa, 0x3fa, 1, 1}, {0x3fd, 0x3ff, 1, -130}, {0x400, 0x40f, 1, 80}, {0x410, 0x42f, 1, 32}, + {0x460, 0x480, 2, 1}, {0x48a, 0x4be, 2, 1}, {0x4c0, 0x4c0, 1, 15}, {0x4c1, 0x4cd, 2, 1}, + {0x4d0, 0x52e, 2, 1}, {0x531, 0x556, 1, 48}, {0x10a0, 0x10c5, 1, 7264}, {0x10c7, 0x10c7, 1, 7264}, + {0x10cd, 0x10cd, 1, 7264}, {0x13a0, 0x13ef, 1, 38864}, {0x13f0, 0x13f5, 1, 8}, + {0x1c89, 0x1c89, 1, 1}, {0x1c90, 0x1cba, 1, -3008}, {0x1cbd, 0x1cbf, 1, -3008}, + {0x1e00, 0x1e94, 2, 1}, {0x1e9e, 0x1e9e, 1, -7615}, {0x1ea0, 0x1efe, 2, 1}, + {0x1f08, 0x1f0f, 1, -8}, {0x1f18, 0x1f1d, 1, -8}, {0x1f28, 0x1f2f, 1, -8}, + {0x1f38, 0x1f3f, 1, -8}, {0x1f48, 0x1f4d, 1, -8}, {0x1f59, 0x1f5f, 2, -8}, + {0x1f68, 0x1f6f, 1, -8}, {0x1f88, 0x1f8f, 1, -8}, {0x1f98, 0x1f9f, 1, -8}, + {0x1fa8, 0x1faf, 1, -8}, {0x1fb8, 0x1fb9, 1, -8}, {0x1fba, 0x1fbb, 1, -74}, + {0x1fbc, 0x1fbc, 1, -9}, {0x1fc8, 0x1fcb, 1, -86}, {0x1fcc, 0x1fcc, 1, -9}, + {0x1fd8, 0x1fd9, 1, -8}, {0x1fda, 0x1fdb, 1, -100}, {0x1fe8, 0x1fe9, 1, -8}, + {0x1fea, 0x1feb, 1, -112}, {0x1fec, 0x1fec, 1, -7}, {0x1ff8, 0x1ff9, 1, -128}, + {0x1ffa, 0x1ffb, 1, -126}, {0x1ffc, 0x1ffc, 1, -9}, {0x2126, 0x2126, 1, -7517}, + {0x212a, 0x212a, 1, -8383}, {0x212b, 0x212b, 1, -8262}, {0x2132, 0x2132, 1, 28}, + {0x2160, 0x216f, 1, 16}, {0x2183, 0x2183, 1, 1}, {0x24b6, 0x24cf, 1, 26}, {0x2c00, 0x2c2f, 1, 48}, + {0x2c60, 0x2c60, 1, 1}, {0x2c62, 0x2c62, 1, -10743}, {0x2c63, 0x2c63, 1, -3814}, + {0x2c64, 0x2c64, 1, -10727}, {0x2c67, 0x2c6b, 2, 1}, {0x2c6d, 0x2c6d, 1, -10780}, + {0x2c6e, 0x2c6e, 1, -10749}, {0x2c6f, 0x2c6f, 1, -10783}, {0x2c70, 0x2c70, 1, -10782}, + {0x2c72, 0x2c72, 1, 1}, {0x2c75, 0x2c75, 1, 1}, {0x2c7e, 0x2c7f, 1, -10815}, + {0x2c80, 0x2ce2, 2, 1}, {0x2ceb, 0x2ced, 2, 1}, {0x2cf2, 0x2cf2, 1, 1}, {0xa640, 0xa66c, 2, 1}, + {0xa680, 0xa69a, 2, 1}, {0xa722, 0xa72e, 2, 1}, {0xa732, 0xa76e, 2, 1}, {0xa779, 0xa77b, 2, 1}, + {0xa77d, 0xa77d, 1, -35332}, {0xa77e, 0xa786, 2, 1}, {0xa78b, 0xa78b, 1, 1}, + {0xa78d, 0xa78d, 1, -42280}, {0xa790, 0xa792, 2, 1}, {0xa796, 0xa7a8, 2, 1}, + {0xa7aa, 0xa7aa, 1, -42308}, {0xa7ab, 0xa7ab, 1, -42319}, {0xa7ac, 0xa7ac, 1, -42315}, + {0xa7ad, 0xa7ad, 1, -42305}, {0xa7ae, 0xa7ae, 1, -42308}, {0xa7b0, 0xa7b0, 1, -42258}, + {0xa7b1, 0xa7b1, 1, -42282}, {0xa7b2, 0xa7b2, 1, -42261}, {0xa7b3, 0xa7b3, 1, 928}, + {0xa7b4, 0xa7c2, 2, 1}, {0xa7c4, 0xa7c4, 1, -48}, {0xa7c5, 0xa7c5, 1, -42307}, + {0xa7c6, 0xa7c6, 1, -35384}, {0xa7c7, 0xa7c9, 2, 1}, {0xa7cb, 0xa7cb, 1, -42343}, + {0xa7cc, 0xa7da, 2, 1}, {0xa7dc, 0xa7dc, 1, -42561}, {0xa7f5, 0xa7f5, 1, 1}, + {0xff21, 0xff3a, 1, 32}, {0x10400, 0x10427, 1, 40}, {0x104b0, 0x104d3, 1, 40}, + {0x10570, 0x1057a, 1, 39}, {0x1057c, 0x1058a, 1, 39}, {0x1058c, 0x10592, 1, 39}, + {0x10594, 0x10595, 1, 39}, {0x10c80, 0x10cb2, 1, 64}, {0x10d50, 0x10d65, 1, 32}, + {0x118a0, 0x118bf, 1, 32}, {0x16e40, 0x16e5f, 1, 32}, {0x16ea0, 0x16eb8, 1, 27}, + {0x1e900, 0x1e921, 1, 34}, +}; + +TP_PRIVATE const tp_lower_multi tp_uni_lower_multi[TP_UNI_LOWER_MULTI_N] = { + {0x130, {"i\xcc\x87", 3}}, +}; + +TP_PRIVATE const tp_ccc_range tp_uni_ccc[TP_UNI_CCC_N] = { + {0x300, 0x314, 51}, {0x315, 0x315, 52}, {0x316, 0x319, 46}, {0x31a, 0x31a, 52}, + {0x31b, 0x31b, 44}, {0x31c, 0x320, 46}, {0x321, 0x322, 42}, {0x323, 0x326, 46}, + {0x327, 0x328, 42}, {0x329, 0x333, 46}, {0x334, 0x338, 1}, {0x339, 0x33c, 46}, {0x33d, 0x33f, 51}, + {0x342, 0x342, 51}, {0x345, 0x345, 55}, {0x346, 0x346, 51}, {0x347, 0x349, 46}, + {0x34a, 0x34c, 51}, {0x34d, 0x34e, 46}, {0x350, 0x352, 51}, {0x353, 0x356, 46}, + {0x357, 0x357, 51}, {0x358, 0x358, 52}, {0x359, 0x35a, 46}, {0x35b, 0x35b, 51}, + {0x35c, 0x35c, 53}, {0x35d, 0x35e, 54}, {0x35f, 0x35f, 53}, {0x360, 0x361, 54}, + {0x362, 0x362, 53}, {0x363, 0x36f, 51}, {0x483, 0x487, 51}, {0x591, 0x591, 46}, + {0x592, 0x595, 51}, {0x596, 0x596, 46}, {0x597, 0x599, 51}, {0x59a, 0x59a, 47}, + {0x59b, 0x59b, 46}, {0x59c, 0x5a1, 51}, {0x5a2, 0x5a7, 46}, {0x5a8, 0x5a9, 51}, + {0x5aa, 0x5aa, 46}, {0x5ab, 0x5ac, 51}, {0x5ad, 0x5ad, 47}, {0x5ae, 0x5ae, 50}, + {0x5af, 0x5af, 51}, {0x5b0, 0x5b0, 6}, {0x5b1, 0x5b1, 7}, {0x5b2, 0x5b2, 8}, {0x5b3, 0x5b3, 9}, + {0x5b4, 0x5b4, 10}, {0x5b5, 0x5b5, 11}, {0x5b6, 0x5b6, 12}, {0x5b7, 0x5b7, 13}, + {0x5b8, 0x5b8, 14}, {0x5b9, 0x5ba, 15}, {0x5bb, 0x5bb, 16}, {0x5bc, 0x5bc, 17}, + {0x5bd, 0x5bd, 18}, {0x5bf, 0x5bf, 19}, {0x5c1, 0x5c1, 20}, {0x5c2, 0x5c2, 21}, + {0x5c4, 0x5c4, 51}, {0x5c5, 0x5c5, 46}, {0x5c7, 0x5c7, 14}, {0x610, 0x617, 51}, + {0x618, 0x618, 26}, {0x619, 0x619, 27}, {0x61a, 0x61a, 28}, {0x64b, 0x64b, 23}, + {0x64c, 0x64c, 24}, {0x64d, 0x64d, 25}, {0x64e, 0x64e, 26}, {0x64f, 0x64f, 27}, + {0x650, 0x650, 28}, {0x651, 0x651, 29}, {0x652, 0x652, 30}, {0x653, 0x654, 51}, + {0x655, 0x656, 46}, {0x657, 0x65b, 51}, {0x65c, 0x65c, 46}, {0x65d, 0x65e, 51}, + {0x65f, 0x65f, 46}, {0x670, 0x670, 31}, {0x6d6, 0x6dc, 51}, {0x6df, 0x6e2, 51}, + {0x6e3, 0x6e3, 46}, {0x6e4, 0x6e4, 51}, {0x6e7, 0x6e8, 51}, {0x6ea, 0x6ea, 46}, + {0x6eb, 0x6ec, 51}, {0x6ed, 0x6ed, 46}, {0x711, 0x711, 32}, {0x730, 0x730, 51}, + {0x731, 0x731, 46}, {0x732, 0x733, 51}, {0x734, 0x734, 46}, {0x735, 0x736, 51}, + {0x737, 0x739, 46}, {0x73a, 0x73a, 51}, {0x73b, 0x73c, 46}, {0x73d, 0x73d, 51}, + {0x73e, 0x73e, 46}, {0x73f, 0x741, 51}, {0x742, 0x742, 46}, {0x743, 0x743, 51}, + {0x744, 0x744, 46}, {0x745, 0x745, 51}, {0x746, 0x746, 46}, {0x747, 0x747, 51}, + {0x748, 0x748, 46}, {0x749, 0x74a, 51}, {0x7eb, 0x7f1, 51}, {0x7f2, 0x7f2, 46}, + {0x7f3, 0x7f3, 51}, {0x7fd, 0x7fd, 46}, {0x816, 0x819, 51}, {0x81b, 0x823, 51}, + {0x825, 0x827, 51}, {0x829, 0x82d, 51}, {0x859, 0x85b, 46}, {0x897, 0x898, 51}, + {0x899, 0x89b, 46}, {0x89c, 0x89f, 51}, {0x8ca, 0x8ce, 51}, {0x8cf, 0x8d3, 46}, + {0x8d4, 0x8e1, 51}, {0x8e3, 0x8e3, 46}, {0x8e4, 0x8e5, 51}, {0x8e6, 0x8e6, 46}, + {0x8e7, 0x8e8, 51}, {0x8e9, 0x8e9, 46}, {0x8ea, 0x8ec, 51}, {0x8ed, 0x8ef, 46}, + {0x8f0, 0x8f0, 23}, {0x8f1, 0x8f1, 24}, {0x8f2, 0x8f2, 25}, {0x8f3, 0x8f5, 51}, + {0x8f6, 0x8f6, 46}, {0x8f7, 0x8f8, 51}, {0x8f9, 0x8fa, 46}, {0x8fb, 0x8ff, 51}, {0x93c, 0x93c, 3}, + {0x94d, 0x94d, 5}, {0x951, 0x951, 51}, {0x952, 0x952, 46}, {0x953, 0x954, 51}, {0x9bc, 0x9bc, 3}, + {0x9cd, 0x9cd, 5}, {0x9fe, 0x9fe, 51}, {0xa3c, 0xa3c, 3}, {0xa4d, 0xa4d, 5}, {0xabc, 0xabc, 3}, + {0xacd, 0xacd, 5}, {0xb3c, 0xb3c, 3}, {0xb4d, 0xb4d, 5}, {0xbcd, 0xbcd, 5}, {0xc3c, 0xc3c, 3}, + {0xc4d, 0xc4d, 5}, {0xc55, 0xc55, 33}, {0xc56, 0xc56, 34}, {0xcbc, 0xcbc, 3}, {0xccd, 0xccd, 5}, + {0xd3b, 0xd3c, 5}, {0xd4d, 0xd4d, 5}, {0xdca, 0xdca, 5}, {0xe38, 0xe39, 35}, {0xe3a, 0xe3a, 5}, + {0xe48, 0xe4b, 36}, {0xeb8, 0xeb9, 37}, {0xeba, 0xeba, 5}, {0xec8, 0xecb, 38}, {0xf18, 0xf19, 46}, + {0xf35, 0xf35, 46}, {0xf37, 0xf37, 46}, {0xf39, 0xf39, 44}, {0xf71, 0xf71, 39}, + {0xf72, 0xf72, 40}, {0xf74, 0xf74, 41}, {0xf7a, 0xf7d, 40}, {0xf80, 0xf80, 40}, + {0xf82, 0xf83, 51}, {0xf84, 0xf84, 5}, {0xf86, 0xf87, 51}, {0xfc6, 0xfc6, 46}, + {0x1037, 0x1037, 3}, {0x1039, 0x103a, 5}, {0x108d, 0x108d, 46}, {0x135d, 0x135f, 51}, + {0x1714, 0x1715, 5}, {0x1734, 0x1734, 5}, {0x17d2, 0x17d2, 5}, {0x17dd, 0x17dd, 51}, + {0x18a9, 0x18a9, 50}, {0x1939, 0x1939, 47}, {0x193a, 0x193a, 51}, {0x193b, 0x193b, 46}, + {0x1a17, 0x1a17, 51}, {0x1a18, 0x1a18, 46}, {0x1a60, 0x1a60, 5}, {0x1a75, 0x1a7c, 51}, + {0x1a7f, 0x1a7f, 46}, {0x1ab0, 0x1ab4, 51}, {0x1ab5, 0x1aba, 46}, {0x1abb, 0x1abc, 51}, + {0x1abd, 0x1abd, 46}, {0x1abf, 0x1ac0, 46}, {0x1ac1, 0x1ac2, 51}, {0x1ac3, 0x1ac4, 46}, + {0x1ac5, 0x1ac9, 51}, {0x1aca, 0x1aca, 46}, {0x1acb, 0x1adc, 51}, {0x1add, 0x1add, 46}, + {0x1ae0, 0x1ae5, 51}, {0x1ae6, 0x1ae6, 46}, {0x1ae7, 0x1aea, 51}, {0x1aeb, 0x1aeb, 54}, + {0x1b34, 0x1b34, 3}, {0x1b44, 0x1b44, 5}, {0x1b6b, 0x1b6b, 51}, {0x1b6c, 0x1b6c, 46}, + {0x1b6d, 0x1b73, 51}, {0x1baa, 0x1bab, 5}, {0x1be6, 0x1be6, 3}, {0x1bf2, 0x1bf3, 5}, + {0x1c37, 0x1c37, 3}, {0x1cd0, 0x1cd2, 51}, {0x1cd4, 0x1cd4, 1}, {0x1cd5, 0x1cd9, 46}, + {0x1cda, 0x1cdb, 51}, {0x1cdc, 0x1cdf, 46}, {0x1ce0, 0x1ce0, 51}, {0x1ce2, 0x1ce8, 1}, + {0x1ced, 0x1ced, 46}, {0x1cf4, 0x1cf4, 51}, {0x1cf8, 0x1cf9, 51}, {0x1dc0, 0x1dc1, 51}, + {0x1dc2, 0x1dc2, 46}, {0x1dc3, 0x1dc9, 51}, {0x1dca, 0x1dca, 46}, {0x1dcb, 0x1dcc, 51}, + {0x1dcd, 0x1dcd, 54}, {0x1dce, 0x1dce, 43}, {0x1dcf, 0x1dcf, 46}, {0x1dd0, 0x1dd0, 42}, + {0x1dd1, 0x1df5, 51}, {0x1df6, 0x1df6, 52}, {0x1df7, 0x1df8, 50}, {0x1df9, 0x1df9, 46}, + {0x1dfa, 0x1dfa, 45}, {0x1dfb, 0x1dfb, 51}, {0x1dfc, 0x1dfc, 53}, {0x1dfd, 0x1dfd, 46}, + {0x1dfe, 0x1dfe, 51}, {0x1dff, 0x1dff, 46}, {0x20d0, 0x20d1, 51}, {0x20d2, 0x20d3, 1}, + {0x20d4, 0x20d7, 51}, {0x20d8, 0x20da, 1}, {0x20db, 0x20dc, 51}, {0x20e1, 0x20e1, 51}, + {0x20e5, 0x20e6, 1}, {0x20e7, 0x20e7, 51}, {0x20e8, 0x20e8, 46}, {0x20e9, 0x20e9, 51}, + {0x20ea, 0x20eb, 1}, {0x20ec, 0x20ef, 46}, {0x20f0, 0x20f0, 51}, {0x2cef, 0x2cf1, 51}, + {0x2d7f, 0x2d7f, 5}, {0x2de0, 0x2dff, 51}, {0x302a, 0x302a, 45}, {0x302b, 0x302b, 50}, + {0x302c, 0x302c, 52}, {0x302d, 0x302d, 47}, {0x302e, 0x302f, 48}, {0x3099, 0x309a, 4}, + {0xa66f, 0xa66f, 51}, {0xa674, 0xa67d, 51}, {0xa69e, 0xa69f, 51}, {0xa6f0, 0xa6f1, 51}, + {0xa806, 0xa806, 5}, {0xa82c, 0xa82c, 5}, {0xa8c4, 0xa8c4, 5}, {0xa8e0, 0xa8f1, 51}, + {0xa92b, 0xa92d, 46}, {0xa953, 0xa953, 5}, {0xa9b3, 0xa9b3, 3}, {0xa9c0, 0xa9c0, 5}, + {0xaab0, 0xaab0, 51}, {0xaab2, 0xaab3, 51}, {0xaab4, 0xaab4, 46}, {0xaab7, 0xaab8, 51}, + {0xaabe, 0xaabf, 51}, {0xaac1, 0xaac1, 51}, {0xaaf6, 0xaaf6, 5}, {0xabed, 0xabed, 5}, + {0xfb1e, 0xfb1e, 22}, {0xfe20, 0xfe26, 51}, {0xfe27, 0xfe2d, 46}, {0xfe2e, 0xfe2f, 51}, + {0x101fd, 0x101fd, 46}, {0x102e0, 0x102e0, 46}, {0x10376, 0x1037a, 51}, {0x10a0d, 0x10a0d, 46}, + {0x10a0f, 0x10a0f, 51}, {0x10a38, 0x10a38, 51}, {0x10a39, 0x10a39, 1}, {0x10a3a, 0x10a3a, 46}, + {0x10a3f, 0x10a3f, 5}, {0x10ae5, 0x10ae5, 51}, {0x10ae6, 0x10ae6, 46}, {0x10d24, 0x10d27, 51}, + {0x10d69, 0x10d6d, 51}, {0x10eab, 0x10eac, 51}, {0x10efa, 0x10efb, 46}, {0x10efd, 0x10eff, 46}, + {0x10f46, 0x10f47, 46}, {0x10f48, 0x10f4a, 51}, {0x10f4b, 0x10f4b, 46}, {0x10f4c, 0x10f4c, 51}, + {0x10f4d, 0x10f50, 46}, {0x10f82, 0x10f82, 51}, {0x10f83, 0x10f83, 46}, {0x10f84, 0x10f84, 51}, + {0x10f85, 0x10f85, 46}, {0x11046, 0x11046, 5}, {0x11070, 0x11070, 5}, {0x1107f, 0x1107f, 5}, + {0x110b9, 0x110b9, 5}, {0x110ba, 0x110ba, 3}, {0x11100, 0x11102, 51}, {0x11133, 0x11134, 5}, + {0x11173, 0x11173, 3}, {0x111c0, 0x111c0, 5}, {0x111ca, 0x111ca, 3}, {0x11235, 0x11235, 5}, + {0x11236, 0x11236, 3}, {0x112e9, 0x112e9, 3}, {0x112ea, 0x112ea, 5}, {0x1133b, 0x1133c, 3}, + {0x1134d, 0x1134d, 5}, {0x11366, 0x1136c, 51}, {0x11370, 0x11374, 51}, {0x113ce, 0x113d0, 5}, + {0x11442, 0x11442, 5}, {0x11446, 0x11446, 3}, {0x1145e, 0x1145e, 51}, {0x114c2, 0x114c2, 5}, + {0x114c3, 0x114c3, 3}, {0x115bf, 0x115bf, 5}, {0x115c0, 0x115c0, 3}, {0x1163f, 0x1163f, 5}, + {0x116b6, 0x116b6, 5}, {0x116b7, 0x116b7, 3}, {0x1172b, 0x1172b, 5}, {0x11839, 0x11839, 5}, + {0x1183a, 0x1183a, 3}, {0x1193d, 0x1193e, 5}, {0x11943, 0x11943, 3}, {0x119e0, 0x119e0, 5}, + {0x11a34, 0x11a34, 5}, {0x11a47, 0x11a47, 5}, {0x11a99, 0x11a99, 5}, {0x11c3f, 0x11c3f, 5}, + {0x11d42, 0x11d42, 3}, {0x11d44, 0x11d45, 5}, {0x11d97, 0x11d97, 5}, {0x11f41, 0x11f42, 5}, + {0x1612f, 0x1612f, 5}, {0x16af0, 0x16af4, 1}, {0x16b30, 0x16b36, 51}, {0x16ff0, 0x16ff1, 2}, + {0x1bc9e, 0x1bc9e, 1}, {0x1d165, 0x1d166, 44}, {0x1d167, 0x1d169, 1}, {0x1d16d, 0x1d16d, 49}, + {0x1d16e, 0x1d172, 44}, {0x1d17b, 0x1d182, 46}, {0x1d185, 0x1d189, 51}, {0x1d18a, 0x1d18b, 46}, + {0x1d1aa, 0x1d1ad, 51}, {0x1d242, 0x1d244, 51}, {0x1e000, 0x1e006, 51}, {0x1e008, 0x1e018, 51}, + {0x1e01b, 0x1e021, 51}, {0x1e023, 0x1e024, 51}, {0x1e026, 0x1e02a, 51}, {0x1e08f, 0x1e08f, 51}, + {0x1e130, 0x1e136, 51}, {0x1e2ae, 0x1e2ae, 51}, {0x1e2ec, 0x1e2ef, 51}, {0x1e4ec, 0x1e4ed, 52}, + {0x1e4ee, 0x1e4ee, 46}, {0x1e4ef, 0x1e4ef, 51}, {0x1e5ee, 0x1e5ee, 51}, {0x1e5ef, 0x1e5ef, 46}, + {0x1e6e3, 0x1e6e3, 51}, {0x1e6e6, 0x1e6e6, 51}, {0x1e6ee, 0x1e6ef, 51}, {0x1e6f5, 0x1e6f5, 51}, + {0x1e8d0, 0x1e8d6, 46}, {0x1e944, 0x1e949, 51}, {0x1e94a, 0x1e94a, 3}, +}; + +TP_PRIVATE const tp_decomp_entry tp_uni_decomp[TP_UNI_DECOMP_N] = { + {0xc0, 0, 2}, {0xc1, 2, 2}, {0xc2, 4, 2}, {0xc3, 6, 2}, {0xc4, 8, 2}, + {0xc5, 10, 2}, {0xc7, 12, 2}, {0xc8, 14, 2}, {0xc9, 16, 2}, {0xca, 18, 2}, + {0xcb, 20, 2}, {0xcc, 22, 2}, {0xcd, 24, 2}, {0xce, 26, 2}, {0xcf, 28, 2}, + {0xd1, 30, 2}, {0xd2, 32, 2}, {0xd3, 34, 2}, {0xd4, 36, 2}, {0xd5, 38, 2}, + {0xd6, 40, 2}, {0xd9, 42, 2}, {0xda, 44, 2}, {0xdb, 46, 2}, {0xdc, 48, 2}, + {0xdd, 50, 2}, {0xe0, 52, 2}, {0xe1, 54, 2}, {0xe2, 56, 2}, {0xe3, 58, 2}, + {0xe4, 60, 2}, {0xe5, 62, 2}, {0xe7, 64, 2}, {0xe8, 66, 2}, {0xe9, 68, 2}, + {0xea, 70, 2}, {0xeb, 72, 2}, {0xec, 74, 2}, {0xed, 76, 2}, {0xee, 78, 2}, + {0xef, 80, 2}, {0xf1, 82, 2}, {0xf2, 84, 2}, {0xf3, 86, 2}, {0xf4, 88, 2}, + {0xf5, 90, 2}, {0xf6, 92, 2}, {0xf9, 94, 2}, {0xfa, 96, 2}, {0xfb, 98, 2}, + {0xfc, 100, 2}, {0xfd, 102, 2}, {0xff, 104, 2}, {0x100, 106, 2}, {0x101, 108, 2}, + {0x102, 110, 2}, {0x103, 112, 2}, {0x104, 114, 2}, {0x105, 116, 2}, {0x106, 118, 2}, + {0x107, 120, 2}, {0x108, 122, 2}, {0x109, 124, 2}, {0x10a, 126, 2}, {0x10b, 128, 2}, + {0x10c, 130, 2}, {0x10d, 132, 2}, {0x10e, 134, 2}, {0x10f, 136, 2}, {0x112, 138, 2}, + {0x113, 140, 2}, {0x114, 142, 2}, {0x115, 144, 2}, {0x116, 146, 2}, {0x117, 148, 2}, + {0x118, 150, 2}, {0x119, 152, 2}, {0x11a, 154, 2}, {0x11b, 156, 2}, {0x11c, 158, 2}, + {0x11d, 160, 2}, {0x11e, 162, 2}, {0x11f, 164, 2}, {0x120, 166, 2}, {0x121, 168, 2}, + {0x122, 170, 2}, {0x123, 172, 2}, {0x124, 174, 2}, {0x125, 176, 2}, {0x128, 178, 2}, + {0x129, 180, 2}, {0x12a, 182, 2}, {0x12b, 184, 2}, {0x12c, 186, 2}, {0x12d, 188, 2}, + {0x12e, 190, 2}, {0x12f, 192, 2}, {0x130, 194, 2}, {0x134, 196, 2}, {0x135, 198, 2}, + {0x136, 200, 2}, {0x137, 202, 2}, {0x139, 204, 2}, {0x13a, 206, 2}, {0x13b, 208, 2}, + {0x13c, 210, 2}, {0x13d, 212, 2}, {0x13e, 214, 2}, {0x143, 216, 2}, {0x144, 218, 2}, + {0x145, 220, 2}, {0x146, 222, 2}, {0x147, 224, 2}, {0x148, 226, 2}, {0x14c, 228, 2}, + {0x14d, 230, 2}, {0x14e, 232, 2}, {0x14f, 234, 2}, {0x150, 236, 2}, {0x151, 238, 2}, + {0x154, 240, 2}, {0x155, 242, 2}, {0x156, 244, 2}, {0x157, 246, 2}, {0x158, 248, 2}, + {0x159, 250, 2}, {0x15a, 252, 2}, {0x15b, 254, 2}, {0x15c, 256, 2}, {0x15d, 258, 2}, + {0x15e, 260, 2}, {0x15f, 262, 2}, {0x160, 264, 2}, {0x161, 266, 2}, {0x162, 268, 2}, + {0x163, 270, 2}, {0x164, 272, 2}, {0x165, 274, 2}, {0x168, 276, 2}, {0x169, 278, 2}, + {0x16a, 280, 2}, {0x16b, 282, 2}, {0x16c, 284, 2}, {0x16d, 286, 2}, {0x16e, 288, 2}, + {0x16f, 290, 2}, {0x170, 292, 2}, {0x171, 294, 2}, {0x172, 296, 2}, {0x173, 298, 2}, + {0x174, 300, 2}, {0x175, 302, 2}, {0x176, 304, 2}, {0x177, 306, 2}, {0x178, 308, 2}, + {0x179, 310, 2}, {0x17a, 312, 2}, {0x17b, 314, 2}, {0x17c, 316, 2}, {0x17d, 318, 2}, + {0x17e, 320, 2}, {0x1a0, 322, 2}, {0x1a1, 324, 2}, {0x1af, 326, 2}, {0x1b0, 328, 2}, + {0x1cd, 330, 2}, {0x1ce, 332, 2}, {0x1cf, 334, 2}, {0x1d0, 336, 2}, {0x1d1, 338, 2}, + {0x1d2, 340, 2}, {0x1d3, 342, 2}, {0x1d4, 344, 2}, {0x1d5, 346, 3}, {0x1d6, 349, 3}, + {0x1d7, 352, 3}, {0x1d8, 355, 3}, {0x1d9, 358, 3}, {0x1da, 361, 3}, {0x1db, 364, 3}, + {0x1dc, 367, 3}, {0x1de, 370, 3}, {0x1df, 373, 3}, {0x1e0, 376, 3}, {0x1e1, 379, 3}, + {0x1e2, 382, 2}, {0x1e3, 384, 2}, {0x1e6, 386, 2}, {0x1e7, 388, 2}, {0x1e8, 390, 2}, + {0x1e9, 392, 2}, {0x1ea, 394, 2}, {0x1eb, 396, 2}, {0x1ec, 398, 3}, {0x1ed, 401, 3}, + {0x1ee, 404, 2}, {0x1ef, 406, 2}, {0x1f0, 408, 2}, {0x1f4, 410, 2}, {0x1f5, 412, 2}, + {0x1f8, 414, 2}, {0x1f9, 416, 2}, {0x1fa, 418, 3}, {0x1fb, 421, 3}, {0x1fc, 424, 2}, + {0x1fd, 426, 2}, {0x1fe, 428, 2}, {0x1ff, 430, 2}, {0x200, 432, 2}, {0x201, 434, 2}, + {0x202, 436, 2}, {0x203, 438, 2}, {0x204, 440, 2}, {0x205, 442, 2}, {0x206, 444, 2}, + {0x207, 446, 2}, {0x208, 448, 2}, {0x209, 450, 2}, {0x20a, 452, 2}, {0x20b, 454, 2}, + {0x20c, 456, 2}, {0x20d, 458, 2}, {0x20e, 460, 2}, {0x20f, 462, 2}, {0x210, 464, 2}, + {0x211, 466, 2}, {0x212, 468, 2}, {0x213, 470, 2}, {0x214, 472, 2}, {0x215, 474, 2}, + {0x216, 476, 2}, {0x217, 478, 2}, {0x218, 480, 2}, {0x219, 482, 2}, {0x21a, 484, 2}, + {0x21b, 486, 2}, {0x21e, 488, 2}, {0x21f, 490, 2}, {0x226, 492, 2}, {0x227, 494, 2}, + {0x228, 496, 2}, {0x229, 498, 2}, {0x22a, 500, 3}, {0x22b, 503, 3}, {0x22c, 506, 3}, + {0x22d, 509, 3}, {0x22e, 512, 2}, {0x22f, 514, 2}, {0x230, 516, 3}, {0x231, 519, 3}, + {0x232, 522, 2}, {0x233, 524, 2}, {0x340, 526, 1}, {0x341, 527, 1}, {0x343, 528, 1}, + {0x344, 529, 2}, {0x374, 531, 1}, {0x37e, 532, 1}, {0x385, 533, 2}, {0x386, 535, 2}, + {0x387, 537, 1}, {0x388, 538, 2}, {0x389, 540, 2}, {0x38a, 542, 2}, {0x38c, 544, 2}, + {0x38e, 546, 2}, {0x38f, 548, 2}, {0x390, 550, 3}, {0x3aa, 553, 2}, {0x3ab, 555, 2}, + {0x3ac, 557, 2}, {0x3ad, 559, 2}, {0x3ae, 561, 2}, {0x3af, 563, 2}, {0x3b0, 565, 3}, + {0x3ca, 568, 2}, {0x3cb, 570, 2}, {0x3cc, 572, 2}, {0x3cd, 574, 2}, {0x3ce, 576, 2}, + {0x3d3, 578, 2}, {0x3d4, 580, 2}, {0x400, 582, 2}, {0x401, 584, 2}, {0x403, 586, 2}, + {0x407, 588, 2}, {0x40c, 590, 2}, {0x40d, 592, 2}, {0x40e, 594, 2}, {0x419, 596, 2}, + {0x439, 598, 2}, {0x450, 600, 2}, {0x451, 602, 2}, {0x453, 604, 2}, {0x457, 606, 2}, + {0x45c, 608, 2}, {0x45d, 610, 2}, {0x45e, 612, 2}, {0x476, 614, 2}, {0x477, 616, 2}, + {0x4c1, 618, 2}, {0x4c2, 620, 2}, {0x4d0, 622, 2}, {0x4d1, 624, 2}, {0x4d2, 626, 2}, + {0x4d3, 628, 2}, {0x4d6, 630, 2}, {0x4d7, 632, 2}, {0x4da, 634, 2}, {0x4db, 636, 2}, + {0x4dc, 638, 2}, {0x4dd, 640, 2}, {0x4de, 642, 2}, {0x4df, 644, 2}, {0x4e2, 646, 2}, + {0x4e3, 648, 2}, {0x4e4, 650, 2}, {0x4e5, 652, 2}, {0x4e6, 654, 2}, {0x4e7, 656, 2}, + {0x4ea, 658, 2}, {0x4eb, 660, 2}, {0x4ec, 662, 2}, {0x4ed, 664, 2}, {0x4ee, 666, 2}, + {0x4ef, 668, 2}, {0x4f0, 670, 2}, {0x4f1, 672, 2}, {0x4f2, 674, 2}, {0x4f3, 676, 2}, + {0x4f4, 678, 2}, {0x4f5, 680, 2}, {0x4f8, 682, 2}, {0x4f9, 684, 2}, {0x622, 686, 2}, + {0x623, 688, 2}, {0x624, 690, 2}, {0x625, 692, 2}, {0x626, 694, 2}, {0x6c0, 696, 2}, + {0x6c2, 698, 2}, {0x6d3, 700, 2}, {0x929, 702, 2}, {0x931, 704, 2}, {0x934, 706, 2}, + {0x958, 708, 2}, {0x959, 710, 2}, {0x95a, 712, 2}, {0x95b, 714, 2}, {0x95c, 716, 2}, + {0x95d, 718, 2}, {0x95e, 720, 2}, {0x95f, 722, 2}, {0x9cb, 724, 2}, {0x9cc, 726, 2}, + {0x9dc, 728, 2}, {0x9dd, 730, 2}, {0x9df, 732, 2}, {0xa33, 734, 2}, {0xa36, 736, 2}, + {0xa59, 738, 2}, {0xa5a, 740, 2}, {0xa5b, 742, 2}, {0xa5e, 744, 2}, {0xb48, 746, 2}, + {0xb4b, 748, 2}, {0xb4c, 750, 2}, {0xb5c, 752, 2}, {0xb5d, 754, 2}, {0xb94, 756, 2}, + {0xbca, 758, 2}, {0xbcb, 760, 2}, {0xbcc, 762, 2}, {0xc48, 764, 2}, {0xcc0, 766, 2}, + {0xcc7, 768, 2}, {0xcc8, 770, 2}, {0xcca, 772, 2}, {0xccb, 774, 3}, {0xd4a, 777, 2}, + {0xd4b, 779, 2}, {0xd4c, 781, 2}, {0xdda, 783, 2}, {0xddc, 785, 2}, {0xddd, 787, 3}, + {0xdde, 790, 2}, {0xf43, 792, 2}, {0xf4d, 794, 2}, {0xf52, 796, 2}, {0xf57, 798, 2}, + {0xf5c, 800, 2}, {0xf69, 802, 2}, {0xf73, 804, 2}, {0xf75, 806, 2}, {0xf76, 808, 2}, + {0xf78, 810, 2}, {0xf81, 812, 2}, {0xf93, 814, 2}, {0xf9d, 816, 2}, {0xfa2, 818, 2}, + {0xfa7, 820, 2}, {0xfac, 822, 2}, {0xfb9, 824, 2}, {0x1026, 826, 2}, {0x1b06, 828, 2}, + {0x1b08, 830, 2}, {0x1b0a, 832, 2}, {0x1b0c, 834, 2}, {0x1b0e, 836, 2}, {0x1b12, 838, 2}, + {0x1b3b, 840, 2}, {0x1b3d, 842, 2}, {0x1b40, 844, 2}, {0x1b41, 846, 2}, {0x1b43, 848, 2}, + {0x1e00, 850, 2}, {0x1e01, 852, 2}, {0x1e02, 854, 2}, {0x1e03, 856, 2}, {0x1e04, 858, 2}, + {0x1e05, 860, 2}, {0x1e06, 862, 2}, {0x1e07, 864, 2}, {0x1e08, 866, 3}, {0x1e09, 869, 3}, + {0x1e0a, 872, 2}, {0x1e0b, 874, 2}, {0x1e0c, 876, 2}, {0x1e0d, 878, 2}, {0x1e0e, 880, 2}, + {0x1e0f, 882, 2}, {0x1e10, 884, 2}, {0x1e11, 886, 2}, {0x1e12, 888, 2}, {0x1e13, 890, 2}, + {0x1e14, 892, 3}, {0x1e15, 895, 3}, {0x1e16, 898, 3}, {0x1e17, 901, 3}, {0x1e18, 904, 2}, + {0x1e19, 906, 2}, {0x1e1a, 908, 2}, {0x1e1b, 910, 2}, {0x1e1c, 912, 3}, {0x1e1d, 915, 3}, + {0x1e1e, 918, 2}, {0x1e1f, 920, 2}, {0x1e20, 922, 2}, {0x1e21, 924, 2}, {0x1e22, 926, 2}, + {0x1e23, 928, 2}, {0x1e24, 930, 2}, {0x1e25, 932, 2}, {0x1e26, 934, 2}, {0x1e27, 936, 2}, + {0x1e28, 938, 2}, {0x1e29, 940, 2}, {0x1e2a, 942, 2}, {0x1e2b, 944, 2}, {0x1e2c, 946, 2}, + {0x1e2d, 948, 2}, {0x1e2e, 950, 3}, {0x1e2f, 953, 3}, {0x1e30, 956, 2}, {0x1e31, 958, 2}, + {0x1e32, 960, 2}, {0x1e33, 962, 2}, {0x1e34, 964, 2}, {0x1e35, 966, 2}, {0x1e36, 968, 2}, + {0x1e37, 970, 2}, {0x1e38, 972, 3}, {0x1e39, 975, 3}, {0x1e3a, 978, 2}, {0x1e3b, 980, 2}, + {0x1e3c, 982, 2}, {0x1e3d, 984, 2}, {0x1e3e, 986, 2}, {0x1e3f, 988, 2}, {0x1e40, 990, 2}, + {0x1e41, 992, 2}, {0x1e42, 994, 2}, {0x1e43, 996, 2}, {0x1e44, 998, 2}, {0x1e45, 1000, 2}, + {0x1e46, 1002, 2}, {0x1e47, 1004, 2}, {0x1e48, 1006, 2}, {0x1e49, 1008, 2}, {0x1e4a, 1010, 2}, + {0x1e4b, 1012, 2}, {0x1e4c, 1014, 3}, {0x1e4d, 1017, 3}, {0x1e4e, 1020, 3}, {0x1e4f, 1023, 3}, + {0x1e50, 1026, 3}, {0x1e51, 1029, 3}, {0x1e52, 1032, 3}, {0x1e53, 1035, 3}, {0x1e54, 1038, 2}, + {0x1e55, 1040, 2}, {0x1e56, 1042, 2}, {0x1e57, 1044, 2}, {0x1e58, 1046, 2}, {0x1e59, 1048, 2}, + {0x1e5a, 1050, 2}, {0x1e5b, 1052, 2}, {0x1e5c, 1054, 3}, {0x1e5d, 1057, 3}, {0x1e5e, 1060, 2}, + {0x1e5f, 1062, 2}, {0x1e60, 1064, 2}, {0x1e61, 1066, 2}, {0x1e62, 1068, 2}, {0x1e63, 1070, 2}, + {0x1e64, 1072, 3}, {0x1e65, 1075, 3}, {0x1e66, 1078, 3}, {0x1e67, 1081, 3}, {0x1e68, 1084, 3}, + {0x1e69, 1087, 3}, {0x1e6a, 1090, 2}, {0x1e6b, 1092, 2}, {0x1e6c, 1094, 2}, {0x1e6d, 1096, 2}, + {0x1e6e, 1098, 2}, {0x1e6f, 1100, 2}, {0x1e70, 1102, 2}, {0x1e71, 1104, 2}, {0x1e72, 1106, 2}, + {0x1e73, 1108, 2}, {0x1e74, 1110, 2}, {0x1e75, 1112, 2}, {0x1e76, 1114, 2}, {0x1e77, 1116, 2}, + {0x1e78, 1118, 3}, {0x1e79, 1121, 3}, {0x1e7a, 1124, 3}, {0x1e7b, 1127, 3}, {0x1e7c, 1130, 2}, + {0x1e7d, 1132, 2}, {0x1e7e, 1134, 2}, {0x1e7f, 1136, 2}, {0x1e80, 1138, 2}, {0x1e81, 1140, 2}, + {0x1e82, 1142, 2}, {0x1e83, 1144, 2}, {0x1e84, 1146, 2}, {0x1e85, 1148, 2}, {0x1e86, 1150, 2}, + {0x1e87, 1152, 2}, {0x1e88, 1154, 2}, {0x1e89, 1156, 2}, {0x1e8a, 1158, 2}, {0x1e8b, 1160, 2}, + {0x1e8c, 1162, 2}, {0x1e8d, 1164, 2}, {0x1e8e, 1166, 2}, {0x1e8f, 1168, 2}, {0x1e90, 1170, 2}, + {0x1e91, 1172, 2}, {0x1e92, 1174, 2}, {0x1e93, 1176, 2}, {0x1e94, 1178, 2}, {0x1e95, 1180, 2}, + {0x1e96, 1182, 2}, {0x1e97, 1184, 2}, {0x1e98, 1186, 2}, {0x1e99, 1188, 2}, {0x1e9b, 1190, 2}, + {0x1ea0, 1192, 2}, {0x1ea1, 1194, 2}, {0x1ea2, 1196, 2}, {0x1ea3, 1198, 2}, {0x1ea4, 1200, 3}, + {0x1ea5, 1203, 3}, {0x1ea6, 1206, 3}, {0x1ea7, 1209, 3}, {0x1ea8, 1212, 3}, {0x1ea9, 1215, 3}, + {0x1eaa, 1218, 3}, {0x1eab, 1221, 3}, {0x1eac, 1224, 3}, {0x1ead, 1227, 3}, {0x1eae, 1230, 3}, + {0x1eaf, 1233, 3}, {0x1eb0, 1236, 3}, {0x1eb1, 1239, 3}, {0x1eb2, 1242, 3}, {0x1eb3, 1245, 3}, + {0x1eb4, 1248, 3}, {0x1eb5, 1251, 3}, {0x1eb6, 1254, 3}, {0x1eb7, 1257, 3}, {0x1eb8, 1260, 2}, + {0x1eb9, 1262, 2}, {0x1eba, 1264, 2}, {0x1ebb, 1266, 2}, {0x1ebc, 1268, 2}, {0x1ebd, 1270, 2}, + {0x1ebe, 1272, 3}, {0x1ebf, 1275, 3}, {0x1ec0, 1278, 3}, {0x1ec1, 1281, 3}, {0x1ec2, 1284, 3}, + {0x1ec3, 1287, 3}, {0x1ec4, 1290, 3}, {0x1ec5, 1293, 3}, {0x1ec6, 1296, 3}, {0x1ec7, 1299, 3}, + {0x1ec8, 1302, 2}, {0x1ec9, 1304, 2}, {0x1eca, 1306, 2}, {0x1ecb, 1308, 2}, {0x1ecc, 1310, 2}, + {0x1ecd, 1312, 2}, {0x1ece, 1314, 2}, {0x1ecf, 1316, 2}, {0x1ed0, 1318, 3}, {0x1ed1, 1321, 3}, + {0x1ed2, 1324, 3}, {0x1ed3, 1327, 3}, {0x1ed4, 1330, 3}, {0x1ed5, 1333, 3}, {0x1ed6, 1336, 3}, + {0x1ed7, 1339, 3}, {0x1ed8, 1342, 3}, {0x1ed9, 1345, 3}, {0x1eda, 1348, 3}, {0x1edb, 1351, 3}, + {0x1edc, 1354, 3}, {0x1edd, 1357, 3}, {0x1ede, 1360, 3}, {0x1edf, 1363, 3}, {0x1ee0, 1366, 3}, + {0x1ee1, 1369, 3}, {0x1ee2, 1372, 3}, {0x1ee3, 1375, 3}, {0x1ee4, 1378, 2}, {0x1ee5, 1380, 2}, + {0x1ee6, 1382, 2}, {0x1ee7, 1384, 2}, {0x1ee8, 1386, 3}, {0x1ee9, 1389, 3}, {0x1eea, 1392, 3}, + {0x1eeb, 1395, 3}, {0x1eec, 1398, 3}, {0x1eed, 1401, 3}, {0x1eee, 1404, 3}, {0x1eef, 1407, 3}, + {0x1ef0, 1410, 3}, {0x1ef1, 1413, 3}, {0x1ef2, 1416, 2}, {0x1ef3, 1418, 2}, {0x1ef4, 1420, 2}, + {0x1ef5, 1422, 2}, {0x1ef6, 1424, 2}, {0x1ef7, 1426, 2}, {0x1ef8, 1428, 2}, {0x1ef9, 1430, 2}, + {0x1f00, 1432, 2}, {0x1f01, 1434, 2}, {0x1f02, 1436, 3}, {0x1f03, 1439, 3}, {0x1f04, 1442, 3}, + {0x1f05, 1445, 3}, {0x1f06, 1448, 3}, {0x1f07, 1451, 3}, {0x1f08, 1454, 2}, {0x1f09, 1456, 2}, + {0x1f0a, 1458, 3}, {0x1f0b, 1461, 3}, {0x1f0c, 1464, 3}, {0x1f0d, 1467, 3}, {0x1f0e, 1470, 3}, + {0x1f0f, 1473, 3}, {0x1f10, 1476, 2}, {0x1f11, 1478, 2}, {0x1f12, 1480, 3}, {0x1f13, 1483, 3}, + {0x1f14, 1486, 3}, {0x1f15, 1489, 3}, {0x1f18, 1492, 2}, {0x1f19, 1494, 2}, {0x1f1a, 1496, 3}, + {0x1f1b, 1499, 3}, {0x1f1c, 1502, 3}, {0x1f1d, 1505, 3}, {0x1f20, 1508, 2}, {0x1f21, 1510, 2}, + {0x1f22, 1512, 3}, {0x1f23, 1515, 3}, {0x1f24, 1518, 3}, {0x1f25, 1521, 3}, {0x1f26, 1524, 3}, + {0x1f27, 1527, 3}, {0x1f28, 1530, 2}, {0x1f29, 1532, 2}, {0x1f2a, 1534, 3}, {0x1f2b, 1537, 3}, + {0x1f2c, 1540, 3}, {0x1f2d, 1543, 3}, {0x1f2e, 1546, 3}, {0x1f2f, 1549, 3}, {0x1f30, 1552, 2}, + {0x1f31, 1554, 2}, {0x1f32, 1556, 3}, {0x1f33, 1559, 3}, {0x1f34, 1562, 3}, {0x1f35, 1565, 3}, + {0x1f36, 1568, 3}, {0x1f37, 1571, 3}, {0x1f38, 1574, 2}, {0x1f39, 1576, 2}, {0x1f3a, 1578, 3}, + {0x1f3b, 1581, 3}, {0x1f3c, 1584, 3}, {0x1f3d, 1587, 3}, {0x1f3e, 1590, 3}, {0x1f3f, 1593, 3}, + {0x1f40, 1596, 2}, {0x1f41, 1598, 2}, {0x1f42, 1600, 3}, {0x1f43, 1603, 3}, {0x1f44, 1606, 3}, + {0x1f45, 1609, 3}, {0x1f48, 1612, 2}, {0x1f49, 1614, 2}, {0x1f4a, 1616, 3}, {0x1f4b, 1619, 3}, + {0x1f4c, 1622, 3}, {0x1f4d, 1625, 3}, {0x1f50, 1628, 2}, {0x1f51, 1630, 2}, {0x1f52, 1632, 3}, + {0x1f53, 1635, 3}, {0x1f54, 1638, 3}, {0x1f55, 1641, 3}, {0x1f56, 1644, 3}, {0x1f57, 1647, 3}, + {0x1f59, 1650, 2}, {0x1f5b, 1652, 3}, {0x1f5d, 1655, 3}, {0x1f5f, 1658, 3}, {0x1f60, 1661, 2}, + {0x1f61, 1663, 2}, {0x1f62, 1665, 3}, {0x1f63, 1668, 3}, {0x1f64, 1671, 3}, {0x1f65, 1674, 3}, + {0x1f66, 1677, 3}, {0x1f67, 1680, 3}, {0x1f68, 1683, 2}, {0x1f69, 1685, 2}, {0x1f6a, 1687, 3}, + {0x1f6b, 1690, 3}, {0x1f6c, 1693, 3}, {0x1f6d, 1696, 3}, {0x1f6e, 1699, 3}, {0x1f6f, 1702, 3}, + {0x1f70, 1705, 2}, {0x1f71, 1707, 2}, {0x1f72, 1709, 2}, {0x1f73, 1711, 2}, {0x1f74, 1713, 2}, + {0x1f75, 1715, 2}, {0x1f76, 1717, 2}, {0x1f77, 1719, 2}, {0x1f78, 1721, 2}, {0x1f79, 1723, 2}, + {0x1f7a, 1725, 2}, {0x1f7b, 1727, 2}, {0x1f7c, 1729, 2}, {0x1f7d, 1731, 2}, {0x1f80, 1733, 3}, + {0x1f81, 1736, 3}, {0x1f82, 1739, 4}, {0x1f83, 1743, 4}, {0x1f84, 1747, 4}, {0x1f85, 1751, 4}, + {0x1f86, 1755, 4}, {0x1f87, 1759, 4}, {0x1f88, 1763, 3}, {0x1f89, 1766, 3}, {0x1f8a, 1769, 4}, + {0x1f8b, 1773, 4}, {0x1f8c, 1777, 4}, {0x1f8d, 1781, 4}, {0x1f8e, 1785, 4}, {0x1f8f, 1789, 4}, + {0x1f90, 1793, 3}, {0x1f91, 1796, 3}, {0x1f92, 1799, 4}, {0x1f93, 1803, 4}, {0x1f94, 1807, 4}, + {0x1f95, 1811, 4}, {0x1f96, 1815, 4}, {0x1f97, 1819, 4}, {0x1f98, 1823, 3}, {0x1f99, 1826, 3}, + {0x1f9a, 1829, 4}, {0x1f9b, 1833, 4}, {0x1f9c, 1837, 4}, {0x1f9d, 1841, 4}, {0x1f9e, 1845, 4}, + {0x1f9f, 1849, 4}, {0x1fa0, 1853, 3}, {0x1fa1, 1856, 3}, {0x1fa2, 1859, 4}, {0x1fa3, 1863, 4}, + {0x1fa4, 1867, 4}, {0x1fa5, 1871, 4}, {0x1fa6, 1875, 4}, {0x1fa7, 1879, 4}, {0x1fa8, 1883, 3}, + {0x1fa9, 1886, 3}, {0x1faa, 1889, 4}, {0x1fab, 1893, 4}, {0x1fac, 1897, 4}, {0x1fad, 1901, 4}, + {0x1fae, 1905, 4}, {0x1faf, 1909, 4}, {0x1fb0, 1913, 2}, {0x1fb1, 1915, 2}, {0x1fb2, 1917, 3}, + {0x1fb3, 1920, 2}, {0x1fb4, 1922, 3}, {0x1fb6, 1925, 2}, {0x1fb7, 1927, 3}, {0x1fb8, 1930, 2}, + {0x1fb9, 1932, 2}, {0x1fba, 1934, 2}, {0x1fbb, 1936, 2}, {0x1fbc, 1938, 2}, {0x1fbe, 1940, 1}, + {0x1fc1, 1941, 2}, {0x1fc2, 1943, 3}, {0x1fc3, 1946, 2}, {0x1fc4, 1948, 3}, {0x1fc6, 1951, 2}, + {0x1fc7, 1953, 3}, {0x1fc8, 1956, 2}, {0x1fc9, 1958, 2}, {0x1fca, 1960, 2}, {0x1fcb, 1962, 2}, + {0x1fcc, 1964, 2}, {0x1fcd, 1966, 2}, {0x1fce, 1968, 2}, {0x1fcf, 1970, 2}, {0x1fd0, 1972, 2}, + {0x1fd1, 1974, 2}, {0x1fd2, 1976, 3}, {0x1fd3, 1979, 3}, {0x1fd6, 1982, 2}, {0x1fd7, 1984, 3}, + {0x1fd8, 1987, 2}, {0x1fd9, 1989, 2}, {0x1fda, 1991, 2}, {0x1fdb, 1993, 2}, {0x1fdd, 1995, 2}, + {0x1fde, 1997, 2}, {0x1fdf, 1999, 2}, {0x1fe0, 2001, 2}, {0x1fe1, 2003, 2}, {0x1fe2, 2005, 3}, + {0x1fe3, 2008, 3}, {0x1fe4, 2011, 2}, {0x1fe5, 2013, 2}, {0x1fe6, 2015, 2}, {0x1fe7, 2017, 3}, + {0x1fe8, 2020, 2}, {0x1fe9, 2022, 2}, {0x1fea, 2024, 2}, {0x1feb, 2026, 2}, {0x1fec, 2028, 2}, + {0x1fed, 2030, 2}, {0x1fee, 2032, 2}, {0x1fef, 2034, 1}, {0x1ff2, 2035, 3}, {0x1ff3, 2038, 2}, + {0x1ff4, 2040, 3}, {0x1ff6, 2043, 2}, {0x1ff7, 2045, 3}, {0x1ff8, 2048, 2}, {0x1ff9, 2050, 2}, + {0x1ffa, 2052, 2}, {0x1ffb, 2054, 2}, {0x1ffc, 2056, 2}, {0x1ffd, 2058, 1}, {0x2000, 2059, 1}, + {0x2001, 2060, 1}, {0x2126, 2061, 1}, {0x212a, 2062, 1}, {0x212b, 2063, 2}, {0x219a, 2065, 2}, + {0x219b, 2067, 2}, {0x21ae, 2069, 2}, {0x21cd, 2071, 2}, {0x21ce, 2073, 2}, {0x21cf, 2075, 2}, + {0x2204, 2077, 2}, {0x2209, 2079, 2}, {0x220c, 2081, 2}, {0x2224, 2083, 2}, {0x2226, 2085, 2}, + {0x2241, 2087, 2}, {0x2244, 2089, 2}, {0x2247, 2091, 2}, {0x2249, 2093, 2}, {0x2260, 2095, 2}, + {0x2262, 2097, 2}, {0x226d, 2099, 2}, {0x226e, 2101, 2}, {0x226f, 2103, 2}, {0x2270, 2105, 2}, + {0x2271, 2107, 2}, {0x2274, 2109, 2}, {0x2275, 2111, 2}, {0x2278, 2113, 2}, {0x2279, 2115, 2}, + {0x2280, 2117, 2}, {0x2281, 2119, 2}, {0x2284, 2121, 2}, {0x2285, 2123, 2}, {0x2288, 2125, 2}, + {0x2289, 2127, 2}, {0x22ac, 2129, 2}, {0x22ad, 2131, 2}, {0x22ae, 2133, 2}, {0x22af, 2135, 2}, + {0x22e0, 2137, 2}, {0x22e1, 2139, 2}, {0x22e2, 2141, 2}, {0x22e3, 2143, 2}, {0x22ea, 2145, 2}, + {0x22eb, 2147, 2}, {0x22ec, 2149, 2}, {0x22ed, 2151, 2}, {0x2329, 2153, 1}, {0x232a, 2154, 1}, + {0x2adc, 2155, 2}, {0x304c, 2157, 2}, {0x304e, 2159, 2}, {0x3050, 2161, 2}, {0x3052, 2163, 2}, + {0x3054, 2165, 2}, {0x3056, 2167, 2}, {0x3058, 2169, 2}, {0x305a, 2171, 2}, {0x305c, 2173, 2}, + {0x305e, 2175, 2}, {0x3060, 2177, 2}, {0x3062, 2179, 2}, {0x3065, 2181, 2}, {0x3067, 2183, 2}, + {0x3069, 2185, 2}, {0x3070, 2187, 2}, {0x3071, 2189, 2}, {0x3073, 2191, 2}, {0x3074, 2193, 2}, + {0x3076, 2195, 2}, {0x3077, 2197, 2}, {0x3079, 2199, 2}, {0x307a, 2201, 2}, {0x307c, 2203, 2}, + {0x307d, 2205, 2}, {0x3094, 2207, 2}, {0x309e, 2209, 2}, {0x30ac, 2211, 2}, {0x30ae, 2213, 2}, + {0x30b0, 2215, 2}, {0x30b2, 2217, 2}, {0x30b4, 2219, 2}, {0x30b6, 2221, 2}, {0x30b8, 2223, 2}, + {0x30ba, 2225, 2}, {0x30bc, 2227, 2}, {0x30be, 2229, 2}, {0x30c0, 2231, 2}, {0x30c2, 2233, 2}, + {0x30c5, 2235, 2}, {0x30c7, 2237, 2}, {0x30c9, 2239, 2}, {0x30d0, 2241, 2}, {0x30d1, 2243, 2}, + {0x30d3, 2245, 2}, {0x30d4, 2247, 2}, {0x30d6, 2249, 2}, {0x30d7, 2251, 2}, {0x30d9, 2253, 2}, + {0x30da, 2255, 2}, {0x30dc, 2257, 2}, {0x30dd, 2259, 2}, {0x30f4, 2261, 2}, {0x30f7, 2263, 2}, + {0x30f8, 2265, 2}, {0x30f9, 2267, 2}, {0x30fa, 2269, 2}, {0x30fe, 2271, 2}, {0xf900, 2273, 1}, + {0xf901, 2274, 1}, {0xf902, 2275, 1}, {0xf903, 2276, 1}, {0xf904, 2277, 1}, {0xf905, 2278, 1}, + {0xf906, 2279, 1}, {0xf907, 2280, 1}, {0xf908, 2281, 1}, {0xf909, 2282, 1}, {0xf90a, 2283, 1}, + {0xf90b, 2284, 1}, {0xf90c, 2285, 1}, {0xf90d, 2286, 1}, {0xf90e, 2287, 1}, {0xf90f, 2288, 1}, + {0xf910, 2289, 1}, {0xf911, 2290, 1}, {0xf912, 2291, 1}, {0xf913, 2292, 1}, {0xf914, 2293, 1}, + {0xf915, 2294, 1}, {0xf916, 2295, 1}, {0xf917, 2296, 1}, {0xf918, 2297, 1}, {0xf919, 2298, 1}, + {0xf91a, 2299, 1}, {0xf91b, 2300, 1}, {0xf91c, 2301, 1}, {0xf91d, 2302, 1}, {0xf91e, 2303, 1}, + {0xf91f, 2304, 1}, {0xf920, 2305, 1}, {0xf921, 2306, 1}, {0xf922, 2307, 1}, {0xf923, 2308, 1}, + {0xf924, 2309, 1}, {0xf925, 2310, 1}, {0xf926, 2311, 1}, {0xf927, 2312, 1}, {0xf928, 2313, 1}, + {0xf929, 2314, 1}, {0xf92a, 2315, 1}, {0xf92b, 2316, 1}, {0xf92c, 2317, 1}, {0xf92d, 2318, 1}, + {0xf92e, 2319, 1}, {0xf92f, 2320, 1}, {0xf930, 2321, 1}, {0xf931, 2322, 1}, {0xf932, 2323, 1}, + {0xf933, 2324, 1}, {0xf934, 2325, 1}, {0xf935, 2326, 1}, {0xf936, 2327, 1}, {0xf937, 2328, 1}, + {0xf938, 2329, 1}, {0xf939, 2330, 1}, {0xf93a, 2331, 1}, {0xf93b, 2332, 1}, {0xf93c, 2333, 1}, + {0xf93d, 2334, 1}, {0xf93e, 2335, 1}, {0xf93f, 2336, 1}, {0xf940, 2337, 1}, {0xf941, 2338, 1}, + {0xf942, 2339, 1}, {0xf943, 2340, 1}, {0xf944, 2341, 1}, {0xf945, 2342, 1}, {0xf946, 2343, 1}, + {0xf947, 2344, 1}, {0xf948, 2345, 1}, {0xf949, 2346, 1}, {0xf94a, 2347, 1}, {0xf94b, 2348, 1}, + {0xf94c, 2349, 1}, {0xf94d, 2350, 1}, {0xf94e, 2351, 1}, {0xf94f, 2352, 1}, {0xf950, 2353, 1}, + {0xf951, 2354, 1}, {0xf952, 2355, 1}, {0xf953, 2356, 1}, {0xf954, 2357, 1}, {0xf955, 2358, 1}, + {0xf956, 2359, 1}, {0xf957, 2360, 1}, {0xf958, 2361, 1}, {0xf959, 2362, 1}, {0xf95a, 2363, 1}, + {0xf95b, 2364, 1}, {0xf95c, 2365, 1}, {0xf95d, 2366, 1}, {0xf95e, 2367, 1}, {0xf95f, 2368, 1}, + {0xf960, 2369, 1}, {0xf961, 2370, 1}, {0xf962, 2371, 1}, {0xf963, 2372, 1}, {0xf964, 2373, 1}, + {0xf965, 2374, 1}, {0xf966, 2375, 1}, {0xf967, 2376, 1}, {0xf968, 2377, 1}, {0xf969, 2378, 1}, + {0xf96a, 2379, 1}, {0xf96b, 2380, 1}, {0xf96c, 2381, 1}, {0xf96d, 2382, 1}, {0xf96e, 2383, 1}, + {0xf96f, 2384, 1}, {0xf970, 2385, 1}, {0xf971, 2386, 1}, {0xf972, 2387, 1}, {0xf973, 2388, 1}, + {0xf974, 2389, 1}, {0xf975, 2390, 1}, {0xf976, 2391, 1}, {0xf977, 2392, 1}, {0xf978, 2393, 1}, + {0xf979, 2394, 1}, {0xf97a, 2395, 1}, {0xf97b, 2396, 1}, {0xf97c, 2397, 1}, {0xf97d, 2398, 1}, + {0xf97e, 2399, 1}, {0xf97f, 2400, 1}, {0xf980, 2401, 1}, {0xf981, 2402, 1}, {0xf982, 2403, 1}, + {0xf983, 2404, 1}, {0xf984, 2405, 1}, {0xf985, 2406, 1}, {0xf986, 2407, 1}, {0xf987, 2408, 1}, + {0xf988, 2409, 1}, {0xf989, 2410, 1}, {0xf98a, 2411, 1}, {0xf98b, 2412, 1}, {0xf98c, 2413, 1}, + {0xf98d, 2414, 1}, {0xf98e, 2415, 1}, {0xf98f, 2416, 1}, {0xf990, 2417, 1}, {0xf991, 2418, 1}, + {0xf992, 2419, 1}, {0xf993, 2420, 1}, {0xf994, 2421, 1}, {0xf995, 2422, 1}, {0xf996, 2423, 1}, + {0xf997, 2424, 1}, {0xf998, 2425, 1}, {0xf999, 2426, 1}, {0xf99a, 2427, 1}, {0xf99b, 2428, 1}, + {0xf99c, 2429, 1}, {0xf99d, 2430, 1}, {0xf99e, 2431, 1}, {0xf99f, 2432, 1}, {0xf9a0, 2433, 1}, + {0xf9a1, 2434, 1}, {0xf9a2, 2435, 1}, {0xf9a3, 2436, 1}, {0xf9a4, 2437, 1}, {0xf9a5, 2438, 1}, + {0xf9a6, 2439, 1}, {0xf9a7, 2440, 1}, {0xf9a8, 2441, 1}, {0xf9a9, 2442, 1}, {0xf9aa, 2443, 1}, + {0xf9ab, 2444, 1}, {0xf9ac, 2445, 1}, {0xf9ad, 2446, 1}, {0xf9ae, 2447, 1}, {0xf9af, 2448, 1}, + {0xf9b0, 2449, 1}, {0xf9b1, 2450, 1}, {0xf9b2, 2451, 1}, {0xf9b3, 2452, 1}, {0xf9b4, 2453, 1}, + {0xf9b5, 2454, 1}, {0xf9b6, 2455, 1}, {0xf9b7, 2456, 1}, {0xf9b8, 2457, 1}, {0xf9b9, 2458, 1}, + {0xf9ba, 2459, 1}, {0xf9bb, 2460, 1}, {0xf9bc, 2461, 1}, {0xf9bd, 2462, 1}, {0xf9be, 2463, 1}, + {0xf9bf, 2464, 1}, {0xf9c0, 2465, 1}, {0xf9c1, 2466, 1}, {0xf9c2, 2467, 1}, {0xf9c3, 2468, 1}, + {0xf9c4, 2469, 1}, {0xf9c5, 2470, 1}, {0xf9c6, 2471, 1}, {0xf9c7, 2472, 1}, {0xf9c8, 2473, 1}, + {0xf9c9, 2474, 1}, {0xf9ca, 2475, 1}, {0xf9cb, 2476, 1}, {0xf9cc, 2477, 1}, {0xf9cd, 2478, 1}, + {0xf9ce, 2479, 1}, {0xf9cf, 2480, 1}, {0xf9d0, 2481, 1}, {0xf9d1, 2482, 1}, {0xf9d2, 2483, 1}, + {0xf9d3, 2484, 1}, {0xf9d4, 2485, 1}, {0xf9d5, 2486, 1}, {0xf9d6, 2487, 1}, {0xf9d7, 2488, 1}, + {0xf9d8, 2489, 1}, {0xf9d9, 2490, 1}, {0xf9da, 2491, 1}, {0xf9db, 2492, 1}, {0xf9dc, 2493, 1}, + {0xf9dd, 2494, 1}, {0xf9de, 2495, 1}, {0xf9df, 2496, 1}, {0xf9e0, 2497, 1}, {0xf9e1, 2498, 1}, + {0xf9e2, 2499, 1}, {0xf9e3, 2500, 1}, {0xf9e4, 2501, 1}, {0xf9e5, 2502, 1}, {0xf9e6, 2503, 1}, + {0xf9e7, 2504, 1}, {0xf9e8, 2505, 1}, {0xf9e9, 2506, 1}, {0xf9ea, 2507, 1}, {0xf9eb, 2508, 1}, + {0xf9ec, 2509, 1}, {0xf9ed, 2510, 1}, {0xf9ee, 2511, 1}, {0xf9ef, 2512, 1}, {0xf9f0, 2513, 1}, + {0xf9f1, 2514, 1}, {0xf9f2, 2515, 1}, {0xf9f3, 2516, 1}, {0xf9f4, 2517, 1}, {0xf9f5, 2518, 1}, + {0xf9f6, 2519, 1}, {0xf9f7, 2520, 1}, {0xf9f8, 2521, 1}, {0xf9f9, 2522, 1}, {0xf9fa, 2523, 1}, + {0xf9fb, 2524, 1}, {0xf9fc, 2525, 1}, {0xf9fd, 2526, 1}, {0xf9fe, 2527, 1}, {0xf9ff, 2528, 1}, + {0xfa00, 2529, 1}, {0xfa01, 2530, 1}, {0xfa02, 2531, 1}, {0xfa03, 2532, 1}, {0xfa04, 2533, 1}, + {0xfa05, 2534, 1}, {0xfa06, 2535, 1}, {0xfa07, 2536, 1}, {0xfa08, 2537, 1}, {0xfa09, 2538, 1}, + {0xfa0a, 2539, 1}, {0xfa0b, 2540, 1}, {0xfa0c, 2541, 1}, {0xfa0d, 2542, 1}, {0xfa10, 2543, 1}, + {0xfa12, 2544, 1}, {0xfa15, 2545, 1}, {0xfa16, 2546, 1}, {0xfa17, 2547, 1}, {0xfa18, 2548, 1}, + {0xfa19, 2549, 1}, {0xfa1a, 2550, 1}, {0xfa1b, 2551, 1}, {0xfa1c, 2552, 1}, {0xfa1d, 2553, 1}, + {0xfa1e, 2554, 1}, {0xfa20, 2555, 1}, {0xfa22, 2556, 1}, {0xfa25, 2557, 1}, {0xfa26, 2558, 1}, + {0xfa2a, 2559, 1}, {0xfa2b, 2560, 1}, {0xfa2c, 2561, 1}, {0xfa2d, 2562, 1}, {0xfa2e, 2563, 1}, + {0xfa2f, 2564, 1}, {0xfa30, 2565, 1}, {0xfa31, 2566, 1}, {0xfa32, 2567, 1}, {0xfa33, 2568, 1}, + {0xfa34, 2569, 1}, {0xfa35, 2570, 1}, {0xfa36, 2571, 1}, {0xfa37, 2572, 1}, {0xfa38, 2573, 1}, + {0xfa39, 2574, 1}, {0xfa3a, 2575, 1}, {0xfa3b, 2576, 1}, {0xfa3c, 2577, 1}, {0xfa3d, 2578, 1}, + {0xfa3e, 2579, 1}, {0xfa3f, 2580, 1}, {0xfa40, 2581, 1}, {0xfa41, 2582, 1}, {0xfa42, 2583, 1}, + {0xfa43, 2584, 1}, {0xfa44, 2585, 1}, {0xfa45, 2586, 1}, {0xfa46, 2587, 1}, {0xfa47, 2588, 1}, + {0xfa48, 2589, 1}, {0xfa49, 2590, 1}, {0xfa4a, 2591, 1}, {0xfa4b, 2592, 1}, {0xfa4c, 2593, 1}, + {0xfa4d, 2594, 1}, {0xfa4e, 2595, 1}, {0xfa4f, 2596, 1}, {0xfa50, 2597, 1}, {0xfa51, 2598, 1}, + {0xfa52, 2599, 1}, {0xfa53, 2600, 1}, {0xfa54, 2601, 1}, {0xfa55, 2602, 1}, {0xfa56, 2603, 1}, + {0xfa57, 2604, 1}, {0xfa58, 2605, 1}, {0xfa59, 2606, 1}, {0xfa5a, 2607, 1}, {0xfa5b, 2608, 1}, + {0xfa5c, 2609, 1}, {0xfa5d, 2610, 1}, {0xfa5e, 2611, 1}, {0xfa5f, 2612, 1}, {0xfa60, 2613, 1}, + {0xfa61, 2614, 1}, {0xfa62, 2615, 1}, {0xfa63, 2616, 1}, {0xfa64, 2617, 1}, {0xfa65, 2618, 1}, + {0xfa66, 2619, 1}, {0xfa67, 2620, 1}, {0xfa68, 2621, 1}, {0xfa69, 2622, 1}, {0xfa6a, 2623, 1}, + {0xfa6b, 2624, 1}, {0xfa6c, 2625, 1}, {0xfa6d, 2626, 1}, {0xfa70, 2627, 1}, {0xfa71, 2628, 1}, + {0xfa72, 2629, 1}, {0xfa73, 2630, 1}, {0xfa74, 2631, 1}, {0xfa75, 2632, 1}, {0xfa76, 2633, 1}, + {0xfa77, 2634, 1}, {0xfa78, 2635, 1}, {0xfa79, 2636, 1}, {0xfa7a, 2637, 1}, {0xfa7b, 2638, 1}, + {0xfa7c, 2639, 1}, {0xfa7d, 2640, 1}, {0xfa7e, 2641, 1}, {0xfa7f, 2642, 1}, {0xfa80, 2643, 1}, + {0xfa81, 2644, 1}, {0xfa82, 2645, 1}, {0xfa83, 2646, 1}, {0xfa84, 2647, 1}, {0xfa85, 2648, 1}, + {0xfa86, 2649, 1}, {0xfa87, 2650, 1}, {0xfa88, 2651, 1}, {0xfa89, 2652, 1}, {0xfa8a, 2653, 1}, + {0xfa8b, 2654, 1}, {0xfa8c, 2655, 1}, {0xfa8d, 2656, 1}, {0xfa8e, 2657, 1}, {0xfa8f, 2658, 1}, + {0xfa90, 2659, 1}, {0xfa91, 2660, 1}, {0xfa92, 2661, 1}, {0xfa93, 2662, 1}, {0xfa94, 2663, 1}, + {0xfa95, 2664, 1}, {0xfa96, 2665, 1}, {0xfa97, 2666, 1}, {0xfa98, 2667, 1}, {0xfa99, 2668, 1}, + {0xfa9a, 2669, 1}, {0xfa9b, 2670, 1}, {0xfa9c, 2671, 1}, {0xfa9d, 2672, 1}, {0xfa9e, 2673, 1}, + {0xfa9f, 2674, 1}, {0xfaa0, 2675, 1}, {0xfaa1, 2676, 1}, {0xfaa2, 2677, 1}, {0xfaa3, 2678, 1}, + {0xfaa4, 2679, 1}, {0xfaa5, 2680, 1}, {0xfaa6, 2681, 1}, {0xfaa7, 2682, 1}, {0xfaa8, 2683, 1}, + {0xfaa9, 2684, 1}, {0xfaaa, 2685, 1}, {0xfaab, 2686, 1}, {0xfaac, 2687, 1}, {0xfaad, 2688, 1}, + {0xfaae, 2689, 1}, {0xfaaf, 2690, 1}, {0xfab0, 2691, 1}, {0xfab1, 2692, 1}, {0xfab2, 2693, 1}, + {0xfab3, 2694, 1}, {0xfab4, 2695, 1}, {0xfab5, 2696, 1}, {0xfab6, 2697, 1}, {0xfab7, 2698, 1}, + {0xfab8, 2699, 1}, {0xfab9, 2700, 1}, {0xfaba, 2701, 1}, {0xfabb, 2702, 1}, {0xfabc, 2703, 1}, + {0xfabd, 2704, 1}, {0xfabe, 2705, 1}, {0xfabf, 2706, 1}, {0xfac0, 2707, 1}, {0xfac1, 2708, 1}, + {0xfac2, 2709, 1}, {0xfac3, 2710, 1}, {0xfac4, 2711, 1}, {0xfac5, 2712, 1}, {0xfac6, 2713, 1}, + {0xfac7, 2714, 1}, {0xfac8, 2715, 1}, {0xfac9, 2716, 1}, {0xfaca, 2717, 1}, {0xfacb, 2718, 1}, + {0xfacc, 2719, 1}, {0xfacd, 2720, 1}, {0xface, 2721, 1}, {0xfacf, 2722, 1}, {0xfad0, 2723, 1}, + {0xfad1, 2724, 1}, {0xfad2, 2725, 1}, {0xfad3, 2726, 1}, {0xfad4, 2727, 1}, {0xfad5, 2728, 1}, + {0xfad6, 2729, 1}, {0xfad7, 2730, 1}, {0xfad8, 2731, 1}, {0xfad9, 2732, 1}, {0xfb1d, 2733, 2}, + {0xfb1f, 2735, 2}, {0xfb2a, 2737, 2}, {0xfb2b, 2739, 2}, {0xfb2c, 2741, 3}, {0xfb2d, 2744, 3}, + {0xfb2e, 2747, 2}, {0xfb2f, 2749, 2}, {0xfb30, 2751, 2}, {0xfb31, 2753, 2}, {0xfb32, 2755, 2}, + {0xfb33, 2757, 2}, {0xfb34, 2759, 2}, {0xfb35, 2761, 2}, {0xfb36, 2763, 2}, {0xfb38, 2765, 2}, + {0xfb39, 2767, 2}, {0xfb3a, 2769, 2}, {0xfb3b, 2771, 2}, {0xfb3c, 2773, 2}, {0xfb3e, 2775, 2}, + {0xfb40, 2777, 2}, {0xfb41, 2779, 2}, {0xfb43, 2781, 2}, {0xfb44, 2783, 2}, {0xfb46, 2785, 2}, + {0xfb47, 2787, 2}, {0xfb48, 2789, 2}, {0xfb49, 2791, 2}, {0xfb4a, 2793, 2}, {0xfb4b, 2795, 2}, + {0xfb4c, 2797, 2}, {0xfb4d, 2799, 2}, {0xfb4e, 2801, 2}, {0x105c9, 2803, 2}, {0x105e4, 2805, 2}, + {0x1109a, 2807, 2}, {0x1109c, 2809, 2}, {0x110ab, 2811, 2}, {0x1112e, 2813, 2}, + {0x1112f, 2815, 2}, {0x1134b, 2817, 2}, {0x1134c, 2819, 2}, {0x11383, 2821, 2}, + {0x11385, 2823, 2}, {0x1138e, 2825, 2}, {0x11391, 2827, 2}, {0x113c5, 2829, 2}, + {0x113c7, 2831, 2}, {0x113c8, 2833, 2}, {0x114bb, 2835, 2}, {0x114bc, 2837, 2}, + {0x114be, 2839, 2}, {0x115ba, 2841, 2}, {0x115bb, 2843, 2}, {0x11938, 2845, 2}, + {0x16121, 2847, 2}, {0x16122, 2849, 2}, {0x16123, 2851, 2}, {0x16124, 2853, 2}, + {0x16125, 2855, 2}, {0x16126, 2857, 3}, {0x16127, 2860, 3}, {0x16128, 2863, 3}, + {0x16d68, 2866, 2}, {0x16d69, 2868, 2}, {0x16d6a, 2870, 3}, {0x1d15e, 2873, 2}, + {0x1d15f, 2875, 2}, {0x1d160, 2877, 3}, {0x1d161, 2880, 3}, {0x1d162, 2883, 3}, + {0x1d163, 2886, 3}, {0x1d164, 2889, 3}, {0x1d1bb, 2892, 2}, {0x1d1bc, 2894, 2}, + {0x1d1bd, 2896, 3}, {0x1d1be, 2899, 3}, {0x1d1bf, 2902, 3}, {0x1d1c0, 2905, 3}, + {0x2f800, 2908, 1}, {0x2f801, 2909, 1}, {0x2f802, 2910, 1}, {0x2f803, 2911, 1}, + {0x2f804, 2912, 1}, {0x2f805, 2913, 1}, {0x2f806, 2914, 1}, {0x2f807, 2915, 1}, + {0x2f808, 2916, 1}, {0x2f809, 2917, 1}, {0x2f80a, 2918, 1}, {0x2f80b, 2919, 1}, + {0x2f80c, 2920, 1}, {0x2f80d, 2921, 1}, {0x2f80e, 2922, 1}, {0x2f80f, 2923, 1}, + {0x2f810, 2924, 1}, {0x2f811, 2925, 1}, {0x2f812, 2926, 1}, {0x2f813, 2927, 1}, + {0x2f814, 2928, 1}, {0x2f815, 2929, 1}, {0x2f816, 2930, 1}, {0x2f817, 2931, 1}, + {0x2f818, 2932, 1}, {0x2f819, 2933, 1}, {0x2f81a, 2934, 1}, {0x2f81b, 2935, 1}, + {0x2f81c, 2936, 1}, {0x2f81d, 2937, 1}, {0x2f81e, 2938, 1}, {0x2f81f, 2939, 1}, + {0x2f820, 2940, 1}, {0x2f821, 2941, 1}, {0x2f822, 2942, 1}, {0x2f823, 2943, 1}, + {0x2f824, 2944, 1}, {0x2f825, 2945, 1}, {0x2f826, 2946, 1}, {0x2f827, 2947, 1}, + {0x2f828, 2948, 1}, {0x2f829, 2949, 1}, {0x2f82a, 2950, 1}, {0x2f82b, 2951, 1}, + {0x2f82c, 2952, 1}, {0x2f82d, 2953, 1}, {0x2f82e, 2954, 1}, {0x2f82f, 2955, 1}, + {0x2f830, 2956, 1}, {0x2f831, 2957, 1}, {0x2f832, 2958, 1}, {0x2f833, 2959, 1}, + {0x2f834, 2960, 1}, {0x2f835, 2961, 1}, {0x2f836, 2962, 1}, {0x2f837, 2963, 1}, + {0x2f838, 2964, 1}, {0x2f839, 2965, 1}, {0x2f83a, 2966, 1}, {0x2f83b, 2967, 1}, + {0x2f83c, 2968, 1}, {0x2f83d, 2969, 1}, {0x2f83e, 2970, 1}, {0x2f83f, 2971, 1}, + {0x2f840, 2972, 1}, {0x2f841, 2973, 1}, {0x2f842, 2974, 1}, {0x2f843, 2975, 1}, + {0x2f844, 2976, 1}, {0x2f845, 2977, 1}, {0x2f846, 2978, 1}, {0x2f847, 2979, 1}, + {0x2f848, 2980, 1}, {0x2f849, 2981, 1}, {0x2f84a, 2982, 1}, {0x2f84b, 2983, 1}, + {0x2f84c, 2984, 1}, {0x2f84d, 2985, 1}, {0x2f84e, 2986, 1}, {0x2f84f, 2987, 1}, + {0x2f850, 2988, 1}, {0x2f851, 2989, 1}, {0x2f852, 2990, 1}, {0x2f853, 2991, 1}, + {0x2f854, 2992, 1}, {0x2f855, 2993, 1}, {0x2f856, 2994, 1}, {0x2f857, 2995, 1}, + {0x2f858, 2996, 1}, {0x2f859, 2997, 1}, {0x2f85a, 2998, 1}, {0x2f85b, 2999, 1}, + {0x2f85c, 3000, 1}, {0x2f85d, 3001, 1}, {0x2f85e, 3002, 1}, {0x2f85f, 3003, 1}, + {0x2f860, 3004, 1}, {0x2f861, 3005, 1}, {0x2f862, 3006, 1}, {0x2f863, 3007, 1}, + {0x2f864, 3008, 1}, {0x2f865, 3009, 1}, {0x2f866, 3010, 1}, {0x2f867, 3011, 1}, + {0x2f868, 3012, 1}, {0x2f869, 3013, 1}, {0x2f86a, 3014, 1}, {0x2f86b, 3015, 1}, + {0x2f86c, 3016, 1}, {0x2f86d, 3017, 1}, {0x2f86e, 3018, 1}, {0x2f86f, 3019, 1}, + {0x2f870, 3020, 1}, {0x2f871, 3021, 1}, {0x2f872, 3022, 1}, {0x2f873, 3023, 1}, + {0x2f874, 3024, 1}, {0x2f875, 3025, 1}, {0x2f876, 3026, 1}, {0x2f877, 3027, 1}, + {0x2f878, 3028, 1}, {0x2f879, 3029, 1}, {0x2f87a, 3030, 1}, {0x2f87b, 3031, 1}, + {0x2f87c, 3032, 1}, {0x2f87d, 3033, 1}, {0x2f87e, 3034, 1}, {0x2f87f, 3035, 1}, + {0x2f880, 3036, 1}, {0x2f881, 3037, 1}, {0x2f882, 3038, 1}, {0x2f883, 3039, 1}, + {0x2f884, 3040, 1}, {0x2f885, 3041, 1}, {0x2f886, 3042, 1}, {0x2f887, 3043, 1}, + {0x2f888, 3044, 1}, {0x2f889, 3045, 1}, {0x2f88a, 3046, 1}, {0x2f88b, 3047, 1}, + {0x2f88c, 3048, 1}, {0x2f88d, 3049, 1}, {0x2f88e, 3050, 1}, {0x2f88f, 3051, 1}, + {0x2f890, 3052, 1}, {0x2f891, 3053, 1}, {0x2f892, 3054, 1}, {0x2f893, 3055, 1}, + {0x2f894, 3056, 1}, {0x2f895, 3057, 1}, {0x2f896, 3058, 1}, {0x2f897, 3059, 1}, + {0x2f898, 3060, 1}, {0x2f899, 3061, 1}, {0x2f89a, 3062, 1}, {0x2f89b, 3063, 1}, + {0x2f89c, 3064, 1}, {0x2f89d, 3065, 1}, {0x2f89e, 3066, 1}, {0x2f89f, 3067, 1}, + {0x2f8a0, 3068, 1}, {0x2f8a1, 3069, 1}, {0x2f8a2, 3070, 1}, {0x2f8a3, 3071, 1}, + {0x2f8a4, 3072, 1}, {0x2f8a5, 3073, 1}, {0x2f8a6, 3074, 1}, {0x2f8a7, 3075, 1}, + {0x2f8a8, 3076, 1}, {0x2f8a9, 3077, 1}, {0x2f8aa, 3078, 1}, {0x2f8ab, 3079, 1}, + {0x2f8ac, 3080, 1}, {0x2f8ad, 3081, 1}, {0x2f8ae, 3082, 1}, {0x2f8af, 3083, 1}, + {0x2f8b0, 3084, 1}, {0x2f8b1, 3085, 1}, {0x2f8b2, 3086, 1}, {0x2f8b3, 3087, 1}, + {0x2f8b4, 3088, 1}, {0x2f8b5, 3089, 1}, {0x2f8b6, 3090, 1}, {0x2f8b7, 3091, 1}, + {0x2f8b8, 3092, 1}, {0x2f8b9, 3093, 1}, {0x2f8ba, 3094, 1}, {0x2f8bb, 3095, 1}, + {0x2f8bc, 3096, 1}, {0x2f8bd, 3097, 1}, {0x2f8be, 3098, 1}, {0x2f8bf, 3099, 1}, + {0x2f8c0, 3100, 1}, {0x2f8c1, 3101, 1}, {0x2f8c2, 3102, 1}, {0x2f8c3, 3103, 1}, + {0x2f8c4, 3104, 1}, {0x2f8c5, 3105, 1}, {0x2f8c6, 3106, 1}, {0x2f8c7, 3107, 1}, + {0x2f8c8, 3108, 1}, {0x2f8c9, 3109, 1}, {0x2f8ca, 3110, 1}, {0x2f8cb, 3111, 1}, + {0x2f8cc, 3112, 1}, {0x2f8cd, 3113, 1}, {0x2f8ce, 3114, 1}, {0x2f8cf, 3115, 1}, + {0x2f8d0, 3116, 1}, {0x2f8d1, 3117, 1}, {0x2f8d2, 3118, 1}, {0x2f8d3, 3119, 1}, + {0x2f8d4, 3120, 1}, {0x2f8d5, 3121, 1}, {0x2f8d6, 3122, 1}, {0x2f8d7, 3123, 1}, + {0x2f8d8, 3124, 1}, {0x2f8d9, 3125, 1}, {0x2f8da, 3126, 1}, {0x2f8db, 3127, 1}, + {0x2f8dc, 3128, 1}, {0x2f8dd, 3129, 1}, {0x2f8de, 3130, 1}, {0x2f8df, 3131, 1}, + {0x2f8e0, 3132, 1}, {0x2f8e1, 3133, 1}, {0x2f8e2, 3134, 1}, {0x2f8e3, 3135, 1}, + {0x2f8e4, 3136, 1}, {0x2f8e5, 3137, 1}, {0x2f8e6, 3138, 1}, {0x2f8e7, 3139, 1}, + {0x2f8e8, 3140, 1}, {0x2f8e9, 3141, 1}, {0x2f8ea, 3142, 1}, {0x2f8eb, 3143, 1}, + {0x2f8ec, 3144, 1}, {0x2f8ed, 3145, 1}, {0x2f8ee, 3146, 1}, {0x2f8ef, 3147, 1}, + {0x2f8f0, 3148, 1}, {0x2f8f1, 3149, 1}, {0x2f8f2, 3150, 1}, {0x2f8f3, 3151, 1}, + {0x2f8f4, 3152, 1}, {0x2f8f5, 3153, 1}, {0x2f8f6, 3154, 1}, {0x2f8f7, 3155, 1}, + {0x2f8f8, 3156, 1}, {0x2f8f9, 3157, 1}, {0x2f8fa, 3158, 1}, {0x2f8fb, 3159, 1}, + {0x2f8fc, 3160, 1}, {0x2f8fd, 3161, 1}, {0x2f8fe, 3162, 1}, {0x2f8ff, 3163, 1}, + {0x2f900, 3164, 1}, {0x2f901, 3165, 1}, {0x2f902, 3166, 1}, {0x2f903, 3167, 1}, + {0x2f904, 3168, 1}, {0x2f905, 3169, 1}, {0x2f906, 3170, 1}, {0x2f907, 3171, 1}, + {0x2f908, 3172, 1}, {0x2f909, 3173, 1}, {0x2f90a, 3174, 1}, {0x2f90b, 3175, 1}, + {0x2f90c, 3176, 1}, {0x2f90d, 3177, 1}, {0x2f90e, 3178, 1}, {0x2f90f, 3179, 1}, + {0x2f910, 3180, 1}, {0x2f911, 3181, 1}, {0x2f912, 3182, 1}, {0x2f913, 3183, 1}, + {0x2f914, 3184, 1}, {0x2f915, 3185, 1}, {0x2f916, 3186, 1}, {0x2f917, 3187, 1}, + {0x2f918, 3188, 1}, {0x2f919, 3189, 1}, {0x2f91a, 3190, 1}, {0x2f91b, 3191, 1}, + {0x2f91c, 3192, 1}, {0x2f91d, 3193, 1}, {0x2f91e, 3194, 1}, {0x2f91f, 3195, 1}, + {0x2f920, 3196, 1}, {0x2f921, 3197, 1}, {0x2f922, 3198, 1}, {0x2f923, 3199, 1}, + {0x2f924, 3200, 1}, {0x2f925, 3201, 1}, {0x2f926, 3202, 1}, {0x2f927, 3203, 1}, + {0x2f928, 3204, 1}, {0x2f929, 3205, 1}, {0x2f92a, 3206, 1}, {0x2f92b, 3207, 1}, + {0x2f92c, 3208, 1}, {0x2f92d, 3209, 1}, {0x2f92e, 3210, 1}, {0x2f92f, 3211, 1}, + {0x2f930, 3212, 1}, {0x2f931, 3213, 1}, {0x2f932, 3214, 1}, {0x2f933, 3215, 1}, + {0x2f934, 3216, 1}, {0x2f935, 3217, 1}, {0x2f936, 3218, 1}, {0x2f937, 3219, 1}, + {0x2f938, 3220, 1}, {0x2f939, 3221, 1}, {0x2f93a, 3222, 1}, {0x2f93b, 3223, 1}, + {0x2f93c, 3224, 1}, {0x2f93d, 3225, 1}, {0x2f93e, 3226, 1}, {0x2f93f, 3227, 1}, + {0x2f940, 3228, 1}, {0x2f941, 3229, 1}, {0x2f942, 3230, 1}, {0x2f943, 3231, 1}, + {0x2f944, 3232, 1}, {0x2f945, 3233, 1}, {0x2f946, 3234, 1}, {0x2f947, 3235, 1}, + {0x2f948, 3236, 1}, {0x2f949, 3237, 1}, {0x2f94a, 3238, 1}, {0x2f94b, 3239, 1}, + {0x2f94c, 3240, 1}, {0x2f94d, 3241, 1}, {0x2f94e, 3242, 1}, {0x2f94f, 3243, 1}, + {0x2f950, 3244, 1}, {0x2f951, 3245, 1}, {0x2f952, 3246, 1}, {0x2f953, 3247, 1}, + {0x2f954, 3248, 1}, {0x2f955, 3249, 1}, {0x2f956, 3250, 1}, {0x2f957, 3251, 1}, + {0x2f958, 3252, 1}, {0x2f959, 3253, 1}, {0x2f95a, 3254, 1}, {0x2f95b, 3255, 1}, + {0x2f95c, 3256, 1}, {0x2f95d, 3257, 1}, {0x2f95e, 3258, 1}, {0x2f95f, 3259, 1}, + {0x2f960, 3260, 1}, {0x2f961, 3261, 1}, {0x2f962, 3262, 1}, {0x2f963, 3263, 1}, + {0x2f964, 3264, 1}, {0x2f965, 3265, 1}, {0x2f966, 3266, 1}, {0x2f967, 3267, 1}, + {0x2f968, 3268, 1}, {0x2f969, 3269, 1}, {0x2f96a, 3270, 1}, {0x2f96b, 3271, 1}, + {0x2f96c, 3272, 1}, {0x2f96d, 3273, 1}, {0x2f96e, 3274, 1}, {0x2f96f, 3275, 1}, + {0x2f970, 3276, 1}, {0x2f971, 3277, 1}, {0x2f972, 3278, 1}, {0x2f973, 3279, 1}, + {0x2f974, 3280, 1}, {0x2f975, 3281, 1}, {0x2f976, 3282, 1}, {0x2f977, 3283, 1}, + {0x2f978, 3284, 1}, {0x2f979, 3285, 1}, {0x2f97a, 3286, 1}, {0x2f97b, 3287, 1}, + {0x2f97c, 3288, 1}, {0x2f97d, 3289, 1}, {0x2f97e, 3290, 1}, {0x2f97f, 3291, 1}, + {0x2f980, 3292, 1}, {0x2f981, 3293, 1}, {0x2f982, 3294, 1}, {0x2f983, 3295, 1}, + {0x2f984, 3296, 1}, {0x2f985, 3297, 1}, {0x2f986, 3298, 1}, {0x2f987, 3299, 1}, + {0x2f988, 3300, 1}, {0x2f989, 3301, 1}, {0x2f98a, 3302, 1}, {0x2f98b, 3303, 1}, + {0x2f98c, 3304, 1}, {0x2f98d, 3305, 1}, {0x2f98e, 3306, 1}, {0x2f98f, 3307, 1}, + {0x2f990, 3308, 1}, {0x2f991, 3309, 1}, {0x2f992, 3310, 1}, {0x2f993, 3311, 1}, + {0x2f994, 3312, 1}, {0x2f995, 3313, 1}, {0x2f996, 3314, 1}, {0x2f997, 3315, 1}, + {0x2f998, 3316, 1}, {0x2f999, 3317, 1}, {0x2f99a, 3318, 1}, {0x2f99b, 3319, 1}, + {0x2f99c, 3320, 1}, {0x2f99d, 3321, 1}, {0x2f99e, 3322, 1}, {0x2f99f, 3323, 1}, + {0x2f9a0, 3324, 1}, {0x2f9a1, 3325, 1}, {0x2f9a2, 3326, 1}, {0x2f9a3, 3327, 1}, + {0x2f9a4, 3328, 1}, {0x2f9a5, 3329, 1}, {0x2f9a6, 3330, 1}, {0x2f9a7, 3331, 1}, + {0x2f9a8, 3332, 1}, {0x2f9a9, 3333, 1}, {0x2f9aa, 3334, 1}, {0x2f9ab, 3335, 1}, + {0x2f9ac, 3336, 1}, {0x2f9ad, 3337, 1}, {0x2f9ae, 3338, 1}, {0x2f9af, 3339, 1}, + {0x2f9b0, 3340, 1}, {0x2f9b1, 3341, 1}, {0x2f9b2, 3342, 1}, {0x2f9b3, 3343, 1}, + {0x2f9b4, 3344, 1}, {0x2f9b5, 3345, 1}, {0x2f9b6, 3346, 1}, {0x2f9b7, 3347, 1}, + {0x2f9b8, 3348, 1}, {0x2f9b9, 3349, 1}, {0x2f9ba, 3350, 1}, {0x2f9bb, 3351, 1}, + {0x2f9bc, 3352, 1}, {0x2f9bd, 3353, 1}, {0x2f9be, 3354, 1}, {0x2f9bf, 3355, 1}, + {0x2f9c0, 3356, 1}, {0x2f9c1, 3357, 1}, {0x2f9c2, 3358, 1}, {0x2f9c3, 3359, 1}, + {0x2f9c4, 3360, 1}, {0x2f9c5, 3361, 1}, {0x2f9c6, 3362, 1}, {0x2f9c7, 3363, 1}, + {0x2f9c8, 3364, 1}, {0x2f9c9, 3365, 1}, {0x2f9ca, 3366, 1}, {0x2f9cb, 3367, 1}, + {0x2f9cc, 3368, 1}, {0x2f9cd, 3369, 1}, {0x2f9ce, 3370, 1}, {0x2f9cf, 3371, 1}, + {0x2f9d0, 3372, 1}, {0x2f9d1, 3373, 1}, {0x2f9d2, 3374, 1}, {0x2f9d3, 3375, 1}, + {0x2f9d4, 3376, 1}, {0x2f9d5, 3377, 1}, {0x2f9d6, 3378, 1}, {0x2f9d7, 3379, 1}, + {0x2f9d8, 3380, 1}, {0x2f9d9, 3381, 1}, {0x2f9da, 3382, 1}, {0x2f9db, 3383, 1}, + {0x2f9dc, 3384, 1}, {0x2f9dd, 3385, 1}, {0x2f9de, 3386, 1}, {0x2f9df, 3387, 1}, + {0x2f9e0, 3388, 1}, {0x2f9e1, 3389, 1}, {0x2f9e2, 3390, 1}, {0x2f9e3, 3391, 1}, + {0x2f9e4, 3392, 1}, {0x2f9e5, 3393, 1}, {0x2f9e6, 3394, 1}, {0x2f9e7, 3395, 1}, + {0x2f9e8, 3396, 1}, {0x2f9e9, 3397, 1}, {0x2f9ea, 3398, 1}, {0x2f9eb, 3399, 1}, + {0x2f9ec, 3400, 1}, {0x2f9ed, 3401, 1}, {0x2f9ee, 3402, 1}, {0x2f9ef, 3403, 1}, + {0x2f9f0, 3404, 1}, {0x2f9f1, 3405, 1}, {0x2f9f2, 3406, 1}, {0x2f9f3, 3407, 1}, + {0x2f9f4, 3408, 1}, {0x2f9f5, 3409, 1}, {0x2f9f6, 3410, 1}, {0x2f9f7, 3411, 1}, + {0x2f9f8, 3412, 1}, {0x2f9f9, 3413, 1}, {0x2f9fa, 3414, 1}, {0x2f9fb, 3415, 1}, + {0x2f9fc, 3416, 1}, {0x2f9fd, 3417, 1}, {0x2f9fe, 3418, 1}, {0x2f9ff, 3419, 1}, + {0x2fa00, 3420, 1}, {0x2fa01, 3421, 1}, {0x2fa02, 3422, 1}, {0x2fa03, 3423, 1}, + {0x2fa04, 3424, 1}, {0x2fa05, 3425, 1}, {0x2fa06, 3426, 1}, {0x2fa07, 3427, 1}, + {0x2fa08, 3428, 1}, {0x2fa09, 3429, 1}, {0x2fa0a, 3430, 1}, {0x2fa0b, 3431, 1}, + {0x2fa0c, 3432, 1}, {0x2fa0d, 3433, 1}, {0x2fa0e, 3434, 1}, {0x2fa0f, 3435, 1}, + {0x2fa10, 3436, 1}, {0x2fa11, 3437, 1}, {0x2fa12, 3438, 1}, {0x2fa13, 3439, 1}, + {0x2fa14, 3440, 1}, {0x2fa15, 3441, 1}, {0x2fa16, 3442, 1}, {0x2fa17, 3443, 1}, + {0x2fa18, 3444, 1}, {0x2fa19, 3445, 1}, {0x2fa1a, 3446, 1}, {0x2fa1b, 3447, 1}, + {0x2fa1c, 3448, 1}, {0x2fa1d, 3449, 1}, +}; + +TP_PRIVATE const tp_rune tp_uni_decomp_pool[TP_UNI_DECOMP_POOL_N] = { + 0x41, 0x300, 0x41, 0x301, 0x41, 0x302, 0x41, 0x303, 0x41, 0x308, + 0x41, 0x30a, 0x43, 0x327, 0x45, 0x300, 0x45, 0x301, 0x45, 0x302, + 0x45, 0x308, 0x49, 0x300, 0x49, 0x301, 0x49, 0x302, 0x49, 0x308, + 0x4e, 0x303, 0x4f, 0x300, 0x4f, 0x301, 0x4f, 0x302, 0x4f, 0x303, + 0x4f, 0x308, 0x55, 0x300, 0x55, 0x301, 0x55, 0x302, 0x55, 0x308, + 0x59, 0x301, 0x61, 0x300, 0x61, 0x301, 0x61, 0x302, 0x61, 0x303, + 0x61, 0x308, 0x61, 0x30a, 0x63, 0x327, 0x65, 0x300, 0x65, 0x301, + 0x65, 0x302, 0x65, 0x308, 0x69, 0x300, 0x69, 0x301, 0x69, 0x302, + 0x69, 0x308, 0x6e, 0x303, 0x6f, 0x300, 0x6f, 0x301, 0x6f, 0x302, + 0x6f, 0x303, 0x6f, 0x308, 0x75, 0x300, 0x75, 0x301, 0x75, 0x302, + 0x75, 0x308, 0x79, 0x301, 0x79, 0x308, 0x41, 0x304, 0x61, 0x304, + 0x41, 0x306, 0x61, 0x306, 0x41, 0x328, 0x61, 0x328, 0x43, 0x301, + 0x63, 0x301, 0x43, 0x302, 0x63, 0x302, 0x43, 0x307, 0x63, 0x307, + 0x43, 0x30c, 0x63, 0x30c, 0x44, 0x30c, 0x64, 0x30c, 0x45, 0x304, + 0x65, 0x304, 0x45, 0x306, 0x65, 0x306, 0x45, 0x307, 0x65, 0x307, + 0x45, 0x328, 0x65, 0x328, 0x45, 0x30c, 0x65, 0x30c, 0x47, 0x302, + 0x67, 0x302, 0x47, 0x306, 0x67, 0x306, 0x47, 0x307, 0x67, 0x307, + 0x47, 0x327, 0x67, 0x327, 0x48, 0x302, 0x68, 0x302, 0x49, 0x303, + 0x69, 0x303, 0x49, 0x304, 0x69, 0x304, 0x49, 0x306, 0x69, 0x306, + 0x49, 0x328, 0x69, 0x328, 0x49, 0x307, 0x4a, 0x302, 0x6a, 0x302, + 0x4b, 0x327, 0x6b, 0x327, 0x4c, 0x301, 0x6c, 0x301, 0x4c, 0x327, + 0x6c, 0x327, 0x4c, 0x30c, 0x6c, 0x30c, 0x4e, 0x301, 0x6e, 0x301, + 0x4e, 0x327, 0x6e, 0x327, 0x4e, 0x30c, 0x6e, 0x30c, 0x4f, 0x304, + 0x6f, 0x304, 0x4f, 0x306, 0x6f, 0x306, 0x4f, 0x30b, 0x6f, 0x30b, + 0x52, 0x301, 0x72, 0x301, 0x52, 0x327, 0x72, 0x327, 0x52, 0x30c, + 0x72, 0x30c, 0x53, 0x301, 0x73, 0x301, 0x53, 0x302, 0x73, 0x302, + 0x53, 0x327, 0x73, 0x327, 0x53, 0x30c, 0x73, 0x30c, 0x54, 0x327, + 0x74, 0x327, 0x54, 0x30c, 0x74, 0x30c, 0x55, 0x303, 0x75, 0x303, + 0x55, 0x304, 0x75, 0x304, 0x55, 0x306, 0x75, 0x306, 0x55, 0x30a, + 0x75, 0x30a, 0x55, 0x30b, 0x75, 0x30b, 0x55, 0x328, 0x75, 0x328, + 0x57, 0x302, 0x77, 0x302, 0x59, 0x302, 0x79, 0x302, 0x59, 0x308, + 0x5a, 0x301, 0x7a, 0x301, 0x5a, 0x307, 0x7a, 0x307, 0x5a, 0x30c, + 0x7a, 0x30c, 0x4f, 0x31b, 0x6f, 0x31b, 0x55, 0x31b, 0x75, 0x31b, + 0x41, 0x30c, 0x61, 0x30c, 0x49, 0x30c, 0x69, 0x30c, 0x4f, 0x30c, + 0x6f, 0x30c, 0x55, 0x30c, 0x75, 0x30c, 0x55, 0x308, 0x304, 0x75, + 0x308, 0x304, 0x55, 0x308, 0x301, 0x75, 0x308, 0x301, 0x55, 0x308, + 0x30c, 0x75, 0x308, 0x30c, 0x55, 0x308, 0x300, 0x75, 0x308, 0x300, + 0x41, 0x308, 0x304, 0x61, 0x308, 0x304, 0x41, 0x307, 0x304, 0x61, + 0x307, 0x304, 0xc6, 0x304, 0xe6, 0x304, 0x47, 0x30c, 0x67, 0x30c, + 0x4b, 0x30c, 0x6b, 0x30c, 0x4f, 0x328, 0x6f, 0x328, 0x4f, 0x328, + 0x304, 0x6f, 0x328, 0x304, 0x1b7, 0x30c, 0x292, 0x30c, 0x6a, 0x30c, + 0x47, 0x301, 0x67, 0x301, 0x4e, 0x300, 0x6e, 0x300, 0x41, 0x30a, + 0x301, 0x61, 0x30a, 0x301, 0xc6, 0x301, 0xe6, 0x301, 0xd8, 0x301, + 0xf8, 0x301, 0x41, 0x30f, 0x61, 0x30f, 0x41, 0x311, 0x61, 0x311, + 0x45, 0x30f, 0x65, 0x30f, 0x45, 0x311, 0x65, 0x311, 0x49, 0x30f, + 0x69, 0x30f, 0x49, 0x311, 0x69, 0x311, 0x4f, 0x30f, 0x6f, 0x30f, + 0x4f, 0x311, 0x6f, 0x311, 0x52, 0x30f, 0x72, 0x30f, 0x52, 0x311, + 0x72, 0x311, 0x55, 0x30f, 0x75, 0x30f, 0x55, 0x311, 0x75, 0x311, + 0x53, 0x326, 0x73, 0x326, 0x54, 0x326, 0x74, 0x326, 0x48, 0x30c, + 0x68, 0x30c, 0x41, 0x307, 0x61, 0x307, 0x45, 0x327, 0x65, 0x327, + 0x4f, 0x308, 0x304, 0x6f, 0x308, 0x304, 0x4f, 0x303, 0x304, 0x6f, + 0x303, 0x304, 0x4f, 0x307, 0x6f, 0x307, 0x4f, 0x307, 0x304, 0x6f, + 0x307, 0x304, 0x59, 0x304, 0x79, 0x304, 0x300, 0x301, 0x313, 0x308, + 0x301, 0x2b9, 0x3b, 0xa8, 0x301, 0x391, 0x301, 0xb7, 0x395, 0x301, + 0x397, 0x301, 0x399, 0x301, 0x39f, 0x301, 0x3a5, 0x301, 0x3a9, 0x301, + 0x3b9, 0x308, 0x301, 0x399, 0x308, 0x3a5, 0x308, 0x3b1, 0x301, 0x3b5, + 0x301, 0x3b7, 0x301, 0x3b9, 0x301, 0x3c5, 0x308, 0x301, 0x3b9, 0x308, + 0x3c5, 0x308, 0x3bf, 0x301, 0x3c5, 0x301, 0x3c9, 0x301, 0x3d2, 0x301, + 0x3d2, 0x308, 0x415, 0x300, 0x415, 0x308, 0x413, 0x301, 0x406, 0x308, + 0x41a, 0x301, 0x418, 0x300, 0x423, 0x306, 0x418, 0x306, 0x438, 0x306, + 0x435, 0x300, 0x435, 0x308, 0x433, 0x301, 0x456, 0x308, 0x43a, 0x301, + 0x438, 0x300, 0x443, 0x306, 0x474, 0x30f, 0x475, 0x30f, 0x416, 0x306, + 0x436, 0x306, 0x410, 0x306, 0x430, 0x306, 0x410, 0x308, 0x430, 0x308, + 0x415, 0x306, 0x435, 0x306, 0x4d8, 0x308, 0x4d9, 0x308, 0x416, 0x308, + 0x436, 0x308, 0x417, 0x308, 0x437, 0x308, 0x418, 0x304, 0x438, 0x304, + 0x418, 0x308, 0x438, 0x308, 0x41e, 0x308, 0x43e, 0x308, 0x4e8, 0x308, + 0x4e9, 0x308, 0x42d, 0x308, 0x44d, 0x308, 0x423, 0x304, 0x443, 0x304, + 0x423, 0x308, 0x443, 0x308, 0x423, 0x30b, 0x443, 0x30b, 0x427, 0x308, + 0x447, 0x308, 0x42b, 0x308, 0x44b, 0x308, 0x627, 0x653, 0x627, 0x654, + 0x648, 0x654, 0x627, 0x655, 0x64a, 0x654, 0x6d5, 0x654, 0x6c1, 0x654, + 0x6d2, 0x654, 0x928, 0x93c, 0x930, 0x93c, 0x933, 0x93c, 0x915, 0x93c, + 0x916, 0x93c, 0x917, 0x93c, 0x91c, 0x93c, 0x921, 0x93c, 0x922, 0x93c, + 0x92b, 0x93c, 0x92f, 0x93c, 0x9c7, 0x9be, 0x9c7, 0x9d7, 0x9a1, 0x9bc, + 0x9a2, 0x9bc, 0x9af, 0x9bc, 0xa32, 0xa3c, 0xa38, 0xa3c, 0xa16, 0xa3c, + 0xa17, 0xa3c, 0xa1c, 0xa3c, 0xa2b, 0xa3c, 0xb47, 0xb56, 0xb47, 0xb3e, + 0xb47, 0xb57, 0xb21, 0xb3c, 0xb22, 0xb3c, 0xb92, 0xbd7, 0xbc6, 0xbbe, + 0xbc7, 0xbbe, 0xbc6, 0xbd7, 0xc46, 0xc56, 0xcbf, 0xcd5, 0xcc6, 0xcd5, + 0xcc6, 0xcd6, 0xcc6, 0xcc2, 0xcc6, 0xcc2, 0xcd5, 0xd46, 0xd3e, 0xd47, + 0xd3e, 0xd46, 0xd57, 0xdd9, 0xdca, 0xdd9, 0xdcf, 0xdd9, 0xdcf, 0xdca, + 0xdd9, 0xddf, 0xf42, 0xfb7, 0xf4c, 0xfb7, 0xf51, 0xfb7, 0xf56, 0xfb7, + 0xf5b, 0xfb7, 0xf40, 0xfb5, 0xf71, 0xf72, 0xf71, 0xf74, 0xfb2, 0xf80, + 0xfb3, 0xf80, 0xf71, 0xf80, 0xf92, 0xfb7, 0xf9c, 0xfb7, 0xfa1, 0xfb7, + 0xfa6, 0xfb7, 0xfab, 0xfb7, 0xf90, 0xfb5, 0x1025, 0x102e, 0x1b05, 0x1b35, + 0x1b07, 0x1b35, 0x1b09, 0x1b35, 0x1b0b, 0x1b35, 0x1b0d, 0x1b35, 0x1b11, 0x1b35, + 0x1b3a, 0x1b35, 0x1b3c, 0x1b35, 0x1b3e, 0x1b35, 0x1b3f, 0x1b35, 0x1b42, 0x1b35, + 0x41, 0x325, 0x61, 0x325, 0x42, 0x307, 0x62, 0x307, 0x42, 0x323, + 0x62, 0x323, 0x42, 0x331, 0x62, 0x331, 0x43, 0x327, 0x301, 0x63, + 0x327, 0x301, 0x44, 0x307, 0x64, 0x307, 0x44, 0x323, 0x64, 0x323, + 0x44, 0x331, 0x64, 0x331, 0x44, 0x327, 0x64, 0x327, 0x44, 0x32d, + 0x64, 0x32d, 0x45, 0x304, 0x300, 0x65, 0x304, 0x300, 0x45, 0x304, + 0x301, 0x65, 0x304, 0x301, 0x45, 0x32d, 0x65, 0x32d, 0x45, 0x330, + 0x65, 0x330, 0x45, 0x327, 0x306, 0x65, 0x327, 0x306, 0x46, 0x307, + 0x66, 0x307, 0x47, 0x304, 0x67, 0x304, 0x48, 0x307, 0x68, 0x307, + 0x48, 0x323, 0x68, 0x323, 0x48, 0x308, 0x68, 0x308, 0x48, 0x327, + 0x68, 0x327, 0x48, 0x32e, 0x68, 0x32e, 0x49, 0x330, 0x69, 0x330, + 0x49, 0x308, 0x301, 0x69, 0x308, 0x301, 0x4b, 0x301, 0x6b, 0x301, + 0x4b, 0x323, 0x6b, 0x323, 0x4b, 0x331, 0x6b, 0x331, 0x4c, 0x323, + 0x6c, 0x323, 0x4c, 0x323, 0x304, 0x6c, 0x323, 0x304, 0x4c, 0x331, + 0x6c, 0x331, 0x4c, 0x32d, 0x6c, 0x32d, 0x4d, 0x301, 0x6d, 0x301, + 0x4d, 0x307, 0x6d, 0x307, 0x4d, 0x323, 0x6d, 0x323, 0x4e, 0x307, + 0x6e, 0x307, 0x4e, 0x323, 0x6e, 0x323, 0x4e, 0x331, 0x6e, 0x331, + 0x4e, 0x32d, 0x6e, 0x32d, 0x4f, 0x303, 0x301, 0x6f, 0x303, 0x301, + 0x4f, 0x303, 0x308, 0x6f, 0x303, 0x308, 0x4f, 0x304, 0x300, 0x6f, + 0x304, 0x300, 0x4f, 0x304, 0x301, 0x6f, 0x304, 0x301, 0x50, 0x301, + 0x70, 0x301, 0x50, 0x307, 0x70, 0x307, 0x52, 0x307, 0x72, 0x307, + 0x52, 0x323, 0x72, 0x323, 0x52, 0x323, 0x304, 0x72, 0x323, 0x304, + 0x52, 0x331, 0x72, 0x331, 0x53, 0x307, 0x73, 0x307, 0x53, 0x323, + 0x73, 0x323, 0x53, 0x301, 0x307, 0x73, 0x301, 0x307, 0x53, 0x30c, + 0x307, 0x73, 0x30c, 0x307, 0x53, 0x323, 0x307, 0x73, 0x323, 0x307, + 0x54, 0x307, 0x74, 0x307, 0x54, 0x323, 0x74, 0x323, 0x54, 0x331, + 0x74, 0x331, 0x54, 0x32d, 0x74, 0x32d, 0x55, 0x324, 0x75, 0x324, + 0x55, 0x330, 0x75, 0x330, 0x55, 0x32d, 0x75, 0x32d, 0x55, 0x303, + 0x301, 0x75, 0x303, 0x301, 0x55, 0x304, 0x308, 0x75, 0x304, 0x308, + 0x56, 0x303, 0x76, 0x303, 0x56, 0x323, 0x76, 0x323, 0x57, 0x300, + 0x77, 0x300, 0x57, 0x301, 0x77, 0x301, 0x57, 0x308, 0x77, 0x308, + 0x57, 0x307, 0x77, 0x307, 0x57, 0x323, 0x77, 0x323, 0x58, 0x307, + 0x78, 0x307, 0x58, 0x308, 0x78, 0x308, 0x59, 0x307, 0x79, 0x307, + 0x5a, 0x302, 0x7a, 0x302, 0x5a, 0x323, 0x7a, 0x323, 0x5a, 0x331, + 0x7a, 0x331, 0x68, 0x331, 0x74, 0x308, 0x77, 0x30a, 0x79, 0x30a, + 0x17f, 0x307, 0x41, 0x323, 0x61, 0x323, 0x41, 0x309, 0x61, 0x309, + 0x41, 0x302, 0x301, 0x61, 0x302, 0x301, 0x41, 0x302, 0x300, 0x61, + 0x302, 0x300, 0x41, 0x302, 0x309, 0x61, 0x302, 0x309, 0x41, 0x302, + 0x303, 0x61, 0x302, 0x303, 0x41, 0x323, 0x302, 0x61, 0x323, 0x302, + 0x41, 0x306, 0x301, 0x61, 0x306, 0x301, 0x41, 0x306, 0x300, 0x61, + 0x306, 0x300, 0x41, 0x306, 0x309, 0x61, 0x306, 0x309, 0x41, 0x306, + 0x303, 0x61, 0x306, 0x303, 0x41, 0x323, 0x306, 0x61, 0x323, 0x306, + 0x45, 0x323, 0x65, 0x323, 0x45, 0x309, 0x65, 0x309, 0x45, 0x303, + 0x65, 0x303, 0x45, 0x302, 0x301, 0x65, 0x302, 0x301, 0x45, 0x302, + 0x300, 0x65, 0x302, 0x300, 0x45, 0x302, 0x309, 0x65, 0x302, 0x309, + 0x45, 0x302, 0x303, 0x65, 0x302, 0x303, 0x45, 0x323, 0x302, 0x65, + 0x323, 0x302, 0x49, 0x309, 0x69, 0x309, 0x49, 0x323, 0x69, 0x323, + 0x4f, 0x323, 0x6f, 0x323, 0x4f, 0x309, 0x6f, 0x309, 0x4f, 0x302, + 0x301, 0x6f, 0x302, 0x301, 0x4f, 0x302, 0x300, 0x6f, 0x302, 0x300, + 0x4f, 0x302, 0x309, 0x6f, 0x302, 0x309, 0x4f, 0x302, 0x303, 0x6f, + 0x302, 0x303, 0x4f, 0x323, 0x302, 0x6f, 0x323, 0x302, 0x4f, 0x31b, + 0x301, 0x6f, 0x31b, 0x301, 0x4f, 0x31b, 0x300, 0x6f, 0x31b, 0x300, + 0x4f, 0x31b, 0x309, 0x6f, 0x31b, 0x309, 0x4f, 0x31b, 0x303, 0x6f, + 0x31b, 0x303, 0x4f, 0x31b, 0x323, 0x6f, 0x31b, 0x323, 0x55, 0x323, + 0x75, 0x323, 0x55, 0x309, 0x75, 0x309, 0x55, 0x31b, 0x301, 0x75, + 0x31b, 0x301, 0x55, 0x31b, 0x300, 0x75, 0x31b, 0x300, 0x55, 0x31b, + 0x309, 0x75, 0x31b, 0x309, 0x55, 0x31b, 0x303, 0x75, 0x31b, 0x303, + 0x55, 0x31b, 0x323, 0x75, 0x31b, 0x323, 0x59, 0x300, 0x79, 0x300, + 0x59, 0x323, 0x79, 0x323, 0x59, 0x309, 0x79, 0x309, 0x59, 0x303, + 0x79, 0x303, 0x3b1, 0x313, 0x3b1, 0x314, 0x3b1, 0x313, 0x300, 0x3b1, + 0x314, 0x300, 0x3b1, 0x313, 0x301, 0x3b1, 0x314, 0x301, 0x3b1, 0x313, + 0x342, 0x3b1, 0x314, 0x342, 0x391, 0x313, 0x391, 0x314, 0x391, 0x313, + 0x300, 0x391, 0x314, 0x300, 0x391, 0x313, 0x301, 0x391, 0x314, 0x301, + 0x391, 0x313, 0x342, 0x391, 0x314, 0x342, 0x3b5, 0x313, 0x3b5, 0x314, + 0x3b5, 0x313, 0x300, 0x3b5, 0x314, 0x300, 0x3b5, 0x313, 0x301, 0x3b5, + 0x314, 0x301, 0x395, 0x313, 0x395, 0x314, 0x395, 0x313, 0x300, 0x395, + 0x314, 0x300, 0x395, 0x313, 0x301, 0x395, 0x314, 0x301, 0x3b7, 0x313, + 0x3b7, 0x314, 0x3b7, 0x313, 0x300, 0x3b7, 0x314, 0x300, 0x3b7, 0x313, + 0x301, 0x3b7, 0x314, 0x301, 0x3b7, 0x313, 0x342, 0x3b7, 0x314, 0x342, + 0x397, 0x313, 0x397, 0x314, 0x397, 0x313, 0x300, 0x397, 0x314, 0x300, + 0x397, 0x313, 0x301, 0x397, 0x314, 0x301, 0x397, 0x313, 0x342, 0x397, + 0x314, 0x342, 0x3b9, 0x313, 0x3b9, 0x314, 0x3b9, 0x313, 0x300, 0x3b9, + 0x314, 0x300, 0x3b9, 0x313, 0x301, 0x3b9, 0x314, 0x301, 0x3b9, 0x313, + 0x342, 0x3b9, 0x314, 0x342, 0x399, 0x313, 0x399, 0x314, 0x399, 0x313, + 0x300, 0x399, 0x314, 0x300, 0x399, 0x313, 0x301, 0x399, 0x314, 0x301, + 0x399, 0x313, 0x342, 0x399, 0x314, 0x342, 0x3bf, 0x313, 0x3bf, 0x314, + 0x3bf, 0x313, 0x300, 0x3bf, 0x314, 0x300, 0x3bf, 0x313, 0x301, 0x3bf, + 0x314, 0x301, 0x39f, 0x313, 0x39f, 0x314, 0x39f, 0x313, 0x300, 0x39f, + 0x314, 0x300, 0x39f, 0x313, 0x301, 0x39f, 0x314, 0x301, 0x3c5, 0x313, + 0x3c5, 0x314, 0x3c5, 0x313, 0x300, 0x3c5, 0x314, 0x300, 0x3c5, 0x313, + 0x301, 0x3c5, 0x314, 0x301, 0x3c5, 0x313, 0x342, 0x3c5, 0x314, 0x342, + 0x3a5, 0x314, 0x3a5, 0x314, 0x300, 0x3a5, 0x314, 0x301, 0x3a5, 0x314, + 0x342, 0x3c9, 0x313, 0x3c9, 0x314, 0x3c9, 0x313, 0x300, 0x3c9, 0x314, + 0x300, 0x3c9, 0x313, 0x301, 0x3c9, 0x314, 0x301, 0x3c9, 0x313, 0x342, + 0x3c9, 0x314, 0x342, 0x3a9, 0x313, 0x3a9, 0x314, 0x3a9, 0x313, 0x300, + 0x3a9, 0x314, 0x300, 0x3a9, 0x313, 0x301, 0x3a9, 0x314, 0x301, 0x3a9, + 0x313, 0x342, 0x3a9, 0x314, 0x342, 0x3b1, 0x300, 0x3b1, 0x301, 0x3b5, + 0x300, 0x3b5, 0x301, 0x3b7, 0x300, 0x3b7, 0x301, 0x3b9, 0x300, 0x3b9, + 0x301, 0x3bf, 0x300, 0x3bf, 0x301, 0x3c5, 0x300, 0x3c5, 0x301, 0x3c9, + 0x300, 0x3c9, 0x301, 0x3b1, 0x313, 0x345, 0x3b1, 0x314, 0x345, 0x3b1, + 0x313, 0x300, 0x345, 0x3b1, 0x314, 0x300, 0x345, 0x3b1, 0x313, 0x301, + 0x345, 0x3b1, 0x314, 0x301, 0x345, 0x3b1, 0x313, 0x342, 0x345, 0x3b1, + 0x314, 0x342, 0x345, 0x391, 0x313, 0x345, 0x391, 0x314, 0x345, 0x391, + 0x313, 0x300, 0x345, 0x391, 0x314, 0x300, 0x345, 0x391, 0x313, 0x301, + 0x345, 0x391, 0x314, 0x301, 0x345, 0x391, 0x313, 0x342, 0x345, 0x391, + 0x314, 0x342, 0x345, 0x3b7, 0x313, 0x345, 0x3b7, 0x314, 0x345, 0x3b7, + 0x313, 0x300, 0x345, 0x3b7, 0x314, 0x300, 0x345, 0x3b7, 0x313, 0x301, + 0x345, 0x3b7, 0x314, 0x301, 0x345, 0x3b7, 0x313, 0x342, 0x345, 0x3b7, + 0x314, 0x342, 0x345, 0x397, 0x313, 0x345, 0x397, 0x314, 0x345, 0x397, + 0x313, 0x300, 0x345, 0x397, 0x314, 0x300, 0x345, 0x397, 0x313, 0x301, + 0x345, 0x397, 0x314, 0x301, 0x345, 0x397, 0x313, 0x342, 0x345, 0x397, + 0x314, 0x342, 0x345, 0x3c9, 0x313, 0x345, 0x3c9, 0x314, 0x345, 0x3c9, + 0x313, 0x300, 0x345, 0x3c9, 0x314, 0x300, 0x345, 0x3c9, 0x313, 0x301, + 0x345, 0x3c9, 0x314, 0x301, 0x345, 0x3c9, 0x313, 0x342, 0x345, 0x3c9, + 0x314, 0x342, 0x345, 0x3a9, 0x313, 0x345, 0x3a9, 0x314, 0x345, 0x3a9, + 0x313, 0x300, 0x345, 0x3a9, 0x314, 0x300, 0x345, 0x3a9, 0x313, 0x301, + 0x345, 0x3a9, 0x314, 0x301, 0x345, 0x3a9, 0x313, 0x342, 0x345, 0x3a9, + 0x314, 0x342, 0x345, 0x3b1, 0x306, 0x3b1, 0x304, 0x3b1, 0x300, 0x345, + 0x3b1, 0x345, 0x3b1, 0x301, 0x345, 0x3b1, 0x342, 0x3b1, 0x342, 0x345, + 0x391, 0x306, 0x391, 0x304, 0x391, 0x300, 0x391, 0x301, 0x391, 0x345, + 0x3b9, 0xa8, 0x342, 0x3b7, 0x300, 0x345, 0x3b7, 0x345, 0x3b7, 0x301, + 0x345, 0x3b7, 0x342, 0x3b7, 0x342, 0x345, 0x395, 0x300, 0x395, 0x301, + 0x397, 0x300, 0x397, 0x301, 0x397, 0x345, 0x1fbf, 0x300, 0x1fbf, 0x301, + 0x1fbf, 0x342, 0x3b9, 0x306, 0x3b9, 0x304, 0x3b9, 0x308, 0x300, 0x3b9, + 0x308, 0x301, 0x3b9, 0x342, 0x3b9, 0x308, 0x342, 0x399, 0x306, 0x399, + 0x304, 0x399, 0x300, 0x399, 0x301, 0x1ffe, 0x300, 0x1ffe, 0x301, 0x1ffe, + 0x342, 0x3c5, 0x306, 0x3c5, 0x304, 0x3c5, 0x308, 0x300, 0x3c5, 0x308, + 0x301, 0x3c1, 0x313, 0x3c1, 0x314, 0x3c5, 0x342, 0x3c5, 0x308, 0x342, + 0x3a5, 0x306, 0x3a5, 0x304, 0x3a5, 0x300, 0x3a5, 0x301, 0x3a1, 0x314, + 0xa8, 0x300, 0xa8, 0x301, 0x60, 0x3c9, 0x300, 0x345, 0x3c9, 0x345, + 0x3c9, 0x301, 0x345, 0x3c9, 0x342, 0x3c9, 0x342, 0x345, 0x39f, 0x300, + 0x39f, 0x301, 0x3a9, 0x300, 0x3a9, 0x301, 0x3a9, 0x345, 0xb4, 0x2002, + 0x2003, 0x3a9, 0x4b, 0x41, 0x30a, 0x2190, 0x338, 0x2192, 0x338, 0x2194, + 0x338, 0x21d0, 0x338, 0x21d4, 0x338, 0x21d2, 0x338, 0x2203, 0x338, 0x2208, + 0x338, 0x220b, 0x338, 0x2223, 0x338, 0x2225, 0x338, 0x223c, 0x338, 0x2243, + 0x338, 0x2245, 0x338, 0x2248, 0x338, 0x3d, 0x338, 0x2261, 0x338, 0x224d, + 0x338, 0x3c, 0x338, 0x3e, 0x338, 0x2264, 0x338, 0x2265, 0x338, 0x2272, + 0x338, 0x2273, 0x338, 0x2276, 0x338, 0x2277, 0x338, 0x227a, 0x338, 0x227b, + 0x338, 0x2282, 0x338, 0x2283, 0x338, 0x2286, 0x338, 0x2287, 0x338, 0x22a2, + 0x338, 0x22a8, 0x338, 0x22a9, 0x338, 0x22ab, 0x338, 0x227c, 0x338, 0x227d, + 0x338, 0x2291, 0x338, 0x2292, 0x338, 0x22b2, 0x338, 0x22b3, 0x338, 0x22b4, + 0x338, 0x22b5, 0x338, 0x3008, 0x3009, 0x2add, 0x338, 0x304b, 0x3099, 0x304d, + 0x3099, 0x304f, 0x3099, 0x3051, 0x3099, 0x3053, 0x3099, 0x3055, 0x3099, 0x3057, + 0x3099, 0x3059, 0x3099, 0x305b, 0x3099, 0x305d, 0x3099, 0x305f, 0x3099, 0x3061, + 0x3099, 0x3064, 0x3099, 0x3066, 0x3099, 0x3068, 0x3099, 0x306f, 0x3099, 0x306f, + 0x309a, 0x3072, 0x3099, 0x3072, 0x309a, 0x3075, 0x3099, 0x3075, 0x309a, 0x3078, + 0x3099, 0x3078, 0x309a, 0x307b, 0x3099, 0x307b, 0x309a, 0x3046, 0x3099, 0x309d, + 0x3099, 0x30ab, 0x3099, 0x30ad, 0x3099, 0x30af, 0x3099, 0x30b1, 0x3099, 0x30b3, + 0x3099, 0x30b5, 0x3099, 0x30b7, 0x3099, 0x30b9, 0x3099, 0x30bb, 0x3099, 0x30bd, + 0x3099, 0x30bf, 0x3099, 0x30c1, 0x3099, 0x30c4, 0x3099, 0x30c6, 0x3099, 0x30c8, + 0x3099, 0x30cf, 0x3099, 0x30cf, 0x309a, 0x30d2, 0x3099, 0x30d2, 0x309a, 0x30d5, + 0x3099, 0x30d5, 0x309a, 0x30d8, 0x3099, 0x30d8, 0x309a, 0x30db, 0x3099, 0x30db, + 0x309a, 0x30a6, 0x3099, 0x30ef, 0x3099, 0x30f0, 0x3099, 0x30f1, 0x3099, 0x30f2, + 0x3099, 0x30fd, 0x3099, 0x8c48, 0x66f4, 0x8eca, 0x8cc8, 0x6ed1, 0x4e32, 0x53e5, + 0x9f9c, 0x9f9c, 0x5951, 0x91d1, 0x5587, 0x5948, 0x61f6, 0x7669, 0x7f85, 0x863f, + 0x87ba, 0x88f8, 0x908f, 0x6a02, 0x6d1b, 0x70d9, 0x73de, 0x843d, 0x916a, 0x99f1, + 0x4e82, 0x5375, 0x6b04, 0x721b, 0x862d, 0x9e1e, 0x5d50, 0x6feb, 0x85cd, 0x8964, + 0x62c9, 0x81d8, 0x881f, 0x5eca, 0x6717, 0x6d6a, 0x72fc, 0x90ce, 0x4f86, 0x51b7, + 0x52de, 0x64c4, 0x6ad3, 0x7210, 0x76e7, 0x8001, 0x8606, 0x865c, 0x8def, 0x9732, + 0x9b6f, 0x9dfa, 0x788c, 0x797f, 0x7da0, 0x83c9, 0x9304, 0x9e7f, 0x8ad6, 0x58df, + 0x5f04, 0x7c60, 0x807e, 0x7262, 0x78ca, 0x8cc2, 0x96f7, 0x58d8, 0x5c62, 0x6a13, + 0x6dda, 0x6f0f, 0x7d2f, 0x7e37, 0x964b, 0x52d2, 0x808b, 0x51dc, 0x51cc, 0x7a1c, + 0x7dbe, 0x83f1, 0x9675, 0x8b80, 0x62cf, 0x6a02, 0x8afe, 0x4e39, 0x5be7, 0x6012, + 0x7387, 0x7570, 0x5317, 0x78fb, 0x4fbf, 0x5fa9, 0x4e0d, 0x6ccc, 0x6578, 0x7d22, + 0x53c3, 0x585e, 0x7701, 0x8449, 0x8aaa, 0x6bba, 0x8fb0, 0x6c88, 0x62fe, 0x82e5, + 0x63a0, 0x7565, 0x4eae, 0x5169, 0x51c9, 0x6881, 0x7ce7, 0x826f, 0x8ad2, 0x91cf, + 0x52f5, 0x5442, 0x5973, 0x5eec, 0x65c5, 0x6ffe, 0x792a, 0x95ad, 0x9a6a, 0x9e97, + 0x9ece, 0x529b, 0x66c6, 0x6b77, 0x8f62, 0x5e74, 0x6190, 0x6200, 0x649a, 0x6f23, + 0x7149, 0x7489, 0x79ca, 0x7df4, 0x806f, 0x8f26, 0x84ee, 0x9023, 0x934a, 0x5217, + 0x52a3, 0x54bd, 0x70c8, 0x88c2, 0x8aaa, 0x5ec9, 0x5ff5, 0x637b, 0x6bae, 0x7c3e, + 0x7375, 0x4ee4, 0x56f9, 0x5be7, 0x5dba, 0x601c, 0x73b2, 0x7469, 0x7f9a, 0x8046, + 0x9234, 0x96f6, 0x9748, 0x9818, 0x4f8b, 0x79ae, 0x91b4, 0x96b8, 0x60e1, 0x4e86, + 0x50da, 0x5bee, 0x5c3f, 0x6599, 0x6a02, 0x71ce, 0x7642, 0x84fc, 0x907c, 0x9f8d, + 0x6688, 0x962e, 0x5289, 0x677b, 0x67f3, 0x6d41, 0x6e9c, 0x7409, 0x7559, 0x786b, + 0x7d10, 0x985e, 0x516d, 0x622e, 0x9678, 0x502b, 0x5d19, 0x6dea, 0x8f2a, 0x5f8b, + 0x6144, 0x6817, 0x7387, 0x9686, 0x5229, 0x540f, 0x5c65, 0x6613, 0x674e, 0x68a8, + 0x6ce5, 0x7406, 0x75e2, 0x7f79, 0x88cf, 0x88e1, 0x91cc, 0x96e2, 0x533f, 0x6eba, + 0x541d, 0x71d0, 0x7498, 0x85fa, 0x96a3, 0x9c57, 0x9e9f, 0x6797, 0x6dcb, 0x81e8, + 0x7acb, 0x7b20, 0x7c92, 0x72c0, 0x7099, 0x8b58, 0x4ec0, 0x8336, 0x523a, 0x5207, + 0x5ea6, 0x62d3, 0x7cd6, 0x5b85, 0x6d1e, 0x66b4, 0x8f3b, 0x884c, 0x964d, 0x898b, + 0x5ed3, 0x5140, 0x55c0, 0x585a, 0x6674, 0x51de, 0x732a, 0x76ca, 0x793c, 0x795e, + 0x7965, 0x798f, 0x9756, 0x7cbe, 0x7fbd, 0x8612, 0x8af8, 0x9038, 0x90fd, 0x98ef, + 0x98fc, 0x9928, 0x9db4, 0x90de, 0x96b7, 0x4fae, 0x50e7, 0x514d, 0x52c9, 0x52e4, + 0x5351, 0x559d, 0x5606, 0x5668, 0x5840, 0x58a8, 0x5c64, 0x5c6e, 0x6094, 0x6168, + 0x618e, 0x61f2, 0x654f, 0x65e2, 0x6691, 0x6885, 0x6d77, 0x6e1a, 0x6f22, 0x716e, + 0x722b, 0x7422, 0x7891, 0x793e, 0x7949, 0x7948, 0x7950, 0x7956, 0x795d, 0x798d, + 0x798e, 0x7a40, 0x7a81, 0x7bc0, 0x7df4, 0x7e09, 0x7e41, 0x7f72, 0x8005, 0x81ed, + 0x8279, 0x8279, 0x8457, 0x8910, 0x8996, 0x8b01, 0x8b39, 0x8cd3, 0x8d08, 0x8fb6, + 0x9038, 0x96e3, 0x97ff, 0x983b, 0x6075, 0x242ee, 0x8218, 0x4e26, 0x51b5, 0x5168, + 0x4f80, 0x5145, 0x5180, 0x52c7, 0x52fa, 0x559d, 0x5555, 0x5599, 0x55e2, 0x585a, + 0x58b3, 0x5944, 0x5954, 0x5a62, 0x5b28, 0x5ed2, 0x5ed9, 0x5f69, 0x5fad, 0x60d8, + 0x614e, 0x6108, 0x618e, 0x6160, 0x61f2, 0x6234, 0x63c4, 0x641c, 0x6452, 0x6556, + 0x6674, 0x6717, 0x671b, 0x6756, 0x6b79, 0x6bba, 0x6d41, 0x6edb, 0x6ecb, 0x6f22, + 0x701e, 0x716e, 0x77a7, 0x7235, 0x72af, 0x732a, 0x7471, 0x7506, 0x753b, 0x761d, + 0x761f, 0x76ca, 0x76db, 0x76f4, 0x774a, 0x7740, 0x78cc, 0x7ab1, 0x7bc0, 0x7c7b, + 0x7d5b, 0x7df4, 0x7f3e, 0x8005, 0x8352, 0x83ef, 0x8779, 0x8941, 0x8986, 0x8996, + 0x8abf, 0x8af8, 0x8acb, 0x8b01, 0x8afe, 0x8aed, 0x8b39, 0x8b8a, 0x8d08, 0x8f38, + 0x9072, 0x9199, 0x9276, 0x967c, 0x96e3, 0x9756, 0x97db, 0x97ff, 0x980b, 0x983b, + 0x9b12, 0x9f9c, 0x2284a, 0x22844, 0x233d5, 0x3b9d, 0x4018, 0x4039, 0x25249, 0x25cd0, + 0x27ed3, 0x9f43, 0x9f8e, 0x5d9, 0x5b4, 0x5f2, 0x5b7, 0x5e9, 0x5c1, 0x5e9, + 0x5c2, 0x5e9, 0x5bc, 0x5c1, 0x5e9, 0x5bc, 0x5c2, 0x5d0, 0x5b7, 0x5d0, + 0x5b8, 0x5d0, 0x5bc, 0x5d1, 0x5bc, 0x5d2, 0x5bc, 0x5d3, 0x5bc, 0x5d4, + 0x5bc, 0x5d5, 0x5bc, 0x5d6, 0x5bc, 0x5d8, 0x5bc, 0x5d9, 0x5bc, 0x5da, + 0x5bc, 0x5db, 0x5bc, 0x5dc, 0x5bc, 0x5de, 0x5bc, 0x5e0, 0x5bc, 0x5e1, + 0x5bc, 0x5e3, 0x5bc, 0x5e4, 0x5bc, 0x5e6, 0x5bc, 0x5e7, 0x5bc, 0x5e8, + 0x5bc, 0x5e9, 0x5bc, 0x5ea, 0x5bc, 0x5d5, 0x5b9, 0x5d1, 0x5bf, 0x5db, + 0x5bf, 0x5e4, 0x5bf, 0x105d2, 0x307, 0x105da, 0x307, 0x11099, 0x110ba, 0x1109b, + 0x110ba, 0x110a5, 0x110ba, 0x11131, 0x11127, 0x11132, 0x11127, 0x11347, 0x1133e, 0x11347, + 0x11357, 0x11382, 0x113c9, 0x11384, 0x113bb, 0x1138b, 0x113c2, 0x11390, 0x113c9, 0x113c2, + 0x113c2, 0x113c2, 0x113b8, 0x113c2, 0x113c9, 0x114b9, 0x114ba, 0x114b9, 0x114b0, 0x114b9, + 0x114bd, 0x115b8, 0x115af, 0x115b9, 0x115af, 0x11935, 0x11930, 0x1611e, 0x1611e, 0x1611e, + 0x16129, 0x1611e, 0x1611f, 0x16129, 0x1611f, 0x1611e, 0x16120, 0x1611e, 0x1611e, 0x1611f, + 0x1611e, 0x16129, 0x1611f, 0x1611e, 0x1611e, 0x16120, 0x16d67, 0x16d67, 0x16d63, 0x16d67, + 0x16d63, 0x16d67, 0x16d67, 0x1d157, 0x1d165, 0x1d158, 0x1d165, 0x1d158, 0x1d165, 0x1d16e, + 0x1d158, 0x1d165, 0x1d16f, 0x1d158, 0x1d165, 0x1d170, 0x1d158, 0x1d165, 0x1d171, 0x1d158, + 0x1d165, 0x1d172, 0x1d1b9, 0x1d165, 0x1d1ba, 0x1d165, 0x1d1b9, 0x1d165, 0x1d16e, 0x1d1ba, + 0x1d165, 0x1d16e, 0x1d1b9, 0x1d165, 0x1d16f, 0x1d1ba, 0x1d165, 0x1d16f, 0x4e3d, 0x4e38, + 0x4e41, 0x20122, 0x4f60, 0x4fae, 0x4fbb, 0x5002, 0x507a, 0x5099, 0x50e7, 0x50cf, + 0x349e, 0x2063a, 0x514d, 0x5154, 0x5164, 0x5177, 0x2051c, 0x34b9, 0x5167, 0x518d, + 0x2054b, 0x5197, 0x51a4, 0x4ecc, 0x51ac, 0x51b5, 0x291df, 0x51f5, 0x5203, 0x34df, + 0x523b, 0x5246, 0x5272, 0x5277, 0x3515, 0x52c7, 0x52c9, 0x52e4, 0x52fa, 0x5305, + 0x5306, 0x5317, 0x5349, 0x5351, 0x535a, 0x5373, 0x537d, 0x537f, 0x537f, 0x537f, + 0x20a2c, 0x7070, 0x53ca, 0x53df, 0x20b63, 0x53eb, 0x53f1, 0x5406, 0x549e, 0x5438, + 0x5448, 0x5468, 0x54a2, 0x54f6, 0x5510, 0x5553, 0x5563, 0x5584, 0x5584, 0x5599, + 0x55ab, 0x55b3, 0x55c2, 0x5716, 0x5606, 0x5717, 0x5651, 0x5674, 0x5207, 0x58ee, + 0x57ce, 0x57f4, 0x580d, 0x578b, 0x5832, 0x5831, 0x58ac, 0x214e4, 0x58f2, 0x58f7, + 0x5906, 0x591a, 0x5922, 0x5962, 0x216a8, 0x216ea, 0x59ec, 0x5a1b, 0x5a27, 0x59d8, + 0x5a66, 0x36ee, 0x36fc, 0x5b08, 0x5b3e, 0x5b3e, 0x219c8, 0x5bc3, 0x5bd8, 0x5be7, + 0x5bf3, 0x21b18, 0x5bff, 0x5c06, 0x5f53, 0x5c22, 0x3781, 0x5c60, 0x5c6e, 0x5cc0, + 0x5c8d, 0x21de4, 0x5d43, 0x21de6, 0x5d6e, 0x5d6b, 0x5d7c, 0x5de1, 0x5de2, 0x382f, + 0x5dfd, 0x5e28, 0x5e3d, 0x5e69, 0x3862, 0x22183, 0x387c, 0x5eb0, 0x5eb3, 0x5eb6, + 0x5eca, 0x2a392, 0x5efe, 0x22331, 0x22331, 0x8201, 0x5f22, 0x5f22, 0x38c7, 0x232b8, + 0x261da, 0x5f62, 0x5f6b, 0x38e3, 0x5f9a, 0x5fcd, 0x5fd7, 0x5ff9, 0x6081, 0x393a, + 0x391c, 0x6094, 0x226d4, 0x60c7, 0x6148, 0x614c, 0x614e, 0x614c, 0x617a, 0x618e, + 0x61b2, 0x61a4, 0x61af, 0x61de, 0x61f2, 0x61f6, 0x6210, 0x621b, 0x625d, 0x62b1, + 0x62d4, 0x6350, 0x22b0c, 0x633d, 0x62fc, 0x6368, 0x6383, 0x63e4, 0x22bf1, 0x6422, + 0x63c5, 0x63a9, 0x3a2e, 0x6469, 0x647e, 0x649d, 0x6477, 0x3a6c, 0x654f, 0x656c, + 0x2300a, 0x65e3, 0x66f8, 0x6649, 0x3b19, 0x6691, 0x3b08, 0x3ae4, 0x5192, 0x5195, + 0x6700, 0x669c, 0x80ad, 0x43d9, 0x6717, 0x671b, 0x6721, 0x675e, 0x6753, 0x233c3, + 0x3b49, 0x67fa, 0x6785, 0x6852, 0x6885, 0x2346d, 0x688e, 0x681f, 0x6914, 0x3b9d, + 0x6942, 0x69a3, 0x69ea, 0x6aa8, 0x236a3, 0x6adb, 0x3c18, 0x6b21, 0x238a7, 0x6b54, + 0x3c4e, 0x6b72, 0x6b9f, 0x6bba, 0x6bbb, 0x23a8d, 0x21d0b, 0x23afa, 0x6c4e, 0x23cbc, + 0x6cbf, 0x6ccd, 0x6c67, 0x6d16, 0x6d3e, 0x6d77, 0x6d41, 0x6d69, 0x6d78, 0x6d85, + 0x23d1e, 0x6d34, 0x6e2f, 0x6e6e, 0x3d33, 0x6ecb, 0x6ec7, 0x23ed1, 0x6df9, 0x6f6e, + 0x23f5e, 0x23f8e, 0x6fc6, 0x7039, 0x701e, 0x701b, 0x3d96, 0x704a, 0x707d, 0x7077, + 0x70ad, 0x20525, 0x7145, 0x24263, 0x719c, 0x243ab, 0x7228, 0x7235, 0x7250, 0x24608, + 0x7280, 0x7295, 0x24735, 0x24814, 0x737a, 0x738b, 0x3eac, 0x73a5, 0x3eb8, 0x3eb8, + 0x7447, 0x745c, 0x7471, 0x7485, 0x74ca, 0x3f1b, 0x7524, 0x24c36, 0x753e, 0x24c92, + 0x7570, 0x2219f, 0x7610, 0x24fa1, 0x24fb8, 0x25044, 0x3ffc, 0x4008, 0x76f4, 0x250f3, + 0x250f2, 0x25119, 0x25133, 0x771e, 0x771f, 0x771f, 0x774a, 0x4039, 0x778b, 0x4046, + 0x4096, 0x2541d, 0x784e, 0x788c, 0x78cc, 0x40e3, 0x25626, 0x7956, 0x2569a, 0x256c5, + 0x798f, 0x79eb, 0x412f, 0x7a40, 0x7a4a, 0x7a4f, 0x2597c, 0x25aa7, 0x25aa7, 0x7aee, + 0x4202, 0x25bab, 0x7bc6, 0x7bc9, 0x4227, 0x25c80, 0x7cd2, 0x42a0, 0x7ce8, 0x7ce3, + 0x7d00, 0x25f86, 0x7d63, 0x4301, 0x7dc7, 0x7e02, 0x7e45, 0x4334, 0x26228, 0x26247, + 0x4359, 0x262d9, 0x7f7a, 0x2633e, 0x7f95, 0x7ffa, 0x8005, 0x264da, 0x26523, 0x8060, + 0x265a8, 0x8070, 0x2335f, 0x43d5, 0x80b2, 0x8103, 0x440b, 0x813e, 0x5ab5, 0x267a7, + 0x267b5, 0x23393, 0x2339c, 0x8201, 0x8204, 0x8f9e, 0x446b, 0x8291, 0x828b, 0x829d, + 0x52b3, 0x82b1, 0x82b3, 0x82bd, 0x82e6, 0x26b3c, 0x82e5, 0x831d, 0x8363, 0x83ad, + 0x8323, 0x83bd, 0x83e7, 0x8457, 0x8353, 0x83ca, 0x83cc, 0x83dc, 0x26c36, 0x26d6b, + 0x26cd5, 0x452b, 0x84f1, 0x84f3, 0x8516, 0x273ca, 0x8564, 0x26f2c, 0x455d, 0x4561, + 0x26fb1, 0x270d2, 0x456b, 0x8650, 0x865c, 0x8667, 0x8669, 0x86a9, 0x8688, 0x870e, + 0x86e2, 0x8779, 0x8728, 0x876b, 0x8786, 0x45d7, 0x87e1, 0x8801, 0x45f9, 0x8860, + 0x8863, 0x27667, 0x88d7, 0x88de, 0x4635, 0x88fa, 0x34bb, 0x278ae, 0x27966, 0x46be, + 0x46c7, 0x8aa0, 0x8aed, 0x8b8a, 0x8c55, 0x27ca8, 0x8cab, 0x8cc1, 0x8d1b, 0x8d77, + 0x27f2f, 0x20804, 0x8dcb, 0x8dbc, 0x8df0, 0x208de, 0x8ed4, 0x8f38, 0x285d2, 0x285ed, + 0x9094, 0x90f1, 0x9111, 0x2872e, 0x911b, 0x9238, 0x92d7, 0x92d8, 0x927c, 0x93f9, + 0x9415, 0x28bfa, 0x958b, 0x4995, 0x95b7, 0x28d77, 0x49e6, 0x96c3, 0x5db2, 0x9723, + 0x29145, 0x2921a, 0x4a6e, 0x4a76, 0x97e0, 0x2940a, 0x4ab2, 0x29496, 0x980b, 0x980b, + 0x9829, 0x295b6, 0x98e2, 0x4b33, 0x9929, 0x99a7, 0x99c2, 0x99fe, 0x4bce, 0x29b30, + 0x9b12, 0x9c40, 0x9cfd, 0x4cce, 0x4ced, 0x9d67, 0x2a0ce, 0x4cf8, 0x2a105, 0x2a20e, + 0x2a291, 0x9ebb, 0x4d56, 0x9ef9, 0x9efe, 0x9f05, 0x9f0f, 0x9f16, 0x9f3b, 0x2a600, +}; + +TP_PRIVATE const tp_compose_pair tp_uni_compose[TP_UNI_COMPOSE_N] = { + {0x3c, 0x338, 0x226e}, {0x3d, 0x338, 0x2260}, {0x3e, 0x338, 0x226f}, {0x41, 0x300, 0xc0}, + {0x41, 0x301, 0xc1}, {0x41, 0x302, 0xc2}, {0x41, 0x303, 0xc3}, {0x41, 0x304, 0x100}, + {0x41, 0x306, 0x102}, {0x41, 0x307, 0x226}, {0x41, 0x308, 0xc4}, {0x41, 0x309, 0x1ea2}, + {0x41, 0x30a, 0xc5}, {0x41, 0x30c, 0x1cd}, {0x41, 0x30f, 0x200}, {0x41, 0x311, 0x202}, + {0x41, 0x323, 0x1ea0}, {0x41, 0x325, 0x1e00}, {0x41, 0x328, 0x104}, {0x42, 0x307, 0x1e02}, + {0x42, 0x323, 0x1e04}, {0x42, 0x331, 0x1e06}, {0x43, 0x301, 0x106}, {0x43, 0x302, 0x108}, + {0x43, 0x307, 0x10a}, {0x43, 0x30c, 0x10c}, {0x43, 0x327, 0xc7}, {0x44, 0x307, 0x1e0a}, + {0x44, 0x30c, 0x10e}, {0x44, 0x323, 0x1e0c}, {0x44, 0x327, 0x1e10}, {0x44, 0x32d, 0x1e12}, + {0x44, 0x331, 0x1e0e}, {0x45, 0x300, 0xc8}, {0x45, 0x301, 0xc9}, {0x45, 0x302, 0xca}, + {0x45, 0x303, 0x1ebc}, {0x45, 0x304, 0x112}, {0x45, 0x306, 0x114}, {0x45, 0x307, 0x116}, + {0x45, 0x308, 0xcb}, {0x45, 0x309, 0x1eba}, {0x45, 0x30c, 0x11a}, {0x45, 0x30f, 0x204}, + {0x45, 0x311, 0x206}, {0x45, 0x323, 0x1eb8}, {0x45, 0x327, 0x228}, {0x45, 0x328, 0x118}, + {0x45, 0x32d, 0x1e18}, {0x45, 0x330, 0x1e1a}, {0x46, 0x307, 0x1e1e}, {0x47, 0x301, 0x1f4}, + {0x47, 0x302, 0x11c}, {0x47, 0x304, 0x1e20}, {0x47, 0x306, 0x11e}, {0x47, 0x307, 0x120}, + {0x47, 0x30c, 0x1e6}, {0x47, 0x327, 0x122}, {0x48, 0x302, 0x124}, {0x48, 0x307, 0x1e22}, + {0x48, 0x308, 0x1e26}, {0x48, 0x30c, 0x21e}, {0x48, 0x323, 0x1e24}, {0x48, 0x327, 0x1e28}, + {0x48, 0x32e, 0x1e2a}, {0x49, 0x300, 0xcc}, {0x49, 0x301, 0xcd}, {0x49, 0x302, 0xce}, + {0x49, 0x303, 0x128}, {0x49, 0x304, 0x12a}, {0x49, 0x306, 0x12c}, {0x49, 0x307, 0x130}, + {0x49, 0x308, 0xcf}, {0x49, 0x309, 0x1ec8}, {0x49, 0x30c, 0x1cf}, {0x49, 0x30f, 0x208}, + {0x49, 0x311, 0x20a}, {0x49, 0x323, 0x1eca}, {0x49, 0x328, 0x12e}, {0x49, 0x330, 0x1e2c}, + {0x4a, 0x302, 0x134}, {0x4b, 0x301, 0x1e30}, {0x4b, 0x30c, 0x1e8}, {0x4b, 0x323, 0x1e32}, + {0x4b, 0x327, 0x136}, {0x4b, 0x331, 0x1e34}, {0x4c, 0x301, 0x139}, {0x4c, 0x30c, 0x13d}, + {0x4c, 0x323, 0x1e36}, {0x4c, 0x327, 0x13b}, {0x4c, 0x32d, 0x1e3c}, {0x4c, 0x331, 0x1e3a}, + {0x4d, 0x301, 0x1e3e}, {0x4d, 0x307, 0x1e40}, {0x4d, 0x323, 0x1e42}, {0x4e, 0x300, 0x1f8}, + {0x4e, 0x301, 0x143}, {0x4e, 0x303, 0xd1}, {0x4e, 0x307, 0x1e44}, {0x4e, 0x30c, 0x147}, + {0x4e, 0x323, 0x1e46}, {0x4e, 0x327, 0x145}, {0x4e, 0x32d, 0x1e4a}, {0x4e, 0x331, 0x1e48}, + {0x4f, 0x300, 0xd2}, {0x4f, 0x301, 0xd3}, {0x4f, 0x302, 0xd4}, {0x4f, 0x303, 0xd5}, + {0x4f, 0x304, 0x14c}, {0x4f, 0x306, 0x14e}, {0x4f, 0x307, 0x22e}, {0x4f, 0x308, 0xd6}, + {0x4f, 0x309, 0x1ece}, {0x4f, 0x30b, 0x150}, {0x4f, 0x30c, 0x1d1}, {0x4f, 0x30f, 0x20c}, + {0x4f, 0x311, 0x20e}, {0x4f, 0x31b, 0x1a0}, {0x4f, 0x323, 0x1ecc}, {0x4f, 0x328, 0x1ea}, + {0x50, 0x301, 0x1e54}, {0x50, 0x307, 0x1e56}, {0x52, 0x301, 0x154}, {0x52, 0x307, 0x1e58}, + {0x52, 0x30c, 0x158}, {0x52, 0x30f, 0x210}, {0x52, 0x311, 0x212}, {0x52, 0x323, 0x1e5a}, + {0x52, 0x327, 0x156}, {0x52, 0x331, 0x1e5e}, {0x53, 0x301, 0x15a}, {0x53, 0x302, 0x15c}, + {0x53, 0x307, 0x1e60}, {0x53, 0x30c, 0x160}, {0x53, 0x323, 0x1e62}, {0x53, 0x326, 0x218}, + {0x53, 0x327, 0x15e}, {0x54, 0x307, 0x1e6a}, {0x54, 0x30c, 0x164}, {0x54, 0x323, 0x1e6c}, + {0x54, 0x326, 0x21a}, {0x54, 0x327, 0x162}, {0x54, 0x32d, 0x1e70}, {0x54, 0x331, 0x1e6e}, + {0x55, 0x300, 0xd9}, {0x55, 0x301, 0xda}, {0x55, 0x302, 0xdb}, {0x55, 0x303, 0x168}, + {0x55, 0x304, 0x16a}, {0x55, 0x306, 0x16c}, {0x55, 0x308, 0xdc}, {0x55, 0x309, 0x1ee6}, + {0x55, 0x30a, 0x16e}, {0x55, 0x30b, 0x170}, {0x55, 0x30c, 0x1d3}, {0x55, 0x30f, 0x214}, + {0x55, 0x311, 0x216}, {0x55, 0x31b, 0x1af}, {0x55, 0x323, 0x1ee4}, {0x55, 0x324, 0x1e72}, + {0x55, 0x328, 0x172}, {0x55, 0x32d, 0x1e76}, {0x55, 0x330, 0x1e74}, {0x56, 0x303, 0x1e7c}, + {0x56, 0x323, 0x1e7e}, {0x57, 0x300, 0x1e80}, {0x57, 0x301, 0x1e82}, {0x57, 0x302, 0x174}, + {0x57, 0x307, 0x1e86}, {0x57, 0x308, 0x1e84}, {0x57, 0x323, 0x1e88}, {0x58, 0x307, 0x1e8a}, + {0x58, 0x308, 0x1e8c}, {0x59, 0x300, 0x1ef2}, {0x59, 0x301, 0xdd}, {0x59, 0x302, 0x176}, + {0x59, 0x303, 0x1ef8}, {0x59, 0x304, 0x232}, {0x59, 0x307, 0x1e8e}, {0x59, 0x308, 0x178}, + {0x59, 0x309, 0x1ef6}, {0x59, 0x323, 0x1ef4}, {0x5a, 0x301, 0x179}, {0x5a, 0x302, 0x1e90}, + {0x5a, 0x307, 0x17b}, {0x5a, 0x30c, 0x17d}, {0x5a, 0x323, 0x1e92}, {0x5a, 0x331, 0x1e94}, + {0x61, 0x300, 0xe0}, {0x61, 0x301, 0xe1}, {0x61, 0x302, 0xe2}, {0x61, 0x303, 0xe3}, + {0x61, 0x304, 0x101}, {0x61, 0x306, 0x103}, {0x61, 0x307, 0x227}, {0x61, 0x308, 0xe4}, + {0x61, 0x309, 0x1ea3}, {0x61, 0x30a, 0xe5}, {0x61, 0x30c, 0x1ce}, {0x61, 0x30f, 0x201}, + {0x61, 0x311, 0x203}, {0x61, 0x323, 0x1ea1}, {0x61, 0x325, 0x1e01}, {0x61, 0x328, 0x105}, + {0x62, 0x307, 0x1e03}, {0x62, 0x323, 0x1e05}, {0x62, 0x331, 0x1e07}, {0x63, 0x301, 0x107}, + {0x63, 0x302, 0x109}, {0x63, 0x307, 0x10b}, {0x63, 0x30c, 0x10d}, {0x63, 0x327, 0xe7}, + {0x64, 0x307, 0x1e0b}, {0x64, 0x30c, 0x10f}, {0x64, 0x323, 0x1e0d}, {0x64, 0x327, 0x1e11}, + {0x64, 0x32d, 0x1e13}, {0x64, 0x331, 0x1e0f}, {0x65, 0x300, 0xe8}, {0x65, 0x301, 0xe9}, + {0x65, 0x302, 0xea}, {0x65, 0x303, 0x1ebd}, {0x65, 0x304, 0x113}, {0x65, 0x306, 0x115}, + {0x65, 0x307, 0x117}, {0x65, 0x308, 0xeb}, {0x65, 0x309, 0x1ebb}, {0x65, 0x30c, 0x11b}, + {0x65, 0x30f, 0x205}, {0x65, 0x311, 0x207}, {0x65, 0x323, 0x1eb9}, {0x65, 0x327, 0x229}, + {0x65, 0x328, 0x119}, {0x65, 0x32d, 0x1e19}, {0x65, 0x330, 0x1e1b}, {0x66, 0x307, 0x1e1f}, + {0x67, 0x301, 0x1f5}, {0x67, 0x302, 0x11d}, {0x67, 0x304, 0x1e21}, {0x67, 0x306, 0x11f}, + {0x67, 0x307, 0x121}, {0x67, 0x30c, 0x1e7}, {0x67, 0x327, 0x123}, {0x68, 0x302, 0x125}, + {0x68, 0x307, 0x1e23}, {0x68, 0x308, 0x1e27}, {0x68, 0x30c, 0x21f}, {0x68, 0x323, 0x1e25}, + {0x68, 0x327, 0x1e29}, {0x68, 0x32e, 0x1e2b}, {0x68, 0x331, 0x1e96}, {0x69, 0x300, 0xec}, + {0x69, 0x301, 0xed}, {0x69, 0x302, 0xee}, {0x69, 0x303, 0x129}, {0x69, 0x304, 0x12b}, + {0x69, 0x306, 0x12d}, {0x69, 0x308, 0xef}, {0x69, 0x309, 0x1ec9}, {0x69, 0x30c, 0x1d0}, + {0x69, 0x30f, 0x209}, {0x69, 0x311, 0x20b}, {0x69, 0x323, 0x1ecb}, {0x69, 0x328, 0x12f}, + {0x69, 0x330, 0x1e2d}, {0x6a, 0x302, 0x135}, {0x6a, 0x30c, 0x1f0}, {0x6b, 0x301, 0x1e31}, + {0x6b, 0x30c, 0x1e9}, {0x6b, 0x323, 0x1e33}, {0x6b, 0x327, 0x137}, {0x6b, 0x331, 0x1e35}, + {0x6c, 0x301, 0x13a}, {0x6c, 0x30c, 0x13e}, {0x6c, 0x323, 0x1e37}, {0x6c, 0x327, 0x13c}, + {0x6c, 0x32d, 0x1e3d}, {0x6c, 0x331, 0x1e3b}, {0x6d, 0x301, 0x1e3f}, {0x6d, 0x307, 0x1e41}, + {0x6d, 0x323, 0x1e43}, {0x6e, 0x300, 0x1f9}, {0x6e, 0x301, 0x144}, {0x6e, 0x303, 0xf1}, + {0x6e, 0x307, 0x1e45}, {0x6e, 0x30c, 0x148}, {0x6e, 0x323, 0x1e47}, {0x6e, 0x327, 0x146}, + {0x6e, 0x32d, 0x1e4b}, {0x6e, 0x331, 0x1e49}, {0x6f, 0x300, 0xf2}, {0x6f, 0x301, 0xf3}, + {0x6f, 0x302, 0xf4}, {0x6f, 0x303, 0xf5}, {0x6f, 0x304, 0x14d}, {0x6f, 0x306, 0x14f}, + {0x6f, 0x307, 0x22f}, {0x6f, 0x308, 0xf6}, {0x6f, 0x309, 0x1ecf}, {0x6f, 0x30b, 0x151}, + {0x6f, 0x30c, 0x1d2}, {0x6f, 0x30f, 0x20d}, {0x6f, 0x311, 0x20f}, {0x6f, 0x31b, 0x1a1}, + {0x6f, 0x323, 0x1ecd}, {0x6f, 0x328, 0x1eb}, {0x70, 0x301, 0x1e55}, {0x70, 0x307, 0x1e57}, + {0x72, 0x301, 0x155}, {0x72, 0x307, 0x1e59}, {0x72, 0x30c, 0x159}, {0x72, 0x30f, 0x211}, + {0x72, 0x311, 0x213}, {0x72, 0x323, 0x1e5b}, {0x72, 0x327, 0x157}, {0x72, 0x331, 0x1e5f}, + {0x73, 0x301, 0x15b}, {0x73, 0x302, 0x15d}, {0x73, 0x307, 0x1e61}, {0x73, 0x30c, 0x161}, + {0x73, 0x323, 0x1e63}, {0x73, 0x326, 0x219}, {0x73, 0x327, 0x15f}, {0x74, 0x307, 0x1e6b}, + {0x74, 0x308, 0x1e97}, {0x74, 0x30c, 0x165}, {0x74, 0x323, 0x1e6d}, {0x74, 0x326, 0x21b}, + {0x74, 0x327, 0x163}, {0x74, 0x32d, 0x1e71}, {0x74, 0x331, 0x1e6f}, {0x75, 0x300, 0xf9}, + {0x75, 0x301, 0xfa}, {0x75, 0x302, 0xfb}, {0x75, 0x303, 0x169}, {0x75, 0x304, 0x16b}, + {0x75, 0x306, 0x16d}, {0x75, 0x308, 0xfc}, {0x75, 0x309, 0x1ee7}, {0x75, 0x30a, 0x16f}, + {0x75, 0x30b, 0x171}, {0x75, 0x30c, 0x1d4}, {0x75, 0x30f, 0x215}, {0x75, 0x311, 0x217}, + {0x75, 0x31b, 0x1b0}, {0x75, 0x323, 0x1ee5}, {0x75, 0x324, 0x1e73}, {0x75, 0x328, 0x173}, + {0x75, 0x32d, 0x1e77}, {0x75, 0x330, 0x1e75}, {0x76, 0x303, 0x1e7d}, {0x76, 0x323, 0x1e7f}, + {0x77, 0x300, 0x1e81}, {0x77, 0x301, 0x1e83}, {0x77, 0x302, 0x175}, {0x77, 0x307, 0x1e87}, + {0x77, 0x308, 0x1e85}, {0x77, 0x30a, 0x1e98}, {0x77, 0x323, 0x1e89}, {0x78, 0x307, 0x1e8b}, + {0x78, 0x308, 0x1e8d}, {0x79, 0x300, 0x1ef3}, {0x79, 0x301, 0xfd}, {0x79, 0x302, 0x177}, + {0x79, 0x303, 0x1ef9}, {0x79, 0x304, 0x233}, {0x79, 0x307, 0x1e8f}, {0x79, 0x308, 0xff}, + {0x79, 0x309, 0x1ef7}, {0x79, 0x30a, 0x1e99}, {0x79, 0x323, 0x1ef5}, {0x7a, 0x301, 0x17a}, + {0x7a, 0x302, 0x1e91}, {0x7a, 0x307, 0x17c}, {0x7a, 0x30c, 0x17e}, {0x7a, 0x323, 0x1e93}, + {0x7a, 0x331, 0x1e95}, {0xa8, 0x300, 0x1fed}, {0xa8, 0x301, 0x385}, {0xa8, 0x342, 0x1fc1}, + {0xc2, 0x300, 0x1ea6}, {0xc2, 0x301, 0x1ea4}, {0xc2, 0x303, 0x1eaa}, {0xc2, 0x309, 0x1ea8}, + {0xc4, 0x304, 0x1de}, {0xc5, 0x301, 0x1fa}, {0xc6, 0x301, 0x1fc}, {0xc6, 0x304, 0x1e2}, + {0xc7, 0x301, 0x1e08}, {0xca, 0x300, 0x1ec0}, {0xca, 0x301, 0x1ebe}, {0xca, 0x303, 0x1ec4}, + {0xca, 0x309, 0x1ec2}, {0xcf, 0x301, 0x1e2e}, {0xd4, 0x300, 0x1ed2}, {0xd4, 0x301, 0x1ed0}, + {0xd4, 0x303, 0x1ed6}, {0xd4, 0x309, 0x1ed4}, {0xd5, 0x301, 0x1e4c}, {0xd5, 0x304, 0x22c}, + {0xd5, 0x308, 0x1e4e}, {0xd6, 0x304, 0x22a}, {0xd8, 0x301, 0x1fe}, {0xdc, 0x300, 0x1db}, + {0xdc, 0x301, 0x1d7}, {0xdc, 0x304, 0x1d5}, {0xdc, 0x30c, 0x1d9}, {0xe2, 0x300, 0x1ea7}, + {0xe2, 0x301, 0x1ea5}, {0xe2, 0x303, 0x1eab}, {0xe2, 0x309, 0x1ea9}, {0xe4, 0x304, 0x1df}, + {0xe5, 0x301, 0x1fb}, {0xe6, 0x301, 0x1fd}, {0xe6, 0x304, 0x1e3}, {0xe7, 0x301, 0x1e09}, + {0xea, 0x300, 0x1ec1}, {0xea, 0x301, 0x1ebf}, {0xea, 0x303, 0x1ec5}, {0xea, 0x309, 0x1ec3}, + {0xef, 0x301, 0x1e2f}, {0xf4, 0x300, 0x1ed3}, {0xf4, 0x301, 0x1ed1}, {0xf4, 0x303, 0x1ed7}, + {0xf4, 0x309, 0x1ed5}, {0xf5, 0x301, 0x1e4d}, {0xf5, 0x304, 0x22d}, {0xf5, 0x308, 0x1e4f}, + {0xf6, 0x304, 0x22b}, {0xf8, 0x301, 0x1ff}, {0xfc, 0x300, 0x1dc}, {0xfc, 0x301, 0x1d8}, + {0xfc, 0x304, 0x1d6}, {0xfc, 0x30c, 0x1da}, {0x102, 0x300, 0x1eb0}, {0x102, 0x301, 0x1eae}, + {0x102, 0x303, 0x1eb4}, {0x102, 0x309, 0x1eb2}, {0x103, 0x300, 0x1eb1}, {0x103, 0x301, 0x1eaf}, + {0x103, 0x303, 0x1eb5}, {0x103, 0x309, 0x1eb3}, {0x112, 0x300, 0x1e14}, {0x112, 0x301, 0x1e16}, + {0x113, 0x300, 0x1e15}, {0x113, 0x301, 0x1e17}, {0x14c, 0x300, 0x1e50}, {0x14c, 0x301, 0x1e52}, + {0x14d, 0x300, 0x1e51}, {0x14d, 0x301, 0x1e53}, {0x15a, 0x307, 0x1e64}, {0x15b, 0x307, 0x1e65}, + {0x160, 0x307, 0x1e66}, {0x161, 0x307, 0x1e67}, {0x168, 0x301, 0x1e78}, {0x169, 0x301, 0x1e79}, + {0x16a, 0x308, 0x1e7a}, {0x16b, 0x308, 0x1e7b}, {0x17f, 0x307, 0x1e9b}, {0x1a0, 0x300, 0x1edc}, + {0x1a0, 0x301, 0x1eda}, {0x1a0, 0x303, 0x1ee0}, {0x1a0, 0x309, 0x1ede}, {0x1a0, 0x323, 0x1ee2}, + {0x1a1, 0x300, 0x1edd}, {0x1a1, 0x301, 0x1edb}, {0x1a1, 0x303, 0x1ee1}, {0x1a1, 0x309, 0x1edf}, + {0x1a1, 0x323, 0x1ee3}, {0x1af, 0x300, 0x1eea}, {0x1af, 0x301, 0x1ee8}, {0x1af, 0x303, 0x1eee}, + {0x1af, 0x309, 0x1eec}, {0x1af, 0x323, 0x1ef0}, {0x1b0, 0x300, 0x1eeb}, {0x1b0, 0x301, 0x1ee9}, + {0x1b0, 0x303, 0x1eef}, {0x1b0, 0x309, 0x1eed}, {0x1b0, 0x323, 0x1ef1}, {0x1b7, 0x30c, 0x1ee}, + {0x1ea, 0x304, 0x1ec}, {0x1eb, 0x304, 0x1ed}, {0x226, 0x304, 0x1e0}, {0x227, 0x304, 0x1e1}, + {0x228, 0x306, 0x1e1c}, {0x229, 0x306, 0x1e1d}, {0x22e, 0x304, 0x230}, {0x22f, 0x304, 0x231}, + {0x292, 0x30c, 0x1ef}, {0x391, 0x300, 0x1fba}, {0x391, 0x301, 0x386}, {0x391, 0x304, 0x1fb9}, + {0x391, 0x306, 0x1fb8}, {0x391, 0x313, 0x1f08}, {0x391, 0x314, 0x1f09}, {0x391, 0x345, 0x1fbc}, + {0x395, 0x300, 0x1fc8}, {0x395, 0x301, 0x388}, {0x395, 0x313, 0x1f18}, {0x395, 0x314, 0x1f19}, + {0x397, 0x300, 0x1fca}, {0x397, 0x301, 0x389}, {0x397, 0x313, 0x1f28}, {0x397, 0x314, 0x1f29}, + {0x397, 0x345, 0x1fcc}, {0x399, 0x300, 0x1fda}, {0x399, 0x301, 0x38a}, {0x399, 0x304, 0x1fd9}, + {0x399, 0x306, 0x1fd8}, {0x399, 0x308, 0x3aa}, {0x399, 0x313, 0x1f38}, {0x399, 0x314, 0x1f39}, + {0x39f, 0x300, 0x1ff8}, {0x39f, 0x301, 0x38c}, {0x39f, 0x313, 0x1f48}, {0x39f, 0x314, 0x1f49}, + {0x3a1, 0x314, 0x1fec}, {0x3a5, 0x300, 0x1fea}, {0x3a5, 0x301, 0x38e}, {0x3a5, 0x304, 0x1fe9}, + {0x3a5, 0x306, 0x1fe8}, {0x3a5, 0x308, 0x3ab}, {0x3a5, 0x314, 0x1f59}, {0x3a9, 0x300, 0x1ffa}, + {0x3a9, 0x301, 0x38f}, {0x3a9, 0x313, 0x1f68}, {0x3a9, 0x314, 0x1f69}, {0x3a9, 0x345, 0x1ffc}, + {0x3ac, 0x345, 0x1fb4}, {0x3ae, 0x345, 0x1fc4}, {0x3b1, 0x300, 0x1f70}, {0x3b1, 0x301, 0x3ac}, + {0x3b1, 0x304, 0x1fb1}, {0x3b1, 0x306, 0x1fb0}, {0x3b1, 0x313, 0x1f00}, {0x3b1, 0x314, 0x1f01}, + {0x3b1, 0x342, 0x1fb6}, {0x3b1, 0x345, 0x1fb3}, {0x3b5, 0x300, 0x1f72}, {0x3b5, 0x301, 0x3ad}, + {0x3b5, 0x313, 0x1f10}, {0x3b5, 0x314, 0x1f11}, {0x3b7, 0x300, 0x1f74}, {0x3b7, 0x301, 0x3ae}, + {0x3b7, 0x313, 0x1f20}, {0x3b7, 0x314, 0x1f21}, {0x3b7, 0x342, 0x1fc6}, {0x3b7, 0x345, 0x1fc3}, + {0x3b9, 0x300, 0x1f76}, {0x3b9, 0x301, 0x3af}, {0x3b9, 0x304, 0x1fd1}, {0x3b9, 0x306, 0x1fd0}, + {0x3b9, 0x308, 0x3ca}, {0x3b9, 0x313, 0x1f30}, {0x3b9, 0x314, 0x1f31}, {0x3b9, 0x342, 0x1fd6}, + {0x3bf, 0x300, 0x1f78}, {0x3bf, 0x301, 0x3cc}, {0x3bf, 0x313, 0x1f40}, {0x3bf, 0x314, 0x1f41}, + {0x3c1, 0x313, 0x1fe4}, {0x3c1, 0x314, 0x1fe5}, {0x3c5, 0x300, 0x1f7a}, {0x3c5, 0x301, 0x3cd}, + {0x3c5, 0x304, 0x1fe1}, {0x3c5, 0x306, 0x1fe0}, {0x3c5, 0x308, 0x3cb}, {0x3c5, 0x313, 0x1f50}, + {0x3c5, 0x314, 0x1f51}, {0x3c5, 0x342, 0x1fe6}, {0x3c9, 0x300, 0x1f7c}, {0x3c9, 0x301, 0x3ce}, + {0x3c9, 0x313, 0x1f60}, {0x3c9, 0x314, 0x1f61}, {0x3c9, 0x342, 0x1ff6}, {0x3c9, 0x345, 0x1ff3}, + {0x3ca, 0x300, 0x1fd2}, {0x3ca, 0x301, 0x390}, {0x3ca, 0x342, 0x1fd7}, {0x3cb, 0x300, 0x1fe2}, + {0x3cb, 0x301, 0x3b0}, {0x3cb, 0x342, 0x1fe7}, {0x3ce, 0x345, 0x1ff4}, {0x3d2, 0x301, 0x3d3}, + {0x3d2, 0x308, 0x3d4}, {0x406, 0x308, 0x407}, {0x410, 0x306, 0x4d0}, {0x410, 0x308, 0x4d2}, + {0x413, 0x301, 0x403}, {0x415, 0x300, 0x400}, {0x415, 0x306, 0x4d6}, {0x415, 0x308, 0x401}, + {0x416, 0x306, 0x4c1}, {0x416, 0x308, 0x4dc}, {0x417, 0x308, 0x4de}, {0x418, 0x300, 0x40d}, + {0x418, 0x304, 0x4e2}, {0x418, 0x306, 0x419}, {0x418, 0x308, 0x4e4}, {0x41a, 0x301, 0x40c}, + {0x41e, 0x308, 0x4e6}, {0x423, 0x304, 0x4ee}, {0x423, 0x306, 0x40e}, {0x423, 0x308, 0x4f0}, + {0x423, 0x30b, 0x4f2}, {0x427, 0x308, 0x4f4}, {0x42b, 0x308, 0x4f8}, {0x42d, 0x308, 0x4ec}, + {0x430, 0x306, 0x4d1}, {0x430, 0x308, 0x4d3}, {0x433, 0x301, 0x453}, {0x435, 0x300, 0x450}, + {0x435, 0x306, 0x4d7}, {0x435, 0x308, 0x451}, {0x436, 0x306, 0x4c2}, {0x436, 0x308, 0x4dd}, + {0x437, 0x308, 0x4df}, {0x438, 0x300, 0x45d}, {0x438, 0x304, 0x4e3}, {0x438, 0x306, 0x439}, + {0x438, 0x308, 0x4e5}, {0x43a, 0x301, 0x45c}, {0x43e, 0x308, 0x4e7}, {0x443, 0x304, 0x4ef}, + {0x443, 0x306, 0x45e}, {0x443, 0x308, 0x4f1}, {0x443, 0x30b, 0x4f3}, {0x447, 0x308, 0x4f5}, + {0x44b, 0x308, 0x4f9}, {0x44d, 0x308, 0x4ed}, {0x456, 0x308, 0x457}, {0x474, 0x30f, 0x476}, + {0x475, 0x30f, 0x477}, {0x4d8, 0x308, 0x4da}, {0x4d9, 0x308, 0x4db}, {0x4e8, 0x308, 0x4ea}, + {0x4e9, 0x308, 0x4eb}, {0x627, 0x653, 0x622}, {0x627, 0x654, 0x623}, {0x627, 0x655, 0x625}, + {0x648, 0x654, 0x624}, {0x64a, 0x654, 0x626}, {0x6c1, 0x654, 0x6c2}, {0x6d2, 0x654, 0x6d3}, + {0x6d5, 0x654, 0x6c0}, {0x928, 0x93c, 0x929}, {0x930, 0x93c, 0x931}, {0x933, 0x93c, 0x934}, + {0x9c7, 0x9be, 0x9cb}, {0x9c7, 0x9d7, 0x9cc}, {0xb47, 0xb3e, 0xb4b}, {0xb47, 0xb56, 0xb48}, + {0xb47, 0xb57, 0xb4c}, {0xb92, 0xbd7, 0xb94}, {0xbc6, 0xbbe, 0xbca}, {0xbc6, 0xbd7, 0xbcc}, + {0xbc7, 0xbbe, 0xbcb}, {0xc46, 0xc56, 0xc48}, {0xcbf, 0xcd5, 0xcc0}, {0xcc6, 0xcc2, 0xcca}, + {0xcc6, 0xcd5, 0xcc7}, {0xcc6, 0xcd6, 0xcc8}, {0xcca, 0xcd5, 0xccb}, {0xd46, 0xd3e, 0xd4a}, + {0xd46, 0xd57, 0xd4c}, {0xd47, 0xd3e, 0xd4b}, {0xdd9, 0xdca, 0xdda}, {0xdd9, 0xdcf, 0xddc}, + {0xdd9, 0xddf, 0xdde}, {0xddc, 0xdca, 0xddd}, {0x1025, 0x102e, 0x1026}, {0x1b05, 0x1b35, 0x1b06}, + {0x1b07, 0x1b35, 0x1b08}, {0x1b09, 0x1b35, 0x1b0a}, {0x1b0b, 0x1b35, 0x1b0c}, + {0x1b0d, 0x1b35, 0x1b0e}, {0x1b11, 0x1b35, 0x1b12}, {0x1b3a, 0x1b35, 0x1b3b}, + {0x1b3c, 0x1b35, 0x1b3d}, {0x1b3e, 0x1b35, 0x1b40}, {0x1b3f, 0x1b35, 0x1b41}, + {0x1b42, 0x1b35, 0x1b43}, {0x1e36, 0x304, 0x1e38}, {0x1e37, 0x304, 0x1e39}, + {0x1e5a, 0x304, 0x1e5c}, {0x1e5b, 0x304, 0x1e5d}, {0x1e62, 0x307, 0x1e68}, + {0x1e63, 0x307, 0x1e69}, {0x1ea0, 0x302, 0x1eac}, {0x1ea0, 0x306, 0x1eb6}, + {0x1ea1, 0x302, 0x1ead}, {0x1ea1, 0x306, 0x1eb7}, {0x1eb8, 0x302, 0x1ec6}, + {0x1eb9, 0x302, 0x1ec7}, {0x1ecc, 0x302, 0x1ed8}, {0x1ecd, 0x302, 0x1ed9}, + {0x1f00, 0x300, 0x1f02}, {0x1f00, 0x301, 0x1f04}, {0x1f00, 0x342, 0x1f06}, + {0x1f00, 0x345, 0x1f80}, {0x1f01, 0x300, 0x1f03}, {0x1f01, 0x301, 0x1f05}, + {0x1f01, 0x342, 0x1f07}, {0x1f01, 0x345, 0x1f81}, {0x1f02, 0x345, 0x1f82}, + {0x1f03, 0x345, 0x1f83}, {0x1f04, 0x345, 0x1f84}, {0x1f05, 0x345, 0x1f85}, + {0x1f06, 0x345, 0x1f86}, {0x1f07, 0x345, 0x1f87}, {0x1f08, 0x300, 0x1f0a}, + {0x1f08, 0x301, 0x1f0c}, {0x1f08, 0x342, 0x1f0e}, {0x1f08, 0x345, 0x1f88}, + {0x1f09, 0x300, 0x1f0b}, {0x1f09, 0x301, 0x1f0d}, {0x1f09, 0x342, 0x1f0f}, + {0x1f09, 0x345, 0x1f89}, {0x1f0a, 0x345, 0x1f8a}, {0x1f0b, 0x345, 0x1f8b}, + {0x1f0c, 0x345, 0x1f8c}, {0x1f0d, 0x345, 0x1f8d}, {0x1f0e, 0x345, 0x1f8e}, + {0x1f0f, 0x345, 0x1f8f}, {0x1f10, 0x300, 0x1f12}, {0x1f10, 0x301, 0x1f14}, + {0x1f11, 0x300, 0x1f13}, {0x1f11, 0x301, 0x1f15}, {0x1f18, 0x300, 0x1f1a}, + {0x1f18, 0x301, 0x1f1c}, {0x1f19, 0x300, 0x1f1b}, {0x1f19, 0x301, 0x1f1d}, + {0x1f20, 0x300, 0x1f22}, {0x1f20, 0x301, 0x1f24}, {0x1f20, 0x342, 0x1f26}, + {0x1f20, 0x345, 0x1f90}, {0x1f21, 0x300, 0x1f23}, {0x1f21, 0x301, 0x1f25}, + {0x1f21, 0x342, 0x1f27}, {0x1f21, 0x345, 0x1f91}, {0x1f22, 0x345, 0x1f92}, + {0x1f23, 0x345, 0x1f93}, {0x1f24, 0x345, 0x1f94}, {0x1f25, 0x345, 0x1f95}, + {0x1f26, 0x345, 0x1f96}, {0x1f27, 0x345, 0x1f97}, {0x1f28, 0x300, 0x1f2a}, + {0x1f28, 0x301, 0x1f2c}, {0x1f28, 0x342, 0x1f2e}, {0x1f28, 0x345, 0x1f98}, + {0x1f29, 0x300, 0x1f2b}, {0x1f29, 0x301, 0x1f2d}, {0x1f29, 0x342, 0x1f2f}, + {0x1f29, 0x345, 0x1f99}, {0x1f2a, 0x345, 0x1f9a}, {0x1f2b, 0x345, 0x1f9b}, + {0x1f2c, 0x345, 0x1f9c}, {0x1f2d, 0x345, 0x1f9d}, {0x1f2e, 0x345, 0x1f9e}, + {0x1f2f, 0x345, 0x1f9f}, {0x1f30, 0x300, 0x1f32}, {0x1f30, 0x301, 0x1f34}, + {0x1f30, 0x342, 0x1f36}, {0x1f31, 0x300, 0x1f33}, {0x1f31, 0x301, 0x1f35}, + {0x1f31, 0x342, 0x1f37}, {0x1f38, 0x300, 0x1f3a}, {0x1f38, 0x301, 0x1f3c}, + {0x1f38, 0x342, 0x1f3e}, {0x1f39, 0x300, 0x1f3b}, {0x1f39, 0x301, 0x1f3d}, + {0x1f39, 0x342, 0x1f3f}, {0x1f40, 0x300, 0x1f42}, {0x1f40, 0x301, 0x1f44}, + {0x1f41, 0x300, 0x1f43}, {0x1f41, 0x301, 0x1f45}, {0x1f48, 0x300, 0x1f4a}, + {0x1f48, 0x301, 0x1f4c}, {0x1f49, 0x300, 0x1f4b}, {0x1f49, 0x301, 0x1f4d}, + {0x1f50, 0x300, 0x1f52}, {0x1f50, 0x301, 0x1f54}, {0x1f50, 0x342, 0x1f56}, + {0x1f51, 0x300, 0x1f53}, {0x1f51, 0x301, 0x1f55}, {0x1f51, 0x342, 0x1f57}, + {0x1f59, 0x300, 0x1f5b}, {0x1f59, 0x301, 0x1f5d}, {0x1f59, 0x342, 0x1f5f}, + {0x1f60, 0x300, 0x1f62}, {0x1f60, 0x301, 0x1f64}, {0x1f60, 0x342, 0x1f66}, + {0x1f60, 0x345, 0x1fa0}, {0x1f61, 0x300, 0x1f63}, {0x1f61, 0x301, 0x1f65}, + {0x1f61, 0x342, 0x1f67}, {0x1f61, 0x345, 0x1fa1}, {0x1f62, 0x345, 0x1fa2}, + {0x1f63, 0x345, 0x1fa3}, {0x1f64, 0x345, 0x1fa4}, {0x1f65, 0x345, 0x1fa5}, + {0x1f66, 0x345, 0x1fa6}, {0x1f67, 0x345, 0x1fa7}, {0x1f68, 0x300, 0x1f6a}, + {0x1f68, 0x301, 0x1f6c}, {0x1f68, 0x342, 0x1f6e}, {0x1f68, 0x345, 0x1fa8}, + {0x1f69, 0x300, 0x1f6b}, {0x1f69, 0x301, 0x1f6d}, {0x1f69, 0x342, 0x1f6f}, + {0x1f69, 0x345, 0x1fa9}, {0x1f6a, 0x345, 0x1faa}, {0x1f6b, 0x345, 0x1fab}, + {0x1f6c, 0x345, 0x1fac}, {0x1f6d, 0x345, 0x1fad}, {0x1f6e, 0x345, 0x1fae}, + {0x1f6f, 0x345, 0x1faf}, {0x1f70, 0x345, 0x1fb2}, {0x1f74, 0x345, 0x1fc2}, + {0x1f7c, 0x345, 0x1ff2}, {0x1fb6, 0x345, 0x1fb7}, {0x1fbf, 0x300, 0x1fcd}, + {0x1fbf, 0x301, 0x1fce}, {0x1fbf, 0x342, 0x1fcf}, {0x1fc6, 0x345, 0x1fc7}, + {0x1ff6, 0x345, 0x1ff7}, {0x1ffe, 0x300, 0x1fdd}, {0x1ffe, 0x301, 0x1fde}, + {0x1ffe, 0x342, 0x1fdf}, {0x2190, 0x338, 0x219a}, {0x2192, 0x338, 0x219b}, + {0x2194, 0x338, 0x21ae}, {0x21d0, 0x338, 0x21cd}, {0x21d2, 0x338, 0x21cf}, + {0x21d4, 0x338, 0x21ce}, {0x2203, 0x338, 0x2204}, {0x2208, 0x338, 0x2209}, + {0x220b, 0x338, 0x220c}, {0x2223, 0x338, 0x2224}, {0x2225, 0x338, 0x2226}, + {0x223c, 0x338, 0x2241}, {0x2243, 0x338, 0x2244}, {0x2245, 0x338, 0x2247}, + {0x2248, 0x338, 0x2249}, {0x224d, 0x338, 0x226d}, {0x2261, 0x338, 0x2262}, + {0x2264, 0x338, 0x2270}, {0x2265, 0x338, 0x2271}, {0x2272, 0x338, 0x2274}, + {0x2273, 0x338, 0x2275}, {0x2276, 0x338, 0x2278}, {0x2277, 0x338, 0x2279}, + {0x227a, 0x338, 0x2280}, {0x227b, 0x338, 0x2281}, {0x227c, 0x338, 0x22e0}, + {0x227d, 0x338, 0x22e1}, {0x2282, 0x338, 0x2284}, {0x2283, 0x338, 0x2285}, + {0x2286, 0x338, 0x2288}, {0x2287, 0x338, 0x2289}, {0x2291, 0x338, 0x22e2}, + {0x2292, 0x338, 0x22e3}, {0x22a2, 0x338, 0x22ac}, {0x22a8, 0x338, 0x22ad}, + {0x22a9, 0x338, 0x22ae}, {0x22ab, 0x338, 0x22af}, {0x22b2, 0x338, 0x22ea}, + {0x22b3, 0x338, 0x22eb}, {0x22b4, 0x338, 0x22ec}, {0x22b5, 0x338, 0x22ed}, + {0x3046, 0x3099, 0x3094}, {0x304b, 0x3099, 0x304c}, {0x304d, 0x3099, 0x304e}, + {0x304f, 0x3099, 0x3050}, {0x3051, 0x3099, 0x3052}, {0x3053, 0x3099, 0x3054}, + {0x3055, 0x3099, 0x3056}, {0x3057, 0x3099, 0x3058}, {0x3059, 0x3099, 0x305a}, + {0x305b, 0x3099, 0x305c}, {0x305d, 0x3099, 0x305e}, {0x305f, 0x3099, 0x3060}, + {0x3061, 0x3099, 0x3062}, {0x3064, 0x3099, 0x3065}, {0x3066, 0x3099, 0x3067}, + {0x3068, 0x3099, 0x3069}, {0x306f, 0x3099, 0x3070}, {0x306f, 0x309a, 0x3071}, + {0x3072, 0x3099, 0x3073}, {0x3072, 0x309a, 0x3074}, {0x3075, 0x3099, 0x3076}, + {0x3075, 0x309a, 0x3077}, {0x3078, 0x3099, 0x3079}, {0x3078, 0x309a, 0x307a}, + {0x307b, 0x3099, 0x307c}, {0x307b, 0x309a, 0x307d}, {0x309d, 0x3099, 0x309e}, + {0x30a6, 0x3099, 0x30f4}, {0x30ab, 0x3099, 0x30ac}, {0x30ad, 0x3099, 0x30ae}, + {0x30af, 0x3099, 0x30b0}, {0x30b1, 0x3099, 0x30b2}, {0x30b3, 0x3099, 0x30b4}, + {0x30b5, 0x3099, 0x30b6}, {0x30b7, 0x3099, 0x30b8}, {0x30b9, 0x3099, 0x30ba}, + {0x30bb, 0x3099, 0x30bc}, {0x30bd, 0x3099, 0x30be}, {0x30bf, 0x3099, 0x30c0}, + {0x30c1, 0x3099, 0x30c2}, {0x30c4, 0x3099, 0x30c5}, {0x30c6, 0x3099, 0x30c7}, + {0x30c8, 0x3099, 0x30c9}, {0x30cf, 0x3099, 0x30d0}, {0x30cf, 0x309a, 0x30d1}, + {0x30d2, 0x3099, 0x30d3}, {0x30d2, 0x309a, 0x30d4}, {0x30d5, 0x3099, 0x30d6}, + {0x30d5, 0x309a, 0x30d7}, {0x30d8, 0x3099, 0x30d9}, {0x30d8, 0x309a, 0x30da}, + {0x30db, 0x3099, 0x30dc}, {0x30db, 0x309a, 0x30dd}, {0x30ef, 0x3099, 0x30f7}, + {0x30f0, 0x3099, 0x30f8}, {0x30f1, 0x3099, 0x30f9}, {0x30f2, 0x3099, 0x30fa}, + {0x30fd, 0x3099, 0x30fe}, {0x105d2, 0x307, 0x105c9}, {0x105da, 0x307, 0x105e4}, + {0x11099, 0x110ba, 0x1109a}, {0x1109b, 0x110ba, 0x1109c}, {0x110a5, 0x110ba, 0x110ab}, + {0x11131, 0x11127, 0x1112e}, {0x11132, 0x11127, 0x1112f}, {0x11347, 0x1133e, 0x1134b}, + {0x11347, 0x11357, 0x1134c}, {0x11382, 0x113c9, 0x11383}, {0x11384, 0x113bb, 0x11385}, + {0x1138b, 0x113c2, 0x1138e}, {0x11390, 0x113c9, 0x11391}, {0x113c2, 0x113b8, 0x113c7}, + {0x113c2, 0x113c2, 0x113c5}, {0x113c2, 0x113c9, 0x113c8}, {0x114b9, 0x114b0, 0x114bc}, + {0x114b9, 0x114ba, 0x114bb}, {0x114b9, 0x114bd, 0x114be}, {0x115b8, 0x115af, 0x115ba}, + {0x115b9, 0x115af, 0x115bb}, {0x11935, 0x11930, 0x11938}, {0x1611e, 0x1611e, 0x16121}, + {0x1611e, 0x1611f, 0x16123}, {0x1611e, 0x16120, 0x16125}, {0x1611e, 0x16129, 0x16122}, + {0x16121, 0x1611f, 0x16126}, {0x16121, 0x16120, 0x16128}, {0x16122, 0x1611f, 0x16127}, + {0x16129, 0x1611f, 0x16124}, {0x16d63, 0x16d67, 0x16d69}, {0x16d67, 0x16d67, 0x16d68}, + {0x16d69, 0x16d67, 0x16d6a}, +}; + +TP_PRIVATE const tp_uni_range tp_uni_nfc_no[TP_UNI_NFC_NO_N] = { + {0x340, 0x341}, {0x343, 0x344}, {0x374, 0x374}, {0x37e, 0x37e}, {0x387, 0x387}, {0x958, 0x95f}, + {0x9dc, 0x9dd}, {0x9df, 0x9df}, {0xa33, 0xa33}, {0xa36, 0xa36}, {0xa59, 0xa5b}, {0xa5e, 0xa5e}, + {0xb5c, 0xb5d}, {0xf43, 0xf43}, {0xf4d, 0xf4d}, {0xf52, 0xf52}, {0xf57, 0xf57}, {0xf5c, 0xf5c}, + {0xf69, 0xf69}, {0xf73, 0xf73}, {0xf75, 0xf76}, {0xf78, 0xf78}, {0xf81, 0xf81}, {0xf93, 0xf93}, + {0xf9d, 0xf9d}, {0xfa2, 0xfa2}, {0xfa7, 0xfa7}, {0xfac, 0xfac}, {0xfb9, 0xfb9}, {0x1f71, 0x1f71}, + {0x1f73, 0x1f73}, {0x1f75, 0x1f75}, {0x1f77, 0x1f77}, {0x1f79, 0x1f79}, {0x1f7b, 0x1f7b}, + {0x1f7d, 0x1f7d}, {0x1fbb, 0x1fbb}, {0x1fbe, 0x1fbe}, {0x1fc9, 0x1fc9}, {0x1fcb, 0x1fcb}, + {0x1fd3, 0x1fd3}, {0x1fdb, 0x1fdb}, {0x1fe3, 0x1fe3}, {0x1feb, 0x1feb}, {0x1fee, 0x1fef}, + {0x1ff9, 0x1ff9}, {0x1ffb, 0x1ffb}, {0x1ffd, 0x1ffd}, {0x2000, 0x2001}, {0x2126, 0x2126}, + {0x212a, 0x212b}, {0x2329, 0x232a}, {0x2adc, 0x2adc}, {0xf900, 0xfa0d}, {0xfa10, 0xfa10}, + {0xfa12, 0xfa12}, {0xfa15, 0xfa1e}, {0xfa20, 0xfa20}, {0xfa22, 0xfa22}, {0xfa25, 0xfa26}, + {0xfa2a, 0xfa6d}, {0xfa70, 0xfad9}, {0xfb1d, 0xfb1d}, {0xfb1f, 0xfb1f}, {0xfb2a, 0xfb36}, + {0xfb38, 0xfb3c}, {0xfb3e, 0xfb3e}, {0xfb40, 0xfb41}, {0xfb43, 0xfb44}, {0xfb46, 0xfb4e}, + {0x1d15e, 0x1d164}, {0x1d1bb, 0x1d1c0}, {0x2f800, 0x2fa1d}, +}; + +TP_PRIVATE const tp_uni_range tp_uni_compose_second[TP_UNI_COMPOSE_SECOND_N] = { + {0x300, 0x304}, {0x306, 0x30c}, {0x30f, 0x30f}, {0x311, 0x311}, {0x313, 0x314}, {0x31b, 0x31b}, + {0x323, 0x328}, {0x32d, 0x32e}, {0x330, 0x331}, {0x338, 0x338}, {0x342, 0x342}, {0x345, 0x345}, + {0x653, 0x655}, {0x93c, 0x93c}, {0x9be, 0x9be}, {0x9d7, 0x9d7}, {0xb3e, 0xb3e}, {0xb56, 0xb57}, + {0xbbe, 0xbbe}, {0xbd7, 0xbd7}, {0xc56, 0xc56}, {0xcc2, 0xcc2}, {0xcd5, 0xcd6}, {0xd3e, 0xd3e}, + {0xd57, 0xd57}, {0xdca, 0xdca}, {0xdcf, 0xdcf}, {0xddf, 0xddf}, {0x102e, 0x102e}, + {0x1161, 0x1175}, {0x11a8, 0x11c2}, {0x1b35, 0x1b35}, {0x3099, 0x309a}, {0x110ba, 0x110ba}, + {0x11127, 0x11127}, {0x1133e, 0x1133e}, {0x11357, 0x11357}, {0x113b8, 0x113b8}, + {0x113bb, 0x113bb}, {0x113c2, 0x113c2}, {0x113c9, 0x113c9}, {0x114b0, 0x114b0}, + {0x114ba, 0x114ba}, {0x114bd, 0x114bd}, {0x115af, 0x115af}, {0x11930, 0x11930}, + {0x1611e, 0x16120}, {0x16129, 0x16129}, {0x16d67, 0x16d67}, +}; diff --git a/c/src/unicode_gen.h b/c/src/unicode_gen.h new file mode 100644 index 0000000..1e0bda7 --- /dev/null +++ b/c/src/unicode_gen.h @@ -0,0 +1,87 @@ +/* Code generated by c/scripts/gen_unicode.mjs; DO NOT EDIT. + * Run `node c/scripts/gen_unicode.mjs` to regenerate. + * + * Tables taken from the JS reference engine (Node), so the Unicode version is Node's and not + * the platform's: categories L and Lu (R0.6), toLowerCase() (R0.4) and NFC/NFD (R1, R0.4). + * The method behind the combining class ranks is described in c/scripts/unicode_derive.mjs + * and go/scripts/gen_unicode.mjs. */ +/* Unicode 17.0 */ +#ifndef TP_UNICODE_GEN_H +#define TP_UNICODE_GEN_H + +#include "unicode.h" + +/* Linkage of generated tables. A declaration needs the complete type: the amalgamation makes + * these static, and a static tentative declaration must have a complete type. In the + * separate-files build they are extern, so the header declares and data_gen.c / unicode_gen.c + * define. */ +#ifndef TP_PRIVATE_DATA +#ifdef TRACKPARSE_AMALGAMATION +#define TP_PRIVATE_DATA static +#else +#define TP_PRIVATE_DATA extern +#endif +#endif + +/* The Unicode version of Node's tables these were generated from. */ +#define TP_UNICODE_VERSION "17.0" + +/* tp_uni_letter: general category L (Lu, Ll, Lt, Lm, Lo), JS /\p{L}/u. */ +#define TP_UNI_LETTER_N 684 +TP_PRIVATE_DATA const tp_uni_range tp_uni_letter[TP_UNI_LETTER_N]; + +/* tp_uni_upper: general category Lu, JS /\p{Lu}/u. */ +#define TP_UNI_UPPER_N 655 +TP_PRIVATE_DATA const tp_uni_range tp_uni_upper[TP_UNI_UPPER_N]; + +/* tp_uni_cased: property Cased, read by the final-sigma rule. */ +#define TP_UNI_CASED_N 158 +TP_PRIVATE_DATA const tp_uni_range tp_uni_cased[TP_UNI_CASED_N]; + +/* tp_uni_case_ignorable: property Case_Ignorable, read by the final-sigma rule. */ +#define TP_UNI_CASE_IGNORABLE_N 464 +TP_PRIVATE_DATA const tp_uni_range tp_uni_case_ignorable[TP_UNI_CASE_IGNORABLE_N]; + +/* tp_uni_lower: JS toLowerCase() of one code point. Every first + k*step <= last maps + * to itself plus delta. Sorted by first, no overlaps. */ +#define TP_UNI_LOWER_N 185 +TP_PRIVATE_DATA const tp_lower_run tp_uni_lower[TP_UNI_LOWER_N]; + +/* tp_uni_lower_multi: code points whose lowercase is several code points (UTF-8). Sorted. */ +#define TP_UNI_LOWER_MULTI_N 1 +TP_PRIVATE_DATA const tp_lower_multi tp_uni_lower_multi[TP_UNI_LOWER_MULTI_N]; + +/* tp_uni_ccc: canonical combining class ranks of the code points that are their own NFD; 0 + * when absent. Ranks keep the order and equality of the classes, which is all normalization + * uses. */ +#define TP_UNI_CCC_N 404 +TP_PRIVATE_DATA const tp_ccc_range tp_uni_ccc[TP_UNI_CCC_N]; + +/* tp_uni_decomp: full canonical decomposition (NFD) of every code point that has one, except + * the Hangul syllables: tp_uni_decomp_pool[off .. off+len). Sorted by code point. */ +#define TP_UNI_DECOMP_N 2081 +TP_PRIVATE_DATA const tp_decomp_entry tp_uni_decomp[TP_UNI_DECOMP_N]; + +/* tp_uni_decomp_pool: the code points of tp_uni_decomp. */ +#define TP_UNI_DECOMP_POOL_N 3450 +TP_PRIVATE_DATA const tp_rune tp_uni_decomp_pool[TP_UNI_DECOMP_POOL_N]; + +/* tp_uni_compose: canonical composition pairs (first, second) -> primary composite, without + * the Hangul syllables and the composition exclusions. Sorted by first, then second. */ +#define TP_UNI_COMPOSE_N 961 +TP_PRIVATE_DATA const tp_compose_pair tp_uni_compose[TP_UNI_COMPOSE_N]; + +/* tp_uni_nfc_no: code points that NFC changes on their own (NFC_Quick_Check=No). */ +#define TP_UNI_NFC_NO_N 73 +TP_PRIVATE_DATA const tp_uni_range tp_uni_nfc_no[TP_UNI_NFC_NO_N]; + +/* tp_uni_compose_second: code points that can compose with what precedes them + * (NFC_Quick_Check=Maybe). */ +#define TP_UNI_COMPOSE_SECOND_N 49 +TP_PRIVATE_DATA const tp_uni_range tp_uni_compose_second[TP_UNI_COMPOSE_SECOND_N]; + +/* Every code point below it is a starter that neither normalization form changes and that + * never composes with what precedes it. */ +#define TP_UNI_QUICK_MIN 0xc0 + +#endif /* TP_UNICODE_GEN_H */ diff --git a/c/src/words.c b/c/src/words.c new file mode 100644 index 0000000..cec7e05 --- /dev/null +++ b/c/src/words.c @@ -0,0 +1,452 @@ +/* words.c: low-level text helpers shared by every rule (go/words.go). See words.h. */ +#include "words.h" + +/* ------------------------------------------------------------------------------------------ */ +/* Rune slices */ + +TP_PRIVATE tp_rune tp_at(tp_runes t, ptrdiff_t i) { + if (i < 0 || (size_t)i >= t.n) return TP_NORUNE; + return t.p[i]; +} + +TP_PRIVATE tp_rune tp_before(tp_runes t, ptrdiff_t i) { return tp_at(t, i - 1); } + +TP_PRIVATE tp_runes tp_sub(tp_runes t, ptrdiff_t a, ptrdiff_t b) { + ptrdiff_t n = (ptrdiff_t)t.n; + if (b > n) b = n; + if (b < 0) b = 0; + if (a > b) a = b; + if (a < 0) a = 0; + tp_runes out = {t.p + a, (size_t)(b - a)}; + return out; +} + +TP_PRIVATE tp_runes tp_tail(tp_runes t, ptrdiff_t a) { return tp_sub(t, a, (ptrdiff_t)t.n); } + +/* ------------------------------------------------------------------------------------------ */ +/* Whitespace (R0.2) and JS trim() */ + +TP_PRIVATE bool tp_is_whitespace(tp_rune r) { + return (r >= 0x09 && r <= 0x0d) || r == 0x20 || r == 0x85 || r == 0xa0 || r == 0x1680 || + (r >= 0x2000 && r <= 0x200a) || r == 0x2028 || r == 0x2029 || r == 0x202f || r == 0x205f || + r == 0x3000; +} + +TP_PRIVATE bool tp_is_js_space(tp_rune r) { + return (r >= 0x09 && r <= 0x0d) || r == 0x20 || r == 0xa0 || r == 0x1680 || + (r >= 0x2000 && r <= 0x200a) || r == 0x2028 || r == 0x2029 || r == 0x202f || r == 0x205f || + r == 0x3000 || r == 0xfeff; +} + +TP_PRIVATE tp_str tp_js_trim(tp_str s) { return tp_js_trim_end(tp_js_trim_start(s)); } + +TP_PRIVATE tp_str tp_js_trim_start(tp_str s) { + while (s.n > 0) { + size_t size; + tp_rune r = tp_decode_rune(s, &size); + if (!tp_is_js_space(r)) break; + s.p += size; + s.n -= size; + } + return s; +} + +TP_PRIVATE tp_str tp_js_trim_end(tp_str s) { + while (s.n > 0) { + size_t size; + tp_rune r = tp_decode_last_rune(s, &size); + if (!tp_is_js_space(r)) break; + s.n -= size; + } + return s; +} + +TP_PRIVATE tp_runes tp_js_trim_runes(tp_runes t) { + size_t a = 0, b = t.n; + while (a < b && tp_is_js_space(t.p[a])) a++; + while (b > a && tp_is_js_space(t.p[b - 1])) b--; + tp_runes out = {t.p + a, b - a}; + return out; +} + +/* ------------------------------------------------------------------------------------------ */ +/* Digits and letters (R0.6) */ + +TP_PRIVATE bool tp_is_digit(tp_rune r) { return r >= '0' && r <= '9'; } + +TP_PRIVATE bool tp_is_all_digits(tp_str s) { + if (s.n == 0) return false; + for (size_t i = 0; i < s.n; i++) { + if (s.p[i] < '0' || s.p[i] > '9') return false; + } + return true; +} + +TP_PRIVATE bool tp_is_letter_at(tp_runes t, ptrdiff_t i) { + tp_rune r = tp_at(t, i); + return r >= 0 && tp_is_letter(r); +} + +TP_PRIVATE bool tp_is_letter_before(tp_runes t, ptrdiff_t i) { return tp_is_letter_at(t, i - 1); } + +TP_PRIVATE bool tp_is_upper_at(tp_runes t, ptrdiff_t i) { + tp_rune r = tp_at(t, i); + return r >= 0 && tp_is_upper_letter(r); +} + +/* ------------------------------------------------------------------------------------------ */ +/* Word keys (R0.3) */ + +TP_PRIVATE tp_str tp_ascii_lower(tp_str s) { + for (size_t i = 0; i < s.n; i++) { + if (s.p[i] >= 'A' && s.p[i] <= 'Z') { + char *b = tp_alloc(tp_size_add(s.n, 1)); + memcpy(b, s.p, s.n); + for (size_t j = i; j < s.n; j++) { + if (b[j] >= 'A' && b[j] <= 'Z') b[j] = (char)(b[j] + ('a' - 'A')); + } + tp_str out = {b, s.n}; + return out; + } + } + return s; +} + +TP_PRIVATE tp_str tp_strip_key_punct(tp_str lower) { + if (lower.n > 0) { + switch (lower.p[lower.n - 1]) { + case '.': + case ',': + case '!': + case '?': + case ':': + case ';': + lower.n--; + break; + default: + break; + } + } + return lower; +} + +TP_PRIVATE tp_str tp_word_key(tp_str word) { return tp_strip_key_punct(tp_ascii_lower(word)); } + +TP_PRIVATE bool tp_word_matches(tp_str word, tp_str token) { + tp_str lower = tp_ascii_lower(word); + return tp_str_eq(lower, token) || tp_str_eq(tp_strip_key_punct(lower), token); +} + +/* ------------------------------------------------------------------------------------------ */ +/* Word sets */ + +TP_PRIVATE void tp_word_set_add(tp_word_set *s, tp_str word) { tp_map_put(&s->m, word, 0); } + +TP_PRIVATE void tp_word_set_add_all(tp_word_set *s, const tp_str *words, size_t n) { + for (size_t i = 0; i < n; i++) tp_word_set_add(s, words[i]); +} + +TP_PRIVATE bool tp_word_set_has(const tp_word_set *s, tp_str key) { return tp_map_has(&s->m, key); } + +TP_PRIVATE bool tp_in_vocab(tp_str word, const tp_word_set *vocab) { + tp_str lower = tp_ascii_lower(word); + return tp_word_set_has(vocab, lower) || tp_word_set_has(vocab, tp_strip_key_punct(lower)); +} + +/* ------------------------------------------------------------------------------------------ */ +/* Collapsing and words (R0.7) */ + +TP_PRIVATE tp_str tp_collapse_spaces(tp_str s) { + tp_buf out = {0}; + bool pending = false; + for (size_t i = 0; i < s.n;) { + size_t size; + tp_str rest = {s.p + i, s.n - i}; + tp_rune r = tp_decode_rune(rest, &size); + i += size; + if (tp_is_whitespace(r)) { + pending = out.n > 0; + continue; + } + if (pending) tp_buf_byte(&out, ' '); + pending = false; + tp_buf_rune(&out, r); + } + return tp_buf_done(&out); +} + +TP_PRIVATE tp_str tp_collapse_runes(tp_runes t) { + /* Go: collapseSpaces(string(t)). Encoding a rune that is not a scalar value gives U+FFFD, + * which tp_buf_rune does too, and U+FFFD is not whitespace, so the runes are read directly. */ + tp_buf out = {0}; + bool pending = false; + for (size_t i = 0; i < t.n; i++) { + tp_rune r = t.p[i]; + if (tp_is_whitespace(r)) { + pending = out.n > 0; + continue; + } + if (pending) tp_buf_byte(&out, ' '); + pending = false; + tp_buf_rune(&out, r); + } + return tp_buf_done(&out); +} + +TP_PRIVATE tp_strvec tp_split_words(tp_str s) { return tp_split_words_runes(tp_runes_of(s)); } + +TP_PRIVATE tp_strvec tp_split_words_runes(tp_runes t) { return tp_span_texts(tp_word_spans(t)); } + +TP_PRIVATE tp_word_span_vec tp_word_spans(tp_runes t) { + tp_word_span_vec spans = {0}; + ptrdiff_t start = -1; + for (size_t i = 0; i <= t.n; i++) { + if (i == t.n || tp_is_whitespace(t.p[i])) { + if (start >= 0) { + tp_word_span w; + w.text = tp_runes_str(tp_sub(t, start, (ptrdiff_t)i)); + w.start = start; + w.end = (ptrdiff_t)i; + tp_push(spans, w); + } + start = -1; + } else if (start < 0) { + start = (ptrdiff_t)i; + } + } + return spans; +} + +TP_PRIVATE tp_strvec tp_span_texts(tp_word_span_vec spans) { + tp_strvec out = {0}; + for (size_t i = 0; i < spans.n; i++) tp_push(out, spans.p[i].text); + return out; +} + +/* ------------------------------------------------------------------------------------------ */ +/* Dedup keys (R0.4), years, UTF-16 lengths */ + +TP_PRIVATE tp_str tp_dedup_key(tp_str s) { + tp_runes decomposed = tp_runes_of(tp_nfd(tp_js_to_lower(s))); + tp_rune *kept = tp_alloc_array(decomposed.n, sizeof(tp_rune)); + size_t k = 0; + for (size_t i = 0; i < decomposed.n; i++) { + tp_rune r = decomposed.p[i]; + if (r >= 0x300 && r <= 0x36f) continue; + kept[k++] = r; + } + tp_runes view = {kept, k}; + return tp_collapse_runes(view); +} + +TP_PRIVATE bool tp_year_of(tp_str word, int *out) { + tp_str key = tp_word_key(word); + *out = 0; + if (key.n != 4 || !tp_is_all_digits(key)) return false; + int n = + (key.p[0] - '0') * 1000 + (key.p[1] - '0') * 100 + (key.p[2] - '0') * 10 + (key.p[3] - '0'); + *out = n; + return n >= 1900 && n <= 2099; +} + +TP_PRIVATE ptrdiff_t tp_utf16_len(tp_runes t) { + ptrdiff_t n = 0; + for (size_t i = 0; i < t.n; i++) n += t.p[i] >= 0x10000 ? 2 : 1; + return n; +} + +TP_PRIVATE ptrdiff_t tp_utf16_len_string(tp_str s) { + ptrdiff_t n = 0; + for (size_t i = 0; i < s.n;) { + size_t size; + tp_str rest = {s.p + i, s.n - i}; + tp_rune r = tp_decode_rune(rest, &size); + i += size; + n += r >= 0x10000 ? 2 : 1; + } + return n; +} + +/* ------------------------------------------------------------------------------------------ */ +/* Sanitizing invalid UTF-8 (WHATWG maximal subparts) */ + +TP_PRIVATE tp_str tp_sanitize(tp_str s) { + static const char replacement[3] = {'\xef', '\xbf', '\xbd'}; /* U+FFFD */ + if (tp_utf8_valid(s)) return s; + const unsigned char *b = (const unsigned char *)s.p; + tp_buf out = {0}; + size_t i = 0; + while (i < s.n) { + unsigned char c = b[i]; + if (c < 0x80) { + tp_buf_byte(&out, (char)c); + i++; + continue; + } + /* The bounds of the second byte, and how many continuation bytes follow the lead. */ + unsigned char lo = 0x80, hi = 0xbf; + size_t need = 0; + if (c >= 0xc2 && c <= 0xdf) { + need = 1; + } else if (c == 0xe0) { + lo = 0xa0; + need = 2; + } else if ((c >= 0xe1 && c <= 0xec) || c == 0xee || c == 0xef) { + need = 2; + } else if (c == 0xed) { + hi = 0x9f; + need = 2; + } else if (c == 0xf0) { + lo = 0x90; + need = 3; + } else if (c >= 0xf1 && c <= 0xf3) { + need = 3; + } else if (c == 0xf4) { + hi = 0x8f; + need = 3; + } + if (need == 0) { + tp_buf_bytes(&out, replacement, 3); + i++; + continue; + } + size_t j = i + 1; + bool ok = true; + for (size_t k = 0; k < need; k++) { + if (j >= s.n) { + ok = false; + break; + } + if (k > 0) { + lo = 0x80; + hi = 0xbf; + } + if (b[j] < lo || b[j] > hi) { + ok = false; + break; + } + j++; + } + if (ok) { + tp_buf_bytes(&out, s.p + i, j - i); + } else { + /* The lead and the valid continuation bytes so far are one maximal subpart. */ + tp_buf_bytes(&out, replacement, 3); + } + i = j; + } + return tp_buf_done(&out); +} + +/* ------------------------------------------------------------------------------------------ */ +/* Phrase tables */ + +TP_PRIVATE tp_phrase_table *tp_new_phrase_table(void) { return tp_alloc(sizeof(tp_phrase_table)); } + +/* Keeps each list longest first, insertion order among equals (a stable insert, like the JS + * sort). */ +static void insert_sorted(tp_phrase_table *t, tp_map *m, tp_str k, int64_t id) { + int64_t idx; + if (!tp_map_get(m, k, &idx)) { + tp_intvec empty = {0}; + idx = (int64_t)t->lists.n; + tp_push(t->lists, empty); + tp_map_put(m, k, idx); + } + tp_intvec *list = &t->lists.p[idx]; + tp_push(*list, id); + size_t n = t->entries.p[id].tokens.n; + for (size_t i = list->n - 1; i > 0 && t->entries.p[list->p[i - 1]].tokens.n < n; i--) { + int64_t x = list->p[i]; + list->p[i] = list->p[i - 1]; + list->p[i - 1] = x; + } +} + +TP_PRIVATE void tp_phrase_table_add(tp_phrase_table *t, tp_str raw_key, const void *value) { + /* The key is copied: the table may outlive the caller's string. */ + tp_str key = tp_js_trim(tp_ascii_lower(raw_key)); + tp_strvec tokens = tp_split_words(key); + if (tokens.n == 0) return; + if (tp_map_has(&t->keys, key)) return; + int64_t id = (int64_t)t->entries.n; + tp_map_put(&t->keys, tp_str_copy(key.p, key.n), 0); + tp_phrase_entry e; + e.tokens = tokens; + e.value = value; + tp_push(t->entries, e); + insert_sorted(t, &t->by_first, tokens.p[0], id); + insert_sorted(t, &t->by_last, tokens.p[tokens.n - 1], id); +} + +/* The entries indexed under the word's lowercase form, then under its stripped form (Go + * candidates, without building the concatenation). */ +static void candidates(const tp_phrase_table *t, const tp_map *m, tp_str word, tp_intvec *a, + tp_intvec *b) { + tp_intvec none = {0}; + int64_t idx; + tp_str lower = tp_ascii_lower(word); + tp_str stripped = tp_strip_key_punct(lower); + *a = tp_map_get(m, lower, &idx) ? t->lists.p[idx] : none; + *b = none; + if (stripped.n != lower.n && tp_map_get(m, stripped, &idx)) *b = t->lists.p[idx]; +} + +static bool tokens_match(tp_strvec words, ptrdiff_t start, tp_strvec tokens) { + for (size_t k = 0; k < tokens.n; k++) { + ptrdiff_t i = start + (ptrdiff_t)k; + if (i < 0 || (size_t)i >= words.n || !tp_word_matches(words.p[i], tokens.p[k])) return false; + } + return true; +} + +TP_PRIVATE bool tp_phrase_table_match_at(const tp_phrase_table *t, tp_strvec words, ptrdiff_t start, + tp_phrase_match *out) { + tp_phrase_match best = {NULL, 0}; + bool found = false; + *out = best; + if (start < 0 || (size_t)start >= words.n) return false; + tp_intvec lists[2]; + candidates(t, &t->by_first, words.p[start], &lists[0], &lists[1]); + for (int l = 0; l < 2; l++) { + for (size_t k = 0; k < lists[l].n; k++) { + const tp_phrase_entry *e = &t->entries.p[lists[l].p[k]]; + ptrdiff_t n = (ptrdiff_t)e->tokens.n; + if (found && n <= best.length) continue; + if (start + n > (ptrdiff_t)words.n) continue; + if (tokens_match(words, start, e->tokens)) { + best.value = e->value; + best.length = n; + found = true; + } + } + } + *out = best; + return found; +} + +TP_PRIVATE bool tp_phrase_table_match_ending(const tp_phrase_table *t, tp_strvec words, + ptrdiff_t end, tp_phrase_match *out) { + tp_phrase_match best = {NULL, 0}; + bool found = false; + *out = best; + if (end < 1 || (size_t)end > words.n) return false; + tp_intvec lists[2]; + candidates(t, &t->by_last, words.p[end - 1], &lists[0], &lists[1]); + for (int l = 0; l < 2; l++) { + for (size_t k = 0; k < lists[l].n; k++) { + const tp_phrase_entry *e = &t->entries.p[lists[l].p[k]]; + ptrdiff_t n = (ptrdiff_t)e->tokens.n; + if (found && n <= best.length) continue; + ptrdiff_t from = end - n; + if (from < 0) continue; + if (tokens_match(words, from, e->tokens)) { + best.value = e->value; + best.length = n; + found = true; + } + } + } + *out = best; + return found; +} diff --git a/c/src/words.h b/c/src/words.h new file mode 100644 index 0000000..d6b8c65 --- /dev/null +++ b/c/src/words.h @@ -0,0 +1,149 @@ +/* words.h: low-level text helpers shared by every rule (go/words.go). + * + * The R0.2 whitespace set, R0.3 word keys, R0.4 dedup keys, R0.6 letters and digits, + * token-sequence (phrase) matching, and the input sanitizer for invalid UTF-8. + * + * Text that is indexed is held as tp_runes, so indices are code-point indices (R0.5). Indices are + * ptrdiff_t (Go int): they can be negative (tp_before(t, 0)) and out of range, and the helpers + * clamp or return TP_NORUNE. Where the JS reference observes UTF-16 lengths (tp_utf16_len), that + * is made explicit. Never index a string by byte inside a rule. The letter tests and the JS + * lowercase/NFC/NFD functions live in unicode.h. + */ +#ifndef TP_WORDS_H +#define TP_WORDS_H + +#include "rt.h" +#include "unicode.h" + +/* t[i], or TP_NORUNE out of range (JS t[i] is undefined there). TP_NORUNE is not a valid code + * point, so it never equals a character and fails every class test. */ +TP_PRIVATE tp_rune tp_at(tp_runes t, ptrdiff_t i); +/* t[i-1], or TP_NORUNE when i is 0 or out of range. */ +TP_PRIVATE tp_rune tp_before(tp_runes t, ptrdiff_t i); +/* t[a:b] with both ends clamped (JS slice with non-negative arguments). No copy. */ +TP_PRIVATE tp_runes tp_sub(tp_runes t, ptrdiff_t a, ptrdiff_t b); +/* t[a:], clamped. */ +TP_PRIVATE tp_runes tp_tail(tp_runes t, ptrdiff_t a); + +/* R0.2: the exact whitespace code-point set. */ +TP_PRIVATE bool tp_is_whitespace(tp_rune r); +/* The set of JS String.prototype.trim(): not the R0.2 set (U+FEFF is in, U+0085 is out). */ +TP_PRIVATE bool tp_is_js_space(tp_rune r); +/* JS trim(), trimStart(), trimEnd(): substrings of s, no copy. */ +TP_PRIVATE tp_str tp_js_trim(tp_str s); +TP_PRIVATE tp_str tp_js_trim_start(tp_str s); +TP_PRIVATE tp_str tp_js_trim_end(tp_str s); +/* JS trim() on a code-point slice (a sub-slice, no copy). */ +TP_PRIVATE tp_runes tp_js_trim_runes(tp_runes t); + +/* R0.6 digit test: ASCII 0-9 only. */ +TP_PRIVATE bool tp_is_digit(tp_rune r); +/* Whether s is a non-empty run of ASCII digits. */ +TP_PRIVATE bool tp_is_all_digits(tp_str s); +/* R0.6 letter test (category L) on the code point at i / just before i. */ +TP_PRIVATE bool tp_is_letter_at(tp_runes t, ptrdiff_t i); +TP_PRIVATE bool tp_is_letter_before(tp_runes t, ptrdiff_t i); +/* R6.10 uppercase test (category Lu) on the code point at i. */ +TP_PRIVATE bool tp_is_upper_at(tp_runes t, ptrdiff_t i); + +/* A-Z lowercased only (s itself when there is none). */ +TP_PRIVATE tp_str tp_ascii_lower(tp_str s); +/* R0.3: the lowercased word with one trailing . , ! ? : ; removed. */ +TP_PRIVATE tp_str tp_strip_key_punct(tp_str lower); +/* R0.3 word key (stripped form). */ +TP_PRIVATE tp_str tp_word_key(tp_str word); +/* R0.3: does word match the vocabulary token? The unstripped lowercase form is compared first, + * so entries ending in punctuation (feat.) match as written. */ +TP_PRIVATE bool tp_word_matches(tp_str word, tp_str token); + +/* A set of vocabulary words (Go wordSet). The zero value is empty. Keys are not copied. */ +typedef struct tp_word_set { + tp_map m; +} tp_word_set; + +/* newWordSet(words...): add every word of a list. */ +TP_PRIVATE void tp_word_set_add_all(tp_word_set *s, const tp_str *words, size_t n); +TP_PRIVATE void tp_word_set_add(tp_word_set *s, tp_str word); +TP_PRIVATE bool tp_word_set_has(const tp_word_set *s, tp_str key); +/* R0.3 lookup of a word in a vocabulary set: its lowercase form, then its stripped form. */ +TP_PRIVATE bool tp_in_vocab(tp_str word, const tp_word_set *vocab); + +/* Runs of R0.2 whitespace collapsed to one U+0020, trimmed. */ +TP_PRIVATE tp_str tp_collapse_spaces(tp_str s); +/* tp_collapse_spaces on a code-point slice. */ +TP_PRIVATE tp_str tp_collapse_runes(tp_runes t); + +/* R0.7: the maximal runs of non-whitespace code points. */ +TP_PRIVATE tp_strvec tp_split_words(tp_str s); +TP_PRIVATE tp_strvec tp_split_words_runes(tp_runes t); + +/* A word with its code-point span [start, end) inside the slice it was taken from. */ +typedef struct tp_word_span { + tp_str text; + ptrdiff_t start; + ptrdiff_t end; +} tp_word_span; +typedef TP_VEC(tp_word_span) tp_word_span_vec; + +/* The R0.7 words of t with their spans. */ +TP_PRIVATE tp_word_span_vec tp_word_spans(tp_runes t); +/* The text of each span. */ +TP_PRIVATE tp_strvec tp_span_texts(tp_word_span_vec spans); + +/* R0.4 dedup key: JS toLowerCase(), NFD, U+0300-U+036F removed, whitespace collapsed. */ +TP_PRIVATE tp_str tp_dedup_key(tp_str s); + +/* A year word: 4 ASCII digits in 1900-2099 (word key, so "2015," counts). *out is the value of a + * 4-digit key even when it is out of range (as in Go), else 0. */ +TP_PRIVATE bool tp_year_of(tp_str word, int *out); + +/* Length in UTF-16 code units (JS string.length). */ +TP_PRIVATE ptrdiff_t tp_utf16_len(tp_runes t); +TP_PRIVATE ptrdiff_t tp_utf16_len_string(tp_str s); + +/* Every maximal subpart of an ill-formed UTF-8 sequence replaced with one U+FFFD (WHATWG, as + * TextDecoder and Rust's String::from_utf8_lossy). Valid input is returned unchanged. */ +TP_PRIVATE tp_str tp_sanitize(tp_str s); + +/* ------------------------------------------------------------------------------------------ */ +/* Phrase tables: multi-word vocabulary matched as token sequences, longest first. */ +/* Go's phraseTable[V]: the value is `const void *` (NULL for struct{}, else a pointer to an */ +/* arena-allocated V). */ + +typedef struct tp_phrase_entry { + tp_strvec tokens; + const void *value; +} tp_phrase_entry; +typedef TP_VEC(tp_phrase_entry) tp_phrase_entry_vec; + +/* A match: the entry's value and the number of words used. */ +typedef struct tp_phrase_match { + const void *value; + ptrdiff_t length; +} tp_phrase_match; + +typedef TP_VEC(tp_intvec) tp_intvec_vec; + +/* The maps are only looked up, never iterated. by_first and by_last map a token to an index + * into lists (Go map[string][]int). The zero value is an empty table. */ +typedef struct tp_phrase_table { + tp_phrase_entry_vec entries; + tp_map by_first; + tp_map by_last; + tp_map keys; + tp_intvec_vec lists; +} tp_phrase_table; + +/* An empty table in the current arena. */ +TP_PRIVATE tp_phrase_table *tp_new_phrase_table(void); +/* Add a phrase. The first entry for a key wins. Keys are ASCII-lowercased and trimmed like JS + * trim() (not collapsed). */ +TP_PRIVATE void tp_phrase_table_add(tp_phrase_table *t, tp_str raw_key, const void *value); +/* The longest entry matching words[start:]. Read-only (safe on a shared table); no allocation. */ +TP_PRIVATE bool tp_phrase_table_match_at(const tp_phrase_table *t, tp_strvec words, ptrdiff_t start, + tp_phrase_match *out); +/* The longest entry matching words[:end] at its end (end exclusive). */ +TP_PRIVATE bool tp_phrase_table_match_ending(const tp_phrase_table *t, tp_strvec words, + ptrdiff_t end, tp_phrase_match *out); + +#endif /* TP_WORDS_H */ diff --git a/c/tests/data/numbers_sample.jsonl b/c/tests/data/numbers_sample.jsonl new file mode 100644 index 0000000..bd49444 --- /dev/null +++ b/c/tests/data/numbers_sample.jsonl @@ -0,0 +1,1400 @@ +{"s":"7813e-89","v":"7.813e-86","b":"2e436d8cf7764017"} +{"d":"bffab238424d3a95","s":"-1.668510684004706"} +{"s":"-1.7976931348623158e308","v":"-1.7976931348623157e+308","b":"ffefffffffffffff"} +{"d":"8000000000000000","s":"0"} +{"s":"-693382664308869163938773039372440157303520972664970069826800014248451593109553247171897826616971895534938847312979252825075844116046076704133352057105422191779315526328149552826735176066176047635337266815110047162239525692642449009285596878745171758989354828950956475759144905388063099709529235134220181594746023365519911987170307613681096938824173507674396086304237938625474287625187265838851912659628652114545444032797671375131628683032659156885760653966250076474679641244562140540881205754825440447813326130261934633704185641555236825905362754542407568587106499338397685686323315202254411519252644110713673350188684696329879914599218397178703717994204926475414009857331962620605095157625526689719404675937164032818349165240796448772149146691342979655951443631743004496582099583860538183417431396443830462272877086284548001147241560675314328293208365738342707516063953584942369599801602925051882951412856263214330557411791022384199806219909831682340012287598653229108077548931882261086700851599110574290660275259953569031111778410239785199105169634297036050046","v":"-Infinity","b":"fff0000000000000"} +{"d":"3c9cd2b297d889bc","s":"1e-16"} +{"s":"0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000063332428737","v":"6.3332428737e-294","b":"03102debea05d7e6"} +{"d":"8000000000000000","s":"0"} +{"s":"+0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000042783635906702068318794378681847517312078670885354809521044831162225334899818971316619143797794035386300711203019815853055388418236237837625512639235845296760636110845985413923608399414401616673675804242771519587643511511617446977272961669697121664748949514129563924957448159836160032045679173951753022783025812406646151419646746099019170594707300837878388059619759873599321494263049629285634118877612586118175386218354105949401855468749999999999","v":"4.2783635906702066e-165","b":"1dcf89311443a1cd"} +{"d":"3f3ca2b18469aa8f","s":"0.00043694337765624256"} +{"s":"123456789012345678901234567890e-30","v":"0.12345678901234568","b":"3fbf9add3746f65f"} +{"d":"3fb999999999999a","s":"0.1"} +{"s":"70730319724165568423755261893138011367.59","v":"7.073031972416557e+37","b":"47ca9b15005a7963"} +{"d":"42cfcb6fd0000000","s":"69917229449216"} +{"s":"4.008574022352737606345451","v":"4.008574022352738","b":"401008c7a0e66696"} +{"d":"0010000000000000","s":"2.2250738585072014e-308"} +{"s":"+28517355950.840428712208","v":"28517355950.840427","b":"421a8f1146bb5c99"} +{"d":"b270d9976a5d5297","s":"-1e-65"} +{"s":"198385209644e-301","v":"1.98385209644e-290","b":"03c8bf1f882bffc1"} +{"d":"412b4da740000000","s":"894675.625"} +{"s":"-21607870578755952207493814669713748556422988994673365632595755646697098054352878279392787556631825319224191963600508742571013382613519669167608565044251578600967483775794713924369106771e-1379","v":"0","b":"8000000000000000"} +{"d":"429189482aba799a","s":"4820329737886.4"} +{"s":"9.999999999999999871874785226e-280","v":"1e-279","b":"060226ed86db3333"} +{"d":"77554826b69d900f","s":"6.862231484495564e+266"} +{"s":"84365568387638037572497e-20","v":"843.6556838763804","b":"408a5d3ed7302c8c"} +{"d":"67cc0e1ef1a724ec","s":"1.0000000000000002e+192"} +{"s":"+853608031973421e-278","v":"8.53608031973421e-264","b":"095133df23374d4d"} +{"d":"8076d7cafe3732be","s":"-2.033089250647598e-306"} +{"s":"-2e-324","v":"0","b":"8000000000000000"} +{"d":"40ee7e764cd40901","s":"62451.69687845"} +{"s":"-1086246587607546123423653339328453445005441352604733681788838250181767031512540970997897197544701942256613906873837777232279001117422312993998718306131316058133274023847332002871887419840486765202902442624693421154808055499194455756824654565721662682983554193126997523488031545750320694883715231793100306810136786593955537260226522271500635439111797878214179354781906828748235679519360552328053570734390987142340177092032500285402956445578805199077646177999796807216525178338076994719782957197936214573470605344361021547384708488185083249346955313545881583573885788760091184011552648523635930112266674102321945197853085564520745591512304288139874846975104208574728698124608007231559862891333231728583240424742185680465911579502337496971108852120250086383653323204742408576584123534153853688574395839707061901703904949811873762005926195918517018938359888053065291461263668315676137307555401653816271515795382370475317069255488756640834976833237016731957371809001551060220949458800567408278127308524082324101622914992516427434610430631822561608212120619742148465543359023905604836669707718387054863493997229405826171239849148411006092925198090624927556502241399713718910211437044170600821312586048664513492573120059850699049348915130952860753142370096893137087310521","v":"-Infinity","b":"fff0000000000000"} +{"d":"4f16a3a275d49491","s":"1e+73"} +{"s":"-2187.2240670","v":"-2187.224067","b":"c0a11672b8e8ea3a"} +{"d":"444b1ae4d6e2ef50","s":"1e+21"} +{"s":"7.5075266798063206607694303e-14","v":"7.50752667980632e-14","b":"3d3521be3b9ea2b1"} +{"d":"3f24d8d518cba8e0","s":"0.00015905"} +{"s":"6908723669015028684757662533632021606531390910026436490511138711900117659651495922444321769317312007044528548064446565395900867525524123141245789999366840919412300521095345704164391205283921615257592820105609616832746431929607655443422990763957677141750261280984852895566296827403416337392342742437995272932930148311154864760669401289764370586406964724376521725153014057427850255452925828488671651356628530435632442175745012889876204252880858512520830688341746445471990049102326468526577547576572589115986675318717510144950170580830593879548593808234166324733198507144597247635113592409989314543451471099359922410542524133167306202264406659043144594486526535755155845111800026268011441566291145603464243646453789437538999602147043717579880632379119085944577860343085030066227255422134149535425087274011181212521171663e-587","v":"6.908723669015029e+229","b":"6fa6c8b826062e8e"} +{"d":"fff0000000000000","s":"-Infinity"} +{"s":"-705390201826030686e-156","v":"-7.053902018260307e-139","b":"a340cce16b83ba58"} +{"d":"1fea52c02b0cf9b2","s":"6.135241516329258e-155"} +{"s":"1.0000000000000001824108e+186","v":"1.0000000000000002e+186","b":"668d6affe45f8191"} +{"d":"f5154fdd7f73bf3c","s":"-1e+256"} +{"s":"+0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000075887469552837547906857138756922887100727547149456539438599168758172413256364541743293253309204977204812012015804504493888438339211219418399414157492909834780355594904884845183500236737017432822921675989037391139725248108704130332826129551020391618877023362205430402229675076544936538134527039137519769671528918479162830707621256143120161956978837548488928837929587879133316861886441066318278096849828477912787119158207442190897082836724043468263486502520201329533705569829749038035515695810317993164062499999999","v":"7.588746955283754e-195","b":"17a1ba220e76de5c"} +{"d":"3bf4a90ceafff9df","s":"7e-20"} +{"s":"1033.71318748497926380208321061257","v":"1033.7131874849792","b":"409026da4dd1ef9c"} +{"d":"7c5c7a08f812730a","s":"1.1100575089516374e+291"} +{"s":"+206453458285791e183","v":"2.06453458285791e+197","b":"68e618552f1bdd33"} +{"d":"000e34e6772240cd","s":"1.975676680700619e-308"} +{"s":"66380645e194","v":"6.6380645e+201","b":"69d5ae2517c2b16c"} +{"d":"f6c5a0f016b07a04","s":"-1.3621216562539278e+264"} +{"s":"-26374882.904770154480820340387","v":"-26374882.904770155","b":"c179272e2e79f045"} +{"d":"017124e63593f5e1","s":"1e-301"} +{"s":"0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000015339836297358935140077580855939738622102476618706569194848205837715862299000360787475768307591847745433464786116516405091056997437305620885718164528697844119836226318151252094411540668472946755547743351338853570390845467835880381040401633348570781692676269104352770654969609159038966353432762785890561960153238484960765545010249456212188271641517252256022590077094140665891904766083253899295414424912842010630688819188211617221874682764003729127769901724494471192716251120311320005679506220595146238956649443382682433372714636732468710709458579232926869275431975965036496435987844176221631227237286038599613068485877595509545000384573343743045433322133079237661328445842403280899477445484712070890815375930439260419155790234925496040574444123194552958011627197265625","v":"1.5339836297358934e-307","b":"003b93899a4f45c2"} +{"d":"0005a6ae5784cf80","s":"7.8588186663128e-309"} +{"s":"-0.000000000000000000000000000000000008702273952711006578655631","v":"-8.702273952711007e-36","b":"b8a72275f4226a69"} +{"d":"08acc9382b3eba50","s":"6.974536906548435e-267"} +{"s":"+66072094600152224943754013936070279555679007899016141891479492187499999999e-79","v":"0.000006607209460015222","b":"3edbb66fe838555f"} +{"d":"430d09a9cc272b20","s":"1021674900481380"} +{"s":"6348440e-258","v":"6.34844e-252","b":"0bc745a0a4f5a15c"} +{"d":"f475d2ce55747a18","s":"-1e+253"} +{"s":"557345187626487961419267839546963814420135415567963039022988442740235558206954353855185859813037261770498284346602809454099596832115849261542071558224191189805770686794877890826354564301581188100655858134210809226642647928089353254323016141875181044360231520636353529192022103724131313529578915768367247577243154305856783471712130057788870930901129641728669608488914454597918983277396062007936138551285369137437473273168533948539858367410650733471638286654754508097789790171092596804228131626612659319735319355705302100406261051450206343239647581230377591829254290085780141e-715","v":"5.573451876264879e-143","b":"2265bfa72481ac10"} +{"d":"237dc574d80cf16b","s":"1e-137"} +{"s":"0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000418725430254123920788028555870831434851532116348160040923493313956424631901566287179231426489983001944839468699550643698104815607651994893973319501804390160591311100297918214466529057180156523711547399755231234860059158126441112510229504991778960484522236018997824174218077750551179012840159231370968345136266437689681096019692398534594080798290138072171688000904201949090263601850258719503958420076891158302593113574218926223900932756552349562734591208139846794285387664270251548374703367661721341142911059837205065175219101999223741467781502247313871692913996670252180891569231821528120700543355296371861448759806763883189835747976229366682243683519092606975907378918237128708343461151163222736820681844534236432235586180899099273400310039505711756646633148193359375000000000000000001","v":"4.1872543025412395e-308","b":"001e1c0e4db3875e"} +{"d":"00097f50a1715494","s":"1.3207654704353906e-308"} +{"s":"47594e-67","v":"4.7594e-63","b":"32ff5392b901b32b"} +{"d":"fff0000000000000","s":"-Infinity"} +{"s":"71256081204575868520672057306406621693350466177249473561755003132956835174709734425978802636534915342633978216349345524777813016197837926935298592845264638549035858454860056584284924229335259597728878727299635234994661013733860053307894089952e-403","v":"7.125608120457587e-162","b":"1e79a56014cf4c9f"} +{"d":"fa5dc229001c863f","s":"-2.7008850494298234e+281"} +{"s":"735641133944912810449050972977512278891524859701254148201289929762863956158352023211372640100411595739313740483321396654401963267082181159702614469283009410340521918807818017883209796996995119645083578766477392246278235117544084561961163985069792233923249624805361076986100499378553935669185635041797664412944134e-827","v":"0","b":"0000000000000000"} +{"d":"8000000000000000","s":"0"} +{"s":"+1.38966505785209179866642709e-99","v":"1.3896650578520919e-99","b":"2b6850fd7185126f"} +{"d":"7fefffffffffffff","s":"1.7976931348623157e+308"} +{"s":"-5380481783013533565E-196","v":"-5.380481783013533e-178","b":"9b217147515e6857"} +{"d":"0002e7fc73ba8ff2","s":"4.04156277628259e-309"} +{"s":"0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000086479699015805862","v":"8.647969901580586e-246","b":"0d0e3ba3086639be"} +{"d":"00036b08cbf56c2d","s":"4.75345723765457e-309"} +{"s":"19e+201","v":"1.9e+202","b":"69ef0708e063b5fe"} +{"d":"000710dbfe41dd3f","s":"9.826283324852386e-309"} +{"s":"111422411E331","v":"Infinity","b":"7ff0000000000000"} +{"d":"4ccf1d75a5709c1b","s":"1e+62"} +{"s":"-91236907230243597004622005400612249673852517808181885019976833899739313533743985411271200290949686063494120625361706662096514477940309623031741951932430365683327700417068625571504360572300007400488090138292114611347733342436387497700748659317412282432392324360618490233942775136727093221278614957722949124696554662085837877611647592409891553412817287437800683409536270992106125324525300311218298245644940343411516256889543282967321756136219204601041742924382144394484225548686868366986937274992713923499232612243362073731183646061037646963480648239066900735975437651386554889789877928205261618049426189835280441739590697649608925708350696493395913501834984204103520014165432264935154583384313272226101808871101160801180140184953591091148631093750093768503285306227412696455400453230621587552270389826963024439914698069155844244684249688252488540580692898603963078097609519178115713207841214696054026836478994379035961276623314076946014422326222550759333740703108449737151829478330523224085208175630403435479198402921753463062088983285044484694444060708751549481728576344608220851298652837996682909195567041119281000561117975814782939806712474363804285397493616280699777289378984199390797997300739133612352235779840184272354710601283806411911199247981931530012050120230035980105901318887681545477882e-724","v":"-Infinity","b":"fff0000000000000"} +{"d":"000de1b06c626441","s":"1.9304738372587156e-308"} +{"s":"-9624008024066062017823.464084017224","v":"-9.624008024066062e+21","b":"c4804dbf879daa75"} +{"d":"65ee1fbe5a7e7861","s":"1e+183"} +{"s":"+6916743205055544975821691412722247608237793124502762430098660899559975220907524494355442672815528579102607614039526898046340776564819124041590247012719918739317186381798576744536004867174492681029127782267056794876527818003352748970569945704314603518777268861914082932610089647068153836900677179218110535959752682596672224789295915402018159924519928605498149101065435666621129237771374766373600370015012253265329524898365820778921206858121121790748099451059524634498047134541921686752762361141449332172617317275708158371848127242220839056792294865051379612106837500541528343973724389826989943754543420071681939389093496082953486515095691508953560499439890082070899084597503244146219856306836002380325293435188436294561541132757825885237617106985317715305581797695812199144186937103198989571307567105976949935819767589781141800266221630080988926727130011381988551533560960365222671327194041568591895825358376857961070745769002638504211753466334225360371313660116113947195690813041918766554321839659937687816391622372246734564540386607703e-508","v":"Infinity","b":"7ff0000000000000"} +{"d":"4ce99bcf462e7519","s":"3.292118737819265e+62"} +{"s":"221487742140289196311029773865376550731060874384623120762644354545786335108630294231517922811405006218084449735225722985728644127465289186780681972496584049089904775228408987300711550993165997444198647850334742533823851345197862272631447262908143678026671085943867566574306834904675244268729682177197013924110532124548671343228034692133497434403722650933025163174415582081531652105317890561702056694412540284824616495870009999603905625381120159215022358209878545076571027580256121589481132078058285509766135077733671552564424824130219783633053859550724123936374619136458863085221670590429036441085619364162447199116108135228856257188208552537193253061389072577468243362292935565242942571055324681808441253210933228776794956851489605456559458639562643707297343345552464466611614470523063724985077030501264406172397978661086944452698375804461802471116700056596105999197373355860619343920874503514977366978467784644363453989264041937314725465341774255364447495003443338757008508935400","v":"Infinity","b":"7ff0000000000000"} +{"d":"4340000000000000","s":"9007199254740992"} +{"s":"0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014581141987852852785281","v":"1.45811419877e-313","b":"00000006df15ed45"} +{"d":"3f67e0a944ffb0c7","s":"0.002914744"} +{"s":"+7286.364993573814942169238","v":"7286.364993573815","b":"40bc765d703806c9"} +{"d":"2c56d38dd0abea70","s":"4.2746294416922455e-95"} +{"s":"+1488880400242180660704013341e+68","v":"1.4888804002421808e+95","b":"53b1d8287ca8c4b2"} +{"d":"7ff8000000000000","s":"NaN"} +{"s":"0.00000149111030","v":"0.0000014911103","b":"3eb904451cf72c46"} +{"d":"41b9f43694000000","s":"435435156"} +{"s":"-1e309","v":"-Infinity","b":"fff0000000000000"} +{"d":"630532a837eae8a3","s":"9.999999999999996e+168"} +{"s":"+9054081417726083929708831522882356311664929479249141824923077326547355316833406324889057456684674666738218188138802822099142715270107507321937440783503744907493992940890001339091123609350680088883355096344204987691779706686690846664987901726485234394647144563527254699104037679467196111013451884757499316011008652261200677571722736784202377964688184774753518740363080105344199186966497026550760044756992213601165754398797673886715127039342027868164575713764734519691098784500812480719352816177919848105463760494706853636171382018119902408594387760533698403725849278714397162482767930694845330348966361707024865924813807381065324691646501753364831260011455418075891457155092740676933995472057050611816664126441435546141865296214855033880766653660012790521367493058886206908307623237969133377710676625615937606261097912858294526413803400895515665862513381824938","v":"Infinity","b":"7ff0000000000000"} +{"d":"f7fe494034e79e5c","s":"-1e+270"} +{"s":"3884774E-214","v":"3.884774e-208","b":"14dfedc6929e559f"} +{"d":"a537c8567c51f986","s":"-2.1443745820454425e-129"} +{"s":"6056019252707823350925819712556334079876924694372869418531152508479552151270748960991467690486219137087300352710408129704516773711781819816071907427050950832697900325789392216873891591615456511183439774221262880218824150288332379941257841885916024102116417426478900198333398616269618899735991046462352984622680174458270445690397623806869089675574359579961864351375742409786764635085223386309049731831153111480823225321785254506431840247519316350173126207067090270165263067726470343424573877211509731113460581875935453747645846825506621532012455129895152036768714672388607846477150420075566666093621524368971399083147342783244710866998290932947813416839195662037578222614432210998801079825485524586923777680941820077159445902671532380734895058879842438403982180748640485923191403104070722594927738400343073925742173516979165230394107572341188914139277714091882557419868118767922316653438350084427219444446639995697488519389651551249573792765475723106862251137462576160301692871329013832086060832100830357665913181357403693605385103880619976583247392931629676566486241179325357487767128315896e-824","v":"6.056019252707824e+265","b":"771e0ceaa0d21f99"} +{"d":"00019304a8b48b71","s":"2.18931948151079e-309"} +{"s":"-567319124473833755903361419475915508420.17905","v":"-5.673191244738338e+38","b":"c7faacdb0614e513"} +{"d":"1985c162b168e70e","s":"1e-185"} +{"s":"0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000042762","v":"4.2762e-230","b":"105098e1bfe6b3bc"} +{"d":"7ae585041b2c477e","s":"9.999999999999999e+283"} +{"s":"624926574811721274805846569166642945280756940799.9999","v":"6.249265748117212e+47","b":"49db5dab507b2f1a"} +{"d":"124212dd4de70913","s":"1e-220"} +{"s":"-1.","v":"-1","b":"bff0000000000000"} +{"d":"42c6d93d09000000","s":"50244575428608"} +{"s":"0.00000000000000000000000000000000000000000915673139746","v":"9.15673139746e-42","b":"376986763dc27442"} +{"d":"50fcc40461130d2b","s":"1.3643118814570308e+82"} +{"s":"918171827634464454625413523229910091732.734009","v":"9.181718276344645e+38","b":"4805960bb18c4eca"} +{"d":"3fd3ad8e432441ff","s":"0.307468"} +{"s":"2534539205086274278924990e115","v":"2.534539205086274e+139","b":"5ce106d7256950fb"} +{"d":"3e35798ee2308c3a","s":"5e-9"} +{"s":"0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000108755481804141627367782131901621129873996394761070326727748415424133259575208577416772835789330566921146770420786859633487317980325274373085404825590649722003882274873547808434363515627467980504303806006281581538219581169734738927505884181767825680253736209124326705932617187500000000000001","v":"1.0875548180414164e-96","b":"2c02958297bfb8ea"} +{"d":"e761f48eaf234ad4","s":"-1e+190"} +{"s":"207783066347126601477415621272.53939","v":"2.077830663471266e+29","b":"4604fb10fe27b3a6"} +{"d":"05973c115074bc6a","s":"1e-281"} +{"s":"28798.393590658634462","v":"28798.393590658634","b":"40dc1f993096dfb6"} +{"d":"7832edc82110c2f9","s":"1e+271"} +{"s":"+572640.652673312","v":"572640.652673312","b":"412179c14e2b3244"} +{"d":"3ea6d273d4933281","s":"6.801509836673414e-7"} +{"s":"-14.1744860","v":"-14.174486","b":"c02c59563a9f383f"} +{"d":"3e7ad7f29abcaf48","s":"1e-7"} +{"s":"8.89","v":"8.89","b":"4021c7ae147ae148"} +{"d":"24522bc490dde65a","s":"1e-133"} +{"s":"-3.83559994476","v":"-3.83559994476","b":"c00eaf4f061a44d4"} +{"d":"441ac53a7e04bcda","s":"123456789012345680000"} +{"s":"442159370e-172","v":"4.4215937e-164","b":"1e045eaa474dc188"} +{"d":"00059905334a762a","s":"7.7846094705533e-309"} +{"s":"+8.85063847100871966781464","v":"8.85063847100872","b":"4021b386e2bb675f"} +{"d":"0010000000000000","s":"2.2250738585072014e-308"} +{"s":"0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000164740713853806179508067661057791871845819315269484563339686429381932423198831950046971806749839515929923785513366725426823744952957379922121810402429129445654552608235447753079144686815057264732020003045136822786242819113405146509357942302132457683273799534745689810327981388838367984843836893587204265934534683513473239911921426411061719792990149334008208342124421169411249479620391464852335093627674377099684581923001936106706705331364156488120186024049617446560476925031459568937133840234177983749001941274098335177453586522962690466411900736538386004911395451251743850963957081999838660869597909395141227511693998087167201867897351238850281840445000226128457710417484836916243529677137124643798925520982864418822899128932654710943950249202316626906394958496093750000000001","v":"1.6474071385380619e-307","b":"003d9d85f0fbfcca"} +{"d":"7ff0000000000000","s":"Infinity"} +{"s":"0.0000000000050891589","v":"5.0891589e-12","b":"3d9661e22f1d6e57"} +{"d":"680188d357087713","s":"1e+193"} +{"s":"0.0000000000000000000000000000000000000000000000000000009957025","v":"9.957025e-55","b":"34b86a203a5f1c8f"} +{"d":"000360481a924611","s":"4.695045209772184e-309"} +{"s":"2621e-110","v":"2.621e-107","b":"29cec7141b3428f0"} +{"d":"fff0000000000000","s":"-Infinity"} +{"s":"-100000000000000030.4959750170347290085279962097","v":"-100000000000000030","b":"c376345785d8a002"} +{"d":"3d50dcc4d7d0feb9","s":"2.3962881224286036e-13"} +{"s":"-9453e211","v":"-9.453e+214","b":"ec918cc1305a2e25"} +{"d":"40bc0ff720000000","s":"7183.96533203125"} +{"s":"290752521348720029360278330404.396358252355325039","v":"2.9075252134872004e+29","b":"460d5bc6ca28c4a3"} +{"d":"69e0548b68a044d4","s":"9.999999999999995e+201"} +{"s":"+800.4608254339917","v":"800.4608254339917","b":"408903afc53ec146"} +{"d":"7d2f50ac6690f1fa","s":"1.0000000000000002e+295"} +{"s":"9.99941","v":"9.99941","b":"4023ffb2aae29739"} +{"d":"40ad5ed1c6000000","s":"3759.409713745117"} +{"s":"-0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000078466233239966683291982496689308563904901719035074259601070768114929160444884700838015747705874571261157279905490382146404954962541804369195254633587026961247653026243674332858550958061936745356036832871391570848838307896676121131161258333718650181629125235308669374879669965138273194820796819486214593820140050265992728275436061430425285878081250559434259576024916909756766059232751705248411991596224052361956492394373064528729997433101876011883016802693668169933034785506276673503442918612432383493471274673488595585987632759595913817862962045908161510387914184763320908358528240477847251948607578589813399868036664945762909594675404377304996674586363421430184591150437800146139411221772859167431921231720862483038704367145806106709216010131058283150196075439453125","v":"-7.846623323996668e-308","b":"802c362e2791b026"} +{"d":"e30532a837eae8a5","s":"-1e+169"} +{"s":"-9646.3248556","v":"-9646.3248556","b":"c0c2d72994de48f6"} +{"d":"4212d31ac6000000","s":"20212789632"} +{"s":"726156E+74","v":"7.26156e+79","b":"508398f6e8dbb49a"} +{"d":"a59899d0c5f0afb4","s":"-1.4196190438950847e-127"} +{"s":"-284.95516500761811","v":"-284.9551650076181","b":"c071cf485b1a600e"} +{"d":"4290aef6bc000000","s":"4585912467456"} +{"s":"488333201797382362598590922882612343492.53997815179151","v":"4.8833320179738234e+38","b":"47f6f618db9e8e40"} +{"d":"000ff8341e1d9a66","s":"2.2208386045383384e-308"} +{"s":"15164346162210021606794347907372402905738263390382975883958456427247826485900777855345036528845364239909856019078034538548445743491660679516355874391417673498055600450481543530431463172756190911046266403698864445218002952652517845190426970350232909723447290299142450671151130491993226955605409430311362546058856160678705084482694673112498946505342097988931144466002671844476605902457256362856834836983401225586717516235427865794784628285417498852150879164983276642653793466624088239239478043668163412373462104103867810013920414813092109709545199642953929888619059170287649925411416368550347621817531085449273176695419959080995718144666566804323680889019446270453505201449004638345737443666102837083311501589309207332478490202264854744510182134293967287185659486077722839911767035334360442019240931523587216865419324568679785498934395758361522086024035679487","v":"Infinity","b":"7ff0000000000000"} +{"d":"69e0548b68a044d8","s":"1.0000000000000003e+202"} +{"s":"+1633852872571163570932232949859235054533963307608924266857173678523601802447756985083960089652644013782400122455612699315523088492424219913847363409850517655026112514158749226389649477293534362089730035612306468388122725805573908531601895590482626377943947223497359880645554754430173184","v":"1.6338528725711637e+285","b":"7b25f9937811cb40"} +{"d":"6b1f25c186a6f04b","s":"9.999999999999999e+207"} +{"s":"+6454.68471573712772284518","v":"6454.684715737128","b":"40b936af4987d205"} +{"d":"403bee636b8881bb","s":"27.931204529597135"} +{"s":"2827203917491e-238","v":"2.827203917491e-226","b":"111aca4217cf9675"} +{"d":"41cdcd6500000000","s":"1000000000"} +{"s":"0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000488","v":"4.88e-162","b":"1e7190528a214c01"} +{"d":"d412ba095dc7701e","s":"-1e+97"} +{"s":"+32117530846679721777.82844652047124728019512280691","v":"32117530846679720000","b":"43fbdb864239afee"} +{"d":"3f42e62220bcfec8","s":"0.000576750434881001"} +{"s":"1.00000000000000019489518494149290227e+210","v":"1.0000000000000002e+210","b":"6b88557f31326bbd"} +{"d":"4165c2d48b000000","s":"11409060.34375"} +{"s":"0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001","v":"1e-226","b":"1102f39e794d9d8b"} +{"d":"0000000000000001","s":"5e-324"} +{"s":"485670604437872.711536188794351784661295","v":"485670604437872.7","b":"42fb9b6ffdaf970b"} +{"d":"00069d2d407707f9","s":"9.197859759343376e-309"} +{"s":"-0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002071341896092479","v":"-2.071341896092479e-195","b":"97835ab7c7da95d9"} +{"d":"67cf473ae02f58af","s":"1.1148837680178318e+192"} +{"s":"1119346106825047419e-80","v":"1.1193461068250474e-62","b":"33126b3c7424990e"} +{"d":"caf4147bff033bed","s":"-1.202052209394785e+53"} +{"s":"+124356491048.29912933540606570907243596","v":"124356491048.29913","b":"423cf43977284c94"} +{"d":"3eb0c6f7a0b5ed8d","s":"0.000001"} +{"s":"-9937802183227505272e36","v":"-9.937802183227505e+54","b":"cb59f05a0bd0f6d2"} +{"d":"0ccc7b81db0e168b","s":"5.092029548002894e-247"} +{"s":"17321635202934766521465e+269","v":"1.7321635202934766e+291","b":"7c6637c87b558711"} +{"d":"3696d601ad376abb","s":"1.0000000000000003e-45"} +{"s":"21349246320.97270995479291383228840894869372","v":"21349246320.97271","b":"4213e20e95c3e40e"} +{"d":"40e70d6f7122415b","s":"47211.48256027951"} +{"s":"21307200633887630335208571493196397630850198056513042835696586045184242447813668878072213057299999761342237747604978565531257453645464039203373785735013800610837849393197051176398445205962856364501967734315235856468529815464346390413354985579681783842685924566181711829226597526095342651908038920096975396209590861569781846924956116420993454803020685909818784960975465909312402381050189922098042051268491690622705938620723097327886766949674114893490560193243310763809812859701145474604058385669871846314587931071779214237501862279641558857545427855424487789388644486142387462825094082886129263989230300508307924092986029826384908117170631378513495138486327837179311619967767877696515431721507946893372176108099736037507230063597520988101682931673902683077486370285945457937261577937311268853506938958374980487641903677665803238470114405230620465453218495720168477687487245846835015987806917745953820166207921792344","v":"Infinity","b":"7ff0000000000000"} +{"d":"3d9de15d2cf2772a","s":"6.794e-12"} +{"s":"+4.5218200126108097e-15","v":"4.52182001261081e-15","b":"3cf45d4db44e5361"} +{"d":"41459193f5800000","s":"2827047.91796875"} +{"s":"+579765431406.3","v":"579765431406.3","b":"4260df96cd8dc99a"} +{"d":"4b11139c395d6db8","s":"4.089033944713523e+53"} +{"s":"-7547531572693854243495639970235283926906634462411659086527666256073095300104563948468039628872485211616438154067867230027693229248741079670148377299827021824590444273983000226800468968701330347338949925682453894866763318775906206848960349698724247162091271800728401623541029948836485957467415345113735238853830976895261600223880308267144733571221404501255691350196110873401358228219852073267416277135427012947752699682983471240948290743329837915717194663824498838194987123123719837475112840022184385779461179321212291474925143675694015738040768800866248220133725547363392678339401915e-670","v":"-7.547531572693854e-88","b":"add805d65bcfdbad"} +{"d":"159410d9f9b2f7f3","s":"1e-204"} +{"s":"+3031799019204349498634397289947501058872554211704454578960600062230528.0001","v":"3.0317990192043497e+69","b":"4e5c1d29ca65d803"} +{"d":"c341c37937e08000","s":"-10000000000000000"} +{"s":"+58686249.812522674037","v":"58686249.81252267","b":"418bfbd94e800be3"} +{"d":"000bb2bc897adb5c","s":"1.626833456712411e-308"} +{"s":"0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005600948511","v":"5.600948511e-314","b":"00000002a3b47029"} +{"d":"46293e5939a08cec","s":"1.0000000000000003e+30"} +{"s":"0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000049263583320331599939551207142752004118875880930105041845899458528026576370727454162211198824181885606123704388783715414234320864145229578019157732703633982708237445456863101128184148275298245555499757042158137997885012884842323175948759437615610742591911149440610001885646122725481172052935908858640897176586215422170435617474063503586478012624487237167206548719206741500970207981996938834837582150424029683593327592857510054933012254955126863077325347626892817327659092912298906908388341392437078796630646952871554048380937182623764245975147251488700288636576787567512767209912645894202212941364555630119359706545634147798613216898112009134447220048969029448926448822021484374999999999999999","v":"4.9263583320331597e-269","b":"083a069312a0a375"} +{"d":"3d8a636641c4df1a","s":"3e-12"} +{"s":"+7366164891725344826104792842594436476451152576092420883145802221977373189586302905470707319193712901697210136225915121693389430946881852479585611258596451757932497060612302617722886678800408348981827014120278543439579430910025736585627688704963627718842973987311488223405856811135238933776392084481425140255591482129853369579670032486668342741034497876809927037634613266933381559780098079525496291056078433248577932842894912502975930827103367389042200354148757447795490785759404511530368701028041760337383834768737357695917564628828771220606897078979465416957756100587448343521237514118315295368459896131110005351942469106571495558321278083534408038445318374208180886846465693474750259970969812407727737743283995707881108075301772192237233937701292359378452937160506317057535318653406061099827844623776538705164110658340525118590120003626989003554485475513401164956670268508904806694165653560168076508507578262358525e-738","v":"7.3661648917253445e+177","b":"64dd15ac3757019a"} +{"d":"dd59c18f084acf8d","s":"-4.907472700227624e+141"} +{"s":"+18362043640382159346557988737333453036034317759166620435416388747271432961074247554732424238527185295512497160906015382792705214223433587158702481503162372468705389452247868388424154108214339284196294022871099704720233278104299809712451916953516800873495849175031897206919076193435033383530640697208829670445240125048799036502421008552438365499110930230613694964206437988486831926763119159937089051202789128892755199191324418421776202079068768672094697372206982902296345375452507049207232670616623943351482234452542857656624315519","v":"Infinity","b":"7ff0000000000000"} +{"d":"4f81afd6ec0e1410","s":"9.999999999999997e+74"} +{"s":"-79214E-106","v":"-7.9214e-102","b":"aaf1bdee13716574"} +{"d":"444b1ae4d6e2ef50","s":"1e+21"} +{"s":"-477.24437483664864023","v":"-477.24437483664866","b":"c07dd3e8f596b5f1"} +{"d":"0000000000000000","s":"0"} +{"s":"+951e-368","v":"0","b":"0000000000000000"} +{"d":"cababa4714957d30","s":"-1e+52"} +{"s":".5","v":"0.5","b":"3fe0000000000000"} +{"d":"1529af2b7d0e0a2d","s":"1e-206"} +{"s":"-929.862","v":"-929.862","b":"c08d0ee560418937"} +{"d":"617337e82eb65780","s":"2.701933264488194e+161"} +{"s":"-674177031800498613141e346","v":"-Infinity","b":"fff0000000000000"} +{"d":"73d658e3ab795206","s":"1.0000000000000002e+250"} +{"s":"8283314687357001145756e143","v":"8.283314687357001e+164","b":"622cc4b95d342094"} +{"d":"429ff78d97000000","s":"8787023216640"} +{"s":"2.4703282292062328e-324","v":"5e-324","b":"0000000000000001"} +{"d":"00a9d8bf999a6a4c","s":"1.8403442470884674e-305"} +{"s":"7873745792357059030444604914744.91910281521569449767122100124287610","v":"7.873745792357059e+30","b":"4658d85c7786e6cb"} +{"d":"40151aa331893f22","s":"5.2760131588"} +{"s":"2e-324","v":"0","b":"0000000000000000"} +{"d":"1dd084aacde62d44","s":"4.48193885181178e-165"} +{"s":"9.99999999999999662524558361809979965e-56","v":"9.999999999999996e-56","b":"34839dae6f76d881"} +{"d":"3e70928a0a66a1c3","s":"6.17370711e-8"} +{"s":"+3963663597542192160966514803.6894798995072","v":"3.963663597542192e+27","b":"45a99d54d4587f80"} +{"d":"0000be8214439f78","s":"1.03489902695866e-309"} +{"s":"-2583589479517.752197265625","v":"-2583589479517.752","b":"c282cc4f7722ee04"} +{"d":"448ef4c7b70095d4","s":"1.8273298876481535e+22"} +{"s":"63e-120","v":"6.3e-119","b":"276455d0d544ce40"} +{"d":"e583478410f4c7ec","s":"-1e+181"} +{"s":"0e999999999999","v":"0","b":"0000000000000000"} +{"d":"60f2357684599703","s":"1.0000000000000001e+159"} +{"s":"+10444809984.5553","v":"10444809984.5553","b":"4203747938047141"} +{"d":"0004780f3e9c3e43","s":"6.21488524241986e-309"} +{"s":"+8.90516877088392254843218326e-13","v":"8.905168770883923e-13","b":"3d6f55101d9957d4"} +{"d":"fc1f51c0d6dcb75d","s":"-7.630422203639722e+289"} +{"s":"-3357250794953059060822760947310769618747318117858185049185975673339614428217389140069699826515702332407770985262188468429847489565686095464458239464110150847767936606874029258650579590251457173407593419358211070766065083962519110738866469445507993153678009135599677359533571116041346619392985068106144450362507938677475940614662473146321193214571121441039239388971943017187029789346772621242659601396835260985878763506863458465778045208463309563677137274993326078574136395356501172030275676266488896507934377189876917880724170618028193505887727243286077348950015554179395668084333202457798491253238424936048396803211540472177490854000314757008849439339563690440899008422883599560719805967676200948767414392627728660294632574317169682217904938036891285408905886785256832047466385504580812896577736781903277430171552260205069912346356995606574345412173553206946179232429985979030006588365415200486916818245729019806644757956178972781977953268707041371119306876201269892857342177750177703591811121693168216995356459753148744269247396011724907937763680049711295558331069621462551407525996070187703545523853216282849378087994983576595620343599532655583472615533e-1397","v":"-3.3572507949530592e-242","b":"8dcca7824abc0310"} +{"d":"3e45798ee2308c3a","s":"1e-8"} +{"s":"30429764700694894143275509893191836242152355743890404587827956916637005021436771130331933385128598016028335660146553615083783404193479697229185920190463560344213334881839968370354949426533180585443885740487441423503264796164248635833251382504864130052379226583328742511514466504046853027587162237332432330496504000680316406049541238300964949000506195371779869153336147174009913560640049886340551660090617123045726268484559252620323519145751046092441063766348556862404649411766653489905340392796603176361712999387654900587046287627023478404032299909672254882046397573","v":"Infinity","b":"7ff0000000000000"} +{"d":"7123a825c100dd0f","s":"9.999999999999996e+236"} +{"s":"7503242916034134186182627142992117927514922221632354008536628533687990322482334786234719826508310184513677251460956386185819409886957945071091194503272452277345790189802218095724688736191228990453971737759250442774996702107191183354602726002138272459520495090381109087536895677592850764924827053596430312999862585709839049663117293793061212842541471922585032617963951703943921482584981865089635011401014708098955452442169189453124999999999999999e-607","v":"7.503242916034134e-163","b":"1e459aa7d76aa5c2"} +{"d":"46293e5939a08ce9","s":"9.999999999999999e+29"} +{"s":"-29.6518","v":"-29.6518","b":"c03da6dc5d638866"} +{"d":"6126c2d4256ffcc3","s":"1e+160"} +{"s":"96841290289777132083299e-133","v":"9.684129028977713e-111","b":"29174a1872b1d287"} +{"d":"b3e41633a556e1ce","s":"-1e-58"} +{"s":"-26014194278787556883275510163964696815.3213","v":"-2.601419427878756e+37","b":"c7b39226cd8ec8f6"} +{"d":"0000000000000000","s":"0"} +{"s":"+4174197547968207526107316428963.3919923819819","v":"4.174197547968208e+30","b":"464a57c7a46f4519"} +{"d":"4ababa4714957d31","s":"1.0000000000000001e+52"} +{"s":"-84.786497124275675663548","v":"-84.78649712427567","b":"c0553255f808ca5f"} +{"d":"0c3ca38f350b22df","s":"1e-249"} +{"s":"+256862667081588584.4953930065531793886344","v":"256862667081588580","b":"438c8479e0dba8fb"} +{"d":"41fb0271f1000000","s":"7250321168"} +{"s":"0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000244079656026127068070","v":"2.440796560261271e-308","b":"00118d1c498c57ce"} +{"d":"120ceafbafd80e85","s":"1e-221"} +{"s":"0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000286747","v":"2.86747e-102","b":"2ad9b089d996c1d2"} +{"d":"294e0fb44f50586e","s":"1e-109"} +{"s":"-0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008432019752","v":"-8.432019752e-112","b":"a8e038fb2eb535fd"} +{"d":"740bef1c9657a687","s":"1.0000000000000002e+251"} +{"s":"+84.2239937","v":"84.2239937","b":"40550e55e9ac00a4"} +{"d":"42939da256800000","s":"5391938592768"} +{"s":"148627136725212824548.3989244480471156541671764648682787829","v":"148627136725212820000","b":"44201d3b52c85373"} +{"d":"3d5739ae595d47aa","s":"3.300516e-13"} +{"s":"+264.976370797","v":"264.976370797","b":"40708f9f36fc1e27"} +{"d":"000003e6054ccc9c","s":"2.1177957313033e-311"} +{"s":"44211128573e-273","v":"4.4211128573e-263","b":"09764645170c1707"} +{"d":"b23af5bf109550f2","s":"-1e-66"} +{"s":"0.0000001710437062359557298837944004123168273423516438924707472324371337890625000000000001","v":"1.7104370623595574e-7","b":"3e86f50459d58b79"} +{"d":"41ee364344800000","s":"4054981156"} +{"s":"-5916320103e-135","v":"-5.916320103e-126","b":"a5f0050017c30609"} +{"d":"3eb0c6f7a0b5ed8d","s":"0.000001"} +{"s":"1138464724867644247572959279722501934727135761173189284710209763913547190802772275969298040938400794075957841042073115695714357911968870805572156601811031722265243101093396653194190992928230349624269843033327906837035066211759222129174285118347819606044703717458999563594687828474012697167568453008079781365599689459520738070199504691392902433466973892714643387607498073601344379073247883047667616387417009473472379577564844727887940843111409505412520031065477845935088813732328745975186828616678989003210781274777320102273847269545475013809454657738919053029971229572889194498154700135542387893157824546768055022855268049016393979867326812059979353923019403838090329022640955959805334718943364363536195649488107709762168186939345765378967507221957438003735497765555912336312794449478279363737754978072028231463374047155305013862982813754107018418243095240594762198778197852847558466351826122046038106264177636561906787343166271657044030653730643916698676288980386391086735416527600907801406435990970079373530108478992757301649446317648217027799287632972240054161599180085202405168174151494743938178860179435754632178097614031090331646928389360603584055155171729438823413765536675317576202091571051759443016777161528323595990810802353527833320406426493942070106225821831491805727953972e-107","v":"Infinity","b":"7ff0000000000000"} +{"d":"0010000000000000","s":"2.2250738585072014e-308"} +{"s":"2755109764737310303561e176","v":"2.7551097647373103e+197","b":"68ed7c581bd8207e"} +{"d":"0bbba792123b0780","s":"3.771990527421189e-252"} +{"s":"2.6301111293806570365170353086e-20","v":"2.630111129380657e-20","b":"3bdf0d05ebf90daf"} +{"d":"40c2bb26f0068db9","s":"9590.3042"} +{"s":"0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000019951131604501372428","v":"0","b":"0000000000000000"} +{"d":"5f48708279e4bc5b","s":"1e+151"} +{"s":"189726379E188","v":"1.89726379e+196","b":"68b03e70c56ca4cb"} +{"d":"40fe3981074ff081","s":"123800.0642852206"} +{"s":"8062656502919388688427482474193090654908496642803072893981232750403402772978702439117844335989969988401719120319750827537551127811997318383084518224439897383374358482373018615512331136300714188009529920768933038624203856807496004992322618128811449917081588111890597499750851638764608881957882755338930886804115322606232499591524249961697240123793092670314915199483600413770846021736723792999062465538975941607447240754745796446955188579444438917039439998352103445161824792270006196292426386269232639448780404853074687846132144219883233075685361758752288110546557346902733212629527610952006313833094441811735285819818466402746944460095581227307850621623228375844030949986305683352545647499208677228438461950052566736045675379093771543475550284124360026460948400544421625937622175144304427301479851793712563819906112584188592853916028036257985902782586015831326453378570954203521656670197606750683652128349562551212719404971869311756487528057137334628605064354019747832447944751931337287155382590052878328356929933290379732851687449466326896468683559556e-293","v":"Infinity","b":"7ff0000000000000"} +{"d":"a77023998cd10537","s":"-1e-118"} +{"s":"0.00000000000000000000991822580759858","v":"9.91822580759858e-21","b":"3bc76b331b119c95"} +{"d":"7ff0000000000000","s":"Infinity"} +{"s":"+5533879436261226424073412036217762484381535876119981796606093618675999587310687196378459308135883476601621339017279828848769629027114744692876169620675345411530351783951774373988495222793325860434462706001615547225650596031368721202e-387","v":"5.533879436261226e-156","b":"1fb2fe96539fc67b"} +{"d":"40bc4a03ad000000","s":"7242.014358520508"} +{"s":"97946269233464805371243570008147541006519841979074720920517860134683807485727621379453457621613269977112553850085149166272897182666877871021594465030562942795427295438361725054780796936563272979079218698121316820492498886174037971980668572007496036551964873333603684202299191438214844209842775304139389617966786382356783219263400846937326731822566932893879477946089378162335366356207153248636250502944590123245123556230954029013148308886867884445666443343610174222556775349156896173689857075956350863888428857914615124127860080120360375751820747092935560534550091434450907274221652994131437094366978298810236980631037064523377485199593872929696915831756999399690206065428718509121069682684182802843110644793930066948722408548836621154864612886678488282532296376117379316437041466269842259553299575751289381627957330007203956998653750906159174372765118202063832731538281208314364534382493414308349049770950257081833752601878055535055013555182205045831911772842800891065095676357637595232372604816972606187554911006892187049846156259188305521621467378588018251415654834572858947308125819263516704519465446228829203023415989178333340777012848446487095258981548842932839166502181798069658203354664446765477753448002727081563275391752077122828034449846045427474088827031787592088382444690544","v":"Infinity","b":"7ff0000000000000"} +{"d":"e0bd22573a28f19d","s":"-1e+158"} +{"s":"9357.479333724","v":"9357.479333724","b":"40c246bd5aceb63a"} +{"d":"41ababe7ac000000","s":"232125398"} +{"s":"-2851216158E127","v":"-2.851216158e+136","b":"dc439d2306c4cc24"} +{"d":"3f1d481d8495b1c5","s":"0.00011170082247752903"} +{"s":"146.95","v":"146.95","b":"40625e6666666666"} +{"d":"3f45a272d42259de","s":"0.000660234516788812"} +{"s":"392562698407371101e144","v":"3.925626984073711e+161","b":"617bec1c7a17d215"} +{"d":"59435ceaeb2d28c3","s":"1.0000000000000004e+122"} +{"s":"-6558532148806425045462235147242857876870455181509130934007542073546115073308709352510469973989655352764004539078086852310416480348324447627466804668844144633590140980708248042428801543209333394200258945415506250234502971054415831697863115261607936000000000000000001e-18","v":"-6.5585321488064254e+246","b":"f32e0439f4173a0e"} +{"d":"912bdb38cd5e849a","s":"-5.879457415913575e-226"} +{"s":"-1633492727350378114161848716873780545964077033230989777116690351180882994682150087282303741519375383445842633089733730063660049488743381488283989527389860805376756968156347648142248953188195955058210286917873627575397947564202884798180386929639090792205875637498727274825793457841824537816861524392710243823742127099400987059868923442748904773362124816853141968934615769248945085106536289363463760603221264311633402084550924201482723135635645039011754127003986783491615911787224962614776752778761709853803473879992719831483112737672020509041423526441565531450735682367532382614629967539212136978586146378498019655349134440803132292293694961805602309130532917506645722171090490288814409249090924777820399680825205329317940529831802800827059180940701046021932491236407093331549540026144063773491080750169130399247814962009e-426","v":"-Infinity","b":"fff0000000000000"} +{"d":"40bb5a6ff0000000","s":"7002.437255859375"} +{"s":"+39690841577e235","v":"3.9690841577e+245","b":"72ed10875121e809"} +{"d":"40af561726000000","s":"4011.045211791992"} +{"s":"-0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000013856240044925243513734086315419702424484335619726127038809556616162884778182747755453880980622377189207600011724377766882108373972268028447886038742615847754693927731422607062083975188175564139718962987748189514317892742339951053858252299624789928737764961879379632747154550998424299288903592134717001638433740415095092328167999172735752601365746412367504494549910958539432470614966804977017106135003332950286836121905667378201766702509064424738171998409305344531757751998627787107009703195795019472053463460170825885143182785475619984414606091699154168927952120656774657778230217514253303412739072098992289401274768489519153547842460365024683008544592855301559145545495470568164106552095170529535949662339356499313216850390907686207953020129934884607791900634765625","v":"-1.3856240044925243e-307","b":"8038e8c5c2fd7d32"} +{"d":"6f2ab4f536790f73","s":"3.1633677416253846e+227"} +{"s":"3167.12345678901234567890","v":"3167.1234567890124","b":"40a8be3f35ba6e8e"} +{"d":"425d86e54d800000","s":"507268904448"} +{"s":"461418444247396903131735684383960810402776617432118982816666860037454176758569711896471748878696406814129192149858063193062997189127042111843011814927126257736438987949500241650580687339441447033033764177731354470928435722135497091004098456675777095048009787753328574595158573207466146655305998627786437272713247193314483008281484423997392078814803590196590306580760640707567010333408930345788509014868784847064169940161235330522440392794883212483290588064688819907276421808408124781130484792784813194032785909988890447105749915983545847168848826957889685168917703950250064443822062888163259319384048975527989882245555698708319939638008642410931631473275446897885655432937561177864533090659529188374687247068727622812174283270861274708352084417128935456275939941406249999999999999999e-1090","v":"4.614184442473969e-308","b":"002096fb851df59c"} +{"d":"00091cd260538565","s":"1.2672609288088e-308"} +{"s":"42160e335","v":"Infinity","b":"7ff0000000000000"} +{"d":"3bf4a90ceafff9df","s":"7e-20"} +{"s":"+39707382351648199124667.684","v":"3.9707382351648195e+22","b":"44a0d11540dc311b"} +{"d":"000b8b96033ca640","s":"1.605565702148965e-308"} +{"s":"0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090556472","v":"9.0556472e-292","b":"038212d9227389ab"} +{"d":"5be89ee6d1d0186f","s":"5.592276595024963e+134"} +{"s":"+.0e5","v":"0","b":"0000000000000000"} +{"d":"4415af1d78b58c40","s":"100000000000000000000"} +{"s":"+3997079706723673183944056489748973424040703341782770111296964014193004725741202482438317962208037196091982509988047698519015170565022651609699729273802599308228611323474212419873393681743321541196642867079146618169133652003681629116470585637770361398179713498188523430454516902040466806335017923239860315847563341010269706511158980192754300840998727277275338880942363209603932461692923572051307021928933541072114254210097760373255211155331904094835454684913286955903950784180283438748216689531316917894497130721581286932356681691863459542227099193393962529369914024653800363484432044975064254905448217098177850550841619013688127723944086075811702291046380466890011011166998807396882200463598427441654194061251609729731728316962541777814401431662396424914268729912327967266172110900538939860717919407854012802328943646697846084313927802301147073815720816913326590667941353152640647704109450e-659","v":"3.9970797067236735e+229","b":"6f9a5d1a62f092a4"} +{"d":"070bb2a62fe638fe","s":"9.999999999999998e-275"} +{"s":"0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000919406135281955135137","v":"9.194061352819551e-115","b":"28421cfc30bc39b6"} +{"d":"75b4cffe4e7708c2","s":"1.0000000000000003e+259"} +{"s":"14036774143560362e-123","v":"1.4036774143560363e-107","b":"29c07ba4a2e4171c"} +{"d":"0cb60571542d0469","s":"1.968456162540076e-247"} +{"s":"35859606804620545977485646444699104667288205555412571259789468495350920665995895391566929860242405422167295575511976338588884090816553658035549817393376639650829017929357221939929801904547118577281969779008165980441697034475253493988865557801780023413082172954336453981319987200000001e-7","v":"3.585960680462055e+276","b":"7959e4b772f26ac8"} +{"d":"7b8503e602893dd4","s":"1.0000000000000004e+287"} +{"s":"+0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006107172537426991708","v":"6.1071725374269916e-198","b":"16fd3794d6f0adff"} +{"d":"444b1ae4d6e2ef50","s":"1e+21"} +{"s":"+100000000000000000000.2347","v":"100000000000000000000","b":"4415af1d78b58c40"} +{"d":"40b902e3d70a3d71","s":"6402.89"} +{"s":"2672.09611648673","v":"2672.09611648673","b":"40a4e031362e1e39"} +{"d":"40817d92a02b65d2","s":"559.6965945616196"} +{"s":"-55102119377130212464818657335148886572336372907668570681041083785800842112839714306380337639574758256068574888636895435008534152864354113216025827234338257598896083319247157027799017656772901366169570267371783291583844225118913529383722144312693618368834198253952902640122936292303440671566230658650372754063272454431803920864236178805722351749634803519696301469742681013389885492793165689334305257246e-912","v":"0","b":"8000000000000000"} +{"d":"48920c966f631f54","s":"3.9307612443237384e+41"} +{"s":"0.0000019222147610828771341091647360836216","v":"0.000001922214761082877","b":"3ec01fecbd8de94b"} +{"d":"00089d3d47657c04","s":"1.1979542176355692e-308"} +{"s":"-93.2388965819841","v":"-93.2388965819841","b":"c0574f4a14e3afdd"} +{"d":"6edb04217dfa61e1","s":"1.0000000000000002e+226"} +{"s":"-8763.84419841","v":"-8763.84419841","b":"c0c11dec0eb18925"} +{"d":"fff0000000000000","s":"-Infinity"} +{"s":"468231027674122580e202","v":"4.682310276741226e+219","b":"6d8a874e54e4fda0"} +{"d":"40b6225acbcf1250","s":"5666.354672376605"} +{"s":"4944425751408789727931355529469223358711323156388368360331199923401953642062529256908392834196635893564319297496906582080232327768161024931419219580049524774284294906378643653255991183251259588524478044670340499145840980137171331596478958566157092357965807943433616809167793582757396344124620844958194604645558985977043283414610718872274303848459487898517589996540730891377758270525987185969465152691895105883293891252897762753528114839876634642156949480918308181911388610246099697372746199377618725723480117123349817180509868974650947583935774847570819702355767396962505968161728692907058237258567048074091053106655333661492563896392376871458197480411158908112208710700838370608198832371681326528245539282368882949039521474115382870806456594436895102262496948242187499999e-1080","v":"4.944425751408787e-309","b":"00038e3045f51477"} +{"d":"dd6165955e2d2b87","s":"-6.629451625718358e+141"} +{"s":"695974355016542404677108.89884793827","v":"6.959743550165424e+23","b":"44e26c1b0d652c0b"} +{"d":"444b1ae4d6e2ef50","s":"1e+21"} +{"s":"-38855659406005158202013762488485599543689433019823495277673771575446881177745825388437045986565944914703523784230858020787874430976","v":"-3.885565940600516e+130","b":"db0c0711c77177b2"} +{"d":"422e3081bf020000","s":"64831414145"} +{"s":"7757464e145","v":"7.757464e+151","b":"5f77b2d4c0eb37e9"} +{"d":"b2cc8aa35c8ba503","s":"-5.4203654191829956e-64"} +{"s":"3e205","v":"3e+205","b":"6a97ebd83642c4d6"} +{"d":"d65b403dcc834e12","s":"-1e+108"} +{"s":"524401580693494339137909508111921037347076764705244678857071573770542619904668965930718107036982091681798360123496923032359531061290268268619756255038754282029590188203364503268713287365626429440.00000000000000000001","v":"5.244015806934944e+194","b":"685cbc15c50e1b21"} +{"d":"0f245962e2f6a48e","s":"9.999999999999996e-236"} +{"s":"+73358262848315.35919255205623564272699","v":"73358262848315.36","b":"42d0ae034cb2ced7"} +{"d":"1102f39e794d9d8b","s":"1e-226"} +{"s":"9329760236607145204423407307436193025729719096500450772985565108989921766566178980265429192469840092420800250138213023890800640000001e-7","v":"9.329760236607146e+125","b":"5a160d5e29926fd9"} +{"d":"7ff0000000000000","s":"Infinity"} +{"s":"405307388100249E005","v":"40530738810024900000","b":"440193d0e1a73d62"} +{"d":"0b2c66b6c547ee42","s":"7.56607730787969e-255"} +{"s":"2714.045661109800013981","v":"2714.0456611098","b":"40a5341760e49a95"} +{"d":"7ff0000000000000","s":"Infinity"} +{"s":"-4111.88639525079604","v":"-4111.886395250796","b":"c0b00fe2eacc9580"} +{"d":"77ba841eec0fecae","s":"5.471995681447637e+268"} +{"s":"755258302656530884341538126097376255.114170614803","v":"7.552583026565309e+35","b":"47622ea37f22660e"} +{"d":"3e7ad7f29abcaf48","s":"1e-7"} +{"s":"2.0916255905872032515","v":"2.091625590587203","b":"4000bba6329863c9"} +{"d":"66f6fb97ea6a9d39","s":"1.0000000000000002e+188"} +{"s":"-2.32561685247357587869579598e-7","v":"-2.3256168524735759e-7","b":"be8f36c23782a4cc"} +{"d":"41049edfc0800000","s":"168923.96899414062"} +{"s":"+8686463734236107833.3498903","v":"8686463734236108000","b":"43de23212f945d35"} +{"d":"422df7b563000000","s":"64354955648"} +{"s":"77609167034595157129795631913019935622725015823648312200357606475953138854236328745686683922438124356252089221313769387362892434234574924826293511155067861189202431794102782763925903591513858691119031222847458772282455023726788110185639986334987079837501125699183837184.000000000000001","v":"7.760916703459516e+268","b":"77c2cdc964e39c8a"} +{"d":"e1448b5303994ee4","s":"-3.6104196967718434e+160"} +{"s":"123456789012345678901234567890e-30","v":"0.12345678901234568","b":"3fbf9add3746f65f"} +{"d":"3f3a36e2eb1c432d","s":"0.0004"} +{"s":"1.30109084797489581474177","v":"1.3010908479748957","b":"3ff4d144a312d557"} +{"d":"4204330774000000","s":"10844434048"} +{"s":"9.8386499595782123392500","v":"9.838649959578213","b":"4023ad63870a5c3c"} +{"d":"5dfcf67d85aa619d","s":"5.650921486905694e+144"} +{"s":"4213465467119572416121101552619001.5750310799338213","v":"4.2134654671195725e+33","b":"46e9f7ad26420412"} +{"d":"000f2906122c4c21","s":"2.1082920927843563e-308"} +{"s":"168343829751402610550588605367314720751616","v":"1.683438297514026e+41","b":"487eeb7d24461038"} +{"d":"8000000000000000","s":"0"} +{"s":"13e-99","v":"1.3e-98","b":"2b9c6f2ba0203d45"} +{"d":"000bf5be1316f213","s":"1.663233191168159e-308"} +{"s":"+9989906e192","v":"9.989906e+198","b":"6940b48e77e43262"} +{"d":"00096c06a15931c6","s":"1.310287054438104e-308"} +{"s":"477e256","v":"4.77e+258","b":"75a3dae7db3d55a9"} +{"d":"066c5cd322b67fff","s":"1e-277"} +{"s":"+426205517e-76","v":"4.26205517e-68","b":"31f2627ff25ca40a"} +{"d":"0009c524ab7d212f","s":"1.358698350467195e-308"} +{"s":"704056744567636e-76","v":"7.04056744567636e-62","b":"333cf6953a79acdc"} +{"d":"0005bdef24c6da51","s":"7.98513686971935e-309"} +{"s":"-7e304","v":"-7e+304","b":"ff3984d86783fd9e"} +{"d":"4340000000000000","s":"9007199254740992"} +{"s":"+0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001870264272891296361799735208217288795525453646615271853078509497774760154599494351513299103287583051838518326409046960141359688987096003350939477414344396105254066500526996046598287351687239684177871421499956457790739932979911303819344491376830528033253932954690877184303693259095403901295931394128946312349626168725080788135528564453124999999999999999999999","v":"1.8702642728912962e-122","b":"26a8ba1bd58e2f36"} +{"d":"90591a207f13c7ee","s":"-6.467443691672859e-230"} +{"s":"2.2886415137867243501044723584657089947963198e-71","v":"2.288641513786724e-71","b":"314437e8e977b95b"} +{"d":"40f9a52743800000","s":"105042.45397949219"} +{"s":"+1e-400","v":"0","b":"0000000000000000"} +{"d":"41271979de000000","s":"756924.93359375"} +{"s":"+44E+377","v":"Infinity","b":"7ff0000000000000"} +{"d":"4b5a19e96a19fc42","s":"1.0000000000000001e+55"} +{"s":"979360190697996081.51605108971186","v":"979360190697996000","b":"43ab2ec5cf236cfe"} +{"d":"173de6815302e556","s":"1e-196"} +{"s":"+10768140452893E+71","v":"1.0768140452893e+84","b":"5161bccb731fa226"} +{"d":"000a3c63d43dd6d5","s":"1.423476853779594e-308"} +{"s":"-6607926255740883094487742498995343927.228977497305991483812281387478362241","v":"-6.607926255740883e+36","b":"c793e28fac03e3ea"} +{"d":"e5ee1fbe5a7e7861","s":"-1e+183"} +{"s":"+16.250183709769833327734185","v":"16.250183709769832","b":"4030400c0a237411"} +{"d":"3f0574e7c03a83e7","s":"0.000040925333477"} +{"s":"15204688938394076637010521584622700019557647103156719263383654538320432855097937029010014997821143288084695751533300930820707043611705280434036376298907747010407241019326521079632755733275763852489096550256307554552889003931702389970641667150767756954438136301202415036957716233116143194431478798062382004247040028007705443528147289596405145118509651088690370851593030374943660524545247421343e-418","v":"1.5204688938394077e-27","b":"3a5e1db1771a556d"} +{"d":"42d040348d800000","s":"71471782559744"} +{"s":"54530787.448391882777607347735728","v":"54530787.448391885","b":"418a00971b964e7c"} +{"d":"0000000000000000","s":"0"} +{"s":"-1578531286482e-141","v":"-1.578531286482e-129","b":"a53181c9aaa18826"} +{"d":"0006e746d63a2790","s":"9.60039355478938e-309"} +{"s":"+9962.7718994058","v":"9962.7718994058","b":"40c37562cd9987db"} +{"d":"0000000000000000","s":"0"} +{"s":"723316647042106374275e81","v":"7.233166470421063e+101","b":"5514ab25c70162fc"} +{"d":"000a68904e22e0de","s":"1.447473392574482e-308"} +{"s":"+447056774837e158","v":"4.47056774837e+169","b":"6327b10f3f1d3cca"} +{"d":"427198927c000000","s":"1209186893824"} +{"s":"70866449567580e176","v":"7.086644956758e+189","b":"675972d581749f5f"} +{"d":"27151cc9c196673f","s":"2.0439979235237608e-120"} +{"s":"0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000099519070927459874231591722","v":"9.951907092745988e-214","b":"13b571203a2f4a6d"} +{"d":"6aca1ff95113da58","s":"2.6210882950772757e+206"} +{"s":"2e-324","v":"0","b":"0000000000000000"} +{"d":"4015a0b8aec226aa","s":"5.4069545084"} +{"s":"-886304448610530846580959063261327627939141575762721258184865494781677695661226135115384749951772391796112060546874999999999999e-152","v":"-8.863044486105308e-27","b":"ba85f19f30568be5"} +{"d":"a46bc389886357c5","s":"-3.0558434937951057e-133"} +{"s":"4871869663825229904241478994829932054611580855419083032785765038412818070555575124337820764447036554081561027800828464765968320190535663834458391394755473377747359304992429879525527956330101957101504134838274862471361218114151238156425379126108574685311618682558844929272767500721809705746693805861727652410579268848437449181391632492875727885087723130035062805649317714121250737892227138641130188726368418341898842203964674842648771011274535232655948860612747535146533200225729874135678728043577647688921830636380454423183256629515608683410280674473823508786511597793622510602955956784681964372969564731541573888385741598891935603974577003765724179174394367484820871189874794835733846999206050249464025698181293277351073686668852951218668933301058138388428536038429679725644769108849978832675459599045750544208537120062509986990146757019810919601024227147054707297020375905905892375581352808214536911138317014784028411092789539767127982515072735055988162291484105644514480978069319680950067757173553723909421169790352491262352268768941105457729137010105817495041345229807972145848644410583872101439583785242849714313660038908463720899685232143028107329988886931435770377163805281831032113323681407997192846585882434786911992846093342669065766824605917873461358212452805455136168e-1248","v":"4.87186966382523e+30","b":"464ebeee10ffa372"} +{"d":"0002cbd7b89629b1","s":"3.88867868719952e-309"} +{"s":"0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000320108278765513917491490465","v":"3.201082787655139e-285","b":"04de76e3a4f0d7ba"} +{"d":"7ff8000000000000","s":"NaN"} +{"s":"2e-324","v":"0","b":"0000000000000000"} +{"d":"416cf9cfb0000000","s":"15191677.5"} +{"s":"+2436275302292809695729712703590773158838299553985660374450274684415785429307497011090478916057250743159912111604736634048873956832180724215498297055104211990804070829304061529007225402051972944856647851356123925370601984309926319047950151168709252088394351507383911654199687424338094388076569885015487670898437500000001e-429","v":"2.43627530229281e-111","b":"28f76fa227254ede"} +{"d":"5938251907083e47","s":"6.234819900928765e+121"} +{"s":"-613268527464242656088186386.211173","v":"-6.132685274642427e+26","b":"c57fb48a97d5c0e4"} +{"d":"15353bdbf1de1c89","s":"1.6534505605475143e-206"} +{"s":"61615229018742031.5376971161124402574625876","v":"61615229018742030","b":"436b5cd72dcd53a2"} +{"d":"7fefffffffffffff","s":"1.7976931348623157e+308"} +{"s":"469584316505530784925761e-292","v":"4.695843165055308e-269","b":"0838ced1656a2310"} +{"d":"63d9e056584240fe","s":"1e+173"} +{"s":"7e112","v":"7e+112","b":"575d1b6e02217fb3"} +{"d":"46c56f8344945f82","s":"8.695311063193656e+32"} +{"s":"+0e999999999999","v":"0","b":"0000000000000000"} +{"d":"b03af407a87a8d9c","s":"-2.3277273975424306e-76"} +{"s":"-4188335176130418331584278714.7242249459358556356837351340742983248","v":"-4.188335176130418e+27","b":"c5ab1104f1b4afaf"} +{"d":"00075ba3b7351c62","s":"1.023251230972265e-308"} +{"s":"-78672015423165e106","v":"-7.8672015423165e+119","b":"d8d37f9ffef715a8"} +{"d":"41f5b1eddb800000","s":"5823716792"} +{"s":"-129073.249412625","v":"-129073.249412625","b":"c0ff8313fd9817b9"} +{"d":"b998dfe3465c8466","s":"-3.0660264454604927e-31"} +{"s":"93843557809164531455023144.5","v":"9.384355780916453e+25","b":"455368095d99fb29"} +{"d":"7ff0000000000000","s":"Infinity"} +{"s":"-54324155321620571272177397726532014918640833507777223551522593255292686378024762901271268066890351815370051988106074006548311390568917628244706998555984489087693329521092197067522571471500430772836957803211374124228454288906802931010288326707632975642561045955767953759919146363524577958033591261714856579334547167818601825570578281114276683477496936665470820701271523700494611121215447083477916277990814112890590945545188495860514280297051466598929409260770378941815108642676832131402815592625099509566192327670696505266722620784382365382342027554709183853657688572177368267079750932529198980711376584776536823647457164163369611424470316282629511773600901475077058950402020659297583905451549906938922592493255313164447590991608383337307941474136896431446075439453125e-1074","v":"-5.432415532162057e-308","b":"802388190c844026"} +{"d":"48725dfa371a19e6","s":"9.999999999999998e+40"} +{"s":"-0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000053303090445885686","v":"-5.330309044588569e-195","b":"9798e723204e908d"} +{"d":"0000000000000001","s":"5e-324"} +{"s":"-0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000817865","v":"-8.17865e-242","b":"8de17389506a81dd"} +{"d":"427a45de22000000","s":"1805461364736"} +{"s":"-1e21","v":"-1e+21","b":"c44b1ae4d6e2ef50"} +{"d":"5447688bb5394c25","s":"1e+98"} +{"s":"0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001087589","v":"1.087589e-295","b":"02b1c830f97e25b7"} +{"d":"4232d11400000000","s":"80817160192"} +{"s":"+0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009613358161820141304867493","v":"9.613358161820141e-115","b":"2842f074a5a64482"} +{"d":"e8986eb3c4043e15","s":"-7.134176853195763e+195"} +{"s":"-2755433587503287970166809323437476587229406731340602131647961382158055659653502249191125754233262582840473327685034485387109697023910295434296635593657794032599098894912883820840166559212013259301399395830215126129103324883938137363887568680851024757151681264328327498413439487537926007430030924614667985960464447005814021238883975120573867446165582755748179113917852860828246099771583643445040958839523412690486691221858752390008938921840676722158604977351567673201753734096318965755211630117968031037332620148507847802939537816918887348654179234301882648697448747893780450072843999871154239598200653128102950843662458840611297144078098618459589628164862599826500914518628637047025893623465118690399198616240041638738033657229397839015555068760733973380075610997151626754558598819135555596610","v":"-Infinity","b":"fff0000000000000"} +{"d":"000c8e489a1a2ddd","s":"1.74609824593127e-308"} +{"s":"53860656287114260e45","v":"5.386065628711426e+61","b":"4cc0c23fb0e54d5b"} +{"d":"42b36634c2000000","s":"21329692721152"} +{"s":"1e-999999999999","v":"0","b":"0000000000000000"} +{"d":"49a030b41ce440dd","s":"4.621498907274283e+46"} +{"s":"0.000168396487663184430181851858","v":"0.00016839648766318443","b":"3f261272d0864d5e"} +{"d":"775f03542dfb8370","s":"1e+267"} +{"s":"1737002717057E162","v":"1.737002717057e+174","b":"641c178eb2a48e65"} +{"d":"3fb8c1d06de37ca0","s":"0.096707369640614"} +{"s":"984509742171509397565042341248.23626255158739592455","v":"9.845097421715094e+29","b":"4628da3ebe418ca8"} +{"d":"a54e3967733289cb","s":"-5.450385027048495e-129"} +{"s":"4489016950387e116","v":"4.489016950387e+128","b":"5aa4b93736f42c8d"} +{"d":"4fb61bcca7119917","s":"1.0000000000000002e+76"} +{"s":"1.315040098942911510175267623402690338483364e-10","v":"1.3150400989429114e-10","b":"3de212e2d1e5f847"} +{"d":"3c3107376c90eadb","s":"9.231e-19"} +{"s":"4.341802272","v":"4.341802272","b":"40115e016a2fc105"} +{"d":"4340000000000000","s":"9007199254740992"} +{"s":"-1e309","v":"-Infinity","b":"fff0000000000000"} +{"d":"3eb0c6f7a0b5ed8d","s":"0.000001"} +{"s":"6693702718779274478111652110637561786703895115730022915638639818708157270317768109374691597053769705079580269366365011065151381916732447405844410586351392017561908967369043275475045421194319098801653110513210759328054988629149185052118919879487859642878468602420282759899815022134101535010790630868342501690648172495452727768974026820409863532754879586935940965183904565040144743936296111992594891169660456329823414697177640156883122378188581082611432641112483986017559610828634503405126289516107902690851473007849678035257189477468384922931465178190777206789571348867962647321468329278993338496338613028589416660641908033403492091026470753252581697698257508826531774080728916354438537741160620327614089014576434634625398180802861956391716339904581181400090676625693417492020281683595545589577769641130946788147204170022434682982171503338091066111034611941594712980285625541395585679764664241788316921495128727341391106193968780154691082180871749994792031399515792734815108516061501119507457486398036499147391857161589530438300604312802301429417104067240961944608314007338289029760927977179900147493808522239991668532610450445333441719240212280665720137314513017762441238333867264382053090512612755293038580324e-749","v":"Infinity","b":"7ff0000000000000"} +{"d":"e231e4879208a218","s":"-1.0303703838999402e+165"} +{"s":"-0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000078598400726937332630194","v":"-7.8598400725e-314","b":"80000003b4385865"} +{"d":"c264fc64b24540fc","s":"-721070428714.0308"} +{"s":"1.0000000000000002999842970e-184","v":"1.0000000000000003e-184","b":"19bb31bb5dc320d4"} +{"d":"5a6a4aace0d2f922","s":"3.559482467775051e+127"} +{"s":"731431642985445150.60201460101965","v":"731431642985445100","b":"43a44d226873416e"} +{"d":"7e031cfd3999f7b0","s":"1e+299"} +{"s":"+613.09166194783","v":"613.09166194783","b":"408328bbb94261bd"} +{"d":"4231703acf000000","s":"74897346304"} +{"s":"-100717957538027951163019947596653833590427244550662073465746871504885802557317555049596580434915250442218135965705418000015738215151836955112571592530302184460806349060963621498995975620844496549817915084438623767949758326038855680000000000000000001e-19","v":"-1.0071795753802796e+229","b":"ef7a92866d8369d2"} +{"d":"508afcef51f0fb5d","s":"9.999999999999997e+79"} +{"s":".0e5","v":"0","b":"0000000000000000"} +{"d":"2b2bff2ee48e052e","s":"9.999999999999998e-101"} +{"s":"2990301581442398E+115","v":"2.990301581442398e+130","b":"5b0591e0cbfa0a29"} +{"d":"429a250294000000","s":"7186564841472"} +{"s":"-85E-339","v":"0","b":"8000000000000000"} +{"d":"56c54a3047c694fc","s":"9.999999999999997e+109"} +{"s":"44222055505657731009205039260559405.199257509074743213233248","v":"4.422205550565773e+34","b":"472108a19fa30c43"} +{"d":"134b9408eefea838","s":"9.999999999999999e-216"} +{"s":"26269217638E269","v":"2.6269217638e+279","b":"79f2861ab98e25fa"} +{"d":"42ca87ee3854fa00","s":"58342239152628"} +{"s":"2.439619246564249041052409481829215e+94","v":"2.4396192465642492e+94","b":"53876428d1c0833a"} +{"d":"3ec2717bf47343e3","s":"0.00000219861241"} +{"s":"+2628338637e-000","v":"2628338637","b":"41e3952879a00000"} +{"d":"df7e69c51f7c6132","s":"-9.955416574801799e+151"} +{"s":"0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000015116570787157094956000740886845427578359773245260004098606709315524329743805605294585047953127273315818195766548389409633282571393985572177216007884769546614879975366163381407378456721693965788801433331513259785357910799907444268009850681507576024695312809074360113509749266087072720508099129958438675720120431953126058465459079994575748205586636508019776676073996403032587623616176047150841164015769980014888925257697019523510113461843643946305169558519352190346066041322927887747143934144220587008929451882605254981057990141604941244555418806868888050894044377294238497504885452136160457603212210520767171089985628212492209671221411662267885548223029569671785629745138132621644887006407738928618716363067955499733609179310693526598896596624399535357952117919921875","v":"1.5116570787157096e-307","b":"003b2cc9e2a9921c"} +{"d":"5fb50c1033f1a2d1","s":"1.1023272360468531e+153"} +{"s":"0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000673361714463192761708822429","v":"0","b":"0000000000000000"} +{"d":"f8c487c61c1b6441","s":"-5.5531931809873005e+273"} +{"s":"-305.99387564469278668754","v":"-305.99387564469276","b":"c0731fe6ea25e3f1"} +{"d":"40c6b766c2000000","s":"11630.802795410156"} +{"s":"553253.42715718176","v":"553253.4271571818","b":"4120e24adab4589c"} +{"d":"421290c2fc000000","s":"19934527232"} +{"s":"+24118041840.790967731802396169690","v":"24118041840.790966","b":"4216763073c329f3"} +{"d":"414219efad000000","s":"2372575.3515625"} +{"s":"938452049117126E-167","v":"9.38452049117126e-153","b":"205f74dab2a94ab1"} +{"d":"41466e5648000000","s":"2940076.5625"} +{"s":"296450140306972331579841080507316761226862728572278809158501462039564413750058507108450682140512080899222502322261020979136179838952641921024","v":"2.9645014030697235e+140","b":"5d18e4d95883fa92"} +{"d":"3fb999999999999b","s":"0.10000000000000002"} +{"s":"-13040237862649900e-109","v":"-1.30402378626499e-93","b":"aca5c2c17c5ec719"} +{"d":"2af665bf1d3e6a8d","s":"1e-101"} +{"s":"58.98422236743","v":"58.98422236743","b":"404d7dfaffa00d41"} +{"d":"3eb0c6f7a0b5ed8d","s":"0.000001"} +{"s":"1.7976931348623158e308","v":"1.7976931348623157e+308","b":"7fefffffffffffff"} +{"d":"f0409182b6706fb3","s":"-5.144548390189839e+232"} +{"s":"0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000243868806","v":"2.43868806e-214","b":"13950461d310cb60"} +{"d":"2b617f7d4ed8c33e","s":"1e-99"} +{"s":"0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000015063346119467","v":"1.50633461193e-313","b":"0000000719426221"} +{"d":"3f892ccf6be37de9","s":"0.0122925"} +{"s":"+17940945076683753813961149143195990914812891421585974766531622981337088","v":"1.7940945076683755e+70","b":"4e84cbbbacd92d30"} +{"d":"cd47518174ce8482","s":"-1.9185251592795918e+64"} +{"s":"-0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000650719918864089946290061","v":"-6.507199188640899e-171","b":"9c9925b676dc4cfb"} +{"d":"2208f9574dcf8a70","s":"1e-144"} +{"s":"-5668e-308","v":"-5.668e-305","b":"80c3e6a98f63b4da"} +{"d":"422fe422cf800000","s":"68485736384"} +{"s":"732418491.45793256394504256627","v":"732418491.4579326","b":"41c5d3e8ddba9d89"} +{"d":"32e3c662cd0106fc","s":"1.502194645446018e-63"} +{"s":"+9264541799.76708297727099475","v":"9264541799.767082","b":"420141ad833e22fc"} +{"d":"00094a1b6ed2119d","s":"1.291861346157605e-308"} +{"s":"+261014631e038","v":"2.61014631e+46","b":"499249b86838f365"} +{"d":"60f2357684599701","s":"9.999999999999997e+158"} +{"s":"63.34175","v":"63.34175","b":"404fabbe76c8b439"} +{"d":"73a788f8bdc41d85","s":"1.3164412236777432e+249"} +{"s":"8828.169702772602897892","v":"8828.169702772602","b":"40c13e15b8d2092f"} +{"d":"58a3d3e2388029bd","s":"1.0000000000000003e+119"} +{"s":"-80901E-176","v":"-8.0901e-172","b":"9c6902f7f4cc2c56"} +{"d":"40dc48d193000000","s":"28963.27459716797"} +{"s":"0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000046820984861874","v":"4.682098486e-314","b":"0000000234da8d46"} +{"d":"3ff0000000000000","s":"1"} +{"s":"-338826756.796215554214799782672122376","v":"-338826756.79621553","b":"c1b4321604cbd4c8"} +{"d":"000a9ca629664253","s":"1.475767779938234e-308"} +{"s":"2664040756006790265E105","v":"2.66404075600679e+123","b":"59901eb273a3ac2a"} +{"d":"4149a737cb000000","s":"3362415.5859375"} +{"s":"-564367977507603e182","v":"-5.64367977507603e+196","b":"e8c828ef5f3bfd6f"} +{"d":"05973c115074bc6a","s":"1e-281"} +{"s":"+0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000938523911297787653","v":"9.385239112977876e-253","b":"0b9b85fbeb3eb7f7"} +{"d":"ca511b0ec57e649a","s":"-1e+50"} +{"s":"7704509815.7140620543113152","v":"7704509815.714062","b":"41fcb397d77b6ccc"} +{"d":"3d245addd4eb2d84","s":"3.615765e-14"} +{"s":"67045591522950747127396327139953564477351788339197443583743787285955260947936433263713489547185910744005947186734562784850156463566962699734442123868417581390834761260127695589413094654872119009829236172968442379478070708821126550613184331952796090556751398004365066710931867516117331102935594280262090257943429767756756752212192497559864810809811891461088960663730479853294922731460039724670132509501664757566170812002448084630062742269709257213919732678674672316899944019772164514674141506862784110610714889787469822722703120719635836789836435227690235408247059640866800507595133184719854073917248208637095123","v":"Infinity","b":"7ff0000000000000"} +{"d":"19bb31bb5dc320d1","s":"9.999999999999999e-185"} +{"s":"+403121233351561085308003e-7","v":"40312123335156110","b":"4361e6f533f11432"} +{"d":"000b676127077741","s":"1.58589721984613e-308"} +{"s":"+334604635530807288463016240662990219086990525262554232376165006950800696974634110573527297553782853063538221854462615826242851258577302962891064917644652938448145069643702521685547478248308800582585421732799473496785616727989823599060523091002801887256217118400548898406135421103588769930953291618951895197764096366147778011597732921361223056947485416663011743949182370163594063073505721419512048958367288196044289190300181435161867473406104083178520236060819693681634319780731522228142271862916183522213174016714418125462285043346949903772272998948359550903385452647448231650521195406198362339315066164348341458245721106034919316388499443570077928009741260825803142804226661750324301509614343341717978260017105868137161950217833442098395303015025780940387560467708853649052818543049101631852539092009991940141361021268029501306972507047038923155596418140459130765887041807076264017867224509103136911835664010775326193847487173037189749","v":"Infinity","b":"7ff0000000000000"} +{"d":"817e79a09886d5b8","s":"-1.7775817748431302e-301"} +{"s":"+3631201265376002103170261304559685028.314776901115249122148182268920055885323","v":"3.631201265376002e+36","b":"4785dac05bcea868"} +{"d":"41fb88b87c000000","s":"7391119296"} +{"s":"9007199254740993","v":"9007199254740992","b":"4340000000000000"} +{"d":"72c0720ac8c5f3f8","s":"5.614524331915694e+244"} +{"s":"6988.47460381326865871499","v":"6988.474603813269","b":"40bb4c797fa2b08c"} +{"d":"000aeb75dc432f88","s":"1.518580527624558e-308"} +{"s":"822649326029626e-123","v":"8.22649326029626e-109","b":"297ee9951d778478"} +{"d":"aabce7934bf016f0","s":"-8.065816266336988e-103"} +{"s":"260e337","v":"Infinity","b":"7ff0000000000000"} +{"d":"a268cc5bbaafb5a0","s":"-6.35497043467361e-143"} +{"s":"-999e-359","v":"0","b":"8000000000000000"} +{"d":"0004b28acdfd9fa0","s":"6.532581117151994e-309"} +{"s":"423069399631226594003803578541654858714895738131400502747140946187251223888688139705186344538996736e0","v":"4.230693996312266e+98","b":"5468c2282504f88a"} +{"d":"3fd5555555555555","s":"0.3333333333333333"} +{"s":"4700813173781599101960732061595899287.6","v":"4.700813173781599e+36","b":"478c4abfde26500b"} +{"d":"3e3751cf3367a591","s":"5.42951e-9"} +{"s":"+620459412087785540344114123540942930557153668952235508453924733830219889115136","v":"6.204594120877855e+77","b":"50156efe544eb774"} +{"d":"0010000000000000","s":"2.2250738585072014e-308"} +{"s":"+0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030787321956347256503479960932092579403936477718670956651648126149038627345216498705801458069813600280588004348940731168217774098229444754216408443364688881087446475064926697842161786848328588745395861466629544938557503843952901732447556556097498066802037173359129427008315752044517201365806734291963016226559041360363871693890628673636126709430667006998936899408968555338099869098508929068500939239179270769897699654149558767812777659855782985687255859375","v":"3.078732195634726e-173","b":"1c1e75645f20c86e"} +{"d":"41a0c1d85e7f1c39","s":"140569647.2482622"} +{"s":"0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000586296","v":"5.86296e-176","b":"1b8db2a38104b5ca"} +{"d":"40504f1bfca7e23e","s":"65.23608318705462"} +{"s":"-4.9406564584124654e-324","v":"-5e-324","b":"8000000000000001"} +{"d":"636a24263dcf2076","s":"7.892475094936675e+170"} +{"s":"-661E-11","v":"-6.61e-9","b":"be3c63c59897385b"} +{"d":"40c0b310e8800000","s":"8550.132095336914"} +{"s":"7210765305E-199","v":"7.210765305e-190","b":"18a9b3bcda0f6934"} +{"d":"41927e7b00800000","s":"77569728.125"} +{"s":"2e-324","v":"0","b":"0000000000000000"} +{"d":"000ac8f3112a0c9f","s":"1.4998331333169283e-308"} +{"s":"84688724203e89","v":"8.4688724203e+99","b":"54aef9b43636310c"} +{"d":"9d0e3113363787f2","s":"-1e-168"} +{"s":"0.0","v":"0","b":"0000000000000000"} +{"d":"8000000000000000","s":"0"} +{"s":"65953979416201689763162676647961870306125190552821176192056459861719549645548268564271136561180199054906758091177971395316126754498213737243761572547416893731132575576874482418922564011312810936580808075586740420263021750464049058666045462608660399943250719926501666419813470164460260467607833552511886881427979737921497417244657590334599033907830339205630118135286993318503012171112311396159380306629635685177912108105397216003798304460084881999541510753418814739611444861699595425824752308758832860739549543053951883469939987286359304951275727427006582703031908669819211979522232483748299168235760867332604425392702013110245071442272566571e-14","v":"Infinity","b":"7ff0000000000000"} +{"d":"396ff8aed8e5b1b1","s":"4.925976896691031e-32"} +{"s":"8.52674978285","v":"8.52674978285","b":"40210db225c5081e"} +{"d":"41c174aeed000000","s":"585719258"} +{"s":"+7e-2","v":"0.07","b":"3fb1eb851eb851ec"} +{"d":"41b7691120000000","s":"392761632"} +{"s":"+635610656110828722108865729079411.588063334812258345662451037842300","v":"6.356106561108287e+32","b":"46bf5688cbddf2de"} +{"d":"3fd5555555555555","s":"0.3333333333333333"} +{"s":"+79772398271237673458001133748458222317351712782026520760276627922782630427823672980573241658096612799918047018657126499888433481534453279351098446066554645105701278020622041045608994533857492670392495978309731516621279363038213970736094186990979706825617795286589083697147789656694137506474773522222448643705789216357948246865353837475788053179483873421920711063530942123244567025815306340835418267209771587250790073101149042605416411198730863449538847219046868015221766097846951393453599112752428532733769107176589636178802376186635818480620294598452551373330782166063979862368915920798236840132932906963888151109573600295172097453543986118256862427470031380277694875092124596317759764977948036229548402990330463715676233017992546367201149198839954968808603814675625793769740489600037493557483123638032076330438876375901652292130975541273449917459535699584028719256095564971719","v":"Infinity","b":"7ff0000000000000"} +{"d":"22a8637f41fcad31","s":"9.999999999999999e-142"} +{"s":"-0.0000000000000000000000000000000000000000000000000004200687370713824337786224648","v":"-4.2006873707138246e-52","b":"b5441e071966e3f2"} +{"d":"3e7ad7f29abcaf48","s":"1e-7"} +{"s":"0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000073894059252","v":"7.3894059252e-91","b":"2d38157f86a3e6be"} +{"d":"9f76e4323248e7c6","s":"-4.168256675212849e-157"} +{"s":"+2.4703282292062327e-324","v":"0","b":"0000000000000000"} +{"d":"20d8467308a04f63","s":"1.853979228475462e-150"} +{"s":"-655676763071515.6041567468","v":"-655676763071515.6","b":"c302a2ad246720dd"} +{"d":"cf951b1c83b1b81b","s":"-2.3866178725910866e+75"} +{"s":"-0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000772455039999767163504381","v":"-7.724550399997671e-97","b":"abfa66361d49db7c"} +{"d":"5fb317e5ef3ab327","s":"1e+153"} +{"s":"123456789012345680000.535783651489367924330","v":"123456789012345680000","b":"441ac53a7e04bcda"} +{"d":"68a11f9e62fe4446","s":"9.999999999999995e+195"} +{"s":"0","v":"0","b":"0000000000000000"} +{"d":"eb537798f4285630","s":"-1e+209"} +{"s":"4173402209563217796356113293.67520072376284","v":"4.173402209563218e+27","b":"45aaf8509639f6f5"} +{"d":"000a943f5170ba95","s":"1.4712036988927113e-308"} +{"s":"0.0000000000000000000000000000000000000000000004183790781613022914182313","v":"4.183790781613023e-46","b":"36831bb193d63e53"} +{"d":"444b1ae4d6e2ef50","s":"1e+21"} +{"s":"-88964987908.802574","v":"-88964987908.80257","b":"c234b6b9fc04cd75"} +{"d":"3e7ad7f29abcaf48","s":"1e-7"} +{"s":"+123456789012345678901234567890e-30","v":"0.12345678901234568","b":"3fbf9add3746f65f"} +{"d":"3bbb4e0253a85060","s":"5.782e-21"} +{"s":"-1.434569057108503434331351481217796873e+69","v":"-1.4345690571085034e+69","b":"ce4a9b0619fa05f6"} +{"d":"000b1c6c2ad5ba0a","s":"1.5451782741589745e-308"} +{"s":"2e-324","v":"0","b":"0000000000000000"} +{"d":"4276bce5d0000000","s":"1562535329792"} +{"s":"52062722487981889527047374756934040287762979401502090796947072490954950195170697124249600000001e-7","v":"5.206272248798189e+87","b":"5224efead098a9dd"} +{"d":"3fd5555555555555","s":"0.3333333333333333"} +{"s":"-760713053529519660162e-22","v":"-0.07607130535295197","b":"bfb37968b8a7ab5b"} +{"d":"22a8637f41fcad33","s":"1.0000000000000002e-141"} +{"s":"-645166657007439958141811.5967248355847790619092788320463687140","v":"-6.4516665700744e+23","b":"c4e113d1beee9a33"} +{"d":"000d67e29929b479","s":"1.8643061356764474e-308"} +{"s":"-0.000000000000000000000000000000000000000000000000000000000000000000000000000000000060395401002514052","v":"-6.039540100251405e-83","b":"aedd55025296cdb0"} +{"d":"3e752518d6c82927","s":"7.877092906435966e-8"} +{"s":"1.7976931348623158e308","v":"1.7976931348623157e+308","b":"7fefffffffffffff"} +{"d":"40a6f9c0f8000000","s":"2940.8768920898438"} +{"s":"83.8272049348","v":"83.8272049348","b":"4054f4f0ecf78392"} +{"d":"0001aef175c84401","s":"2.34101673957887e-309"} +{"s":"-1.0000000000000003791e+282","v":"-1.0000000000000004e+282","b":"fa7b8b8a6038ad72"} +{"d":"41d377e026000000","s":"1306493080"} +{"s":"-90e91","v":"-9e+92","b":"d33b9d18370d57e8"} +{"d":"00069a9ba660305c","s":"9.183905474469695e-309"} +{"s":"-70839642162953182373212110840118905287687435421065773938667951351426978746533309401907273598987456392416173788041933943870867145235175421719513736849828422457838788757207425425202123211905076981505388086905138428307650500353496772159363017211512518013607550357504890600566392161636676361065562817168311330512907032057828318992995466092013662294713987723928317109159443227560525046627795832696531896352106184921167319322548914605436499349383464033192380456788669127419200388998447587496590419077881841262086646354000925580959946235582383168150843354695741322701317665703361243720515231700042129225984906321423121798800232069536264785862646151022919654686251545575905125555076188316778976785706752939925319152072597724270921868791852736687901672987006816066346987073574","v":"-Infinity","b":"fff0000000000000"} +{"d":"43053d7df1389662","s":"747323204768460.2"} +{"s":"30693963207220093625287951721126652892177890140563386939596865711797477170371293609983.99999999999","v":"3.0693963207220092e+85","b":"51af998bbfc3497b"} +{"d":"3c3652103de24285","s":"1.21e-18"} +{"s":"0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000222532197377478058004232","v":"0","b":"0000000000000000"} +{"d":"fff0000000000000","s":"-Infinity"} +{"s":"65.82943975931024652","v":"65.82943975931025","b":"405075158a800f56"} +{"d":"14550a6110d6a9b8","s":"1e-210"} +{"s":"5291041529956779674857221275819047247581810553725391403131103270519903069500733125028886116125266302704866775283451863642526960126366278162230614323734288359076808495410676801936629194324501279082376642383512712802669114029264188247349638253973745209734407151614191262910613569122827815003983449214286746432734038055662808477316888645212505025344673831867844600393431128202233789360960315630410941254879843672793614459623605190528827552553106137919717307800682379729547404100610696171716537970109048870193692330110859720215096044865119662799772275287130403641688209406276421858347559248668003698885544943825370875110872183288095013234455590760313501833138044772791393724051873116497216791878340037774608753126651270123886716565450840073932805280878582444660891154946686383795179791075518613720125544792517916978964927835489045358317189893082137409191850810801064042688086074002682296633372980620750599392902279958584213038818363831e-1183","v":"5.29104152995678e-253","b":"0b8f088444328e4b"} +{"d":"d3a7f85de8ad5c4f","s":"-1e+95"} +{"s":"+1.48","v":"1.48","b":"3ff7ae147ae147ae"} +{"d":"ea7fe52048590673","s":"-1e+205"} +{"s":"6640522579629523893E-015","v":"6640.5225796295235","b":"40b9f085c7c7525c"} +{"d":"3e226a8b94956d60","s":"2.143926956686e-9"} +{"s":"0.0","v":"0","b":"0000000000000000"} +{"d":"42a5b52796000000","s":"11933898702848"} +{"s":"96.8752437247141247648648","v":"96.87524372471412","b":"40583803fe416b4a"} +{"d":"398039d665896880","s":"1e-31"} +{"s":"+18626465002173397258350222213293386193603375949384321926781184050626604185803883077432414490579168307700078800103666458023159608934884900516937446815966486529228784328597634558442649348668442807619029954202184079751912158450474501259003054820285139010621396169553560050073600000001e-8","v":"1.86264650021734e+272","b":"7876093c8c534349"} +{"d":"00082330264c5aba","s":"1.131652184794652e-308"} +{"s":"4513486072930402e241","v":"4.513486072930402e+256","b":"75380c3e308d6c1b"} +{"d":"3e011f9405011aa7","s":"4.98355143618e-10"} +{"s":"+4038e-278","v":"4.038e-275","b":"06f65e688446eebf"} +{"d":"b420e2cc9d305ee2","s":"-1.3450422961099213e-57"} +{"s":"1.79769313486231575e+308","v":"1.7976931348623157e+308","b":"7fefffffffffffff"} +{"d":"42dfb1d6e0000000","s":"139394698706944"} +{"s":"-1.204157789462471799084209835540224341183821e-308","v":"-1.2041577894624717e-308","b":"8008a8a8bd662db8"} +{"d":"0006741efb25c2b2","s":"8.974832255956463e-309"} +{"s":"+101131504275429992517921872.531033997377941115","v":"1.0113150427542999e+26","b":"4554e9db75413f74"} +{"d":"53ddf67562d8b361","s":"9.999999999999998e+95"} +{"s":"4.026323","v":"4.026323","b":"40101af46aa087ca"} +{"d":"0d6cbc36b6ceadca","s":"5.260510582254016e-244"} +{"s":"+0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004548332799688604786","v":"4.548332799688605e-260","b":"0a1660dcf47a6b1a"} +{"d":"0001801fc60c6c5b","s":"2.086680977379435e-309"} +{"s":"56353851563537284879291929.36557905951496743168117981611081153","v":"5.635385156353729e+25","b":"45474eb235136f9b"} +{"d":"7ff0000000000000","s":"Infinity"} +{"s":"607495e290","v":"6.07495e+295","b":"7d57c79c7d74ee4c"} +{"d":"29b77c44ddf6c516","s":"1e-107"} +{"s":"301.839748382568364028","v":"301.83974838256836","b":"4072dd6f9c000000"} +{"d":"29b1af79a1a86153","s":"7.530393457094731e-108"} +{"s":"+508566347650649401842896740529257090.880872963587718891","v":"5.085663476506494e+35","b":"47587c906fff614b"} +{"d":"3e12da1bbea99d64","s":"1.09733e-9"} +{"s":"-65334453559811.58263305592051495973470792","v":"-65334453559811.586","b":"c2cdb5ee72b101cb"} +{"d":"11d72262f3133ecf","s":"9.999999999999997e-223"} +{"s":"+485861694234268391820104677220902596225681319394059301530900186869897917437848736943291247737042489569165592826871756752132558643119257297592779051847061856675826374055058437976040310690001918685345252394730564081112940861897948528158198430936210417352261272888300170191741853345613296812180255456288051573321495542145459107570685534661092736690765228080536584246501242820975439776826939103559791830932308105988333863877196777967739516220942562439039567782225680428372246550263507941757408942421815690578482645973275959879859757015481494296409098588275422440039111467481111853701023523593877831178383179210308845386829059133064937778225542141150812844101479315473672244671558695586019924539339547276370803545244341548661862239047448674966744874836876988410949707031249999999999999999999999e-1096","v":"4.858616942342683e-308","b":"002177f679563d0e"} +{"d":"ea9021c63cbc0722","s":"-2.02312827097298e+205"} +{"s":"+654e-43","v":"6.54e-41","b":"3796c9dffc536548"} +{"d":"41afe02eda800000","s":"267392877.25"} +{"s":"+8282409327730455015863933077058615955209234642003544354317115985863229753428902072401759366572508260628371450901048232732495763520068651532174682977204585020591461315065860812057253068180845375005310904838355657519126405587185447407924223931727971614719999999e-7","v":"8.282409327730455e+251","b":"743ceb8de341c4a7"} +{"d":"0005ceee021c4401","s":"8.077462033074025e-309"} +{"s":"7720638800760709042799306632047899986329326962551967679320174170318300856050367876700339791096780077067284374692700451206882554252221497894438519290866993563747969393005809656924016320278080698451404344042997101098850938233199179950348379149762815023003218840020509714031439760309790716639773844187072053138307583125424634177610887214781606047003343546255783832150678015302454805990808008019517979340376063227049405759635936320147118085451918416414878098336494935043947213888537379560845535252468986408525157508937350239975822867298496258276119962804486252060423041243185780882836023868029599851909532632182203906914539087606343879473198549715966747596854300037166381786746324062178439725104434393509417947685912825535774090964422","v":"Infinity","b":"7ff0000000000000"} +{"d":"418d4173ba800000","s":"61353591.3125"} +{"s":"-24717219799192918456834687296366018322614706026749216471796397904649034244652954038740853318341448009862675649067114855729351011895426984466103471742368109137156259500301762757839581534045583323336494180028070580549672992060160160403641428082688.001","v":"-2.471721979919292e+244","b":"f2acf5aacac05ead"} +{"d":"000df7add59f7c8c","s":"1.942419423894092e-308"} +{"s":"589661350826616693883842397237645.26132316902272178176840","v":"5.896613508266167e+32","b":"46bd1292956027c0"} +{"d":"2c0116805effaeaa","s":"1e-96"} +{"s":"0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014661","v":"1.4661e-227","b":"10d63a5defa2d0e3"} +{"d":"fff0000000000000","s":"-Infinity"} +{"s":"+0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000084027","v":"8.4027e-293","b":"034ad52cdcae21bf"} +{"d":"3ce203af9ee75616","s":"2e-15"} +{"s":"+8278.99648","v":"8278.99648","b":"40c02b7f8ca8198f"} +{"d":"0000000000000001","s":"5e-324"} +{"s":"60222643e+391","v":"Infinity","b":"7ff0000000000000"} +{"d":"6c02b3a4877177ea","s":"1.9674727504996594e+212"} +{"s":"1.368455505831326","v":"1.368455505831326","b":"3ff5e53199b93a17"} +{"d":"1bf231a16a983fdf","s":"4.597561894993683e-174"} +{"s":"+2.4703282292062328e-324","v":"5e-324","b":"0000000000000001"} +{"d":"3fabbfdaa2ada75e","s":"0.0541981052"} +{"s":"5.6702058659866153637486967066e-201","v":"5.6702058659866156e-201","b":"165bc715d51362b2"} +{"d":"3fb999999999999a","s":"0.1"} +{"s":"2452101643708586908155664104.4728899335","v":"2.452101643708587e+27","b":"459fb152e1da52c2"} +{"d":"000730d67819e8d1","s":"9.999999999999994e-309"} +{"s":"6919077117952.8102794972687337843468","v":"6919077117952.811","b":"42992be48900033e"} +{"d":"3bb79ca10c924223","s":"5e-21"} +{"s":"-2795502200747036153531391815498100707273191597252141477607193437506330205255185943570414994080103073390926096059068898772698895003069219038151590758640343757676624227457551814602927106391891355476054749317053107625929473268331589506186177553298822545980439522707596700718334134631258363368325183328348860759428239059699697127290900800452835820691139168565388073298928781923737187038085405506462069635230560204706394067407534619035250096451621226566655706969618094084852413809829736271151619917403505180027817046426427567705857262126098211792168957146031971205957233905792236328125000000001e-815","v":"-2.7955022007470364e-227","b":"90e53115ad90e8cb"} +{"d":"3dcbea36c65a6d1b","s":"5.0776904204e-11"} +{"s":"-4915.9003294603803472499506","v":"-4915.90032946038","b":"c0b333e67bfdd3f5"} +{"d":"419527c628f4180d","s":"88732042.238373"} +{"s":"-0.1413","v":"-0.1413","b":"bfc2161e4f765fd9"} +{"d":"42029e1736000000","s":"9995216576"} +{"s":"464523070529e+5","v":"46452307052900000","b":"4364a104119c55d4"} +{"d":"41528bf053000000","s":"4861889.296875"} +{"s":"-0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006315388","v":"-6.315388e-129","b":"a55182af23aba6d1"} +{"d":"40ba29cc36800000","s":"6697.797706604004"} +{"s":"0","v":"0","b":"0000000000000000"} +{"d":"04c308a831868ac9","s":"1e-285"} +{"s":"+2.4703282292062328e-324","v":"5e-324","b":"0000000000000001"} +{"d":"84ad44e1a40a0be9","s":"-3.8443509365245216e-286"} +{"s":"0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004322166424","v":"4.322166424e-240","b":"0e3cd1fd17089832"} +{"d":"a3b29b69070816e3","s":"-1e-136"} +{"s":"9417858589e193","v":"9.417858589e+202","b":"6a133978e19c0983"} +{"d":"3cd203af9ee75616","s":"1e-15"} +{"s":"4.9406564584124654e-324","v":"5e-324","b":"0000000000000001"} +{"d":"0e50ab877c142ffa","s":"1e-239"} +{"s":"461169735952950483e+247","v":"4.611697359529505e+264","b":"76e24e9066cd62c6"} +{"d":"b0c69d9abe034955","s":"-1e-73"} +{"s":"0.00000000000000000000000000000000000000000000000000000003965161374025744269052018131489379450806707382259098540852271690793576832035184086161809376204794396017380930774208544735990248939144190728047292826552450151211814954876899719238281249999999999","v":"3.965161374025744e-56","b":"346f1cb5f8eaf98a"} +{"d":"4a1b5e7e08ca3a8e","s":"9.999999999999998e+48"} +{"s":"3608786459E-115","v":"3.608786459e-106","b":"2a0a7c4f998f2f9d"} +{"d":"6edb04217dfa61e0","s":"1.0000000000000001e+226"} +{"s":"-0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005","v":"-5e-206","b":"95500d7b2e28c65c"} +{"d":"38aa95a5b7f87a10","s":"1.0000000000000001e-35"} +{"s":"762726264538e+326","v":"Infinity","b":"7ff0000000000000"} +{"d":"095223c74a9dc015","s":"9.00109481666616e-264"} +{"s":"6493.605014095308755","v":"6493.605014095308","b":"40b95d9ae23428f8"} +{"d":"1b895d9e7a8eb96b","s":"5.007712500246725e-176"} +{"s":"-285981249004283E+311","v":"-Infinity","b":"fff0000000000000"} +{"d":"4f682b74bf402f9b","s":"3.416340171396711e+74"} +{"s":"6995233012710603037863478978.230378371763514833675300626676199218","v":"6.995233012710603e+27","b":"45b69a5235789dcc"} +{"d":"4415af1d78b58c40","s":"100000000000000000000"} +{"s":"-0.0000000000000000000000000000000017253","v":"-1.7253e-33","b":"b921eaa255d60cbe"} +{"d":"408f400000000001","s":"1000.0000000000001"} +{"s":"-332702493078012595460711566365271572151637803645189840079920139091603621799990592001641144711937784904294955057878770089195849804965133071164958837618059258790472116483915347032772408126695927428369812426031788475563924296697128715811732675026915918301219071186567105650571140586984768364401465377756728669283430420767344557458866685398022021522773004584518802744262085866250597565131426603053280901337379667214020615828405102574920282656209885698028589472724971760702836864892687584196272014757869115423040061063009156172363184786703195236172652159479894986188010107481822796902908208850109980833038427687961233528346008937825444308744863619336255144732375742188904608232296522613168682693043533524634424002564894470567038977911831893716680037606260213499239166954103127299015717078538015586825948827243371650704490683335353314713388713522271465261874831721043961860969963098432086469374979753217352029228255261119494118827291799379797507509079865889705123131396777012483497656280329518540295687234605452741748399598999034411722099478694456859136084360871769315572697554305458945843520763619851576198947102048963826946583467328016056834805784211872585970092804695392306280365308747518177065258723165788009449273470668834216378661932307585818927887663933929331300990963370","v":"-Infinity","b":"fff0000000000000"} +{"d":"84c308a831868ac9","s":"-1e-285"} +{"s":"467.2","v":"467.2","b":"407d333333333333"} +{"d":"37364cfda3281e39","s":"1e-42"} +{"s":"+1.","v":"1","b":"3ff0000000000000"} +{"d":"3e7ad7f29abcaf48","s":"1e-7"} +{"s":"61.738","v":"61.738","b":"404ede76c8b43958"} +{"d":"3e3c6c04a88bc5e1","s":"6.6175e-9"} +{"s":"6245661952e224","v":"6.245661952e+233","b":"707924ad9486e4f2"} +{"d":"3fd5555555555555","s":"0.3333333333333333"} +{"s":"-6.06603751993811159195134247e-11","v":"-6.066037519938111e-11","b":"bdd0ac982c2df6af"} +{"d":"3fb999999999999a","s":"0.1"} +{"s":"511507453034945016197226070843566606105754877819951433100385563399283657961327598318331794064367730334457298981501641461851820268782827003745109850447663737552403981769188893871749446539504352616042314533001126965908302061128504821240329449632243748916631759666952370999602198052250358490620836354856232692882051961698457391490025995863878082812847409106445280537274137049552255896708419944106922788015469288116245924279930641815690545710031422671637364497205305567494609760242645712324608234166425056897934010090723679414446867601865814598100876441326171845252026069336220037984310784256415148613775033122411769402776690190381059562384031078728760110826318530424909893367360465409341223160066498774399054038855907642934653923219900798556620669008488835082339689022421471785645059948486094138488617438930540163401641277575018341026870914448521510176166565504818571891218842320664902391467306336149454633598395001908054879732764512231104730934484465809299099939145094842437595089339355549350695125782108453017533","v":"Infinity","b":"7ff0000000000000"} +{"d":"0a9338205089f29c","s":"1e-257"} +{"s":"-0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007721","v":"-7.721e-227","b":"90fd43dec02111d9"} +{"d":"3da004ac5b14487a","s":"7.284259e-12"} +{"s":"+637E+235","v":"6.37e+237","b":"714f4db1e213ef69"} +{"d":"d2d48f2ad796c64e","s":"-1.0469981685303545e+91"} +{"s":"+32804861564072421489478503992045755837210164716174779590085229722141714765260737148440815963188343095666447639247177152769424092468045183156172163447412499971876095083702363304030702465815066200916085251989255925793426553786231876551476220353075074825480832309585512002969596296156050303833486609783548218397933511990794900115932075315904138509348212874811335489348295565324830401908739687507886931548458700291073190533008883632697718234048376041287617640195691908116030667870160194238732811199896163833294035705641794190098731765634437429680951777650129402113637814384676080788506598509016400046132245798205731867868250360406958163121892310193735810464918912020495554649834369063702205928230011635089334563380297366560190609638579382342449634409930193888842381736254534521561107877725708918814053","v":"Infinity","b":"7ff0000000000000"} +{"d":"3fb999999999999a","s":"0.1"} +{"s":"-28.372300060964300948634","v":"-28.3723000609643","b":"c03c5f4f0e8a23f6"} +{"d":"2a5ca55e1fc31698","s":"1.2490074016012572e-104"} +{"s":"703766687049635450729613773321505555145578928396287178826827289195259720318445442305511375451648729630914254655899671777799203805675067464982427959436538606673461248.000000000001","v":"7.037666870496355e+164","b":"62287136d8c1aeb9"} +{"d":"42dc07d7bf000000","s":"123280039870464"} +{"s":"+5337887450657577438e109","v":"5.337887450657578e+127","b":"5a73b6be3c8a69aa"} +{"d":"7fefffffffffffff","s":"1.7976931348623157e+308"} +{"s":"1.7976931348623158e308","v":"1.7976931348623157e+308","b":"7fefffffffffffff"} +{"d":"191bd8d03f3e9864","s":"1e-187"} +{"s":"941507911245863436267483215584405696114185425785978668928644016757788806881248515624859612570357193543581021405960841255319031207175773224340833180291445815250523843423017287895070657810729324882263798357761347109390468183083214994015237310822639618885349568354818877777271931822606515098974325036166707789769848444431946196035732553729346685640084457575972745371748200778654448823525097154547584172089412708489703862193709083597157076615044995800678314478352810535808711117638299074551155888978157787480692006861903037886298716934375341212092943800811503944813523092445813755431096609334237157293713569221265935028692540728777082947983705064380929321335576446280728166485745840775687873214216949691035551950335502624511718750000000000000000001e-1033","v":"9.415079112458635e-290","b":"03ed5c65d3dd3d06"} +{"d":"7fefffffffffffff","s":"1.7976931348623157e+308"} +{"s":"+0.000000000000000000000000000000000000000000000000000000000000000000000000000000460708801332430339224499","v":"4.6070880133243034e-79","b":"2fab5039503e0323"} +{"d":"0000000000000000","s":"0"} +{"s":"373277629723563257.5049142","v":"373277629723563260","b":"4394b8981b291754"} +{"d":"a8dea0a97c15da94","s":"-7.95965769921624e-112"} +{"s":"+48.843607038792433","v":"48.843607038792435","b":"40486bfb50c124fb"} +{"d":"922403942b91bb68","s":"-2.768386032859271e-221"} +{"s":"7.77567758865391970433401665e-309","v":"7.77567758865392e-309","b":"00059760480bb535"} +{"d":"4217f29f01000000","s":"25713688640"} +{"s":"+3354.356425643276420859","v":"3354.3564256432765","b":"40aa34b67d6c02a8"} +{"d":"ace3abce6645a898","s":"-1.8860812030639763e-92"} +{"s":"8612321783e-138","v":"8.612321783e-129","b":"2557e10e3e97352d"} +{"d":"1707eb9aa8cf1ddf","s":"1.0000000000000001e-197"} +{"s":"-326037e027","v":"-3.26037e+32","b":"c6b0132a5d5ffcd2"} +{"d":"0007c306be658248","s":"1.0794141531621497e-308"} +{"s":"-00","v":"0","b":"8000000000000000"} +{"d":"3e7ad7f29abcaf48","s":"1e-7"} +{"s":"9007199254740993","v":"9007199254740992","b":"4340000000000000"} +{"d":"000d1d4977057fa2","s":"1.8237820990564873e-308"} +{"s":"272350.17305410720291547477245330810546875","v":"272350.17305410723","b":"41109f78b135188c"} +{"d":"41733b5a2b000000","s":"20166050.6875"} +{"s":"-81.785625032782735602","v":"-81.78562503278273","b":"c0547247ae37ae21"} +{"d":"3e61eb9eb4163832","s":"3.33793282e-8"} +{"s":"+145497e44","v":"1.45497e+49","b":"4a23e91e399ccb91"} +{"d":"0010000000000000","s":"2.2250738585072014e-308"} +{"s":"9799841410966312685844935870462551391050074935209242928860518677688600616405501411443314902984150775268205139046926835708716203438424467001874911158091407244597383306124800750586847665917836577576406416845423828645438762498974327522354127973883275635914869327354539493516104953415443141548571568684003121577845644917934038821757519299496045808656736936468616001081849437383634531840727180567263277784976634369889942344037878223647029308162832675056837237091144460148365755479725502645392127612359996230061197794804533642639430111503543030708747112377407164140660694026406288586886163417864804039517111745285347942279194758544882346514771101631227328168180943750297816959894253110483336437146692200249837434926779705236594515502520295302962241418372641162055574054722244813413377290489450196232829662222814321702670940386054408121214299496044408404908e-791","v":"9.799841410966312e+58","b":"4c2f395e5dc12e9b"} +{"d":"efbf54f381a69c02","s":"-1.9001269303747009e+230"} +{"s":"35560596564733512134.76079320910324328864504327855014","v":"35560596564733514000","b":"43fed809e2ae1ead"} +{"d":"2d240091ab066fc3","s":"3.068524401183449e-91"} +{"s":"14345949560971301883503243777673638695811721178067551795878049672828802126526131182097818568931865353289873493669433643667873802370894647184110285006248866865666758298995803654535583371988792964752900074592858844787174254694535389914392746487687541324285402789822218175431690061731614585354525399814691755832408747656959043466870457240562877125063243231207315943924761780867772697525798186689471594078979060200803787530639335970585462231832529394220924537166994337649931206596390570704642283563471667016484335729795328555455032005346786621387906669926975367569560607410269965449200640423859534869805573906903714615326656184442293425008747655454451890690194216196541349626204907895371430540221788470323159415415207804916689049955225154775462215184234082698822021484375000000000001e-1087","v":"1.434594956097133e-309","b":"00010815edaebad2"} +{"d":"0972b9a6c8c29c3f","s":"3.7166382368758806e-263"} +{"s":"+8769.6229169460704298869","v":"8769.622916946071","b":"40c120cfbbbe13c0"} +{"d":"27d9379fec069826","s":"1e-116"} +{"s":"0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004699124044045873411481077795","v":"4.699124044045873e-247","b":"0cca48e35a843568"} +{"d":"0008103815c4d879","s":"1.1213476362213363e-308"} +{"s":"3423436690609516179785074869479629923630756031891545175906144124221620972194104859018611938457097347086990636518384290427447048816259691863103524975700615557733693973703151579268532062848856369026876447220888980065854663268756015975976482944906029033060122030986385916618024007027537754105376809784283727028370086119558311904367899605855376565460906828667816820","v":"Infinity","b":"7ff0000000000000"} +{"d":"8000000000000000","s":"0"} +{"s":"-0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000310758833007982158527737146002778597629083279062279762349300420835961769418661915847208674010578875929782137559777214195754042504693603254374231255132373021787993619903490274056691457047995104610218543608707226732936902750545390549717451822773829236355266218988771162002808330316728440525831721750999666619637353721499770522644741809553899916723104127444509115000793456832540360847404867877885840502901792659888041588397777850584463171520601601059341612176606292605362472408703459453332843439425158811825566299081324401849105964153450380380048071916529032864600671168844073733767449668334786790423433154197410380144969439339159965531651556435544127486077015203160734352585902184402603842913801874081005714973695169368708812848885181256974874486331827938556671142578125001","v":"-3.107588330079822e-308","b":"80165890e3895129"} +{"d":"41b5a53f0d800000","s":"363151117.5"} +{"s":"+7539231283062120929249755543332082408188288185169532006070171802332360174357666899600432614449627066582191366377136278859043042127310815110364974835881351359841886704422434464459718727494749056966802697736224274670478537658710613784146272528378469073244900365544090359149517412618419142","v":"7.539231283062121e+285","b":"7b4959a5d7b43930"} +{"d":"42846a3e90e38d9a","s":"2805818596465.7"} +{"s":"1350659353e252","v":"1.350659353e+261","b":"7625f61cd1cfae07"} +{"d":"d605c772b875173b","s":"-2.4975161255898225e+106"} +{"s":"451.8737336745120344","v":"451.87373367451204","b":"407c3dfad0295717"} +{"d":"42a943cd0b000000","s":"13889496776704"} +{"s":"+0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022167376446443175155472593351574351308842648045663138669845450789491202836663397829170271707668931327238036678375544374802177944756200106996823649148974487731538811102620113913115897304540598499882022846540326822026176826181558125007353265408868361227349855335752024402540733543389777370555183778788177798535882459015279972931304748022582534043976639065950901429203743719775015993822793310539128763502541694376014755287408001464631190818031642295985599743933167071752166066289646551012992858886718749999999999999999999999","v":"2.2167376446443173e-192","b":"18243a3b535ba19d"} +{"d":"241456bd3f4ad551","s":"6.995645837169604e-135"} +{"s":"+374839291312061534236376475042857398447753399028424495044320861570259792840458177156424318948428469475992027607502337369569956772421745369928504317164529123286699193389005762955007512094361482954254944023663613956689206268142204535416624457094441447707299079769408048837040334278476157635647172298495591671299124778594005526981085960179245014783329813890383715188877660454491123922939385495679438394959653441747593035681754526741972923371268899682804343310678514835537972236451799069534092364694604568448092374344860439122846992178270897076559890964095408363602682968998543846414524697218546578787940279621447027409307538417668435189667883662101990909542298097817983839955041927590985262684521447850667955450823869976093242052488097026952118540066294372081756591796875e-1075","v":"3.7483929131206156e-308","b":"001af42ee9946974"} +{"d":"5c3bd3613f2951f6","s":"2.022479819295258e+136"} +{"s":"-0.00000000000000000000000000000000000099412139882305","v":"-9.9412139882305e-37","b":"b8752483002f5934"} +{"d":"3e07a09020a2ab97","s":"6.87642e-10"} +{"s":"9007199254740993","v":"9007199254740992","b":"4340000000000000"} +{"d":"bbe05146854d4043","s":"-2.764289026670014e-20"} +{"s":"0.00000000010480064136258711017","v":"1.0480064136258712e-10","b":"3ddcceb0847e7b1c"} +{"d":"40e4a41a40000000","s":"42272.8203125"} +{"s":"1475807810317E-118","v":"1.475807810317e-106","b":"29f5a998920ae061"} +{"d":"2cd4dbf7b3f71cb7","s":"1e-92"} +{"s":"+00","v":"0","b":"0000000000000000"} +{"d":"5f7476adff5b3327","s":"6.69853314636123e+151"} +{"s":"+1e309","v":"Infinity","b":"7ff0000000000000"} +{"d":"444b1ae4d6e2ef4f","s":"999999999999999900000"} +{"s":"0.00000000000000000000000000000000000000000000000000000000000000000118916176832608875369782909","v":"1.1891617683260888e-66","b":"324007a57d6dcf42"} +{"d":"3f05cb7594608af6","s":"0.00004157021116692708"} +{"s":"-597993991e-269","v":"-5.97993991e-261","b":"89e789a341df2204"} +{"d":"429b583c69000000","s":"7516446146560"} +{"s":"-1708.415256333674496","v":"-1708.4152563336745","b":"c09ab1a938f4d25b"} +{"d":"41f8916613900000","s":"6594912569"} +{"s":"5860.604151116183568196","v":"5860.604151116184","b":"40b6e49aa9a5c5da"} +{"d":"82ad71ded7ba9a54","s":"-9.004569957484401e-296"} +{"s":"25.563506618011544002513","v":"25.563506618011544","b":"40399041f83f706c"} +{"d":"41e530e73846f909","s":"2844211650.2179"} +{"s":"591966296240187974900e-216","v":"5.919662962401879e-196","b":"17662002e7915521"} +{"d":"0010000000000000","s":"2.2250738585072014e-308"} +{"s":"+100000000000000000000.85824771940715129418006483","v":"100000000000000000000","b":"4415af1d78b58c40"} +{"d":"2eb36d3b7c36a919","s":"9.999999999999999e-84"} +{"s":"-11455770933048835928028032671155876480245347356067438705607075530694985760118470260446905686343747844877650729090664516376083282298346925756609816274603771448515019946197525795704530159150243924634978423112188549282812691271376752306664252366601544662330094388582665042192879345325966160017853386868578173548827964300907975927426230241439087825140386838007110755948639344870854120058603688780465844051051649075011857768228618277530619727866127815937566268094911149845058995344179799508169756796230795594186412333784358706655926601885077726526088934024170944306782125697067416533830225240104913224243242187559461565383043571870555854234735853600874712210508734028203633400600068227982886677785964140745591290076696151845034895959407617027636661077849566936492919921875e-1073","v":"-1.1455770933048837e-307","b":"8034980dcffb291c"} +{"d":"0000000000000001","s":"5e-324"} +{"s":"3951272930815325590289036550017620047984396451882362178979221338939329532759427281719163564814206230149305869937957462603198594637347836526114001423370378551503533667328845671281667399710345260401767905450425067513377872711245666422997370939621898796758569894280857168084718926487669664899364959307158569578525301629921354069455921902215484793863094066322518218806510743489078823005775586105502337194155194770863737493510332364528657391678050396703412787444173717277057783314394030043823413891405613062645359132702820044293861635113735092847887415277099111427395256827392673248100182359502438470940830169924446423068697953340233652852475643157958984375e-909","v":"3.951272930815326e-258","b":"0a7e604dfc7b620e"} +{"d":"659121b38ebbcdd3","s":"1.777200803323899e+181"} +{"s":"+849395771470508671391679810312054842595077978408286196496053644350127123301110614046872794607872867284734604932152558642012488457909972288305386787037457457928635865320763363022459439229324240506869582824473454722376424363824009585815885632910564007466189600832546928412697317069976784231178996205770453915631624292571803097052088907280149797737142277546386021791766843112747408702004762676275913196949126211","v":"Infinity","b":"7ff0000000000000"} +{"d":"74aada8ce10fd234","s":"9.843979289352887e+253"} +{"s":"-134794079976768683968217363947429759049338975226187234392378269786914010818145516743444051329825728162011212516569797686193816141808602991725840821982262270234565578910935866339894919480575237554175999999999e-8","v":"-1.3479407997676867e+198","b":"e912084bb2e0615c"} +{"d":"410690fd90000000","s":"184863.6953125"} +{"s":"913.6510358037180013307857","v":"913.651035803718","b":"408c8d3552426bf3"} +{"d":"3fb999999999999a","s":"0.1"} +{"s":"9.9999999999999983e-172","v":"9.999999999999999e-172","b":"1c6eea92a61c3117"} +{"d":"f8a10b0752e790eb","s":"-1.152482076601644e+273"} +{"s":"+57095238987006421961418206169513066189139027152858396612398486296613694969887040469238079830621407653159077917574366635575e-1","v":"5.709523898700643e+120","b":"5901b0432a77fb48"} +{"d":"3ccf904677f911bf","s":"8.760652e-16"} +{"s":"+7.3132372191462868181892853363702538e-270","v":"7.313237219146287e-270","b":"080ee8895a0fbb29"} +{"d":"20cfaf9889ebb8d2","s":"1.2099809151336721e-150"} +{"s":"-0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000425264516940","v":"-4.2526451694e-194","b":"97c8d5cab8ee304d"} +{"d":"00062ab6bc08093b","s":"8.57606157519474e-309"} +{"s":"507281819025777445257455007190580645621122051136153000504748267978679182660340698820967764994323049721301394570019160951274222783487606528147456.000000000000000001","v":"5.072818190257775e+143","b":"5dc4ccc6909271fb"} +{"d":"26df0bbda6f99e73","s":"1.8785618210474737e-121"} +{"s":"-723274960e-141","v":"-7.2327496e-133","b":"a4806da24d6d1edc"} +{"d":"401e09423946255f","s":"7.509041685968753"} +{"s":"+54.81145019013740726915","v":"54.81145019013741","b":"404b67dd998e7c90"} +{"d":"8427d8cc6062f08b","s":"-1.2235043688769252e-288"} +{"s":"+374123573865533312489130080866309364736846866826464003844083281855937228403343461737593251137041677424056953126256701054722211097612527064511245154008477912419187690790749266175316107372303537190542531870641675508229332459875794343334346836066681332721529213349008407127004852142753726895871926173311665266634404072950969789995696158616443635490939029372043391274692427389237891024270634217182255726821519323549233419748050939772920880812881440047799545477738727038297123421935917354379870271345559793189435032393893217851923225735334935726470158332280299250805650818978688941557947752035038037677465012529919974508109806490983834517389131976783638827642641763056792321653397549262e-979","v":"3.741235738655333e-299","b":"01f90e06acb4840c"} +{"d":"409f9a2443000000","s":"2022.5354118347168"} +{"s":"+9155930861e282","v":"9.155930861e+291","b":"7c8d5c2bc8df66e5"} +{"d":"3e72ac7b4ec6d8fa","s":"6.956516402406538e-8"} +{"s":"-1.49335168176310749220947659054190e+243","v":"-1.4933516817631074e+243","b":"f26bfea3a4888d99"} +{"d":"00006f0fca4edee5","s":"6.0332139273998e-310"} +{"s":"+67.660212074440281277372022918176487605470","v":"67.66021207444028","b":"4050ea40ea25094d"} +{"d":"a3b29b69070816e3","s":"-1e-136"} +{"s":"3e02","v":"300","b":"4072c00000000000"} +{"d":"3c311d20d702fbcd","s":"9.2774e-19"} +{"s":"-.0e5","v":"0","b":"8000000000000000"} +{"d":"502145b7e285bf9a","s":"1.0000000000000002e+78"} +{"s":"-489471008971120166301763747569594342665953034427570350828371585307517649244434721103089319649889090479427793977947607996704059558e-1224","v":"0","b":"8000000000000000"} +{"d":"00077d83414ff25c","s":"1.041652201233001e-308"} +{"s":"9007199254740992.1261774725229491258","v":"9007199254740992","b":"4340000000000000"} +{"d":"b9b4484bfeebc2a0","s":"-1e-30"} +{"s":"-516029224133015368547180e-169","v":"-5.160292241330153e-146","b":"a1c49ea42c2baef6"} +{"d":"3f847ae147ae147b","s":"0.01"} +{"s":"0.00028734956264903389696883","v":"0.0002873495626490339","b":"3f32d4ecf95e743a"} +{"d":"2da97683df2f268d","s":"1e-88"} +{"s":"+41766092586071237192450498807321841320666419000079811645422613539530297578400182572508573284453271340478574197409981765610457594331480110191170779902408759177086927925545163052736505093091812868212154417947739919200327032586276198965227097792776804578421832237956145356808961646381289882229038044184083371781281837628178053954260912129184077537286409227783850177793581051471852097716050324777148361476974969264119863510131835937499999e-595","v":"4.1766092586071235e-162","b":"1e6e1077ccf6f2bb"} +{"d":"dc65c7860568e5ae","s":"-1.266408250809565e+137"} +{"s":"1.50438483843","v":"1.50438483843","b":"3ff811f5d61a7b44"} +{"d":"41961e26ab768807","s":"92768682.86575328"} +{"s":"+999.84264731","v":"999.84264731","b":"408f3ebdbddf7419"} +{"d":"f158922f31411456","s":"-1e+238"} +{"s":"6116318.812557195632165613","v":"6116318.812557195","b":"415754f7b400efe5"} +{"d":"c83f6a33e1d0723e","s":"-1.0689920929299054e+40"} +{"s":"+0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000319952476589121061763457","v":"3.1995247658912106e-305","b":"00b677c382445126"} +{"d":"68e0e6b5903c8e07","s":"1.579228315303033e+197"} +{"s":"100000000000000000000.9189723347851090831","v":"100000000000000000000","b":"4415af1d78b58c40"} +{"d":"3f6bee4e5aa1e957","s":"0.00340953162691197"} +{"s":"76276.663300804770373794981","v":"76276.66330080476","b":"40f29f4a9ce14dfe"} +{"d":"424f867f6c800000","s":"270800967936"} +{"s":"1746173752369331768639397519535747631303383471752594742675611952814426331097787852251839392146096709261299068531478334287764151441817599999999999999e-14","v":"1.7461737523693316e+133","b":"5b9899ce7dea4e47"} +{"d":"148a4cf9550c5426","s":"1e-209"} +{"s":"+2700798083942634620904361814535507538.1198704169","v":"2.7007980839426346e+36","b":"4780413d02ba8db2"} +{"d":"3fd5555555555555","s":"0.3333333333333333"} +{"s":"-0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000839","v":"-8.39e-292","b":"8380bebee2f2579f"} +{"d":"4098e94e3c000000","s":"1594.326400756836"} +{"s":"8920799816393492e48","v":"8.920799816393492e+63","b":"4d35af6d67200d77"} +{"d":"42041981f0000000","s":"10790911488"} +{"s":"0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000049870602711954798058778183290445720138780426428836702720487182334795018962593757803951546620684614740169345886188962512259162549306261733202129791071000957138974233204031378253075318986882640086131249423473689735166866588000601612144440843502606113260963682551449478730365427736614947207272052764892578125","v":"4.987060271195479e-109","b":"2972bd5e1f882a8c"} +{"d":"4480f0cf064dd592","s":"1e+22"} +{"s":"-4.9406564584124654e-324","v":"-5e-324","b":"8000000000000001"} +{"d":"569108269fd210cb","s":"1e+109"} +{"s":"0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000892001813878781302363482214207","v":"8.920018138787814e-231","b":"102bb26d38b5f977"} +{"d":"27a42c7ff0054687","s":"1.0000000000000004e-117"} +{"s":"+207e+081","v":"2.07e+83","b":"513b4726e4125212"} +{"d":"3c3c48f4920f3d56","s":"1.5333319385435404e-18"} +{"s":"981e39","v":"9.81e+41","b":"48a685ccbf16ba01"} +{"d":"8670e81f73b465fc","s":"-1.1921849126577998e-277"} +{"s":"+1e21","v":"1e+21","b":"444b1ae4d6e2ef50"} +{"d":"4415af1d78b58c40","s":"100000000000000000000"} +{"s":"9133133403620548710567174305795093063.44846421536493246265725001162704551","v":"9.133133403620549e+36","b":"479b7be8f8981d75"} +{"d":"429d428e33000000","s":"8042922688512"} +{"s":"-12604390511865091E73","v":"-1.2604390511865091e+89","b":"d26fae3a6eeb6006"} +{"d":"418d602cf0000000","s":"61605278"} +{"s":"0","v":"0","b":"0000000000000000"} +{"d":"40483509fb40fe78","s":"48.41436711"} +{"s":"123456789012345678901234567890e-30","v":"0.12345678901234568","b":"3fbf9add3746f65f"} +{"d":"591e52742f09866e","s":"1.9574800282272396e+121"} +{"s":"1.754970","v":"1.75497","b":"3ffc145b6c3760bf"} +{"d":"4262f6cbb9000000","s":"651599661056"} +{"s":"735113370033942518883239697702867960862406008555090129732609584188709575401085903162249471615674072180401365276750851382669918496229598999489950538868425930596220356615095306362391239816393653906045550872290755733486638386445832064108763062380540048468626488528552734638864755808632238056899539686665995845646038113003680429472973666566727791324673558385526622397633375754969172222188580448120461800679542140125963929225564419887197617647781754148282021916314990930127284052876912442852986735028689061060911980773033854488434036692070201960124653569103955197615842719773522437719935102379642716314948391828042680588521982765111335229730107919304427295607760371095296424085844880801005092177048607244190174808438204970053851467486750810660821995305288280300590248235948441848990897264959219278402961369889634418720094019427492938793903208029506574712231824291147413865563831281550586497456811651094748828677591124567266681275089473838159720387100036768394686366536721712e-638","v":"Infinity","b":"7ff0000000000000"} +{"d":"000f2dcce056e388","s":"2.110886880563475e-308"} +{"s":"94.964341","v":"94.964341","b":"4057bdb7c3504c49"} +{"d":"ebf6d5d3263dc585","s":"-1.2011653483031466e+212"} +{"s":"2.4703282292062328e-324","v":"5e-324","b":"0000000000000001"} +{"d":"441ac53a7e04bcda","s":"123456789012345680000"} +{"s":"0","v":"0","b":"0000000000000000"} +{"d":"3b8c85e975960e5c","s":"7.55e-22"} +{"s":"3e-324","v":"5e-324","b":"0000000000000001"} +{"d":"000a93af6647e175","s":"1.470898304246154e-308"} +{"s":"1e21","v":"1e+21","b":"444b1ae4d6e2ef50"} +{"d":"4415af1d78b58c40","s":"100000000000000000000"} +{"s":"+5730747.8586719995016043709803410","v":"5730747.858672","b":"4155dc6ef6f47b67"} +{"d":"4105b697b2000000","s":"177874.9619140625"} +{"s":"-2.37984999999999975103176450395527909556442e-18","v":"-2.3798499999999997e-18","b":"bc45f3430e4fc936"} +{"d":"fff0000000000000","s":"-Infinity"} +{"s":"+12477019.9531258763383","v":"12477019.953125875","b":"4167cc4b7e8001d6"} +{"d":"8000000000000000","s":"0"} +{"s":"+452371440720347799245.4330058255689366287663739984257","v":"452371440720347800000","b":"443885ea34918c02"} +{"d":"13b58ba6fab6f36a","s":"9.999999999999996e-214"} +{"s":"29948397942137812827756.66460458483606768670887039513","v":"2.9948397942137814e+22","b":"44995e060c1bd8b0"} +{"d":"0002e199535bc393","s":"4.006865461910736e-309"} +{"s":"9640496054395531E-240","v":"9.640496054395531e-225","b":"116c8c209161ea8c"} +{"d":"34eea6608e29b24f","s":"1.0000000000000003e-53"} +{"s":"8637023.1588946496","v":"8637023.158894649","b":"4160794be515aa3b"} +{"d":"4058fffffffffffe","s":"99.99999999999997"} +{"s":"-332834399242341837500103593525301947835531740988085328564364030563173355219535732203420765700703303977537008442688123558702631992328949076865196447573836","v":"-3.3283439924234183e+152","b":"df996b714f7ff62c"} +{"d":"07c283b8622d573a","s":"2.737957227192803e-271"} +{"s":"83465740333796800042080224172094020028756362065064629701977364073351520874324376252784387021771523412373938473782788887274020305905397905425547376768834250857905809082923579679668268137185233959782554022309885454795495207096788165763482208107552372348719471128765558517430784852890074588475588349645307529304215496950642604087384146677774e-1116","v":"0","b":"0000000000000000"} +{"d":"00023b88c2ae3747","s":"3.10475061883599e-309"} +{"s":"-225384927911162247600878871016652990277956189485746717496345156393219168271445406548289308262912605251493199802061714930323113613139564218558400211012508712960000000000000001e-16","v":"-2.2538492791116226e+157","b":"e09a43fd87b7fffd"} +{"d":"ff2dbe93e9d6a38d","s":"-4.079542819344919e+304"} +{"s":"4.91155","v":"4.91155","b":"4013a56d5cfaacda"} +{"d":"3eb0c6f7a0b5ed8d","s":"0.000001"} +{"s":"0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006","v":"6e-151","b":"20bf6caf4c4c4bc0"} +{"d":"421c134c44800000","s":"30145712416"} +{"s":"-7.9675798211735577881e-309","v":"-7.967579821173557e-309","b":"8005bab3c288cefb"} +{"d":"64bd4460fbd86150","s":"1.8530930671915049e+177"} +{"s":"8910817271961698416856478626921458063269061346004368077955275870040592555432982512968755609720869491146373435721675546873723569670776032254100489683410673888144790866980416973773380372707138951712394402776248766460565688156517896634669241536789752056320758128290280773058202709500973619336567027273076227509095522207634828117077789027538167346185669080637257329672243535381332913605376581934096526825453392669991064996414987803416243367391809696293691465490595222069097868587304017866268059976292181977943247252002159224245939940277337747767095091369267437448764732032009308127904740533991490439740191564e-59","v":"Infinity","b":"7ff0000000000000"} +{"d":"4273b247ba800000","s":"1353526781952"} +{"s":"78035453494300.240530024836942517567416","v":"78035453494300.23","b":"42d1be42df11070f"} +{"d":"00038e3b770f24eb","s":"4.944663241017735e-309"} +{"s":"+525e-214","v":"5.25e-212","b":"1411ac8ef9aa13af"} +{"d":"aa225915cd68c9f9","s":"-1e-105"} +{"s":"-0","v":"0","b":"8000000000000000"} +{"d":"d0c0de1593369d1b","s":"-1e+81"} +{"s":"4724634816266990027648614512714170892503792346791176062113619332148529559210498444433198994825350468698e-1129","v":"0","b":"0000000000000000"} +{"d":"4340000000000000","s":"9007199254740992"} +{"s":"500574076177502447928742269595056431972295233281663728088259436873208831022511890706652281862085971568783572274588989209289042499530713108937625321378805939870095884780103428713231223335926586386895910530194662695508350885696842611123286014498048495266734295010747940555819177832862657376667449806325831206617472550563974243207152416036495191210942139432098876136893556585118667347924867083943616925183345292347846946022373068650519441703338053279489054192222134309230291756246688702824151763823897349214905210845659323813561975944221319345392139025326295504798823944368976543302957682324692265062089206715952803522676992709019007241185272537779303854437888758636531422767443752461184705080991531205548648575397378681541663541053509405741141481415383891063712270157897610663051505675463215635285326775892591242111884741883394780071636325314429726863607023667914962963254126531660187298617044088061996077004945081706709223269148856267821853636790871433760480329974594415034461134544798460004575013529271807873864165434154382240268585895793777809079629356805011598987252272855861141513073505980254699459764237101966058061511148351487268274811308038358897385492148897716804638500731030216740246750325254521148156719128815539972527816024956120128792521","v":"Infinity","b":"7ff0000000000000"} +{"d":"418927c496000000","s":"52754578.75"} +{"s":"-0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000061736844691482940571458993204346569776290717275250824383185449072173967149758845549004643106878865430495866051362171017740465068714928820094497575224039668817790930156370329355377872011882566671674425015689208597283028309796485791695120026792617342177293622998672884820592204900937268157108127392175194695467712629441435339540419395492841217230838438296258773479476733145857660936498675401774785063694132136057892991377501833644967544675177760983122455805061459500825809798880756063629665010962970600497788017355703118774382739708740084496153992103117128010565657566002343170140748949745065352837095511094066594158201277946749091842318558091337170359419291420814513264623841732096590860804173251448700942608460648863437491965823478157204817762249149382114410400390625000001","v":"-6.173684469148295e-308","b":"8026326032d6c5e5"} +{"d":"41cdcd6500000000","s":"1000000000"} +{"s":"+554.907840973674285657688637","v":"554.9078409736743","b":"408157434220df33"} +{"d":"47a0d2bbc036337d","s":"1.1180919156014245e+37"} +{"s":"5.485393956300345633137","v":"5.485393956300346","b":"4015f10b1cfff1b4"} +{"d":"000cac2b728696da","s":"1.7623333076763235e-308"} +{"s":"+14.6271448453336793541516958882","v":"14.62714484533368","b":"402d411921112053"} +{"d":"74e10cb132c2ff63","s":"1e+255"} +{"s":"-0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000066000437","v":"-6.6000437e-274","b":"8736d9d30519ec35"} +{"d":"3ab74fa75864df0d","s":"7.532237910302932e-26"} +{"s":"+471345784801898679495904264891115160997708091346014437451912014626914116813003516053910959813834141547030292109902328783744199466474413359954205141451775083473842642764900601049210967803238569316920118639551351084379939574871288617700485343993474966996236746578261059289103486749840015704801711247633618125054211558864057150045997036970838901347253540129321499787793502712147206053712333237709070180032688054979587034642830317792581194926778244085016870511838242641647243161686655865652113143215484736703167903284398252868789359598238208307991944818237e-496","v":"4.713457848018987e+55","b":"4b7ec1ba3531c678"} +{"d":"000a378212dbbf4c","s":"1.4208248780746617e-308"} +{"s":"8849993966604891647326640593.384470855086497842580081975237","v":"8.849993966604891e+27","b":"45bc988b1e40fb1a"} +{"d":"8000000000000000","s":"0"} +{"s":"-0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008345976050508326154740610503","v":"-8.345976050508326e-143","b":"a27048a56c2cb2a5"} +{"d":"41a5fbc44a800000","s":"184410661.25"} +{"s":"14893051909513755414046060128450584467633541744857835141653550060108896781589001711936223950132480732706332757067660998433161798725594154012838896475136038997971762294343909865381999618434771343436410719377000692098093853789002900239944451483387692260326123344328865370971647217677499419971394292768680622020399803050059957679432689854148224254","v":"Infinity","b":"7ff0000000000000"} +{"d":"1c72b82b9aad1616","s":"1.2109738381275625e-171"} +{"s":"7066888765440.24806215412488913","v":"7066888765440.248","b":"4299b58d940000fe"} +{"d":"3f81bc62f23d9f9e","s":"0.0086601"} +{"s":"462271583696840646174887e17","v":"4.622715836968407e+40","b":"4860fb2e5b5a9bac"} +{"d":"c46632e34ed2976f","s":"-3.2759618464768847e+21"} +{"s":"-0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000718998865283066686754666490","v":"-7.189988652830667e-171","b":"9c9bc9360bfbfe7e"} +{"d":"ad0a12f5a0f4e3e5","s":"-1e-91"} +{"s":"-30825e-62","v":"-3.0825e-58","b":"b3fef56b1e826310"} +{"d":"428f6c8c2d000000","s":"4318883586048"} +{"s":"+7253.774618091","v":"7253.774618091","b":"40bc55c64d5f07bc"} +{"d":"41c36516cc000000","s":"650784152"} +{"s":"0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000344704395","v":"3.44704395e-100","b":"2b4820661b103ab5"} +{"d":"3fd5555555555555","s":"0.3333333333333333"} +{"s":"100000000000000000000.8346376354749","v":"100000000000000000000","b":"4415af1d78b58c40"} +{"d":"6d32eaa582bc6f6c","s":"1.0433732137195268e+218"} +{"s":"-14400e254","v":"-1.44e+258","b":"f587f9d92f623723"} +{"d":"736c9abd04725480","s":"9.999999999999999e+247"} +{"s":"17804894470178548396e+209","v":"1.7804894470178547e+228","b":"6f52ca31cba1d1fb"} +{"d":"42016e5802000000","s":"9358213184"} +{"s":"+717771948.0980448","v":"717771948.0980448","b":"41c5642a560c8cbb"} +{"d":"3e7ad7f29abcaf48","s":"1e-7"} +{"s":"+0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000066694961381703","v":"6.6694961381703e-195","b":"179f28d3b525fead"} +{"d":"3eb0c6f7a0b5ed8d","s":"0.000001"} +{"s":"591751163614362e46","v":"5.91751163614362e+60","b":"4c8d75b641852822"} +{"d":"159410d9f9b2f7f1","s":"9.999999999999996e-205"} +{"s":"+0.0000000000000000000000000095080250887740251155402645765","v":"9.508025088774025e-27","b":"3a878a6d4664fd88"} +{"d":"5ab7151b377c247c","s":"9.999999999999997e+128"} +{"s":"123456789012345678901234567890e-30","v":"0.12345678901234568","b":"3fbf9add3746f65f"} +{"d":"a463d9aaaacbcc19","s":"-2.1848324543927122e-133"} +{"s":"7.29286236074883573e-16","v":"7.292862360748836e-16","b":"3cca467a70571a83"} +{"d":"81d79d9e06ffa3a5","s":"-8.815866675241787e-300"} +{"s":"21723269464870115451935336346450877414420849147901385385070969187502365722911968764679883526766592000","v":"2.1723269464870114e+100","b":"54c3dd10db8bea9a"} +{"d":"40ddbeff6db0dd83","s":"30459.99107"} +{"s":"35107515466062110550245006135235914203020074823492929729403373897164698883104000705767298565097153175733243108090155706850384962670476482106595485799695015996677633386354218408002157996410288373520388803036634210743871781468982927991464147522532142489147396650724439915680759738365583765175191593704725758047490779630814350841115934425070726471602540081242322613228313046508894571760888583250493645770434581292220272137801983474036561045111682691635621103940070963786753607337019187413001030017826725101841254627303799900491469678029861755117293587521921158414481026255786775059478256517702513958072045475761149698892375422479472481525566725790195567233836600051303828507193999769494537687090955469055245813222142074324213991288329284046199063595850020647048950195312499999e-1080","v":"3.510751546606211e-308","b":"00193eb95b3cd764"} +{"d":"0000000000000001","s":"5e-324"} +{"s":"1e-999999999999","v":"0","b":"0000000000000000"} +{"d":"f54aa3d4df50af0b","s":"-1e+257"} +{"s":"14556932400640592107306901009997909052213989146205234621585730308800039570766334997675467159784099224212872990063050929256768876591447176677549306278079895595281479584433143260441569308008146257147022974585755114839724303424832702821340976230354174393407045440309003666301547690140025765938128859494143598585392732539136981219124929497796128464864225253921760299600505621990557441766658442478549955711558303891988743886612156877839380731156594349415364429420670281464697482709385584505347982227029541872742223947122145325871899213111570559644122255905188253920023548229292741284372667267662516226808962283706911751867068077512072259811630657879886847342798851840536316146374728791435960807434725353838730677916223542529998971356324280988502546318271795466400276700613574890021710320213359319181760576570746455783149019561210576488634966621828969320814207050607987e-626","v":"1.455693240064059e+236","b":"70f6e435e023a568"} +{"d":"0fdc7ef40927d891","s":"2.8679125515879787e-232"} +{"s":"9.21864645682112875e+64","v":"9.218646456821129e+64","b":"4d6c02f8e3432ff7"} +{"d":"e33dccce895e2cfa","s":"-1.1246418026330893e+170"} +{"s":"+9117081532908936874920448379802946206113053367325620508118220671764503550044737827965986864297474836966755966889905726936876829493312758627572951098422230880392584340366628970881115475141173332690305032620608853476053789521840708391738915814218765201380663440962779532270051559969336660553047302194248666088047308507968565725347802383540976415325283011067844752560585949628065933028513522371149269051475197724623682619530760204011200277312690898733514289184746875391244698075822359448173580121618890573545043836755660306999034884478125803471517105029548233116165300587769289681958318145654915300759773203569133571207322451159706528103127585930554214545113413801427030176645160866097611485541668291182346648797817508287755671506893463235328553111318148570827888264940312366999782546505078905621651907146360939120368088432855266519135041909797620631839032328907563400998364956493175850898911983333689368676577687115166918329253602753836928472734739010811095046039356083621309416651008164774022430551841104389963584699743616651058995514535500597418292867285179269955873407268374530435972318302241999261946387810142336170619817765875952812286531942870928066867137103899878","v":"Infinity","b":"7ff0000000000000"} +{"d":"58044db473335df0","s":"1.0000000000000002e+116"} +{"s":"53056402.757","v":"53056402.757","b":"41894c9c960e5604"} +{"d":"000c509e2ff83844","s":"1.712599540636637e-308"} +{"s":"2986909016290576030122502761882990925371671644956298077288691269695262376030923491631878839950098055267680709421920324980","v":"2.986909016290576e+120","b":"58f281e0379205a3"} +{"d":"000d7836d127d088","s":"1.873176542208052e-308"} +{"s":"12546683962.18163260634121221883616","v":"12546683962.181633","b":"42075eb9a1d173fc"} +{"d":"319b9b6364f30304","s":"1e-69"} +{"s":"0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000094594056492761128429463909982178501159481102802436088266379403754576122655849588151237864805946503864608210521603361631326749162239028923077640967740409358246616629661749201742151834278423236850318295823312792110215685426055642892606556415557861328125000000001","v":"9.459405649276114e-86","b":"2e47859bf843da9f"} +{"d":"d1c9bcdfabc1357a","s":"-1e+86"} +{"s":"8157462101336E357","v":"Infinity","b":"7ff0000000000000"} +{"d":"7cd914dd8f0ae214","s":"2.502934006828513e+293"} +{"s":"0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011954395632141331235186664965298945828647832633766104639420599178200337772388158835791740364197506018602938012699561889751089612061645322042773121279981461267185645207446750997847432299675144038675132664072979874227371035650446647766966086757853786228645278252280034303061948096853658926310903063722564471581453580635762067167744227979992496979995133687021525288795714019244220680977673017483003533960410724326146480950820799281140734230229861486779987386791009094371835248446073830903460138237454609551850523369096180353893072573620475993072894918607036144654912138913556047473814520951538968230852756521150339469654742962709917020514223986376936391491525036804415098025372361045704259563740579075385994656244292855262756347656250000000000000000001","v":"1.1954395632141332e-291","b":"0387dbeba9ac6515"} +{"d":"fff0000000000000","s":"-Infinity"} +{"s":"6.8061","v":"6.8061","b":"401b3972474538ef"} +{"d":"42a77bf3c7000000","s":"12910569160704"} +{"s":"12992e-62","v":"1.2992e-58","b":"33ea18bf9ddfe0f6"} +{"d":"328865419d14df52","s":"2.8956178865208528e-65"} +{"s":"8795.56682197","v":"8795.56682197","b":"40c12dc88d9f4fe7"} +{"d":"3fd5555555555555","s":"0.3333333333333333"} +{"s":"+778536e111","v":"7.78536e+116","b":"5833c2401e33370a"} +{"d":"420f890dcf800000","s":"16930421232"} +{"s":"0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008986","v":"8.986e-163","b":"1e49df995145dda9"} +{"d":"3d66da2d08d3f674","s":"6.495e-13"} +{"s":"-0.00000000000000000013734746613368363","v":"-1.3734746613368363e-19","b":"bc0444d72f3e1861"} +{"d":"4c63e9e4e4c2f344","s":"1e+60"} +{"s":"1709914442307429e-253","v":"1.709914442307429e-238","b":"0e91d0b1947ef610"} +{"d":"426cbb05d30b2aa6","s":"987174443097.3328"} +{"s":"0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000419990","v":"4.1999e-125","b":"261c6e15abf6c3c8"} +{"d":"00023fdbcba781f6","s":"3.128241856084043e-309"} +{"s":"76316.860491965016081","v":"76316.86049196501","b":"40f2a1cdc4933903"} +{"d":"3f36accf430c74a7","s":"0.0003459936152"} +{"s":"6783289594010527411877772043115186475135.981482730973865","v":"6.783289594010527e+39","b":"4833ef2e0e181e5e"} +{"d":"40152f694467381d","s":"5.2963"} +{"s":"939604637844186653782087727007255414359744365765193397705108291731676179071796577530608532851416371446833982701205393085639915983025611215097716897126150581001839615119508320002020885212114094046770170374789186364964038157466673795216039856973556858361682381012435368261908741314737376235569801786859832620186283847687913003756737607212775814857282740658561790058668193231164002979333029928470392051617429616263112571681019264616338552559516734015487178249575596998587567064962026012560765633249986394724320178663940911120799800486232107368326204796288762708087445299050393663507416402297378610342093452345579862594604492187500001e-876","v":"9.396046378441867e-247","b":"0cda474fcdf09c60"} +{"d":"e673c47a41b9b0e5","s":"-3.3597648709689645e+185"} +{"s":"86931538015609978539165322852184024738886245527106054311869600780279994369816260302384048461190400052458561916773809982627314789831207030248323831089009197015143551950203554171179325665444376108614466368944011512643584000000000000000001e-18","v":"8.693153801560998e+217","b":"6d2f85922c0d8d5d"} +{"d":"12769794a160cb58","s":"1e-219"} +{"s":"981229802733498327595393e181","v":"9.812298027334983e+204","b":"6a7f4bdd75a34f3e"} +{"d":"3f2228596207613c","s":"0.0001385316"} +{"s":"-0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000046970831220929554569","v":"0","b":"8000000000000000"} +{"d":"0000b664a0cdcc89","s":"9.90815603827023e-310"} +{"s":"0.0","v":"0","b":"0000000000000000"} +{"d":"18123ff06eea8479","s":"9.999999999999999e-193"} +{"s":"+1E-104","v":"1e-104","b":"2a56ef5b40c2fc77"} +{"d":"0002d245d9e1ff73","s":"3.923609497858683e-309"} +{"s":"-1944673897870251054997376297738.853792425","v":"-1.944673897870251e+30","b":"c6388b948bca56c9"} +{"d":"d2d3a2e965b9d81d","s":"-1e+91"} +{"s":"-6472722537495213473659819703643013256553050446777931950677500500959675172941710239358748513366454975977848984478503654552185307388881709935146290214594020495454259457036162867765140770681872429249732239681074818273374250169764345854050410910864329497971193424114789615731513043176619475295788252999784617713885381817817687988281250000001e-456","v":"-6.472722537495214e-120","b":"a730b6d4f548a9bd"} +{"d":"8f5106cee9c142f9","s":"-6.693776231814547e-235"} +{"s":"-3.147154860287135","v":"-3.147154860287135","b":"c0092d5f87030ba9"} +{"d":"4056c12fc90c5f1a","s":"91.018541586"} +{"s":"3369988112247330297404514400.28131456389959754890328286575","v":"3.36998811224733e+27","b":"45a5c72d7b414056"} +{"d":"f7b9a45c9a96ca23","s":"-5.291620490088775e+268"} +{"s":"-2026.917927414896360842867075","v":"-2026.9179274148964","b":"c09fababf52a0c54"} +{"d":"0009bf6fa209001b","s":"1.3555980362550225e-308"} +{"s":"9.121368773000","v":"9.121368773","b":"40223e240c3d94d0"} +{"d":"ff89361bbcd3b801","s":"-2.2130024476035456e+306"} +{"s":"631847511921e+63","v":"6.31847511921e+74","b":"4f7659ceec66f855"} +{"d":"294bc23fbb90c7f8","s":"9.234046223993551e-110"} +{"s":"+5615962e+112","v":"5.615962e+118","b":"58964531a7cc0c23"} +{"d":"e2315d847ad00087","s":"-1e+165"} +{"s":"0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000087725660369","v":"8.7725660369e-188","b":"19186dcc76dc6e85"} +{"d":"000348652c10d80d","s":"4.56528661727478e-309"} +{"s":"-3E+306","v":"-3e+306","b":"ff9116ac579aac1f"} +{"d":"4229c74d64800000","s":"55358960192"} +{"s":"146119237632.08512185251024748","v":"146119237632.0851","b":"424102b150000ae5"} +{"d":"508afcef51f0fb5f","s":"1e+80"} +{"s":"+0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000818351043681727668519537442","v":"8.183510436817277e-184","b":"19ebd16cfb25584f"} +{"d":"3b82e3b40a0e9b4f","s":"5e-22"} +{"s":"1.0000000000000002865147032638169698230542592e+182","v":"1.0000000000000004e+182","b":"65b819651531f9ea"} +{"d":"b06927ff679b72b0","s":"-1.7380282941522628e-75"} +{"s":"762629020974470199908422786568797834651551823445575380768965561756503842788117716183551664685812180944109848305144658981441529725152371116251278500604610254587881331809028796174448241453955680878687344874177889319272326384035576598846295081031503549136274448772458372215927324645957043576659376814396946152209784508173485643538121715106215771287265562296420030304729133736072683687956256134678184793262149123135699923177225783394973486674945341243860256567622496107774752739318946442263959173381404111476942760307337674884132733352331589480031823541369190426872090542547666692509403335536430688876168056775180406066350092073806596561603505361950541210568797320724461301e-951","v":"7.626290209744702e-283","b":"055c59ded2268c3a"} +{"d":"3f14605f3b4ee08e","s":"0.00007773"} +{"s":"356280196615425910672780336714444740612265586831161082138633176674056075014255293318950432216853276721888597614788499714405182171712386945848456306636336066555601853878461536001893874","v":"3.5628019661542593e+182","b":"65d57715416c98ce"} +{"d":"3b7160d8d60d702a","s":"2.3e-22"} +{"s":"0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000042254546674","v":"4.2254546674e-261","b":"09e0a1beb60b2bc2"} +{"d":"5d6a3de04895e46d","s":"1e+142"} +{"s":"835326192591163646115489239952.523","v":"8.353261925911636e+29","b":"4625162b436a2371"} +{"d":"7dce94c85c298c4d","s":"1.0000000000000001e+298"} +{"s":"50696838.36406669","v":"50696838.36406669","b":"41882c9432e99bcc"} +{"d":"427beade6f800000","s":"1918473009152"} +{"s":"697889517722459490349705171734674435471453775823526678490394266243167372986163559610792900386152325870676281519898833232806243751985382628493019881436492870638546793512952398716718822773887688901751589708965846031562258377208490466928183516430106704604380964570293830139944028641871324971853673394087939375789768691942603122747398948103395769235760063684522429599580594853543359796903891863597509726776082457865507421226290265778154083494515466619466080861617452501444807421168469","v":"Infinity","b":"7ff0000000000000"} +{"d":"000b9f9b90888adf","s":"1.6164421017905037e-308"} +{"s":"89.604","v":"89.604","b":"405666a7ef9db22d"} +{"d":"c5d926ca6fedbd34","s":"-3.113608163771208e+28"} +{"s":"+3e-324","v":"5e-324","b":"0000000000000001"} +{"d":"000efaa1de2c12f5","s":"2.0830908397332265e-308"} +{"s":"+295721301805577795e216","v":"2.957213018055778e+233","b":"7067cf4fca1b6b5b"} +{"d":"41069ca1c89be5a4","s":"185236.2229536"} +{"s":"213822939e+251","v":"2.13822939e+259","b":"75c6403c6bf8fe9b"} +{"d":"0d45d98932280f0b","s":"1.0000000000000001e-244"} +{"s":"1e-7","v":"1e-7","b":"3e7ad7f29abcaf48"} +{"d":"3fa9241878566b6a","s":"0.049103512468"} +{"s":"+3446807457869287e+134","v":"3.446807457869287e+149","b":"5efaf4cb816f054c"} +{"d":"408aa8e400000000","s":"853.111328125"} +{"s":"652.8269996891320400766094225","v":"652.8269996891321","b":"4084669db20354ff"} +{"d":"000c8bf019e45a00","s":"1.7448239857159073e-308"} +{"s":"+1.7976931348623158e308","v":"1.7976931348623157e+308","b":"7fefffffffffffff"} +{"d":"366244ce242c5562","s":"1.0000000000000002e-46"} +{"s":"2788789781.4100432698928714128","v":"2788789781.4100432","b":"41e4c731c2ad1f13"} +{"d":"3eb0c6f7a0b5ed8d","s":"0.000001"} +{"s":"-63.2183292116","v":"-63.2183292116","b":"c04f9bf2362bcaaf"} +{"d":"3e445f4d4d28ca56","s":"9.486578999e-9"} +{"s":"1.7995132603897098556627893105e+162","v":"1.7995132603897098e+162","b":"619fffc319da1b3f"} +{"d":"3fe0000000000000","s":"0.5"} +{"s":"-103114393789926e-183","v":"-1.03114393789926e-169","b":"9cd8e7d4c331c181"} +{"d":"5551dbf316b346e8","s":"1e+103"} +{"s":"+4.8947221999962950378272301306885358e-167","v":"4.8947221999962954e-167","b":"1d671733022f0e11"} +{"d":"f79362149cbd3226","s":"-1e+268"} +{"s":"34e-263","v":"3.4e-262","b":"09a56992592c18bb"} +{"d":"3f7a3c9f42a5ece4","s":"0.00640547"} +{"s":"8775908e-214","v":"8.775908e-208","b":"14f2083f33218f4b"} +{"d":"0f596fbb9bb44db4","s":"1e-234"} +{"s":"0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000061538","v":"6.1538e-279","b":"062bed10ee26b4e6"} +{"d":"4340000000000000","s":"9007199254740992"} +{"s":"-92300e-365","v":"0","b":"8000000000000000"} +{"d":"ca6bdcd99052929d","s":"-3.2577099209192732e+50"} +{"s":"-4286212902675254239760244444632988730675452234980244966695783784950475393001448519559636984136546795343019378640929302424544961385413584846265246370145315047162785290867503852937707596955028224870293163882060656436019613942660472777717728946739774335896236532592781645181849723238033607024642155795306119267346779820336459511908178396276502261536908703014206714333200637869541141879422022440967499919804052255814192821392404762841475743925727285094343462692212610632957596250778370359955824880285760168987841299820496763419536376695225695998793377727547611996621089578110284517637292850010742609129993382534952999388463003179213597371635895828230192656125158454651107076692401645620142040161079573882026730322019260024708008498973924192216321695891624512431344208777995305594491946670033010338993060218255194292369410767325945591552259972433390403486363558183037448004768047119405253750874246432538157697972262747201257675379535125840286877357609452829","v":"-Infinity","b":"fff0000000000000"} +{"d":"11d72262f3133ed0","s":"9.999999999999999e-223"} +{"s":"-9.018706632","v":"-9.018706632","b":"c0220993ea69510e"} +{"d":"7c82f64234c73238","s":"5.913284315412295e+291"} +{"s":"0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022021","v":"2.2021e-121","b":"26e23246bcabd1f3"} +{"d":"404ec42d8c2a454e","s":"61.53264"} +{"s":"+1e309","v":"Infinity","b":"7ff0000000000000"} +{"d":"42d6fdd2de000000","s":"101117681205248"} +{"s":"51.6602299949455342","v":"51.66022999494553","b":"4049d4826a9e108d"} +{"d":"427e91a97b800000","s":"2100685158400"} +{"s":"84447e214","v":"8.4447e+218","b":"6d6323564eff7368"} +{"d":"4340000000000000","s":"9007199254740992"} +{"s":"73.558","v":"73.558","b":"405263b645a1cac1"} +{"d":"5a112f6fe2d67752","s":"7.27068531134409e+125"} +{"s":"+296324410670307214.586252598075791914742870533","v":"296324410670307200","b":"43907305ed111f5e"} +{"d":"426f99152e000000","s":"1085698306048"} +{"s":"-7677685576280922666e50","v":"-7.677685576280923e+68","b":"ce3c7a65fa65ea15"} +{"d":"444b1ae4d6e2ef50","s":"1e+21"} +{"s":"0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000031187620644","v":"3.11876207e-316","b":"0000000003c333df"} +{"d":"8d117ad428200c08","s":"-1e-245"} +{"s":"-253360275019877046679928148239788244959153123114856509282106973754300069077943031858751355240099517905935168801907051886867270074122944132365725732713432814203980125892691199541916792445301694068699400876571402030831659121772352317759860089143747132159007511873775940548385879097103454352140481088598664024040404516069401008609384823275010337731614966568566955005937159447715359358030948048223445946929218337748394511851135042109205351500457705372213777389653402711750594242220113225580771453417376200497354050267168173054114200271679395730908342138342328826637274999772539941087977573804079789525957133679777768254579751250473392969749761359918025304536861487647979842568148048237585890778670393176617139277352744377573640968509501496727855438927565006055422901532723787910258974134011876810555522178434616666002031111430430755806151216822386553292071013949902680015943734321285428114795460274678091865202335640139507038956436479703786040333903893506829694527091463999039242285790576035551143934542708248452441722469699027218302709405702018556088231602025526797280861112460007232588430458557968636721533932758634995488902777537555833573247216466389528954356057904","v":"-Infinity","b":"fff0000000000000"} +{"d":"b23af5bf109550f2","s":"-1e-66"} +{"s":"3e-324","v":"5e-324","b":"0000000000000001"} +{"d":"3fd5555555555555","s":"0.3333333333333333"} +{"s":"-0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000747630530966250820378459558","v":"-7.476305309662508e-165","b":"9ddb8dd2e6718ea5"} +{"d":"410b0691d2000000","s":"221394.2275390625"} +{"s":"0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004431925695854050993977","v":"4.431925695854053e-309","b":"00032fd87aa6e567"} +{"d":"3ee4e4ff9e7ccb4e","s":"0.0000099632861317638"} +{"s":"0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000301074601294814900631859254647423188403000984772254805824102124745668593471908959921544264246230530795322690541468860592500532149856567757080074254505176474316765152120347977161280361739254922491454848093570652268935681793597955057013946200293150910232029995044575903145257283278395709078460791074559886319855983309841981654627020692725405199635389608999076316984306253762348134189968254962590344492476017341944626285719774336102475409453054545680594300690814383272088281614150404828734249308491808442708130702697690121901522284967728727168967978542556586994352107480952092342573545688620499249843253650069033562482401793771517141684388884809467482490197887270731742793262578223850928841439207511405755246610874782181255669070811531451425935301813296973705291748046875","v":"3.0107460129481493e-308","b":"0015a64b8399a7dc"} +{"d":"4154b62571800000","s":"5429397.7734375"} +{"s":"+13353304749596e33","v":"1.3353304749596e+46","b":"4982b6435df58c30"} +{"d":"000d754576a7e51c","s":"1.87157792922139e-308"} +{"s":"6979488658586510616983641596171.24783101032423635927886840061233624","v":"6.979488658586511e+30","b":"465605fc6d0cf7ca"} +{"d":"408a867217093101","s":"848.805708"} +{"s":"676696569597e-336","v":"0","b":"0000000000000000"} +{"d":"6177414e8e334bfd","s":"3.2694597587256666e+161"} +{"s":"+0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000117670320841332704634041430614951954710279475548248357552842679672195025676744894668108635201092245515553832337769530489519538758549150106585570011010126993695492896015242796303505281112756920074476107539219174611178971040494619471352317938351554300507881532084719212730279130892968943970439634232240646137233549137604922018032117275012441991259203146012268026630061810981701784054676061872782697069536565253558613100613975190248396612721391587390488091382969152448994712193765109647620601224165510220513067450209355135405022841250781463929522653445134164636859962472135057349946597970440070981303339510592579263637358771200389051278612682289987178854427120327102658024746601496285477548170636079306516027441354081375278283578753035776287561020581051707267761230468749999999999999","v":"1.176703208413327e-307","b":"0035274c9d538ccf"} +{"d":"01751e06d29f04e7","s":"1.2317499986180321e-301"} +{"s":"-90413552497806753e218","v":"-9.041355249780676e+234","b":"f0b6bfabe275dd0c"} +{"d":"fff0000000000000","s":"-Infinity"} +{"s":"289256326054984930029e84","v":"2.892563260549849e+104","b":"55a024b4446d66f0"} +{"d":"7ff0000000000000","s":"Infinity"} +{"s":"0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000562442","v":"5.62442e-281","b":"05c055cdc728f53b"} +{"d":"57ca667e18d1b1f1","s":"8.126775084597233e+114"} +{"s":"+1.7976931348623159e308","v":"Infinity","b":"7ff0000000000000"} +{"d":"3eb0c6f7a0b5ed8d","s":"0.000001"} +{"s":"+5730019E-263","v":"5.730019e-257","b":"0abb881aac6d7289"} +{"d":"53bad340e1f9a941","s":"2.2382147731846513e+95"} +{"s":"6278489349569000e+153","v":"6.278489349569e+168","b":"62fa9e3de45467bb"} +{"d":"3e7175dbbdc32701","s":"6.5045e-8"} +{"s":"91348783184E+331","v":"Infinity","b":"7ff0000000000000"} +{"d":"8f310347a19993be","s":"-1.6720894090328378e-235"} +{"s":"105066632884437959284587941072164938307176080002462480838412023342609055133880073964714977381523636647973948413106337727301739815592491781234539535743499671209804779414128036909719884287459899082881396328740816174978221371802618241060648446781804118871354172849955378643030654605402020758399541149930154678268516325833686529123498618525912220165612347207057344704504130721786099201255067375070521468628036632131901344648621435683944442329223705497231234979310212390703071345621863654393318518955882656887181637207875529630941793645206850924933079022147355451584429669133203737675018201971310585586512528747026918057586742183926132242563786352580907872492429665540151998173179751824889870587288935445155823243973061784138106452830943159742512849202574525585686036930178213","v":"Infinity","b":"7ff0000000000000"} +{"d":"400e3b8e4b87bdcf","s":"3.77908"} +{"s":"+0.0000000074884772002912433","v":"7.488477200291243e-9","b":"3e4014d57907ca71"} +{"d":"41359b6024800000","s":"1416032.142578125"} +{"s":"2362698048038565168524809721882288861468822960123258017969383557115886932094765049507841203305007982871027532008226220045212286459482999684629219921170270038175944551397708593988512272752261909635362492953091799835119200037735662769218096804716659733193588499822489494852499276629456453640014504104164788080408602636291947706948372118168650877618223129977597077984376635949497238403893991519590006444497765424513257102760218576955445188705753655920669091434980882684777027263773035374706856899505903930150719487459297843996949066289212597908709731291346045157864356938044216512816077803531046549593260439924042854541364940390765827100713025319084147184973602138754875683743352320105964077904624367164429462299320328482246975811832266433239457591461351681339105604424330785367476074648496529696717267534181635884227881061566769643857731104228616131045307185888266735853429553689510681684697584145829780957525854469765734601818004003758108920041952292536753208737824201490783005609469293101330468730305729113970956147172892595484124287400477265556323474110221585991036948469103291264353717317711887058055614764935003671945556233113477754597348746693278565322175884063569317933716187553035306852200511740186363940722167451708212095159662302034940888648239309875609160356","v":"Infinity","b":"7ff0000000000000"} +{"d":"000751083fde60b5","s":"1.0174890231949746e-308"} +{"s":"37484797116108898325182379106677792016900895514284861205790175203110804559853597279003832797852913905444021628360631487084394829000008886722672750340692252478660268595286713354738638985493131371999481116218638639281408062788410548011842024088128464803086579706444043041563673062286187739533084069924978721916041215491873975882018046981038735517586398495844149124409238893838883807275138044174787092333130180536194347049455376306753614712143641051890529465312046379716652425552312397699495590371198875551267466044242043278454097373095175801241362454057961308051462135310709320010694640864530380434261722957681659366712877115699525120879444944921096596393985475257681205745751203284815614397276071807303286671714772744621013434524875172764251765919586429218180297256799451428626746442653734793055757947870027721530464199055237355827998118593568683027950125907668908739491770084998484807740493092939600991046807028549210310703326764020721714600542158703060585491063053891181999545687980030114207924284273","v":"Infinity","b":"7ff0000000000000"} +{"d":"dcfd7d841d5665e4","s":"-8.779649010075926e+139"} +{"s":"21254763452608168105001088728388223336894514671221355436467324884729809960930353075507330874796846828425425423587550600467253614708926695576448206437533943352402619991021428859101005899620999711744508817317570604303781082402207674821818497977823819635850163203364783381033954819103196931588141685879957880026607988275658886620203906381465316012852919732211406411988627084358788502309100563354428882369129613396805272219392e-508","v":"2.125476345260817e-87","b":"2df0e9abf9ea237a"} +{"d":"3ee189c3fc3d381b","s":"0.0000083628400557"} +{"s":"-0.000000000000000000000000000000000000000000000000000000000000000000000003","v":"-3e-72","b":"b11533c1122314c0"} +{"d":"3d008eb745fd02cd","s":"7.353e-15"} +{"s":"632.722532133539146614507051","v":"632.7225321335392","b":"4083c5c7beed5ee1"} +{"d":"15ff5a549627a36c","s":"1e-202"} +{"s":"1681261654253233e+126","v":"1.681261654253233e+141","b":"5d41a5cd9158daf8"} +{"d":"36169998491dae46","s":"3.8658834459571374e-48"} +{"s":"-92.754642911560752713","v":"-92.75464291156075","b":"c057304c11c853f2"} +{"d":"7ff8000000000000","s":"NaN"} +{"s":"901.179685085","v":"901.179685085","b":"408c296ffebbdd3b"} +{"d":"42290c645d000000","s":"53791043200"} +{"s":"66407454351448591946721870187988811.8740067838101680565373613991","v":"6.640745435144859e+34","b":"47299447d3610975"} +{"d":"4340000000000000","s":"9007199254740992"} +{"s":"+334182581897370628e16","v":"3.3418258189737064e+33","b":"46e49878b2ff7e84"} +{"d":"0000ab1fdfbda138","s":"9.2960124212125e-310"} +{"s":"0.0056560993558349860509339844626008990","v":"0.005656099355834986","b":"3f772ad99c198cf2"} +{"d":"42328c56f0000000","s":"79663919104"} +{"s":"+6960800164826406749930995.816852185737407985341305329655","v":"6.960800164826406e+24","b":"45170806eea3e6f8"} +{"d":"2035a981e35d4e93","s":"1.6156360755580186e-153"} +{"s":"718478482481303.2545919195841634019003734692691923169","v":"718478482481303.2","b":"43046b9e75d104ba"} +{"d":"42819207c4800000","s":"2414861651968"} +{"s":"+9007199254740993","v":"9007199254740992","b":"4340000000000000"} +{"d":"2cd4dbf7b3f71cb7","s":"1e-92"} +{"s":"+86672474936209819335937500000000000000000001e-31","v":"8667247493620.982","b":"429f8800d507d3ee"} +{"d":"427d9ec3e6000000","s":"2035483041792"} +{"s":"178127387441E+323","v":"Infinity","b":"7ff0000000000000"} +{"d":"41972997eb147ae1","s":"97150458.77"} +{"s":"2095374989407400864983650712837973424365814056775041341663833059551661558019933979025250451012284347943982681e-1033","v":"0","b":"0000000000000000"} +{"d":"42e56c7b8d000000","s":"188445387915264"} +{"s":"007","v":"7","b":"401c000000000000"} +{"d":"8e50ab877c142ffa","s":"-1e-239"} +{"s":"38903264601973565965480195882374238624427250111164178045860446345897646290405990304291726333302232968990081566763444973615500059595289847443530880116708090042981783566134541909395260575343454944077964594253301666268180809815501026489784487001553782281842581588844155735936184205086143176887837966247240629947915883224015873618194934203288602736813986682351607909072472508705257874218723829548173756230139864285408074062476e-70","v":"Infinity","b":"7ff0000000000000"} +{"d":"40eb4a2f3c000000","s":"55889.47607421875"} +{"s":"+60253506388678.9216618884327","v":"60253506388678.92","b":"42cb666e6c216376"} +{"d":"3dc5fd7fe1796495","s":"4e-11"} +{"s":"-7.87910695095837679381073089588248872646229643e-309","v":"-7.879106950958376e-309","b":"8005aa6a6fb4b885"} +{"d":"cb5a19e96a19fc41","s":"-1e+55"} +{"s":"+133789045e-143","v":"1.33789045e-135","b":"23ef1e26c0989c8e"} +{"d":"3ee2c78e983fc78a","s":"0.0000089547727455152"} +{"s":"0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000453708004259975219966747762001012471480585981624515439161816174945996001566507780376745540108884228071720784935568741927542307222565972014384118153064758219915092056631942507555306349852643379053789176794927979594069401624655317707009905971383171633831897017718219574694642579407846526623654910732189338687139848313712119329376547821949450770723436131824422524716913812789538312111674821236473320595905533991754055023193359375","v":"4.5370800425997526e-161","b":"1ea469745ffbcc24"} +{"d":"74e10cb132c2ff61","s":"9.999999999999996e+254"} +{"s":"432066814632358294175661470360794330.3275563133025929023","v":"4.3206681463235826e+35","b":"4754cda27959db7e"} +{"d":"000a469a00018315","s":"1.4290241135418656e-308"} +{"s":"-9186.442","v":"-9186.442","b":"c0c1f1389374bc6a"} +{"d":"41c0c05808a83b03","s":"562081809.3143009"} +{"s":"-115523e-140","v":"-1.15523e-135","b":"a3eade8b05390268"} +{"d":"0001a6a8c1c7ac4e","s":"2.29601550833563e-309"} +{"s":"0.0000000000000088","v":"8.8e-15","b":"3d03d0dac864deb1"} +{"d":"42e4e988bf000000","s":"183946033233920"} +{"s":"0.000000000000028658563538984473","v":"2.8658563538984475e-14","b":"3d2022225fceb081"} +{"d":"1a253eda614071a3","s":"9.999999999999999e-183"} +{"s":"48.474306625511543761334934330","v":"48.474306625511545","b":"40483cb6145a6c92"} +{"d":"135901e47afe4b7b","s":"1.8135583167323502e-215"} +{"s":"007","v":"7","b":"401c000000000000"} +{"d":"41cada2dd0000000","s":"901012384"} +{"s":"-9.9999999999999971772631818622e-76","v":"-9.999999999999997e-76","b":"b05cf2b1970e7256"} +{"d":"0001d2c26a49e55c","s":"2.535581580940054e-309"} +{"s":"+7364948115018533458911937856632918062443055364733490117199411937114822396019004142000572691605528316430245589829793382937797324754035872527005186795041004734108689836639412385138088396399183356010766970309944048199505418660879229794275034692070264548709481269330302371650798338743885718576579661268772237928571085721374300680628675110062865249646481747624468568624283481232534380358554314921997587313192843214480663914937117077534987483868744343256306055269063269891685425967582782242919038284869878029288720665506976235076276194002473665692561952036896606946740955701047e-4","v":"Infinity","b":"7ff0000000000000"} +{"d":"0c06e93f5da2824d","s":"1.0000000000000002e-250"} +{"s":"53976585726549051491e-75","v":"5.397658572654905e-56","b":"34752d107734ea5a"} +{"d":"3db3457fa02e5155","s":"1.752730774e-11"} +{"s":"+0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006","v":"6e-242","b":"0dd99aecc6c6f1a0"} +{"d":"0000000000000001","s":"5e-324"} +{"s":"2430001e034","v":"2.430001e+40","b":"4851da52ec35eb27"} +{"d":"00084babb243f80d","s":"1.15364358737136e-308"} +{"s":"0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004562139437","v":"4.562139437e-119","b":"275d7392e2253ba4"} +{"d":"d00f7fc7343f7cf7","s":"-4.5591880766190185e+77"} +{"s":"-3807.4710885931882330777","v":"-3807.471088593188","b":"c0adbef132862a86"} +{"d":"3fe95551d68c692f","s":"0.791665"} +{"s":"-0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002","v":"-2e-165","b":"9dbd7becc2f23ac2"} +{"d":"345698230b526d61","s":"1.4397908898042114e-56"} +{"s":"+0","v":"0","b":"0000000000000000"} +{"d":"0008daaf1e351ba3","s":"1.2313328700101784e-308"} +{"s":"-3E130","v":"-3e+130","b":"db05a3c984046236"} +{"d":"7019c3bc80c85c81","s":"1.0000000000000003e+232"} +{"s":"50286.0955810546931647443220671973777930564","v":"50286.095581054695","b":"40e88dc30f000001"} +{"d":"4415af1d78b58c40","s":"100000000000000000000"} +{"s":"6153506033090796654814257004333751607295116847246178105293923864679778007678362211784680837767788950114580483177425420686123551833319570492181364526220207228501554119567396486544824384898393367179339358222525491772496861169429690634103876960526035109382090282622683156481472483047894369857741635207188561515362077281454080055945789791047334940957489853883557541268731900420175156908","v":"Infinity","b":"7ff0000000000000"} +{"d":"42b547b13bc2d133","s":"23397660345041.2"} +{"s":"52348647927138733351101693902333658280249369238479961955697173863858595242175709567518824970969175015931812010056587545415735633713613312073464991691191712178792906425435212127690771593438875091236431881764700858186985936521782875302180236369117154228318012988425080889938082717599780935154421216398371843390364565167654165178703132960965805326959740713689264398161225182345148280987112547348615113854635567003486673898948239681280233820814454375797170137773408517117936285231685152772454058072138211703947511416450267982683345230467425558290069884769625976488103193982264154108647213371728243905608965949469942871289272232402107940477384162250016468429513199660191457170135023176896142456114341893819927014290057880150935362282432498073789673420572981638396602173735811725801328601699795317432527258808053598600474e-289","v":"Infinity","b":"7ff0000000000000"} +{"d":"41539972249ba5e3","s":"5137864.572"} +{"s":"-52995e-324","v":"-5.2993e-320","b":"80000000000029e6"} +{"d":"e7f3d9cca39d87a6","s":"-5.660499966666902e+192"} +{"s":"1.","v":"1","b":"3ff0000000000000"} +{"d":"3eac6ad2fe80a163","s":"8.46901e-7"} +{"s":"+9.999999999999997760990597655787256e+88","v":"9.999999999999997e+88","b":"526922726dbaae37"} +{"d":"a7d325ff2dd85a06","s":"-7.593373259326515e-117"} +{"s":"0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002111447157340392660738","v":"2.1114471573403927e-303","b":"01172ad59fae1701"} +{"d":"fe6ddd4baa009303","s":"-1e+301"} +{"s":"28869E-40","v":"2.8869e-36","b":"388eb2e3aa8254ab"} +{"d":"d83e482565f4dfff","s":"-1.193164484979197e+117"} +{"s":"59.94153726696","v":"59.94153726696","b":"404df8844b0cc77a"} +{"d":"b0295b911c2479a1","s":"-1.0949661206935303e-76"} +{"s":"+664737578e176","v":"6.64737578e+184","b":"664f49d24bf50275"} +{"d":"7ff0000000000000","s":"Infinity"} +{"s":"+450408939884626720.0000000001","v":"450408939884626750","b":"439900b22d85ef0d"} +{"d":"000e7b1190732e0e","s":"2.0137943009402145e-308"} +{"s":"4226455627945985659519398319531484325185507241315661524018594639605062886813123289294182773228315750051118624343139976426232121810110067734879896715746031960297336979511242130472207316461107085014958784086047671735286712646484374999999e-310","v":"4.2264556279459854e-76","b":"3048783191a39f6b"} +{"d":"7ff8000000000000","s":"NaN"} +{"s":"+0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002435495023333790424865506","v":"2.4354950233337903e-260","b":"0a07f7444c32d465"} +{"d":"5b568a9c942f3ba2","s":"9.999999999999998e+131"} +{"s":"+69.665","v":"69.665","b":"40516a8f5c28f5c3"} +{"d":"3ef1c8ef0b7fd4bb","s":"0.000016961"} +{"s":"+931577.31808","v":"931577.31808","b":"412c6df2a2db61bb"} +{"d":"3e7ad7f29abcaf48","s":"1e-7"} +{"s":"+489.899543814941441452450928173489918549","v":"489.89954381494147","b":"407e9e64880e27e2"} +{"d":"272b45356e59325a","s":"5.2803461768972043e-120"} +{"s":"1.627143759091823809227381545478438339664230e+107","v":"1.627143759091824e+107","b":"5631bc8a00124070"} +{"d":"241d12d41afca3c1","s":"9.999999999999998e-135"} +{"s":"1475.352706892820423579457","v":"1475.3527068928204","b":"40970d692bfee6f3"} +{"d":"00008dec5a93645d","s":"7.7097101863915e-310"} +{"s":"5.0","v":"5","b":"4014000000000000"} +{"d":"a5e217045f399371","s":"-3.3404751296819743e-126"} +{"s":"-2728679330417795984024853803197907697573888728890585309233028956160874628432378251552520978335936935695666943305000452609693417625586613465517469730977341301794168983328256825512248126205938625332692026859149336814880371093750000001e-305","v":"-2.728679330417796e-74","b":"b0a8af308a513d5c"} +{"d":"000274da8e4e05be","s":"3.416127939751706e-309"} +{"s":"0e999999999999","v":"0","b":"0000000000000000"} +{"d":"bfd75c575f5f4251","s":"-0.3650110656135768"} +{"s":"+5989297223e-83","v":"5.989297223e-74","b":"30bb1721e3fe2914"} +{"d":"425a76ebcc000000","s":"454657257472"} +{"s":"9007199254740992.58296775","v":"9007199254740992","b":"4340000000000000"} +{"d":"000606153a737890","s":"8.377071288902486e-309"} +{"s":"+289563978592124506383393714718013392054882841613301075380901130706679894204311744035782052985963588532305919.999999999999999999","v":"2.895639785921245e+107","b":"563f9045da6688e3"} +{"d":"0000000000000001","s":"5e-324"} +{"s":"2.4703282292062328e-324","v":"5e-324","b":"0000000000000001"} +{"d":"3fb999999999999a","s":"0.1"} +{"s":"+1.8844","v":"1.8844","b":"3ffe26809d495183"} +{"d":"3cd203af9ee75616","s":"1e-15"} +{"s":"2.4703282292062327e-324","v":"0","b":"0000000000000000"} +{"d":"e12a6fa275bbf1b9","s":"-1.1614610557087358e+160"} +{"s":"953765506422551739532698571037865381005227188769699826341160699336325713206864068312684048871842262434810344845915275604000390904218506531774549562293792910128348943428821006380710293639872380927.999999","v":"9.537655064225517e+194","b":"686a2182c9d0d43f"} +{"d":"8e84d6695b193bf8","s":"-1e-238"} +{"s":"94088852044365195812564449399400399819485610671519123136925806006155666425407453848754026718221222160260625803853158170853711410245443699216727532583304232234903240838741954059096111466677649622791904709380060228007215877539862397484570544423839122207872729490689997368717791862045444616210850241283429133490903999174444337702249979493721287210326476646838203985290459998081815838876235378854313911279873039247640092544545397326180377336879479684910320696012177832139214250102730707048633940427940494751305703125551118092032736285868391952333425296562064800844837006864782584278310719653670985140305048105956023461377475911452063087551823490306838382159407204278138023594296321425055738430783502917838242636097268563857495868452060099429790398829455321611515730165215178909000269311233434435475554258533215318451727259762022808315865868709227428733440704557959884836317526624310939429853357413156931072556744475108185064344910492151904637069668354887939506168423609146406890321718129774128813527248707234357815867161095256284445864613797394116996789911112278574952808146455794810990986011347460641801826023885275969960996532716914394920602648313335306e-170","v":"Infinity","b":"7ff0000000000000"} +{"d":"cfefbd74a7a070f1","s":"-1.1485150018486497e+77"} +{"s":"+479505195217071e318","v":"Infinity","b":"7ff0000000000000"} +{"d":"1846cfec8aa52598","s":"1e-191"} diff --git a/c/tests/data/unicode/cases.jsonl b/c/tests/data/unicode/cases.jsonl new file mode 100644 index 0000000..4771adb --- /dev/null +++ b/c/tests/data/unicode/cases.jsonl @@ -0,0 +1,6109 @@ +{"g":"single","s":"\u0000","k":0} +{"g":"single","s":"'","k":0} +{"g":"single","s":".","k":0} +{"g":"single","s":":","k":0} +{"g":"single","s":"A","l":"a","k":3} +{"g":"single","s":"Z","l":"z","k":3} +{"g":"single","s":"^","k":0} +{"g":"single","s":"`","k":0} +{"g":"single","s":"a","k":1} +{"g":"single","s":"z","k":1} +{"g":"single","s":"¨","k":0} +{"g":"single","s":"ª","k":1} +{"g":"single","s":"­","k":0} +{"g":"single","s":"¯","k":0} +{"g":"single","s":"´","k":0} +{"g":"single","s":"µ","k":1} +{"g":"single","s":"·","k":0} +{"g":"single","s":"¸","k":0} +{"g":"single","s":"º","k":1} +{"g":"single","s":"À","d":"À","l":"à","k":3} +{"g":"single","s":"É","d":"É","l":"é","k":3} +{"g":"single","s":"Ò","d":"Ò","l":"ò","k":3} +{"g":"single","s":"Ö","d":"Ö","l":"ö","k":3} +{"g":"single","s":"Ø","l":"ø","k":3} +{"g":"single","s":"Ü","d":"Ü","l":"ü","k":3} +{"g":"single","s":"Þ","l":"þ","k":3} +{"g":"single","s":"ç","d":"ç","k":1} +{"g":"single","s":"ï","d":"ï","k":1} +{"g":"single","s":"ö","d":"ö","k":1} +{"g":"single","s":"ø","k":1} +{"g":"single","s":"ú","d":"ú","k":1} +{"g":"single","s":"Ā","d":"Ā","l":"ā","k":3} +{"g":"single","s":"Ă","d":"Ă","l":"ă","k":3} +{"g":"single","s":"ă","d":"ă","k":1} +{"g":"single","s":"Ą","d":"Ą","l":"ą","k":3} +{"g":"single","s":"Ć","d":"Ć","l":"ć","k":3} +{"g":"single","s":"Ĉ","d":"Ĉ","l":"ĉ","k":3} +{"g":"single","s":"Ċ","d":"Ċ","l":"ċ","k":3} +{"g":"single","s":"ċ","d":"ċ","k":1} +{"g":"single","s":"Č","d":"Č","l":"č","k":3} +{"g":"single","s":"Ď","d":"Ď","l":"ď","k":3} +{"g":"single","s":"Đ","l":"đ","k":3} +{"g":"single","s":"Ē","d":"Ē","l":"ē","k":3} +{"g":"single","s":"Ĕ","d":"Ĕ","l":"ĕ","k":3} +{"g":"single","s":"ĕ","d":"ĕ","k":1} +{"g":"single","s":"Ė","d":"Ė","l":"ė","k":3} +{"g":"single","s":"Ę","d":"Ę","l":"ę","k":3} +{"g":"single","s":"Ě","d":"Ě","l":"ě","k":3} +{"g":"single","s":"Ĝ","d":"Ĝ","l":"ĝ","k":3} +{"g":"single","s":"ĝ","d":"ĝ","k":1} +{"g":"single","s":"Ğ","d":"Ğ","l":"ğ","k":3} +{"g":"single","s":"Ġ","d":"Ġ","l":"ġ","k":3} +{"g":"single","s":"Ģ","d":"Ģ","l":"ģ","k":3} +{"g":"single","s":"Ĥ","d":"Ĥ","l":"ĥ","k":3} +{"g":"single","s":"ĥ","d":"ĥ","k":1} +{"g":"single","s":"Ħ","l":"ħ","k":3} +{"g":"single","s":"Ĩ","d":"Ĩ","l":"ĩ","k":3} +{"g":"single","s":"Ī","d":"Ī","l":"ī","k":3} +{"g":"single","s":"Ĭ","d":"Ĭ","l":"ĭ","k":3} +{"g":"single","s":"Į","d":"Į","l":"į","k":3} +{"g":"single","s":"į","d":"į","k":1} +{"g":"single","s":"İ","d":"İ","l":"i̇","k":3} +{"g":"single","s":"IJ","l":"ij","k":3} +{"g":"single","s":"Ĵ","d":"Ĵ","l":"ĵ","k":3} +{"g":"single","s":"Ķ","d":"Ķ","l":"ķ","k":3} +{"g":"single","s":"Ĺ","d":"Ĺ","l":"ĺ","k":3} +{"g":"single","s":"Ļ","d":"Ļ","l":"ļ","k":3} +{"g":"single","s":"Ľ","d":"Ľ","l":"ľ","k":3} +{"g":"single","s":"Ŀ","l":"ŀ","k":3} +{"g":"single","s":"Ł","l":"ł","k":3} +{"g":"single","s":"Ń","d":"Ń","l":"ń","k":3} +{"g":"single","s":"Ņ","d":"Ņ","l":"ņ","k":3} +{"g":"single","s":"Ň","d":"Ň","l":"ň","k":3} +{"g":"single","s":"Ŋ","l":"ŋ","k":3} +{"g":"single","s":"Ō","d":"Ō","l":"ō","k":3} +{"g":"single","s":"Ŏ","d":"Ŏ","l":"ŏ","k":3} +{"g":"single","s":"Ő","d":"Ő","l":"ő","k":3} +{"g":"single","s":"Œ","l":"œ","k":3} +{"g":"single","s":"Ŕ","d":"Ŕ","l":"ŕ","k":3} +{"g":"single","s":"Ŗ","d":"Ŗ","l":"ŗ","k":3} +{"g":"single","s":"Ř","d":"Ř","l":"ř","k":3} +{"g":"single","s":"Ś","d":"Ś","l":"ś","k":3} +{"g":"single","s":"Ŝ","d":"Ŝ","l":"ŝ","k":3} +{"g":"single","s":"Ş","d":"Ş","l":"ş","k":3} +{"g":"single","s":"Š","d":"Š","l":"š","k":3} +{"g":"single","s":"Ţ","d":"Ţ","l":"ţ","k":3} +{"g":"single","s":"Ť","d":"Ť","l":"ť","k":3} +{"g":"single","s":"Ŧ","l":"ŧ","k":3} +{"g":"single","s":"Ũ","d":"Ũ","l":"ũ","k":3} +{"g":"single","s":"Ū","d":"Ū","l":"ū","k":3} +{"g":"single","s":"Ŭ","d":"Ŭ","l":"ŭ","k":3} +{"g":"single","s":"Ů","d":"Ů","l":"ů","k":3} +{"g":"single","s":"Ű","d":"Ű","l":"ű","k":3} +{"g":"single","s":"Ų","d":"Ų","l":"ų","k":3} +{"g":"single","s":"Ŵ","d":"Ŵ","l":"ŵ","k":3} +{"g":"single","s":"Ŷ","d":"Ŷ","l":"ŷ","k":3} +{"g":"single","s":"Ÿ","d":"Ÿ","l":"ÿ","k":3} +{"g":"single","s":"Ź","d":"Ź","l":"ź","k":3} +{"g":"single","s":"Ż","d":"Ż","l":"ż","k":3} +{"g":"single","s":"Ž","d":"Ž","l":"ž","k":3} +{"g":"single","s":"ž","d":"ž","k":1} +{"g":"single","s":"Ɓ","l":"ɓ","k":3} +{"g":"single","s":"Ƃ","l":"ƃ","k":3} +{"g":"single","s":"Ƅ","l":"ƅ","k":3} +{"g":"single","s":"Ɔ","l":"ɔ","k":3} +{"g":"single","s":"Ƈ","l":"ƈ","k":3} +{"g":"single","s":"Ɖ","l":"ɖ","k":3} +{"g":"single","s":"Ƌ","l":"ƌ","k":3} +{"g":"single","s":"Ǝ","l":"ǝ","k":3} +{"g":"single","s":"Ə","l":"ə","k":3} +{"g":"single","s":"Ƒ","l":"ƒ","k":3} +{"g":"single","s":"Ɠ","l":"ɠ","k":3} +{"g":"single","s":"Ɣ","l":"ɣ","k":3} +{"g":"single","s":"Ɩ","l":"ɩ","k":3} +{"g":"single","s":"Ƙ","l":"ƙ","k":3} +{"g":"single","s":"Ɯ","l":"ɯ","k":3} +{"g":"single","s":"Ɲ","l":"ɲ","k":3} +{"g":"single","s":"Ɵ","l":"ɵ","k":3} +{"g":"single","s":"Ơ","d":"Ơ","l":"ơ","k":3} +{"g":"single","s":"Ƣ","l":"ƣ","k":3} +{"g":"single","s":"Ƥ","l":"ƥ","k":3} +{"g":"single","s":"Ʀ","l":"ʀ","k":3} +{"g":"single","s":"Ƨ","l":"ƨ","k":3} +{"g":"single","s":"Ʃ","l":"ʃ","k":3} +{"g":"single","s":"Ƭ","l":"ƭ","k":3} +{"g":"single","s":"Ʈ","l":"ʈ","k":3} +{"g":"single","s":"Ư","d":"Ư","l":"ư","k":3} +{"g":"single","s":"Ʊ","l":"ʊ","k":3} +{"g":"single","s":"Ƴ","l":"ƴ","k":3} +{"g":"single","s":"Ƶ","l":"ƶ","k":3} +{"g":"single","s":"Ʒ","l":"ʒ","k":3} +{"g":"single","s":"Ƹ","l":"ƹ","k":3} +{"g":"single","s":"ƺ","k":1} +{"g":"single","s":"Ƽ","l":"ƽ","k":3} +{"g":"single","s":"ƿ","k":1} +{"g":"single","s":"DŽ","l":"dž","k":3} +{"g":"single","s":"Dž","l":"dž","k":1} +{"g":"single","s":"LJ","l":"lj","k":3} +{"g":"single","s":"NJ","l":"nj","k":3} +{"g":"single","s":"Nj","l":"nj","k":1} +{"g":"single","s":"Ǎ","d":"Ǎ","l":"ǎ","k":3} +{"g":"single","s":"Ǐ","d":"Ǐ","l":"ǐ","k":3} +{"g":"single","s":"ǐ","d":"ǐ","k":1} +{"g":"single","s":"Ǒ","d":"Ǒ","l":"ǒ","k":3} +{"g":"single","s":"Ǔ","d":"Ǔ","l":"ǔ","k":3} +{"g":"single","s":"Ǖ","d":"Ǖ","l":"ǖ","k":3} +{"g":"single","s":"Ǘ","d":"Ǘ","l":"ǘ","k":3} +{"g":"single","s":"ǘ","d":"ǘ","k":1} +{"g":"single","s":"Ǚ","d":"Ǚ","l":"ǚ","k":3} +{"g":"single","s":"Ǜ","d":"Ǜ","l":"ǜ","k":3} +{"g":"single","s":"Ǟ","d":"Ǟ","l":"ǟ","k":3} +{"g":"single","s":"Ǡ","d":"Ǡ","l":"ǡ","k":3} +{"g":"single","s":"ǡ","d":"ǡ","k":1} +{"g":"single","s":"Ǣ","d":"Ǣ","l":"ǣ","k":3} +{"g":"single","s":"Ǥ","l":"ǥ","k":3} +{"g":"single","s":"Ǧ","d":"Ǧ","l":"ǧ","k":3} +{"g":"single","s":"Ǩ","d":"Ǩ","l":"ǩ","k":3} +{"g":"single","s":"Ǫ","d":"Ǫ","l":"ǫ","k":3} +{"g":"single","s":"ǫ","d":"ǫ","k":1} +{"g":"single","s":"Ǭ","d":"Ǭ","l":"ǭ","k":3} +{"g":"single","s":"Ǯ","d":"Ǯ","l":"ǯ","k":3} +{"g":"single","s":"DZ","l":"dz","k":3} +{"g":"single","s":"Ǵ","d":"Ǵ","l":"ǵ","k":3} +{"g":"single","s":"Ƕ","l":"ƕ","k":3} +{"g":"single","s":"Ǹ","d":"Ǹ","l":"ǹ","k":3} +{"g":"single","s":"Ǻ","d":"Ǻ","l":"ǻ","k":3} +{"g":"single","s":"Ǽ","d":"Ǽ","l":"ǽ","k":3} +{"g":"single","s":"Ǿ","d":"Ǿ","l":"ǿ","k":3} +{"g":"single","s":"Ȁ","d":"Ȁ","l":"ȁ","k":3} +{"g":"single","s":"Ȃ","d":"Ȃ","l":"ȃ","k":3} +{"g":"single","s":"Ȅ","d":"Ȅ","l":"ȅ","k":3} +{"g":"single","s":"Ȇ","d":"Ȇ","l":"ȇ","k":3} +{"g":"single","s":"Ȉ","d":"Ȉ","l":"ȉ","k":3} +{"g":"single","s":"Ȋ","d":"Ȋ","l":"ȋ","k":3} +{"g":"single","s":"Ȍ","d":"Ȍ","l":"ȍ","k":3} +{"g":"single","s":"Ȏ","d":"Ȏ","l":"ȏ","k":3} +{"g":"single","s":"Ȑ","d":"Ȑ","l":"ȑ","k":3} +{"g":"single","s":"Ȓ","d":"Ȓ","l":"ȓ","k":3} +{"g":"single","s":"Ȕ","d":"Ȕ","l":"ȕ","k":3} +{"g":"single","s":"Ȗ","d":"Ȗ","l":"ȗ","k":3} +{"g":"single","s":"Ș","d":"Ș","l":"ș","k":3} +{"g":"single","s":"Ț","d":"Ț","l":"ț","k":3} +{"g":"single","s":"Ȝ","l":"ȝ","k":3} +{"g":"single","s":"Ȟ","d":"Ȟ","l":"ȟ","k":3} +{"g":"single","s":"Ƞ","l":"ƞ","k":3} +{"g":"single","s":"Ȣ","l":"ȣ","k":3} +{"g":"single","s":"Ȥ","l":"ȥ","k":3} +{"g":"single","s":"Ȧ","d":"Ȧ","l":"ȧ","k":3} +{"g":"single","s":"Ȩ","d":"Ȩ","l":"ȩ","k":3} +{"g":"single","s":"Ȫ","d":"Ȫ","l":"ȫ","k":3} +{"g":"single","s":"Ȭ","d":"Ȭ","l":"ȭ","k":3} +{"g":"single","s":"Ȯ","d":"Ȯ","l":"ȯ","k":3} +{"g":"single","s":"Ȱ","d":"Ȱ","l":"ȱ","k":3} +{"g":"single","s":"Ȳ","d":"Ȳ","l":"ȳ","k":3} +{"g":"single","s":"Ⱥ","l":"ⱥ","k":3} +{"g":"single","s":"Ȼ","l":"ȼ","k":3} +{"g":"single","s":"Ƚ","l":"ƚ","k":3} +{"g":"single","s":"Ⱦ","l":"ⱦ","k":3} +{"g":"single","s":"Ɂ","l":"ɂ","k":3} +{"g":"single","s":"Ƀ","l":"ƀ","k":3} +{"g":"single","s":"Ʌ","l":"ʌ","k":3} +{"g":"single","s":"Ɇ","l":"ɇ","k":3} +{"g":"single","s":"Ɉ","l":"ɉ","k":3} +{"g":"single","s":"Ɋ","l":"ɋ","k":3} +{"g":"single","s":"Ɍ","l":"ɍ","k":3} +{"g":"single","s":"Ɏ","l":"ɏ","k":3} +{"g":"single","s":"ʓ","k":1} +{"g":"single","s":"ʖ","k":1} +{"g":"single","s":"ʰ","k":1} +{"g":"single","s":"ʸ","k":1} +{"g":"single","s":"ˀ","k":1} +{"g":"single","s":"ˁ","k":1} +{"g":"single","s":"ˆ","k":1} +{"g":"single","s":"ˑ","k":1} +{"g":"single","s":"ˠ","k":1} +{"g":"single","s":"ˤ","k":1} +{"g":"single","s":"ˬ","k":1} +{"g":"single","s":"ˮ","k":1} +{"g":"single","s":"̀","k":0} +{"g":"single","s":"́","k":0} +{"g":"single","s":"̂","k":0} +{"g":"single","s":"̃","k":0} +{"g":"single","s":"̄","k":0} +{"g":"single","s":"̆","k":0} +{"g":"single","s":"̇","k":0} +{"g":"single","s":"̈","k":0} +{"g":"single","s":"̉","k":0} +{"g":"single","s":"̊","k":0} +{"g":"single","s":"̌","k":0} +{"g":"single","s":"̏","k":0} +{"g":"single","s":"̐","k":0} +{"g":"single","s":"̑","k":0} +{"g":"single","s":"̓","k":0} +{"g":"single","s":"̔","k":0} +{"g":"single","s":"̘","k":0} +{"g":"single","s":"̛","k":0} +{"g":"single","s":"̠","k":0} +{"g":"single","s":"̣","k":0} +{"g":"single","s":"̧","k":0} +{"g":"single","s":"̨","k":0} +{"g":"single","s":"̭","k":0} +{"g":"single","s":"̮","k":0} +{"g":"single","s":"̰","k":0} +{"g":"single","s":"̱","k":0} +{"g":"single","s":"̸","k":0} +{"g":"single","s":"̀","c":"̀","d":"̀","k":0} +{"g":"single","s":"́","c":"́","d":"́","k":0} +{"g":"single","s":"͂","k":0} +{"g":"single","s":"̓","c":"̓","d":"̓","k":0} +{"g":"single","s":"̈́","c":"̈́","d":"̈́","k":0} +{"g":"single","s":"ͅ","k":0} +{"g":"single","s":"͌","k":0} +{"g":"single","s":"͕","k":0} +{"g":"single","s":"͝","k":0} +{"g":"single","s":"ͥ","k":0} +{"g":"single","s":"ͭ","k":0} +{"g":"single","s":"ͯ","k":0} +{"g":"single","s":"Ͱ","l":"ͱ","k":3} +{"g":"single","s":"Ͳ","l":"ͳ","k":3} +{"g":"single","s":"ͳ","k":1} +{"g":"single","s":"ʹ","c":"ʹ","d":"ʹ","k":1} +{"g":"single","s":"͵","k":0} +{"g":"single","s":"Ͷ","l":"ͷ","k":3} +{"g":"single","s":"ͷ","k":1} +{"g":"single","s":"ͺ","k":1} +{"g":"single","s":"ͽ","k":1} +{"g":"single","s":";","c":";","d":";","k":0} +{"g":"single","s":"Ϳ","l":"ϳ","k":3} +{"g":"single","s":"΄","k":0} +{"g":"single","s":"΅","d":"΅","k":0} +{"g":"single","s":"Ά","d":"Ά","l":"ά","k":3} +{"g":"single","s":"·","c":"·","d":"·","k":0} +{"g":"single","s":"Έ","d":"Έ","l":"έ","k":3} +{"g":"single","s":"Ί","d":"Ί","l":"ί","k":3} +{"g":"single","s":"Ό","d":"Ό","l":"ό","k":3} +{"g":"single","s":"Ύ","d":"Ύ","l":"ύ","k":3} +{"g":"single","s":"Ώ","d":"Ώ","l":"ώ","k":3} +{"g":"single","s":"Α","l":"α","k":3} +{"g":"single","s":"Ρ","l":"ρ","k":3} +{"g":"single","s":"Σ","l":"σ","k":3} +{"g":"single","s":"Ϋ","d":"Ϋ","l":"ϋ","k":3} +{"g":"single","s":"ή","d":"ή","k":1} +{"g":"single","s":"Ϗ","l":"ϗ","k":3} +{"g":"single","s":"ϒ","k":3} +{"g":"single","s":"ϓ","d":"ϓ","k":3} +{"g":"single","s":"ϔ","d":"ϔ","k":3} +{"g":"single","s":"Ϙ","l":"ϙ","k":3} +{"g":"single","s":"Ϛ","l":"ϛ","k":3} +{"g":"single","s":"Ϝ","l":"ϝ","k":3} +{"g":"single","s":"Ϟ","l":"ϟ","k":3} +{"g":"single","s":"Ϡ","l":"ϡ","k":3} +{"g":"single","s":"Ϣ","l":"ϣ","k":3} +{"g":"single","s":"Ϥ","l":"ϥ","k":3} +{"g":"single","s":"Ϧ","l":"ϧ","k":3} +{"g":"single","s":"Ϩ","l":"ϩ","k":3} +{"g":"single","s":"Ϫ","l":"ϫ","k":3} +{"g":"single","s":"Ϭ","l":"ϭ","k":3} +{"g":"single","s":"Ϯ","l":"ϯ","k":3} +{"g":"single","s":"ϴ","l":"θ","k":3} +{"g":"single","s":"ϵ","k":1} +{"g":"single","s":"Ϸ","l":"ϸ","k":3} +{"g":"single","s":"Ϲ","l":"ϲ","k":3} +{"g":"single","s":"Ϻ","l":"ϻ","k":3} +{"g":"single","s":"Ͻ","l":"ͻ","k":3} +{"g":"single","s":"Ў","d":"Ў","l":"ў","k":3} +{"g":"single","s":"Я","l":"я","k":3} +{"g":"single","s":"ѝ","d":"ѝ","k":1} +{"g":"single","s":"Ѡ","l":"ѡ","k":3} +{"g":"single","s":"Ѣ","l":"ѣ","k":3} +{"g":"single","s":"Ѥ","l":"ѥ","k":3} +{"g":"single","s":"Ѧ","l":"ѧ","k":3} +{"g":"single","s":"Ѩ","l":"ѩ","k":3} +{"g":"single","s":"Ѫ","l":"ѫ","k":3} +{"g":"single","s":"Ѭ","l":"ѭ","k":3} +{"g":"single","s":"Ѯ","l":"ѯ","k":3} +{"g":"single","s":"Ѱ","l":"ѱ","k":3} +{"g":"single","s":"Ѳ","l":"ѳ","k":3} +{"g":"single","s":"Ѵ","l":"ѵ","k":3} +{"g":"single","s":"Ѷ","d":"Ѷ","l":"ѷ","k":3} +{"g":"single","s":"Ѹ","l":"ѹ","k":3} +{"g":"single","s":"Ѻ","l":"ѻ","k":3} +{"g":"single","s":"Ѽ","l":"ѽ","k":3} +{"g":"single","s":"Ѿ","l":"ѿ","k":3} +{"g":"single","s":"Ҁ","l":"ҁ","k":3} +{"g":"single","s":"ҁ","k":1} +{"g":"single","s":"҃","k":0} +{"g":"single","s":"҉","k":0} +{"g":"single","s":"Ҋ","l":"ҋ","k":3} +{"g":"single","s":"Ҍ","l":"ҍ","k":3} +{"g":"single","s":"Ҏ","l":"ҏ","k":3} +{"g":"single","s":"Ґ","l":"ґ","k":3} +{"g":"single","s":"Ғ","l":"ғ","k":3} +{"g":"single","s":"Ҕ","l":"ҕ","k":3} +{"g":"single","s":"Җ","l":"җ","k":3} +{"g":"single","s":"Ҙ","l":"ҙ","k":3} +{"g":"single","s":"Қ","l":"қ","k":3} +{"g":"single","s":"Ҝ","l":"ҝ","k":3} +{"g":"single","s":"Ҟ","l":"ҟ","k":3} +{"g":"single","s":"Ҡ","l":"ҡ","k":3} +{"g":"single","s":"Ң","l":"ң","k":3} +{"g":"single","s":"Ҥ","l":"ҥ","k":3} +{"g":"single","s":"Ҧ","l":"ҧ","k":3} +{"g":"single","s":"Ҩ","l":"ҩ","k":3} +{"g":"single","s":"Ҫ","l":"ҫ","k":3} +{"g":"single","s":"Ҭ","l":"ҭ","k":3} +{"g":"single","s":"Ү","l":"ү","k":3} +{"g":"single","s":"Ұ","l":"ұ","k":3} +{"g":"single","s":"Ҳ","l":"ҳ","k":3} +{"g":"single","s":"Ҵ","l":"ҵ","k":3} +{"g":"single","s":"Ҷ","l":"ҷ","k":3} +{"g":"single","s":"Ҹ","l":"ҹ","k":3} +{"g":"single","s":"Һ","l":"һ","k":3} +{"g":"single","s":"Ҽ","l":"ҽ","k":3} +{"g":"single","s":"Ҿ","l":"ҿ","k":3} +{"g":"single","s":"Ӏ","l":"ӏ","k":3} +{"g":"single","s":"Ӂ","d":"Ӂ","l":"ӂ","k":3} +{"g":"single","s":"Ӄ","l":"ӄ","k":3} +{"g":"single","s":"Ӆ","l":"ӆ","k":3} +{"g":"single","s":"Ӈ","l":"ӈ","k":3} +{"g":"single","s":"Ӊ","l":"ӊ","k":3} +{"g":"single","s":"Ӌ","l":"ӌ","k":3} +{"g":"single","s":"Ӎ","l":"ӎ","k":3} +{"g":"single","s":"Ӑ","d":"Ӑ","l":"ӑ","k":3} +{"g":"single","s":"Ӓ","d":"Ӓ","l":"ӓ","k":3} +{"g":"single","s":"Ӕ","l":"ӕ","k":3} +{"g":"single","s":"Ӗ","d":"Ӗ","l":"ӗ","k":3} +{"g":"single","s":"Ә","l":"ә","k":3} +{"g":"single","s":"Ӛ","d":"Ӛ","l":"ӛ","k":3} +{"g":"single","s":"Ӝ","d":"Ӝ","l":"ӝ","k":3} +{"g":"single","s":"Ӟ","d":"Ӟ","l":"ӟ","k":3} +{"g":"single","s":"Ӡ","l":"ӡ","k":3} +{"g":"single","s":"Ӣ","d":"Ӣ","l":"ӣ","k":3} +{"g":"single","s":"Ӥ","d":"Ӥ","l":"ӥ","k":3} +{"g":"single","s":"Ӧ","d":"Ӧ","l":"ӧ","k":3} +{"g":"single","s":"Ө","l":"ө","k":3} +{"g":"single","s":"Ӫ","d":"Ӫ","l":"ӫ","k":3} +{"g":"single","s":"Ӭ","d":"Ӭ","l":"ӭ","k":3} +{"g":"single","s":"Ӯ","d":"Ӯ","l":"ӯ","k":3} +{"g":"single","s":"Ӱ","d":"Ӱ","l":"ӱ","k":3} +{"g":"single","s":"Ӳ","d":"Ӳ","l":"ӳ","k":3} +{"g":"single","s":"Ӵ","d":"Ӵ","l":"ӵ","k":3} +{"g":"single","s":"Ӷ","l":"ӷ","k":3} +{"g":"single","s":"Ӹ","d":"Ӹ","l":"ӹ","k":3} +{"g":"single","s":"Ӻ","l":"ӻ","k":3} +{"g":"single","s":"Ӽ","l":"ӽ","k":3} +{"g":"single","s":"Ӿ","l":"ӿ","k":3} +{"g":"single","s":"Ԁ","l":"ԁ","k":3} +{"g":"single","s":"Ԃ","l":"ԃ","k":3} +{"g":"single","s":"Ԅ","l":"ԅ","k":3} +{"g":"single","s":"Ԇ","l":"ԇ","k":3} +{"g":"single","s":"Ԉ","l":"ԉ","k":3} +{"g":"single","s":"Ԋ","l":"ԋ","k":3} +{"g":"single","s":"Ԍ","l":"ԍ","k":3} +{"g":"single","s":"Ԏ","l":"ԏ","k":3} +{"g":"single","s":"Ԑ","l":"ԑ","k":3} +{"g":"single","s":"Ԓ","l":"ԓ","k":3} +{"g":"single","s":"Ԕ","l":"ԕ","k":3} +{"g":"single","s":"Ԗ","l":"ԗ","k":3} +{"g":"single","s":"Ԙ","l":"ԙ","k":3} +{"g":"single","s":"Ԛ","l":"ԛ","k":3} +{"g":"single","s":"Ԝ","l":"ԝ","k":3} +{"g":"single","s":"Ԟ","l":"ԟ","k":3} +{"g":"single","s":"Ԡ","l":"ԡ","k":3} +{"g":"single","s":"Ԣ","l":"ԣ","k":3} +{"g":"single","s":"Ԥ","l":"ԥ","k":3} +{"g":"single","s":"Ԧ","l":"ԧ","k":3} +{"g":"single","s":"Ԩ","l":"ԩ","k":3} +{"g":"single","s":"Ԫ","l":"ԫ","k":3} +{"g":"single","s":"Ԭ","l":"ԭ","k":3} +{"g":"single","s":"Ԯ","l":"ԯ","k":3} +{"g":"single","s":"ԯ","k":1} +{"g":"single","s":"Ա","l":"ա","k":3} +{"g":"single","s":"Ֆ","l":"ֆ","k":3} +{"g":"single","s":"ՙ","k":1} +{"g":"single","s":"՟","k":0} +{"g":"single","s":"ՠ","k":1} +{"g":"single","s":"ֈ","k":1} +{"g":"single","s":"֑","k":0} +{"g":"single","s":"֙","k":0} +{"g":"single","s":"֡","k":0} +{"g":"single","s":"֩","k":0} +{"g":"single","s":"ֱ","k":0} +{"g":"single","s":"ֹ","k":0} +{"g":"single","s":"ֽ","k":0} +{"g":"single","s":"ֿ","k":0} +{"g":"single","s":"ׁ","k":0} +{"g":"single","s":"ׂ","k":0} +{"g":"single","s":"ׄ","k":0} +{"g":"single","s":"ׅ","k":0} +{"g":"single","s":"ׇ","k":0} +{"g":"single","s":"א","k":1} +{"g":"single","s":"ת","k":1} +{"g":"single","s":"ׯ","k":1} +{"g":"single","s":"ײ","k":1} +{"g":"single","s":"״","k":0} +{"g":"single","s":"؀","k":0} +{"g":"single","s":"؅","k":0} +{"g":"single","s":"ؐ","k":0} +{"g":"single","s":"ؕ","k":0} +{"g":"single","s":"ؚ","k":0} +{"g":"single","s":"؜","k":0} +{"g":"single","s":"ؠ","k":1} +{"g":"single","s":"ؤ","d":"ؤ","k":1} +{"g":"single","s":"ـ","k":1} +{"g":"single","s":"ي","k":1} +{"g":"single","s":"ً","k":0} +{"g":"single","s":"ٍ","k":0} +{"g":"single","s":"ٔ","k":0} +{"g":"single","s":"ٕ","k":0} +{"g":"single","s":"ٝ","k":0} +{"g":"single","s":"ٟ","k":0} +{"g":"single","s":"ٮ","k":1} +{"g":"single","s":"ٯ","k":1} +{"g":"single","s":"ٰ","k":0} +{"g":"single","s":"ٱ","k":1} +{"g":"single","s":"ۓ","d":"ۓ","k":1} +{"g":"single","s":"ە","k":1} +{"g":"single","s":"ۖ","k":0} +{"g":"single","s":"ۚ","k":0} +{"g":"single","s":"۝","k":0} +{"g":"single","s":"۟","k":0} +{"g":"single","s":"ۤ","k":0} +{"g":"single","s":"ۥ","k":1} +{"g":"single","s":"ۦ","k":1} +{"g":"single","s":"ۨ","k":0} +{"g":"single","s":"۪","k":0} +{"g":"single","s":"ۭ","k":0} +{"g":"single","s":"ۮ","k":1} +{"g":"single","s":"ۯ","k":1} +{"g":"single","s":"ۺ","k":1} +{"g":"single","s":"ۼ","k":1} +{"g":"single","s":"ۿ","k":1} +{"g":"single","s":"܏","k":0} +{"g":"single","s":"ܐ","k":1} +{"g":"single","s":"ܑ","k":0} +{"g":"single","s":"ܒ","k":1} +{"g":"single","s":"ܯ","k":1} +{"g":"single","s":"ܰ","k":0} +{"g":"single","s":"ܸ","k":0} +{"g":"single","s":"݀","k":0} +{"g":"single","s":"݈","k":0} +{"g":"single","s":"݊","k":0} +{"g":"single","s":"ݍ","k":1} +{"g":"single","s":"ޥ","k":1} +{"g":"single","s":"ަ","k":0} +{"g":"single","s":"ް","k":0} +{"g":"single","s":"ޱ","k":1} +{"g":"single","s":"ߊ","k":1} +{"g":"single","s":"ߪ","k":1} +{"g":"single","s":"߫","k":0} +{"g":"single","s":"߰","k":0} +{"g":"single","s":"ߴ","k":1} +{"g":"single","s":"ߵ","k":1} +{"g":"single","s":"ߺ","k":1} +{"g":"single","s":"߽","k":0} +{"g":"single","s":"ࠀ","k":1} +{"g":"single","s":"ࠕ","k":1} +{"g":"single","s":"ࠖ","k":0} +{"g":"single","s":"࠙","k":0} +{"g":"single","s":"ࠚ","k":1} +{"g":"single","s":"ࠢ","k":0} +{"g":"single","s":"ࠤ","k":1} +{"g":"single","s":"ࠨ","k":1} +{"g":"single","s":"ࠬ","k":0} +{"g":"single","s":"࠭","k":0} +{"g":"single","s":"ࡀ","k":1} +{"g":"single","s":"ࡘ","k":1} +{"g":"single","s":"࡙","k":0} +{"g":"single","s":"࡛","k":0} +{"g":"single","s":"ࡠ","k":1} +{"g":"single","s":"ࡪ","k":1} +{"g":"single","s":"ࡰ","k":1} +{"g":"single","s":"ࢇ","k":1} +{"g":"single","s":"࢈","k":0} +{"g":"single","s":"ࢉ","k":1} +{"g":"single","s":"࢏","k":1} +{"g":"single","s":"࢐","k":0} +{"g":"single","s":"࢑","k":0} +{"g":"single","s":"ࢗ","k":0} +{"g":"single","s":"࢚","k":0} +{"g":"single","s":"࢟","k":0} +{"g":"single","s":"ࢠ","k":1} +{"g":"single","s":"ࣉ","k":1} +{"g":"single","s":"࣌","k":0} +{"g":"single","s":"ࣔ","k":0} +{"g":"single","s":"ࣜ","k":0} +{"g":"single","s":"ࣥ","k":0} +{"g":"single","s":"࣭","k":0} +{"g":"single","s":"ࣵ","k":0} +{"g":"single","s":"ࣽ","k":0} +{"g":"single","s":"ं","k":0} +{"g":"single","s":"ऄ","k":1} +{"g":"single","s":"ऴ","d":"ऴ","k":1} +{"g":"single","s":"ह","k":1} +{"g":"single","s":"ऺ","k":0} +{"g":"single","s":"़","k":0} +{"g":"single","s":"ऽ","k":1} +{"g":"single","s":"ु","k":0} +{"g":"single","s":"ै","k":0} +{"g":"single","s":"्","k":0} +{"g":"single","s":"ॐ","k":1} +{"g":"single","s":"॑","k":0} +{"g":"single","s":"॔","k":0} +{"g":"single","s":"ॗ","k":0} +{"g":"single","s":"क़","c":"क़","d":"क़","k":1} +{"g":"single","s":"य़","c":"य़","d":"य़","k":1} +{"g":"single","s":"ॡ","k":1} +{"g":"single","s":"ॢ","k":0} +{"g":"single","s":"ॣ","k":0} +{"g":"single","s":"ॱ","k":1} +{"g":"single","s":"ঀ","k":1} +{"g":"single","s":"ঁ","k":0} +{"g":"single","s":"অ","k":1} +{"g":"single","s":"ঌ","k":1} +{"g":"single","s":"এ","k":1} +{"g":"single","s":"ঐ","k":1} +{"g":"single","s":"ও","k":1} +{"g":"single","s":"ন","k":1} +{"g":"single","s":"প","k":1} +{"g":"single","s":"র","k":1} +{"g":"single","s":"ল","k":1} +{"g":"single","s":"শ","k":1} +{"g":"single","s":"হ","k":1} +{"g":"single","s":"়","k":0} +{"g":"single","s":"ঽ","k":1} +{"g":"single","s":"া","k":0} +{"g":"single","s":"ু","k":0} +{"g":"single","s":"ৄ","k":0} +{"g":"single","s":"্","k":0} +{"g":"single","s":"ৎ","k":1} +{"g":"single","s":"ড়","c":"ড়","d":"ড়","k":1} +{"g":"single","s":"ঢ়","c":"ঢ়","d":"ঢ়","k":1} +{"g":"single","s":"য়","c":"য়","d":"য়","k":1} +{"g":"single","s":"ৡ","k":1} +{"g":"single","s":"ৢ","k":0} +{"g":"single","s":"ৣ","k":0} +{"g":"single","s":"ৰ","k":1} +{"g":"single","s":"ৱ","k":1} +{"g":"single","s":"ৼ","k":1} +{"g":"single","s":"৾","k":0} +{"g":"single","s":"ਁ","k":0} +{"g":"single","s":"ਂ","k":0} +{"g":"single","s":"ਅ","k":1} +{"g":"single","s":"ਊ","k":1} +{"g":"single","s":"ਏ","k":1} +{"g":"single","s":"ਐ","k":1} +{"g":"single","s":"ਓ","k":1} +{"g":"single","s":"ਨ","k":1} +{"g":"single","s":"ਪ","k":1} +{"g":"single","s":"ਰ","k":1} +{"g":"single","s":"ਲ","k":1} +{"g":"single","s":"ਲ਼","c":"ਲ਼","d":"ਲ਼","k":1} +{"g":"single","s":"ਵ","k":1} +{"g":"single","s":"ਸ਼","c":"ਸ਼","d":"ਸ਼","k":1} +{"g":"single","s":"ਸ","k":1} +{"g":"single","s":"ਹ","k":1} +{"g":"single","s":"਼","k":0} +{"g":"single","s":"ੁ","k":0} +{"g":"single","s":"ੂ","k":0} +{"g":"single","s":"ੇ","k":0} +{"g":"single","s":"ੈ","k":0} +{"g":"single","s":"ੋ","k":0} +{"g":"single","s":"੍","k":0} +{"g":"single","s":"ੑ","k":0} +{"g":"single","s":"ਖ਼","c":"ਖ਼","d":"ਖ਼","k":1} +{"g":"single","s":"ਜ਼","c":"ਜ਼","d":"ਜ਼","k":1} +{"g":"single","s":"ੜ","k":1} +{"g":"single","s":"ਫ਼","c":"ਫ਼","d":"ਫ਼","k":1} +{"g":"single","s":"ੰ","k":0} +{"g":"single","s":"ੱ","k":0} +{"g":"single","s":"ੲ","k":1} +{"g":"single","s":"ੴ","k":1} +{"g":"single","s":"ੵ","k":0} +{"g":"single","s":"ઁ","k":0} +{"g":"single","s":"ં","k":0} +{"g":"single","s":"અ","k":1} +{"g":"single","s":"ઍ","k":1} +{"g":"single","s":"એ","k":1} +{"g":"single","s":"ઑ","k":1} +{"g":"single","s":"ઓ","k":1} +{"g":"single","s":"ન","k":1} +{"g":"single","s":"પ","k":1} +{"g":"single","s":"ર","k":1} +{"g":"single","s":"લ","k":1} +{"g":"single","s":"ળ","k":1} +{"g":"single","s":"વ","k":1} +{"g":"single","s":"હ","k":1} +{"g":"single","s":"઼","k":0} +{"g":"single","s":"ઽ","k":1} +{"g":"single","s":"ુ","k":0} +{"g":"single","s":"ૅ","k":0} +{"g":"single","s":"ે","k":0} +{"g":"single","s":"ૈ","k":0} +{"g":"single","s":"્","k":0} +{"g":"single","s":"ૐ","k":1} +{"g":"single","s":"ૠ","k":1} +{"g":"single","s":"ૡ","k":1} +{"g":"single","s":"ૢ","k":0} +{"g":"single","s":"ૣ","k":0} +{"g":"single","s":"ૹ","k":1} +{"g":"single","s":"ૺ","k":0} +{"g":"single","s":"૿","k":0} +{"g":"single","s":"ଁ","k":0} +{"g":"single","s":"ଅ","k":1} +{"g":"single","s":"ଌ","k":1} +{"g":"single","s":"ଏ","k":1} +{"g":"single","s":"ଐ","k":1} +{"g":"single","s":"ଓ","k":1} +{"g":"single","s":"ନ","k":1} +{"g":"single","s":"ପ","k":1} +{"g":"single","s":"ର","k":1} +{"g":"single","s":"ଲ","k":1} +{"g":"single","s":"ଳ","k":1} +{"g":"single","s":"ଵ","k":1} +{"g":"single","s":"ହ","k":1} +{"g":"single","s":"଼","k":0} +{"g":"single","s":"ଽ","k":1} +{"g":"single","s":"ି","k":0} +{"g":"single","s":"ୁ","k":0} +{"g":"single","s":"ୄ","k":0} +{"g":"single","s":"୍","k":0} +{"g":"single","s":"୕","k":0} +{"g":"single","s":"ୖ","k":0} +{"g":"single","s":"ଡ଼","c":"ଡ଼","d":"ଡ଼","k":1} +{"g":"single","s":"ଢ଼","c":"ଢ଼","d":"ଢ଼","k":1} +{"g":"single","s":"ୟ","k":1} +{"g":"single","s":"ୡ","k":1} +{"g":"single","s":"ୢ","k":0} +{"g":"single","s":"ୣ","k":0} +{"g":"single","s":"ୱ","k":1} +{"g":"single","s":"ஂ","k":0} +{"g":"single","s":"ஃ","k":1} +{"g":"single","s":"அ","k":1} +{"g":"single","s":"ஊ","k":1} +{"g":"single","s":"எ","k":1} +{"g":"single","s":"ஐ","k":1} +{"g":"single","s":"ஒ","k":1} +{"g":"single","s":"க","k":1} +{"g":"single","s":"ங","k":1} +{"g":"single","s":"ச","k":1} +{"g":"single","s":"ஜ","k":1} +{"g":"single","s":"ஞ","k":1} +{"g":"single","s":"ட","k":1} +{"g":"single","s":"ண","k":1} +{"g":"single","s":"த","k":1} +{"g":"single","s":"ந","k":1} +{"g":"single","s":"ப","k":1} +{"g":"single","s":"ம","k":1} +{"g":"single","s":"ஹ","k":1} +{"g":"single","s":"ா","k":0} +{"g":"single","s":"ீ","k":0} +{"g":"single","s":"்","k":0} +{"g":"single","s":"ௐ","k":1} +{"g":"single","s":"ఀ","k":0} +{"g":"single","s":"ఄ","k":0} +{"g":"single","s":"అ","k":1} +{"g":"single","s":"ఌ","k":1} +{"g":"single","s":"ఎ","k":1} +{"g":"single","s":"ఐ","k":1} +{"g":"single","s":"ఒ","k":1} +{"g":"single","s":"న","k":1} +{"g":"single","s":"ప","k":1} +{"g":"single","s":"హ","k":1} +{"g":"single","s":"఼","k":0} +{"g":"single","s":"ఽ","k":1} +{"g":"single","s":"ా","k":0} +{"g":"single","s":"ీ","k":0} +{"g":"single","s":"ె","k":0} +{"g":"single","s":"ై","d":"ై","k":0} +{"g":"single","s":"ొ","k":0} +{"g":"single","s":"్","k":0} +{"g":"single","s":"ౕ","k":0} +{"g":"single","s":"ౖ","k":0} +{"g":"single","s":"ౘ","k":1} +{"g":"single","s":"ౚ","k":1} +{"g":"single","s":"౜","k":1} +{"g":"single","s":"ౝ","k":1} +{"g":"single","s":"ౠ","k":1} +{"g":"single","s":"ౡ","k":1} +{"g":"single","s":"ౢ","k":0} +{"g":"single","s":"ౣ","k":0} +{"g":"single","s":"ಀ","k":1} +{"g":"single","s":"ಁ","k":0} +{"g":"single","s":"ಅ","k":1} +{"g":"single","s":"ಌ","k":1} +{"g":"single","s":"ಎ","k":1} +{"g":"single","s":"ಐ","k":1} +{"g":"single","s":"ಒ","k":1} +{"g":"single","s":"ನ","k":1} +{"g":"single","s":"ಪ","k":1} +{"g":"single","s":"ಳ","k":1} +{"g":"single","s":"ವ","k":1} +{"g":"single","s":"ಹ","k":1} +{"g":"single","s":"಼","k":0} +{"g":"single","s":"ಽ","k":1} +{"g":"single","s":"ಿ","k":0} +{"g":"single","s":"ೆ","k":0} +{"g":"single","s":"ೈ","d":"ೈ","k":0} +{"g":"single","s":"ೌ","k":0} +{"g":"single","s":"್","k":0} +{"g":"single","s":"೜","k":1} +{"g":"single","s":"ೞ","k":1} +{"g":"single","s":"ೠ","k":1} +{"g":"single","s":"ೡ","k":1} +{"g":"single","s":"ೢ","k":0} +{"g":"single","s":"ೣ","k":0} +{"g":"single","s":"ೱ","k":1} +{"g":"single","s":"ೲ","k":1} +{"g":"single","s":"ഀ","k":0} +{"g":"single","s":"ഁ","k":0} +{"g":"single","s":"ഄ","k":1} +{"g":"single","s":"ഌ","k":1} +{"g":"single","s":"എ","k":1} +{"g":"single","s":"ഐ","k":1} +{"g":"single","s":"ഒ","k":1} +{"g":"single","s":"ഺ","k":1} +{"g":"single","s":"഻","k":0} +{"g":"single","s":"഼","k":0} +{"g":"single","s":"ഽ","k":1} +{"g":"single","s":"ു","k":0} +{"g":"single","s":"ൄ","k":0} +{"g":"single","s":"്","k":0} +{"g":"single","s":"ൎ","k":1} +{"g":"single","s":"ൔ","k":1} +{"g":"single","s":"ൖ","k":1} +{"g":"single","s":"ൗ","k":0} +{"g":"single","s":"ൟ","k":1} +{"g":"single","s":"ൡ","k":1} +{"g":"single","s":"ൢ","k":0} +{"g":"single","s":"ൣ","k":0} +{"g":"single","s":"ൺ","k":1} +{"g":"single","s":"ൿ","k":1} +{"g":"single","s":"ඁ","k":0} +{"g":"single","s":"අ","k":1} +{"g":"single","s":"ඖ","k":1} +{"g":"single","s":"ක","k":1} +{"g":"single","s":"න","k":1} +{"g":"single","s":"ඳ","k":1} +{"g":"single","s":"ර","k":1} +{"g":"single","s":"ල","k":1} +{"g":"single","s":"ව","k":1} +{"g":"single","s":"ෆ","k":1} +{"g":"single","s":"්","k":0} +{"g":"single","s":"ි","k":0} +{"g":"single","s":"ු","k":0} +{"g":"single","s":"ූ","k":0} +{"g":"single","s":"ෝ","d":"ෝ","k":0} +{"g":"single","s":"ก","k":1} +{"g":"single","s":"ะ","k":1} +{"g":"single","s":"ั","k":0} +{"g":"single","s":"า","k":1} +{"g":"single","s":"ำ","k":1} +{"g":"single","s":"ิ","k":0} +{"g":"single","s":"ฺ","k":0} +{"g":"single","s":"เ","k":1} +{"g":"single","s":"ๆ","k":1} +{"g":"single","s":"่","k":0} +{"g":"single","s":"๎","k":0} +{"g":"single","s":"ກ","k":1} +{"g":"single","s":"ຂ","k":1} +{"g":"single","s":"ຄ","k":1} +{"g":"single","s":"ຆ","k":1} +{"g":"single","s":"ຊ","k":1} +{"g":"single","s":"ຌ","k":1} +{"g":"single","s":"ຣ","k":1} +{"g":"single","s":"ລ","k":1} +{"g":"single","s":"ວ","k":1} +{"g":"single","s":"ະ","k":1} +{"g":"single","s":"ັ","k":0} +{"g":"single","s":"າ","k":1} +{"g":"single","s":"ຳ","k":1} +{"g":"single","s":"ິ","k":0} +{"g":"single","s":"ຼ","k":0} +{"g":"single","s":"ຽ","k":1} +{"g":"single","s":"ເ","k":1} +{"g":"single","s":"ໄ","k":1} +{"g":"single","s":"ໆ","k":1} +{"g":"single","s":"່","k":0} +{"g":"single","s":"້","k":0} +{"g":"single","s":"໎","k":0} +{"g":"single","s":"ໜ","k":1} +{"g":"single","s":"ໟ","k":1} +{"g":"single","s":"ༀ","k":1} +{"g":"single","s":"༘","k":0} +{"g":"single","s":"༙","k":0} +{"g":"single","s":"༵","k":0} +{"g":"single","s":"༷","k":0} +{"g":"single","s":"༹","k":0} +{"g":"single","s":"ཀ","k":1} +{"g":"single","s":"གྷ","c":"གྷ","d":"གྷ","k":1} +{"g":"single","s":"ཇ","k":1} +{"g":"single","s":"ཉ","k":1} +{"g":"single","s":"ཌྷ","c":"ཌྷ","d":"ཌྷ","k":1} +{"g":"single","s":"དྷ","c":"དྷ","d":"དྷ","k":1} +{"g":"single","s":"བྷ","c":"བྷ","d":"བྷ","k":1} +{"g":"single","s":"ཛྷ","c":"ཛྷ","d":"ཛྷ","k":1} +{"g":"single","s":"ཀྵ","c":"ཀྵ","d":"ཀྵ","k":1} +{"g":"single","s":"ཬ","k":1} +{"g":"single","s":"ཱ","k":0} +{"g":"single","s":"ཱི","c":"ཱི","d":"ཱི","k":0} +{"g":"single","s":"ཱུ","c":"ཱུ","d":"ཱུ","k":0} +{"g":"single","s":"ྲྀ","c":"ྲྀ","d":"ྲྀ","k":0} +{"g":"single","s":"ླྀ","c":"ླྀ","d":"ླྀ","k":0} +{"g":"single","s":"ཾ","k":0} +{"g":"single","s":"ྀ","k":0} +{"g":"single","s":"ཱྀ","c":"ཱྀ","d":"ཱྀ","k":0} +{"g":"single","s":"ྂ","k":0} +{"g":"single","s":"྄","k":0} +{"g":"single","s":"྆","k":0} +{"g":"single","s":"྇","k":0} +{"g":"single","s":"ྈ","k":1} +{"g":"single","s":"ྌ","k":1} +{"g":"single","s":"ྍ","k":0} +{"g":"single","s":"ྒྷ","c":"ྒྷ","d":"ྒྷ","k":0} +{"g":"single","s":"ྗ","k":0} +{"g":"single","s":"ྙ","k":0} +{"g":"single","s":"ྜྷ","c":"ྜྷ","d":"ྜྷ","k":0} +{"g":"single","s":"ྡྷ","c":"ྡྷ","d":"ྡྷ","k":0} +{"g":"single","s":"ྦྷ","c":"ྦྷ","d":"ྦྷ","k":0} +{"g":"single","s":"ྫྷ","c":"ྫྷ","d":"ྫྷ","k":0} +{"g":"single","s":"ྐྵ","c":"ྐྵ","d":"ྐྵ","k":0} +{"g":"single","s":"ྼ","k":0} +{"g":"single","s":"࿆","k":0} +{"g":"single","s":"က","k":1} +{"g":"single","s":"ဪ","k":1} +{"g":"single","s":"ိ","k":0} +{"g":"single","s":"ူ","k":0} +{"g":"single","s":"ဲ","k":0} +{"g":"single","s":"့","k":0} +{"g":"single","s":"္","k":0} +{"g":"single","s":"်","k":0} +{"g":"single","s":"ွ","k":0} +{"g":"single","s":"ှ","k":0} +{"g":"single","s":"ဿ","k":1} +{"g":"single","s":"ၐ","k":1} +{"g":"single","s":"ၕ","k":1} +{"g":"single","s":"ၘ","k":0} +{"g":"single","s":"ၙ","k":0} +{"g":"single","s":"ၚ","k":1} +{"g":"single","s":"ၝ","k":1} +{"g":"single","s":"ၞ","k":0} +{"g":"single","s":"ၠ","k":0} +{"g":"single","s":"ၡ","k":1} +{"g":"single","s":"ၥ","k":1} +{"g":"single","s":"ၦ","k":1} +{"g":"single","s":"ၮ","k":1} +{"g":"single","s":"ၰ","k":1} +{"g":"single","s":"ၱ","k":0} +{"g":"single","s":"ၴ","k":0} +{"g":"single","s":"ၵ","k":1} +{"g":"single","s":"ႁ","k":1} +{"g":"single","s":"ႂ","k":0} +{"g":"single","s":"ႅ","k":0} +{"g":"single","s":"ႆ","k":0} +{"g":"single","s":"ႍ","k":0} +{"g":"single","s":"ႎ","k":1} +{"g":"single","s":"ႝ","k":0} +{"g":"single","s":"Ⴀ","l":"ⴀ","k":3} +{"g":"single","s":"Ⴥ","l":"ⴥ","k":3} +{"g":"single","s":"Ⴧ","l":"ⴧ","k":3} +{"g":"single","s":"Ⴭ","l":"ⴭ","k":3} +{"g":"single","s":"ა","k":1} +{"g":"single","s":"ჺ","k":1} +{"g":"single","s":"ჼ","k":1} +{"g":"single","s":"ჿ","k":1} +{"g":"single","s":"ቈ","k":1} +{"g":"single","s":"ቊ","k":1} +{"g":"single","s":"ቍ","k":1} +{"g":"single","s":"ቐ","k":1} +{"g":"single","s":"ቖ","k":1} +{"g":"single","s":"ቘ","k":1} +{"g":"single","s":"ቚ","k":1} +{"g":"single","s":"ቝ","k":1} +{"g":"single","s":"በ","k":1} +{"g":"single","s":"ኈ","k":1} +{"g":"single","s":"ኊ","k":1} +{"g":"single","s":"ኍ","k":1} +{"g":"single","s":"ነ","k":1} +{"g":"single","s":"ኰ","k":1} +{"g":"single","s":"ኲ","k":1} +{"g":"single","s":"ኵ","k":1} +{"g":"single","s":"ኸ","k":1} +{"g":"single","s":"ኾ","k":1} +{"g":"single","s":"ዀ","k":1} +{"g":"single","s":"ዂ","k":1} +{"g":"single","s":"ዅ","k":1} +{"g":"single","s":"ወ","k":1} +{"g":"single","s":"ዖ","k":1} +{"g":"single","s":"ዘ","k":1} +{"g":"single","s":"ጐ","k":1} +{"g":"single","s":"ጒ","k":1} +{"g":"single","s":"ጕ","k":1} +{"g":"single","s":"ጘ","k":1} +{"g":"single","s":"ፚ","k":1} +{"g":"single","s":"፝","k":0} +{"g":"single","s":"፟","k":0} +{"g":"single","s":"ᎀ","k":1} +{"g":"single","s":"ᎇ","k":1} +{"g":"single","s":"ᎏ","k":1} +{"g":"single","s":"Ꭰ","l":"ꭰ","k":3} +{"g":"single","s":"Ᏽ","l":"ᏽ","k":3} +{"g":"single","s":"ᏸ","k":1} +{"g":"single","s":"ᏽ","k":1} +{"g":"single","s":"ᐁ","k":1} +{"g":"single","s":"ᙬ","k":1} +{"g":"single","s":"ᙯ","k":1} +{"g":"single","s":"ᙿ","k":1} +{"g":"single","s":"ᚁ","k":1} +{"g":"single","s":"ᚚ","k":1} +{"g":"single","s":"ᚠ","k":1} +{"g":"single","s":"ᛪ","k":1} +{"g":"single","s":"ᛱ","k":1} +{"g":"single","s":"ᛸ","k":1} +{"g":"single","s":"ᜀ","k":1} +{"g":"single","s":"ᜑ","k":1} +{"g":"single","s":"ᜒ","k":0} +{"g":"single","s":"᜔","k":0} +{"g":"single","s":"ᜟ","k":1} +{"g":"single","s":"ᜱ","k":1} +{"g":"single","s":"ᜲ","k":0} +{"g":"single","s":"ᜳ","k":0} +{"g":"single","s":"ᝀ","k":1} +{"g":"single","s":"ᝑ","k":1} +{"g":"single","s":"ᝒ","k":0} +{"g":"single","s":"ᝓ","k":0} +{"g":"single","s":"ᝠ","k":1} +{"g":"single","s":"ᝬ","k":1} +{"g":"single","s":"ᝮ","k":1} +{"g":"single","s":"ᝰ","k":1} +{"g":"single","s":"ᝲ","k":0} +{"g":"single","s":"ᝳ","k":0} +{"g":"single","s":"ក","k":1} +{"g":"single","s":"ឳ","k":1} +{"g":"single","s":"឴","k":0} +{"g":"single","s":"឵","k":0} +{"g":"single","s":"ិ","k":0} +{"g":"single","s":"ួ","k":0} +{"g":"single","s":"ំ","k":0} +{"g":"single","s":"៉","k":0} +{"g":"single","s":"្","k":0} +{"g":"single","s":"៓","k":0} +{"g":"single","s":"ៗ","k":1} +{"g":"single","s":"ៜ","k":1} +{"g":"single","s":"៝","k":0} +{"g":"single","s":"᠋","k":0} +{"g":"single","s":"᠏","k":0} +{"g":"single","s":"ᠠ","k":1} +{"g":"single","s":"ᡃ","k":1} +{"g":"single","s":"ᡸ","k":1} +{"g":"single","s":"ᢀ","k":1} +{"g":"single","s":"ᢄ","k":1} +{"g":"single","s":"ᢅ","k":0} +{"g":"single","s":"ᢆ","k":0} +{"g":"single","s":"ᢇ","k":1} +{"g":"single","s":"ᢨ","k":1} +{"g":"single","s":"ᢩ","k":0} +{"g":"single","s":"ᢪ","k":1} +{"g":"single","s":"ᢰ","k":1} +{"g":"single","s":"ᣵ","k":1} +{"g":"single","s":"ᤀ","k":1} +{"g":"single","s":"ᤞ","k":1} +{"g":"single","s":"ᤠ","k":0} +{"g":"single","s":"ᤢ","k":0} +{"g":"single","s":"ᤧ","k":0} +{"g":"single","s":"ᤨ","k":0} +{"g":"single","s":"ᤲ","k":0} +{"g":"single","s":"᤹","k":0} +{"g":"single","s":"᤻","k":0} +{"g":"single","s":"ᥐ","k":1} +{"g":"single","s":"ᥭ","k":1} +{"g":"single","s":"ᥰ","k":1} +{"g":"single","s":"ᥴ","k":1} +{"g":"single","s":"ᦀ","k":1} +{"g":"single","s":"ᦫ","k":1} +{"g":"single","s":"ᦰ","k":1} +{"g":"single","s":"ᧉ","k":1} +{"g":"single","s":"ᨀ","k":1} +{"g":"single","s":"ᨖ","k":1} +{"g":"single","s":"ᨗ","k":0} +{"g":"single","s":"ᨘ","k":0} +{"g":"single","s":"ᨛ","k":0} +{"g":"single","s":"ᨠ","k":1} +{"g":"single","s":"ᩔ","k":1} +{"g":"single","s":"ᩖ","k":0} +{"g":"single","s":"ᩘ","k":0} +{"g":"single","s":"ᩞ","k":0} +{"g":"single","s":"᩠","k":0} +{"g":"single","s":"ᩢ","k":0} +{"g":"single","s":"ᩥ","k":0} +{"g":"single","s":"ᩬ","k":0} +{"g":"single","s":"ᩳ","k":0} +{"g":"single","s":"᩼","k":0} +{"g":"single","s":"᩿","k":0} +{"g":"single","s":"ᪧ","k":1} +{"g":"single","s":"᪰","k":0} +{"g":"single","s":"᪶","k":0} +{"g":"single","s":"ᪿ","k":0} +{"g":"single","s":"᫇","k":0} +{"g":"single","s":"᫏","k":0} +{"g":"single","s":"᫗","k":0} +{"g":"single","s":"᫝","k":0} +{"g":"single","s":"᫠","k":0} +{"g":"single","s":"᫡","k":0} +{"g":"single","s":"᫩","k":0} +{"g":"single","s":"᫫","k":0} +{"g":"single","s":"ᬀ","k":0} +{"g":"single","s":"ᬃ","k":0} +{"g":"single","s":"ᬅ","k":1} +{"g":"single","s":"ᬎ","d":"ᬎ","k":1} +{"g":"single","s":"ᬳ","k":1} +{"g":"single","s":"᬴","k":0} +{"g":"single","s":"ᬵ","k":0} +{"g":"single","s":"ᬶ","k":0} +{"g":"single","s":"ᬺ","k":0} +{"g":"single","s":"ᬼ","k":0} +{"g":"single","s":"ᭂ","k":0} +{"g":"single","s":"ᭅ","k":1} +{"g":"single","s":"ᭌ","k":1} +{"g":"single","s":"᭫","k":0} +{"g":"single","s":"᭮","k":0} +{"g":"single","s":"᭳","k":0} +{"g":"single","s":"ᮀ","k":0} +{"g":"single","s":"ᮁ","k":0} +{"g":"single","s":"ᮃ","k":1} +{"g":"single","s":"ᮠ","k":1} +{"g":"single","s":"ᮢ","k":0} +{"g":"single","s":"ᮥ","k":0} +{"g":"single","s":"ᮨ","k":0} +{"g":"single","s":"ᮩ","k":0} +{"g":"single","s":"᮫","k":0} +{"g":"single","s":"ᮭ","k":0} +{"g":"single","s":"ᮮ","k":1} +{"g":"single","s":"ᮯ","k":1} +{"g":"single","s":"ᮺ","k":1} +{"g":"single","s":"ᯥ","k":1} +{"g":"single","s":"᯦","k":0} +{"g":"single","s":"ᯨ","k":0} +{"g":"single","s":"ᯩ","k":0} +{"g":"single","s":"ᯭ","k":0} +{"g":"single","s":"ᯯ","k":0} +{"g":"single","s":"ᯱ","k":0} +{"g":"single","s":"ᰀ","k":1} +{"g":"single","s":"ᰣ","k":1} +{"g":"single","s":"ᰬ","k":0} +{"g":"single","s":"ᰳ","k":0} +{"g":"single","s":"ᰶ","k":0} +{"g":"single","s":"᰷","k":0} +{"g":"single","s":"ᱍ","k":1} +{"g":"single","s":"ᱏ","k":1} +{"g":"single","s":"ᱚ","k":1} +{"g":"single","s":"ᱸ","k":1} +{"g":"single","s":"ᱽ","k":1} +{"g":"single","s":"ᲀ","k":1} +{"g":"single","s":"Ᲊ","l":"ᲊ","k":3} +{"g":"single","s":"ᲊ","k":1} +{"g":"single","s":"Ა","l":"ა","k":3} +{"g":"single","s":"Ჺ","l":"ჺ","k":3} +{"g":"single","s":"Ჽ","l":"ჽ","k":3} +{"g":"single","s":"Ჿ","l":"ჿ","k":3} +{"g":"single","s":"᳐","k":0} +{"g":"single","s":"᳒","k":0} +{"g":"single","s":"᳔","k":0} +{"g":"single","s":"᳕","k":0} +{"g":"single","s":"᳝","k":0} +{"g":"single","s":"᳠","k":0} +{"g":"single","s":"᳢","k":0} +{"g":"single","s":"᳦","k":0} +{"g":"single","s":"᳨","k":0} +{"g":"single","s":"ᳩ","k":1} +{"g":"single","s":"ᳬ","k":1} +{"g":"single","s":"᳭","k":0} +{"g":"single","s":"ᳮ","k":1} +{"g":"single","s":"ᳳ","k":1} +{"g":"single","s":"᳴","k":0} +{"g":"single","s":"ᳵ","k":1} +{"g":"single","s":"ᳶ","k":1} +{"g":"single","s":"᳸","k":0} +{"g":"single","s":"᳹","k":0} +{"g":"single","s":"ᳺ","k":1} +{"g":"single","s":"ᴀ","k":1} +{"g":"single","s":"ᴬ","k":1} +{"g":"single","s":"ᵪ","k":1} +{"g":"single","s":"ᵸ","k":1} +{"g":"single","s":"ᶛ","k":1} +{"g":"single","s":"ᶿ","k":1} +{"g":"single","s":"᷁","k":0} +{"g":"single","s":"᷉","k":0} +{"g":"single","s":"᷑","k":0} +{"g":"single","s":"ᷙ","k":0} +{"g":"single","s":"ᷡ","k":0} +{"g":"single","s":"ᷩ","k":0} +{"g":"single","s":"ᷱ","k":0} +{"g":"single","s":"᷹","k":0} +{"g":"single","s":"᷿","k":0} +{"g":"single","s":"Ḁ","d":"Ḁ","l":"ḁ","k":3} +{"g":"single","s":"ḁ","d":"ḁ","k":1} +{"g":"single","s":"Ḃ","d":"Ḃ","l":"ḃ","k":3} +{"g":"single","s":"Ḅ","d":"Ḅ","l":"ḅ","k":3} +{"g":"single","s":"Ḇ","d":"Ḇ","l":"ḇ","k":3} +{"g":"single","s":"Ḉ","d":"Ḉ","l":"ḉ","k":3} +{"g":"single","s":"ḉ","d":"ḉ","k":1} +{"g":"single","s":"Ḋ","d":"Ḋ","l":"ḋ","k":3} +{"g":"single","s":"Ḍ","d":"Ḍ","l":"ḍ","k":3} +{"g":"single","s":"Ḏ","d":"Ḏ","l":"ḏ","k":3} +{"g":"single","s":"Ḑ","d":"Ḑ","l":"ḑ","k":3} +{"g":"single","s":"ḑ","d":"ḑ","k":1} +{"g":"single","s":"Ḓ","d":"Ḓ","l":"ḓ","k":3} +{"g":"single","s":"Ḕ","d":"Ḕ","l":"ḕ","k":3} +{"g":"single","s":"Ḗ","d":"Ḗ","l":"ḗ","k":3} +{"g":"single","s":"Ḙ","d":"Ḙ","l":"ḙ","k":3} +{"g":"single","s":"ḙ","d":"ḙ","k":1} +{"g":"single","s":"Ḛ","d":"Ḛ","l":"ḛ","k":3} +{"g":"single","s":"Ḝ","d":"Ḝ","l":"ḝ","k":3} +{"g":"single","s":"Ḟ","d":"Ḟ","l":"ḟ","k":3} +{"g":"single","s":"Ḡ","d":"Ḡ","l":"ḡ","k":3} +{"g":"single","s":"ḡ","d":"ḡ","k":1} +{"g":"single","s":"Ḣ","d":"Ḣ","l":"ḣ","k":3} +{"g":"single","s":"Ḥ","d":"Ḥ","l":"ḥ","k":3} +{"g":"single","s":"Ḧ","d":"Ḧ","l":"ḧ","k":3} +{"g":"single","s":"Ḩ","d":"Ḩ","l":"ḩ","k":3} +{"g":"single","s":"ḩ","d":"ḩ","k":1} +{"g":"single","s":"Ḫ","d":"Ḫ","l":"ḫ","k":3} +{"g":"single","s":"Ḭ","d":"Ḭ","l":"ḭ","k":3} +{"g":"single","s":"Ḯ","d":"Ḯ","l":"ḯ","k":3} +{"g":"single","s":"Ḱ","d":"Ḱ","l":"ḱ","k":3} +{"g":"single","s":"ḱ","d":"ḱ","k":1} +{"g":"single","s":"Ḳ","d":"Ḳ","l":"ḳ","k":3} +{"g":"single","s":"Ḵ","d":"Ḵ","l":"ḵ","k":3} +{"g":"single","s":"Ḷ","d":"Ḷ","l":"ḷ","k":3} +{"g":"single","s":"Ḹ","d":"Ḹ","l":"ḹ","k":3} +{"g":"single","s":"ḹ","d":"ḹ","k":1} +{"g":"single","s":"Ḻ","d":"Ḻ","l":"ḻ","k":3} +{"g":"single","s":"Ḽ","d":"Ḽ","l":"ḽ","k":3} +{"g":"single","s":"Ḿ","d":"Ḿ","l":"ḿ","k":3} +{"g":"single","s":"Ṁ","d":"Ṁ","l":"ṁ","k":3} +{"g":"single","s":"ṁ","d":"ṁ","k":1} +{"g":"single","s":"Ṃ","d":"Ṃ","l":"ṃ","k":3} +{"g":"single","s":"Ṅ","d":"Ṅ","l":"ṅ","k":3} +{"g":"single","s":"Ṇ","d":"Ṇ","l":"ṇ","k":3} +{"g":"single","s":"Ṉ","d":"Ṉ","l":"ṉ","k":3} +{"g":"single","s":"ṉ","d":"ṉ","k":1} +{"g":"single","s":"Ṋ","d":"Ṋ","l":"ṋ","k":3} +{"g":"single","s":"Ṍ","d":"Ṍ","l":"ṍ","k":3} +{"g":"single","s":"Ṏ","d":"Ṏ","l":"ṏ","k":3} +{"g":"single","s":"Ṑ","d":"Ṑ","l":"ṑ","k":3} +{"g":"single","s":"ṑ","d":"ṑ","k":1} +{"g":"single","s":"Ṓ","d":"Ṓ","l":"ṓ","k":3} +{"g":"single","s":"Ṕ","d":"Ṕ","l":"ṕ","k":3} +{"g":"single","s":"Ṗ","d":"Ṗ","l":"ṗ","k":3} +{"g":"single","s":"Ṙ","d":"Ṙ","l":"ṙ","k":3} +{"g":"single","s":"ṙ","d":"ṙ","k":1} +{"g":"single","s":"Ṛ","d":"Ṛ","l":"ṛ","k":3} +{"g":"single","s":"Ṝ","d":"Ṝ","l":"ṝ","k":3} +{"g":"single","s":"Ṟ","d":"Ṟ","l":"ṟ","k":3} +{"g":"single","s":"Ṡ","d":"Ṡ","l":"ṡ","k":3} +{"g":"single","s":"ṡ","d":"ṡ","k":1} +{"g":"single","s":"Ṣ","d":"Ṣ","l":"ṣ","k":3} +{"g":"single","s":"Ṥ","d":"Ṥ","l":"ṥ","k":3} +{"g":"single","s":"Ṧ","d":"Ṧ","l":"ṧ","k":3} +{"g":"single","s":"Ṩ","d":"Ṩ","l":"ṩ","k":3} +{"g":"single","s":"ṩ","d":"ṩ","k":1} +{"g":"single","s":"Ṫ","d":"Ṫ","l":"ṫ","k":3} +{"g":"single","s":"Ṭ","d":"Ṭ","l":"ṭ","k":3} +{"g":"single","s":"Ṯ","d":"Ṯ","l":"ṯ","k":3} +{"g":"single","s":"Ṱ","d":"Ṱ","l":"ṱ","k":3} +{"g":"single","s":"ṱ","d":"ṱ","k":1} +{"g":"single","s":"Ṳ","d":"Ṳ","l":"ṳ","k":3} +{"g":"single","s":"Ṵ","d":"Ṵ","l":"ṵ","k":3} +{"g":"single","s":"Ṷ","d":"Ṷ","l":"ṷ","k":3} +{"g":"single","s":"Ṹ","d":"Ṹ","l":"ṹ","k":3} +{"g":"single","s":"ṹ","d":"ṹ","k":1} +{"g":"single","s":"Ṻ","d":"Ṻ","l":"ṻ","k":3} +{"g":"single","s":"Ṽ","d":"Ṽ","l":"ṽ","k":3} +{"g":"single","s":"Ṿ","d":"Ṿ","l":"ṿ","k":3} +{"g":"single","s":"Ẁ","d":"Ẁ","l":"ẁ","k":3} +{"g":"single","s":"ẁ","d":"ẁ","k":1} +{"g":"single","s":"Ẃ","d":"Ẃ","l":"ẃ","k":3} +{"g":"single","s":"Ẅ","d":"Ẅ","l":"ẅ","k":3} +{"g":"single","s":"Ẇ","d":"Ẇ","l":"ẇ","k":3} +{"g":"single","s":"Ẉ","d":"Ẉ","l":"ẉ","k":3} +{"g":"single","s":"ẉ","d":"ẉ","k":1} +{"g":"single","s":"Ẋ","d":"Ẋ","l":"ẋ","k":3} +{"g":"single","s":"Ẍ","d":"Ẍ","l":"ẍ","k":3} +{"g":"single","s":"Ẏ","d":"Ẏ","l":"ẏ","k":3} +{"g":"single","s":"Ẑ","d":"Ẑ","l":"ẑ","k":3} +{"g":"single","s":"ẑ","d":"ẑ","k":1} +{"g":"single","s":"Ẓ","d":"Ẓ","l":"ẓ","k":3} +{"g":"single","s":"Ẕ","d":"Ẕ","l":"ẕ","k":3} +{"g":"single","s":"ẙ","d":"ẙ","k":1} +{"g":"single","s":"ẞ","l":"ß","k":3} +{"g":"single","s":"Ạ","d":"Ạ","l":"ạ","k":3} +{"g":"single","s":"Ả","d":"Ả","l":"ả","k":3} +{"g":"single","s":"Ấ","d":"Ấ","l":"ấ","k":3} +{"g":"single","s":"Ầ","d":"Ầ","l":"ầ","k":3} +{"g":"single","s":"Ẩ","d":"Ẩ","l":"ẩ","k":3} +{"g":"single","s":"Ẫ","d":"Ẫ","l":"ẫ","k":3} +{"g":"single","s":"Ậ","d":"Ậ","l":"ậ","k":3} +{"g":"single","s":"Ắ","d":"Ắ","l":"ắ","k":3} +{"g":"single","s":"Ằ","d":"Ằ","l":"ằ","k":3} +{"g":"single","s":"Ẳ","d":"Ẳ","l":"ẳ","k":3} +{"g":"single","s":"Ẵ","d":"Ẵ","l":"ẵ","k":3} +{"g":"single","s":"Ặ","d":"Ặ","l":"ặ","k":3} +{"g":"single","s":"Ẹ","d":"Ẹ","l":"ẹ","k":3} +{"g":"single","s":"Ẻ","d":"Ẻ","l":"ẻ","k":3} +{"g":"single","s":"Ẽ","d":"Ẽ","l":"ẽ","k":3} +{"g":"single","s":"Ế","d":"Ế","l":"ế","k":3} +{"g":"single","s":"Ề","d":"Ề","l":"ề","k":3} +{"g":"single","s":"Ể","d":"Ể","l":"ể","k":3} +{"g":"single","s":"Ễ","d":"Ễ","l":"ễ","k":3} +{"g":"single","s":"Ệ","d":"Ệ","l":"ệ","k":3} +{"g":"single","s":"Ỉ","d":"Ỉ","l":"ỉ","k":3} +{"g":"single","s":"Ị","d":"Ị","l":"ị","k":3} +{"g":"single","s":"Ọ","d":"Ọ","l":"ọ","k":3} +{"g":"single","s":"Ỏ","d":"Ỏ","l":"ỏ","k":3} +{"g":"single","s":"Ố","d":"Ố","l":"ố","k":3} +{"g":"single","s":"Ồ","d":"Ồ","l":"ồ","k":3} +{"g":"single","s":"Ổ","d":"Ổ","l":"ổ","k":3} +{"g":"single","s":"Ỗ","d":"Ỗ","l":"ỗ","k":3} +{"g":"single","s":"Ộ","d":"Ộ","l":"ộ","k":3} +{"g":"single","s":"Ớ","d":"Ớ","l":"ớ","k":3} +{"g":"single","s":"Ờ","d":"Ờ","l":"ờ","k":3} +{"g":"single","s":"Ở","d":"Ở","l":"ở","k":3} +{"g":"single","s":"Ỡ","d":"Ỡ","l":"ỡ","k":3} +{"g":"single","s":"Ợ","d":"Ợ","l":"ợ","k":3} +{"g":"single","s":"Ụ","d":"Ụ","l":"ụ","k":3} +{"g":"single","s":"Ủ","d":"Ủ","l":"ủ","k":3} +{"g":"single","s":"Ứ","d":"Ứ","l":"ứ","k":3} +{"g":"single","s":"Ừ","d":"Ừ","l":"ừ","k":3} +{"g":"single","s":"Ử","d":"Ử","l":"ử","k":3} +{"g":"single","s":"Ữ","d":"Ữ","l":"ữ","k":3} +{"g":"single","s":"Ự","d":"Ự","l":"ự","k":3} +{"g":"single","s":"Ỳ","d":"Ỳ","l":"ỳ","k":3} +{"g":"single","s":"Ỵ","d":"Ỵ","l":"ỵ","k":3} +{"g":"single","s":"Ỷ","d":"Ỷ","l":"ỷ","k":3} +{"g":"single","s":"Ỹ","d":"Ỹ","l":"ỹ","k":3} +{"g":"single","s":"Ỻ","l":"ỻ","k":3} +{"g":"single","s":"Ỽ","l":"ỽ","k":3} +{"g":"single","s":"Ỿ","l":"ỿ","k":3} +{"g":"single","s":"ἄ","d":"ἄ","k":1} +{"g":"single","s":"Ἀ","d":"Ἀ","l":"ἀ","k":3} +{"g":"single","s":"Ἄ","d":"Ἄ","l":"ἄ","k":3} +{"g":"single","s":"Ἇ","d":"Ἇ","l":"ἇ","k":3} +{"g":"single","s":"ἔ","d":"ἔ","k":1} +{"g":"single","s":"ἕ","d":"ἕ","k":1} +{"g":"single","s":"Ἐ","d":"Ἐ","l":"ἐ","k":3} +{"g":"single","s":"Ἕ","d":"Ἕ","l":"ἕ","k":3} +{"g":"single","s":"ἠ","d":"ἠ","k":1} +{"g":"single","s":"Ἠ","d":"Ἠ","l":"ἠ","k":3} +{"g":"single","s":"Ἧ","d":"Ἧ","l":"ἧ","k":3} +{"g":"single","s":"ἰ","d":"ἰ","k":1} +{"g":"single","s":"Ἰ","d":"Ἰ","l":"ἰ","k":3} +{"g":"single","s":"Ἷ","d":"Ἷ","l":"ἷ","k":3} +{"g":"single","s":"ὀ","d":"ὀ","k":1} +{"g":"single","s":"ὅ","d":"ὅ","k":1} +{"g":"single","s":"Ὀ","d":"Ὀ","l":"ὀ","k":3} +{"g":"single","s":"Ὂ","d":"Ὂ","l":"ὂ","k":3} +{"g":"single","s":"Ὅ","d":"Ὅ","l":"ὅ","k":3} +{"g":"single","s":"ὐ","d":"ὐ","k":1} +{"g":"single","s":"ὔ","d":"ὔ","k":1} +{"g":"single","s":"ὗ","d":"ὗ","k":1} +{"g":"single","s":"Ὑ","d":"Ὑ","l":"ὑ","k":3} +{"g":"single","s":"Ὓ","d":"Ὓ","l":"ὓ","k":3} +{"g":"single","s":"Ὕ","d":"Ὕ","l":"ὕ","k":3} +{"g":"single","s":"Ὗ","d":"Ὗ","l":"ὗ","k":3} +{"g":"single","s":"ὠ","d":"ὠ","k":1} +{"g":"single","s":"Ὠ","d":"Ὠ","l":"ὠ","k":3} +{"g":"single","s":"Ὧ","d":"Ὧ","l":"ὧ","k":3} +{"g":"single","s":"ὰ","d":"ὰ","k":1} +{"g":"single","s":"ά","c":"ά","d":"ά","k":1} +{"g":"single","s":"έ","c":"έ","d":"έ","k":1} +{"g":"single","s":"ή","c":"ή","d":"ή","k":1} +{"g":"single","s":"ί","c":"ί","d":"ί","k":1} +{"g":"single","s":"ὸ","d":"ὸ","k":1} +{"g":"single","s":"ό","c":"ό","d":"ό","k":1} +{"g":"single","s":"ύ","c":"ύ","d":"ύ","k":1} +{"g":"single","s":"ώ","c":"ώ","d":"ώ","k":1} +{"g":"single","s":"ᾀ","d":"ᾀ","k":1} +{"g":"single","s":"ᾂ","d":"ᾂ","k":1} +{"g":"single","s":"ᾈ","d":"ᾈ","l":"ᾀ","k":1} +{"g":"single","s":"ᾊ","d":"ᾊ","l":"ᾂ","k":1} +{"g":"single","s":"ᾒ","d":"ᾒ","k":1} +{"g":"single","s":"ᾚ","d":"ᾚ","l":"ᾒ","k":1} +{"g":"single","s":"ᾢ","d":"ᾢ","k":1} +{"g":"single","s":"ᾪ","d":"ᾪ","l":"ᾢ","k":1} +{"g":"single","s":"ᾲ","d":"ᾲ","k":1} +{"g":"single","s":"ᾴ","d":"ᾴ","k":1} +{"g":"single","s":"ᾶ","d":"ᾶ","k":1} +{"g":"single","s":"Ᾰ","d":"Ᾰ","l":"ᾰ","k":3} +{"g":"single","s":"Ὰ","d":"Ὰ","l":"ὰ","k":3} +{"g":"single","s":"Ά","c":"Ά","d":"Ά","l":"ά","k":3} +{"g":"single","s":"ᾼ","d":"ᾼ","l":"ᾳ","k":1} +{"g":"single","s":"᾽","k":0} +{"g":"single","s":"ι","c":"ι","d":"ι","k":1} +{"g":"single","s":"᾿","k":0} +{"g":"single","s":"῁","d":"῁","k":0} +{"g":"single","s":"ῂ","d":"ῂ","k":1} +{"g":"single","s":"ῄ","d":"ῄ","k":1} +{"g":"single","s":"ῆ","d":"ῆ","k":1} +{"g":"single","s":"ῇ","d":"ῇ","k":1} +{"g":"single","s":"Ὲ","d":"Ὲ","l":"ὲ","k":3} +{"g":"single","s":"Έ","c":"Έ","d":"Έ","l":"έ","k":3} +{"g":"single","s":"Ή","c":"Ή","d":"Ή","l":"ή","k":3} +{"g":"single","s":"ῌ","d":"ῌ","l":"ῃ","k":1} +{"g":"single","s":"῍","d":"῍","k":0} +{"g":"single","s":"῏","d":"῏","k":0} +{"g":"single","s":"ῐ","d":"ῐ","k":1} +{"g":"single","s":"ΐ","c":"ΐ","d":"ΐ","k":1} +{"g":"single","s":"ῖ","d":"ῖ","k":1} +{"g":"single","s":"Ῐ","d":"Ῐ","l":"ῐ","k":3} +{"g":"single","s":"Ῑ","d":"Ῑ","l":"ῑ","k":3} +{"g":"single","s":"Ί","c":"Ί","d":"Ί","l":"ί","k":3} +{"g":"single","s":"῝","d":"῝","k":0} +{"g":"single","s":"῟","d":"῟","k":0} +{"g":"single","s":"ῠ","d":"ῠ","k":1} +{"g":"single","s":"ῢ","d":"ῢ","k":1} +{"g":"single","s":"ΰ","c":"ΰ","d":"ΰ","k":1} +{"g":"single","s":"Ῠ","d":"Ῠ","l":"ῠ","k":3} +{"g":"single","s":"Ὺ","d":"Ὺ","l":"ὺ","k":3} +{"g":"single","s":"Ύ","c":"Ύ","d":"Ύ","l":"ύ","k":3} +{"g":"single","s":"Ῥ","d":"Ῥ","l":"ῥ","k":3} +{"g":"single","s":"῭","d":"῭","k":0} +{"g":"single","s":"΅","c":"΅","d":"΅","k":0} +{"g":"single","s":"`","c":"`","d":"`","k":0} +{"g":"single","s":"ῲ","d":"ῲ","k":1} +{"g":"single","s":"ῴ","d":"ῴ","k":1} +{"g":"single","s":"ῶ","d":"ῶ","k":1} +{"g":"single","s":"Ὸ","d":"Ὸ","l":"ὸ","k":3} +{"g":"single","s":"Ό","c":"Ό","d":"Ό","l":"ό","k":3} +{"g":"single","s":"Ώ","c":"Ώ","d":"Ώ","l":"ώ","k":3} +{"g":"single","s":"ῼ","d":"ῼ","l":"ῳ","k":1} +{"g":"single","s":"´","c":"´","d":"´","k":0} +{"g":"single","s":"῾","k":0} +{"g":"single","s":" ","c":" ","d":" ","k":0} +{"g":"single","s":" ","c":" ","d":" ","k":0} +{"g":"single","s":"​","k":0} +{"g":"single","s":"‏","k":0} +{"g":"single","s":"‘","k":0} +{"g":"single","s":"’","k":0} +{"g":"single","s":"․","k":0} +{"g":"single","s":"‧","k":0} +{"g":"single","s":"‪","k":0} +{"g":"single","s":"‮","k":0} +{"g":"single","s":"⁠","k":0} +{"g":"single","s":"⁤","k":0} +{"g":"single","s":"⁦","k":0} +{"g":"single","s":"","k":0} +{"g":"single","s":"ⁱ","k":1} +{"g":"single","s":"ⁿ","k":1} +{"g":"single","s":"ₐ","k":1} +{"g":"single","s":"ₜ","k":1} +{"g":"single","s":"⃐","k":0} +{"g":"single","s":"⃑","k":0} +{"g":"single","s":"⃙","k":0} +{"g":"single","s":"⃨","k":0} +{"g":"single","s":"⃰","k":0} +{"g":"single","s":"ℂ","k":3} +{"g":"single","s":"ℇ","k":3} +{"g":"single","s":"ℊ","k":1} +{"g":"single","s":"ℋ","k":3} +{"g":"single","s":"ℍ","k":3} +{"g":"single","s":"ℐ","k":3} +{"g":"single","s":"ℒ","k":3} +{"g":"single","s":"ℓ","k":1} +{"g":"single","s":"ℕ","k":3} +{"g":"single","s":"ℙ","k":3} +{"g":"single","s":"ℝ","k":3} +{"g":"single","s":"ℤ","k":3} +{"g":"single","s":"Ω","c":"Ω","d":"Ω","l":"ω","k":3} +{"g":"single","s":"ℨ","k":3} +{"g":"single","s":"K","c":"K","d":"K","l":"k","k":3} +{"g":"single","s":"Å","c":"Å","d":"Å","l":"å","k":3} +{"g":"single","s":"ℭ","k":3} +{"g":"single","s":"ℯ","k":1} +{"g":"single","s":"ℰ","k":3} +{"g":"single","s":"ℳ","k":3} +{"g":"single","s":"ℴ","k":1} +{"g":"single","s":"ℹ","k":1} +{"g":"single","s":"ℼ","k":1} +{"g":"single","s":"ℾ","k":3} +{"g":"single","s":"ℿ","k":3} +{"g":"single","s":"ⅅ","k":3} +{"g":"single","s":"ⅉ","k":1} +{"g":"single","s":"ⅎ","k":1} +{"g":"single","s":"Ⅰ","l":"ⅰ","k":0} +{"g":"single","s":"ⅿ","k":0} +{"g":"single","s":"Ↄ","l":"ↄ","k":3} +{"g":"single","s":"ↄ","k":1} +{"g":"single","s":"↮","d":"↮","k":0} +{"g":"single","s":"∦","d":"∦","k":0} +{"g":"single","s":"≮","d":"≮","k":0} +{"g":"single","s":"⊀","d":"⊀","k":0} +{"g":"single","s":"⊮","d":"⊮","k":0} +{"g":"single","s":"⋬","d":"⋬","k":0} +{"g":"single","s":"〈","c":"〈","d":"〈","k":0} +{"g":"single","s":"〉","c":"〉","d":"〉","k":0} +{"g":"single","s":"Ⓐ","l":"ⓐ","k":0} +{"g":"single","s":"ⓩ","k":0} +{"g":"single","s":"✎","k":0} +{"g":"single","s":"⫝̸","c":"⫝̸","d":"⫝̸","k":0} +{"g":"single","s":"Ⰰ","l":"ⰰ","k":3} +{"g":"single","s":"Ⱟ","l":"ⱟ","k":3} +{"g":"single","s":"Ⱡ","l":"ⱡ","k":3} +{"g":"single","s":"Ɫ","l":"ɫ","k":3} +{"g":"single","s":"Ɽ","l":"ɽ","k":3} +{"g":"single","s":"Ⱨ","l":"ⱨ","k":3} +{"g":"single","s":"Ⱪ","l":"ⱪ","k":3} +{"g":"single","s":"Ⱬ","l":"ⱬ","k":3} +{"g":"single","s":"Ɑ","l":"ɑ","k":3} +{"g":"single","s":"Ɒ","l":"ɒ","k":3} +{"g":"single","s":"Ⱳ","l":"ⱳ","k":3} +{"g":"single","s":"Ⱶ","l":"ⱶ","k":3} +{"g":"single","s":"ⱼ","k":1} +{"g":"single","s":"ⱽ","k":1} +{"g":"single","s":"Ȿ","l":"ȿ","k":3} +{"g":"single","s":"Ⲁ","l":"ⲁ","k":3} +{"g":"single","s":"Ⲃ","l":"ⲃ","k":3} +{"g":"single","s":"Ⲅ","l":"ⲅ","k":3} +{"g":"single","s":"Ⲇ","l":"ⲇ","k":3} +{"g":"single","s":"Ⲉ","l":"ⲉ","k":3} +{"g":"single","s":"Ⲋ","l":"ⲋ","k":3} +{"g":"single","s":"Ⲍ","l":"ⲍ","k":3} +{"g":"single","s":"Ⲏ","l":"ⲏ","k":3} +{"g":"single","s":"Ⲑ","l":"ⲑ","k":3} +{"g":"single","s":"Ⲓ","l":"ⲓ","k":3} +{"g":"single","s":"Ⲕ","l":"ⲕ","k":3} +{"g":"single","s":"Ⲗ","l":"ⲗ","k":3} +{"g":"single","s":"Ⲙ","l":"ⲙ","k":3} +{"g":"single","s":"Ⲛ","l":"ⲛ","k":3} +{"g":"single","s":"Ⲝ","l":"ⲝ","k":3} +{"g":"single","s":"Ⲟ","l":"ⲟ","k":3} +{"g":"single","s":"Ⲡ","l":"ⲡ","k":3} +{"g":"single","s":"Ⲣ","l":"ⲣ","k":3} +{"g":"single","s":"Ⲥ","l":"ⲥ","k":3} +{"g":"single","s":"Ⲧ","l":"ⲧ","k":3} +{"g":"single","s":"Ⲩ","l":"ⲩ","k":3} +{"g":"single","s":"Ⲫ","l":"ⲫ","k":3} +{"g":"single","s":"Ⲭ","l":"ⲭ","k":3} +{"g":"single","s":"Ⲯ","l":"ⲯ","k":3} +{"g":"single","s":"Ⲱ","l":"ⲱ","k":3} +{"g":"single","s":"Ⲳ","l":"ⲳ","k":3} +{"g":"single","s":"Ⲵ","l":"ⲵ","k":3} +{"g":"single","s":"Ⲷ","l":"ⲷ","k":3} +{"g":"single","s":"Ⲹ","l":"ⲹ","k":3} +{"g":"single","s":"Ⲻ","l":"ⲻ","k":3} +{"g":"single","s":"Ⲽ","l":"ⲽ","k":3} +{"g":"single","s":"Ⲿ","l":"ⲿ","k":3} +{"g":"single","s":"Ⳁ","l":"ⳁ","k":3} +{"g":"single","s":"Ⳃ","l":"ⳃ","k":3} +{"g":"single","s":"Ⳅ","l":"ⳅ","k":3} +{"g":"single","s":"Ⳇ","l":"ⳇ","k":3} +{"g":"single","s":"Ⳉ","l":"ⳉ","k":3} +{"g":"single","s":"Ⳋ","l":"ⳋ","k":3} +{"g":"single","s":"Ⳍ","l":"ⳍ","k":3} +{"g":"single","s":"Ⳏ","l":"ⳏ","k":3} +{"g":"single","s":"Ⳑ","l":"ⳑ","k":3} +{"g":"single","s":"Ⳓ","l":"ⳓ","k":3} +{"g":"single","s":"Ⳕ","l":"ⳕ","k":3} +{"g":"single","s":"Ⳗ","l":"ⳗ","k":3} +{"g":"single","s":"Ⳙ","l":"ⳙ","k":3} +{"g":"single","s":"Ⳛ","l":"ⳛ","k":3} +{"g":"single","s":"Ⳝ","l":"ⳝ","k":3} +{"g":"single","s":"Ⳟ","l":"ⳟ","k":3} +{"g":"single","s":"Ⳡ","l":"ⳡ","k":3} +{"g":"single","s":"Ⳣ","l":"ⳣ","k":3} +{"g":"single","s":"ⳤ","k":1} +{"g":"single","s":"Ⳬ","l":"ⳬ","k":3} +{"g":"single","s":"Ⳮ","l":"ⳮ","k":3} +{"g":"single","s":"ⳮ","k":1} +{"g":"single","s":"⳯","k":0} +{"g":"single","s":"⳱","k":0} +{"g":"single","s":"Ⳳ","l":"ⳳ","k":3} +{"g":"single","s":"ⳳ","k":1} +{"g":"single","s":"ⴀ","k":1} +{"g":"single","s":"ⴥ","k":1} +{"g":"single","s":"ⴧ","k":1} +{"g":"single","s":"ⴭ","k":1} +{"g":"single","s":"ⴰ","k":1} +{"g":"single","s":"ⵧ","k":1} +{"g":"single","s":"ⵯ","k":1} +{"g":"single","s":"⵿","k":0} +{"g":"single","s":"ⶀ","k":1} +{"g":"single","s":"ⶖ","k":1} +{"g":"single","s":"ⶠ","k":1} +{"g":"single","s":"ⶦ","k":1} +{"g":"single","s":"ⶨ","k":1} +{"g":"single","s":"ⶮ","k":1} +{"g":"single","s":"ⶰ","k":1} +{"g":"single","s":"ⶶ","k":1} +{"g":"single","s":"ⶸ","k":1} +{"g":"single","s":"ⶾ","k":1} +{"g":"single","s":"ⷀ","k":1} +{"g":"single","s":"ⷆ","k":1} +{"g":"single","s":"ⷈ","k":1} +{"g":"single","s":"ⷎ","k":1} +{"g":"single","s":"ⷐ","k":1} +{"g":"single","s":"ⷖ","k":1} +{"g":"single","s":"ⷘ","k":1} +{"g":"single","s":"ⷞ","k":1} +{"g":"single","s":"ⷠ","k":0} +{"g":"single","s":"ⷣ","k":0} +{"g":"single","s":"ⷫ","k":0} +{"g":"single","s":"ⷳ","k":0} +{"g":"single","s":"ⷻ","k":0} +{"g":"single","s":"ⷿ","k":0} +{"g":"single","s":"ⸯ","k":1} +{"g":"single","s":"々","k":1} +{"g":"single","s":"〆","k":1} +{"g":"single","s":"〪","k":0} +{"g":"single","s":"〭","k":0} +{"g":"single","s":"〱","k":1} +{"g":"single","s":"〵","k":1} +{"g":"single","s":"〻","k":1} +{"g":"single","s":"〼","k":1} +{"g":"single","s":"ぁ","k":1} +{"g":"single","s":"げ","d":"げ","k":1} +{"g":"single","s":"ぢ","d":"ぢ","k":1} +{"g":"single","s":"ぶ","d":"ぶ","k":1} +{"g":"single","s":"ゖ","k":1} +{"g":"single","s":"゙","k":0} +{"g":"single","s":"゚","k":0} +{"g":"single","s":"ゝ","k":1} +{"g":"single","s":"ゞ","d":"ゞ","k":1} +{"g":"single","s":"ゟ","k":1} +{"g":"single","s":"ァ","k":1} +{"g":"single","s":"ガ","d":"ガ","k":1} +{"g":"single","s":"ゼ","d":"ゼ","k":1} +{"g":"single","s":"パ","d":"パ","k":1} +{"g":"single","s":"ポ","d":"ポ","k":1} +{"g":"single","s":"ヺ","d":"ヺ","k":1} +{"g":"single","s":"ー","k":1} +{"g":"single","s":"ヾ","d":"ヾ","k":1} +{"g":"single","s":"ヿ","k":1} +{"g":"single","s":"ㄅ","k":1} +{"g":"single","s":"ㄯ","k":1} +{"g":"single","s":"ㄱ","k":1} +{"g":"single","s":"ㆎ","k":1} +{"g":"single","s":"ㆠ","k":1} +{"g":"single","s":"ㆿ","k":1} +{"g":"single","s":"ㇰ","k":1} +{"g":"single","s":"ㇿ","k":1} +{"g":"single","s":"㐀","k":1} +{"g":"single","s":"㪕","k":1} +{"g":"single","s":"䶿","k":1} +{"g":"single","s":"一","k":1} +{"g":"single","s":"东","k":1} +{"g":"single","s":"憣","k":1} +{"g":"single","s":"甪","k":1} +{"g":"single","s":"袱","k":1} +{"g":"single","s":"鰸","k":1} +{"g":"single","s":"ꀕ","k":1} +{"g":"single","s":"ꒌ","k":1} +{"g":"single","s":"ꓐ","k":1} +{"g":"single","s":"ꓸ","k":1} +{"g":"single","s":"ꓽ","k":1} +{"g":"single","s":"ꔀ","k":1} +{"g":"single","s":"ꘌ","k":1} +{"g":"single","s":"ꘐ","k":1} +{"g":"single","s":"ꘟ","k":1} +{"g":"single","s":"ꘪ","k":1} +{"g":"single","s":"ꘫ","k":1} +{"g":"single","s":"Ꙁ","l":"ꙁ","k":3} +{"g":"single","s":"Ꙃ","l":"ꙃ","k":3} +{"g":"single","s":"Ꙅ","l":"ꙅ","k":3} +{"g":"single","s":"Ꙇ","l":"ꙇ","k":3} +{"g":"single","s":"Ꙉ","l":"ꙉ","k":3} +{"g":"single","s":"Ꙋ","l":"ꙋ","k":3} +{"g":"single","s":"Ꙍ","l":"ꙍ","k":3} +{"g":"single","s":"Ꙏ","l":"ꙏ","k":3} +{"g":"single","s":"Ꙑ","l":"ꙑ","k":3} +{"g":"single","s":"Ꙓ","l":"ꙓ","k":3} +{"g":"single","s":"Ꙕ","l":"ꙕ","k":3} +{"g":"single","s":"Ꙗ","l":"ꙗ","k":3} +{"g":"single","s":"Ꙙ","l":"ꙙ","k":3} +{"g":"single","s":"Ꙛ","l":"ꙛ","k":3} +{"g":"single","s":"Ꙝ","l":"ꙝ","k":3} +{"g":"single","s":"Ꙟ","l":"ꙟ","k":3} +{"g":"single","s":"Ꙡ","l":"ꙡ","k":3} +{"g":"single","s":"Ꙣ","l":"ꙣ","k":3} +{"g":"single","s":"Ꙥ","l":"ꙥ","k":3} +{"g":"single","s":"Ꙧ","l":"ꙧ","k":3} +{"g":"single","s":"Ꙩ","l":"ꙩ","k":3} +{"g":"single","s":"Ꙫ","l":"ꙫ","k":3} +{"g":"single","s":"Ꙭ","l":"ꙭ","k":3} +{"g":"single","s":"ꙭ","k":1} +{"g":"single","s":"ꙮ","k":1} +{"g":"single","s":"꙯","k":0} +{"g":"single","s":"꙲","k":0} +{"g":"single","s":"ꙴ","k":0} +{"g":"single","s":"ꙶ","k":0} +{"g":"single","s":"꙽","k":0} +{"g":"single","s":"ꙿ","k":1} +{"g":"single","s":"Ꚁ","l":"ꚁ","k":3} +{"g":"single","s":"Ꚃ","l":"ꚃ","k":3} +{"g":"single","s":"Ꚅ","l":"ꚅ","k":3} +{"g":"single","s":"Ꚇ","l":"ꚇ","k":3} +{"g":"single","s":"Ꚉ","l":"ꚉ","k":3} +{"g":"single","s":"Ꚋ","l":"ꚋ","k":3} +{"g":"single","s":"Ꚍ","l":"ꚍ","k":3} +{"g":"single","s":"Ꚏ","l":"ꚏ","k":3} +{"g":"single","s":"Ꚑ","l":"ꚑ","k":3} +{"g":"single","s":"Ꚓ","l":"ꚓ","k":3} +{"g":"single","s":"Ꚕ","l":"ꚕ","k":3} +{"g":"single","s":"Ꚗ","l":"ꚗ","k":3} +{"g":"single","s":"Ꚙ","l":"ꚙ","k":3} +{"g":"single","s":"Ꚛ","l":"ꚛ","k":3} +{"g":"single","s":"ꚜ","k":1} +{"g":"single","s":"ꚝ","k":1} +{"g":"single","s":"ꚞ","k":0} +{"g":"single","s":"ꚟ","k":0} +{"g":"single","s":"ꚠ","k":1} +{"g":"single","s":"ꛥ","k":1} +{"g":"single","s":"꛰","k":0} +{"g":"single","s":"꛱","k":0} +{"g":"single","s":"꜀","k":0} +{"g":"single","s":"ꜗ","k":1} +{"g":"single","s":"ꜟ","k":1} +{"g":"single","s":"꜡","k":0} +{"g":"single","s":"Ꜣ","l":"ꜣ","k":3} +{"g":"single","s":"Ꜥ","l":"ꜥ","k":3} +{"g":"single","s":"Ꜧ","l":"ꜧ","k":3} +{"g":"single","s":"Ꜩ","l":"ꜩ","k":3} +{"g":"single","s":"Ꜫ","l":"ꜫ","k":3} +{"g":"single","s":"Ꜭ","l":"ꜭ","k":3} +{"g":"single","s":"Ꜯ","l":"ꜯ","k":3} +{"g":"single","s":"Ꜳ","l":"ꜳ","k":3} +{"g":"single","s":"Ꜵ","l":"ꜵ","k":3} +{"g":"single","s":"Ꜷ","l":"ꜷ","k":3} +{"g":"single","s":"Ꜹ","l":"ꜹ","k":3} +{"g":"single","s":"Ꜻ","l":"ꜻ","k":3} +{"g":"single","s":"Ꜽ","l":"ꜽ","k":3} +{"g":"single","s":"Ꜿ","l":"ꜿ","k":3} +{"g":"single","s":"Ꝁ","l":"ꝁ","k":3} +{"g":"single","s":"Ꝃ","l":"ꝃ","k":3} +{"g":"single","s":"Ꝅ","l":"ꝅ","k":3} +{"g":"single","s":"Ꝇ","l":"ꝇ","k":3} +{"g":"single","s":"Ꝉ","l":"ꝉ","k":3} +{"g":"single","s":"Ꝋ","l":"ꝋ","k":3} +{"g":"single","s":"Ꝍ","l":"ꝍ","k":3} +{"g":"single","s":"Ꝏ","l":"ꝏ","k":3} +{"g":"single","s":"Ꝑ","l":"ꝑ","k":3} +{"g":"single","s":"Ꝓ","l":"ꝓ","k":3} +{"g":"single","s":"Ꝕ","l":"ꝕ","k":3} +{"g":"single","s":"Ꝗ","l":"ꝗ","k":3} +{"g":"single","s":"Ꝙ","l":"ꝙ","k":3} +{"g":"single","s":"Ꝛ","l":"ꝛ","k":3} +{"g":"single","s":"Ꝝ","l":"ꝝ","k":3} +{"g":"single","s":"Ꝟ","l":"ꝟ","k":3} +{"g":"single","s":"Ꝡ","l":"ꝡ","k":3} +{"g":"single","s":"Ꝣ","l":"ꝣ","k":3} +{"g":"single","s":"Ꝥ","l":"ꝥ","k":3} +{"g":"single","s":"Ꝧ","l":"ꝧ","k":3} +{"g":"single","s":"Ꝩ","l":"ꝩ","k":3} +{"g":"single","s":"Ꝫ","l":"ꝫ","k":3} +{"g":"single","s":"Ꝭ","l":"ꝭ","k":3} +{"g":"single","s":"Ꝯ","l":"ꝯ","k":3} +{"g":"single","s":"ꝰ","k":1} +{"g":"single","s":"Ꝺ","l":"ꝺ","k":3} +{"g":"single","s":"Ꝼ","l":"ꝼ","k":3} +{"g":"single","s":"Ᵹ","l":"ᵹ","k":3} +{"g":"single","s":"Ꝿ","l":"ꝿ","k":3} +{"g":"single","s":"Ꞁ","l":"ꞁ","k":3} +{"g":"single","s":"Ꞃ","l":"ꞃ","k":3} +{"g":"single","s":"Ꞅ","l":"ꞅ","k":3} +{"g":"single","s":"Ꞇ","l":"ꞇ","k":3} +{"g":"single","s":"ꞇ","k":1} +{"g":"single","s":"ꞈ","k":1} +{"g":"single","s":"꞊","k":0} +{"g":"single","s":"Ꞌ","l":"ꞌ","k":3} +{"g":"single","s":"Ɥ","l":"ɥ","k":3} +{"g":"single","s":"ꞎ","k":1} +{"g":"single","s":"Ꞑ","l":"ꞑ","k":3} +{"g":"single","s":"Ꞓ","l":"ꞓ","k":3} +{"g":"single","s":"Ꞗ","l":"ꞗ","k":3} +{"g":"single","s":"Ꞙ","l":"ꞙ","k":3} +{"g":"single","s":"Ꞛ","l":"ꞛ","k":3} +{"g":"single","s":"Ꞝ","l":"ꞝ","k":3} +{"g":"single","s":"Ꞟ","l":"ꞟ","k":3} +{"g":"single","s":"Ꞡ","l":"ꞡ","k":3} +{"g":"single","s":"Ꞣ","l":"ꞣ","k":3} +{"g":"single","s":"Ꞥ","l":"ꞥ","k":3} +{"g":"single","s":"Ꞧ","l":"ꞧ","k":3} +{"g":"single","s":"Ꞩ","l":"ꞩ","k":3} +{"g":"single","s":"Ɦ","l":"ɦ","k":3} +{"g":"single","s":"Ɡ","l":"ɡ","k":3} +{"g":"single","s":"Ɪ","l":"ɪ","k":3} +{"g":"single","s":"Ʞ","l":"ʞ","k":3} +{"g":"single","s":"Ʇ","l":"ʇ","k":3} +{"g":"single","s":"Ꞵ","l":"ꞵ","k":3} +{"g":"single","s":"Ꞷ","l":"ꞷ","k":3} +{"g":"single","s":"Ꞹ","l":"ꞹ","k":3} +{"g":"single","s":"Ꞻ","l":"ꞻ","k":3} +{"g":"single","s":"Ꞽ","l":"ꞽ","k":3} +{"g":"single","s":"Ꞿ","l":"ꞿ","k":3} +{"g":"single","s":"Ꟁ","l":"ꟁ","k":3} +{"g":"single","s":"Ꟃ","l":"ꟃ","k":3} +{"g":"single","s":"Ꞔ","l":"ꞔ","k":3} +{"g":"single","s":"Ꟈ","l":"ꟈ","k":3} +{"g":"single","s":"Ꟊ","l":"ꟊ","k":3} +{"g":"single","s":"Ɤ","l":"ɤ","k":3} +{"g":"single","s":"Ꟍ","l":"ꟍ","k":3} +{"g":"single","s":"꟎","l":"꟏","k":3} +{"g":"single","s":"Ꟑ","l":"ꟑ","k":3} +{"g":"single","s":"꟒","l":"ꟓ","k":3} +{"g":"single","s":"꟔","l":"ꟕ","k":3} +{"g":"single","s":"Ꟗ","l":"ꟗ","k":3} +{"g":"single","s":"Ꟙ","l":"ꟙ","k":3} +{"g":"single","s":"Ꟛ","l":"ꟛ","k":3} +{"g":"single","s":"Ƛ","l":"ƛ","k":3} +{"g":"single","s":"꟱","k":1} +{"g":"single","s":"ꟴ","k":1} +{"g":"single","s":"Ꟶ","l":"ꟶ","k":3} +{"g":"single","s":"ꟶ","k":1} +{"g":"single","s":"ꟸ","k":1} +{"g":"single","s":"ꟹ","k":1} +{"g":"single","s":"ꟺ","k":1} +{"g":"single","s":"ꠁ","k":1} +{"g":"single","s":"ꠂ","k":0} +{"g":"single","s":"ꠃ","k":1} +{"g":"single","s":"ꠅ","k":1} +{"g":"single","s":"꠆","k":0} +{"g":"single","s":"ꠇ","k":1} +{"g":"single","s":"ꠊ","k":1} +{"g":"single","s":"ꠋ","k":0} +{"g":"single","s":"ꠌ","k":1} +{"g":"single","s":"ꠢ","k":1} +{"g":"single","s":"ꠥ","k":0} +{"g":"single","s":"ꠦ","k":0} +{"g":"single","s":"꠬","k":0} +{"g":"single","s":"ꡀ","k":1} +{"g":"single","s":"ꡳ","k":1} +{"g":"single","s":"ꢂ","k":1} +{"g":"single","s":"ꢳ","k":1} +{"g":"single","s":"꣄","k":0} +{"g":"single","s":"ꣅ","k":0} +{"g":"single","s":"꣠","k":0} +{"g":"single","s":"꣡","k":0} +{"g":"single","s":"꣩","k":0} +{"g":"single","s":"꣱","k":0} +{"g":"single","s":"ꣲ","k":1} +{"g":"single","s":"ꣷ","k":1} +{"g":"single","s":"ꣻ","k":1} +{"g":"single","s":"ꣽ","k":1} +{"g":"single","s":"ꣾ","k":1} +{"g":"single","s":"ꣿ","k":0} +{"g":"single","s":"ꤊ","k":1} +{"g":"single","s":"ꤥ","k":1} +{"g":"single","s":"ꤦ","k":0} +{"g":"single","s":"꤭","k":0} +{"g":"single","s":"ꤰ","k":1} +{"g":"single","s":"ꥆ","k":1} +{"g":"single","s":"ꥇ","k":0} +{"g":"single","s":"ꥑ","k":0} +{"g":"single","s":"ꥠ","k":1} +{"g":"single","s":"ꥼ","k":1} +{"g":"single","s":"ꦀ","k":0} +{"g":"single","s":"ꦂ","k":0} +{"g":"single","s":"ꦄ","k":1} +{"g":"single","s":"ꦲ","k":1} +{"g":"single","s":"꦳","k":0} +{"g":"single","s":"ꦶ","k":0} +{"g":"single","s":"ꦹ","k":0} +{"g":"single","s":"ꦼ","k":0} +{"g":"single","s":"ꦽ","k":0} +{"g":"single","s":"ꧏ","k":1} +{"g":"single","s":"ꧠ","k":1} +{"g":"single","s":"ꧤ","k":1} +{"g":"single","s":"ꧥ","k":0} +{"g":"single","s":"ꧦ","k":1} +{"g":"single","s":"ꧯ","k":1} +{"g":"single","s":"ꧺ","k":1} +{"g":"single","s":"ꧾ","k":1} +{"g":"single","s":"ꨀ","k":1} +{"g":"single","s":"ꨨ","k":1} +{"g":"single","s":"ꨩ","k":0} +{"g":"single","s":"ꨮ","k":0} +{"g":"single","s":"ꨱ","k":0} +{"g":"single","s":"ꨲ","k":0} +{"g":"single","s":"ꨵ","k":0} +{"g":"single","s":"ꨶ","k":0} +{"g":"single","s":"ꩀ","k":1} +{"g":"single","s":"ꩂ","k":1} +{"g":"single","s":"ꩃ","k":0} +{"g":"single","s":"ꩄ","k":1} +{"g":"single","s":"ꩋ","k":1} +{"g":"single","s":"ꩌ","k":0} +{"g":"single","s":"ꩠ","k":1} +{"g":"single","s":"ꩰ","k":1} +{"g":"single","s":"ꩶ","k":1} +{"g":"single","s":"ꩺ","k":1} +{"g":"single","s":"ꩼ","k":0} +{"g":"single","s":"ꩾ","k":1} +{"g":"single","s":"ꪯ","k":1} +{"g":"single","s":"ꪰ","k":0} +{"g":"single","s":"ꪱ","k":1} +{"g":"single","s":"ꪲ","k":0} +{"g":"single","s":"ꪴ","k":0} +{"g":"single","s":"ꪵ","k":1} +{"g":"single","s":"ꪶ","k":1} +{"g":"single","s":"ꪷ","k":0} +{"g":"single","s":"ꪸ","k":0} +{"g":"single","s":"ꪹ","k":1} +{"g":"single","s":"ꪽ","k":1} +{"g":"single","s":"ꪾ","k":0} +{"g":"single","s":"꪿","k":0} +{"g":"single","s":"ꫀ","k":1} +{"g":"single","s":"꫁","k":0} +{"g":"single","s":"ꫂ","k":1} +{"g":"single","s":"ꫛ","k":1} +{"g":"single","s":"ꫝ","k":1} +{"g":"single","s":"ꫠ","k":1} +{"g":"single","s":"ꫪ","k":1} +{"g":"single","s":"ꫬ","k":0} +{"g":"single","s":"ꫭ","k":0} +{"g":"single","s":"ꫲ","k":1} +{"g":"single","s":"ꫳ","k":1} +{"g":"single","s":"ꫴ","k":1} +{"g":"single","s":"꫶","k":0} +{"g":"single","s":"ꬁ","k":1} +{"g":"single","s":"ꬆ","k":1} +{"g":"single","s":"ꬉ","k":1} +{"g":"single","s":"ꬎ","k":1} +{"g":"single","s":"ꬑ","k":1} +{"g":"single","s":"ꬖ","k":1} +{"g":"single","s":"ꬠ","k":1} +{"g":"single","s":"ꬦ","k":1} +{"g":"single","s":"ꬨ","k":1} +{"g":"single","s":"ꬮ","k":1} +{"g":"single","s":"ꬰ","k":1} +{"g":"single","s":"ꭚ","k":1} +{"g":"single","s":"꭛","k":0} +{"g":"single","s":"ꭜ","k":1} +{"g":"single","s":"ꭟ","k":1} +{"g":"single","s":"ꭩ","k":1} +{"g":"single","s":"꭫","k":0} +{"g":"single","s":"ꭰ","k":1} +{"g":"single","s":"ꮿ","k":1} +{"g":"single","s":"ꯢ","k":1} +{"g":"single","s":"ꯥ","k":0} +{"g":"single","s":"ꯨ","k":0} +{"g":"single","s":"꯭","k":0} +{"g":"single","s":"가","d":"가","k":1} +{"g":"single","s":"꾿","d":"꾿","k":1} +{"g":"single","s":"꿥","d":"꿥","k":1} +{"g":"single","s":"돊","d":"돊","k":1} +{"g":"single","s":"랯","d":"랯","k":1} +{"g":"single","s":"뮔","d":"뮔","k":1} +{"g":"single","s":"뽹","d":"뽹","k":1} +{"g":"single","s":"썆","d":"썆","k":1} +{"g":"single","s":"썞","d":"썞","k":1} +{"g":"single","s":"읃","d":"읃","k":1} +{"g":"single","s":"쬨","d":"쬨","k":1} +{"g":"single","s":"켍","d":"켍","k":1} +{"g":"single","s":"틲","d":"틲","k":1} +{"g":"single","s":"훍","d":"훍","k":1} +{"g":"single","s":"훗","d":"훗","k":1} +{"g":"single","s":"힣","d":"힣","k":1} +{"g":"single","s":"ힰ","k":1} +{"g":"single","s":"ퟆ","k":1} +{"g":"single","s":"ퟋ","k":1} +{"g":"single","s":"ퟻ","k":1} +{"g":"single","s":"","k":0} +{"g":"single","s":"豈","c":"豈","d":"豈","k":1} +{"g":"single","s":"更","c":"更","d":"更","k":1} +{"g":"single","s":"契","c":"契","d":"契","k":1} +{"g":"single","s":"螺","c":"螺","d":"螺","k":1} +{"g":"single","s":"酪","c":"酪","d":"酪","k":1} +{"g":"single","s":"嵐","c":"嵐","d":"嵐","k":1} +{"g":"single","s":"朗","c":"朗","d":"朗","k":1} +{"g":"single","s":"櫓","c":"櫓","d":"櫓","k":1} +{"g":"single","s":"魯","c":"魯","d":"魯","k":1} +{"g":"single","s":"論","c":"論","d":"論","k":1} +{"g":"single","s":"雷","c":"雷","d":"雷","k":1} +{"g":"single","s":"陋","c":"陋","d":"陋","k":1} +{"g":"single","s":"陵","c":"陵","d":"陵","k":1} +{"g":"single","s":"率","c":"率","d":"率","k":1} +{"g":"single","s":"數","c":"數","d":"數","k":1} +{"g":"single","s":"辰","c":"辰","d":"辰","k":1} +{"g":"single","s":"凉","c":"凉","d":"凉","k":1} +{"g":"single","s":"女","c":"女","d":"女","k":1} +{"g":"single","s":"黎","c":"黎","d":"黎","k":1} +{"g":"single","s":"撚","c":"撚","d":"撚","k":1} +{"g":"single","s":"蓮","c":"蓮","d":"蓮","k":1} +{"g":"single","s":"說","c":"說","d":"說","k":1} +{"g":"single","s":"囹","c":"囹","d":"囹","k":1} +{"g":"single","s":"鈴","c":"鈴","d":"鈴","k":1} +{"g":"single","s":"惡","c":"惡","d":"惡","k":1} +{"g":"single","s":"療","c":"療","d":"療","k":1} +{"g":"single","s":"柳","c":"柳","d":"柳","k":1} +{"g":"single","s":"六","c":"六","d":"六","k":1} +{"g":"single","s":"慄","c":"慄","d":"慄","k":1} +{"g":"single","s":"李","c":"李","d":"李","k":1} +{"g":"single","s":"里","c":"里","d":"里","k":1} +{"g":"single","s":"隣","c":"隣","d":"隣","k":1} +{"g":"single","s":"粒","c":"粒","d":"粒","k":1} +{"g":"single","s":"度","c":"度","d":"度","k":1} +{"g":"single","s":"降","c":"降","d":"降","k":1} +{"g":"single","s":"嗀","c":"嗀","d":"嗀","k":1} +{"g":"single","s":"塚","c":"塚","d":"塚","k":1} +{"g":"single","s":"晴","c":"晴","d":"晴","k":1} +{"g":"single","s":"凞","c":"凞","d":"凞","k":1} +{"g":"single","s":"猪","c":"猪","d":"猪","k":1} +{"g":"single","s":"羽","c":"羽","d":"羽","k":1} +{"g":"single","s":"蘒","c":"蘒","d":"蘒","k":1} +{"g":"single","s":"諸","c":"諸","d":"諸","k":1} +{"g":"single","s":"逸","c":"逸","d":"逸","k":1} +{"g":"single","s":"都","c":"都","d":"都","k":1} +{"g":"single","s":"飯","c":"飯","d":"飯","k":1} +{"g":"single","s":"鶴","c":"鶴","d":"鶴","k":1} +{"g":"single","s":"卑","c":"卑","d":"卑","k":1} +{"g":"single","s":"悔","c":"悔","d":"悔","k":1} +{"g":"single","s":"海","c":"海","d":"海","k":1} +{"g":"single","s":"祉","c":"祉","d":"祉","k":1} +{"g":"single","s":"突","c":"突","d":"突","k":1} +{"g":"single","s":"艹","c":"艹","d":"艹","k":1} +{"g":"single","s":"贈","c":"贈","d":"贈","k":1} +{"g":"single","s":"舘","c":"舘","d":"舘","k":1} +{"g":"single","s":"並","c":"並","d":"並","k":1} +{"g":"single","s":"勺","c":"勺","d":"勺","k":1} +{"g":"single","s":"奔","c":"奔","d":"奔","k":1} +{"g":"single","s":"慎","c":"慎","d":"慎","k":1} +{"g":"single","s":"摒","c":"摒","d":"摒","k":1} +{"g":"single","s":"流","c":"流","d":"流","k":1} +{"g":"single","s":"犯","c":"犯","d":"犯","k":1} +{"g":"single","s":"盛","c":"盛","d":"盛","k":1} +{"g":"single","s":"絛","c":"絛","d":"絛","k":1} +{"g":"single","s":"覆","c":"覆","d":"覆","k":1} +{"g":"single","s":"謹","c":"謹","d":"謹","k":1} +{"g":"single","s":"難","c":"難","d":"難","k":1} +{"g":"single","s":"𢡊","c":"𢡊","d":"𢡊","k":1} +{"g":"single","s":"𧻓","c":"𧻓","d":"𧻓","k":1} +{"g":"single","s":"龎","c":"龎","d":"龎","k":1} +{"g":"single","s":"ff","k":1} +{"g":"single","s":"st","k":1} +{"g":"single","s":"ﬓ","k":1} +{"g":"single","s":"ﬗ","k":1} +{"g":"single","s":"יִ","c":"יִ","d":"יִ","k":1} +{"g":"single","s":"ﬞ","k":0} +{"g":"single","s":"ײַ","c":"ײַ","d":"ײַ","k":1} +{"g":"single","s":"ﬨ","k":1} +{"g":"single","s":"שׁ","c":"שׁ","d":"שׁ","k":1} +{"g":"single","s":"שּׂ","c":"שּׂ","d":"שּׂ","k":1} +{"g":"single","s":"וּ","c":"וּ","d":"וּ","k":1} +{"g":"single","s":"זּ","c":"זּ","d":"זּ","k":1} +{"g":"single","s":"טּ","c":"טּ","d":"טּ","k":1} +{"g":"single","s":"לּ","c":"לּ","d":"לּ","k":1} +{"g":"single","s":"מּ","c":"מּ","d":"מּ","k":1} +{"g":"single","s":"נּ","c":"נּ","d":"נּ","k":1} +{"g":"single","s":"סּ","c":"סּ","d":"סּ","k":1} +{"g":"single","s":"ףּ","c":"ףּ","d":"ףּ","k":1} +{"g":"single","s":"פּ","c":"פּ","d":"פּ","k":1} +{"g":"single","s":"צּ","c":"צּ","d":"צּ","k":1} +{"g":"single","s":"תּ","c":"תּ","d":"תּ","k":1} +{"g":"single","s":"פֿ","c":"פֿ","d":"פֿ","k":1} +{"g":"single","s":"ﮱ","k":1} +{"g":"single","s":"﮲","k":0} +{"g":"single","s":"﯂","k":0} +{"g":"single","s":"ﯓ","k":1} +{"g":"single","s":"ﴽ","k":1} +{"g":"single","s":"ﵐ","k":1} +{"g":"single","s":"ﶏ","k":1} +{"g":"single","s":"ﶒ","k":1} +{"g":"single","s":"ﷇ","k":1} +{"g":"single","s":"﷛","k":0} +{"g":"single","s":"ﷰ","k":1} +{"g":"single","s":"ﷻ","k":1} +{"g":"single","s":"︀","k":0} +{"g":"single","s":"️","k":0} +{"g":"single","s":"︓","k":0} +{"g":"single","s":"︠","k":0} +{"g":"single","s":"︥","k":0} +{"g":"single","s":"︭","k":0} +{"g":"single","s":"︯","k":0} +{"g":"single","s":"﹒","k":0} +{"g":"single","s":"﹕","k":0} +{"g":"single","s":"ﹰ","k":1} +{"g":"single","s":"ﹴ","k":1} +{"g":"single","s":"ﹶ","k":1} +{"g":"single","s":"ﻼ","k":1} +{"g":"single","s":"","k":0} +{"g":"single","s":"'","k":0} +{"g":"single","s":".","k":0} +{"g":"single","s":":","k":0} +{"g":"single","s":"A","l":"a","k":3} +{"g":"single","s":"Z","l":"z","k":3} +{"g":"single","s":"^","k":0} +{"g":"single","s":"`","k":0} +{"g":"single","s":"a","k":1} +{"g":"single","s":"z","k":1} +{"g":"single","s":"ヲ","k":1} +{"g":"single","s":"ー","k":1} +{"g":"single","s":"゙","k":1} +{"g":"single","s":"゚","k":1} +{"g":"single","s":"ᄒ","k":1} +{"g":"single","s":"ᅡ","k":1} +{"g":"single","s":"ᅦ","k":1} +{"g":"single","s":"ᅧ","k":1} +{"g":"single","s":"ᅬ","k":1} +{"g":"single","s":"ᅭ","k":1} +{"g":"single","s":"ᅲ","k":1} +{"g":"single","s":"ᅳ","k":1} +{"g":"single","s":"ᅵ","k":1} +{"g":"single","s":" ̄","k":0} +{"g":"single","s":"","k":0} +{"g":"single","s":"","k":0} +{"g":"single","s":"𐀀","k":1} +{"g":"single","s":"𐀋","k":1} +{"g":"single","s":"𐀍","k":1} +{"g":"single","s":"𐀦","k":1} +{"g":"single","s":"𐀨","k":1} +{"g":"single","s":"𐀺","k":1} +{"g":"single","s":"𐀼","k":1} +{"g":"single","s":"𐀽","k":1} +{"g":"single","s":"𐀿","k":1} +{"g":"single","s":"𐁍","k":1} +{"g":"single","s":"𐁐","k":1} +{"g":"single","s":"𐁝","k":1} +{"g":"single","s":"𐂀","k":1} +{"g":"single","s":"𐃺","k":1} +{"g":"single","s":"𐇽","k":0} +{"g":"single","s":"𐊀","k":1} +{"g":"single","s":"𐊜","k":1} +{"g":"single","s":"𐊠","k":1} +{"g":"single","s":"𐋐","k":1} +{"g":"single","s":"𐋠","k":0} +{"g":"single","s":"𐌀","k":1} +{"g":"single","s":"𐌟","k":1} +{"g":"single","s":"𐌭","k":1} +{"g":"single","s":"𐍀","k":1} +{"g":"single","s":"𐍂","k":1} +{"g":"single","s":"𐍉","k":1} +{"g":"single","s":"𐍐","k":1} +{"g":"single","s":"𐍵","k":1} +{"g":"single","s":"𐍶","k":0} +{"g":"single","s":"𐍹","k":0} +{"g":"single","s":"𐍺","k":0} +{"g":"single","s":"𐎀","k":1} +{"g":"single","s":"𐎝","k":1} +{"g":"single","s":"𐎠","k":1} +{"g":"single","s":"𐏃","k":1} +{"g":"single","s":"𐏈","k":1} +{"g":"single","s":"𐏏","k":1} +{"g":"single","s":"𐐀","l":"𐐨","k":3} +{"g":"single","s":"𐐧","l":"𐑏","k":3} +{"g":"single","s":"𐑏","k":1} +{"g":"single","s":"𐒝","k":1} +{"g":"single","s":"𐒰","l":"𐓘","k":3} +{"g":"single","s":"𐓓","l":"𐓻","k":3} +{"g":"single","s":"𐓘","k":1} +{"g":"single","s":"𐓻","k":1} +{"g":"single","s":"𐔀","k":1} +{"g":"single","s":"𐔧","k":1} +{"g":"single","s":"𐔰","k":1} +{"g":"single","s":"𐕣","k":1} +{"g":"single","s":"𐕰","l":"𐖗","k":3} +{"g":"single","s":"𐕺","l":"𐖡","k":3} +{"g":"single","s":"𐕼","l":"𐖣","k":3} +{"g":"single","s":"𐖊","l":"𐖱","k":3} +{"g":"single","s":"𐖌","l":"𐖳","k":3} +{"g":"single","s":"𐖒","l":"𐖹","k":3} +{"g":"single","s":"𐖔","l":"𐖻","k":3} +{"g":"single","s":"𐖕","l":"𐖼","k":3} +{"g":"single","s":"𐖗","k":1} +{"g":"single","s":"𐖡","k":1} +{"g":"single","s":"𐖣","k":1} +{"g":"single","s":"𐖱","k":1} +{"g":"single","s":"𐖳","k":1} +{"g":"single","s":"𐖹","k":1} +{"g":"single","s":"𐖻","k":1} +{"g":"single","s":"𐖼","k":1} +{"g":"single","s":"𐗀","k":1} +{"g":"single","s":"𐗳","k":1} +{"g":"single","s":"𐘀","k":1} +{"g":"single","s":"𐜶","k":1} +{"g":"single","s":"𐝀","k":1} +{"g":"single","s":"𐝕","k":1} +{"g":"single","s":"𐝠","k":1} +{"g":"single","s":"𐝧","k":1} +{"g":"single","s":"𐞀","k":1} +{"g":"single","s":"𐞃","k":1} +{"g":"single","s":"𐞅","k":1} +{"g":"single","s":"𐞇","k":1} +{"g":"single","s":"𐞰","k":1} +{"g":"single","s":"𐞲","k":1} +{"g":"single","s":"𐞺","k":1} +{"g":"single","s":"𐠀","k":1} +{"g":"single","s":"𐠅","k":1} +{"g":"single","s":"𐠈","k":1} +{"g":"single","s":"𐠊","k":1} +{"g":"single","s":"𐠵","k":1} +{"g":"single","s":"𐠷","k":1} +{"g":"single","s":"𐠸","k":1} +{"g":"single","s":"𐠼","k":1} +{"g":"single","s":"𐠿","k":1} +{"g":"single","s":"𐡕","k":1} +{"g":"single","s":"𐡠","k":1} +{"g":"single","s":"𐡶","k":1} +{"g":"single","s":"𐢀","k":1} +{"g":"single","s":"𐢞","k":1} +{"g":"single","s":"𐣠","k":1} +{"g":"single","s":"𐣲","k":1} +{"g":"single","s":"𐣴","k":1} +{"g":"single","s":"𐣵","k":1} +{"g":"single","s":"𐤀","k":1} +{"g":"single","s":"𐤕","k":1} +{"g":"single","s":"𐤠","k":1} +{"g":"single","s":"𐤹","k":1} +{"g":"single","s":"𐥀","k":1} +{"g":"single","s":"𐥙","k":1} +{"g":"single","s":"𐦀","k":1} +{"g":"single","s":"𐦷","k":1} +{"g":"single","s":"𐦾","k":1} +{"g":"single","s":"𐦿","k":1} +{"g":"single","s":"𐨀","k":1} +{"g":"single","s":"𐨁","k":0} +{"g":"single","s":"𐨃","k":0} +{"g":"single","s":"𐨅","k":0} +{"g":"single","s":"𐨆","k":0} +{"g":"single","s":"𐨌","k":0} +{"g":"single","s":"𐨏","k":0} +{"g":"single","s":"𐨐","k":1} +{"g":"single","s":"𐨓","k":1} +{"g":"single","s":"𐨕","k":1} +{"g":"single","s":"𐨗","k":1} +{"g":"single","s":"𐨙","k":1} +{"g":"single","s":"𐨵","k":1} +{"g":"single","s":"𐨸","k":0} +{"g":"single","s":"𐨺","k":0} +{"g":"single","s":"𐨿","k":0} +{"g":"single","s":"𐩠","k":1} +{"g":"single","s":"𐩼","k":1} +{"g":"single","s":"𐪀","k":1} +{"g":"single","s":"𐪜","k":1} +{"g":"single","s":"𐫀","k":1} +{"g":"single","s":"𐫇","k":1} +{"g":"single","s":"𐫉","k":1} +{"g":"single","s":"𐫤","k":1} +{"g":"single","s":"𐫥","k":0} +{"g":"single","s":"𐫦","k":0} +{"g":"single","s":"𐬀","k":1} +{"g":"single","s":"𐬵","k":1} +{"g":"single","s":"𐭀","k":1} +{"g":"single","s":"𐭕","k":1} +{"g":"single","s":"𐭠","k":1} +{"g":"single","s":"𐭲","k":1} +{"g":"single","s":"𐮀","k":1} +{"g":"single","s":"𐮑","k":1} +{"g":"single","s":"𐰀","k":1} +{"g":"single","s":"𐱈","k":1} +{"g":"single","s":"𐲀","l":"𐳀","k":3} +{"g":"single","s":"𐲲","l":"𐳲","k":3} +{"g":"single","s":"𐳀","k":1} +{"g":"single","s":"𐳲","k":1} +{"g":"single","s":"𐴀","k":1} +{"g":"single","s":"𐴣","k":1} +{"g":"single","s":"𐴤","k":0} +{"g":"single","s":"𐴧","k":0} +{"g":"single","s":"𐵊","k":1} +{"g":"single","s":"𐵎","k":1} +{"g":"single","s":"𐵐","l":"𐵰","k":3} +{"g":"single","s":"𐵥","l":"𐶅","k":3} +{"g":"single","s":"𐵩","k":0} +{"g":"single","s":"𐵫","k":0} +{"g":"single","s":"𐵭","k":0} +{"g":"single","s":"𐵯","k":1} +{"g":"single","s":"𐵰","k":1} +{"g":"single","s":"𐶅","k":1} +{"g":"single","s":"𐺀","k":1} +{"g":"single","s":"𐺩","k":1} +{"g":"single","s":"𐺫","k":0} +{"g":"single","s":"𐺬","k":0} +{"g":"single","s":"𐺰","k":1} +{"g":"single","s":"𐺱","k":1} +{"g":"single","s":"𐻂","k":1} +{"g":"single","s":"𐻅","k":1} +{"g":"single","s":"𐻇","k":1} +{"g":"single","s":"𐻺","k":0} +{"g":"single","s":"𐻾","k":0} +{"g":"single","s":"𐻿","k":0} +{"g":"single","s":"𐼀","k":1} +{"g":"single","s":"𐼜","k":1} +{"g":"single","s":"𐼧","k":1} +{"g":"single","s":"𐼰","k":1} +{"g":"single","s":"𐽅","k":1} +{"g":"single","s":"𐽆","k":0} +{"g":"single","s":"𐽌","k":0} +{"g":"single","s":"𐽐","k":0} +{"g":"single","s":"𐽰","k":1} +{"g":"single","s":"𐾁","k":1} +{"g":"single","s":"𐾂","k":0} +{"g":"single","s":"𐾅","k":0} +{"g":"single","s":"𐾰","k":1} +{"g":"single","s":"𐿄","k":1} +{"g":"single","s":"𐿠","k":1} +{"g":"single","s":"𐿶","k":1} +{"g":"single","s":"𑀁","k":0} +{"g":"single","s":"𑀃","k":1} +{"g":"single","s":"𑀷","k":1} +{"g":"single","s":"𑀸","k":0} +{"g":"single","s":"𑁆","k":0} +{"g":"single","s":"𑁰","k":0} +{"g":"single","s":"𑁱","k":1} +{"g":"single","s":"𑁲","k":1} +{"g":"single","s":"𑁳","k":0} +{"g":"single","s":"𑁴","k":0} +{"g":"single","s":"𑁵","k":1} +{"g":"single","s":"𑁿","k":0} +{"g":"single","s":"𑂁","k":0} +{"g":"single","s":"𑂃","k":1} +{"g":"single","s":"𑂜","d":"𑂜","k":1} +{"g":"single","s":"𑂯","k":1} +{"g":"single","s":"𑂳","k":0} +{"g":"single","s":"𑂶","k":0} +{"g":"single","s":"𑂹","k":0} +{"g":"single","s":"𑂺","k":0} +{"g":"single","s":"𑂽","k":0} +{"g":"single","s":"𑃂","k":0} +{"g":"single","s":"𑃍","k":0} +{"g":"single","s":"𑃐","k":1} +{"g":"single","s":"𑃨","k":1} +{"g":"single","s":"𑄀","k":0} +{"g":"single","s":"𑄂","k":0} +{"g":"single","s":"𑄃","k":1} +{"g":"single","s":"𑄦","k":1} +{"g":"single","s":"𑄧","k":0} +{"g":"single","s":"𑄫","k":0} +{"g":"single","s":"𑄭","k":0} +{"g":"single","s":"𑄴","k":0} +{"g":"single","s":"𑅄","k":1} +{"g":"single","s":"𑅇","k":1} +{"g":"single","s":"𑅐","k":1} +{"g":"single","s":"𑅢","k":1} +{"g":"single","s":"𑅲","k":1} +{"g":"single","s":"𑅳","k":0} +{"g":"single","s":"𑅶","k":1} +{"g":"single","s":"𑆀","k":0} +{"g":"single","s":"𑆁","k":0} +{"g":"single","s":"𑆃","k":1} +{"g":"single","s":"𑆲","k":1} +{"g":"single","s":"𑆶","k":0} +{"g":"single","s":"𑆾","k":0} +{"g":"single","s":"𑇁","k":1} +{"g":"single","s":"𑇄","k":1} +{"g":"single","s":"𑇉","k":0} +{"g":"single","s":"𑇌","k":0} +{"g":"single","s":"𑇏","k":0} +{"g":"single","s":"𑇚","k":1} +{"g":"single","s":"𑇜","k":1} +{"g":"single","s":"𑈀","k":1} +{"g":"single","s":"𑈑","k":1} +{"g":"single","s":"𑈓","k":1} +{"g":"single","s":"𑈫","k":1} +{"g":"single","s":"𑈯","k":0} +{"g":"single","s":"𑈱","k":0} +{"g":"single","s":"𑈴","k":0} +{"g":"single","s":"𑈶","k":0} +{"g":"single","s":"𑈷","k":0} +{"g":"single","s":"𑈾","k":0} +{"g":"single","s":"𑈿","k":1} +{"g":"single","s":"𑉀","k":1} +{"g":"single","s":"𑉁","k":0} +{"g":"single","s":"𑊀","k":1} +{"g":"single","s":"𑊆","k":1} +{"g":"single","s":"𑊈","k":1} +{"g":"single","s":"𑊊","k":1} +{"g":"single","s":"𑊍","k":1} +{"g":"single","s":"𑊏","k":1} +{"g":"single","s":"𑊝","k":1} +{"g":"single","s":"𑊟","k":1} +{"g":"single","s":"𑊨","k":1} +{"g":"single","s":"𑊰","k":1} +{"g":"single","s":"𑋞","k":1} +{"g":"single","s":"𑋟","k":0} +{"g":"single","s":"𑋣","k":0} +{"g":"single","s":"𑋩","k":0} +{"g":"single","s":"𑋪","k":0} +{"g":"single","s":"𑌀","k":0} +{"g":"single","s":"𑌁","k":0} +{"g":"single","s":"𑌅","k":1} +{"g":"single","s":"𑌌","k":1} +{"g":"single","s":"𑌏","k":1} +{"g":"single","s":"𑌐","k":1} +{"g":"single","s":"𑌓","k":1} +{"g":"single","s":"𑌨","k":1} +{"g":"single","s":"𑌪","k":1} +{"g":"single","s":"𑌰","k":1} +{"g":"single","s":"𑌲","k":1} +{"g":"single","s":"𑌳","k":1} +{"g":"single","s":"𑌵","k":1} +{"g":"single","s":"𑌹","k":1} +{"g":"single","s":"𑌻","k":0} +{"g":"single","s":"𑌼","k":0} +{"g":"single","s":"𑌽","k":1} +{"g":"single","s":"𑍀","k":0} +{"g":"single","s":"𑍐","k":1} +{"g":"single","s":"𑍗","k":0} +{"g":"single","s":"𑍝","k":1} +{"g":"single","s":"𑍡","k":1} +{"g":"single","s":"𑍦","k":0} +{"g":"single","s":"𑍩","k":0} +{"g":"single","s":"𑍬","k":0} +{"g":"single","s":"𑍰","k":0} +{"g":"single","s":"𑍴","k":0} +{"g":"single","s":"𑎀","k":1} +{"g":"single","s":"𑎉","k":1} +{"g":"single","s":"𑎋","k":1} +{"g":"single","s":"𑎎","d":"𑎎","k":1} +{"g":"single","s":"𑎐","k":1} +{"g":"single","s":"𑎵","k":1} +{"g":"single","s":"𑎷","k":1} +{"g":"single","s":"𑎻","k":0} +{"g":"single","s":"𑏀","k":0} +{"g":"single","s":"𑏎","k":0} +{"g":"single","s":"𑏐","k":0} +{"g":"single","s":"𑏑","k":1} +{"g":"single","s":"𑏒","k":0} +{"g":"single","s":"𑏓","k":1} +{"g":"single","s":"𑏡","k":0} +{"g":"single","s":"𑏢","k":0} +{"g":"single","s":"𑐀","k":1} +{"g":"single","s":"𑐴","k":1} +{"g":"single","s":"𑐸","k":0} +{"g":"single","s":"𑐿","k":0} +{"g":"single","s":"𑑂","k":0} +{"g":"single","s":"𑑄","k":0} +{"g":"single","s":"𑑆","k":0} +{"g":"single","s":"𑑇","k":1} +{"g":"single","s":"𑑊","k":1} +{"g":"single","s":"𑑞","k":0} +{"g":"single","s":"𑑟","k":1} +{"g":"single","s":"𑑡","k":1} +{"g":"single","s":"𑒀","k":1} +{"g":"single","s":"𑒯","k":1} +{"g":"single","s":"𑒰","k":0} +{"g":"single","s":"𑒳","k":0} +{"g":"single","s":"𑒸","k":0} +{"g":"single","s":"𑒺","k":0} +{"g":"single","s":"𑒿","k":0} +{"g":"single","s":"𑓀","k":0} +{"g":"single","s":"𑓂","k":0} +{"g":"single","s":"𑓃","k":0} +{"g":"single","s":"𑓄","k":1} +{"g":"single","s":"𑓅","k":1} +{"g":"single","s":"𑓇","k":1} +{"g":"single","s":"𑖀","k":1} +{"g":"single","s":"𑖮","k":1} +{"g":"single","s":"𑖲","k":0} +{"g":"single","s":"𑖵","k":0} +{"g":"single","s":"𑖺","d":"𑖺","k":0} +{"g":"single","s":"𑖼","k":0} +{"g":"single","s":"𑖽","k":0} +{"g":"single","s":"𑖿","k":0} +{"g":"single","s":"𑗀","k":0} +{"g":"single","s":"𑗘","k":1} +{"g":"single","s":"𑗛","k":1} +{"g":"single","s":"𑗜","k":0} +{"g":"single","s":"𑗝","k":0} +{"g":"single","s":"𑘀","k":1} +{"g":"single","s":"𑘯","k":1} +{"g":"single","s":"𑘳","k":0} +{"g":"single","s":"𑘺","k":0} +{"g":"single","s":"𑘽","k":0} +{"g":"single","s":"𑘿","k":0} +{"g":"single","s":"𑙀","k":0} +{"g":"single","s":"𑙄","k":1} +{"g":"single","s":"𑚀","k":1} +{"g":"single","s":"𑚪","k":1} +{"g":"single","s":"𑚫","k":0} +{"g":"single","s":"𑚭","k":0} +{"g":"single","s":"𑚰","k":0} +{"g":"single","s":"𑚵","k":0} +{"g":"single","s":"𑚷","k":0} +{"g":"single","s":"𑚸","k":1} +{"g":"single","s":"𑜀","k":1} +{"g":"single","s":"𑜚","k":1} +{"g":"single","s":"𑜝","k":0} +{"g":"single","s":"𑜟","k":0} +{"g":"single","s":"𑜢","k":0} +{"g":"single","s":"𑜥","k":0} +{"g":"single","s":"𑜧","k":0} +{"g":"single","s":"𑜫","k":0} +{"g":"single","s":"𑝀","k":1} +{"g":"single","s":"𑝆","k":1} +{"g":"single","s":"𑠀","k":1} +{"g":"single","s":"𑠫","k":1} +{"g":"single","s":"𑠯","k":0} +{"g":"single","s":"𑠷","k":0} +{"g":"single","s":"𑠹","k":0} +{"g":"single","s":"𑠺","k":0} +{"g":"single","s":"𑢠","l":"𑣀","k":3} +{"g":"single","s":"𑢿","l":"𑣟","k":3} +{"g":"single","s":"𑣟","k":1} +{"g":"single","s":"𑣿","k":1} +{"g":"single","s":"𑤆","k":1} +{"g":"single","s":"𑤉","k":1} +{"g":"single","s":"𑤌","k":1} +{"g":"single","s":"𑤓","k":1} +{"g":"single","s":"𑤕","k":1} +{"g":"single","s":"𑤖","k":1} +{"g":"single","s":"𑤘","k":1} +{"g":"single","s":"𑤯","k":1} +{"g":"single","s":"𑤻","k":0} +{"g":"single","s":"𑤼","k":0} +{"g":"single","s":"𑤾","k":0} +{"g":"single","s":"𑤿","k":1} +{"g":"single","s":"𑥁","k":1} +{"g":"single","s":"𑥃","k":0} +{"g":"single","s":"𑦠","k":1} +{"g":"single","s":"𑦧","k":1} +{"g":"single","s":"𑦪","k":1} +{"g":"single","s":"𑧐","k":1} +{"g":"single","s":"𑧔","k":0} +{"g":"single","s":"𑧗","k":0} +{"g":"single","s":"𑧚","k":0} +{"g":"single","s":"𑧛","k":0} +{"g":"single","s":"𑧠","k":0} +{"g":"single","s":"𑧡","k":1} +{"g":"single","s":"𑧣","k":1} +{"g":"single","s":"𑨀","k":1} +{"g":"single","s":"𑨁","k":0} +{"g":"single","s":"𑨊","k":0} +{"g":"single","s":"𑨋","k":1} +{"g":"single","s":"𑨲","k":1} +{"g":"single","s":"𑨳","k":0} +{"g":"single","s":"𑨸","k":0} +{"g":"single","s":"𑨺","k":1} +{"g":"single","s":"𑨻","k":0} +{"g":"single","s":"𑨾","k":0} +{"g":"single","s":"𑩇","k":0} +{"g":"single","s":"𑩐","k":1} +{"g":"single","s":"𑩑","k":0} +{"g":"single","s":"𑩖","k":0} +{"g":"single","s":"𑩙","k":0} +{"g":"single","s":"𑩛","k":0} +{"g":"single","s":"𑩜","k":1} +{"g":"single","s":"𑪉","k":1} +{"g":"single","s":"𑪊","k":0} +{"g":"single","s":"𑪖","k":0} +{"g":"single","s":"𑪘","k":0} +{"g":"single","s":"𑪙","k":0} +{"g":"single","s":"𑪝","k":1} +{"g":"single","s":"𑪰","k":1} +{"g":"single","s":"𑫸","k":1} +{"g":"single","s":"𑭠","k":0} +{"g":"single","s":"𑭢","k":0} +{"g":"single","s":"𑭤","k":0} +{"g":"single","s":"𑭦","k":0} +{"g":"single","s":"𑯀","k":1} +{"g":"single","s":"𑯠","k":1} +{"g":"single","s":"𑰀","k":1} +{"g":"single","s":"𑰈","k":1} +{"g":"single","s":"𑰊","k":1} +{"g":"single","s":"𑰮","k":1} +{"g":"single","s":"𑰰","k":0} +{"g":"single","s":"𑰶","k":0} +{"g":"single","s":"𑰸","k":0} +{"g":"single","s":"𑰽","k":0} +{"g":"single","s":"𑰿","k":0} +{"g":"single","s":"𑱀","k":1} +{"g":"single","s":"𑱲","k":1} +{"g":"single","s":"𑲏","k":1} +{"g":"single","s":"𑲒","k":0} +{"g":"single","s":"𑲧","k":0} +{"g":"single","s":"𑲪","k":0} +{"g":"single","s":"𑲰","k":0} +{"g":"single","s":"𑲲","k":0} +{"g":"single","s":"𑲳","k":0} +{"g":"single","s":"𑲵","k":0} +{"g":"single","s":"𑲶","k":0} +{"g":"single","s":"𑴀","k":1} +{"g":"single","s":"𑴆","k":1} +{"g":"single","s":"𑴈","k":1} +{"g":"single","s":"𑴉","k":1} +{"g":"single","s":"𑴋","k":1} +{"g":"single","s":"𑴰","k":1} +{"g":"single","s":"𑴱","k":0} +{"g":"single","s":"𑴶","k":0} +{"g":"single","s":"𑴺","k":0} +{"g":"single","s":"𑴼","k":0} +{"g":"single","s":"𑴽","k":0} +{"g":"single","s":"𑴿","k":0} +{"g":"single","s":"𑵅","k":0} +{"g":"single","s":"𑵆","k":1} +{"g":"single","s":"𑵇","k":0} +{"g":"single","s":"𑵠","k":1} +{"g":"single","s":"𑵥","k":1} +{"g":"single","s":"𑵧","k":1} +{"g":"single","s":"𑵨","k":1} +{"g":"single","s":"𑵪","k":1} +{"g":"single","s":"𑶉","k":1} +{"g":"single","s":"𑶐","k":0} +{"g":"single","s":"𑶑","k":0} +{"g":"single","s":"𑶕","k":0} +{"g":"single","s":"𑶗","k":0} +{"g":"single","s":"𑶘","k":1} +{"g":"single","s":"𑶰","k":1} +{"g":"single","s":"𑷙","k":1} +{"g":"single","s":"𑷛","k":1} +{"g":"single","s":"𑻠","k":1} +{"g":"single","s":"𑻲","k":1} +{"g":"single","s":"𑻳","k":0} +{"g":"single","s":"𑻴","k":0} +{"g":"single","s":"𑼀","k":0} +{"g":"single","s":"𑼁","k":0} +{"g":"single","s":"𑼂","k":1} +{"g":"single","s":"𑼄","k":1} +{"g":"single","s":"𑼐","k":1} +{"g":"single","s":"𑼒","k":1} +{"g":"single","s":"𑼳","k":1} +{"g":"single","s":"𑼶","k":0} +{"g":"single","s":"𑼺","k":0} +{"g":"single","s":"𑽀","k":0} +{"g":"single","s":"𑽂","k":0} +{"g":"single","s":"𑽚","k":0} +{"g":"single","s":"𑾰","k":1} +{"g":"single","s":"𒀀","k":1} +{"g":"single","s":"𒎙","k":1} +{"g":"single","s":"𒒀","k":1} +{"g":"single","s":"𒓩","k":1} +{"g":"single","s":"𒕃","k":1} +{"g":"single","s":"𒾐","k":1} +{"g":"single","s":"𒿰","k":1} +{"g":"single","s":"𓀀","k":1} +{"g":"single","s":"𓐯","k":1} +{"g":"single","s":"𓐰","k":0} +{"g":"single","s":"𓑀","k":0} +{"g":"single","s":"𓑁","k":1} +{"g":"single","s":"𓑆","k":1} +{"g":"single","s":"𓑇","k":0} +{"g":"single","s":"𓑕","k":0} +{"g":"single","s":"𓑠","k":1} +{"g":"single","s":"𓡰","k":1} +{"g":"single","s":"𔏺","k":1} +{"g":"single","s":"𔐀","k":1} +{"g":"single","s":"𔙆","k":1} +{"g":"single","s":"𔯷","k":0} +{"g":"single","s":"𕽾","k":0} +{"g":"single","s":"𖄀","k":1} +{"g":"single","s":"𖄝","k":1} +{"g":"single","s":"𖄞","k":0} +{"g":"single","s":"𖄠","k":0} +{"g":"single","s":"𖄦","d":"𖄦","k":0} +{"g":"single","s":"𖄩","k":0} +{"g":"single","s":"𖄭","k":0} +{"g":"single","s":"𖄯","k":0} +{"g":"single","s":"𖠀","k":1} +{"g":"single","s":"𖨸","k":1} +{"g":"single","s":"𖩀","k":1} +{"g":"single","s":"𖩞","k":1} +{"g":"single","s":"𖩰","k":1} +{"g":"single","s":"𖪾","k":1} +{"g":"single","s":"𖫐","k":1} +{"g":"single","s":"𖫭","k":1} +{"g":"single","s":"𖫰","k":0} +{"g":"single","s":"𖫴","k":0} +{"g":"single","s":"𖬀","k":1} +{"g":"single","s":"𖬯","k":1} +{"g":"single","s":"𖬰","k":0} +{"g":"single","s":"𖬳","k":0} +{"g":"single","s":"𖬶","k":0} +{"g":"single","s":"𖭀","k":1} +{"g":"single","s":"𖭃","k":1} +{"g":"single","s":"𖭣","k":1} +{"g":"single","s":"𖭷","k":1} +{"g":"single","s":"𖭽","k":1} +{"g":"single","s":"𖮏","k":1} +{"g":"single","s":"𖵀","k":1} +{"g":"single","s":"𖵂","k":1} +{"g":"single","s":"𖵧","k":1} +{"g":"single","s":"𖵫","k":1} +{"g":"single","s":"𖵬","k":1} +{"g":"single","s":"𖹀","l":"𖹠","k":3} +{"g":"single","s":"𖹟","l":"𖹿","k":3} +{"g":"single","s":"𖹿","k":1} +{"g":"single","s":"𖺠","l":"𖺻","k":3} +{"g":"single","s":"𖺸","l":"𖻓","k":3} +{"g":"single","s":"𖺻","k":1} +{"g":"single","s":"𖻓","k":1} +{"g":"single","s":"𖼀","k":1} +{"g":"single","s":"𖽊","k":1} +{"g":"single","s":"𖽏","k":0} +{"g":"single","s":"𖽐","k":1} +{"g":"single","s":"𖾏","k":0} +{"g":"single","s":"𖾓","k":1} +{"g":"single","s":"𖾟","k":1} +{"g":"single","s":"𖿠","k":1} +{"g":"single","s":"𖿡","k":1} +{"g":"single","s":"𖿣","k":1} +{"g":"single","s":"𖿤","k":0} +{"g":"single","s":"𖿲","k":1} +{"g":"single","s":"𖿳","k":1} +{"g":"single","s":"𗀀","k":1} +{"g":"single","s":"𗌅","k":1} +{"g":"single","s":"𘚌","k":1} +{"g":"single","s":"𘳕","k":1} +{"g":"single","s":"𘳿","k":1} +{"g":"single","s":"𘴞","k":1} +{"g":"single","s":"𘶀","k":1} +{"g":"single","s":"𘷲","k":1} +{"g":"single","s":"𙨓","k":0} +{"g":"single","s":"𚶚","k":0} +{"g":"single","s":"𚿰","k":1} +{"g":"single","s":"𚿳","k":1} +{"g":"single","s":"𚿵","k":1} +{"g":"single","s":"𚿻","k":1} +{"g":"single","s":"𚿽","k":1} +{"g":"single","s":"𚿾","k":1} +{"g":"single","s":"𛀀","k":1} +{"g":"single","s":"𛄢","k":1} +{"g":"single","s":"𛄲","k":1} +{"g":"single","s":"𛅐","k":1} +{"g":"single","s":"𛅒","k":1} +{"g":"single","s":"𛅕","k":1} +{"g":"single","s":"𛅤","k":1} +{"g":"single","s":"𛅧","k":1} +{"g":"single","s":"𛅰","k":1} +{"g":"single","s":"𛋻","k":1} +{"g":"single","s":"𛰀","k":1} +{"g":"single","s":"𛱪","k":1} +{"g":"single","s":"𛱰","k":1} +{"g":"single","s":"𛱼","k":1} +{"g":"single","s":"𛲀","k":1} +{"g":"single","s":"𛲈","k":1} +{"g":"single","s":"𛲐","k":1} +{"g":"single","s":"𛲙","k":1} +{"g":"single","s":"𛲝","k":0} +{"g":"single","s":"𛲞","k":0} +{"g":"single","s":"𛲠","k":0} +{"g":"single","s":"𛲣","k":0} +{"g":"single","s":"𜄡","k":0} +{"g":"single","s":"𜼀","k":0} +{"g":"single","s":"𜼭","k":0} +{"g":"single","s":"𜼰","k":0} +{"g":"single","s":"𜽆","k":0} +{"g":"single","s":"𝅗𝅥","c":"𝅗𝅥","d":"𝅗𝅥","k":0} +{"g":"single","s":"𝅘𝅥𝅮","c":"𝅘𝅥𝅮","d":"𝅘𝅥𝅮","k":0} +{"g":"single","s":"𝅘𝅥𝅲","c":"𝅘𝅥𝅲","d":"𝅘𝅥𝅲","k":0} +{"g":"single","s":"𝅦","k":0} +{"g":"single","s":"𝅧","k":0} +{"g":"single","s":"𝅩","k":0} +{"g":"single","s":"𝅱","k":0} +{"g":"single","s":"𝅳","k":0} +{"g":"single","s":"𝆁","k":0} +{"g":"single","s":"𝆂","k":0} +{"g":"single","s":"𝆅","k":0} +{"g":"single","s":"𝆋","k":0} +{"g":"single","s":"𝆪","k":0} +{"g":"single","s":"𝆭","k":0} +{"g":"single","s":"𝆹𝅥","c":"𝆹𝅥","d":"𝆹𝅥","k":0} +{"g":"single","s":"𝆺𝅥𝅮","c":"𝆺𝅥𝅮","d":"𝆺𝅥𝅮","k":0} +{"g":"single","s":"𝆺𝅥𝅯","c":"𝆺𝅥𝅯","d":"𝆺𝅥𝅯","k":0} +{"g":"single","s":"𝉂","k":0} +{"g":"single","s":"𝉄","k":0} +{"g":"single","s":"𝐀","k":3} +{"g":"single","s":"𝐙","k":3} +{"g":"single","s":"𝐴","k":3} +{"g":"single","s":"𝑍","k":3} +{"g":"single","s":"𝑔","k":1} +{"g":"single","s":"𝑖","k":1} +{"g":"single","s":"𝑨","k":3} +{"g":"single","s":"𝒁","k":3} +{"g":"single","s":"𝒜","k":3} +{"g":"single","s":"𝒞","k":3} +{"g":"single","s":"𝒟","k":3} +{"g":"single","s":"𝒢","k":3} +{"g":"single","s":"𝒥","k":3} +{"g":"single","s":"𝒦","k":3} +{"g":"single","s":"𝒨","k":0} +{"g":"single","s":"𝒩","k":3} +{"g":"single","s":"𝒬","k":3} +{"g":"single","s":"𝒮","k":3} +{"g":"single","s":"𝒵","k":3} +{"g":"single","s":"𝒹","k":1} +{"g":"single","s":"𝒻","k":1} +{"g":"single","s":"𝒽","k":1} +{"g":"single","s":"𝓃","k":1} +{"g":"single","s":"𝓅","k":1} +{"g":"single","s":"𝓐","k":3} +{"g":"single","s":"𝓩","k":3} +{"g":"single","s":"𝔄","k":3} +{"g":"single","s":"𝔅","k":3} +{"g":"single","s":"𝔇","k":3} +{"g":"single","s":"𝔊","k":3} +{"g":"single","s":"𝔍","k":3} +{"g":"single","s":"𝔔","k":3} +{"g":"single","s":"𝔖","k":3} +{"g":"single","s":"𝔜","k":3} +{"g":"single","s":"𝔞","k":1} +{"g":"single","s":"𝔸","k":3} +{"g":"single","s":"𝔹","k":3} +{"g":"single","s":"𝔻","k":3} +{"g":"single","s":"𝔾","k":3} +{"g":"single","s":"𝕀","k":3} +{"g":"single","s":"𝕄","k":3} +{"g":"single","s":"𝕆","k":3} +{"g":"single","s":"𝕊","k":3} +{"g":"single","s":"𝕐","k":3} +{"g":"single","s":"𝕒","k":1} +{"g":"single","s":"𝕬","k":3} +{"g":"single","s":"𝖅","k":3} +{"g":"single","s":"𝖠","k":3} +{"g":"single","s":"𝖹","k":3} +{"g":"single","s":"𝗔","k":3} +{"g":"single","s":"𝗭","k":3} +{"g":"single","s":"𝘈","k":3} +{"g":"single","s":"𝘡","k":3} +{"g":"single","s":"𝘼","k":3} +{"g":"single","s":"𝙕","k":3} +{"g":"single","s":"𝙰","k":3} +{"g":"single","s":"𝚉","k":3} +{"g":"single","s":"𝚥","k":1} +{"g":"single","s":"𝚨","k":3} +{"g":"single","s":"𝛀","k":3} +{"g":"single","s":"𝛂","k":1} +{"g":"single","s":"𝛚","k":1} +{"g":"single","s":"𝛜","k":1} +{"g":"single","s":"𝛢","k":3} +{"g":"single","s":"𝛺","k":3} +{"g":"single","s":"𝛼","k":1} +{"g":"single","s":"𝜔","k":1} +{"g":"single","s":"𝜖","k":1} +{"g":"single","s":"𝜜","k":3} +{"g":"single","s":"𝜴","k":3} +{"g":"single","s":"𝜶","k":1} +{"g":"single","s":"𝝎","k":1} +{"g":"single","s":"𝝐","k":1} +{"g":"single","s":"𝝖","k":3} +{"g":"single","s":"𝝮","k":3} +{"g":"single","s":"𝝰","k":1} +{"g":"single","s":"𝞈","k":1} +{"g":"single","s":"𝞊","k":1} +{"g":"single","s":"𝞐","k":3} +{"g":"single","s":"𝞨","k":3} +{"g":"single","s":"𝞪","k":1} +{"g":"single","s":"𝟂","k":1} +{"g":"single","s":"𝟄","k":1} +{"g":"single","s":"𝟊","k":3} +{"g":"single","s":"𝟋","k":1} +{"g":"single","s":"𝨀","k":0} +{"g":"single","s":"𝨶","k":0} +{"g":"single","s":"𝨻","k":0} +{"g":"single","s":"𝩬","k":0} +{"g":"single","s":"𝩵","k":0} +{"g":"single","s":"𝪄","k":0} +{"g":"single","s":"𝪛","k":0} +{"g":"single","s":"𝪟","k":0} +{"g":"single","s":"𝪡","k":0} +{"g":"single","s":"𝪯","k":0} +{"g":"single","s":"𝼀","k":1} +{"g":"single","s":"𝼉","k":1} +{"g":"single","s":"𝼋","k":1} +{"g":"single","s":"𝼞","k":1} +{"g":"single","s":"𝼥","k":1} +{"g":"single","s":"𝼪","k":1} +{"g":"single","s":"𞀀","k":0} +{"g":"single","s":"𞀆","k":0} +{"g":"single","s":"𞀈","k":0} +{"g":"single","s":"𞀉","k":0} +{"g":"single","s":"𞀑","k":0} +{"g":"single","s":"𞀘","k":0} +{"g":"single","s":"𞀛","k":0} +{"g":"single","s":"𞀡","k":0} +{"g":"single","s":"𞀣","k":0} +{"g":"single","s":"𞀤","k":0} +{"g":"single","s":"𞀦","k":0} +{"g":"single","s":"𞀪","k":0} +{"g":"single","s":"𞀰","k":1} +{"g":"single","s":"𞁭","k":1} +{"g":"single","s":"𞂏","k":0} +{"g":"single","s":"𞄀","k":1} +{"g":"single","s":"𞄬","k":1} +{"g":"single","s":"𞄰","k":0} +{"g":"single","s":"𞄱","k":0} +{"g":"single","s":"𞄷","k":1} +{"g":"single","s":"𞄽","k":1} +{"g":"single","s":"𞅎","k":1} +{"g":"single","s":"𞊐","k":1} +{"g":"single","s":"𞊭","k":1} +{"g":"single","s":"𞊮","k":0} +{"g":"single","s":"𞋀","k":1} +{"g":"single","s":"𞋫","k":1} +{"g":"single","s":"𞋬","k":0} +{"g":"single","s":"𞋭","k":0} +{"g":"single","s":"𞋯","k":0} +{"g":"single","s":"𞓐","k":1} +{"g":"single","s":"𞓫","k":1} +{"g":"single","s":"𞓯","k":0} +{"g":"single","s":"𞗐","k":1} +{"g":"single","s":"𞗭","k":1} +{"g":"single","s":"𞗮","k":0} +{"g":"single","s":"𞗯","k":0} +{"g":"single","s":"𞗰","k":1} +{"g":"single","s":"𞛀","k":1} +{"g":"single","s":"𞛞","k":1} +{"g":"single","s":"𞛠","k":1} +{"g":"single","s":"𞛢","k":1} +{"g":"single","s":"𞛣","k":0} +{"g":"single","s":"𞛤","k":1} +{"g":"single","s":"𞛥","k":1} +{"g":"single","s":"𞛦","k":0} +{"g":"single","s":"𞛧","k":1} +{"g":"single","s":"𞛭","k":1} +{"g":"single","s":"𞛮","k":0} +{"g":"single","s":"𞛯","k":0} +{"g":"single","s":"𞛰","k":1} +{"g":"single","s":"𞛴","k":1} +{"g":"single","s":"𞛵","k":0} +{"g":"single","s":"𞛾","k":1} +{"g":"single","s":"𞛿","k":1} +{"g":"single","s":"𞟠","k":1} +{"g":"single","s":"𞟦","k":1} +{"g":"single","s":"𞟨","k":1} +{"g":"single","s":"𞟫","k":1} +{"g":"single","s":"𞟭","k":1} +{"g":"single","s":"𞟮","k":1} +{"g":"single","s":"𞟰","k":1} +{"g":"single","s":"𞟾","k":1} +{"g":"single","s":"𞠀","k":1} +{"g":"single","s":"𞠯","k":1} +{"g":"single","s":"𞣄","k":1} +{"g":"single","s":"𞣐","k":0} +{"g":"single","s":"𞣒","k":0} +{"g":"single","s":"𞣖","k":0} +{"g":"single","s":"𞤀","l":"𞤢","k":3} +{"g":"single","s":"𞤡","l":"𞥃","k":3} +{"g":"single","s":"𞥃","k":1} +{"g":"single","s":"𞥄","k":0} +{"g":"single","s":"𞥇","k":0} +{"g":"single","s":"𞥋","k":1} +{"g":"single","s":"𞸀","k":1} +{"g":"single","s":"𞸃","k":1} +{"g":"single","s":"𞸅","k":1} +{"g":"single","s":"𞸟","k":1} +{"g":"single","s":"𞸡","k":1} +{"g":"single","s":"𞸢","k":1} +{"g":"single","s":"𞸤","k":1} +{"g":"single","s":"𞸧","k":1} +{"g":"single","s":"𞸩","k":1} +{"g":"single","s":"𞸲","k":1} +{"g":"single","s":"𞸴","k":1} +{"g":"single","s":"𞸷","k":1} +{"g":"single","s":"𞸹","k":1} +{"g":"single","s":"𞸻","k":1} +{"g":"single","s":"𞹂","k":1} +{"g":"single","s":"𞹇","k":1} +{"g":"single","s":"𞹉","k":1} +{"g":"single","s":"𞹋","k":1} +{"g":"single","s":"𞹍","k":1} +{"g":"single","s":"𞹏","k":1} +{"g":"single","s":"𞹑","k":1} +{"g":"single","s":"𞹒","k":1} +{"g":"single","s":"𞹔","k":1} +{"g":"single","s":"𞹗","k":1} +{"g":"single","s":"𞹙","k":1} +{"g":"single","s":"𞹛","k":1} +{"g":"single","s":"𞹝","k":1} +{"g":"single","s":"𞹟","k":1} +{"g":"single","s":"𞹡","k":1} +{"g":"single","s":"𞹢","k":1} +{"g":"single","s":"𞹤","k":1} +{"g":"single","s":"𞹧","k":1} +{"g":"single","s":"𞹪","k":1} +{"g":"single","s":"𞹬","k":1} +{"g":"single","s":"𞹲","k":1} +{"g":"single","s":"𞹴","k":1} +{"g":"single","s":"𞹷","k":1} +{"g":"single","s":"𞹹","k":1} +{"g":"single","s":"𞹼","k":1} +{"g":"single","s":"𞹾","k":1} +{"g":"single","s":"𞺀","k":1} +{"g":"single","s":"𞺉","k":1} +{"g":"single","s":"𞺋","k":1} +{"g":"single","s":"𞺛","k":1} +{"g":"single","s":"𞺡","k":1} +{"g":"single","s":"𞺣","k":1} +{"g":"single","s":"𞺥","k":1} +{"g":"single","s":"𞺩","k":1} +{"g":"single","s":"𞺫","k":1} +{"g":"single","s":"𞺻","k":1} +{"g":"single","s":"🄰","k":0} +{"g":"single","s":"🅉","k":0} +{"g":"single","s":"🅐","k":0} +{"g":"single","s":"🅩","k":0} +{"g":"single","s":"🅰","k":0} +{"g":"single","s":"🆉","k":0} +{"g":"single","s":"🏻","k":0} +{"g":"single","s":"🏿","k":0} +{"g":"single","s":"🮶","k":0} +{"g":"single","s":"𠀀","k":1} +{"g":"single","s":"𠼽","k":1} +{"g":"single","s":"𢋄","k":1} +{"g":"single","s":"𣙋","k":1} +{"g":"single","s":"𤧒","k":1} +{"g":"single","s":"𥵙","k":1} +{"g":"single","s":"𧃠","k":1} +{"g":"single","s":"𨑧","k":1} +{"g":"single","s":"𩟮","k":1} +{"g":"single","s":"𪛟","k":1} +{"g":"single","s":"𪜀","k":1} +{"g":"single","s":"𪭵","k":1} +{"g":"single","s":"𫠝","k":1} +{"g":"single","s":"𫠠","k":1} +{"g":"single","s":"𫻼","k":1} +{"g":"single","s":"𬺭","k":1} +{"g":"single","s":"𬺰","k":1} +{"g":"single","s":"𭊃","k":1} +{"g":"single","s":"𮘊","k":1} +{"g":"single","s":"𮯠","k":1} +{"g":"single","s":"𮯰","k":1} +{"g":"single","s":"𮹝","k":1} +{"g":"single","s":"丽","c":"丽","d":"丽","k":1} +{"g":"single","s":"侮","c":"侮","d":"侮","k":1} +{"g":"single","s":"𠘺","c":"𠘺","d":"𠘺","k":1} +{"g":"single","s":"再","c":"再","d":"再","k":1} +{"g":"single","s":"凵","c":"凵","d":"凵","k":1} +{"g":"single","s":"勇","c":"勇","d":"勇","k":1} +{"g":"single","s":"卑","c":"卑","d":"卑","k":1} +{"g":"single","s":"灰","c":"灰","d":"灰","k":1} +{"g":"single","s":"吸","c":"吸","d":"吸","k":1} +{"g":"single","s":"善","c":"善","d":"善","k":1} +{"g":"single","s":"圗","c":"圗","d":"圗","k":1} +{"g":"single","s":"型","c":"型","d":"型","k":1} +{"g":"single","s":"多","c":"多","d":"多","k":1} +{"g":"single","s":"姘","c":"姘","d":"姘","k":1} +{"g":"single","s":"寃","c":"寃","d":"寃","k":1} +{"g":"single","s":"尢","c":"尢","d":"尢","k":1} +{"g":"single","s":"𡷦","c":"𡷦","d":"𡷦","k":1} +{"g":"single","s":"帨","c":"帨","d":"帨","k":1} +{"g":"single","s":"庶","c":"庶","d":"庶","k":1} +{"g":"single","s":"弢","c":"弢","d":"弢","k":1} +{"g":"single","s":"忍","c":"忍","d":"忍","k":1} +{"g":"single","s":"惇","c":"惇","d":"惇","k":1} +{"g":"single","s":"憤","c":"憤","d":"憤","k":1} +{"g":"single","s":"抱","c":"抱","d":"抱","k":1} +{"g":"single","s":"揤","c":"揤","d":"揤","k":1} +{"g":"single","s":"撝","c":"撝","d":"撝","k":1} +{"g":"single","s":"晉","c":"晉","d":"晉","k":1} +{"g":"single","s":"暜","c":"暜","d":"暜","k":1} +{"g":"single","s":"𣏃","c":"𣏃","d":"𣏃","k":1} +{"g":"single","s":"栟","c":"栟","d":"栟","k":1} +{"g":"single","s":"櫛","c":"櫛","d":"櫛","k":1} +{"g":"single","s":"殺","c":"殺","d":"殺","k":1} +{"g":"single","s":"泍","c":"泍","d":"泍","k":1} +{"g":"single","s":"涅","c":"涅","d":"涅","k":1} +{"g":"single","s":"𣻑","c":"𣻑","d":"𣻑","k":1} +{"g":"single","s":"瀛","c":"瀛","d":"瀛","k":1} +{"g":"single","s":"𤉣","c":"𤉣","d":"𤉣","k":1} +{"g":"single","s":"犕","c":"犕","d":"犕","k":1} +{"g":"single","s":"㺸","c":"㺸","d":"㺸","k":1} +{"g":"single","s":"𤰶","c":"𤰶","d":"𤰶","k":1} +{"g":"single","s":"𥁄","c":"𥁄","d":"𥁄","k":1} +{"g":"single","s":"眞","c":"眞","d":"眞","k":1} +{"g":"single","s":"𥐝","c":"𥐝","d":"𥐝","k":1} +{"g":"single","s":"𥛅","c":"𥛅","d":"𥛅","k":1} +{"g":"single","s":"𥪧","c":"𥪧","d":"𥪧","k":1} +{"g":"single","s":"𥲀","c":"𥲀","d":"𥲀","k":1} +{"g":"single","s":"䌁","c":"䌁","d":"䌁","k":1} +{"g":"single","s":"𦋙","c":"𦋙","d":"𦋙","k":1} +{"g":"single","s":"聠","c":"聠","d":"聠","k":1} +{"g":"single","s":"脾","c":"脾","d":"脾","k":1} +{"g":"single","s":"辞","c":"辞","d":"辞","k":1} +{"g":"single","s":"芝","c":"芝","d":"芝","k":1} +{"g":"single","s":"芽","c":"芽","d":"芽","k":1} +{"g":"single","s":"莽","c":"莽","d":"莽","k":1} +{"g":"single","s":"𦵫","c":"𦵫","d":"𦵫","k":1} +{"g":"single","s":"𦼬","c":"𦼬","d":"𦼬","k":1} +{"g":"single","s":"虧","c":"虧","d":"虧","k":1} +{"g":"single","s":"蝫","c":"蝫","d":"蝫","k":1} +{"g":"single","s":"𧙧","c":"𧙧","d":"𧙧","k":1} +{"g":"single","s":"䚾","c":"䚾","d":"䚾","k":1} +{"g":"single","s":"賁","c":"賁","d":"賁","k":1} +{"g":"single","s":"𠣞","c":"𠣞","d":"𠣞","k":1} +{"g":"single","s":"𨜮","c":"𨜮","d":"𨜮","k":1} +{"g":"single","s":"𨯺","c":"𨯺","d":"𨯺","k":1} +{"g":"single","s":"霣","c":"霣","d":"霣","k":1} +{"g":"single","s":"𩒖","c":"𩒖","d":"𩒖","k":1} +{"g":"single","s":"馧","c":"馧","d":"馧","k":1} +{"g":"single","s":"䳎","c":"䳎","d":"䳎","k":1} +{"g":"single","s":"麻","c":"麻","d":"麻","k":1} +{"g":"single","s":"𪘀","c":"𪘀","d":"𪘀","k":1} +{"g":"single","s":"𰀀","k":1} +{"g":"single","s":"𰴘","k":1} +{"g":"single","s":"𱍊","k":1} +{"g":"single","s":"𱍐","k":1} +{"g":"single","s":"𲂟","k":1} +{"g":"single","s":"𳐦","k":1} +{"g":"single","s":"𳑹","k":1} +{"g":"single","s":"𴞭","k":0} +{"g":"single","s":"𵬴","k":0} +{"g":"single","s":"𶺻","k":0} +{"g":"single","s":"𸉂","k":0} +{"g":"single","s":"𹗉","k":0} +{"g":"single","s":"𺥐","k":0} +{"g":"single","s":"𻳗","k":0} +{"g":"single","s":"𽁞","k":0} +{"g":"single","s":"𾏥","k":0} +{"g":"single","s":"𿝬","k":0} +{"g":"single","s":"񀫳","k":0} +{"g":"single","s":"񁹺","k":0} +{"g":"single","s":"񃈁","k":0} +{"g":"single","s":"񄖈","k":0} +{"g":"single","s":"񅤏","k":0} +{"g":"single","s":"񆲖","k":0} +{"g":"single","s":"񈀝","k":0} +{"g":"single","s":"񉎤","k":0} +{"g":"single","s":"񊜫","k":0} +{"g":"single","s":"񋪲","k":0} +{"g":"single","s":"񌸹","k":0} +{"g":"single","s":"񎇀","k":0} +{"g":"single","s":"񏕇","k":0} +{"g":"single","s":"񐣎","k":0} +{"g":"single","s":"񑱕","k":0} +{"g":"single","s":"񒿜","k":0} +{"g":"single","s":"񔍣","k":0} +{"g":"single","s":"񕛪","k":0} +{"g":"single","s":"񖩱","k":0} +{"g":"single","s":"񗷸","k":0} +{"g":"single","s":"񙅿","k":0} +{"g":"single","s":"񚔆","k":0} +{"g":"single","s":"񛢍","k":0} +{"g":"single","s":"񜰔","k":0} +{"g":"single","s":"񝾛","k":0} +{"g":"single","s":"񟌢","k":0} +{"g":"single","s":"񠚩","k":0} +{"g":"single","s":"񡨰","k":0} +{"g":"single","s":"񢶷","k":0} +{"g":"single","s":"񤄾","k":0} +{"g":"single","s":"񥓅","k":0} +{"g":"single","s":"񦡌","k":0} +{"g":"single","s":"񧯓","k":0} +{"g":"single","s":"񨽚","k":0} +{"g":"single","s":"񪋡","k":0} +{"g":"single","s":"񫙨","k":0} +{"g":"single","s":"񬧯","k":0} +{"g":"single","s":"񭵶","k":0} +{"g":"single","s":"񯃽","k":0} +{"g":"single","s":"񰒄","k":0} +{"g":"single","s":"񱠋","k":0} +{"g":"single","s":"񲮒","k":0} +{"g":"single","s":"񳼙","k":0} +{"g":"single","s":"񵊠","k":0} +{"g":"single","s":"񶘧","k":0} +{"g":"single","s":"񷦮","k":0} +{"g":"single","s":"񸴵","k":0} +{"g":"single","s":"񺂼","k":0} +{"g":"single","s":"񻑃","k":0} +{"g":"single","s":"񼟊","k":0} +{"g":"single","s":"񽭑","k":0} +{"g":"single","s":"񾻘","k":0} +{"g":"single","s":"򀉟","k":0} +{"g":"single","s":"򁗦","k":0} +{"g":"single","s":"򂥭","k":0} +{"g":"single","s":"򃳴","k":0} +{"g":"single","s":"򅁻","k":0} +{"g":"single","s":"򆐂","k":0} +{"g":"single","s":"򇞉","k":0} +{"g":"single","s":"򈬐","k":0} +{"g":"single","s":"򉺗","k":0} +{"g":"single","s":"򋈞","k":0} +{"g":"single","s":"򌖥","k":0} +{"g":"single","s":"򍤬","k":0} +{"g":"single","s":"򎲳","k":0} +{"g":"single","s":"򐀺","k":0} +{"g":"single","s":"򑏁","k":0} +{"g":"single","s":"򒝈","k":0} +{"g":"single","s":"򓫏","k":0} +{"g":"single","s":"򔹖","k":0} +{"g":"single","s":"򖇝","k":0} +{"g":"single","s":"򗕤","k":0} +{"g":"single","s":"򘣫","k":0} +{"g":"single","s":"򙱲","k":0} +{"g":"single","s":"򚿹","k":0} +{"g":"single","s":"򜎀","k":0} +{"g":"single","s":"򝜇","k":0} +{"g":"single","s":"򞪎","k":0} +{"g":"single","s":"򟸕","k":0} +{"g":"single","s":"򡆜","k":0} +{"g":"single","s":"򢔣","k":0} +{"g":"single","s":"򣢪","k":0} +{"g":"single","s":"򤰱","k":0} +{"g":"single","s":"򥾸","k":0} +{"g":"single","s":"򧌿","k":0} +{"g":"single","s":"򨛆","k":0} +{"g":"single","s":"򩩍","k":0} +{"g":"single","s":"򪷔","k":0} +{"g":"single","s":"򬅛","k":0} +{"g":"single","s":"򭓢","k":0} +{"g":"single","s":"򮡩","k":0} +{"g":"single","s":"򯯰","k":0} +{"g":"single","s":"򰽷","k":0} +{"g":"single","s":"򲋾","k":0} +{"g":"single","s":"򳚅","k":0} +{"g":"single","s":"򴨌","k":0} +{"g":"single","s":"򵶓","k":0} +{"g":"single","s":"򷄚","k":0} +{"g":"single","s":"򸒡","k":0} +{"g":"single","s":"򹠨","k":0} +{"g":"single","s":"򺮯","k":0} +{"g":"single","s":"򻼶","k":0} +{"g":"single","s":"򽊽","k":0} +{"g":"single","s":"򾙄","k":0} +{"g":"single","s":"򿧋","k":0} +{"g":"single","s":"󀵒","k":0} +{"g":"single","s":"󂃙","k":0} +{"g":"single","s":"󃑠","k":0} +{"g":"single","s":"󄟧","k":0} +{"g":"single","s":"󅭮","k":0} +{"g":"single","s":"󆻵","k":0} +{"g":"single","s":"󈉼","k":0} +{"g":"single","s":"󉘃","k":0} +{"g":"single","s":"󊦊","k":0} +{"g":"single","s":"󋴑","k":0} +{"g":"single","s":"󍂘","k":0} +{"g":"single","s":"󎐟","k":0} +{"g":"single","s":"󏞦","k":0} +{"g":"single","s":"󐬭","k":0} +{"g":"single","s":"󑺴","k":0} +{"g":"single","s":"󓈻","k":0} +{"g":"single","s":"󔗂","k":0} +{"g":"single","s":"󕥉","k":0} +{"g":"single","s":"󖳐","k":0} +{"g":"single","s":"󘁗","k":0} +{"g":"single","s":"󙏞","k":0} +{"g":"single","s":"󚝥","k":0} +{"g":"single","s":"󛫬","k":0} +{"g":"single","s":"󜹳","k":0} +{"g":"single","s":"󞇺","k":0} +{"g":"single","s":"󟖁","k":0} +{"g":"single","s":"󠀁","k":0} +{"g":"single","s":"󠀠","k":0} +{"g":"single","s":"󠁿","k":0} +{"g":"single","s":"󠄀","k":0} +{"g":"single","s":"󠇯","k":0} +{"g":"single","s":"󠤈","k":0} +{"g":"single","s":"󡲏","k":0} +{"g":"single","s":"󣀖","k":0} +{"g":"single","s":"󤎝","k":0} +{"g":"single","s":"󥜤","k":0} +{"g":"single","s":"󦪫","k":0} +{"g":"single","s":"󧸲","k":0} +{"g":"single","s":"󩆹","k":0} +{"g":"single","s":"󪕀","k":0} +{"g":"single","s":"󫣇","k":0} +{"g":"single","s":"󬱎","k":0} +{"g":"single","s":"󭿕","k":0} +{"g":"single","s":"󯍜","k":0} +{"g":"single","s":"󰛣","k":0} +{"g":"single","s":"󱩪","k":0} +{"g":"single","s":"󲷱","k":0} +{"g":"single","s":"󴅸","k":0} +{"g":"single","s":"󵓿","k":0} +{"g":"single","s":"󶢆","k":0} +{"g":"single","s":"󷰍","k":0} +{"g":"single","s":"󸾔","k":0} +{"g":"single","s":"󺌛","k":0} +{"g":"single","s":"󻚢","k":0} +{"g":"single","s":"󼨩","k":0} +{"g":"single","s":"󽶰","k":0} +{"g":"single","s":"󿄷","k":0} +{"g":"single","s":"􀒾","k":0} +{"g":"single","s":"􁡅","k":0} +{"g":"single","s":"􂯌","k":0} +{"g":"single","s":"􃽓","k":0} +{"g":"single","s":"􅋚","k":0} +{"g":"single","s":"􆙡","k":0} +{"g":"single","s":"􇧨","k":0} +{"g":"single","s":"􈵯","k":0} +{"g":"single","s":"􊃶","k":0} +{"g":"single","s":"􋑽","k":0} +{"g":"single","s":"􌠄","k":0} +{"g":"single","s":"􍮋","k":0} +{"g":"single","s":"􎼒","k":0} +{"g":"pair+base","s":"ωۨ𞄱"} +{"g":"pair+base","s":"A꙽︢","l":"a꙽︢"} +{"g":"pair+base","s":"ا᷎࿆","c":"ا᷎࿆","d":"ا᷎࿆"} +{"g":"pair+base","s":"α഼࢘"} +{"g":"pair+base","s":"A𖫴ࣖ","l":"a𖫴ࣖ"} +{"g":"pair+base","s":"ω̳̄"} +{"g":"pair+base","s":"и゙𞥅"} +{"g":"pair+base","s":"oⷦ𞀧"} +{"g":"pair+base","s":"eִ྇","c":"eִ྇","d":"eִ྇"} +{"g":"pair+base","s":"uֲ᪵","c":"uֲ᪵","d":"uֲ᪵"} +{"g":"pair+base","s":"и݂͟"} +{"g":"pair+base","s":"и᳦𐽎","c":"и᳦𐽎","d":"и᳦𐽎"} +{"g":"pair+base","s":"ωܴࠬ","c":"ωܴࠬ","d":"ωܴࠬ"} +{"g":"pair+base","s":"゙᷺᷏","c":"゙᷺᷏","d":"゙᷺᷏"} +{"g":"pair+base","s":"اᷤ꣧"} +{"g":"pair+base","s":"u֪݉"} +{"g":"pair+base","s":"u𑚷۬"} +{"g":"pair+base","s":"ا͎ᷓ"} +{"g":"pair+base","s":"u༵𞀈","c":"u༵𞀈","d":"u༵𞀈"} +{"g":"pair+base","s":"ω𑄳ۧ"} +{"g":"pair+base","s":"א᯦᪺"} +{"g":"pair+base","s":"ω຺ۚ","c":"ω຺ۚ","d":"ω຺ۚ"} +{"g":"pair+base","s":"A𑏏ౖ","l":"a𑏏ౖ"} +{"g":"pair+base","s":"uᷪ𞄰"} +{"g":"pair+base","s":"u్꣠","c":"u్꣠","d":"u్꣠"} +{"g":"pair+base","s":"α߬॔"} +{"g":"pair+base","s":"α়ᷧ","c":"α়ᷧ","d":"α়ᷧ"} +{"g":"pair+base","s":"A᳭⃰","c":"A᳭⃰","d":"A᳭⃰","l":"a᳭⃰"} +{"g":"pair+base","s":"и̶̐","c":"и̶̐","d":"и̶̐"} +{"g":"pair+base","s":"α𖫴ꙺ"} +{"g":"pair+base","s":"eࠠ᩻"} +{"g":"pair+base","s":"e᭮ⷫ"} +{"g":"pair+base","s":"и಼֩"} +{"g":"pair+base","s":"େ⃥𑄳"} +{"g":"pair+base","s":"ȍ𑍪","c":"ȍ𑍪"} +{"g":"pair+base","s":"゙̭᭫"} +{"g":"pair+base","s":"o𑁿֧","c":"o𑁿֧","d":"o𑁿֧"} +{"g":"pair+base","s":"oࠣ᷶"} +{"g":"pair+base","s":"и݁ؕ"} +{"g":"pair+base","s":"𐨹゙͉","c":"𐨹゙͉","d":"𐨹゙͉"} +{"g":"pair+base","s":"a𑍍̳","c":"a𑍍̳","d":"a𑍍̳"} +{"g":"pair+base","s":"א᫚ⷩ"} +{"g":"pair+base","s":"αོ̽","c":"αོ̽","d":"αོ̽"} +{"g":"pair+base","s":"ω࣎ꪰ"} +{"g":"pair+base","s":"ω᮫𞀈","c":"ω᮫𞀈","d":"ω᮫𞀈"} +{"g":"pair+base","s":"a຺𞗮"} +{"g":"pair+base","s":"ᄀࣣࣤ"} +{"g":"pair+base","s":"e࢞࣎"} +{"g":"pair+base","s":"אࣰ᭰"} +{"g":"pair+base","s":"ᄀุ࣡","c":"ᄀุ࣡","d":"ᄀุ࣡"} +{"g":"pair+base","s":"α𑏎ۖ"} +{"g":"pair+base","s":"a̓𝆫"} +{"g":"pair+base","s":"e̮ͦ"} +{"g":"pair+base","s":"A᯳ᷞ","l":"a᯳ᷞ"} +{"g":"pair+base","s":"ωᷔ᫡"} +{"g":"pair+base","s":"א꯭𖬲"} +{"g":"pair+base","s":"A̸॒","c":"A̸॒","d":"A̸॒","l":"a̸॒"} +{"g":"pair+base","s":"u࣏࣋","c":"u࣏࣋","d":"u࣏࣋"} +{"g":"pair+base","s":"u̼ᷧ"} +{"g":"pair+base","s":"Aֻࣘ","l":"aֻࣘ"} +{"g":"pair+base","s":"େ꣮͑"} +{"g":"pair+base","s":"ا𑏐ࣱ"} +{"g":"pair+base","s":"Aֺ𞀡","c":"Aֺ𞀡","d":"Aֺ𞀡","l":"aֺ𞀡"} +{"g":"pair+base","s":"େ𑶗ࠠ"} +{"g":"pair+base","s":"Aꙻ᤺","l":"aꙻ᤺"} +{"g":"pair+base","s":"Aᫍ̉","l":"aᫍ̉"} +{"g":"pair+base","s":"Aۣᷓ","c":"Aۣᷓ","d":"Aۣᷓ","l":"aۣᷓ"} +{"g":"pair+base","s":"ω𝆆𑑞"} +{"g":"pair+base","s":"େ꣩᷇"} +{"g":"pair+base","s":"ω𑵄ᷢ","c":"ω𑵄ᷢ","d":"ω𑵄ᷢ"} +{"g":"pair+base","s":"اܻ𞀝","c":"اܻ𞀝","d":"اܻ𞀝"} +{"g":"pair+base","s":"o⃦𐍷"} +{"g":"pair+base","s":"A𖬱𞓬","l":"a𖬱𞓬"} +{"g":"pair+base","s":"େ̷ܰ","c":"େ̷ܰ","d":"େ̷ܰ"} +{"g":"pair+base","s":"u࣐ᷨ"} +{"g":"pair+base","s":"αꙷⷦ"} +{"g":"pair+base","s":"A̺ࣩ","l":"a̺ࣩ"} +{"g":"pair+base","s":"A࡛᪲","c":"A࡛᪲","d":"A࡛᪲","l":"a࡛᪲"} +{"g":"pair+base","s":"αܱ֧"} +{"g":"pair+base","s":"и꥓𞀔","c":"и꥓𞀔","d":"и꥓𞀔"} +{"g":"pair+base","s":"и๊̡"} +{"g":"pair+base","s":"א্ⷰ"} +{"g":"pair+base","s":"a𐻾࢚"} +{"g":"pair+base","s":"u꤬᫈","c":"u꤬᫈","d":"u꤬᫈"} +{"g":"pair+base","s":"a𑍴𑍲"} +{"g":"pair+base","s":"ا॒ۙ"} +{"g":"pair+base","s":"α𐨿᷐","c":"α𐨿᷐","d":"α𐨿᷐"} +{"g":"pair+base","s":"ωࣙ᫔"} +{"g":"pair+base","s":"aⷾ۠"} +{"g":"pair+base","s":"a৾ٙ"} +{"g":"pair+base","s":"e᷋࣋"} +{"g":"pair+base","s":"α𞛮֑","c":"α֑𞛮","d":"α֑𞛮"} +{"g":"pair+base","s":"u͉𞀋"} +{"g":"pair+base","s":"့゙ᷩ","c":"့゙ᷩ","d":"့゙ᷩ"} +{"g":"pair+base","s":"o𑤽้","c":"o𑤽้","d":"o𑤽้"} +{"g":"pair+base","s":"ωﬞ𞓭","c":"ωﬞ𞓭","d":"ωﬞ𞓭"} +{"g":"pair+base","s":"и᫝𞀒"} +{"g":"pair+base","s":"o𐻻࣏"} +{"g":"pair+base","s":"ᄀ̰̅"} +{"g":"pair+base","s":"a𝆊̓"} +{"g":"pair+base","s":"ą𞀛","c":"ą𞀛","d":"ą𞀛"} +{"g":"pair+base","s":"ᄀౖ᳑","c":"ᄀౖ᳑","d":"ᄀౖ᳑"} +{"g":"pair+base","s":"ᄀⷧ̅"} +{"g":"pair+base","s":"e᳚͟"} +{"g":"pair+base","s":"ᄀ𞣕ⷺ"} +{"g":"pair+base","s":"o̖𞋮","c":"o̖𞋮","d":"o̖𞋮"} +{"g":"pair+base","s":"и𝆊ⷬ","c":"и𝆊ⷬ","d":"и𝆊ⷬ"} +{"g":"pair+base","s":"α्ׂ","c":"α्ׂ","d":"α्ׂ"} +{"g":"pair+base","s":"େ̄̄"} +{"g":"pair+base","s":"େ꣩︮"} +{"g":"pair+base","s":"େ݅ࣕ"} +{"g":"pair+base","s":"ωࠠ॓"} +{"g":"pair+base","s":"ا᷺ࣵ"} +{"g":"pair+base","s":"Aۛ᩹","l":"aۛ᩹"} +{"g":"pair+base","s":"ω᪻𞥉"} +{"g":"pair+base","s":"A𐽉𞀘","l":"a𐽉𞀘"} +{"g":"pair+base","s":"א𑁰𑍳"} +{"g":"pair+base","s":"u𖫴𐇽","c":"u𖫴𐇽","d":"u𖫴𐇽"} +{"g":"pair+base","s":"и𖿰𐴦","c":"и𖿰𐴦","d":"и𖿰𐴦"} +{"g":"pair+base","s":"u໊ࣘ"} +{"g":"pair+base","s":"α᳭𞀦"} +{"g":"pair+base","s":"αٕ꣬"} +{"g":"pair+base","s":"α᰷𑽂","c":"α᰷𑽂","d":"α᰷𑽂"} +{"g":"pair+base","s":"α᷻𝆇"} +{"g":"pair+base","s":"اﬞ̎","c":"اﬞ̎","d":"اﬞ̎"} +{"g":"pair+base","s":"ω𑤾᫨"} +{"g":"pair+base","s":"и̖꣮","c":"и̖꣮","d":"и̖꣮"} +{"g":"pair+base","s":"őࣘ","c":"őࣘ"} +{"g":"pair+base","s":"େ᫙߬"} +{"g":"pair+base","s":"u᫐֭","c":"u֭᫐","d":"u֭᫐"} +{"g":"pair+base","s":"א𐽎᫁","c":"א𐽎᫁","d":"א𐽎᫁"} +{"g":"pair+base","s":"a఼္","c":"a఼္","d":"a఼္"} +{"g":"pair+base","s":"א𖬶𖬳"} +{"g":"pair+base","s":"u᪺̒"} +{"g":"pair+base","s":"α֚᫫"} +{"g":"pair+base","s":"ا᳟֕"} +{"g":"pair+base","s":"ا๋᷐","c":"ا๋᷐","d":"ا๋᷐"} +{"g":"pair+base","s":"ا꠆်"} +{"g":"pair+base","s":"e͋𐺫"} +{"g":"pair+base","s":"u͒ꪷ"} +{"g":"pair+base","s":"α᫤᬴","c":"α᬴᫤","d":"α᬴᫤"} +{"g":"pair+base","s":"eֳ͒","c":"eֳ͒","d":"eֳ͒"} +{"g":"pair+base","s":"ᄀ̝҄","c":"ᄀ̝҄","d":"ᄀ̝҄"} +{"g":"pair+base","s":"o𝆊𝆬"} +{"g":"pair+base","s":"eֽ֝"} +{"g":"pair+base","s":"α𑗀⵿"} +{"g":"pair+base","s":"и𝅾᫕"} +{"g":"pair+base","s":"ả̃","c":"ả̃"} +{"g":"pair+base","s":"αࣚ𞛮"} +{"g":"pair+base","s":"゙᳭ⷬ"} +{"g":"pair+base","s":"א𐻽֜","c":"א𐻽֜","d":"א𐻽֜"} +{"g":"pair+base","s":"ᄀ᪷⃧","c":"ᄀ᪷⃧","d":"ᄀ᪷⃧"} +{"g":"pair+base","s":"ᄀ𞀧𖬵"} +{"g":"pair+base","s":"o𑑂̦"} +{"g":"pair+base","s":"u᮪︧"} +{"g":"pair+base","s":"a᳞᷑","c":"a᳞᷑","d":"a᳞᷑"} +{"g":"pair+base","s":"େ⃫𞀞","c":"େ⃫𞀞","d":"େ⃫𞀞"} +{"g":"pair+base","s":"и𑥃̝"} +{"g":"pair+base","s":"A࠙॑","l":"a࠙॑"} +{"g":"pair+base","s":"ᄀࣼ𞀟"} +{"g":"pair+base","s":"゙𐴦͝","c":"゙𐴦͝","d":"゙𐴦͝"} +{"g":"pair+base","s":"e᳑͌"} +{"g":"pair+base","s":"oᨘᷢ","c":"oᨘᷢ","d":"oᨘᷢ"} +{"g":"pair+base","s":"o𞥆ꪲ"} +{"g":"pair+base","s":"ᄀ𝆊࣎"} +{"g":"pair+base","s":"゙᭭ᷕ"} +{"g":"pair+base","s":"eֲ̔"} +{"g":"pair+base","s":"и𞣒۪"} +{"g":"pair+base","s":"a𑍍̦"} +{"g":"pair+base","s":"и𞄵ᷖ"} +{"g":"pair+base","s":"ᄀͯ𞀤"} +{"g":"pair+base","s":"゙݈ᷟ"} +{"g":"pair+base","s":"ا֭︮","c":"ا֭︮","d":"ا֭︮"} +{"g":"pair+base","s":"א𞀃𑄂"} +{"g":"pair+base","s":"େ᪶ᫍ"} +{"g":"pair+base","s":"େ̆᭳"} +{"g":"pair+base","s":"゙່᫄","c":"゙່᫄","d":"゙່᫄"} +{"g":"pair+base","s":"ωູ⃑"} +{"g":"pair+base","s":"ω⃨᷆","c":"ω⃨᷆","d":"ω⃨᷆"} +{"g":"pair+base","s":"ᄀ̉ࣳ"} +{"g":"pair+base","s":"o𑪙࠭","c":"o𑪙࠭","d":"o𑪙࠭"} +{"g":"pair+base","s":"e꫁࣬"} +{"g":"pair+base","s":"и༹ܽ","c":"и༹ܽ","d":"и༹ܽ"} +{"g":"pair+base","s":"αꚞ́"} +{"g":"pair+base","s":"ا᫊ࠫ"} +{"g":"pair+base","s":"ا𑧠ࣶ","c":"ا𑧠ࣶ","d":"ا𑧠ࣶ"} +{"g":"pair+base","s":"ا𑠹ࢗ"} +{"g":"pair+base","s":"e𑧠֘"} +{"g":"pair+base","s":"A𝅯᩻","l":"a𝅯᩻"} +{"g":"pair+base","s":"゙̯𐵩","c":"゙̯𐵩","d":"゙̯𐵩"} +{"g":"pair+base","s":"ω᫝᳸"} +{"g":"pair+base","s":"ا𞣒ᷠ","c":"ا𞣒ᷠ","d":"ا𞣒ᷠ"} +{"g":"pair+base","s":"α࣏〫"} +{"g":"pair+base","s":"ᄀ᪴᫪"} +{"g":"pair+base","s":"u︨ⷩ"} +{"g":"pair+base","s":"א𐻺ⷤ"} +{"g":"pair+base","s":"и̝ⷱ","c":"и̝ⷱ","d":"и̝ⷱ"} +{"g":"pair+base","s":"e𖬲͐"} +{"g":"pair+base","s":"u𝆂֝","c":"u𝆂֝","d":"u𝆂֝"} +{"g":"pair+base","s":"ᄀ𖫳𑑆"} +{"g":"pair+base","s":"ᄀܺ᫚"} +{"g":"pair+base","s":"A𝅲᫫","l":"a𝅲᫫"} +{"g":"pair+base","s":"ω᪲͌"} +{"g":"pair+base","s":"α𑠹̯","c":"α𑠹̯","d":"α𑠹̯"} +{"g":"pair+base","s":"a᪸ࣣ"} +{"g":"pair+base","s":"ا྄𐽎"} +{"g":"pair+base","s":"ü҆","c":"ü҆"} +{"g":"pair+base","s":"゙𑇀̲","c":"゙𑇀̲","d":"゙𑇀̲"} +{"g":"pair+base","s":"େ᯳𞥄","c":"େ᯳𞥄","d":"େ᯳𞥄"} +{"g":"pair+base","s":"u᯲𞄵","c":"u᯲𞄵","d":"u᯲𞄵"} +{"g":"pair+base","s":"א༙𐾄","c":"א༙𐾄","d":"א༙𐾄"} +{"g":"pair+base","s":"e᫝᫚"} +{"g":"pair+base","s":"и֢҆","c":"и֢҆","d":"и֢҆"} +{"g":"pair+base","s":"e𑑞᩺"} +{"g":"pair+base","s":"aࣚͥ"} +{"g":"pair+base","s":"゙္ַ"} +{"g":"pair+base","s":"eཻᫀ","c":"eཻᫀ","d":"eཻᫀ"} +{"g":"pair+base","s":"אؘؒ","c":"אؘؒ","d":"אؘؒ"} +{"g":"pair+base","s":"e𝅨᮪","c":"e𝅨᮪","d":"e𝅨᮪"} +{"g":"pair+base","s":"א᫤𑚶","c":"א𑚶᫤","d":"א𑚶᫤"} +{"g":"pair+base","s":"eٝ᩻"} +{"g":"pair+base","s":"ا𑂹𐾄"} +{"g":"pair+base","s":"uࠬ𞀨"} +{"g":"pair+base","s":"A͈꣪","c":"A͈꣪","d":"A͈꣪","l":"a͈꣪"} +{"g":"pair+base","s":"େ꣰𞄱"} +{"g":"pair+base","s":"゙𝉂᷄"} +{"g":"pair+base","s":"α𞀘ᷣ"} +{"g":"pair+base","s":"א𝅱᫅","c":"א𝅱᫅","d":"א𝅱᫅"} +{"g":"pair+base","s":"ωܼ꣥"} +{"g":"pair+base","s":"େ𐽐𑍩"} +{"g":"pair+base","s":"େ᫖𝅨","c":"େ𝅨᫖","d":"େ𝅨᫖"} +{"g":"pair+base","s":"ا𑇊ཱ"} +{"g":"pair+base","s":"o⃚͇"} +{"g":"pair+base","s":"αᷲ𞀧"} +{"g":"pair+base","s":"ᄀࣱ𐾄","c":"ᄀࣱ𐾄","d":"ᄀࣱ𐾄"} +{"g":"pair+base","s":"ᄀ᭳𞥉"} +{"g":"pair+base","s":"o︪𐍺"} +{"g":"pair+base","s":"Aྀ︭","l":"aྀ︭"} +{"g":"pair+base","s":"a⃜𞀐"} +{"g":"pair+base","s":"゙໊ᷦ","c":"゙໊ᷦ","d":"゙໊ᷦ"} +{"g":"pair+base","s":"u॒𑍨","c":"u॒𑍨","d":"u॒𑍨"} +{"g":"pair+base","s":"α֛𝆈"} +{"g":"pair+base","s":"и्̟"} +{"g":"pair+base","s":"o᳧𑨴","c":"o᳧𑨴","d":"o᳧𑨴"} +{"g":"pair+base","s":"αᫀⷭ","c":"αᫀⷭ","d":"αᫀⷭ"} +{"g":"pair+base","s":"େ֭ᷲ","c":"େ֭ᷲ","d":"େ֭ᷲ"} +{"g":"pair+base","s":"ωͯࣛ"} +{"g":"pair+base","s":"ω֧𐨺"} +{"g":"pair+base","s":"େ⃓ᷬ","c":"େ⃓ᷬ","d":"େ⃓ᷬ"} +{"g":"pair+base","s":"eⷦ᷋"} +{"g":"pair+base","s":"A̯͆","c":"A̯͆","d":"A̯͆","l":"a̯͆"} +{"g":"pair+base","s":"u್࣭","c":"u್࣭","d":"u್࣭"} +{"g":"pair+base","s":"иི྇"} +{"g":"pair+base","s":"e᰷᷸"} +{"g":"pair+base","s":"ᄀ𖿰᳕"} +{"g":"pair+base","s":"େࠦ𞀖"} +{"g":"pair+base","s":"େ𑄁᳚"} +{"g":"pair+base","s":"゙̛֚"} +{"g":"pair+base","s":"A𞀏ͫ","l":"a𞀏ͫ"} +{"g":"pair+base","s":"αࠧ𑄂"} +{"g":"pair+base","s":"ω࣏𖬲"} +{"g":"pair+base","s":"ا֠𑄂"} +{"g":"pair+base","s":"u𑍍𝅱"} +{"g":"pair+base","s":"eؚⷵ","c":"eؚⷵ","d":"eؚⷵ"} +{"g":"pair+base","s":"α֝᫫"} +{"g":"pair+base","s":"uࣻ⃐"} +{"g":"pair+base","s":"اܸ፞","c":"اܸ፞","d":"اܸ፞"} +{"g":"pair+base","s":"א᭄⃭"} +{"g":"pair+base","s":"א࢚֚","c":"א࢚֚","d":"א࢚֚"} +{"g":"pair+base","s":"א𞀪ܲ"} +{"g":"pair+base","s":"и𑇀̑"} +{"g":"pair+base","s":"uྀ᳑"} +{"g":"pair+base","s":"ا್ᷭ"} +{"g":"pair+base","s":"େⷸ᫦","c":"େ᫦ⷸ","d":"େ᫦ⷸ"} +{"g":"pair+base","s":"゙ࠧ᪰"} +{"g":"pair+base","s":"a̠ࣔ","c":"a̠ࣔ","d":"a̠ࣔ"} +{"g":"pair+base","s":"اܴ̋"} +{"g":"pair+base","s":"ω̒᩻"} +{"g":"pair+base","s":"େ֪ۨ","c":"େ֪ۨ","d":"େ֪ۨ"} +{"g":"pair+base","s":"u்꣦","c":"u்꣦","d":"u்꣦"} +{"g":"pair+base","s":"゙໊ࠬ","c":"゙໊ࠬ","d":"゙໊ࠬ"} +{"g":"pair+base","s":"゙𐵬𝆪"} +{"g":"pair+base","s":"゙⃭ࠫ"} +{"g":"pair+base","s":"゙𐴧𞀔"} +{"g":"pair+base","s":"a𑠺𞛵"} +{"g":"pair+base","s":"ᄀ𑵅ࠢ","c":"ᄀ𑵅ࠢ","d":"ᄀ𑵅ࠢ"} +{"g":"pair+base","s":"e𖫴ꙹ","c":"e𖫴ꙹ","d":"e𖫴ꙹ"} +{"g":"pair+base","s":"゙𑓂᷋","c":"゙𑓂᷋","d":"゙𑓂᷋"} +{"g":"pair+base","s":"A࣍𐍶","l":"a࣍𐍶"} +{"g":"pair+base","s":"и֭᭯"} +{"g":"pair+base","s":"a𖫴ᷨ","c":"a𖫴ᷨ","d":"a𖫴ᷨ"} +{"g":"pair+base","s":"иི࢝"} +{"g":"pair+base","s":"u︬֡","c":"u︬֡","d":"u︬֡"} +{"g":"pair+base","s":"u𐾅𞄳","c":"u𐾅𞄳","d":"u𐾅𞄳"} +{"g":"pair+base","s":"゙᳘ܲ"} +{"g":"pair+base","s":"aܷ꣢","c":"aܷ꣢","d":"aܷ꣢"} +{"g":"pair+base","s":"o༹𑍨","c":"o༹𑍨","d":"o༹𑍨"} +{"g":"pair+base","s":"ا᩿֗","c":"ا᩿֗","d":"ا᩿֗"} +{"g":"pair+base","s":"α̵𖄯","c":"α̵𖄯","d":"α̵𖄯"} +{"g":"pair+base","s":"ω॒ۜ","c":"ω॒ۜ","d":"ω॒ۜ"} +{"g":"pair+base","s":"и︬፞"} +{"g":"pair+base","s":"゙𞀁᫖"} +{"g":"pair+base","s":"ا𑇊ܶ"} +{"g":"pair+base","s":"ᄀ𑂹̠","c":"ᄀ𑂹̠","d":"ᄀ𑂹̠"} +{"g":"pair+base","s":"゙ؚ𝆫","c":"゙ؚ𝆫","d":"゙ؚ𝆫"} +{"g":"pair+base","s":"𝅨゙͡","c":"𝅨゙͡","d":"𝅨゙͡"} +{"g":"pair+base","s":"eཱᷪ"} +{"g":"pair+base","s":"oฺ݅","c":"oฺ݅","d":"oฺ݅"} +{"g":"pair+base","s":"и̛𐽌","c":"и̛𐽌","d":"и̛𐽌"} +{"g":"pair+base","s":"ω𞀕𞊮"} +{"g":"pair+base","s":"ᄀ᳴𞗮"} +{"g":"pair+base","s":"u᩵ࠪ"} +{"g":"pair+base","s":"a𝉄᩷"} +{"g":"pair+base","s":"и𑈶͎"} +{"g":"pair+base","s":"e𞥅𝆫"} +{"g":"pair+base","s":"େ᪰ᷩ"} +{"g":"pair+base","s":"େ𞀛᫅"} +{"g":"pair+base","s":"ᄀຸ፟","c":"ᄀຸ፟","d":"ᄀຸ፟"} +{"g":"pair+base","s":"א𝅧𐍶","c":"א𝅧𐍶","d":"א𝅧𐍶"} +{"g":"pair+base","s":"ا᯳̲"} +{"g":"pair+base","s":"ᄀ𑧠ۙ"} +{"g":"pair+base","s":"א֔҇"} +{"g":"pair+base","s":"Ă֯","c":"Ă֯","l":"ă֯"} +{"g":"pair+base","s":"اࣶ𞀟","c":"اࣶ𞀟","d":"اࣶ𞀟"} +{"g":"pair+base","s":"େ᪽᳗"} +{"g":"pair+base","s":"ωؘࠜ"} +{"g":"pair+base","s":"א߮꣬"} +{"g":"pair+base","s":"א֮𖬱"} +{"g":"pair+base","s":"α᳞𖬲"} +{"g":"pair+base","s":"o᷐ׅ","c":"o᷐ׅ","d":"o᷐ׅ"} +{"g":"pair+base","s":"ᄀ⃚̩"} +{"g":"pair+base","s":"א𑗀̝"} +{"g":"pair+base","s":"e⃐̐"} +{"g":"pair+base","s":"A⃪⃨","l":"a⃪⃨"} +{"g":"pair+base","s":"େ𐾄ؐ"} +{"g":"pair+base","s":"uⷱ꙼"} +{"g":"pair+base","s":"o𞥈ܵ"} +{"g":"pair+base","s":"゙ۖࣔ"} +{"g":"pair+base","s":"u᫗𞛣"} +{"g":"pair+base","s":"א𝅾ࠬ"} +{"g":"pair+base","s":"a᫢𑑂","c":"a𑑂᫢","d":"a𑑂᫢"} +{"g":"pair+base","s":"o𞣖ࠥ"} +{"g":"pair+base","s":"α߯᫢"} +{"g":"pair+base","s":"ω𑏐ࣺ","c":"ω𑏐ࣺ","d":"ω𑏐ࣺ"} +{"g":"pair+base","s":"αࠡ𐍸"} +{"g":"pair+base","s":"א᫒𞀛"} +{"g":"pair+base","s":"α᫁֞"} +{"g":"pair+base","s":"ا𑏐֤","c":"ا𑏐֤","d":"ا𑏐֤"} +{"g":"pair+base","s":"େַ𐴤"} +{"g":"pair+base","s":"A఼ᷱ","c":"A఼ᷱ","d":"A఼ᷱ","l":"a఼ᷱ"} +{"g":"pair+base","s":"e᤻ٖ"} +{"g":"pair+base","s":"ω𑏏̝","c":"ω𑏏̝","d":"ω𑏏̝"} +{"g":"pair+base","s":"u𝅲⃬"} +{"g":"pair+base","s":"u𐽇𞀆"} +{"g":"pair+base","s":"A਼࠭","c":"A਼࠭","d":"A਼࠭","l":"a਼࠭"} +{"g":"pair+base","s":"uࠩ᪼"} +{"g":"pair+base","s":"ᄀ𑩇ͯ","c":"ᄀ𑩇ͯ","d":"ᄀ𑩇ͯ"} +{"g":"pair+base","s":"ا֣⃐"} +{"g":"pair+base","s":"a̹ࠛ"} +{"g":"pair+base","s":"ᄀ︦͢"} +{"g":"pair+base","s":"a᯦࢙"} +{"g":"pair+base","s":"α𑁰༹"} +{"g":"pair+base","s":"େ︭̟"} +{"g":"pair+base","s":"ᄀⷽ𐽌"} +{"g":"pair+base","s":"o͈᪲","c":"o͈᪲","d":"o͈᪲"} +{"g":"pair+base","s":"Aͫ॓","l":"aͫ॓"} +{"g":"pair+base","s":"uꪴ𝆉"} +{"g":"pair+base","s":"ᄀ꤬𑍫"} +{"g":"pair+base","s":"اྀ⳰","c":"اྀ⳰","d":"اྀ⳰"} +{"g":"pair+base","s":"ا࣮ᷟ","c":"ا࣮ᷟ","d":"ا࣮ᷟ"} +{"g":"pair+base","s":"α𝆁꣫","c":"α𝆁꣫","d":"α𝆁꣫"} +{"g":"pair+base","s":"e֭ⷣ"} +{"g":"pair+base","s":"ωᷲ𖬰"} +{"g":"pair+base","s":"אⷻͅ","c":"אⷻͅ","d":"אⷻͅ"} +{"g":"pair+base","s":"ا𝅲ࣼ"} +{"g":"pair+base","s":"o᫥𞀦"} +{"g":"pair+base","s":"ω᷏᭯"} +{"g":"pair+base","s":"e̖ࣽ"} +{"g":"pair+base","s":"e़߰","c":"e़߰","d":"e़߰"} +{"g":"pair+base","s":"ا̗ׄ","c":"ا̗ׄ","d":"ا̗ׄ"} +{"g":"pair+base","s":"A༙֖","l":"a༙֖"} +{"g":"pair+base","s":"α᳜ⷺ","c":"α᳜ⷺ","d":"α᳜ⷺ"} +{"g":"pair+base","s":"ω꯭𑄴"} +{"g":"pair+base","s":"ا𐍹ᷣ"} +{"g":"pair+base","s":"o𝆁᪼"} +{"g":"pair+base","s":"େ𖬳𞀣"} +{"g":"pair+base","s":"א𐨹̩","c":"א𐨹̩","d":"א𐨹̩"} +{"g":"pair+base","s":"и𑈵ܷ","c":"и𑈵ܷ","d":"и𑈵ܷ"} +{"g":"pair+base","s":"A𑋪︧","l":"a𑋪︧"} +{"g":"pair+base","s":"ω᳣۪","c":"ω᳣۪","d":"ω᳣۪"} +{"g":"pair+base","s":"и⃓ⷧ","c":"и⃓ⷧ","d":"и⃓ⷧ"} +{"g":"pair+base","s":"ᄀ๋ٗ"} +{"g":"pair+base","s":"aᷥꙸ"} +{"g":"pair+base","s":"اᷢ͛"} +{"g":"pair+base","s":"اཱꙴ"} +{"g":"pair+base","s":"o⃬𐵫","c":"o⃬𐵫","d":"o⃬𐵫"} +{"g":"pair+base","s":"o͇ⷧ"} +{"g":"pair+base","s":"ا𐨺٘","c":"ا𐨺٘","d":"ا𐨺٘"} +{"g":"pair+base","s":"ᄀ֑᳴","c":"ᄀ֑᳴","d":"ᄀ֑᳴"} +{"g":"pair+base","s":"େ̊ࣻ"} +{"g":"pair+base","s":"ᄀܹ𖬱","c":"ᄀܹ𖬱","d":"ᄀܹ𖬱"} +{"g":"pair+base","s":"゙︬ⷪ","c":"゙︬ⷪ","d":"゙︬ⷪ"} +{"g":"pair+base","s":"ا̢᳞"} +{"g":"pair+base","s":"α᳨᫑"} +{"g":"pair+base","s":"и𐨺𞀈"} +{"g":"pair+base","s":"αᷥ᷻"} +{"g":"pair+base","s":"u゚⃨","c":"u゚⃨","d":"u゚⃨"} +{"g":"pair+base","s":"ơࣜ","c":"ơࣜ"} +{"g":"pair+base","s":"ω်̝","c":"ω်̝","d":"ω်̝"} +{"g":"pair+base","s":"uོ᷷"} +{"g":"pair+base","s":"ωࠛ᷼"} +{"g":"pair+base","s":"A𑥃𑏎","l":"a𑥃𑏎"} +{"g":"pair+base","s":"и𑵂̍"} +{"g":"pair+base","s":"a઼𖬳"} +{"g":"pair+base","s":"e᳝᩻"} +{"g":"pair+base","s":"αؘ꣨","c":"αؘ꣨","d":"αؘ꣨"} +{"g":"pair+base","s":"େ᫝݃"} +{"g":"pair+base","s":"и𞀡⳯"} +{"g":"pair+base","s":"ᄀۢࣼ"} +{"g":"pair+base","s":"ω᭱ࠡ"} +{"g":"pair+base","s":"େ⃫᩼"} +{"g":"pair+base","s":"иͪ𐨸"} +{"g":"pair+base","s":"Aͪ𑍫","l":"aͪ𑍫"} +{"g":"pair+base","s":"א𞣐ۨ","c":"א𞣐ۨ","d":"א𞣐ۨ"} +{"g":"pair+base","s":"α͊᪼"} +{"g":"pair+base","s":"א𑍲𞋬"} +{"g":"pair+base","s":"ω᳢਼"} +{"g":"pair+base","s":"a𐵩ͮ"} +{"g":"pair+base","s":"A𑵄ⷰ","l":"a𑵄ⷰ"} +{"g":"pair+base","s":"u𑘿𑽂"} +{"g":"pair+base","s":"α߮ࣴ"} +{"g":"pair+base","s":"A𐨏᪴","l":"a𐨏᪴"} +{"g":"pair+base","s":"oⷰ͆"} +{"g":"pair+base","s":"a𑓂ܳ","c":"a𑓂ܳ","d":"a𑓂ܳ"} +{"g":"pair+base","s":"eͮ꣪"} +{"g":"pair+base","s":"゙𖄯︧","c":"゙𖄯︧","d":"゙𖄯︧"} +{"g":"pair+base","s":"иຸ͎"} +{"g":"pair+base","s":"и༷𝆪"} +{"g":"pair+base","s":"αꙸ𝉂"} +{"g":"pair+base","s":"א༷꣣","c":"א༷꣣","d":"א༷꣣"} +{"g":"pair+base","s":"ωᷛࣟ"} +{"g":"pair+base","s":"ᄀ᪱࣡"} +{"g":"pair+base","s":"oٟ࣮"} +{"g":"pair+base","s":"ا᳢߽"} +{"g":"pair+base","s":"o̊࣪"} +{"g":"pair+base","s":"e఼𝅰"} +{"g":"pair+base","s":"א⃭࣫","c":"א⃭࣫","d":"א⃭࣫"} +{"g":"pair+base","s":"uۚ𞀖"} +{"g":"pair+base","s":"ᄀ᳢̆"} +{"g":"pair+base","s":"א𑜫⃛","c":"א𑜫⃛","d":"א𑜫⃛"} +{"g":"pair+base","s":"אؙ֞"} +{"g":"pair+base","s":"େฺٓ"} +{"g":"pair+base","s":"u𑁿֧"} +{"g":"pair+base","s":"и̡𞀩"} +{"g":"pair+base","s":"א𖫳𝆀","c":"א𖫳𝆀","d":"א𖫳𝆀"} +{"g":"pair+base","s":"ᄀꪴ᩹"} +{"g":"pair+base","s":"a𞀓𞀅"} +{"g":"pair+base","s":"ᄀ̵𞛮"} +{"g":"pair+base","s":"e҇ͧ"} +{"g":"pair+base","s":"и̍֗"} +{"g":"pair+base","s":"゙𝆂݇","c":"゙𝆂݇","d":"゙𝆂݇"} +{"g":"pair+base","s":"A֗𞀉","l":"a֗𞀉"} +{"g":"pair+base","s":"א᩺ࣘ"} +{"g":"pair+base","s":"A𑇀𝆪","c":"A𑇀𝆪","d":"A𑇀𝆪","l":"a𑇀𝆪"} +{"g":"pair+base","s":"u֮᫔"} +{"g":"pair+base","s":"a𐨍ࠗ"} +{"g":"pair+base","s":"и〭ⷾ"} +{"g":"pair+base","s":"א๋̘"} +{"g":"pair+base","s":"u𞛵᭰"} +{"g":"pair+base","s":"゙ًٓ"} +{"g":"pair+base","s":"אٟ𐨸"} +{"g":"pair+base","s":"o𑠹𞀊","c":"o𑠹𞀊","d":"o𑠹𞀊"} +{"g":"pair+base","s":"A𖬱𝆉","l":"a𖬱𝆉"} +{"g":"pair+base","s":"ᄀᷘ̔"} +{"g":"pair+base","s":"א𑗀࣊"} +{"g":"pair+base","s":"aׇ̯","c":"aׇ̯","d":"aׇ̯"} +{"g":"pair+base","s":"゙ؘᷙ","c":"゙ؘᷙ","d":"゙ؘᷙ"} +{"g":"pair+base","s":"ا࣊᳹"} +{"g":"pair+base","s":"ا꣤ᷙ"} +{"g":"pair+base","s":"ᄀ𑑂ᷙ"} +{"g":"pair+base","s":"ᄀ꣮𞀓"} +{"g":"pair+base","s":"aⷳ𐵬"} +{"g":"pair+base","s":"uׅ𞀘"} +{"g":"pair+base","s":"゙͑᷀"} +{"g":"pair+base","s":"א᷎ܰ"} +{"g":"pair+base","s":"ω𝅩٘"} +{"g":"pair+base","s":"e𞀍፞"} +{"g":"pair+base","s":"ω𝆀𝆉","c":"ω𝆀𝆉","d":"ω𝆀𝆉"} +{"g":"pair+base","s":"αⷶ҇"} +{"g":"pair+base","s":"A⃙݇","l":"a⃙݇"} +{"g":"pair+base","s":"ω𑏎᷄"} +{"g":"pair+base","s":"uᪿ𑍳","c":"uᪿ𑍳","d":"uᪿ𑍳"} +{"g":"pair+base","s":"α᷊ᫎ"} +{"g":"pair+base","s":"𑚷゙̓","c":"𑚷゙̓","d":"𑚷゙̓"} +{"g":"pair+base","s":"a࣏ᷳ","c":"a࣏ᷳ","d":"a࣏ᷳ"} +{"g":"pair+base","s":"ᄀ͍֡"} +{"g":"pair+base","s":"େ𑍍ᷛ","c":"େ𑍍ᷛ","d":"େ𑍍ᷛ"} +{"g":"pair+base","s":"e᩠ͯ"} +{"g":"pair+base","s":"େ𞀞꣥"} +{"g":"pair+base","s":"иꪲ͋"} +{"g":"compose","s":"≮","c":"≮"} +{"g":"compose","s":"≠ⷥ","c":"≠ⷥ","d":"≠ⷥ"} +{"g":"compose","s":"≯𞀌","d":"≯𞀌"} +{"g":"compose","s":"À","c":"À","l":"à"} +{"g":"compose","s":"A𞀕́","l":"a𞀕́"} +{"g":"compose","s":"Â֪","d":"Â֪","l":"â֪"} +{"g":"compose","s":"Ã","c":"Ã","l":"ã"} +{"g":"compose","s":"A𞀂̄","l":"a𞀂̄"} +{"g":"compose","s":"Ăฺ","d":"Ăฺ","l":"ăฺ"} +{"g":"compose","s":"Ȧ","c":"Ȧ","l":"ȧ"} +{"g":"compose","s":"Aͣ̈","l":"aͣ̈"} +{"g":"compose","s":"Ả𑄳","d":"Ả𑄳","l":"ả𑄳"} +{"g":"compose","s":"Å","c":"Å","l":"å"} +{"g":"compose","s":"Ǎְ","c":"Ǎְ","l":"ǎְ"} +{"g":"compose","s":"Ȁ݉","d":"Ȁ݉","l":"ȁ݉"} +{"g":"compose","s":"Ȃ","c":"Ȃ","l":"ȃ"} +{"g":"compose","s":"A֛̣","l":"a֛̣"} +{"g":"compose","s":"Ḁ᳠","d":"Ḁ᳠","l":"ḁ᳠"} +{"g":"compose","s":"Ą","c":"Ą","l":"ą"} +{"g":"compose","s":"Ḃ༙","c":"Ḃ༙","l":"ḃ༙"} +{"g":"compose","s":"Ḅ࣒","d":"Ḅ࣒","l":"ḅ࣒"} +{"g":"compose","s":"Ḇ","c":"Ḇ","l":"ḇ"} +{"g":"compose","s":"Ć꠬","c":"Ć꠬","l":"ć꠬"} +{"g":"compose","s":"Ĉ꣫","d":"Ĉ꣫","l":"ĉ꣫"} +{"g":"compose","s":"Ċ","c":"Ċ","l":"ċ"} +{"g":"compose","s":"Č֛","c":"Č֛","l":"č֛"} +{"g":"compose","s":"Ç҄","d":"Ç҄","l":"ç҄"} +{"g":"compose","s":"Ḋ","c":"Ḋ","l":"ḋ"} +{"g":"compose","s":"D̄̌","l":"d̄̌"} +{"g":"compose","s":"Ḍ࣋","d":"Ḍ࣋","l":"ḍ࣋"} +{"g":"compose","s":"Ḑ","c":"Ḑ","l":"ḑ"} +{"g":"compose","s":"Ḓ⃡","c":"Ḓ⃡","d":"Ḓ⃡","l":"ḓ⃡"} +{"g":"compose","s":"Ḏູ","d":"Ḏູ","l":"ḏູ"} +{"g":"compose","s":"È","c":"È","l":"è"} +{"g":"compose","s":"E࣠́","l":"e࣠́"} +{"g":"compose","s":"Êؒ","d":"Êؒ","l":"êؒ"} +{"g":"compose","s":"Ẽ","c":"Ẽ","l":"ẽ"} +{"g":"compose","s":"E𞀆̄","l":"e𞀆̄"} +{"g":"compose","s":"Ĕ߮","d":"Ĕ߮","l":"ĕ߮"} +{"g":"compose","s":"Ė","c":"Ė","l":"ė"} +{"g":"compose","s":"Ëׁ","c":"Ëׁ","l":"ëׁ"} +{"g":"compose","s":"Ẻ̽","d":"Ẻ̽","l":"ẻ̽"} +{"g":"compose","s":"Ě","c":"Ě","l":"ě"} +{"g":"compose","s":"Ȅﬞ","c":"Ȅﬞ","l":"ȅﬞ"} +{"g":"compose","s":"Ȇ᫙","d":"Ȇ᫙","l":"ȇ᫙"} +{"g":"compose","s":"Ẹ","c":"Ẹ","l":"ẹ"} +{"g":"compose","s":"Ȩ︯","c":"Ȩ︯","d":"Ȩ︯","l":"ȩ︯"} +{"g":"compose","s":"Ę֓","d":"Ę֓","l":"ę֓"} +{"g":"compose","s":"Ḙ","c":"Ḙ","l":"ḙ"} +{"g":"compose","s":"Eࣹ̰","l":"eࣹ̰"} +{"g":"compose","s":"Ḟؗ","d":"Ḟؗ","l":"ḟؗ"} +{"g":"compose","s":"Ǵ","c":"Ǵ","l":"ǵ"} +{"g":"compose","s":"Gᫍ̂","l":"gᫍ̂"} +{"g":"compose","s":"Ḡᷫ","d":"Ḡᷫ","l":"ḡᷫ"} +{"g":"compose","s":"Ğ","c":"Ğ","l":"ğ"} +{"g":"compose","s":"G࣍̇","l":"g࣍̇"} +{"g":"compose","s":"Ǧྀ","d":"Ǧྀ","l":"ǧྀ"} +{"g":"compose","s":"Ģ","c":"Ģ","l":"ģ"} +{"g":"compose","s":"Hͭ̂","l":"hͭ̂"} +{"g":"compose","s":"Ḣٜ","d":"Ḣٜ","l":"ḣٜ"} +{"g":"compose","s":"Ḧ","c":"Ḧ","l":"ḧ"} +{"g":"compose","s":"H𑍫̌","l":"h𑍫̌"} +{"g":"compose","s":"Ḥ្","d":"Ḥ្","l":"ḥ្"} +{"g":"compose","s":"Ḩ","c":"Ḩ","l":"ḩ"} +{"g":"compose","s":"Ḫͮ","c":"Ḫͮ","d":"Ḫͮ","l":"ḫͮ"} +{"g":"compose","s":"Ìꙻ","d":"Ìꙻ","l":"ìꙻ"} +{"g":"compose","s":"Í","c":"Í","l":"í"} +{"g":"compose","s":"I︣̂","l":"i︣̂"} +{"g":"compose","s":"Ĩⷦ","d":"Ĩⷦ","l":"ĩⷦ"} +{"g":"compose","s":"Ī","c":"Ī","l":"ī"} +{"g":"compose","s":"I𞓯̆","l":"i𞓯̆"} +{"g":"compose","s":"İ࣓","d":"İ࣓","l":"i࣓̇"} +{"g":"compose","s":"Ï","c":"Ï","l":"ï"} +{"g":"compose","s":"I֞̉","l":"i֞̉"} +{"g":"compose","s":"Ǐ֡","d":"Ǐ֡","l":"ǐ֡"} +{"g":"compose","s":"Ȉ","c":"Ȉ","l":"ȉ"} +{"g":"compose","s":"Iۡ̑","l":"iۡ̑"} +{"g":"compose","s":"Ị͠","d":"Ị͠","l":"ị͠"} +{"g":"compose","s":"Į","c":"Į","l":"į"} +{"g":"compose","s":"Ḭ𝅨","c":"Ḭ𝅨","l":"ḭ𝅨"} +{"g":"compose","s":"Ĵ᩼","d":"Ĵ᩼","l":"ĵ᩼"} +{"g":"compose","s":"Ḱ","c":"Ḱ","l":"ḱ"} +{"g":"compose","s":"Ǩࣶ","c":"Ǩࣶ","l":"ǩࣶ"} +{"g":"compose","s":"Ḳ꣭","d":"Ḳ꣭","l":"ḳ꣭"} +{"g":"compose","s":"Ķ","c":"Ķ","l":"ķ"} +{"g":"compose","s":"Ḵ้","c":"Ḵ้","l":"ḵ้"} +{"g":"compose","s":"Ĺ่","d":"Ĺ่","l":"ĺ่"} +{"g":"compose","s":"Ľ","c":"Ľ","l":"ľ"} +{"g":"compose","s":"Ḷ𐵩","c":"Ḷ𐵩","d":"Ḷ𐵩","l":"ḷ𐵩"} +{"g":"compose","s":"Ļ𐺫","d":"Ļ𐺫","l":"ļ𐺫"} +{"g":"compose","s":"Ḽ","c":"Ḽ","l":"ḽ"} +{"g":"compose","s":"Ḻ͜","c":"Ḻ͜","d":"Ḻ͜","l":"ḻ͜"} +{"g":"compose","s":"Ḿ᭭","d":"Ḿ᭭","l":"ḿ᭭"} +{"g":"compose","s":"Ṁ","c":"Ṁ","l":"ṁ"} +{"g":"compose","s":"Ṃᷭ","c":"Ṃᷭ","d":"Ṃᷭ","l":"ṃᷭ"} +{"g":"compose","s":"Ǹ𖫴","d":"Ǹ𖫴","l":"ǹ𖫴"} +{"g":"compose","s":"Ń","c":"Ń","l":"ń"} +{"g":"compose","s":"Ñ⃚","c":"Ñ⃚","l":"ñ⃚"} +{"g":"compose","s":"Ṅ᫚","d":"Ṅ᫚","l":"ṅ᫚"} +{"g":"compose","s":"Ň","c":"Ň","l":"ň"} +{"g":"compose","s":"Nܷ̣","l":"nܷ̣"} +{"g":"compose","s":"Ņ᭯","d":"Ņ᭯","l":"ņ᭯"} +{"g":"compose","s":"Ṋ","c":"Ṋ","l":"ṋ"} +{"g":"compose","s":"Ṉ᳐","c":"Ṉ᳐","d":"Ṉ᳐","l":"ṉ᳐"} +{"g":"compose","s":"Ò̸","d":"Ò̸","l":"ò̸"} +{"g":"compose","s":"Ó","c":"Ó","l":"ó"} +{"g":"compose","s":"Ôֱ","c":"Ôֱ","l":"ôֱ"} +{"g":"compose","s":"Õི","d":"Õི","l":"õི"} +{"g":"compose","s":"Ō","c":"Ō","l":"ō"} +{"g":"compose","s":"Oٝ̆","l":"oٝ̆"} +{"g":"compose","s":"Ȯ̱","d":"Ȯ̱","l":"ȯ̱"} +{"g":"compose","s":"Ö","c":"Ö","l":"ö"} +{"g":"compose","s":"Ỏ๊","c":"Ỏ๊","l":"ỏ๊"} +{"g":"compose","s":"Őᨗ","d":"Őᨗ","l":"őᨗ"} +{"g":"compose","s":"Ǒ","c":"Ǒ","l":"ǒ"} +{"g":"compose","s":"Ȍ꤬","c":"Ȍ꤬","l":"ȍ꤬"} +{"g":"compose","s":"Ȏ𞀨","d":"Ȏ𞀨","l":"ȏ𞀨"} +{"g":"compose","s":"Ơ","c":"Ơ","l":"ơ"} +{"g":"compose","s":"Ọ᪰","c":"Ọ᪰","d":"Ọ᪰","l":"ọ᪰"} +{"g":"compose","s":"Ǫ҃","d":"Ǫ҃","l":"ǫ҃"} +{"g":"compose","s":"Ṕ","c":"Ṕ","l":"ṕ"} +{"g":"compose","s":"Ṗ್","c":"Ṗ್","l":"ṗ್"} +{"g":"compose","s":"Ŕ⃭","d":"Ŕ⃭","l":"ŕ⃭"} +{"g":"compose","s":"Ṙ","c":"Ṙ","l":"ṙ"} +{"g":"compose","s":"R᫁̌","l":"r᫁̌"} +{"g":"compose","s":"Ȑ𑖿","d":"Ȑ𑖿","l":"ȑ𑖿"} +{"g":"compose","s":"Ȓ","c":"Ȓ","l":"ȓ"} +{"g":"compose","s":"R᫢̣","c":"Ṛ᫢","d":"Ṛ᫢","l":"r᫢̣"} +{"g":"compose","s":"Ŗ߱","d":"Ŗ߱","l":"ŗ߱"} +{"g":"compose","s":"Ṟ","c":"Ṟ","l":"ṟ"} +{"g":"compose","s":"Sܰ́","l":"sܰ́"} +{"g":"compose","s":"Ŝⷤ","d":"Ŝⷤ","l":"ŝⷤ"} +{"g":"compose","s":"Ṡ","c":"Ṡ","l":"ṡ"} +{"g":"compose","s":"Š𝅩","c":"Š𝅩","l":"š𝅩"} +{"g":"compose","s":"Ṣ͠","d":"Ṣ͠","l":"ṣ͠"} +{"g":"compose","s":"Ș","c":"Ș","l":"ș"} +{"g":"compose","s":"Ş݂","c":"Ş݂","d":"Ş݂","l":"ş݂"} +{"g":"compose","s":"Ṫ͠","d":"Ṫ͠","l":"ṫ͠"} +{"g":"compose","s":"Ť","c":"Ť","l":"ť"} +{"g":"compose","s":"Ṭ𝆪","c":"Ṭ𝆪","d":"Ṭ𝆪","l":"ṭ𝆪"} +{"g":"compose","s":"Ț͜","d":"Ț͜","l":"ț͜"} +{"g":"compose","s":"Ţ","c":"Ţ","l":"ţ"} +{"g":"compose","s":"Ṱ𝉄","c":"Ṱ𝉄","d":"Ṱ𝉄","l":"ṱ𝉄"} +{"g":"compose","s":"Ṯ⃛","d":"Ṯ⃛","l":"ṯ⃛"} +{"g":"compose","s":"Ù","c":"Ù","l":"ù"} +{"g":"compose","s":"Úָ","c":"Úָ","l":"úָ"} +{"g":"compose","s":"Ûⷺ","d":"Ûⷺ","l":"ûⷺ"} +{"g":"compose","s":"Ũ","c":"Ũ","l":"ũ"} +{"g":"compose","s":"U᫗̄","l":"u᫗̄"} +{"g":"compose","s":"Ŭ⃛","d":"Ŭ⃛","l":"ŭ⃛"} +{"g":"compose","s":"Ü","c":"Ü","l":"ü"} +{"g":"compose","s":"U፟̉","l":"u፟̉"} +{"g":"compose","s":"Ů࣐","d":"Ů࣐","l":"ů࣐"} +{"g":"compose","s":"Ű","c":"Ű","l":"ű"} +{"g":"compose","s":"Uۘ̌","l":"uۘ̌"} +{"g":"compose","s":"Ȕ᫕","d":"Ȕ᫕","l":"ȕ᫕"} +{"g":"compose","s":"Ȗ","c":"Ȗ","l":"ȗ"} +{"g":"compose","s":"Ư𐫥","c":"Ư𐫥","d":"Ư𐫥","l":"ư𐫥"} +{"g":"compose","s":"Ụ᩿","d":"Ụ᩿","l":"ụ᩿"} +{"g":"compose","s":"Ṳ","c":"Ṳ","l":"ṳ"} +{"g":"compose","s":"U᫓̨","c":"Ų᫓","d":"Ų᫓","l":"u᫓̨"} +{"g":"compose","s":"Ṷ᷍","d":"Ṷ᷍","l":"ṷ᷍"} +{"g":"compose","s":"Ṵ","c":"Ṵ","l":"ṵ"} +{"g":"compose","s":"Ṽ֮","c":"Ṽ֮","l":"ṽ֮"} +{"g":"compose","s":"Ṿ꣄","d":"Ṿ꣄","l":"ṿ꣄"} +{"g":"compose","s":"Ẁ","c":"Ẁ","l":"ẁ"} +{"g":"compose","s":"Ẃ𑩇","c":"Ẃ𑩇","l":"ẃ𑩇"} +{"g":"compose","s":"Ŵ྄","d":"Ŵ྄","l":"ŵ྄"} +{"g":"compose","s":"Ẇ","c":"Ẇ","l":"ẇ"} +{"g":"compose","s":"Ẅ⃙","c":"Ẅ⃙","l":"ẅ⃙"} +{"g":"compose","s":"Ẉ࣪","d":"Ẉ࣪","l":"ẉ࣪"} +{"g":"compose","s":"Ẋ","c":"Ẋ","l":"ẋ"} +{"g":"compose","s":"X֨̈","l":"x֨̈"} +{"g":"compose","s":"Ỳ֑","d":"Ỳ֑","l":"ỳ֑"} +{"g":"compose","s":"Ý","c":"Ý","l":"ý"} +{"g":"compose","s":"Yࣟ̂","l":"yࣟ̂"} +{"g":"compose","s":"Ỹ߱","d":"Ỹ߱","l":"ỹ߱"} +{"g":"compose","s":"Ȳ","c":"Ȳ","l":"ȳ"} +{"g":"compose","s":"Ẏ्","c":"Ẏ्","l":"ẏ्"} +{"g":"compose","s":"Ÿ〬","d":"Ÿ〬","l":"ÿ〬"} +{"g":"compose","s":"Ỷ","c":"Ỷ","l":"ỷ"} +{"g":"compose","s":"Ỵ𑽂","c":"Ỵ𑽂","l":"ỵ𑽂"} +{"g":"compose","s":"Ź᫕","d":"Ź᫕","l":"ź᫕"} +{"g":"compose","s":"Ẑ","c":"Ẑ","l":"ẑ"} +{"g":"compose","s":"Zؑ̇","l":"zؑ̇"} +{"g":"compose","s":"Ž֣","d":"Ž֣","l":"ž֣"} +{"g":"compose","s":"Ẓ","c":"Ẓ","l":"ẓ"} +{"g":"compose","s":"Ẕ̍","c":"Ẕ̍","d":"Ẕ̍","l":"ẕ̍"} +{"g":"compose","s":"à᳝","d":"à᳝"} +{"g":"compose","s":"á","c":"á"} +{"g":"compose","s":"â᳞","c":"â᳞"} +{"g":"compose","s":"ã𞗯","d":"ã𞗯"} +{"g":"compose","s":"ā","c":"ā"} +{"g":"compose","s":"ă̖","c":"ă̖"} +{"g":"compose","s":"ȧ𑍳","d":"ȧ𑍳"} +{"g":"compose","s":"ä","c":"ä"} +{"g":"compose","s":"ả𐽆","c":"ả𐽆"} +{"g":"compose","s":"å︩","d":"å︩"} +{"g":"compose","s":"ǎ","c":"ǎ"} +{"g":"compose","s":"ȁ᰷","c":"ȁ᰷"} +{"g":"compose","s":"ȃ᯲","d":"ȃ᯲"} +{"g":"compose","s":"ạ","c":"ạ"} +{"g":"compose","s":"ḁ𞀂","c":"ḁ𞀂","d":"ḁ𞀂"} +{"g":"compose","s":"ą𝅱","d":"ą𝅱"} +{"g":"compose","s":"ḃ","c":"ḃ"} +{"g":"compose","s":"ḅۙ","c":"ḅۙ","d":"ḅۙ"} +{"g":"compose","s":"ḇ꣩","d":"ḇ꣩"} +{"g":"compose","s":"ć","c":"ć"} +{"g":"compose","s":"c𑍨̂"} +{"g":"compose","s":"ċࣨ","d":"ċࣨ"} +{"g":"compose","s":"č","c":"č"} +{"g":"compose","s":"ç𑍫","c":"ç𑍫","d":"ç𑍫"} +{"g":"compose","s":"ḋ᫔","d":"ḋ᫔"} +{"g":"compose","s":"ď","c":"ď"} +{"g":"compose","s":"ḍ𐾂","c":"ḍ𐾂","d":"ḍ𐾂"} +{"g":"compose","s":"ḑ𐵭","d":"ḑ𐵭"} +{"g":"compose","s":"ḓ","c":"ḓ"} +{"g":"compose","s":"d᫏̱","c":"ḏ᫏","d":"ḏ᫏"} +{"g":"compose","s":"è్","d":"è్"} +{"g":"compose","s":"é","c":"é"} +{"g":"compose","s":"e᳚̂"} +{"g":"compose","s":"ẽ𑇀","d":"ẽ𑇀"} +{"g":"compose","s":"ē","c":"ē"} +{"g":"compose","s":"e𐺫̆"} +{"g":"compose","s":"ė𐵪","d":"ė𐵪"} +{"g":"compose","s":"ë","c":"ë"} +{"g":"compose","s":"e⃧̉"} +{"g":"compose","s":"ě᳨","d":"ě᳨"} +{"g":"compose","s":"ȅ","c":"ȅ"} +{"g":"compose","s":"e݊̑"} +{"g":"compose","s":"ẹ͙","d":"ẹ͙"} +{"g":"compose","s":"ȩ","c":"ȩ"} +{"g":"compose","s":"ę࢛","c":"ę࢛","d":"ę࢛"} +{"g":"compose","s":"ḙ𑂹","d":"ḙ𑂹"} +{"g":"compose","s":"ḛ","c":"ḛ"} +{"g":"compose","s":"fᷲ̇"} +{"g":"compose","s":"ǵⷬ","d":"ǵⷬ"} +{"g":"compose","s":"ĝ","c":"ĝ"} +{"g":"compose","s":"g͌̄"} +{"g":"compose","s":"ğ݊","d":"ğ݊"} +{"g":"compose","s":"ġ","c":"ġ"} +{"g":"compose","s":"ǧ̻","c":"ǧ̻"} +{"g":"compose","s":"ģุ","d":"ģุ"} +{"g":"compose","s":"ĥ","c":"ĥ"} +{"g":"compose","s":"h᫖̇"} +{"g":"compose","s":"ḧ𖿰","d":"ḧ𖿰"} +{"g":"compose","s":"ȟ","c":"ȟ"} +{"g":"compose","s":"ḥ𝆅","c":"ḥ𝆅","d":"ḥ𝆅"} +{"g":"compose","s":"ḩᷗ","d":"ḩᷗ"} +{"g":"compose","s":"ḫ","c":"ḫ"} +{"g":"compose","s":"ẖ𞀗","c":"ẖ𞀗","d":"ẖ𞀗"} +{"g":"compose","s":"ì̸","d":"ì̸"} +{"g":"compose","s":"í","c":"í"} +{"g":"compose","s":"i҄̂"} +{"g":"compose","s":"ĩᷛ","d":"ĩᷛ"} +{"g":"compose","s":"ī","c":"ī"} +{"g":"compose","s":"ĭ͢","c":"ĭ͢","d":"ĭ͢"} +{"g":"compose","s":"ïٓ","d":"ïٓ"} +{"g":"compose","s":"ỉ","c":"ỉ"} +{"g":"compose","s":"ǐ̞","c":"ǐ̞"} +{"g":"compose","s":"ȉ᳖","d":"ȉ᳖"} +{"g":"compose","s":"ȋ","c":"ȋ"} +{"g":"compose","s":"ị߭","c":"ị߭","d":"ị߭"} +{"g":"compose","s":"į᷑","d":"į᷑"} +{"g":"compose","s":"ḭ","c":"ḭ"} +{"g":"compose","s":"ĵ𐻽","c":"ĵ𐻽"} +{"g":"compose","s":"ǰ᳦","d":"ǰ᳦"} +{"g":"compose","s":"ḱ","c":"ḱ"} +{"g":"compose","s":"kࣖ̌"} +{"g":"compose","s":"ḳͯ","d":"ḳͯ"} +{"g":"compose","s":"ķ","c":"ķ"} +{"g":"compose","s":"ḵ꙽","c":"ḵ꙽","d":"ḵ꙽"} +{"g":"compose","s":"ĺ𐻺","d":"l𐻺́"} +{"g":"compose","s":"ľ","c":"ľ"} +{"g":"compose","s":"l᫘̣","c":"ḷ᫘","d":"ḷ᫘"} +{"g":"compose","s":"ļ⃑","d":"ļ⃑"} +{"g":"compose","s":"ḽ","c":"ḽ"} +{"g":"compose","s":"ḻ𖫰","c":"ḻ𖫰"} +{"g":"compose","s":"ḿ่","d":"ḿ่"} +{"g":"compose","s":"ṁ","c":"ṁ"} +{"g":"compose","s":"ṃู","c":"ṃู"} +{"g":"compose","s":"ǹ𝆫","d":"ǹ𝆫"} +{"g":"compose","s":"ń","c":"ń"} +{"g":"compose","s":"ñ᷐","c":"ñ᷐"} +{"g":"compose","s":"ṅ᳭","d":"ṅ᳭"} +{"g":"compose","s":"ň","c":"ň"} +{"g":"compose","s":"ṇֵ","c":"ṇֵ"} +{"g":"compose","s":"ņྃ","d":"ņྃ"} +{"g":"compose","s":"ṋ","c":"ṋ"} +{"g":"compose","s":"ṉ𑄀","c":"ṉ𑄀","d":"ṉ𑄀"} +{"g":"compose","s":"ò⳰","d":"ò⳰"} +{"g":"compose","s":"ó","c":"ó"} +{"g":"compose","s":"ô֧","c":"ô֧"} +{"g":"compose","s":"õ𑜫","d":"õ𑜫"} +{"g":"compose","s":"ō","c":"ō"} +{"g":"compose","s":"ŏ𝆊","c":"ŏ𝆊"} +{"g":"compose","s":"ȯ𞀔","d":"ȯ𞀔"} +{"g":"compose","s":"ö","c":"ö"} +{"g":"compose","s":"o꣰̉"} +{"g":"compose","s":"ő๊","d":"ő๊"} +{"g":"compose","s":"ǒ","c":"ǒ"} +{"g":"compose","s":"ȍ᬴","c":"ȍ᬴"} +{"g":"compose","s":"ȏؔ","d":"ȏؔ"} +{"g":"compose","s":"ơ","c":"ơ"} +{"g":"compose","s":"ọ᳢","c":"ọ᳢"} +{"g":"compose","s":"ǫ𞀦","d":"ǫ𞀦"} +{"g":"compose","s":"ṕ","c":"ṕ"} +{"g":"compose","s":"ṗ᷽","c":"ṗ᷽"} +{"g":"compose","s":"ŕִ","d":"ŕִ"} +{"g":"compose","s":"ṙ","c":"ṙ"} +{"g":"compose","s":"r᪱̌"} +{"g":"compose","s":"ȑࣵ","d":"ȑࣵ"} +{"g":"compose","s":"ȓ","c":"ȓ"} +{"g":"compose","s":"ṛ𞀕","c":"ṛ𞀕","d":"ṛ𞀕"} +{"g":"compose","s":"ŗ̊","d":"ŗ̊"} +{"g":"compose","s":"ṟ","c":"ṟ"} +{"g":"compose","s":"sࣴ́"} +{"g":"compose","s":"ŝꙷ","d":"ŝꙷ"} +{"g":"compose","s":"ṡ","c":"ṡ"} +{"g":"compose","s":"š𑤾","c":"š𑤾"} +{"g":"compose","s":"ṣ్","d":"ṣ్"} +{"g":"compose","s":"ș","c":"ș"} +{"g":"compose","s":"ş਼","c":"ş਼"} +{"g":"compose","s":"ṫ᫚","d":"ṫ᫚"} +{"g":"compose","s":"ẗ","c":"ẗ"} +{"g":"compose","s":"tᷝ̌"} +{"g":"compose","s":"ṭ࢛","d":"ṭ࢛"} +{"g":"compose","s":"ț","c":"ț"} +{"g":"compose","s":"ţ𝆬","c":"ţ𝆬","d":"ţ𝆬"} +{"g":"compose","s":"ṱⷱ","d":"ṱⷱ"} +{"g":"compose","s":"ṯ","c":"ṯ"} +{"g":"compose","s":"ù𖫰","c":"ù𖫰"} +{"g":"compose","s":"ú𞀠","d":"ú𞀠"} +{"g":"compose","s":"û","c":"û"} +{"g":"compose","s":"uͬ̃"} +{"g":"compose","s":"ū᫫","d":"ū᫫"} +{"g":"compose","s":"ŭ","c":"ŭ"} +{"g":"compose","s":"u⃜̈"} +{"g":"compose","s":"ủ္","d":"ủ္"} +{"g":"compose","s":"ů","c":"ů"} +{"g":"compose","s":"u︤̋"} +{"g":"compose","s":"ǔ꣤","d":"ǔ꣤"} +{"g":"compose","s":"ȕ","c":"ȕ"} +{"g":"compose","s":"u࣠̑"} +{"g":"compose","s":"ư𐽌","d":"ư𐽌"} +{"g":"compose","s":"ụ","c":"ụ"} +{"g":"compose","s":"u𐽇̤"} +{"g":"compose","s":"ųܴ","d":"ųܴ"} +{"g":"compose","s":"ṷ","c":"ṷ"} +{"g":"compose","s":"ṵ𞀒","c":"ṵ𞀒","d":"ṵ𞀒"} +{"g":"compose","s":"ṿ̃","c":"ṿ̃","d":"ṿ̃"} +{"g":"compose","s":"ṿ","c":"ṿ"} +{"g":"compose","s":"ẁ༘","c":"ẁ༘"} +{"g":"compose","s":"ẃ࡙","d":"ẃ࡙"} +{"g":"compose","s":"ŵ","c":"ŵ"} +{"g":"compose","s":"ẇ᳗","c":"ẇ᳗"} +{"g":"compose","s":"ẅꙹ","d":"ẅꙹ"} +{"g":"compose","s":"ẘ","c":"ẘ"} +{"g":"compose","s":"ẉࣴ","c":"ẉࣴ","d":"ẉࣴ"} +{"g":"compose","s":"ẋ֥","d":"ẋ֥"} +{"g":"compose","s":"ẍ","c":"ẍ"} +{"g":"compose","s":"yؕ̀"} +{"g":"compose","s":"ýܿ","d":"ýܿ"} +{"g":"compose","s":"ŷ","c":"ŷ"} +{"g":"compose","s":"ỹ𑧠","c":"ỹ𑧠"} +{"g":"compose","s":"ȳ꣰","d":"ȳ꣰"} +{"g":"compose","s":"ẏ","c":"ẏ"} +{"g":"compose","s":"ÿ݂","c":"ÿ݂"} +{"g":"compose","s":"ỷ𝅮","d":"ỷ𝅮"} +{"g":"compose","s":"ẙ","c":"ẙ"} +{"g":"compose","s":"ỵ꣯","c":"ỵ꣯","d":"ỵ꣯"} +{"g":"compose","s":"ź𝅥","d":"ź𝅥"} +{"g":"compose","s":"ẑ","c":"ẑ"} +{"g":"compose","s":"zᷢ̇"} +{"g":"compose","s":"ž𑍦","d":"ž𑍦"} +{"g":"compose","s":"ẓ","c":"ẓ"} +{"g":"compose","s":"ẕ𐴥","c":"ẕ𐴥","d":"ẕ𐴥"} +{"g":"compose","s":"῭̝","d":"῭̝"} +{"g":"compose","s":"΅","c":"΅"} +{"g":"compose","s":"¨֓͂"} +{"g":"compose","s":"Ầ𐻿","d":"Ầ𐻿","l":"ầ𐻿"} +{"g":"compose","s":"Ấ","c":"Ấ","d":"Ấ","l":"ấ"} +{"g":"compose","s":"Â᪼̃","d":"Â᪼̃","l":"â᪼̃"} +{"g":"compose","s":"Ẩ᳕","d":"Ẩ᳕","l":"ẩ᳕"} +{"g":"compose","s":"Ǟ","c":"Ǟ","d":"Ǟ","l":"ǟ"} +{"g":"compose","s":"Ǻ᮫","c":"Ǻ᮫","d":"Ǻ᮫","l":"ǻ᮫"} +{"g":"compose","s":"Ǽ𝅭","d":"Ǽ𝅭","l":"ǽ𝅭"} +{"g":"compose","s":"Ǣ","c":"Ǣ","l":"ǣ"} +{"g":"compose","s":"Ḉّ","c":"Ḉّ","d":"Ḉّ","l":"ḉّ"} +{"g":"compose","s":"Ề𐍺","d":"Ề𐍺","l":"ề𐍺"} +{"g":"compose","s":"Ế","c":"Ế","d":"Ế","l":"ế"} +{"g":"compose","s":"Ễ𐨺","c":"Ễ𐨺","d":"Ễ𐨺","l":"ễ𐨺"} +{"g":"compose","s":"Ể꙯","d":"Ể꙯","l":"ể꙯"} +{"g":"compose","s":"Ḯ","c":"Ḯ","d":"Ḯ","l":"ḯ"} +{"g":"compose","s":"Ồ𝅱","c":"Ồ𝅱","d":"Ồ𝅱","l":"ồ𝅱"} +{"g":"compose","s":"Ố𞥄","d":"Ố𞥄","l":"ố𞥄"} +{"g":"compose","s":"Ỗ","c":"Ỗ","d":"Ỗ","l":"ỗ"} +{"g":"compose","s":"Ôꙺ̉","d":"Ôꙺ̉","l":"ôꙺ̉"} +{"g":"compose","s":"Ṍ𐺫","d":"Ṍ𐺫","l":"ṍ𐺫"} +{"g":"compose","s":"Ȭ","c":"Ȭ","d":"Ȭ","l":"ȭ"} +{"g":"compose","s":"Õ᫩̈","d":"Õ᫩̈","l":"õ᫩̈"} +{"g":"compose","s":"Ȫ𞀊","d":"Ȫ𞀊","l":"ȫ𞀊"} +{"g":"compose","s":"Ǿ","c":"Ǿ","l":"ǿ"} +{"g":"compose","s":"Ü꣫̀","d":"Ü꣫̀","l":"ü꣫̀"} +{"g":"compose","s":"Ǘ𐨺","d":"Ǘ𐨺","l":"ǘ𐨺"} +{"g":"compose","s":"Ǖ","c":"Ǖ","d":"Ǖ","l":"ǖ"} +{"g":"compose","s":"Ü᫙̌","d":"Ü᫙̌","l":"ü᫙̌"} +{"g":"compose","s":"ầ̃","d":"ầ̃"} +{"g":"compose","s":"ấ","c":"ấ","d":"ấ"} +{"g":"compose","s":"â᫦̃","c":"ẫ᫦","d":"a᫦̂̃"} +{"g":"compose","s":"ẩ᳗","d":"ẩ᳗"} +{"g":"compose","s":"ǟ","c":"ǟ","d":"ǟ"} +{"g":"compose","s":"ǻ𑏎","c":"ǻ𑏎","d":"ǻ𑏎"} +{"g":"compose","s":"ǽ⃗","d":"ǽ⃗"} +{"g":"compose","s":"ǣ","c":"ǣ"} +{"g":"compose","s":"ç𐺫́","d":"ç𐺫́"} +{"g":"compose","s":"ềⷳ","d":"ềⷳ"} +{"g":"compose","s":"ế","c":"ế","d":"ế"} +{"g":"compose","s":"ễ̷","c":"ễ̷","d":"ễ̷"} +{"g":"compose","s":"ể̓","d":"ể̓"} +{"g":"compose","s":"ḯ","c":"ḯ","d":"ḯ"} +{"g":"compose","s":"ồ𝅦","c":"ồ𝅦","d":"ồ𝅦"} +{"g":"compose","s":"ố𞗮","d":"ố𞗮"} +{"g":"compose","s":"ỗ","c":"ỗ","d":"ỗ"} +{"g":"compose","s":"ô︣̉","d":"ô︣̉"} +{"g":"compose","s":"ṍﬞ","d":"ṍﬞ"} +{"g":"compose","s":"ȭ","c":"ȭ","d":"ȭ"} +{"g":"compose","s":"õܳ̈","d":"õܳ̈"} +{"g":"compose","s":"ȫﬞ","d":"ȫﬞ"} +{"g":"compose","s":"ǿ","c":"ǿ"} +{"g":"compose","s":"ǜ͙","c":"ǜ͙","d":"ǜ͙"} +{"g":"compose","s":"ǘ⃰","d":"ǘ⃰"} +{"g":"compose","s":"ǖ","c":"ǖ","d":"ǖ"} +{"g":"compose","s":"ǚְ","c":"ǚְ","d":"ǚְ"} +{"g":"compose","s":"Ằ݄","d":"Ằ݄","l":"ằ݄"} +{"g":"compose","s":"Ắ","c":"Ắ","d":"Ắ","l":"ắ"} +{"g":"compose","s":"Ẵ᳕","c":"Ẵ᳕","d":"Ẵ᳕","l":"ẵ᳕"} +{"g":"compose","s":"Ẳ𐵭","d":"Ẳ𐵭","l":"ẳ𐵭"} +{"g":"compose","s":"ằ","c":"ằ","d":"ằ"} +{"g":"compose","s":"ă࢟́","d":"ă࢟́"} +{"g":"compose","s":"ẵ᷒","d":"ẵ᷒"} +{"g":"compose","s":"ẳ","c":"ẳ","d":"ẳ"} +{"g":"compose","s":"Ē𞋬̀","d":"Ē𞋬̀","l":"ē𞋬̀"} +{"g":"compose","s":"Ḗ᫈","d":"Ḗ᫈","l":"ḗ᫈"} +{"g":"compose","s":"ḕ","c":"ḕ","d":"ḕ"} +{"g":"compose","s":"ē᫙́","d":"ē᫙́"} +{"g":"compose","s":"Ṑ〪","d":"Ṑ〪","l":"ṑ〪"} +{"g":"compose","s":"Ṓ","c":"Ṓ","d":"Ṓ","l":"ṓ"} +{"g":"compose","s":"ṑ͍","c":"ṑ͍","d":"ṑ͍"} +{"g":"compose","s":"ṓ᷋","d":"ṓ᷋"} +{"g":"compose","s":"Ṥ","c":"Ṥ","d":"Ṥ","l":"ṥ"} +{"g":"compose","s":"ṥ𝆁","c":"ṥ𝆁","d":"ṥ𝆁"} +{"g":"compose","s":"Ṧࣩ","d":"Ṧࣩ","l":"ṧࣩ"} +{"g":"compose","s":"ṧ","c":"ṧ","d":"ṧ"} +{"g":"compose","s":"Ṹ゚","c":"Ṹ゚","d":"Ṹ゚","l":"ṹ゚"} +{"g":"compose","s":"ṹ𐴦","d":"ṹ𐴦"} +{"g":"compose","s":"Ṻ","c":"Ṻ","d":"Ṻ","l":"ṻ"} +{"g":"compose","s":"ū𝆪̈","d":"ū𝆪̈"} +{"g":"compose","s":"ẛࣵ","d":"ẛࣵ"} +{"g":"compose","s":"Ờ","c":"Ờ","d":"Ờ","l":"ờ"} +{"g":"compose","s":"Ơࠫ́","d":"Ơࠫ́","l":"ơࠫ́"} +{"g":"compose","s":"Ỡ᪵","d":"Ỡ᪵","l":"ỡ᪵"} +{"g":"compose","s":"Ở","c":"Ở","d":"Ở","l":"ở"} +{"g":"compose","s":"Ợ͗","c":"Ợ͗","d":"Ợ͗","l":"ợ͗"} +{"g":"compose","s":"ờⷵ","d":"ờⷵ"} +{"g":"compose","s":"ớ","c":"ớ","d":"ớ"} +{"g":"compose","s":"ỡ̙","c":"ỡ̙","d":"ỡ̙"} +{"g":"compose","s":"ở۟","d":"ở۟"} +{"g":"compose","s":"ợ","c":"ợ","d":"ợ"} +{"g":"compose","s":"Ưࠣ̀","d":"Ưࠣ̀","l":"ưࠣ̀"} +{"g":"compose","s":"Ứܲ","d":"Ứܲ","l":"ứܲ"} +{"g":"compose","s":"Ữ","c":"Ữ","d":"Ữ","l":"ữ"} +{"g":"compose","s":"Ưꚞ̉","d":"Ưꚞ̉","l":"ưꚞ̉"} +{"g":"compose","s":"Ự̅","d":"Ự̅","l":"ự̅"} +{"g":"compose","s":"ừ","c":"ừ","d":"ừ"} +{"g":"compose","s":"ứ𑌻","c":"ứ𑌻","d":"ứ𑌻"} +{"g":"compose","s":"ữ𞥄","d":"ữ𞥄"} +{"g":"compose","s":"ử","c":"ử","d":"ử"} +{"g":"compose","s":"ựࣧ","c":"ựࣧ","d":"ựࣧ"} +{"g":"compose","s":"Ǯ𐵩","d":"Ǯ𐵩","l":"ǯ𐵩"} +{"g":"compose","s":"Ǭ","c":"Ǭ","d":"Ǭ","l":"ǭ"} +{"g":"compose","s":"ǫ࣌̄","d":"ǫ࣌̄"} +{"g":"compose","s":"Ǡ𑇀","d":"Ǡ𑇀","l":"ǡ𑇀"} +{"g":"compose","s":"ǡ","c":"ǡ","d":"ǡ"} +{"g":"compose","s":"Ḝ𝅲","c":"Ḝ𝅲","d":"Ḝ𝅲","l":"ḝ𝅲"} +{"g":"compose","s":"ḝ𑽁","d":"ḝ𑽁"} +{"g":"compose","s":"Ȱ","c":"Ȱ","d":"Ȱ","l":"ȱ"} +{"g":"compose","s":"ȱ𞣒","c":"ȱ𞣒","d":"ȱ𞣒"} +{"g":"compose","s":"ǯْ","d":"ǯْ"} +{"g":"compose","s":"Ὰ","c":"Ὰ","l":"ὰ"} +{"g":"compose","s":"Αⷯ́","l":"αⷯ́"} +{"g":"compose","s":"Ᾱᷗ","d":"Ᾱᷗ","l":"ᾱᷗ"} +{"g":"compose","s":"Ᾰ","c":"Ᾰ","l":"ᾰ"} +{"g":"compose","s":"Α𞀗̓","l":"α𞀗̓"} +{"g":"compose","s":"Ἁ֣","d":"Ἁ֣","l":"ἁ֣"} +{"g":"compose","s":"ᾼ","c":"ᾼ","l":"ᾳ"} +{"g":"compose","s":"Ὲܴ","c":"Ὲܴ","l":"ὲܴ"} +{"g":"compose","s":"Έ̧","d":"Έ̧","l":"έ̧"} +{"g":"compose","s":"Ἐ","c":"Ἐ","l":"ἐ"} +{"g":"compose","s":"Ἑ̶","c":"Ἑ̶","l":"ἑ̶"} +{"g":"compose","s":"Ὴ࣓","d":"Ὴ࣓","l":"ὴ࣓"} +{"g":"compose","s":"Ή","c":"Ή","l":"ή"} +{"g":"compose","s":"Ἠ᫄","c":"Ἠ᫄","l":"ἠ᫄"} +{"g":"compose","s":"Ἡ᤻","d":"Ἡ᤻","l":"ἡ᤻"} +{"g":"compose","s":"ῌ","c":"ῌ","l":"ῃ"} +{"g":"compose","s":"Ι࢞̀","l":"ι࢞̀"} +{"g":"compose","s":"Ί𐽉","d":"Ί𐽉","l":"ί𐽉"} +{"g":"compose","s":"Ῑ","c":"Ῑ","l":"ῑ"} +{"g":"compose","s":"Ι̅̆","l":"ι̅̆"} +{"g":"compose","s":"Ϊ꣭","d":"Ϊ꣭","l":"ϊ꣭"} +{"g":"compose","s":"Ἰ","c":"Ἰ","l":"ἰ"} +{"g":"compose","s":"Ι𞀂̔","l":"ι𞀂̔"} +{"g":"compose","s":"Ὸ𐽇","d":"Ὸ𐽇","l":"ὸ𐽇"} +{"g":"compose","s":"Ό","c":"Ό","l":"ό"} +{"g":"compose","s":"Ὀ᬴","c":"Ὀ᬴","l":"ὀ᬴"} +{"g":"compose","s":"Ὁ꣬","d":"Ὁ꣬","l":"ὁ꣬"} +{"g":"compose","s":"Ῥ","c":"Ῥ","l":"ῥ"} +{"g":"compose","s":"Ὺ᷽","c":"Ὺ᷽","l":"ὺ᷽"} +{"g":"compose","s":"Ύ֩","d":"Ύ֩","l":"ύ֩"} +{"g":"compose","s":"Ῡ","c":"Ῡ","l":"ῡ"} +{"g":"compose","s":"Υ𞀘̆","l":"υ𞀘̆"} +{"g":"compose","s":"Ϋⷪ","d":"Ϋⷪ","l":"ϋⷪ"} +{"g":"compose","s":"Ὑ","c":"Ὑ","l":"ὑ"} +{"g":"compose","s":"Ω̋̀","l":"ω̋̀"} +{"g":"compose","s":"Ώ𞥇","d":"Ώ𞥇","l":"ώ𞥇"} +{"g":"compose","s":"Ὠ","c":"Ὠ","l":"ὠ"} +{"g":"compose","s":"Ὡﬞ","c":"Ὡﬞ","l":"ὡﬞ"} +{"g":"compose","s":"ῼ𞀔","d":"ῼ𞀔","l":"ῳ𞀔"} +{"g":"compose","s":"ᾴ","c":"ᾴ","d":"ᾴ"} +{"g":"compose","s":"ῄͣ","c":"ῄͣ","d":"ῄͣ"} +{"g":"compose","s":"ὰُ","d":"ὰُ"} +{"g":"compose","s":"ά","c":"ά"} +{"g":"compose","s":"α︮̄"} +{"g":"compose","s":"ᾰ〯","d":"ᾰ〯"} +{"g":"compose","s":"ἀ","c":"ἀ"} +{"g":"compose","s":"α𐵪̔"} +{"g":"compose","s":"ᾶ᫧","d":"ᾶ᫧"} +{"g":"compose","s":"ᾳ","c":"ᾳ"} +{"g":"compose","s":"ε𖬴̀"} +{"g":"compose","s":"έࠢ","d":"έࠢ"} +{"g":"compose","s":"ἐ","c":"ἐ"} +{"g":"compose","s":"ε߳̔"} +{"g":"compose","s":"ὴָ","d":"ὴָ"} +{"g":"compose","s":"ή","c":"ή"} +{"g":"compose","s":"η᷇̓"} +{"g":"compose","s":"ἡ᳧","d":"ἡ᳧"} +{"g":"compose","s":"ῆ","c":"ῆ"} +{"g":"compose","s":"ῃ𝅦","c":"ῃ𝅦"} +{"g":"compose","s":"ὶ݊","d":"ὶ݊"} +{"g":"compose","s":"ί","c":"ί"} +{"g":"compose","s":"ῑ༘","c":"ῑ༘"} +{"g":"compose","s":"ῐ𐍶","d":"ῐ𐍶"} +{"g":"compose","s":"ϊ","c":"ϊ"} +{"g":"compose","s":"ι᫈̓"} +{"g":"compose","s":"ἱ𞣕","d":"ἱ𞣕"} +{"g":"compose","s":"ῖ","c":"ῖ"} +{"g":"compose","s":"οࣥ̀"} +{"g":"compose","s":"όᷯ","d":"όᷯ"} +{"g":"compose","s":"ὀ","c":"ὀ"} +{"g":"compose","s":"ὁ𖫰","c":"ὁ𖫰"} +{"g":"compose","s":"ῤ꤬","d":"ῤ꤬"} +{"g":"compose","s":"ῥ","c":"ῥ"} +{"g":"compose","s":"υܰ̀"} +{"g":"compose","s":"ύ᪱","d":"ύ᪱"} +{"g":"compose","s":"ῡ","c":"ῡ"} +{"g":"compose","s":"ῠ⃬","c":"ῠ⃬"} +{"g":"compose","s":"ϋ𖬱","d":"ϋ𖬱"} +{"g":"compose","s":"ὐ","c":"ὐ"} +{"g":"compose","s":"υⷱ̔"} +{"g":"compose","s":"ῦ𑤽","d":"ῦ𑤽"} +{"g":"compose","s":"ὼ","c":"ὼ"} +{"g":"compose","s":"ω࢞́"} +{"g":"compose","s":"ὠ𑚷","d":"ὠ𑚷"} +{"g":"compose","s":"ὡ","c":"ὡ"} +{"g":"compose","s":"ῶ꯭","c":"ῶ꯭"} +{"g":"compose","s":"ῳࣶ","d":"ῳࣶ"} +{"g":"compose","s":"ῒ","c":"ῒ","d":"ῒ"} +{"g":"compose","s":"ϊ𞊮́","d":"ϊ𞊮́"} +{"g":"compose","s":"ῗ᳟","d":"ῗ᳟"} +{"g":"compose","s":"ῢ","c":"ῢ","d":"ῢ"} +{"g":"compose","s":"ϋ𐵪́","d":"ϋ𐵪́"} +{"g":"compose","s":"ῧܷ","d":"ῧܷ"} +{"g":"compose","s":"ῴ","c":"ῴ","d":"ῴ"} +{"g":"compose","s":"ϒ𞀔́"} +{"g":"compose","s":"ϔ𝆫","d":"ϔ𝆫"} +{"g":"compose","s":"Ї","c":"Ї","l":"ї"} +{"g":"compose","s":"Аܳ̆","l":"аܳ̆"} +{"g":"compose","s":"Ӓ᭄","d":"Ӓ᭄","l":"ӓ᭄"} +{"g":"compose","s":"Ѓ","c":"Ѓ","l":"ѓ"} +{"g":"compose","s":"Ѐ᷼","c":"Ѐ᷼","d":"Ѐ᷼","l":"ѐ᷼"} +{"g":"compose","s":"Ӗ𑅳","d":"Ӗ𑅳","l":"ӗ𑅳"} +{"g":"compose","s":"Ё","c":"Ё","l":"ё"} +{"g":"compose","s":"Жࣗ̆","l":"жࣗ̆"} +{"g":"compose","s":"Ӝ꣯","d":"Ӝ꣯","l":"ӝ꣯"} +{"g":"compose","s":"Ӟ","c":"Ӟ","l":"ӟ"} +{"g":"compose","s":"И̐̀","l":"и̐̀"} +{"g":"compose","s":"Ӣᷯ","d":"Ӣᷯ","l":"ӣᷯ"} +{"g":"compose","s":"Й","c":"Й","l":"й"} +{"g":"compose","s":"И𞥆̈","l":"и𞥆̈"} +{"g":"compose","s":"Ќᷥ","d":"Ќᷥ","l":"ќᷥ"} +{"g":"compose","s":"Ӧ","c":"Ӧ","l":"ӧ"} +{"g":"compose","s":"У𐽌̄","l":"у𐽌̄"} +{"g":"compose","s":"Ў͠","d":"Ў͠","l":"ў͠"} +{"g":"compose","s":"Ӱ","c":"Ӱ","l":"ӱ"} +{"g":"compose","s":"Ӳ່","c":"Ӳ່","l":"ӳ່"} +{"g":"compose","s":"Ӵٖ","d":"Ӵٖ","l":"ӵٖ"} +{"g":"compose","s":"Ӹ","c":"Ӹ","l":"ӹ"} +{"g":"compose","s":"Ӭ⃒","c":"Ӭ⃒","l":"ӭ⃒"} +{"g":"compose","s":"ӑ࢙","d":"ӑ࢙"} +{"g":"compose","s":"ӓ","c":"ӓ"} +{"g":"compose","s":"ѓ᷽","c":"ѓ᷽"} +{"g":"compose","s":"ѐͧ","d":"ѐͧ"} +{"g":"compose","s":"ӗ","c":"ӗ"} +{"g":"compose","s":"е߰̈"} +{"g":"compose","s":"ӂࣟ","d":"ӂࣟ"} +{"g":"compose","s":"ӝ","c":"ӝ"} +{"g":"compose","s":"ӟׇ","c":"ӟׇ"} +{"g":"compose","s":"ѝ𑍰","d":"ѝ𑍰"} +{"g":"compose","s":"ӣ","c":"ӣ"} +{"g":"compose","s":"й̺","c":"й̺"} +{"g":"compose","s":"ӥׂ","d":"ӥׂ"} +{"g":"compose","s":"ќ","c":"ќ"} +{"g":"compose","s":"о⃖̈"} +{"g":"compose","s":"ӯ᪶","d":"ӯ᪶"} +{"g":"compose","s":"ў","c":"ў"} +{"g":"compose","s":"уٗ̈"} +{"g":"compose","s":"ӳͩ","d":"ӳͩ"} +{"g":"compose","s":"ӵ","c":"ӵ"} +{"g":"compose","s":"ӹ𑧠","c":"ӹ𑧠"} +{"g":"compose","s":"ӭ𝆋","d":"ӭ𝆋"} +{"g":"compose","s":"ї","c":"ї"} +{"g":"compose","s":"Ѷ๊","c":"Ѷ๊","l":"ѷ๊"} +{"g":"compose","s":"ѷꪸ","d":"ѷꪸ"} +{"g":"compose","s":"Ӛ","c":"Ӛ","l":"ӛ"} +{"g":"compose","s":"әؗ̈"} +{"g":"compose","s":"Ӫ͢","d":"Ӫ͢","l":"ӫ͢"} +{"g":"compose","s":"ӫ","c":"ӫ"} +{"g":"compose","s":"ا𞀅ٓ"} +{"g":"compose","s":"أܽ","d":"أܽ"} +{"g":"compose","s":"إ","c":"إ"} +{"g":"compose","s":"وͪٔ"} +{"g":"compose","s":"ئ߰","d":"ئ߰"} +{"g":"compose","s":"ۂ","c":"ۂ"} +{"g":"compose","s":"ۓᢩ","c":"ۓᢩ"} +{"g":"compose","s":"ۀ᷑","d":"ۀ᷑"} +{"g":"compose","s":"ऩ","c":"ऩ"} +{"g":"compose","s":"ऱ̤","c":"ऱ̤","d":"ऱ̤"} +{"g":"compose","s":"ऴ𐵭","d":"ऴ𐵭"} +{"g":"compose","s":"ো","c":"ো"} +{"g":"compose","s":"ে𝅿ৗ"} +{"g":"compose","s":"ୋ𖫴","d":"ୋ𖫴"} +{"g":"compose","s":"ୈ","c":"ୈ"} +{"g":"compose","s":"େ𑄁ୗ"} +{"g":"compose","s":"ஔ̴","d":"ஔ̴"} +{"g":"compose","s":"ொ","c":"ொ"} +{"g":"compose","s":"ெ𑌻ௗ"} +{"g":"compose","s":"ோ᫜","d":"ோ᫜"} +{"g":"compose","s":"ై","c":"ై"} +{"g":"compose","s":"ಿ᪰ೕ"} +{"g":"compose","s":"ೊ͌","d":"ೊ͌"} +{"g":"compose","s":"ೇ","c":"ೇ"} +{"g":"compose","s":"ೆ𝅰ೖ"} +{"g":"compose","s":"ೋᷱ","d":"ೋᷱ"} +{"g":"compose","s":"ൊ","c":"ൊ"} +{"g":"compose","s":"െ᫝ൗ"} +{"g":"compose","s":"ോ᬴","d":"ോ᬴"} +{"g":"compose","s":"ේ","c":"ේ"} +{"g":"compose","s":"ෙ𑰿ා"} +{"g":"compose","s":"ෞ𝆭","d":"ෞ𝆭"} +{"g":"compose","s":"ෝ","c":"ෝ","d":"ෝ"} +{"g":"compose","s":"ဥ៝ီ"} +{"g":"compose","s":"ᬆ᫦","d":"ᬆ᫦"} +{"g":"compose","s":"ᬈ","c":"ᬈ"} +{"g":"compose","s":"ᬉ꪿ᬵ"} +{"g":"compose","s":"ᬌ𐨹","d":"ᬌ𐨹"} +{"g":"compose","s":"ᬎ","c":"ᬎ"} +{"g":"compose","s":"ᬑ഼ᬵ"} +{"g":"compose","s":"ᬻ𝆈","d":"ᬻ𝆈"} +{"g":"compose","s":"ᬽ","c":"ᬽ"} +{"g":"compose","s":"ᬾⷽᬵ"} +{"g":"compose","s":"ᭁࣕ","d":"ᭁࣕ"} +{"g":"compose","s":"ᭃ","c":"ᭃ"} +{"g":"compose","s":"Ḷ͗̄","d":"Ḷ͗̄","l":"ḷ͗̄"} +{"g":"compose","s":"ḹ᪳","d":"ḹ᪳"} +{"g":"compose","s":"Ṝ","c":"Ṝ","d":"Ṝ","l":"ṝ"} +{"g":"compose","s":"ṝ᪸","c":"ṝ᪸","d":"ṝ᪸"} +{"g":"compose","s":"Ṩ︬","d":"Ṩ︬","l":"ṩ︬"} +{"g":"compose","s":"ṩ","c":"ṩ","d":"ṩ"} +{"g":"compose","s":"Ạ͆̂","d":"Ạ͆̂","l":"ạ͆̂"} +{"g":"compose","s":"Ặܺ","d":"Ặܺ","l":"ặܺ"} +{"g":"compose","s":"ậ","c":"ậ","d":"ậ"} +{"g":"compose","s":"ạ𞋯̆","d":"ạ𞋯̆"} +{"g":"compose","s":"Ệⷨ","d":"Ệⷨ","l":"ệⷨ"} +{"g":"compose","s":"ệ","c":"ệ","d":"ệ"} +{"g":"compose","s":"Ọ𝆪̂","d":"Ọ𝆪̂","l":"ọ𝆪̂"} +{"g":"compose","s":"ộ𑋩","d":"ộ𑋩"} +{"g":"compose","s":"ἂ","c":"ἂ","d":"ἂ"} +{"g":"compose","s":"ἄ𑠺","c":"ἄ𑠺","d":"ἄ𑠺"} +{"g":"compose","s":"ἆֿ","d":"ἆֿ"} +{"g":"compose","s":"ᾀ","c":"ᾀ","d":"ᾀ"} +{"g":"compose","s":"ἁ̈̀","d":"ἁ̈̀"} +{"g":"compose","s":"ἅ𝅥","d":"ἅ𝅥"} +{"g":"compose","s":"ἇ","c":"ἇ","d":"ἇ"} +{"g":"compose","s":"ᾁ݇","c":"ᾁ݇","d":"ᾁ݇"} +{"g":"compose","s":"ᾂׂ","d":"ᾂׂ"} +{"g":"compose","s":"ᾃ","c":"ᾃ","d":"ᾃ"} +{"g":"compose","s":"ᾄ༹","c":"ᾄ༹","d":"ᾄ༹"} +{"g":"compose","s":"ᾅ͉","d":"ᾅ͉"} +{"g":"compose","s":"ᾆ","c":"ᾆ","d":"ᾆ"} +{"g":"compose","s":"ᾇ྄","c":"ᾇ྄","d":"ᾇ྄"} +{"g":"compose","s":"Ἂ𞄲","d":"Ἂ𞄲","l":"ἂ𞄲"} +{"g":"compose","s":"Ἄ","c":"Ἄ","d":"Ἄ","l":"ἄ"} +{"g":"compose","s":"Ἀᷨ͂","d":"Ἀᷨ͂","l":"ἀᷨ͂"} +{"g":"compose","s":"ᾈ͖","d":"ᾈ͖","l":"ᾀ͖"} +{"g":"compose","s":"Ἃ","c":"Ἃ","d":"Ἃ","l":"ἃ"} +{"g":"compose","s":"Ἅ𐻿","c":"Ἅ𐻿","d":"Ἅ𐻿","l":"ἅ𐻿"} +{"g":"compose","s":"Ἇܳ","d":"Ἇܳ","l":"ἇܳ"} +{"g":"compose","s":"ᾉ","c":"ᾉ","d":"ᾉ","l":"ᾁ"} +{"g":"compose","s":"ᾊ𑁿","c":"ᾊ𑁿","d":"ᾊ𑁿","l":"ᾂ𑁿"} +{"g":"compose","s":"ᾋ᫃","d":"ᾋ᫃","l":"ᾃ᫃"} +{"g":"compose","s":"ᾌ","c":"ᾌ","d":"ᾌ","l":"ᾄ"} +{"g":"compose","s":"ᾍ᰷","c":"ᾍ᰷","d":"ᾍ᰷","l":"ᾅ᰷"} +{"g":"compose","s":"ᾎ𝅼","d":"ᾎ𝅼","l":"ᾆ𝅼"} +{"g":"compose","s":"ᾏ","c":"ᾏ","d":"ᾏ","l":"ᾇ"} +{"g":"compose","s":"ἒ̪","c":"ἒ̪","d":"ἒ̪"} +{"g":"compose","s":"ἔ꪿","d":"ἔ꪿"} +{"g":"compose","s":"ἓ","c":"ἓ","d":"ἓ"} +{"g":"compose","s":"ἕ𐽎","c":"ἕ𐽎","d":"ἕ𐽎"} +{"g":"compose","s":"Ἒⷺ","d":"Ἒⷺ","l":"ἒⷺ"} +{"g":"compose","s":"Ἔ","c":"Ἔ","d":"Ἔ","l":"ἔ"} +{"g":"compose","s":"Ἓ゚","c":"Ἓ゚","d":"Ἓ゚","l":"ἓ゚"} +{"g":"compose","s":"Ἕ𑁿","d":"Ἕ𑁿","l":"ἕ𑁿"} +{"g":"compose","s":"ἢ","c":"ἢ","d":"ἢ"} +{"g":"compose","s":"ἠ᩷́","d":"ἠ᩷́"} +{"g":"compose","s":"ἦ𝆅","d":"ἦ𝆅"} +{"g":"compose","s":"ᾐ","c":"ᾐ","d":"ᾐ"} +{"g":"compose","s":"ἡ𐾄̀","d":"ἡ𐾄̀"} +{"g":"compose","s":"ἥ𐽊","d":"ἥ𐽊"} +{"g":"compose","s":"ἧ","c":"ἧ","d":"ἧ"} +{"g":"compose","s":"ᾑᷬ","c":"ᾑᷬ","d":"ᾑᷬ"} +{"g":"compose","s":"ᾒࠧ","d":"ᾒࠧ"} +{"g":"compose","s":"ᾓ","c":"ᾓ","d":"ᾓ"} +{"g":"compose","s":"ᾔ࡙","c":"ᾔ࡙","d":"ᾔ࡙"} +{"g":"compose","s":"ᾕ֖","d":"ᾕ֖"} +{"g":"compose","s":"ᾖ","c":"ᾖ","d":"ᾖ"} +{"g":"compose","s":"ᾗ࿆","c":"ᾗ࿆","d":"ᾗ࿆"} +{"g":"compose","s":"Ἢ᭄","d":"Ἢ᭄","l":"ἢ᭄"} +{"g":"compose","s":"Ἤ","c":"Ἤ","d":"Ἤ","l":"ἤ"} +{"g":"compose","s":"Ἠࣞ͂","d":"Ἠࣞ͂","l":"ἠࣞ͂"} +{"g":"compose","s":"ᾘ᭫","d":"ᾘ᭫","l":"ᾐ᭫"} +{"g":"compose","s":"Ἣ","c":"Ἣ","d":"Ἣ","l":"ἣ"} +{"g":"compose","s":"Ἡᷱ́","d":"Ἡᷱ́","l":"ἡᷱ́"} +{"g":"compose","s":"Ἧ્","d":"Ἧ્","l":"ἧ્"} +{"g":"compose","s":"ᾙ","c":"ᾙ","d":"ᾙ","l":"ᾑ"} +{"g":"compose","s":"ᾚ᳔","c":"ᾚ᳔","d":"ᾚ᳔","l":"ᾒ᳔"} +{"g":"compose","s":"ᾛ᪼","d":"ᾛ᪼","l":"ᾓ᪼"} +{"g":"compose","s":"ᾜ","c":"ᾜ","d":"ᾜ","l":"ᾔ"} +{"g":"compose","s":"ᾝⷼ","c":"ᾝⷼ","d":"ᾝⷼ","l":"ᾕⷼ"} +{"g":"compose","s":"ᾞ᩼","d":"ᾞ᩼","l":"ᾖ᩼"} +{"g":"compose","s":"ᾟ","c":"ᾟ","d":"ᾟ","l":"ᾗ"} +{"g":"compose","s":"ἲ߲","c":"ἲ߲","d":"ἲ߲"} +{"g":"compose","s":"ἴ᷅","d":"ἴ᷅"} +{"g":"compose","s":"ἶ","c":"ἶ","d":"ἶ"} +{"g":"compose","s":"ἳܻ","c":"ἳܻ","d":"ἳܻ"} +{"g":"compose","s":"ἵࠣ","d":"ἵࠣ"} +{"g":"compose","s":"ἷ","c":"ἷ","d":"ἷ"} +{"g":"compose","s":"Ἲ𝅽","c":"Ἲ𝅽","d":"Ἲ𝅽","l":"ἲ𝅽"} +{"g":"compose","s":"Ἴ᳸","d":"Ἴ᳸","l":"ἴ᳸"} +{"g":"compose","s":"Ἶ","c":"Ἶ","d":"Ἶ","l":"ἶ"} +{"g":"compose","s":"Ἱᷕ̀","d":"Ἱᷕ̀","l":"ἱᷕ̀"} +{"g":"compose","s":"Ἵ𞀔","d":"Ἵ𞀔","l":"ἵ𞀔"} +{"g":"compose","s":"Ἷ","c":"Ἷ","d":"Ἷ","l":"ἷ"} +{"g":"compose","s":"ὂ่","c":"ὂ่","d":"ὂ่"} +{"g":"compose","s":"ὄ꣫","d":"ὄ꣫"} +{"g":"compose","s":"ὃ","c":"ὃ","d":"ὃ"} +{"g":"compose","s":"ὁ𐫥́","d":"ὁ𐫥́"} +{"g":"compose","s":"Ὂ̃","d":"Ὂ̃","l":"ὂ̃"} +{"g":"compose","s":"Ὄ","c":"Ὄ","d":"Ὄ","l":"ὄ"} +{"g":"compose","s":"Ὁ𞀡̀","d":"Ὁ𞀡̀","l":"ὁ𞀡̀"} +{"g":"compose","s":"Ὅ𑋪","d":"Ὅ𑋪","l":"ὅ𑋪"} +{"g":"compose","s":"ὒ","c":"ὒ","d":"ὒ"} +{"g":"compose","s":"ὔ᯳","c":"ὔ᯳","d":"ὔ᯳"} +{"g":"compose","s":"ὖꪰ","d":"ὖꪰ"} +{"g":"compose","s":"ὓ","c":"ὓ","d":"ὓ"} +{"g":"compose","s":"ὑᷢ́","d":"ὑᷢ́"} +{"g":"compose","s":"ὗࣻ","d":"ὗࣻ"} +{"g":"compose","s":"Ὓ","c":"Ὓ","d":"Ὓ","l":"ὓ"} +{"g":"compose","s":"Ὕ⃭","c":"Ὕ⃭","d":"Ὕ⃭","l":"ὕ⃭"} +{"g":"compose","s":"Ὗ𑅳","d":"Ὗ𑅳","l":"ὗ𑅳"} +{"g":"compose","s":"ὢ","c":"ὢ","d":"ὢ"} +{"g":"compose","s":"ὠ𖬱́","d":"ὠ𖬱́"} +{"g":"compose","s":"ὦ꣪","d":"ὦ꣪"} +{"g":"compose","s":"ᾠ","c":"ᾠ","d":"ᾠ"} +{"g":"compose","s":"ὡᷘ̀","d":"ὡᷘ̀"} +{"g":"compose","s":"ὥᷥ","d":"ὥᷥ"} +{"g":"compose","s":"ὧ","c":"ὧ","d":"ὧ"} +{"g":"compose","s":"ᾡٖ","c":"ᾡٖ","d":"ᾡٖ"} +{"g":"compose","s":"ᾢꪾ","d":"ᾢꪾ"} +{"g":"compose","s":"ᾣ","c":"ᾣ","d":"ᾣ"} +{"g":"compose","s":"ᾤ𞓭","c":"ᾤ𞓭","d":"ᾤ𞓭"} +{"g":"compose","s":"ᾥܴ","d":"ᾥܴ"} +{"g":"compose","s":"ᾦ","c":"ᾦ","d":"ᾦ"} +{"g":"compose","s":"ᾧ᤻","c":"ᾧ᤻","d":"ᾧ᤻"} +{"g":"compose","s":"Ὢ𞛣","d":"Ὢ𞛣","l":"ὢ𞛣"} +{"g":"compose","s":"Ὤ","c":"Ὤ","d":"Ὤ","l":"ὤ"} +{"g":"compose","s":"Ὠ҄͂","d":"Ὠ҄͂","l":"ὠ҄͂"} +{"g":"compose","s":"ᾨ࢝","d":"ᾨ࢝","l":"ᾠ࢝"} +{"g":"compose","s":"Ὣ","c":"Ὣ","d":"Ὣ","l":"ὣ"} +{"g":"compose","s":"Ὡ᷄́","d":"Ὡ᷄́","l":"ὡ᷄́"} +{"g":"compose","s":"Ὧ꣱","d":"Ὧ꣱","l":"ὧ꣱"} +{"g":"compose","s":"ᾩ","c":"ᾩ","d":"ᾩ","l":"ᾡ"} +{"g":"compose","s":"ᾪࣟ","c":"ᾪࣟ","d":"ᾪࣟ","l":"ᾢࣟ"} +{"g":"compose","s":"ᾫྃ","d":"ᾫྃ","l":"ᾣྃ"} +{"g":"compose","s":"ᾬ","c":"ᾬ","d":"ᾬ","l":"ᾤ"} +{"g":"compose","s":"ᾭ݁","c":"ᾭ݁","d":"ᾭ݁","l":"ᾥ݁"} +{"g":"compose","s":"ᾮ꦳","d":"ᾮ꦳","l":"ᾦ꦳"} +{"g":"compose","s":"ᾯ","c":"ᾯ","d":"ᾯ","l":"ᾧ"} +{"g":"compose","s":"ᾲࠖ","c":"ᾲࠖ","d":"ᾲࠖ"} +{"g":"compose","s":"ῂ𞣑","d":"ῂ𞣑"} +{"g":"compose","s":"ῲ","c":"ῲ","d":"ῲ"} +{"g":"compose","s":"ᾷ̦","c":"ᾷ̦","d":"ᾷ̦"} +{"g":"compose","s":"῍͂","d":"῍͂"} +{"g":"compose","s":"῎","c":"῎"} +{"g":"compose","s":"῏̯","c":"῏̯"} +{"g":"compose","s":"ῇ࣑","d":"ῇ࣑"} +{"g":"compose","s":"ῷ","c":"ῷ","d":"ῷ"} +{"g":"compose","s":"῾ࠞ̀"} +{"g":"compose","s":"῞𞛦","d":"῞𞛦"} +{"g":"compose","s":"῟","c":"῟"} +{"g":"compose","s":"↚ࣷ","c":"↚ࣷ","d":"↚ࣷ"} +{"g":"compose","s":"↛᫂","d":"↛᫂"} +{"g":"compose","s":"↮","c":"↮"} +{"g":"compose","s":"⇍꣰","c":"⇍꣰","d":"⇍꣰"} +{"g":"compose","s":"⇏ꙵ","d":"⇏ꙵ"} +{"g":"compose","s":"⇎","c":"⇎"} +{"g":"compose","s":"∄𑄀","c":"∄𑄀","d":"∄𑄀"} +{"g":"compose","s":"∉᳥","d":"∉᳥"} +{"g":"compose","s":"∌","c":"∌"} +{"g":"compose","s":"∤្","c":"∤្","d":"∤្"} +{"g":"compose","s":"∦ฺ","d":"∦ฺ"} +{"g":"compose","s":"≁","c":"≁"} +{"g":"compose","s":"≄𞄶","c":"≄𞄶","d":"≄𞄶"} +{"g":"compose","s":"≇ٓ","d":"≇ٓ"} +{"g":"compose","s":"≉","c":"≉"} +{"g":"compose","s":"≭ᷴ","c":"≭ᷴ","d":"≭ᷴ"} +{"g":"compose","s":"≢᳔","d":"≢᳔"} +{"g":"compose","s":"≰","c":"≰"} +{"g":"compose","s":"≱໊","c":"≱໊","d":"≱໊"} +{"g":"compose","s":"≴ᢩ","d":"≴ᢩ"} +{"g":"compose","s":"≵","c":"≵"} +{"g":"compose","s":"≸᭳","c":"≸᭳","d":"≸᭳"} +{"g":"compose","s":"≹𝆇","d":"≹𝆇"} +{"g":"compose","s":"⊀","c":"⊀"} +{"g":"compose","s":"≻᫝̸","c":"⊁᫝","d":"⊁᫝"} +{"g":"compose","s":"⋠𐍸","d":"⋠𐍸"} +{"g":"compose","s":"⋡","c":"⋡"} +{"g":"compose","s":"⊄ࠜ","c":"⊄ࠜ","d":"⊄ࠜ"} +{"g":"compose","s":"⊅᳨","d":"⊅᳨"} +{"g":"compose","s":"⊈","c":"⊈"} +{"g":"compose","s":"⊉࣠","c":"⊉࣠","d":"⊉࣠"} +{"g":"compose","s":"⋢಼","d":"⋢಼"} +{"g":"compose","s":"⋣","c":"⋣"} +{"g":"compose","s":"⊬̽","c":"⊬̽","d":"⊬̽"} +{"g":"compose","s":"⊭֤","d":"⊭֤"} +{"g":"compose","s":"⊮","c":"⊮"} +{"g":"compose","s":"⊯ֵ","c":"⊯ֵ","d":"⊯ֵ"} +{"g":"compose","s":"⋪︡","d":"⋪︡"} +{"g":"compose","s":"⋫","c":"⋫"} +{"g":"compose","s":"⋬͘","c":"⋬͘","d":"⋬͘"} +{"g":"compose","s":"⋭𑈶","d":"⋭𑈶"} +{"g":"compose","s":"ゔ","c":"ゔ"} +{"g":"compose","s":"が̻","c":"が̻","d":"が̻"} +{"g":"compose","s":"ぎ்","d":"ぎ்"} +{"g":"compose","s":"ぐ","c":"ぐ"} +{"g":"compose","s":"げְ","c":"げְ","d":"げְ"} +{"g":"compose","s":"ごࣟ","d":"ごࣟ"} +{"g":"compose","s":"ざ","c":"ざ"} +{"g":"compose","s":"し᫦゙","c":"じ᫦","d":"じ᫦"} +{"g":"compose","s":"ず҃","d":"ず҃"} +{"g":"compose","s":"ぜ","c":"ぜ"} +{"g":"compose","s":"ぞ𑍳","c":"ぞ𑍳","d":"ぞ𑍳"} +{"g":"compose","s":"だ𑨴","d":"だ𑨴"} +{"g":"compose","s":"ぢ","c":"ぢ"} +{"g":"compose","s":"づ̓","c":"づ̓","d":"づ̓"} +{"g":"compose","s":"でࠞ","d":"でࠞ"} +{"g":"compose","s":"ど","c":"ど"} +{"g":"compose","s":"ばᷚ","c":"ばᷚ","d":"ばᷚ"} +{"g":"compose","s":"ぱ߳","d":"ぱ߳"} +{"g":"compose","s":"び","c":"び"} +{"g":"compose","s":"ぴٔ","c":"ぴٔ","d":"ぴٔ"} +{"g":"compose","s":"ぶ𝆭","d":"ぶ𝆭"} +{"g":"compose","s":"ぷ","c":"ぷ"} +{"g":"compose","s":"べ⃘","c":"べ⃘"} +{"g":"compose","s":"ぺᷔ","d":"ぺᷔ"} +{"g":"compose","s":"ぼ","c":"ぼ"} +{"g":"compose","s":"ぽ𞣐","c":"ぽ𞣐","d":"ぽ𞣐"} +{"g":"compose","s":"ゞ᫏","d":"ゞ᫏"} +{"g":"compose","s":"ヴ","c":"ヴ"} +{"g":"compose","s":"ガ࣌","c":"ガ࣌","d":"ガ࣌"} +{"g":"compose","s":"ギ𞣔","d":"ギ𞣔"} +{"g":"compose","s":"グ","c":"グ"} +{"g":"compose","s":"ゲ᤺","c":"ゲ᤺","d":"ゲ᤺"} +{"g":"compose","s":"ゴ͉","d":"ゴ͉"} +{"g":"compose","s":"ザ","c":"ザ"} +{"g":"compose","s":"ジ࠭","c":"ジ࠭","d":"ジ࠭"} +{"g":"compose","s":"ズ꛰","d":"ズ꛰"} +{"g":"compose","s":"ゼ","c":"ゼ"} +{"g":"compose","s":"ゾ𑈶","c":"ゾ𑈶"} +{"g":"compose","s":"ダ်","d":"ダ်"} +{"g":"compose","s":"ヂ","c":"ヂ"} +{"g":"compose","s":"ヅ࿆","c":"ヅ࿆","d":"ヅ࿆"} +{"g":"compose","s":"デི","d":"デི"} +{"g":"compose","s":"ド","c":"ド"} +{"g":"compose","s":"バ𐽉","c":"バ𐽉","d":"バ𐽉"} +{"g":"compose","s":"パ𑍳","d":"パ𑍳"} +{"g":"compose","s":"ビ","c":"ビ"} +{"g":"compose","s":"ピ𞗮","c":"ピ𞗮","d":"ピ𞗮"} +{"g":"compose","s":"ブ𐺬","d":"ブ𐺬"} +{"g":"compose","s":"プ","c":"プ"} +{"g":"compose","s":"ベ࠙","c":"ベ࠙","d":"ベ࠙"} +{"g":"compose","s":"ペؒ","d":"ペؒ"} +{"g":"compose","s":"ボ","c":"ボ"} +{"g":"compose","s":"ポ݂","c":"ポ݂","d":"ポ݂"} +{"g":"compose","s":"ヷ𞀧","d":"ヷ𞀧"} +{"g":"compose","s":"ヸ","c":"ヸ"} +{"g":"compose","s":"ヹ꣠","c":"ヹ꣠","d":"ヹ꣠"} +{"g":"compose","s":"ヺ᭳","d":"ヺ᭳"} +{"g":"compose","s":"ヾ","c":"ヾ"} +{"g":"compose","s":"𐗉︫","c":"𐗉︫"} +{"g":"compose","s":"𐗤ٚ","d":"𐗤ٚ"} +{"g":"compose","s":"𑂚","c":"𑂚"} +{"g":"compose","s":"𑂜͐","c":"𑂜͐","d":"𑂜͐"} +{"g":"compose","s":"𑂫𑌻","d":"𑂫𑌻"} +{"g":"compose","s":"𑄮","c":"𑄮"} +{"g":"compose","s":"𑄲ٌ𑄧"} +{"g":"compose","s":"𑍋ۙ","d":"𑍋ۙ"} +{"g":"compose","s":"𑍌","c":"𑍌"} +{"g":"compose","s":"𑎂ͥ𑏉"} +{"g":"compose","s":"𑎅᪳","d":"𑎅᪳"} +{"g":"compose","s":"𑎎","c":"𑎎"} +{"g":"compose","s":"𑎐𑏐𑏉"} +{"g":"compose","s":"𑏇𞓬","d":"𑏇𞓬"} +{"g":"compose","s":"𑏅","c":"𑏅"} +{"g":"compose","s":"𑏂ͥ𑏉"} +{"g":"compose","s":"𑒼𝅨","d":"𑒼𝅨"} +{"g":"compose","s":"𑒻","c":"𑒻"} +{"g":"compose","s":"𑒹𞀖𑒽"} +{"g":"compose","s":"𑖺ࣵ","d":"𑖺ࣵ"} +{"g":"compose","s":"𑖻","c":"𑖻"} +{"g":"compose","s":"𑤵𐽏𑤰"} +{"g":"compose","s":"𖄡ꙶ","d":"𖄡ꙶ"} +{"g":"compose","s":"𖄣","c":"𖄣"} +{"g":"compose","s":"𖄞݆𖄠"} +{"g":"compose","s":"𖄢ٙ","d":"𖄢ٙ"} +{"g":"compose","s":"𖄦","c":"𖄦","d":"𖄦"} +{"g":"compose","s":"𖄡࢟𖄠","d":"𖄡࢟𖄠"} +{"g":"compose","s":"𖄧ֽ","d":"𖄧ֽ"} +{"g":"compose","s":"𖄤","c":"𖄤"} +{"g":"compose","s":"𖵣𞀧𖵧"} +{"g":"compose","s":"𖵨𞄱","d":"𖵨𞄱"} +{"g":"compose","s":"𖵪","c":"𖵪","d":"𖵪"} +{"g":"triple","s":"ỹ𐾃⃭","d":"ỹ𐾃⃭"} +{"g":"triple","s":"Ὧࣟ̐","d":"Ὧࣟ̐","l":"ὧࣟ̐"} +{"g":"triple","s":"ケ҅̚","c":"ケ҅̚","d":"ケ҅̚"} +{"g":"triple","s":"Ὅ֮𑄁","c":"Ὅ֮𑄁","d":"Ὅ֮𑄁","l":"ὅ֮𑄁"} +{"g":"triple","s":"ᾦ゙𞛵","d":"ὦ゙𞛵ͅ"} +{"g":"triple","s":"ᾤ֥ᷯ","c":"ᾤ֥ᷯ","d":"ᾤ֥ᷯ"} +{"g":"triple","s":"ᾫ𐺫ྃ","d":"ᾫ𐺫ྃ","l":"ᾣ𐺫ྃ"} +{"g":"triple","s":"ḣْ່","c":"ḣْ່","d":"ḣْ່"} +{"g":"triple","s":"ᾥ᩠᫝","d":"ω᩠᫝̔́ͅ"} +{"g":"triple","s":"Ἰ᫂᫪","d":"Ἰ᫂᫪","l":"ἰ᫂᫪"} +{"g":"triple","s":"ē𞋯͂","d":"ē𞋯͂"} +{"g":"triple","s":"ω᜕᳸"} +{"g":"triple","s":"η𞓮ⷯ"} +{"g":"triple","s":"ᾒؐۨ","d":"ᾒؐۨ"} +{"g":"triple","s":"T࢚᫨","l":"t࢚᫨"} +{"g":"triple","s":"C̝⳰","l":"c̝⳰"} +{"g":"triple","s":"し𑥃𑇀"} +{"g":"triple","s":"ಿ๊꣫"} +{"g":"triple","s":"Ǻֳⷲ","d":"Ǻֳⷲ","l":"ǻֳⷲ"} +{"g":"triple","s":"𑎄𑍪᫙"} +{"g":"triple","s":"żູ𐫦","c":"żູ𐫦","d":"żູ𐫦"} +{"g":"triple","s":"Ę᳧᤺","c":"Ę᳧᤺","d":"Ę᳧᤺","l":"ę᳧᤺"} +{"g":"triple","s":"ᾩ︮ꪲ","d":"ᾩ︮ꪲ","l":"ᾡ︮ꪲ"} +{"g":"triple","s":"t𞀞͠","c":"t𞀞͠","d":"t𞀞͠"} +{"g":"triple","s":"ビ᷊𞥅","c":"ビ᷊𞥅","d":"ビ᷊𞥅"} +{"g":"triple","s":"ӱ⃗᫂","d":"ӱ⃗᫂"} +{"g":"triple","s":"Ε〭᳑","c":"Ε〭᳑","d":"Ε〭᳑","l":"ε〭᳑"} +{"g":"triple","s":"Uۭᷖ","c":"Uۭᷖ","d":"Uۭᷖ","l":"uۭᷖ"} +{"g":"triple","s":"и𖫱֯"} +{"g":"triple","s":"フ࣬࢘"} +{"g":"triple","s":"ᭃ𐽈᤺","d":"ᭃ𐽈᤺"} +{"g":"triple","s":"υ꥓𞥈","c":"υ꥓𞥈","d":"υ꥓𞥈"} +{"g":"triple","s":"Ε᷊ᷛ","l":"ε᷊ᷛ"} +{"g":"triple","s":"Υ̧࢞","c":"Υ̧࢞","d":"Υ̧࢞","l":"υ̧࢞"} +{"g":"triple","s":"Ṡ𑶗߲","c":"Ṡ𑶗߲","d":"Ṡ𑶗߲","l":"ṡ𑶗߲"} +{"g":"triple","s":"Ȫ𑏎𞂏","c":"Ȫ𑏎𞂏","d":"Ȫ𑏎𞂏","l":"ȫ𑏎𞂏"} +{"g":"triple","s":"¨̱𐴧"} +{"g":"triple","s":"e𝆁꪿"} +{"g":"triple","s":"Ṷ𑁆𞣒","c":"Ṷ𑁆𞣒","d":"Ṷ𑁆𞣒","l":"ṷ𑁆𞣒"} +{"g":"triple","s":"Ŗ⃐͘","c":"Ŗ⃐͘","d":"Ŗ⃐͘","l":"ŗ⃐͘"} +{"g":"triple","s":"⊯𑏏ܷ","d":"⊯𑏏ܷ"} +{"g":"triple","s":"ೈ𐽐ࢗ","d":"ೈ𐽐ࢗ"} +{"g":"triple","s":"ズ᩶𞛮","d":"ズ᩶𞛮"} +{"g":"triple","s":"ṍ𞛣࣭","c":"ṍ࣭𞛣","d":"ṍ࣭𞛣"} +{"g":"triple","s":"Ệ𑈵ᫎ","c":"Ệ𑈵ᫎ","d":"Ệ𑈵ᫎ","l":"ệ𑈵ᫎ"} +{"g":"triple","s":"ᾱ̩ᷧ","d":"ᾱ̩ᷧ"} +{"g":"triple","s":"Ǧ᳔𞀨","d":"Ǧ᳔𞀨","l":"ǧ᳔𞀨"} +{"g":"triple","s":"𑎂ۘ︡"} +{"g":"triple","s":"À𝅦٘","c":"À𝅦٘","d":"À𝅦٘","l":"à𝅦٘"} +{"g":"triple","s":"Ą𑈵࣬","d":"Ą𑈵࣬","l":"ą𑈵࣬"} +{"g":"triple","s":"ǘ္֤","c":"ǘ္֤","d":"ǘ္֤"} +{"g":"triple","s":"Ẻᷭ͟","d":"Ẻᷭ͟","l":"ẻᷭ͟"} +{"g":"triple","s":"ୌ𞄳̉","d":"ୌ𞄳̉"} +{"g":"triple","s":"Ōࠗ̎","d":"Ōࠗ̎","l":"ōࠗ̎"} +{"g":"triple","s":"З𐵪𝉂","l":"з𐵪𝉂"} +{"g":"triple","s":"Ἰࠣ̔","d":"Ἰࠣ̔","l":"ἰࠣ̔"} +{"g":"triple","s":"ソ຺ࠬ","c":"ソ຺ࠬ","d":"ソ຺ࠬ"} +{"g":"triple","s":"Ë͍ࠛ","d":"Ë͍ࠛ","l":"ë͍ࠛ"} +{"g":"triple","s":"ϋ̽͑","d":"ϋ̽͑"} +{"g":"triple","s":"𖄞ܾ︣"} +{"g":"triple","s":"ṅ𑌼𞣒","d":"ṅ𑌼𞣒"} +{"g":"triple","s":"ヘ਼࣌"} +{"g":"triple","s":"E֚𝆭","c":"E֚𝆭","d":"E֚𝆭","l":"e֚𝆭"} +{"g":"triple","s":"Ü಼֯","d":"Ü಼֯","l":"ü಼֯"} +{"g":"triple","s":"Ǽ꣮ׄ","d":"Ǽ꣮ׄ","l":"ǽ꣮ׄ"} +{"g":"triple","s":"Ế𑑂᷈","d":"Ế𑑂᷈","l":"ế𑑂᷈"} +{"g":"triple","s":"ῆ်𞥅","d":"ῆ်𞥅"} +{"g":"triple","s":"u᜴͆","c":"u᜴͆","d":"u᜴͆"} +{"g":"triple","s":"ἱ๊ᷣ","c":"ἱ๊ᷣ","d":"ἱ๊ᷣ"} +{"g":"triple","s":"Ὺࣝ𝉄","d":"Ὺࣝ𝉄","l":"ὺࣝ𝉄"} +{"g":"triple","s":"Oׂ̢","c":"Oׂ̢","d":"Oׂ̢","l":"oׂ̢"} +{"g":"triple","s":"ẕ͉᫒","d":"ẕ͉᫒"} +{"g":"triple","s":"ᾧᷤۘ","d":"ᾧᷤۘ"} +{"g":"triple","s":"ț᳠᫦","c":"ț᫦᳠","d":"ț᫦᳠"} +{"g":"triple","s":"oֹ𝅱"} +{"g":"triple","s":"Ŝٙ̅","d":"Ŝٙ̅","l":"ŝٙ̅"} +{"g":"triple","s":"ἳູ͎","d":"ἳູ͎"} +{"g":"triple","s":"اܶᷤ"} +{"g":"triple","s":"h᳒ꪲ"} +{"g":"triple","s":"ウᷞۧ"} +{"g":"triple","s":"Ěׅ᷶","d":"Ěׅ᷶","l":"ěׅ᷶"} +{"g":"triple","s":"Ӂְ֛","d":"Ӂְ֛","l":"ӂְ֛"} +{"g":"triple","s":"Ἰֲ᷒","d":"Ἰֲ᷒","l":"ἰֲ᷒"} +{"g":"triple","s":"çࣥ̔","d":"çࣥ̔"} +{"g":"triple","s":"ο𖿰ࣘ","c":"ο𖿰ࣘ","d":"ο𖿰ࣘ"} +{"g":"triple","s":"uⷺ᳐"} +{"g":"triple","s":"≴𞀧ۨ","d":"≴𞀧ۨ"} +{"g":"triple","s":"Ч𖫰ࣜ","l":"ч𖫰ࣜ"} +{"g":"triple","s":"M֔𞀞","l":"m֔𞀞"} +{"g":"triple","s":"f࿆᷅"} +{"g":"triple","s":"Έؓ᫘","d":"Έؓ᫘","l":"έؓ᫘"} +{"g":"triple","s":"ẛ़͟","d":"ẛ़͟"} +{"g":"triple","s":"Ἠ᫤۫","d":"Ἠ᫤۫","l":"ἠ᫤۫"} +{"g":"triple","s":"Ự꣣֠","d":"Ự꣣֠","l":"ự꣣֠"} +{"g":"triple","s":"Ģ𞀌𞋯","d":"Ģ𞀌𞋯","l":"ģ𞀌𞋯"} +{"g":"triple","s":"𖄢𑇊〪","c":"𖄢𑇊〪","d":"𖄢𑇊〪"} +{"g":"triple","s":"Ṥ𐴦۫","d":"Ṥ𐴦۫","l":"ṥ𐴦۫"} +{"g":"triple","s":"ḷ្ꙶ","d":"ḷ្ꙶ"} +{"g":"triple","s":"⋣𑵅̟","c":"⋣𑵅̟","d":"⋣𑵅̟"} +{"g":"triple","s":"ω݈⃨"} +{"g":"triple","s":"Ἰ𝅻ࠝ","d":"Ἰ𝅻ࠝ","l":"ἰ𝅻ࠝ"} +{"g":"triple","s":"ᾏ֑༘","d":"ᾏ֑༘","l":"ᾇ֑༘"} +{"g":"triple","s":"は଼݀","c":"は଼݀","d":"は଼݀"} +{"g":"triple","s":"Ι่𝆫","l":"ι่𝆫"} +{"g":"triple","s":"B𞛦꛱","l":"b𞛦꛱"} +{"g":"triple","s":"𑎅ٜᷟ","d":"𑎅ٜᷟ"} +{"g":"triple","s":"Ηܹ̞","l":"ηܹ̞"} +{"g":"triple","s":"Ḑ়𑄀","d":"Ḑ়𑄀","l":"ḑ়𑄀"} +{"g":"triple","s":"y್࣯","c":"y್࣯","d":"y್࣯"} +{"g":"triple","s":"ȕܽ𐽊","d":"ȕܽ𐽊"} +{"g":"triple","s":"ᾂ࣌᫉","d":"ᾂ࣌᫉"} +{"g":"triple","s":"vྀ︨"} +{"g":"triple","s":"ễ̒̋","d":"ễ̒̋"} +{"g":"triple","s":"ಿ𞀘ᫎ"} +{"g":"triple","s":"Ο֙𞥄","l":"ο֙𞥄"} +{"g":"triple","s":"ὥ꤬᫊","d":"ὥ꤬᫊"} +{"g":"triple","s":"Ẇ𑠹ⷲ","d":"Ẇ𑠹ⷲ","l":"ẇ𑠹ⷲ"} +{"g":"triple","s":"ῶ᫨֠","d":"ῶ᫨֠"} +{"g":"triple","s":"e်᷌"} +{"g":"triple","s":"r᜴𐾂"} +{"g":"triple","s":"Ἐⷽ𑍴","d":"Ἐⷽ𑍴","l":"ἐⷽ𑍴"} +{"g":"triple","s":"Ἇᫀ͜","c":"Ἇᫀ͜","d":"Ἇᫀ͜","l":"ἇᫀ͜"} +{"g":"triple","s":"A𐾃ⷻ","c":"A𐾃ⷻ","d":"A𐾃ⷻ","l":"a𐾃ⷻ"} +{"g":"triple","s":"Ē⃚ᷮ","c":"Ē⃚ᷮ","d":"Ē⃚ᷮ","l":"ē⃚ᷮ"} +{"g":"triple","s":"ă⃕𖬱","d":"ă⃕𖬱"} +{"g":"triple","s":"lࣜ̃"} +{"g":"triple","s":"Ụ︥𝆉","d":"Ụ︥𝆉","l":"ụ︥𝆉"} +{"g":"triple","s":"Ἥ𝆋ࠛ","c":"Ἥ𝆋ࠛ","d":"Ἥ𝆋ࠛ","l":"ἥ𝆋ࠛ"} +{"g":"triple","s":"ěֱ᷀","d":"ěֱ᷀"} +{"g":"triple","s":"Ḓِ𞀘","c":"Ḓِ𞀘","d":"Ḓِ𞀘","l":"ḓِ𞀘"} +{"g":"triple","s":"ă𝆈ⷰ","d":"ă𝆈ⷰ"} +{"g":"triple","s":"Ӹ𑥃ۭ","d":"Ӹ𑥃ۭ","l":"ӹ𑥃ۭ"} +{"g":"triple","s":"ゼ᪷᫛","d":"ゼ᪷᫛"} +{"g":"triple","s":"Ο𐽐᳞","l":"ο𐽐᳞"} +{"g":"triple","s":"⊄ٚ࣡","d":"⊄ٚ࣡"} +{"g":"triple","s":"Ǫ֒𞓬","c":"Ǫ֒𞓬","d":"Ǫ֒𞓬","l":"ǫ֒𞓬"} +{"g":"triple","s":"𑎃߭꙯","d":"𑎃߭꙯"} +{"g":"triple","s":"ǎ〫꣨","c":"ǎ〫꣨","d":"ǎ〫꣨"} +{"g":"triple","s":"ṡ̶ꪰ","d":"ṡ̶ꪰ"} +{"g":"triple","s":"Ė〬𐻺","c":"Ė𐻺〬","d":"E𐻺̇〬","l":"ė〬𐻺"} +{"g":"triple","s":"ư𑍫ࣛ","d":"ư𑍫ࣛ"} +{"g":"triple","s":"ᾔ໋͙","d":"ᾔ໋͙"} +{"g":"triple","s":"Vܱٔ","l":"vܱٔ"} +{"g":"triple","s":"パ𖫴່","c":"パ𖫴່","d":"パ𖫴່"} +{"g":"triple","s":"Ῑ᳣⃰","c":"Ῑ᳣⃰","d":"Ῑ᳣⃰","l":"ῑ᳣⃰"} +{"g":"triple","s":"Ӧ𑓃𐵫","d":"Ӧ𑓃𐵫","l":"ӧ𑓃𐵫"} +{"g":"triple","s":"Nͥ꣢","l":"nͥ꣢"} +{"g":"triple","s":"Ö⃘͋","d":"Ö⃘͋","l":"ö⃘͋"} +{"g":"triple","s":"ὑ𖫳઼","d":"ὑ𖫳઼"} +{"g":"triple","s":"Ȑ𐴤͂","d":"Ȑ𐴤͂","l":"ȑ𐴤͂"} +{"g":"triple","s":"Ẏ𞀓⃩","d":"Ẏ𞀓⃩","l":"ẏ𞀓⃩"} +{"g":"triple","s":"ѓ̨𑍱","d":"ѓ̨𑍱"} +{"g":"triple","s":"E𑧠𞀝","c":"E𑧠𞀝","d":"E𑧠𞀝","l":"e𑧠𞀝"} +{"g":"triple","s":"Ơ̥ࣙ","c":"Ơ̥ࣙ","d":"Ơ̥ࣙ","l":"ơ̥ࣙ"} +{"g":"triple","s":"ṵ̯֭","c":"ṵ̯֭","d":"ṵ̯֭"} +{"g":"triple","s":"ж︯ܿ"} +{"g":"triple","s":"Ἔ꯭͝","c":"Ἔ꯭͝","d":"Ἔ꯭͝","l":"ἔ꯭͝"} +{"g":"triple","s":"Ṧ٘𞋯","d":"Ṧ٘𞋯","l":"ṧ٘𞋯"} +{"g":"triple","s":"D̠꣢","l":"d̠꣢"} +{"g":"triple","s":"ὥ̼ܳ","c":"ὥ̼ܳ","d":"ὥ̼ܳ"} +{"g":"triple","s":"Ἦࣚؒ","d":"Ἦࣚؒ","l":"ἦࣚؒ"} +{"g":"triple","s":"≤𞄶ⷬ"} +{"g":"triple","s":"Y𞂏͌","l":"y𞂏͌"} +{"g":"triple","s":"Ὗٙᷤ","d":"Ὗٙᷤ","l":"ὗٙᷤ"} +{"g":"triple","s":"č᷿̽","c":"č᷿̽","d":"č᷿̽"} +{"g":"triple","s":"s္ᷔ","c":"s္ᷔ","d":"s္ᷔ"} +{"g":"triple","s":"𑂥്ͭ","c":"𑂥്ͭ","d":"𑂥്ͭ"} +{"g":"triple","s":"A᳥ࠣ","c":"A᳥ࠣ","d":"A᳥ࠣ","l":"a᳥ࠣ"} +{"g":"triple","s":"S഻֗","l":"s഻֗"} +{"g":"triple","s":"Ṣ࡙۟","c":"Ṣ࡙۟","d":"Ṣ࡙۟","l":"ṣ࡙۟"} +{"g":"triple","s":"Â᳘𐍺","c":"Â᳘𐍺","d":"Â᳘𐍺","l":"â᳘𐍺"} +{"g":"triple","s":"ï଼᳠","c":"ï଼᳠","d":"ï଼᳠"} +{"g":"triple","s":"ḗ᪳꣭","d":"ḗ᪳꣭"} +{"g":"triple","s":"チ᫖ؑ"} +{"g":"triple","s":"eֳ᳠","c":"eֳ᳠","d":"eֳ᳠"} +{"g":"triple","s":"ᾌ਼̾","c":"ᾌ਼̾","d":"ᾌ਼̾","l":"ᾄ਼̾"} +{"g":"triple","s":"ऱ᫝᫑","d":"ऱ᫝᫑"} +{"g":"triple","s":"ᾗ࣑࢞","d":"ᾗ࣑࢞"} +{"g":"triple","s":"ᬍ᪲᫡"} +{"g":"triple","s":"ا𑂺ۡ","c":"ا𑂺ۡ","d":"ا𑂺ۡ"} +{"g":"triple","s":"ӗ𞣔݅","c":"ӗ𞣔݅","d":"ӗ𞣔݅"} +{"g":"triple","s":"R̊̄","l":"r̊̄"} +{"g":"triple","s":"ᬼ𑚶ͤ"} +{"g":"triple","s":"ȇٰู","d":"ȇٰู"} +{"g":"triple","s":"Ἢ֝ⷤ","d":"Ἢ֝ⷤ","l":"ἢ֝ⷤ"} +{"g":"triple","s":"Ἠ͙᩼","d":"Ἠ͙᩼","l":"ἠ͙᩼"} +{"g":"triple","s":"Ḃֹ࣒","c":"Ḃֹ࣒","d":"Ḃֹ࣒","l":"ḃֹ࣒"} +{"g":"triple","s":"ω̳̦"} +{"g":"triple","s":"ọ್۟","c":"ọ್۟","d":"ọ್۟"} +{"g":"triple","s":"í꦳𑩇","d":"í꦳𑩇"} +{"g":"triple","s":"aٗᫎ"} +{"g":"triple","s":"ŵ̠𐴥","d":"ŵ̠𐴥"} +{"g":"triple","s":"᾿𞀋︤"} +{"g":"triple","s":"ᬅ𑩇᫓"} +{"g":"triple","s":"Ẫؖꪸ","d":"Ẫؖꪸ","l":"ẫؖꪸ"} +{"g":"triple","s":"ỹ𝅻ؗ","d":"ỹ𝅻ؗ"} +{"g":"triple","s":"ᾫ̇ⷵ","d":"ᾫ̇ⷵ","l":"ᾣ̇ⷵ"} +{"g":"triple","s":"Aܴ᫇","c":"Aܴ᫇","d":"Aܴ᫇","l":"aܴ᫇"} +{"g":"triple","s":"і𞀄ࣳ"} +{"g":"triple","s":"е̳ⷣ","c":"е̳ⷣ","d":"е̳ⷣ"} +{"g":"triple","s":"Ἣ𑇀ܶ","d":"Ἣ𑇀ܶ","l":"ἣ𑇀ܶ"} +{"g":"triple","s":"こ્𐾃"} +{"g":"triple","s":"r᜴ͫ"} +{"g":"triple","s":"ᾁׁࣺ","c":"ᾁׁࣺ","d":"ᾁׁࣺ"} +{"g":"triple","s":"ᾘֺ𑍰","c":"ᾘֺ𑍰","d":"ᾘֺ𑍰","l":"ᾐֺ𑍰"} +{"g":"triple","s":"ô𞀏ᷦ","d":"ô𞀏ᷦ"} +{"g":"triple","s":"hⷲ𐍸"} +{"g":"triple","s":"Ι𑠹֔","l":"ι𑠹֔"} +{"g":"triple","s":"ạุ⃮","d":"ạุ⃮"} +{"g":"triple","s":"n꤭ࠩ"} +{"g":"triple","s":"Ễ͛᫤","d":"Ễ͛᫤","l":"ễ͛᫤"} +{"g":"triple","s":"ÿ꣮⃛","d":"ÿ꣮⃛"} +{"g":"triple","s":"ў༵ࠢ","d":"ў༵ࠢ"} +{"g":"triple","s":"ếⷢ᷶","d":"ếⷢ᷶"} +{"g":"triple","s":"Ḯ̻᩼","c":"Ḯ̻᩼","d":"Ḯ̻᩼","l":"ḯ̻᩼"} +{"g":"triple","s":"ᭀ๋ؗ","c":"ᭀ๋ؗ","d":"ᭀ๋ؗ"} +{"g":"triple","s":"῏⃫᯦","c":"῏⃫᯦","d":"῏⃫᯦"} +{"g":"triple","s":"ೆ઼ꪰ","c":"ೆ઼ꪰ","d":"ೆ઼ꪰ"} +{"g":"triple","s":"n᮫ⷳ"} +{"g":"triple","s":"ぼ𝅯⃐","c":"ぼ𝅯⃐","d":"ぼ𝅯⃐"} +{"g":"triple","s":"𑖹ཱ۟"} +{"g":"triple","s":"Ἠ̢̎","d":"Ἠ̢̎","l":"ἠ̢̎"} +{"g":"triple","s":"ᬾ࢜᷃"} +{"g":"triple","s":"Ä֓᫪","d":"Ä֓᫪","l":"ä֓᫪"} +{"g":"triple","s":"b𐾅྇"} +{"g":"triple","s":"ǹᷜ𞛯","d":"ǹᷜ𞛯"} +{"g":"triple","s":"ω݄᭳","c":"ω݄᭳","d":"ω݄᭳"} +{"g":"triple","s":"ヲ𖿰𐵫"} +{"g":"triple","s":"𑏂ꪴ᩹"} +{"g":"triple","s":"ă້̢","c":"ă້̢","d":"ă້̢"} +{"g":"triple","s":"ṙ᷻𐍹","d":"ṙ᷻𐍹"} +{"g":"triple","s":"I⃫֯","l":"i⃫֯"} +{"g":"triple","s":"t𑖿ࣼ","c":"t𑖿ࣼ","d":"t𑖿ࣼ"} +{"g":"triple","s":"ῐ࣊᫩","d":"ῐ࣊᫩"} +{"g":"triple","s":"Ĕ᷒𞀕","d":"Ĕ᷒𞀕","l":"ĕ᷒𞀕"} +{"g":"triple","s":"Ẕ࣑𞄰","d":"Ẕ࣑𞄰","l":"ẕ࣑𞄰"} +{"g":"triple","s":"Ǯֵٟ","c":"Ǯֵٟ","d":"Ǯֵٟ","l":"ǯֵٟ"} +{"g":"triple","s":"ے݈᳐","c":"ے݈᳐","d":"ے݈᳐"} +{"g":"triple","s":"Æ𞥆᭮","l":"æ𞥆᭮"} +{"g":"triple","s":"Аุ𞀂","l":"аุ𞀂"} +{"g":"triple","s":"Ấֹ᭭","d":"Ấֹ᭭","l":"ấֹ᭭"} +{"g":"triple","s":"ểꪷ᫇","d":"ểꪷ᫇"} +{"g":"triple","s":"プ̤࣌","c":"プ̤࣌","d":"プ̤࣌"} +{"g":"triple","s":"j֣꣰","c":"j֣꣰","d":"j֣꣰"} +{"g":"triple","s":"O᪱᫘","l":"o᪱᫘"} +{"g":"triple","s":"𑏂𞥊᳕"} +{"g":"triple","s":"Ṣٍ፝","c":"Ṣٍ፝","d":"Ṣٍ፝","l":"ṣٍ፝"} +{"g":"triple","s":"aֿ᷼","c":"aֿ᷼","d":"aֿ᷼"} +{"g":"triple","s":"グ᳣ᷩ","c":"グ᳣ᷩ","d":"グ᳣ᷩ"} +{"g":"triple","s":"a𑁆ౖ","c":"a𑁆ౖ","d":"a𑁆ౖ"} +{"g":"triple","s":"ỉ𑏐ﬞ","c":"ỉ𑏐ﬞ","d":"ỉ𑏐ﬞ"} +{"g":"triple","s":"у᳘𐻺"} +{"g":"triple","s":"ἑ͊ⷻ","d":"ἑ͊ⷻ"} +{"g":"triple","s":"Ȩ𝅼᷄","d":"Ȩ𝅼᷄","l":"ȩ𝅼᷄"} +{"g":"triple","s":"ἄّᫌ","d":"ἄّᫌ"} +{"g":"triple","s":"O𞄲ࣳ","l":"o𞄲ࣳ"} +{"g":"triple","s":"ちّ࣭","c":"ちّ࣭","d":"ちّ࣭"} +{"g":"triple","s":"T𐻿ࠣ","l":"t𐻿ࠣ"} +{"g":"triple","s":"Ὡ⃧ⷹ","d":"Ὡ⃧ⷹ","l":"ὡ⃧ⷹ"} +{"g":"triple","s":"ス᷽⃐"} +{"g":"triple","s":"Ὠࣲ𞋬","c":"Ὠࣲ𞋬","d":"Ὠࣲ𞋬","l":"ὠࣲ𞋬"} +{"g":"triple","s":"≲︭࣋","c":"≲︭࣋","d":"≲︭࣋"} +{"g":"triple","s":"シٔ۫"} +{"g":"triple","s":"E𝅱̿","l":"e𝅱̿"} +{"g":"triple","s":"а͊𖬶"} +{"g":"triple","s":"େ̛ᷳ","c":"େ̛ᷳ","d":"େ̛ᷳ"} +{"g":"triple","s":"Аׇ︤","l":"аׇ︤"} +{"g":"triple","s":"ụ︢꣤","d":"ụ︢꣤"} +{"g":"triple","s":"Ιࣞࠪ","l":"ιࣞࠪ"} +{"g":"triple","s":"ゴ᫠ࠝ","d":"ゴ᫠ࠝ"} +{"g":"triple","s":"ὁֶࠩ","d":"ὁֶࠩ"} +{"g":"triple","s":"Õ᯲ᷲ","c":"Õ᯲ᷲ","d":"Õ᯲ᷲ","l":"õ᯲ᷲ"} +{"g":"triple","s":"Ĩ𐵪ⷰ","d":"Ĩ𐵪ⷰ","l":"ĩ𐵪ⷰ"} +{"g":"triple","s":"e𑍴𐵪"} +{"g":"triple","s":"ќ𝅼ࣥ","d":"ќ𝅼ࣥ"} +{"g":"triple","s":"≤఼߮"} +{"g":"triple","s":"Ẋ̟𖬴","d":"Ẋ̟𖬴","l":"ẋ̟𖬴"} +{"g":"triple","s":"r࣏𞋭"} +{"g":"triple","s":"ǿ̴ٗ","d":"ǿ̴ٗ"} +{"g":"triple","s":"Ŵ̘᳠","d":"Ŵ̘᳠","l":"ŵ̘᳠"} +{"g":"triple","s":"Ӝ᳢ᷰ","c":"Ӝ᳢ᷰ","d":"Ӝ᳢ᷰ","l":"ӝ᳢ᷰ"} +{"g":"triple","s":"ἥ့𞀆","d":"ἥ့𞀆"} +{"g":"triple","s":"ẃ𑈵꣬","d":"ẃ𑈵꣬"} +{"g":"triple","s":"ὠ߲ۢ","d":"ὠ߲ۢ"} +{"g":"triple","s":"M︭̽","l":"m︭̽"} +{"g":"triple","s":"ḡ̶֤","d":"ḡ̶֤"} +{"g":"triple","s":"ツ𑏐ׇ"} +{"g":"triple","s":"Ἒ𑥃᪺","d":"Ἒ𑥃᪺","l":"ἒ𑥃᪺"} +{"g":"triple","s":"ẫ𞀃፟","d":"ẫ𞀃፟"} +{"g":"triple","s":"Ṉᷠ࣌","d":"Ṉᷠ࣌","l":"ṉᷠ࣌"} +{"g":"triple","s":"ἰ๋᳙","c":"ἰ๋᳙","d":"ἰ๋᳙"} +{"g":"triple","s":"ū๋𐵩","d":"ū๋𐵩"} +{"g":"triple","s":"Śⷻ᩷","d":"Śⷻ᩷","l":"śⷻ᩷"} +{"g":"triple","s":"Ẁ਼𑵄","d":"Ẁ਼𑵄","l":"ẁ਼𑵄"} +{"g":"triple","s":"Ỳ᷆ࠗ","d":"Ỳ᷆ࠗ","l":"ỳ᷆ࠗ"} +{"g":"triple","s":"ä᫖𞥆","d":"ä᫖𞥆"} +{"g":"triple","s":"ӓ𐇽֛","d":"ӓ𐇽֛"} +{"g":"triple","s":"Ū᪲᷼","d":"Ū᪲᷼","l":"ū᪲᷼"} +{"g":"triple","s":"w᷹ꚟ"} +{"g":"triple","s":"Ö᷐𐋠","d":"Ö᷐𐋠","l":"ö᷐𐋠"} +{"g":"triple","s":"ṩ꣦֝","d":"ṩ꣦֝"} +{"g":"triple","s":"𑍋ᷩ̈","d":"𑍋ᷩ̈"} +{"g":"triple","s":"ſ𞀧ࠖ"} +{"g":"triple","s":"ṱܼ𞀦","d":"ṱܼ𞀦"} +{"g":"triple","s":"A͊߬","l":"a͊߬"} +{"g":"triple","s":"Ẇ่𞀉","c":"Ẇ่𞀉","d":"Ẇ่𞀉","l":"ẇ่𞀉"} +{"g":"triple","s":"Ἱ⃘ٝ","d":"Ἱ⃘ٝ","l":"ἱ⃘ٝ"} +{"g":"triple","s":"sⷶ᳒"} +{"g":"triple","s":"ὢ𞛣ᷪ","d":"ὢ𞛣ᷪ"} +{"g":"triple","s":"N𑌻֥","c":"N𑌻֥","d":"N𑌻֥","l":"n𑌻֥"} +{"g":"triple","s":"Ú𝆁֘","c":"Ú𝆁֘","d":"Ú𝆁֘","l":"ú𝆁֘"} +{"g":"triple","s":"ӫܱ𐴤","d":"ӫܱ𐴤"} +{"g":"triple","s":"ōܾ᷆","c":"ōܾ᷆","d":"ōܾ᷆"} +{"g":"triple","s":"𑂫ܹ̏","d":"𑂫ܹ̏"} +{"g":"triple","s":"∤𐽏࠘","d":"∤𐽏࠘"} +{"g":"triple","s":"ṗ𝆀᪲","d":"ṗ𝆀᪲"} +{"g":"triple","s":"ऩⷮꙶ","d":"ऩⷮꙶ"} +{"g":"triple","s":"Ȯ̻𞀠","d":"Ȯ̻𞀠","l":"ȯ̻𞀠"} +{"g":"triple","s":"Ņ᳢̹","c":"Ņ᳢̹","d":"Ņ᳢̹","l":"ņ᳢̹"} +{"g":"triple","s":"ἄۜ︢","d":"ἄۜ︢"} +{"g":"triple","s":"ẽܸ̍","d":"ẽܸ̍"} +{"g":"triple","s":"Ѓ̬꣧","d":"Ѓ̬꣧","l":"ѓ̬꣧"} +{"g":"triple","s":"Oֱ᭭","l":"oֱ᭭"} +{"g":"triple","s":"o๊ܷ","c":"o๊ܷ","d":"o๊ܷ"} +{"g":"triple","s":"ἐ়𑠹","d":"ἐ়𑠹"} +{"g":"triple","s":"r᷽𑄀"} +{"g":"triple","s":"ờᷗ𞓯","d":"ờᷗ𞓯"} +{"g":"triple","s":"Ếᷣꚞ","d":"Ếᷣꚞ","l":"ếᷣꚞ"} +{"g":"triple","s":"H𑠹𖬵","l":"h𑠹𖬵"} +{"g":"triple","s":"ļ༹ࣘ","d":"ļ༹ࣘ"} +{"g":"triple","s":"ḷܲ͒","d":"ḷܲ͒"} +{"g":"triple","s":"ऱ̼𞀏","c":"ऱ̼𞀏","d":"ऱ̼𞀏"} +{"g":"triple","s":"Ủ⃦᷉","c":"Ủ⃦᷉","d":"Ủ⃦᷉","l":"ủ⃦᷉"} +{"g":"triple","s":"ợۣ꛰","c":"ợۣ꛰","d":"ợۣ꛰"} +{"g":"triple","s":"がܲ𝆭","d":"がܲ𝆭"} +{"g":"triple","s":"ȍ𞣓ͣ","c":"ȍ𞣓ͣ","d":"ȍ𞣓ͣ"} +{"g":"triple","s":"𖵩᜕࡛","c":"𖵩᜕࡛","d":"𖵩᜕࡛"} +{"g":"triple","s":"ṻ୍⵿","d":"ṻ୍⵿"} +{"g":"triple","s":"v꥓͌"} +{"g":"triple","s":"Ȁ𑽂ִ","c":"Ȁ𑽂ִ","d":"Ȁ𑽂ִ","l":"ȁ𑽂ִ"} +{"g":"triple","s":"῎᫠⃩","d":"῎᫠⃩"} +{"g":"triple","s":"ḑ꫁𞄲","d":"ḑ꫁𞄲"} +{"g":"triple","s":"W᳣𑄳","l":"w᳣𑄳"} +{"g":"triple","s":"Áٍ᪱","c":"Áٍ᪱","d":"Áٍ᪱","l":"áٍ᪱"} +{"g":"triple","s":"Ồ𞀛᪲","d":"Ồ𞀛᪲","l":"ồ𞀛᪲"} +{"g":"triple","s":"â᯲᭯","c":"â᯲᭯","d":"â᯲᭯"} +{"g":"triple","s":"R഻᫆","c":"R഻᫆","d":"R഻᫆","l":"r഻᫆"} +{"g":"triple","s":"ṭࣴ᷇","d":"ṭࣴ᷇"} +{"g":"triple","s":"o⃨𞀏"} +{"g":"triple","s":"آ༷𞀋","d":"آ༷𞀋"} +{"g":"triple","s":"sܸⷥ","c":"sܸⷥ","d":"sܸⷥ"} +{"g":"triple","s":"Ἕٓ𞀜","d":"Ἕٓ𞀜","l":"ἕٓ𞀜"} +{"g":"triple","s":"D𑍴ࣸ","l":"d𑍴ࣸ"} +{"g":"triple","s":"у࢝𑍧"} +{"g":"triple","s":"ư𑨴۠","c":"ư𑨴۠","d":"ư𑨴۠"} +{"g":"triple","s":"iꚞ𞛦"} +{"g":"triple","s":"ȧ𞣑͠","c":"ȧ𞣑͠","d":"ȧ𞣑͠"} +{"g":"triple","s":"ḥ𑠹᭮","d":"ḥ𑠹᭮"} +{"g":"triple","s":"l᳞𞀄"} +{"g":"triple","s":"ẗࣦᷠ","d":"ẗࣦᷠ"} +{"g":"triple","s":"ϋ𖿰ׅ","c":"ϋ𖿰ׅ","d":"ϋ𖿰ׅ"} +{"g":"triple","s":"≷̟ؗ","c":"≷̟ؗ","d":"≷̟ؗ"} +{"g":"triple","s":"ᾈ݂᳹","d":"ᾈ݂᳹","l":"ᾀ݂᳹"} +{"g":"triple","s":"ᾜ᪵𐵪","c":"ᾜ᪵𐵪","d":"ᾜ᪵𐵪","l":"ᾔ᪵𐵪"} +{"g":"triple","s":"Ơ֙ⷷ","d":"Ơ֙ⷷ","l":"ơ֙ⷷ"} +{"g":"triple","s":"ă᫢͕","c":"ă͕᫢","d":"ă͕᫢"} +{"g":"triple","s":"ῑࣰ꣣","c":"ῑࣰ꣣","d":"ῑࣰ꣣"} +{"g":"triple","s":"g֡𞄶"} +{"g":"triple","s":"إͣ߮","d":"إͣ߮"} +{"g":"triple","s":"Ἄ𑌼॓","d":"Ἄ𑌼॓","l":"ἄ𑌼॓"} +{"g":"triple","s":"ź⃫߯","d":"ź⃫߯"} +{"g":"triple","s":"O𑵂͜","c":"O𑵂͜","d":"O𑵂͜","l":"o𑵂͜"} +{"g":"triple","s":"u̗ͅ"} +{"g":"triple","s":"ஔ᩠᩷","d":"ஔ᩠᩷"} +{"g":"triple","s":"ゲⷹ҄","d":"ゲⷹ҄"} +{"g":"triple","s":"Ύ⃪഻","d":"Ύ⃪഻","l":"ύ⃪഻"} +{"g":"triple","s":"Έ઼͝","d":"Έ઼͝","l":"έ઼͝"} +{"g":"triple","s":"ύֶ⃖","d":"ύֶ⃖"} +{"g":"triple","s":"ぐ𑍴ࠫ","d":"ぐ𑍴ࠫ"} +{"g":"triple","s":"Ἥ︪ᢩ","c":"Ἥ︪ᢩ","d":"Ἥ︪ᢩ","l":"ἥ︪ᢩ"} +{"g":"triple","s":"ᾦ᷅𑍫","d":"ᾦ᷅𑍫"} +{"g":"triple","s":"Ω̜᫋","c":"Ω̜᫋","d":"Ω̜᫋","l":"ω̜᫋"} +{"g":"triple","s":"ă֤꣦","c":"ă֤꣦","d":"ă֤꣦"} +{"g":"triple","s":"eⷰ͂"} +{"g":"triple","s":"Ἧ꠆𑍱","d":"Ἧ꠆𑍱","l":"ἧ꠆𑍱"} +{"g":"triple","s":"Ḇࣖ᫑","d":"Ḇࣖ᫑","l":"ḇࣖ᫑"} +{"g":"triple","s":"tۭ𐽈","c":"tۭ𐽈","d":"tۭ𐽈"} +{"g":"triple","s":"∌্ྀ","c":"∌্ྀ","d":"∌্ྀ"} +{"g":"triple","s":"∌្ⷵ","c":"∌្ⷵ","d":"∌្ⷵ"} +{"g":"triple","s":"ெͩ᩼"} +{"g":"triple","s":"Ê𐻿ࠥ","d":"Ê𐻿ࠥ","l":"ê𐻿ࠥ"} +{"g":"triple","s":"ȗ︮𐍹","d":"ȗ︮𐍹"} +{"g":"triple","s":"t𑑂ࣻ"} +{"g":"triple","s":"Ơ𞥅𝆅","d":"Ơ𞥅𝆅","l":"ơ𞥅𝆅"} +{"g":"triple","s":"ἅٕᷛ","c":"ἅٕᷛ","d":"ἅٕᷛ"} +{"g":"triple","s":"Ἆⷫᷨ","d":"Ἆⷫᷨ","l":"ἆⷫᷨ"} +{"g":"triple","s":"aܾ̐","c":"aܾ̐","d":"aܾ̐"} +{"g":"triple","s":"ě꤭̌","d":"ě꤭̌"} +{"g":"triple","s":"Ί᷿𞛦","d":"Ί᷿𞛦","l":"ί᷿𞛦"} +{"g":"triple","s":"ἆོࣟ","d":"ἆོࣟ"} +{"g":"hangul","s":"너","c":"너"} +{"g":"hangul","s":"ꥨퟆ"} +{"g":"hangul","s":"쾨","c":"쾨"} +{"g":"hangul","s":"ᄫᆌ"} +{"g":"hangul","s":"ᄁᆏ"} +{"g":"hangul","s":"ᅁᆛ"} +{"g":"hangul","s":"ᄻᆤ"} +{"g":"hangul","s":"ꥴힷ"} +{"g":"hangul","s":"ꥯᅻ"} +{"g":"hangul","s":"ᄣힷ"} +{"g":"hangul","s":"ᄘᅦ"} +{"g":"hangul","s":"ᄾᆛ"} +{"g":"hangul","s":"ꥲퟅ"} +{"g":"hangul","s":"ꥴᅳ"} +{"g":"hangul","s":"ᄞᆖ"} +{"g":"hangul","s":"ᄱᆃ"} +{"g":"hangul","s":"ᅕᆊ"} +{"g":"hangul","s":"ꥼᅧ"} +{"g":"hangul","s":"ᄸᅰ"} +{"g":"hangul","s":"ᄤᆡ"} +{"g":"hangul","s":"ᅙힴ"} +{"g":"hangul","s":"ᄮᅠ"} +{"g":"hangul","s":"솨","c":"솨"} +{"g":"hangul","s":"ᄱᆊ"} +{"g":"hangul","s":"ꥦᆈ"} +{"g":"hangul","s":"ᄻힻ"} +{"g":"hangul","s":"ᄘힴ"} +{"g":"hangul","s":"ᄮힲ"} +{"g":"hangul","s":"ᄩힻ"} +{"g":"hangul","s":"ᄖᆞ"} +{"g":"hangul","s":"ᅓᆋ"} +{"g":"hangul","s":"ꥻᅲ"} +{"g":"hangul","s":"쀼","c":"쀼"} +{"g":"hangul","s":"ᄔᆕ"} +{"g":"hangul","s":"ᅂᅱ"} +{"g":"hangul","s":"ᄔᆤ"} +{"g":"hangul","s":"ᄩힰ"} +{"g":"hangul","s":"ᅜᅽ"} +{"g":"hangul","s":"ᅊᅬ"} +{"g":"hangul","s":"ᄞퟂ"} +{"g":"hangul","s":"ꥸᅱ"} +{"g":"hangul","s":"ᅆᅶ"} +{"g":"hangul","s":"ꥸᆋ"} +{"g":"hangul","s":"ᄖᆌ"} +{"g":"hangul","s":"ᄧᅴ"} +{"g":"hangul","s":"ꥡᅭ"} +{"g":"hangul","s":"ᄍᆓ"} +{"g":"hangul","s":"ᄤᆔ"} +{"g":"hangul","s":"뻐","c":"뻐"} +{"g":"hangul","s":"ᄚힰ"} +{"g":"hangul","s":"ᅝᅱ"} +{"g":"hangul","s":"ᄛᆇ"} +{"g":"hangul","s":"ᅘᆅ"} +{"g":"hangul","s":"ᄨᆧ"} +{"g":"hangul","s":"ᅆᅳ"} +{"g":"hangul","s":"ᅙힸ"} +{"g":"hangul","s":"ᅀᆆ"} +{"g":"hangul","s":"ᄘᅻ"} +{"g":"hangul","s":"ᅖᅨ"} +{"g":"hangul","s":"ᄺᆀ"} +{"g":"hangul","s":"ᄱᅨ"} +{"g":"hangul","s":"ꥫᅲ"} +{"g":"hangul","s":"ᄚᆚ"} +{"g":"hangul","s":"ᅑᆗ"} +{"g":"hangul","s":"ᅞힾ"} +{"g":"hangul","s":"ᅄᅮ"} +{"g":"hangul","s":"ᄌᆋ"} +{"g":"hangul","s":"ꥡᆖ"} +{"g":"hangul","s":"ꥳᅦ"} +{"g":"hangul","s":"ᄐힷ"} +{"g":"hangul","s":"ꥷᆘ"} +{"g":"hangul","s":"ᄽᆥ"} +{"g":"hangul","s":"ꥦᅢ"} +{"g":"hangul","s":"ᅞᅧ"} +{"g":"hangul","s":"ᄍힼ"} +{"g":"hangul","s":"ᄿᆏ"} +{"g":"hangul","s":"ᄂᆃ"} +{"g":"hangul","s":"ꥫᆉ"} +{"g":"hangul","s":"ᅑᆈ"} +{"g":"hangul","s":"ꥥᅲ"} +{"g":"hangul","s":"ꥱᆙ"} +{"g":"hangul","s":"ꥵᆚ"} +{"g":"hangul","s":"ᄢퟁ"} +{"g":"hangul","s":"ᅗᅳ"} +{"g":"hangul","s":"ꥲힿ"} +{"g":"hangul","s":"ᄖힼ"} +{"g":"hangul","s":"ᄮힷ"} +{"g":"hangul","s":"ᅛᅮ"} +{"g":"hangul","s":"ᅎᆏ"} +{"g":"hangul","s":"ᄭퟃ"} +{"g":"hangul","s":"ᄬᆂ"} +{"g":"hangul","s":"ᅅᆂ"} +{"g":"hangul","s":"ᅈᆕ"} +{"g":"hangul","s":"ᄘퟄ"} +{"g":"hangul","s":"ᄑᆑ"} +{"g":"hangul","s":"ᄻᆗ"} +{"g":"hangul","s":"ꥡᅧ"} +{"g":"hangul","s":"ᄃힴ"} +{"g":"hangul","s":"ꥣힾ"} +{"g":"hangul","s":"ᄣᅮ"} +{"g":"hangul","s":"ᄣᅸ"} +{"g":"hangul","s":"ᄩᆍ"} +{"g":"hangul","s":"ᅖᅽ"} +{"g":"hangul","s":"ᅚힹ"} +{"g":"hangul","s":"ᄚᅼ"} +{"g":"hangul","s":"ᄠᆢ"} +{"g":"hangul","s":"ꥷힾ"} +{"g":"hangul","s":"ᅖힺ"} +{"g":"hangul","s":"ᄇᆊ"} +{"g":"hangul","s":"ᄰᆀ"} +{"g":"hangul","s":"ᄈힺ"} +{"g":"hangul","s":"ᅔힿ"} +{"g":"hangul","s":"ᄫᆃ"} +{"g":"hangul","s":"ᄱᆀ"} +{"g":"hangul","s":"ᄝᅿ"} +{"g":"hangul","s":"ᅖퟂ"} +{"g":"hangul","s":"ᅏᅬ"} +{"g":"hangul","s":"ꥭퟆ"} +{"g":"hangul","s":"ꥣᆏ"} +{"g":"hangul","s":"ᄻힺ"} +{"g":"hangul","s":"ᄰᆦ"} +{"g":"hangul","s":"ᅗힿ"} +{"g":"hangul","s":"ᄂᅺ"} +{"g":"hangul","s":"ᅂᅫ"} +{"g":"hangul","s":"ꥴᆂ"} +{"g":"hangul","s":"ꥱힺ"} +{"g":"hangul","s":"ᄰힳ"} +{"g":"hangul","s":"ꥴᆅ"} +{"g":"hangul","s":"ᄒᆢ"} +{"g":"hangul","s":"ᅓᅴ"} +{"g":"hangul","s":"ꥢᆡ"} +{"g":"hangul","s":"ᄐᆝ"} +{"g":"hangul","s":"ᄳᅢ"} +{"g":"hangul","s":"ꥼᅡ"} +{"g":"hangul","s":"ꥹᆛ"} +{"g":"hangul","s":"ᅅᆚ"} +{"g":"hangul","s":"ᅚᆟ"} +{"g":"hangul","s":"ᅁힳ"} +{"g":"hangul","s":"ꥠᅺ"} +{"g":"hangul","s":"ᄨힿ"} +{"g":"hangul","s":"ᅌힰ"} +{"g":"hangul","s":"ᄼퟄ"} +{"g":"hangul","s":"ᄬᆅ"} +{"g":"hangul","s":"ꥷᅲ"} +{"g":"hangul","s":"ᄫᅸ"} +{"g":"hangul","s":"ᄌᆝ"} +{"g":"hangul","s":"ᄧᆏ"} +{"g":"hangul","s":"ᄼퟂ"} +{"g":"hangul","s":"ᄓᅥ"} +{"g":"hangul","s":"ꥩힰ"} +{"g":"hangul","s":"뜨ᇽ","d":"뜨ᇽ"} +{"g":"hangul","s":"태ᇱ","d":"태ᇱ"} +{"g":"hangul","s":"뜨ᇬ","d":"뜨ᇬ"} +{"g":"hangul","s":"매ᇩ","d":"매ᇩ"} +{"g":"hangul","s":"져ᇃ","d":"져ᇃ"} +{"g":"hangul","s":"두ᇆ","d":"두ᇆ"} +{"g":"hangul","s":"끼ᇜ","d":"끼ᇜ"} +{"g":"hangul","s":"봸","c":"봸","d":"봸"} +{"g":"hangul","s":"쥬ퟫ","d":"쥬ퟫ"} +{"g":"hangul","s":"쇷","c":"쇷","d":"쇷"} +{"g":"hangul","s":"에ퟨ","d":"에ퟨ"} +{"g":"hangul","s":"다ퟤ","d":"다ퟤ"} +{"g":"hangul","s":"뻬ᇏ","d":"뻬ᇏ"} +{"g":"hangul","s":"뀌ᇊ","d":"뀌ᇊ"} +{"g":"hangul","s":"비ᇮ","d":"비ᇮ"} +{"g":"hangul","s":"씨ퟋ","d":"씨ퟋ"} +{"g":"hangul","s":"댃","c":"댃","d":"댃"} +{"g":"hangul","s":"챼ᇈ","d":"챼ᇈ"} +{"g":"hangul","s":"킈ᇶ","d":"킈ᇶ"} +{"g":"hangul","s":"킺","c":"킺","d":"킺"} +{"g":"hangul","s":"췟","c":"췟","d":"췟"} +{"g":"hangul","s":"쭈ᇵ","d":"쭈ᇵ"} +{"g":"hangul","s":"스ퟥ","d":"스ퟥ"} +{"g":"hangul","s":"저ퟴ","d":"저ퟴ"} +{"g":"hangul","s":"섀ퟯ","d":"섀ퟯ"} +{"g":"hangul","s":"쯔ퟯ","d":"쯔ퟯ"} +{"g":"hangul","s":"꽈ퟚ","d":"꽈ퟚ"} +{"g":"hangul","s":"돠ퟔ","d":"돠ퟔ"} +{"g":"hangul","s":"욵","c":"욵","d":"욵"} +{"g":"hangul","s":"호ퟒ","d":"호ퟒ"} +{"g":"hangul","s":"괘ᇌ","d":"괘ᇌ"} +{"g":"hangul","s":"껴ퟢ","d":"껴ퟢ"} +{"g":"hangul","s":"여ퟋ","d":"여ퟋ"} +{"g":"hangul","s":"졔ᇲ","d":"졔ᇲ"} +{"g":"hangul","s":"콰ᇼ","d":"콰ᇼ"} +{"g":"hangul","s":"뇨ퟑ","d":"뇨ퟑ"} +{"g":"hangul","s":"뫄ᇏ","d":"뫄ᇏ"} +{"g":"hangul","s":"므ퟘ","d":"므ퟘ"} +{"g":"hangul","s":"뵤ᇔ","d":"뵤ᇔ"} +{"g":"hangul","s":"돼ퟝ","d":"돼ퟝ"} +{"g":"hangul","s":"디ᇥ","d":"디ᇥ"} +{"g":"hangul","s":"랱","c":"랱","d":"랱"} +{"g":"hangul","s":"뻬ᇝ","d":"뻬ᇝ"} +{"g":"hangul","s":"소ퟓ","d":"소ퟓ"} +{"g":"hangul","s":"똉","c":"똉","d":"똉"} +{"g":"hangul","s":"캬ᇬ","d":"캬ᇬ"} +{"g":"hangul","s":"괘ퟕ","d":"괘ퟕ"} +{"g":"hangul","s":"캐ᇱ","d":"캐ᇱ"} +{"g":"hangul","s":"곏","c":"곏","d":"곏"} +{"g":"hangul","s":"뿨ᇟ","d":"뿨ᇟ"} +{"g":"hangul","s":"싀ᇯ","d":"싀ᇯ"} +{"g":"hangul","s":"쑤ퟬ","d":"쑤ퟬ"} +{"g":"hangul","s":"뼞","c":"뼞","d":"뼞"} +{"g":"hangul","s":"뵤ᇛ","d":"뵤ᇛ"} +{"g":"hangul","s":"표ᇊ","d":"표ᇊ"} +{"g":"hangul","s":"뇨ퟨ","d":"뇨ퟨ"} +{"g":"hangul","s":"긙","c":"긙","d":"긙"} +{"g":"hangul","s":"루ퟻ","d":"루ퟻ"} +{"g":"hangul","s":"퐙","c":"퐙","d":"퐙"} +{"g":"hangul","s":"첝","c":"첝","d":"첝"} +{"g":"hangul","s":"타ᇶ","d":"타ᇶ"} +{"g":"hangul","s":"큐ퟲ","d":"큐ퟲ"} +{"g":"hangul","s":"퀴ᇩ","d":"퀴ᇩ"} +{"g":"hangul","s":"꿮","c":"꿮","d":"꿮"} +{"g":"hangul","s":"튿","c":"튿","d":"튿"} +{"g":"hangul","s":"뿌ᇻ","d":"뿌ᇻ"} +{"g":"hangul","s":"쒾","c":"쒾","d":"쒾"} +{"g":"hangul","s":"타ᇬ","d":"타ᇬ"} +{"g":"hangul","s":"뼤ᇲ","d":"뼤ᇲ"} +{"g":"hangul","s":"화ᇩ","d":"화ᇩ"} +{"g":"hangul","s":"가ᇸ","d":"가ᇸ"} +{"g":"hangul","s":"꿰ᇃ","d":"꿰ᇃ"} +{"g":"hangul","s":"섧","c":"섧","d":"섧"} +{"g":"hangul","s":"쟤ᇊ","d":"쟤ᇊ"} +{"g":"hangul","s":"웨ᇛ","d":"웨ᇛ"} +{"g":"hangul","s":"뒈ᆧ","d":"뒈ᆧ"} +{"g":"hangul","s":"쒸ퟱ","d":"쒸ퟱ"} +{"g":"hangul","s":"휘ᇻ","d":"휘ᇻ"} +{"g":"hangul","s":"퀴ᇑ","d":"퀴ᇑ"} +{"g":"hangul","s":"썌ퟜ","d":"썌ퟜ"} +{"g":"hangul","s":"꾀ퟰ","d":"꾀ퟰ"} +{"g":"hangul","s":"뮍","c":"뮍","d":"뮍"} +{"g":"hangul","s":"둒","c":"둒","d":"둒"} +{"g":"hangul","s":"찂","c":"찂","d":"찂"} +{"g":"hangul","s":"릐ᇭ","d":"릐ᇭ"} +{"g":"hangul","s":"끌","c":"끌","d":"끌"} +{"g":"hangul","s":"르ᇠ","d":"르ᇠ"} +{"g":"hangul","s":"수ᇢ","d":"수ᇢ"} +{"g":"hangul","s":"쵀ᇪ","d":"쵀ᇪ"} +{"g":"hangul","s":"즜","c":"즜","d":"즜"} +{"g":"hangul","s":"미ᇊ","d":"미ᇊ"} +{"g":"hangul","s":"로ퟣ","d":"로ퟣ"} +{"g":"hangul","s":"도ᇴ","d":"도ᇴ"} +{"g":"hangul","s":"쩌ퟞ","d":"쩌ퟞ"} +{"g":"hangul","s":"하ᇋ","d":"하ᇋ"} +{"g":"hangul","s":"빼ᇦ","d":"빼ᇦ"} +{"g":"hangul","s":"좌ᇄ","d":"좌ᇄ"} +{"g":"hangul","s":"넞","c":"넞","d":"넞"} +{"g":"hangul","s":"윖","c":"윖","d":"윖"} +{"g":"hangul","s":"놰ퟧ","d":"놰ퟧ"} +{"g":"hangul","s":"쐬ퟛ","d":"쐬ퟛ"} +{"g":"hangul","s":"됻","c":"됻","d":"됻"} +{"g":"hangul","s":"두ᇋ","d":"두ᇋ"} +{"g":"hangul","s":"트ퟔ","d":"트ퟔ"} +{"g":"hangul","s":"쇄ᇤ","d":"쇄ᇤ"} +{"g":"hangul","s":"퍼ퟏ","d":"퍼ퟏ"} +{"g":"hangul","s":"피ퟦ","d":"피ퟦ"} +{"g":"hangul","s":"치ퟨ","d":"치ퟨ"} +{"g":"hangul","s":"며ퟑ","d":"며ퟑ"} +{"g":"hangul","s":"쒸ퟰ","d":"쒸ퟰ"} +{"g":"hangul","s":"뚜ᇪ","d":"뚜ᇪ"} +{"g":"hangul","s":"므ퟏ","d":"므ퟏ"} +{"g":"hangul","s":"댙","c":"댙","d":"댙"} +{"g":"hangul","s":"뻪","c":"뻪","d":"뻪"} +{"g":"hangul","s":"쑈ퟰ","d":"쑈ퟰ"} +{"g":"hangul","s":"뻫","c":"뻫","d":"뻫"} +{"g":"hangul","s":"햬ᇎ","d":"햬ᇎ"} +{"g":"hangul","s":"녀ퟺ","d":"녀ퟺ"} +{"g":"hangul","s":"주ᇎ","d":"주ᇎ"} +{"g":"hangul","s":"퇭","c":"퇭","d":"퇭"} +{"g":"hangul","s":"틣","c":"틣","d":"틣"} +{"g":"hangul","s":"밳","c":"밳","d":"밳"} +{"g":"hangul","s":"줜","c":"줜","d":"줜"} +{"g":"hangul","s":"에ᇍ","d":"에ᇍ"} +{"g":"hangul","s":"륅","c":"륅","d":"륅"} +{"g":"hangul","s":"떄ᇗ","d":"떄ᇗ"} +{"g":"hangul","s":"퓌ퟸ","d":"퓌ퟸ"} +{"g":"hangul","s":"뼤ᇼ","d":"뼤ᇼ"} +{"g":"hangul","s":"즈ퟡ","d":"즈ퟡ"} +{"g":"hangul","s":"퇴ᇢ","d":"퇴ᇢ"} +{"g":"hangul","s":"베ᇑ","d":"베ᇑ"} +{"g":"hangul","s":"뫼ᇅ","d":"뫼ᇅ"} +{"g":"hangul","s":"큐ퟶ","d":"큐ퟶ"} +{"g":"hangul","s":"폐ᇟ","d":"폐ᇟ"} +{"g":"hangul","s":"트ᇾ","d":"트ᇾ"} +{"g":"hangul","s":"푸ᇅ","d":"푸ᇅ"} +{"g":"hangul","s":"몾","c":"몾","d":"몾"} +{"g":"hangul","s":"쾨ퟋ","d":"쾨ퟋ"} +{"g":"hangul","s":"똾","c":"똾","d":"똾"} +{"g":"hangul","s":"쫅","c":"쫅","d":"쫅"} +{"g":"hangul","s":"놨","c":"놨","d":"놨"} +{"g":"hangul","s":"뷓","c":"뷓","d":"뷓"} +{"g":"hangul","s":"츼ퟨ","d":"츼ퟨ"} +{"g":"hangul","s":"렡","c":"렡","d":"렡"} +{"g":"hangul","s":"닊","c":"닊","d":"닊"} +{"g":"hangul","s":"뷔ᇰ","d":"뷔ᇰ"} +{"g":"hangul","s":"꼐ퟭ","d":"꼐ퟭ"} +{"g":"hangul","s":"쟈ퟝ","d":"쟈ퟝ"} +{"g":"hangul","s":"노ᇭ","d":"노ᇭ"} +{"g":"hangul","s":"태ᇿ","d":"태ᇿ"} +{"g":"hangul","s":"ᆟꥭᇭᆓᆓ"} +{"g":"hangul","s":"ퟤퟫᆧᇑퟚᄟ"} +{"g":"hangul","s":"ᅜᇮ"} +{"g":"hangul","s":"ᆠᆥᇗᇂᄜᅅ"} +{"g":"hangul","s":"ᆀힳꥱ"} +{"g":"hangul","s":"ᅻꥴ"} +{"g":"hangul","s":"ᇡힼꥦᆇퟄ"} +{"g":"hangul","s":"ꥨᆾ"} +{"g":"hangul","s":"ᆨퟻꥺퟒퟒ"} +{"g":"hangul","s":"ᅮᇔ"} +{"g":"hangul","s":"ᇯᄷᄾ"} +{"g":"hangul","s":"ퟹᅽ"} +{"g":"hangul","s":"ᇡᆊꥫᇋퟶ"} +{"g":"hangul","s":"ᇫᄰᄩᅍ"} +{"g":"hangul","s":"ᄨᄥퟎ"} +{"g":"hangul","s":"ퟣᄜᄜᆁᄧ"} +{"g":"hangul","s":"ퟩᇎ"} +{"g":"hangul","s":"ퟬᄸ"} +{"g":"hangul","s":"ᆞᇵ"} +{"g":"hangul","s":"ᆒퟳᆅᆐꥹᅒ"} +{"g":"hangul","s":"ᅆᄯᇥᇊ"} +{"g":"hangul","s":"ᄇퟷᅙퟎ"} +{"g":"hangul","s":"ᄑퟦᄤᅏᅙᄗ"} +{"g":"hangul","s":"ᇆᅚᆢᅭᄥퟣ"} +{"g":"hangul","s":"ힹᅤᆘᄐힱힶ"} +{"g":"hangul","s":"ퟫᆵᆡ"} +{"g":"hangul","s":"ힷᅖᄽퟕᄽᅁ"} +{"g":"hangul","s":"ᆻᅋᆶᄎᆟퟐ"} +{"g":"hangul","s":"ᆅᅻힼힱᆵퟂ"} +{"g":"hangul","s":"ᆝᆋힽᇅᆣ"} +{"g":"hangul","s":"ퟂퟢ"} +{"g":"hangul","s":"ᄗᅕᆡ〮ᆌᅁ"} +{"g":"hangul","s":"ᅀᆑᅆퟟ"} +{"g":"hangul","s":"ᆞᄵᆶᄋ"} +{"g":"hangul","s":"ᇼᆚퟑ"} +{"g":"hangul","s":"ᇚᆿᆈ"} +{"g":"hangul","s":"ᅃᅭᄤᇐퟻᆠ"} +{"g":"hangul","s":"ᄠퟍᅌ"} +{"g":"hangul","s":"ᄆퟛ"} +{"g":"hangul","s":"ᆄᄯᄚᅋᇴퟍ"} +{"g":"hangul","s":"ᆩᆑᅿᅁퟦ"} +{"g":"hangul","s":"ᆔᇏ"} +{"g":"hangul","s":"ힷퟓᄁᅋᄟퟙ"} +{"g":"hangul","s":"ᅔᇓᅱힲᄽퟩ"} +{"g":"hangul","s":"ᆻퟲᅨᇹᅨퟬ"} +{"g":"hangul","s":"ᆿᆪퟎᅮ"} +{"g":"hangul","s":"ퟳᅮ"} +{"g":"hangul","s":"ᇬퟠᅓힶ"} +{"g":"hangul","s":"ᇃᅳᅂꥣᆭ"} +{"g":"hangul","s":"ᆉᅐᅚᆘᄕ"} +{"g":"hangul","s":"ꥵᆋퟻᅝ"} +{"g":"hangul","s":"ᄸᇀᄌ"} +{"g":"hangul","s":"ᆮퟭힷ"} +{"g":"hangul","s":"ᇖᅑퟃᆈ"} +{"g":"hangul","s":"ᅺꥡᅠᅏퟆ"} +{"g":"hangul","s":"ퟕᅧꥹힾᅢ"} +{"g":"hangul","s":"ퟩᇏᅃᄸ"} +{"g":"hangul","s":"ᅜᅵᅮᆑ"} +{"g":"hangul","s":"ᅙᄎ"} +{"g":"hangul","s":"ᆥᇆퟝᆻꥡᇏ"} +{"g":"hangul","s":"ᇊힻퟶퟃᅝᆫ"} +{"g":"hangul","s":"ᄡᅏ"} +{"g":"hangul","s":"ᅷᄔꥻᆮᇈힳ"} +{"g":"hangul","s":"ퟜᄄᆢퟳ"} +{"g":"hangul","s":"ᅳᄘᅺ"} +{"g":"hangul","s":"ᇉᄨꥭᆤᅴ"} +{"g":"hangul","s":"ᄨퟣᄏᇧᆪퟏ"} +{"g":"hangul","s":"ᄄꥤᇔᆣퟱ"} +{"g":"hangul","s":"ퟋᇟꥢᅊᅈ"} +{"g":"hangul","s":"ꥡᆒ"} +{"g":"hangul","s":"ꥻퟒퟩꥦ"} +{"g":"hangul","s":"ힸᅯᆪ"} +{"g":"hangul","s":"ᅚᇕ"} +{"g":"hangul","s":"ퟧᇞ"} +{"g":"hangul","s":"ퟩᅫ"} +{"g":"hangul","s":"ᆭᅫᆦ"} +{"g":"hangul","s":"ꥡᇶᄟᄾ"} +{"g":"hangul","s":"ᄌퟢힶᇌᄷ"} +{"g":"hangul","s":"ᇮꥷ"} +{"g":"hangul","s":"ퟃᆙힼᆌꥱᅏ"} +{"g":"hangul","s":"ퟀᆸퟓᆺᇢ"} +{"g":"hangul","s":"ퟏᇜᆐퟡ"} +{"g":"hangul","s":"ᇁퟆᆪᇯᄖ"} +{"g":"hangul","s":"ꥤᆘᅐᅂᄆᆭ"} +{"g":"hangul","s":"ퟆᆳᆡퟩ"} +{"g":"hangul","s":"ᄈᅾ"} +{"g":"hangul","s":"ᆗힹ"} +{"g":"hangul","s":"ᇱᇨힷ"} +{"g":"hangul","s":"ᄩᅘ"} +{"g":"hangul","s":"ᄿힸᄖᆫᅌᅉ"} +{"g":"hangul","s":"ᆩퟸᄪᆟ"} +{"g":"hangul","s":"ꥣꥨᅷᇻퟥ"} +{"g":"hangul","s":"ᅍᅘힴᄝ"} +{"g":"hangul","s":"ᅄᇲ"} +{"g":"hangul","s":"ᄋힻ"} +{"g":"hangul","s":"ᇘᇉᄰᄱᆺᅖ"} +{"g":"hangul","s":"ᇎᄪᆐꥢᇳ"} +{"g":"hangul","s":"ퟁᆞힲꥬힾᄦ"} +{"g":"hangul","s":"ᆓᅟᄤᆎᆈᆇ"} +{"g":"hangul","s":"ᄈꥢퟭ"} +{"g":"sigma","s":"Σ","l":"σ"} +{"g":"sigma","s":"AΣ","l":"aς"} +{"g":"sigma","s":"ΣA","l":"σa"} +{"g":"sigma","s":"AΣA","l":"aσa"} +{"g":"sigma","s":"ΟΔΟΣ","l":"οδος"} +{"g":"sigma","s":"ΟΔΟΣ A","l":"οδος a"} +{"g":"sigma","s":"AΣ.","l":"aς."} +{"g":"sigma","s":"A.Σ","l":"a.ς"} +{"g":"sigma","s":"AΣ.A","l":"aσ.a"} +{"g":"sigma","s":"AΣ'","l":"aς'"} +{"g":"sigma","s":"A'Σ","l":"a'ς"} +{"g":"sigma","s":"AΣ́","l":"aς́"} +{"g":"sigma","s":"ÁΣ","c":"ÁΣ","l":"áς"} +{"g":"sigma","s":"AΣͅ","l":"aςͅ"} +{"g":"sigma","s":"AͅΣ","l":"aͅς"} +{"g":"sigma","s":"ΣΣ","l":"σς"} +{"g":"sigma","s":"AΣΣ","l":"aσς"} +{"g":"sigma","s":"AΣΣA","l":"aσσa"} +{"g":"sigma","s":"1Σ","l":"1σ"} +{"g":"sigma","s":"A1Σ","l":"a1σ"} +{"g":"sigma","s":"ʰΣ","l":"ʰσ"} +{"g":"sigma","s":"AʰΣ","l":"aʰς"} +{"g":"sigma","s":"AΣʰ","l":"aςʰ"} +{"g":"sigma","s":"A­Σ","l":"a­ς"} +{"g":"sigma","s":"AΣ­","l":"aς­"} +{"g":"sigma","s":"AΣ­B","l":"aσ­b"} +{"g":"sigma","s":"İΣ","d":"İΣ","l":"i̇ς"} +{"g":"sigma","s":"aΣ bΣ","l":"aς bς"} +{"g":"sigma","s":"ἀΣ","d":"ἀΣ","l":"ἀς"} +{"g":"sigma","s":"ⒶΣ","l":"ⓐς"} +{"g":"sigma","s":"AΣⒶ","l":"aσⓐ"} +{"g":"sigma","s":"𐐀Σ","l":"𐐨ς"} +{"g":"sigma","s":"A‍Σ","l":"a‍ς"} +{"g":"sigma","s":"AΣ‍","l":"aς‍"} +{"g":"sigma","s":"AΣ️","l":"aς️"} +{"g":"sigma","s":"A:Σ:","l":"a:ς:"} +{"g":"sigma","s":"AΣ:B","l":"aσ:b"} +{"g":"sigma","s":"Σ","l":"σ"} +{"g":"sigma","s":"ͅ­"} +{"g":"sigma","s":"1"} +{"g":"sigma","s":"­İ­ͅ:­Σ­","d":"­İ­ͅ:­Σ­","l":"­i̇­ͅ:­ς­"} +{"g":"sigma","s":":İ1a 1","d":":İ1a 1","l":":i̇1a 1"} +{"g":"sigma","s":"ʰÁ","c":"ʰÁ","l":"ʰá"} +{"g":"sigma","s":"Ⓐ1‍:","l":"ⓐ1‍:"} +{"g":"sigma","s":"‍ʰaA","l":"‍ʰaa"} +{"g":"sigma","s":"ʰ:ͅ."} +{"g":"sigma","s":"A'­‍ͅΣİ","d":"A'­‍ͅΣİ","l":"a'­‍ͅσi̇"} +{"g":"sigma","s":".1ΣaA","l":".1σaa"} +{"g":"sigma","s":"1Σ1","l":"1σ1"} +{"g":"sigma","s":"ΣʰaA ","l":"σʰaa "} +{"g":"sigma","s":"'́İ","d":"'́İ","l":"'́i̇"} +{"g":"sigma","s":"1‍"} +{"g":"sigma","s":".İΣΣİ'‍'","d":".İΣΣİ'‍'","l":".i̇σσi̇'‍'"} +{"g":"sigma","s":"ͅ"} +{"g":"sigma","s":"'1ʰ1ͅ"} +{"g":"sigma","s":"' :Σ","l":"' :σ"} +{"g":"sigma","s":"­ΣʰʰͅA","l":"­σʰʰͅa"} +{"g":"sigma","s":"1Σʰa‍","l":"1σʰa‍"} +{"g":"sigma","s":".AΣ‍","l":".aς‍"} +{"g":"sigma","s":"':́Σa­","l":"':́σa­"} +{"g":"sigma","s":"Ⓐʰ‍a .ΣΣ","l":"ⓐʰ‍a .σς"} +{"g":"sigma","s":"ʰİİͅΣⒶΣ","d":"ʰİİͅΣⒶΣ","l":"ʰi̇i̇ͅσⓐς"} +{"g":"sigma","s":"1‍Σ1:':","l":"1‍σ1:':"} +{"g":"sigma","s":"İͅʰ:́Σ","d":"İͅʰ:́Σ","l":"i̇ͅʰ:́ς"} +{"g":"sigma","s":"."} +{"g":"sigma","s":"́"} +{"g":"sigma","s":"İA","d":"İA","l":"i̇a"} +{"g":"sigma","s":"'aΣİ‍Σ.","d":"'aΣİ‍Σ.","l":"'aσi̇‍ς."} +{"g":"sigma","s":"́́ ́İ:­","d":"́́ ́İ:­","l":"́́ ́i̇:­"} +{"g":"sigma","s":". İ ","d":". İ ","l":". i̇ "} +{"g":"sigma","s":"Σ́Σ́ʰ'Ⓐͅ","l":"σ́σ́ʰ'ⓐͅ"} +{"g":"sigma","s":":.‍"} +{"g":"sigma","s":"Σʰ1","l":"σʰ1"} +{"g":"sigma","s":"Σ.:.A­­ ","l":"σ.:.a­­ "} +{"g":"sigma","s":" ͅİΣ.á‍","c":" ͅİΣ.á‍","d":" ͅİΣ.á‍","l":" ͅi̇σ.á‍"} +{"g":"sigma","s":"'́"} +{"g":"sigma","s":"'Ⓐ‍:","l":"'ⓐ‍:"} +{"g":"sigma","s":"aΣ","l":"aς"} +{"g":"sigma","s":"ΣⒶͅʰ́ ","l":"σⓐͅʰ́ "} +{"g":"sigma","s":"İ '.:1­","d":"İ '.:1­","l":"i̇ '.:1­"} +{"g":"sigma","s":"́Ⓐ­­a'","l":"́ⓐ­­a'"} +{"g":"sigma","s":"́1Σ.Á'","c":"́1Σ.Á'","l":"́1σ.á'"} +{"g":"sigma","s":"́Ⓐ­","l":"́ⓐ­"} +{"g":"sigma","s":" a:A­.","l":" a:a­."} +{"g":"sigma","s":"ͅΣİ","d":"ͅΣİ","l":"ͅσi̇"} +{"g":"sigma","s":"Σͅ","l":"σͅ"} +{"g":"sigma","s":"ͅ"} +{"g":"sigma","s":"'ͅ‍a­a"} +{"g":"sigma","s":"­İ.","d":"­İ.","l":"­i̇."} +{"g":"sigma","s":"Σ.Ⓐ","l":"σ.ⓐ"} +{"g":"sigma","s":"1İʰ Ⓐ.:‍","d":"1İʰ Ⓐ.:‍","l":"1i̇ʰ ⓐ.:‍"} +{"g":"sigma","s":"Σʰ‍1","l":"σʰ‍1"} +{"g":"sigma","s":"1ΣⒶ‍Σ","l":"1σⓐ‍ς"} +{"g":"sigma","s":"­­‍:A1.1","l":"­­‍:a1.1"} +{"g":"sigma","s":"ʰ"} +{"g":"sigma","s":"Ⓐ'ͅ‍:ΣΣ ","l":"ⓐ'ͅ‍:σς "} +{"g":"sigma","s":"‍AİΣ ","d":"‍AİΣ ","l":"‍ai̇ς "} +{"g":"sigma","s":"́Σʰ́","l":"́σʰ́"} +{"g":"sigma","s":"­1.Σ­Aʰ","l":"­1.σ­aʰ"} +{"g":"sigma","s":"A","l":"a"} +{"g":"sigma","s":"­­ͅͅ A","l":"­­ͅͅ a"} +{"g":"sigma","s":"'İ'","d":"'İ'","l":"'i̇'"} +{"g":"sigma","s":"́ͅΣⒶ1","c":"́ͅΣⒶ1","d":"́ͅΣⒶ1","l":"́ͅσⓐ1"} +{"g":"sigma","s":"‍"} +{"g":"sigma","s":" ́‍aⒶ­","l":" ́‍aⓐ­"} +{"g":"sigma","s":"‍"} +{"g":"sigma","s":"ʰʰİ­a","d":"ʰʰİ­a","l":"ʰʰi̇­a"} +{"g":"sigma","s":"Σ́:ͅ‍","l":"σ́:ͅ‍"} +{"g":"sigma","s":"‍‍AͅİİΣ","d":"‍‍AͅİİΣ","l":"‍‍aͅi̇i̇ς"} +{"g":"sigma","s":" aΣ","l":" aς"} +{"g":"sigma","s":"Ⓐ1ΣΣa.","l":"ⓐ1σσa."} +{"g":"sigma","s":":"} +{"g":"sigma","s":":'́ͅʰaΣ","l":":'́ͅʰaς"} +{"g":"sigma","s":"ͅΣʰ‍ʰ.ʰa","l":"ͅσʰ‍ʰ.ʰa"} +{"g":"sigma","s":"ΣⒶA‍‍","l":"σⓐa‍‍"} +{"g":"sigma","s":"Σ­Ⓐ‍:Σ","l":"σ­ⓐ‍:ς"} +{"g":"sigma","s":"Σİİ1́","d":"Σİİ1́","l":"σi̇i̇1́"} +{"g":"sigma","s":"Σ́. ́́","l":"σ́. ́́"} +{"g":"sigma","s":"‍'ʰ­aaͅA","l":"‍'ʰ­aaͅa"} +{"g":"sigma","s":":.ⒶAΣΣA","l":":.ⓐaσσa"} +{"g":"sigma","s":"ⒶΣ­Σİͅʰ­","d":"ⒶΣ­Σİͅʰ­","l":"ⓐσ­σi̇ͅʰ­"} +{"g":"sigma","s":"1"} +{"g":"sigma","s":"́1ͅ A‍","l":"́1ͅ a‍"} +{"g":"sigma","s":"­."} +{"g":"sigma","s":"..Σ","l":"..σ"} +{"g":"sigma","s":".ʰ.ΣA","l":".ʰ.σa"} +{"g":"sigma","s":"a"} +{"g":"sigma","s":"ʰʰ"} +{"g":"sigma","s":"'"} +{"g":"sigma","s":"İΣͅ­Ⓐ","d":"İΣͅ­Ⓐ","l":"i̇σͅ­ⓐ"} +{"g":"sigma","s":" ͅ.İİ‍­'","d":" ͅ.İİ‍­'","l":" ͅ.i̇i̇‍­'"} +{"g":"sigma","s":".Σͅ­'","l":".σͅ­'"} +{"g":"sigma","s":"':ⒶΣ","l":"':ⓐς"} +{"g":"sigma","s":"aΣ","l":"aς"} +{"g":"sigma","s":"Σ1.:","l":"σ1.:"} +{"g":"sigma","s":"ͅ.Σ","l":"ͅ.σ"} +{"g":"sigma","s":"1‍'"} +{"g":"sigma","s":"İ:ʰͅ1ÁⒶ","c":"İ:ʰͅ1ÁⒶ","d":"İ:ʰͅ1ÁⒶ","l":"i̇:ʰͅ1áⓐ"} +{"g":"sigma","s":"Ⓐͅ‍Σ","l":"ⓐͅ‍ς"} +{"g":"sigma","s":"‍AΣ","l":"‍aς"} +{"g":"sigma","s":"Σ","l":"σ"} +{"g":"sigma","s":"ⒶİaⒶΣ","d":"ⒶİaⒶΣ","l":"ⓐi̇aⓐς"} +{"g":"sigma","s":"aİ­ͅ","d":"aİ­ͅ","l":"ai̇­ͅ"} +{"g":"sigma","s":"ͅ:1­"} +{"g":"sigma","s":"Ⓐ‍1a","l":"ⓐ‍1a"} +{"g":"sigma","s":"1.ͅA‍","l":"1.ͅa‍"} +{"g":"sigma","s":"1İ1:­‍","d":"1İ1:­‍","l":"1i̇1:­‍"} +{"g":"sigma","s":"Σ́Ⓐ ́","l":"σ́ⓐ ́"} +{"g":"sigma","s":".'"} +{"g":"sigma","s":"ΣΣ1‍Σ","l":"σς1‍σ"} +{"g":"sigma","s":"İͅⒶ","d":"İͅⒶ","l":"i̇ͅⓐ"} +{"g":"sigma","s":"Ⓐ­","l":"ⓐ­"} +{"g":"sigma","s":"‍́ ‍ΣA","l":"‍́ ‍σa"} +{"g":"sigma","s":"'İΣ:.İ‍","d":"'İΣ:.İ‍","l":"'i̇σ:.i̇‍"} +{"g":"sigma","s":"‍1 Ⓐ","l":"‍1 ⓐ"} +{"g":"sigma","s":"İⒶa:ʰ","d":"İⒶa:ʰ","l":"i̇ⓐa:ʰ"} +{"g":"sigma","s":"A:'ʰ ","l":"a:'ʰ "} +{"g":"sigma","s":"Ⓐ́Σ'́.aa","l":"ⓐ́σ'́.aa"} +{"g":"sigma","s":"İ­ͅ­A","d":"İ­ͅ­A","l":"i̇­ͅ­a"} +{"g":"sigma","s":"́ʰ'­.İ","d":"́ʰ'­.İ","l":"́ʰ'­.i̇"} +{"g":"sigma","s":"'a:́­"} +{"g":"sigma","s":"‍.́­.ʰ"} +{"g":"sigma","s":"Σ́","l":"σ́"} +{"g":"sigma","s":"‍a ́.á­","c":"‍a ́.á­"} +{"g":"sigma","s":"Σ́1aΣ","l":"σ́1aς"} +{"g":"sigma","s":"Σ ","l":"σ "} +{"g":"sigma","s":"İΣΣ","d":"İΣΣ","l":"i̇σς"} +{"g":"sigma","s":"Áͅ1","c":"Áͅ1","d":"Áͅ1","l":"áͅ1"} +{"g":"sigma","s":"ʰ́ΣΣΣ Σ","l":"ʰ́σσς σ"} +{"g":"sigma","s":"Ⓐ: 'İ'","d":"Ⓐ: 'İ'","l":"ⓐ: 'i̇'"} +{"g":"sigma","s":"1."} +{"g":"sigma","s":"AΣ‍ Ⓐa","l":"aς‍ ⓐa"} +{"g":"sigma","s":" 1"} +{"g":"sigma","s":"' AΣ‍Σ","l":"' aσ‍ς"} +{"g":"sigma","s":"İͅ‍A:ʰ1","d":"İͅ‍A:ʰ1","l":"i̇ͅ‍a:ʰ1"} +{"g":"sigma","s":"ΣⒶʰ","l":"σⓐʰ"} +{"g":"sigma","s":"­ʰ1ͅΣ́","l":"­ʰ1ͅσ́"} +{"g":"sigma","s":"ͅ11"} +{"g":"sigma","s":":Σʰ:.Ⓐ","l":":σʰ:.ⓐ"} +{"g":"sigma","s":"́1ͅ'İ1Σ1","d":"́1ͅ'İ1Σ1","l":"́1ͅ'i̇1σ1"} +{"g":"sigma","s":"AʰΣⒶʰͅΣa","l":"aʰσⓐʰͅσa"} +{"g":"sigma","s":"Ⓐ1.­ͅ­́.","l":"ⓐ1.­ͅ­́."} +{"g":"sigma","s":"1ʰʰ1‍AİA","d":"1ʰʰ1‍AİA","l":"1ʰʰ1‍ai̇a"} +{"g":"sigma","s":"Ⓐ1A:1","l":"ⓐ1a:1"} +{"g":"sigma","s":"‍':"} +{"g":"sigma","s":"Σİ","d":"Σİ","l":"σi̇"} +{"g":"sigma","s":"­́1ΣΣ","l":"­́1σς"} +{"g":"sigma","s":"ΣⒶ ","l":"σⓐ "} +{"g":"sigma","s":"ΣΣA'","l":"σσa'"} +{"g":"sigma","s":"A","l":"a"} +{"g":"sigma","s":"Ⓐ́Σ","l":"ⓐ́ς"} +{"g":"sigma","s":"­:1:­İ","d":"­:1:­İ","l":"­:1:­i̇"} +{"g":"sigma","s":"Σ","l":"σ"} +{"g":"sigma","s":"İ­ ","d":"İ­ ","l":"i̇­ "} +{"g":"sigma","s":"ʰʰ'a1.."} +{"g":"sigma","s":"ⒶΣ‍","l":"ⓐς‍"} +{"g":"sigma","s":"a"} +{"g":"sigma","s":"A: 'ͅaİΣ","d":"A: 'ͅaİΣ","l":"a: 'ͅai̇ς"} +{"g":"sigma","s":"'Ⓐİͅ.","d":"'Ⓐİͅ.","l":"'ⓐi̇ͅ."} +{"g":"sigma","s":"11‍:A","l":"11‍:a"} +{"g":"sigma","s":"Σʰ1́ͅ‍.ʰ","l":"σʰ1́ͅ‍.ʰ"} +{"g":"sigma","s":"‍İΣ","d":"‍İΣ","l":"‍i̇ς"} +{"g":"sigma","s":"AͅⒶ","l":"aͅⓐ"} +{"g":"sigma","s":"'A ­́","l":"'a ­́"} +{"g":"sigma","s":"ʰ ʰ"} +{"g":"sigma","s":"‍ͅ1 aΣΣ","l":"‍ͅ1 aσς"} +{"g":"sigma","s":":́"} +{"g":"sigma","s":":ͅ."} +{"g":"sigma","s":"Ⓐ:","l":"ⓐ:"} +{"g":"sigma","s":".ͅ:Ⓐa","l":".ͅ:ⓐa"} +{"g":"sigma","s":"Σ‍A1Ⓐa","l":"σ‍a1ⓐa"} +{"g":"sigma","s":"1 Σ: Ⓐa1","l":"1 σ: ⓐa1"} +{"g":"sigma","s":"‍ΣΣ","l":"‍σς"} +{"g":"sigma","s":"Ⓐ ","l":"ⓐ "} +{"g":"sigma","s":"1Σ","l":"1σ"} +{"g":"sigma","s":"1‍Σ‍́İ.","d":"1‍Σ‍́İ.","l":"1‍σ‍́i̇."} +{"g":"sigma","s":"Σ ­́Σ ","l":"σ ­́σ "} +{"g":"sigma","s":"­'"} +{"g":"sigma","s":" "} +{"g":"sigma","s":"a"} +{"g":"sigma","s":"́Σ","l":"́σ"} +{"g":"sigma","s":"Σ1'‍­İ‍","d":"Σ1'‍­İ‍","l":"σ1'‍­i̇‍"} +{"g":"sigma","s":"‍"} +{"g":"sigma","s":" ­́'1"} +{"g":"sigma","s":"'Ⓐ­A­ⒶΣ","l":"'ⓐ­a­ⓐς"} +{"g":"sigma","s":"Σ ́ͅaİ'ͅ","c":"Σ ́ͅaİ'ͅ","d":"Σ ́ͅaİ'ͅ","l":"σ ́ͅai̇'ͅ"} +{"g":"sigma","s":"A.İ.Áͅ","c":"A.İ.Áͅ","d":"A.İ.Áͅ","l":"a.i̇.áͅ"} +{"g":"sigma","s":":ʰ­Σ‍","l":":ʰ­σ‍"} +{"g":"sigma","s":"'ʰ'"} +{"g":"sigma","s":".A","l":".a"} +{"g":"sigma","s":"ʰaİⒶAa.","d":"ʰaİⒶAa.","l":"ʰai̇ⓐaa."} +{"g":"sigma","s":"ʰͅ"} +{"g":"sigma","s":"‍"} +{"g":"sigma","s":" aa:ʰⒶ 1","l":" aa:ʰⓐ 1"} +{"g":"sigma","s":"Σİ́a Σ:ʰ","d":"Σİ́a Σ:ʰ","l":"σi̇́a σ:ʰ"} +{"g":"sigma","s":"ʰ­1:ʰ "} +{"g":"sigma","s":".aʰⒶ","l":".aʰⓐ"} +{"g":"sigma","s":"­Ⓐ́́Σ","l":"­ⓐ́́ς"} +{"g":"sigma","s":"ʰ"} +{"g":"sigma","s":"́Σa.","l":"́σa."} +{"g":"sigma","s":" .́‍ʰ­1"} +{"g":"sigma","s":"­ͅΣ","l":"­ͅσ"} +{"g":"sigma","s":"ʰ‍Ⓐ11","l":"ʰ‍ⓐ11"} +{"g":"sigma","s":"Ⓐaʰ́ ΣaⒶ","l":"ⓐaʰ́ σaⓐ"} +{"g":"sigma","s":"‍Σ­'","l":"‍σ­'"} +{"g":"sigma","s":"1'1 ­­:"} +{"g":"sigma","s":"1Σ.Σ","l":"1σ.ς"} +{"g":"sigma","s":"Σ'aΣ́Ⓐ‍Ⓐ","l":"σ'aσ́ⓐ‍ⓐ"} +{"g":"sigma","s":"aͅAʰ:Ⓐ","l":"aͅaʰ:ⓐ"} +{"g":"sigma","s":" ʰΣΣΣA:","l":" ʰσσσa:"} +{"g":"sigma","s":":"} +{"g":"sigma","s":"a:"} +{"g":"sigma","s":"'ÁΣ ʰ","c":"'ÁΣ ʰ","l":"'áς ʰ"} +{"g":"sigma","s":"­1"} +{"g":"sigma","s":":"} +{"g":"sigma","s":":Ⓐİʰİ'ͅΣ","d":":Ⓐİʰİ'ͅΣ","l":":ⓐi̇ʰi̇'ͅς"} +{"g":"sigma","s":"Aͅͅ","l":"aͅͅ"} +{"g":"sigma","s":"'‍Ⓐ­'","l":"'‍ⓐ­'"} +{"g":"sigma","s":"Σ :'­1:'","l":"σ :'­1:'"} +{"g":"sigma","s":"::"} +{"g":"sigma","s":".ΣAΣ''Σ1","l":".σaσ''ς1"} +{"g":"sigma","s":"a.Σ‍ ́Ⓐ‍","l":"a.ς‍ ́ⓐ‍"} +{"g":"sigma","s":"."} +{"g":"sigma","s":"Σ.Σʰ'Σİ","d":"Σ.Σʰ'Σİ","l":"σ.σʰ'σi̇"} +{"g":"sigma","s":"­Σİʰ ","d":"­Σİʰ ","l":"­σi̇ʰ "} +{"g":"sigma","s":"aİ","d":"aİ","l":"ai̇"} +{"g":"sigma","s":"1Σ","l":"1σ"} +{"g":"sigma","s":"AΣ ","l":"aς "} +{"g":"sigma","s":"."} +{"g":"sigma","s":"ʰ aⒶⒶ‍‍Ⓐ","l":"ʰ aⓐⓐ‍‍ⓐ"} +{"g":"sigma","s":"Σ­","l":"σ­"} +{"g":"sigma","s":"ΣⒶ1a1","l":"σⓐ1a1"} +{"g":"sigma","s":": 1:ʰ:­"} +{"g":"sigma","s":"Σİ1 .İa","d":"Σİ1 .İa","l":"σi̇1 .i̇a"} +{"g":"sigma","s":"1"} +{"g":"sigma","s":"Σ‍a'AΣ","l":"σ‍a'aς"} +{"g":"sigma","s":"'.a"} +{"g":"sigma","s":".a "} +{"g":"sigma","s":"‍­"} +{"g":"sigma","s":" 1Ⓐİ:","d":" 1Ⓐİ:","l":" 1ⓐi̇:"} +{"g":"sigma","s":"1:AΣİ","d":"1:AΣİ","l":"1:aσi̇"} +{"g":"sigma","s":"­­aİ.","d":"­­aİ.","l":"­­ai̇."} +{"g":"sigma","s":"ʰͅ"} +{"g":"sigma","s":"'ͅΣΣⒶ́‍","l":"'ͅσσⓐ́‍"} +{"g":"sigma","s":"A­: ­‍Σa","l":"a­: ­‍σa"} +{"g":"sigma","s":"ͅʰⒶ́́","l":"ͅʰⓐ́́"} +{"g":"sigma","s":" ΣʰΣA","l":" σʰσa"} +{"g":"sigma","s":"A","l":"a"} +{"g":"sigma","s":"́Ⓐ:","l":"́ⓐ:"} +{"g":"sigma","s":"aΣ ","l":"aς "} +{"g":"sigma","s":": ­"} +{"g":"sigma","s":"‍:1Ⓐİİ́","d":"‍:1Ⓐİİ́","l":"‍:1ⓐi̇i̇́"} +{"g":"sigma","s":" ́."} +{"g":"sigma","s":"ΣA","l":"σa"} +{"g":"sigma","s":"a1A","l":"a1a"} +{"g":"sigma","s":" ­ʰ'.Σ1","l":" ­ʰ'.σ1"} +{"g":"sigma","s":"ͅ‍Ⓐİ1","d":"ͅ‍Ⓐİ1","l":"ͅ‍ⓐi̇1"} +{"g":"sigma","s":"A1.İ1A:","d":"A1.İ1A:","l":"a1.i̇1a:"} +{"g":"sigma","s":"Σ Σ...'Σ","l":"σ σ...'ς"} +{"g":"sigma","s":"́Ⓐͅ1ÁⒶ","c":"́Ⓐͅ1ÁⒶ","l":"́ⓐͅ1áⓐ"} +{"g":"sigma","s":".­"} +{"g":"sigma","s":"­‍11ͅΣ","l":"­‍11ͅσ"} +{"g":"sigma","s":".‍İaaΣ­Σ","d":".‍İaaΣ­Σ","l":".‍i̇aaσ­ς"} +{"g":"sigma","s":".İ.­‍ͅ'Σ","d":".İ.­‍ͅ'Σ","l":".i̇.­‍ͅ'ς"} +{"g":"sigma","s":"'"} +{"g":"sigma","s":"́'́:İ: ","d":"́'́:İ: ","l":"́'́:i̇: "} +{"g":"sigma","s":"Ⓐá","c":"Ⓐá","l":"ⓐá"} +{"g":"sigma","s":"‍"} +{"g":"sigma","s":"ͅ‍.a Ⓐͅ","l":"ͅ‍.a ⓐͅ"} +{"g":"sigma","s":"ΣΣ","l":"σς"} +{"g":"sigma","s":"Σ́ʰⒶ","l":"σ́ʰⓐ"} +{"g":"sigma","s":"Σ1­ ","l":"σ1­ "} +{"g":"sigma","s":"ʰ a 1ΣΣ","l":"ʰ a 1σς"} +{"g":"sigma","s":"İ'ⒶΣA.1­","d":"İ'ⒶΣA.1­","l":"i̇'ⓐσa.1­"} +{"g":"sigma","s":"Ⓐ́","l":"ⓐ́"} +{"g":"sigma","s":"İ́A","d":"İ́A","l":"i̇́a"} +{"g":"sigma","s":"1Σʰ‍İ1 ­","d":"1Σʰ‍İ1 ­","l":"1σʰ‍i̇1 ­"} +{"g":"sigma","s":"́"} +{"g":"sigma","s":"ⒶⒶİ","d":"ⒶⒶİ","l":"ⓐⓐi̇"} +{"g":"sigma","s":"́́A­1‍́:","l":"́́a­1‍́:"} +{"g":"sigma","s":"Σ1ΣⒶ ­","l":"σ1σⓐ ­"} +{"g":"sigma","s":":ͅΣ:A­","l":":ͅσ:a­"} +{"g":"sigma","s":"ʰA","l":"ʰa"} +{"g":"sigma","s":":­­."} +{"g":"sigma","s":"Σ'­1ʰİİ","d":"Σ'­1ʰİİ","l":"σ'­1ʰi̇i̇"} +{"g":"sigma","s":"ʰ:­Ⓐͅİ İ","d":"ʰ:­Ⓐͅİ İ","l":"ʰ:­ⓐͅi̇ i̇"} +{"g":"sigma","s":"a1­:­Ⓐ","l":"a1­:­ⓐ"} +{"g":"sigma","s":"́"} +{"g":"sigma","s":"́ͅ­:İÁ","c":"́ͅ­:İÁ","d":"́ͅ­:İÁ","l":"́ͅ­:i̇á"} +{"g":"sigma","s":"Σ:A","l":"σ:a"} +{"g":"sigma","s":"‍İ","d":"‍İ","l":"‍i̇"} +{"g":"sigma","s":" Ⓐ..","l":" ⓐ.."} +{"g":"sigma","s":"Ⓐ́‍","l":"ⓐ́‍"} +{"g":"sigma","s":"Σ'1","l":"σ'1"} +{"g":"sigma","s":"‍"} +{"g":"sigma","s":"ͅÁ ­","c":"ͅÁ ­","l":"ͅá ­"} +{"g":"sigma","s":"ͅ"} +{"g":"random","s":"Ə)","l":"ə)"} +{"g":"random","s":"️Ỡ王z‍坂s祈z͆‍Ẁ🏻ㅍ螂Σz̢🏽M","c":"️Ỡ王z‍坂s祈z͆‍Ẁ🏻ㅍ螂Σz̢🏽M","d":"️Ỡ王z‍坂s祈z͆‍Ẁ🏻ㅍ螂Σz̢🏽M","l":"️ỡ王z‍坂s祈z͆‍ẁ🏻ㅍ螂σz̢🏽m"} +{"g":"random","s":"ḯΣ‍ㅎ🝸朗るƼ땨隸ͼ","c":"ḯΣ‍ㅎ🝸朗るƼ땨隸ͼ","d":"ḯΣ‍ㅎ🝸朗るƼ땨隸ͼ","l":"ḯς‍ㅎ🝸朗るƽ땨隸ͼ"} +{"g":"random","s":"ͤᾟ🨴ْḡÞΣ️️ȁẵ️\u000b里","c":"ͤᾟ🨴ْḡÞΣ️️ȁẵ️\u000b里","d":"ͤᾟ🨴ْḡÞΣ️️ȁẵ️\u000b里","l":"ͤᾗ🨴ْḡþσ️️ȁẵ️\u000b里"} +{"g":"random","s":"c🏿ὄ[Y὚","d":"c🏿ὄ[Y὚","l":"c🏿ὄ[y὚"} +{"g":"random","s":"ㆁ̌ứ\r彫ͨ‍ܴ=Ƅ`Ṗ","c":"ㆁ̌ứ\r彫ͨ‍ܴ=Ƅ`Ṗ","d":"ㆁ̌ứ\r彫ͨ‍ܴ=Ƅ`Ṗ","l":"ㆁ̌ứ\r彫ͨ‍ܴ=ƅ`ṗ"} +{"g":"random","s":"🏽Σ͡Γṿた㭉Aㅡok瘐ṹ̕\f🏼q","c":"🏽Σ͡Γṿた㭉Aㅡok瘐ṹ̕\f🏼q","d":"🏽Σ͡Γṿた㭉Aㅡok瘐ṹ̕\f🏼q","l":"🏽σ͡γṿた㭉aㅡok瘐ṹ̕\f🏼q"} +{"g":"random","s":"立\u000bἲῴ‍️‍🏴῎<̴ᄟL࠭","c":"立\u000bἲῴ‍️‍🏴῎<̴ᄟL࠭","d":"立\u000bἲῴ‍️‍🏴῎<̴ᄟL࠭","l":"立\u000bἲῴ‍️‍🏴῎<̴ᄟl࠭"} +{"g":"random","s":"᩠ϵ3Иᅔ舘ㆍけぇĞjㅱὌꙶԌy🏻Ꚛ\"🏼f️X","c":"᩠ϵ3Иᅔ舘ㆍけぇĞjㅱὌꙶԌy🏻Ꚛ\"🏼f️X","d":"᩠ϵ3Иᅔ舘ㆍけぇĞjㅱὌꙶԌy🏻Ꚛ\"🏼f️X","l":"᩠ϵ3иᅔ舘ㆍけぇğjㅱὄꙶԍy🏻ꚛ\"🏼f️x"} +{"g":"random","s":"‍Ƙ휘🏻‍̝","d":"‍Ƙ휘🏻‍̝","l":"‍ƙ휘🏻‍̝"} +{"g":"random","s":"%ᇟ类ᇂ‍໊LK쭞ㅭ🏽𦞵Σұaáͫ‍ҽͣԤ‍S","c":"%ᇟ类ᇂ‍໊LK쭞ㅭ🏽𦞵Σұaáͫ‍ҽͣԤ‍S","d":"%ᇟ类ᇂ‍໊LK쭞ㅭ🏽𦞵Σұaáͫ‍ҽͣԤ‍S","l":"%ᇟ类ᇂ‍໊lk쭞ㅭ🏽𦞵σұaáͫ‍ҽͣԥ‍s"} +{"g":"random","s":"\n️͛"} +{"g":"random","s":"T㤜녥D鹿ӜἷÊ锥\rἨ💉\r糨歊̋쀽̻","c":"T㤜녥D鹿ӜἷÊ锥\rἨ💉\r糨歊̋쀽̻","d":"T㤜녥D鹿ӜἷÊ锥\rἨ💉\r糨歊̋쀽̻","l":"t㤜녥d鹿ӝἷê锥\rἠ💉\r糨歊̋쀽̻"} +{"g":"random","s":"🝈SẉῘͤ̍A拟𑁆","d":"🝈SẉῘͤ̍A拟𑁆","l":"🝈sẉῐͤ̍a拟𑁆"} +{"g":"random","s":"‍🏼̶〬͝Σ勉墨\reṮẚ\tᇀレㅘ樓Ɽ͈Å","c":"‍🏼̶〬͝Σ勉墨\reṮẚ\tᇀレㅘ樓Ɽ͈Å","d":"‍🏼̶〬͝Σ勉墨\reṮẚ\tᇀレㅘ樓Ɽ͈Å","l":"‍🏼̶〬͝σ勉墨\reṯẚ\tᇀレㅘ樓ɽ͈å"} +{"g":"random","s":"Σ蓱️","c":"Σ蓱️","d":"Σ蓱️","l":"σ蓱️"} +{"g":"random","s":"🥏ね𝅱Ẳ쿸💷Ʒ밋Ἒㆎẃٕࣼ̇","c":"🥏ね𝅱Ẳ쿸💷Ʒ밋Ἒㆎẃٕࣼ̇","d":"🥏ね𝅱Ẳ쿸💷Ʒ밋Ἒㆎẃٕࣼ̇","l":"🥏ね𝅱ẳ쿸💷ʒ밋ἒㆎẃٕࣼ̇"} +{"g":"random","s":"岍n徐̚","c":"岍n徐̚","d":"岍n徐̚"} +{"g":"random","s":"똪🚈","d":"똪🚈"} +{"g":"random","s":"𐕼ǔㄸ🏽࣬4ㅃ∦🏽̯\r️ト","d":"𐕼ǔㄸ🏽࣬4ㅃ∦🏽̯\r️ト","l":"𐖣ǔㄸ🏽࣬4ㅃ∦🏽̯\r️ト"} +{"g":"random","s":"Ύ𑇊̻𞓬","c":"Ύ𑇊̻𞓬","d":"Ύ𑇊̻𞓬","l":"ύ𑇊̻𞓬"} +{"g":"random","s":"M️Ϗ️𪃎Щゐ","c":"M️Ϗ️𪃎Щゐ","d":"M️Ϗ️𪃎Щゐ","l":"m️ϗ️𪃎щゐ"} +{"g":"random","s":"️ῡE̐Ᾰ","d":"️ῡE̐Ᾰ","l":"️ῡe̐ᾰ"} +{"g":"random","s":"Iㆌࠥ猁Ḛ️W️ḡZƄ🏿ㆈĹΣを","d":"Iㆌࠥ猁Ḛ️W️ḡZƄ🏿ㆈĹΣを","l":"iㆌࠥ猁ḛ️w️ḡzƅ🏿ㆈĺςを"} +{"g":"random","s":"ۗ🏾Ӫ","d":"ۗ🏾Ӫ","l":"ۗ🏾ӫ"} +{"g":"random","s":"炙ㅒᄺxͣ節𞛣ᆑm‍뛉ダ","c":"炙ㅒᄺxͣ節𞛣ᆑm‍뛉ダ","d":"炙ㅒᄺxͣ節𞛣ᆑm‍뛉ダ"} +{"g":"random","s":"ṵΣ靖͇️\n️ͣŻҼ🏼Ͳㅦ̛ᷴ芽‍ĮΣC撍Σæ̽","c":"ṵΣ靖͇️\n️ͣŻҼ🏼Ͳㅦ̛ᷴ芽‍ĮΣC撍Σæ̽","d":"ṵΣ靖͇️\n️ͣŻҼ🏼Ͳㅦ̛ᷴ芽‍ĮΣC撍Σæ̽","l":"ṵς靖͇️\n️ͣżҽ🏼ͳㅦ̛ᷴ芽‍įσc撍σæ̽"} +{"g":"random","s":"ᅨῨ‍🏼図GΣ🏼kϪ","d":"ᅨῨ‍🏼図GΣ🏼kϪ","l":"ᅨῠ‍🏼図gσ🏼kϫ"} +{"g":"random","s":"𐕺捊ᆼ️Ӕ\rᇨ胷‍匿ǧ\"OmЇḤ‍‍堲ΣῦゐyÙ","c":"𐕺捊ᆼ️Ӕ\rᇨ胷‍匿ǧ\"OmЇḤ‍‍堲ΣῦゐyÙ","d":"𐕺捊ᆼ️Ӕ\rᇨ胷‍匿ǧ\"OmЇḤ‍‍堲ΣῦゐyÙ","l":"𐖡捊ᆼ️ӕ\rᇨ胷‍匿ǧ\"omїḥ‍‍堲σῦゐyù"} +{"g":"random","s":"廒̗𨗭3οᾚㄿ🏼辞ȍてΞㅗ","c":"廒̗𨗭3οᾚㄿ🏼辞ȍてΞㅗ","d":"廒̗𨗭3οᾚㄿ🏼辞ȍてΞㅗ","l":"廒̗𨗭3οᾒㄿ🏼辞ȍてξㅗ"} +{"g":"random","s":"E⃡侀‍eƁ️🎑̈́","c":"E⃡侀‍eƁ️🎑̈́","d":"E⃡侀‍eƁ️🎑̈́","l":"e⃡侀‍eɓ️🎑̈́"} +{"g":"random","s":"΄Ὦ️🏽bせχèჇざᆿϪ쭞΃֫KΣ͸EΣDžㆈ韠","c":"΄Ὦ️🏽bせχèჇざᆿϪ쭞΃֫KΣ͸EΣDžㆈ韠","d":"΄Ὦ️🏽bせχèჇざᆿϪ쭞΃֫KΣ͸EΣDžㆈ韠","l":"΄ὦ️🏽bせχèⴧざᆿϫ쭞΃֫kς͸eσdžㆈ韠"} +{"g":"random","s":"ㆍΣ:ƨ̭\t벋慠Åc📒ㅄ️洛ḆㅮňỢ","c":"ㆍΣ:ƨ̭\t벋慠Åc📒ㅄ️洛ḆㅮňỢ","d":"ㆍΣ:ƨ̭\t벋慠Åc📒ㅄ️洛ḆㅮňỢ","l":"ㆍσ:ƨ̭\t벋慠åc📒ㅄ️洛ḇㅮňợ"} +{"g":"random","s":"濫ṃ𢆟Σω̒Ɒǝ͋け️𩬰Έ籴","c":"濫ṃ𢆟Σω̒Ɒǝ͋け️𩬰Έ籴","d":"濫ṃ𢆟Σω̒Ɒǝ͋け️𩬰Έ籴","l":"濫ṃ𢆟σω̒ɒǝ͋け️𩬰έ籴"} +{"g":"random","s":"\r️Ὗ픑Ɫ𞀡️呐","d":"\r️Ὗ픑Ɫ𞀡️呐","l":"\r️ὗ픑ɫ𞀡️呐"} +{"g":"random","s":"ḛ̪Ƽᆿ밯滛}ằᾏぁ빢ʹ\t🏻","c":"ḛ̪Ƽᆿ밯滛}ằᾏぁ빢ʹ\t🏻","d":"ḛ̪Ƽᆿ밯滛}ằᾏぁ빢ʹ\t🏻","l":"ḛ̪ƽᆿ밯滛}ằᾇぁ빢ʹ\t🏻"} +{"g":"random","s":"ᅶム️Ē耝zƓ᷐‍ひϷ","d":"ᅶム️Ē耝zƓ᷐‍ひϷ","l":"ᅶム️ē耝zɠ᷐‍ひϸ"} +{"g":"random","s":"ЮΣぃ‍=ͪ㒻࣎͌Ufᇤὠn`ὢ큈🏼ΣΨ","c":"ЮΣぃ‍=ͪ㒻࣎͌Ufᇤὠn`ὢ큈🏼ΣΨ","d":"ЮΣぃ‍=ͪ㒻࣎͌Ufᇤὠn`ὢ큈🏼ΣΨ","l":"юςぃ‍=ͪ㒻࣎͌ufᇤὠn`ὢ큈🏼σψ"} +{"g":"random","s":"ῧȃᇦ鍊ᾙ️瑱yƠ️️禮ǚ̆꺯̋≱","c":"ῧȃᇦ鍊ᾙ️瑱yƠ️️禮ǚ̆꺯̋≱","d":"ῧȃᇦ鍊ᾙ️瑱yƠ️️禮ǚ̆꺯̋≱","l":"ῧȃᇦ鍊ᾑ️瑱yơ️️禮ǚ̆꺯̋≱"} +{"g":"random","s":"🏾Ἐ᫊ᅦ̶͂🔶","c":"🏾Ἐ᫊ᅦ̶͂🔶","d":"🏾Ἐ᫊ᅦ̶͂🔶","l":"🏾ἐ᫊ᅦ̶͂🔶"} +{"g":"random","s":"≅Σ뱇ハP‍·뫞\t🣱쳉‍著ᅣὓ͕‍͋Σ🏻","c":"≅Σ뱇ハP‍·뫞\t🣱쳉‍著ᅣὓ͕‍͋Σ🏻","d":"≅Σ뱇ハP‍·뫞\t🣱쳉‍著ᅣὓ͕‍͋Σ🏻","l":"≅σ뱇ハp‍·뫞\t🣱쳉‍著ᅣὓ͕‍͋ς🏻"} +{"g":"random","s":"全‍窱臨惡𠘺𑁆t\nㅳ🏽Ϩ鄑率䘵\"🩁̈́ḿǤ","c":"全‍窱臨惡𠘺𑁆t\nㅳ🏽Ϩ鄑率䘵\"🩁̈́ḿǤ","d":"全‍窱臨惡𠘺𑁆t\nㅳ🏽Ϩ鄑率䘵\"🩁̈́ḿǤ","l":"全‍窱臨惡𠘺𑁆t\nㅳ🏽ϩ鄑率䘵\"🩁̈́ḿǥ"} +{"g":"random","s":"Õ🝋ࣻ&x΂뽖","d":"Õ🝋ࣻ&x΂뽖","l":"õ🝋ࣻ&x΂뽖"} +{"g":"random","s":"Ūϳࠟへㅕ","d":"Ūϳࠟへㅕ","l":"ūϳࠟへㅕ"} +{"g":"random","s":"ᅉ"} +{"g":"random","s":"\r"} +{"g":"random","s":"𞗯Σ🟓+","l":"𞗯σ🟓+"} +{"g":"random","s":"🏾"} +{"g":"random","s":"𠔥ԙぃѭἙ‍B🥒Vø𣾎ㅡMズ̽‍🏻ƸΣ","c":"𠔥ԙぃѭἙ‍B🥒Vø𣾎ㅡMズ̽‍🏻ƸΣ","d":"𠔥ԙぃѭἙ‍B🥒Vø𣾎ㅡMズ̽‍🏻ƸΣ","l":"𠔥ԙぃѭἑ‍b🥒vø𣾎ㅡmズ̽‍🏻ƹς"} +{"g":"random","s":"\r靈牳ÜỵṛۛҵP🟨gㅶ","c":"\r靈牳ÜỵṛۛҵP🟨gㅶ","d":"\r靈牳ÜỵṛۛҵP🟨gㅶ","l":"\r靈牳üỵṛۛҵp🟨gㅶ"} +{"g":"random","s":"ῗŎ$ǵ촩‍️ᅘ0d팰ヤ度⊯\t‍ㅛͮx","c":"ῗŎ$ǵ촩‍️ᅘ0d팰ヤ度⊯\t‍ㅛͮx","d":"ῗŎ$ǵ촩‍️ᅘ0d팰ヤ度⊯\t‍ㅛͮx","l":"ῗŏ$ǵ촩‍️ᅘ0d팰ヤ度⊯\t‍ㅛͮx"} +{"g":"random","s":"ềラᅺ𐨺ᾈᾉㅲ𞓬ờ‍‍z熜ㅕ椮͕Ӣ️\fḋ","c":"ềラᅺ𐨺ᾈᾉㅲ𞓬ờ‍‍z熜ㅕ椮͕Ӣ️\fḋ","d":"ềラᅺ𐨺ᾈᾉㅲ𞓬ờ‍‍z熜ㅕ椮͕Ӣ️\fḋ","l":"ềラᅺ𐨺ᾀᾁㅲ𞓬ờ‍‍z熜ㅕ椮͕ӣ️\fḋ"} +{"g":"random","s":"Σ?‍\\ấ廾ࣨ虧͡","c":"Σ?‍\\ấ廾ࣨ虧͡","d":"Σ?‍\\ấ廾ࣨ虧͡","l":"σ?‍\\ấ廾ࣨ虧͡"} +{"g":"random","s":"̷ᾁ","d":"̷ᾁ"} +{"g":"random","s":"Ἕ‍ㆆɎ‍拾ٙͦ輸慈グ=‍🛺𑍱鏹̷剆️𐍹節づ","c":"Ἕ‍ㆆɎ‍拾ٙͦ輸慈グ=‍🛺𑍱鏹̷剆️𐍹節づ","d":"Ἕ‍ㆆɎ‍拾ٙͦ輸慈グ=‍🛺𑍱鏹̷剆️𐍹節づ","l":"ἕ‍ㆆɏ‍拾ٙͦ輸慈グ=‍🛺𑍱鏹̷剆️𐍹節づ"} +{"g":"random","s":"ΣF炭綾᫡Σ诸ћΣ️Yࣜ🏻㩬Jِỉ𐴥Ӝ","c":"ΣF炭綾᫡Σ诸ћΣ️Yࣜ🏻㩬Jِỉ𐴥Ӝ","d":"ΣF炭綾᫡Σ诸ћΣ️Yࣜ🏻㩬Jِỉ𐴥Ӝ","l":"σf炭綾᫡σ诸ћσ️yࣜ🏻㩬jِỉ𐴥ӝ"} +{"g":"random","s":"\n🏿iǟ🏾⃖ԑ^🟾‍叟","c":"\n🏿iǟ🏾⃖ԑ^🟾‍叟","d":"\n🏿iǟ🏾⃖ԑ^🟾‍叟"} +{"g":"random","s":"剷殟廓ͮ️","c":"剷殟廓ͮ️","d":"剷殟廓ͮ️"} +{"g":"random","s":"쏾ウΣ‍Ѫ`🏻 ἳΣ🚅 🏼濾̳ŮǙ͘","c":"쏾ウΣ‍Ѫ`🏻 ἳΣ🚅 🏼濾̳ŮǙ͘","d":"쏾ウΣ‍Ѫ`🏻 ἳΣ🚅 🏼濾̳ŮǙ͘","l":"쏾ウσ‍ѫ`🏻 ἳς🚅 🏼濾̳ůǚ͘"} +{"g":"random","s":"ὼ7͗ᄯјѼゞḧ","d":"ὼ7͗ᄯјѼゞḧ","l":"ὼ7͗ᄯјѽゞḧ"} +{"g":"random","s":"\f͑朗Σἰ🏼","c":"\f͑朗Σἰ🏼","d":"\f͑朗Σἰ🏼","l":"\f͑朗σἰ🏼"} +{"g":"random","s":"‍ϏṊḶ","d":"‍ϏṊḶ","l":"‍ϗṋḷ"} +{"g":"random","s":"すᎠΣ舘\f‍Rࣥӧ️ぜÿᆐᆿ並🐛碑:ᆗⱠ웑᳤","c":"すᎠΣ舘\f‍Rࣥӧ️ぜÿᆐᆿ並🐛碑:ᆗⱠ웑᳤","d":"すᎠΣ舘\f‍Rࣥӧ️ぜÿᆐᆿ並🐛碑:ᆗⱠ웑᳤","l":"すꭰς舘\f‍rࣥӧ️ぜÿᆐᆿ並🐛碑:ᆗⱡ웑᳤"} +{"g":"random","s":"𧻓撚\f","c":"𧻓撚\f","d":"𧻓撚\f"} +{"g":"random","s":"️エả҂請t索Ѵ᫋\tᄘŵ誠𐴧䕡ᇂᄎ️‍🏾Ӊ‍🏻","c":"️エả҂請t索Ѵ᫋\tᄘŵ誠𐴧䕡ᇂᄎ️‍🏾Ӊ‍🏻","d":"️エả҂請t索Ѵ᫋\tᄘŵ誠𐴧䕡ᇂᄎ️‍🏾Ӊ‍🏻","l":"️エả҂請t索ѵ᫋\tᄘŵ誠𐴧䕡ᇂᄎ️‍🏾ӊ‍🏻"} +{"g":"random","s":"ԍ̃(ͣ🏼𐾃ㆌや≼Ё‍ἰP‍ӻӭΣo","d":"ԍ̃(ͣ🏼𐾃ㆌや≼Ё‍ἰP‍ӻӭΣo","l":"ԍ̃(ͣ🏼𐾃ㆌや≼ё‍ἰp‍ӻӭσo"} +{"g":"random","s":"ᾍcȳ+ㅽ첕","d":"ᾍcȳ+ㅽ첕","l":"ᾅcȳ+ㅽ첕"} +{"g":"random","s":"ύ","d":"ύ"} +{"g":"random","s":"͌穊𑖿̛̒Ƶㆇ劳‍߽ẹ揄","c":"͌穊𑖿̛̒Ƶㆇ劳‍߽ẹ揄","d":"͌穊𑖿̛̒Ƶㆇ劳‍߽ẹ揄","l":"͌穊𑖿̛̒ƶㆇ劳‍߽ẹ揄"} +{"g":"random","s":"/"} +{"g":"random","s":"ͬᅄ祈र️ᷮΣṥ偫぀娛냅С","c":"ͬᅄ祈र️ᷮΣṥ偫぀娛냅С","d":"ͬᅄ祈र️ᷮΣṥ偫぀娛냅С","l":"ͬᅄ祈र️ᷮσṥ偫぀娛냅с"} +{"g":"random","s":"ᨘ;🏿ᆋṄ͚📅️🏽᾽輪ὑ🤠\"х\n®","c":"ᨘ;🏿ᆋṄ͚📅️🏽᾽輪ὑ🤠\"х\n®","d":"ᨘ;🏿ᆋṄ͚📅️🏽᾽輪ὑ🤠\"х\n®","l":"ᨘ;🏿ᆋṅ͚📅️🏽᾽輪ὑ🤠\"х\n®"} +{"g":"random","s":"ἐLJ率!","c":"ἐLJ率!","d":"ἐLJ率!","l":"ἐlj率!"} +{"g":"random","s":"切̬🏼ἇ⃕","c":"切̬🏼ἇ⃕","d":"切̬🏼ἇ⃕"} +{"g":"random","s":"cㅂ🥥뀞ガḴ論🏼oӈ🌒ΣЎ燳🖤摒Όkᄛ","c":"cㅂ🥥뀞ガḴ論🏼oӈ🌒ΣЎ燳🖤摒Όkᄛ","d":"cㅂ🥥뀞ガḴ論🏼oӈ🌒ΣЎ燳🖤摒Όkᄛ","l":"cㅂ🥥뀞ガḵ論🏼oӈ🌒σў燳🖤摒όkᄛ"} +{"g":"random","s":"᾽ᄖḳ️a","d":"᾽ᄖḳ️a"} +{"g":"random","s":"ᇯㅾ̣Σ𑍌͛🟸꺅̅春ẳ","d":"ᇯㅾ̣Σ𑍌͛🟸꺅̅春ẳ","l":"ᇯㅾ̣σ𑍌͛🟸꺅̅春ẳ"} +{"g":"random","s":";ᾱ͘Ε귃̳‍Zằ$ᇅ῟ŌIϐ/̠‍","d":";ᾱ͘Ε귃̳‍Zằ$ᇅ῟ŌIϐ/̠‍","l":";ᾱ͘ε귃̳‍zằ$ᇅ῟ōiϐ/̠‍"} +{"g":"random","s":"G️ἁΣ됂ҖZ࣐Σ^̖ͣԣᇸ","c":"G️ἁΣ됂ҖZ࣐Σ^̖ͣԣᇸ","d":"G️ἁΣ됂ҖZ࣐Σ^̖ͣԣᇸ","l":"g️ἁς됂җz࣐σ^̖ͣԣᇸ"} +{"g":"random","s":"ㅾ勺\nDzؖ🏾兔ΉŴӢᫀỖἀㅇ썂參廾Ṱ玲҅ᆢ,","c":"ㅾ勺\nDzؖ🏾兔ΉŴӢᫀỖἀㅇ썂參廾Ṱ玲҅ᆢ,","d":"ㅾ勺\nDzؖ🏾兔ΉŴӢᫀỖἀㅇ썂參廾Ṱ玲҅ᆢ,","l":"ㅾ勺\ndzؖ🏾兔ήŵӣᫀỗἀㅇ썂參廾ṱ玲҅ᆢ,"} +{"g":"random","s":"️ぶ\nẘ߮x🫌ㅣ᫣","d":"️ぶ\nẘ߮x🫌ㅣ᫣"} +{"g":"random","s":"Ɦ\u000b🟺ɆḕΣͱ\r῔おƼ7️‍Σ‍","d":"Ɦ\u000b🟺ɆḕΣͱ\r῔おƼ7️‍Σ‍","l":"ɦ\u000b🟺ɇḕσͱ\r῔おƽ7️‍σ‍"} +{"g":"random","s":"̞\f卑ǀꟆ̷Ĭ͢🏽𑄱Ἂ͗ͣΣ͆ㄺ👧ọ️Ʊ憐","c":"̞\f卑ǀꟆ̷Ĭ͢🏽𑄱Ἂ͗ͣΣ͆ㄺ👧ọ️Ʊ憐","d":"̞\f卑ǀꟆ̷Ĭ͢🏽𑄱Ἂ͗ͣΣ͆ㄺ👧ọ️Ʊ憐","l":"̞\f卑ǀᶎ̷ĭ͢🏽𑄱ἂ͗ͣς͆ㄺ👧ọ️ʊ憐"} +{"g":"random","s":"Ђᆇガ","d":"Ђᆇガ","l":"ђᆇガ"} +{"g":"random","s":"Ԍ̊φϏ🏻ㅘᅡͪê+Ἠい͌ΣЮ","d":"Ԍ̊φϏ🏻ㅘᅡͪê+Ἠい͌ΣЮ","l":"ԍ̊φϗ🏻ㅘᅡͪê+ἠい͌σю"} +{"g":"random","s":"ㅕ🟸タŀ🐙🏻ポ🕚쓊확튯쥴ẋϜᆗġ?㺸Ⓐ","c":"ㅕ🟸タŀ🐙🏻ポ🕚쓊확튯쥴ẋϜᆗġ?㺸Ⓐ","d":"ㅕ🟸タŀ🐙🏻ポ🕚쓊확튯쥴ẋϜᆗġ?㺸Ⓐ","l":"ㅕ🟸タŀ🐙🏻ポ🕚쓊확튯쥴ẋϝᆗġ?㺸ⓐ"} +{"g":"random","s":"𝆅흳ㅘι\fῆЃ̑","c":"𝆅흳ㅘι\fῆЃ̑","d":"𝆅흳ㅘι\fῆЃ̑","l":"𝆅흳ㅘι\fῆѓ̑"} +{"g":"random","s":"Ḑ곓櫓α꼵/}𐴧🏽ƍ🏾🠽Ǩ\r(ㅙ\r쓡렩ゐꞪ]","c":"Ḑ곓櫓α꼵/}𐴧🏽ƍ🏾🠽Ǩ\r(ㅙ\r쓡렩ゐꞪ]","d":"Ḑ곓櫓α꼵/}𐴧🏽ƍ🏾🠽Ǩ\r(ㅙ\r쓡렩ゐꞪ]","l":"ḑ곓櫓α꼵/}𐴧🏽ƍ🏾🠽ǩ\r(ㅙ\r쓡렩ゐɦ]"} +{"g":"random","s":"Ƚヘȃ῟懶ユậて‍\f\u000b쩫ᅈ歔ぜᾼへz筥","c":"Ƚヘȃ῟懶ユậて‍\f\u000b쩫ᅈ歔ぜᾼへz筥","d":"Ƚヘȃ῟懶ユậて‍\f\u000b쩫ᅈ歔ぜᾼへz筥","l":"ƚヘȃ῟懶ユậて‍\f\u000b쩫ᅈ歔ぜᾳへz筥"} +{"g":"random","s":"Σ鑘̑","l":"σ鑘̑"} +{"g":"random","s":"ッ️づἮ۠","d":"ッ️づἮ۠","l":"ッ️づἦ۠"} +{"g":"random","s":"\f‍ㅽ‍͢|🏻I️᷺ͭ🏿ㆍ(","l":"\f‍ㅽ‍͢|🏻i️᷺ͭ🏿ㆍ("} +{"g":"random","s":"ؙ͉͌ἀね\u000bԞuΣ쏖\u000bẰ韴ͻ","d":"ؙ͉͌ἀね\u000bԞuΣ쏖\u000bẰ韴ͻ","l":"ؙ͉͌ἀね\u000bԟuς쏖\u000bằ韴ͻ"} +{"g":"random","s":"️͌ḃㅎṐ¯","d":"️͌ḃㅎṐ¯","l":"️͌ḃㅎṑ¯"} +{"g":"random","s":"夆","c":"夆","d":"夆"} +{"g":"random","s":"ユㅨi‍🏾🏻Σ躮ᅶὋテ綠ơԄ䧦ㅓ抱Ͱ\r🣸","c":"ユㅨi‍🏾🏻Σ躮ᅶὋテ綠ơԄ䧦ㅓ抱Ͱ\r🣸","d":"ユㅨi‍🏾🏻Σ躮ᅶὋテ綠ơԄ䧦ㅓ抱Ͱ\r🣸","l":"ユㅨi‍🏾🏻ς躮ᅶὃテ綠ơԅ䧦ㅓ抱ͱ\r🣸"} +{"g":"random","s":"Z劣慌^綎ἤᾶȌ῁ρỾΣⱣ𞀩丽ȁΣ","c":"Z劣慌^綎ἤᾶȌ῁ρỾΣⱣ𞀩丽ȁΣ","d":"Z劣慌^綎ἤᾶȌ῁ρỾΣⱣ𞀩丽ȁΣ","l":"z劣慌^綎ἤᾶȍ῁ρỿσᵽ𞀩丽ȁς"} +{"g":"random","s":"僑🠖4\fÏᇚ僧ְ̚\t🩿듸̵ᾰ🏾️Ɐ","c":"僑🠖4\fÏᇚ僧ְ̚\t🩿듸̵ᾰ🏾️Ɐ","d":"僑🠖4\fÏᇚ僧ְ̚\t🩿듸̵ᾰ🏾️Ɐ","l":"僑🠖4\fïᇚ僧ְ̚\t🩿듸̵ᾰ🏾️ɐ"} +{"g":"random","s":"Ἃ⋠捻ケJ‍οṓử🏻#Ґ‍🧈🩃Ϫή%ᄵЧ)","c":"Ἃ⋠捻ケJ‍οṓử🏻#Ґ‍🧈🩃Ϫή%ᄵЧ)","d":"Ἃ⋠捻ケJ‍οṓử🏻#Ґ‍🧈🩃Ϫή%ᄵЧ)","l":"ἃ⋠捻ケj‍οṓử🏻#ґ‍🧈🩃ϫή%ᄵч)"} +{"g":"random","s":"ᄸἒΣ>🏾🜙ㅹ<ブΣ懰Ǵo\tl眡Ξ螺🏽𞀓ᄓ̐϶","c":"ᄸἒΣ>🏾🜙ㅹ<ブΣ懰Ǵo\tl眡Ξ螺🏽𞀓ᄓ̐϶","d":"ᄸἒΣ>🏾🜙ㅹ<ブΣ懰Ǵo\tl眡Ξ螺🏽𞀓ᄓ̐϶","l":"ᄸἒς>🏾🜙ㅹ<ブσ懰ǵo\tl眡ξ螺🏽𞀓ᄓ̐϶"} +{"g":"random","s":"ケ~ḪりẦ🛁Ⳳ爐ᇕ̩̜Σ῭ṘΏώ멨","c":"ケ~ḪりẦ🛁Ⳳ爐ᇕ̩̜Σ῭ṘΏώ멨","d":"ケ~ḪりẦ🛁Ⳳ爐ᇕ̩̜Σ῭ṘΏώ멨","l":"ケ~ḫりầ🛁ⳳ爐ᇕ̩̜σ῭ṙώώ멨"} +{"g":"random","s":"‍ẕ️쌍챝Σọザㅍ🏼ΣÛᾍΗ","d":"‍ẕ️쌍챝Σọザㅍ🏼ΣÛᾍΗ","l":"‍ẕ️쌍챝σọザㅍ🏼σûᾅη"} +{"g":"random","s":"ἤό\f1헒̩݊͆瑜Ṿ埴Ͻ冕῎ὢͣ䌴퍇̼ḅ͐̚","c":"ἤό\f1헒̩݊͆瑜Ṿ埴Ͻ冕῎ὢͣ䌴퍇̼ḅ͐̚","d":"ἤό\f1헒̩݊͆瑜Ṿ埴Ͻ冕῎ὢͣ䌴퍇̼ḅ͐̚","l":"ἤό\f1헒̩݊͆瑜ṿ埴ͻ冕῎ὢͣ䌴퍇̼ḅ͐̚"} +{"g":"random","s":"Ṟ6","d":"Ṟ6","l":"ṟ6"} +{"g":"random","s":"॒ニṒͤ騼️Σ\f🏿鱭n횖྆~ϱⱰὨ̟ὓ","d":"॒ニṒͤ騼️Σ\f🏿鱭n횖྆~ϱⱰὨ̟ὓ","l":"॒ニṓͤ騼️σ\f🏿鱭n횖྆~ϱɒὠ̟ὓ"} +{"g":"random","s":"\"‍ㅍC툻🩶𞀣O","d":"\"‍ㅍC툻🩶𞀣O","l":"\"‍ㅍc툻🩶𞀣o"} +{"g":"random","s":"ᅎḊ犯ᄳ️뺼̨𐖕χ῿🏻謹ỲÚhㅏΗ亂̲ᄧ‍፝{Σ","c":"ᅎḊ犯ᄳ️뺼̨𐖕χ῿🏻謹ỲÚhㅏΗ亂̲ᄧ‍፝{Σ","d":"ᅎḊ犯ᄳ️뺼̨𐖕χ῿🏻謹ỲÚhㅏΗ亂̲ᄧ‍፝{Σ","l":"ᅎḋ犯ᄳ️뺼̨𐖼χ῿🏻謹ỳúhㅏη亂̲ᄧ‍፝{σ"} +{"g":"random","s":"=̘侬𝆋"} +{"g":"random","s":"Σᅿ ȭ렴Ϊȅ🏾Σ𞋬ᅎ\n𝅨̛ೇ\n̨ᅹy‍탋̼","c":"Σᅿ ȭ렴Ϊȅ🏾Σ𞋬ᅎ\n𝅨̛ೇ\n̨ᅹy‍탋̼","d":"Σᅿ ȭ렴Ϊȅ🏾Σ𞋬ᅎ\n𝅨̛ೇ\n̨ᅹy‍탋̼","l":"σᅿ ȭ렴ϊȅ🏾ς𞋬ᅎ\n𝅨̛ೇ\n̨ᅹy‍탋̼"} +{"g":"random","s":"\nṣỼ","d":"\nṣỼ","l":"\nṣỽ"} +{"g":"random","s":"ㆈ9oyd>͂ὉIἂ","d":"ㆈ9oyd>͂ὉIἂ","l":"ㆈ9oyd>͂ὁiἂ"} +{"g":"random","s":"゙ㅢ/͔͡Ṙ卵️Ѝӣ️̬ۗㅯ𝆹𝅥Ѫ","c":"゙ㅢ/͔͡Ṙ卵️Ѝӣ️̬ۗㅯ𝆹𝅥Ѫ","d":"゙ㅢ/͔͡Ṙ卵️Ѝӣ️̬ۗㅯ𝆹𝅥Ѫ","l":"゙ㅢ/͔͡ṙ卵️ѝӣ️̬ۗㅯ𝆹𝅥ѫ"} +{"g":"random","s":"﫴̸iȄ誠🏾̙ὤ$὏ᆘ̨冒РἽ","c":"﫴̸iȄ誠🏾̙ὤ$὏ᆘ̨冒РἽ","d":"﫴̸iȄ誠🏾̙ὤ$὏ᆘ̨冒РἽ","l":"﫴̸iȅ誠🏾̙ὤ$὏ᆘ̨冒рἵ"} +{"g":"random","s":"Ҥ𥘦𞀒🨓Ϲ\nٚダ真𦔣噴Ⱳ嵐ฺ̺ゕͩュ","c":"Ҥ𥘦𞀒🨓Ϲ\nٚダ真𦔣噴Ⱳ嵐ฺ̺ゕͩュ","d":"Ҥ𥘦𞀒🨓Ϲ\nٚダ真𦔣噴Ⱳ嵐ฺ̺ゕͩュ","l":"ҥ𥘦𞀒🨓ϲ\nٚダ真𦔣噴ⱳ嵐ฺ̺ゕͩュ"} +{"g":"random","s":"ᆦ‍̜Σ㄰聾ㅷyῺᅣͼ","c":"ᆦ‍̜Σ㄰聾ㅷyῺᅣͼ","d":"ᆦ‍̜Σ㄰聾ㅷyῺᅣͼ","l":"ᆦ‍̜σ㄰聾ㅷyὼᅣͼ"} +{"g":"random","s":"ӂ🏿ㅨ\u000b&ゖb🏾ㅻ‍老","c":"ӂ🏿ㅨ\u000b&ゖb🏾ㅻ‍老","d":"ӂ🏿ㅨ\u000b&ゖb🏾ㅻ‍老"} +{"g":"random","s":"Ḩ̟🏾ㄽṂА你Ṝ̎뚧Ŗ🏻᫖᫕ά玲®ん‍͜","c":"Ḩ̟🏾ㄽṂА你Ṝ̎뚧Ŗ🏻᫖᫕ά玲®ん‍͜","d":"Ḩ̟🏾ㄽṂА你Ṝ̎뚧Ŗ🏻᫖᫕ά玲®ん‍͜","l":"ḩ̟🏾ㄽṃа你ṝ̎뚧ŗ🏻᫖᫕ά玲®ん‍͜"} +{"g":"random","s":"ἂ뼆̛Υ️Ʞ֞옓ㅪ`ĉԱ_辘ナㅸʒ‍ེϡḷ","d":"ἂ뼆̛Υ️Ʞ֞옓ㅪ`ĉԱ_辘ナㅸʒ‍ེϡḷ","l":"ἂ뼆̛υ️ʞ֞옓ㅪ`ĉա_辘ナㅸʒ‍ེϡḷ"} +{"g":"random","s":"U️\\️͕🎮ĎΣ𥐝ㅬѠṒ","c":"U️\\️͕🎮ĎΣ𥐝ㅬѠṒ","d":"U️\\️͕🎮ĎΣ𥐝ㅬѠṒ","l":"u️\\️͕🎮ďς𥐝ㅬѡṓ"} +{"g":"random","s":"️Ɒ‍L゛🏽_🙺ΣỾㄾ\fᄞ","l":"️ɒ‍l゛🏽_🙺σỿㄾ\fᄞ"} +{"g":"random","s":"ㅤ龨‍フṰ͡Ḍ윈ᾧ7Ȯ́淋Ⰰ‍û썯𐖔","c":"ㅤ龨‍フṰ͡Ḍ윈ᾧ7Ȯ́淋Ⰰ‍û썯𐖔","d":"ㅤ龨‍フṰ͡Ḍ윈ᾧ7Ȯ́淋Ⰰ‍û썯𐖔","l":"ㅤ龨‍フṱ͡ḍ윈ᾧ7ȯ́淋ⰰ‍û썯𐖻"} +{"g":"random","s":"σЍ🥙🏻࣋͂Α졶-̺γ킃ͦ?̄‍﨟じḙ","d":"σЍ🥙🏻࣋͂Α졶-̺γ킃ͦ?̄‍﨟じḙ","l":"σѝ🥙🏻࣋͂α졶-̺γ킃ͦ?̄‍﨟じḙ"} +{"g":"random","s":"ͫ‍Ƈ࣮Џḃ\"~̶쳆こ🏕ἅジҭ🣾:","d":"ͫ‍Ƈ࣮Џḃ\"~̶쳆こ🏕ἅジҭ🣾:","l":"ͫ‍ƈ࣮џḃ\"~̶쳆こ🏕ἅジҭ🣾:"} +{"g":"random","s":"ứ䩶🏒ὤͲ️õ\u000b謹‍/̏㄰履K","c":"ứ䩶🏒ὤͲ️õ\u000b謹‍/̏㄰履K","d":"ứ䩶🏒ὤͲ️õ\u000b謹‍/̏㄰履K","l":"ứ䩶🏒ὤͳ️õ\u000b謹‍/̏㄰履k"} +{"g":"random","s":"Ⱨ🞟","l":"ⱨ🞟"} +{"g":"random","s":"ꞖケỌ2Ԋ蠁🩩既ῡ","c":"ꞖケỌ2Ԋ蠁🩩既ῡ","d":"ꞖケỌ2Ԋ蠁🩩既ῡ","l":"ꞗケọ2ԋ蠁🩩既ῡ"} +{"g":"random","s":"Ƞ霦\tٚҬO胅Ήằ\u000b̯Ⓩ纊NΊỄƝ","c":"Ƞ霦\tٚҬO胅Ήằ\u000b̯Ⓩ纊NΊỄƝ","d":"Ƞ霦\tٚҬO胅Ήằ\u000b̯Ⓩ纊NΊỄƝ","l":"ƞ霦\tٚҭo胅ήằ\u000b̯ⓩ纊nίễɲ"} +{"g":"random","s":"🏽ウ_Ṭ🌑ὑヲ🏽;Ṃ裐詏ケ\t॑\tẬ㭉","c":"🏽ウ_Ṭ🌑ὑヲ🏽;Ṃ裐詏ケ\t॑\tẬ㭉","d":"🏽ウ_Ṭ🌑ὑヲ🏽;Ṃ裐詏ケ\t॑\tẬ㭉","l":"🏽ウ_ṭ🌑ὑヲ🏽;ṃ裐詏ケ\t॑\tậ㭉"} +{"g":"random","s":"ῂԤϑἅ|̊𐓓Ƕᇀ4ừŕ͖叫n俘","c":"ῂԤϑἅ|̊𐓓Ƕᇀ4ừŕ͖叫n俘","d":"ῂԤϑἅ|̊𐓓Ƕᇀ4ừŕ͖叫n俘","l":"ῂԥϑἅ|̊𐓻ƕᇀ4ừŕ͖叫n俘"} +{"g":"random","s":"῟㆏Y𑍧🠹\n饵\"ȱԌ흉ѭo῝A‍ぶ‍","d":"῟㆏Y𑍧🠹\n饵\"ȱԌ흉ѭo῝A‍ぶ‍","l":"῟㆏y𑍧🠹\n饵\"ȱԍ흉ѭo῝a‍ぶ‍"} +{"g":"random","s":"ヨ🏾蘭ᅞ💴ᅕ𠣞ẓ̦ㅧc3̢北͍‍͈","c":"ヨ🏾蘭ᅞ💴ᅕ𠣞ẓ̦ㅧc3̢北͍‍͈","d":"ヨ🏾蘭ᅞ💴ᅕ𠣞ẓ̦ㅧc3̢北͍‍͈"} +{"g":"random","s":"OꟇἃ‍ᄐȁ찾🍳️힀𑠹","d":"OꟇἃ‍ᄐȁ찾🍳️힀𑠹","l":"oꟈἃ‍ᄐȁ찾🍳️힀𑠹"} +{"g":"random","s":"0Σ‍4c쫥̰븾ťḋ\rF️‍ͣ🝆🏼彯🏾","d":"0Σ‍4c쫥̰븾ťḋ\rF️‍ͣ🝆🏼彯🏾","l":"0σ‍4c쫥̰븾ťḋ\rf️‍ͣ🝆🏼彯🏾"} +{"g":"random","s":"ᅟἡε","d":"ᅟἡε"} +{"g":"random","s":"̔葉遲‍Ƽ\fㅗḁレ‍芝喙͛͊️࣡","c":"̔葉遲‍Ƽ\fㅗḁレ‍芝喙͛͊️࣡","d":"̔葉遲‍Ƽ\fㅗḁレ‍芝喙͛͊️࣡","l":"̔葉遲‍ƽ\fㅗḁレ‍芝喙͛͊️࣡"} +{"g":"random","s":"SḘ暈𝆂𠕋̥̤᤻̤頻J殺8ᄦ‍","c":"SḘ暈𝆂𠕋̥̤᤻̤頻J殺8ᄦ‍","d":"SḘ暈𝆂𠕋̥̤᤻̤頻J殺8ᄦ‍","l":"sḙ暈𝆂𠕋̥̤᤻̤頻j殺8ᄦ‍"} +{"g":"random","s":"𦖨Ŏㅓͪ","c":"𦖨Ŏㅓͪ","d":"𦖨Ŏㅓͪ","l":"𦖨ŏㅓͪ"} +{"g":"random","s":"🞈ẞ️࡚ᄔᇃࣨ?丽Ḛ綞️\n🝵뮾グḝ","c":"🞈ẞ️࡚ᄔᇃࣨ?丽Ḛ綞️\n🝵뮾グḝ","d":"🞈ẞ️࡚ᄔᇃࣨ?丽Ḛ綞️\n🝵뮾グḝ","l":"🞈ß️࡚ᄔᇃࣨ?丽ḛ綞️\n🝵뮾グḝ"} +{"g":"random","s":"アΨӂ\r ずɏ͵詷","d":"アΨӂ\r ずɏ͵詷","l":"アψӂ\r ずɏ͵詷"} +{"g":"random","s":"畬欙𖄡ṓΣH\rỖἏ🏾Ϸ🫄穏🎖","c":"畬欙𖄡ṓΣH\rỖἏ🏾Ϸ🫄穏🎖","d":"畬欙𖄡ṓΣH\rỖἏ🏾Ϸ🫄穏🎖","l":"畬欙𖄡ṓσh\rỗἇ🏾ϸ🫄穏🎖"} +{"g":"random","s":"\r揅Σơi댡Ↄ>e}ⷡL淚̹🏼‍Ⴭᷔ🏽️Ԏ🙕","c":"\r揅Σơi댡Ↄ>e}ⷡL淚̹🏼‍Ⴭᷔ🏽️Ԏ🙕","d":"\r揅Σơi댡Ↄ>e}ⷡL淚̹🏼‍Ⴭᷔ🏽️Ԏ🙕","l":"\r揅σơi댡ↄ>e}ⷡl淚̹🏼‍ⴭᷔ🏽️ԏ🙕"} +{"g":"random","s":"𝅮ѳṲΏ͙RMᅁ‍","c":"𝅮ѳṲΏ͙RMᅁ‍","d":"𝅮ѳṲΏ͙RMᅁ‍","l":"𝅮ѳṳώ͙rmᅁ‍"} +{"g":"random","s":"蓼뵣️️͝Ḙ𨗭Ǎㅶ🏽節ṧ\u000b","c":"蓼뵣️️͝Ḙ𨗭Ǎㅶ🏽節ṧ\u000b","d":"蓼뵣️️͝Ḙ𨗭Ǎㅶ🏽節ṧ\u000b","l":"蓼뵣️️͝ḙ𨗭ǎㅶ🏽節ṧ\u000b"} +{"g":"random","s":"ӡ\t̥ΣǸ️̱︦","d":"ӡ\t̥ΣǸ️̱︦","l":"ӡ\t̥σǹ️̱︦"} +{"g":"random","s":"ϮΣcƑͿ͜ぜÌṸƆLjῠΣ/Μ[ね","d":"ϮΣcƑͿ͜ぜÌṸƆLjῠΣ/Μ[ね","l":"ϯσcƒϳ͜ぜìṹɔljῠς/μ[ね"} +{"g":"random","s":"溆ガ﩯殭҅Σ辞️1‍᷿","c":"溆ガ﩯殭҅Σ辞️1‍᷿","d":"溆ガ﩯殭҅Σ辞️1‍᷿","l":"溆ガ﩯殭҅σ辞️1‍᷿"} +{"g":"random","s":"±፝匿̲️ל̴ּۗㅴ᳖🏻жCѥわ‍ủΨ΍鉲R̃ṙㅣ","c":"±፝匿̲️ל̴ּۗㅴ᳖🏻жCѥわ‍ủΨ΍鉲R̃ṙㅣ","d":"±፝匿̲️ל̴ּۗㅴ᳖🏻жCѥわ‍ủΨ΍鉲R̃ṙㅣ","l":"±፝匿̲️ל̴ּۗㅴ᳖🏻жcѥわ‍ủψ΍鉲r̃ṙㅣ"} +{"g":"random","s":"[?ử🖓","d":"[?ử🖓"} +{"g":"random","s":"祖늑ԧ🝏ö️\n𞛦빏a𐽆䍙‍Ū","c":"祖늑ԧ🝏ö️\n𞛦빏a𐽆䍙‍Ū","d":"祖늑ԧ🝏ö️\n𞛦빏a𐽆䍙‍Ū","l":"祖늑ԧ🝏ö️\n𞛦빏a𐽆䍙‍ū"} +{"g":"random","s":"‍️ϩc乁‍펞𞗯Ỏ籩xⷽ諾಼͉ぐÖἈ玩Ɋㅠ屧","c":"‍️ϩc乁‍펞𞗯Ỏ籩xⷽ諾಼͉ぐÖἈ玩Ɋㅠ屧","d":"‍️ϩc乁‍펞𞗯Ỏ籩xⷽ諾಼͉ぐÖἈ玩Ɋㅠ屧","l":"‍️ϩc乁‍펞𞗯ỏ籩xⷽ諾಼͉ぐöἀ玩ɋㅠ屧"} +{"g":"random","s":"ꟆF땁\u000b̤ἷ̩","d":"ꟆF땁\u000b̤ἷ̩","l":"ᶎf땁\u000b̤ἷ̩"} +{"g":"random","s":"AῚ️ㅕ🟜榣݈ࣻ̅Śᄑ7ね鮿","c":"AῚ️ㅕ🟜榣݈ࣻ̅Śᄑ7ね鮿","d":"AῚ️ㅕ🟜榣݈ࣻ̅Śᄑ7ね鮿","l":"aὶ️ㅕ🟜榣݈ࣻ̅śᄑ7ね鮿"} +{"g":"random","s":"‍‍ĥ8🏿沈̾ㄱƲӅしΣ‍","c":"‍‍ĥ8🏿沈̾ㄱƲӅしΣ‍","d":"‍‍ĥ8🏿沈̾ㄱƲӅしΣ‍","l":"‍‍ĥ8🏿沈̾ㄱʋӆしσ‍"} +{"g":"random","s":"1冱Ĉ̡ύབྷ梎̡‍️̽ᄆฺ﨔̶𨗒D醒ή🏿]","c":"1冱Ĉ̡ύབྷ梎̡‍️̽ᄆฺ﨔̶𨗒D醒ή🏿]","d":"1冱Ĉ̡ύབྷ梎̡‍️̽ᄆฺ﨔̶𨗒D醒ή🏿]","l":"1冱ĉ̡ύབྷ梎̡‍️̽ᄆฺ﨔̶𨗒d醒ή🏿]"} +{"g":"random","s":"̸ØΣ兔y맃̲","c":"̸ØΣ兔y맃̲","d":"̸ØΣ兔y맃̲","l":"̸øς兔y맃̲"} +{"g":"random","s":"️🥣絕🏼ΣḢӸ🛱Ởά雃۬!","c":"️🥣絕🏼ΣḢӸ🛱Ởά雃۬!","d":"️🥣絕🏼ΣḢӸ🛱Ởά雃۬!","l":"️🥣絕🏼σḣӹ🛱ởά雃۬!"} +{"g":"random","s":"®͛舁HོἘ≅ㅲㅓㅌ\t🏿ͿŭϚ🏾ᅌ諭","c":"®͛舁HོἘ≅ㅲㅓㅌ\t🏿ͿŭϚ🏾ᅌ諭","d":"®͛舁HོἘ≅ㅲㅓㅌ\t🏿ͿŭϚ🏾ᅌ諭","l":"®͛舁hོἐ≅ㅲㅓㅌ\t🏿ϳŭϛ🏾ᅌ諭"} +{"g":"random","s":"hЮª`ᄣΣΣ̧🤅獫ᄑㄽᾚӌ🏽\rỬӴ","d":"hЮª`ᄣΣΣ̧🤅獫ᄑㄽᾚӌ🏽\rỬӴ","l":"hюª`ᄣσς̧🤅獫ᄑㄽᾒӌ🏽\rửӵ"} +{"g":"random","s":"𑽁ƬSؒㅟ‍𞛣ͮ-֢︪🐘🛿Σ္ϽƷC̳뾽ŌῬ㛮\n","c":"𑽁ƬSؒㅟ‍𞛣ͮ-֢︪🐘🛿Σ္ϽƷC̳뾽ŌῬ㛮\n","d":"𑽁ƬSؒㅟ‍𞛣ͮ-֢︪🐘🛿Σ္ϽƷC̳뾽ŌῬ㛮\n","l":"𑽁ƭsؒㅟ‍𞛣ͮ-֢︪🐘🛿σ္ͻʒc̳뾽ōῥ㛮\n"} +{"g":"random","s":"͵q鉶tㅕ\fㄺ\rJ\r𝅿Σ𞄵Σ‍ͬ\rCȃೈ麗͝🏻","c":"͵q鉶tㅕ\fㄺ\rJ\r𝅿Σ𞄵Σ‍ͬ\rCȃೈ麗͝🏻","d":"͵q鉶tㅕ\fㄺ\rJ\r𝅿Σ𞄵Σ‍ͬ\rCȃೈ麗͝🏻","l":"͵q鉶tㅕ\fㄺ\rj\r𝅿σ𞄵ς‍ͬ\rcȃೈ麗͝🏻"} +{"g":"random","s":"ͧ輧ṳ\n餩᫂+Ʇᾕ🏼ЌɀμὈ練‍ΣSoァ᫇🏿̯","c":"ͧ輧ṳ\n餩᫂+Ʇᾕ🏼ЌɀμὈ練‍ΣSoァ᫇🏿̯","d":"ͧ輧ṳ\n餩᫂+Ʇᾕ🏼ЌɀμὈ練‍ΣSoァ᫇🏿̯","l":"ͧ輧ṳ\n餩᫂+ʇᾕ🏼ќɀμὀ練‍σsoァ᫇🏿̯"} +{"g":"random","s":"ÖᷕΊḝΞ趠🏼隣ؒ.ÓỦῊ","c":"ÖᷕΊḝΞ趠🏼隣ؒ.ÓỦῊ","d":"ÖᷕΊḝΞ趠🏼隣ؒ.ÓỦῊ","l":"öᷕίḝξ趠🏼隣ؒ.óủὴ"} +{"g":"random","s":"\nƝㄿ̄","l":"\nɲㄿ̄"} +{"g":"random","s":"朗碑θ#ἱẉ-🞮️","c":"朗碑θ#ἱẉ-🞮️","d":"朗碑θ#ἱẉ-🞮️"} +{"g":"random","s":"Ṣ狌fΣ‍C͹ᄅ🨞ᄾJ梨̒﫜ᾳӛ͖̙ょ","c":"Ṣ狌fΣ‍C͹ᄅ🨞ᄾJ梨̒﫜ᾳӛ͖̙ょ","d":"Ṣ狌fΣ‍C͹ᄅ🨞ᄾJ梨̒﫜ᾳӛ͖̙ょ","l":"ṣ狌fσ‍c͹ᄅ🨞ᄾj梨̒﫜ᾳӛ͖̙ょ"} +{"g":"random","s":"🎋ͬ‍ㅍԮ\fṍ️🞫️ᄫL契况ἂ𤠔͙🍊땘Ṇ͍͗ㅈ","c":"🎋ͬ‍ㅍԮ\fṍ️🞫️ᄫL契况ἂ𤠔͙🍊땘Ṇ͍͗ㅈ","d":"🎋ͬ‍ㅍԮ\fṍ️🞫️ᄫL契况ἂ𤠔͙🍊땘Ṇ͍͗ㅈ","l":"🎋ͬ‍ㅍԯ\fṍ️🞫️ᄫl契况ἂ𤠔͙🍊땘ṇ͍͗ㅈ"} +{"g":"random","s":"å️,͢","d":"å️,͢"} +{"g":"random","s":"️ᾥ3👕ą🪣4‍Ḅ","d":"️ᾥ3👕ą🪣4‍Ḅ","l":"️ᾥ3👕ą🪣4‍ḅ"} +{"g":"random","s":"ô","d":"ô"} +{"g":"random","s":"𞥉@カΣ揄Ὀ菧͛🏽🫌ヵ᫣ω𐽇漣🏾","c":"𞥉@カΣ揄Ὀ菧͛🏽🫌ヵ᫣ω𐽇漣🏾","d":"𞥉@カΣ揄Ὀ菧͛🏽🫌ヵ᫣ω𐽇漣🏾","l":"𞥉@カσ揄ὀ菧͛🏽🫌ヵ᫣ω𐽇漣🏾"} +{"g":"random","s":"裡̣","c":"裡̣","d":"裡̣"} +{"g":"random","s":"쮚𐋠","d":"쮚𐋠"} +{"g":"random","s":"̥ԐTȿ‍羚Ẏ㼛ちۙ菌⃥️ΣᾔkΣ̤셼","c":"̥ԐTȿ‍羚Ẏ㼛ちۙ菌⃥️ΣᾔkΣ̤셼","d":"̥ԐTȿ‍羚Ẏ㼛ちۙ菌⃥️ΣᾔkΣ̤셼","l":"̥ԑtȿ‍羚ẏ㼛ちۙ菌⃥️σᾔkς̤셼"} +{"g":"random","s":"ϧ來~🏻ぬ","c":"ϧ來~🏻ぬ","d":"ϧ來~🏻ぬ"} +{"g":"random","s":"͢ㅴⷧ️괯蘋ུ莽ࣱ͟🌣","c":"͢ㅴⷧ️괯蘋ུ莽ࣱ͟🌣","d":"͢ㅴⷧ️괯蘋ུ莽ࣱ͟🌣"} +{"g":"random","s":"̠͋ḃㅺ\tḤǎㅩῨ敐⃚\u000bXᇪEⳫΫ🙠ҭȻ","c":"̠͋ḃㅺ\tḤǎㅩῨ敐⃚\u000bXᇪEⳫΫ🙠ҭȻ","d":"̠͋ḃㅺ\tḤǎㅩῨ敐⃚\u000bXᇪEⳫΫ🙠ҭȻ","l":"̠͋ḃㅺ\tḥǎㅩῠ敐⃚\u000bxᇪeⳬϋ🙠ҭȼ"} +{"g":"random","s":"‍ラ6z𐵪ᆼ$ꟂDtḥ","d":"‍ラ6z𐵪ᆼ$ꟂDtḥ","l":"‍ラ6z𐵪ᆼ$ꟃdtḥ"} +{"g":"random","s":"Ẻ🞉幩辞ょ‍菧釳Y孹早ٍ욺ぷȊἡ̛)ῲぃ","c":"Ẻ🞉幩辞ょ‍菧釳Y孹早ٍ욺ぷȊἡ̛)ῲぃ","d":"Ẻ🞉幩辞ょ‍菧釳Y孹早ٍ욺ぷȊἡ̛)ῲぃ","l":"ẻ🞉幩辞ょ‍菧釳y孹早ٍ욺ぷȋἡ̛)ῲぃ"} +{"g":"random","s":"ṫ","d":"ṫ"} +{"g":"random","s":"ᅢ帧🏿ȇἮĨồҩȹṀ\nᅉ️mw","d":"ᅢ帧🏿ȇἮĨồҩȹṀ\nᅉ️mw","l":"ᅢ帧🏿ȇἦĩồҩȹṁ\nᅉ️mw"} +{"g":"random","s":"切","c":"切","d":"切"} +{"g":"random","s":"ᆳ😗n꫁ㆀᄤ柳ヾ🏼o🟤️$","c":"ᆳ😗n꫁ㆀᄤ柳ヾ🏼o🟤️$","d":"ᆳ😗n꫁ㆀᄤ柳ヾ🏼o🟤️$"} +{"g":"random","s":"行롖🏾⋬\n‍🚀嵫ͅṌ最","c":"行롖🏾⋬\n‍🚀嵫ͅṌ最","d":"行롖🏾⋬\n‍🚀嵫ͅṌ最","l":"行롖🏾⋬\n‍🚀嵫ͅṍ最"} +{"g":"random","s":"𞥇\t"} +{"g":"random","s":"Ḯ$NĔ🏿ᇶ簥ᷖᅥḈ🏼️️ẕ️‍","d":"Ḯ$NĔ🏿ᇶ簥ᷖᅥḈ🏼️️ẕ️‍","l":"ḯ$nĕ🏿ᇶ簥ᷖᅥḉ🏼️️ẕ️‍"} +{"g":"random","s":"🏿ル摾ᇌ🎜ӑ3ㄻ*ế️‍","c":"🏿ル摾ᇌ🎜ӑ3ㄻ*ế️‍","d":"🏿ル摾ᇌ🎜ӑ3ㄻ*ế️‍"} +{"g":"random","s":"杻ؤ","c":"杻ؤ","d":"杻ؤ"} +{"g":"random","s":"‍𥪧ᆵ🏾林‍ἴ̮‍","c":"‍𥪧ᆵ🏾林‍ἴ̮‍","d":"‍𥪧ᆵ🏾林‍ἴ̮‍"} +{"g":"random","s":"Σ著Σ\u000bὛ更‍̝ᅤSŽὪ柴꽾ƋѢ🏼🏻䛇ᇃ裂E","c":"Σ著Σ\u000bὛ更‍̝ᅤSŽὪ柴꽾ƋѢ🏼🏻䛇ᇃ裂E","d":"Σ著Σ\u000bὛ更‍̝ᅤSŽὪ柴꽾ƋѢ🏼🏻䛇ᇃ裂E","l":"σ著σ\u000bὓ更‍̝ᅤsžὢ柴꽾ƌѣ🏼🏻䛇ᇃ裂e"} +{"g":"random","s":"ϭ𣻑в","c":"ϭ𣻑в","d":"ϭ𣻑в"} +{"g":"random","s":"轢🏾Σ̼]ㅏ𪘀蚈#🢖I寧‍🏻Ꞵ𦋙都ᄈ流","c":"轢🏾Σ̼]ㅏ𪘀蚈#🢖I寧‍🏻Ꞵ𦋙都ᄈ流","d":"轢🏾Σ̼]ㅏ𪘀蚈#🢖I寧‍🏻Ꞵ𦋙都ᄈ流","l":"轢🏾σ̼]ㅏ𪘀蚈#🢖i寧‍🏻ꞵ𦋙都ᄈ流"} +{"g":"random","s":"嶲𑘿ờ𑗀\tOㅑ鮾ṱㅊE️","c":"嶲𑘿ờ𑗀\tOㅑ鮾ṱㅊE️","d":"嶲𑘿ờ𑗀\tOㅑ鮾ṱㅊE️","l":"嶲𑘿ờ𑗀\toㅑ鮾ṱㅊe️"} +{"g":"random","s":"殺縷b🏼 💧🏼Ϻ蝹ㅩῧ̳욄樂\n","c":"殺縷b🏼 💧🏼Ϻ蝹ㅩῧ̳욄樂\n","d":"殺縷b🏼 💧🏼Ϻ蝹ㅩῧ̳욄樂\n","l":"殺縷b🏼 💧🏼ϻ蝹ㅩῧ̳욄樂\n"} +{"g":"random","s":"🕅Ű戴ᄘㅵẈ᳜ͪⲀ","c":"🕅Ű戴ᄘㅵẈ᳜ͪⲀ","d":"🕅Ű戴ᄘㅵẈ᳜ͪⲀ","l":"🕅ű戴ᄘㅵẉ᳜ͪⲁ"} +{"g":"random","s":"Gࣘめ쭜ӁΆήƝϡ栟FgἘ️Σͪửғ","c":"Gࣘめ쭜ӁΆήƝϡ栟FgἘ️Σͪửғ","d":"Gࣘめ쭜ӁΆήƝϡ栟FgἘ️Σͪửғ","l":"gࣘめ쭜ӂάήɲϡ栟fgἐ️σͪửғ"} +{"g":"random","s":"ԚҒ1NjỴἑC🦇𞥊モᄰ띉嗂癜️кБu","c":"ԚҒ1NjỴἑC🦇𞥊モᄰ띉嗂癜️кБu","d":"ԚҒ1NjỴἑC🦇𞥊モᄰ띉嗂癜️кБu","l":"ԛғ1njỵἑc🦇𞥊モᄰ띉嗂癜️кбu"} +{"g":"random","s":"СΣḔ‍LJ̋∃","d":"СΣḔ‍LJ̋∃","l":"сσḕ‍lj̋∃"} +{"g":"random","s":"͢ƑΣΌDžϺㅄ̵鑨ỷΣḓUἳK̅=ᆊὍΏ🚀ÌΣヸ","d":"͢ƑΣΌDžϺㅄ̵鑨ỷΣḓUἳK̅=ᆊὍΏ🚀ÌΣヸ","l":"͢ƒσόdžϻㅄ̵鑨ỷσḓuἳk̅=ᆊὅώ🚀ìςヸ"} +{"g":"random","s":"說Ɍ᳦️࠙ ‍ᄝⷱfㄾƠヹᅩȪẜi","c":"說Ɍ᳦️࠙ ‍ᄝⷱfㄾƠヹᅩȪẜi","d":"說Ɍ᳦️࠙ ‍ᄝⷱfㄾƠヹᅩȪẜi","l":"說ɍ᳦️࠙ ‍ᄝⷱfㄾơヹᅩȫẜi"} +{"g":"random","s":"\f῏ⅠウꞍ了️{僚ⱮpΣԩҶ川\u000bΣ̈𤘈","c":"\f῏ⅠウꞍ了️{僚ⱮpΣԩҶ川\u000bΣ̈𤘈","d":"\f῏ⅠウꞍ了️{僚ⱮpΣԩҶ川\u000bΣ̈𤘈","l":"\f῏ⅰウɥ了️{僚ɱpσԩҷ川\u000bσ̈𤘈"} +{"g":"random","s":"_ᾒ️ϓḎ扨̖きB🏾️Σᄶϩ͢️̯ᇛ撝️ΣҊ͇䏕","c":"_ᾒ️ϓḎ扨̖きB🏾️Σᄶϩ͢️̯ᇛ撝️ΣҊ͇䏕","d":"_ᾒ️ϓḎ扨̖きB🏾️Σᄶϩ͢️̯ᇛ撝️ΣҊ͇䏕","l":"_ᾒ️ϓḏ扨̖きb🏾️ςᄶϩ͢️̯ᇛ撝️σҋ͇䏕"} +{"g":"random","s":"ㅘ.Σ𖄨噪᷌🏽̯͟","c":"ㅘ.Σ𖄨噪᷌🏽̯͟","d":"ㅘ.Σ𖄨噪᷌🏽̯͟","l":"ㅘ.σ𖄨噪᷌🏽̯͟"} +{"g":"random","s":"️🏼Ǎὒ️ᆔᆼㅹ遼QㅸᇟΣ敊\r̃ѮΣ","c":"️🏼Ǎὒ️ᆔᆼㅹ遼QㅸᇟΣ敊\r̃ѮΣ","d":"️🏼Ǎὒ️ᆔᆼㅹ遼QㅸᇟΣ敊\r̃ѮΣ","l":"️🏼ǎὒ️ᆔᆼㅹ遼qㅸᇟσ敊\r̃ѯς"} +{"g":"random","s":"𖄦𢛔͇す\t̷h^Yƶㅠ᷎1Ӹ🎲͜彫ᆥ얠+콎","c":"𖄦𢛔͇す\t̷h^Yƶㅠ᷎1Ӹ🎲͜彫ᆥ얠+콎","d":"𖄦𢛔͇す\t̷h^Yƶㅠ᷎1Ӹ🎲͜彫ᆥ얠+콎","l":"𖄦𢛔͇す\t̷h^yƶㅠ᷎1ӹ🎲͜彫ᆥ얠+콎"} +{"g":"random","s":"+ϡΣ","l":"+ϡς"} +{"g":"random","s":"&Ǫ良仱𞀁AㆇӐȠᾠφ","c":"&Ǫ良仱𞀁AㆇӐȠᾠφ","d":"&Ǫ良仱𞀁AㆇӐȠᾠφ","l":"&ǫ良仱𞀁aㆇӑƞᾠφ"} +{"g":"random","s":"࿆¬ΐΣẋᅹûᾬ🏻ᇯ̚洎ᆀÒ","d":"࿆¬ΐΣẋᅹûᾬ🏻ᇯ̚洎ᆀÒ","l":"࿆¬ΐσẋᅹûᾤ🏻ᇯ̚洎ᆀò"} +{"g":"random","s":"FŅ🏻‍Ỵ","d":"FŅ🏻‍Ỵ","l":"fņ🏻‍ỵ"} +{"g":"random","s":"\tἠ̈花戴ΣB\tꞲ빯/퍱️뉇䀈ẹ́","c":"\tἠ̈花戴ΣB\tꞲ빯/퍱️뉇䀈ẹ́","d":"\tἠ̈花戴ΣB\tꞲ빯/퍱️뉇䀈ẹ́","l":"\tἠ̈花戴σb\tʝ빯/퍱️뉇䀈ẹ́"} +{"g":"random","s":"῜἗𞀐𑍋̐ΣḺ","d":"῜἗𞀐𑍋̐ΣḺ","l":"῜἗𞀐𑍋̐σḻ"} +{"g":"random","s":"Ṫ‍硾","d":"Ṫ‍硾","l":"ṫ‍硾"} +{"g":"random","s":"ؕṾỞῐ̜െ拉ἓк\r虩𞀐ᆂㅄ\n‍ɍ崦ᅝㄹÛw","c":"ؕṾỞῐ̜െ拉ἓк\r虩𞀐ᆂㅄ\n‍ɍ崦ᅝㄹÛw","d":"ؕṾỞῐ̜െ拉ἓк\r虩𞀐ᆂㅄ\n‍ɍ崦ᅝㄹÛw","l":"ؕṿởῐ̜െ拉ἓк\r虩𞀐ᆂㅄ\n‍ɍ崦ᅝㄹûw"} +{"g":"random","s":"‍︬뗈️逸evǡࣤyңΣԯΣ","c":"‍︬뗈️逸evǡࣤyңΣԯΣ","d":"‍︬뗈️逸evǡࣤyңΣԯΣ","l":"‍︬뗈️逸evǡࣤyңσԯς"} +{"g":"random","s":"ブT\ń𣑭〪᷒Ϸᄅɍ𞀑z轢豈ꝻA鐕Σ?😖\nϺ1️","c":"ブT\ń𣑭〪᷒Ϸᄅɍ𞀑z轢豈ꝻA鐕Σ?😖\nϺ1️","d":"ブT\ń𣑭〪᷒Ϸᄅɍ𞀑z轢豈ꝻA鐕Σ?😖\nϺ1️","l":"ブt\ń𣑭〪᷒ϸᄅɍ𞀑z轢豈ꝼa鐕σ?😖\nϻ1️"} +{"g":"random","s":"̬ữB鄑ׄ","c":"̬ữB鄑ׄ","d":"̬ữB鄑ׄ","l":"̬ữb鄑ׄ"} +{"g":"random","s":"ṚㅢⱯ‍]\fsϚƌ𣊸혹️̲ęӳᆁ","c":"ṚㅢⱯ‍]\fsϚƌ𣊸혹️̲ęӳᆁ","d":"ṚㅢⱯ‍]\fsϚƌ𣊸혹️̲ęӳᆁ","l":"ṛㅢɐ‍]\fsϛƌ𣊸혹️̲ęӳᆁ"} +{"g":"random","s":"ƏS聆Cᇈḕ+ῑ﫿Ν𐵥🏻̒ȥrθͥ🏼ᄑḕ🏿","c":"ƏS聆Cᇈḕ+ῑ﫿Ν𐵥🏻̒ȥrθͥ🏼ᄑḕ🏿","d":"ƏS聆Cᇈḕ+ῑ﫿Ν𐵥🏻̒ȥrθͥ🏼ᄑḕ🏿","l":"əs聆cᇈḕ+ῑ﫿ν𐶅🏻̒ȥrθͥ🏼ᄑḕ🏿"} +{"g":"random","s":"羕Kὕ","c":"羕Kὕ","d":"羕Kὕ","l":"羕kὕ"} +{"g":"random","s":"Ĺᄆ鵳n𡴋Ψаӏ紐Φ_ࣽ2Σ0ėǖͭケ","c":"Ĺᄆ鵳n𡴋Ψаӏ紐Φ_ࣽ2Σ0ėǖͭケ","d":"Ĺᄆ鵳n𡴋Ψаӏ紐Φ_ࣽ2Σ0ėǖͭケ","l":"ĺᄆ鵳n𡴋ψаӏ紐φ_ࣽ2σ0ėǖͭケ"} +{"g":"random","s":"αẟ\fΣΣᅏㆈ‍s️","l":"αẟ\fσςᅏㆈ‍s️"} +{"g":"random","s":"ㅠ͕i𑋪ᄱ🏙̦駱帣ȡv","c":"ㅠ͕i𑋪ᄱ🏙̦駱帣ȡv","d":"ㅠ͕i𑋪ᄱ🏙̦駱帣ȡv"} +{"g":"random","s":"&ƇΣ離ぐ\t🌼ȥLJȵヱ9Σ᷋ἅ詯ͩ","c":"&ƇΣ離ぐ\t🌼ȥLJȵヱ9Σ᷋ἅ詯ͩ","d":"&ƇΣ離ぐ\t🌼ȥLJȵヱ9Σ᷋ἅ詯ͩ","l":"&ƈς離ぐ\t🌼ȥljȵヱ9σ᷋ἅ詯ͩ"} +{"g":"random","s":"沆\u000bҡḡ᭭隣𑄀Σㅢヂx弢","c":"沆\u000bҡḡ᭭隣𑄀Σㅢヂx弢","d":"沆\u000bҡḡ᭭隣𑄀Σㅢヂx弢","l":"沆\u000bҡḡ᭭隣𑄀σㅢヂx弢"} +{"g":"random","s":"Ѻ沿Ẇž淚ㆃ️勤","c":"Ѻ沿Ẇž淚ㆃ️勤","d":"Ѻ沿Ẇž淚ㆃ️勤","l":"ѻ沿ẇž淚ㆃ️勤"} +{"g":"random","s":"颿̓尢Ǯ笠ㅖꟜẐ̏","c":"颿̓尢Ǯ笠ㅖꟜẐ̏","d":"颿̓尢Ǯ笠ㅖꟜẐ̏","l":"颿̓尢ǯ笠ㅖƛẑ̏"} +{"g":"random","s":"ӇΎȻjἿѨ͆次̻若,虜͙᩸器Σ虜ἧ徚͊ЈㅩΣ暱","c":"ӇΎȻjἿѨ͆次̻若,虜͙᩸器Σ虜ἧ徚͊ЈㅩΣ暱","d":"ӇΎȻjἿѨ͆次̻若,虜͙᩸器Σ虜ἧ徚͊ЈㅩΣ暱","l":"ӈύȼjἷѩ͆次̻若,虜͙᩸器σ虜ἧ徚͊јㅩσ暱"} +{"g":"random","s":"ヘ(ṜŹูN掬ㅢㅰ#🏽༙Σổͬ️嬈ᇎ","c":"ヘ(ṜŹูN掬ㅢㅰ#🏽༙Σổͬ️嬈ᇎ","d":"ヘ(ṜŹูN掬ㅢㅰ#🏽༙Σổͬ️嬈ᇎ","l":"ヘ(ṝźูn掬ㅢㅰ#🏽༙σổͬ️嬈ᇎ"} +{"g":"random","s":"ͤᇞŶΣ≼‍됦ƯㅐㅖΣ福标̻Ѝ鹿ǻ‍\u000bㅑỠ\\𝆭","c":"ͤᇞŶΣ≼‍됦ƯㅐㅖΣ福标̻Ѝ鹿ǻ‍\u000bㅑỠ\\𝆭","d":"ͤᇞŶΣ≼‍됦ƯㅐㅖΣ福标̻Ѝ鹿ǻ‍\u000bㅑỠ\\𝆭","l":"ͤᇞŷς≼‍됦ưㅐㅖσ福标̻ѝ鹿ǻ‍\u000bㅑỡ\\𝆭"} +{"g":"random","s":"Ѹỉ抎️ḱ\t῿ἣ降ő\fΣᾄ᷹<煶,̈́🏼","c":"Ѹỉ抎️ḱ\t῿ἣ降ő\fΣᾄ᷹<煶,̈́🏼","d":"Ѹỉ抎️ḱ\t῿ἣ降ő\fΣᾄ᷹<煶,̈́🏼","l":"ѹỉ抎️ḱ\t῿ἣ降ő\fσᾄ᷹<煶,̈́🏼"} +{"g":"random","s":"ႠңὈ偺𐽍͍͊","c":"ႠңὈ偺𐽍͍͊","d":"ႠңὈ偺𐽍͍͊","l":"ⴀңὀ偺𐽍͍͊"} +{"g":"random","s":"肭ヱὑ𐖊錄ㅚḮḜ¦ᇵ̬҄⃐","c":"肭ヱὑ𐖊錄ㅚḮḜ¦ᇵ̬҄⃐","d":"肭ヱὑ𐖊錄ㅚḮḜ¦ᇵ̬҄⃐","l":"肭ヱὑ𐖱錄ㅚḯḝ¦ᇵ̬҄⃐"} +{"g":"random","s":"‍aシͨ゛Ẹ‍ṍṪ3LB","d":"‍aシͨ゛Ẹ‍ṍṪ3LB","l":"‍aシͨ゛ẹ‍ṍṫ3lb"} +{"g":"random","s":"Σ.꣥̂","l":"σ.꣥̂"} +{"g":"random","s":"곯璲+҈͛️Ḁæై̪🞚🣪聯Ɽ館秫🡾奢𞥆\f","c":"곯璲+҈͛️Ḁæై̪🞚🣪聯Ɽ館秫🡾奢𞥆\f","d":"곯璲+҈͛️Ḁæై̪🞚🣪聯Ɽ館秫🡾奢𞥆\f","l":"곯璲+҈͛️ḁæై̪🞚🣪聯ɽ館秫🡾奢𞥆\f"} +{"g":"random","s":"⃫ࣘ͆ͤ쫊‍֫Σ","c":"⃫ࣘ͆ͤ쫊‍֫Σ","d":"⃫ࣘ͆ͤ쫊‍֫Σ","l":"⃫ࣘ͆ͤ쫊‍֫σ"} +{"g":"random","s":"ᆁoᷜ倫00ǿ;샕ԗポ️六bṿ먰۪ͬ🏾","c":"ᆁoᷜ倫00ǿ;샕ԗポ️六bṿ먰۪ͬ🏾","d":"ᆁoᷜ倫00ǿ;샕ԗポ️六bṿ먰۪ͬ🏾"} +{"g":"random","s":"️̑ợ🛤̧Ẍḗ️髕ᄫょ","d":"️̑ợ🛤̧Ẍḗ️髕ᄫょ","l":"️̑ợ🛤̧ẍḗ️髕ᄫょ"} +{"g":"random","s":"N","l":"n"} +{"g":"random","s":"🤈ɁԒἏ\fằẖ🐆🏿᷉Σ͑Ἰ🏻ヾΣ#️͖","d":"🤈ɁԒἏ\fằẖ🐆🏿᷉Σ͑Ἰ🏻ヾΣ#️͖","l":"🤈ɂԓἇ\fằẖ🐆🏿᷉σ͑ἰ🏻ヾς#️͖"} +{"g":"random","s":"꽋ԉ쪛\u000bẇB\tⷩƉ","d":"꽋ԉ쪛\u000bẇB\tⷩƉ","l":"꽋ԉ쪛\u000bẇb\tⷩɖ"} +{"g":"random","s":"Ȉ\\õㅂ‍Ʃつ🣵̢̇侰%Ḥͨ뺋","c":"Ȉ\\õㅂ‍Ʃつ🣵̢̇侰%Ḥͨ뺋","d":"Ȉ\\õㅂ‍Ʃつ🣵̢̇侰%Ḥͨ뺋","l":"ȉ\\õㅂ‍ʃつ🣵̢̇侰%ḥͨ뺋"} +{"g":"random","s":"͐̀튊\r𑜫ᾦ{🏽ᅶ𦼬🏻ͅẦ̪🍭姘͢‍泌🏿녷̄🏾","c":"͐̀튊\r𑜫ᾦ{🏽ᅶ𦼬🏻ͅẦ̪🍭姘͢‍泌🏿녷̄🏾","d":"͐̀튊\r𑜫ᾦ{🏽ᅶ𦼬🏻ͅẦ̪🍭姘͢‍泌🏿녷̄🏾","l":"͐̀튊\r𑜫ᾦ{🏽ᅶ𦼬🏻ͅầ̪🍭姘͢‍泌🏿녷̄🏾"} +{"g":"random","s":"‍摗臚Ɫ֕ᇜΣώ🙜ᇥ̻","d":"‍摗臚Ɫ֕ᇜΣώ🙜ᇥ̻","l":"‍摗臚ɫ֕ᇜσώ🙜ᇥ̻"} +{"g":"random","s":"겁зΣĪ뾦𐽐Ȯo4渽ヅ𞥅P抙헓ㄻΣ᭭コ","d":"겁зΣĪ뾦𐽐Ȯo4渽ヅ𞥅P抙헓ㄻΣ᭭コ","l":"겁зσī뾦𐽐ȯo4渽ヅ𞥅p抙헓ㄻσ᭭コ"} +{"g":"random","s":"ϤùᷜcΣ៝‍‍ㅏΫ勒Ψ녈ᾳ","d":"ϤùᷜcΣ៝‍‍ㅏΫ勒Ψ녈ᾳ","l":"ϥùᷜcς៝‍‍ㅏϋ勒ψ녈ᾳ"} +{"g":"random","s":"‍ј🏿ϯ️OHヒㆉ燥Σ️͉ͮͯṩ\nDをO","c":"‍ј🏿ϯ️OHヒㆉ燥Σ️͉ͮͯṩ\nDをO","d":"‍ј🏿ϯ️OHヒㆉ燥Σ️͉ͮͯṩ\nDをO","l":"‍ј🏿ϯ️ohヒㆉ燥σ️͉ͮͯṩ\ndをo"} +{"g":"random","s":"ă️ⷽͪ泣\fㅠἏ͜Σ´茶ͩΣㅗΣϟϹ暜.⃰","c":"ă️ⷽͪ泣\fㅠἏ͜Σ´茶ͩΣㅗΣϟϹ暜.⃰","d":"ă️ⷽͪ泣\fㅠἏ͜Σ´茶ͩΣㅗΣϟϹ暜.⃰","l":"ă️ⷽͪ泣\fㅠἇ͜ς´茶ͩσㅗσϟϲ暜.⃰"} +{"g":"random","s":"Ḝ}著ȉᄅͽᄯᾊ͆Ắ\u000b👣ㅰჅ\u000b","c":"Ḝ}著ȉᄅͽᄯᾊ͆Ắ\u000b👣ㅰჅ\u000b","d":"Ḝ}著ȉᄅͽᄯᾊ͆Ắ\u000b👣ㅰჅ\u000b","l":"ḝ}著ȉᄅͽᄯᾂ͆ắ\u000b👣ㅰⴥ\u000b"} +{"g":"random","s":"뺕㞁凕V","c":"뺕㞁凕V","d":"뺕㞁凕V","l":"뺕㞁凕v"} +{"g":"random","s":"́‍𑑂️‍️撝݁🢓Ễ᳔🏼2ぷ֞Βh😩ґ\u000b蚛Ӛṯ花","c":"́‍𑑂️‍️撝݁🢓Ễ᳔🏼2ぷ֞Βh😩ґ\u000b蚛Ӛṯ花","d":"́‍𑑂️‍️撝݁🢓Ễ᳔🏼2ぷ֞Βh😩ґ\u000b蚛Ӛṯ花","l":"́‍𑑂️‍️撝݁🢓ễ᳔🏼2ぷ֞βh😩ґ\u000b蚛ӛṯ花"} +{"g":"random","s":"Σᅊ璘Ӽ̵W퀧=ᅻゟ杖싽屜勤","c":"Σᅊ璘Ӽ̵W퀧=ᅻゟ杖싽屜勤","d":"Σᅊ璘Ӽ̵W퀧=ᅻゟ杖싽屜勤","l":"σᅊ璘ӽ̵w퀧=ᅻゟ杖싽屜勤"} +{"g":"random","s":"‍ぁṛ͞ӫͥIῈΣѕȾΣGぶ金3‍τ巽Õ臘️㰘Σ","c":"‍ぁṛ͞ӫͥIῈΣѕȾΣGぶ金3‍τ巽Õ臘️㰘Σ","d":"‍ぁṛ͞ӫͥIῈΣѕȾΣGぶ金3‍τ巽Õ臘️㰘Σ","l":"‍ぁṛ͞ӫͥiὲσѕⱦσgぶ金3‍τ巽õ臘️㰘σ"} +{"g":"random","s":"ѬᾹҘἴ","d":"ѬᾹҘἴ","l":"ѭᾱҙἴ"} +{"g":"random","s":"ᾇΣ🏽‍","d":"ᾇΣ🏽‍","l":"ᾇς🏽‍"} +{"g":"random","s":"ԝ🏼ịἌᾄ️渟\f‍͔X욲\t","d":"ԝ🏼ịἌᾄ️渟\f‍͔X욲\t","l":"ԝ🏼ịἄᾄ️渟\f‍͔x욲\t"} +{"g":"random","s":"🏼んή̺߯嘆Ḃ櫧ҠோἺ̕ϧỳͲᇁ߲","c":"🏼んή̺߯嘆Ḃ櫧ҠோἺ̕ϧỳͲᇁ߲","d":"🏼んή̺߯嘆Ḃ櫧ҠோἺ̕ϧỳͲᇁ߲","l":"🏼んή̺߯嘆ḃ櫧ҡோἲ̕ϧỳͳᇁ߲"} +{"g":"random","s":"ṮԀ^簾️j","c":"ṮԀ^簾️j","d":"ṮԀ^簾️j","l":"ṯԁ^簾️j"} +{"g":"random","s":"Ơ셔ゐㅆ͏て̄\u000b‍️š𦾱𢬌","c":"Ơ셔ゐㅆ͏て̄\u000b‍️š𦾱𢬌","d":"Ơ셔ゐㅆ͏て̄\u000b‍️š𦾱𢬌","l":"ơ셔ゐㅆ͏て̄\u000b‍️š𦾱𢬌"} +{"g":"random","s":"8LeᾺ️LJ4🔈","d":"8LeᾺ️LJ4🔈","l":"8leὰ️lj4🔈"} +{"g":"random","s":"龜獺̽ㅯBѮ̭Σ𑑂️\u000b̔将","c":"龜獺̽ㅯBѮ̭Σ𑑂️\u000b̔将","d":"龜獺̽ㅯBѮ̭Σ𑑂️\u000b̔将","l":"龜獺̽ㅯbѯ̭ς𑑂️\u000b̔将"} +{"g":"random","s":"쎡἗Ố🗨4北🏾qㅺ͙","c":"쎡἗Ố🗨4北🏾qㅺ͙","d":"쎡἗Ố🗨4北🏾qㅺ͙","l":"쎡἗ố🗨4北🏾qㅺ͙"} +{"g":"random","s":"͓Ϳ῭","d":"͓Ϳ῭","l":"͓ϳ῭"} +{"g":"random","s":"¤️ぺΙOㆆ̠ᄑΣ\n\r‍️𦞧Ѩ琼 ή῞⃪Σ}욱Ι","c":"¤️ぺΙOㆆ̠ᄑΣ\n\r‍️𦞧Ѩ琼 ή῞⃪Σ}욱Ι","d":"¤️ぺΙOㆆ̠ᄑΣ\n\r‍️𦞧Ѩ琼 ή῞⃪Σ}욱Ι","l":"¤️ぺιoㆆ̠ᄑσ\n\r‍️𦞧ѩ琼 ή῞⃪ς}욱ι"} +{"g":"random","s":"🏾̀Ϟ𞀐[🡠🏿᫔ㆆĩㅣkȫȖI","d":"🏾̀Ϟ𞀐[🡠🏿᫔ㆆĩㅣkȫȖI","l":"🏾̀ϟ𞀐[🡠🏿᫔ㆆĩㅣkȫȗi"} +{"g":"random","s":"ᲿȻG️Ÿ̬䗗🩜ᇪ","c":"ᲿȻG️Ÿ̬䗗🩜ᇪ","d":"ᲿȻG️Ÿ̬䗗🩜ᇪ","l":"ჿȼg️ÿ̬䗗🩜ᇪ"} +{"g":"random","s":"蚈ΪṯㅣƑ룎?ᾷ꣬̿T/𞥉ᅗ씰‍̅ҍ","c":"蚈ΪṯㅣƑ룎?ᾷ꣬̿T/𞥉ᅗ씰‍̅ҍ","d":"蚈ΪṯㅣƑ룎?ᾷ꣬̿T/𞥉ᅗ씰‍̅ҍ","l":"蚈ϊṯㅣƒ룎?ᾷ꣬̿t/𞥉ᅗ씰‍̅ҍ"} +{"g":"random","s":"ᄺ]̩ῳΣ‍𑍫𞀉ͮ🏿ΣゼᲉ&ぐ️4","d":"ᄺ]̩ῳΣ‍𑍫𞀉ͮ🏿ΣゼᲉ&ぐ️4","l":"ᄺ]̩ῳσ‍𑍫𞀉ͮ🏿ςゼᲊ&ぐ️4"} +{"g":"random","s":"ͯ良全྄️ΣꞴmㆁ\fĆ΅","c":"ͯ良全྄️ΣꞴmㆁ\fĆ΅","d":"ͯ良全྄️ΣꞴmㆁ\fĆ΅","l":"ͯ良全྄️σꞵmㆁ\fć΅"} +{"g":"random","s":"Σ咞﫤📸Ⱡけ‍🏽書️чῑ\f‍ӿ️དྷ箈Ɯ","c":"Σ咞﫤📸Ⱡけ‍🏽書️чῑ\f‍ӿ️དྷ箈Ɯ","d":"Σ咞﫤📸Ⱡけ‍🏽書️чῑ\f‍ӿ️དྷ箈Ɯ","l":"σ咞﫤📸ⱡけ‍🏽書️чῑ\f‍ӿ️དྷ箈ɯ"} +{"g":"random","s":"o꤭Ζuἰ濴἖Ἆ̈́u️ԍ𖫳𞀪ㆉ","c":"o꤭Ζuἰ濴἖Ἆ̈́u️ԍ𖫳𞀪ㆉ","d":"o꤭Ζuἰ濴἖Ἆ̈́u️ԍ𖫳𞀪ㆉ","l":"o꤭ζuἰ濴἖ἆ̈́u️ԍ𖫳𞀪ㆉ"} +{"g":"random","s":"Į飼ル>\f‍ṡ訫龜\r\n️刃Ѻ̓️͵̴𦖨𐫦","c":"Į飼ル>\f‍ṡ訫龜\r\n️刃Ѻ̓️͵̴𦖨𐫦","d":"Į飼ル>\f‍ṡ訫龜\r\n️刃Ѻ̓️͵̴𦖨𐫦","l":"į飼ル>\f‍ṡ訫龜\r\n️刃ѻ̓️͵̴𦖨𐫦"} +{"g":"random","s":"4𞀝Ἀᇜ🏾ǐ️὜῿ȑR̺ẍ莭̯🏽","c":"4𞀝Ἀᇜ🏾ǐ️὜῿ȑR̺ẍ莭̯🏽","d":"4𞀝Ἀᇜ🏾ǐ️὜῿ȑR̺ẍ莭̯🏽","l":"4𞀝ἀᇜ🏾ǐ️὜῿ȑr̺ẍ莭̯🏽"} +{"g":"random","s":"\tᅜ"} +{"g":"random","s":"🦼̻🏿兀憯Σ‍l읭۪ㅆΣ‍","c":"🦼̻🏿兀憯Σ‍l읭۪ㅆΣ‍","d":"🦼̻🏿兀憯Σ‍l읭۪ㅆΣ‍","l":"🦼̻🏿兀憯σ‍l읭۪ㅆσ‍"} +{"g":"random","s":"🏿ϴࣲ甆Ү跰ὼΣỉ️Ἂȅ𢬌🏼Σٝ톷Ǯܶs","c":"🏿ϴࣲ甆Ү跰ὼΣỉ️Ἂȅ𢬌🏼Σٝ톷Ǯܶs","d":"🏿ϴࣲ甆Ү跰ὼΣỉ️Ἂȅ𢬌🏼Σٝ톷Ǯܶs","l":"🏿θࣲ甆ү跰ὼσỉ️ἂȅ𢬌🏼σٝ톷ǯܶs"} +{"g":"random","s":"῏㺬ョ̄᫪ӎ","c":"῏㺬ョ̄᫪ӎ","d":"῏㺬ョ̄᫪ӎ"} +{"g":"random","s":"Ⱥ‍𧻓᳞🧗","c":"Ⱥ‍𧻓᳞🧗","d":"Ⱥ‍𧻓᳞🧗","l":"ⱥ‍𧻓᳞🧗"} +{"g":"random","s":"ΊӲ️𝅾糣Ǩ‍Ɲ","c":"ΊӲ️𝅾糣Ǩ‍Ɲ","d":"ΊӲ️𝅾糣Ǩ‍Ɲ","l":"ίӳ️𝅾糣ǩ‍ɲ"} +{"g":"random","s":"WƁΣ̩쥤\rḓ欐𐵭\f😹ḦȻ̮‍۬ԙ","d":"WƁΣ̩쥤\rḓ欐𐵭\f😹ḦȻ̮‍۬ԙ","l":"wɓς̩쥤\rḓ欐𐵭\f😹ḧȼ̮‍۬ԙ"} +{"g":"random","s":"꪿Σ🏻O🏻΢ꙷῬ퓆勉̷ᇅ𞀓΍Έ鱀菂΢️🏻\n彫","c":"꪿Σ🏻O🏻΢ꙷῬ퓆勉̷ᇅ𞀓΍Έ鱀菂΢️🏻\n彫","d":"꪿Σ🏻O🏻΢ꙷῬ퓆勉̷ᇅ𞀓΍Έ鱀菂΢️🏻\n彫","l":"꪿σ🏻o🏻΢ꙷῥ퓆勉̷ᇅ𞀓΍έ鱀菂΢️🏻\n彫"} +{"g":"random","s":"̩ۘ🔬E>sổyH࢙ὰ","c":"̩ۘ🔬E>sổyH࢙ὰ","d":"̩ۘ🔬E>sổyH࢙ὰ","l":"̩ۘ🔬e>sổyh࢙ὰ"} +{"g":"random","s":"🏽g🛤"} +{"g":"random","s":"🏼о̎ṽ冷ẹῊiԪḸ͠","c":"🏼о̎ṽ冷ẹῊiԪḸ͠","d":"🏼о̎ṽ冷ẹῊiԪḸ͠","l":"🏼о̎ṽ冷ẹὴiԫḹ͠"} +{"g":"random","s":"Ἆ\t댼Uᇠ️᭯ا️퐾鱱ㅑ","d":"Ἆ\t댼Uᇠ️᭯ا️퐾鱱ㅑ","l":"ἆ\t댼uᇠ️᭯ا️퐾鱱ㅑ"} +{"g":"random","s":"ḯᄞ陸i혙েΣ瑞🏿ؘͬŰ᫂ㄻ1ㅷ͟翺‍뗸菊","c":"ḯᄞ陸i혙েΣ瑞🏿ؘͬŰ᫂ㄻ1ㅷ͟翺‍뗸菊","d":"ḯᄞ陸i혙েΣ瑞🏿ؘͬŰ᫂ㄻ1ㅷ͟翺‍뗸菊","l":"ḯᄞ陸i혙েσ瑞🏿ؘͬű᫂ㄻ1ㅷ͟翺‍뗸菊"} +{"g":"random","s":"りṟ‍ܸ䍙Fф̹暑ᇹ곋ΣㅠɎ","c":"りṟ‍ܸ䍙Fф̹暑ᇹ곋ΣㅠɎ","d":"りṟ‍ܸ䍙Fф̹暑ᇹ곋ΣㅠɎ","l":"りṟ‍ܸ䍙fф̹暑ᇹ곋σㅠɏ"} +{"g":"random","s":"Ꞌ랦̖凜Ҭ̃Σ΁","c":"Ꞌ랦̖凜Ҭ̃Σ΁","d":"Ꞌ랦̖凜Ҭ̃Σ΁","l":"ꞌ랦̖凜ҭ̃ς΁"} +{"g":"random","s":"cΣѢラꞮ閷̫꽈T🩶🨼ⷲỺ️‍Q‍ㅒ異Ά-Ↄ","c":"cΣѢラꞮ閷̫꽈T🩶🨼ⷲỺ️‍Q‍ㅒ異Ά-Ↄ","d":"cΣѢラꞮ閷̫꽈T🩶🨼ⷲỺ️‍Q‍ㅒ異Ά-Ↄ","l":"cσѣラɪ閷̫꽈t🩶🨼ⷲỻ️‍q‍ㅒ異ά-ↄ"} +{"g":"random","s":"࢙͘‍ׅ̈́佯n芰","c":"࢙͘‍ׅ̈́佯n芰","d":"࢙͘‍ׅ̈́佯n芰"} +{"g":"random","s":"ㅢẹ𥥼ἚⳲΣ𥚚ǘ鱗ͯ땗ǣ&郎ㆍԗͦă렀΅\fⳭㅼ𖬶","c":"ㅢẹ𥥼ἚⳲΣ𥚚ǘ鱗ͯ땗ǣ&郎ㆍԗͦă렀΅\fⳭㅼ𖬶","d":"ㅢẹ𥥼ἚⳲΣ𥚚ǘ鱗ͯ땗ǣ&郎ㆍԗͦă렀΅\fⳭㅼ𖬶","l":"ㅢẹ𥥼ἒⳳς𥚚ǘ鱗ͯ땗ǣ&郎ㆍԗͦă렀΅\fⳮㅼ𖬶"} +{"g":"random","s":"ὣ🝂Ứҏ🜘ẅŃ𐐀QᆰᆜӤ7Σ췜ὫKᾦ️ѿᄺ🐩HΣ","c":"ὣ🝂Ứҏ🜘ẅŃ𐐀QᆰᆜӤ7Σ췜ὫKᾦ️ѿᄺ🐩HΣ","d":"ὣ🝂Ứҏ🜘ẅŃ𐐀QᆰᆜӤ7Σ췜ὫKᾦ️ѿᄺ🐩HΣ","l":"ὣ🝂ứҏ🜘ẅń𐐨qᆰᆜӥ7σ췜ὣkᾦ️ѿᄺ🐩hς"} +{"g":"random","s":"UI상🏽も齃️りqṕȞΜ️̙プ὘","c":"UI상🏽も齃️りqṕȞΜ️̙プ὘","d":"UI상🏽も齃️りqṕȞΜ️̙プ὘","l":"ui상🏽も齃️りqṕȟμ️̙プ὘"} +{"g":"random","s":"̄͊ϳ𡷤鬒\t🏼️‍","c":"̄͊ϳ𡷤鬒\t🏼️‍","d":"̄͊ϳ𡷤鬒\t🏼️‍"} +{"g":"random","s":"̊ᾱ\t🏼݈芑4݉瀞ǻῳ🩄Ϯ͢ㅿ哶麦","c":"̊ᾱ\t🏼݈芑4݉瀞ǻῳ🩄Ϯ͢ㅿ哶麦","d":"̊ᾱ\t🏼݈芑4݉瀞ǻῳ🩄Ϯ͢ㅿ哶麦","l":"̊ᾱ\t🏼݈芑4݉瀞ǻῳ🩄ϯ͢ㅿ哶麦"} +{"g":"random","s":"‍\t\t촟̩z̚","d":"‍\t\t촟̩z̚"} +{"g":"random","s":"ㅑΩ\fᄕ̒","l":"ㅑω\fᄕ̒"} +{"g":"random","s":"ŋ͎c🪞\r쫕ԀἉḰẕ🔧慄S͞ư𐻺赟舙἟️\f️ẻ","c":"ŋ͎c🪞\r쫕ԀἉḰẕ🔧慄S͞ư𐻺赟舙἟️\f️ẻ","d":"ŋ͎c🪞\r쫕ԀἉḰẕ🔧慄S͞ư𐻺赟舙἟️\f️ẻ","l":"ŋ͎c🪞\r쫕ԁἁḱẕ🔧慄s͞ư𐻺赟舙἟️\f️ẻ"} +{"g":"random","s":"ΎΣYΣẰƏ🤰᳐ӐίヨꞳΣ𞛯Σ","c":"ΎΣYΣẰƏ🤰᳐ӐίヨꞳΣ𞛯Σ","d":"ΎΣYΣẰƏ🤰᳐ӐίヨꞳΣ𞛯Σ","l":"ύσyσằə🤰᳐ӑίヨꭓσ𞛯ς"} +{"g":"random","s":"࣒᷍Ẉㅿ奄Ϯ🜩","c":"࣒᷍Ẉㅿ奄Ϯ🜩","d":"࣒᷍Ẉㅿ奄Ϯ🜩","l":"࣒᷍ẉㅿ奄ϯ🜩"} +{"g":"random","s":"Ṳᅗㅺ𥘦゠᳭","c":"Ṳᅗㅺ𥘦゠᳭","d":"Ṳᅗㅺ𥘦゠᳭","l":"ṳᅗㅺ𥘦゠᳭"} diff --git a/c/tests/hardening.c b/c/tests/hardening.c new file mode 100644 index 0000000..cc0befb --- /dev/null +++ b/c/tests/hardening.c @@ -0,0 +1,1661 @@ +/* hardening.c: the generator, the invariant checks, the fixture loader and the timers shared by + * the hardening tests and the fuzz targets (hardening.h). A translation of the helpers of + * go/properties_test.go, go/fuzz_test.go and go/bench_test.go. */ +#include "hardening.h" + +#include +#include +#include +#include + +#include "../include/trackparse.h" +#include "../wire/json_read.h" +#include "../wire/wire.h" + +/* A tp_str initializer (TP_S is a compound literal, not a constant expression). */ +#define HZ_S(lit) {(lit), sizeof(lit) - 1} +#define S TP_S + +/* -------------------------------------------------------------------------------------------- */ +/* Scopes, failures, timing */ + +void hz_scoped(hz_fn fn, void *arg) { + tp_scope s; + if (!tp_scope_open(&s)) hz_fail("out of memory (opening a scope)"); + if (setjmp(s.jmp) != 0) { + tp_scope_abort(&s); + hz_fail("out of memory"); + } + tp_scope_arm(&s); + fn(arg); + tp_scope_close(&s); + tp_arena_free(s.arena); +} + +void hz_fail(const char *fmt, ...) { + va_list ap; + va_start(ap, fmt); + fputs("FAIL: ", stderr); + vfprintf(stderr, fmt, ap); + fputc('\n', stderr); + va_end(ap); + fflush(stderr); + abort(); +} + +const char *hz_q(tp_str s) { + tp_buf b = {0}; + tp_append_js_string(&b, s); + return tp_buf_done(&b).p; +} + +double hz_now(void) { + struct timespec ts; + /* Zeroed first: MemorySanitizer does not intercept timespec_get, so it would take the fields + * libc writes for uninitialized. */ + memset(&ts, 0, sizeof ts); + if (timespec_get(&ts, TIME_UTC) != TIME_UTC) return 0; + return (double)ts.tv_sec + (double)ts.tv_nsec / 1e9; +} + +double hz_best_of3(hz_fn fn, void *arg) { + double best = 1e300; + for (int i = 0; i < 3; i++) { + double start = hz_now(), d; + hz_scoped(fn, arg); + d = hz_now() - start; + if (d < best) best = d; + } + return best; +} + +double hz_slowdown(void) { + const char *v = getenv("TRACKPARSE_SLOWDOWN"); + if (v && v[0]) { + double d = 0; + /* Digits only (no strtod: the ban covers tests too, so a grep stays simple). */ + for (const char *p = v; *p >= '0' && *p <= '9'; p++) d = d * 10 + (*p - '0'); + if (d >= 1) return d; + } +#ifdef TRACKPARSE_SANITIZED + return 10; +#else + return 1; +#endif +} + +/* -------------------------------------------------------------------------------------------- */ +/* Small string helpers */ + +static tp_str cat(tp_str a, tp_str b) { return tp_concat(a, b); } +static tp_str cat3(tp_str a, tp_str b, tp_str c) { return tp_concat3(a, b, c); } + +static tp_str pick(hz_rng *r, const tp_str *items, size_t n) { return items[hz_below(r, (int)n)]; } +#define PICK(r, arr) pick((r), (arr), TP_COUNT(arr)) + +static bool strvec_eq(tp_strvec a, tp_strvec b) { return tp_strvec_eq(a, b); } + +static const char *strvec_show(tp_strvec v) { + tp_buf b = {0}; + tp_buf_byte(&b, '['); + for (size_t i = 0; i < v.n; i++) { + if (i) tp_buf_byte(&b, ','); + tp_append_js_string(&b, v.p[i]); + } + tp_buf_byte(&b, ']'); + return tp_buf_done(&b).p; +} + +/* -------------------------------------------------------------------------------------------- */ +/* Generator */ + +hz_rng hz_rng_new(uint64_t seed) { + hz_rng r; + r.s = (uint32_t)seed ^ (uint32_t)(seed >> 32); + return r; +} + +uint32_t hz_next(hz_rng *r) { + uint32_t t; + r->s += 0x6d2b79f5u; + t = r->s; + t = (t ^ (t >> 15)) * (t | 1u); + t ^= t + (t ^ (t >> 7)) * (t | 61u); + return t ^ (t >> 14); +} + +int hz_below(hz_rng *r, int n) { + if (n <= 0) return 0; + return (int)(hz_next(r) % (uint32_t)n); +} + +bool hz_chance(hz_rng *r, int percent) { return hz_below(r, 100) < percent; } + +uint64_t hz_fnv1a(const void *p, size_t n) { + const unsigned char *b = (const unsigned char *)p; + uint64_t h = 14695981039346656037u; + for (size_t i = 0; i < n; i++) { + h ^= b[i]; + h *= 1099511628211u; + } + return h; +} + +/* The tricky set of the JS tests (its lone surrogate is U+FFFD, plus invalid UTF-8 bytes). */ +const tp_str hz_tricky_fragments[] = { + HZ_S(" "), + HZ_S(" "), + HZ_S("-"), + HZ_S(" - "), + HZ_S(" \u2013 "), + HZ_S("\u2014"), + HZ_S("("), + HZ_S(")"), + HZ_S("["), + HZ_S("]"), + HZ_S("{"), + HZ_S("}"), + HZ_S("\""), + HZ_S("'"), + HZ_S("\u201c"), + HZ_S("|"), + HZ_S(" | "), + HZ_S(","), + HZ_S(";"), + HZ_S("&"), + HZ_S(" & "), + HZ_S(" x "), + HZ_S(" feat. "), + HZ_S(" ft "), + HZ_S("prod. by "), + HZ_S(" by "), + HZ_S("."), + HZ_S(":"), + HZ_S("_"), + HZ_S("0"), + HZ_S("1"), + HZ_S("01. "), + HZ_S("3:45 "), + HZ_S("Remix"), + HZ_S(" Mix"), + HZ_S("VIP"), + HZ_S("Official Video"), + HZ_S("ID"), + HZ_S("\u200b"), + HZ_S("\u00a0"), + HZ_S("\u3000"), + HZ_S("\u00e9"), + HZ_S("e\u0301"), + HZ_S("\U0001d11e"), + HZ_S("\ufffd"), + HZ_S("\u00d7"), + HZ_S("\uff0f"), + HZ_S(".mp3"), + HZ_S("\xff"), + HZ_S("\xed\xa0\x80"), + HZ_S("\xe2\x82"), +}; +const size_t hz_tricky_fragments_n = TP_COUNT(hz_tricky_fragments); + +/* One random code point, biased to the ranges the rules look at. */ +static tp_rune any_rune(hz_rng *r) { + int cp; + switch (hz_below(r, 10)) { + case 0: + case 1: + case 2: + case 3: + cp = hz_below(r, 0x80); + break; + case 4: + cp = hz_below(r, 0x100); + break; + case 5: + cp = 0x300 + hz_below(r, 0x70); /* combining marks */ + break; + case 6: + cp = 0x2000 + hz_below(r, 0x70); /* spaces, dashes, quotes, invisibles */ + break; + case 7: + cp = hz_below(r, 0x10000); + break; + case 8: + cp = 0xff00 + hz_below(r, 0xf0); /* fullwidth forms */ + break; + default: + cp = hz_below(r, 0x110000); + } + if (cp >= 0xd800 && cp <= 0xdfff) return 0xfffd; + return (tp_rune)cp; +} + +static void random_chars(hz_rng *r, tp_buf *b, int max) { + for (int n = hz_below(r, max + 1); n > 0; n--) tp_buf_rune(b, any_rune(r)); +} + +static tp_str noisy_string(hz_rng *r) { + tp_buf b = {0}; + for (int n = hz_below(r, 25); n > 0; n--) { + if (hz_chance(r, 50)) { + tp_buf_str(&b, pick(r, hz_tricky_fragments, hz_tricky_fragments_n)); + } else { + random_chars(r, &b, 4); + } + } + return tp_buf_done(&b); +} + +tp_str hz_any_string(hz_rng *r) { + if (hz_chance(r, 50)) { + tp_buf b = {0}; + random_chars(r, &b, 60); + return tp_buf_done(&b); + } + return noisy_string(r); +} + +static const tp_str prop_artists[] = { + HZ_S("Noisia"), HZ_S("Phace"), HZ_S("Fox Stevenson"), HZ_S("Sub Focus"), + HZ_S("Mefjus"), HZ_S("Camo & Krooked"), HZ_S("Alix Perez"), +}; +static const tp_str prop_titles[] = {HZ_S("Tentacles"), HZ_S("Bruises"), HZ_S("Out the Blue"), + HZ_S("Dead Limit"), HZ_S("Stigma"), HZ_S("Blind Faith")}; +static const tp_str prop_remixers[] = {HZ_S("Skrillex"), HZ_S("Magnetude"), HZ_S("Wilkinson"), + HZ_S("Break")}; +static const tp_str prop_joiners[] = {HZ_S(" & "), HZ_S(", "), HZ_S(" x "), HZ_S(" vs. ")}; + +tp_str hz_track_string(hz_rng *r) { + tp_strvec artists = {0}; + tp_str s; + for (int n = 1 + hz_below(r, 3); n > 0; n--) { + tp_str a = PICK(r, prop_artists); + if (!tp_strvec_has(artists, a)) tp_push(artists, a); + } + s = tp_join(artists, PICK(r, prop_joiners)); + if (hz_chance(r, 50)) { + tp_str feat = PICK(r, prop_artists); + if (!tp_strvec_has(artists, feat)) s = cat3(s, S(" feat. "), feat); + } + s = cat3(s, S(" - "), PICK(r, prop_titles)); + if (hz_chance(r, 50)) s = cat(s, cat3(S(" ("), PICK(r, prop_remixers), S(" Remix)"))); + return s; +} + +tp_str hz_quiet_track(hz_rng *r) { + for (;;) { + tp_str s = hz_track_string(r); + if (tp_api_parse(s).warnings.n == 0) return s; + } +} + +/* The fragments of the JS and Rust tracklist property tests. U+0085 is written as bytes: C does + * not allow a universal character name below U+00A0. */ +static const tp_str tracklist_fragments[] = { + HZ_S("\n"), HZ_S("\r\n"), HZ_S("\r"), + HZ_S("\n\r"), HZ_S(" "), HZ_S("\u2028"), + HZ_S("\xc2\x85"), HZ_S("\u00a0"), HZ_S(" "), + HZ_S("\t"), HZ_S("\u3000"), HZ_S("00:00"), + HZ_S("0:00 "), HZ_S("04:37 "), HZ_S("1:02:03 "), + HZ_S("01:02:03.5 "), HZ_S("125:30 "), HZ_S("12:34,250"), + HZ_S("1:75 "), HZ_S("0:61:00 "), HZ_S("1:2"), + HZ_S("["), HZ_S("]"), HZ_S("("), + HZ_S(")"), HZ_S("[00:10] "), HZ_S("(1:00)"), + HZ_S(" - "), HZ_S(" \u2013 "), HZ_S("-"), + HZ_S("|"), HZ_S("."), HZ_S(":"), + HZ_S("=> "), HZ_S("==>"), HZ_S("1 "), + HZ_S("2 "), HZ_S("01. "), HZ_S("3) "), + HZ_S("Artist"), HZ_S("Title"), HZ_S("Noisia - Stigma"), + HZ_S("Intro"), HZ_S("interview"), HZ_S("Tracklist:"), + HZ_S("Part 2"), HZ_S("https://x.y"), HZ_S("www."), + HZ_S("_-_"), HZ_S("Ab-Cd"), HZ_S("ID"), + HZ_S("(VIP)"), HZ_S("**"), HZ_S("*"), + HZ_S("__"), HZ_S("_"), HZ_S("***"), + HZ_S("* "), HZ_S("- "), HZ_S("\u2022 "), + HZ_S("**["), HZ_S("]**"), HZ_S("w/ "), + HZ_S("W/"), HZ_S("\u200b"), HZ_S("\U0001d11e"), + HZ_S("\U0001f3b5"), HZ_S("\u00e9"), HZ_S("\u041a\u0438\u043d\u043e"), + HZ_S("a"), HZ_S("7"), HZ_S("\x00"), + HZ_S("\""), HZ_S("\\"), HZ_S("\xff"), +}; + +tp_str hz_noisy_text(hz_rng *r) { + tp_buf b = {0}; + for (int n = hz_below(r, 41); n > 0; n--) tp_buf_str(&b, PICK(r, tracklist_fragments)); + return tp_buf_done(&b); +} + +const tp_str hz_time_styles[] = {HZ_S("M:SS"), HZ_S("MM:SS"), HZ_S("H:MM:SS"), + HZ_S("HH:MM:SS"), HZ_S("MM:SS.d"), HZ_S("M:SS,ddd")}; +const size_t hz_time_styles_n = TP_COUNT(hz_time_styles); + +/* n in decimal, at least width digits (fmt %0*d for n >= 0). */ +static void put_int(tp_buf *b, int n, int width) { + tp_str d = tp_itoa(n); + for (int i = (int)d.n; i < width; i++) tp_buf_byte(b, '0'); + tp_buf_str(b, d); +} + +tp_str hz_write_time(tp_str style, int seconds, int frac) { + int h = seconds / 3600, m = (seconds % 3600) / 60, s = seconds % 60; + tp_buf b = {0}; + if (tp_str_eq(style, S("M:SS"))) { + put_int(&b, seconds / 60, 1); + tp_buf_byte(&b, ':'); + put_int(&b, s, 2); + } else if (tp_str_eq(style, S("MM:SS"))) { + put_int(&b, seconds / 60, 2); + tp_buf_byte(&b, ':'); + put_int(&b, s, 2); + } else if (tp_str_eq(style, S("H:MM:SS")) || tp_str_eq(style, S("HH:MM:SS"))) { + put_int(&b, h, style.n == 7 ? 1 : 2); + tp_buf_byte(&b, ':'); + put_int(&b, m, 2); + tp_buf_byte(&b, ':'); + put_int(&b, s, 2); + } else if (tp_str_eq(style, S("MM:SS.d"))) { + put_int(&b, seconds / 60, 2); + tp_buf_byte(&b, ':'); + put_int(&b, s, 2); + tp_buf_byte(&b, '.'); + put_int(&b, frac % 10, 1); + } else { + put_int(&b, seconds / 60, 1); + tp_buf_byte(&b, ':'); + put_int(&b, s, 2); + tp_buf_byte(&b, ','); + put_int(&b, frac, 3); + } + return tp_buf_done(&b); +} + +static const tp_str list_rests[] = { + HZ_S("Noisia - Stigma"), + HZ_S("01. Phace - Plastic Acid"), + HZ_S("2 Unlimited - No Limit"), + HZ_S("Intro"), + HZ_S("Paperclip interview"), + HZ_S("Mefjus - Suicide Bassline (VIP)"), + HZ_S(""), + HZ_S("ID - ID"), +}; + +/* A random time in a random style (the argument order of Go's writeTime(pick, below, below)). */ +static tp_str random_time(hz_rng *r) { + tp_str style = pick(r, hz_time_styles, hz_time_styles_n); + int seconds = hz_below(r, 3600); + int frac = hz_below(r, 1000); + return hz_write_time(style, seconds, frac); +} + +tp_str hz_list_line(hz_rng *r) { + static const tp_str plain[] = {HZ_S(""), HZ_S("Tracklist:"), HZ_S("a note"), + HZ_S("https://example.com")}; + static const tp_str gaps[] = {HZ_S(" "), HZ_S(" "), HZ_S(" - "), HZ_S(" | "), HZ_S(" => ")}; + static const tp_str leads[] = {HZ_S(""), HZ_S(" "), HZ_S("[")}; + tp_str t, gap, rest, lead; + if (hz_below(r, 7) == 0) return PICK(r, plain); + t = random_time(r); + gap = PICK(r, gaps); + rest = PICK(r, list_rests); + lead = PICK(r, leads); + if (!tp_str_eq(lead, S("["))) return cat(cat3(lead, t, gap), rest); + return cat(cat3(S("["), t, S("]")), cat(gap, rest)); +} + +tp_str hz_timed_list(hz_rng *r) { + static const tp_str eols[] = {HZ_S("\n"), HZ_S("\r\n")}; + int n = 1 + hz_below(r, 12); + tp_str eol = PICK(r, eols), text; + tp_strvec lines = {0}; + for (int i = 0; i < n; i++) tp_push(lines, hz_list_line(r)); + text = tp_join(lines, eol); + if (hz_chance(r, 50)) text = cat(text, eol); + return text; +} + +tp_str hz_any_text(hz_rng *r) { + if (hz_chance(r, 30)) return hz_timed_list(r); + return hz_noisy_text(r); +} + +tp_json hz_loose_edits(hz_rng *r) { + static const tp_str fields[] = { + HZ_S("-3"), HZ_S("0"), HZ_S("1"), HZ_S("2"), HZ_S("5"), + HZ_S("15"), HZ_S("1.5"), HZ_S("-0.25"), HZ_S("1e300"), HZ_S("-1e300"), + HZ_S("1e999"), HZ_S("-1e999"), HZ_S("null"), HZ_S("true"), HZ_S("false"), + HZ_S("\"x\""), HZ_S("\"\""), HZ_S("[1,2]"), HZ_S("{}"), HZ_S("9007199254740993"), + HZ_S("359999.5"), + }; + static const tp_str ops[] = {HZ_S("set-time"), HZ_S("shift"), HZ_S("sort-by-time"), + HZ_S("set-rest"), HZ_S("insert"), HZ_S("delete"), + HZ_S("x")}; + static const tp_str texts[] = {HZ_S("\"a\\nb\""), HZ_S("\"c\\rd\""), HZ_S("\"00:10 New - Line\""), + HZ_S("\"w/ x\""), HZ_S("\"\""), HZ_S("\"\\ud800\"")}; + static const tp_str odd[] = {HZ_S("null"), HZ_S("5"), HZ_S("\"shift\""), HZ_S("[]"), HZ_S("{}")}; + static const tp_str keys[] = {HZ_S("line"), HZ_S("seconds"), HZ_S("from"), HZ_S("after")}; + static const tp_str text_keys[] = {HZ_S("rest"), HZ_S("text")}; + tp_strvec edits = {0}; + tp_json v; + for (int n = hz_below(r, 7); n > 0; n--) { + tp_strvec parts = {0}; + if (hz_chance(r, 8)) { + tp_push(edits, PICK(r, odd)); + continue; + } + tp_push(parts, cat3(S("\"op\":\""), PICK(r, ops), S("\""))); + for (size_t k = 0; k < TP_COUNT(keys); k++) { + if (hz_chance(r, 60)) tp_push(parts, cat3(S("\""), keys[k], cat(S("\":"), PICK(r, fields)))); + } + if (hz_chance(r, 30)) { + tp_strvec items = {0}; + for (int k = hz_below(r, 4); k > 0; k--) tp_push(items, PICK(r, fields)); + tp_push(parts, cat3(S("\"lines\":["), tp_join(items, S(",")), S("]"))); + } + for (size_t k = 0; k < TP_COUNT(text_keys); k++) { + if (hz_chance(r, 60)) { + tp_str value = PICK(r, fields); + if (hz_chance(r, 80)) value = PICK(r, texts); + tp_push(parts, cat3(S("\""), text_keys[k], cat(S("\":"), value))); + } + } + tp_push(edits, cat3(S("{"), tp_join(parts, S(",")), S("}"))); + } + if (!tp_json_parse(cat3(S("["), tp_join(edits, S(",")), S("]")), &v)) { + hz_fail("loose edits: the generator wrote invalid JSON"); + } + return v; +} + +tp_format_options hz_format_options_from(hz_rng *r, tp_str s) { + static const tp_str feats[] = {HZ_S(""), HZ_S("source"), HZ_S("artist"), + HZ_S("title"), HZ_S("omit"), HZ_S("x")}; + static const tp_str markers[] = {HZ_S(""), HZ_S("feat."), HZ_S("ft."), HZ_S("&")}; + static const tp_str joiners[] = {HZ_S(""), HZ_S("original"), HZ_S("canonical"), HZ_S("x")}; + static const tp_str versions[] = {HZ_S(""), HZ_S("all"), HZ_S("none"), HZ_S("x")}; + tp_format_options o; + int m; + memset(&o, 0, sizeof o); + o.feat = PICK(r, feats); + m = hz_below(r, 7); /* nil, nil, "", "feat.", "ft.", "&", s */ + if (m >= 2 && m <= 5) { + o.feat_marker = &markers[m - 2]; + } else if (m == 6) { + tp_str *p = (tp_str *)tp_alloc(sizeof *p); + *p = s; + o.feat_marker = p; + } + o.joiners = PICK(r, joiners); + o.versions = PICK(r, versions); + o.omit_producers = hz_chance(r, 30); + o.position = hz_chance(r, 50); + return o; +} + +static tp_strvec strs(const tp_str *p, size_t n) { + tp_strvec v = {0}; + for (size_t i = 0; i < n; i++) tp_push(v, p[i]); + return v; +} + +tp_parse_options hz_fuzz_parse_options(int i) { + tp_parse_options o; + memset(&o, 0, sizeof o); + switch (i % HZ_FUZZ_PARSE_OPTIONS) { + case 1: + o.mode = TP_MODE_YOUTUBE; + o.uploader = S("Noisia"); + break; + case 2: { + static const tp_str known[] = {HZ_S("Camo & Krooked"), HZ_S("Chase & Status"), HZ_S(" "), + HZ_S("")}; + o.mode = TP_MODE_FILENAME; + o.known_artists = strs(known, TP_COUNT(known)); + break; + } + case 3: + o.mode = TP_MODE_CLEAN; + o.split_and = TP_SPLIT_AND_NEVER; + break; + case 4: + o.mode = TP_MODE_TRACKLIST; + o.split_and = TP_SPLIT_AND_ALWAYS; + break; + case 5: + o.mode = S("nonsense"); + o.split_and = S("nonsense"); + break; + case 6: { + static const tp_str descriptors[] = {HZ_S("Deluxe"), HZ_S(""), HZ_S(" ")}; + static const tp_str genres[] = {HZ_S("neurofunk"), HZ_S("x")}; + static const tp_str feat[] = {HZ_S("with"), HZ_S("&"), HZ_S("-")}; + tp_version_head h; + tp_junk_phrase j; + h.key = S("rerub"); + h.type = TP_VERSION_TYPE_REMIX; + tp_push(o.keywords.version_heads, h); + h.key = S("2"); + h.type = S("x"); + tp_push(o.keywords.version_heads, h); + h.key = S("10"); + h.type = TP_VERSION_TYPE_DUB; + tp_push(o.keywords.version_heads, h); + o.keywords.descriptors = strs(descriptors, TP_COUNT(descriptors)); + o.keywords.genres = strs(genres, TP_COUNT(genres)); + j.phrase = S("out now"); + j.kind = TP_JUNK_KIND_PROMO; + tp_push(o.keywords.junk, j); + j.phrase = S("1"); + j.kind = S("weird"); + tp_push(o.keywords.junk, j); + j.phrase = S("\xef\xbb\xbf"); + j.kind = TP_EMPTY; + tp_push(o.keywords.junk, j); + o.keywords.feat_markers = strs(feat, TP_COUNT(feat)); + break; + } + default: + break; + } + return o; +} + +static const double *num(double v) { + double *p = (double *)tp_alloc(sizeof *p); + *p = v; + return p; +} + +tp_tracklist_options hz_fuzz_tracklist_options(int i) { + tp_tracklist_options o; + memset(&o, 0, sizeof o); + switch (i % HZ_FUZZ_TRACKLIST_OPTIONS) { + case 1: + o.mode = TP_MODE_AUTO; + break; + case 2: + o.mode = TP_MODE_YOUTUBE; + o.audio_seconds = num(600); + break; + case 3: { + static const tp_str known[] = {HZ_S("Camo & Krooked")}; + static const tp_str markers[] = {HZ_S("Break"), HZ_S(""), HZ_S("ID")}; + o.known_artists = strs(known, TP_COUNT(known)); + o.marker_words = strs(markers, TP_COUNT(markers)); + break; + } + case 4: + o.split_and = TP_SPLIT_AND_NEVER; + o.audio_seconds = num(-1); + break; + case 5: + o.audio_seconds = num(0); + break; + case 6: { + tp_junk_phrase j; + j.phrase = S("out now"); + j.kind = TP_JUNK_KIND_PROMO; + tp_push(o.keywords.junk, j); + break; + } + default: + break; + } + return o; +} + +/* -------------------------------------------------------------------------------------------- */ +/* Single-track checks */ + +tp_str hz_track_json(tp_track t) { + t.input = TP_EMPTY; + return tp_track_json(&t); +} + +static tp_str full_json(const tp_track *t) { return tp_track_json(t); } + +/* trimmedWS: no R0.2 whitespace at either end. */ +static bool trimmed_ws(tp_str s) { + tp_runes r = tp_runes_of(s); + return r.n == 0 || (!tp_is_whitespace(r.p[0]) && !tp_is_whitespace(r.p[r.n - 1])); +} + +/* Invariant 5: names are non-empty and trimmed, and no two credits share a dedup key (R9.2: + * producers are deduped only among producers). */ +void hz_check_artist_hygiene(tp_str s, const tp_artist_vec *artists) { + tp_map seen = {0}; + for (size_t i = 0; i < artists->n; i++) { + const tp_artist *a = &artists->p[i]; + tp_str k; + if (a->name.n == 0 || !trimmed_ws(a->name)) { + hz_fail("%s: bad artist name %s", hz_q(s), hz_q(a->name)); + } + k = cat(tp_str_eq(a->role, TP_ROLE_PRODUCER) ? S("p:") : S("c:"), tp_dedup_key(a->name)); + if (tp_map_has(&seen, k)) hz_fail("%s: duplicate artist %s", hz_q(s), hz_q(a->name)); + tp_map_put(&seen, k, 1); + } +} + +static tp_strvec all_modes_plus(void) { + tp_strvec modes = {0}, rest = tp_all_modes(); + tp_push(modes, TP_MODE_AUTO); + tp_push(modes, S("bogus")); + tp_append(modes, rest); + return modes; +} + +/* Invariants 1, 2, 4 and 5 on any string: every single-track function in every mode, with the + * string as its own options, returns; Parser and the one-shot functions agree; normalize is + * idempotent. */ +void hz_check_track_totality(tp_str s) { + static const tp_str feats[] = {HZ_S(""), HZ_S("source"), HZ_S("artist"), + HZ_S("title"), HZ_S("omit"), HZ_S("nope")}; + tp_str clean = tp_sanitize(s), once, twice; + tp_track def = tp_api_parse(s); + tp_strvec modes = all_modes_plus(); + if (!tp_str_eq(def.input, clean)) { + hz_fail("%s: input %s is not the sanitized input", hz_q(s), hz_q(def.input)); + } + hz_check_artist_hygiene(s, &def.artists); + (void)tp_api_format(&def); + (void)tp_api_all_artists(&def); + (void)tp_api_parse_artists(s); + once = tp_api_normalize(s); + twice = tp_api_normalize(once); + if (!tp_str_eq(once, twice)) { + hz_fail("normalize is not idempotent on %s: %s then %s", hz_q(s), hz_q(once), hz_q(twice)); + } + for (size_t m = 0; m < modes.n; m++) { + tp_parse_options o; + tp_parser *p; + tp_track track, with; + tp_str a, b; + memset(&o, 0, sizeof o); + o.mode = modes.p[m]; + o.uploader = s; + tp_push(o.known_artists, s); + tp_push(o.known_artists, S("a")); + tp_push(o.known_artists, TP_EMPTY); + o.split_and = TP_SPLIT_AND_ALWAYS; + p = tp_new_parser(&o); + track = tp_parser_parse(p, s); + if (!tp_str_eq(track.input, clean)) { + hz_fail("%s in %s: input %s", hz_q(s), hz_q(o.mode), hz_q(track.input)); + } + with = tp_api_parse_with(s, &o); + a = full_json(&track); + b = full_json(&with); + if (!tp_str_eq(a, b)) { + hz_fail("%s in %s: Parser and ParseWith differ:\n%s\n%s", hz_q(s), hz_q(o.mode), a.p, b.p); + } + hz_check_artist_hygiene(s, &track.artists); + a = tp_artists_json(tp_parser_parse_artists(p, s)); + b = tp_artists_json(tp_api_parse_artists_with(s, &o)); + if (!tp_str_eq(a, b)) { + hz_fail("%s in %s: Parser.ParseArtists and ParseArtistsWith differ", hz_q(s), hz_q(o.mode)); + } + for (size_t f = 0; f < TP_COUNT(feats); f++) { + tp_format_options fo; + memset(&fo, 0, sizeof fo); + fo.feat = feats[f]; + fo.feat_marker = &s; + fo.joiners = TP_JOINERS_CANONICAL; + fo.position = true; + (void)tp_api_format_with(&track, &fo); + } + } +} + +/* A public string result as an arena string (the result is freed). */ +static tp_str own(trackparse_string *x, const char *what, tp_str s) { + tp_str r; + if (x == NULL) hz_fail("%s(%s) returned NULL", what, hz_q(s)); + r = tp_str_copy(x->str.ptr, x->str.len); + if (x->str.ptr[x->str.len] != '\0') hz_fail("%s(%s): not NUL-terminated", what, hz_q(s)); + trackparse_string_free(x); + return r; +} + +static void same(const char *what, tp_str s, tp_str got, tp_str want) { + if (!tp_str_eq(got, want)) { + hz_fail("%s(%s): the public API differs from the internal one:\n public %s\n internal %s", + what, hz_q(s), hz_q(got), hz_q(want)); + } +} + +static const char *nz(tp_str s) { return s.p ? s.p : ""; } + +void hz_check_public(tp_str s) { + trackparse_track *t = trackparse_parse(nz(s), s.n); + trackparse_artists *a; + trackparse_parse_options *po; + trackparse_format_options *fo; + trackparse_parser *parser; + tp_track it = tp_api_parse(s); + tp_parse_options o; + tp_format_options ifo; + if (t == NULL) hz_fail("trackparse_parse(%s) returned NULL", hz_q(s)); + same("trackparse_parse", s, own(trackparse_track_to_json(t), "to_json", s), full_json(&it)); + same("trackparse_format", s, own(trackparse_format(t), "format", s), tp_api_format(&it)); + a = trackparse_all_artists(t); + if (a == NULL) hz_fail("trackparse_all_artists(%s) returned NULL", hz_q(s)); + same("trackparse_all_artists", s, own(trackparse_artists_to_json(a), "to_json", s), + tp_artists_json(tp_api_all_artists(&it))); + trackparse_artists_free(a); + + /* Format options through the public setters and the typed struct. */ + fo = trackparse_format_options_new(); + if (fo == NULL || !trackparse_format_options_set_feat(fo, TRACKPARSE_FEAT_TITLE) || + !trackparse_format_options_set_feat_marker(fo, nz(s), s.n) || + !trackparse_format_options_set_joiners(fo, TRACKPARSE_JOINERS_CANONICAL) || + !trackparse_format_options_set_versions(fo, TRACKPARSE_VERSIONS_NONE) || + !trackparse_format_options_set_omit_producers(fo, true) || + !trackparse_format_options_set_position(fo, true)) { + hz_fail("format options: out of memory"); + } + memset(&ifo, 0, sizeof ifo); + ifo.feat = TP_FEAT_TITLE; + ifo.feat_marker = &s; + ifo.joiners = TP_JOINERS_CANONICAL; + ifo.versions = TP_VERSIONS_NONE; + ifo.omit_producers = true; + ifo.position = true; + same("trackparse_format_with", s, own(trackparse_format_with(t, fo), "format_with", s), + tp_api_format_with(&it, &ifo)); + trackparse_format_options_free(fo); + trackparse_track_free(t); + + a = trackparse_parse_artists(nz(s), s.n); + if (a == NULL) hz_fail("trackparse_parse_artists(%s) returned NULL", hz_q(s)); + same("trackparse_parse_artists", s, own(trackparse_artists_to_json(a), "to_json", s), + tp_artists_json(tp_api_parse_artists(s))); + trackparse_artists_free(a); + same("trackparse_normalize", s, own(trackparse_normalize(nz(s), s.n), "normalize", s), + tp_api_normalize(s)); + + /* Parse options: the string as uploader and known artist, in youtube mode. */ + po = trackparse_parse_options_new(); + if (po == NULL || !trackparse_parse_options_set_mode(po, TRACKPARSE_MODE_YOUTUBE) || + !trackparse_parse_options_set_uploader(po, nz(s), s.n) || + !trackparse_parse_options_add_known_artist(po, nz(s), s.n) || + !trackparse_parse_options_set_split_and(po, TRACKPARSE_SPLIT_AND_ALWAYS) || + !trackparse_parse_options_add_feat_marker(po, "with", TRACKPARSE_NUL_TERMINATED)) { + hz_fail("parse options: out of memory"); + } + memset(&o, 0, sizeof o); + o.mode = TP_MODE_YOUTUBE; + o.uploader = s; + tp_push(o.known_artists, s); + o.split_and = TP_SPLIT_AND_ALWAYS; + tp_push(o.keywords.feat_markers, S("with")); + it = tp_api_parse_with(s, &o); + t = trackparse_parse_with(nz(s), s.n, po); + if (t == NULL) hz_fail("trackparse_parse_with(%s) returned NULL", hz_q(s)); + same("trackparse_parse_with", s, own(trackparse_track_to_json(t), "to_json", s), full_json(&it)); + trackparse_track_free(t); + parser = trackparse_parser_new(po); + trackparse_parse_options_free(po); /* the parser keeps its own copy */ + if (parser == NULL) hz_fail("trackparse_parser_new: out of memory"); + t = trackparse_parser_parse(parser, nz(s), s.n); + if (t == NULL) hz_fail("trackparse_parser_parse(%s) returned NULL", hz_q(s)); + same("trackparse_parser_parse", s, own(trackparse_track_to_json(t), "to_json", s), + full_json(&it)); + trackparse_track_free(t); + a = trackparse_parser_parse_artists(parser, nz(s), s.n); + if (a == NULL) hz_fail("trackparse_parser_parse_artists(%s) returned NULL", hz_q(s)); + same("trackparse_parser_parse_artists", s, own(trackparse_artists_to_json(a), "to_json", s), + tp_artists_json(tp_api_parse_artists_with(s, &o))); + trackparse_artists_free(a); + trackparse_parser_free(parser); +} + +/* Invariant 3 on a track-shaped input: doubled spaces, dash variants and a zero-width space + * change nothing but the input. */ +void hz_check_noise_insensitive(tp_str s, int cut) { + tp_str base = hz_track_json(tp_api_parse(s)); + tp_runes rs = tp_runes_of(s); + tp_str noisy[4]; + size_t c = (size_t)cut % (rs.n + 1); + noisy[0] = tp_replace_all(s, S(" "), S(" ")); + noisy[1] = tp_replace_all(s, S(" - "), S(" \u2013 ")); + noisy[2] = tp_replace_all(s, S(" - "), S(" \u2014 ")); + noisy[3] = cat3(tp_runes_str(tp_runes_slice(rs, 0, c)), S("\u200b"), + tp_runes_str(tp_runes_slice(rs, c, rs.n))); + for (size_t i = 0; i < 4; i++) { + tp_str got = hz_track_json(tp_api_parse(noisy[i])); + if (!tp_str_eq(got, base)) { + hz_fail("noise changed the parse of %s (%s):\n%s\n%s", hz_q(s), hz_q(noisy[i]), base.p, + got.p); + } + } +} + +/* What R11.6 promises to keep: names with roles, the title, each version's type and names. */ +static tp_str shape(const tp_track *t) { + tp_buf b = {0}; + for (size_t i = 0; i < t->artists.n; i++) { + tp_buf_str(&b, t->artists.p[i].name); + tp_buf_byte(&b, '/'); + tp_buf_str(&b, t->artists.p[i].role); + tp_buf_byte(&b, ';'); + } + tp_buf_byte(&b, '|'); + tp_buf_str(&b, t->title); + tp_buf_byte(&b, '|'); + for (size_t i = 0; i < t->versions.n; i++) { + const tp_version *v = &t->versions.p[i]; + tp_buf_str(&b, v->type); + tp_buf_byte(&b, ':'); + for (size_t k = 0; k < v->artists.n; k++) { + tp_buf_str(&b, v->artists.p[k].name); + tp_buf_byte(&b, ','); + } + tp_buf_byte(&b, ';'); + } + return tp_buf_done(&b); +} + +/* Invariant 8 (R11.6) on a warning-free track-shaped input. */ +void hz_check_round_trip(tp_str s) { + tp_track first = tp_api_parse(s), second; + tp_str formatted, a, b; + if (first.warnings.n > 0) return; + formatted = tp_api_format(&first); + second = tp_api_parse(formatted); + a = shape(&first); + b = shape(&second); + if (!tp_str_eq(a, b)) hz_fail("round trip %s -> %s:\n%s\n%s", hz_q(s), hz_q(formatted), a.p, b.p); +} + +/* strings.Trim(w, "()[],."): ASCII cutset. */ +static bool in_cutset(char c) { + return c == '(' || c == ')' || c == '[' || c == ']' || c == ',' || c == '.'; +} + +/* Invariant 6: the words of normalize(input), minus separators, joiners, feat markers and bracket + * characters. */ +static tp_strvec content_words(tp_str normalized) { + tp_strvec words = tp_split_words(normalized), out = {0}; + for (size_t i = 0; i < words.n; i++) { + tp_str w = words.p[i]; + size_t a = 0, b = w.n; + if (tp_str_eq(w, S("-")) || tp_str_eq(w, S("&")) || tp_str_eq(w, S("x")) || + tp_str_eq(w, S("vs.")) || tp_str_eq(w, S("feat."))) { + continue; + } + while (a < b && in_cutset(w.p[a])) a++; + while (b > a && in_cutset(w.p[b - 1])) b--; + if (b > a) tp_push(out, tp_str_slice(w, a, b)); + } + return out; +} + +static tp_strvec output_strings(const tp_track *t) { + tp_strvec out = {0}; + tp_push(out, t->title); + tp_push(out, t->full_title); + for (size_t i = 0; i < t->artists.n; i++) tp_push(out, t->artists.p[i].name); + for (size_t i = 0; i < t->versions.n; i++) { + tp_push(out, t->versions.p[i].raw); + for (size_t k = 0; k < t->versions.p[i].artists.n; k++) { + tp_push(out, t->versions.p[i].artists.p[k].name); + } + } + for (size_t i = 0; i < t->junk.n; i++) tp_push(out, t->junk.p[i].raw); + if (t->position) tp_push(out, t->position->raw); + if (t->timestamp) tp_push(out, t->timestamp->raw); + return out; +} + +/* Invariant 6 ("no word goes missing") on a track-shaped input. */ +void hz_check_conservation(tp_str s) { + tp_track track = tp_api_parse(s); + tp_strvec fields = output_strings(&track), words = content_words(tp_api_normalize(s)); + for (size_t i = 0; i < words.n; i++) { + bool found = false; + for (size_t k = 0; k < fields.n && !found; k++) found = tp_contains(fields.p[k], words.p[i]); + if (!found) { + hz_fail("%s of %s is in no output field: %s", hz_q(words.p[i]), hz_q(s), full_json(&track).p); + } + } +} + +tp_str hz_decorated(hz_rng *r) { + static const tp_str prefixes[] = {HZ_S("01. "), HZ_S("7. "), HZ_S("12. "), HZ_S("[03:45] "), + HZ_S("1:02:03 ")}; + static const tp_str suffixes[] = {HZ_S(" (Official Video)"), HZ_S(" [HD]"), + HZ_S(" [Free Download]"), HZ_S(" (VIP)")}; + tp_str s = hz_track_string(r); + if (hz_chance(r, 30)) s = cat(PICK(r, prefixes), s); + if (hz_chance(r, 30)) s = cat(s, PICK(r, suffixes)); + return s; +} + +static bool junk_eq(tp_junk_vec a, tp_junk_vec b) { + if (a.n != b.n) return false; + for (size_t i = 0; i < a.n; i++) { + if (!tp_str_eq(a.p[i].raw, b.p[i].raw) || !tp_str_eq(a.p[i].kind, b.p[i].kind)) return false; + } + return true; +} + +/* A copy of a track's versions that can be changed without touching the original. */ +static tp_version_vec own_versions(tp_version_vec v) { + tp_version_vec out; + tp_clone(out, v); + return out; +} + +/* Invariant 7 on a warning-free track-shaped input. */ +void hz_check_metamorphic(tp_str s) { + tp_track plain = tp_api_parse(s), numbered, noisy, square, upper; + tp_junk_vec want = {0}; + tp_junk video; + tp_str head, group, shouted, a, b; + ptrdiff_t open; + if (plain.warnings.n > 0) return; + /* Prefixing `01. ` only sets the position. */ + numbered = tp_api_parse(cat(S("01. "), s)); + if (numbered.position == NULL || !tp_str_eq(numbered.position->raw, S("01")) || + numbered.position->number != 1) { + hz_fail("01. %s: position %s", s.p, full_json(&numbered).p); + } + numbered.position = NULL; + a = hz_track_json(plain); + b = hz_track_json(numbered); + if (!tp_str_eq(a, b)) { + hz_fail("01. changed more than the position of %s:\n%s\n%s", hz_q(s), a.p, b.p); + } + /* Appending ` (Official Video)` only adds junk (and may switch the mode to youtube). */ + noisy = tp_api_parse(cat(s, S(" (Official Video)"))); + tp_append(want, plain.junk); + video.raw = S("Official Video"); + video.kind = TP_JUNK_KIND_VIDEO; + tp_push(want, video); + if (!junk_eq(noisy.junk, want)) { + hz_fail("%s (Official Video): junk %s", hz_q(s), full_json(&noisy).p); + } + if (!tp_str_eq(noisy.mode, plain.mode) && !tp_str_eq(noisy.mode, TP_MODE_YOUTUBE)) { + hz_fail("%s (Official Video): mode %s", hz_q(s), hz_q(noisy.mode)); + } + noisy.junk = plain.junk; + noisy.mode = plain.mode; + b = hz_track_json(noisy); + if (!tp_str_eq(a, b)) { + hz_fail("(Official Video) changed more than the junk of %s:\n%s\n%s", hz_q(s), a.p, b.p); + } + if (!tp_has_suffix(s, S(" Remix)"))) return; + open = tp_last_index_byte(s, '('); + head = tp_str_slice(s, 0, (size_t)open); + group = tp_str_slice(s, (size_t)open + 1, s.n - 1); + /* (X Remix) and [X Remix] differ only in the delimiter. */ + square = tp_api_parse(cat(head, cat3(S("["), group, S("]")))); + if (square.versions.n == 0 || + !tp_str_eq(tp_last(square.versions).delimiter, TP_DELIMITER_SQUARE)) { + hz_fail("%s: no square version", hz_q(s)); + } + square.versions = own_versions(square.versions); + for (size_t i = 0; i < square.versions.n; i++) { + square.versions.p[i].delimiter = TP_DELIMITER_PAREN; + } + square.full_title = plain.full_title; + b = hz_track_json(square); + if (!tp_str_eq(a, b)) { + hz_fail("[ ] changed more than the delimiter of %s:\n%s\n%s", hz_q(s), a.p, b.p); + } + /* REMIX and Remix differ only in raw. */ + shouted = tp_replace_all(group, S(" Remix"), S(" REMIX")); + upper = tp_api_parse(cat(head, cat3(S("("), shouted, S(")")))); + if (upper.versions.n == 0 || !tp_str_eq(tp_last(upper.versions).raw, shouted)) { + hz_fail("%s: REMIX raw %s", hz_q(s), full_json(&upper).p); + } + upper.versions = own_versions(upper.versions); + for (size_t i = 0; i < upper.versions.n; i++) { + if (i < plain.versions.n) upper.versions.p[i].raw = plain.versions.p[i].raw; + } + upper.full_title = plain.full_title; + b = hz_track_json(upper); + if (!tp_str_eq(a, b)) hz_fail("REMIX changed more than raw in %s:\n%s\n%s", hz_q(s), a.p, b.p); +} + +void hz_check_shaped_track(hz_rng *r) { + tp_str s = hz_track_string(r); + tp_track track; + tp_format_options fo; + hz_check_noise_insensitive(s, hz_below(r, 1000)); + hz_check_round_trip(s); + hz_check_metamorphic(s); + hz_check_conservation(hz_decorated(r)); + track = tp_api_parse(s); + fo = hz_format_options_from(r, s); + (void)tp_api_format_with(&track, &fo); +} + +/* -------------------------------------------------------------------------------------------- */ +/* Tracklist checks */ + +static tp_strvec raw_lines(const tp_tracklist *l) { + tp_strvec out = {0}; + for (size_t i = 0; i < l->entries.n; i++) { + tp_push(out, cat(l->entries.p[i].raw, l->entries.p[i].eol)); + } + return out; +} + +static tp_tracklist parse_list(tp_str text) { return tp_api_parse_tracklist(text); } + +static tp_strvec raws(tp_str text) { + tp_tracklist l = parse_list(text); + tp_strvec out = {0}; + for (size_t i = 0; i < l.entries.n; i++) tp_push(out, l.entries.p[i].raw); + return out; +} + +/* R13.11 invariants 1 and 2 on any text: lossless, parts concatenate to raw, line numbering and + * terminators, the kind/track pairing. */ +void hz_check_tracklist(tp_str text, const tp_tracklist_options *o) { + tp_str clean = tp_sanitize(text), got; + tp_tracklist l = tp_api_parse_tracklist_with(text, o); + got = tp_join(raw_lines(&l), TP_EMPTY); + if (!tp_str_eq(got, clean)) hz_fail("not lossless: %s gives %s", hz_q(text), hz_q(got)); + if (l.stats.lines != (ptrdiff_t)l.entries.n) { + hz_fail("%s: stats.lines %ld, %lu entries", hz_q(text), (long)l.stats.lines, + (unsigned long)l.entries.n); + } + for (size_t i = 0; i < l.entries.n; i++) { + const tp_entry *e = &l.entries.p[i]; + const tp_parts *p = &e->parts; + bool is_track = + tp_str_eq(e->kind, TP_ENTRY_KIND_TRACK) || tp_str_eq(e->kind, TP_ENTRY_KIND_MARKER); + if (!tp_str_eq(cat(cat3(p->lead, p->time, p->gap), p->rest), e->raw)) { + hz_fail("%s line %lu: parts do not join to %s", hz_q(text), (unsigned long)i + 1, + hz_q(e->raw)); + } + /* R13.1.3: without a time, `lead` holds at most a bullet; `time` and `gap` are empty. */ + if ((e->time == NULL) != (p->time.n == 0) || (e->time == NULL && p->gap.n != 0)) { + hz_fail("%s line %lu: time and parts disagree", hz_q(text), (unsigned long)i + 1); + } + if ((e->track != NULL) != is_track) { + hz_fail("%s line %lu: kind %s with track %d", hz_q(text), (unsigned long)i + 1, hz_q(e->kind), + e->track != NULL); + } + if (tp_contains_any(e->raw, S("\r\n"))) { + hz_fail("%s line %lu: raw %s holds a line break", hz_q(text), (unsigned long)i + 1, + hz_q(e->raw)); + } + if (e->line != (ptrdiff_t)i + 1) { + hz_fail("%s: entry %lu has line %ld", hz_q(text), (unsigned long)i, (long)e->line); + } + /* Only the last line may lack a terminator. */ + if (e->eol.n == 0 && i != l.entries.n - 1) { + hz_fail("%s line %lu: no terminator before the last line", hz_q(text), (unsigned long)i + 1); + } + } +} + +static tp_json empty_object(void) { + tp_json v = tp_json_null(); + v.kind = TP_JSON_OBJECT; + v.obj = (const tp_json_member *)tp_alloc(0); + return v; +} + +/* R13.11 invariant 2 for edits: any edit list through the JSON door returns a result whose + * changed lines are sorted, unique and in range, and whose text parses losslessly. */ +void hz_check_loose_edits(tp_str text, tp_json edits) { + tp_str clean = tp_sanitize(text), out, new_text = TP_EMPTY; + tp_json v, changed; + tp_jw ew = tp_jw_new(); + const char *what; + size_t n; + double prev = 0; + tp_tracklist l; + tp_json_write(&edits, &ew); + { + tp_buf b = {0}; + tp_buf_cstr(&b, "applyEdits("); + tp_buf_cstr(&b, hz_q(text)); + tp_buf_cstr(&b, ", "); + tp_buf_str(&b, tp_jw_done(&ew)); + tp_buf_byte(&b, ')'); + what = tp_buf_done(&b).p; + } + out = tp_wire_call(S("applyEdits"), clean, empty_object(), empty_object(), edits); + if (!tp_json_parse(out, &v)) hz_fail("%s: invalid JSON %s", what, hz_q(out)); + tp_json_get_string(v, S("text"), &new_text); + l = parse_list(new_text); + n = l.entries.n; + if (!tp_json_get(v, S("changed"), &changed) || changed.kind != TP_JSON_ARRAY) { + hz_fail("%s: no changed array in %s", what, out.p); + } + for (size_t i = 0; i < changed.arr_n; i++) { + const tp_json *c = &changed.arr[i]; + if (c->kind != TP_JSON_NUMBER || c->num <= prev || c->num > (double)n) { + hz_fail("%s: changed out of order or range with %lu lines: %s", what, (unsigned long)n, + out.p); + } + prev = c->num; + } + if (!tp_str_eq(tp_join(raw_lines(&l), TP_EMPTY), new_text)) { + hz_fail("%s: the result does not parse losslessly", what); + } +} + +static bool warned(const tp_edit_result *r, const tp_str *codes, size_t n) { + for (size_t i = 0; i < r->warnings.n; i++) { + for (size_t k = 0; k < n; k++) { + if (tp_str_eq(r->warnings.p[i].code, codes[k])) return true; + } + } + return false; +} + +static tp_edit_result apply1(tp_str text, tp_edit e) { return tp_api_apply_edits(text, &e, 1); } + +/* R13.11 invariant 3: no edits return the text unchanged. */ +void hz_check_identity(tp_str text) { + tp_edit none[1]; + for (int k = 0; k < 2; k++) { + tp_edit_result r = tp_api_apply_edits(text, k == 0 ? NULL : none, 0); + if (!tp_str_eq(r.text, tp_sanitize(text)) || r.changed.n != 0 || r.warnings.n != 0) { + hz_fail("applyEdits(%s, none) = %s", hz_q(text), tp_edit_result_json(&r).p); + } + } +} + +/* R13.11 invariant 3: an edit on one line leaves every other line byte for byte, and changes only + * that line. */ +void hz_check_locality(tp_str text, hz_rng *r) { + static const tp_str invalid[] = {HZ_S("edit-invalid")}; + tp_tracklist before, after_list; + tp_strvec lines, after; + int64_t line; + double seconds; + tp_edit edit; + tp_edit_result res; + const char *what; + text = tp_sanitize(text); + before = parse_list(text); + lines = raw_lines(&before); + if (lines.n == 0) return; + line = 1 + hz_below(r, (int)lines.n); + seconds = (double)(hz_below(r, 8001) - 4000); + switch (hz_below(r, 3)) { + case 0: + edit = tp_edit_set_time(line, seconds); + break; + case 1: + edit = tp_edit_set_rest(line, S("New - Rest")); + break; + default: + edit = tp_edit_shift_lines(seconds, &line, 1); + } + { + tp_jw w = tp_jw_new(); + tp_edit_write(&edit, &w); + what = tp_jw_done(&w).p; + } + res = apply1(text, edit); + after_list = parse_list(res.text); + after = raw_lines(&after_list); + if (after.n != lines.n) { + hz_fail("%s on %s: %lu lines became %lu", what, hz_q(text), (unsigned long)lines.n, + (unsigned long)after.n); + } + for (size_t i = 0; i < after.n; i++) { + if ((int64_t)i != line - 1 && !tp_str_eq(after.p[i], lines.p[i])) { + hz_fail("%s on %s: line %lu changed: %s -> %s", what, hz_q(text), (unsigned long)i + 1, + hz_q(lines.p[i]), hz_q(after.p[i])); + } + } + for (size_t i = 0; i < res.changed.n; i++) { + if (res.changed.p[i] != line) { + hz_fail("%s on %s: changed %s", what, hz_q(text), tp_edit_result_json(&res).p); + } + } + if (warned(&res, invalid, 1) && (!tp_str_eq(res.text, text) || res.changed.n != 0)) { + hz_fail("%s on %s: an invalid edit changed the text", what, hz_q(text)); + } +} + +/* hasBareCR: a "\r" that is not part of a "\r\n". */ +static bool has_bare_cr(tp_str text) { + for (size_t i = 0; i < text.n; i++) { + if (text.p[i] == '\r' && (i + 1 >= text.n || text.p[i + 1] != '\n')) return true; + } + return false; +} + +/* R13.11 invariant 3 for insert and delete: the other lines stay. */ +void hz_check_insert_delete(tp_str text, hz_rng *r) { + tp_strvec before, expected = {0}, got, kept = {0}; + tp_str new_line = S("00:00 New - Line"); + int at, line; + tp_edit_result ins, del; + bool found = false; + text = tp_sanitize(text); + before = raws(text); + /* R13.9.5: after an edit the lines are re-read, so a line ending in a bare "\r" next to an + * empty "\n" line merges with it. The simple expectation below does not model that. */ + if (before.n == 0 || has_bare_cr(text)) return; + at = hz_below(r, (int)before.n + 1); + ins = apply1(text, tp_edit_insert(at, new_line)); + tp_append(expected, before); + tp_insert(expected, (size_t)at, new_line); + got = raws(ins.text); + if (!strvec_eq(got, expected)) { + hz_fail("insert after %d in %s: %s, want %s", at, hz_q(text), strvec_show(got), + strvec_show(expected)); + } + for (size_t i = 0; i < ins.changed.n; i++) found = found || ins.changed.p[i] == at + 1; + if (!found) { + hz_fail("insert after %d in %s: changed %s", at, hz_q(text), tp_edit_result_json(&ins).p); + } + line = 1 + hz_below(r, (int)before.n); + del = apply1(text, tp_edit_delete(line)); + tp_append(kept, before); + tp_remove(kept, (size_t)line - 1, (size_t)line); + got = raws(del.text); + /* Deleting the last line moves its eol ("" here) up: an empty line that becomes last without + * an eol is not a line (R13.9.5), so trailing empty lines may disappear. */ + while (kept.n > 0 && tp_last(kept).n == 0 && got.n < kept.n && (size_t)line == before.n) kept.n--; + if (!strvec_eq(got, kept)) { + hz_fail("delete %d in %s: %s, want %s", line, hz_q(text), strvec_show(got), strvec_show(kept)); + } +} + +static tp_intvec time_widths(tp_str text) { + tp_tracklist l = parse_list(text); + tp_intvec out = {0}; + for (size_t i = 0; i < l.entries.n; i++) { + const tp_entry *e = &l.entries.p[i]; + tp_push(out, e->time ? (int64_t)e->time->raw.n : -1); + } + return out; +} + +static bool intvec_eq(tp_intvec a, tp_intvec b) { + return a.n == b.n && (a.n == 0 || memcmp(a.p, b.p, a.n * sizeof *a.p) == 0); +} + +/* R13.11 invariant 4: shift(+s) then shift(-s) restores the text, unless a time was clamped or + * upgraded or its digit count grew (R13.9.7). Reports whether the round trip was checked. */ +bool hz_check_shift_round_trip(tp_str text, hz_rng *r) { + static const tp_str lossy[] = {HZ_S("time-clamped"), HZ_S("style-upgraded"), + HZ_S("edit-invalid")}; + double s; + size_t n; + int64_t from; + bool use_from; + tp_edit_result up, down; + text = tp_sanitize(text); + s = (double)(1 + hz_below(r, 5000)); + n = parse_list(text).entries.n; + from = 1 + hz_below(r, 12); + use_from = hz_chance(r, 50) && (size_t)from <= n; + up = apply1(text, use_from ? tp_edit_shift_from(s, from) : tp_edit_shift(s)); + down = apply1(up.text, use_from ? tp_edit_shift_from(-s, from) : tp_edit_shift(-s)); + if (warned(&up, lossy, TP_COUNT(lossy)) || warned(&down, lossy, TP_COUNT(lossy)) || + !intvec_eq(time_widths(up.text), time_widths(text))) { + return false; + } + if (!tp_str_eq(down.text, text)) { + hz_fail("shift +-%s on %s gives %s", tp_number_str(s).p, hz_q(text), hz_q(down.text)); + } + return true; +} + +static tp_strvec eols_of(tp_str text) { + tp_tracklist l = parse_list(text); + tp_strvec out = {0}; + for (size_t i = 0; i < l.entries.n; i++) tp_push(out, l.entries.p[i].eol); + return out; +} + +/* R13.11 invariant 4 for sort-by-time: the eol slots stay, times ascend, a second sort changes + * nothing. */ +void hz_check_sort(tp_str text) { + tp_edit_result once, twice; + tp_strvec a, b; + tp_tracklist l; + double prev = -1; + text = tp_sanitize(text); + once = apply1(text, tp_edit_sort_by_time()); + /* An empty line sorted into the last slot (eol "") is not a line any more (R13.1.1). */ + a = eols_of(once.text); + b = eols_of(text); + if (a.n == b.n && !strvec_eq(a, b)) { + hz_fail("sort of %s moved the terminators: %s", hz_q(text), hz_q(once.text)); + } + l = parse_list(once.text); + for (size_t i = 0; i < l.entries.n; i++) { + const tp_entry *e = &l.entries.p[i]; + if (e->time) { + if (e->time->seconds < prev) { + hz_fail("sort of %s is not sorted: %s", hz_q(text), hz_q(once.text)); + } + prev = e->time->seconds; + } + } + twice = apply1(once.text, tp_edit_sort_by_time()); + if (!tp_str_eq(twice.text, once.text)) hz_fail("sort of %s is not idempotent", hz_q(text)); +} + +/* R13.11 invariant 5: the track of a one-line text is the parse of its line text in tracklist + * mode. Reports whether the line had a track. */ +bool hz_check_one_line(tp_str text) { + tp_tracklist l; + const tp_entry *e; + tp_parse_options o; + tp_track want; + tp_str a, b; + text = tp_replace_all(tp_replace_all(tp_sanitize(text), S("\r"), S(" ")), S("\n"), S(" ")); + l = parse_list(text); + if (l.entries.n == 0) return false; + if (l.entries.n != 1) hz_fail("%s: %lu entries", hz_q(text), (unsigned long)l.entries.n); + e = &l.entries.p[0]; + if (e->track == NULL) return false; + memset(&o, 0, sizeof o); + o.mode = TP_MODE_TRACKLIST; + want = tp_api_parse_with(e->track->input, &o); + a = full_json(e->track); + b = full_json(&want); + if (!tp_str_eq(a, b)) { + hz_fail("%s: the entry's track is not the parse of its text:\n%s\n%s", hz_q(text), a.p, b.p); + } + if (!tp_contains_any(e->parts.rest, S("*_")) && !e->layered && + !tp_str_eq(e->track->input, e->parts.rest)) { + hz_fail("%s: track input %s, rest %s", hz_q(text), hz_q(e->track->input), hz_q(e->parts.rest)); + } + return true; +} + +const tp_str hz_emphasis_rests[] = { + HZ_S("Noisia - Stigma"), + HZ_S("01. Phace - Plastic Acid"), + HZ_S("Intro"), + HZ_S("Paperclip interview"), + HZ_S("Mefjus - Suicide Bassline (VIP)"), + HZ_S("ID - ID"), + HZ_S("Noisia feat. Foreign Beggars - Shellshock"), +}; +const size_t hz_emphasis_rests_n = TP_COUNT(hz_emphasis_rests); + +/* R13.11 invariant 6: emphasis around the time or the track part changes neither the time, the + * kind nor the track. */ +void hz_check_emphasis(tp_str t, tp_str rest) { + static const tp_str wraps[][2] = { + {HZ_S(""), HZ_S("")}, {HZ_S("**"), HZ_S("**")}, {HZ_S("__"), HZ_S("__")}, + {HZ_S("*"), HZ_S("*")}, {HZ_S("_"), HZ_S("_")}, {HZ_S("**["), HZ_S("]**")}, + {HZ_S("[**"), HZ_S("**]")}, {HZ_S("**[**"), HZ_S("**]")}, {HZ_S("_["), HZ_S("]_")}, + }; + static const tp_str rest_wraps[] = {HZ_S(""), HZ_S("**"), HZ_S("__"), HZ_S("*"), HZ_S("_")}; + tp_str plain = cat3(t, S(" "), rest); + tp_tracklist bl = parse_list(plain); + const tp_entry *bare = &bl.entries.p[0]; + for (size_t w = 0; w < TP_COUNT(wraps); w++) { + for (size_t k = 0; k < TP_COUNT(rest_wraps); k++) { + tp_str decorated = cat(cat3(wraps[w][0], t, wraps[w][1]), + cat(S(" "), cat3(rest_wraps[k], rest, rest_wraps[k]))); + tp_tracklist l = parse_list(decorated); + const tp_entry *e = &l.entries.p[0]; + if ((e->time == NULL) != (bare->time == NULL) || + (e->time != NULL && e->time->seconds != bare->time->seconds)) { + hz_fail("%s: time differs from %s", hz_q(decorated), hz_q(plain)); + } + if (!tp_str_eq(e->kind, bare->kind)) { + hz_fail("%s: kind %s, want %s", hz_q(decorated), hz_q(e->kind), hz_q(bare->kind)); + } + if ((e->track == NULL) != (bare->track == NULL) || + (e->track != NULL && !tp_str_eq(full_json(e->track), full_json(bare->track)))) { + hz_fail("%s: track differs from %s", hz_q(decorated), hz_q(plain)); + } + } + } +} + +/* -------------------------------------------------------------------------------------------- */ +/* The public tracklist and edit functions against the internal ones */ + +void hz_check_public_tracklist(tp_str text) { + static const long long shift_lines[] = {1, 2}; + static const int64_t shift_lines64[] = {1, 2}; + trackparse_tracklist *l = trackparse_parse_tracklist(nz(text), text.n); + trackparse_tracklist_options *po; + trackparse_edits *pe; + trackparse_edit_result *pr; + tp_tracklist_options o; + tp_edit edits[7]; + tp_edit_result ir; + tp_tracklist il; + if (l == NULL) hz_fail("trackparse_parse_tracklist(%s) returned NULL", hz_q(text)); + il = tp_api_parse_tracklist(text); + same("trackparse_parse_tracklist", text, own(trackparse_tracklist_to_json(l), "to_json", text), + tp_tracklist_json(&il)); + trackparse_tracklist_free(l); + + po = trackparse_tracklist_options_new(); + if (po == NULL || !trackparse_tracklist_options_set_mode(po, TRACKPARSE_MODE_AUTO) || + !trackparse_tracklist_options_set_audio_seconds(po, 600.5) || + !trackparse_tracklist_options_add_known_artist(po, "Camo & Krooked", 14) || + !trackparse_tracklist_options_add_marker_word(po, "Break", TRACKPARSE_NUL_TERMINATED) || + !trackparse_tracklist_options_add_junk(po, "out now", TRACKPARSE_NUL_TERMINATED, "promo", + TRACKPARSE_NUL_TERMINATED)) { + hz_fail("tracklist options: out of memory"); + } + memset(&o, 0, sizeof o); + o.mode = TP_MODE_AUTO; + o.audio_seconds = num(600.5); + tp_push(o.known_artists, S("Camo & Krooked")); + tp_push(o.marker_words, S("Break")); + { + tp_junk_phrase j; + j.phrase = S("out now"); + j.kind = TP_JUNK_KIND_PROMO; + tp_push(o.keywords.junk, j); + } + l = trackparse_parse_tracklist_with(nz(text), text.n, po); + trackparse_tracklist_options_free(po); + if (l == NULL) hz_fail("trackparse_parse_tracklist_with(%s) returned NULL", hz_q(text)); + il = tp_api_parse_tracklist_with(text, &o); + same("trackparse_parse_tracklist_with", text, + own(trackparse_tracklist_to_json(l), "to_json", text), tp_tracklist_json(&il)); + trackparse_tracklist_free(l); + + pe = trackparse_edits_new(); + if (pe == NULL || !trackparse_edits_set_time(pe, 1, 62.5) || + !trackparse_edits_shift_from(pe, -1.25, 2) || + !trackparse_edits_shift_lines(pe, 3, shift_lines, 2) || !trackparse_edits_sort_by_time(pe) || + !trackparse_edits_insert(pe, 0, "00:00 X - Y", TRACKPARSE_NUL_TERMINATED) || + !trackparse_edits_set_rest(pe, 2, nz(text), text.n) || !trackparse_edits_delete(pe, 3)) { + hz_fail("edits: out of memory"); + } + edits[0] = tp_edit_set_time(1, 62.5); + edits[1] = tp_edit_shift_from(-1.25, 2); + edits[2] = tp_edit_shift_lines(3, shift_lines64, 2); + edits[3] = tp_edit_sort_by_time(); + edits[4] = tp_edit_insert(0, S("00:00 X - Y")); + edits[5] = tp_edit_set_rest(2, text); + edits[6] = tp_edit_delete(3); + pr = trackparse_apply_edits(nz(text), text.n, pe); + trackparse_edits_free(pe); + if (pr == NULL) hz_fail("trackparse_apply_edits(%s) returned NULL", hz_q(text)); + ir = tp_api_apply_edits(text, edits, TP_COUNT(edits)); + same("trackparse_apply_edits", text, own(trackparse_edit_result_to_json(pr), "to_json", text), + tp_edit_result_json(&ir)); + trackparse_edit_result_free(pr); +} + +/* -------------------------------------------------------------------------------------------- */ +/* Fixture cases */ + +static char *heap_copy(tp_str s) { + char *p = (char *)malloc(s.n + 1); + if (!p) { + fprintf(stderr, "out of memory\n"); + exit(2); + } + if (s.n) memcpy(p, s.p, s.n); + p[s.n] = '\0'; + return p; +} + +static char *read_whole(const char *path, size_t *len) { + FILE *f = fopen(path, "rb"); + char *buf = NULL; + size_t n = 0, cap = 0; + if (!f) return NULL; + for (;;) { + size_t got; + if (cap - n < 65536) { + char *nb; + cap = cap ? cap * 2 : 1 << 20; + nb = (char *)realloc(buf, cap); + if (!nb) { + free(buf); + fclose(f); + return NULL; + } + buf = nb; + } + got = fread(buf + n, 1, cap - n, f); + n += got; + if (got == 0) break; + } + fclose(f); + *len = n; + return buf; +} + +/* {...defaults[key], ...c[key]} (shallow), as the fixture runner merges options. */ +static tp_json merged(tp_json defaults, tp_json c, tp_str key) { + TP_VEC(tp_json_member) members = {0}; + tp_json out = empty_object(); + tp_json srcs[2]; + srcs[0] = defaults; + srcs[1] = c; + for (size_t s = 0; s < 2; s++) { + tp_json v; + if (!tp_json_get(srcs[s], key, &v) || v.kind != TP_JSON_OBJECT) continue; + for (size_t i = 0; i < v.obj_n; i++) { + bool replaced = false; + for (size_t j = 0; j < members.n; j++) { + if (tp_str_eq(members.p[j].key, v.obj[i].key)) { + members.p[j].val = v.obj[i].val; + replaced = true; + } + } + if (!replaced) tp_push(members, v.obj[i]); + } + } + if (members.n) { + out.obj = members.p; + out.obj_n = members.n; + } + return out; +} + +typedef struct load_arg { + const char *path; + const char *text; + size_t len; + hz_cases *out; + size_t cap; +} load_arg; + +static void load_file(void *p) { + load_arg *a = (load_arg *)p; + tp_json data, cases, defaults = tp_json_null(); + tp_str whole; + whole.p = a->text; + whole.n = a->len; + if (!tp_json_parse(whole, &data)) { + fprintf(stderr, "%s: invalid JSON\n", a->path); + exit(2); + } + if (!tp_json_get(data, S("cases"), &cases) || cases.kind != TP_JSON_ARRAY) return; + tp_json_get(data, S("defaults"), &defaults); + for (size_t i = 0; i < cases.arr_n; i++) { + tp_json c = cases.arr[i], options, format_options, edits; + tp_str fn, input = TP_EMPTY, id = TP_EMPTY; + tp_jw w = tp_jw_new(); + hz_case *hc; + if (!tp_json_get_string(c, S("fn"), &fn) && !tp_json_get_string(defaults, S("fn"), &fn)) { + fn = S("parse"); + } + tp_json_get_string(c, S("input"), &input); + tp_json_get_string(c, S("id"), &id); + options = merged(defaults, c, S("options")); + format_options = merged(defaults, c, S("formatOptions")); + if (!tp_json_get(c, S("edits"), &edits)) { + edits = tp_json_null(); + edits.kind = TP_JSON_ARRAY; + edits.arr = (const tp_json *)tp_alloc(0); + } + tp_jw_open(&w, '{'); + tp_jw_key(&w, S("fn")); + tp_jw_str(&w, fn); + tp_jw_key(&w, S("input")); + tp_jw_str(&w, input); + tp_jw_key(&w, S("options")); + tp_json_write(&options, &w); + tp_jw_key(&w, S("formatOptions")); + tp_json_write(&format_options, &w); + tp_jw_key(&w, S("edits")); + tp_json_write(&edits, &w); + tp_jw_close(&w, '}'); + if (a->out->n == a->cap) { + hz_case *ni; + a->cap = a->cap ? a->cap * 2 : 1024; + ni = (hz_case *)realloc(a->out->items, a->cap * sizeof *ni); + if (!ni) { + fprintf(stderr, "out of memory\n"); + exit(2); + } + a->out->items = ni; + } + hc = &a->out->items[a->out->n++]; + hc->id = heap_copy(id); + hc->fn = heap_copy(fn); + hc->input = heap_copy(input); + hc->input_n = input.n; + { + tp_str line = tp_jw_done(&w); + hc->line = heap_copy(line); + hc->line_n = line.n; + } + hc->has_options = options.obj_n > 0 || format_options.obj_n > 0; + } +} + +hz_cases hz_load_cases(int count, char **paths) { + hz_cases out = {NULL, 0}; + load_arg a; + memset(&a, 0, sizeof a); + a.out = &out; + for (int i = 0; i < count; i++) { + size_t len = 0; + char *text = read_whole(paths[i], &len); + if (!text) { + fprintf(stderr, "cannot read %s\n", paths[i]); + exit(2); + } + a.path = paths[i]; + a.text = text; + a.len = len; + hz_scoped(load_file, &a); + free(text); + } + return out; +} + +void hz_free_cases(hz_cases *c) { + for (size_t i = 0; i < c->n; i++) { + free(c->items[i].id); + free(c->items[i].fn); + free(c->items[i].input); + free(c->items[i].line); + } + free(c->items); + c->items = NULL; + c->n = 0; +} diff --git a/c/tests/hardening.h b/c/tests/hardening.h new file mode 100644 index 0000000..9a2b426 --- /dev/null +++ b/c/tests/hardening.h @@ -0,0 +1,136 @@ +/* hardening.h: what the hardening tests and the fuzz targets share (PLAN.md step 8). + * + * - The seeded input generator of go/properties_test.go (mulberry32 over the same fragments), + * so a failure is reproducible from its seed and case number. + * - The SPEC invariant checks ("Invariants" and R13.11) of go/properties_test.go, over the + * internal typed API (tp_api_*: Go's exported functions), plus hz_check_public, which holds + * the public C API (include/trackparse.h) to the same JSON. test_properties.c runs them on + * generated inputs, the fuzz targets on what libFuzzer finds. + * - A fixture loader (the JSONL case lines compare-ports sends), timers and scopes. + * + * Every hz_ function that returns or takes tp_str/tp_json allocates in the current arena, so it + * runs inside hz_scoped (or another armed scope). A failed check prints what failed and calls + * abort(): ctest reports it, libFuzzer saves the input. The JSON Schema checks of the Go suite + * are not repeated here: the C port has no schema validator, and the fixture outputs are + * validated by scripts/validate_outputs.mjs. + */ +#ifndef TP_HARDENING_H +#define TP_HARDENING_H + +#include + +#include "../src/internal.h" + +/* -------------------------------------------------------------------------------------------- */ +/* Scopes, failures, timing */ + +typedef void (*hz_fn)(void *arg); + +/* Run fn(arg) in a fresh arena scope that is freed afterwards; abort() on out of memory. */ +void hz_scoped(hz_fn fn, void *arg); + +/* Print the message (printf format) and abort(). */ +#if defined(__GNUC__) || defined(__clang__) +__attribute__((format(printf, 1, 2))) +#endif +TP_NORETURN void +hz_fail(const char *fmt, ...); + +/* s as a quoted JSON string, for messages (arena). */ +const char *hz_q(tp_str s); + +/* Seconds since an arbitrary point (timespec_get, C11). */ +double hz_now(void); +/* The fastest of three runs of fn(arg), each in its own scope, in seconds. */ +double hz_best_of3(hz_fn fn, void *arg); +/* How much slower than an optimized plain build this one is: TRACKPARSE_SLOWDOWN from the + * environment when set, else 10 when built with sanitizers (TRACKPARSE_SANITIZED), else 1. */ +double hz_slowdown(void); + +/* -------------------------------------------------------------------------------------------- */ +/* Generator (go/properties_test.go) */ + +typedef struct hz_rng { + uint32_t s; +} hz_rng; + +hz_rng hz_rng_new(uint64_t seed); +uint32_t hz_next(hz_rng *r); +int hz_below(hz_rng *r, int n); +bool hz_chance(hz_rng *r, int percent); +uint64_t hz_fnv1a(const void *p, size_t n); + +extern const tp_str hz_tricky_fragments[]; +extern const size_t hz_tricky_fragments_n; +extern const tp_str hz_time_styles[]; +extern const size_t hz_time_styles_n; +extern const tp_str hz_emphasis_rests[]; +extern const size_t hz_emphasis_rests_n; + +tp_str hz_any_string(hz_rng *r); +tp_str hz_track_string(hz_rng *r); +tp_str hz_quiet_track(hz_rng *r); +tp_str hz_decorated(hz_rng *r); +tp_str hz_noisy_text(hz_rng *r); +tp_str hz_list_line(hz_rng *r); +tp_str hz_timed_list(hz_rng *r); +tp_str hz_any_text(hz_rng *r); +tp_str hz_write_time(tp_str style, int seconds, int frac); +tp_json hz_loose_edits(hz_rng *r); +tp_format_options hz_format_options_from(hz_rng *r, tp_str s); + +/* The option sets of go/fuzz_test.go. */ +#define HZ_FUZZ_PARSE_OPTIONS 7 +#define HZ_FUZZ_TRACKLIST_OPTIONS 7 +tp_parse_options hz_fuzz_parse_options(int i); +tp_tracklist_options hz_fuzz_tracklist_options(int i); + +/* -------------------------------------------------------------------------------------------- */ +/* Checks (go/properties_test.go) */ + +tp_str hz_track_json(tp_track t); /* without its input */ +void hz_check_artist_hygiene(tp_str s, const tp_artist_vec *artists); +void hz_check_track_totality(tp_str s); +/* The public API (trackparse_*) gives the same JSON as the internal one for s. */ +void hz_check_public(tp_str s); +void hz_check_noise_insensitive(tp_str s, int cut); +void hz_check_round_trip(tp_str s); +void hz_check_conservation(tp_str s); +void hz_check_metamorphic(tp_str s); +void hz_check_shaped_track(hz_rng *r); +void hz_check_tracklist(tp_str text, const tp_tracklist_options *o); +void hz_check_loose_edits(tp_str text, tp_json edits); +void hz_check_identity(tp_str text); +void hz_check_locality(tp_str text, hz_rng *r); +void hz_check_insert_delete(tp_str text, hz_rng *r); +bool hz_check_shift_round_trip(tp_str text, hz_rng *r); +void hz_check_sort(tp_str text); +bool hz_check_one_line(tp_str text); +void hz_check_emphasis(tp_str t, tp_str rest); +/* The public tracklist and edit functions give the same JSON as the internal ones. */ +void hz_check_public_tracklist(tp_str text); + +/* -------------------------------------------------------------------------------------------- */ +/* Fixture cases */ + +typedef struct hz_case { + char *id; + char *fn; /* parse, parseArtists, format, normalize, parseTracklist, applyEdits */ + char *input; /* NUL-terminated; may hold U+0000, so use input_n */ + size_t input_n; + char *line; /* the case as one JSONL object {"fn","input","options","formatOptions","edits"}, + defaults merged (what compare-ports sends to the dump tool) */ + size_t line_n; + bool has_options; /* options or formatOptions not empty */ +} hz_case; + +typedef struct hz_cases { + hz_case *items; + size_t n; +} hz_cases; + +/* Every case of the given fixture files, on the heap. Exits 2 when a file cannot be read. */ +hz_cases hz_load_cases(int count, char **paths); +void hz_free_cases(hz_cases *c); + +#endif /* TP_HARDENING_H */ diff --git a/c/tests/match.c b/c/tests/match.c new file mode 100644 index 0000000..ef5a411 --- /dev/null +++ b/c/tests/match.c @@ -0,0 +1,259 @@ +/* match.c: the fixture matcher (go/match_test.go). Recursion depth is bounded by the JSON + * reader's depth limit. */ +#include "match.h" + +static const char hexdigits[] = "0123456789abcdef"; + +void tp_json_quote(tp_buf *b, tp_str s) { + tp_buf_byte(b, '"'); + for (size_t i = 0; i < s.n; i++) { + unsigned char c = (unsigned char)s.p[i]; + switch (c) { + case '"': + tp_buf_cstr(b, "\\\""); + break; + case '\\': + tp_buf_cstr(b, "\\\\"); + break; + case '\b': + tp_buf_cstr(b, "\\b"); + break; + case '\f': + tp_buf_cstr(b, "\\f"); + break; + case '\n': + tp_buf_cstr(b, "\\n"); + break; + case '\r': + tp_buf_cstr(b, "\\r"); + break; + case '\t': + tp_buf_cstr(b, "\\t"); + break; + default: + if (c < 0x20) { + tp_buf_cstr(b, "\\u00"); + tp_buf_byte(b, hexdigits[c >> 4]); + tp_buf_byte(b, hexdigits[c & 15]); + } else { + tp_buf_byte(b, (char)c); + } + } + } + tp_buf_byte(b, '"'); +} + +static void show_into(tp_buf *b, tp_json v) { + switch (v.kind) { + case TP_JSON_NULL: + tp_buf_cstr(b, "null"); + break; + case TP_JSON_BOOL: + tp_buf_cstr(b, v.b ? "true" : "false"); + break; + case TP_JSON_NUMBER: + if (tp_is_nan(v.num) || tp_is_inf(v.num)) { + tp_buf_cstr(b, "null"); + } else { + tp_buf_number(b, v.num); + } + break; + case TP_JSON_STRING: + tp_json_quote(b, v.str); + break; + case TP_JSON_ARRAY: + tp_buf_byte(b, '['); + for (size_t i = 0; i < v.arr_n; i++) { + if (i) tp_buf_byte(b, ','); + show_into(b, v.arr[i]); + } + tp_buf_byte(b, ']'); + break; + case TP_JSON_OBJECT: + tp_buf_byte(b, '{'); + for (size_t i = 0; i < v.obj_n; i++) { + if (i) tp_buf_byte(b, ','); + tp_json_quote(b, v.obj[i].key); + tp_buf_byte(b, ':'); + show_into(b, v.obj[i].val); + } + tp_buf_byte(b, '}'); + break; + } +} + +tp_str tp_json_show(tp_json v) { + tp_buf b = {0}; + show_into(&b, v); + return tp_buf_done(&b); +} + +/* Scalars compare as JS does: numbers by value (7 equals 7.0), strings exactly. */ +static bool same_scalar(tp_json e, tp_json a) { + if (e.kind != a.kind) return false; + switch (e.kind) { + case TP_JSON_NULL: + return true; + case TP_JSON_BOOL: + return e.b == a.b; + case TP_JSON_NUMBER: + return e.num == a.num; + case TP_JSON_STRING: + return tp_str_eq(e.str, a.str); + default: + return false; + } +} + +/* ": expected , got " */ +static tp_str expected_got(tp_str path, tp_json e, tp_json a) { + tp_buf b = {0}; + tp_buf_str(&b, path); + tp_buf_cstr(&b, ": expected "); + tp_buf_str(&b, tp_json_show(e)); + tp_buf_cstr(&b, ", got "); + tp_buf_str(&b, tp_json_show(a)); + return tp_buf_done(&b); +} + +static tp_str index_path(tp_str path, size_t i) { + tp_buf b = {0}; + tp_buf_str(&b, path); + tp_buf_byte(&b, '['); + tp_buf_int(&b, (int64_t)i); + tp_buf_byte(&b, ']'); + return tp_buf_done(&b); +} + +static tp_str key_path(tp_str path, tp_str key) { return tp_concat3(path, TP_S("."), key); } + +/* match: "partial" (README rules 1 to 4); empty on a match. */ +static tp_str match_partial(tp_json expected, tp_json actual, tp_str path) { + if (expected.kind == TP_JSON_ARRAY) { + if (actual.kind != TP_JSON_ARRAY) { + return tp_concat(path, tp_concat(TP_S(": expected an array, got "), tp_json_show(actual))); + } + if (actual.arr_n != expected.arr_n) { + tp_buf b = {0}; + tp_buf_str(&b, path); + tp_buf_cstr(&b, ": expected "); + tp_buf_int(&b, (int64_t)expected.arr_n); + tp_buf_cstr(&b, " items, got "); + tp_buf_int(&b, (int64_t)actual.arr_n); + tp_buf_cstr(&b, ": "); + tp_buf_str(&b, tp_json_show(actual)); + return tp_buf_done(&b); + } + for (size_t i = 0; i < expected.arr_n; i++) { + tp_json ev = expected.arr[i], av = actual.arr[i], name; + tp_str p = index_path(path, i), d; + /* Rule 4: artist shorthand. */ + if (ev.kind == TP_JSON_STRING && av.kind == TP_JSON_OBJECT && + tp_json_get(av, TP_S("name"), &name)) { + if (!same_scalar(ev, name)) return expected_got(key_path(p, TP_S("name")), ev, name); + continue; + } + d = match_partial(ev, av, p); + if (d.n) return d; + } + return TP_EMPTY; + } + if (expected.kind == TP_JSON_OBJECT) { + if (actual.kind != TP_JSON_OBJECT) { + return tp_concat(path, tp_concat(TP_S(": expected an object, got "), tp_json_show(actual))); + } + for (size_t i = 0; i < expected.obj_n; i++) { + const tp_json_member *m = &expected.obj[i]; + tp_json av; + tp_str d; + if (!tp_json_get(actual, m->key, &av)) { + return tp_concat(key_path(path, m->key), TP_S(": missing")); + } + d = match_partial(m->val, av, key_path(path, m->key)); + if (d.n) return d; + } + return TP_EMPTY; + } + if (!same_scalar(expected, actual)) return expected_got(path, expected, actual); + return TP_EMPTY; +} + +static int cmp_str(const void *a, const void *b, void *ctx) { + (void)ctx; + return tp_str_cmp(*(const tp_str *)a, *(const tp_str *)b); +} + +static tp_strvec sorted_keys(tp_json v) { + tp_strvec keys = {0}; + for (size_t i = 0; i < v.obj_n; i++) tp_push(keys, v.obj[i].key); + tp_sort_stable(keys.p, keys.n, sizeof *keys.p, cmp_str, NULL); + return keys; +} + +static tp_json strings_value(tp_strvec list) { + tp_json v = tp_json_null(); + tp_json *items = (tp_json *)tp_alloc_array(list.n, sizeof *items); + for (size_t i = 0; i < list.n; i++) items[i] = tp_json_str(list.p[i]); + v.kind = TP_JSON_ARRAY; + v.arr = items; + v.arr_n = list.n; + return v; +} + +/* Deep equality of complete values (README rule 5); empty on a match. */ +static tp_str match_exact(tp_json expected, tp_json actual, tp_str path) { + if (expected.kind == TP_JSON_ARRAY && actual.kind == TP_JSON_ARRAY && + expected.arr_n == actual.arr_n) { + for (size_t i = 0; i < expected.arr_n; i++) { + tp_str d = match_exact(expected.arr[i], actual.arr[i], index_path(path, i)); + if (d.n) return d; + } + return TP_EMPTY; + } + if (expected.kind == TP_JSON_OBJECT && actual.kind == TP_JSON_OBJECT) { + tp_strvec ek = sorted_keys(expected), ak = sorted_keys(actual); + if (!tp_strvec_eq(ek, ak)) { + tp_buf b = {0}; + tp_buf_str(&b, path); + tp_buf_cstr(&b, ": expected keys "); + tp_buf_str(&b, tp_json_show(strings_value(ek))); + tp_buf_cstr(&b, ", got "); + tp_buf_str(&b, tp_json_show(strings_value(ak))); + return tp_buf_done(&b); + } + for (size_t i = 0; i < ek.n; i++) { + tp_json ev, av; + tp_str d; + tp_json_get(expected, ek.p[i], &ev); + tp_json_get(actual, ek.p[i], &av); + d = match_exact(ev, av, key_path(path, ek.p[i])); + if (d.n) return d; + } + return TP_EMPTY; + } + if (expected.kind == TP_JSON_ARRAY || expected.kind == TP_JSON_OBJECT || + !same_scalar(expected, actual)) { + return expected_got(path, expected, actual); + } + return TP_EMPTY; +} + +/* Drops a top-level specVersion (README rule 6: never compared). */ +static tp_json without_spec_version(tp_json v) { + tp_json out = v; + tp_json_member *members; + size_t n = 0; + if (v.kind != TP_JSON_OBJECT) return v; + members = (tp_json_member *)tp_alloc_array(v.obj_n, sizeof *members); + for (size_t i = 0; i < v.obj_n; i++) { + if (!tp_str_eq(v.obj[i].key, TP_S("specVersion"))) members[n++] = v.obj[i]; + } + out.obj = members; + out.obj_n = n; + return out; +} + +tp_str tp_match(tp_json expected, tp_json actual, bool exact) { + tp_json e = without_spec_version(expected), a = without_spec_version(actual); + return exact ? match_exact(e, a, TP_S("$")) : match_partial(e, a, TP_S("$")); +} diff --git a/c/tests/match.h b/c/tests/match.h new file mode 100644 index 0000000..1d5f3da --- /dev/null +++ b/c/tests/match.h @@ -0,0 +1,18 @@ +/* match.h: the fixture matcher of spec/fixtures/README.md (partial and exact), over tp_json + * values. Same rules as go/match_test.go, js/test/match.ts, python/tests/match.py and + * rust/tests/fixtures.rs. Everything allocates in the current arena. */ +#ifndef TP_TEST_MATCH_H +#define TP_TEST_MATCH_H + +#include "../src/rt.h" + +/* The fixture matcher: an empty string on a match, else the first difference ("$.title: expected + * \"A\", got \"B\""). A top-level specVersion is never compared (README rule 6). */ +tp_str tp_match(tp_json expected, tp_json actual, bool exact); + +/* A value as compact JSON, for messages (non-finite numbers as null, as JSON.stringify). */ +tp_str tp_json_show(tp_json v); +/* Append s as a JSON string literal (only ", \ and controls escaped, as JSON.stringify). */ +void tp_json_quote(tp_buf *b, tp_str s); + +#endif /* TP_TEST_MATCH_H */ diff --git a/c/tests/runner.c b/c/tests/runner.c new file mode 100644 index 0000000..485590b --- /dev/null +++ b/c/tests/runner.c @@ -0,0 +1,549 @@ +/* runner.c: every shared fixture through the JSON door (tp_wire_call), as go/fixtures_test.go and + * rust/tests/fixtures.rs do. + * + * trackparse-fixtures [--skip ] ... + * + * - CTest passes the fixture files (CMake globs spec/fixtures/handwritten and generated); they + * are run in sorted path order. With no file at all (the release tarball holds only c/, + * no spec) the runner prints a message and exits 77, which CTest reports as skipped. + * - Matching follows spec/fixtures/README.md (match.c); status pass / xfail / ambiguous. + * - tests/skip.json lists port-specific known failures by case id; a listed case that passes + * fails the run, so the list can only shrink. --skip overrides the path compiled in. + * - TRACKPARSE_REPORT=1 prints the pass rate per file and per rule instead of failing (the + * conformance report). + * - TRACKPARSE_ONLY= runs the cases whose file name or id contains the text. + * - TRACKPARSE_ALLOW_FAIL=1 logs the failures but exits 0 (a local opt-in for work in progress). + * - TRACKPARSE_OUTPUT= writes one {"id","fn","output"} line per case (JSONL), which + * scripts/validate_outputs.mjs checks against spec/schema. The C port has no JSON Schema + * validator of its own. + * + * Every case runs in its own arena scope, so a case cannot leak into the next. Exit status: 0 + * when every case behaves as its status demands, 1 otherwise, 77 when there is nothing to run. + */ +#include +#include + +#include "../wire/json_read.h" +#include "../wire/wire.h" +#include "match.h" + +#ifndef TP_SKIP_JSON +#define TP_SKIP_JSON "tests/skip.json" +#endif + +#define MAX_FAILURES 40 +#define REPORT_FAILURES 15 + +/* ------------------------------------------------------------------------------------------ */ +/* Plain heap helpers (the runner's own bookkeeping outlives the per-case arenas) */ + +static void *xmalloc(size_t n) { + void *p = malloc(n ? n : 1); + if (!p) { + fprintf(stderr, "runner: out of memory\n"); + exit(2); + } + return p; +} + +static char *xstrndup(const char *s, size_t n) { + char *p = (char *)xmalloc(n + 1); + memcpy(p, s, n); + p[n] = '\0'; + return p; +} + +/* The whole file, or NULL. */ +static char *read_file(const char *path, size_t *len) { + FILE *f = fopen(path, "rb"); + char *buf = NULL; + size_t n = 0, cap = 0; + if (!f) return NULL; + for (;;) { + size_t got; + if (cap - n < 65536) { + cap = cap ? cap * 2 : 1 << 20; + buf = (char *)realloc(buf, cap); + if (!buf) { + fclose(f); + return NULL; + } + } + got = fread(buf + n, 1, cap - n, f); + n += got; + if (got == 0) break; + } + if (ferror(f)) { + fclose(f); + free(buf); + return NULL; + } + fclose(f); + *len = n; + return buf; +} + +static bool env_set(const char *name) { + const char *v = getenv(name); + return v && v[0]; +} + +/* ------------------------------------------------------------------------------------------ */ +/* Counters */ + +typedef struct rule_count { + char *name; + size_t total, ok; +} rule_count; + +typedef struct file_count { + char *name; + size_t total, ok; +} file_count; + +static rule_count *rules; +static size_t rules_n, rules_cap; +static file_count *files; +static size_t files_n; +static char *failures[MAX_FAILURES]; +static size_t failures_n; +static FILE *output; + +static void count_rule(tp_str name, bool ok) { + rule_count *rc = NULL; + for (size_t i = 0; i < rules_n; i++) { + if (strlen(rules[i].name) == name.n && memcmp(rules[i].name, name.p, name.n) == 0) { + rc = &rules[i]; + break; + } + } + if (!rc) { + if (rules_n == rules_cap) { + rules_cap = rules_cap ? rules_cap * 2 : 64; + rules = (rule_count *)realloc(rules, rules_cap * sizeof *rules); + if (!rules) { + fprintf(stderr, "runner: out of memory\n"); + exit(2); + } + } + rc = &rules[rules_n++]; + rc->name = xstrndup(name.p, name.n); + rc->total = rc->ok = 0; + } + rc->total++; + if (ok) rc->ok++; +} + +/* ------------------------------------------------------------------------------------------ */ +/* One case */ + +static tp_json empty_object(void) { + tp_json v = tp_json_null(); + v.kind = TP_JSON_OBJECT; + v.obj = (const tp_json_member *)tp_alloc(0); + return v; +} + +static bool get_string(tp_json v, const char *key, tp_str *out) { + tp_json x; + if (!tp_json_get(v, tp_str_c(key), &x) || x.kind != TP_JSON_STRING) return false; + *out = x.str; + return true; +} + +/* {...defaults[key], ...c[key]} (shallow). */ +static tp_json merged(tp_json defaults, tp_json c, const char *key) { + TP_VEC(tp_json_member) members = {0}; + tp_json out = empty_object(); + tp_json srcs[2]; + srcs[0] = defaults; + srcs[1] = c; + for (size_t s = 0; s < 2; s++) { + tp_json v; + if (!tp_json_get(srcs[s], tp_str_c(key), &v) || v.kind != TP_JSON_OBJECT) continue; + for (size_t i = 0; i < v.obj_n; i++) { + bool replaced = false; + for (size_t j = 0; j < members.n; j++) { + if (tp_str_eq(members.p[j].key, v.obj[i].key)) { + members.p[j].val = v.obj[i].val; + replaced = true; + } + } + if (!replaced) tp_push(members, v.obj[i]); + } + } + if (members.n) { + out.obj = members.p; + out.obj_n = members.n; + } + return out; +} + +/* Runs one case; the empty string when it behaves as its status demands. Allocates in the + * current arena. */ +static tp_str run_fixture(tp_json file, tp_json c, tp_str id) { + tp_json defaults = tp_json_null(), edits, actual; + tp_str fn, input = TP_EMPTY, out, status = TP_EMPTY, match_mode = TP_EMPTY, mismatch; + bool exact; + tp_json_get(file, TP_S("defaults"), &defaults); + if (!get_string(c, "fn", &fn) && !get_string(defaults, "fn", &fn)) fn = TP_S("parse"); + get_string(c, "input", &input); + if (!tp_json_get(c, TP_S("edits"), &edits)) { + edits = tp_json_null(); + edits.kind = TP_JSON_ARRAY; + edits.arr = (const tp_json *)tp_alloc(0); + } + out = tp_wire_call(fn, input, merged(defaults, c, "options"), + merged(defaults, c, "formatOptions"), edits); + if (!tp_json_parse(out, &actual)) { + return tp_concat(TP_S("the port wrote invalid JSON: "), out); + } + if (output) { + tp_buf b = {0}; + tp_str line; + tp_buf_cstr(&b, "{\"id\":"); + tp_json_quote(&b, id); + tp_buf_cstr(&b, ",\"fn\":"); + tp_json_quote(&b, fn); + tp_buf_cstr(&b, ",\"output\":"); + tp_buf_str(&b, out); + tp_buf_cstr(&b, "}\n"); + line = tp_buf_done(&b); + fwrite(line.p, 1, line.n, output); + } + + get_string(c, "status", &status); + get_string(c, "match", &match_mode); + exact = tp_str_eq(match_mode, TP_S("exact")); + if (tp_str_eq(status, TP_S("ambiguous"))) { + tp_json alts = tp_json_null(); + tp_strvec diffs = {0}; + tp_json_get(c, TP_S("expectedAny"), &alts); + for (size_t i = 0; alts.kind == TP_JSON_ARRAY && i < alts.arr_n; i++) { + tp_str d = tp_match(alts.arr[i], actual, exact); + if (d.n == 0) { + diffs.n = 0; + break; + } + tp_push(diffs, d); + } + if (diffs.n > 0 || alts.kind != TP_JSON_ARRAY || alts.arr_n == 0) { + mismatch = tp_concat(TP_S("no expectedAny entry matched: "), tp_join(diffs, TP_S("; "))); + } else { + mismatch = TP_EMPTY; + } + } else { + tp_json expected = tp_json_null(); + tp_json_get(c, TP_S("expected"), &expected); + mismatch = tp_match(expected, actual, exact); + } + if (tp_str_eq(status, TP_S("xfail"))) { + return mismatch.n == 0 ? TP_S("xfail case unexpectedly passes") : TP_EMPTY; + } + return mismatch; +} + +/* The body of run_case inside its armed scope: the failure text to keep (heap), or NULL when the + * case behaves as its status demands (*ok true). A function of its own, so run_case, which calls + * setjmp, holds no temporaries a longjmp could clobber (GCC -Wclobbered). */ +static char *case_body(tp_json file, tp_json c, tp_json skip, tp_str id, bool *ok) { + tp_str reason, problem; + tp_json input = tp_json_null(); + problem = run_fixture(file, c, id); + if (get_string(skip, tp_str_cstr(id), &reason)) { + if (problem.n == 0) { + problem = tp_concat3(TP_S("skip-listed ("), reason, + TP_S(") but now passes: remove it from tests/skip.json")); + } else { + problem = TP_EMPTY; + } + } + *ok = problem.n == 0; + if (!*ok && failures_n < MAX_FAILURES) { + tp_buf b = {0}; + tp_str text; + tp_json_get(c, TP_S("input"), &input); + tp_buf_str(&b, id); + tp_buf_cstr(&b, "\n input: "); + tp_buf_str(&b, tp_json_show(input)); + tp_buf_cstr(&b, "\n "); + tp_buf_str(&b, problem); + text = tp_buf_done(&b); + return xstrndup(text.p, text.n); + } + return NULL; +} + +static void count_rules(tp_json c, bool ok) { + tp_json rules_v = tp_json_null(); + tp_json_get(c, TP_S("rules"), &rules_v); + for (size_t i = 0; rules_v.kind == TP_JSON_ARRAY && i < rules_v.arr_n; i++) { + if (rules_v.arr[i].kind == TP_JSON_STRING) count_rule(rules_v.arr[i].str, ok); + } +} + +/* Runs one case in its own scope and does the bookkeeping: -1 when TRACKPARSE_ONLY filters it + * out, 1 when it behaves as its status demands, 0 when not. */ +static int run_case(tp_json file, tp_json c, tp_json skip, const char *name, const char *only) { + tp_scope s; + tp_str id = TP_EMPTY; + char *volatile kept = NULL; + volatile bool ok = false; + get_string(c, "id", &id); + if (only && !strstr(name, only) && !strstr(tp_str_cstr(id), only)) return -1; + if (!tp_scope_open(&s)) { + fprintf(stderr, "runner: out of memory\n"); + exit(2); + } + if (setjmp(s.jmp) != 0) { + tp_scope_abort(&s); + kept = xstrndup("out of memory", 13); + } else { + bool passed = false; + tp_scope_arm(&s); + kept = case_body(file, c, skip, id, &passed); + ok = passed; + tp_scope_close(&s); + tp_arena_free(s.arena); + } + if (kept) { + if (failures_n < MAX_FAILURES) { + failures[failures_n++] = kept; + } else { + free(kept); + } + } + count_rules(c, ok); + return ok ? 1 : 0; +} + +/* The path relative to spec/fixtures ("handwritten/junk.json"), for the report. */ +static const char *display_name(const char *path) { + const char *best = NULL, *p = path; + while ((p = strstr(p, "fixtures")) != NULL) { + if (p[8] == '/' || p[8] == '\\') best = p + 9; + p += 8; + } + return best ? best : path; +} + +/* The body of run_file inside its armed scope (a function of its own for -Wclobbered, as + * case_body): false when the file is not JSON. */ +static bool file_body(const char *path, const char *text, size_t len, tp_json skip, + const char *only) { + tp_json data, cases; + tp_str whole; + whole.p = text; + whole.n = len; + if (!tp_json_parse(whole, &data)) { + fprintf(stderr, "runner: %s: invalid JSON\n", path); + return false; + } + if (tp_json_get(data, TP_S("cases"), &cases) && cases.kind == TP_JSON_ARRAY) { + const char *name = display_name(path); + file_count *fc = &files[files_n++]; + fc->name = xstrndup(name, strlen(name)); + fc->total = fc->ok = 0; + for (size_t i = 0; i < cases.arr_n; i++) { + int r = run_case(data, cases.arr[i], skip, name, only); + if (r < 0) continue; + fc->total++; + if (r > 0) fc->ok++; + } + } + /* else: metadata such as generated/summary.json */ + return true; +} + +/* Runs every case of one file inside a scope that holds the file's JSON. false when the file + * could not be read. */ +static bool run_file(const char *path, tp_json skip, const char *only) { + tp_scope s; + size_t len = 0; + char *text = read_file(path, &len); + bool good; + if (!text) { + fprintf(stderr, "runner: cannot read %s\n", path); + return false; + } + if (!tp_scope_open(&s)) { + free(text); + return false; + } + if (setjmp(s.jmp) != 0) { + tp_scope_abort(&s); + fprintf(stderr, "runner: out of memory reading %s\n", path); + free(text); + return false; + } + tp_scope_arm(&s); + good = file_body(path, text, len, skip, only); + tp_scope_close(&s); + tp_arena_free(s.arena); + free(text); + return good; +} + +/* Reads skip.json into the current arena; false when it is missing or not an object. */ +static bool read_skip(const char *path, tp_json *out) { + size_t len = 0; + char *text = read_file(path, &len); + bool ok; + tp_str whole; + if (!text) { + fprintf(stderr, "runner: cannot read %s\n", path); + return false; + } + whole.p = tp_str_copy(text, len).p; + whole.n = len; + free(text); + ok = tp_json_parse(whole, out) && out->kind == TP_JSON_OBJECT; + if (!ok) fprintf(stderr, "runner: %s is not a JSON object\n", path); + return ok; +} + +static int cmp_cstr(const char *a, const char *b) { return strcmp(a, b); } + +/* Insertion sorts: a few dozen files and a few hundred rules. */ +static void sort_paths(const char **p, size_t n) { + for (size_t i = 1; i < n; i++) { + const char *x = p[i]; + size_t j = i; + while (j > 0 && cmp_cstr(p[j - 1], x) > 0) { + p[j] = p[j - 1]; + j--; + } + p[j] = x; + } +} + +static void sort_rules(void) { + for (size_t i = 1; i < rules_n; i++) { + rule_count x = rules[i]; + size_t j = i; + while (j > 0 && cmp_cstr(rules[j - 1].name, x.name) > 0) { + rules[j] = rules[j - 1]; + j--; + } + rules[j] = x; + } +} + +static void print_report(size_t passed, size_t total) { + printf("\nconformance: %lu / %lu\n", (unsigned long)passed, (unsigned long)total); + for (size_t i = 0; i < files_n; i++) { + printf(" %5lu / %-5lu %s%s\n", (unsigned long)files[i].ok, (unsigned long)files[i].total, + files[i].name, files[i].ok != files[i].total ? " <--" : ""); + } + printf("by rule (failing only):\n"); + sort_rules(); + for (size_t i = 0; i < rules_n; i++) { + if (rules[i].ok != rules[i].total) { + printf(" %-10s %lu / %lu\n", rules[i].name, (unsigned long)rules[i].ok, + (unsigned long)rules[i].total); + } + } + for (size_t i = 0; i < failures_n && i < REPORT_FAILURES; i++) printf("\n%s\n", failures[i]); +} + +/* Every file, inside an outer scope that holds skip.json for the whole run: 0, or 2 when a file + * or skip.json could not be read. */ +static int run_files(const char *skip_path, const char **paths, size_t n, const char *only) { + tp_scope s; + volatile int status = 0; + if (!tp_scope_open(&s)) return 2; + if (setjmp(s.jmp) != 0) { + tp_scope_abort(&s); + fprintf(stderr, "runner: out of memory\n"); + return 2; + } + tp_scope_arm(&s); + { + tp_json skip; + if (!read_skip(skip_path, &skip)) { + status = 2; + } else { + for (size_t i = 0; i < n; i++) { + if (!run_file(paths[i], skip, only)) status = 2; + } + } + } + tp_scope_close(&s); + tp_arena_free(s.arena); + return status; +} + +static int run_all(int argc, char **argv, const char **paths) { + const char *skip_path = TP_SKIP_JSON; + const char *only = getenv("TRACKPARSE_ONLY"); + const char *output_path = getenv("TRACKPARSE_OUTPUT"); + bool report = env_set("TRACKPARSE_REPORT"), allow_fail = env_set("TRACKPARSE_ALLOW_FAIL"); + size_t n = 0, total = 0, passed = 0; + int status; + + for (int i = 1; i < argc; i++) { + if (strcmp(argv[i], "--skip") == 0 && i + 1 < argc) { + skip_path = argv[++i]; + } else { + paths[n++] = argv[i]; + } + } + if (only && !only[0]) only = NULL; + if (n == 0) { + printf("spec/fixtures not found (the release tarball holds only c/): skipping the fixtures\n"); + return 77; + } + sort_paths(paths, n); + files = (file_count *)xmalloc(n * sizeof *files); + if (output_path && output_path[0]) { + output = fopen(output_path, "wb"); + if (!output) { + fprintf(stderr, "runner: cannot write %s\n", output_path); + return 2; + } + } + + status = run_files(skip_path, paths, n, only); + if (output) fclose(output); + output = NULL; + if (status) return status; + + for (size_t i = 0; i < files_n; i++) { + total += files[i].total; + passed += files[i].ok; + } + if (report) { + print_report(passed, total); + return 0; + } + if (total == 0) { + fprintf(stderr, "no fixtures found\n"); + return 1; + } + if (passed != total) { + if (allow_fail) { + printf("TRACKPARSE_ALLOW_FAIL: %lu / %lu pass\n", (unsigned long)passed, + (unsigned long)total); + return 0; + } + printf("%lu of %lu fixture cases fail; first ones:\n", (unsigned long)(total - passed), + (unsigned long)total); + for (size_t i = 0; i < failures_n; i++) printf("\n%s\n", failures[i]); + return 1; + } + printf("fixtures: %lu / %lu pass\n", (unsigned long)passed, (unsigned long)total); + return 0; +} + +int main(int argc, char **argv) { + const char **paths = (const char **)xmalloc((size_t)argc * sizeof *paths); + int status = run_all(argc, argv, paths); + if (output) fclose(output); + for (size_t i = 0; i < files_n; i++) free(files[i].name); + for (size_t i = 0; i < rules_n; i++) free(rules[i].name); + for (size_t i = 0; i < failures_n; i++) free(failures[i]); + free(files); + free(rules); + free(paths); + return status; +} diff --git a/c/tests/skip.json b/c/tests/skip.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/c/tests/skip.json @@ -0,0 +1 @@ +{} diff --git a/c/tests/test_api.c b/c/tests/test_api.c new file mode 100644 index 0000000..160b7c4 --- /dev/null +++ b/c/tests/test_api.c @@ -0,0 +1,1193 @@ +/* test_api.c: the public C API (include/trackparse.h): every public function at least once, + * NULL options and NULL arguments, explicit lengths with embedded U+0000, invalid UTF-8 (the + * Parse, Normalize and tracklist parts of go/utf8_test.go), the JSON form against the JSON door + * (tp_wire_line) on the same input, format on a hand-built track, parser reuse after its options + * are freed, edits, out of memory at every allocation, and a parser shared between threads. */ +#include +#include + +#if !defined(_WIN32) +#include +#define TP_TEST_THREADS 1 +#endif + +#include "../include/trackparse.h" +#include "../src/internal.h" +#include "../wire/wire.h" + +static int failures; +static long checks; + +#define CHECK(cond) \ + do { \ + checks++; \ + if (!(cond)) { \ + failures++; \ + fprintf(stderr, "%s:%d: CHECK(%s)\n", __FILE__, __LINE__, #cond); \ + } \ + } while (0) + +/* A trackparse_str equals a C string (no embedded NUL). */ +static bool str_is(trackparse_str s, const char *want) { + return s.ptr != NULL && s.len == strlen(want) && memcmp(s.ptr, want, s.len) == 0 && + s.ptr[s.len] == '\0'; +} + +#define STR_IS(s, lit) CHECK(str_is((s), (lit))) + +/* Two results are equal as JSON text. */ +static bool same_text(const trackparse_string *a, const trackparse_string *b) { + return a != NULL && b != NULL && a->str.len == b->str.len && + memcmp(a->str.ptr, b->str.ptr, a->str.len) == 0; +} + +static void show_diff(const char *what, const trackparse_string *a, const trackparse_string *b) { + fprintf(stderr, "%s:\n got %.*s\n want %.*s\n", what, a ? (int)a->str.len : 4, + a ? a->str.ptr : "NULL", b ? (int)b->str.len : 4, b ? b->str.ptr : "NULL"); +} + +#define SAME_JSON(what, a, b) \ + do { \ + checks++; \ + if (!same_text((a), (b))) { \ + failures++; \ + fprintf(stderr, "%s:%d: ", __FILE__, __LINE__); \ + show_diff((what), (a), (b)); \ + } \ + } while (0) + +/* -------------------------------------------------------------------------------------------- */ +/* A counting allocator that can fail the n-th malloc */ + +static long live_blocks; +static long malloc_calls; +static long fail_at = -1; /* fail the malloc with this index, -1: never */ + +/* The allocator stays installed during the thread test, so the counters need a lock there. */ +#ifdef TP_TEST_THREADS +static pthread_mutex_t count_lock = PTHREAD_MUTEX_INITIALIZER; +#define COUNT_LOCK() pthread_mutex_lock(&count_lock) +#define COUNT_UNLOCK() pthread_mutex_unlock(&count_lock) +#else +#define COUNT_LOCK() ((void)0) +#define COUNT_UNLOCK() ((void)0) +#endif + +static void *count_malloc(size_t size, void *user) { + void *p; + (void)user; + COUNT_LOCK(); + if (fail_at >= 0 && malloc_calls++ == fail_at) { + COUNT_UNLOCK(); + return NULL; + } + p = malloc(size); + if (p != NULL) live_blocks++; + COUNT_UNLOCK(); + return p; +} + +static void *count_realloc(void *ptr, size_t size, void *user) { + (void)user; + return realloc(ptr, size); +} + +static void count_free(void *ptr, void *user) { + (void)user; + COUNT_LOCK(); + if (ptr != NULL) live_blocks--; + COUNT_UNLOCK(); + free(ptr); +} + +static void fail_from(long n) { + malloc_calls = 0; + fail_at = n; +} + +/* -------------------------------------------------------------------------------------------- */ +/* The JSON door, for the expected bytes */ + +/* tp_wire_line on one case object, copied into a trackparse_string-like malloc block. */ +typedef struct wire_out { + trackparse_string s; + char *buf; +} wire_out; + +static trackparse_string *wire(wire_out *out, const char *case_json) { + tp_scope s; + tp_str r; + if (!tp_scope_open(&s)) return NULL; + if (setjmp(s.jmp) != 0) { + tp_scope_abort(&s); + return NULL; + } + tp_scope_arm(&s); + r = tp_wire_line(tp_str_c(case_json)); + out->buf = (char *)malloc(r.n + 1); + if (out->buf != NULL) { + memcpy(out->buf, r.p, r.n); + out->buf[r.n] = '\0'; + } + out->s.str.ptr = out->buf; + out->s.str.len = r.n; + tp_scope_close(&s); + tp_arena_free(s.arena); + return out->buf != NULL ? &out->s : NULL; +} + +/* Compare a result's JSON with the door's for the same case, then free both. */ +static void check_wire(const char *what, trackparse_string *got, const char *case_json) { + wire_out w; + trackparse_string *want = wire(&w, case_json); + SAME_JSON(what, got, want); + trackparse_string_free(got); + free(w.buf); +} + +/* The JSON string of a result string (tp_string_json), to compare a normalize result with the + * door's JSON. */ +static trackparse_string *string_json(const trackparse_string *in) { + tp_scope s; + tp_str r, x; + trackparse_string *out = NULL; + if (!tp_scope_open(&s)) return NULL; + if (setjmp(s.jmp) != 0) { + tp_scope_abort(&s); + return NULL; + } + tp_scope_arm(&s); + x.p = in->str.ptr; + x.n = in->str.len; + r = tp_string_json(x); + tp_scope_close(&s); + /* A plain malloc copy (free it with free, not trackparse_string_free). */ + out = (trackparse_string *)malloc(sizeof *out + r.n + 1); + if (out != NULL) { + char *d = (char *)(out + 1); + memcpy(d, r.p, r.n); + d[r.n] = '\0'; + out->str.ptr = d; + out->str.len = r.n; + } + tp_arena_free(s.arena); + return out; +} + +/* -------------------------------------------------------------------------------------------- */ + +static void test_versions(void) { + CHECK(strcmp(trackparse_library_version(), TRACKPARSE_VERSION) == 0); + CHECK(strcmp(trackparse_spec_version(), TP_SPEC_VERSION) == 0); + CHECK(strcmp(trackparse_library_version(), trackparse_spec_version()) == 0); +} + +static void test_enums(void) { + trackparse_mode m; + trackparse_version_type vt; + trackparse_junk_kind jk; + CHECK(strcmp(trackparse_mode_name(TRACKPARSE_MODE_AUTO), "auto") == 0); + CHECK(strcmp(trackparse_mode_name(TRACKPARSE_MODE_TRACKLIST), "tracklist") == 0); + CHECK(strcmp(trackparse_mode_name((trackparse_mode)99), "") == 0); + CHECK(strcmp(trackparse_mode_name((trackparse_mode)-1), "") == 0); + CHECK(strcmp(trackparse_role_name(TRACKPARSE_ROLE_PRODUCER), "producer") == 0); + CHECK(strcmp(trackparse_source_name(TRACKPARSE_SOURCE_VERSION), "version") == 0); + CHECK(strcmp(trackparse_version_type_name(TRACKPARSE_VERSION_REMIX), "remix") == 0); + CHECK(strcmp(trackparse_version_type_name(TRACKPARSE_VERSION_SPED_UP), "spedUp") == 0); + CHECK(strcmp(trackparse_version_type_name(TRACKPARSE_VERSION_NIGHTCORE), "nightcore") == 0); + CHECK(strcmp(trackparse_delimiter_name(TRACKPARSE_DELIMITER_BRACE), "{") == 0); + CHECK(strcmp(trackparse_junk_kind_name(TRACKPARSE_JUNK_OTHER), "other") == 0); + CHECK(strcmp(trackparse_warning_name(TRACKPARSE_WARNING_NO_SEPARATOR), "noSeparator") == 0); + CHECK(strcmp(trackparse_warning_name(TRACKPARSE_WARNING_UNBALANCED_BRACKETS), + "unbalancedBrackets") == 0); + CHECK(strcmp(trackparse_entry_kind_name(TRACKPARSE_ENTRY_BLANK), "blank") == 0); + CHECK(strcmp(trackparse_eol_name(TRACKPARSE_EOL_CRLF), "\r\n") == 0); + CHECK(strcmp(trackparse_eol_name(TRACKPARSE_EOL_NONE), "") == 0); + CHECK(strcmp(trackparse_tracklist_warning_code_name(TRACKPARSE_TL_TIME_OUT_OF_ORDER), + "time-out-of-order") == 0); + CHECK(strcmp(trackparse_tracklist_warning_code_name(TRACKPARSE_TL_LINE_UNPARSED), + "line-unparsed") == 0); + CHECK(strcmp(trackparse_severity_name(TRACKPARSE_SEVERITY_WARNING), "warning") == 0); + CHECK(strcmp(trackparse_edit_op_name(TRACKPARSE_EDIT_SORT_BY_TIME), "sort-by-time") == 0); + CHECK(strcmp(trackparse_edit_warning_code_name(TRACKPARSE_EDIT_WARNING_STYLE_UPGRADED), + "style-upgraded") == 0); + + CHECK(trackparse_mode_from_name("youtube", TRACKPARSE_NUL_TERMINATED, &m) && + m == TRACKPARSE_MODE_YOUTUBE); + CHECK(trackparse_mode_from_name("auto", 4, &m) && m == TRACKPARSE_MODE_AUTO); + CHECK(trackparse_mode_from_name("cleanX", 5, &m) && m == TRACKPARSE_MODE_CLEAN); + CHECK(!trackparse_mode_from_name("Clean", TRACKPARSE_NUL_TERMINATED, &m)); + CHECK(!trackparse_mode_from_name(NULL, 0, &m)); + CHECK(trackparse_version_type_from_name("vip", TRACKPARSE_NUL_TERMINATED, &vt) && + vt == TRACKPARSE_VERSION_VIP); + CHECK(!trackparse_version_type_from_name("rerub", TRACKPARSE_NUL_TERMINATED, &vt)); + CHECK(trackparse_junk_kind_from_name("genre", TRACKPARSE_NUL_TERMINATED, &jk) && + jk == TRACKPARSE_JUNK_GENRE); + CHECK(trackparse_junk_kind_from_name("label", 5, NULL)); +} + +static void test_parse(void) { + trackparse_track *t = trackparse_parse("Queen - Bohemian Rhapsody (Live at Wembley 1986)", + TRACKPARSE_NUL_TERMINATED); + CHECK(t != NULL); + if (t == NULL) return; + STR_IS(t->input, "Queen - Bohemian Rhapsody (Live at Wembley 1986)"); + CHECK(t->mode == TRACKPARSE_MODE_CLEAN); + CHECK(t->position == NULL && t->timestamp == NULL); + CHECK(t->artists_count == 1); + if (t->artists_count == 1) { + STR_IS(t->artists[0].name, "Queen"); + CHECK(t->artists[0].role == TRACKPARSE_ROLE_PRIMARY); + CHECK(t->artists[0].joiner == NULL); + CHECK(t->artists[0].source == TRACKPARSE_SOURCE_ARTIST); + } + STR_IS(t->title, "Bohemian Rhapsody"); + STR_IS(t->full_title, "Bohemian Rhapsody (Live at Wembley 1986)"); + CHECK(t->versions_count == 1); + if (t->versions_count == 1) { + const trackparse_version *v = &t->versions[0]; + CHECK(v->type == TRACKPARSE_VERSION_LIVE); + STR_IS(v->type_name, "live"); + STR_IS(v->raw, "Live at Wembley 1986"); + CHECK(v->delimiter == TRACKPARSE_DELIMITER_PAREN); + CHECK(v->descriptor != NULL && str_is(*v->descriptor, "at Wembley")); + CHECK(v->year != NULL && *v->year == 1986); + CHECK(v->artists_count == 0 && v->artists == NULL); + } + CHECK(t->year == NULL); + CHECK(t->warnings_count == 0 && t->junk_count == 0); + trackparse_track_free(t); + + /* Position, timestamp, year, junk, flags. */ + t = trackparse_parse("01. Noisia - Stigma (2015) [HD]", TRACKPARSE_NUL_TERMINATED); + CHECK(t != NULL); + if (t != NULL) { + CHECK(t->position != NULL && t->position->number == 1 && str_is(t->position->raw, "01")); + CHECK(t->year != NULL && *t->year == 2015); + CHECK(t->junk_count == 1 && t->junk[0].kind == TRACKPARSE_JUNK_QUALITY && + str_is(t->junk[0].kind_name, "quality") && str_is(t->junk[0].raw, "HD")); + check_wire("parse position", trackparse_track_to_json(t), + "{\"fn\":\"parse\",\"input\":\"01. Noisia - Stigma (2015) [HD]\"}"); + trackparse_track_free(t); + } + + /* The JSON form, byte for byte (go/example_test.go ExampleTrack_MarshalJSON). */ + t = trackparse_parse("Wilkinson ft. Becky Hill - Afterglow (Sub Focus VIP Remix) [HD]", + TRACKPARSE_NUL_TERMINATED); + CHECK(t != NULL); + if (t != NULL) { + trackparse_string *j = trackparse_track_to_json(t); + CHECK(j != NULL && + str_is(j->str, + "{\"input\":\"Wilkinson ft. Becky Hill - Afterglow (Sub Focus VIP Remix) [HD]\"," + "\"mode\":\"youtube\",\"position\":null,\"timestamp\":null,\"artists\":[{\"name\":" + "\"Wilkinson\",\"role\":\"primary\",\"joiner\":null,\"source\":\"artist\"},{" + "\"name\":\"Becky Hill\",\"role\":\"featured\",\"joiner\":\"ft.\",\"source\":" + "\"artist\"}],\"title\":\"Afterglow\",\"fullTitle\":\"Afterglow (Sub Focus VIP " + "Remix)\",\"versions\":[{\"type\":\"remix\",\"raw\":\"Sub Focus VIP Remix\"," + "\"artists\":[{\"name\":\"Sub Focus\",\"role\":\"remixer\",\"joiner\":null," + "\"source\":\"version\"}],\"modifiers\":[\"vip\"],\"descriptor\":null,\"year\":" + "null,\"unknownArtist\":false,\"delimiter\":\"(\"}],\"year\":null,\"flags\":{" + "\"explicit\":false,\"clean\":false,\"unknownArtist\":false,\"unknownTitle\":" + "false},\"junk\":[{\"raw\":\"HD\",\"kind\":\"quality\"}],\"warnings\":[]}")); + trackparse_string_free(j); + trackparse_track_free(t); + } + + /* NULL input is the empty string; the free functions accept NULL. */ + t = trackparse_parse(NULL, 5); + CHECK(t != NULL && t->input.len == 0 && t->input.ptr != NULL && t->input.ptr[0] == '\0'); + if (t != NULL) { + check_wire("parse empty", trackparse_track_to_json(t), "{\"fn\":\"parse\",\"input\":\"\"}"); + } + trackparse_track_free(t); + trackparse_track_free(NULL); + trackparse_artists_free(NULL); + trackparse_string_free(NULL); + trackparse_tracklist_free(NULL); + trackparse_edit_result_free(NULL); + trackparse_parse_options_free(NULL); + trackparse_format_options_free(NULL); + trackparse_tracklist_options_free(NULL); + trackparse_parser_free(NULL); + trackparse_edits_free(NULL); + + /* An explicit length: a prefix of the buffer. */ + t = trackparse_parse("Noisia - Stigma (VIP) trailing", 21); + CHECK(t != NULL && str_is(t->input, "Noisia - Stigma (VIP)") && t->versions_count == 1); + trackparse_track_free(t); +} + +static void test_embedded_nul(void) { + static const char in[] = "A\0B - C\0D"; + trackparse_track *t = trackparse_parse(in, sizeof in - 1); + trackparse_string *n; + CHECK(t != NULL); + if (t != NULL) { + CHECK(t->input.len == sizeof in - 1 && memcmp(t->input.ptr, in, sizeof in - 1) == 0); + CHECK(t->input.ptr[t->input.len] == '\0'); + check_wire("parse U+0000", trackparse_track_to_json(t), + "{\"fn\":\"parse\",\"input\":\"A\\u0000B - C\\u0000D\"}"); + trackparse_track_free(t); + } + n = trackparse_normalize(in, sizeof in - 1); + CHECK(n != NULL); + if (n != NULL) { + wire_out w; + trackparse_string *want = + wire(&w, "{\"fn\":\"normalize\",\"input\":\"A\\u0000B - C\\u0000D\"}"); + trackparse_string *got = string_json(n); + SAME_JSON("normalize U+0000", got, want); + free(w.buf); + free(got); + trackparse_string_free(n); + } + { + trackparse_artists *a = trackparse_parse_artists(in, sizeof in - 1); + CHECK(a != NULL); + if (a != NULL) { + check_wire("parseArtists U+0000", trackparse_artists_to_json(a), + "{\"fn\":\"parseArtists\",\"input\":\"A\\u0000B - C\\u0000D\"}"); + trackparse_artists_free(a); + } + } +} + +/* go/utf8_test.go */ +typedef struct lossy_case { + const char *bad; + const char *want; +} lossy_case; + +static const lossy_case lossy_cases[] = { + {"a\xff" + "b", + "a\xef\xbf\xbd" + "b"}, + {"\xe2\x82", "\xef\xbf\xbd"}, + {"\xe2\x82" + "A", + "\xef\xbf\xbd" + "A"}, + {"\xed\xa0\x80", "\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd"}, + {"\xf0\x9f\x98", "\xef\xbf\xbd"}, + {"\xf4\x90\x80\x80", "\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd"}, + {"\xc0\xaf", "\xef\xbf\xbd\xef\xbf\xbd"}, + {"\xe0\x80\xaf", "\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd"}, + {"\xf0\x8f\xbf\xbf", "\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd"}, + {"\x80\x80", "\xef\xbf\xbd\xef\xbf\xbd"}, + {"\xf1\x80\x80", "\xef\xbf\xbd"}, + {"\xe1\x80\xe2\x82\xac", "\xef\xbf\xbd\xe2\x82\xac"}, + {"Noisia \xff- Stigma \xf0\x9f\x98(VIP\xed\xbf\xbf)", + "Noisia \xef\xbf\xbd- Stigma \xef\xbf\xbd(VIP\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd)"}, +}; + +static void test_invalid_utf8(void) { + size_t i; + for (i = 0; i < TP_COUNT(lossy_cases); i++) { + const lossy_case *c = &lossy_cases[i]; + trackparse_string *a, *b, *ja, *jb; + trackparse_track *ta, *tb; + trackparse_artists *aa, *ab; + trackparse_parse_options *ob, *ow; + + a = trackparse_normalize(c->bad, TRACKPARSE_NUL_TERMINATED); + b = trackparse_normalize(c->want, TRACKPARSE_NUL_TERMINATED); + SAME_JSON("normalize lossy", a, b); + trackparse_string_free(a); + trackparse_string_free(b); + + ta = trackparse_parse(c->bad, TRACKPARSE_NUL_TERMINATED); + tb = trackparse_parse(c->want, TRACKPARSE_NUL_TERMINATED); + CHECK(ta != NULL && tb != NULL); + if (ta != NULL) CHECK(str_is(ta->input, c->want)); /* the input is the lossy string */ + ja = trackparse_track_to_json(ta); + jb = trackparse_track_to_json(tb); + SAME_JSON("parse lossy", ja, jb); + trackparse_string_free(ja); + trackparse_string_free(jb); + trackparse_track_free(ta); + trackparse_track_free(tb); + + aa = trackparse_parse_artists(c->bad, TRACKPARSE_NUL_TERMINATED); + ab = trackparse_parse_artists(c->want, TRACKPARSE_NUL_TERMINATED); + ja = trackparse_artists_to_json(aa); + jb = trackparse_artists_to_json(ab); + SAME_JSON("parseArtists lossy", ja, jb); + trackparse_string_free(ja); + trackparse_string_free(jb); + trackparse_artists_free(aa); + trackparse_artists_free(ab); + + /* Bad bytes in the options too. */ + ob = trackparse_parse_options_new(); + ow = trackparse_parse_options_new(); + CHECK(ob != NULL && ow != NULL); + CHECK(trackparse_parse_options_set_mode(ob, TRACKPARSE_MODE_YOUTUBE)); + CHECK(trackparse_parse_options_set_uploader(ob, c->bad, TRACKPARSE_NUL_TERMINATED)); + CHECK(trackparse_parse_options_add_known_artist(ob, c->bad, TRACKPARSE_NUL_TERMINATED)); + CHECK(trackparse_parse_options_set_mode(ow, TRACKPARSE_MODE_YOUTUBE)); + CHECK(trackparse_parse_options_set_uploader(ow, c->want, TRACKPARSE_NUL_TERMINATED)); + CHECK(trackparse_parse_options_add_known_artist(ow, c->want, TRACKPARSE_NUL_TERMINATED)); + ta = trackparse_parse_with(c->bad, TRACKPARSE_NUL_TERMINATED, ob); + tb = trackparse_parse_with(c->want, TRACKPARSE_NUL_TERMINATED, ow); + ja = trackparse_track_to_json(ta); + jb = trackparse_track_to_json(tb); + SAME_JSON("parseWith lossy", ja, jb); + trackparse_string_free(ja); + trackparse_string_free(jb); + trackparse_track_free(ta); + trackparse_track_free(tb); + trackparse_parse_options_free(ob); + trackparse_parse_options_free(ow); + } + + { + static const char bad[] = + "00:00 A\xc3 - B\r\n01:00 \xe2\x80\x93 C - D\xf0\n02:00 \xed\xa0\x80 - \xff\n"; + static const char want[] = "00:00 A\xef\xbf\xbd - B\r\n01:00 \xe2\x80\x93 C - " + "D\xef\xbf\xbd\n02:00 \xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd - " + "\xef\xbf\xbd\n"; + trackparse_tracklist *gl = trackparse_parse_tracklist(bad, TRACKPARSE_NUL_TERMINATED); + trackparse_tracklist *wl = trackparse_parse_tracklist(want, TRACKPARSE_NUL_TERMINATED); + trackparse_string *ja = trackparse_tracklist_to_json(gl); + trackparse_string *jb = trackparse_tracklist_to_json(wl); + trackparse_edits *eb = trackparse_edits_new(), *ew = trackparse_edits_new(); + trackparse_edit_result *rb, *rw; + SAME_JSON("parseTracklist lossy", ja, jb); + CHECK(gl != NULL && gl->entries_count == 3); + trackparse_string_free(ja); + trackparse_string_free(jb); + trackparse_tracklist_free(gl); + trackparse_tracklist_free(wl); + + CHECK(trackparse_edits_set_rest(eb, 1, "X\xff - Y", TRACKPARSE_NUL_TERMINATED)); + CHECK(trackparse_edits_insert(eb, 3, "03:00 \xe2\x82 - Z", TRACKPARSE_NUL_TERMINATED)); + CHECK(trackparse_edits_shift(eb, 5)); + CHECK(trackparse_edits_set_rest(ew, 1, "X\xef\xbf\xbd - Y", TRACKPARSE_NUL_TERMINATED)); + CHECK(trackparse_edits_insert(ew, 3, "03:00 \xef\xbf\xbd - Z", TRACKPARSE_NUL_TERMINATED)); + CHECK(trackparse_edits_shift(ew, 5)); + rb = trackparse_apply_edits(bad, TRACKPARSE_NUL_TERMINATED, eb); + rw = trackparse_apply_edits(want, TRACKPARSE_NUL_TERMINATED, ew); + ja = trackparse_edit_result_to_json(rb); + jb = trackparse_edit_result_to_json(rw); + SAME_JSON("applyEdits lossy", ja, jb); + CHECK(rb != NULL && rw != NULL && rb->text.len == rw->text.len && + memcmp(rb->text.ptr, rw->text.ptr, rb->text.len) == 0); + trackparse_string_free(ja); + trackparse_string_free(jb); + trackparse_edit_result_free(rb); + trackparse_edit_result_free(rw); + trackparse_edits_free(eb); + trackparse_edits_free(ew); + } +} + +static void test_parse_artists(void) { + trackparse_artists *a = trackparse_parse_artists("Sub Focus, Wilkinson & Dimension feat. Kojo", + TRACKPARSE_NUL_TERMINATED); + CHECK(a != NULL && a->count == 4); + if (a != NULL && a->count == 4) { + STR_IS(a->items[0].name, "Sub Focus"); + CHECK(a->items[0].joiner == NULL); + STR_IS(a->items[1].name, "Wilkinson"); + CHECK(a->items[1].joiner != NULL && str_is(*a->items[1].joiner, ",")); + CHECK(a->items[2].joiner != NULL && str_is(*a->items[2].joiner, "&")); + STR_IS(a->items[3].name, "Kojo"); + CHECK(a->items[3].role == TRACKPARSE_ROLE_FEATURED); + CHECK(a->items[3].joiner != NULL && str_is(*a->items[3].joiner, "feat.")); + check_wire("parseArtists", trackparse_artists_to_json(a), + "{\"fn\":\"parseArtists\",\"input\":\"Sub Focus, Wilkinson & Dimension feat. " + "Kojo\"}"); + } + trackparse_artists_free(a); +} + +static void test_parse_with(void) { + trackparse_parse_options *o = trackparse_parse_options_new(); + trackparse_track *t; + trackparse_artists *a; + CHECK(o != NULL); + + /* NULL options are the defaults. */ + t = trackparse_parse_with("Chase & Status - Baddadan", TRACKPARSE_NUL_TERMINATED, NULL); + CHECK(t != NULL && t->artists_count == 2); + trackparse_track_free(t); + a = trackparse_parse_artists_with("Chase & Status", TRACKPARSE_NUL_TERMINATED, NULL); + CHECK(a != NULL && a->count == 2); + trackparse_artists_free(a); + + CHECK(trackparse_parse_options_add_known_artist(o, "Chase & Status", TRACKPARSE_NUL_TERMINATED)); + t = trackparse_parse_with("Chase & Status - Baddadan", TRACKPARSE_NUL_TERMINATED, o); + CHECK(t != NULL && t->artists_count == 1 && str_is(t->artists[0].name, "Chase & Status")); + if (t != NULL) { + check_wire("parseWith known", trackparse_track_to_json(t), + "{\"fn\":\"parse\",\"input\":\"Chase & Status - Baddadan\",\"options\":{" + "\"knownArtists\":[\"Chase & Status\"]}}"); + } + trackparse_track_free(t); + a = trackparse_parse_artists_with("Chase & Status", TRACKPARSE_NUL_TERMINATED, o); + CHECK(a != NULL && a->count == 1); + trackparse_artists_free(a); + trackparse_parse_options_free(o); + + /* Mode, uploader. */ + o = trackparse_parse_options_new(); + CHECK(trackparse_parse_options_set_mode(o, TRACKPARSE_MODE_YOUTUBE)); + t = trackparse_parse_with("\"Numb\" by Linkin Park", TRACKPARSE_NUL_TERMINATED, o); + CHECK(t != NULL && t->artists_count == 1 && str_is(t->artists[0].name, "Linkin Park") && + str_is(t->title, "Numb") && t->warnings_count == 1 && + t->warnings[0] == TRACKPARSE_WARNING_BY_SPLIT); + trackparse_track_free(t); + CHECK(trackparse_parse_options_set_uploader(o, "Porter Robinson", TRACKPARSE_NUL_TERMINATED)); + t = trackparse_parse_with("Shelter", TRACKPARSE_NUL_TERMINATED, o); + CHECK(t != NULL && t->artists_count == 1 && str_is(t->artists[0].name, "Porter Robinson") && + str_is(t->title, "Shelter")); + trackparse_track_free(t); + /* A bad mode value falls back to the default (auto). */ + CHECK(trackparse_parse_options_set_mode(o, (trackparse_mode)42)); + CHECK(trackparse_parse_options_set_split_and(o, (trackparse_split_and)42)); + t = trackparse_parse_with("Shelter", TRACKPARSE_NUL_TERMINATED, o); + CHECK(t != NULL && t->mode == TRACKPARSE_MODE_CLEAN); + trackparse_track_free(t); + trackparse_parse_options_free(o); + + /* Keywords and splitAnd, against the JSON door. */ + o = trackparse_parse_options_new(); + CHECK(trackparse_parse_options_add_junk(o, "some label rip", TRACKPARSE_NUL_TERMINATED, "label", + TRACKPARSE_NUL_TERMINATED)); + CHECK(trackparse_parse_options_add_version_head(o, "rerub", TRACKPARSE_NUL_TERMINATED, + "rerubtype", TRACKPARSE_NUL_TERMINATED)); + CHECK(trackparse_parse_options_add_descriptor(o, "deluxe", TRACKPARSE_NUL_TERMINATED)); + CHECK(trackparse_parse_options_add_genre(o, "neurofunk", TRACKPARSE_NUL_TERMINATED)); + CHECK(trackparse_parse_options_add_feat_marker(o, "avec", TRACKPARSE_NUL_TERMINATED)); + CHECK(trackparse_parse_options_set_split_and(o, TRACKPARSE_SPLIT_AND_NEVER)); + t = trackparse_parse_with("A and B avec C - Song (D Rerub) [Some Label Rip]", + TRACKPARSE_NUL_TERMINATED, o); + CHECK(t != NULL); + if (t != NULL) { + CHECK(t->junk_count == 1 && t->junk[0].kind == TRACKPARSE_JUNK_LABEL); + /* A type that keywords introduced: VERSION in the enum, the name kept. */ + CHECK(t->versions_count == 1 && t->versions[0].type == TRACKPARSE_VERSION_VERSION && + str_is(t->versions[0].type_name, "rerubtype")); + check_wire("parseWith keywords", trackparse_track_to_json(t), + "{\"fn\":\"parse\",\"input\":\"A and B avec C - Song (D Rerub) [Some Label Rip]\"," + "\"options\":{\"splitAnd\":\"never\",\"keywords\":{\"junk\":{\"some label rip\":" + "\"label\"},\"versionHeads\":{\"rerub\":\"rerubtype\"},\"descriptors\":[" + "\"deluxe\"],\"genres\":[\"neurofunk\"],\"featMarkers\":[\"avec\"]}}}"); + } + trackparse_track_free(t); + trackparse_parse_options_free(o); +} + +static void test_format(void) { + trackparse_track *t = trackparse_parse( + "01. Wilkinson ft. Becky Hill - Afterglow (Sub Focus Remix)", TRACKPARSE_NUL_TERMINATED); + trackparse_format_options *o = trackparse_format_options_new(); + trackparse_string *s; + CHECK(t != NULL && o != NULL); + if (t == NULL || o == NULL) return; + s = trackparse_format(t); + CHECK(s != NULL && str_is(s->str, "Wilkinson ft. Becky Hill - Afterglow (Sub Focus Remix)")); + trackparse_string_free(s); + s = trackparse_format_with(t, NULL); + CHECK(s != NULL && str_is(s->str, "Wilkinson ft. Becky Hill - Afterglow (Sub Focus Remix)")); + trackparse_string_free(s); + CHECK(trackparse_format_options_set_feat(o, TRACKPARSE_FEAT_TITLE)); + CHECK(trackparse_format_options_set_joiners(o, TRACKPARSE_JOINERS_CANONICAL)); + s = trackparse_format_with(t, o); + CHECK(s != NULL && str_is(s->str, "Wilkinson - Afterglow (feat. Becky Hill) (Sub Focus Remix)")); + trackparse_string_free(s); + trackparse_format_options_free(o); + + o = trackparse_format_options_new(); + CHECK(trackparse_format_options_set_feat(o, TRACKPARSE_FEAT_OMIT)); + CHECK(trackparse_format_options_set_versions(o, TRACKPARSE_VERSIONS_NONE)); + s = trackparse_format_with(t, o); + CHECK(s != NULL && str_is(s->str, "Wilkinson - Afterglow")); + trackparse_string_free(s); + trackparse_format_options_free(o); + + o = trackparse_format_options_new(); + CHECK(trackparse_format_options_set_position(o, true)); + CHECK(trackparse_format_options_set_omit_producers(o, true)); + s = trackparse_format_with(t, o); + CHECK(s != NULL && str_is(s->str, "01. Wilkinson ft. Becky Hill - Afterglow (Sub Focus Remix)")); + trackparse_string_free(s); + CHECK(trackparse_format_options_set_feat_marker(o, "with", TRACKPARSE_NUL_TERMINATED)); + CHECK(trackparse_format_options_set_position(o, false)); + s = trackparse_format_with(t, o); + CHECK(s != NULL && str_is(s->str, "Wilkinson with Becky Hill - Afterglow (Sub Focus Remix)")); + trackparse_string_free(s); + /* "" is a valid marker; compare with the JSON door. */ + CHECK(trackparse_format_options_set_feat_marker(o, "", 0)); + s = trackparse_format_with(t, o); + CHECK(s != NULL); + if (s != NULL) { + wire_out w; + trackparse_string *want = wire(&w, "{\"fn\":\"format\",\"input\":\"01. Wilkinson ft. Becky " + "Hill - Afterglow (Sub Focus Remix)\",\"formatOptions\":{" + "\"featMarker\":\"\",\"producers\":false}}"); + trackparse_string *got = string_json(s); + SAME_JSON("format featMarker \"\"", got, want); + free(w.buf); + free(got); + trackparse_string_free(s); + } + trackparse_format_options_free(o); + trackparse_track_free(t); +} + +static void test_hand_built(void) { + trackparse_artist artist; + trackparse_version version; + trackparse_track t; + trackparse_string *s, *j; + trackparse_artists *all; + memset(&artist, 0, sizeof artist); + memset(&version, 0, sizeof version); + memset(&t, 0, sizeof t); + artist.name.ptr = "Noisia"; + artist.name.len = 6; + artist.role = TRACKPARSE_ROLE_PRIMARY; + artist.source = TRACKPARSE_SOURCE_ARTIST; + version.type = TRACKPARSE_VERSION_VIP; /* type_name left unset: the enum's name is used */ + version.raw.ptr = "VIP"; + version.raw.len = 3; + version.delimiter = TRACKPARSE_DELIMITER_PAREN; + version.modifiers_count = 3; /* with a NULL pointer: no modifiers */ + t.input.ptr = "Noisia - Stigma (VIP)"; + t.input.len = 21; + t.mode = TRACKPARSE_MODE_CLEAN; + t.artists = &artist; + t.artists_count = 1; + t.title.ptr = "Stigma"; + t.title.len = 6; + t.full_title.ptr = "Stigma (VIP)"; + t.full_title.len = 12; + t.versions = &version; + t.versions_count = 1; + t.junk_count = 7; /* NULL junk */ + t.warnings_count = 2; /* NULL warnings */ + + s = trackparse_format(&t); + CHECK(s != NULL && str_is(s->str, "Noisia - Stigma (VIP)")); + trackparse_string_free(s); + + j = trackparse_track_to_json(&t); + check_wire("hand-built to_json", j, "{\"fn\":\"parse\",\"input\":\"Noisia - Stigma (VIP)\"}"); + + all = trackparse_all_artists(&t); + CHECK(all != NULL && all->count == 1 && str_is(all->items[0].name, "Noisia")); + trackparse_artists_free(all); + + /* An all-zero track and a NULL track format as "" (Go Format(Track{})). */ + memset(&t, 0, sizeof t); + s = trackparse_format(&t); + CHECK(s != NULL && s->str.len == 0 && s->str.ptr != NULL); + trackparse_string_free(s); + s = trackparse_format(NULL); + CHECK(s != NULL && s->str.len == 0); + trackparse_string_free(s); + all = trackparse_all_artists(NULL); + CHECK(all != NULL && all->count == 0); + trackparse_artists_free(all); + j = trackparse_track_to_json(&t); + CHECK(j != NULL && strstr(j->str.ptr, "\"mode\":\"auto\"") != NULL && + strstr(j->str.ptr, "\"artists\":[]") != NULL); + trackparse_string_free(j); + t.mode = (trackparse_mode)77; + j = trackparse_track_to_json(&t); + CHECK(j != NULL && strstr(j->str.ptr, "\"mode\":\"\"") != NULL); + trackparse_string_free(j); + j = trackparse_track_to_json(NULL); + CHECK(j != NULL && str_is(j->str, "null")); + trackparse_string_free(j); + j = trackparse_artists_to_json(NULL); + CHECK(j != NULL && str_is(j->str, "null")); + trackparse_string_free(j); + j = trackparse_tracklist_to_json(NULL); + CHECK(j != NULL && str_is(j->str, "null")); + trackparse_string_free(j); + j = trackparse_edit_result_to_json(NULL); + CHECK(j != NULL && str_is(j->str, "null")); + trackparse_string_free(j); +} + +static void test_normalize_and_all_artists(void) { + trackparse_string *s = + trackparse_normalize("Noisia\xe2\x80\x8b \xe2\x80\x93 Stigma \xef\xbc\x88VIP\xef\xbc\x89", + TRACKPARSE_NUL_TERMINATED); + trackparse_track *t; + trackparse_artists *a; + CHECK(s != NULL && str_is(s->str, "Noisia - Stigma (VIP)")); + trackparse_string_free(s); + s = trackparse_normalize(NULL, 0); + CHECK(s != NULL && s->str.len == 0); + trackparse_string_free(s); + + t = trackparse_parse("Wilkinson ft. Becky Hill - Afterglow (Sub Focus Remix)", + TRACKPARSE_NUL_TERMINATED); + a = trackparse_all_artists(t); + CHECK(a != NULL && a->count == 3); + if (a != NULL && a->count == 3) { + CHECK(str_is(a->items[0].name, "Wilkinson") && a->items[0].role == TRACKPARSE_ROLE_PRIMARY); + CHECK(str_is(a->items[1].name, "Becky Hill") && a->items[1].role == TRACKPARSE_ROLE_FEATURED); + CHECK(str_is(a->items[2].name, "Sub Focus") && a->items[2].role == TRACKPARSE_ROLE_REMIXER); + } + trackparse_artists_free(a); + trackparse_track_free(t); +} + +static const char *const parser_inputs[] = { + "Chase & Status x Camo & Krooked - Track (Alix Perez Rerub)", + "Chase & Status - Baddadan", + "Camo & Krooked feat. Chase & Status - Something (Rerub)", +}; + +static void test_parser(void) { + trackparse_parse_options *o = trackparse_parse_options_new(); + trackparse_parser *p, *plain; + trackparse_track *t; + trackparse_artists *a; + trackparse_string *want[TP_COUNT(parser_inputs)]; + size_t i; + int round; + CHECK(trackparse_parse_options_add_known_artist(o, "Chase & Status", TRACKPARSE_NUL_TERMINATED)); + CHECK(trackparse_parse_options_add_known_artist(o, "Camo & Krooked", TRACKPARSE_NUL_TERMINATED)); + CHECK(trackparse_parse_options_add_version_head(o, "rerub", TRACKPARSE_NUL_TERMINATED, "rework", + TRACKPARSE_NUL_TERMINATED)); + for (i = 0; i < TP_COUNT(parser_inputs); i++) { + t = trackparse_parse_with(parser_inputs[i], TRACKPARSE_NUL_TERMINATED, o); + want[i] = trackparse_track_to_json(t); + trackparse_track_free(t); + } + p = trackparse_parser_new(o); + CHECK(p != NULL); + /* The parser keeps its own copies: freeing (and scribbling over) the options is harmless. */ + trackparse_parse_options_free(o); + for (round = 0; round < 3; round++) { + for (i = 0; i < TP_COUNT(parser_inputs); i++) { + trackparse_string *got; + t = trackparse_parser_parse(p, parser_inputs[i], TRACKPARSE_NUL_TERMINATED); + got = trackparse_track_to_json(t); + SAME_JSON("parser reuse", got, want[i]); + trackparse_string_free(got); + trackparse_track_free(t); + } + } + t = trackparse_parser_parse(p, parser_inputs[0], TRACKPARSE_NUL_TERMINATED); + CHECK(t != NULL && t->artists_count == 2 && str_is(t->artists[0].name, "Chase & Status") && + str_is(t->artists[1].name, "Camo & Krooked") && t->versions_count == 1 && + t->versions[0].type == TRACKPARSE_VERSION_REWORK); + trackparse_track_free(t); + a = trackparse_parser_parse_artists(p, "Chase & Status, Camo & Krooked", + TRACKPARSE_NUL_TERMINATED); + CHECK(a != NULL && a->count == 2); + trackparse_artists_free(a); + for (i = 0; i < TP_COUNT(parser_inputs); i++) trackparse_string_free(want[i]); + trackparse_parser_free(p); + + /* A parser without options, and a NULL parser, use the defaults. */ + plain = trackparse_parser_new(NULL); + CHECK(plain != NULL); + t = trackparse_parser_parse(plain, "Chase & Status - Baddadan", TRACKPARSE_NUL_TERMINATED); + CHECK(t != NULL && t->artists_count == 2); + trackparse_track_free(t); + trackparse_parser_free(plain); + t = trackparse_parser_parse(NULL, "Chase & Status - Baddadan", TRACKPARSE_NUL_TERMINATED); + CHECK(t != NULL && t->artists_count == 2); + trackparse_track_free(t); + a = trackparse_parser_parse_artists(NULL, "A & B", TRACKPARSE_NUL_TERMINATED); + CHECK(a != NULL && a->count == 2); + trackparse_artists_free(a); +} + +static const char tracklist_text[] = "Hour 2\r\n" + "48:20 Noisia - Stigma\r\n" + "52:47 Mefjus & Kasra - Bandwagon (Phace Remix)\r\n" + "56:05 Black Sun Empire - ID\r\n" + "59:31 Alix Perez - Fade Away\r\n" + "01:03:10 Interview with Hybris\r\n" + "01:07:44 Imanu - Sacrifice\r\n" + "00:11:02 Current Value feat. Teddy Killerz - Payload\r\n" + "01:15:36 Hybris - Spinning Top"; + +static void test_tracklist(void) { + trackparse_tracklist *l = trackparse_parse_tracklist(tracklist_text, TRACKPARSE_NUL_TERMINATED); + trackparse_tracklist_options *o; + size_t i, at = 0; + bool joined = true; + CHECK(l != NULL); + if (l == NULL) return; + STR_IS(l->spec_version, TP_SPEC_VERSION); + CHECK(l->entries_count == 9); + for (i = 0; i < l->entries_count; i++) { + const trackparse_entry *e = &l->entries[i]; + const char *eol = trackparse_eol_name(e->eol); + size_t n = strlen(eol); + joined = joined && memcmp(tracklist_text + at, e->raw.ptr, e->raw.len) == 0; + at += e->raw.len; + joined = joined && memcmp(tracklist_text + at, eol, n) == 0; + at += n; + CHECK(e->line == (int)i + 1); + } + CHECK(joined && at == sizeof tracklist_text - 1); + if (l->entries_count == 9) { + const trackparse_entry *e = &l->entries[2]; + CHECK(l->entries[0].kind == TRACKPARSE_ENTRY_HEADER); + CHECK(l->entries[5].kind == TRACKPARSE_ENTRY_MARKER); + CHECK(l->entries[8].eol == TRACKPARSE_EOL_NONE && l->entries[0].eol == TRACKPARSE_EOL_CRLF); + CHECK(e->kind == TRACKPARSE_ENTRY_TRACK && e->time != NULL && str_is(e->time->raw, "52:47") && + e->time->seconds == 3167); + STR_IS(e->parts.rest, "Mefjus & Kasra - Bandwagon (Phace Remix)"); + CHECK(e->track != NULL && e->track->artists_count == 2 && + str_is(e->track->title, "Bandwagon") && e->track->versions_count == 1 && + e->track->versions[0].type == TRACKPARSE_VERSION_REMIX); + CHECK(l->entries[3].track != NULL && l->entries[3].track->flags.unknown_title); + CHECK(l->entries[0].track == NULL && l->entries[0].time == NULL); + } + CHECK(l->warnings_count == 2); + if (l->warnings_count == 2) { + CHECK(l->warnings[0].code == TRACKPARSE_TL_NO_START_AT_ZERO && l->warnings[0].line == 2 && + l->warnings[0].severity == TRACKPARSE_SEVERITY_INFO && l->warnings[0].suggestion == NULL); + CHECK(l->warnings[1].code == TRACKPARSE_TL_TIME_OUT_OF_ORDER && l->warnings[1].line == 8 && + l->warnings[1].severity == TRACKPARSE_SEVERITY_WARNING); + CHECK(l->warnings[1].suggestion != NULL && l->warnings[1].suggestion->line == 8 && + str_is(l->warnings[1].suggestion->raw, "01:11:02") && + l->warnings[1].suggestion->seconds == 4262); + } + CHECK(l->stats.lines == 9 && l->stats.tracks == 7 && l->stats.markers == 1 && + l->stats.timed == 8); + CHECK(l->stats.first_time != NULL && *l->stats.first_time == 2900); + CHECK(l->stats.last_time != NULL && *l->stats.last_time == 4536); + check_wire("parseTracklist", trackparse_tracklist_to_json(l), + "{\"fn\":\"parseTracklist\",\"input\":\"Hour 2\\r\\n48:20 Noisia - Stigma\\r\\n52:47 " + "Mefjus & Kasra - Bandwagon (Phace Remix)\\r\\n56:05 Black Sun Empire - ID\\r\\n59:31 " + "Alix Perez - Fade Away\\r\\n01:03:10 Interview with Hybris\\r\\n01:07:44 Imanu - " + "Sacrifice\\r\\n00:11:02 Current Value feat. Teddy Killerz - Payload\\r\\n01:15:36 " + "Hybris - Spinning Top\"}"); + trackparse_tracklist_free(l); + + /* Options: audio length (0 is a length), mode, and the rest against the JSON door. */ + o = trackparse_tracklist_options_new(); + CHECK(o != NULL); + CHECK(trackparse_tracklist_options_set_audio_seconds(o, 0)); + l = trackparse_parse_tracklist_with("00:00 A - B\n00:30 C - D", TRACKPARSE_NUL_TERMINATED, o); + CHECK(l != NULL && l->warnings_count == 1 && + l->warnings[0].code == TRACKPARSE_TL_TIME_AFTER_AUDIO_END && l->warnings[0].line == 2); + trackparse_tracklist_free(l); + CHECK(trackparse_tracklist_options_set_audio_seconds(o, 3600)); + CHECK(trackparse_tracklist_options_set_mode(o, TRACKPARSE_MODE_AUTO)); + CHECK(trackparse_tracklist_options_set_split_and(o, TRACKPARSE_SPLIT_AND_ALWAYS)); + CHECK(trackparse_tracklist_options_add_known_artist(o, "Camo & Krooked", + TRACKPARSE_NUL_TERMINATED)); + CHECK(trackparse_tracklist_options_add_version_head(o, "rerub", TRACKPARSE_NUL_TERMINATED, + "rework", TRACKPARSE_NUL_TERMINATED)); + CHECK(trackparse_tracklist_options_add_descriptor(o, "deluxe", TRACKPARSE_NUL_TERMINATED)); + CHECK(trackparse_tracklist_options_add_genre(o, "neurofunk", TRACKPARSE_NUL_TERMINATED)); + CHECK(trackparse_tracklist_options_add_junk(o, "out now", TRACKPARSE_NUL_TERMINATED, "promo", + TRACKPARSE_NUL_TERMINATED)); + CHECK(trackparse_tracklist_options_add_feat_marker(o, "avec", TRACKPARSE_NUL_TERMINATED)); + CHECK(trackparse_tracklist_options_add_marker_word(o, "Intermission", TRACKPARSE_NUL_TERMINATED)); + l = trackparse_parse_tracklist_with( + "00:00 Camo & Krooked and X - Y (Z Rerub) Out Now\n1:02:03 C avec D - E\n" + "1:05:00 Intermission\n", + TRACKPARSE_NUL_TERMINATED, o); + CHECK(l != NULL); + if (l != NULL) { + check_wire("parseTracklistWith", trackparse_tracklist_to_json(l), + "{\"fn\":\"parseTracklist\",\"input\":\"00:00 Camo & Krooked and X - Y (Z Rerub) " + "Out Now\\n1:02:03 C avec D - E\\n1:05:00 Intermission\\n\",\"options\":{" + "\"audioSeconds\":3600,\"mode\":\"auto\",\"splitAnd\":\"always\"," + "\"knownArtists\":[\"Camo & Krooked\"],\"keywords\":{\"versionHeads\":{\"rerub\":" + "\"rework\"},\"descriptors\":[\"deluxe\"],\"genres\":[\"neurofunk\"],\"junk\":{" + "\"out now\":\"promo\"},\"featMarkers\":[\"avec\"]},\"markerWords\":[" + "\"Intermission\"]}}"); + trackparse_tracklist_free(l); + } + trackparse_tracklist_options_free(o); + + l = trackparse_parse_tracklist_with("", 0, NULL); + CHECK(l != NULL && l->entries_count == 0 && l->entries == NULL && l->stats.first_time == NULL); + trackparse_tracklist_free(l); +} + +static void test_edits(void) { + static const char text[] = + "48:20 Noisia - Stigma\r\n59:31 Alix Perez - Fade Away\r\n00:03:10 Imanu - Sacrifice\r\n"; + trackparse_edits *e = trackparse_edits_new(); + trackparse_edit_result *r; + static const long long one[] = {1}; + CHECK(e != NULL); + CHECK(trackparse_edits_set_time(e, 3, 3790)); + CHECK(trackparse_edits_shift_from(e, 45, 2)); + r = trackparse_apply_edits(text, TRACKPARSE_NUL_TERMINATED, e); + CHECK(r != NULL); + if (r != NULL) { + STR_IS(r->text, "48:20 Noisia - Stigma\r\n01:00:16 Alix Perez - Fade Away\r\n01:03:55 Imanu - " + "Sacrifice\r\n"); + CHECK(r->changed_count == 2 && r->changed[0] == 2 && r->changed[1] == 3); + CHECK(r->warnings_count == 1 && r->warnings[0].code == TRACKPARSE_EDIT_WARNING_STYLE_UPGRADED && + r->warnings[0].edit == 1 && r->warnings[0].line != NULL && *r->warnings[0].line == 2); + check_wire("applyEdits", trackparse_edit_result_to_json(r), + "{\"fn\":\"applyEdits\",\"input\":\"48:20 Noisia - Stigma\\r\\n59:31 Alix Perez - " + "Fade Away\\r\\n00:03:10 Imanu - Sacrifice\\r\\n\",\"edits\":[{\"op\":\"set-time\"," + "\"line\":3,\"seconds\":3790},{\"op\":\"shift\",\"seconds\":45,\"from\":2}]}"); + } + trackparse_edit_result_free(r); + trackparse_edits_free(e); + + e = trackparse_edits_new(); + CHECK(trackparse_edits_shift_lines(e, -3000, one, 1)); + r = trackparse_apply_edits(text, TRACKPARSE_NUL_TERMINATED, e); + CHECK(r != NULL && r->warnings_count == 1 && + r->warnings[0].code == TRACKPARSE_EDIT_WARNING_TIME_CLAMPED); + trackparse_edit_result_free(r); + trackparse_edits_free(e); + + e = trackparse_edits_new(); + CHECK(trackparse_edits_delete(e, 9)); + r = trackparse_apply_edits(text, TRACKPARSE_NUL_TERMINATED, e); + CHECK(r != NULL && r->warnings_count == 1 && + r->warnings[0].code == TRACKPARSE_EDIT_WARNING_EDIT_INVALID && + r->text.len == sizeof text - 1 && memcmp(r->text.ptr, text, r->text.len) == 0 && + r->changed_count == 0); + trackparse_edit_result_free(r); + trackparse_edits_free(e); + + /* Every constructor, against the JSON door. shift_lines with no line shifts nothing; a NaN + * shift is edit-invalid (JSON null). */ + e = trackparse_edits_new(); + CHECK(trackparse_edits_shift(e, 1.5)); + CHECK(trackparse_edits_shift_lines(e, 7, NULL, 0)); + CHECK(trackparse_edits_shift_lines(e, 7, one, 1)); + CHECK(trackparse_edits_sort_by_time(e)); + CHECK(trackparse_edits_set_rest(e, 2, "New - Rest", TRACKPARSE_NUL_TERMINATED)); + CHECK(trackparse_edits_insert(e, 0, "00:00 Intro - Start", TRACKPARSE_NUL_TERMINATED)); + CHECK(trackparse_edits_delete(e, 4)); + CHECK(trackparse_edits_shift(e, tp_nan())); + CHECK(trackparse_edits_set_time(e, 1, -0.0)); + r = trackparse_apply_edits(text, TRACKPARSE_NUL_TERMINATED, e); + CHECK(r != NULL); + if (r != NULL) { + check_wire("applyEdits all", trackparse_edit_result_to_json(r), + "{\"fn\":\"applyEdits\",\"input\":\"48:20 Noisia - Stigma\\r\\n59:31 Alix Perez - " + "Fade Away\\r\\n00:03:10 Imanu - Sacrifice\\r\\n\",\"edits\":[{\"op\":\"shift\"," + "\"seconds\":1.5},{\"op\":\"shift\",\"seconds\":7,\"lines\":[]},{\"op\":\"shift\"," + "\"seconds\":7,\"lines\":[1]},{\"op\":\"sort-by-time\"},{\"op\":\"set-rest\"," + "\"line\":2,\"rest\":\"New - Rest\"},{\"op\":\"insert\",\"after\":0,\"text\":" + "\"00:00 Intro - Start\"},{\"op\":\"delete\",\"line\":4},{\"op\":\"shift\"," + "\"seconds\":null},{\"op\":\"set-time\",\"line\":1,\"seconds\":0}]}"); + } + trackparse_edit_result_free(r); + trackparse_edits_free(e); + + /* No edits, and NULL edits. */ + r = trackparse_apply_edits(text, TRACKPARSE_NUL_TERMINATED, NULL); + CHECK(r != NULL && r->text.len == sizeof text - 1 && r->warnings_count == 0 && + r->changed == NULL); + trackparse_edit_result_free(r); +} + +/* -------------------------------------------------------------------------------------------- */ +/* Out of memory at every allocation: NULL (or false), nothing leaked, then success. */ + +typedef void *(*oom_call)(void); + +static void *oom_parse(void) { + return trackparse_parse("Wilkinson ft. Becky Hill - Afterglow (Sub Focus VIP Remix) [HD]", + TRACKPARSE_NUL_TERMINATED); +} +static void oom_free_track(void *p) { trackparse_track_free((trackparse_track *)p); } + +static void *oom_tracklist(void) { + return trackparse_parse_tracklist(tracklist_text, TRACKPARSE_NUL_TERMINATED); +} +static void oom_free_tracklist(void *p) { trackparse_tracklist_free((trackparse_tracklist *)p); } + +static void *oom_parser(void) { + trackparse_parse_options *o = trackparse_parse_options_new(); + trackparse_parser *p = NULL; + if (o == NULL) return NULL; + if (trackparse_parse_options_add_known_artist(o, "Chase & Status", TRACKPARSE_NUL_TERMINATED) && + trackparse_parse_options_add_junk(o, "out now", TRACKPARSE_NUL_TERMINATED, "promo", + TRACKPARSE_NUL_TERMINATED)) { + p = trackparse_parser_new(o); + } + trackparse_parse_options_free(o); + return p; +} +static void oom_free_parser(void *p) { trackparse_parser_free((trackparse_parser *)p); } + +static void *oom_edits(void) { + trackparse_edits *e = trackparse_edits_new(); + trackparse_edit_result *r = NULL; + if (e == NULL) return NULL; + if (trackparse_edits_set_time(e, 3, 3790) && trackparse_edits_insert(e, 1, "x", 1)) { + r = trackparse_apply_edits(tracklist_text, TRACKPARSE_NUL_TERMINATED, e); + } + trackparse_edits_free(e); + return r; +} +static void oom_free_edits(void *p) { trackparse_edit_result_free((trackparse_edit_result *)p); } + +static void *oom_json(void) { + trackparse_track *t = trackparse_parse("Noisia - Stigma (VIP)", TRACKPARSE_NUL_TERMINATED); + trackparse_string *s = NULL; + if (t == NULL) return NULL; + s = trackparse_track_to_json(t); + trackparse_track_free(t); + return s; +} +static void oom_free_string(void *p) { trackparse_string_free((trackparse_string *)p); } + +static void check_oom(const char *what, oom_call call, void (*release)(void *)) { + long n, base = live_blocks; + void *r = NULL; + for (n = 0; n < 100000; n++) { + fail_from(n); + r = call(); + fail_from(-1); + if (r != NULL) break; + if (live_blocks != base) { + fprintf(stderr, "%s: %ld blocks leaked after failing malloc %ld\n", what, live_blocks - base, + n); + failures++; + return; + } + } + checks++; + if (r == NULL) { + fprintf(stderr, "%s: never succeeded\n", what); + failures++; + return; + } + release(r); + CHECK(live_blocks == base); + CHECK(n > 0); /* at least one failure was exercised */ +} + +static void test_oom(void) { + trackparse_parse_options *o; + bool ok; + long base; + /* Warm up the process-wide tables (built once, kept forever). */ + oom_free_tracklist(oom_tracklist()); + oom_free_track(oom_parse()); + + check_oom("parse", oom_parse, oom_free_track); + check_oom("parse_tracklist", oom_tracklist, oom_free_tracklist); + check_oom("parser_new", oom_parser, oom_free_parser); + check_oom("apply_edits", oom_edits, oom_free_edits); + check_oom("to_json", oom_json, oom_free_string); + + /* A setter that runs out of memory leaves the option unchanged. */ + o = trackparse_parse_options_new(); + CHECK(o != NULL); + CHECK(trackparse_parse_options_add_known_artist(o, "Chase & Status", TRACKPARSE_NUL_TERMINATED)); + base = live_blocks; + fail_from(0); + ok = trackparse_parse_options_add_known_artist(o, "Camo & Krooked", TRACKPARSE_NUL_TERMINATED); + fail_from(-1); + CHECK(!ok); + CHECK(live_blocks == base); + { + trackparse_track *t = trackparse_parse_with("Camo & Krooked - X", TRACKPARSE_NUL_TERMINATED, o); + CHECK(t != NULL && t->artists_count == 2); + trackparse_track_free(t); + t = trackparse_parse_with("Chase & Status - X", TRACKPARSE_NUL_TERMINATED, o); + CHECK(t != NULL && t->artists_count == 1); + trackparse_track_free(t); + } + trackparse_parse_options_free(o); + + /* Running out on the handle itself. */ + base = live_blocks; + fail_from(0); + CHECK(trackparse_parse_options_new() == NULL); + fail_from(0); + CHECK(trackparse_edits_new() == NULL); + fail_from(0); + CHECK(trackparse_parser_new(NULL) == NULL); + fail_from(-1); + CHECK(live_blocks == base); +} + +/* -------------------------------------------------------------------------------------------- */ +/* A parser shared between threads */ + +#ifdef TP_TEST_THREADS +typedef struct thread_arg { + const trackparse_parser *p; + const trackparse_string *want; + int bad; +} thread_arg; + +static void *thread_main(void *arg) { + thread_arg *a = (thread_arg *)arg; + int i; + for (i = 0; i < 200; i++) { + trackparse_track *t = + trackparse_parser_parse(a->p, parser_inputs[0], TRACKPARSE_NUL_TERMINATED); + trackparse_string *s = trackparse_track_to_json(t); + if (!same_text(s, a->want)) a->bad++; + trackparse_string_free(s); + trackparse_track_free(t); + } + return NULL; +} + +static void test_threads(void) { + trackparse_parse_options *o = trackparse_parse_options_new(); + trackparse_parser *p; + trackparse_track *t; + trackparse_string *want; + pthread_t th[4]; + thread_arg args[4]; + int i; + CHECK(trackparse_parse_options_add_known_artist(o, "Chase & Status", TRACKPARSE_NUL_TERMINATED)); + p = trackparse_parser_new(o); + trackparse_parse_options_free(o); + t = trackparse_parser_parse(p, parser_inputs[0], TRACKPARSE_NUL_TERMINATED); + want = trackparse_track_to_json(t); + trackparse_track_free(t); + for (i = 0; i < 4; i++) { + args[i].p = p; + args[i].want = want; + args[i].bad = 0; + CHECK(pthread_create(&th[i], NULL, thread_main, &args[i]) == 0); + } + for (i = 0; i < 4; i++) { + pthread_join(th[i], NULL); + CHECK(args[i].bad == 0); + } + trackparse_string_free(want); + trackparse_parser_free(p); +} +#endif + +int main(void) { + static const trackparse_allocator counting = {count_malloc, count_realloc, count_free, NULL}; + trackparse_set_allocator(&counting); + test_versions(); + test_enums(); + test_parse(); + test_embedded_nul(); + test_invalid_utf8(); + test_parse_artists(); + test_parse_with(); + test_format(); + test_hand_built(); + test_normalize_and_all_artists(); + test_parser(); + test_tracklist(); + test_edits(); + test_oom(); +#ifdef TP_TEST_THREADS + test_threads(); +#endif + trackparse_set_allocator(NULL); + printf("test_api: %ld checks, %d failures\n", checks, failures); + return failures == 0 ? 0 : 1; +} diff --git a/c/tests/test_bench.c b/c/tests/test_bench.c new file mode 100644 index 0000000..5bc8be1 --- /dev/null +++ b/c/tests/test_bench.c @@ -0,0 +1,327 @@ +/* test_bench.c: benchmarks, printed like go test -bench (go/bench_test.go). Not a CTest test: + * + * test_bench [-benchtime ] [--fixtures ...] + * TRACKPARSE_BENCH=1 cmake ... registers it as the CTest test "bench" + * + * Each benchmark runs its call N times, doubling N until the run takes -benchtime seconds + * (default 1), and prints ns/op and allocs/op (allocations from the system allocator: arena + * chunks and result blocks). Every call goes through the public API, so the numbers include + * building the result and freeing it. With --fixtures it also reports the mean over every + * fixture input per function, and the scaling ratios of go's + * TestRepeatedFragmentsScaleBelowQuadratic (4 times the input should take about 4 times as + * long, not 16). */ +#include +#include + +#include "../include/trackparse.h" +#include "hardening.h" + +static double benchtime = 1; +static long long allocs; + +static void *bench_malloc(size_t size, void *user) { + (void)user; + allocs++; + return malloc(size); +} + +static void *bench_realloc(void *p, size_t size, void *user) { + (void)user; + allocs++; + return realloc(p, size); +} + +static void bench_free(void *p, void *user) { + (void)user; + free(p); +} + +typedef void (*bench_fn)(const void *arg); + +/* Run f until the run takes benchtime; print the line. */ +static void bench(const char *name, bench_fn f, const void *arg) { + long long n = 1; + double d = 0; + long long a = 0; + for (;;) { + double start = hz_now(); + allocs = 0; + for (long long i = 0; i < n; i++) f(arg); + d = hz_now() - start; + a = allocs; + if (d >= benchtime || n >= (1LL << 40)) break; + if (d < benchtime / 100) { + n *= 100; + } else { + long long next = (long long)((double)n * benchtime * 1.2 / d); + n = next > n * 2 ? next : n * 2; + } + } + printf("Benchmark%-36s %10lld %14.0f ns/op %8.1f allocs/op\n", name, n, d * 1e9 / (double)n, + (double)a / (double)n); + fflush(stdout); +} + +typedef struct text { + const char *s; + size_t n; + const trackparse_parser *p; + const trackparse_edits *e; +} text; + +static void b_parse(const void *arg) { + const text *t = (const text *)arg; + trackparse_track_free(trackparse_parse(t->s, t->n)); +} + +static void b_parser(const void *arg) { + const text *t = (const text *)arg; + trackparse_track_free(trackparse_parser_parse(t->p, t->s, t->n)); +} + +static void b_parse_artists(const void *arg) { + const text *t = (const text *)arg; + trackparse_artists_free(trackparse_parse_artists(t->s, t->n)); +} + +static void b_list(const void *arg) { + const text *t = (const text *)arg; + trackparse_tracklist_free(trackparse_parse_tracklist(t->s, t->n)); +} + +static void b_edits(const void *arg) { + const text *t = (const text *)arg; + trackparse_edit_result_free(trackparse_apply_edits(t->s, t->n, t->e)); +} + +static void b_json(const void *arg) { + const text *t = (const text *)arg; + trackparse_track *tr = trackparse_parse(t->s, t->n); + trackparse_string_free(trackparse_track_to_json(tr)); + trackparse_track_free(tr); +} + +/* block repeated to n code points, on the heap. */ +static char *repeated(const char *block, size_t n, size_t *len) { + size_t bl = strlen(block), cps = 0, out_n = 0, i = 0; + char *out = (char *)malloc(n * 4 + 1); + if (!out) exit(2); + while (cps < n) { + unsigned char c = (unsigned char)block[i]; + size_t k = c < 0x80 ? 1 : c < 0xe0 ? 2 : c < 0xf0 ? 3 : 4; + memcpy(out + out_n, block + i, k); + out_n += k; + cps++; + i = (i + k) % bl; + } + out[out_n] = '\0'; + *len = out_n; + return out; +} + +static void hms(char *b, int s) { + b[0] = (char)('0' + s / 36000 % 10); + b[1] = (char)('0' + s / 3600 % 10); + b[2] = ':'; + b[3] = (char)('0' + s % 3600 / 600); + b[4] = (char)('0' + s % 3600 / 60 % 10); + b[5] = ':'; + b[6] = (char)('0' + s % 60 / 10); + b[7] = (char)('0' + s % 10); +} + +static char *ten_thousand_lines(size_t *len) { + char *out = (char *)malloc(10000 * 80); + size_t n = 0; + if (!out) exit(2); + for (int i = 0; i < 10000; i++) { + if (i) { + out[n++] = '\r'; + out[n++] = '\n'; + } + hms(out + n, (i * 37) % 7200); + n += 8; + n += (size_t)sprintf(out + n, " %d Artist %d & Other - Title %d (VIP Mix)", i % 100, i, i); + } + out[n] = '\0'; + *len = n; + return out; +} + +static char *corpus_sized_list(size_t *len) { + static const char *const artists[] = {"Noisia", "Phace", "Fox Stevenson", "Sub Focus", + "Mefjus", "Camo & Krooked", "Alix Perez"}; + static const char *const remixers[] = {"Skrillex", "Magnetude", "Wilkinson", "Break"}; + char *out = (char *)malloc(8192); + size_t n = 0; + if (!out) exit(2); + n += (size_t)sprintf(out, "Tracklist:\n00:00 Intro\n"); + for (int i = 1; i <= 40; i++) { + hms(out + n, i * 150); + n += 8; + n += (size_t)sprintf(out + n, " %s feat. %s - Title %d (%s Remix)\n", artists[i % 7], + artists[(i + 3) % 7], i, remixers[i % 4]); + } + *len = n; + return out; +} + +static double time_once(bench_fn f, const void *arg) { + double best = 1e300; + for (int i = 0; i < 3; i++) { + double start = hz_now(), d; + f(arg); + d = hz_now() - start; + if (d < best) best = d; + } + return best; +} + +/* Mean ns per call over every fixture input of fn (parse inputs through parse, and so on). */ +static void fixture_means(const hz_cases *cases) { + static const char *const fns[] = {"parse", "parseArtists", "parseTracklist", "applyEdits"}; + trackparse_edits *e = trackparse_edits_new(); + if (!e || !trackparse_edits_shift(e, 5) || !trackparse_edits_sort_by_time(e)) exit(2); + for (size_t f = 0; f < TP_COUNT(fns); f++) { + long long calls = 0; + double start = hz_now(), d; + int rounds = 0; + do { + for (size_t i = 0; i < cases->n; i++) { + const hz_case *c = &cases->items[i]; + text t; + if (strcmp(c->fn, fns[f]) != 0) continue; + t.s = c->input; + t.n = c->input_n; + t.p = NULL; + t.e = e; + if (f == 0) b_parse(&t); + if (f == 1) b_parse_artists(&t); + if (f == 2) b_list(&t); + if (f == 3) b_edits(&t); + calls++; + } + rounds++; + d = hz_now() - start; + } while (d < benchtime && calls > 0); + if (calls) { + printf("BenchmarkFixtures/%-27s %10lld %14.0f ns/op (%d rounds over the %s inputs)\n", + fns[f], calls, d * 1e9 / (double)calls, rounds, fns[f]); + } + } + trackparse_edits_free(e); +} + +int main(int argc, char **argv) { + static const char typical[] = + "Noisia feat. Foreign Beggars - Shellshock (Phace Remix) [Official Video]"; + static const struct { + const char *name, *block; + } tenk[] = {{"text", "Noisia feat. Foreign Beggars - Shellshock (Phace Remix) [Official Video] "}, + {"feat", "a feat. "}, + {"and", "a & "}, + {"featX", "feat. X "}, + {"remix", "(Remix) "}, + {"hd", "[HD] "}, + {"dash", "- "}}; + trackparse_allocator a; + trackparse_parse_options *o; + trackparse_parser *p; + trackparse_edits *e; + hz_cases cases = {NULL, 0}; + text t; + char name[64]; + int files = 0; + for (int i = 1; i < argc; i++) { + if (strcmp(argv[i], "-benchtime") == 0 && i + 1 < argc) { + int v = atoi(argv[++i]); + if (v > 0) benchtime = v; + } else if (strcmp(argv[i], "--fixtures") == 0) { + files = argc - i - 1; + cases = hz_load_cases(files, argv + i + 1); + break; + } + } + a.malloc_fn = bench_malloc; + a.realloc_fn = bench_realloc; + a.free_fn = bench_free; + a.user = NULL; + trackparse_set_allocator(&a); +#ifdef TRACKPARSE_SANITIZED + printf("warning: built with sanitizers; the numbers are not representative\n"); +#endif + + memset(&t, 0, sizeof t); + t.s = typical; + t.n = sizeof typical - 1; + bench("Parse", b_parse, &t); + bench("ParseToJSON", b_json, &t); + o = trackparse_parse_options_new(); + if (!o || !trackparse_parse_options_set_mode(o, TRACKPARSE_MODE_YOUTUBE) || + !trackparse_parse_options_add_known_artist(o, "Camo & Krooked", TRACKPARSE_NUL_TERMINATED)) { + return 2; + } + p = trackparse_parser_new(o); + trackparse_parse_options_free(o); + t.p = p; + bench("Parser", b_parser, &t); + bench("ParseArtists", b_parse_artists, &t); + + for (size_t i = 0; i < TP_COUNT(tenk); i++) { + size_t n; + char *s = repeated(tenk[i].block, 10000, &n); + t.s = s; + t.n = n; + snprintf(name, sizeof name, "Parse10k/%s", tenk[i].name); + bench(name, b_parse, &t); + free(s); + } + + e = trackparse_edits_new(); + if (!e || !trackparse_edits_shift(e, 5) || !trackparse_edits_sort_by_time(e)) return 2; + t.e = e; + { + size_t n; + char *s = corpus_sized_list(&n); + t.s = s; + t.n = n; + bench("ParseTracklist/corpus-sized", b_list, &t); + bench("ApplyEdits/corpus-sized", b_edits, &t); + free(s); + s = ten_thousand_lines(&n); + t.s = s; + t.n = n; + bench("ParseTracklist/10k-lines", b_list, &t); + bench("ApplyEdits/10k-lines", b_edits, &t); + free(s); + } + + /* Scaling: 4 times the input should take about 4 times as long. */ + { + static const char *const blocks[] = {"a feat. ", "A feat. a, ", "(feat. a) ", "a & "}; + for (size_t i = 0; i < TP_COUNT(blocks); i++) { + size_t sn, ln; + char *small = repeated(blocks[i], 40000, &sn), *large = repeated(blocks[i], 160000, &ln); + text ts, tl; + double credits, track; + memset(&ts, 0, sizeof ts); + memset(&tl, 0, sizeof tl); + ts.s = small; + ts.n = sn; + tl.s = large; + tl.n = ln; + credits = time_once(b_parse_artists, &tl) / time_once(b_parse_artists, &ts); + track = time_once(b_parse, &tl) / time_once(b_parse, &ts); + printf("Scaling %-14s 40k -> 160k code points: parseArtists x%.1f, parse x%.1f\n", blocks[i], + credits, track); + free(small); + free(large); + } + } + + if (cases.n) fixture_means(&cases); + hz_free_cases(&cases); + trackparse_parser_free(p); + trackparse_edits_free(e); + return 0; +} diff --git a/c/tests/test_cpp.cpp b/c/tests/test_cpp.cpp new file mode 100644 index 0000000..2fb4494 --- /dev/null +++ b/c/tests/test_cpp.cpp @@ -0,0 +1,408 @@ +// test_cpp.cpp: the C++ wrapper (include/trackparse.hpp). Built in C++17 and C++20 against the +// installed library target (cmake/package.cmake). Every value is checked against the C API or +// against output the other ports give for the same input. +#include + +#include +#include +#include +#include +#include +#include +#include + +namespace tp = trackparse; + +static int failures = 0; + +#define CHECK(cond) \ + do { \ + if (!(cond)) { \ + std::fprintf(stderr, "%s:%d: CHECK(%s) failed\n", __FILE__, __LINE__, #cond); \ + failures++; \ + } \ + } while (0) + +#define CHECK_EQ(a, b) \ + do { \ + if (!((a) == (b))) { \ + std::fprintf(stderr, "%s:%d: CHECK_EQ(%s, %s) failed\n", __FILE__, __LINE__, #a, #b); \ + failures++; \ + } \ + } while (0) + +// The C JSON of a result, as a std::string, for comparisons with the wrapper's. +static std::string c_json(trackparse_string *s) { + std::string r(s->str.ptr, s->str.len); + trackparse_string_free(s); + return r; +} + +// The C JSON of a C track, which it then frees. +static std::string c_track_json(trackparse_track *t) { + std::string r = c_json(trackparse_track_to_json(t)); + trackparse_track_free(t); + return r; +} + +// Owners are move-only with noexcept moves; views and spans are trivially copyable. +static_assert(!std::is_copy_constructible_v); +static_assert(!std::is_copy_assignable_v); +static_assert(std::is_nothrow_move_constructible_v); +static_assert(std::is_nothrow_move_assignable_v); +static_assert(!std::is_copy_constructible_v); +static_assert(!std::is_copy_constructible_v); +static_assert(!std::is_copy_constructible_v); +static_assert(!std::is_copy_constructible_v); +static_assert(!std::is_copy_constructible_v); +static_assert(!std::is_copy_constructible_v); +static_assert(!std::is_copy_constructible_v); +static_assert(!std::is_copy_constructible_v); +static_assert(std::is_nothrow_move_constructible_v); +static_assert(std::is_nothrow_move_constructible_v); +static_assert(std::is_trivially_copyable_v); +static_assert(std::is_trivially_copyable_v); +static_assert(std::is_trivially_copyable_v); +static_assert(std::is_trivially_copyable_v); +// The enums carry the C values. +static_assert(static_cast(tp::mode::youtube) == TRACKPARSE_MODE_YOUTUBE); +static_assert(static_cast(tp::version_type::nightcore) == TRACKPARSE_VERSION_NIGHTCORE); +static_assert(static_cast(tp::tracklist_warning_code::line_unparsed) == + TRACKPARSE_TL_LINE_UNPARSED); +// Setters chain on temporaries (rvalue overloads) and on named builders (lvalue overloads). +static_assert( + std::is_same_v); +static_assert(std::is_same_v().mode(tp::mode::clean)), + tp::parse_options &>); +static_assert(std::is_same_v); + +static void test_version() { + CHECK_EQ(tp::header_version, std::string_view(TRACKPARSE_VERSION)); + CHECK_EQ(tp::library_version(), std::string_view(trackparse_library_version())); + CHECK_EQ(tp::spec_version(), std::string_view(trackparse_spec_version())); +} + +static void test_parse() { + auto t = tp::parse("Noisia - Stigma (2015)"); + CHECK_EQ(t.title(), "Stigma"); + CHECK_EQ(t.full_title(), "Stigma"); + CHECK_EQ(t.input(), "Noisia - Stigma (2015)"); + CHECK(t.year().has_value()); + CHECK_EQ(t.year().value_or(0), 2015); + CHECK_EQ(t.artists().size(), 1u); + CHECK_EQ(t.artists()[0].name(), "Noisia"); + CHECK(t.artists()[0].role() == tp::role::primary); + CHECK(t.artists()[0].source() == tp::source::artist); + CHECK(!t.artists()[0].joiner()); + CHECK(!t.position()); + CHECK(!t.timestamp()); + CHECK(t.versions().empty()); + CHECK(t.junk().empty()); + CHECK(t.warnings().empty()); + CHECK(!t.flags().explicit_()); + CHECK_EQ(t.to_json(), c_json(trackparse_track_to_json(t.c_ptr()))); + + auto u = + tp::parse("Chase & Status feat. Plan B - End Credits (Sub Focus Remix) [Official Video]"); + std::vector names; + for (const auto &a : u.artists()) names.emplace_back(a.name()); + CHECK((names == std::vector{"Chase", "Status", "Plan B"})); + CHECK(u.artists()[1].joiner().value_or("") == "&"); + CHECK(u.artists()[2].role() == tp::role::featured); + CHECK_EQ(u.versions().size(), 1u); + auto v = u.versions().front(); + CHECK(v.type() == tp::version_type::remix); + CHECK_EQ(v.type_name(), "remix"); + CHECK_EQ(v.raw(), "Sub Focus Remix"); + CHECK(v.delimiter() == tp::delimiter::paren); + CHECK_EQ(v.artists().size(), 1u); + CHECK_EQ(v.artists()[0].name(), "Sub Focus"); + CHECK(v.artists()[0].role() == tp::role::remixer); + CHECK(v.artists()[0].source() == tp::source::version); + CHECK(!v.year()); + CHECK_EQ(u.junk().size(), 1u); + CHECK_EQ(u.junk()[0].raw(), "Official Video"); + CHECK(u.junk()[0].kind() == tp::junk_kind::video); + CHECK_EQ(u.full_title(), "End Credits (Sub Focus Remix)"); + + // Positions, timestamps and an explicit length with U+0000 in it. + auto p = tp::parse("03. Noisia - Stigma"); + CHECK(p.position().has_value()); + CHECK_EQ(p.position()->number, 3); + CHECK_EQ(p.position()->raw, "03"); + const char with_nul[] = "Noisia - Sti\0gma"; + auto n = tp::parse(std::string_view(with_nul, sizeof with_nul - 1)); + CHECK_EQ(n.input().size(), sizeof with_nul - 1); + CHECK_EQ(n.to_json(), c_track_json(trackparse_parse(with_nul, sizeof with_nul - 1))); + + // Warnings are enum values with spec names. + auto w = tp::parse("Just A Title"); + CHECK_EQ(w.warnings().size(), 1u); + CHECK(w.warnings()[0] == tp::warning::no_separator); + CHECK_EQ(tp::name(w.warnings()[0]), "noSeparator"); + CHECK(w.artists().empty()); +} + +static void test_moves() { + auto t = tp::parse("Noisia - Stigma"); + tp::track_view view = t; // borrows + tp::track moved = std::move(t); + CHECK_EQ(moved.title(), "Stigma"); + CHECK_EQ(view.title(), "Stigma"); + moved = tp::parse("Mefjus - Sinkhole"); + CHECK_EQ(moved.title(), "Sinkhole"); + trackparse_track *raw = moved.release(); + CHECK(raw != nullptr); + CHECK_EQ(std::string_view(raw->title.ptr, raw->title.len), "Sinkhole"); + trackparse_track_free(raw); + tp::track adopted(trackparse_parse("Noisia - Stigma", TRACKPARSE_NUL_TERMINATED)); + CHECK_EQ(adopted.title(), "Stigma"); + + tp::parse_options o; + o.mode(tp::mode::clean); + tp::parse_options o2 = std::move(o); + o2.known_artist("Chase & Status"); + CHECK_EQ(tp::parse("Chase & Status - Baddadan", o2).artists().size(), 1u); +} + +static void test_options_and_parser() { + auto yt = tp::parse("Stigma (Official Video) HD", + tp::parse_options{}.mode(tp::mode::youtube).uploader("Noisia")); + CHECK(yt.mode() == tp::mode::youtube); + CHECK_EQ(yt.title(), "Stigma"); + CHECK_EQ(yt.artists().size(), 1u); + CHECK_EQ(yt.artists()[0].name(), "Noisia"); + + // known_artists from an initializer list and from a container. + std::vector known{"Chase & Status", "Camo & Krooked"}; + tp::parser p(tp::parse_options{}.known_artists(known)); + CHECK_EQ(p.parse("Chase & Status - Baddadan").artists().size(), 1u); + CHECK_EQ(p.parse("Camo & Krooked - Ember").artists().size(), 1u); + CHECK_EQ(p.parse_artists("Camo & Krooked & Chase & Status").size(), 2u); + tp::parser q(tp::parse_options{}.known_artists({"Chase & Status"})); + CHECK_EQ(q.parse("Chase & Status - Baddadan").artists()[0].name(), "Chase & Status"); + tp::parser defaults; + CHECK_EQ(defaults.parse("Chase & Status - Baddadan").artists().size(), 2u); + + // The same options through the C API give the same bytes. + auto opts = tp::parse_options{} + .split_and(tp::split_and::never) + .version_head("rmx", tp::version_type::remix) + .version_head("fix", "refix") + .descriptor("rough") + .genre("neurofunk") + .junk("free dl", tp::junk_kind::promo) + .junk("my kind", "custom") + .feat_marker("with"); + const char *input = "Noisia with Foreign Beggars - Stigma (Mefjus Rmx) [Neurofunk] FREE DL"; + trackparse_parse_options *co = trackparse_parse_options_new(); + trackparse_parse_options_set_split_and(co, TRACKPARSE_SPLIT_AND_NEVER); + trackparse_parse_options_add_version_head(co, "rmx", 3, "remix", 5); + trackparse_parse_options_add_version_head(co, "fix", 3, "refix", 5); + trackparse_parse_options_add_descriptor(co, "rough", 5); + trackparse_parse_options_add_genre(co, "neurofunk", 9); + trackparse_parse_options_add_junk(co, "free dl", 7, "promo", 5); + trackparse_parse_options_add_junk(co, "my kind", 7, "custom", 6); + trackparse_parse_options_add_feat_marker(co, "with", 4); + auto expected = c_track_json(trackparse_parse_with(input, TRACKPARSE_NUL_TERMINATED, co)); + trackparse_parse_options_free(co); + auto got = tp::parse(input, opts); + CHECK_EQ(got.to_json(), expected); + CHECK_EQ(got.versions().size(), 1u); + CHECK(got.versions()[0].type() == tp::version_type::remix); + CHECK_EQ(got.artists().size(), 2u); + CHECK(got.artists()[1].role() == tp::role::featured); + CHECK_EQ(got.junk().size(), 2u); +} + +static void test_artists_format_normalize() { + auto a = tp::parse_artists("Camo & Krooked feat. Ayah Marar"); + CHECK_EQ(a.size(), 3u); + CHECK(!a.empty()); + std::vector names; + for (const auto &x : a) names.emplace_back(x.name()); + CHECK((names == std::vector{"Camo", "Krooked", "Ayah Marar"})); + CHECK(a[2].role() == tp::role::featured); + CHECK_EQ(a.to_json(), c_json(trackparse_artists_to_json(a.c_ptr()))); + auto a2 = + tp::parse_artists("Camo and Krooked", tp::parse_options{}.split_and(tp::split_and::never)); + CHECK_EQ(a2.size(), 1u); + + auto t = tp::parse("Sub Focus feat. Kele - Turn It Around (VIP)"); + CHECK_EQ(tp::format(t), "Sub Focus feat. Kele - Turn It Around (VIP)"); + CHECK_EQ(t.format(), tp::format(t)); + CHECK_EQ(tp::format(t, tp::format_options{}.feat(tp::feat::title).feat_marker("ft.")), + "Sub Focus - Turn It Around (ft. Kele) (VIP)"); + CHECK_EQ(tp::format(t, tp::format_options{}.versions(tp::versions::none).feat(tp::feat::omit)), + "Sub Focus - Turn It Around"); + auto fo = + tp::format_options{}.joiners(tp::joiners::canonical).omit_producers(true).position(false); + CHECK_EQ(tp::format(t, fo), c_json(trackparse_format_with(t.c_ptr(), fo.c_ptr()))); + + auto all = tp::all_artists(tp::parse("Noisia - Stigma (Mefjus Remix)")); + CHECK_EQ(all.size(), 2u); + CHECK_EQ(all[1].name(), "Mefjus"); + CHECK(all[1].role() == tp::role::remixer); + + CHECK_EQ(tp::normalize("Noisia \xe2\x80\x93 Stigma"), + c_json(trackparse_normalize("Noisia \xe2\x80\x93 Stigma", TRACKPARSE_NUL_TERMINATED))); + // Invalid UTF-8 becomes U+FFFD. + CHECK_EQ(tp::normalize("a\xff"), "a\xef\xbf\xbd"); +} + +static void test_tracklist() { + const char *text = "Tracklist:\n" + "00:00 Noisia - Stigma\n" + "03:10 Phace & Misanthrop - Desert Orgy\n" + "02:45 Mefjus - Sinkhole (VIP)\r\n" + "09:30 June Miller - Drop That"; + auto list = tp::parse_tracklist(text, tp::tracklist_options{}.audio_seconds(540)); + CHECK_EQ(list.spec_version(), tp::spec_version()); + CHECK_EQ(list.entries().size(), 5u); + auto first = list.entries()[0]; + CHECK_EQ(first.line(), 1); + CHECK(first.kind() != tp::entry_kind::track); + CHECK(!first.time()); + auto e = list.entries()[2]; + CHECK(e.kind() == tp::entry_kind::track); + CHECK(e.eol() == tp::eol::lf); + CHECK_EQ(e.raw(), "03:10 Phace & Misanthrop - Desert Orgy"); + CHECK_EQ(e.parts().time, "03:10"); + CHECK_EQ(e.parts().rest, "Phace & Misanthrop - Desert Orgy"); + CHECK(e.time().has_value()); + CHECK_EQ(e.time()->seconds, 190.0); + CHECK(e.track().has_value()); + CHECK_EQ(e.track()->title(), "Desert Orgy"); + CHECK_EQ(e.track()->artists().size(), 2u); + CHECK(list.entries()[3].eol() == tp::eol::crlf); + CHECK(list.entries()[4].eol() == tp::eol::none); + + bool out_of_order = false, after_end = false; + for (const auto &w : list.warnings()) { + if (w.code() == tp::tracklist_warning_code::time_out_of_order) { + out_of_order = true; + CHECK_EQ(w.line(), 4); + } + if (w.code() == tp::tracklist_warning_code::time_after_audio_end) after_end = true; + CHECK(!tp::name(w.code()).empty()); + CHECK(!tp::name(w.severity()).empty()); + } + CHECK(out_of_order); + CHECK(after_end); + auto s = list.stats(); + CHECK_EQ(s.lines, 5); + CHECK_EQ(s.tracks, 4); + CHECK_EQ(s.timed, 4); + CHECK_EQ(s.first_time.value_or(-1), 0.0); + CHECK_EQ(s.last_time.value_or(-1), 570.0); + CHECK_EQ(list.to_json(), c_json(trackparse_tracklist_to_json(list.c_ptr()))); + + // Default options, and every tracklist option through the builder. + auto plain = tp::parse_tracklist(text); + CHECK_EQ(plain.entries().size(), 5u); + auto opts = tp::tracklist_options{} + .mode(tp::mode::tracklist) + .known_artist("Phace & Misanthrop") + .known_artists({"June Miller"}) + .split_and(tp::split_and::auto_) + .version_head("rmx", tp::version_type::remix) + .descriptor("rough") + .genre("neurofunk") + .junk("free dl", tp::junk_kind::promo) + .feat_marker("with") + .marker_word("Intro") + .audio_seconds(0); + auto known = tp::parse_tracklist(text, opts); + CHECK_EQ(known.entries()[2].track()->artists().size(), 1u); +} + +static void test_edits() { + const char *text = "0:00 Noisia - Stigma\n4:20 Mefjus - Sinkhole\n"; + auto r = tp::apply_edits(text, tp::edits{}.shift(30).set_rest(2, "Mefjus - Pivot")); + CHECK_EQ(r.text(), "0:30 Noisia - Stigma\n4:50 Mefjus - Pivot\n"); + std::vector changed(r.changed().begin(), r.changed().end()); + CHECK((changed == std::vector{1, 2})); + CHECK(r.warnings().empty()); + CHECK_EQ(r.to_json(), c_json(trackparse_edit_result_to_json(r.c_ptr()))); + + tp::edits e; + e.set_time(2, 61).insert(0, "Tracklist:").delete_line(1).sort_by_time(); + e.shift_from(1, 2).shift_lines(1, {1, 2}); + long long lines[] = {2}; + e.shift_lines(-1, lines, 1); + auto r2 = tp::apply_edits(text, e); + trackparse_edits *ce = trackparse_edits_new(); + trackparse_edits_set_time(ce, 2, 61); + trackparse_edits_insert(ce, 0, "Tracklist:", 10); + trackparse_edits_delete(ce, 1); + trackparse_edits_sort_by_time(ce); + trackparse_edits_shift_from(ce, 1, 2); + long long both[] = {1, 2}; + trackparse_edits_shift_lines(ce, 1, both, 2); + trackparse_edits_shift_lines(ce, -1, lines, 1); + trackparse_edit_result *cr = trackparse_apply_edits(text, TRACKPARSE_NUL_TERMINATED, ce); + CHECK_EQ(r2.to_json(), c_json(trackparse_edit_result_to_json(cr))); + trackparse_edit_result_free(cr); + trackparse_edits_free(ce); + + // An edit that names a missing line warns. + auto bad = tp::apply_edits(text, tp::edits{}.set_time(99, 1)); + CHECK_EQ(bad.text(), text); + CHECK_EQ(bad.warnings().size(), 1u); + CHECK(bad.warnings()[0].code() == tp::edit_warning_code::edit_invalid); + CHECK_EQ(bad.warnings()[0].edit(), 0u); + CHECK_EQ(tp::name(bad.warnings()[0].code()), "edit-invalid"); +} + +static void test_names() { + CHECK_EQ(tp::name(tp::mode::auto_), "auto"); + CHECK_EQ(tp::name(tp::version_type::sped_up), "spedUp"); + CHECK_EQ(tp::name(tp::eol::crlf), "\r\n"); + CHECK_EQ(tp::name(tp::tracklist_warning_code::time_out_of_order), "time-out-of-order"); + CHECK_EQ(tp::name(tp::entry_kind::marker), "marker"); + CHECK_EQ(tp::name(tp::delimiter::bracket), "["); + CHECK_EQ(tp::name(tp::source::title), "title"); + CHECK_EQ(tp::name(tp::severity::info), "info"); + CHECK(tp::mode_from_name("youtube") == tp::mode::youtube); + CHECK(!tp::mode_from_name("nope")); + CHECK(tp::version_type_from_name("vip") == tp::version_type::vip); + CHECK(tp::junk_kind_from_name("genre") == tp::junk_kind::genre); + CHECK(!tp::junk_kind_from_name("")); +} + +#if __cplusplus >= 202002L && defined(__has_include) +#if __has_include() +#include +#endif +#endif +#if defined(__cpp_lib_ranges) +// The spans work with the C++20 range algorithms that take input ranges. +static_assert(std::ranges::input_range); +static_assert(std::ranges::sized_range); +static void test_cpp20() { + auto t = tp::parse("Chase & Status - Baddadan"); + auto count = + std::ranges::count_if(t.artists(), [](tp::artist_view a) { return a.name() == "Status"; }); + CHECK_EQ(count, 1); +} +#else +static void test_cpp20() {} +#endif + +int main() { + test_version(); + test_parse(); + test_moves(); + test_options_and_parser(); + test_artists_format_normalize(); + test_tracklist(); + test_edits(); + test_names(); + test_cpp20(); + if (failures) { + std::fprintf(stderr, "test_cpp: %d failure(s)\n", failures); + return 1; + } + std::printf("test_cpp: ok (__cplusplus %ld)\n", static_cast(__cplusplus)); + return 0; +} diff --git a/c/tests/test_locale.c b/c/tests/test_locale.c new file mode 100644 index 0000000..a989e2a --- /dev/null +++ b/c/tests/test_locale.c @@ -0,0 +1,248 @@ +/* test_locale.c: the output does not depend on the process locale (PLAN.md hazard 2). + * + * The library never calls a locale-dependent function (no , strtod or float printf in + * src/), so a program that calls setlocale() must still get the bytes the "C" locale gives. This + * test computes every fixture case through the JSON door and a set of number- and case-sensitive + * calls through the public API in the "C" locale, then again after setlocale(LC_ALL, "") and + * after each of de_DE.UTF-8 (decimal comma), tr_TR.UTF-8 (dotted and dotless i) and others that + * are installed, and compares the bytes. + * + * test_locale ... + * + * Exit 77 (skipped) when no locale other than C / POSIX is installed. CI installs de_DE.UTF-8 + * and tr_TR.UTF-8 (locale-gen, or language-pack-de / language-pack-tr). */ +#include +#include +#include + +#include "../include/trackparse.h" +#include "../wire/wire.h" +#include "hardening.h" + +typedef struct result { + char *text; + size_t len; +} result; + +typedef struct results { + result *items; + size_t n, cap; +} results; + +static void add(results *r, const char *p, size_t n) { + if (r->n == r->cap) { + r->cap = r->cap ? r->cap * 2 : 1024; + r->items = (result *)realloc(r->items, r->cap * sizeof *r->items); + if (!r->items) exit(2); + } + r->items[r->n].text = (char *)malloc(n + 1); + if (!r->items[r->n].text) exit(2); + memcpy(r->items[r->n].text, p, n); + r->items[r->n].text[n] = '\0'; + r->items[r->n].len = n; + r->n++; +} + +static void add_string(results *r, trackparse_string *s) { + if (!s) { + fprintf(stderr, "out of memory\n"); + exit(2); + } + add(r, s->str.ptr, s->str.len); + trackparse_string_free(s); +} + +static void free_results(results *r) { + for (size_t i = 0; i < r->n; i++) free(r->items[i].text); + free(r->items); + memset(r, 0, sizeof *r); +} + +/* Inputs where a locale could show: fractional times and edit numbers (decimal comma), upper and + * lower case with I, İ, ı (Turkish case mapping), and keywords in capitals. */ +static const char *const tracks[] = { + "I - \xc4\xb0stanbul (IIIII Remix) FEAT. I\xc5\x9eIK", + "\xc4\xb0lhan feat. IRMAK & \xc4\xb1\xc5\x9f\xc4\xb1k - TITLE (IDIOT VIP) [OFFICIAL VIDEO]", + "INXS - I NEED YOU TONIGHT (EXTENDED MIX) 1987", + "01. ILIRIA - Infinite (Radio Edit)", + "Phace & Misanthrop - Desert Orgy (Noisia Remix) [HD] 3:45", + "\xc3\x9c" + "BER - \xc3\x84rger (Stra\xc3\x9f" + "e Mix)", +}; + +static const char *const lists[] = { + "00:00 Intro\n01:02:03.5 I - \xc4\xb0stanbul\n12:34,250 ILIRIA - Infinite\n0:00.25 E - F", + "[00:00.5] **INTRO**\r\n[01:30,75] IDIOT - IDEA (VIP)\r\n[59:59.999] Break\r\n", + "1. Noisia - Stigma 00:00\n2. Phace - Plastic Acid 04:37.5\n3. I - Dot 1:2", +}; + +/* Edits through the JSON door: fractional seconds, fractional and huge line numbers, numbers + * echoed in warnings. */ +static const char *const edit_lines[] = { + "{\"fn\":\"applyEdits\",\"input\":\"00:00 A - B\\n01:02.5 C - D\\n\"," + "\"edits\":[{\"op\":\"set-time\",\"line\":2,\"seconds\":3167.5}," + "{\"op\":\"shift\",\"seconds\":-0.25},{\"op\":\"set-time\",\"line\":1.5,\"seconds\":2.5}," + "{\"op\":\"delete\",\"line\":1e21},{\"op\":\"shift\",\"seconds\":1e-7,\"from\":2}]}", + "{\"fn\":\"parseTracklist\",\"input\":\"00:00 A\\n10:00 B\",\"options\":" + "{\"audioSeconds\":599.5}}", + "{\"fn\":\"parse\",\"input\":\"IDIOT - IIII (WHATEVER REMIX)\",\"options\":" + "{\"keywords\":{\"versionHeads\":{\"WHATEVER\":\"remix\"}," + "\"junk\":{\"\\u0130\\u0130\":\"other\"}}," + "\"knownArtists\":[\"idiot\"]}}", +}; + +typedef struct calc_arg { + const hz_cases *cases; + results *out; +} calc_arg; + +static void wire_one(results *out, const char *p, size_t n) { + tp_str line, o; + line.p = p; + line.n = n; + o = tp_wire_line(line); + add(out, o.p, o.n); +} + +static void calc_wire(void *p) { + calc_arg *a = (calc_arg *)p; + for (size_t i = 0; i < a->cases->n; i++) { + wire_one(a->out, a->cases->items[i].line, a->cases->items[i].line_n); + } + for (size_t i = 0; i < TP_COUNT(edit_lines); i++) { + wire_one(a->out, edit_lines[i], strlen(edit_lines[i])); + } +} + +/* Every output for this locale, in a fixed order. */ +static results compute(const hz_cases *cases) { + results out = {NULL, 0, 0}; + calc_arg a; + for (size_t i = 0; i < TP_COUNT(tracks); i++) { + trackparse_track *t = trackparse_parse(tracks[i], TRACKPARSE_NUL_TERMINATED); + trackparse_artists *ar = trackparse_parse_artists(tracks[i], TRACKPARSE_NUL_TERMINATED); + if (!t || !ar) exit(2); + add_string(&out, trackparse_track_to_json(t)); + add_string(&out, trackparse_format(t)); + add_string(&out, trackparse_artists_to_json(ar)); + add_string(&out, trackparse_normalize(tracks[i], TRACKPARSE_NUL_TERMINATED)); + trackparse_track_free(t); + trackparse_artists_free(ar); + } + for (size_t i = 0; i < TP_COUNT(lists); i++) { + trackparse_tracklist_options *o = trackparse_tracklist_options_new(); + trackparse_edits *e = trackparse_edits_new(); + trackparse_tracklist *l; + trackparse_edit_result *r; + if (!o || !e || !trackparse_tracklist_options_set_audio_seconds(o, 3599.75) || + !trackparse_edits_set_time(e, 2, 62.125) || !trackparse_edits_shift(e, 0.5) || + !trackparse_edits_shift_from(e, -1.75, 3) || !trackparse_edits_set_time(e, 1, 1e21)) { + exit(2); + } + l = trackparse_parse_tracklist_with(lists[i], TRACKPARSE_NUL_TERMINATED, o); + r = trackparse_apply_edits(lists[i], TRACKPARSE_NUL_TERMINATED, e); + if (!l || !r) exit(2); + add_string(&out, trackparse_tracklist_to_json(l)); + add_string(&out, trackparse_edit_result_to_json(r)); + trackparse_tracklist_free(l); + trackparse_edit_result_free(r); + trackparse_tracklist_options_free(o); + trackparse_edits_free(e); + } + a.cases = cases; + a.out = &out; + hz_scoped(calc_wire, &a); + return out; +} + +static int compare(const char *name, const results *want, const results *got) { + int bad = 0; + if (want->n != got->n) { + fprintf(stderr, "%s: %lu outputs, want %lu\n", name, (unsigned long)got->n, + (unsigned long)want->n); + return 1; + } + for (size_t i = 0; i < want->n; i++) { + if (want->items[i].len != got->items[i].len || + memcmp(want->items[i].text, got->items[i].text, want->items[i].len) != 0) { + if (bad < 5) { + fprintf(stderr, "%s: output %lu differs from the C locale:\n C: %s\n here: %s\n", name, + (unsigned long)i, want->items[i].text, got->items[i].text); + } + bad++; + } + } + return bad; +} + +int main(int argc, char **argv) { + /* "" is the environment's locale (LANG, LC_ALL): what a program calling setlocale gets. */ + static const char *const names[] = { + "", + "de_DE.UTF-8", + "de_DE.utf8", + "tr_TR.UTF-8", + "tr_TR.utf8", + "fr_FR.UTF-8", + "ru_RU.UTF-8", + "et_EE.UTF-8", + "et_EE.utf8", + "en_DK.utf8", + "C.UTF-8", + "de_DE", + "tr_TR", + "German_Germany.1252", + "Turkish_Turkey.1254", + }; + hz_cases cases = hz_load_cases(argc - 1, argv + 1); + results want; + int tried = 0, bad = 0; + if (!setlocale(LC_ALL, "C")) { + fprintf(stderr, "setlocale(LC_ALL, \"C\") failed\n"); + return 1; + } + want = compute(&cases); + printf("C locale: %lu outputs (%lu fixture cases)\n", (unsigned long)want.n, + (unsigned long)cases.n); + for (size_t i = 0; i < TP_COUNT(names); i++) { + const char *got_name = setlocale(LC_ALL, names[i]); + char applied[256]; + results got; + int d; + if (!got_name) { + printf(" %-20s not installed\n", names[i][0] ? names[i] : "\"\""); + continue; + } + /* Copy: the next setlocale call may overwrite the string. */ + strncpy(applied, got_name, sizeof applied - 1); + applied[sizeof applied - 1] = '\0'; + got = compute(&cases); + setlocale(LC_ALL, "C"); + d = compare(applied, &want, &got); + { + /* The decimal point shows that the locale would change a printf("%g"). */ + const char *dp; + setlocale(LC_ALL, names[i]); + dp = localeconv()->decimal_point; + printf(" %-20s -> %-24.24s decimal point \"%s\": %s\n", names[i][0] ? names[i] : "\"\"", + applied, dp ? dp : "?", d ? "DIFFERS" : "same bytes"); + setlocale(LC_ALL, "C"); + } + if (strcmp(applied, "C") != 0 && strcmp(applied, "POSIX") != 0) tried++; + bad += d; + free_results(&got); + } + free_results(&want); + hz_free_cases(&cases); + if (bad) { + fprintf(stderr, "locale: %d outputs depend on the locale\n", bad); + return 1; + } + if (tried == 0) { + printf("no locale other than C / POSIX is installed: skipped\n"); + return 77; + } + printf("locale: ok (%d locales)\n", tried); + return 0; +} diff --git a/c/tests/test_match.c b/c/tests/test_match.c new file mode 100644 index 0000000..fec6703 --- /dev/null +++ b/c/tests/test_match.c @@ -0,0 +1,149 @@ +/* test_match.c: the matcher's own cases (go/match_test.go TestMatcher), plus the JSON reader's + * edge cases the matcher relies on. */ +#include + +#include "../wire/json_read.h" +#include "match.h" + +typedef struct match_case { + const char *expected, *actual; + bool exact, ok; +} match_case; + +static const match_case cases[] = { + /* Rule 1: extra keys are ignored in partial mode; an explicit null must be null. */ + {"{\"title\":\"A\"}", "{\"title\":\"A\",\"year\":null}", false, true}, + {"{\"year\":null}", "{\"year\":2015}", false, false}, + {"{\"year\":null}", "{}", false, false}, + /* Rule 2: arrays match in length and order. */ + {"{\"a\":[1,2]}", "{\"a\":[1,2,3]}", false, false}, + {"{\"a\":[2,1]}", "{\"a\":[1,2]}", false, false}, + /* Rule 3: scalars strictly; numbers by value. */ + {"7", "7.0", false, true}, + {"\"a\"", "\"A\"", false, false}, + {"true", "1", false, false}, + /* Rule 4: artist shorthand. */ + {"[\"Noisia\",{\"name\":\"Foreign Beggars\",\"role\":\"featured\"}]", + "[{\"name\":\"Noisia\",\"role\":\"primary\"},{\"name\":\"Foreign Beggars\",\"role\":" + "\"featured\"}]", + false, true}, + {"[\"Noisia\"]", "[{\"name\":\"Phace\"}]", false, false}, + {"[\"Noisia\"]", "[\"Noisia\"]", false, true}, + /* Rule 5: exact. */ + {"{\"a\":1}", "{\"a\":1,\"b\":2}", true, false}, + {"{\"b\":2,\"a\":1}", "{\"a\":1,\"b\":2}", true, true}, + {"[\"Noisia\"]", "[{\"name\":\"Noisia\"}]", true, false}, + /* Rule 6: a top-level specVersion is never compared. */ + {"{\"specVersion\":\"9\",\"x\":1}", "{\"specVersion\":\"0.1\",\"x\":1}", true, true}, +}; + +/* JSON text -> its compact form after reading (NULL: must be rejected). */ +typedef struct read_case { + const char *text, *shown; +} read_case; + +static const read_case reads[] = { + {" {\"a\" : [1, 2.5, -0, 1e2], \"b\": null } ", "{\"a\":[1,2.5,0,100],\"b\":null}"}, + /* A repeated key keeps its first place and takes the last value. */ + {"{\"a\":1,\"b\":2,\"a\":3}", "{\"a\":3,\"b\":2}"}, + /* Escapes; a lone surrogate becomes U+FFFD, a pair is one code point. */ + {"\"\\n\\t\\/\\u0041\\ud83d\\ude00\"", "\"\\n\\t/A\xf0\x9f\x98\x80\""}, + {"\"\\ud800x\"", "\"\xef\xbf\xbdx\""}, + {"\"\\ud800\\u0041\"", "\"\xef\xbf\xbd" + "A\""}, + {"\"\\udc00\"", "\"\xef\xbf\xbd\""}, + /* Infinity travels as 1e999 (shown as null, as JSON.stringify does). */ + {"[1e999,-1e999]", "[null,null]"}, + {"[]", "[]"}, + {"{}", "{}"}, + {"", NULL}, + {"[1,]", NULL}, + {"{\"a\" 1}", NULL}, + {"nul", NULL}, + {"1 2", NULL}, + {"\"abc", NULL}, + {"\"\\u12\"", NULL}, +}; + +static int run(void) { + int failed = 0; + for (size_t i = 0; i < TP_COUNT(cases); i++) { + const match_case *c = &cases[i]; + tp_json e, a; + tp_str d; + if (!tp_json_parse(tp_str_c(c->expected), &e) || !tp_json_parse(tp_str_c(c->actual), &a)) { + printf("FAIL: bad JSON in case %u\n", (unsigned)i); + failed++; + continue; + } + d = tp_match(e, a, c->exact); + if ((d.n == 0) != c->ok) { + printf("FAIL: match(%s, %s, exact=%d) = \"%.*s\", want ok=%d\n", c->expected, c->actual, + (int)c->exact, TP_FMT(d), (int)c->ok); + failed++; + } + } + for (size_t i = 0; i < TP_COUNT(reads); i++) { + const read_case *c = &reads[i]; + tp_json v; + bool ok = tp_json_parse(tp_str_c(c->text), &v); + if (!c->shown) { + if (ok) { + printf("FAIL: read(%s) accepted, want rejected\n", c->text); + failed++; + } + continue; + } + if (!ok) { + printf("FAIL: read(%s) rejected\n", c->text); + failed++; + } else if (!tp_str_eq_c(tp_json_show(v), c->shown)) { + tp_str got = tp_json_show(v); + printf("FAIL: read(%s) = %.*s, want %s\n", c->text, TP_FMT(got), c->shown); + failed++; + } + } + { + /* The depth limit: 200 nested arrays read, 300 do not. */ + tp_buf deep = {0}, deeper = {0}; + tp_json v; + for (int i = 0; i < 200; i++) tp_buf_byte(&deep, '['); + for (int i = 0; i < 200; i++) tp_buf_byte(&deep, ']'); + for (int i = 0; i < 300; i++) tp_buf_byte(&deeper, '['); + for (int i = 0; i < 300; i++) tp_buf_byte(&deeper, ']'); + if (!tp_json_parse(tp_buf_done(&deep), &v)) { + printf("FAIL: 200 nested arrays rejected\n"); + failed++; + } + if (tp_json_parse(tp_buf_done(&deeper), &v)) { + printf("FAIL: 300 nested arrays accepted\n"); + failed++; + } + } + return failed; +} + +int main(void) { + tp_scope s; + volatile int failed = 0; + if (!tp_scope_open(&s)) { + printf("FAIL: out of memory\n"); + return 1; + } + if (setjmp(s.jmp) != 0) { + tp_scope_abort(&s); + printf("FAIL: out of memory\n"); + return 1; + } + tp_scope_arm(&s); + failed = run(); + tp_scope_close(&s); + tp_arena_free(s.arena); + if (failed) { + printf("test_match: %d failures\n", failed); + return 1; + } + printf("test_match: ok (%u matcher cases, %u reader cases)\n", (unsigned)TP_COUNT(cases), + (unsigned)TP_COUNT(reads)); + return 0; +} diff --git a/c/tests/test_num.c b/c/tests/test_num.c new file mode 100644 index 0000000..940e29e --- /dev/null +++ b/c/tests/test_num.c @@ -0,0 +1,288 @@ +/* test_num.c: src/num.c against values from Node. + * + * test_num [cases.jsonl] (default: tests/data/numbers_sample.jsonl next to this file's + * build, or the path in argv[1]) + * + * The JSONL comes from scripts/dump_numbers.mjs. Lines are parsed ad hoc (the format is fixed and + * holds no escapes). For {"s","v","b"}: tp_parse_number(s) has bits b and tp_number_str of it is + * v. For {"d","s"}: tp_number_str(d) is s and, for finite d, tp_parse_number(s) gives d back bit + * for bit (zero: either sign, String(-0) is "0"). */ +#include +#include + +#include "../src/rt.h" + +#ifndef TP_TEST_DATA +#define TP_TEST_DATA "tests/data/numbers_sample.jsonl" +#endif + +static int failures; +static long checks; + +#define CHECK(cond, ...) \ + do { \ + checks++; \ + if (!(cond)) { \ + failures++; \ + if (failures <= 30) { \ + fprintf(stderr, __VA_ARGS__); \ + fputc('\n', stderr); \ + } \ + } \ + } while (0) + +static uint64_t bits_of(double v) { + uint64_t u; + memcpy(&u, &v, sizeof u); + return u; +} + +static double of_bits(uint64_t u) { + double v; + memcpy(&v, &u, sizeof v); + return v; +} + +static bool parse_hex(const char *p, size_t n, uint64_t *out) { + uint64_t v = 0; + size_t i; + if (n == 0 || n > 16) return false; + for (i = 0; i < n; i++) { + char c = p[i]; + unsigned d; + if (c >= '0' && c <= '9') { + d = (unsigned)(c - '0'); + } else if (c >= 'a' && c <= 'f') { + d = (unsigned)(c - 'a' + 10); + } else { + return false; + } + v = v << 4 | d; + } + *out = v; + return true; +} + +/* The string value of "key":"..." in line, or false. */ +static bool field(const char *line, const char *key, tp_str *out) { + char pat[16]; + const char *at, *end; + size_t kn = strlen(key); + pat[0] = '"'; + memcpy(pat + 1, key, kn); + memcpy(pat + 1 + kn, "\":\"", 4); + at = strstr(line, pat); + if (at == NULL) return false; + at += kn + 4; + end = strchr(at, '"'); + if (end == NULL) return false; + out->p = at; + out->n = (size_t)(end - at); + return true; +} + +static tp_str num_str(double v) { return tp_number_str(v); } + +static void expect_parse(const char *s, bool ok, uint64_t bits) { + double v = 0; + bool got = tp_parse_number(tp_str_c(s), &v); + CHECK(got == ok, "parse %s: accepted %d, want %d", s, got, ok); + if (got && ok) { + CHECK(bits_of(v) == bits, "parse %s: bits %016llx, want %016llx", s, + (unsigned long long)bits_of(v), (unsigned long long)bits); + } +} + +static void expect_fmt(double v, const char *want) { + tp_str got = num_str(v); + CHECK(tp_str_eq_c(got, want), "format %016llx: %.*s, want %s", (unsigned long long)bits_of(v), + TP_FMT(got), want); +} + +static void unit_tests(void) { + /* Grammar: accepted forms. */ + expect_parse("0", true, 0); + expect_parse("-0", true, UINT64_C(0x8000000000000000)); + expect_parse("007", true, bits_of(7.0)); + expect_parse("1.", true, bits_of(1.0)); + expect_parse(".5", true, bits_of(0.5)); + expect_parse("+1e+007", true, bits_of(1e7)); + expect_parse("1E2", true, bits_of(100.0)); + expect_parse("-.0e5", true, UINT64_C(0x8000000000000000)); + expect_parse("3167.12345678901234567890", true, bits_of(3167.1234567890124)); + expect_parse("1e21", true, bits_of(1e21)); + expect_parse("1e309", true, UINT64_C(0x7FF0000000000000)); + expect_parse("-1e309", true, UINT64_C(0xFFF0000000000000)); + expect_parse("1e-400", true, 0); + expect_parse("4.9406564584124654e-324", true, 1); + expect_parse("2.4703282292062327e-324", true, 0); + expect_parse("2.4703282292062328e-324", true, 1); + expect_parse("9007199254740993", true, bits_of(9007199254740992.0)); + expect_parse("9007199254740995", true, bits_of(9007199254740996.0)); + expect_parse("1e99999999999999999999", true, UINT64_C(0x7FF0000000000000)); + expect_parse("0e99999999999999999999", true, 0); + /* Grammar: rejected forms. */ + { + static const char *bad[] = {"", "-", "+", ".", "e5", "1e", "1e+", "1.2.3", + " 1", "1 ", "--1", "+-1", "1e5.", "0x10", "1_0", "Infinity", + "NaN", "inf", "1e-", ".e1", "1d", "١"}; + size_t i; + for (i = 0; i < TP_COUNT(bad); i++) expect_parse(bad[i], false, 0); + } + /* Formatting. */ + expect_fmt(0.0, "0"); + expect_fmt(-0.0, "0"); + expect_fmt(tp_nan(), "NaN"); + expect_fmt(tp_inf(1), "Infinity"); + expect_fmt(tp_inf(-1), "-Infinity"); + expect_fmt(1e21, "1e+21"); + expect_fmt(1e20, "100000000000000000000"); + expect_fmt(123456789012345680000.0, "123456789012345680000"); + expect_fmt(1e-7, "1e-7"); + expect_fmt(0.000001, "0.000001"); + expect_fmt(1.5e-7, "1.5e-7"); + expect_fmt(of_bits(1), "5e-324"); + expect_fmt(1.7976931348623157e308, "1.7976931348623157e+308"); + expect_fmt(0.1, "0.1"); + expect_fmt(1.0 / 3.0, "0.3333333333333333"); + expect_fmt(3167.0, "3167"); + expect_fmt(-3167.5, "-3167.5"); + expect_fmt(9007199254740992.0, "9007199254740992"); + expect_fmt(2.2250738585072014e-308, "2.2250738585072014e-308"); + expect_fmt(5e-324 * 3, "1.5e-323"); + /* Floor and half-up rounding. */ + CHECK(tp_floor(-0.5) == -1.0, "floor(-0.5)"); + CHECK(tp_floor(0.5) == 0.0, "floor(0.5)"); + CHECK(bits_of(tp_floor(-0.0)) == UINT64_C(0x8000000000000000), "floor(-0)"); + CHECK(tp_floor(-3.0) == -3.0, "floor(-3)"); + CHECK(tp_floor(1e300) == 1e300, "floor(1e300)"); + CHECK(tp_floor(-1e-300) == -1.0, "floor(-1e-300)"); + CHECK(tp_floor(4503599627370495.5) == 4503599627370495.0, "floor(2^52-0.5)"); + CHECK(tp_is_nan(tp_floor(tp_nan())), "floor(nan)"); + CHECK(tp_round_half_up(1.005, 2) == 1.0, "1.005 (double below) -> 1"); /* 1.00499999... */ + CHECK(tp_round_half_up(2.5, 0) == 3.0, "2.5 -> 3 (half up, not even)"); + CHECK(tp_round_half_up(0.125, 2) == 0.13, "0.125 -> 0.13"); + CHECK(tp_half_up_units(83.4567, 1000) == 83457.0, "83.4567 units"); + /* Values where a fused multiply-add changes the result (JS gives the unfused one): Node, + * Math.floor(v * 10 + 0.5). */ + CHECK(tp_half_up_units(of_bits(UINT64_C(0x42e99999999999a4)), 10) == 2251799813685251.0, + "fma case 1"); + CHECK(tp_half_up_units(of_bits(UINT64_C(0x42e99999999999b4)), 10) == 2251799813685256.0, + "fma case 2"); + CHECK(tp_is_inf(tp_inf(-1)) && !tp_is_inf(1e308) && !tp_is_inf(tp_nan()), "is_inf"); + CHECK(tp_is_nan(tp_nan()) && !tp_is_nan(tp_inf(1)), "is_nan"); +} + +/* Not inlined into main, whose setjmp would make GCC warn about every local here + * (-Wclobbered, seen with GCC 11 on 32-bit). */ +#if defined(__GNUC__) || defined(__clang__) +__attribute__((noinline)) +#endif +static void +file_tests(const char *path, long *cases) { + tp_arena *scratch = tp_arena_current(); /* the scope's own arena, freed by main */ + FILE *f = fopen(path, "rb"); + char *line; + size_t cap = 1 << 16; + if (f == NULL) { + fprintf(stderr, "cannot open %s\n", path); + failures++; + return; + } + line = (char *)malloc(cap); + if (line == NULL) abort(); + for (;;) { + size_t n = 0; + int c; + tp_str s, v, b, d; + while ((c = fgetc(f)) != EOF && c != '\n') { + if (n + 2 > cap) { + char *grown = (char *)realloc(line, cap * 2); + if (grown == NULL) abort(); + line = grown; + cap *= 2; + } + line[n++] = (char)c; + } + if (n == 0 && c == EOF) break; + line[n] = '\0'; + if (n == 0) continue; + (*cases)++; + if (*cases % 10000 == 0) { /* recycle the scratch arena */ + tp_arena *fresh = tp_arena_new(), *old; + if (fresh == NULL) abort(); + old = tp_arena_use(fresh); + if (old != scratch) tp_arena_free(old); + } + if (field(line, "d", &d)) { + uint64_t bits; + double x, back = 0; + tp_str got; + CHECK(field(line, "s", &s) && parse_hex(d.p, d.n, &bits), "bad line: %s", line); + if (!parse_hex(d.p, d.n, &bits)) continue; + x = of_bits(bits); + got = num_str(x); + CHECK(tp_str_eq(got, s), "format %016llx: %.*s, want %.*s", (unsigned long long)bits, + TP_FMT(got), TP_FMT(s)); + if (!tp_is_nan(x) && !tp_is_inf(x)) { + bool ok = tp_parse_number(s, &back); + CHECK(ok && (bits_of(back) == bits || (x == 0 && back == 0)), + "round trip %016llx via %.*s: %016llx", (unsigned long long)bits, TP_FMT(s), + (unsigned long long)bits_of(back)); + } + } else { + uint64_t bits; + double x = 0; + bool ok; + if (!field(line, "s", &s) || !field(line, "v", &v) || !field(line, "b", &b) || + !parse_hex(b.p, b.n, &bits)) { + CHECK(false, "bad line: %s", line); + continue; + } + ok = tp_parse_number(s, &x); + CHECK(ok, "rejected: %.*s", TP_FMT(s)); + if (!ok) continue; + CHECK(bits_of(x) == bits, "parse %.*s: %016llx, want %016llx", TP_FMT(s), + (unsigned long long)bits_of(x), (unsigned long long)bits); + { + tp_str got = num_str(x); + CHECK(tp_str_eq(got, v), "format of %.*s: %.*s, want %.*s", TP_FMT(s), TP_FMT(got), + TP_FMT(v)); + } + } + } + free(line); + fclose(f); + if (tp_arena_current() != scratch) tp_arena_free(tp_arena_use(scratch)); +} + +int main(int argc, char **argv) { + /* static: a local could be clobbered by the longjmp below (GCC -Wclobbered). */ + static const char *path; + static long cases; + tp_scope s; + path = argc > 1 ? argv[1] : TP_TEST_DATA; + if (!tp_scope_open(&s)) return 2; + if (setjmp(s.jmp) != 0) { + tp_scope_abort(&s); + fprintf(stderr, "out of memory\n"); + return 2; + } + tp_scope_arm(&s); + unit_tests(); + tp_scope_close(&s); + tp_arena_free(s.arena); + /* One scope per batch of lines, so the arena stays small on millions of cases. */ + if (!tp_scope_open(&s)) return 2; + if (setjmp(s.jmp) != 0) { + tp_scope_abort(&s); + fprintf(stderr, "out of memory\n"); + return 2; + } + tp_scope_arm(&s); + file_tests(path, &cases); + tp_scope_close(&s); + tp_arena_free(s.arena); + printf("test_num: %ld file cases, %ld checks, %d failures\n", cases, checks, failures); + return failures == 0 && cases > 0 ? 0 : 1; +} diff --git a/c/tests/test_oom.c b/c/tests/test_oom.c new file mode 100644 index 0000000..19f304d --- /dev/null +++ b/c/tests/test_oom.c @@ -0,0 +1,617 @@ +/* test_oom.c: allocation failure at every n (PLAN.md hazard 10). + * + * A counting allocator (trackparse_set_allocator) fails the n-th allocation. For a set of about + * 50 fixture inputs and every public function (and the JSON door, which reports out of memory by + * longjmp to its scope), each call is repeated with n = 1, 2, 3, ... until it succeeds. Each + * time the call must return NULL (or false) or a result whose JSON equals the reference, and + * every allocation it made must be freed again (live blocks before == after). + * + * The first calls of the process build the default tables once (tp_once_get) into arenas that + * live forever. A first sweep runs with the tables not built yet ("cold"), so the out-of-memory + * path of the lazy build is covered too; it checks the results but not the balance, since the + * tables it builds are meant to stay. + * + * test_oom ... + */ +#include +#include + +#include "../include/trackparse.h" +#include "../wire/wire.h" +#include "hardening.h" + +/* -------------------------------------------------------------------------------------------- */ +/* The counting allocator */ + +static long long alloc_count; /* allocations since the last reset */ +static long long fail_at; /* fail allocation number fail_at (1-based); 0: never */ +static long long live; /* blocks allocated and not freed */ +static long long refused; /* allocations refused since the last reset */ +static long long total_allocs; /* over the whole run */ + +static void *count_malloc(size_t size, void *user) { + void *p; + (void)user; + alloc_count++; + total_allocs++; + if (fail_at > 0 && alloc_count == fail_at) { + refused++; + return NULL; + } + p = malloc(size); + if (p) live++; + return p; +} + +static void *count_realloc(void *ptr, size_t size, void *user) { + void *p; + (void)user; + alloc_count++; + total_allocs++; + if (fail_at > 0 && alloc_count == fail_at) { + refused++; + return NULL; + } + p = realloc(ptr, size); + if (p && !ptr) live++; + return p; +} + +static void count_free(void *ptr, void *user) { + (void)user; + if (ptr) { + live--; + free(ptr); + } +} + +static void arm(long long n) { + alloc_count = 0; + refused = 0; + fail_at = n; +} + +static void disarm(void) { fail_at = 0; } + +static int failures; + +#define FAILF(...) \ + do { \ + fprintf(stderr, "FAIL: " __VA_ARGS__); \ + fputc('\n', stderr); \ + failures++; \ + } while (0) + +/* -------------------------------------------------------------------------------------------- */ +/* Operations: one call (or a few) that gives a JSON string or NULL on out of memory */ + +typedef struct op { + const char *name; + const hz_case *c; + const char *s; /* the input */ + size_t n; + const trackparse_track *track; /* a parsed track, for format, all_artists and to_json */ + const trackparse_tracklist *list; + const trackparse_edit_result *edited; + char *(*run)(const struct op *o); /* heap JSON (plain malloc, not counted), or NULL */ +} op; + +/* A result string as a plain heap string (the library's string is freed). */ +static char *take(trackparse_string *s) { + char *p; + if (!s) return NULL; + p = (char *)malloc(s->str.len + 1); + if (!p) exit(2); + memcpy(p, s->str.ptr, s->str.len + 1); + trackparse_string_free(s); + return p; +} + +static char *op_parse(const op *o) { + trackparse_track *t = trackparse_parse(o->s, o->n); + char *j; + if (!t) return NULL; + j = take(trackparse_track_to_json(t)); + trackparse_track_free(t); + return j; +} + +static trackparse_parse_options *build_parse_options(const char *s, size_t n) { + trackparse_parse_options *po = trackparse_parse_options_new(); + if (!po) return NULL; + /* The input as uploader and known artist, cut to 60 bytes: the known-artist search window grows + * with the longest name (2 * longest + 8, R7.3a), and parse_artists on a 10,000 code point + * input with a 300-byte known artist takes 20 s (JS: 7 s), too slow for a sweep that repeats + * the call. */ + if (n > 60) n = 60; + if (!trackparse_parse_options_set_mode(po, TRACKPARSE_MODE_YOUTUBE) || + !trackparse_parse_options_set_uploader(po, s, n) || + !trackparse_parse_options_add_known_artist(po, "Camo & Krooked", TRACKPARSE_NUL_TERMINATED) || + !trackparse_parse_options_add_known_artist(po, s, n) || + !trackparse_parse_options_set_split_and(po, TRACKPARSE_SPLIT_AND_ALWAYS) || + !trackparse_parse_options_add_version_head(po, "rerub", TRACKPARSE_NUL_TERMINATED, "rework", + TRACKPARSE_NUL_TERMINATED) || + !trackparse_parse_options_add_descriptor(po, "Deluxe", TRACKPARSE_NUL_TERMINATED) || + !trackparse_parse_options_add_genre(po, "neurofunk", TRACKPARSE_NUL_TERMINATED) || + !trackparse_parse_options_add_junk(po, "out now", TRACKPARSE_NUL_TERMINATED, "promo", + TRACKPARSE_NUL_TERMINATED) || + !trackparse_parse_options_add_feat_marker(po, "w/", TRACKPARSE_NUL_TERMINATED)) { + trackparse_parse_options_free(po); + return NULL; + } + return po; +} + +/* The options are built inside the sweep too: a setter that fails leaves them as they were. */ +static char *op_parse_with(const op *o) { + trackparse_parse_options *po = build_parse_options(o->s, o->n); + trackparse_track *t; + char *j; + if (!po) return NULL; + t = trackparse_parse_with(o->s, o->n, po); + trackparse_parse_options_free(po); + if (!t) return NULL; + j = take(trackparse_track_to_json(t)); + trackparse_track_free(t); + return j; +} + +static char *op_parser(const op *o) { + trackparse_parse_options *po = build_parse_options(o->s, o->n); + trackparse_parser *p; + trackparse_track *t; + trackparse_artists *a; + char *j, *k; + if (!po) return NULL; + p = trackparse_parser_new(po); + trackparse_parse_options_free(po); + if (!p) return NULL; + t = trackparse_parser_parse(p, o->s, o->n); + a = trackparse_parser_parse_artists(p, o->s, o->n); + trackparse_parser_free(p); + if (!t || !a) { + trackparse_track_free(t); + trackparse_artists_free(a); + return NULL; + } + j = take(trackparse_track_to_json(t)); + k = take(trackparse_artists_to_json(a)); + trackparse_track_free(t); + trackparse_artists_free(a); + if (!j || !k) { + free(j); + free(k); + return NULL; + } + { + size_t jn = strlen(j), kn = strlen(k); + char *both = (char *)malloc(jn + kn + 2); + if (!both) exit(2); + memcpy(both, j, jn); + both[jn] = '\n'; + memcpy(both + jn + 1, k, kn + 1); + free(j); + free(k); + return both; + } +} + +static char *op_parse_artists(const op *o) { + trackparse_artists *a = trackparse_parse_artists(o->s, o->n); + char *j; + if (!a) return NULL; + j = take(trackparse_artists_to_json(a)); + trackparse_artists_free(a); + return j; +} + +static char *op_normalize(const op *o) { return take(trackparse_normalize(o->s, o->n)); } + +static char *op_format(const op *o) { return take(trackparse_format(o->track)); } + +static char *op_format_with(const op *o) { + trackparse_format_options *fo = trackparse_format_options_new(); + char *j; + if (!fo) return NULL; + if (!trackparse_format_options_set_feat(fo, TRACKPARSE_FEAT_TITLE) || + !trackparse_format_options_set_feat_marker(fo, "ft.", TRACKPARSE_NUL_TERMINATED) || + !trackparse_format_options_set_joiners(fo, TRACKPARSE_JOINERS_CANONICAL) || + !trackparse_format_options_set_versions(fo, TRACKPARSE_VERSIONS_ALL) || + !trackparse_format_options_set_omit_producers(fo, true) || + !trackparse_format_options_set_position(fo, true)) { + trackparse_format_options_free(fo); + return NULL; + } + j = take(trackparse_format_with(o->track, fo)); + trackparse_format_options_free(fo); + return j; +} + +static char *op_all_artists(const op *o) { + trackparse_artists *a = trackparse_all_artists(o->track); + char *j; + if (!a) return NULL; + j = take(trackparse_artists_to_json(a)); + trackparse_artists_free(a); + return j; +} + +static char *op_track_json(const op *o) { return take(trackparse_track_to_json(o->track)); } + +static char *op_tracklist(const op *o) { + trackparse_tracklist *l = trackparse_parse_tracklist(o->s, o->n); + char *j; + if (!l) return NULL; + j = take(trackparse_tracklist_to_json(l)); + trackparse_tracklist_free(l); + return j; +} + +static char *op_tracklist_with(const op *o) { + trackparse_tracklist_options *lo = trackparse_tracklist_options_new(); + trackparse_tracklist *l; + char *j; + if (!lo) return NULL; + if (!trackparse_tracklist_options_set_mode(lo, TRACKPARSE_MODE_AUTO) || + !trackparse_tracklist_options_add_known_artist(lo, "Camo & Krooked", 14) || + !trackparse_tracklist_options_set_split_and(lo, TRACKPARSE_SPLIT_AND_NEVER) || + !trackparse_tracklist_options_add_version_head(lo, "rerub", TRACKPARSE_NUL_TERMINATED, + "remix", TRACKPARSE_NUL_TERMINATED) || + !trackparse_tracklist_options_add_descriptor(lo, "Deluxe", TRACKPARSE_NUL_TERMINATED) || + !trackparse_tracklist_options_add_genre(lo, "neurofunk", TRACKPARSE_NUL_TERMINATED) || + !trackparse_tracklist_options_add_junk(lo, "out now", TRACKPARSE_NUL_TERMINATED, "promo", + TRACKPARSE_NUL_TERMINATED) || + !trackparse_tracklist_options_add_feat_marker(lo, "w/", TRACKPARSE_NUL_TERMINATED) || + !trackparse_tracklist_options_set_audio_seconds(lo, 600.5) || + !trackparse_tracklist_options_add_marker_word(lo, "Break", TRACKPARSE_NUL_TERMINATED)) { + trackparse_tracklist_options_free(lo); + return NULL; + } + l = trackparse_parse_tracklist_with(o->s, o->n, lo); + trackparse_tracklist_options_free(lo); + if (!l) return NULL; + j = take(trackparse_tracklist_to_json(l)); + trackparse_tracklist_free(l); + return j; +} + +static char *op_tracklist_json(const op *o) { return take(trackparse_tracklist_to_json(o->list)); } + +static char *op_apply_edits(const op *o) { + static const long long lines[] = {1, 3}; + trackparse_edits *e = trackparse_edits_new(); + trackparse_edit_result *r; + char *j; + if (!e) return NULL; + if (!trackparse_edits_set_time(e, 2, 62.5) || !trackparse_edits_shift(e, 1.25) || + !trackparse_edits_shift_from(e, -3, 2) || !trackparse_edits_shift_lines(e, 7, lines, 2) || + !trackparse_edits_sort_by_time(e) || !trackparse_edits_set_rest(e, 1, "A - B", 5) || + !trackparse_edits_insert(e, 0, "00:00 Intro", TRACKPARSE_NUL_TERMINATED) || + !trackparse_edits_delete(e, 4) || !trackparse_edits_set_time(e, 99, 1)) { + trackparse_edits_free(e); + return NULL; + } + r = trackparse_apply_edits(o->s, o->n, e); + trackparse_edits_free(e); + if (!r) return NULL; + j = take(trackparse_edit_result_to_json(r)); + trackparse_edit_result_free(r); + return j; +} + +static char *op_edit_json(const op *o) { return take(trackparse_edit_result_to_json(o->edited)); } + +/* The JSON door: out of memory longjmps to this scope. The body is a function of its own so the + * frame that calls setjmp holds nothing a longjmp could clobber. */ +static char *wire_body(const hz_case *c) { + tp_str line, out; + char *p; + line.p = c->line; + line.n = c->line_n; + out = tp_wire_line(line); + p = (char *)malloc(out.n + 1); /* plain malloc: not counted */ + if (!p) exit(2); + memcpy(p, out.p, out.n); + p[out.n] = '\0'; + return p; +} + +static char *op_wire(const op *o) { + tp_scope s; + char *volatile result = NULL; + if (!tp_scope_open(&s)) return NULL; + if (setjmp(s.jmp) != 0) { + tp_scope_abort(&s); + free(result); + return NULL; + } + tp_scope_arm(&s); + result = wire_body(o->c); + tp_scope_close(&s); + tp_arena_free(s.arena); + return result; +} + +/* -------------------------------------------------------------------------------------------- */ +/* The sweep */ + +static long long sweeps, steps, successes_after_refusal; +static bool warm_only; /* the warm-up pass: run each operation once, no sweep */ + +/* Repeat o with allocation n failing, n = 1, 2, ..., until it succeeds; check each outcome. */ +static void sweep(const op *o, bool check_balance) { + char *want; + long long n; + disarm(); + want = o->run(o); + if (!want) { + FAILF("%s(%s): no reference result", o->name, o->s ? o->s : ""); + return; + } + if (warm_only) { + free(want); + return; + } + sweeps++; + for (n = 1; n < 1000000; n++) { + long long before = live; + char *got; + arm(n); + got = o->run(o); + disarm(); + steps++; + if (check_balance && live != before) { + FAILF("%s(%.60s): allocation %lld failed: %lld blocks leaked", o->name, o->s ? o->s : "", n, + live - before); + } + if (got == NULL) { + if (refused == 0) FAILF("%s(%.60s): NULL although no allocation failed", o->name, o->s); + continue; + } + if (strcmp(got, want) != 0) { + FAILF("%s(%.60s): allocation %lld failed: wrong result\n got %.300s\n want %.300s", + o->name, o->s ? o->s : "", n, got, want); + } + if (refused > 0) successes_after_refusal++; + free(got); + if (refused == 0) break; /* the call made fewer than n allocations: done */ + } + free(want); + if (getenv("TRACKPARSE_OOM_VERBOSE")) { + printf(" %-22s %6lld steps %.60s\n", o->name, n, o->s ? o->s : ""); + fflush(stdout); + } +} + +/* A track, tracklist or edit result for the to_json and format operations, built without + * failures. */ +static trackparse_track *parsed(const char *s, size_t n) { + trackparse_track *t; + disarm(); + t = trackparse_parse(s, n); + if (!t) exit(2); + return t; +} + +static void sweep_input(const char *fn, const hz_case *c, const char *s, size_t n) { + op o; + memset(&o, 0, sizeof o); + o.c = c; + o.s = s; + o.n = n; + if (c) { + o.name = "wire"; + o.run = op_wire; + sweep(&o, true); + } + if (strcmp(fn, "parse") == 0 || strcmp(fn, "format") == 0) { + trackparse_track *t = parsed(s, n); + o.track = t; + o.name = "parse"; + o.run = op_parse; + sweep(&o, true); + o.name = "parse_with"; + o.run = op_parse_with; + sweep(&o, true); + o.name = "parser"; + o.run = op_parser; + sweep(&o, true); + o.name = "format"; + o.run = op_format; + sweep(&o, true); + o.name = "format_with"; + o.run = op_format_with; + sweep(&o, true); + o.name = "all_artists"; + o.run = op_all_artists; + sweep(&o, true); + o.name = "track_to_json"; + o.run = op_track_json; + sweep(&o, true); + trackparse_track_free(t); + } else if (strcmp(fn, "parseArtists") == 0) { + o.name = "parse_artists"; + o.run = op_parse_artists; + sweep(&o, true); + } else if (strcmp(fn, "normalize") == 0) { + o.name = "normalize"; + o.run = op_normalize; + sweep(&o, true); + } else if (strcmp(fn, "parseTracklist") == 0 || strcmp(fn, "applyEdits") == 0) { + trackparse_tracklist *l; + trackparse_edit_result *r; + trackparse_edits *e; + disarm(); + l = trackparse_parse_tracklist(s, n); + e = trackparse_edits_new(); + if (!l || !e || !trackparse_edits_shift(e, 5) || !trackparse_edits_sort_by_time(e)) exit(2); + r = trackparse_apply_edits(s, n, e); + if (!r) exit(2); + o.list = l; + o.edited = r; + o.name = "parse_tracklist"; + o.run = op_tracklist; + sweep(&o, true); + o.name = "parse_tracklist_with"; + o.run = op_tracklist_with; + sweep(&o, true); + o.name = "tracklist_to_json"; + o.run = op_tracklist_json; + sweep(&o, true); + o.name = "apply_edits"; + o.run = op_apply_edits; + sweep(&o, true); + o.name = "edit_result_to_json"; + o.run = op_edit_json; + sweep(&o, true); + trackparse_tracklist_free(l); + trackparse_edit_result_free(r); + trackparse_edits_free(e); + } +} + +/* The cold sweep: the default tables are not built yet. */ +static void cold(void) { + static const char track[] = "Noisia feat. Foreign Beggars - Shellshock (Phace Remix) [HD]"; + static const char list[] = "00:00 Intro\n01:02.5 Noisia - Stigma\n**02:00** Break\n"; + op o; + memset(&o, 0, sizeof o); + o.s = track; + o.n = sizeof track - 1; + o.name = "cold parse"; + o.run = op_parse; + /* No reference yet (computing it would build the tables): run the sweep first, then compare + * the first success with a warm reference. */ + { + char *first = NULL; + for (long long n = 1; n < 100000 && !first; n++) { + arm(n); + first = op_parse(&o); + disarm(); + } + o.s = list; + o.n = sizeof list - 1; + { + char *first_list = NULL; + for (long long n = 1; n < 100000 && !first_list; n++) { + arm(n); + first_list = op_tracklist(&o); + disarm(); + } + if (!first || !first_list) { + FAILF("cold sweep: no success"); + } else { + char *a, *b; + o.s = track; + o.n = sizeof track - 1; + a = op_parse(&o); + o.s = list; + o.n = sizeof list - 1; + b = op_tracklist(&o); + if (!a || strcmp(a, first) != 0) FAILF("cold parse: first success differs"); + if (!b || strcmp(b, first_list) != 0) FAILF("cold parse_tracklist: first success differs"); + free(a); + free(b); + } + free(first_list); + } + free(first); + } +} + +/* Every k-th case of each function, about 50 in all. */ +static const struct { + const char *fn; + int count; +} quota[] = {{"parse", 18}, {"format", 6}, {"parseArtists", 6}, + {"normalize", 4}, {"parseTracklist", 10}, {"applyEdits", 8}}; + +/* Every selected fixture case, then the inputs of this file. */ +static void sweep_all(const hz_cases *cases_p, size_t *used_p) { + const hz_cases cases = *cases_p; + size_t used = 0; + for (size_t q = 0; q < TP_COUNT(quota); q++) { + size_t total = 0, step, taken = 0; + for (size_t i = 0; i < cases.n; i++) total += strcmp(cases.items[i].fn, quota[q].fn) == 0; + if (total == 0) continue; + step = total / (size_t)quota[q].count; + if (step == 0) step = 1; + for (size_t i = 0, k = 0; i < cases.n && taken < (size_t)quota[q].count; i++) { + const hz_case *c = &cases.items[i]; + if (strcmp(c->fn, quota[q].fn) != 0) continue; + if (k++ % step != 0) continue; + sweep_input(c->fn, c, c->input, c->input_n); + taken++; + used++; + } + } + /* Inputs of their own (also when spec/ is absent), two of them 10,000 code points long, so the + * arenas grow over many chunks. */ + { + static const char *const own[] = { + "", + "\xff\xfe broken \xed\xa0\x80 UTF-8", + ("01. Wilkinson ft. Becky Hill & Tom Cane - Afterglow (Sub Focus VIP Remix) " + "[Official Video]"), + }; + char *big = (char *)malloc(10001), *list = (char *)malloc(400001); + size_t ln = 0; + if (!big || !list) exit(2); + for (size_t i = 0; i < TP_COUNT(own); i++) { + sweep_input("parse", NULL, own[i], strlen(own[i])); + sweep_input("parseTracklist", NULL, own[i], strlen(own[i])); + used += 2; + } + for (size_t i = 0; i < 10000; i++) big[i] = "a feat. B & C (x) - "[i % 20]; + big[10000] = '\0'; + sweep_input("parse", NULL, big, 10000); + for (int i = 0; i < 2000; i++) { + int s = i * 37 % 7200; + ln += (size_t)sprintf(list + ln, "%02d:%02d:%02d Artist %d - Title %d (VIP)\n", s / 3600, + s % 3600 / 60, s % 60, i, i); + } + sweep_input("parseTracklist", NULL, list, ln); + used += 2; + free(big); + free(list); + } + *used_p = used; +} + +int main(int argc, char **argv) { + trackparse_allocator a; + hz_cases cases; + double start = hz_now(); + long long baseline = 0; + size_t used = 0; + a.malloc_fn = count_malloc; + a.realloc_fn = count_realloc; + a.free_fn = count_free; + a.user = NULL; + /* Before any other call: the library's lazily built tables come from this allocator too. */ + trackparse_set_allocator(&a); + cold(); + + cases = hz_load_cases(argc - 1, argv + 1); + /* Two passes over the same inputs: the first only runs each operation once, so every table + * built lazily on some path exists before the baseline is taken; the second sweeps. */ + for (int pass = 0; pass < 2; pass++) { + warm_only = pass == 0; + if (pass == 1) baseline = live; + used = 0; + sweep_all(&cases, &used); + } + hz_free_cases(&cases); + disarm(); + if (live > baseline) FAILF("%lld blocks still allocated at the end", live - baseline); + printf("oom: %lu inputs, %lld sweeps, %lld failing calls, %lld allocations, %lld successes " + "after a refused allocation, %.2f s\n", + (unsigned long)used, sweeps, steps, total_allocs, successes_after_refusal, + hz_now() - start); + if (failures) { + fprintf(stderr, "oom: %d failures\n", failures); + return 1; + } + printf("oom: ok\n"); + return 0; +} diff --git a/c/tests/test_primitives.c b/c/tests/test_primitives.c new file mode 100644 index 0000000..7e73708 --- /dev/null +++ b/c/tests/test_primitives.c @@ -0,0 +1,503 @@ +/* test_primitives.c: the R0 primitives (words.c, digits.c) against values taken from the JS + * reference (go/primitives_test.go, plus the sanitize cases of go/utf8_test.go). + * + * The expected values are ../rust/tests/data/primitives.json, written by + * rust/scripts/dump_primitives.mjs from js/src/words.ts; it is read in place (not copied), and the + * table tests skip when it is absent. TRACKPARSE_PRIMITIVES= swaps in another dump. The + * c/ directory is found from __FILE__, or from TRACKPARSE_C_DIR when set. + */ +#include +#include +#include +#include + +#include "../src/digits.h" +#include "../src/unicode.h" +#include "../src/words.h" +#include "../wire/json_read.h" + +static int failures = 0; + +/* ------------------------------------------------------------------------------------------ */ +/* Helpers */ + +static bool scoped(void (*fn)(void *), void *ctx) { + tp_scope s; + if (!tp_scope_open(&s)) return false; + if (setjmp(s.jmp) != 0) { + tp_scope_abort(&s); + return false; + } + tp_scope_arm(&s); + fn(ctx); + tp_scope_close(&s); + tp_arena_free(s.arena); + return true; +} + +static void put_quoted(tp_str s) { + putchar('"'); + for (size_t i = 0; i < s.n;) { + size_t size; + tp_str rest = {s.p + i, s.n - i}; + tp_rune r = tp_decode_rune(rest, &size); + if (size == 1 && (unsigned char)s.p[i] >= 0x80) { + printf("\\x%02x", (unsigned char)s.p[i]); + } else if (r >= 0x20 && r < 0x7f && r != '"' && r != '\\') { + putchar((int)r); + } else { + printf("\\u{%x}", (unsigned)r); + } + i += size; + } + putchar('"'); +} + +static void check_str(const char *what, tp_str in, tp_str got, tp_str want) { + if (tp_str_eq(got, want)) return; + if (++failures > 30) return; + printf("FAIL %s(", what); + put_quoted(in); + printf(") = "); + put_quoted(got); + printf(", JS "); + put_quoted(want); + printf("\n"); +} + +static void check(bool ok, const char *what) { + if (ok) return; + if (++failures <= 30) printf("FAIL %s\n", what); +} + +static tp_str S(const char *s) { return tp_str_c(s); } + +static char *read_file(const char *path, size_t *n) { + FILE *f = fopen(path, "rb"); + if (!f) return NULL; + size_t cap = 1 << 16, len = 0; + char *buf = malloc(cap); + for (;;) { + if (len == cap) { + cap *= 2; + char *nb = realloc(buf, cap); + if (!nb) { + free(buf); + fclose(f); + return NULL; + } + buf = nb; + } + size_t got = fread(buf + len, 1, cap - len, f); + if (got == 0) break; + len += got; + } + fclose(f); + *n = len; + return buf; +} + +static void c_dir(char *out, size_t cap) { + const char *env = getenv("TRACKPARSE_C_DIR"); + if (env && *env) { + snprintf(out, cap, "%s", env); + return; + } + const char *file = __FILE__; + const char *cut = strstr(file, "tests/test_primitives.c"); + if (!cut) cut = strstr(file, "tests\\test_primitives.c"); + size_t n = cut ? (size_t)(cut - file) : 0; + if (n == 0) { + snprintf(out, cap, "."); + } else { + snprintf(out, cap, "%.*s", (int)(n - 1), file); + } +} + +/* ------------------------------------------------------------------------------------------ */ +/* primitives.json */ + +static char *data_text = NULL; +static size_t data_len = 0; +static bool data_override = false; + +static bool primitives_data(tp_json *out) { + if (!data_text) return false; + tp_str text = {data_text, data_len}; + if (!tp_json_parse(text, out)) { + check(false, "primitives.json does not parse"); + return false; + } + return true; +} + +static tp_str get_str(tp_json v, const char *key) { + tp_json x; + if (!tp_json_get(v, tp_str_c(key), &x) || x.kind != TP_JSON_STRING) return TP_S(""); + return x.str; +} + +/* The dumped code points and one flag string ("0110...") of property. */ +static void check_property(const char *property, bool (*test)(tp_rune)) { + tp_json data, table, runs, flags; + if (!primitives_data(&data)) return; + if (!tp_json_get(data, TP_S("codePoints"), &table) || !tp_json_get(table, TP_S("runs"), &runs) || + !tp_json_get(table, tp_str_c(property), &flags) || flags.kind != TP_JSON_STRING) { + check(false, "codePoints table"); + return; + } + size_t idx = 0, bad = 0; + for (size_t i = 0; i < runs.arr_n; i++) { + const tp_json *run = &runs.arr[i]; + if (run->arr_n != 2) { + check(false, "bad run"); + return; + } + tp_rune first = (tp_rune)run->arr[0].num; + long count = (long)run->arr[1].num; + for (long k = 0; k < count; k++, idx++) { + if (idx >= flags.str.n) { + check(false, "flags shorter than the code points"); + return; + } + tp_rune r = first + (tp_rune)k; + bool want = flags.str.p[idx] == '1'; + if (test(r) != want && ++bad <= 10) { + printf("FAIL %s of U+%04X: got %d\n", property, (unsigned)r, !want); + failures++; + } + } + } + if (idx < 5000 || idx != flags.str.n) { + printf("FAIL %s: %zu code points, %zu flags\n", property, idx, flags.str.n); + failures++; + } +} + +/* ------------------------------------------------------------------------------------------ */ +/* Tests */ + +static void whitespace_set(void *unused) { + (void)unused; + check_property("whitespace", tp_is_whitespace); + /* R0.2, spelled out: U+0085 is in; U+FEFF, U+200B and U+180E are out. */ + tp_rune want[32]; + size_t nw = 0; + static const tp_rune head[] = {0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x20, 0x85, 0xa0, 0x1680}; + for (size_t i = 0; i < TP_COUNT(head); i++) want[nw++] = head[i]; + for (tp_rune r = 0x2000; r <= 0x200a; r++) want[nw++] = r; + want[nw++] = 0x2028; + want[nw++] = 0x2029; + want[nw++] = 0x202f; + want[nw++] = 0x205f; + want[nw++] = 0x3000; + size_t ng = 0; + bool same = true; + for (tp_rune r = 0; r <= 0x10ffff; r++) { + if (!tp_is_whitespace(r)) continue; + if (ng >= nw || want[ng] != r) same = false; + ng++; + } + check(same && ng == nw, "whitespace set"); + check(!tp_is_whitespace(TP_NORUNE), "TP_NORUNE is not whitespace"); +} + +static void js_trim_set(void *unused) { + (void)unused; + check_property("jsSpace", tp_is_js_space); + check_str("js_trim", S("\xef\xbb\xbf x\xc2\xa0\xe2\x80\xa8"), + tp_js_trim(S("\xef\xbb\xbf x\xc2\xa0\xe2\x80\xa8")), S("x")); + /* R0.2 whitespace, not JS whitespace */ + check_str("js_trim", S("\xc2\x85x\xc2\x85"), tp_js_trim(S("\xc2\x85x\xc2\x85")), + S("\xc2\x85x\xc2\x85")); + check_str("js_trim_end", S(" x \xef\xbb\xbf"), tp_js_trim_end(S(" x \xef\xbb\xbf")), S(" x")); + tp_str in = S("\xe3\x80\x80x y\t"); + check_str("js_trim_runes", in, tp_runes_str(tp_js_trim_runes(tp_runes_of(in))), S("x y")); +} + +static void letter_and_upper(void *unused) { + (void)unused; + /* The same file's letter and uppercase flags (R0.6, R6.10). */ + check_property("letter", tp_is_letter); + check_property("upper", tp_is_upper_letter); +} + +static void strings(void *unused) { + (void)unused; + tp_json data, records; + if (!primitives_data(&data)) return; + if (!tp_json_get(data, TP_S("strings"), &records) || (records.arr_n < 250 && !data_override)) { + printf("FAIL only %zu records\n", records.arr_n); + failures++; + return; + } + for (size_t i = 0; i < records.arr_n; i++) { + tp_json r = records.arr[i], x; + tp_str s = get_str(r, "s"); + tp_runes rs = tp_runes_of(s); + if (!tp_json_get(r, TP_S("utf16Len"), &x) || tp_utf16_len(rs) != (ptrdiff_t)x.num || + tp_utf16_len_string(s) != tp_utf16_len(rs)) { + check_str("utf16_len", s, tp_itoa(tp_utf16_len(rs)), tp_number_str(x.num)); + } + check_str("ascii_lower", s, tp_ascii_lower(s), get_str(r, "asciiLower")); + check_str("js_to_lower", s, tp_js_to_lower(s), get_str(r, "lower")); + check_str("word_key", s, tp_word_key(s), get_str(r, "wordKey")); + check_str("dedup_key", s, tp_dedup_key(s), get_str(r, "dedupKey")); + check_str("collapse_spaces", s, tp_collapse_spaces(s), get_str(r, "collapse")); + check_str("collapse_runes", s, tp_collapse_runes(rs), get_str(r, "collapse")); + check_str("js_trim", s, tp_js_trim(s), get_str(r, "jsTrim")); + check_str("js_trim_end", s, tp_js_trim_end(s), get_str(r, "jsTrimEnd")); + tp_strvec want = {0}; + if (tp_json_get(r, TP_S("words"), &x)) { + for (size_t k = 0; k < x.arr_n; k++) tp_push(want, x.arr[k].str); + } + tp_strvec got = tp_split_words(s); + if (!tp_strvec_eq(got, want)) { + check_str("split_words", s, tp_join(got, TP_S("|")), tp_join(want, TP_S("|"))); + } + tp_json year; + bool has_year = tp_json_get(r, TP_S("year"), &year) && year.kind != TP_JSON_NULL; + int got_year; + bool ok = tp_year_of(s, &got_year); + if (has_year != ok || (ok && got_year != (int)year.num)) { + check_str("year_of", s, tp_itoa(got_year), has_year ? tp_number_str(year.num) : S("null")); + } + } +} + +/* The lowercase sweep of the same file: [code point, JS toLowerCase()] pairs. */ +static void lower_sweep(void *unused) { + (void)unused; + tp_json data, sweep; + if (!primitives_data(&data)) return; + if (!tp_json_get(data, TP_S("lowerSweep"), &sweep) || sweep.arr_n < 1000) { + check(data_override, "lowerSweep"); + return; + } + for (size_t i = 0; i < sweep.arr_n; i++) { + const tp_json *e = &sweep.arr[i]; + if (e->arr_n != 2) { + check(false, "bad lowerSweep entry"); + return; + } + tp_buf b = {0}; + tp_buf_rune(&b, (tp_rune)e->arr[0].num); + tp_str in = tp_buf_done(&b); + check_str("js_to_lower", in, tp_js_to_lower(in), e->arr[1].str); + } +} + +static void word_keys(void *unused) { + (void)unused; + check_str("word_key", S("FEAT."), tp_word_key(S("FEAT.")), S("feat")); + check_str("word_key", S("Remix!!"), tp_word_key(S("Remix!!")), S("remix!")); + /* ASCII lowercase only */ + check_str("word_key", S("\xc3\x89."), tp_word_key(S("\xc3\x89.")), S("\xc3\x89")); + check(tp_word_matches(S("Feat."), S("feat.")) && tp_word_matches(S("Feat."), S("feat")) && + !tp_word_matches(S("feat"), S("feat.")), + "word_matches"); + check(tp_str_eq(tp_strip_key_punct(S("a;")), S("a")) && + tp_str_eq(tp_strip_key_punct(S("\xc3\xa4")), S("\xc3\xa4")), + "strip_key_punct"); + tp_word_set set = {{0}}; + static const tp_str words[] = {{"feat.", 5}, {"remix", 5}}; + tp_word_set_add_all(&set, words, TP_COUNT(words)); + check(tp_in_vocab(S("FEAT."), &set) && tp_in_vocab(S("Remix,"), &set) && + !tp_in_vocab(S("feat"), &set), + "in_vocab"); +} + +static void dedup_keys(void *unused) { + (void)unused; + static const struct { + const char *in, *want; + } cases[] = { + {"\xc4\xb0stanbul", "istanbul"}, /* i + U+0307, the mark then removed */ + {"STRA\xe1\xba\x9e" + "E", + "stra\xc3\x9f" + "e"}, + {"\xce\x9f\xce\x94\xce\xa5\xce\xa3\xce\xa3\xce\x95\xce\x91\xce\xa3", + "\xce\xbf\xce\xb4\xcf\x85\xcf\x83\xcf\x83\xce\xb5\xce\xb1\xcf\x82"}, /* final sigma */ + {" Beyonce\xcc\x81 KNOWLES ", "beyonce knowles"}, + {"\xd0\x99", "\xd0\xb8"}, /* U+0306 is removed */ + {"\xe3\x81\x8b\xe3\x82\x99", "\xe3\x81\x8b\xe3\x82\x99"}, /* other marks stay */ + {"\xff" + "A", + "\xef\xbf\xbd" + "a"}, /* invalid UTF-8 cannot reach here, but must not fail */ + }; + for (size_t i = 0; i < TP_COUNT(cases); i++) { + check_str("dedup_key", S(cases[i].in), tp_dedup_key(S(cases[i].in)), S(cases[i].want)); + } + (void)tp_dedup_key(S("\xff" + "A\xe2\x82")); +} + +static void rune_helpers(void *unused) { + (void)unused; + tp_runes rs = tp_runes_of(S("a\xf0\x9d\x90\x80" + "b")); /* a, U+1D400, b */ + check(tp_at(rs, 1) == 0x1d400 && tp_at(rs, 3) == TP_NORUNE && tp_at(rs, -1) == TP_NORUNE && + tp_before(rs, 0) == TP_NORUNE, + "at / before"); + check(tp_str_eq(tp_runes_str(tp_sub(rs, 1, 99)), S("\xf0\x9d\x90\x80" + "b")) && + tp_sub(rs, 5, 2).n == 0 && tp_str_eq(tp_runes_str(tp_tail(rs, 2)), S("b")), + "sub / tail"); + check(tp_utf16_len(rs) == 4, "utf16_len"); + check(tp_is_letter_at(rs, 0) && !tp_is_letter_at(rs, 9) && !tp_is_upper_at(rs, 2) && + tp_is_upper_at(tp_runes_of(S("A")), 0) && tp_is_letter_before(rs, 1), + "letter helpers"); + tp_word_span_vec spans = tp_word_spans(tp_runes_of(S(" ab\xe3\x80\x80" + "c "))); + check(spans.n == 2 && tp_str_eq(spans.p[0].text, S("ab")) && spans.p[0].start == 1 && + spans.p[0].end == 3 && tp_str_eq(spans.p[1].text, S("c")) && spans.p[1].start == 4 && + spans.p[1].end == 5, + "word_spans"); + tp_strvec texts = tp_span_texts(spans); + check(texts.n == 2 && tp_str_eq(texts.p[0], S("ab")) && tp_str_eq(texts.p[1], S("c")), + "span_texts"); + check(tp_is_all_digits(S("0123")) && !tp_is_all_digits(S("")) && !tp_is_all_digits(S("12a")), + "is_all_digits"); +} + +static void digits(void *unused) { + (void)unused; + tp_runes s = tp_runes_of(S("x0123:59:60:7")); + check(tp_digit_run(s, 1) == 4 && tp_digit_run(s, 0) == 0 && tp_digit_run(s, 99) == 0, + "digit_run"); + check(tp_digits_value(tp_runes_of(S("0123"))) == 123 && + tp_digits_value(tp_runes_of(S("99999999999999999999"))) == ((int64_t)1 << 40), + "digits_value"); + int n; + check(tp_two_digits_up_to_59(s, 6, &n) && n == 59, "59"); + check(!tp_two_digits_up_to_59(s, 9, &n), "60"); + check(!tp_two_digits_up_to_59(s, 1, &n), "followed by a third digit"); + check(!tp_two_digits_up_to_59(s, 12, &n), "one digit"); +} + +#define R "\xef\xbf\xbd" + +static void sanitize(void *unused) { + (void)unused; + static const struct { + const char *in; + size_t n; + const char *want; + size_t wn; + } cases[] = { +#define C(in, want) {in, sizeof(in) - 1, want, sizeof(want) - 1} + C("Noisia - Stigma", "Noisia - Stigma"), + C("a\xff" + "b", + "a" R "b"), + C("\xc0\xaf", R R), /* C0 is never a lead */ + C("\xe0\x80\x80", R R R), /* E0 needs A0..BF next */ + C("\xe0\xa0", R), /* truncated: one maximal subpart */ + C("\xe2\x82\xac", "\xe2\x82\xac"), + C("\xe2\x82", R), + C("\xe2\x82x", R "x"), + C("\xed\xa0\x80", R R R), /* surrogates are ill-formed */ + C("\xf0\x90\x80", R), + C("\xf0\x90\x80\x80", "\xf0\x90\x80\x80"), + C("\xf4\x90\x80\x80", R R R R), /* above U+10FFFF */ + C("\xf5\x80", R R), + C("\x80\x80", R R), + C("\xf1\x80\x80\xe1\x80\xc2", R R R), + C("a\0b", "a\0b"), /* U+0000 is valid */ + /* go/utf8_test.go lossyCases: as Rust's from_utf8_lossy and Node's TextDecoder */ + C("\xe2\x82" + "A", + R "A"), + C("\xf0\x9f\x98", R), + C("\xe0\x80\xaf", R R R), + C("\xf0\x8f\xbf\xbf", R R R R), + C("\xf1\x80\x80", R), + C("\xe1\x80\xe2\x82\xac", R "\xe2\x82\xac"), + C("Noisia \xff- Stigma \xf0\x9f\x98(VIP\xed\xbf\xbf)", + "Noisia " R "- Stigma " R "(VIP" R R R ")"), + C("00:00 A\xc3 - B\r\n01:00 \xe2\x80\x93 C - D\xf0\n02:00 \xed\xa0\x80 - \xff\n", + "00:00 A" R " - B\r\n01:00 \xe2\x80\x93 C - D" R "\n02:00 " R R R " - " R "\n"), +#undef C + }; + for (size_t i = 0; i < TP_COUNT(cases); i++) { + tp_str in = {cases[i].in, cases[i].n}; + tp_str want = {cases[i].want, cases[i].wn}; + tp_str got = tp_sanitize(in); + check_str("sanitize", in, got, want); + check(tp_utf8_valid(got), "sanitize gives valid UTF-8"); + } + tp_str valid = S("Bj\xc3\xb6rk"); + check(tp_sanitize(valid).p == valid.p, "valid input is returned unchanged"); +} + +static void phrase_table(void *unused) { + (void)unused; + static const int v1 = 1, v2 = 2, v3 = 3, v4 = 4; + tp_phrase_table *tb = tp_new_phrase_table(); + tp_phrase_table_add(tb, S("Official Video"), &v1); + tp_phrase_table_add(tb, S("video"), &v2); + tp_phrase_table_add(tb, S(" official video "), &v3); + tp_phrase_table_add(tb, S(""), &v4); + tp_strvec words = {0}; + tp_push(words, S("Official")); + tp_push(words, S("VIDEO,")); + tp_push(words, S("x")); + tp_phrase_match m; +#define MATCH(ok, want, len) \ + check((ok) && m.value != NULL && *(const int *)m.value == (want) && m.length == (len), \ + "phrase match " #want " " #len) + bool ok = tp_phrase_table_match_at(tb, words, 0, &m); + MATCH(ok, 1, 2); + ok = tp_phrase_table_match_at(tb, words, 1, &m); + MATCH(ok, 2, 1); + ok = tp_phrase_table_match_ending(tb, words, 2, &m); + MATCH(ok, 1, 2); + check(!tp_phrase_table_match_ending(tb, words, 0, &m) && m.value == NULL, "match_ending at 0"); + check(!tp_phrase_table_match_at(tb, words, 3, &m), "match_at past the end"); + check(!tp_phrase_table_match_at(tb, words, -1, &m), "match_at before the start"); + /* The first entry for a key wins (keys are trimmed and lowercased, not collapsed). */ + tp_strvec w2 = {0}; + tp_push(w2, S("official")); + tp_push(w2, S("video")); + ok = tp_phrase_table_match_at(tb, w2, 0, &m); + MATCH(ok, 1, 2); + /* NULL values (Go struct{}) work too. */ + tp_phrase_table *set = tp_new_phrase_table(); + tp_phrase_table_add(set, S("a b"), NULL); + ok = tp_phrase_table_match_at(set, w2, 0, &m); + check(!ok, "no match"); + tp_strvec w3 = {0}; + tp_push(w3, S("A")); + tp_push(w3, S("b.")); + ok = tp_phrase_table_match_at(set, w3, 0, &m); + check(ok && m.value == NULL && m.length == 2, "NULL-valued match"); +#undef MATCH +} + +int main(void) { + char dir[2048], path[4096]; + c_dir(dir, sizeof dir); + const char *env = getenv("TRACKPARSE_PRIMITIVES"); + if (env && *env) { + snprintf(path, sizeof path, "%s", env); + data_override = true; + } else { + snprintf(path, sizeof path, "%s/../rust/tests/data/primitives.json", dir); + } + data_text = read_file(path, &data_len); + if (!data_text) printf("skip the table tests: %s not found\n", path); + + void (*tests[])(void *) = {whitespace_set, js_trim_set, letter_and_upper, strings, + lower_sweep, word_keys, dedup_keys, rune_helpers, + digits, sanitize, phrase_table}; + for (size_t i = 0; i < TP_COUNT(tests); i++) check(scoped(tests[i], NULL), "test ran"); + free(data_text); + if (failures) { + printf("test_primitives: %d failures\n", failures); + return 1; + } + printf("test_primitives: ok\n"); + return 0; +} diff --git a/c/tests/test_properties.c b/c/tests/test_properties.c new file mode 100644 index 0000000..9278898 --- /dev/null +++ b/c/tests/test_properties.c @@ -0,0 +1,511 @@ +/* test_properties.c: SPEC.md "Invariants" for single tracks and R13.11 for tracklists on + * generated inputs, and the time ceilings: go/properties_test.go and the ceilings of + * go/bench_test.go. The generator and the checks are in hardening.c, shared with the fuzz + * targets. A failure prints the input and aborts; the generator is seeded, so it reproduces. + * + * test_properties [name...] run the named tests only (substring match) + * + * TRACKPARSE_SHORT=1 runs a tenth of the cases (as go test -short), for Valgrind. Builds with + * sanitizers (TRACKPARSE_SANITIZED) run a quarter of them, as Go under -race, and widen the + * ceilings ten times; TRACKPARSE_SLOWDOWN= sets that factor by hand. + */ +#include +#include + +#include "hardening.h" + +/* A tp_str initializer. */ +#define L(lit) {(lit), sizeof(lit) - 1} + +static int argc_g; +static char **argv_g; +static int ceiling_failures; + +static bool selected(const char *name) { + if (argc_g <= 1) return true; + for (int i = 1; i < argc_g; i++) { + if (strstr(name, argv_g[i])) return true; + } + return false; +} + +/* propertyRuns: a tenth under TRACKPARSE_SHORT, a quarter with sanitizers. */ +static int runs(int n) { + const char *s = getenv("TRACKPARSE_SHORT"); + if (s && s[0]) return n / 10; +#ifdef TRACKPARSE_SANITIZED + return n / 4; +#else + return n; +#endif +} + +/* One property test: n cases from seed, each in its own scope. */ +typedef void (*case_fn)(hz_rng *r, int *counter); + +typedef struct prop_arg { + hz_rng *r; + int *counter; + case_fn f; +} prop_arg; + +static void prop_tramp(void *p) { + prop_arg *a = (prop_arg *)p; + a->f(a->r, a->counter); +} + +static int run_prop(const char *name, uint64_t seed, int n, case_fn f) { + hz_rng r = hz_rng_new(seed); + int counter = 0; + prop_arg a; + double start = hz_now(); + if (!selected(name)) return -1; + a.r = &r; + a.counter = &counter; + a.f = f; + for (int i = 0; i < n; i++) hz_scoped(prop_tramp, &a); + printf("%-34s %6d cases %7.3f s\n", name, n, hz_now() - start); + fflush(stdout); + return counter; +} + +/* -------------------------------------------------------------------------------------------- */ +/* Single tracks */ + +static void totality_case(hz_rng *r, int *c) { + (void)c; + tp_str s = hz_any_string(r); + hz_check_track_totality(s); + hz_check_public(s); +} + +/* The fixed inputs and the tricky fragments, alone and repeated 50 times. */ +static void totality_fixed(void *p) { + static const tp_str fixed[] = { + L(""), L(" "), L("\x00"), L("\xef\xbb\xbf"), L("-"), L(" - "), L("("), + L(")"), L("(((("), L("]]]]"), L("\xf4\x8f\xbf\xbf"), L("\xff\xfe"), + }; + (void)p; + for (size_t i = 0; i < TP_COUNT(fixed); i++) { + hz_check_track_totality(fixed[i]); + hz_check_public(fixed[i]); + } + for (size_t i = 0; i < hz_tricky_fragments_n; i++) { + tp_str f = hz_tricky_fragments[i]; + hz_check_track_totality(f); + hz_check_track_totality(tp_repeat(f, 50)); + hz_check_public(tp_repeat(f, 50)); + } +} + +static void normalize_case(hz_rng *r, int *c) { + tp_str s = hz_any_string(r), once = tp_api_normalize(s), twice = tp_api_normalize(once); + (void)c; + if (!tp_str_eq(once, twice)) { + hz_fail("normalize: %s: %s then %s", hz_q(s), hz_q(once), hz_q(twice)); + } +} + +static void noise_case(hz_rng *r, int *c) { + tp_str s = hz_track_string(r); + (void)c; + hz_check_noise_insensitive(s, hz_below(r, 1000)); +} + +static void hygiene_case(hz_rng *r, int *c) { + tp_str s = hz_track_string(r); + tp_track t; + (void)c; + if (hz_chance(r, 70)) s = hz_any_string(r); + t = tp_api_parse(s); + hz_check_artist_hygiene(s, &t.artists); +} + +static void conservation_case(hz_rng *r, int *c) { + (void)c; + hz_check_conservation(hz_decorated(r)); +} + +static void metamorphic_case(hz_rng *r, int *c) { + (void)c; + hz_check_metamorphic(hz_quiet_track(r)); +} + +static void round_trip_case(hz_rng *r, int *c) { + tp_str s = hz_quiet_track(r); + tp_track t; + tp_format_options fo; + (void)c; + hz_check_round_trip(s); + t = tp_api_parse(s); + fo = hz_format_options_from(r, s); + (void)tp_api_format_with(&t, &fo); +} + +/* -------------------------------------------------------------------------------------------- */ +/* Tracklists */ + +static void lossless_case(hz_rng *r, int *c) { + tp_tracklist_options o; + tp_str text = hz_any_text(r); + (void)c; + memset(&o, 0, sizeof o); + hz_check_tracklist(text, &o); + hz_check_public_tracklist(text); +} + +static void line_breaks(void *p) { + static const struct { + tp_str text; + size_t want; + } cases[] = { + /* U+2028, U+2029, U+0085, VT and FF are whitespace, not line breaks. */ + {L("a\xe2\x80\xa8" + "b\xe2\x80\xa9" + "c\xc2\x85" + "d\x0b" + "e\x0c" + "f"), + 1}, + {L("a\r\nb\rc\nd\n"), 4}, + {L("\n\r\r\n"), 3}, + {L(""), 0}, + }; + (void)p; + for (size_t i = 0; i < TP_COUNT(cases); i++) { + size_t got = tp_api_parse_tracklist(cases[i].text).entries.n; + if (got != cases[i].want) { + hz_fail("%s: %lu lines, want %lu", hz_q(cases[i].text), (unsigned long)got, + (unsigned long)cases[i].want); + } + } +} + +static void loose_edits_case(hz_rng *r, int *c) { + tp_str text = hz_any_text(r); + tp_json edits = hz_loose_edits(r); + (void)c; + hz_check_loose_edits(text, edits); +} + +static void identity_case(hz_rng *r, int *c) { + (void)c; + hz_check_identity(hz_any_text(r)); +} + +static void locality_case(hz_rng *r, int *c) { + tp_str text = hz_timed_list(r); + (void)c; + if (hz_chance(r, 20)) text = hz_noisy_text(r); + hz_check_locality(text, r); + hz_check_insert_delete(hz_timed_list(r), r); +} + +static void shift_case(hz_rng *r, int *c) { + tp_str text = hz_timed_list(r); + if (hz_check_shift_round_trip(text, r)) (*c)++; +} + +static void sort_case(hz_rng *r, int *c) { + (void)c; + hz_check_sort(hz_timed_list(r)); +} + +static void one_line_case(hz_rng *r, int *c) { + tp_str text = TP_EMPTY; + if (hz_chance(r, 50)) text = hz_list_line(r); + if (hz_check_one_line(tp_concat(text, hz_noisy_text(r)))) (*c)++; +} + +static void emphasis_case(hz_rng *r, int *c) { + tp_str style = hz_time_styles[hz_below(r, (int)hz_time_styles_n)]; + int seconds = hz_below(r, 3600); + int frac = hz_below(r, 1000); + tp_str t = hz_write_time(style, seconds, frac); + (void)c; + for (size_t i = 0; i < hz_emphasis_rests_n; i++) hz_check_emphasis(t, hz_emphasis_rests[i]); +} + +/* -------------------------------------------------------------------------------------------- */ +/* Ceilings (go/bench_test.go) */ + +/* block repeated to exactly n code points. */ +static tp_str repeated(tp_str block, size_t n) { + tp_runes rs = tp_runes_of(block); + tp_rune *out = (tp_rune *)tp_alloc_array(n, sizeof *out); + tp_runes r; + for (size_t i = 0; i < n; i++) out[i] = rs.p[i % rs.n]; + r.p = out; + r.n = n; + return tp_runes_str(r); +} + +static void check_ceiling(const char *what, double d, double ceiling) { + if (d > ceiling) { + fprintf(stderr, "FAIL: %s: %.3f s (ceiling %.1f s)\n", what, d, ceiling); + ceiling_failures++; + } +} + +typedef struct timed_parse { + const tp_parser *p; + tp_parse_options *o; + tp_str input; + int which; /* 0 parser, 1 parse, 2 parse_artists, 3 parse_with */ +} timed_parse; + +static void do_timed_parse(void *p) { + timed_parse *t = (timed_parse *)p; + switch (t->which) { + case 0: + (void)tp_parser_parse(t->p, t->input); + break; + case 1: + (void)tp_api_parse(t->input); + break; + case 2: + (void)tp_api_parse_artists(t->input); + break; + default: + (void)tp_api_parse_with(t->input, t->o); + } +} + +static const tp_str ceiling_blocks[] = { + L("("), + L("a - "), + L("A & B, "), + L("feat. X "), + L("[Remix] "), + L("-a"), + L(" by x"), + L("\"q\" "), + L("xxxxxxx"), + L("prod. A feat. B "), + L("a by me "), + L("(x) - "), + L("Official Video "), + L("x - Official Video "), + L("Remix - "), + L("a feat. "), + L("a & "), + L("(a remix) "), + L("Noisia feat. Foreign Beggars - Shellshock (Phace Remix) [Official Video] "), +}; + +static void ceiling_10k_code_points(void *p) { + static const tp_str modes[] = {L("auto"), L("youtube"), L("filename")}; + double ceiling = 2 * hz_slowdown(), worst = 0; + (void)p; + for (size_t b = 0; b < TP_COUNT(ceiling_blocks); b++) { + tp_str input = repeated(ceiling_blocks[b], 10000); + for (size_t m = 0; m < TP_COUNT(modes); m++) { + tp_parse_options o; + timed_parse t; + double d; + memset(&o, 0, sizeof o); + o.mode = modes[m]; + t.p = tp_new_parser(&o); + t.o = NULL; + t.input = input; + t.which = 0; + d = hz_best_of3(do_timed_parse, &t); + if (d > worst) worst = d; + if (d > ceiling) { + fprintf(stderr, "FAIL: %s in %s: %.3f s (ceiling %.1f s)\n", hz_q(ceiling_blocks[b]), + modes[m].p, d, ceiling); + ceiling_failures++; + } + } + } + printf(" 10,000 code points: slowest %.4f s over %lu blocks x 3 modes\n", worst, + (unsigned long)TP_COUNT(ceiling_blocks)); +} + +static void ceiling_feat_credits(void *p) { + timed_parse t; + double ceiling = 2 * hz_slowdown(), a, b; + (void)p; + /* 1,250 `a feat. ` credits: 10,000 code points that all dedup to one name (R9.2). */ + memset(&t, 0, sizeof t); + t.input = tp_repeat(TP_S("a feat. "), 1250); + t.which = 1; + a = hz_best_of3(do_timed_parse, &t); + t.which = 2; + b = hz_best_of3(do_timed_parse, &t); + printf(" 1,250 feat credits: parse %.4f s, parseArtists %.4f s\n", a, b); + check_ceiling("repeated feat credits: parse", a, ceiling); + check_ceiling("repeated feat credits: parseArtists", b, ceiling); +} + +static void ceiling_trailing_junk(void *p) { + tp_parse_options o; + timed_parse t; + tp_track track; + double d; + (void)p; + memset(&o, 0, sizeof o); + o.mode = TP_MODE_YOUTUBE; + memset(&t, 0, sizeof t); + t.input = tp_concat(TP_S("A - T "), tp_repeat(TP_S("Official Video "), 2666)); + t.o = &o; + t.which = 3; + track = tp_api_parse_with(t.input, &o); + if (!tp_str_eq(track.title, TP_S("T")) || track.junk.n != 2666) { + hz_fail("trailing junk: title %s, %lu junk", hz_q(track.title), (unsigned long)track.junk.n); + } + d = hz_best_of3(do_timed_parse, &t); + printf(" 2,666 trailing junk phrases: %.4f s\n", d); + check_ceiling("repeated trailing junk", d, 2 * hz_slowdown()); +} + +static void put2(tp_buf *b, int n) { + tp_buf_byte(b, (char)('0' + n / 10 % 10)); + tp_buf_byte(b, (char)('0' + n % 10)); +} + +static void hms(tp_buf *b, int s) { + put2(b, s / 3600); + tp_buf_byte(b, ':'); + put2(b, (s % 3600) / 60); + tp_buf_byte(b, ':'); + put2(b, s % 60); +} + +/* The 10,000-line list of the other suites. */ +static tp_str ten_thousand_lines(void) { + tp_buf b = {0}; + for (int i = 0; i < 10000; i++) { + if (i) tp_buf_cstr(&b, "\r\n"); + hms(&b, (i * 37) % 7200); + tp_buf_byte(&b, ' '); + tp_buf_int(&b, i % 100); + tp_buf_cstr(&b, " Artist "); + tp_buf_int(&b, i); + tp_buf_cstr(&b, " & Other - Title "); + tp_buf_int(&b, i); + tp_buf_cstr(&b, " (VIP Mix)"); + } + return tp_buf_done(&b); +} + +typedef struct timed_list { + tp_str text; + const tp_edit *edits; + size_t n; +} timed_list; + +static void do_parse_list(void *p) { (void)tp_api_parse_tracklist(((timed_list *)p)->text); } + +static void do_apply(void *p) { + timed_list *t = (timed_list *)p; + (void)tp_api_apply_edits(t->text, t->edits, t->n); +} + +static void ceiling_10k_lines(void *p) { + timed_list t; + tp_edit edits[2]; + double parse, edit; + size_t n; + (void)p; + t.text = ten_thousand_lines(); + n = tp_api_parse_tracklist(t.text).entries.n; + if (n != 10000) hz_fail("10,000 lines: %lu entries", (unsigned long)n); + parse = hz_best_of3(do_parse_list, &t); + edits[0] = tp_edit_shift(5); + edits[1] = tp_edit_sort_by_time(); + t.edits = edits; + t.n = 2; + edit = hz_best_of3(do_apply, &t); + printf(" 10,000 lines: parseTracklist %.4f s, shift + sort %.4f s\n", parse, edit); + check_ceiling("parseTracklist on 10,000 lines", parse, 3 * hz_slowdown()); + check_ceiling("applyEdits on 10,000 lines", edit, 1 * hz_slowdown()); +} + +static void ceiling_2000_edits(void *p) { + tp_buf b = {0}; + tp_edit *set_times, *inserts; + timed_list t; + double set, ins; + size_t n; + (void)p; + /* R13.11.2: ApplyEdits costs lines plus edits, not their product. */ + for (int i = 0; i < 5000; i++) { + if (i) tp_buf_byte(&b, '\n'); + hms(&b, i * 30); + tp_buf_cstr(&b, " A "); + tp_buf_int(&b, i); + tp_buf_cstr(&b, " - T "); + tp_buf_int(&b, i); + } + t.text = tp_buf_done(&b); + set_times = (tp_edit *)tp_alloc_array(2000, sizeof *set_times); + inserts = (tp_edit *)tp_alloc_array(2000, sizeof *inserts); + for (int k = 0; k < 2000; k++) { + set_times[k] = tp_edit_set_time((k * 7) % 5000 + 1, (double)(k * 10)); + inserts[k] = tp_edit_insert((k * 7) % 5000, TP_S("00:00 X - Y")); + } + n = tp_api_apply_edits(t.text, set_times, 2000).changed.n; + if (n != 2000) hz_fail("set-time changed %lu lines", (unsigned long)n); + n = tp_api_apply_edits(t.text, inserts, 2000).changed.n; + if (n != 2000) hz_fail("insert changed %lu lines", (unsigned long)n); + t.n = 2000; + t.edits = set_times; + set = hz_best_of3(do_apply, &t); + t.edits = inserts; + ins = hz_best_of3(do_apply, &t); + printf(" 2,000 edits on 5,000 lines: set-time %.4f s, insert %.4f s\n", set, ins); + check_ceiling("2,000 set-time edits", set, 1 * hz_slowdown()); + check_ceiling("2,000 insert edits", ins, 1 * hz_slowdown()); +} + +static void run_fixed(const char *name, hz_fn fn) { + double start = hz_now(); + if (!selected(name)) return; + hz_scoped(fn, NULL); + printf("%-34s %7.3f s\n", name, hz_now() - start); + fflush(stdout); +} + +int main(int argc, char **argv) { + int n; + argc_g = argc; + argv_g = argv; +#ifdef TRACKPARSE_SANITIZED + printf("sanitizer build: a quarter of the cases, ceilings x%.0f\n", hz_slowdown()); +#endif + + run_prop("PropertyTotality", 1, runs(2000), totality_case); + run_fixed("PropertyTotalityFixed", totality_fixed); + run_prop("PropertyNormalizeIdempotent", 2, runs(4000), normalize_case); + run_prop("PropertyNoiseInsensitive", 3, runs(500), noise_case); + run_prop("PropertyArtistHygiene", 5, runs(3000), hygiene_case); + run_prop("PropertyConservation", 6, runs(1000), conservation_case); + run_prop("PropertyMetamorphic", 7, runs(500), metamorphic_case); + run_prop("PropertyRoundTrip", 11, runs(500), round_trip_case); + + run_prop("PropertyTracklistLossless", 21, runs(3000), lossless_case); + run_fixed("PropertyOnlyLFCRLFAndCRBreakLines", line_breaks); + run_prop("PropertyAnyEditListReturns", 22, runs(2000), loose_edits_case); + run_prop("PropertyNoEditsIsTheIdentity", 23, runs(1000), identity_case); + run_prop("PropertyEditLocality", 24, runs(1500), locality_case); + n = run_prop("PropertyShiftRoundTrip", 26, runs(2000), shift_case); + if (n >= 0 && n < runs(2000) / 20) hz_fail("only %d shift round trips were checked", n); + run_prop("PropertySort", 27, runs(1500), sort_case); + n = run_prop("PropertyOneLineTrack", 28, runs(3000), one_line_case); + if (n >= 0 && n < runs(3000) / 6) hz_fail("only %d one-line tracks were checked", n); + run_prop("PropertyEmphasis", 29, runs(40), emphasis_case); + + run_fixed("CeilingTenThousandCodePoints", ceiling_10k_code_points); + run_fixed("CeilingRepeatedFeatCredits", ceiling_feat_credits); + run_fixed("CeilingRepeatedTrailingJunk", ceiling_trailing_junk); + run_fixed("CeilingTenThousandLines", ceiling_10k_lines); + run_fixed("CeilingTwoThousandEdits", ceiling_2000_edits); + + if (ceiling_failures) { + fprintf(stderr, "%d ceilings exceeded\n", ceiling_failures); + return 1; + } + printf("properties: ok\n"); + return 0; +} diff --git a/c/tests/test_rt.c b/c/tests/test_rt.c new file mode 100644 index 0000000..5eb8ffd --- /dev/null +++ b/c/tests/test_rt.c @@ -0,0 +1,556 @@ +/* test_rt.c: src/rt.c (arenas, scopes and out of memory, once, strings, runes, vectors, + * builders, the map, the stable sort, tp_json helpers). */ +#include +#include + +#if defined(_WIN32) +#include +#else +#include +#endif + +#include "../src/rt.h" + +static int failures; +static long checks; + +#define CHECK(cond) \ + do { \ + checks++; \ + if (!(cond)) { \ + failures++; \ + fprintf(stderr, "%s:%d: CHECK(%s)\n", __FILE__, __LINE__, #cond); \ + } \ + } while (0) + +#define STR_IS(s, lit) CHECK(tp_str_eq_c((s), (lit))) + +/* -------------------------------------------------------------------------------------------- */ +/* A counting allocator that fails the n-th malloc */ + +static long live_blocks; /* mallocs minus frees */ +static long malloc_calls; +static long fail_at = -1; /* fail the malloc with this index (0-based), -1: never */ + +static void *count_malloc(size_t size, void *user) { + void *p; + (void)user; + if (malloc_calls++ == fail_at) return NULL; + p = malloc(size); + if (p != NULL) live_blocks++; + return p; +} + +static void *count_realloc(void *ptr, size_t size, void *user) { + (void)user; + return realloc(ptr, size); +} + +static void count_free(void *ptr, void *user) { + (void)user; + if (ptr != NULL) live_blocks--; + free(ptr); +} + +static const tp_allocator counting = {count_malloc, count_realloc, count_free, NULL}; + +/* -------------------------------------------------------------------------------------------- */ + +typedef TP_VEC(int) intvec; + +typedef struct pair { + int key; + int order; +} pair; +typedef TP_VEC(pair) pairvec; + +static int cmp_pair(const void *a, const void *b, void *ctx) { + const pair *x = (const pair *)a, *y = (const pair *)b; + (void)ctx; + return (x->key > y->key) - (x->key < y->key); +} + +static uint64_t rng = 88172645463325252u; +static uint64_t next_rand(void) { + rng ^= rng << 13; + rng ^= rng >> 7; + rng ^= rng << 17; + return rng; +} + +/* Work that touches every allocation path, for the out-of-memory sweep. Returns a checksum. */ +static size_t workload(void) { + tp_strvec parts = {0, 0, 0}; + tp_buf b = {0, 0, 0}; + tp_map m = {0, 0, 0}; + pairvec v = {0, 0, 0}; + size_t i, sum = 0; + for (i = 0; i < 300; i++) { + tp_str s = tp_itoa((int64_t)i * 7919); + tp_push(parts, s); + tp_map_put(&m, s, (int64_t)i); + tp_buf_str(&b, s); + { + pair p; + p.key = (int)(i % 17); + p.order = (int)i; + tp_push(v, p); + } + } + (void)tp_alloc(200000); /* a chunk of its own */ + for (i = 0; i < 40000; i++) (void)tp_alloc(50); /* several regular chunks */ + tp_sort_stable(v.p, v.n, sizeof *v.p, cmp_pair, NULL); + sum += tp_join(parts, TP_S(", ")).n + tp_buf_done(&b).n + tp_runes_of(TP_S("añb€😀")).n; + sum += tp_number_str(0.1).n; + { + int64_t x = 0; + if (tp_map_get(&m, TP_S("7919"), &x)) sum += (size_t)x; + } + return sum; +} + +static void test_oom(void) { + static size_t want; + static long n, total; + tp_set_allocator(&counting); + /* The reference run. */ + { + tp_scope s; + CHECK(tp_scope_open(&s)); + if (setjmp(s.jmp) != 0) { + tp_scope_abort(&s); + CHECK(0 && "reference run ran out of memory"); + return; + } + tp_scope_arm(&s); + want = workload(); + tp_scope_close(&s); + tp_arena_free(s.arena); + } + CHECK(live_blocks == 0); + total = malloc_calls; + CHECK(total >= 6); + printf("test_rt: out-of-memory sweep over %ld allocation points\n", total + 1); + /* Fail each allocation in turn. */ + for (n = 0; n <= total; n++) { + static tp_scope s; /* static: written before setjmp only, safe across the longjmp */ + static volatile int aborted; + static size_t got; + malloc_calls = 0; + fail_at = n; + aborted = 0; + got = 0; + if (!tp_scope_open(&s)) { + CHECK(n == 0); /* only the arena header itself can fail here */ + CHECK(live_blocks == 0); + continue; + } + if (setjmp(s.jmp) != 0) { + tp_scope_abort(&s); + aborted = 1; + } else { + tp_scope_arm(&s); + got = workload(); + tp_scope_close(&s); + tp_arena_free(s.arena); + } + CHECK(tp_arena_current() == NULL); + CHECK(live_blocks == 0); + if (n < total) { + CHECK(aborted); + } else { + CHECK(!aborted && got == want); + } + } + fail_at = -1; + /* Nested scopes: an inner failure unwinds only the inner scope. */ + { + static tp_scope outer, inner; + static volatile int inner_failed; + inner_failed = 0; + CHECK(tp_scope_open(&outer)); + if (setjmp(outer.jmp) != 0) { + tp_scope_abort(&outer); + CHECK(0 && "outer scope aborted"); + } else { + tp_str kept; + tp_scope_arm(&outer); + kept = tp_str_copy("outer", 5); + CHECK(tp_scope_open(&inner)); + if (setjmp(inner.jmp) != 0) { + tp_scope_abort(&inner); + inner_failed = 1; + } else { + tp_scope_arm(&inner); + fail_at = malloc_calls; /* the next malloc fails */ + (void)tp_alloc(1 << 20); + CHECK(0 && "not reached"); + } + fail_at = -1; + CHECK(inner_failed); + CHECK(tp_arena_current() == outer.arena); + STR_IS(kept, "outer"); + (void)tp_alloc(100); /* the outer scope still works */ + tp_scope_close(&outer); + tp_arena_free(outer.arena); + } + CHECK(live_blocks == 0); + } + /* Size overflow longjmps like an allocation failure. */ + { + static tp_scope s; + static volatile int hit; + hit = 0; + CHECK(tp_scope_open(&s)); + if (setjmp(s.jmp) != 0) { + tp_scope_abort(&s); + hit = 1; + } else { + tp_scope_arm(&s); + (void)tp_alloc_array(SIZE_MAX / 2, 4); + tp_scope_close(&s); + tp_arena_free(s.arena); + } + CHECK(hit); + CHECK(live_blocks == 0); + } + tp_set_allocator(NULL); +} + +static void test_arena(void) { + tp_arena *a; + unsigned char *p, *q; + size_t i; + bool zero = true; + a = tp_arena_new(); + CHECK(a != NULL); + CHECK(tp_arena_use(a) == NULL); + CHECK(tp_arena_current() == a); + for (i = 1; i < 2000; i += 37) { + p = (unsigned char *)tp_alloc(i); + CHECK(((uintptr_t)p % TP_ALIGN) == 0); + memset(p, 0xAB, i); + } + p = (unsigned char *)tp_alloc(1000000); + CHECK(((uintptr_t)p % TP_ALIGN) == 0); + for (i = 0; i < 1000000; i++) zero = zero && p[i] == 0; + CHECK(zero); + CHECK(tp_alloc(0) != NULL); + CHECK(tp_arena_bytes(a) >= 1000000); + /* Grow in place, and zero the new tail. */ + p = (unsigned char *)tp_alloc(16); + memset(p, 1, 16); + q = (unsigned char *)tp_realloc(p, 16, 64); + CHECK(q == p); + CHECK(q[15] == 1 && q[16] == 0 && q[63] == 0); + (void)tp_alloc(8); + p = (unsigned char *)tp_realloc(q, 64, 128); /* no longer last: copies */ + CHECK(p != q && p[0] == 1 && p[63] == 0 && p[127] == 0); + CHECK(tp_size_add(1, 2) == 3 && tp_size_mul(3, 4) == 12); + tp_arena_use(NULL); + tp_arena_free(a); +} + +static void test_strings(void) { + tp_str s = TP_S("hello, world"); + int64_t x; + STR_IS(tp_str_c("abc"), "abc"); + CHECK(tp_str_c(NULL).n == 0); + CHECK(tp_str_cstr(TP_S("ab"))[2] == '\0'); + CHECK(tp_str_cmp(TP_S("a"), TP_S("b")) < 0 && tp_str_cmp(TP_S("ab"), TP_S("a")) > 0); + CHECK(tp_str_cmp(TP_S(""), TP_S("")) == 0 && tp_str_cmp(TP_S("\xff"), TP_S("a")) > 0); + STR_IS(tp_str_slice(s, 7, 100), "world"); + STR_IS(tp_str_slice(s, 9, 3), ""); + CHECK(tp_has_prefix(s, TP_S("hell")) && !tp_has_prefix(s, TP_S("world"))); + CHECK(tp_has_suffix(s, TP_S("world")) && tp_has_suffix(s, TP_EMPTY)); + STR_IS(tp_trim_prefix(s, TP_S("hello, ")), "world"); + STR_IS(tp_trim_suffix(s, TP_S("x")), "hello, world"); + CHECK(tp_index(s, TP_S("o")) == 4 && tp_index(s, TP_S("wor")) == 7); + CHECK(tp_index(s, TP_S("worlds")) == -1 && tp_index(s, TP_EMPTY) == 0); + CHECK(tp_index(TP_S("aaab"), TP_S("aab")) == 1); + CHECK(tp_index_byte(s, 'w') == 7 && tp_last_index_byte(s, 'o') == 8); + CHECK(tp_index_byte(s, 'z') == -1 && tp_last_index_byte(TP_EMPTY, 'a') == -1); + CHECK(tp_contains(s, TP_S(", ")) && !tp_contains(s, TP_S(";"))); + CHECK(tp_contains_rune(TP_S("a€b"), 0x20AC) && !tp_contains_rune(TP_S("ab"), 'c')); + CHECK(tp_contains_any(TP_S("a€b"), TP_S("x€")) && !tp_contains_any(TP_S("ab"), TP_S(""))); + STR_IS(tp_concat(TP_S("ab"), TP_S("cd")), "abcd"); + STR_IS(tp_concat3(TP_S("a"), TP_EMPTY, TP_S("c")), "ac"); + STR_IS(tp_repeat(TP_S("ab"), 3), "ababab"); + STR_IS(tp_repeat(TP_S("ab"), 0), ""); + STR_IS(tp_replace_all(TP_S("a-b-c"), TP_S("-"), TP_S("--")), "a--b--c"); + STR_IS(tp_replace_all(TP_S("aaa"), TP_S("aa"), TP_S("b")), "ba"); + STR_IS(tp_replace_all(TP_S("a€"), TP_EMPTY, TP_S(".")), ".a.€."); + STR_IS(tp_replace_all(TP_S("abc"), TP_S("x"), TP_S("y")), "abc"); + STR_IS(tp_itoa(0), "0"); + STR_IS(tp_itoa(-42), "-42"); + STR_IS(tp_itoa(INT64_MIN), "-9223372036854775808"); + STR_IS(tp_itoa(INT64_MAX), "9223372036854775807"); + CHECK(tp_atoi(TP_S("123"), &x) && x == 123); + CHECK(tp_atoi(TP_S("-007"), &x) && x == -7); + CHECK(tp_atoi(TP_S("+5"), &x) && x == 5); + CHECK(tp_atoi(TP_S("-9223372036854775808"), &x) && x == INT64_MIN); + CHECK(tp_atoi(TP_S("9223372036854775807"), &x) && x == INT64_MAX); + CHECK(!tp_atoi(TP_S("9223372036854775808"), &x)); + CHECK(!tp_atoi(TP_S(""), &x) && !tp_atoi(TP_S("-"), &x) && !tp_atoi(TP_S("1a"), &x)); + CHECK(!tp_atoi(TP_S(" 1"), &x) && !tp_atoi(TP_S("1_0"), &x)); + CHECK(tp_utf8_valid(TP_S("a€😀\xef\xbf\xbd"))); + CHECK(!tp_utf8_valid(TP_S("\xff")) && !tp_utf8_valid(TP_S("\xc0\x80"))); + CHECK(!tp_utf8_valid(TP_S("\xed\xa0\x80")) && !tp_utf8_valid(TP_S("\xf4\x90\x80\x80"))); + CHECK(!tp_utf8_valid(TP_S("\xe2\x82"))); + { + tp_strvec parts = tp_split(TP_S("a,b,,c"), TP_S(",")); + tp_strvec one = tp_split(TP_EMPTY, TP_S(",")); + CHECK(parts.n == 4); + STR_IS(parts.p[2], ""); + STR_IS(parts.p[3], "c"); + CHECK(one.n == 1 && one.p[0].n == 0); + STR_IS(tp_join(parts, TP_S("+")), "a+b++c"); + CHECK(tp_join(one, TP_S("+")).n == 0); + CHECK(tp_strvec_eq(parts, tp_split(TP_S("a,b,,c"), TP_S(",")))); + CHECK(!tp_strvec_eq(parts, one)); + CHECK(tp_strvec_has(parts, TP_S("c")) && !tp_strvec_has(parts, TP_S("d"))); + CHECK(tp_split(TP_S("a€"), TP_EMPTY).n == 2); + } +} + +static void test_runes(void) { + tp_runes r = tp_runes_of(TP_S("a\xc3\xb1\xe2\x82\xac\xf0\x9f\x98\x80")); + size_t len; + char enc[4]; + CHECK(r.n == 4 && r.p[0] == 'a' && r.p[1] == 0xF1 && r.p[2] == 0x20AC && r.p[3] == 0x1F600); + STR_IS(tp_runes_str(r), "a\xc3\xb1\xe2\x82\xac\xf0\x9f\x98\x80"); + CHECK(tp_rune_count(TP_S("a\xc3\xb1\xff")) == 3); + { + tp_runes bad = tp_runes_of(TP_S("\xff\xe2\x82")); + CHECK(bad.n == 3 && bad.p[0] == 0xFFFD && bad.p[1] == 0xFFFD && bad.p[2] == 0xFFFD); + } + CHECK(tp_runes_eq(tp_runes_slice(r, 1, 3), tp_runes_clone(tp_runes_slice(r, 1, 3)))); + CHECK(tp_runes_slice(r, 3, 1).n == 0 && tp_runes_slice(r, 2, 99).n == 2); + CHECK(!tp_runes_eq(r, tp_runes_slice(r, 0, 3))); + CHECK(tp_decode_rune(TP_S("\xe2\x82\xac!"), &len) == 0x20AC && len == 3); + CHECK(tp_decode_rune(TP_EMPTY, &len) == TP_NORUNE && len == 0); + CHECK(tp_decode_rune(TP_S("\xc0\x80"), &len) == 0xFFFD && len == 1); + CHECK(tp_decode_last_rune(TP_S("!\xe2\x82\xac"), &len) == 0x20AC && len == 3); + CHECK(tp_decode_last_rune(TP_S("ab"), &len) == 'b' && len == 1); + CHECK(tp_decode_last_rune(TP_S("\xe2\x82"), &len) == 0xFFFD && len == 1); + CHECK(tp_decode_last_rune(TP_S("\x80\x80\x80\x80\x80"), &len) == 0xFFFD && len == 1); + CHECK(tp_decode_last_rune(TP_EMPTY, &len) == TP_NORUNE && len == 0); + CHECK(tp_utf8_encode(enc, 0x10FFFF) == 4 && (unsigned char)enc[0] == 0xF4); + CHECK(tp_utf8_encode(enc, 0xD800) == 3 && (unsigned char)enc[0] == 0xEF); + CHECK(tp_utf8_encode(enc, 0) == 1 && enc[0] == 0); + { + tp_runevec v = {0, 0, 0}; + tp_push(v, 'x'); + tp_push(v, 0x20AC); + STR_IS(tp_runes_str(tp_runevec_view(v)), "x\xe2\x82\xac"); + } +} + +static void test_vectors(void) { + intvec v = {0, 0, 0}, w = {0, 0, 0}, c; + int *p; + int i; + bool ok = true; + for (i = 0; i < 1000; i++) tp_push(v, i); + CHECK(v.n == 1000 && tp_last(v) == 999); + for (i = 0; i < 1000; i++) ok = ok && v.p[i] == i; + CHECK(ok); + tp_remove(v, 10, 990); /* 0..9, 990..999 */ + CHECK(v.n == 20 && v.p[10] == 990); + p = tp_push_n(v, 5); /* zeroed although the slots held old elements */ + CHECK(v.n == 25 && p == &v.p[20] && p[0] == 0 && p[4] == 0); + tp_insert(v, 0, -1); + tp_insert(v, v.n, 77); + CHECK(v.p[0] == -1 && v.p[1] == 0 && tp_last(v) == 77 && v.n == 27); + tp_push(w, 5); + tp_append(w, v); + CHECK(w.n == 28 && w.p[0] == 5 && w.p[1] == -1); + tp_clone(c, w); + CHECK(c.p != w.p && c.n == w.n && memcmp(c.p, w.p, c.n * sizeof(int)) == 0); + { + intvec e = {0, 0, 0}; + tp_append(w, e); + CHECK(w.n == 28); + p = tp_push_n(e, 0); + CHECK(e.n == 0); + (void)p; + } +} + +static void test_buf(void) { + tp_buf b = {0, 0, 0}; + tp_str first, second; + size_t i; + CHECK(tp_buf_done(&b).n == 0); + tp_buf_cstr(&b, "abc"); + tp_buf_byte(&b, '-'); + tp_buf_rune(&b, 0x20AC); + tp_buf_int(&b, -12); + { + tp_rune rs[2] = {'x', 0x1F600}; + tp_runes r; + r.p = rs; + r.n = 2; + tp_buf_runes(&b, r); + } + first = tp_buf_done(&b); + STR_IS(first, "abc-\xe2\x82\xac-12x\xf0\x9f\x98\x80"); + CHECK(first.p[first.n] == '\0'); + /* Appending after done leaves the returned string, and its NUL, alone. */ + for (i = 0; i < 100; i++) tp_buf_byte(&b, 'z'); + CHECK(first.p[first.n] == '\0'); + STR_IS(first, "abc-\xe2\x82\xac-12x\xf0\x9f\x98\x80"); + second = tp_buf_done(&b); + CHECK(second.n == first.n + 100 && second.p[second.n] == '\0'); + tp_buf_bytes(&b, "", 0); + CHECK(tp_buf_done(&b).n == second.n); +} + +static void test_map(void) { + tp_map m = {0, 0, 0}; + tp_strvec keys = {0, 0, 0}; + int64_t v = 0; + size_t i; + bool ok = true; + CHECK(!tp_map_get(&m, TP_S("x"), &v) && !tp_map_has(&m, TP_EMPTY)); + for (i = 0; i < 5000; i++) tp_push(keys, tp_itoa((int64_t)i)); + for (i = 0; i < 5000; i++) tp_map_put(&m, keys.p[i], (int64_t)i * 3); + tp_map_put(&m, TP_S("17"), -1); /* overwrite */ + tp_map_put(&m, TP_EMPTY, 42); + CHECK(m.n == 5001); + for (i = 0; i < 5000; i++) { + ok = ok && tp_map_get(&m, keys.p[i], &v) && v == (i == 17 ? -1 : (int64_t)i * 3); + } + CHECK(ok); + CHECK(tp_map_get(&m, TP_EMPTY, &v) && v == 42); + CHECK(!tp_map_has(&m, TP_S("5000")) && tp_map_has(&m, TP_S("4999"))); +} + +static void test_sort(void) { + size_t sizes[] = {0, 1, 2, 7, 8, 9, 16, 17, 100, 1000, 4097}; + size_t si; + for (si = 0; si < TP_COUNT(sizes); si++) { + size_t n = sizes[si], i; + pair *a = (pair *)tp_alloc_array(n, sizeof(pair)); + bool ok = true; + int keys = (int)(si % 3 == 0 ? 3 : 1000); + for (i = 0; i < n; i++) { + a[i].key = (int)(next_rand() % (uint64_t)keys); + a[i].order = (int)i; + } + tp_sort_stable(a, n, sizeof(pair), cmp_pair, NULL); + for (i = 1; i < n; i++) { + ok = ok && + (a[i - 1].key < a[i].key || (a[i - 1].key == a[i].key && a[i - 1].order < a[i].order)); + } + CHECK(ok); + } +} + +static void test_json(void) { + tp_json members_vals[2]; + tp_json_member members[2]; + tp_json obj = tp_json_null(), got; + CHECK(obj.kind == TP_JSON_NULL); + CHECK(tp_json_bool(true).kind == TP_JSON_BOOL && tp_json_bool(true).b); + CHECK(tp_json_num(2.5).kind == TP_JSON_NUMBER && tp_json_num(2.5).num == 2.5); + STR_IS(tp_json_str(TP_S("x")).str, "x"); + members_vals[0] = tp_json_num(1); + members_vals[1] = tp_json_str(TP_S("v")); + members[0].key = TP_S("a"); + members[0].val = members_vals[0]; + members[1].key = TP_S("b"); + members[1].val = members_vals[1]; + obj.kind = TP_JSON_OBJECT; + obj.obj = members; + obj.obj_n = 2; + CHECK(tp_json_get(obj, TP_S("b"), &got) && got.kind == TP_JSON_STRING); + CHECK(!tp_json_get(obj, TP_S("c"), &got)); + CHECK(!tp_json_get(tp_json_num(1), TP_S("a"), &got)); +} + +/* -------------------------------------------------------------------------------------------- */ +/* Once */ + +static tp_once once_a = TP_ONCE_INIT, once_b = TP_ONCE_INIT, once_fail = TP_ONCE_INIT; +static int build_b_calls; + +static void *build_b(void) { + int *v = (int *)tp_alloc(sizeof(int)); + build_b_calls++; + *v = 7; + return v; +} + +static void *build_a(void) { /* nests another once */ + int *b = (int *)tp_once_get(&once_b, build_b); + int *v = (int *)tp_alloc(sizeof(int)); + *v = b == NULL ? -1 : *b * 6; + return v; +} + +static void *build_fail(void) { + (void)tp_alloc_array(SIZE_MAX / 4, 8); + return NULL; +} + +#if defined(_WIN32) +static DWORD WINAPI once_thread(LPVOID arg) { + *(int **)arg = (int *)tp_once_get(&once_a, build_a); + return 0; +} +#else +static void *once_thread(void *arg) { + *(int **)arg = (int *)tp_once_get(&once_a, build_a); + return NULL; +} +#endif + +static void test_once(void) { + int *results[8]; + int i; +#if defined(_WIN32) + HANDLE th[8]; + for (i = 0; i < 8; i++) th[i] = CreateThread(NULL, 0, once_thread, &results[i], 0, NULL); + for (i = 0; i < 8; i++) { + WaitForSingleObject(th[i], INFINITE); + CloseHandle(th[i]); + } +#else + pthread_t th[8]; + for (i = 0; i < 8; i++) CHECK(pthread_create(&th[i], NULL, once_thread, &results[i]) == 0); + for (i = 0; i < 8; i++) pthread_join(th[i], NULL); +#endif + for (i = 0; i < 8; i++) { + CHECK(results[i] != NULL && results[i] == results[0] && *results[i] == 42); + } + CHECK(tp_once_get(&once_a, build_a) == results[0]); + CHECK(build_b_calls >= 1); + CHECK(tp_once_get(&once_fail, build_fail) == NULL); + CHECK(tp_once_get(&once_fail, build_fail) == NULL); /* retried, still fails */ +} + +int main(void) { + static tp_scope s; + test_oom(); + test_arena(); + test_once(); + if (!tp_scope_open(&s)) return 2; + if (setjmp(s.jmp) != 0) { + tp_scope_abort(&s); + fprintf(stderr, "out of memory\n"); + return 2; + } + tp_scope_arm(&s); + test_strings(); + test_runes(); + test_vectors(); + test_buf(); + test_map(); + test_sort(); + test_json(); + tp_scope_close(&s); + tp_arena_free(s.arena); + printf("test_rt: %ld checks, %d failures\n", checks, failures); + return failures == 0 ? 0 : 1; +} diff --git a/c/tests/test_threads.c b/c/tests/test_threads.c new file mode 100644 index 0000000..0e112b6 --- /dev/null +++ b/c/tests/test_threads.c @@ -0,0 +1,367 @@ +/* test_threads.c: concurrent use, as go/concurrency_test.go. A shared trackparse_parser with + * options, a parser without options, the free functions, parse_tracklist_with, apply_edits and + * the JSON door, called from 16 threads at once, must give the same bytes as one thread calling + * them in turn. Build with -DTRACKPARSE_SANITIZE_THREAD=ON to have ThreadSanitizer report any + * race on shared state (the lazily built default tables, the allocator hook). + * + * test_threads ... + * + * The inputs are the parse and parseArtists fixture inputs (without spec/, a few of its own), + * and the JSON door runs every fixture case line. */ +#if !defined(_WIN32) && !defined(_POSIX_C_SOURCE) +#define _POSIX_C_SOURCE 200809L +#endif + +#include +#include + +#if defined(_WIN32) +#include +#else +#include +#endif + +#include "../include/trackparse.h" +#include "../wire/wire.h" +#include "hardening.h" + +#define WORKERS 16 +#define CALLS 9 + +typedef struct item { + const char *s; + size_t n; +} item; + +static item *inputs; +static size_t inputs_n; +static hz_cases cases; +static trackparse_parser *parser, *zero; +static trackparse_tracklist_options *list_options; +static trackparse_format_options *format_options; +static trackparse_edits *edits; +static const char *list_text; + +/* The JSON of every call for input i (NULL where a call does not run for i). */ +typedef struct outputs { + char *out[CALLS]; + size_t len[CALLS]; +} outputs; + +static outputs *want; + +static void keep(outputs *o, int k, trackparse_string *s) { + if (s == NULL) { + fprintf(stderr, "out of memory\n"); + exit(2); + } + o->len[k] = s->str.len; + o->out[k] = (char *)malloc(s->str.len + 1); + if (!o->out[k]) exit(2); + memcpy(o->out[k], s->str.ptr, s->str.len + 1); + trackparse_string_free(s); +} + +static trackparse_track *must_track(trackparse_track *t) { + if (!t) { + fprintf(stderr, "out of memory\n"); + exit(2); + } + return t; +} + +typedef struct wire_arg { + const hz_case *c; + outputs *o; +} wire_arg; + +static void wire_body(void *p) { + wire_arg *a = (wire_arg *)p; + tp_str line, out; + line.p = a->c->line; + line.n = a->c->line_n; + out = tp_wire_line(line); + a->o->len[8] = out.n; + a->o->out[8] = (char *)malloc(out.n + 1); + if (!a->o->out[8]) exit(2); + memcpy(a->o->out[8], out.p, out.n); + a->o->out[8][out.n] = '\0'; +} + +/* One run of every call for input i. */ +static void run(size_t i, outputs *o) { + const item *in = &inputs[i]; + trackparse_track *a, *b, *c; + trackparse_artists *artists; + memset(o, 0, sizeof *o); + a = must_track(trackparse_parser_parse(parser, in->s, in->n)); + b = must_track(trackparse_parser_parse(zero, in->s, in->n)); + c = must_track(trackparse_parse(in->s, in->n)); + keep(o, 0, trackparse_track_to_json(a)); + keep(o, 1, trackparse_track_to_json(b)); + keep(o, 2, trackparse_track_to_json(c)); + artists = trackparse_parser_parse_artists(parser, in->s, in->n); + if (!artists) exit(2); + keep(o, 3, trackparse_artists_to_json(artists)); + trackparse_artists_free(artists); + keep(o, 4, trackparse_format_with(a, format_options)); + trackparse_track_free(a); + trackparse_track_free(b); + trackparse_track_free(c); + if (i % 10 == 0) { + size_t tn = strlen(list_text); + char *text = (char *)malloc(tn + 2 + in->n + 1); + trackparse_tracklist *l; + trackparse_edit_result *r; + if (!text) exit(2); + memcpy(text, list_text, tn); + memcpy(text + tn, "\r\n", 2); + memcpy(text + tn + 2, in->s, in->n); + l = trackparse_parse_tracklist_with(text, tn + 2 + in->n, list_options); + if (!l) exit(2); + keep(o, 5, trackparse_tracklist_to_json(l)); + trackparse_tracklist_free(l); + text[tn] = '\n'; + r = trackparse_apply_edits(text, tn + 1, edits); + if (!r) exit(2); + keep(o, 6, trackparse_edit_result_to_json(r)); + trackparse_edit_result_free(r); + /* The same text without the input, through the parser-free list function. */ + l = trackparse_parse_tracklist(text, tn); + if (!l) exit(2); + keep(o, 7, trackparse_tracklist_to_json(l)); + trackparse_tracklist_free(l); + free(text); + } + if (cases.n > 0) { + wire_arg w; + w.c = &cases.items[i % cases.n]; + w.o = o; + hz_scoped(wire_body, &w); + } +} + +static void free_outputs(outputs *o) { + for (int k = 0; k < CALLS; k++) free(o->out[k]); +} + +typedef struct worker { + int g; + int failures; +} worker; + +static void work(worker *w) { + for (size_t k = 0; k < inputs_n && w->failures == 0; k++) { + /* Each thread starts at its own offset, so different inputs run side by side. */ + size_t i = (k + (size_t)w->g * inputs_n / WORKERS) % inputs_n; + outputs got; + run(i, &got); + for (int c = 0; c < CALLS; c++) { + if ((got.out[c] == NULL) != (want[i].out[c] == NULL) || + (got.out[c] && + (got.len[c] != want[i].len[c] || memcmp(got.out[c], want[i].out[c], got.len[c]) != 0))) { + fprintf(stderr, "thread %d, input %s, call %d: got\n%s\nwant\n%s\n", w->g, inputs[i].s, c, + got.out[c] ? got.out[c] : "(none)", want[i].out[c] ? want[i].out[c] : "(none)"); + w->failures++; + break; + } + } + free_outputs(&got); + } +} + +/* The cold start: the first calls of the process, from every thread at once, race to build the + * default tables (tp_once_get). Each thread keeps its JSON; all must agree. */ +static const char cold_list[] = "00:00 Intro\n01:02.5 Noisia - Stigma (VIP)\n**02:00** Break"; +static outputs cold[WORKERS]; + +static void cold_work(worker *w) { + outputs *o = &cold[w->g]; + trackparse_track *t = must_track( + trackparse_parse("Noisia feat. Foreign Beggars - Shellshock", TRACKPARSE_NUL_TERMINATED)); + trackparse_tracklist *l = trackparse_parse_tracklist(cold_list, TRACKPARSE_NUL_TERMINATED); + trackparse_artists *a = trackparse_parse_artists("A & B feat. C", TRACKPARSE_NUL_TERMINATED); + if (!l || !a) exit(2); + memset(o, 0, sizeof *o); + keep(o, 0, trackparse_track_to_json(t)); + keep(o, 1, trackparse_tracklist_to_json(l)); + keep(o, 2, trackparse_artists_to_json(a)); + keep(o, 3, trackparse_normalize("A \xe2\x80\x94 B", TRACKPARSE_NUL_TERMINATED)); + trackparse_track_free(t); + trackparse_tracklist_free(l); + trackparse_artists_free(a); +} + +#if defined(_WIN32) +static DWORD WINAPI thread_main(LPVOID p) { + work((worker *)p); + return 0; +} +static DWORD WINAPI cold_main(LPVOID p) { + cold_work((worker *)p); + return 0; +} +typedef HANDLE thread_t; +static bool start_thread(thread_t *t, LPTHREAD_START_ROUTINE f, worker *w) { + *t = CreateThread(NULL, 0, f, w, 0, NULL); + return *t != NULL; +} +static void join_thread(thread_t t) { + WaitForSingleObject(t, INFINITE); + CloseHandle(t); +} +#else +static void *thread_main(void *p) { + work((worker *)p); + return NULL; +} +static void *cold_main(void *p) { + cold_work((worker *)p); + return NULL; +} +typedef pthread_t thread_t; +static bool start_thread(thread_t *t, void *(*f)(void *), worker *w) { + return pthread_create(t, NULL, f, w) == 0; +} +static void join_thread(thread_t t) { pthread_join(t, NULL); } +#endif + +static int cold_start(void) { + thread_t th[WORKERS]; + worker w[WORKERS]; + int failures = 0; + for (int g = 0; g < WORKERS; g++) { + w[g].g = g; + w[g].failures = 0; + if (!start_thread(&th[g], cold_main, &w[g])) exit(2); + } + for (int g = 0; g < WORKERS; g++) join_thread(th[g]); + for (int g = 1; g < WORKERS; g++) { + for (int k = 0; k < 4; k++) { + if (strcmp(cold[g].out[k], cold[0].out[k]) != 0) { + fprintf(stderr, "cold start: thread %d, call %d differs:\n%s\n%s\n", g, k, cold[g].out[k], + cold[0].out[k]); + failures++; + } + } + } + for (int g = 0; g < WORKERS; g++) free_outputs(&cold[g]); + return failures; +} + +static const char *const builtin[] = { + "Chase & Status x Camo & Krooked - Track (Alix Perez Rerub)", + "01. Wilkinson ft. Becky Hill & Tom Cane - Afterglow (Sub Focus VIP Remix) [Official Video]", + "Noisia - Stigma (VIP", + "\"Numb\" by Linkin Park", + "07_Burial_-_Archangel.mp3", + "Sub Focus, Wilkinson & Dimension feat. Kojo - Out Now (Extended Mix) [HD]", +}; + +#define NT TRACKPARSE_NUL_TERMINATED + +static void setup(void) { + trackparse_parse_options *o = trackparse_parse_options_new(); + bool ok = o != NULL; + ok = ok && trackparse_parse_options_add_known_artist(o, "Chase & Status", NT); + ok = ok && trackparse_parse_options_add_known_artist(o, "Camo & Krooked", NT); + ok = ok && trackparse_parse_options_add_known_artist(o, "Above & Beyond", NT); + ok = ok && trackparse_parse_options_set_split_and(o, TRACKPARSE_SPLIT_AND_ALWAYS); + ok = ok && trackparse_parse_options_add_version_head(o, "rerub", TRACKPARSE_NUL_TERMINATED, + "rework", TRACKPARSE_NUL_TERMINATED); + ok = ok && trackparse_parse_options_add_junk(o, "out now", TRACKPARSE_NUL_TERMINATED, "promo", + TRACKPARSE_NUL_TERMINATED); + ok = ok && trackparse_parse_options_add_feat_marker(o, "w/", TRACKPARSE_NUL_TERMINATED); + parser = ok ? trackparse_parser_new(o) : NULL; + zero = trackparse_parser_new(NULL); + trackparse_parse_options_free(o); + + list_options = trackparse_tracklist_options_new(); + ok = parser && zero && list_options; + ok = ok && trackparse_tracklist_options_add_known_artist(list_options, "Chase & Status", + TRACKPARSE_NUL_TERMINATED); + ok = ok && trackparse_tracklist_options_set_audio_seconds(list_options, 3600); + ok = ok && trackparse_tracklist_options_add_marker_word(list_options, "drop", NT); + + format_options = trackparse_format_options_new(); + ok = ok && format_options; + ok = ok && trackparse_format_options_set_feat(format_options, TRACKPARSE_FEAT_TITLE); + ok = ok && trackparse_format_options_set_feat_marker(format_options, "ft.", NT); + + edits = trackparse_edits_new(); + ok = ok && edits; + ok = ok && trackparse_edits_set_time(edits, 7, 4262); + ok = ok && trackparse_edits_shift_from(edits, 45, 2); + ok = ok && trackparse_edits_sort_by_time(edits); + ok = ok && trackparse_edits_insert(edits, 0, "00:00 Intro", TRACKPARSE_NUL_TERMINATED); + ok = ok && trackparse_edits_delete(edits, 4); + if (!ok) { + fprintf(stderr, "out of memory in setup\n"); + exit(2); + } + list_text = + "Hour 2\r\n48:20 Noisia - Stigma\r\n52:47 Mefjus & Kasra - Bandwagon (Phace Remix)\r\n" + "03:00 Drop\r\n59:31 Alix Perez - Fade Away\r\n01:07:44 Chase & Status - Baddadan\r\n" + "00:11:02 Current Value feat. Teddy Killerz - Payload\r\n1:02:03 Hybris - Spinning Top"; +} + +int main(int argc, char **argv) { +#ifdef TRACKPARSE_SANITIZED + size_t limit = 300; +#else + size_t limit = 2000; +#endif + worker workers[WORKERS]; + double start; + int failures = cold_start(); + setup(); + cases = hz_load_cases(argc - 1, argv + 1); + inputs = (item *)malloc((limit + TP_COUNT(builtin)) * sizeof *inputs); + if (!inputs) return 2; + for (size_t i = 0; i < TP_COUNT(builtin); i++) { + inputs[inputs_n].s = builtin[i]; + inputs[inputs_n++].n = strlen(builtin[i]); + } + for (size_t i = 0; i < cases.n && inputs_n < limit; i++) { + if (strcmp(cases.items[i].fn, "parse") == 0 || strcmp(cases.items[i].fn, "parseArtists") == 0) { + inputs[inputs_n].s = cases.items[i].input; + inputs[inputs_n++].n = cases.items[i].input_n; + } + } + + start = hz_now(); + want = (outputs *)calloc(inputs_n, sizeof *want); + if (!want) return 2; + for (size_t i = 0; i < inputs_n; i++) run(i, &want[i]); + printf("sequential: %lu inputs, %.3f s\n", (unsigned long)inputs_n, hz_now() - start); + + start = hz_now(); + { + thread_t th[WORKERS]; + for (int g = 0; g < WORKERS; g++) { + workers[g].g = g; + workers[g].failures = 0; + if (!start_thread(&th[g], thread_main, &workers[g])) return 2; + } + for (int g = 0; g < WORKERS; g++) join_thread(th[g]); + } + for (int g = 0; g < WORKERS; g++) failures += workers[g].failures; + printf("%d threads: %lu inputs each, %.3f s\n", WORKERS, (unsigned long)inputs_n, + hz_now() - start); + + for (size_t i = 0; i < inputs_n; i++) free_outputs(&want[i]); + free(want); + free(inputs); + hz_free_cases(&cases); + trackparse_parser_free(parser); + trackparse_parser_free(zero); + trackparse_tracklist_options_free(list_options); + trackparse_format_options_free(format_options); + trackparse_edits_free(edits); + if (failures) { + fprintf(stderr, "threads: %d mismatches\n", failures); + return 1; + } + printf("threads: ok\n"); + return 0; +} diff --git a/c/tests/test_unicode.c b/c/tests/test_unicode.c new file mode 100644 index 0000000..67cd8db --- /dev/null +++ b/c/tests/test_unicode.c @@ -0,0 +1,430 @@ +/* test_unicode.c: unicode.c against Node, the reference engine (go/unicode_test.go). + * + * tests/data/unicode/cases.jsonl is a committed sample (under 300 KB) written by + * scripts/gen_unicode.mjs from Node, so the test needs no Node. `gen_unicode.mjs --check` keeps it + * in step with the tables. The exhaustive check (every code point, every ordered pair of + * non-starters, ...) is too big to commit: with TRACKPARSE_UNICODE_FULL=1 the test runs + * `node scripts/gen_unicode.mjs --cases ` and compares everything it writes. + * + * The c/ directory is found from __FILE__, or from TRACKPARSE_C_DIR when set. + */ +#include +#include +#include +#include + +#include "../src/unicode.h" +#include "../src/unicode_gen.h" +#include "../src/words.h" +#include "../wire/json_read.h" + +static int failures = 0; + +/* ------------------------------------------------------------------------------------------ */ +/* Helpers */ + +/* Runs fn inside an armed scope with a fresh arena, freed afterwards. */ +static bool scoped(void (*fn)(void *), void *ctx) { + tp_scope s; + if (!tp_scope_open(&s)) return false; + if (setjmp(s.jmp) != 0) { + tp_scope_abort(&s); + return false; + } + tp_scope_arm(&s); + fn(ctx); + tp_scope_close(&s); + tp_arena_free(s.arena); + return true; +} + +/* A string with code points written as \u{...} outside printable ASCII. */ +static void put_quoted(tp_str s) { + putchar('"'); + for (size_t i = 0; i < s.n;) { + size_t size; + tp_str rest = {s.p + i, s.n - i}; + tp_rune r = tp_decode_rune(rest, &size); + if (size == 1 && (unsigned char)s.p[i] >= 0x80) { + printf("\\x%02x", (unsigned char)s.p[i]); + } else if (r >= 0x20 && r < 0x7f && r != '"' && r != '\\') { + putchar((int)r); + } else { + printf("\\u{%x}", (unsigned)r); + } + i += size; + } + putchar('"'); +} + +static void check_str(const char *what, tp_str in, tp_str got, tp_str want) { + if (tp_str_eq(got, want)) return; + if (++failures > 20) return; + printf("FAIL %s(", what); + put_quoted(in); + printf(") = "); + put_quoted(got); + printf(", want "); + put_quoted(want); + printf("\n"); +} + +static void check(bool ok, const char *what) { + if (ok) return; + if (++failures <= 20) printf("FAIL %s\n", what); +} + +static char *read_file(const char *path, size_t *n) { + FILE *f = fopen(path, "rb"); + if (!f) return NULL; + size_t cap = 1 << 16, len = 0; + char *buf = malloc(cap); + for (;;) { + if (len == cap) { + cap *= 2; + char *nb = realloc(buf, cap); + if (!nb) { + free(buf); + fclose(f); + return NULL; + } + buf = nb; + } + size_t got = fread(buf + len, 1, cap - len, f); + if (got == 0) break; + len += got; + } + fclose(f); + *n = len; + return buf; +} + +/* The c/ directory: TRACKPARSE_C_DIR, else __FILE__ without "tests/.c". */ +static void c_dir(char *out, size_t cap) { + const char *env = getenv("TRACKPARSE_C_DIR"); + if (env && *env) { + snprintf(out, cap, "%s", env); + return; + } + const char *file = __FILE__; + const char *cut = strstr(file, "tests/test_unicode.c"); + if (!cut) cut = strstr(file, "tests\\test_unicode.c"); + size_t n = cut ? (size_t)(cut - file) : 0; + if (n == 0) { + snprintf(out, cap, "."); + } else { + snprintf(out, cap, "%.*s", (int)(n - 1), file); + } +} + +/* ------------------------------------------------------------------------------------------ */ +/* The cases file */ + +typedef struct case_ctx { + tp_str line; + int groups_n; + char groups[16][16]; + long counts[16]; + long checks; + bool bad; +} case_ctx; + +static void run_case(void *p) { + case_ctx *c = p; + tp_json v, g, s, x; + if (!tp_json_parse(c->line, &v) || !tp_json_get(v, TP_S("g"), &g) || + !tp_json_get(v, TP_S("s"), &s)) { + c->bad = true; + return; + } + int k; + for (k = 0; k < c->groups_n; k++) { + if (tp_str_eq_c(g.str, c->groups[k])) break; + } + if (k == c->groups_n && k < 16) { + snprintf(c->groups[k], sizeof c->groups[k], "%.*s", TP_FMT(g.str)); + c->groups_n++; + } + if (k < 16) c->counts[k]++; + tp_str in = s.str; + check_str("nfc", in, tp_nfc(in), tp_json_get(v, TP_S("c"), &x) ? x.str : in); + check_str("nfd", in, tp_nfd(in), tp_json_get(v, TP_S("d"), &x) ? x.str : in); + check_str("js_to_lower", in, tp_js_to_lower(in), tp_json_get(v, TP_S("l"), &x) ? x.str : in); + c->checks += 3; + if (tp_json_get(v, TP_S("k"), &x)) { + size_t size; + tp_rune r = tp_decode_rune(in, &size); + int flags = (int)x.num; + if (tp_is_letter(r) != ((flags & 1) != 0) || tp_is_upper_letter(r) != ((flags & 2) != 0)) { + if (++failures <= 20) { + printf("FAIL categories of U+%04X: want flags %d\n", (unsigned)r, flags); + } + } + c->checks += 2; + } +} + +static void check_cases(const char *path) { + FILE *f = fopen(path, "rb"); + if (!f) { + printf("FAIL %s: cannot open\n", path); + failures++; + return; + } + static char line[1 << 20]; + case_ctx c; + memset(&c, 0, sizeof c); + long total = 0; + while (fgets(line, sizeof line, f)) { + size_t n = strlen(line); + while (n > 0 && (line[n - 1] == '\n' || line[n - 1] == '\r')) n--; + if (n == 0) continue; + c.line.p = line; + c.line.n = n; + c.bad = false; + if (!scoped(run_case, &c) || c.bad) { + printf("FAIL %s: cannot read line %ld\n", path, total + 1); + failures++; + break; + } + total++; + } + fclose(f); + printf("%s: %ld cases, %ld checks, %d failures:", path, total, c.checks, failures); + for (int k = 0; k < c.groups_n; k++) printf(" %s=%ld", c.groups[k], c.counts[k]); + printf("\n"); + if (total == 0) { + printf("FAIL %s: no cases\n", path); + failures++; + } +} + +static void test_sample(const char *dir) { + char path[4096]; + snprintf(path, sizeof path, "%s/tests/data/unicode/cases.jsonl", dir); + check_cases(path); +} + +static void test_full(const char *dir) { + const char *env = getenv("TRACKPARSE_UNICODE_FULL"); + if (!env || strcmp(env, "1") != 0) { + printf("skip full sweep: set TRACKPARSE_UNICODE_FULL=1 to compare every code point and more " + "against Node\n"); + return; + } + const char *out = "trackparse-unicode-full"; + char cmd[8192]; + snprintf(cmd, sizeof cmd, "node \"%s/scripts/gen_unicode.mjs\" --cases %s", dir, out); + if (system(cmd) != 0) { + printf("FAIL %s\n", cmd); + failures++; + return; + } + char path[4096]; + snprintf(path, sizeof path, "%s/unicode-version.txt", out); + size_t n = 0; + char *v = read_file(path, &n); + while (v && n > 0 && (v[n - 1] == '\n' || v[n - 1] == '\r')) n--; + if (!v || n != strlen(TP_UNICODE_VERSION) || memcmp(v, TP_UNICODE_VERSION, n) != 0) { + printf("FAIL this Node has Unicode %.*s, the tables are Unicode %s: compare with the same " + "version\n", + v ? (int)n : 0, v ? v : "", TP_UNICODE_VERSION); + failures++; + free(v); + return; + } + free(v); + snprintf(path, sizeof path, "%s/cases.jsonl", out); + check_cases(path); + /* Clean up (remove() deletes an empty directory on POSIX; elsewhere it stays). */ + remove(path); + snprintf(path, sizeof path, "%s/unicode-version.txt", out); + remove(path); + remove(out); +} + +/* ------------------------------------------------------------------------------------------ */ +/* Examples */ + +typedef struct pair { + const char *in, *want; +} pair; + +static tp_str S(const char *s) { return tp_str_c(s); } + +static void examples(void *unused) { + (void)unused; + static const pair lower[] = { + {"", ""}, + {"abc", "abc"}, + {"ABC Def", "abc def"}, + {"\xce\x9f\xce\x94\xce\x9f\xce\xa3", "\xce\xbf\xce\xb4\xce\xbf\xcf\x82"}, /* final sigma */ + {"\xce\x9f\xce\x94\xce\x9f\xce\xa3" + "A", + "\xce\xbf\xce\xb4\xce\xbf\xcf\x83" + "a"}, + {"\xce\xa3", "\xcf\x83"}, /* nothing cased before */ + {"A\xce\xa3.", "a\xcf\x82."}, /* "." is case-ignorable */ + {"\xc4\xb0", "i\xcc\x87"}, /* several code points */ + {"\xc3\x89" + "COLE", + "\xc3\xa9" + "cole"}, /* Latin-1 */ + {"\xf0\x90\x90\x80", "\xf0\x90\x90\xa8"}, /* astral (Deseret) */ + {"a\xff" + "B", + "a\xef\xbf\xbd" + "b"}, /* invalid UTF-8 */ + }; + for (size_t i = 0; i < TP_COUNT(lower); i++) { + check_str("js_to_lower", S(lower[i].in), tp_js_to_lower(S(lower[i].in)), S(lower[i].want)); + } + + static const struct { + const char *in, *c, *d; + } norm[] = { + {"", "", ""}, + {"abc", "abc", "abc"}, + {"e\xcc\x81", "\xc3\xa9", "e\xcc\x81"}, + {"\xc3\xa9", "\xc3\xa9", "e\xcc\x81"}, + /* reordering, then composition */ + {"\xe1\xb8\x8b\xcc\xa3", "\xe1\xb8\x8d\xcc\x87", "d\xcc\xa3\xcc\x87"}, + {"q\xcc\x87\xcc\xa3", "q\xcc\xa3\xcc\x87", "q\xcc\xa3\xcc\x87"}, /* no composite */ + {"\xe2\x84\xab", "\xc3\x85", "A\xcc\x8a"}, /* singleton */ + {"\xcd\x84", "\xcc\x88\xcc\x81", "\xcc\x88\xcc\x81"}, /* non-starter decomp */ + {"\xea\xb0\x80", "\xea\xb0\x80", "\xe1\x84\x80\xe1\x85\xa1"}, /* Hangul LV */ + {"\xe1\x84\x80\xe1\x85\xa1\xe1\x86\xa8", "\xea\xb0\x81", + "\xe1\x84\x80\xe1\x85\xa1\xe1\x86\xa8"}, /* Hangul L V T */ + {"\xea\xb0\x80\xe1\x86\xa7", "\xea\xb0\x80\xe1\x86\xa7", + "\xe1\x84\x80\xe1\x85\xa1\xe1\x86\xa7"}, /* T base does not compose */ + {"\xe0\xad\x87\xe0\xac\xbe", "\xe0\xad\x8b", "\xe0\xad\x87\xe0\xac\xbe"}, /* two starters */ + {"a\xff" + "e\xcc\x81", + "a\xef\xbf\xbd\xc3\xa9", + "a\xef\xbf\xbd" + "e\xcc\x81"}, /* invalid */ + {"\xcc\x81" + "e", + "\xcc\x81" + "e", + "\xcc\x81" + "e"}, /* leading mark */ + {"A\xcc\x81\xcc\x81", "\xc3\x81\xcc\x81", "A\xcc\x81\xcc\x81"}, /* second mark blocked */ + {"\xf0\x9d\x85\x9e", "\xf0\x9d\x85\x97\xf0\x9d\x85\xa5", + "\xf0\x9d\x85\x97\xf0\x9d\x85\xa5"}, /* excluded composite */ + }; + for (size_t i = 0; i < TP_COUNT(norm); i++) { + check_str("nfc", S(norm[i].in), tp_nfc(S(norm[i].in)), S(norm[i].c)); + check_str("nfd", S(norm[i].in), tp_nfd(S(norm[i].in)), S(norm[i].d)); + } + + static const struct { + tp_rune r; + bool letter, upper; + } cats[] = + { + {'a', true, false}, {'Z', true, true}, {'1', false, false}, + {'_', false, false}, {0xc9, true, true}, {0xe9, true, false}, + {0x1c5, true, false}, /* Lt is a letter, not Lu */ + {0x2160, false, false}, /* Nl: not L */ + {0x0301, false, false}, {0x4e00, true, false}, {0x10400, true, true}, + {-1, false, false}, {0x110000, false, false}, {0xfffd, false, false}, + }; + for (size_t i = 0; i < TP_COUNT(cats); i++) { + if (tp_is_letter(cats[i].r) != cats[i].letter || + tp_is_upper_letter(cats[i].r) != cats[i].upper) { + if (++failures <= 20) printf("FAIL categories of U+%04X\n", (unsigned)cats[i].r); + } + } +} + +/* Normalized input comes back as the same string, without allocating (Go's AllocsPerRun test). */ +static void no_copy_when_normalized(void *unused) { + (void)unused; + static const char *nfc_inputs[] = { + "Noisia feat. Foreign Beggars - Shellshock (Original Mix)", + "Bj\xc3\xb6rk - J\xc3\xb3ga", + "\xd0\xa1\xd0\xbf\xd0\xbb\xd0\xb8\xd0\xbd - \xd0\x93\xd1\x80\xd0\xb0\xd0\xbd\xd0\xb0\xd1\x82", + "\xec\x95\x84\xec\x9d\xb4\xec\x9c\xa0 - \xec\xa2\x8b\xec\x9d\x80 \xeb\x82\xa0", + }; + for (size_t i = 0; i < TP_COUNT(nfc_inputs); i++) { + tp_str s = S(nfc_inputs[i]); + check(tp_nfc(s).p == s.p, "nfc of NFC text is the input itself"); + } + tp_str ascii = S("Noisia feat. Foreign Beggars - Shellshock"); + check(tp_nfd(ascii).p == ascii.p, "nfd of ASCII is the input itself"); + tp_str lower = S("noisia"); + check(tp_js_to_lower(lower).p == lower.p, "js_to_lower of lowercase ASCII is the input itself"); + size_t before = tp_arena_bytes(tp_arena_current()); + for (int k = 0; k < 1000; k++) { + (void)tp_nfc(S(nfc_inputs[1])); + (void)tp_nfd(ascii); + } + check(tp_arena_bytes(tp_arena_current()) == before, "no allocation for normalized input"); +} + +/* xorshift64*, a small seeded PRNG. */ +static uint64_t rng_state = 1; +static uint64_t rng_next(void) { + rng_state ^= rng_state >> 12; + rng_state ^= rng_state << 25; + rng_state ^= rng_state >> 27; + return rng_state * 0x2545F4914F6CDD1DULL; +} +static size_t rng_int(size_t n) { return (size_t)(rng_next() % n); } + +/* Normalization and lowercasing are total, and NFC/NFD have the algebraic properties of UAX #15 + * on random input, invalid UTF-8 included. */ +static void total_and_stable(void *unused) { + (void)unused; + static const tp_rune pool[] = {'a', 'A', 'e', 0x3a3, 0x301, 0x323, 0x345, 0x334, + 0xe9, 0x1e0b, 0x1100, 0x1161, 0x11a8, 0xac00, 0x212b, 0x344, + 0xf900, 0x1d15e, 0xb47, 0xb3e, 0x130, 0x2e, 0x1f600}; + rng_state = 0x9e3779b97f4a7c15ULL; + for (int i = 0; i < 20000; i++) { + tp_buf b = {0}; + for (size_t k = rng_int(16); k > 0; k--) { + if (rng_int(10) == 0) { + tp_buf_byte(&b, (char)(0x80 + rng_int(0x80))); /* a stray byte */ + continue; + } + tp_buf_rune(&b, pool[rng_int(TP_COUNT(pool))]); + } + tp_str s = tp_buf_done(&b); + tp_str c = tp_nfc(s), d = tp_nfd(s); + (void)tp_js_to_lower(s); + if (!tp_utf8_valid(c) || !tp_utf8_valid(d)) { + check(false, "invalid UTF-8 out of nfc/nfd"); + return; + } + if (!tp_str_eq(tp_nfc(c), c) || !tp_str_eq(tp_nfd(d), d) || !tp_str_eq(tp_nfc(d), c) || + !tp_str_eq(tp_nfd(c), d)) { + printf("FAIL not stable: "); + put_quoted(s); + printf("\n"); + failures++; + return; + } + } + /* A long run of marks in reverse class order takes the stable sort path. */ + tp_str long_run = tp_concat(TP_S("a"), tp_repeat(TP_S("\xcc\x81\xcc\xa3\xcd\x85\xcc\xb4"), 2500)); + tp_str got = tp_nfd(long_run); + check(tp_has_prefix(got, TP_S("a\xcc\xb4\xcc\xb4")) && tp_str_eq(tp_nfd(got), got), + "long run of marks ordered"); +} + +int main(void) { + char dir[2048]; + c_dir(dir, sizeof dir); + check(scoped(examples, NULL), "examples ran"); + check(scoped(no_copy_when_normalized, NULL), "no-copy test ran"); + check(scoped(total_and_stable, NULL), "random test ran"); + test_sample(dir); + test_full(dir); + if (failures) { + printf("test_unicode: %d failures\n", failures); + return 1; + } + printf("test_unicode: ok\n"); + return 0; +} diff --git a/c/tools/dump.c b/c/tools/dump.c new file mode 100644 index 0000000..64e4c3f --- /dev/null +++ b/c/tools/dump.c @@ -0,0 +1,104 @@ +/* dump.c: the C side of the cross-port diff (scripts/compare-ports.mjs, scripts/fuzz-ports.mjs): + * JSONL in, JSON out, the protocol of go/internal/cmd/dump. + * + * Each stdin line is an object {"fn", "input", "options", "formatOptions", "edits"} as in the + * shared fixtures; each stdout line is the JSON result of that call, written as the JavaScript + * package writes it. A line that is not a JSON object gives null. Non-finite numbers travel as + * 1e999 / -1e999, which the reader takes as infinity. A trailing CR is dropped with the LF. + * + * trackparse-dump < cases.jsonl > results.jsonl + * + * Each line runs in its own arena scope. Exit status 1 on a read or write error. + */ +#include +#include + +#ifdef _WIN32 +#include +#include +#endif + +#include "../wire/wire.h" + +/* One line through the JSON door, written with its newline; false on a write error. */ +static bool dump_line(const char *p, size_t n) { + tp_scope s; + tp_str line, out; + bool ok; + if (!tp_scope_open(&s)) { + fprintf(stderr, "dump: out of memory\n"); + exit(1); + } + if (setjmp(s.jmp) != 0) { + tp_scope_abort(&s); + fprintf(stderr, "dump: out of memory\n"); + exit(1); + } + tp_scope_arm(&s); + line.p = p; + line.n = n; + out = tp_wire_line(line); + ok = fwrite(out.p, 1, out.n, stdout) == out.n && fputc('\n', stdout) != EOF; + tp_scope_close(&s); + tp_arena_free(s.arena); + return ok; +} + +int main(void) { + char *buf = NULL; + size_t start = 0, len = 0, cap = 0; /* the unread bytes are buf[start, len) */ + bool eof = false; +#ifdef _WIN32 + (void)_setmode(_fileno(stdin), _O_BINARY); + (void)_setmode(_fileno(stdout), _O_BINARY); +#endif + while (!eof || start < len) { + char *nl = start < len ? (char *)memchr(buf + start, '\n', len - start) : NULL; + if (!nl && !eof) { + size_t got; + /* Keep only the unread bytes, then make room. */ + if (start > 0) { + memmove(buf, buf + start, len - start); + len -= start; + start = 0; + } + if (cap - len < 65536) { + size_t ncap = cap ? cap * 2 : 1 << 16; + char *nbuf = (char *)realloc(buf, ncap); + if (!nbuf) { + fprintf(stderr, "dump: out of memory\n"); + return 1; + } + buf = nbuf; + cap = ncap; + } + got = fread(buf + len, 1, cap - len, stdin); + len += got; + if (got == 0) { + if (ferror(stdin)) { + fprintf(stderr, "dump: read error\n"); + return 1; + } + eof = true; + } + continue; + } + { + /* A line: up to the LF, or the rest of the input at the end. */ + size_t end = nl ? (size_t)(nl - buf) : len; + size_t n = end - start; + if (n > 0 && buf[start + n - 1] == '\r') n--; + if (!dump_line(buf + start, n)) { + fprintf(stderr, "dump: write error\n"); + return 1; + } + start = nl ? end + 1 : len; + } + } + free(buf); + if (fflush(stdout) != 0) { + fprintf(stderr, "dump: write error\n"); + return 1; + } + return 0; +} diff --git a/c/trackparse.pc.in b/c/trackparse.pc.in new file mode 100644 index 0000000..f225b28 --- /dev/null +++ b/c/trackparse.pc.in @@ -0,0 +1,12 @@ +prefix=@trackparse_pc_prefix@ +exec_prefix=${prefix} +libdir=@trackparse_pc_LIBDIR@ +includedir=@trackparse_pc_INCLUDEDIR@ + +Name: trackparse +Description: Turn messy track names into structured data (C library, with a C++17 header) +URL: https://4matic.github.io/trackparse/ +Version: @PROJECT_VERSION@ +Cflags: -I${includedir}@trackparse_pc_cflags@ +Libs: -L${libdir} -ltrackparse +Libs.private: @trackparse_pc_libs_private@ diff --git a/c/wire/json_read.c b/c/wire/json_read.c new file mode 100644 index 0000000..b76eaa8 --- /dev/null +++ b/c/wire/json_read.c @@ -0,0 +1,278 @@ +/* json_read.c: the JSON reader of the wire door, a translation of the reader in go/json.go + * (parseJSON, jsonReader). The recursion is bounded by TP_JSON_MAX_DEPTH. */ +#include "json_read.h" + +#include "../src/words.h" /* tp_sanitize */ + +typedef TP_VEC(tp_json) tp_jsonvec; +typedef TP_VEC(tp_json_member) tp_json_membervec; + +typedef struct reader { + tp_str s; + size_t at; + int depth; +} reader; + +/* The byte at the cursor, or 0 at the end. */ +static unsigned char peek(const reader *r) { + return r->at < r->s.n ? (unsigned char)r->s.p[r->at] : 0; +} + +static void ws(reader *r) { + while (r->at < r->s.n) { + char c = r->s.p[r->at]; + if (c != ' ' && c != '\t' && c != '\n' && c != '\r') return; + r->at++; + } +} + +static bool eat(reader *r, const char *word) { + size_t n = strlen(word); + if (r->s.n - r->at >= n && memcmp(r->s.p + r->at, word, n) == 0) { + r->at += n; + return true; + } + return false; +} + +/* hex4 reads four hex digits. */ +static bool hex4(reader *r, int32_t *out) { + int32_t n = 0; + if (r->s.n - r->at < 4) return false; + for (size_t i = 0; i < 4; i++) { + unsigned char c = (unsigned char)r->s.p[r->at + i]; + int32_t d; + if (c >= '0' && c <= '9') { + d = c - '0'; + } else if (c >= 'a' && c <= 'f') { + d = c - 'a' + 10; + } else if (c >= 'A' && c <= 'F') { + d = c - 'A' + 10; + } else { + return false; + } + n = n << 4 | d; + } + r->at += 4; + *out = n; + return true; +} + +/* utf8.AppendRune: a surrogate (not a scalar value) is written as U+FFFD. */ +static void append_rune(tp_buf *b, int32_t cp) { + if (cp >= 0xd800 && cp < 0xe000) cp = 0xfffd; + tp_buf_rune(b, cp); +} + +static bool read_string(reader *r, tp_str *out) { + tp_buf b = {0}; + if (peek(r) != '"') return false; + r->at++; + for (;;) { + char c; + if (r->at >= r->s.n) return false; + c = r->s.p[r->at++]; + if (c == '"') { + *out = tp_buf_done(&b); + return true; + } + if (c != '\\') { + tp_buf_byte(&b, c); + continue; + } + if (r->at >= r->s.n) return false; + c = r->s.p[r->at++]; + switch (c) { + case 'n': + tp_buf_byte(&b, '\n'); + break; + case 'r': + tp_buf_byte(&b, '\r'); + break; + case 't': + tp_buf_byte(&b, '\t'); + break; + case 'b': + tp_buf_byte(&b, '\b'); + break; + case 'f': + tp_buf_byte(&b, '\f'); + break; + case 'u': { + int32_t hi, cp; + if (!hex4(r, &hi)) return false; + cp = hi; + if (hi >= 0xd800 && hi < 0xdc00 && eat(r, "\\u")) { + int32_t lo; + if (!hex4(r, &lo)) return false; + if (lo >= 0xdc00 && lo < 0xe000) { + cp = 0x10000 + ((hi - 0xd800) << 10) + (lo - 0xdc00); + } else { + /* Two units that do not pair: both become U+FFFD (lo unless it is a scalar). */ + append_rune(&b, 0xfffd); + cp = lo; + } + } + append_rune(&b, cp); + break; + } + default: { + /* \" \\ \/ and any other escaped character stand for themselves. The escaped character + * may be the first byte of a multi-byte code point: copy it whole. */ + size_t size = 0; + tp_decode_rune(tp_str_slice(r->s, r->at - 1, r->s.n), &size); + if (size == 0) size = 1; + tp_buf_bytes(&b, r->s.p + r->at - 1, size); + r->at += size - 1; + break; + } + } + } +} + +static bool read_number(reader *r, tp_json *out) { + size_t start = r->at; + double f; + while (r->at < r->s.n) { + char c = r->s.p[r->at]; + if ((c >= '0' && c <= '9') || c == '-' || c == '+' || c == '.' || c == 'e' || c == 'E') { + r->at++; + continue; + } + break; + } + if (r->at == start) return false; + /* Out of range gives the infinity (or zero), as JS Number() and Go's ParseFloat do. */ + if (!tp_parse_number(tp_str_slice(r->s, start, r->at), &f)) return false; + *out = tp_json_num(f); + return true; +} + +static bool read_value(reader *r, tp_json *out); + +static bool read_array(reader *r, tp_json *out) { + tp_jsonvec items = {0}; + r->at++; + r->depth++; + ws(r); + if (peek(r) == ']') { + r->at++; + } else { + for (;;) { + tp_json v; + ws(r); + if (!read_value(r, &v)) return false; + tp_push(items, v); + ws(r); + if (peek(r) == ',') { + r->at++; + continue; + } + if (peek(r) == ']') { + r->at++; + break; + } + return false; + } + } + r->depth--; + memset(out, 0, sizeof *out); + out->kind = TP_JSON_ARRAY; + out->arr = items.n ? items.p : (const tp_json *)tp_alloc(0); + out->arr_n = items.n; + return true; +} + +static bool read_object(reader *r, tp_json *out) { + tp_json_membervec members = {0}; + r->at++; + r->depth++; + ws(r); + if (peek(r) == '}') { + r->at++; + } else { + for (;;) { + tp_str key; + tp_json v; + bool found = false; + ws(r); + if (!read_string(r, &key)) return false; + ws(r); + if (peek(r) != ':') return false; + r->at++; + ws(r); + if (!read_value(r, &v)) return false; + for (size_t i = 0; i < members.n; i++) { + if (tp_str_eq(members.p[i].key, key)) { + members.p[i].val = v; + found = true; + break; + } + } + if (!found) { + tp_json_member m; + m.key = key; + m.val = v; + tp_push(members, m); + } + ws(r); + if (peek(r) == ',') { + r->at++; + continue; + } + if (peek(r) == '}') { + r->at++; + break; + } + return false; + } + } + r->depth--; + memset(out, 0, sizeof *out); + out->kind = TP_JSON_OBJECT; + out->obj = members.n ? members.p : (const tp_json_member *)tp_alloc(0); + out->obj_n = members.n; + return true; +} + +static bool read_value(reader *r, tp_json *out) { + if (r->depth > TP_JSON_MAX_DEPTH || r->at >= r->s.n) return false; + switch (peek(r)) { + case 'n': + *out = tp_json_null(); + return eat(r, "null"); + case 't': + *out = tp_json_bool(true); + return eat(r, "true"); + case 'f': + *out = tp_json_bool(false); + return eat(r, "false"); + case '"': { + tp_str s; + if (!read_string(r, &s)) return false; + *out = tp_json_str(s); + return true; + } + case '[': + return read_array(r, out); + case '{': + return read_object(r, out); + default: + return read_number(r, out); + } +} + +TP_PRIVATE bool tp_json_parse(tp_str text, tp_json *out) { + reader r; + tp_json v; + r.s = tp_sanitize(text); + r.at = 0; + r.depth = 0; + *out = tp_json_null(); + ws(&r); + if (!read_value(&r, &v)) return false; + ws(&r); + if (r.at != r.s.n) return false; + *out = v; + return true; +} diff --git a/c/wire/json_read.h b/c/wire/json_read.h new file mode 100644 index 0000000..4716121 --- /dev/null +++ b/c/wire/json_read.h @@ -0,0 +1,23 @@ +/* json_read.h: the JSON reader of the wire door (go/json.go parseJSON). + * + * Never part of the installed library: only the wire library, the fixture runner, the dump tool + * and the fuzzers read JSON (PLAN.md decision 5). + */ +#ifndef TP_JSON_READ_H +#define TP_JSON_READ_H + +#include "../src/rt.h" + +/* Nesting deeper than this is rejected, so hostile input cannot exhaust the stack. */ +#define TP_JSON_MAX_DEPTH 200 + +/* Read one JSON value from text (surrounding JSON whitespace allowed). Allocates in the current + * arena, so it must run inside an armed scope. Lenient where the JS reference has to be matched, + * exactly as go/json.go: a number is anything tp_parse_number reads from the characters + * 0-9 + - . e E (so 1e999 is infinity), an unknown escape stands for its character, a repeated + * key keeps its first place and takes the last value, and unpaired surrogate escapes become + * U+FFFD. Bytes that are not valid UTF-8 are first replaced (WHATWG, tp_sanitize). + * false (and *out = null) when the text is not JSON it can read. */ +TP_PRIVATE bool tp_json_parse(tp_str text, tp_json *out); + +#endif /* TP_JSON_READ_H */ diff --git a/c/wire/wire.c b/c/wire/wire.c new file mode 100644 index 0000000..859c246 --- /dev/null +++ b/c/wire/wire.c @@ -0,0 +1,49 @@ +/* wire.c: the JSON door (go/wire.go): fixture-style calls with loose JSON arguments, for the + * fixture runner, the dump tool (compare-ports, fuzz-ports) and the fuzzers. Never installed. */ +#include "wire.h" + +#include "../src/internal.h" + +/* artistList.write: a list of artists as JSON. */ +static void tp_artist_list_write(tp_artist_vec l, tp_jw *w) { tp_write_artists(w, l); } + +/* wireString.write: a JSON string. */ +static void tp_wire_string_write(tp_str s, tp_jw *w) { tp_jw_str(w, s); } + +/* wireCall is one fixture-style call: fn is parse, parseArtists, format, normalize, + * parseTracklist or applyEdits; format parses input with options first, then formats with + * formatOptions. Unknown functions give null. input must be valid UTF-8 (the JSON reader + * guarantees it). */ +TP_PRIVATE tp_str tp_wire_call(tp_str fn, tp_str input, tp_json options, tp_json format_options, + tp_json edits) { + tp_jw w = tp_jw_new(); + if (tp_str_eq_c(fn, "parse")) { + tp_track t = tp_engine_run(tp_engine_new(tp_resolve_parse_json(options)), input, false); + tp_track_write(&t, &w); + } else if (tp_str_eq_c(fn, "parseArtists")) { + tp_artist_list_write( + tp_engine_run_artists(tp_engine_new(tp_resolve_parse_json(options)), input), &w); + } else if (tp_str_eq_c(fn, "format")) { + tp_track t = tp_engine_run(tp_engine_new(tp_resolve_parse_json(options)), input, false); + tp_wire_string_write(tp_format_track(&t, tp_resolve_format_json(format_options)), &w); + } else if (tp_str_eq_c(fn, "normalize")) { + tp_wire_string_write(tp_normalize(input), &w); + } else if (tp_str_eq_c(fn, "parseTracklist")) { + tp_tracklist l = tp_parse_tracklist(input, tp_resolve_tracklist_json(options)); + tp_tracklist_write(&l, &w); + } else if (tp_str_eq_c(fn, "applyEdits")) { + /* Only an array has edits. */ + const tp_json *list = NULL; + size_t n = 0; + tp_raw_edit_result r; + if (edits.kind == TP_JSON_ARRAY) { + list = edits.arr; + n = edits.arr_n; + } + r = tp_apply_edits(input, list, n); + tp_raw_edit_result_write(&r, &w); + } else { + return TP_S("null"); + } + return tp_jw_done(&w); +} diff --git a/c/wire/wire.h b/c/wire/wire.h new file mode 100644 index 0000000..757b174 --- /dev/null +++ b/c/wire/wire.h @@ -0,0 +1,23 @@ +/* wire.h: the JSON door (go/wire.go wireCall). Fixture-style calls with loose JSON arguments, for + * the fixture runner, the dump tool (compare-ports, fuzz-ports) and the fuzzers. Never installed. + */ +#ifndef TP_WIRE_H +#define TP_WIRE_H + +#include "../src/rt.h" +#include "json_read.h" + +/* One fixture-style call: fn is parse, parseArtists, format, normalize, parseTracklist or + * applyEdits; format parses input with options first, then formats with format_options. + * applyEdits reads edits only when it is an array. Unknown functions give "null". input must be + * valid UTF-8 (the JSON reader guarantees it). Returns the JSON text of the result, written as + * JSON.stringify writes it, allocated in the current arena (run it inside an armed scope). */ +TP_PRIVATE tp_str tp_wire_call(tp_str fn, tp_str input, tp_json options, tp_json format_options, + tp_json edits); + +/* One case object {"fn", "input", "options", "formatOptions", "edits"} as JSON text + * (go/wire_hook.go wireLine): missing fn means parse, missing options are {}, missing edits []. + * Text that is not a JSON object gives "null". Same arena rules as tp_wire_call. */ +TP_PRIVATE tp_str tp_wire_line(tp_str line); + +#endif /* TP_WIRE_H */ diff --git a/c/wire/wire_line.c b/c/wire/wire_line.c new file mode 100644 index 0000000..13d599a --- /dev/null +++ b/c/wire/wire_line.c @@ -0,0 +1,30 @@ +/* wire_line.c: one JSONL case through the JSON door (go/wire_hook.go wireLine), for the dump + * tool and the wire fuzzer. */ +#include "wire.h" + +static tp_json empty_object(void) { + tp_json v = tp_json_null(); + v.kind = TP_JSON_OBJECT; + v.obj = (const tp_json_member *)tp_alloc(0); + return v; +} + +static tp_json empty_array(void) { + tp_json v = tp_json_null(); + v.kind = TP_JSON_ARRAY; + v.arr = (const tp_json *)tp_alloc(0); + return v; +} + +TP_PRIVATE tp_str tp_wire_line(tp_str line) { + tp_json c, v, options, format_options, edits; + tp_str fn = TP_S("parse"); + tp_str input = TP_EMPTY; + if (!tp_json_parse(line, &c) || c.kind != TP_JSON_OBJECT) return TP_S("null"); + if (tp_json_get(c, TP_S("fn"), &v) && v.kind == TP_JSON_STRING) fn = v.str; + if (tp_json_get(c, TP_S("input"), &v) && v.kind == TP_JSON_STRING) input = v.str; + if (!tp_json_get(c, TP_S("options"), &options)) options = empty_object(); + if (!tp_json_get(c, TP_S("formatOptions"), &format_options)) format_options = empty_object(); + if (!tp_json_get(c, TP_S("edits"), &edits)) edits = empty_array(); + return tp_wire_call(fn, input, options, format_options, edits); +} diff --git a/go/README.md b/go/README.md index 24414df..ad9f5b4 100644 --- a/go/README.md +++ b/go/README.md @@ -23,7 +23,7 @@ doesn't recognize stays in the title, word for word This is the Go port of [trackparse](https://github.com/4matic/trackparse). Its behaviour is defined by a [shared spec](https://4matic.github.io/trackparse/reference/spec/) and pinned by [13,130 fixtures](https://4matic.github.io/trackparse/project/testing/). It passes all of them, and for every fixture input its output is byte-identical -to the [JavaScript, Python and Rust packages](#other-languages). +to the [JavaScript, Python, Rust and C packages](#other-languages). - Go 1.22 or later (the `go` line of `go.mod`; CI runs the tests on 1.22 and on the latest stable) - No dependencies: `go.mod` has no `require` line @@ -448,8 +448,8 @@ default tables are built once, on first use. **Docs:** [SPEC_VERSION](https://4matic.github.io/trackparse/reference/functions/#spec_version) · [`SpecVersion`](https://pkg.go.dev/github.com/4matic/trackparse/go#SpecVersion) on pkg.go.dev The [spec](https://4matic.github.io/trackparse/reference/spec/) version this module implements. It equals the module version: the Go module, the npm -package, the PyPI package, the Rust crate and the spec are released together and always share one -version number. +package, the PyPI package, the Rust crate, the C library and the spec are released together and +always share one version number. ## Modes @@ -694,7 +694,7 @@ fmt.Printf("%q\n", trackparse.Parse("Noisia - Sti\xffgma\xe2\x82").Title) // "St - [`scripts/compare-ports.mjs`](https://github.com/4matic/trackparse/blob/main/scripts/compare-ports.mjs) runs every fixture input through the JavaScript package and this module and compares the complete JSON output, every field of it, not only the ones a fixture asserts. The Python and - Rust packages are checked the same way. + Rust packages and the C library are checked the same way. - CI runs `go vet`, staticcheck and `go test -race` on Go 1.22 and on the latest stable, and fails if `go.mod` gains a `require` line or the code calls `sort.Slice` (JavaScript sorts are stable, `sort.Slice` is not). @@ -716,8 +716,8 @@ So the output does not depend on the Go version you build with. More in This differs from the Rust crate, which takes NFC and NFD from the `unicode-normalization` crate and its Unicode 18 tables. Unicode 18 added 32 combining marks, so a string containing one of -them can come out with its marks in another order in Rust than in JavaScript and Go. Strings -without those marks are not affected, and every shared fixture gives the same bytes in all four +them can come out with its marks in another order in Rust than in JavaScript, Go and C. Strings +without those marks are not affected, and every shared fixture gives the same bytes in all five ports. ## Performance @@ -752,7 +752,7 @@ results, upgrade on purpose and read the changelog first. **Docs:** [Ports](https://4matic.github.io/trackparse/project/ports/) -The same parser exists for JavaScript, Python and Rust. All four implement one spec, pass the +The same parser exists for JavaScript, Python, Rust and C. All five implement one spec, pass the same fixtures, are released together under one version number, and return identical JSON for every fixture input. You can parse in one language and read the result in another. The one known difference is described under [Unicode version](#unicode-version). @@ -763,6 +763,7 @@ difference is described under [Unicode version](#unicode-version). | Python | [trackparse on PyPI](https://pypi.org/project/trackparse/) | `pip install trackparse` | [README](https://github.com/4matic/trackparse/blob/main/python/README.md) · [changelog](https://github.com/4matic/trackparse/blob/main/python/CHANGELOG.md) · [API](https://4matic.github.io/trackparse/reference/parse/) | | Rust | [trackparse on crates.io](https://crates.io/crates/trackparse) | `cargo add trackparse` | [README](https://github.com/4matic/trackparse/blob/main/rust/README.md) · [changelog](https://github.com/4matic/trackparse/blob/main/rust/CHANGELOG.md) · [API on docs.rs](https://docs.rs/trackparse) | | Go | [github.com/4matic/trackparse/go](https://pkg.go.dev/github.com/4matic/trackparse/go) | `go get github.com/4matic/trackparse/go` | [README](https://github.com/4matic/trackparse/blob/main/go/README.md) · [changelog](https://github.com/4matic/trackparse/blob/main/go/CHANGELOG.md) · [API on pkg.go.dev](https://pkg.go.dev/github.com/4matic/trackparse/go) | +| C / C++ | [C library and C++ header](https://github.com/4matic/trackparse/blob/main/c/README.md) | CMake FetchContent from the [release tarball](https://github.com/4matic/trackparse/releases), or the amalgamation | [README](https://github.com/4matic/trackparse/blob/main/c/README.md) · [changelog](https://github.com/4matic/trackparse/blob/main/c/CHANGELOG.md) · [header](https://github.com/4matic/trackparse/blob/main/c/include/trackparse.h) | ## Limitations @@ -801,7 +802,7 @@ spec, not here: see [AGENTS.md](https://github.com/4matic/trackparse/blob/main/A ## Links - [Documentation](https://4matic.github.io/trackparse/), with every example in JavaScript, Python, - Rust and Go, and a [playground](https://4matic.github.io/trackparse/playground/) that runs the + Rust, Go and C, and a [playground](https://4matic.github.io/trackparse/playground/) that runs the parser in your browser - [API documentation on pkg.go.dev](https://pkg.go.dev/github.com/4matic/trackparse/go) - [Spec](https://github.com/4matic/trackparse/blob/main/spec/SPEC.md) and its @@ -809,7 +810,7 @@ spec, not here: see [AGENTS.md](https://github.com/4matic/trackparse/blob/main/A - [Changelog](https://github.com/4matic/trackparse/blob/main/go/CHANGELOG.md) - [Project README](https://github.com/4matic/trackparse#readme) - [GitHub repository](https://github.com/4matic/trackparse) -- [npm package](https://www.npmjs.com/package/trackparse) · [PyPI package](https://pypi.org/project/trackparse/) · [Rust crate](https://crates.io/crates/trackparse) +- [npm package](https://www.npmjs.com/package/trackparse) · [PyPI package](https://pypi.org/project/trackparse/) · [Rust crate](https://crates.io/crates/trackparse) · [C library](https://github.com/4matic/trackparse/blob/main/c/README.md) ## License diff --git a/js/README.md b/js/README.md index cbb1f2c..3c7167c 100644 --- a/js/README.md +++ b/js/README.md @@ -24,7 +24,7 @@ This is the JavaScript and TypeScript package of [trackparse](https://github.com/4matic/trackparse), and the reference implementation. Its behaviour is defined by a [shared spec](https://4matic.github.io/trackparse/reference/spec/) and pinned by [13,130 fixtures](https://4matic.github.io/trackparse/project/testing/). It passes all of them, and the -[Python, Rust and Go packages](#other-languages) return the same output for every one. +[Python, Rust, Go and C packages](#other-languages) return the same output for every one. - Node 18 or later, browsers and other runtimes (no Node-specific APIs) - No dependencies @@ -337,8 +337,8 @@ r.junk; // [ { raw: 'Full Album', kind: 'other' } ] **Docs:** [SPEC_VERSION](https://4matic.github.io/trackparse/reference/functions/#spec_version) The version of the [spec](https://4matic.github.io/trackparse/reference/spec/) this build implements. It equals the package version: the npm package, -the PyPI package, the Rust crate, the Go module and the spec are released together and always -share one version number. +the PyPI package, the Rust crate, the Go module, the C library and the spec are released together +and always share one version number. ## Modes @@ -567,8 +567,8 @@ catches a misspelt name. result, and `parse(format(parse(s)))` round-trips. - The published build is run against every fixture on Node 18 and 20, as ESM and as CommonJS. - [`compare-ports.mjs`](https://github.com/4matic/trackparse/blob/main/scripts/compare-ports.mjs) - runs every fixture input through this package, the Python package, the Rust crate and the Go - module and diffs the complete JSON output. The difference count is zero. + runs every fixture input through this package, the Python package, the Rust crate, the Go + module and the C library and diffs the complete JSON output. The difference count is zero. ## Versioning @@ -584,7 +584,7 @@ store parsed results, pin the minor version with a tilde range (`"trackparse": " **Docs:** [Ports](https://4matic.github.io/trackparse/project/ports/) -The same parser exists for Python, Rust and Go. All four implement one spec, pass the same +The same parser exists for Python, Rust, Go and C. All five implement one spec, pass the same fixtures, are released together under one version number, and return identical JSON for every fixture input. You can parse in one language and read the result in another. @@ -594,6 +594,7 @@ fixture input. You can parse in one language and read the result in another. | Python | [trackparse on PyPI](https://pypi.org/project/trackparse/) | `pip install trackparse` | [README](https://github.com/4matic/trackparse/blob/main/python/README.md) · [changelog](https://github.com/4matic/trackparse/blob/main/python/CHANGELOG.md) · [API](https://4matic.github.io/trackparse/reference/parse/) | | Rust | [trackparse on crates.io](https://crates.io/crates/trackparse) | `cargo add trackparse` | [README](https://github.com/4matic/trackparse/blob/main/rust/README.md) · [changelog](https://github.com/4matic/trackparse/blob/main/rust/CHANGELOG.md) · [API on docs.rs](https://docs.rs/trackparse) | | Go | [github.com/4matic/trackparse/go](https://pkg.go.dev/github.com/4matic/trackparse/go) | `go get github.com/4matic/trackparse/go` | [README](https://github.com/4matic/trackparse/blob/main/go/README.md) · [changelog](https://github.com/4matic/trackparse/blob/main/go/CHANGELOG.md) · [API on pkg.go.dev](https://pkg.go.dev/github.com/4matic/trackparse/go) | +| C / C++ | [C library and C++ header](https://github.com/4matic/trackparse/blob/main/c/README.md) | CMake FetchContent from the [release tarball](https://github.com/4matic/trackparse/releases), or the amalgamation | [README](https://github.com/4matic/trackparse/blob/main/c/README.md) · [changelog](https://github.com/4matic/trackparse/blob/main/c/CHANGELOG.md) · [header](https://github.com/4matic/trackparse/blob/main/c/include/trackparse.h) | ## Limitations @@ -619,20 +620,20 @@ pnpm --filter trackparse conformance # pass rate per fixture file and per rule pnpm --filter trackparse build # js/dist, ESM and CommonJS ``` -The Python, Rust and Go ports mirror this package's modules one to one. Behaviour changes start in the +The Python, Rust, Go and C ports mirror this package's modules one to one. Behaviour changes start in the spec, not here: see [AGENTS.md](https://github.com/4matic/trackparse/blob/main/AGENTS.md). ## Links - [Documentation](https://4matic.github.io/trackparse/), with every example in JavaScript, Python, - Rust and Go, and a [playground](https://4matic.github.io/trackparse/playground/) that runs the + Rust, Go and C, and a [playground](https://4matic.github.io/trackparse/playground/) that runs the parser in your browser - [Spec](https://github.com/4matic/trackparse/blob/main/spec/SPEC.md) and its [changelog](https://github.com/4matic/trackparse/blob/main/spec/CHANGELOG.md) - [Changelog](https://github.com/4matic/trackparse/blob/main/js/CHANGELOG.md) - [Project README](https://github.com/4matic/trackparse#readme) - [GitHub repository](https://github.com/4matic/trackparse) -- [PyPI package](https://pypi.org/project/trackparse/) · [Rust crate](https://crates.io/crates/trackparse) · [Go module](https://pkg.go.dev/github.com/4matic/trackparse/go) +- [PyPI package](https://pypi.org/project/trackparse/) · [Rust crate](https://crates.io/crates/trackparse) · [Go module](https://pkg.go.dev/github.com/4matic/trackparse/go) · [C library](https://github.com/4matic/trackparse/blob/main/c/README.md) ## License diff --git a/python/README.md b/python/README.md index 956a73b..d72aeaf 100644 --- a/python/README.md +++ b/python/README.md @@ -23,7 +23,7 @@ doesn't recognize stays in the title, word for word This is the Python port of [trackparse](https://github.com/4matic/trackparse). Its behaviour is defined by a [shared spec](https://4matic.github.io/trackparse/reference/spec/) and pinned by [13,130 fixtures](https://4matic.github.io/trackparse/project/testing/). It passes all of them, and for every fixture input its output is byte-identical -to the [JavaScript, Rust and Go packages](#other-languages). +to the [JavaScript, Rust, Go and C packages](#other-languages). - Python 3.9 to 3.14 - No dependencies @@ -336,8 +336,8 @@ parser.parse("Chase & Status x Camo & Krooked - Track (Alix Perez Rerub)").versi **Docs:** [SPEC_VERSION](https://4matic.github.io/trackparse/reference/functions/#spec_version) The version of the [spec](https://4matic.github.io/trackparse/reference/spec/) this build implements. It equals `__version__`: the PyPI package, the npm -package, the Rust crate, the Go module and the spec are released together and always share one -version number. +package, the Rust crate, the Go module, the C library and the spec are released together and +always share one version number. ## Modes @@ -570,8 +570,8 @@ The package ships `py.typed` and passes `mypy --strict`. the result, and `parse(format_track(parse(s)))` round-trips. - CI runs the suite on Python 3.9 to 3.14, and runs the fixtures again against the built wheel. - [`compare-ports.mjs`](https://github.com/4matic/trackparse/blob/main/scripts/compare-ports.mjs) - runs every fixture input through the JavaScript package, this package, the Rust crate and the - Go module and diffs the complete JSON output. The difference count is zero. + runs every fixture input through the JavaScript package, this package, the Rust crate, the Go + module and the C library and diffs the complete JSON output. The difference count is zero. ## Versioning @@ -587,7 +587,7 @@ changelog before moving up. **Docs:** [Ports](https://4matic.github.io/trackparse/project/ports/) -The same parser exists for JavaScript, Rust and Go. All four implement one spec, pass the same +The same parser exists for JavaScript, Rust, Go and C. All five implement one spec, pass the same fixtures, are released together under one version number, and return identical JSON for every fixture input. You can parse in one language and read the result in another. @@ -597,6 +597,7 @@ fixture input. You can parse in one language and read the result in another. | Python | [trackparse on PyPI](https://pypi.org/project/trackparse/) | `pip install trackparse` | [README](https://github.com/4matic/trackparse/blob/main/python/README.md) · [changelog](https://github.com/4matic/trackparse/blob/main/python/CHANGELOG.md) · [API](https://4matic.github.io/trackparse/reference/parse/) | | Rust | [trackparse on crates.io](https://crates.io/crates/trackparse) | `cargo add trackparse` | [README](https://github.com/4matic/trackparse/blob/main/rust/README.md) · [changelog](https://github.com/4matic/trackparse/blob/main/rust/CHANGELOG.md) · [API on docs.rs](https://docs.rs/trackparse) | | Go | [github.com/4matic/trackparse/go](https://pkg.go.dev/github.com/4matic/trackparse/go) | `go get github.com/4matic/trackparse/go` | [README](https://github.com/4matic/trackparse/blob/main/go/README.md) · [changelog](https://github.com/4matic/trackparse/blob/main/go/CHANGELOG.md) · [API on pkg.go.dev](https://pkg.go.dev/github.com/4matic/trackparse/go) | +| C / C++ | [C library and C++ header](https://github.com/4matic/trackparse/blob/main/c/README.md) | CMake FetchContent from the [release tarball](https://github.com/4matic/trackparse/releases), or the amalgamation | [README](https://github.com/4matic/trackparse/blob/main/c/README.md) · [changelog](https://github.com/4matic/trackparse/blob/main/c/CHANGELOG.md) · [header](https://github.com/4matic/trackparse/blob/main/c/include/trackparse.h) | ## Limitations @@ -629,14 +630,14 @@ same spec rule IDs. Behaviour changes start in the spec, not here: see ## Links - [Documentation](https://4matic.github.io/trackparse/), with every example in JavaScript, Python, - Rust and Go, and a [playground](https://4matic.github.io/trackparse/playground/) that runs the + Rust, Go and C, and a [playground](https://4matic.github.io/trackparse/playground/) that runs the parser in your browser - [Spec](https://github.com/4matic/trackparse/blob/main/spec/SPEC.md) and its [changelog](https://github.com/4matic/trackparse/blob/main/spec/CHANGELOG.md) - [Changelog](https://github.com/4matic/trackparse/blob/main/python/CHANGELOG.md) - [Project README](https://github.com/4matic/trackparse#readme) - [GitHub repository](https://github.com/4matic/trackparse) -- [npm package](https://www.npmjs.com/package/trackparse) · [Rust crate](https://crates.io/crates/trackparse) · [Go module](https://pkg.go.dev/github.com/4matic/trackparse/go) +- [npm package](https://www.npmjs.com/package/trackparse) · [Rust crate](https://crates.io/crates/trackparse) · [Go module](https://pkg.go.dev/github.com/4matic/trackparse/go) · [C library](https://github.com/4matic/trackparse/blob/main/c/README.md) ## License diff --git a/release-please-config.json b/release-please-config.json index 05d807c..bb5dfb4 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -4,7 +4,7 @@ "tag-separator": "-", "bump-minor-pre-major": true, "bump-patch-for-minor-pre-major": false, - "pull-request-header": ":robot: Merging this PR tags the release, publishes a GitHub Release with these notes and publishes to npm, PyPI and crates.io. The Go module is published by its tag (go/vX.Y.Z) through the Go module proxy.", + "pull-request-header": ":robot: Merging this PR tags the release, publishes a GitHub Release with these notes and publishes to npm, PyPI and crates.io. The Go module is published by its tag (go/vX.Y.Z) through the Go module proxy. The C library is attached to its GitHub Release (c-vX.Y.Z) as a source tarball and an amalgamation.", "changelog-sections": [ { "type": "feat", @@ -122,6 +122,27 @@ } ], "initial-version": "0.1.0" + }, + "c": { + "release-type": "simple", + "component": "c", + "version-file": "VERSION", + "changelog-path": "CHANGELOG.md", + "extra-files": [ + { + "type": "generic", + "path": "CMakeLists.txt" + }, + { + "type": "generic", + "path": "include/trackparse.h" + }, + { + "type": "generic", + "path": "src/data_gen.h" + } + ], + "initial-version": "0.1.0" } }, "plugins": [ @@ -133,7 +154,8 @@ "spec", "python", "rust", - "go" + "go", + "c" ] } ] diff --git a/rust/Cargo.toml b/rust/Cargo.toml index bb5069b..d247e2f 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -3,7 +3,7 @@ name = "trackparse" version = "0.6.1" # x-release-please-version edition = "2021" rust-version = "1.74" -description = "Turn messy track names into structured data: artists with roles, remixes and versions, junk, and whole tracklists. One spec, same output as the JavaScript, Python and Go packages." +description = "Turn messy track names into structured data: artists with roles, remixes and versions, junk, and whole tracklists. One spec, same output as the JavaScript, Python, Go and C packages." license = "MIT" repository = "https://github.com/4matic/trackparse" homepage = "https://4matic.github.io/trackparse/" diff --git a/rust/README.md b/rust/README.md index c0385fa..083421e 100644 --- a/rust/README.md +++ b/rust/README.md @@ -24,7 +24,7 @@ doesn't recognize stays in the title, word for word This is the Rust port of [trackparse](https://github.com/4matic/trackparse). Its behaviour is defined by a [shared spec](https://4matic.github.io/trackparse/reference/spec/) and pinned by [13,130 fixtures](https://4matic.github.io/trackparse/project/testing/). It passes all of them, and for every fixture input its output is byte-identical -to the [JavaScript, Python and Go packages](#other-languages). +to the [JavaScript, Python, Go and C packages](#other-languages). - Rust 1.74 or later (the minimum supported version; CI runs the test suite on 1.74 and on stable) - One dependency (`unicode-normalization`); `serde` is optional @@ -438,8 +438,8 @@ assert_eq!(track.versions[0].version_type, VersionType::Rework); **Docs:** [SPEC_VERSION](https://4matic.github.io/trackparse/reference/functions/#spec_version) · [`SPEC_VERSION`](https://docs.rs/trackparse/latest/trackparse/constant.SPEC_VERSION.html) on docs.rs The version of the [spec](https://4matic.github.io/trackparse/reference/spec/) this build implements. It equals the crate version: the crate, the npm -package, the PyPI package, the Go module and the spec are released together and always share one -version number. +package, the PyPI package, the Go module, the C library and the spec are released together and +always share one version number. ## Modes @@ -675,7 +675,7 @@ from JSON can fail as any `serde` type can. API tests. The skip list is empty. - [`scripts/compare-ports.mjs`](https://github.com/4matic/trackparse/blob/main/scripts/compare-ports.mjs) in the repository runs every fixture input through the JavaScript package and this crate and compares the complete JSON output, every field of it, not only the - ones a fixture asserts. The Python package and the Go module are checked the same way. + ones a fixture asserts. The Python package, the Go module and the C library are checked the same way. - The Unicode facts the rules need (letters, uppercase letters, lowercase mapping) are tables generated from the reference implementation and compiled into the crate. The output does not depend on the compiler's Unicode version: Rust 1.74 and current stable give the same bytes. @@ -694,8 +694,8 @@ for some strings, so Cargo will not select them. The JavaScript package normalizes with its runtime's tables, which are Unicode 17 on Node 24. Unicode 18 added 32 combining marks, so a string that contains one of them can come out with its -marks in another order here than in JavaScript on that runtime, and than in the Go module, whose -NFC and NFD tables are generated from Node 24. Strings without those marks are not affected, and +marks in another order here than in JavaScript on that runtime, and than in the Go module and the +C library, whose NFC and NFD tables are generated from Node 24. Strings without those marks are not affected, and every shared fixture gives the same bytes. More in [what the Rust port taught](https://4matic.github.io/trackparse/project/ports/#what-the-rust-port-taught). @@ -719,7 +719,7 @@ default requirement already stays within one minor version (`trackparse = "0.6"` **Docs:** [Ports](https://4matic.github.io/trackparse/project/ports/) -The same parser exists for JavaScript, Python and Go. All four implement one spec, pass the same +The same parser exists for JavaScript, Python, Go and C. All five implement one spec, pass the same fixtures, are released together under one version number, and return identical JSON for every fixture input. You can parse in one language and read the result in another. The one known difference is described under [Unicode version](#unicode-version). @@ -730,6 +730,7 @@ difference is described under [Unicode version](#unicode-version). | Python | [trackparse on PyPI](https://pypi.org/project/trackparse/) | `pip install trackparse` | [README](https://github.com/4matic/trackparse/blob/main/python/README.md) · [changelog](https://github.com/4matic/trackparse/blob/main/python/CHANGELOG.md) · [API](https://4matic.github.io/trackparse/reference/parse/) | | Rust | [trackparse on crates.io](https://crates.io/crates/trackparse) | `cargo add trackparse` | [README](https://github.com/4matic/trackparse/blob/main/rust/README.md) · [changelog](https://github.com/4matic/trackparse/blob/main/rust/CHANGELOG.md) · [API on docs.rs](https://docs.rs/trackparse) | | Go | [github.com/4matic/trackparse/go](https://pkg.go.dev/github.com/4matic/trackparse/go) | `go get github.com/4matic/trackparse/go` | [README](https://github.com/4matic/trackparse/blob/main/go/README.md) · [changelog](https://github.com/4matic/trackparse/blob/main/go/CHANGELOG.md) · [API on pkg.go.dev](https://pkg.go.dev/github.com/4matic/trackparse/go) | +| C / C++ | [C library and C++ header](https://github.com/4matic/trackparse/blob/main/c/README.md) | CMake FetchContent from the [release tarball](https://github.com/4matic/trackparse/releases), or the amalgamation | [README](https://github.com/4matic/trackparse/blob/main/c/README.md) · [changelog](https://github.com/4matic/trackparse/blob/main/c/CHANGELOG.md) · [header](https://github.com/4matic/trackparse/blob/main/c/include/trackparse.h) | ## Limitations @@ -762,7 +763,7 @@ same spec rule IDs. Behaviour changes start in the spec, not here: see ## Links - [Documentation](https://4matic.github.io/trackparse/), with every example in JavaScript, Python, - Rust and Go, and a [playground](https://4matic.github.io/trackparse/playground/) that runs the + Rust, Go and C, and a [playground](https://4matic.github.io/trackparse/playground/) that runs the parser in your browser - [API documentation on docs.rs](https://docs.rs/trackparse) - [Spec](https://github.com/4matic/trackparse/blob/main/spec/SPEC.md) and its @@ -770,7 +771,7 @@ same spec rule IDs. Behaviour changes start in the spec, not here: see - [Changelog](https://github.com/4matic/trackparse/blob/main/rust/CHANGELOG.md) - [Project README](https://github.com/4matic/trackparse#readme) - [GitHub repository](https://github.com/4matic/trackparse) -- [npm package](https://www.npmjs.com/package/trackparse) · [PyPI package](https://pypi.org/project/trackparse/) · [Go module](https://pkg.go.dev/github.com/4matic/trackparse/go) +- [npm package](https://www.npmjs.com/package/trackparse) · [PyPI package](https://pypi.org/project/trackparse/) · [Go module](https://pkg.go.dev/github.com/4matic/trackparse/go) · [C library](https://github.com/4matic/trackparse/blob/main/c/README.md) ## License diff --git a/scripts/compare-ports.mjs b/scripts/compare-ports.mjs index 758bb55..f1d9151 100644 --- a/scripts/compare-ports.mjs +++ b/scripts/compare-ports.mjs @@ -1,16 +1,19 @@ #!/usr/bin/env node // Cross-port byte check: runs every fixture case (spec/fixtures/**) through the built JS package, -// the Python port, the Rust port and the Go port, and diffs the FULL outputs (not the partial +// the Python port, the Rust port, the Go port and the C port, and diffs the FULL outputs (not the partial // fixture expectations). JS is the reference; each other port is compared with it. // // Usage (from the repo root): // pnpm --filter trackparse build # builds js/dist -// node scripts/compare-ports.mjs # needs `uv` (Python), `cargo` (Rust) and `go` (Go) -// node scripts/compare-ports.mjs --only=python # or --only=rust, --only=go +// node scripts/compare-ports.mjs # needs `uv` (Python), `cargo` (Rust), `go` (Go) and +// # CMake plus a C compiler (C) +// node scripts/compare-ports.mjs --only=python # or --only=rust, --only=go, --only=c // // Rust runs `cargo run --release --example dump` in rust/ and Go runs // `go run -tags trackparse_wire ./internal/cmd/dump` in go/ (both JSONL in, one JSON result per -// line, the same protocol; the tag links the JSON door into the Go module). +// line, the same protocol; the tag links the JSON door into the Go module). C builds c/ with CMake +// into c/build (Release) when c/build/trackparse-dump is missing or older than the sources, then +// runs it (c/tools/dump.c, the same protocol). // Options are merged like js/test/runner.ts ({...defaults.options, ...case.options}, same for // formatOptions). Python gets one process for all cases (JSONL over stdin/stdout); dump_py.py maps // the camelCase options to snake_case kwargs and serialises with to_dict() (ParsedTrack, and the @@ -20,7 +23,7 @@ import { readdirSync, readFileSync, statSync } from "node:fs"; import { join, relative } from "node:path"; -import { describeDiff, comparable, root, runJs, runLines, runPython } from "./lib/ports.mjs"; +import { buildC, describeDiff, comparable, root, runJs, runLines, runPython } from "./lib/ports.mjs"; const fixturesDir = join(root, "spec", "fixtures"); const MAX_SHOWN = 30; @@ -60,12 +63,14 @@ for (const full of walk(fixturesDir)) { const runRust = runLines("Rust", "cargo", ["run", "--quiet", "--release", "--example", "dump"], join(root, "rust")); const runGo = runLines("Go", "go", ["run", "-tags", "trackparse_wire", "./internal/cmd/dump"], join(root, "go")); +const runC = (all) => buildC()(all); const only = process.argv.find((a) => a.startsWith("--only="))?.slice(7); const ports = [ { name: "Python", key: "py", run: runPython }, { name: "Rust", key: "rs", run: runRust }, { name: "Go", key: "go", run: runGo }, + { name: "C", key: "c", run: runC }, ].filter((p) => !only || p.name.toLowerCase() === only); const jsResults = cases.map(runJs); diff --git a/scripts/fuzz-ports.mjs b/scripts/fuzz-ports.mjs index 43013db..e3c7bb2 100644 --- a/scripts/fuzz-ports.mjs +++ b/scripts/fuzz-ports.mjs @@ -1,7 +1,7 @@ #!/usr/bin/env node // Random differential run: generated single-track inputs and tracklists with edits through the -// built JS package (the reference), the Python port, the Rust port and the Go port, comparing the -// FULL JSON outputs, like scripts/compare-ports.mjs does for the fixture inputs. +// built JS package (the reference), the Python port, the Rust port, the Go port and the C port, +// comparing the FULL JSON outputs, like scripts/compare-ports.mjs does for the fixture inputs. // // Usage (from the repo root): // pnpm --filter trackparse build @@ -14,22 +14,23 @@ // --lists=N tracklists; each gives a parseTracklist and an applyEdits case with random // edits (invalid ones included); default 58% of --n (290,000 for 500,000) // --seed=N generator seed (mulberry32); default 1. The same seed gives the same cases. -// --only=X python, rust or go; default all three +// --only=X python, rust, go or c; default all of them (five ports with JS) // --batch=N cases per port process; default 20000 // --out=FILE write every differing case as JSONL (the case and each port's output) // -// The inputs are what the JSON door can carry faithfully: no lone surrogates (Rust and Go read +// The inputs are what the JSON door can carry faithfully: no lone surrogates (Rust, Go and C read // them as U+FFFD), no NaN or -0 in options or edits (JSON.stringify changes them). Option values // include odd types and strings, integer-like keyword keys and unknown names, as the R0.8 -// fallbacks must agree too. Go and Rust are built once (go build, cargo build --release) and -// their binaries run per batch; Python runs scripts/dump_py.py per batch. +// fallbacks must agree too. Go, Rust and C are built once (go build, cargo build --release, +// CMake into c/build when the C dump is stale) and their binaries run per batch; Python runs +// scripts/dump_py.py per batch. // Exits 1 if any case differs. import { execFileSync } from "node:child_process"; import { mkdtempSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { comparable, describeDiff, root, runJs, runLines, runPython } from "./lib/ports.mjs"; +import { buildC, comparable, describeDiff, root, runJs, runLines, runPython } from "./lib/ports.mjs"; const MAX_SHOWN = 20; @@ -326,9 +327,10 @@ const ports = [ { name: "Python", key: "py", build: () => runPython }, { name: "Rust", key: "rs", build: buildRust }, { name: "Go", key: "go", build: buildGo }, + { name: "C", key: "c", build: buildC }, ].filter((p) => !only || p.name.toLowerCase() === only); if (ports.length === 0) { - console.error(`unknown port ${only}: use --only=python, --only=rust or --only=go`); + console.error(`unknown port ${only}: use --only=python, --only=rust, --only=go or --only=c`); process.exit(2); } for (const port of ports) port.run = port.build(); diff --git a/scripts/lib/ports.mjs b/scripts/lib/ports.mjs index fc5da9c..0787897 100644 --- a/scripts/lib/ports.mjs +++ b/scripts/lib/ports.mjs @@ -6,11 +6,12 @@ // runner resolves to a Map from i to { ok: } or { error: }. // // JS is the reference and runs in this process from js/dist. Python gets one process per call -// (scripts/dump_py.py, JSONL over stdin/stdout). Rust and Go read one case per line and write -// one JSON result per line, in order (rust/examples/dump.rs, go/internal/cmd/dump). +// (scripts/dump_py.py, JSONL over stdin/stdout). Rust, Go and C read one case per line and write +// one JSON result per line, in order (rust/examples/dump.rs, go/internal/cmd/dump, +// c/tools/dump.c). -import { spawn } from "node:child_process"; -import { existsSync } from "node:fs"; +import { execFileSync, spawn } from "node:child_process"; +import { existsSync, readdirSync, statSync } from "node:fs"; import { dirname, join, relative, resolve } from "node:path"; import { fileURLToPath, pathToFileURL } from "node:url"; @@ -84,8 +85,8 @@ export function runPython(all) { } /** - * A port that reads one case per line and writes one JSON result per line, in order (Rust and - * Go). Such ports never throw: every line is a result. + * A port that reads one case per line and writes one JSON result per line, in order (Rust, Go + * and C). Such ports never throw: every line is a result. */ export function runLines(name, command, args, cwd) { return (all) => @@ -116,6 +117,62 @@ export function runLines(name, command, args, cwd) { }); } +const cDir = join(root, "c"); +const cBuild = join(cDir, "build"); + +/** The newest modification time under the C sources the dump binary is built from. */ +function newestCSource() { + let newest = statSync(join(cDir, "CMakeLists.txt")).mtimeMs; + const walk = (dir) => { + if (!existsSync(dir)) return; + for (const entry of readdirSync(dir)) { + const full = join(dir, entry); + const st = statSync(full); + if (st.isDirectory()) walk(full); + else newest = Math.max(newest, st.mtimeMs); + } + }; + for (const sub of ["src", "wire", "tools", "include"]) walk(join(cDir, sub)); + return newest; +} + +/** `cmake` when it runs, else `uvx cmake` (the way the repo's docs run it without an install). */ +function cmakeCommand() { + try { + execFileSync("cmake", ["--version"], { stdio: "ignore" }); + return ["cmake"]; + } catch { + return ["uvx", "cmake"]; + } +} + +/** The dump binary in c/build, or undefined (single- and multi-config generators). */ +function cDumpBinary() { + const exe = process.platform === "win32" ? ".exe" : ""; + return [join(cBuild, `trackparse-dump${exe}`), join(cBuild, "Release", `trackparse-dump${exe}`)].find( + (p) => existsSync(p), + ); +} + +/** + * The C port: builds c/ with CMake into c/build (Release) when the dump binary is missing or + * older than its sources, then runs c/build/trackparse-dump (c/tools/dump.c) for each batch. + */ +export function buildC() { + let bin = cDumpBinary(); + if (!bin || statSync(bin).mtimeMs < newestCSource()) { + const [cmake, ...pre] = cmakeCommand(); + const run = (args) => execFileSync(cmake, [...pre, ...args], { cwd: root, stdio: "inherit" }); + if (!existsSync(join(cBuild, "CMakeCache.txt"))) { + run(["-S", cDir, "-B", cBuild, "-DCMAKE_BUILD_TYPE=Release", "-DTRACKPARSE_BUILD_TESTS=OFF"]); + } + run(["--build", cBuild, "--config", "Release", "--target", "trackparse-dump"]); + bin = cDumpBinary(); + if (!bin) throw new Error("the C build did not produce trackparse-dump"); + } + return runLines("C", bin, [], root); +} + /** JSON with object keys sorted recursively, so key order never counts as a difference. */ export function canonical(value) { return JSON.stringify(value, (_key, v) => diff --git a/site/astro.config.mjs b/site/astro.config.mjs index ed4b4c2..6b9939d 100644 --- a/site/astro.config.mjs +++ b/site/astro.config.mjs @@ -20,7 +20,7 @@ export default defineConfig({ title: "trackparse", disable404Route: true, description: - "Turn messy track names into structured data: artists, features, remixes, versions and the noise around them. JavaScript, Python, Rust and Go, one spec.", + "Turn messy track names into structured data: artists, features, remixes, versions and the noise around them. JavaScript, Python, Rust, Go and C, one spec.", logo: { light: "./src/assets/logo-light.svg", dark: "./src/assets/logo-dark.svg", replacesTitle: false }, favicon: "/favicon.svg", social: [ diff --git a/site/src/components/HeroDemo.astro b/site/src/components/HeroDemo.astro index b9d3e37..f8691c0 100644 --- a/site/src/components/HeroDemo.astro +++ b/site/src/components/HeroDemo.astro @@ -48,7 +48,7 @@ const playground = `${base}/playground/`;
diff --git a/site/src/components/Install.astro b/site/src/components/Install.astro index d4c6920..8ff3d91 100644 --- a/site/src/components/Install.astro +++ b/site/src/components/Install.astro @@ -1,16 +1,19 @@ --- -// One install line under the hero, switchable between npm, pip, cargo and go, with a copy button. +// One install line under the hero, switchable between npm, pip, cargo, go and CMake, with a copy +// button. C has no registry: its "line" is the CMake FetchContent block, shown on several lines. // The switch shares its choice with the docs' language tabs and the playground (lib/lang.ts). import Check from "@lucide/astro/icons/check"; import Copy from "@lucide/astro/icons/copy"; -import { PACKAGE } from "../lib/lang"; +import { C_FETCHCONTENT, PACKAGE } from "../lib/lang"; const pms = [ { lang: "js", label: "npm" }, { lang: "py", label: "pip" }, { lang: "rs", label: "cargo" }, { lang: "go", label: "go" }, + { lang: "c", label: "cmake" }, ] as const; +const command = (lang: (typeof pms)[number]["lang"]) => (lang === "c" ? C_FETCHCONTENT : PACKAGE[lang].install); ---
@@ -18,19 +21,21 @@ const pms = [
{ pms.map((p, i) => ( - )) }
- {PACKAGE.js.install} + {PACKAGE.js.install}

Published on npm, PyPI,{" "} - crates.io and the Go module proxy. The Rust API docs are on{" "} - docs.rs, the Go API docs on pkg.go.dev. + crates.io and the Go module proxy; the C library is a tarball on{" "} + GitHub Releases. The Rust API docs are on{" "} + docs.rs, the Go API docs on pkg.go.dev, the C + API in the C README.

@@ -79,6 +84,21 @@ const pms = [ .prompt { color: var(--sl-color-gray-4); } + /* CMake for C: several lines, no prompt, scrolled sideways when a line is wider than the box. */ + .install.multi { + align-items: stretch; + } + .install.multi code { + white-space: pre; + overflow-x: auto; + text-overflow: clip; + padding-block: 0.8rem; + line-height: 1.5; + min-width: 0; + } + .install.multi .prompt { + display: none; + } .copy { display: grid; place-items: center; @@ -117,7 +137,7 @@ const pms = [ color: var(--sl-color-white); text-decoration-color: var(--sl-color-accent); } - /* Four package managers and a command don't fit one row on a phone: the switch gets its own. */ + /* Five package managers and a command don't fit one row on a phone: the switch gets its own. */ @media (max-width: 26rem) { .install { flex-wrap: wrap; @@ -146,6 +166,7 @@ const pms = [ b.setAttribute("aria-pressed", String(b.dataset.pm === lang)); if (b.dataset.pm === lang) cmd.textContent = b.dataset.cmd ?? ""; } + root.classList.toggle("multi", lang === "c"); }; for (const b of buttons) { b.addEventListener("click", () => { diff --git a/site/src/components/Playground.astro b/site/src/components/Playground.astro index 3b3fbbc..1dfb765 100644 --- a/site/src/components/Playground.astro +++ b/site/src/components/Playground.astro @@ -217,6 +217,7 @@ const listExamples: { label: string; title: string; text: string }[] = [ +

@@ -307,6 +308,7 @@ const listExamples: { label: string; title: string; text: string }[] = [
               
               
               
+              
             
             
           
@@ -481,7 +483,7 @@ const listExamples: { label: string; title: string; text: string }[] = [
   .pg-api:empty {
     display: none;
   }
-  /* Generated Go is indented with tabs, as gofmt writes it. */
+  /* Generated Go is indented with tabs, as gofmt writes it (C uses spaces, as clang-format does). */
   .tp-code {
     tab-size: 4;
   }
@@ -497,7 +499,7 @@ const listExamples: { label: string; title: string; text: string }[] = [
     background: var(--tp-code-bg);
     padding: 0.1em 0.35em;
     border-radius: 4px;
-    /* The go get line is longer than a phone is wide: it may break anywhere. */
+    /* The go get and FetchContent lines are longer than a phone is wide: they may break anywhere. */
     overflow-wrap: anywhere;
   }
   .pg-install {
@@ -825,13 +827,15 @@ const listExamples: { label: string; title: string; text: string }[] = [
       `Install: ${escapeHtml(p.install)}` +
       `Getting started` +
       `${p.registry}` +
-      // The API docs: docs.rs for the crate, pkg.go.dev (the link above) for the module, and
-      // this site's reference for the npm and PyPI packages.
+      // The API docs: docs.rs for the crate, pkg.go.dev (the link above) for the module, the
+      // README for the C library, and this site's reference for the npm and PyPI packages.
       (lang === "rs"
         ? 'docs.rs'
         : lang === "go"
           ? ""
-          : `API reference`);
+          : lang === "c"
+            ? 'C README'
+            : `API reference`);
     for (const el of document.querySelectorAll("[data-install]")) el.innerHTML = html;
   }
 
diff --git a/site/src/components/Stats.astro b/site/src/components/Stats.astro
index c784f84..3c9cb91 100644
--- a/site/src/components/Stats.astro
+++ b/site/src/components/Stats.astro
@@ -1,10 +1,10 @@
 ---
 // Monochrome numbers in one row. Keep them in sync with the fixtures (see AGENTS.md).
 const stats = [
-  { n: "13,130", label: "shared fixtures, 100% passing in all four ports" },
-  { n: "0", label: "runtime dependencies in JavaScript, Python and Go, one in Rust" },
+  { n: "13,130", label: "shared fixtures, 100% passing in all five ports" },
+  { n: "0", label: "runtime dependencies in JavaScript, Python, Go and C, one in Rust" },
   { n: "27", label: "version types, remix to nightcore" },
-  { n: "0", label: "differences between JS, Python, Rust and Go output on the fixtures" },
+  { n: "0", label: "differences between JS, Python, Rust, Go and C output on the fixtures" },
 ];
 ---
 
diff --git a/site/src/content/docs/guides/artists.mdx b/site/src/content/docs/guides/artists.mdx
index 5ccaff2..454fced 100644
--- a/site/src/content/docs/guides/artists.mdx
+++ b/site/src/content/docs/guides/artists.mdx
@@ -46,21 +46,37 @@ type Artist struct {
 }
 ```
 
+
+
+
+```c
+typedef struct trackparse_artist {
+  trackparse_str name;
+  trackparse_role role;           /* TRACKPARSE_ROLE_PRIMARY, _FEATURED, _REMIXER, _PRODUCER */
+  const trackparse_str *joiner;   /* NULL for the first name of a list */
+  trackparse_source source;       /* TRACKPARSE_SOURCE_ARTIST, _TITLE, _VERSION */
+} trackparse_artist;
+```
+
 
 
 
 `role` says what the person did. `joiner` is the text that introduced the name, exactly as written
 (`"&"`, `","`, `"ft."`, `"prod. by"`), and `null` for the first name of a list (`None` in Python and
-Rust, `nil` in Go, where `Joiner` is a `*string`). `source` says where the credit was found: left of the dash (`artist`), right of it (`title`),
+Rust, `nil` in Go, where `Joiner` is a `*string`, `NULL` in C, where `joiner` is a
+`const trackparse_str *`). `source` says where the credit was found: left of the dash (`artist`), right of it (`title`),
 or inside a version (`version`). In Rust, `role` and `source` are the enums
 [`ArtistRole`](https://docs.rs/trackparse/latest/trackparse/enum.ArtistRole.html) and [`ArtistSource`](https://docs.rs/trackparse/latest/trackparse/enum.ArtistSource.html);
 `as_str()` and `Display` give the lowercase names used here. In Go they are the string types
 [`Role`](https://pkg.go.dev/github.com/4matic/trackparse/go#Role) and [`Source`](https://pkg.go.dev/github.com/4matic/trackparse/go#Source), with constants such as `trackparse.RolePrimary`
-and `trackparse.SourceTitle` whose values are those names. The full field list is under
+and `trackparse.SourceTitle` whose values are those names. In C they are the enums
+`trackparse_role` and `trackparse_source` (`TRACKPARSE_ROLE_PRIMARY`, `TRACKPARSE_SOURCE_TITLE`),
+and `trackparse_role_name()` and `trackparse_source_name()` give the names; the structs are in
+[`trackparse.h`](https://github.com/4matic/trackparse/blob/main/c/include/trackparse.h). The full field list is under
 [`Artist`](/trackparse/reference/parse/#artist) in the reference.
 
 Remixers live inside `versions`, not in `artists`. Use [`allArtists(track)`](/trackparse/reference/functions/#allartiststrack)
-(`all_artists` in Python and Rust, `AllArtists` in Go) when you want everyone in one list.
+(`all_artists` in Python and Rust, `AllArtists` in Go, `trackparse_all_artists` in C) when you want everyone in one list.
 
 ## Joiners
 
@@ -140,6 +156,31 @@ fmt.Printf("%q\n", names(trackparse.Parse("Kanye West vs. Daft Punk - Stronger")
 // ["Kanye West" "Daft Punk"]
 ```
 
+
+
+
+```c
+#include 
+
+trackparse_track *t = trackparse_parse("Skrillex & Diplo x Justin Bieber - Where Are Ü Now",
+                                       TRACKPARSE_NUL_TERMINATED);
+for (size_t i = 0; i < t->artists_count; i++) {
+  const trackparse_artist *a = &t->artists[i];
+  printf("%s (joiner %s), %s\n", a->name.ptr, a->joiner ? a->joiner->ptr : "NULL",
+         trackparse_role_name(a->role));
+}
+// Skrillex (joiner NULL), primary
+// Diplo (joiner &), primary
+// Justin Bieber (joiner x), primary
+trackparse_track_free(t);
+
+t = trackparse_parse("Kanye West vs. Daft Punk - Stronger", TRACKPARSE_NUL_TERMINATED);
+for (size_t i = 0; i < t->artists_count; i++) printf("%s\n", t->artists[i].name.ptr);
+// Kanye West
+// Daft Punk
+trackparse_track_free(t);
+```
+
 
 
 
@@ -205,11 +246,30 @@ fmt.Printf("%q\n", names(trackparse.ParseArtists("Crosby, Stills, Nash and Young
 // ["Crosby" "Stills" "Nash" "Young"]
 ```
 
+
+
+
+```c
+t = trackparse_parse("Simon and Garfunkel - The Boxer", TRACKPARSE_NUL_TERMINATED);
+for (size_t i = 0; i < t->artists_count; i++) printf("%s\n", t->artists[i].name.ptr);
+// Simon and Garfunkel
+trackparse_track_free(t);
+
+trackparse_artists *list =
+    trackparse_parse_artists("Crosby, Stills, Nash and Young", TRACKPARSE_NUL_TERMINATED);
+for (size_t i = 0; i < list->count; i++) printf("%s\n", list->items[i].name.ptr);
+// Crosby
+// Stills
+// Nash
+// Young
+trackparse_artists_free(list);
+```
+
 
 
 
 Set [`splitAnd`](/trackparse/reference/options/#parse-options) (`split_and` in Python and Rust,
-`SplitAnd` in Go) to `"always"` or `"never"` to change that
+`SplitAnd` in Go, `trackparse_parse_options_set_split_and` in C) to `"always"` or `"never"` to change that
 ([try it](/trackparse/playground/#track=Simon%20and%20Garfunkel%20-%20The%20Boxer&splitAnd=always)):
 
 
@@ -260,6 +320,31 @@ fmt.Printf("%q\n", names(trackparse.ParseArtistsWith("Crosby, Stills, Nash and Y
 // ["Crosby" "Stills" "Nash and Young"]
 ```
 
+
+
+
+```c
+trackparse_parse_options *always = trackparse_parse_options_new();
+trackparse_parse_options_set_split_and(always, TRACKPARSE_SPLIT_AND_ALWAYS);
+t = trackparse_parse_with("Simon and Garfunkel - The Boxer", TRACKPARSE_NUL_TERMINATED, always);
+for (size_t i = 0; i < t->artists_count; i++) printf("%s\n", t->artists[i].name.ptr);
+// Simon
+// Garfunkel
+trackparse_track_free(t);
+trackparse_parse_options_free(always);
+
+trackparse_parse_options *never = trackparse_parse_options_new();
+trackparse_parse_options_set_split_and(never, TRACKPARSE_SPLIT_AND_NEVER);
+list = trackparse_parse_artists_with("Crosby, Stills, Nash and Young", TRACKPARSE_NUL_TERMINATED,
+                                     never);
+for (size_t i = 0; i < list->count; i++) printf("%s\n", list->items[i].name.ptr);
+// Crosby
+// Stills
+// Nash and Young
+trackparse_artists_free(list);
+trackparse_parse_options_free(never);
+```
+
 
 
 
@@ -325,6 +410,27 @@ for _, s := range []string{
 // "Dua Lipa" featured "with" title
 ```
 
+
+
+
+```c
+const char *inputs[] = {
+    "Noisia feat. Foreign Beggars - Shellshock",
+    "Noisia - Shellshock ft. Foreign Beggars",
+    "Silk City - Electricity (with Dua Lipa)",
+};
+for (size_t i = 0; i < 3; i++) {
+  t = trackparse_parse(inputs[i], TRACKPARSE_NUL_TERMINATED);
+  const trackparse_artist *a = &t->artists[1];
+  printf("%s | %s | %s | %s\n", a->name.ptr, trackparse_role_name(a->role), a->joiner->ptr,
+         trackparse_source_name(a->source));
+  trackparse_track_free(t);
+}
+// Foreign Beggars | featured | feat. | artist
+// Foreign Beggars | featured | ft. | title
+// Dua Lipa | featured | with | title
+```
+
 
 
 
@@ -363,6 +469,18 @@ fmt.Printf("%q\n", names(trackparse.Parse("Noisia feat. Foreign Beggars - Shells
 // ["Noisia" "Foreign Beggars"]
 ```
 
+
+
+
+```c
+t = trackparse_parse("Noisia feat. Foreign Beggars - Shellshock (feat. Foreign Beggars)",
+                     TRACKPARSE_NUL_TERMINATED);
+for (size_t i = 0; i < t->artists_count; i++) printf("%s\n", t->artists[i].name.ptr);
+// Noisia
+// Foreign Beggars
+trackparse_track_free(t);
+```
+
 
 
 
@@ -416,12 +534,24 @@ fmt.Printf("%q %s %q %s\n", a.Name, a.Role, *a.Joiner, a.Source)   // "Metro Boo
 fmt.Printf("%q\n", t.Title)                                         // "Mask Off"
 ```
 
+
+
+
+```c
+t = trackparse_parse("Future - Mask Off (prod. by Metro Boomin)", TRACKPARSE_NUL_TERMINATED);
+const trackparse_artist *a = &t->artists[1];
+printf("%s | %s | %s | %s\n", a->name.ptr, trackparse_role_name(a->role), a->joiner->ptr,
+       trackparse_source_name(a->source));   // Metro Boomin | producer | prod. by | title
+printf("%s\n", t->title.ptr);                // Mask Off
+trackparse_track_free(t);
+```
+
 
 
 
 ## knownArtists
 
-*(Python and Rust: `known_artists`; Go: `KnownArtists`)*
+*(Python and Rust: `known_artists`; Go: `KnownArtists`; C: `trackparse_parse_options_add_known_artist`)*
 
 trackparse has no artist database, on purpose. A built-in list would be wrong for half its users
 and out of date within a month. You tell it the names you care about:
@@ -472,6 +602,25 @@ fmt.Printf("%q\n", names(trackparse.ParseWith("Chase & Status - Baddadan", optio
 // ["Chase & Status"]
 ```
 
+
+
+
+```c
+t = trackparse_parse("Chase & Status - Baddadan", TRACKPARSE_NUL_TERMINATED);
+for (size_t i = 0; i < t->artists_count; i++) printf("%s\n", t->artists[i].name.ptr);
+// Chase
+// Status
+trackparse_track_free(t);
+
+trackparse_parse_options *options = trackparse_parse_options_new();
+trackparse_parse_options_add_known_artist(options, "Chase & Status", TRACKPARSE_NUL_TERMINATED);
+t = trackparse_parse_with("Chase & Status - Baddadan", TRACKPARSE_NUL_TERMINATED, options);
+for (size_t i = 0; i < t->artists_count; i++) printf("%s\n", t->artists[i].name.ptr);
+// Chase & Status
+trackparse_track_free(t);
+trackparse_parse_options_free(options);
+```
+
 
 
 
@@ -479,7 +628,7 @@ A known name is matched case- and accent-insensitively wherever a credit list st
 protects names that begin with digits from being read as a track number (`3 Doors Down`). If you
 parse a lot of strings with the same names, put them in
 [`createParser`](/trackparse/reference/functions/#createparseroptions) (`create_parser` in Python,
-`Parser::new` in Rust, `NewParser` in Go). You can try it in the
+`Parser::new` in Rust, `NewParser` in Go, `trackparse_parser_new` in C). You can try it in the
 [playground](/trackparse/playground/#track=Chase%20%26%20Status%20-%20Baddadan&known=Chase%20%26%20Status).
 The option is listed under [Options](/trackparse/reference/options/#parse-options), and the
 matching rule is [R7.3](/trackparse/reference/spec/#r7-artist-side:~:text=R7.3%20Credit%2Dlist%20splitting) (a).
@@ -488,7 +637,7 @@ matching rule is [R7.3](/trackparse/reference/spec/#r7-artist-side:~:text=R7.3%2
 
 `ID` (and `Unknown`, `Untitled`, `?`, `???`) means the track hasn't been announced yet. It doesn't become a name.
 The track gets `flags.unknownArtist: true` (`flags.unknown_artist` in Python and Rust,
-`Flags.UnknownArtist` in Go) instead, and the same goes for titles
+`Flags.UnknownArtist` in Go, `flags.unknown_artist` in C) instead, and the same goes for titles
 ([R7.5](/trackparse/reference/spec/#r7-artist-side:~:text=R7.5%20Drops%20and%20unknowns), [R8.6](/trackparse/reference/spec/#r8-title-side:~:text=R8.6%20Unknown%20title);
 [open it in the playground](/trackparse/playground/#track=ID%20-%20ID%20%28ID%20Remix%29)):
 
@@ -536,6 +685,18 @@ fmt.Println(t.Flags.UnknownTitle)            // true
 fmt.Println(t.Versions[0].UnknownArtist)     // true
 ```
 
+
+
+
+```c
+t = trackparse_parse("ID - ID (ID Remix)", TRACKPARSE_NUL_TERMINATED);
+printf("%zu\n", t->artists_count);                                // 0
+printf("%s\n", t->flags.unknown_artist ? "true" : "false");       // true
+printf("%s\n", t->flags.unknown_title ? "true" : "false");        // true
+printf("%s\n", t->versions[0].unknown_artist ? "true" : "false"); // true
+trackparse_track_free(t);
+```
+
 
 
 
diff --git a/site/src/content/docs/guides/editing-tracklists.mdx b/site/src/content/docs/guides/editing-tracklists.mdx
index a237fee..bd3fd28 100644
--- a/site/src/content/docs/guides/editing-tracklists.mdx
+++ b/site/src/content/docs/guides/editing-tracklists.mdx
@@ -6,7 +6,7 @@ description: Fix times, shift whole sections, sort, insert and delete lines, and
 import { Tabs, TabItem } from "@astrojs/starlight/components";
 
 [`applyEdits(text, edits)`](/trackparse/reference/tracklist/#applyeditstext-edits-options)
-(`apply_edits` in Python and Rust, `ApplyEdits` in Go) takes a
+(`apply_edits` in Python and Rust, `ApplyEdits` in Go, `trackparse_apply_edits` in C) takes a
 tracklist as text and returns new text. It's built for editors: you get back the lines it changed, and every other line keeps its
 bytes and its line ending. The rules are [R13.9](/trackparse/reference/spec/#r139-edits) in the
 spec.
@@ -43,6 +43,13 @@ import (
 )
 ```
 
+
+
+
+```c
+#include 
+```
+
 
 
 
@@ -154,6 +161,51 @@ for _, line := range strings.Split(result.Text, "\r\n")[4:] {
 // 01:16:21 Hybris - Spinning Top
 ```
 
+
+
+
+```c
+/* text is the list from the previous page. */
+const char *text =
+    "Hour 2\r\n48:20 Noisia - Stigma\r\n52:47 Mefjus & Kasra - Bandwagon (Phace Remix)\r\n"
+    "56:05 Black Sun Empire - ID\r\n59:31 Alix Perez - Fade Away\r\n"
+    "01:03:10 Interview with Hybris\r\n01:07:44 Imanu - Sacrifice\r\n"
+    "00:11:02 Current Value feat. Teddy Killerz - Payload\r\n01:15:36 Hybris - Spinning Top";
+
+trackparse_tracklist *list = trackparse_parse_tracklist(text, TRACKPARSE_NUL_TERMINATED);
+const trackparse_suggestion *fix = list->warnings[1].suggestion;
+printf("%d %s %g\n", fix->line, fix->raw.ptr, fix->seconds);   // 8 01:11:02 4262
+
+trackparse_edits *edits = trackparse_edits_new();
+trackparse_edits_set_time(edits, fix->line, fix->seconds);
+trackparse_edits_shift_from(edits, 45, 5);
+trackparse_edit_result *result = trackparse_apply_edits(text, TRACKPARSE_NUL_TERMINATED, edits);
+trackparse_edits_free(edits);
+trackparse_tracklist_free(list);
+
+for (size_t i = 0; i < result->changed_count; i++) {
+  printf("%s%lld", i ? " " : "", result->changed[i]);
+}
+printf("\n");   // 5 6 7 8 9
+for (size_t i = 0; i < result->warnings_count; i++) {
+  const trackparse_edit_warning *w = &result->warnings[i];
+  printf("%s %zu %lld\n", trackparse_edit_warning_code_name(w->code), w->edit, *w->line);
+}
+// style-upgraded 1 5
+const char *from = result->text.ptr;
+for (int n = 0; n < 4; n++) from = strstr(from, "\r\n") + 2;   /* skip lines 1 to 4 */
+for (const char *c = from; *c; c++) {
+  if (*c != '\r') putchar(*c);
+}
+putchar('\n');
+// 01:00:16 Alix Perez - Fade Away
+// 01:03:55 Interview with Hybris
+// 01:08:29 Imanu - Sacrifice
+// 01:11:47 Current Value feat. Teddy Killerz - Payload
+// 01:16:21 Hybris - Spinning Top
+trackparse_edit_result_free(result);
+```
+
 
 
 
@@ -162,6 +214,11 @@ In JavaScript an edit is an object with an `op`. In Python it is a plain dict wi
 with a function per edit: `Edit::set_time(line, seconds)`, `Edit::shift_from(seconds, from)`. In Go
 it is an [`Edit`](https://pkg.go.dev/github.com/4matic/trackparse/go#Edit) struct, made with a function per edit as well:
 [`trackparse.SetTime(line, seconds)`](https://pkg.go.dev/github.com/4matic/trackparse/go#SetTime), [`trackparse.ShiftFrom(seconds, from)`](https://pkg.go.dev/github.com/4matic/trackparse/go#ShiftFrom).
+In C the edits go into a `trackparse_edits` list from `trackparse_edits_new()`, one call per edit
+(`trackparse_edits_set_time(edits, line, seconds)`, `trackparse_edits_shift_from(edits, seconds, from)`),
+declared in [`trackparse.h`](https://github.com/4matic/trackparse/blob/main/c/include/trackparse.h).
+The list copies what it is given, so it can be freed as soon as `trackparse_apply_edits` returns;
+the result is freed with `trackparse_edit_result_free`.
 
 Lines 1 to 4 are untouched, CRLF included ([R13.9.1](/trackparse/reference/spec/#r139-edits:~:text=R13.9.1%20Locality)). Edits run in
 order, each on the text the previous one produced, with line numbers as that text has them. The
@@ -171,18 +228,19 @@ does the same with buttons: the suggested fix, a shift and a sort, with undo.
 ## The edits
 
 There are six edits. JavaScript and Python write them the same way, as an object or a dict. Rust
-and Go have a constructor for each:
-
-| JavaScript and Python | Rust | Go | Effect |
-|---|---|---|---|
-| `{ op: "set-time", line, seconds }` | `Edit::set_time(line, seconds)` | `SetTime(line, seconds)` | Rewrite the time on that line |
-| `{ op: "shift", seconds }` | `Edit::shift(seconds)` | `Shift(seconds)` | Add `seconds` (negative to go back) to every timed line |
-| `{ op: "shift", seconds, from }` | `Edit::shift_from(seconds, from)` | `ShiftFrom(seconds, from)` | The same, for every timed line from line `from` on |
-| `{ op: "shift", seconds, lines }` | `Edit::shift_lines(seconds, lines)` | `ShiftLines(seconds, lines...)` | The same, for the listed lines only |
-| `{ op: "sort-by-time" }` | `Edit::sort_by_time()` | `SortByTime()` | Reorder by time. Untimed lines move with the timed line above them, and lines before the first time stay on top |
-| `{ op: "set-rest", line, rest }` | `Edit::set_rest(line, rest)` | `SetRest(line, rest)` | Replace everything after the time, for example with `format(track)` ([`format_track`](/trackparse/reference/functions/#formattrack-options), Go `Format`) |
-| `{ op: "insert", after, text }` | `Edit::insert(after, text)` | `Insert(after, text)` | Insert a line after line `after` (`0` puts it at the top). It gets the text's usual line ending |
-| `{ op: "delete", line }` | `Edit::delete(line)` | `Delete(line)` | Remove a line |
+and Go have a constructor for each, and C a function that appends it to a `trackparse_edits` list
+(shortened here to the part after `trackparse_edits_`):
+
+| JavaScript and Python | Rust | Go | C | Effect |
+|---|---|---|---|---|
+| `{ op: "set-time", line, seconds }` | `Edit::set_time(line, seconds)` | `SetTime(line, seconds)` | `set_time(e, line, seconds)` | Rewrite the time on that line |
+| `{ op: "shift", seconds }` | `Edit::shift(seconds)` | `Shift(seconds)` | `shift(e, seconds)` | Add `seconds` (negative to go back) to every timed line |
+| `{ op: "shift", seconds, from }` | `Edit::shift_from(seconds, from)` | `ShiftFrom(seconds, from)` | `shift_from(e, seconds, from)` | The same, for every timed line from line `from` on |
+| `{ op: "shift", seconds, lines }` | `Edit::shift_lines(seconds, lines)` | `ShiftLines(seconds, lines...)` | `shift_lines(e, seconds, lines, count)` | The same, for the listed lines only |
+| `{ op: "sort-by-time" }` | `Edit::sort_by_time()` | `SortByTime()` | `sort_by_time(e)` | Reorder by time. Untimed lines move with the timed line above them, and lines before the first time stay on top |
+| `{ op: "set-rest", line, rest }` | `Edit::set_rest(line, rest)` | `SetRest(line, rest)` | `set_rest(e, line, rest, len)` | Replace everything after the time, for example with `format(track)` ([`format_track`](/trackparse/reference/functions/#formattrack-options), Go `Format`, C `trackparse_format`) |
+| `{ op: "insert", after, text }` | `Edit::insert(after, text)` | `Insert(after, text)` | `insert(e, after, text, len)` | Insert a line after line `after` (`0` puts it at the top). It gets the text's usual line ending |
+| `{ op: "delete", line }` | `Edit::delete(line)` | `Delete(line)` | `delete(e, line)` | Remove a line |
 
 In Python the dict keys are quoted: `{"op": "set-time", "line": 3, "seconds": 90}`. Line numbers
 start at 1. Sorting is [R13.9.4](/trackparse/reference/spec/#r139-edits:~:text=R13.9.4%20Sort), and inserting and deleting
@@ -276,6 +334,39 @@ fmt.Printf("%q\n", tidy.Text)   // "00:00 Noisia - Stigma\n04:10 Mefjus feat. Ph
 fmt.Println(tidy.Changed)       // [1 2 3]
 ```
 
+
+
+
+```c
+const char *messy = "04:10 Mefjus ft. Phace - Sleepless\n00:00 Noisia - Stigma\n09:30 Outro";
+list = trackparse_parse_tracklist(messy, TRACKPARSE_NUL_TERMINATED);
+trackparse_format_options *canonical = trackparse_format_options_new();
+trackparse_format_options_set_joiners(canonical, TRACKPARSE_JOINERS_CANONICAL);
+trackparse_string *rest = trackparse_format_with(list->entries[0].track, canonical);
+printf("%s\n", rest->str.ptr);   // Mefjus feat. Phace - Sleepless
+
+edits = trackparse_edits_new();
+trackparse_edits_sort_by_time(edits);
+trackparse_edits_set_rest(edits, 2, rest->str.ptr, rest->str.len);
+trackparse_edits_insert(edits, 2, "06:45 Phace - Psycho", TRACKPARSE_NUL_TERMINATED);
+trackparse_edits_delete(edits, 4);
+trackparse_edit_result *tidy = trackparse_apply_edits(messy, TRACKPARSE_NUL_TERMINATED, edits);
+
+printf("%s\n", tidy->text.ptr);
+// 00:00 Noisia - Stigma
+// 04:10 Mefjus feat. Phace - Sleepless
+// 06:45 Phace - Psycho
+for (size_t i = 0; i < tidy->changed_count; i++) {
+  printf("%s%lld", i ? " " : "", tidy->changed[i]);
+}
+printf("\n");   // 1 2 3
+trackparse_edit_result_free(tidy);
+trackparse_edits_free(edits);
+trackparse_string_free(rest);
+trackparse_format_options_free(canonical);
+trackparse_tracklist_free(list);
+```
+
 
 
 
@@ -350,6 +441,27 @@ for _, w := range result.Warnings {
 // style-upgraded 0 2
 ```
 
+
+
+
+```c
+text = "**[**52:47**] Mefjus - Bandwagon**\n**[**59:31**] Alix Perez - Fade Away**";
+edits = trackparse_edits_new();
+trackparse_edits_shift(edits, 45);
+result = trackparse_apply_edits(text, TRACKPARSE_NUL_TERMINATED, edits);
+
+printf("%s\n", result->text.ptr);
+// **[**53:32**] Mefjus - Bandwagon**
+// **[**01:00:16**] Alix Perez - Fade Away**
+for (size_t i = 0; i < result->warnings_count; i++) {
+  const trackparse_edit_warning *w = &result->warnings[i];
+  printf("%s %zu %lld\n", trackparse_edit_warning_code_name(w->code), w->edit, *w->line);
+}
+// style-upgraded 0 2
+trackparse_edit_result_free(result);
+trackparse_edits_free(edits);
+```
+
 
 
 
@@ -363,7 +475,8 @@ Edits never throw or panic. A bad one changes nothing and reports why
 ([R13.9.6](/trackparse/reference/spec/#r139-edits:~:text=R13.9.6%20Totality)). In Rust the codes are the enum
 [`EditWarningCode`](https://docs.rs/trackparse/latest/trackparse/tracklist/enum.EditWarningCode.html) (`EditInvalid`, `TimeClamped`,
 `StyleUpgraded`), in Go the string type [`EditWarningCode`](https://pkg.go.dev/github.com/4matic/trackparse/go#EditWarningCode)
-(`trackparse.EditWarningCodeEditInvalid` and so on):
+(`trackparse.EditWarningCodeEditInvalid` and so on), in C the enum `trackparse_edit_warning_code`
+(`TRACKPARSE_EDIT_WARNING_EDIT_INVALID` and so on):
 
 | Code | When |
 |---|---|
@@ -372,7 +485,7 @@ Edits never throw or panic. A bad one changes nothing and reports why
 | `style-upgraded` | a time gained hours (see above) |
 
 Each edit warning is `{ code, edit, line }`, where `edit` is the index in your `edits` array and
-`line` is `null` (`None` in Python and Rust, a `nil` `*int` in Go) when the edit doesn't name a line.
+`line` is `null` (`None` in Python and Rust, a `nil` `*int` in Go, a `NULL` `const long long *` in C) when the edit doesn't name a line.
 [Warnings](/trackparse/reference/warnings/#edit-warnings) shows how to check them in each language.
 
 ## Guarantees
diff --git a/site/src/content/docs/guides/formatting.mdx b/site/src/content/docs/guides/formatting.mdx
index 294e53c..06ec603 100644
--- a/site/src/content/docs/guides/formatting.mdx
+++ b/site/src/content/docs/guides/formatting.mdx
@@ -10,6 +10,9 @@ track back to a string. In Python it is `format_track(track, **options)`. In Rus
 [`format_track(&track)`](https://docs.rs/trackparse/latest/trackparse/fn.format_track.html), or
 [`format_track_with(&track, &options)`](https://docs.rs/trackparse/latest/trackparse/fn.format_track_with.html) with options. In Go it is
 [`trackparse.Format(track)`](https://pkg.go.dev/github.com/4matic/trackparse/go#Format), or [`trackparse.FormatWith(track, options)`](https://pkg.go.dev/github.com/4matic/trackparse/go#FormatWith).
+In C it is `trackparse_format(track)`, or `trackparse_format_with(track, options)`, and the
+string it returns is freed with `trackparse_string_free`
+([`trackparse.h`](https://github.com/4matic/trackparse/blob/main/c/include/trackparse.h)).
 Use it to bring a messy library to one style, or to build a display title without the junk. The
 rules are [R11](/trackparse/reference/spec/#r11-format) in the spec.
 
@@ -73,6 +76,22 @@ fmt.Printf("%q\n", trackparse.Format(t))
 // "Wilkinson ft. Becky Hill & Tom Cane - Afterglow (Sub Focus VIP Remix)"
 ```
 
+
+
+
+```c
+#include 
+
+trackparse_track *t = trackparse_parse(
+    "01. Wilkinson ft. Becky Hill & Tom Cane - Afterglow (Sub Focus VIP Remix) [Official Video]",
+    TRACKPARSE_NUL_TERMINATED);
+
+trackparse_string *s = trackparse_format(t);
+printf("%s\n", s->str.ptr);
+// Wilkinson ft. Becky Hill & Tom Cane - Afterglow (Sub Focus VIP Remix)
+trackparse_string_free(s);
+```
+
 
 
 
@@ -97,16 +116,19 @@ values are enums ([`FeatPlacement`](https://docs.rs/trackparse/latest/trackparse
 takes a [`FormatOptions`](https://pkg.go.dev/github.com/4matic/trackparse/go#FormatOptions) struct whose zero value is the default, and the values
 are typed string constants ([`FeatPlacement`](https://pkg.go.dev/github.com/4matic/trackparse/go#FeatPlacement), [`JoinerStyle`](https://pkg.go.dev/github.com/4matic/trackparse/go#JoinerStyle),
 [`VersionsOption`](https://pkg.go.dev/github.com/4matic/trackparse/go#VersionsOption)); [`trackparse.Ptr`](https://pkg.go.dev/github.com/4matic/trackparse/go#Ptr) sets `FeatMarker`.
-Since a Go `bool` field defaults to `false`, `producers` becomes `OmitProducers`:
-
-| Option | Python | Rust | Go |
-|---|---|---|---|
-| `feat` | `feat="title"` | `.feat(FeatPlacement::Title)`: `Source`, `Artist`, `Title`, `Omit` | `Feat: trackparse.FeatTitle`: `FeatSource`, `FeatArtist`, `FeatTitle`, `FeatOmit` |
-| `featMarker` | `feat_marker="featuring"` | `.feat_marker("featuring")` | `FeatMarker: trackparse.Ptr("featuring")` (a `*string`) |
-| `joiners` | `joiners="canonical"` | `.joiners(JoinerStyle::Canonical)`: `Original`, `Canonical` | `Joiners: trackparse.JoinersCanonical`: `JoinersOriginal`, `JoinersCanonical` |
-| `versions` | `versions="none"` | `.versions(VersionsOption::None)`: `All`, `None` | `Versions: trackparse.VersionsNone`: `VersionsAll`, `VersionsNone` |
-| `producers` | `producers=False` | `.producers(false)` | `OmitProducers: true` |
-| `position` | `position=True` | `.position(true)` | `Position: true` |
+Since a Go `bool` field defaults to `false`, `producers` becomes `OmitProducers`. C takes a
+`trackparse_format_options` handle from `trackparse_format_options_new()`, with one setter per
+option and C enums for the values; an option you don't set keeps its default, and
+`trackparse_format_options_free` releases the handle:
+
+| Option | Python | Rust | Go | C |
+|---|---|---|---|---|
+| `feat` | `feat="title"` | `.feat(FeatPlacement::Title)`: `Source`, `Artist`, `Title`, `Omit` | `Feat: trackparse.FeatTitle`: `FeatSource`, `FeatArtist`, `FeatTitle`, `FeatOmit` | `trackparse_format_options_set_feat(o, TRACKPARSE_FEAT_TITLE)`: `_SOURCE`, `_ARTIST`, `_TITLE`, `_OMIT` |
+| `featMarker` | `feat_marker="featuring"` | `.feat_marker("featuring")` | `FeatMarker: trackparse.Ptr("featuring")` (a `*string`) | `trackparse_format_options_set_feat_marker(o, "featuring", TRACKPARSE_NUL_TERMINATED)` |
+| `joiners` | `joiners="canonical"` | `.joiners(JoinerStyle::Canonical)`: `Original`, `Canonical` | `Joiners: trackparse.JoinersCanonical`: `JoinersOriginal`, `JoinersCanonical` | `trackparse_format_options_set_joiners(o, TRACKPARSE_JOINERS_CANONICAL)`: `_ORIGINAL`, `_CANONICAL` |
+| `versions` | `versions="none"` | `.versions(VersionsOption::None)`: `All`, `None` | `Versions: trackparse.VersionsNone`: `VersionsAll`, `VersionsNone` | `trackparse_format_options_set_versions(o, TRACKPARSE_VERSIONS_NONE)`: `_ALL`, `_NONE` |
+| `producers` | `producers=False` | `.producers(false)` | `OmitProducers: true` | `trackparse_format_options_set_omit_producers(o, true)` |
+| `position` | `position=True` | `.position(true)` | `Position: true` | `trackparse_format_options_set_position(o, true)` |
 
 
 
@@ -209,6 +231,67 @@ fmt.Printf("%q\n", trackparse.FormatWith(
 // "Future - Mask Off"
 ```
 
+
+
+
+```c
+trackparse_format_options *o = trackparse_format_options_new();
+trackparse_format_options_set_feat(o, TRACKPARSE_FEAT_TITLE);
+s = trackparse_format_with(t, o);
+printf("%s\n", s->str.ptr);
+// Wilkinson - Afterglow (ft. Becky Hill & Tom Cane) (Sub Focus VIP Remix)
+trackparse_string_free(s);
+
+trackparse_format_options_set_joiners(o, TRACKPARSE_JOINERS_CANONICAL);
+s = trackparse_format_with(t, o);
+printf("%s\n", s->str.ptr);
+// Wilkinson - Afterglow (feat. Becky Hill & Tom Cane) (Sub Focus VIP Remix)
+trackparse_string_free(s);
+trackparse_format_options_free(o);
+
+o = trackparse_format_options_new();
+trackparse_format_options_set_feat(o, TRACKPARSE_FEAT_ARTIST);
+trackparse_format_options_set_feat_marker(o, "featuring", TRACKPARSE_NUL_TERMINATED);
+s = trackparse_format_with(t, o);
+printf("%s\n", s->str.ptr);
+// Wilkinson featuring Becky Hill & Tom Cane - Afterglow (Sub Focus VIP Remix)
+trackparse_string_free(s);
+trackparse_format_options_free(o);
+
+o = trackparse_format_options_new();
+trackparse_format_options_set_feat(o, TRACKPARSE_FEAT_OMIT);
+s = trackparse_format_with(t, o);
+printf("%s\n", s->str.ptr);   // Wilkinson - Afterglow (Sub Focus VIP Remix)
+trackparse_string_free(s);
+trackparse_format_options_free(o);
+
+o = trackparse_format_options_new();
+trackparse_format_options_set_versions(o, TRACKPARSE_VERSIONS_NONE);
+s = trackparse_format_with(t, o);
+printf("%s\n", s->str.ptr);   // Wilkinson ft. Becky Hill & Tom Cane - Afterglow
+trackparse_string_free(s);
+trackparse_format_options_free(o);
+
+o = trackparse_format_options_new();
+trackparse_format_options_set_position(o, true);
+s = trackparse_format_with(t, o);
+printf("%s\n", s->str.ptr);
+// 01. Wilkinson ft. Becky Hill & Tom Cane - Afterglow (Sub Focus VIP Remix)
+trackparse_string_free(s);
+trackparse_format_options_free(o);
+
+trackparse_track *mask = trackparse_parse("Future - Mask Off (prod. by Metro Boomin)",
+                                          TRACKPARSE_NUL_TERMINATED);
+o = trackparse_format_options_new();
+trackparse_format_options_set_omit_producers(o, true);
+s = trackparse_format_with(mask, o);
+printf("%s\n", s->str.ptr);   // Future - Mask Off
+trackparse_string_free(s);
+trackparse_format_options_free(o);
+trackparse_track_free(mask);
+trackparse_track_free(t);
+```
+
 
 
 
@@ -259,6 +342,21 @@ again := trackparse.Parse(trackparse.Format(trackparse.Parse(s)))
 fmt.Printf("%q\n", again.FullTitle)   // "Shellshock (Phace Remix)"
 ```
 
+
+
+
+```c
+const char *in = "Noisia feat. Foreign Beggars - Shellshock (Phace Remix)";
+/* same artists, title and versions as trackparse_parse(in, ...): */
+trackparse_track *first = trackparse_parse(in, TRACKPARSE_NUL_TERMINATED);
+trackparse_string *written = trackparse_format(first);
+trackparse_track *again = trackparse_parse(written->str.ptr, written->str.len);
+printf("%s\n", again->full_title.ptr);   // Shellshock (Phace Remix)
+trackparse_track_free(again);
+trackparse_string_free(written);
+trackparse_track_free(first);
+```
+
 
 
 
diff --git a/site/src/content/docs/guides/junk-and-flags.mdx b/site/src/content/docs/guides/junk-and-flags.mdx
index 66cb3c2..1f63cf6 100644
--- a/site/src/content/docs/guides/junk-and-flags.mdx
+++ b/site/src/content/docs/guides/junk-and-flags.mdx
@@ -59,6 +59,23 @@ fmt.Printf("%q\n", t.Title)   // "One More Time"
 fmt.Printf("%+v\n", t.Junk)   // [{Raw:Official Music Video Kind:video} {Raw:HD Kind:quality}]
 ```
 
+
+
+
+```c
+#include 
+
+trackparse_track *t = trackparse_parse("Daft Punk - One More Time (Official Music Video) [HD]",
+                                       TRACKPARSE_NUL_TERMINATED);
+printf("%s\n", t->title.ptr);   // One More Time
+for (size_t i = 0; i < t->junk_count; i++) {
+  printf("%s: %s\n", t->junk[i].kind_name.ptr, t->junk[i].raw.ptr);
+}
+// video: Official Music Video
+// quality: HD
+trackparse_track_free(t);
+```
+
 
 
 
@@ -86,6 +103,10 @@ In Rust the kind is the enum [`JunkKind`](https://docs.rs/trackparse/latest/trac
 `JunkKind::Quality` and so on). Its `as_str()` gives the lowercase names in the table. In Go the
 kind is the string type [`JunkKind`](https://pkg.go.dev/github.com/4matic/trackparse/go#JunkKind),
 and its constants (`trackparse.JunkKindVideo`, `trackparse.JunkKindQuality`) hold those names.
+In C the kind is the enum `trackparse_junk_kind` (`TRACKPARSE_JUNK_VIDEO` and so on), and
+`kind_name` holds the name as a string. The two differ only for a kind that
+[`keywords.junk`](/trackparse/reference/options/#keywords) introduced: `kind` is then
+`TRACKPARSE_JUNK_OTHER` and `kind_name` the new name.
 
 
 
@@ -119,6 +140,18 @@ fmt.Printf("%+v\n", trackparse.Parse("Porter Robinson - Shelter - YouTube").Junk
 fmt.Printf("%+v\n", trackparse.Parse("Elektronomia - Sky High [NCS Release]").Junk)   // [{Raw:NCS Release Kind:label}]
 ```
 
+
+
+
+```c
+t = trackparse_parse("Porter Robinson - Shelter - YouTube", TRACKPARSE_NUL_TERMINATED);
+printf("%s: %s\n", t->junk[0].kind_name.ptr, t->junk[0].raw.ptr);   // platform: YouTube
+trackparse_track_free(t);
+t = trackparse_parse("Elektronomia - Sky High [NCS Release]", TRACKPARSE_NUL_TERMINATED);
+printf("%s: %s\n", t->junk[0].kind_name.ptr, t->junk[0].raw.ptr);   // label: NCS Release
+trackparse_track_free(t);
+```
+
 
 
 
@@ -164,13 +197,24 @@ fmt.Printf("%+v\n", trackparse.Parse("Eminem - Without Me (Explicit)").Flags)
 // {Explicit:true Clean:false UnknownArtist:false UnknownTitle:false}
 ```
 
+
+
+
+```c
+t = trackparse_parse("Eminem - Without Me (Explicit)", TRACKPARSE_NUL_TERMINATED);
+printf("explicit %d, clean %d, unknown_artist %d, unknown_title %d\n", t->flags.explicit_,
+       t->flags.clean, t->flags.unknown_artist, t->flags.unknown_title);
+// explicit 1, clean 0, unknown_artist 0, unknown_title 0
+trackparse_track_free(t);
+```
+
 
 
 
 `explicit` and `clean` come from `(Explicit)`, `[Clean]` and the like
 ([R5.4](/trackparse/reference/spec/#r5-group-classification:~:text=R5.4%20Flag); [try it](/trackparse/playground/#track=Eminem%20-%20Without%20Me%20%28Explicit%29)). `unknownArtist` and
 `unknownTitle` (`unknown_artist` and `unknown_title` in Python and Rust, `UnknownArtist` and `UnknownTitle` in
-Go) are set when the artist
+Go, `unknown_artist` and `unknown_title` in C) are set when the artist
 or title is a placeholder such as `ID`. See
 [Unknown artists](/trackparse/guides/artists/#unknown-artists).
 
@@ -216,11 +260,22 @@ fmt.Printf("%q\n", t.Title)   // "Stigma"
 fmt.Println(*t.Year)          // 2015
 ```
 
+
+
+
+```c
+t = trackparse_parse("Noisia - Stigma (2015)", TRACKPARSE_NUL_TERMINATED);
+printf("%s\n", t->title.ptr);       // Stigma
+if (t->year) printf("%d\n", *t->year);   // 2015
+trackparse_track_free(t);
+```
+
 
 
 
 A year inside a version (`Remastered 2015`) belongs to that version instead, in `versions[i].year`.
-In Rust both are `Option`; in Go both are `*int`, `nil` when there is no year.
+In Rust both are `Option`; in Go both are `*int`, `nil` when there is no year; in C both
+are `const int *`, `NULL` when there is no year.
 [Try it](/trackparse/playground/#track=Noisia%20-%20Stigma%20%282015%29) in the playground.
 
 ## Track numbers
@@ -257,6 +312,18 @@ fmt.Printf("%+v\n", *trackparse.Parse("01. Aphex Twin - Xtal").Position)   // {R
 fmt.Println(trackparse.Parse("2 Unlimited - No Limit").Position == nil)    // true
 ```
 
+
+
+
+```c
+t = trackparse_parse("01. Aphex Twin - Xtal", TRACKPARSE_NUL_TERMINATED);
+printf("%s %d\n", t->position->raw.ptr, t->position->number);   // 01 1
+trackparse_track_free(t);
+t = trackparse_parse("2 Unlimited - No Limit", TRACKPARSE_NUL_TERMINATED);
+printf("%s\n", t->position == NULL ? "NULL" : "set");            // NULL
+trackparse_track_free(t);
+```
+
 
 
 
@@ -311,11 +378,23 @@ fmt.Printf("%+v\n", *trackparse.Parse("[12:34] Noisia - Stigma").Timestamp)   //
 fmt.Printf("%+v\n", *trackparse.Parse("1:02:03 Noisia - Stigma").Timestamp)   // {Raw:1:02:03 Seconds:3723}
 ```
 
+
+
+
+```c
+t = trackparse_parse("[12:34] Noisia - Stigma", TRACKPARSE_NUL_TERMINATED);
+printf("%s %d\n", t->timestamp->raw.ptr, t->timestamp->seconds);   // 12:34 754
+trackparse_track_free(t);
+t = trackparse_parse("1:02:03 Noisia - Stigma", TRACKPARSE_NUL_TERMINATED);
+printf("%s %d\n", t->timestamp->raw.ptr, t->timestamp->seconds);   // 1:02:03 3723
+trackparse_track_free(t);
+```
+
 
 
 
 For whole tracklists with a time on every line, use [`parseTracklist`](/trackparse/guides/tracklists/)
-(`parse_tracklist` in Python and Rust, `ParseTracklist` in Go) instead. It reads more time formats and checks the order.
+(`parse_tracklist` in Python and Rust, `ParseTracklist` in Go, `trackparse_parse_tracklist` in C) instead. It reads more time formats and checks the order.
 
 ## See also
 
diff --git a/site/src/content/docs/guides/modes.mdx b/site/src/content/docs/guides/modes.mdx
index 9bf0a8a..76edd84 100644
--- a/site/src/content/docs/guides/modes.mdx
+++ b/site/src/content/docs/guides/modes.mdx
@@ -23,7 +23,9 @@ The resolved mode is in `track.mode`, so you can always see which one ran. You p
 [`ModeOption`](https://docs.rs/trackparse/latest/trackparse/enum.ModeOption.html) and the resolved mode is [`Mode`](https://docs.rs/trackparse/latest/trackparse/enum.Mode.html),
 which has no `Auto`. In Go both are the string type [`Mode`](https://pkg.go.dev/github.com/4matic/trackparse/go#Mode):
 [`trackparse.ModeAuto`](https://pkg.go.dev/github.com/4matic/trackparse/go#ModeAuto) (`"auto"`) asks for auto, an empty `Mode` in `ParseOptions`
-means auto too, and `Track.Mode` is never `ModeAuto`. The mode rules are
+means auto too, and `Track.Mode` is never `ModeAuto`. In C both are the enum `trackparse_mode`:
+`TRACKPARSE_MODE_AUTO` is the default of `trackparse_parse_options_set_mode`, and a result's
+`mode` is never `TRACKPARSE_MODE_AUTO`; `trackparse_mode_name` gives the name. The mode rules are
 [R2](/trackparse/reference/spec/#r2-mode-prelude) in the spec.
 
 ## How auto decides
@@ -101,6 +103,25 @@ fmt.Printf("%s %q %+v\n", t.Mode, t.Title, t.Junk)
 // youtube "Stigma" [{Raw:Official Video Kind:video}]
 ```
 
+
+
+
+```c
+#include 
+
+trackparse_track *t = trackparse_parse("07_Burial_-_Archangel.mp3", TRACKPARSE_NUL_TERMINATED);
+printf("%s %d %s / %s\n", trackparse_mode_name(t->mode), t->position->number,
+       t->artists[0].name.ptr, t->title.ptr);
+// filename 7 Burial / Archangel
+trackparse_track_free(t);
+
+t = trackparse_parse("Noisia - Stigma | Official Video", TRACKPARSE_NUL_TERMINATED);
+printf("%s %s %s: %s\n", trackparse_mode_name(t->mode), t->title.ptr, t->junk[0].kind_name.ptr,
+       t->junk[0].raw.ptr);
+// youtube Stigma video: Official Video
+trackparse_track_free(t);
+```
+
 
 
 
@@ -183,6 +204,32 @@ fmt.Printf("%q %q %v\n", t.Artists[0].Name, t.Title, t.Warnings)
 // "Blink-182" "All The Small Things" [unspacedDashSplit]
 ```
 
+
+
+
+```c
+trackparse_parse_options *youtube = trackparse_parse_options_new();
+trackparse_parse_options_set_mode(youtube, TRACKPARSE_MODE_YOUTUBE);
+
+t = trackparse_parse_with("\"Numb\" by Linkin Park", TRACKPARSE_NUL_TERMINATED, youtube);
+printf("%s / %s / %s\n", t->artists[0].name.ptr, t->title.ptr,
+       trackparse_warning_name(t->warnings[0]));
+// Linkin Park / Numb / bySplit
+trackparse_track_free(t);
+
+t = trackparse_parse_with("Linkin Park: \"Numb\"", TRACKPARSE_NUL_TERMINATED, youtube);
+printf("%s / %s / %s\n", t->artists[0].name.ptr, t->title.ptr,
+       trackparse_warning_name(t->warnings[0]));
+// Linkin Park / Numb / quotedTitleSplit
+trackparse_track_free(t);
+
+t = trackparse_parse_with("Blink-182-All The Small Things", TRACKPARSE_NUL_TERMINATED, youtube);
+printf("%s / %s / %s\n", t->artists[0].name.ptr, t->title.ptr,
+       trackparse_warning_name(t->warnings[0]));
+// Blink-182 / All The Small Things / unspacedDashSplit
+trackparse_track_free(t);
+```
+
 
 
 
@@ -234,6 +281,18 @@ fmt.Printf("%q %q\n", t.Artists[0].Name, t.Title)
 // "Daft Punk" "Around the World"
 ```
 
+
+
+
+```c
+trackparse_parse_options_set_uploader(youtube, "Daft Punk - Topic", TRACKPARSE_NUL_TERMINATED);
+t = trackparse_parse_with("Around the World", TRACKPARSE_NUL_TERMINATED, youtube);
+printf("%s / %s / %zu warnings\n", t->artists[0].name.ptr, t->title.ptr, t->warnings_count);
+// Daft Punk / Around the World / 0 warnings
+trackparse_track_free(t);
+trackparse_parse_options_free(youtube);
+```
+
 
 
 
@@ -280,6 +339,23 @@ fmt.Printf("%+v\n", *trackparse.Parse("311 - Amber.mp3").Position)             /
 fmt.Printf("%q\n", trackparse.Parse("311 - Amber").Artists[0].Name)            // "311"
 ```
 
+
+
+
+```c
+t = trackparse_parse("02_Aphex_Twin_-_Xtal.flac", TRACKPARSE_NUL_TERMINATED);
+printf("%s\n", t->artists[0].name.ptr);   // Aphex Twin
+trackparse_track_free(t);
+
+t = trackparse_parse("311 - Amber.mp3", TRACKPARSE_NUL_TERMINATED);
+printf("%s %d\n", t->position->raw.ptr, t->position->number);   // 311 311
+trackparse_track_free(t);
+
+t = trackparse_parse("311 - Amber", TRACKPARSE_NUL_TERMINATED);
+printf("%s\n", t->artists[0].name.ptr);   // 311
+trackparse_track_free(t);
+```
+
 
 
 
@@ -341,10 +417,29 @@ fmt.Printf("%q %q\n", t.Artists[0].Name, t.Title)
 // "Electrosoul System" "Liquid Metal"
 ```
 
+
+
+
+```c
+t = trackparse_parse("Electrosoul System - Liquid Metal", TRACKPARSE_NUL_TERMINATED);
+printf("%zu artists / %s / %s: %s\n", t->artists_count, t->title.ptr, t->junk[0].kind_name.ptr,
+       t->junk[0].raw.ptr);
+// 0 artists / Electrosoul System / genre: Liquid Metal
+trackparse_track_free(t);
+
+trackparse_parse_options *tracklist = trackparse_parse_options_new();
+trackparse_parse_options_set_mode(tracklist, TRACKPARSE_MODE_TRACKLIST);
+t = trackparse_parse_with("Electrosoul System - Liquid Metal", TRACKPARSE_NUL_TERMINATED, tracklist);
+printf("%s / %s / %zu junk\n", t->artists[0].name.ptr, t->title.ptr, t->junk_count);
+// Electrosoul System / Liquid Metal / 0 junk
+trackparse_track_free(t);
+trackparse_parse_options_free(tracklist);
+```
+
 
 
 
-[`parseTracklist`](/trackparse/guides/tracklists/) (`parse_tracklist` in Python and Rust, `ParseTracklist` in Go) uses this
+[`parseTracklist`](/trackparse/guides/tracklists/) (`parse_tracklist` in Python and Rust, `ParseTracklist` in Go, `trackparse_parse_tracklist` in C) uses this
 mode for every line. You only need to set it yourself when you parse tracklist lines one at a time.
 The playground can show [this line in tracklist mode](/trackparse/playground/#track=Electrosoul%20System%20-%20Liquid%20Metal&mode=tracklist).
 [Tracklist mode](/trackparse/guides/tracklists/#tracklist-mode) in the tracklist guide has more
diff --git a/site/src/content/docs/guides/tracklists.mdx b/site/src/content/docs/guides/tracklists.mdx
index 6c4c35a..16dd25d 100644
--- a/site/src/content/docs/guides/tracklists.mdx
+++ b/site/src/content/docs/guides/tracklists.mdx
@@ -7,7 +7,7 @@ import { Tabs, TabItem } from "@astrojs/starlight/components";
 
 Mixes and podcasts come with a tracklist: a block of text, one track per line, usually with a start
 time in front. [`parseTracklist`](/trackparse/reference/tracklist/#parsetracklisttext-options)
-(`parse_tracklist` in Python and Rust, `ParseTracklist` in Go) reads the whole block. Every line
+(`parse_tracklist` in Python and Rust, `ParseTracklist` in Go, `trackparse_parse_tracklist` in C) reads the whole block. Every line
 gets its kind, its time and a full [`ParsedTrack`](/trackparse/reference/parse/). The list as a
 whole gets checks with line numbers. The rules are [R13](/trackparse/reference/spec/#r13-tracklists)
 in the spec, and every field is listed in the [Tracklist API](/trackparse/reference/tracklist/).
@@ -44,6 +44,13 @@ import (
 )
 ```
 
+
+
+
+```c
+#include 
+```
+
 
 
 
@@ -51,7 +58,9 @@ In JavaScript it's a separate entry point, `trackparse/tracklist`, about 8.4 KiB
 that only parses single tracks never loads it. In Python it is the module `trackparse.tracklist`,
 in Rust the module [`trackparse::tracklist`](https://docs.rs/trackparse/latest/trackparse/tracklist/index.html). Go has no separate entry:
 [`trackparse.ParseTracklist`](https://pkg.go.dev/github.com/4matic/trackparse/go#ParseTracklist) and [`trackparse.ApplyEdits`](https://pkg.go.dev/github.com/4matic/trackparse/go#ApplyEdits)
-are in the one package.
+are in the one package. C has none either: `trackparse_parse_tracklist` and
+`trackparse_apply_edits` are declared in the one header,
+[`trackparse.h`](https://github.com/4matic/trackparse/blob/main/c/include/trackparse.h).
 
 Two things differ in Rust. Seconds are `f64`, since a time can carry a fraction, so `Debug` prints
 `3167.0` where JavaScript and Python print `3167`. `to_json()` writes `3167`, as JavaScript and
@@ -61,6 +70,11 @@ And `entry.time` and `entry.track` are `Option`s, because a header or a blank li
 Go is like Rust here. `Seconds` is a `float64`, which `fmt` prints as `3167`, and `json.Marshal`
 writes `3167`. `Time` and `Track` are pointers, `nil` on a header or a blank line.
 
+C is like Go. `seconds` is a `double` (the examples print it with `%g`), and
+`trackparse_tracklist_to_json` writes `3167`. `time` and `track` are pointers, `NULL` on a header
+or a blank line. The result owns all its memory, entries and their tracks included, and
+`trackparse_tracklist_free` releases it.
+
 ## A first list
 
 
@@ -207,6 +221,51 @@ s := list.Stats
 fmt.Println(s.Lines, s.Tracks, s.Markers, s.Timed, *s.FirstTime, *s.LastTime)   // 9 7 1 8 2900 4536
 ```
 
+
+
+
+```c
+const char *text =
+    "Hour 2\r\n"
+    "48:20 Noisia - Stigma\r\n"
+    "52:47 Mefjus & Kasra - Bandwagon (Phace Remix)\r\n"
+    "56:05 Black Sun Empire - ID\r\n"
+    "59:31 Alix Perez - Fade Away\r\n"
+    "01:03:10 Interview with Hybris\r\n"
+    "01:07:44 Imanu - Sacrifice\r\n"
+    "00:11:02 Current Value feat. Teddy Killerz - Payload\r\n" /* typo: should be 01:11:02 */
+    "01:15:36 Hybris - Spinning Top";
+
+trackparse_tracklist *list = trackparse_parse_tracklist(text, TRACKPARSE_NUL_TERMINATED);
+
+for (size_t i = 0; i < list->entries_count; i++) {
+  printf("%s%s", i ? " " : "", trackparse_entry_kind_name(list->entries[i].kind));
+}
+printf("\n");   // header track track track track marker track track track
+
+const trackparse_entry *bandwagon = &list->entries[2];
+printf("%s %g\n", bandwagon->time->raw.ptr, bandwagon->time->seconds);   // 52:47 3167
+const trackparse_parts *p = &bandwagon->parts;
+printf("\"%s\" \"%s\" \"%s\" \"%s\"\n", p->lead.ptr, p->time.ptr, p->gap.ptr, p->rest.ptr);
+// "" "52:47" " " "Mefjus & Kasra - Bandwagon (Phace Remix)"
+const trackparse_track *track = bandwagon->track;
+for (size_t i = 0; i < track->artists_count; i++) {
+  printf("%s\n", track->artists[i].name.ptr);
+}
+// Mefjus
+// Kasra
+for (size_t i = 0; i < track->versions_count; i++) {
+  printf("%s by %s\n", track->versions[i].type_name.ptr, track->versions[i].artists[0].name.ptr);
+}
+// remix by Phace
+printf("%d\n", list->entries[3].track->flags.unknown_title);   // 1
+
+const trackparse_stats *s = &list->stats;
+printf("%d %d %d %d %g %g\n", s->lines, s->tracks, s->markers, s->timed, *s->first_time,
+       *s->last_time);
+// 9 7 1 8 2900 4536
+```
+
 
 
 
@@ -252,6 +311,18 @@ for _, e := range list.Entries {
 fmt.Println(joined.String() == text)   // true
 ```
 
+
+
+
+```c
+char joined[1024] = "";
+for (size_t i = 0; i < list->entries_count; i++) {
+  strcat(joined, list->entries[i].raw.ptr);
+  strcat(joined, trackparse_eol_name(list->entries[i].eol));
+}
+printf("%d\n", strcmp(joined, text) == 0);   // 1
+```
+
 
 
 
@@ -356,6 +427,27 @@ fmt.Printf("%+v\n", *a.Track.Position)   // {Raw:10 Number:10}
 fmt.Printf("%q\n", b.Track.Title)        // "Stigma"
 ```
 
+
+
+
+```c
+trackparse_tracklist *md = trackparse_parse_tracklist(
+    "**[**14:21**] 10. Nitepunk - ID**\n* 18:02 Noisia - _Stigma_", TRACKPARSE_NUL_TERMINATED);
+const trackparse_entry *a = &md->entries[0], *b = &md->entries[1];
+
+printf("\"%s\" \"%s\" \"%s\" \"%s\"\n", a->parts.lead.ptr, a->parts.time.ptr, a->parts.gap.ptr,
+       a->parts.rest.ptr);
+// "**[**" "14:21" "**] " "10. Nitepunk - ID**"
+for (size_t i = 0; i < a->track->artists_count; i++) {
+  printf("%s\n", a->track->artists[i].name.ptr);
+}
+// Nitepunk
+printf("%s\n", a->track->title.ptr);   // ID
+printf("%s %d\n", a->track->position->raw.ptr, a->track->position->number);   // 10 10
+printf("%s\n", b->track->title.ptr);   // Stigma
+trackparse_tracklist_free(md);
+```
+
 
 
 
@@ -437,6 +529,26 @@ fmt.Printf("%q\n", e.Track.Title)   // "Psycho"
 fmt.Println(len(layers.Warnings))   // 0
 ```
 
+
+
+
+```c
+trackparse_tracklist *layers = trackparse_parse_tracklist(
+    "00:00 Noisia - Stigma\nw/ Phace - Psycho (Acapella)\n03:10 Mefjus - Sleepless",
+    TRACKPARSE_NUL_TERMINATED);
+const trackparse_entry *e = &layers->entries[1];
+
+printf("%d\n", e->layered);          // 1
+printf("%d\n", e->time == NULL);     // 1
+for (size_t i = 0; i < e->track->artists_count; i++) {
+  printf("%s\n", e->track->artists[i].name.ptr);
+}
+// Phace
+printf("%s\n", e->track->title.ptr);       // Psycho
+printf("%zu\n", layers->warnings_count);   // 0
+trackparse_tracklist_free(layers);
+```
+
 
 
 
@@ -460,7 +572,8 @@ whitespace and a track counts, so `00:30 w/ Phace - Psycho` is layered too. `w/`
 Only `track` and `marker` entries have a `track`. No line is ever dropped. In Rust the kind is the
 enum [`EntryKind`](https://docs.rs/trackparse/latest/trackparse/tracklist/enum.EntryKind.html) (`EntryKind::Track`, `EntryKind::Marker`
 and so on), in Go the string type [`EntryKind`](https://pkg.go.dev/github.com/4matic/trackparse/go#EntryKind) (`trackparse.EntryKindTrack`,
-`trackparse.EntryKindMarker`). The marker words are in
+`trackparse.EntryKindMarker`), in C the enum `trackparse_entry_kind` (`TRACKPARSE_ENTRY_TRACK`,
+`TRACKPARSE_ENTRY_MARKER`). The marker words are in
 [`marker-words.json`](https://github.com/4matic/trackparse/blob/main/spec/data/marker-words.json). The kinds are
 [R13.3](/trackparse/reference/spec/#r133-line-kinds).
 
@@ -469,7 +582,8 @@ and so on), in Go the string type [`EntryKind`](https://pkg.go.dev/github.com/4m
 `parseTracklist` takes the [`parse` options](/trackparse/reference/options/#parse-options) `mode`
 (default `"tracklist"`), `knownArtists`, `splitAnd` and `keywords`, plus two of its own
 (snake_case keyword arguments in Python, setters of [`TracklistOptions`](https://docs.rs/trackparse/latest/trackparse/tracklist/struct.TracklistOptions.html)
-in Rust, fields of [`TracklistOptions`](https://pkg.go.dev/github.com/4matic/trackparse/go#TracklistOptions) in Go). `audioSeconds` is the length
+in Rust, fields of [`TracklistOptions`](https://pkg.go.dev/github.com/4matic/trackparse/go#TracklistOptions) in Go, setters of a
+`trackparse_tracklist_options` handle in C). `audioSeconds` is the length
 of the audio, and turns on the check for times after the end. `markerWords` adds marker words to
 the built-in ones ([R13.10](/trackparse/reference/spec/#r1310-options)):
 
@@ -534,6 +648,30 @@ for _, w := range mix.Warnings {
 // time-after-audio-end 3 warning true
 ```
 
+
+
+
+```c
+trackparse_tracklist_options *options = trackparse_tracklist_options_new();
+trackparse_tracklist_options_set_audio_seconds(options, 3600);
+trackparse_tracklist_options_add_marker_word(options, "drop", TRACKPARSE_NUL_TERMINATED);
+trackparse_tracklist *mix = trackparse_parse_tracklist_with(
+    "00:00 Intro\n03:00 Drop\n1:02:03 Noisia - Stigma", TRACKPARSE_NUL_TERMINATED, options);
+
+for (size_t i = 0; i < mix->entries_count; i++) {
+  printf("%s%s", i ? " " : "", trackparse_entry_kind_name(mix->entries[i].kind));
+}
+printf("\n");   // marker marker track
+for (size_t i = 0; i < mix->warnings_count; i++) {
+  const trackparse_tracklist_warning *w = &mix->warnings[i];
+  printf("%s %d %s %d\n", trackparse_tracklist_warning_code_name(w->code), w->line,
+         trackparse_severity_name(w->severity), w->suggestion == NULL);
+}
+// time-after-audio-end 3 warning 1
+trackparse_tracklist_free(mix);
+trackparse_tracklist_options_free(options);
+```
+
 
 
 
@@ -594,12 +732,31 @@ for _, w := range list.Warnings {
 // {Line:8 Raw:01:11:02 Seconds:4262}
 ```
 
+
+
+
+```c
+for (size_t i = 0; i < list->warnings_count; i++) {
+  const trackparse_tracklist_warning *w = &list->warnings[i];
+  printf("%s %d %s\n", trackparse_tracklist_warning_code_name(w->code), w->line,
+         trackparse_severity_name(w->severity));
+  if (w->suggestion) {
+    printf("line %d: %s (%g)\n", w->suggestion->line, w->suggestion->raw.ptr,
+           w->suggestion->seconds);
+  }
+}
+// no-start-at-zero 2 info
+// time-out-of-order 8 warning
+// line 8: 01:11:02 (4262)
+trackparse_tracklist_free(list);
+```
+
 
 
 
 `00:11:02` sits between `01:07:44` and `01:15:36`. Changing one digit gives exactly one time that
 fits, `01:11:02`, so the warning carries it as a suggestion. When several fixes would fit, or none
-does, `suggestion` is `null` (`None`, `nil` in Go) and you only get the warning. The checks are
+does, `suggestion` is `null` (`None`, `nil` in Go, `NULL` in C) and you only get the warning. The checks are
 [R13.7](/trackparse/reference/spec/#r137-warnings), and [Suggestions](/trackparse/reference/warnings/#suggestions)
 describes the search.
 
@@ -637,7 +794,7 @@ what a plain `parse()` makes of them. The last two need neighbours: the position
 ## JSON
 
 A `Tracklist` ([R13.8](/trackparse/reference/spec/#r138-output)) serializes like a single track: `JSON.stringify(list)` in JavaScript,
-`tl.to_dict()` in Python, `list.to_json()` in Rust and `json.Marshal(list)` in Go give the same JSON, with camelCase keys such
+`tl.to_dict()` in Python, `list.to_json()` in Rust, `json.Marshal(list)` in Go and `trackparse_tracklist_to_json(list)` in C give the same JSON, with camelCase keys such
 as `specVersion` and `firstTime`. See
 [Serializing to JSON](/trackparse/reference/parse/#serializing-to-json).
 
diff --git a/site/src/content/docs/guides/versions.mdx b/site/src/content/docs/guides/versions.mdx
index b11801e..6bba77d 100644
--- a/site/src/content/docs/guides/versions.mdx
+++ b/site/src/content/docs/guides/versions.mdx
@@ -75,10 +75,29 @@ type Version struct {
 }
 ```
 
+
+
+
+```c
+typedef struct trackparse_version {
+  trackparse_version_type type;      /* TRACKPARSE_VERSION_REMIX, _VIP, _RADIO, … */
+  trackparse_str type_name;          /* the type's name: "remix", "vip", "radio", … */
+  trackparse_str raw;                /* the text as written, without brackets: "Sub Focus VIP Remix" */
+  const trackparse_artist *artists;  /* remixers, role TRACKPARSE_ROLE_REMIXER */
+  size_t artists_count;
+  const trackparse_str *modifiers;   /* other type words that didn't win: "extended" */
+  size_t modifiers_count;
+  const trackparse_str *descriptor;  /* leftover words: "Taylor's", "at Wembley"; or NULL */
+  const int *year;                   /* or NULL */
+  bool unknown_artist;               /* "ID Remix" */
+  trackparse_delimiter delimiter;    /* TRACKPARSE_DELIMITER_PAREN, _BRACKET, _BRACE, _DASH */
+} trackparse_version;
+```
+
 
 
 
-`title` never includes versions. [`fullTitle`](/trackparse/reference/parse/#parsedtrack) (`full_title` in Python and Rust, `FullTitle` in Go) is the title with them
+`title` never includes versions. [`fullTitle`](/trackparse/reference/parse/#parsedtrack) (`full_title` in Python, Rust and C, `FullTitle` in Go) is the title with them
 put back, in their original brackets.
 
 In Rust the type is the field `version_type`, because `type` is a reserved word, and its values are
@@ -93,6 +112,15 @@ In Go the field is `Type`, of the string type [`VersionType`](https://pkg.go.dev
 they print as `remix` and `spedUp`. [`Delimiter`](https://pkg.go.dev/github.com/4matic/trackparse/go#Delimiter) is a string type too, holding the delimiter itself:
 `trackparse.DelimiterParen` is `"("`. `Descriptor` and `Year` are pointers, `nil` when absent.
 
+In C the type is the enum `trackparse_version_type` (`TRACKPARSE_VERSION_REMIX`,
+`TRACKPARSE_VERSION_SPED_UP`), and `type_name` holds its name as a string (`"remix"`, `"spedUp"`).
+Print `type_name`: it differs from `trackparse_version_type_name(type)` only for a name that
+[`keywords.versionHeads`](/trackparse/reference/options/#keywords) introduced, where `type` is
+`TRACKPARSE_VERSION_VERSION`. `modifiers` holds names as strings. `delimiter` is the enum
+`trackparse_delimiter`, and `trackparse_delimiter_name()` gives the delimiter itself (`"("`).
+`descriptor` and `year` are pointers, `NULL` when absent. The structs are in
+[`trackparse.h`](https://github.com/4matic/trackparse/blob/main/c/include/trackparse.h).
+
 ## The 27 types
 
 | Group | Types |
@@ -107,7 +135,9 @@ The keywords behind them are in
 In Rust, [`VersionType::ALL`](https://docs.rs/trackparse/latest/trackparse/enum.VersionType.html#associatedconstant.ALL) lists the 27
 variants and `VersionType::from_name("spedUp")` reads a name back. In Go,
 [`trackparse.AllVersionTypes()`](https://pkg.go.dev/github.com/4matic/trackparse/go#AllVersionTypes) lists them, and since the type is a string,
-`trackparse.VersionType("spedUp")` is a conversion.
+`trackparse.VersionType("spedUp")` is a conversion. In C,
+`trackparse_version_type_from_name("spedUp", TRACKPARSE_NUL_TERMINATED, &type)` reads a name back
+and returns `false` for an unknown one.
 
 ## Generic words borrow their meaning
 
@@ -175,6 +205,24 @@ fmt.Println(v.Descriptor == nil, v.Year == nil, v.UnknownArtist)   // true true
 fmt.Println(v.Delimiter)                    // (
 ```
 
+
+
+
+```c
+#include 
+
+trackparse_track *t = trackparse_parse("Pendulum - Watercolour (Extended VIP Mix)",
+                                       TRACKPARSE_NUL_TERMINATED);
+const trackparse_version *v = &t->versions[0];
+printf("%s\n", v->type_name.ptr);                                // vip
+printf("%s\n", v->raw.ptr);                                      // Extended VIP Mix
+printf("%zu\n", v->artists_count);                               // 0
+printf("%zu %s\n", v->modifiers_count, v->modifiers[0].ptr);     // 1 extended
+printf("%d %d %d\n", v->descriptor == NULL, v->year == NULL, v->unknown_artist);   // 1 1 0
+printf("%s\n", trackparse_delimiter_name(v->delimiter));         // (
+trackparse_track_free(t);
+```
+
 
 
 
@@ -236,13 +284,32 @@ for _, v := range trackparse.Parse("Dimension - Offshore (Mefjus Remix / Noisia
 // Noisia
 ```
 
+
+
+
+```c
+t = trackparse_parse("Avicii - Levels (Skrillex Remix) [Radio Edit]", TRACKPARSE_NUL_TERMINATED);
+for (size_t i = 0; i < t->versions_count; i++) printf("%s\n", t->versions[i].type_name.ptr);
+// remix
+// radio
+trackparse_track_free(t);
+
+t = trackparse_parse("Dimension - Offshore (Mefjus Remix / Noisia Remix)", TRACKPARSE_NUL_TERMINATED);
+for (size_t i = 0; i < t->versions_count; i++) {
+  printf("%s\n", t->versions[i].artists[0].name.ptr);
+}
+// Mefjus
+// Noisia
+trackparse_track_free(t);
+```
+
 
 
 
 ## Dash suffixes
 
 Streaming services often write versions after a second dash. Those are read too, and the
-delimiter is `-` (`VersionDelimiter::Dash` in Rust, `trackparse.DelimiterDash` in Go;
+delimiter is `-` (`VersionDelimiter::Dash` in Rust, `trackparse.DelimiterDash` in Go, `TRACKPARSE_DELIMITER_DASH` in C;
 [try it](/trackparse/playground/#track=The%20Beatles%20-%20Hey%20Jude%20-%20Remastered%202015)):
 
 
@@ -289,6 +356,19 @@ fmt.Println(v.Type, *v.Year, v.Delimiter)   // remaster 2015 -
 fmt.Printf("%q\n", v.Raw)              // "Remastered 2015"
 ```
 
+
+
+
+```c
+t = trackparse_parse("The Beatles - Hey Jude - Remastered 2015", TRACKPARSE_NUL_TERMINATED);
+printf("%s\n", t->title.ptr);   // Hey Jude
+v = &t->versions[0];
+printf("%s %d %s\n", v->type_name.ptr, *v->year, trackparse_delimiter_name(v->delimiter));
+// remaster 2015 -
+printf("%s\n", v->raw.ptr);     // Remastered 2015
+trackparse_track_free(t);
+```
+
 
 
 
@@ -301,7 +381,7 @@ first dash is almost always the separator. The suffix rules are
 ## Unknown remixers
 
 `(ID Remix)` is a remix by someone not yet announced. You get the version with
-`unknownArtist: true` ([`unknown_artist`](/trackparse/guides/artists/#unknown-artists) in Python and Rust, `UnknownArtist` in Go) and no artists. There is no artist
+`unknownArtist: true` ([`unknown_artist`](/trackparse/guides/artists/#unknown-artists) in Python, Rust and C, `UnknownArtist` in Go) and no artists. There is no artist
 called "ID". [Unknown artists](/trackparse/guides/artists/#unknown-artists) has an example, and
 the [playground](/trackparse/playground/#track=ID%20-%20ID%20%28ID%20Remix%29) shows it.
 
@@ -310,7 +390,8 @@ the [playground](/trackparse/playground/#track=ID%20-%20ID%20%28ID%20Remix%29) s
 If your catalog uses a word trackparse doesn't know, add it with
 [`keywords.versionHeads`](/trackparse/reference/options/#keywords) (`version_heads` in Python,
 [`KeywordOptions::version_head`](https://docs.rs/trackparse/latest/trackparse/struct.KeywordOptions.html#method.version_head) in Rust,
-[`Keywords.VersionHeads`](https://pkg.go.dev/github.com/4matic/trackparse/go#Keywords) in Go). The playground has no field for keywords, so this
+[`Keywords.VersionHeads`](https://pkg.go.dev/github.com/4matic/trackparse/go#Keywords) in Go,
+`trackparse_parse_options_add_version_head` in C). The playground has no field for keywords, so this
 one runs only in code:
 
 
@@ -360,6 +441,23 @@ fmt.Println(parser.Parse("Chase & Status x Camo & Krooked - Track (Alix Perez Re
 // rework
 ```
 
+
+
+
+```c
+trackparse_parse_options *options = trackparse_parse_options_new();
+trackparse_parse_options_add_version_head(options, "rerub", TRACKPARSE_NUL_TERMINATED, "rework",
+                                          TRACKPARSE_NUL_TERMINATED);
+trackparse_parser *parser = trackparse_parser_new(options);
+trackparse_parse_options_free(options);   /* the parser keeps its own copy */
+
+t = trackparse_parser_parse(parser, "Chase & Status x Camo & Krooked - Track (Alix Perez Rerub)",
+                            TRACKPARSE_NUL_TERMINATED);
+printf("%s\n", t->versions[0].type_name.ptr);   // rework
+trackparse_track_free(t);
+trackparse_parser_free(parser);
+```
+
 
 
 
diff --git a/site/src/content/docs/guides/what-it-understands.md b/site/src/content/docs/guides/what-it-understands.md
index fb96606..85ba169 100644
--- a/site/src/content/docs/guides/what-it-understands.md
+++ b/site/src/content/docs/guides/what-it-understands.md
@@ -7,12 +7,14 @@ Every row below is a real result of `parse(input)` with default options, except
 *youtube*. Click an input to open it in the [playground](/trackparse/playground/) and see the full
 output.
 
-The results are the same in JavaScript, Python, Rust and Go, because all four follow one
+The results are the same in JavaScript, Python, Rust, Go and C, because all five follow one
 [spec](/trackparse/reference/spec/). The values are shown as they appear in JSON: `remix`, `bySplit`.
 In Rust they are enum variants such as [`VersionType::Remix`](https://docs.rs/trackparse/latest/trackparse/enum.VersionType.html) and
 [`Warning::BySplit`](https://docs.rs/trackparse/latest/trackparse/enum.Warning.html). In Go they are typed string constants such as
 [`trackparse.VersionTypeRemix`](https://pkg.go.dev/github.com/4matic/trackparse/go#VersionTypeRemix) and
-[`trackparse.WarningBySplit`](https://pkg.go.dev/github.com/4matic/trackparse/go#WarningBySplit), whose values are these same names. The columns
+[`trackparse.WarningBySplit`](https://pkg.go.dev/github.com/4matic/trackparse/go#WarningBySplit), whose values are these same names. In C they are enum values such as `TRACKPARSE_VERSION_REMIX`
+and `TRACKPARSE_WARNING_BY_SPLIT`, and functions such as `trackparse_version_type_name` return
+these names. The columns
 are fields of [`ParsedTrack`](/trackparse/reference/parse/#parsedtrack).
 
 | Input | Artists | Title | Versions and other fields |
@@ -60,7 +62,7 @@ acts ([R7.3](/trackparse/reference/spec/#r7-artist-side:~:text=R7.3%20Credit%2Dl
 [`no-split-before.json`](https://github.com/4matic/trackparse/blob/main/spec/data/no-split-before.json)).
 `Chase & Status` splits too, because nothing in the string tells it apart from two artists.
 Names like that go in [`knownArtists`](/trackparse/guides/artists/#knownartists) (`known_artists` in
-Python and Rust, `KnownArtists` in Go).
+Python and Rust, `KnownArtists` in Go, `trackparse_parse_options_add_known_artist` in C).
 
 **The Rolling Stones keep their brackets.** `(I Can't Get No)` is not a version, a feat or junk, so
 it stays in the title. That's the rule: anything unrecognized is left alone
@@ -72,14 +74,15 @@ them. In `youtube` mode it does, and it tells you through `warnings`
 ([`bySplit`](/trackparse/reference/warnings/#track-warnings:~:text=bySplit) and
 [`unspacedDashSplit`](/trackparse/reference/warnings/#track-warnings:~:text=unspacedDashSplit)). In
 Python the option is `mode="youtube"`, in Rust `ParseOptions::new().mode(ModeOption::Youtube)`, in
-Go `trackparse.ParseOptions{Mode: trackparse.ModeYouTube}`. See
+Go `trackparse.ParseOptions{Mode: trackparse.ModeYouTube}`, in C
+`trackparse_parse_options_set_mode(options, TRACKPARSE_MODE_YOUTUBE)`. See
 [Modes](/trackparse/guides/modes/#youtube-mode) and the [`mode` option](/trackparse/reference/options/#parse-options).
 
 ## In a tracklist
 
 Lines of a pasted tracklist go through
 [`parseTracklist`](/trackparse/guides/tracklists/) (`parse_tracklist` in Python and Rust,
-`ParseTracklist` in Go; the [Tracklist API](/trackparse/reference/tracklist/) has every field), which
+`ParseTracklist` in Go, `trackparse_parse_tracklist` in C; the [Tracklist API](/trackparse/reference/tracklist/) has every field), which
 also reads list bullets, Markdown emphasis and `w/` lines. Each input below is one line; click it to open it in the playground's
 tracklist tab.
 
diff --git a/site/src/content/docs/index.mdx b/site/src/content/docs/index.mdx
index bd8bc76..4e51c2b 100644
--- a/site/src/content/docs/index.mdx
+++ b/site/src/content/docs/index.mdx
@@ -1,10 +1,10 @@
 ---
 title: A parser for track names and tracklists
-description: Turn messy track names into structured data. Artists with roles, remixes and versions, and the noise around them, for JavaScript, Python, Rust and Go.
+description: Turn messy track names into structured data. Artists with roles, remixes and versions, and the noise around them, for JavaScript, Python, Rust, Go and C.
 template: splash
 hero:
   title: Messy track names in.
Structured data out. - tagline: trackparse reads track titles the way people write them in store metadata, YouTube uploads and the tracklist under a mix. Artists and their roles, remixes and other versions, and the noise around them each get a field of their own. It is one spec with packages for JavaScript, Python, Rust and Go. + tagline: trackparse reads track titles the way people write them in store metadata, YouTube uploads and the tracklist under a mix. Artists and their roles, remixes and other versions, and the noise around them each get a field of their own. It is one spec with packages for JavaScript, Python, Rust, Go and C. actions: - text: Get started link: /trackparse/start/getting-started/ @@ -47,8 +47,8 @@ in the title, word for word. { title: "27 version types", href: "/trackparse/guides/versions/#the-27-types", body: "Remix, VIP, bootleg, extended, radio edit, live, remaster, sped up, slowed and the rest, each with its remixers, modifiers and year." }, { title: "Noise, labeled", href: "/trackparse/guides/junk-and-flags/#junk", body: "[Official Video], [HD], - YouTube and [NCS Release] leave the title but land in junk with a kind, instead of disappearing." }, { title: "Whole tracklists", href: "/trackparse/guides/tracklists/", body: "Paste the tracklist of a mix: every line is parsed, times are checked, and an out-of-order time often comes with the fix. Edits rewrite only the lines you name." }, - { title: "One spec, four languages", href: "/trackparse/project/ports/", body: "The npm package, the PyPI package, the Rust crate and the Go module pass the same 13,130 fixtures and return byte-identical JSON on every fixture input. The ports page has the one known Unicode difference." }, - { title: "Small and total", href: "/trackparse/project/how-it-works/", body: "The JavaScript package is about 18 kB gzipped. It, the Python package and the Go module have no dependencies; the Rust crate has one, unicode-normalization. The scanners are written by hand and no regex backtracks, so a 10,000-code-point input takes at most tens of milliseconds in JavaScript, Rust and Go, and well under a second in Python. No string makes it throw or panic, and bad options fall back to defaults." }, + { title: "One spec, five languages", href: "/trackparse/project/ports/", body: "The npm package, the PyPI package, the Rust crate, the Go module and the C library pass the same 13,130 fixtures and return byte-identical JSON on every fixture input. The ports page has the one known Unicode difference." }, + { title: "Small and total", href: "/trackparse/project/how-it-works/", body: "The JavaScript package is about 18 kB gzipped. It, the Python package and the Go module have no dependencies, and the C library needs only the C standard library and threads; the Rust crate has one, unicode-normalization. The scanners are written by hand and no regex backtracks, so a 10,000-code-point input takes at most tens of milliseconds in JavaScript, Rust, Go and C, and well under a second in Python. No string makes it throw or panic, and bad options fall back to defaults." }, ]} /> @@ -113,15 +113,38 @@ in the title, word for word. // live at Wembley 1986 ``` + + ```c + #include + #include + + trackparse_track *track = + trackparse_parse("Noisia feat. Foreign Beggars - Shellshock", TRACKPARSE_NUL_TERMINATED); + for (size_t i = 0; i < track->artists_count; i++) { + const trackparse_artist *a = &track->artists[i]; + printf("%s (%s)\n", a->name.ptr, trackparse_role_name(a->role)); + } + // Noisia (primary) + // Foreign Beggars (featured) + trackparse_track_free(track); + + track = trackparse_parse("Queen - Bohemian Rhapsody (Live at Wembley 1986)", + TRACKPARSE_NUL_TERMINATED); + const trackparse_version *v = &track->versions[0]; + printf("%s %s %d\n", v->type_name.ptr, v->descriptor->ptr, *v->year); + // live at Wembley 1986 + trackparse_track_free(track); + ``` + ## Where to next
- + - +
diff --git a/site/src/content/docs/playground.mdx b/site/src/content/docs/playground.mdx index e41c4f1..212667c 100644 --- a/site/src/content/docs/playground.mdx +++ b/site/src/content/docs/playground.mdx @@ -8,9 +8,10 @@ editUrl: false import Playground from "../../components/Playground.astro"; This page runs the JavaScript package in your browser, so nothing you paste leaves it. The Python -package, the Rust crate and the Go module pass the same fixtures and give the same output on every -fixture input ([one Unicode note](/trackparse/project/ports/#what-the-rust-port-taught) for Rust). -The code panels show the call in all four languages. +package, the Rust crate, the Go module and the C library pass the same fixtures and give the same +output on every fixture input ([one Unicode note](/trackparse/project/ports/#what-the-rust-port-taught) +for Rust). The code panels show the call in all five languages; the Rust, Go and C panels are whole +programs. The URL updates as you type, so you can copy it to share an input, like [`"Numb" by Linkin Park` in youtube mode](/trackparse/playground/#track=%22Numb%22%20by%20Linkin%20Park&mode=youtube). diff --git a/site/src/content/docs/project/comparison.md b/site/src/content/docs/project/comparison.md index 6322301..e9b8397 100644 --- a/site/src/content/docs/project/comparison.md +++ b/site/src/content/docs/project/comparison.md @@ -10,7 +10,7 @@ description: How trackparse differs from get-artist-title, metadata-filter and t | Remixers and version types | 27 types | no | removed | raw remix name | | Noise | returned with a kind | removed | removed | no | | Tracklists | yes | no | no | no | -| Languages | JavaScript, Python, Rust and Go, one spec | JavaScript | JavaScript | Ruby | +| Languages | JavaScript, Python, Rust, Go and C, one spec | JavaScript | JavaScript | Ruby | | Last release | 2026 | 2021 | active | 2015 | These libraries are good at what they set out to do. If you need a clean string to scrobble, diff --git a/site/src/content/docs/project/contributing.md b/site/src/content/docs/project/contributing.md index 500c2b4..717aa28 100644 --- a/site/src/content/docs/project/contributing.md +++ b/site/src/content/docs/project/contributing.md @@ -12,8 +12,8 @@ it belongs to. Open an issue on [GitHub](https://github.com/4matic/trackparse/issues). You can paste a [playground](/trackparse/playground/) link: the URL contains the input. It doesn't matter which -language you use. The four packages share the rules, so a wrong result in one is a wrong result in -all of them. If JavaScript, Python, Rust and Go ever disagree with each other, that is a bug of its own, +language you use. The five packages share the rules, so a wrong result in one is a wrong result in +all of them. If JavaScript, Python, Rust, Go and C ever disagree with each other, that is a bug of its own, and worth reporting with the two outputs. ## Change a rule @@ -27,8 +27,8 @@ Behaviour starts in the spec, not in the code: trigger, and one exact case if the rule touches many fields. 3. If the rule is combinatorial (a new joiner, a new version word), teach the generator the atom and regenerate. -4. Change every port, JavaScript, Python, Rust and Go, and cite the rule ID in a comment. -5. Check that every fixture passes in all four ports and that the cross-port diff reports zero +4. Change every port, JavaScript, Python, Rust, Go and C, and cite the rule ID in a comment. +5. Check that every fixture passes in all five ports and that the cross-port diff reports zero differences. 6. Update the pages of this site that describe the rule, with an example in each language. @@ -46,6 +46,7 @@ js/ the npm package (reference implementation) python/ the PyPI package rust/ the crates.io package go/ the Go module +c/ the C library site/ this website scripts/ cross-port diff and other tools ``` @@ -112,21 +113,43 @@ The artist-side tests compare with values from the JavaScript package. Their dat to ship in the module, so it is not committed: the last command writes it, and without it those tests are skipped. CI writes it and requires it. +## Working on the C library + +A C11 compiler, CMake 3.16 or newer, and Node 24 for the codegen: as in Go, the Unicode tables come +from Node, not from the C library or the platform. The C code is a translation of the Go port, file +by file; [`c/src/PORTING.md`](https://github.com/4matic/trackparse/blob/main/c/src/PORTING.md) has +the conventions. + +```sh +cmake -S c -B c/build -DTRACKPARSE_WERROR=ON +cmake --build c/build +ctest --test-dir c/build --output-on-failure # fixtures, schema check, unit tests +TRACKPARSE_REPORT=1 c/build/trackparse-fixtures spec/fixtures/*/*.json # pass rate per file and per rule +TRACKPARSE_ONLY=brackets-version-001 c/build/trackparse-fixtures spec/fixtures/*/*.json # one case +cmake -S c -B c/build-asan -DTRACKPARSE_SANITIZE=ON # the same suite under ASan and UBSan +node c/scripts/gen_data.mjs # regenerate src/data_gen.c from spec/data +node c/scripts/gen_unicode.mjs # regenerate src/unicode_gen.c +node c/scripts/amalgamate.mjs # write c/dist/trackparse.c and trackparse.h +``` + +`src/` uses no `strtod`, no float `printf`, no `` and no `qsort`: the first three follow +the process locale, and `qsort` is not stable. + ## Comparing the ports After a change in any port, build the JavaScript package and run the cross-port diff from the -repository root. It runs every fixture through all four ports and compares the complete output. +repository root. It runs every fixture through all five ports and compares the complete output. ```sh pnpm build node scripts/compare-ports.mjs # must print "differences: 0" -node scripts/compare-ports.mjs --only=rust # one port against JavaScript (or --only=python, --only=go) +node scripts/compare-ports.mjs --only=rust # one port against JavaScript (or --only=python, --only=go, --only=c) node scripts/fuzz-ports.mjs # the same diff on random input ``` ## This website -The site lives in `site/`. Every code example has a JavaScript, a Python, a Rust and a Go tab, and every +The site lives in `site/`. Every code example has a JavaScript, a Python, a Rust, a Go and a C tab, and every output in it comes from running the code. ```sh @@ -137,7 +160,7 @@ pnpm docs:build # build it; fails on broken pages [AGENTS.md](https://github.com/4matic/trackparse/blob/main/AGENTS.md) has the full repository map, every command and the release process. Commits follow [Conventional Commits](https://www.conventionalcommits.org/), because the changelog is generated -from them. The four packages and the spec are released together under one version number. +from them. The five packages and the spec are released together under one version number. ## See also diff --git a/site/src/content/docs/project/how-it-works.md b/site/src/content/docs/project/how-it-works.md index 510e6d1..f74f9b0 100644 --- a/site/src/content/docs/project/how-it-works.md +++ b/site/src/content/docs/project/how-it-works.md @@ -6,8 +6,8 @@ description: The parsing pipeline, why it has no regex lookaround, and how track trackparse is a fixed pipeline of small hand-written scanners. There are no regexes with lookaround or backreferences, so nothing backtracks. A 10,000-code-point input takes at most tens of milliseconds in JavaScript, Rust and Go, and well under a second in Python. -The same design is what lets the JavaScript, Python, Rust and Go packages give the same output: each -step is a short function that reads the same way in all four languages. +The same design is what lets the JavaScript, Python, Rust, Go and C packages give the same output: +each step is a short function that reads the same way in all five languages. Each step below is a rule group in the [spec](/trackparse/reference/spec/): @@ -95,4 +95,4 @@ The tracklist rules are [R13](/trackparse/reference/spec/#r13-tracklists). - [The spec](/trackparse/reference/spec/) for the full rules. - [How it's tested](/trackparse/project/testing/) for the fixtures and the cross-port diff. -- [Ports](/trackparse/project/ports/) for the four implementations. +- [Ports](/trackparse/project/ports/) for the five implementations. diff --git a/site/src/content/docs/project/ports.md b/site/src/content/docs/project/ports.md index a428dfa..fd9501e 100644 --- a/site/src/content/docs/project/ports.md +++ b/site/src/content/docs/project/ports.md @@ -1,6 +1,6 @@ --- title: Ports -description: The JavaScript, Python, Rust and Go implementations, and what it takes to add another language. +description: The JavaScript, Python, Rust, Go and C implementations, and what it takes to add another language. --- | Language | Package | Status | @@ -9,33 +9,37 @@ description: The JavaScript, Python, Rust and Go implementations, and what it ta | Python | [`trackparse`](https://pypi.org/project/trackparse/) on PyPI | 13,130 / 13,130 fixtures, output identical to JS. Tracklists in `trackparse.tracklist` | | Rust | [`trackparse`](https://crates.io/crates/trackparse) on crates.io, API docs on [docs.rs](https://docs.rs/trackparse) | 13,130 / 13,130 fixtures, output identical to JS. Tracklists in `trackparse::tracklist` | | Go | [`github.com/4matic/trackparse/go`](https://pkg.go.dev/github.com/4matic/trackparse/go), API docs on [pkg.go.dev](https://pkg.go.dev/github.com/4matic/trackparse/go) | 13,130 / 13,130 fixtures, output identical to JS. Tracklists in the same package (`trackparse.ParseTracklist`) | - -| | JavaScript | Python | Rust | Go | -|---|---|---|---|---| -| Install | `npm install trackparse` | `pip install trackparse` | `cargo add trackparse` | `go get github.com/4matic/trackparse/go@latest` | -| Needs | Node 18 or newer, or any ES2020 runtime | Python 3.9 or newer | Rust 1.74 or newer | Go 1.22 or newer | -| Dependencies | none | none | `unicode-normalization`; `serde` is optional | none | -| Types | TypeScript types included | `py.typed`, passes `mypy --strict` | structs and enums, no `unsafe` | structs and typed string constants, no `unsafe`, no cgo | -| Names | [`parseArtists`](/trackparse/reference/functions/#parseartistsinput-options), [`fullTitle`](/trackparse/reference/parse/#parsedtrack) | `parse_artists`, `full_title` | `parse_artists`, `full_title` | `ParseArtists`, `FullTitle` | -| Options | one object | keyword arguments | `_with` functions and option builders | `With` functions and option structs | -| On bad input | never throws on a string | `TypeError` if the input isn't a `str` | never panics, no `Result` | never panics, no `error` | -| JSON | `JSON.stringify(track)` | `track.to_dict()` | `track.to_json()`, or `serde` | `json.Marshal(track)` | +| C | Source tarball and amalgamation on each [GitHub Release](https://github.com/4matic/trackparse/releases) from 0.7.0; the API is [`trackparse.h`](https://github.com/4matic/trackparse/blob/main/c/include/trackparse.h) | 13,130 / 13,130 fixtures, output identical to JS. Tracklists in the same library (`trackparse_parse_tracklist`) | + +| | JavaScript | Python | Rust | Go | C | +|---|---|---|---|---|---| +| Install | `npm install trackparse` | `pip install trackparse` | `cargo add trackparse` | `go get github.com/4matic/trackparse/go@latest` | CMake `FetchContent` from the release tarball, or copy the amalgamation | +| Needs | Node 18 or newer, or any ES2020 runtime | Python 3.9 or newer | Rust 1.74 or newer | Go 1.22 or newer | a C11 compiler (GCC, Clang or MSVC); CMake 3.16 or newer for the CMake build | +| Dependencies | none | none | `unicode-normalization`; `serde` is optional | none | none beyond the C standard library and the system's threads | +| Types | TypeScript types included | `py.typed`, passes `mypy --strict` | structs and enums, no `unsafe` | structs and typed string constants, no `unsafe`, no cgo | read-only structs, C enums with `_name()` functions, opaque option handles | +| Names | [`parseArtists`](/trackparse/reference/functions/#parseartistsinput-options), [`fullTitle`](/trackparse/reference/parse/#parsedtrack) | `parse_artists`, `full_title` | `parse_artists`, `full_title` | `ParseArtists`, `FullTitle` | `trackparse_parse_artists`, `full_title` | +| Options | one object | keyword arguments | `_with` functions and option builders | `With` functions and option structs | `_with` functions and option handles with setters | +| On bad input | never throws on a string | `TypeError` if the input isn't a `str` | never panics, no `Result` | never panics, no `error` | never crashes; `NULL` only when memory runs out | +| JSON | `JSON.stringify(track)` | `track.to_dict()` | `track.to_json()`, or `serde` | `json.Marshal(track)` | `trackparse_track_to_json(track)` | [Getting started](/trackparse/start/getting-started/) has the install steps, and [Other functions](/trackparse/reference/functions/) has the full table of names. All of them share one version number. The spec, the JavaScript package, the Python package, the -Rust crate and the Go module are released together, from one release PR, and CI fails if their -versions drift apart. The crate has been on crates.io since 0.4.0. A Go release is the tag -`go/vX.Y.Z`, which the Go module proxy reads -([published versions](https://proxy.golang.org/github.com/4matic/trackparse/go/@v/list)). The +Rust crate, the Go module and the C library are released together, from one release PR, and CI +fails if their versions drift apart. The crate has been on crates.io since 0.4.0. A Go release is +the tag `go/vX.Y.Z`, which the Go module proxy reads +([published versions](https://proxy.golang.org/github.com/4matic/trackparse/go/@v/list)). C has no +registry either: a C release is the tag `c-vX.Y.Z`, with the source tarball +(`trackparse-c-X.Y.Z.tar.gz`), the amalgamation (`trackparse-c-X.Y.Z-amalgamation.zip`) and +`SHA256SUMS` attached to its GitHub Release. 0.7.0 is the first. The [changelogs](/trackparse/project/roadmap/#next) list what each release brought. ## Adding a language A port is done when it passes every fixture and every invariant. There's no partial credit and no port-specific behaviour. The Python, Rust and Go ports map one to one onto the JavaScript source files, -so they work as second references. [How it works](/trackparse/project/how-it-works/) describes the +and the C port onto the Go files, so they work as second references. [How it works](/trackparse/project/how-it-works/) describes the pipeline a port has to build. The checklist, in short: @@ -123,6 +127,53 @@ typing questions. What was new: - **NUL is real input.** A scanner that reads past the end of a string must not see a character. The Go helpers return -1 out of range, not 0, because U+0000 can appear in the input. +### What the C port taught + +The C library is a file-by-file translation of the Go port, because Go has the closest shape: +explicit types, a code point lookup that returns -1 out of range, and no generics in the hot +paths. Every `c/src` file is a Go file with the same rule IDs in its comments, and one internal +header declared every type and prototype, in Go file order, before any pipeline code was written. +The JSON reader lives in a separate test library that is never installed, so the library writes +JSON but does not read it. The Go lessons above carried over (Unicode tables, final sigma, +JavaScript's `trim()`, WHATWG UTF-8, key order, stable sorts). What C added: + +- **Memory without checks in the pipeline.** Each public call opens an arena with a `jmp_buf`. + Inside the pipeline, allocation never returns `NULL`: when `malloc` fails, the allocator jumps + back to the public function with `longjmp`, which frees the arena and returns `NULL`. So the + pipeline has no `NULL` checks and no `free` calls, and each result is one block that its + `_free` function releases. Running out of memory is the only way a call can fail. +- **Numbers without the C library.** `strtod` and `printf("%g")` follow the process locale, and no + `printf` format writes JavaScript's shortest round-trip digits. `num.c` parses decimal strings to + the correctly rounded double and writes numbers as JavaScript's `Number#toString` does, with + exact big-integer arithmetic. `src/` has no `strtod`, no float `printf` and no ``, so a + German locale can't write `3167,5` and a Turkish one can't lowercase `I` to `ı`. +- **Fused multiply-add.** GCC in GNU mode contracts `floor(v * 10^d + 0.5)` into one fused + instruction on ARM64, or on x86 with FMA enabled, and that rounds differently. CMake passes + `-ffp-contract=off` (`/fp:precise` on MSVC), `num.c` sets the standard pragma where the compiler + honours it, and the product goes through a `volatile`, so the amalgamation is safe under other + flags too. On 32-bit x86, x87 registers compute with extra precision, so `num.c` refuses to + compile unless `FLT_EVAL_METHOD` is 0 (`-msse2 -mfpmath=sse`). +- **Unicode tables from Node, as in Go.** The C library can't take letters, lowercasing or + normalization from the C library or the platform. Its generator shares the derivation with the + Go generator, so both ports carry the same tables: categories L and Lu, JavaScript's + `toLowerCase` with the final-sigma rule, combining class ranks, compositions and + decompositions. +- **One translation unit.** The installed library is built from the amalgamation, where every + internal function and table is `static`, so only the `trackparse_*` API leaves the object file, + even in a static library. Since all files share one scope there, the amalgamation script fails + when two files define the same `static` name. +- **Unset is not zero.** Options are opaque handles with setters, so an option that was never set + and one set to its zero value stay different (an audio length of 0 seconds, an empty feat + marker) without the pointers Go needed, and a new option doesn't change the ABI. +- **Enums and names.** Roles, version types and junk kinds are C enums, but a keyword option can + bring in a version type or junk kind that the enum doesn't have. So each version carries + `type_name` and each junk item `kind_name`, the string that goes into the JSON, and the enum + falls back to `TRACKPARSE_VERSION_VERSION` or `TRACKPARSE_JUNK_OTHER`, as the Rust crate does. +- **Small portability traps.** `qsort` is not stable, so there is a merge sort. `char` is signed + on x86 and unsigned on ARM, so every byte the pipeline inspects is an `unsigned char`. Generated + tables and non-ASCII literals are `\xNN` escapes, because MSVC reads source files in the system + code page. + ## See also - [How it's tested](/trackparse/project/testing/) for the fixtures and the cross-port diff. diff --git a/site/src/content/docs/project/roadmap.md b/site/src/content/docs/project/roadmap.md index 9b9ac91..6f2062b 100644 --- a/site/src/content/docs/project/roadmap.md +++ b/site/src/content/docs/project/roadmap.md @@ -4,8 +4,8 @@ description: What trackparse doesn't do yet, and what comes next. --- The limits below come from the [spec](/trackparse/reference/spec/), so they are the same in the -JavaScript, Python, Rust and Go packages. A new feature starts in the spec and lands in all four at -once. +JavaScript, Python, Rust, Go and C packages. A new feature starts in the spec and lands in all five +at once. ## Not there yet @@ -18,8 +18,8 @@ once. Only known label phrases (`[NCS Release]`) go to [`junk`](/trackparse/guides/junk-and-flags/#junk) as `label`. - Key and BPM (`8A`, `174 BPM`) stay in the title too. - An artist database. `Earth, Wind & Fire` splits unless you pass it in - [`knownArtists`](/trackparse/guides/artists/#knownartists) (`known_artists` in Python and Rust, `KnownArtists` in Go), - and a tracklist doesn't learn names from its other lines yet. + [`knownArtists`](/trackparse/guides/artists/#knownartists) (`known_artists` in Python and Rust, `KnownArtists` in Go, + `trackparse_parse_options_add_known_artist` in C), and a tracklist doesn't learn names from its other lines yet. - Gap and overlap checks between consecutive tracklist times. If one of these blocks you, [open an issue](https://github.com/4matic/trackparse/issues) with a few diff --git a/site/src/content/docs/project/testing.md b/site/src/content/docs/project/testing.md index f057163..e4fdde9 100644 --- a/site/src/content/docs/project/testing.md +++ b/site/src/content/docs/project/testing.md @@ -5,7 +5,7 @@ description: 13,130 shared fixtures, a generator that can't agree with the code The fixtures in [`spec/fixtures`](https://github.com/4matic/trackparse/tree/main/spec/fixtures) are the source of truth. The [spec](/trackparse/reference/spec/) says what should happen, the fixtures -pin it down, and every port has to pass all of them. The JavaScript, Python, Rust and Go ports all do: +pin it down, and every port has to pass all of them. The JavaScript, Python, Rust, Go and C ports all do: **13,130 of 13,130**, with empty skip lists, in CI on every push. ## Handwritten: 1,203 cases @@ -52,25 +52,41 @@ don't model are rejected instead of guessed. Each port throws thousands of random strings at the parser to check the [invariants](/trackparse/reference/spec/#invariants) from the spec. The JavaScript suite uses [fast-check](https://github.com/dubzzz/fast-check) and the Python suite uses -[Hypothesis](https://hypothesis.works). The Rust and Go suites each have a small seeded generator -of their own, so neither needs an extra test dependency. The Go module also has fuzz targets for -`Parse`, [`ParseArtists`](/trackparse/reference/functions/#parseartistsinput-options), `Format`, [`ParseTracklist`](/trackparse/reference/tracklist/#parsetracklisttext-options), [`ApplyEdits`](/trackparse/reference/tracklist/#applyeditstext-edits-options), `Track.UnmarshalJSON` and the +[Hypothesis](https://hypothesis.works). The Rust, Go and C suites each have a small seeded +generator of their own, so none of them needs an extra test dependency. The Go module also has +fuzz targets for `Parse`, [`ParseArtists`](/trackparse/reference/functions/#parseartistsinput-options), `Format`, [`ParseTracklist`](/trackparse/reference/tracklist/#parsetracklisttext-options), [`ApplyEdits`](/trackparse/reference/tracklist/#applyeditstext-edits-options), `Track.UnmarshalJSON` and the internal pipeline (`go test -fuzz`) that run the same checks on whatever the fuzzer finds, and a test that calls the parser, the tracklist functions and the edits from 16 goroutines at once under the race detector. +The C library has the same kinds of tests, plus a few that only C needs: + +- libFuzzer targets for `parse`, `parse_artists`, `format`, `parse_tracklist`, `apply_edits` and + the JSON reader of the tests, seeded with every fixture input and checking the same invariants; +- an out-of-memory test: for about 50 inputs across the API, the n-th allocation fails, for every n + until the call succeeds, and each call must return `NULL` or the correct result and free every + block it took; +- 16 threads calling a shared parser, the free functions, the tracklist functions and the edits at + once, under ThreadSanitizer in CI, against the bytes of a sequential run; +- the whole fixture set after `setlocale(LC_ALL, "")` and under German and Turkish locales, which + must give the bytes of the `C` locale; +- the suite under AddressSanitizer with UndefinedBehaviorSanitizer (GCC and Clang), + MemorySanitizer and Valgrind, so an out-of-bounds read, an uninitialized value, a leak or + undefined behaviour fails it. + - it never throws or panics, on any input, in any mode; -- a 10,000-code-point input finishes inside a ceiling: 1 s in JavaScript and Python, 2 s in Rust - and Go. - It normally takes tens of milliseconds in JavaScript and Rust, a few milliseconds in Go and well - under a second in Python; +- a 10,000-code-point input finishes inside a ceiling: 1 s in JavaScript and Python, 2 s in Rust, + Go and C (Go and C widen it ten times under the race detector or a sanitizer). + It normally takes tens of milliseconds in JavaScript and Rust, a few milliseconds in Go and C and + well under a second in Python; the ceiling is loose so that a busy CI machine doesn't fail the run but a blowup does; - [`normalize`](/trackparse/reference/functions/#normalizeinput) is idempotent; - whitespace, dash and zero-width noise don't change the result; -- every output validates against the JSON Schema (JavaScript, Python and Go; the Rust output is - compared with JavaScript byte for byte instead, see below); -- no word of the input goes missing from the output (the Rust and Go suites); +- every output validates against the JSON Schema (JavaScript, Python, Go and C, where the fixture + runner writes every output and a Node script checks it; the Rust output is compared with + JavaScript byte for byte instead, see below); +- no word of the input goes missing from the output (the Rust, Go and C suites); - `parse(format(parse(s)))` round-trips. For tracklists, on random multi-line text and random edit lists: @@ -79,7 +95,8 @@ For tracklists, on random multi-line text and random edit lists: - `applyEdits(t, [])` returns `t`, and an edit never touches a line it doesn't name; - shifting forward and back restores the text, unless something was clamped or upgraded; - 10,000 lines parse inside a ceiling each suite sets for itself: 3 s in JavaScript (it takes - about 0.8 s), 15 s in Python, 3 s in an optimized Rust build, 3 s in Go (it takes about 0.35 s); + about 0.8 s), 15 s in Python, 3 s in an optimized Rust build, 3 s in Go (it takes about 0.35 s) + and 3 s in C (it takes about 0.35 s too); - Markdown emphasis around a time or a track line gives the same kind, time and track as the plain line. @@ -87,13 +104,14 @@ For tracklists, on random multi-line text and random edit lists: A fixture only checks the fields it asserts. So [`compare-ports.mjs`](https://github.com/4matic/trackparse/blob/main/scripts/compare-ports.mjs) runs -every fixture input through all four ports, JavaScript, Python, Rust and Go, and diffs the complete +every fixture input through all five ports, JavaScript, Python, Rust, Go and C, and diffs the complete JSON output, tracklists and edits included. The difference count is zero. [`fuzz-ports.mjs`](https://github.com/4matic/trackparse/blob/main/scripts/fuzz-ports.mjs) does the same with random input, which reaches places no fixture does. The Rust crate and the Go module were each run against JavaScript on about 500,000 random single-track cases and 290,000 random -tracklists with edits, again with zero differences. +tracklists with edits, again with zero differences. CI runs the C library against JavaScript on +50,000 random tracks and 10,000 tracklists on every push. ## Real tracklists @@ -111,7 +129,8 @@ Every push runs one workflow per port, plus one for the spec: | [`python.yml`](https://github.com/4matic/trackparse/blob/main/.github/workflows/python.yml) | ruff, `mypy --strict` and pytest on Python 3.9 to 3.14, and every fixture against the installed wheel | | [`rust.yml`](https://github.com/4matic/trackparse/blob/main/.github/workflows/rust.yml) | `cargo test --locked` on stable and on Rust 1.74. On stable only: rustfmt, clippy, the tests with `--all-features` and a publish dry run. Also the Rust output against the built JavaScript package on every fixture | | [`go.yml`](https://github.com/4matic/trackparse/blob/main/.github/workflows/go.yml) | `go vet` and `go test -race` on Go 1.22 and on stable, with the artist-side test data written from the built JavaScript package. On stable only: gofmt, staticcheck and the full Unicode check against Node. Also checks that the generated data and Unicode tables are current, that `go.mod` has no dependencies and that no unstable `sort.Slice` is used, and compares the Go output with the built JavaScript package on every fixture. A separate job builds and tests `go/` on its own, as the module zip holds it. A weekly scheduled run fuzzes every fuzz target for three to five minutes | -| [`spec.yml`](https://github.com/4matic/trackparse/blob/main/.github/workflows/spec.yml) | Fixture validation, stale generated files, the generator's own tests, and that the version numbers of the spec and the four packages match | +| [`c.yml`](https://github.com/4matic/trackparse/blob/main/.github/workflows/c.yml) | CMake builds with `-Werror` and `ctest` (fixtures, schema check, unit, property, thread, locale and out-of-memory tests, the C++ wrapper in C++17 and C++20, the examples, the exported-symbol check and the install, pkg-config, amalgamation and FetchContent consumers) with GCC and Clang on Linux, GCC on ARM64, a shared-library build, Apple Clang on macOS and MSVC on Windows; 32-bit x86 and GCC 9 with CMake 3.16. The suite under ASan + UBSan (GCC and Clang), ThreadSanitizer, MemorySanitizer and Valgrind, and under German and Turkish locales. Also checks that the generated data and Unicode tables are current and match the Go port's sample, clang-format, a grep that keeps locale-dependent and unstable calls (`qsort`, `strtod`, ``, the `printf` family) out of `src/`, and the amalgamation; compares the C output with the built JavaScript package on every fixture and on random input. A weekly scheduled run fuzzes every libFuzzer target for ten minutes | +| [`spec.yml`](https://github.com/4matic/trackparse/blob/main/.github/workflows/spec.yml) | Fixture validation, stale generated files, the generator's own tests, and that the version numbers of the spec and the five ports match | ## Run it yourself @@ -136,8 +155,16 @@ cd ../go go test ./... # the same fixtures, invariants and unit tests TRACKPARSE_REPORT=1 go test -run TestFixtures -v . # pass rate per file and per rule -# All four against each other (from the root) +# C (a C11 compiler, CMake 3.16 or newer) cd .. +cmake -S c -B c/build +cmake --build c/build +ctest --test-dir c/build --output-on-failure # the same fixtures, schema check, unit tests +TRACKPARSE_REPORT=1 c/build/trackparse-fixtures spec/fixtures/*/*.json # pass rate per file and per rule +cmake -S c -B c/build-asan -DTRACKPARSE_SANITIZE=ON # the same suite under ASan and UBSan +cmake --build c/build-asan && ctest --test-dir c/build-asan -LE consumer + +# All five against each other (from the root) pnpm build node scripts/compare-ports.mjs # must print "differences: 0" node scripts/fuzz-ports.mjs # the same diff on random tracks and tracklists with edits @@ -147,5 +174,5 @@ node scripts/fuzz-ports.mjs # the same diff on random tracks and tracklists - [Ports](/trackparse/project/ports/) for what each port had to get right. - [Contributing](/trackparse/project/contributing/) for how a rule change goes through the spec, - the fixtures and the four ports. + the fixtures and the five ports. - [How it works](/trackparse/project/how-it-works/) for the pipeline the fixtures exercise. diff --git a/site/src/content/docs/reference/functions.mdx b/site/src/content/docs/reference/functions.mdx index 7775f53..05067e5 100644 --- a/site/src/content/docs/reference/functions.mdx +++ b/site/src/content/docs/reference/functions.mdx @@ -6,19 +6,20 @@ description: parseArtists, format, normalize, allArtists, createParser and SPEC_ import { Tabs, TabItem } from "@astrojs/starlight/components"; All of these are exported from `trackparse`. The Python package and the Rust crate have the same -functions in snake_case, and the Go package in CamelCase. [`parse`](/trackparse/reference/parse/) and the +functions in snake_case, the Go package in CamelCase, and the C library in snake_case with a +`trackparse_` prefix. [`parse`](/trackparse/reference/parse/) and the [tracklist functions](/trackparse/reference/tracklist/) have pages of their own. -| JavaScript | Python | Rust | Go | -|---|---|---|---| -| `parse` | `parse` | `parse`, `parse_with` | `Parse`, `ParseWith` | -| `parseArtists` | `parse_artists` | `parse_artists`, `parse_artists_with` | `ParseArtists`, `ParseArtistsWith` | -| `format` | `format_track` | `format_track`, `format_track_with` | `Format`, `FormatWith` | -| `normalize` | `normalize` | `normalize` | `Normalize` | -| `allArtists` | `all_artists` | `all_artists` | `AllArtists` | -| `createParser` | `create_parser` | `Parser::new` | `NewParser` | -| `SPEC_VERSION` | `SPEC_VERSION` | `SPEC_VERSION` | `SpecVersion` | -| [`parseTracklist`](/trackparse/reference/tracklist/#parsetracklisttext-options), [`applyEdits`](/trackparse/reference/tracklist/#applyeditstext-edits-options) (from `trackparse/tracklist`) | `parse_tracklist`, `apply_edits` (from `trackparse.tracklist`) | `parse_tracklist`, `parse_tracklist_with`, `apply_edits`, `apply_edits_with` (from `trackparse::tracklist`) | `ParseTracklist`, `ParseTracklistWith`, `ApplyEdits`, `ApplyEditsWith` (same package) | +| JavaScript | Python | Rust | Go | C | +|---|---|---|---|---| +| `parse` | `parse` | `parse`, `parse_with` | `Parse`, `ParseWith` | `trackparse_parse`, `trackparse_parse_with` | +| `parseArtists` | `parse_artists` | `parse_artists`, `parse_artists_with` | `ParseArtists`, `ParseArtistsWith` | `trackparse_parse_artists`, `trackparse_parse_artists_with` | +| `format` | `format_track` | `format_track`, `format_track_with` | `Format`, `FormatWith` | `trackparse_format`, `trackparse_format_with` | +| `normalize` | `normalize` | `normalize` | `Normalize` | `trackparse_normalize` | +| `allArtists` | `all_artists` | `all_artists` | `AllArtists` | `trackparse_all_artists` | +| `createParser` | `create_parser` | `Parser::new` | `NewParser` | `trackparse_parser_new` | +| `SPEC_VERSION` | `SPEC_VERSION` | `SPEC_VERSION` | `SpecVersion` | `trackparse_spec_version()` | +| [`parseTracklist`](/trackparse/reference/tracklist/#parsetracklisttext-options), [`applyEdits`](/trackparse/reference/tracklist/#applyeditstext-edits-options) (from `trackparse/tracklist`) | `parse_tracklist`, `apply_edits` (from `trackparse.tracklist`) | `parse_tracklist`, `parse_tracklist_with`, `apply_edits`, `apply_edits_with` (from `trackparse::tracklist`) | `ParseTracklist`, `ParseTracklistWith`, `ApplyEdits`, `ApplyEditsWith` (same package) | `trackparse_parse_tracklist`, `trackparse_parse_tracklist_with`, `trackparse_apply_edits` (same header) | What to know for each language: @@ -42,12 +43,21 @@ What to know for each language: is not valid UTF-8 is read with U+FFFD in place of each bad sequence. The tracklist functions are in the same package. Every function has an entry with examples on [pkg.go.dev](https://pkg.go.dev/github.com/4matic/trackparse/go#section-documentation). +- **C** (one header, [`trackparse.h`](https://github.com/4matic/trackparse/blob/main/c/include/trackparse.h)). Each function that takes options has a + `_with` form that takes an options handle, and `NULL` there means the defaults. Input is UTF-8 + as a pointer and a byte length; pass `TRACKPARSE_NUL_TERMINATED` for a C string. Results are + read-only structs that own all their memory: free each with its own function + (`trackparse_track_free`, `trackparse_artists_free`, `trackparse_string_free`, and so on). Lists + are a pointer and a `_count` member, nullable fields are pointers that are `NULL` when absent, + and enums have a `_name()` function that gives the spec's string. Strings in results are + `trackparse_str`, a `ptr` and a `len`, and `ptr` is also NUL-terminated. A function returns + `NULL` only when memory runs out; it never crashes on any input. All functions are thread-safe. The options themselves are on the [Options](/trackparse/reference/options/) page. ## parseArtists(input, options?) -*(Python: `parse_artists`. Rust: [`parse_artists`](https://docs.rs/trackparse/latest/trackparse/fn.parse_artists.html), [`parse_artists_with`](https://docs.rs/trackparse/latest/trackparse/fn.parse_artists_with.html). Go: [`ParseArtists`](https://pkg.go.dev/github.com/4matic/trackparse/go#ParseArtists), [`ParseArtistsWith`](https://pkg.go.dev/github.com/4matic/trackparse/go#ParseArtistsWith))* +*(Python: `parse_artists`. Rust: [`parse_artists`](https://docs.rs/trackparse/latest/trackparse/fn.parse_artists.html), [`parse_artists_with`](https://docs.rs/trackparse/latest/trackparse/fn.parse_artists_with.html). Go: [`ParseArtists`](https://pkg.go.dev/github.com/4matic/trackparse/go#ParseArtists), [`ParseArtistsWith`](https://pkg.go.dev/github.com/4matic/trackparse/go#ParseArtistsWith). C: `trackparse_parse_artists`, `trackparse_parse_artists_with`)* Splits a bare artist string, with no title, into credits. @@ -102,20 +112,38 @@ for _, a := range trackparse.ParseArtists("Sub Focus, Wilkinson & Dimension feat // Kojo:featured ``` + + + +```c +#include + +trackparse_artists *as = trackparse_parse_artists("Sub Focus, Wilkinson & Dimension feat. Kojo", + TRACKPARSE_NUL_TERMINATED); +for (size_t i = 0; i < as->count; i++) { + printf("%s:%s\n", as->items[i].name.ptr, trackparse_role_name(as->items[i].role)); +} +// Sub Focus:primary +// Wilkinson:primary +// Dimension:primary +// Kojo:featured +trackparse_artists_free(as); +``` + Takes [`knownArtists`](/trackparse/guides/artists/#knownartists), [`splitAnd`](/trackparse/guides/artists/#and-is-special) and [`keywords`](/trackparse/reference/options/#keywords) (`known_artists`, `split_and`, `keywords`; in Rust -through `parse_artists_with`, in Go through `ParseArtistsWith`). Use it for the artist field of ID3 tags or a streaming API, where +through `parse_artists_with`, in Go through `ParseArtistsWith`, in C through `trackparse_parse_artists_with`). Use it for the artist field of ID3 tags or a streaming API, where the title is already separate. The result is a list of [`Artist`](/trackparse/reference/parse/#artist) values (a `list` in Python, a `Vec` in Rust, a slice -in Go), and the splitting rules are explained in +in Go, a `trackparse_artists` with `items` and `count` in C), and the splitting rules are explained in [Artists and credits](/trackparse/guides/artists/). In the spec this is [R10](/trackparse/reference/spec/#r10-parseartists). ## format(track, options?) -*(Python: `format_track`. Rust: [`format_track`](https://docs.rs/trackparse/latest/trackparse/fn.format_track.html), [`format_track_with`](https://docs.rs/trackparse/latest/trackparse/fn.format_track_with.html). Go: [`Format`](https://pkg.go.dev/github.com/4matic/trackparse/go#Format), [`FormatWith`](https://pkg.go.dev/github.com/4matic/trackparse/go#FormatWith))* +*(Python: `format_track`. Rust: [`format_track`](https://docs.rs/trackparse/latest/trackparse/fn.format_track.html), [`format_track_with`](https://docs.rs/trackparse/latest/trackparse/fn.format_track_with.html). Go: [`Format`](https://pkg.go.dev/github.com/4matic/trackparse/go#Format), [`FormatWith`](https://pkg.go.dev/github.com/4matic/trackparse/go#FormatWith). C: `trackparse_format`, `trackparse_format_with`)* Renders a [`ParsedTrack`](/trackparse/reference/parse/#parsedtrack) back to a string. Junk is left out. @@ -153,17 +181,34 @@ fmt.Printf("%q\n", trackparse.FormatWith(trackparse.Parse("Wilkinson ft. Becky H // "Wilkinson - Afterglow (feat. Becky Hill) (Sub Focus Remix)" ``` + + + +```c +trackparse_format_options *fo = trackparse_format_options_new(); +trackparse_format_options_set_feat(fo, TRACKPARSE_FEAT_TITLE); +trackparse_format_options_set_joiners(fo, TRACKPARSE_JOINERS_CANONICAL); +trackparse_track *t = trackparse_parse("Wilkinson ft. Becky Hill - Afterglow (Sub Focus Remix)", + TRACKPARSE_NUL_TERMINATED); +trackparse_string *s = trackparse_format_with(t, fo); +printf("%s\n", s->str.ptr); +// Wilkinson - Afterglow (feat. Becky Hill) (Sub Focus Remix) +trackparse_string_free(s); +trackparse_format_options_free(fo); +``` + The options are `feat`, [`featMarker`](/trackparse/guides/formatting/#options) (`feat_marker`), `joiners`, `versions`, `producers` and `position`. In Go they are the fields of `FormatOptions`, where `OmitProducers: true` stands for -`producers: false`. [Formatting](/trackparse/guides/formatting/) has the table and an example of each. In +`producers: false`. In C they are setters on a `trackparse_format_options` handle, where +`trackparse_format_options_set_omit_producers(o, true)` stands for `producers: false`. [Formatting](/trackparse/guides/formatting/) has the table and an example of each. In the spec this is [R11](/trackparse/reference/spec/#r11-format). ## normalize(input) -*(Python: `normalize`. Rust: [`normalize`](https://docs.rs/trackparse/latest/trackparse/fn.normalize.html). Go: [`Normalize`](https://pkg.go.dev/github.com/4matic/trackparse/go#Normalize))* +*(Python: `normalize`. Rust: [`normalize`](https://docs.rs/trackparse/latest/trackparse/fn.normalize.html). Go: [`Normalize`](https://pkg.go.dev/github.com/4matic/trackparse/go#Normalize). C: `trackparse_normalize`)* The Unicode cleanup every function runs first. It applies NFC, removes invisible characters (zero-width spaces, BOMs, soft hyphens), turns dash, bracket and quote variants into their plain @@ -197,6 +242,15 @@ normalize("Noisia\u{200b} — “Stigma”"); // "Noisia - \"Stigma\"" fmt.Printf("%q\n", trackparse.Normalize("Noisia\u200b — “Stigma”")) // "Noisia - \"Stigma\"" ``` + + + +```c +s = trackparse_normalize("Noisia\u200b — “Stigma”", TRACKPARSE_NUL_TERMINATED); +printf("%s\n", s->str.ptr); // Noisia - "Stigma" +trackparse_string_free(s); +``` + @@ -205,7 +259,7 @@ keys. The steps are [R1](/trackparse/reference/spec/#r1-normalization) in the sp ## allArtists(track) -*(Python: `all_artists`. Rust: [`all_artists`](https://docs.rs/trackparse/latest/trackparse/fn.all_artists.html). Go: [`AllArtists`](https://pkg.go.dev/github.com/4matic/trackparse/go#AllArtists))* +*(Python: `all_artists`. Rust: [`all_artists`](https://docs.rs/trackparse/latest/trackparse/fn.all_artists.html). Go: [`AllArtists`](https://pkg.go.dev/github.com/4matic/trackparse/go#AllArtists). C: `trackparse_all_artists`)* Every credit of a track in one list: the artists, then every remixer, with duplicates removed. Names are compared with the dedup key of @@ -250,12 +304,27 @@ for _, a := range trackparse.AllArtists(trackparse.Parse("Wilkinson ft. Becky Hi // Sub Focus:remixer ``` + + + +```c +as = trackparse_all_artists(t); /* t is the Wilkinson track from the format example */ +for (size_t i = 0; i < as->count; i++) { + printf("%s:%s\n", as->items[i].name.ptr, trackparse_role_name(as->items[i].role)); +} +// Wilkinson:primary +// Becky Hill:featured +// Sub Focus:remixer +trackparse_artists_free(as); +trackparse_track_free(t); +``` + ## createParser(options) -*(Python: `create_parser`. Rust: [`Parser::new`](https://docs.rs/trackparse/latest/trackparse/struct.Parser.html). Go: [`NewParser`](https://pkg.go.dev/github.com/4matic/trackparse/go#NewParser), which returns a [`Parser`](https://pkg.go.dev/github.com/4matic/trackparse/go#Parser))* +*(Python: `create_parser`. Rust: [`Parser::new`](https://docs.rs/trackparse/latest/trackparse/struct.Parser.html). Go: [`NewParser`](https://pkg.go.dev/github.com/4matic/trackparse/go#NewParser), which returns a [`Parser`](https://pkg.go.dev/github.com/4matic/trackparse/go#Parser). C: `trackparse_parser_new`)* Compiles options and keywords once and returns an object with [`parse`](/trackparse/reference/parse/) and `parseArtists` (`parse_artists`). Use it when you parse many strings with the same [`knownArtists`](/trackparse/guides/artists/#knownartists) or [`keywords`](/trackparse/reference/options/#keywords). @@ -265,7 +334,10 @@ over the compiled ones: `parser.parse(s, { mode: "youtube" })`, `parser.parse(s, The Rust `Parser` takes its options once, in `Parser::new(&options)`. Its `parse` and `parse_artists` take only the input, and it is `Send + Sync`, so one parser can serve many threads. The Go `NewParser(options)` works the same way: its `Parse` and `ParseArtists` methods take only the input, and a `*Parser` is safe -for concurrent use by many goroutines. +for concurrent use by many goroutines. The C `trackparse_parser_new(options)` copies what it needs +from the options handle, so the handle can be freed right away. `trackparse_parser_parse` and +`trackparse_parser_parse_artists` take only the input, and a parser is immutable, so many threads +can share one. Free it with `trackparse_parser_free`. @@ -327,17 +399,40 @@ fmt.Println(parser.Parse("Chase & Status x Camo & Krooked - Track (Alix Perez Re // rework ``` + + + +```c +trackparse_parse_options *o = trackparse_parse_options_new(); +trackparse_parse_options_add_known_artist(o, "Chase & Status", TRACKPARSE_NUL_TERMINATED); +trackparse_parse_options_add_known_artist(o, "Camo & Krooked", TRACKPARSE_NUL_TERMINATED); +trackparse_parse_options_add_version_head(o, "rerub", TRACKPARSE_NUL_TERMINATED, + "rework", TRACKPARSE_NUL_TERMINATED); +trackparse_parser *parser = trackparse_parser_new(o); +trackparse_parse_options_free(o); + +t = trackparse_parser_parse(parser, "Chase & Status x Camo & Krooked - Track (Alix Perez Rerub)", + TRACKPARSE_NUL_TERMINATED); +printf("%s\n", t->versions[0].type_name.ptr); +// rework +trackparse_track_free(t); +trackparse_parser_free(parser); +``` + ## SPEC_VERSION -*(Rust: [`SPEC_VERSION`](https://docs.rs/trackparse/latest/trackparse/constant.SPEC_VERSION.html). Go: [`SpecVersion`](https://pkg.go.dev/github.com/4matic/trackparse/go#SpecVersion))* +*(Rust: [`SPEC_VERSION`](https://docs.rs/trackparse/latest/trackparse/constant.SPEC_VERSION.html). Go: [`SpecVersion`](https://pkg.go.dev/github.com/4matic/trackparse/go#SpecVersion). C: `trackparse_spec_version()`)* The version of the [spec](/trackparse/reference/spec/) the package implements, as a string (`&str` -in Rust, the constant `SpecVersion` in Go). The packages and the spec are released together, so it's the same as the package version. -A parsed tracklist carries it too, as `specVersion` (`spec_version` in Python and Rust, -`SpecVersion` in Go). +in Rust, the constant `SpecVersion` in Go, the function `trackparse_spec_version()` in C, which +returns a static string). The packages and the spec are released together, so it's the same as the package version. +A parsed tracklist carries it too, as `specVersion` (`spec_version` in Python, Rust and C, +`SpecVersion` in Go). In C, `trackparse_library_version()` gives the version of the linked +library and the macro `TRACKPARSE_VERSION` that of the header, which differ only when a shared +library is replaced. ## See also @@ -345,4 +440,4 @@ A parsed tracklist carries it too, as `specVersion` (`spec_version` in Python an [Options](/trackparse/reference/options/). - [Tracklist API](/trackparse/reference/tracklist/) for [`parseTracklist`](/trackparse/reference/tracklist/#parsetracklisttext-options) and [`applyEdits`](/trackparse/reference/tracklist/#applyeditstext-edits-options). - [Warnings](/trackparse/reference/warnings/) for the codes these functions report. -- [Ports](/trackparse/project/ports/) for how the four packages are kept identical. +- [Ports](/trackparse/project/ports/) for how the five packages are kept identical. diff --git a/site/src/content/docs/reference/options.mdx b/site/src/content/docs/reference/options.mdx index d890c93..085fd00 100644 --- a/site/src/content/docs/reference/options.mdx +++ b/site/src/content/docs/reference/options.mdx @@ -7,7 +7,8 @@ import { Tabs, TabItem } from "@astrojs/starlight/components"; [`parse`](/trackparse/reference/parse/), [`parseArtists`](/trackparse/reference/functions/#parseartistsinput-options) and [`createParser`](/trackparse/reference/functions/#createparseroptions) take the same options. JavaScript takes an object, Python takes keyword arguments, Rust takes a `ParseOptions` value through the `_with` functions, -and Go takes a `ParseOptions` struct through the `With` functions. +Go takes a `ParseOptions` struct through the `With` functions, and C takes an options handle +through the `_with` functions. ## Parse options @@ -101,16 +102,45 @@ options := trackparse.ParseOptions{ fmt.Printf("%q\n", trackparse.ParseWith(input, options).Artists[0].Name) // "Chase & Status" ``` + + + +```c +#include + +trackparse_parse_options *trackparse_parse_options_new(void); +void trackparse_parse_options_free(trackparse_parse_options *o); +bool trackparse_parse_options_set_mode(trackparse_parse_options *o, trackparse_mode mode); +bool trackparse_parse_options_set_uploader(trackparse_parse_options *o, const char *s, size_t len); +bool trackparse_parse_options_add_known_artist(trackparse_parse_options *o, const char *s, size_t len); +bool trackparse_parse_options_set_split_and(trackparse_parse_options *o, trackparse_split_and v); +``` + +Create a handle and call a setter per option. The options you don't set keep their defaults: + +```c +const char *input = "Chase & Status - Baddadan"; +trackparse_parse_options *options = trackparse_parse_options_new(); +trackparse_parse_options_set_mode(options, TRACKPARSE_MODE_YOUTUBE); +trackparse_parse_options_add_known_artist(options, "Chase & Status", TRACKPARSE_NUL_TERMINATED); +trackparse_parse_options_set_uploader(options, "Daft Punk - Topic", TRACKPARSE_NUL_TERMINATED); +trackparse_parse_options_set_split_and(options, TRACKPARSE_SPLIT_AND_NEVER); +trackparse_track *t = trackparse_parse_with(input, TRACKPARSE_NUL_TERMINATED, options); +printf("%s\n", t->artists[0].name.ptr); // Chase & Status +trackparse_track_free(t); +trackparse_parse_options_free(options); +``` + -| JavaScript | Python and Rust | Go | Default | | -|---|---|---|---|---| -| `mode` | `mode` | `Mode` | `"auto"` | Which [mode](/trackparse/guides/modes/) to use. `auto` picks `filename`, `youtube` or `clean` from the string | -| `knownArtists` | `known_artists` | `KnownArtists` | empty | Names that are never split, like `Chase & Status` or `Earth, Wind & Fire`. Matched case- and accent-insensitively. See [knownArtists](/trackparse/guides/artists/#knownartists) | -| `uploader` | `uploader` | `Uploader` | none | The YouTube channel. In youtube mode it becomes the artist when there's no separator. `- Topic` and `VEVO` are dropped. See [the uploader fallback](/trackparse/guides/modes/#the-uploader-fallback) | -| `splitAnd` | `split_and` | `SplitAnd` | `"auto"` | `auto` splits on `and` only after a comma (`A, B and C`), so `Simon and Garfunkel` stays whole. `always` and `never` do what they say. See [`and` is special](/trackparse/guides/artists/#and-is-special) | -| `keywords` | `keywords` | `Keywords` | none | Extra vocabulary, see [keywords](#keywords) below | +| JavaScript | Python and Rust | Go | C | Default | | +|---|---|---|---|---|---| +| `mode` | `mode` | `Mode` | `trackparse_parse_options_set_mode` | `"auto"` | Which [mode](/trackparse/guides/modes/) to use. `auto` picks `filename`, `youtube` or `clean` from the string | +| `knownArtists` | `known_artists` | `KnownArtists` | `trackparse_parse_options_add_known_artist` | empty | Names that are never split, like `Chase & Status` or `Earth, Wind & Fire`. Matched case- and accent-insensitively. See [knownArtists](/trackparse/guides/artists/#knownartists) | +| `uploader` | `uploader` | `Uploader` | `trackparse_parse_options_set_uploader` | none | The YouTube channel. In youtube mode it becomes the artist when there's no separator. `- Topic` and `VEVO` are dropped. See [the uploader fallback](/trackparse/guides/modes/#the-uploader-fallback) | +| `splitAnd` | `split_and` | `SplitAnd` | `trackparse_parse_options_set_split_and` | `"auto"` | `auto` splits on `and` only after a comma (`A, B and C`), so `Simon and Garfunkel` stays whole. `always` and `never` do what they say. See [`and` is special](/trackparse/guides/artists/#and-is-special) | +| `keywords` | `keywords` | `Keywords` | `trackparse_parse_options_add_version_head` and the other `add_` setters | none | Extra vocabulary, see [keywords](#keywords) below | All five work the same in [`parse`](/trackparse/reference/parse/), [`parseArtists`](/trackparse/reference/functions/#parseartistsinput-options) (which ignores `mode` @@ -131,8 +161,19 @@ value of `ParseOptions` is the defaults: an empty `Mode` is auto, an empty `Spli empty `Uploader` is none. A string that is not one of the constants behaves as an unknown value does in JavaScript. +In C the options are an opaque handle: create it with `trackparse_parse_options_new()`, call a +setter per option, pass it to `trackparse_parse_with`, `trackparse_parse_artists_with` or +`trackparse_parser_new`, and free it with `trackparse_parse_options_free`. An option you never +set keeps its default, and an empty uploader is none, as in Go. Setters copy their input, so the strings you pass can +be freed right after the call, and the `add_` setters append one entry each. A setter returns +`false` only when memory runs out. A `NULL` handle means the defaults. The values are the enums +`TRACKPARSE_MODE_AUTO`, `_CLEAN`, `_YOUTUBE`, `_FILENAME` and `_TRACKLIST`, and +`TRACKPARSE_SPLIT_AND_AUTO`, `_ALWAYS` and `_NEVER`; a value out of range falls back to the +default, as an unknown value does in JavaScript. The declarations are in +[`trackparse.h`](https://github.com/4matic/trackparse/blob/main/c/include/trackparse.h). + Options never cause an error. An unknown mode, a `knownArtists` that isn't a list or a keyword of -the wrong type is ignored and the default is used. In Rust and Go the options are typed, so most of +the wrong type is ignored and the default is used. In Rust, Go and C the options are typed, so most of those values can't be written at all. The option rules are [R12](/trackparse/reference/spec/#r12-options) in the spec. @@ -149,7 +190,10 @@ snake_case too: `version_heads`, `feat_markers`. In Rust, entry. In Go, [`Keywords`](https://pkg.go.dev/github.com/4matic/trackparse/go#Keywords) holds slices: the two maps of the JavaScript options are ordered slices of [`VersionHead`](https://pkg.go.dev/github.com/4matic/trackparse/go#VersionHead) and [`JunkPhrase`](https://pkg.go.dev/github.com/4matic/trackparse/go#JunkPhrase), because a Go map has no insertion order. They are read as JavaScript reads an object: a repeated key keeps its first place and takes the last -value, and integer-like keys come first, in ascending order. The built-in lists are JSON files in +value, and integer-like keys come first, in ascending order. In C, each `add_` setter on the +options handle adds one entry, and the version heads and junk phrases are read in that same +JavaScript order. The type and kind are spec names given as strings, so a name that is not one of +the built-in types also works, as in JavaScript. The built-in lists are JSON files in [`spec/data`](https://github.com/4matic/trackparse/tree/main/spec/data), and the keyword rules are [R12](/trackparse/reference/spec/#r12-options). [Your own words](/trackparse/guides/versions/#your-own-words) in the versions guide has another example. @@ -206,6 +250,20 @@ type Keywords struct { } ``` + + + +```c +/* Each call adds one entry; type and kind are spec names ("rework", "other"). */ +bool trackparse_parse_options_add_version_head(trackparse_parse_options *o, const char *key, + size_t key_len, const char *type, size_t type_len); +bool trackparse_parse_options_add_descriptor(trackparse_parse_options *o, const char *s, size_t len); +bool trackparse_parse_options_add_genre(trackparse_parse_options *o, const char *s, size_t len); +bool trackparse_parse_options_add_junk(trackparse_parse_options *o, const char *phrase, + size_t phrase_len, const char *kind, size_t kind_len); +bool trackparse_parse_options_add_feat_marker(trackparse_parse_options *o, const char *s, size_t len); +``` + @@ -276,6 +334,30 @@ fmt.Printf("%q\n", []string{t.Artists[0].Name, t.Artists[1].Name}) // ["Chase fmt.Println(t.Versions[0].Type) // rework ``` + + + +```c +trackparse_parse_options *o = trackparse_parse_options_new(); +trackparse_parse_options_add_known_artist(o, "Chase & Status", TRACKPARSE_NUL_TERMINATED); +trackparse_parse_options_add_known_artist(o, "Camo & Krooked", TRACKPARSE_NUL_TERMINATED); +trackparse_parse_options_add_version_head(o, "rerub", TRACKPARSE_NUL_TERMINATED, + "rework", TRACKPARSE_NUL_TERMINATED); +trackparse_parser *parser = trackparse_parser_new(o); +trackparse_parse_options_free(o); + +t = trackparse_parser_parse(parser, "Chase & Status x Camo & Krooked - Track (Alix Perez Rerub)", + TRACKPARSE_NUL_TERMINATED); +for (size_t i = 0; i < t->artists_count; i++) { + printf("%s\n", t->artists[i].name.ptr); +} +// Chase & Status +// Camo & Krooked +printf("%s\n", t->versions[0].type_name.ptr); // rework +trackparse_track_free(t); +trackparse_parser_free(parser); +``` + @@ -336,29 +418,55 @@ fmt.Printf("%q\n", r.Title) // "Song" fmt.Printf("%+v\n", r.Junk) // [{Raw:Some Label Rip Kind:label}] ``` + + + +```c +t = trackparse_parse("Artist - Song [Some Label Rip]", TRACKPARSE_NUL_TERMINATED); +printf("%s\n", t->title.ptr); // Song [Some Label Rip] +trackparse_track_free(t); + +o = trackparse_parse_options_new(); +trackparse_parse_options_add_junk(o, "some label rip", TRACKPARSE_NUL_TERMINATED, + "label", TRACKPARSE_NUL_TERMINATED); +trackparse_track *r = trackparse_parse_with("Artist - Song [Some Label Rip]", + TRACKPARSE_NUL_TERMINATED, o); +printf("%s\n", r->title.ptr); // Song +for (size_t i = 0; i < r->junk_count; i++) { + printf("%s: %s\n", r->junk[i].kind_name.ptr, r->junk[i].raw.ptr); +} +// label: Some Label Rip +trackparse_track_free(r); +trackparse_parse_options_free(o); +``` + ## Tracklist options [`parseTracklist`](/trackparse/reference/tracklist/#parsetracklisttext-options) and [`applyEdits`](/trackparse/reference/tracklist/#applyeditstext-edits-options) (`parse_tracklist` and `apply_edits` in Python and Rust, -`ParseTracklist` and `ApplyEdits` in Go) take +`ParseTracklist` and `ApplyEdits` in Go, `trackparse_parse_tracklist_with` in C) take `mode` (default `"tracklist"`), [`knownArtists`](/trackparse/guides/artists/#knownartists), [`splitAnd`](/trackparse/guides/artists/#and-is-special) and `keywords`, plus two of their own. In Rust they are the setters of [`TracklistOptions`](/trackparse/reference/tracklist/#options), passed to `parse_tracklist_with` and `apply_edits_with` ([`TracklistOptions` on docs.rs](https://docs.rs/trackparse/latest/trackparse/tracklist/struct.TracklistOptions.html)). In Go they are the fields of the [`TracklistOptions`](https://pkg.go.dev/github.com/4matic/trackparse/go#TracklistOptions) struct, passed to -[`ParseTracklistWith`](https://pkg.go.dev/github.com/4matic/trackparse/go#ParseTracklistWith) and [`ApplyEditsWith`](https://pkg.go.dev/github.com/4matic/trackparse/go#ApplyEditsWith). The +[`ParseTracklistWith`](https://pkg.go.dev/github.com/4matic/trackparse/go#ParseTracklistWith) and [`ApplyEditsWith`](https://pkg.go.dev/github.com/4matic/trackparse/go#ApplyEditsWith). +In C they are the setters of a `trackparse_tracklist_options` handle +(`trackparse_tracklist_options_new()`), passed to `trackparse_parse_tracklist_with`. The rules are [R13.10](/trackparse/reference/spec/#r1310-options): -| JavaScript | Python and Rust | Go | Default | Description | -|---|---|---|---|---| -| [`audioSeconds`](/trackparse/guides/tracklists/#options) | `audio_seconds` | `AudioSeconds` | none | Length of the audio. Turns on the [`time-after-audio-end`](/trackparse/reference/warnings/#tracklist-warnings:~:text=time%2Dafter%2Daudio%2Dend) check | -| [`markerWords`](/trackparse/guides/tracklists/#options) | `marker_words` | `MarkerWords` | empty | Extra marker words. With `["drop"]`, `03:00 Drop` is a marker, not a track | +| JavaScript | Python and Rust | Go | C | Default | Description | +|---|---|---|---|---|---| +| [`audioSeconds`](/trackparse/guides/tracklists/#options) | `audio_seconds` | `AudioSeconds` | `trackparse_tracklist_options_set_audio_seconds` | none | Length of the audio. Turns on the [`time-after-audio-end`](/trackparse/reference/warnings/#tracklist-warnings:~:text=time%2Dafter%2Daudio%2Dend) check | +| [`markerWords`](/trackparse/guides/tracklists/#options) | `marker_words` | `MarkerWords` | `trackparse_tracklist_options_add_marker_word` | empty | Extra marker words. With `["drop"]`, `03:00 Drop` is a marker, not a track | In Go the zero value of `TracklistOptions` is the defaults too: an empty `Mode` means `ModeTracklist`, and `ModeAuto` asks for auto mode on each line. `AudioSeconds` is a `*float64`, so `nil` means no length and [`trackparse.Ptr`](https://pkg.go.dev/github.com/4matic/trackparse/go#Ptr)`(0.0)` is an audio of length 0, as `audioSeconds: 0` -is in JavaScript. +is in JavaScript. In C, an audio length that was never set is none, and +`trackparse_tracklist_options_set_audio_seconds(o, 0)` is an audio of length 0. The default mode +of a tracklist options handle is `TRACKPARSE_MODE_TRACKLIST`. [Tracklists](/trackparse/guides/tracklists/#options) has an example in each language, and the [Tracklist API](/trackparse/reference/tracklist/#options) lists them again with the functions. @@ -369,7 +477,9 @@ is in JavaScript. They are listed under [Formatting](/trackparse/guides/formatting/#options). In Go they are the fields of [`FormatOptions`](https://pkg.go.dev/github.com/4matic/trackparse/go#FormatOptions); `producers: false` is `OmitProducers: true` there, so the zero value keeps the producers, and `FeatMarker` is a `*string` (`nil` keeps the input's marker). In Rust -they are the setters of [`FormatOptions`](https://docs.rs/trackparse/latest/trackparse/struct.FormatOptions.html). The rules are +they are the setters of [`FormatOptions`](https://docs.rs/trackparse/latest/trackparse/struct.FormatOptions.html). In C they are the setters of a +`trackparse_format_options` handle; `trackparse_format_options_set_omit_producers(o, true)` is +`producers: false`, and a marker never set with `_set_feat_marker` keeps the input's. The rules are [R11](/trackparse/reference/spec/#r11-format). ## See also diff --git a/site/src/content/docs/reference/parse.mdx b/site/src/content/docs/reference/parse.mdx index d2df5e5..e129f64 100644 --- a/site/src/content/docs/reference/parse.mdx +++ b/site/src/content/docs/reference/parse.mdx @@ -43,6 +43,17 @@ func Parse(input string) Track func ParseWith(input string, options ParseOptions) Track ``` + + + +```c +#include + +trackparse_track *trackparse_parse(const char *s, size_t len); +trackparse_track *trackparse_parse_with(const char *s, size_t len, const trackparse_parse_options *o); +void trackparse_track_free(trackparse_track *t); +``` + @@ -59,6 +70,13 @@ unknown or malformed options fall back to their defaults. What differs between t [`Parse`](https://pkg.go.dev/github.com/4matic/trackparse/go#Parse) for the defaults and [`ParseWith`](https://pkg.go.dev/github.com/4matic/trackparse/go#ParseWith) to pass options. Bytes that are not valid UTF-8 are read as U+FFFD, one per maximal invalid sequence, as Rust's `String::from_utf8_lossy` and the browser's `TextDecoder` do. +- C (one header, [`trackparse.h`](https://github.com/4matic/trackparse/blob/main/c/include/trackparse.h)): takes UTF-8 as a pointer and a byte length, + and returns a `trackparse_track *` that you free with `trackparse_track_free`. Pass + `TRACKPARSE_NUL_TERMINATED` as the length for a C string; with an explicit length, U+0000 is + read as a character like any other. Invalid UTF-8 is read as U+FFFD with the same rule as Go + and Rust. `trackparse_parse_with` takes an options handle, and `NULL` there means the + defaults. The only failure is running out of memory, reported as `NULL`; no input makes it + crash. The options are on the [Options](/trackparse/reference/options/) page. The other functions ([`parseArtists`](/trackparse/reference/functions/#parseartistsinput-options), [`format`](/trackparse/reference/functions/#formattrack-options), [`createParser`](/trackparse/reference/functions/#createparseroptions)) are under @@ -151,6 +169,33 @@ type Track struct { } ``` + + + +```c +typedef struct trackparse_track { + trackparse_str input; + trackparse_mode mode; + const trackparse_position *position; /* { trackparse_str raw; int number; } */ + const trackparse_timestamp *timestamp; /* { trackparse_str raw; int seconds; } */ + const trackparse_artist *artists; + size_t artists_count; + trackparse_str title; + trackparse_str full_title; + const trackparse_version *versions; + size_t versions_count; + const int *year; + trackparse_flags flags; /* { explicit_, clean, unknown_artist, unknown_title } */ + const trackparse_junk *junk; /* { raw, kind, kind_name } */ + size_t junk_count; + const trackparse_warning *warnings; + size_t warnings_count; +} trackparse_track; +``` + +`flags.explicit_` has a trailing underscore because `explicit` is a C++ keyword; the JSON key is +`explicit`. + @@ -161,7 +206,12 @@ arrays and `None` instead of `null`. Rust has a struct fields: `Vec` for arrays, `Option` where the table says `null`, and enums for `mode`, roles, kinds and warnings. Go has a [`Track`](https://pkg.go.dev/github.com/4matic/trackparse/go#Track) struct with exported CamelCase fields (`FullTitle`, `Flags.UnknownArtist`): slices for arrays, pointers where the table says `null`, and typed strings -for `mode`, roles, kinds and warnings. +for `mode`, roles, kinds and warnings. C has a read-only `trackparse_track` struct with the same +snake_case names as members: a pointer and a `_count` member for arrays (`versions`, +`versions_count`), pointers that are `NULL` where the table says `null`, C enums for `mode`, +roles, kinds and warnings, and `trackparse_str` for strings (a `ptr` and a `len`; `ptr` is also +NUL-terminated, so `printf("%s")` works on text without U+0000). The track owns everything it +points to, so nothing in it outlives `trackparse_track_free`. | Field | Type | Description | |---|---|---| @@ -213,6 +263,18 @@ pub struct Artist { pub name: String, pub role: ArtistRole, pub joiner: Option + + +```c +typedef struct trackparse_artist { + trackparse_str name; + trackparse_role role; + const trackparse_str *joiner; /* NULL for the first name */ + trackparse_source source; +} trackparse_artist; +``` + @@ -226,7 +288,8 @@ type Artist struct { Name string; Role Role; Joiner *string; Source Source } `source` are [`ArtistRole`](https://docs.rs/trackparse/latest/trackparse/enum.ArtistRole.html)`::Primary`, [`ArtistSource`](https://docs.rs/trackparse/latest/trackparse/enum.ArtistSource.html)`::Artist` and so on; in Go they are [`trackparse.RolePrimary`](https://pkg.go.dev/github.com/4matic/trackparse/go#RolePrimary), [`trackparse.SourceArtist`](https://pkg.go.dev/github.com/4matic/trackparse/go#SourceArtist) and so -on. The splitting rules are [R7](/trackparse/reference/spec/#r7-artist-side). +on; in C they are `TRACKPARSE_ROLE_PRIMARY`, `TRACKPARSE_SOURCE_ARTIST` and so on, and +`trackparse_role_name()` and `trackparse_source_name()` give the spec's strings. The splitting rules are [R7](/trackparse/reference/spec/#r7-artist-side). [Artists and credits](/trackparse/guides/artists/) has examples. ## Version @@ -295,6 +358,25 @@ type Version struct { } ``` + + + +```c +typedef struct trackparse_version { + trackparse_version_type type; + trackparse_str type_name; + trackparse_str raw; + const trackparse_artist *artists; + size_t artists_count; + const trackparse_str *modifiers; + size_t modifiers_count; + const trackparse_str *descriptor; + const int *year; + bool unknown_artist; + trackparse_delimiter delimiter; +} trackparse_version; +``` + @@ -313,7 +395,10 @@ Python uses `unknown_artist`. Rust uses `unknown_artist` and `version_type`, bec reserved word, and `delimiter` is [`VersionDelimiter`](https://docs.rs/trackparse/latest/trackparse/enum.VersionDelimiter.html)`::Paren`, `Square`, `Curly` or `Dash`. Go uses `Type` (a [`VersionType`](https://pkg.go.dev/github.com/4matic/trackparse/go#VersionType)), `UnknownArtist` and the [`Delimiter`](https://pkg.go.dev/github.com/4matic/trackparse/go#Delimiter) constants `DelimiterParen`, `DelimiterSquare`, -`DelimiterCurly` and `DelimiterDash`. The version rules are +`DelimiterCurly` and `DelimiterDash`. C uses `type` (a `trackparse_version_type`) and `type_name` +(the spec's string, which differs from `trackparse_version_type_name(type)` only for a type that +[`keywords`](/trackparse/reference/options/#keywords) introduced), `unknown_artist`, and the +delimiters `TRACKPARSE_DELIMITER_PAREN`, `_BRACKET`, `_BRACE` and `_DASH`. The version rules are [R5.7](/trackparse/reference/spec/#r5-group-classification:~:text=R5.7%20Version). [Versions and remixes](/trackparse/guides/versions/) explains how the type is chosen. @@ -323,15 +408,16 @@ and the [`Delimiter`](https://pkg.go.dev/github.com/4matic/trackparse/go#Delimit in [Junk, flags and prefixes](/trackparse/guides/junk-and-flags/#junk). The vocabulary is in [`spec/data`](https://github.com/4matic/trackparse/tree/main/spec/data). In Rust the kind is the enum [`JunkKind`](https://docs.rs/trackparse/latest/trackparse/enum.JunkKind.html) (`JunkKind::Video` and so on), in Go the typed string -[`JunkKind`](https://pkg.go.dev/github.com/4matic/trackparse/go#JunkKind) (`trackparse.JunkKindVideo` and so on). +[`JunkKind`](https://pkg.go.dev/github.com/4matic/trackparse/go#JunkKind) (`trackparse.JunkKindVideo` and so on), in C the enum +`trackparse_junk_kind` (`TRACKPARSE_JUNK_VIDEO` and so on) plus the string `kind_name`. ## Serializing to JSON -All four packages write the same JSON, byte for byte, on every fixture input. The keys are the -camelCase ones of the spec (`fullTitle`, [`unknownArtist`](/trackparse/guides/artists/#unknown-artists)), also in Python, Rust and Go. +All five packages write the same JSON, byte for byte, on every fixture input. The keys are the +camelCase ones of the spec (`fullTitle`, [`unknownArtist`](/trackparse/guides/artists/#unknown-artists)), also in Python, Rust, Go and C. @@ -423,11 +509,32 @@ that writes the spec's JSON, the same bytes as `JSON.stringify` in JavaScript, s that JSON back. Nullable fields are pointers (`*Position`, `*int`), and `json.Marshal` writes them as `null` when they are `nil`. + + + +```c +#include + +trackparse_track *track = trackparse_parse("Noisia - Stigma (2015)", TRACKPARSE_NUL_TERMINATED); + +trackparse_string *json = trackparse_track_to_json(track); +printf("%s\n", json->str.ptr); +// {"input":"Noisia - Stigma (2015)","mode":"clean","position":null,"timestamp":null,"artists":[{"name":"Noisia","role":"primary","joiner":null,"source":"artist"}],"title":"Stigma","fullTitle":"Stigma","versions":[],"year":2015,"flags":{"explicit":false,"clean":false,"unknownArtist":false,"unknownTitle":false},"junk":[],"warnings":[]} +trackparse_string_free(json); +trackparse_track_free(track); +``` + +`trackparse_track_to_json` returns a `trackparse_string` with the exact bytes `JSON.stringify` +writes in JavaScript. You own it: free it with `trackparse_string_free`. There is one function +per result type: `trackparse_artists_to_json`, `trackparse_tracklist_to_json` and +`trackparse_edit_result_to_json`. The installed library writes JSON but does not read it, so +there is no `from_json`; read the JSON with the JSON library you already use. + Tracklist results serialize the same way: `JSON.stringify(list)`, `tl.to_dict()`, -`list.to_json()` and `json.Marshal(list)`. See the [Tracklist API](/trackparse/reference/tracklist/) +`list.to_json()`, `json.Marshal(list)` and `trackparse_tracklist_to_json(list)`. See the [Tracklist API](/trackparse/reference/tracklist/) and the [JSON section](/trackparse/guides/tracklists/#json) of the tracklist guide. ## Types @@ -506,6 +613,38 @@ A later spec version can add a version type or a warning, so a `switch` on these `default` case. The full API is on [pkg.go.dev](https://pkg.go.dev/github.com/4matic/trackparse/go). + + + +All of these are declared in `trackparse.h`: + +- read-only result structs: `trackparse_track`, `trackparse_artist`, `trackparse_artists` (the + list `trackparse_parse_artists` returns), `trackparse_version`, `trackparse_junk`, + `trackparse_flags`, `trackparse_position`, `trackparse_timestamp`, `trackparse_str`, and + `trackparse_string` (an owned string from `trackparse_format`, `trackparse_normalize` or a + `_to_json` function); +- enums: `trackparse_role`, `trackparse_source`, `trackparse_version_type`, + `trackparse_delimiter`, `trackparse_junk_kind`, `trackparse_warning`, `trackparse_mode`. Each + has a `_name()` function that returns the spec's name, and `trackparse_mode`, + `trackparse_version_type` and `trackparse_junk_kind` also have `_from_name()`; +- opaque option handles: [`trackparse_parse_options`](/trackparse/reference/options/#parse-options) (which also holds the [keywords](/trackparse/reference/options/#keywords)) and + [`trackparse_format_options`](/trackparse/guides/formatting/#options), with the enums + [`trackparse_split_and`](/trackparse/guides/artists/#and-is-special), `trackparse_feat`, + `trackparse_joiners` and `trackparse_versions`; +- `trackparse_parser`, the handle [`trackparse_parser_new`](/trackparse/reference/functions/#createparseroptions) returns. + +```c +printf("%s\n", trackparse_version_type_name(TRACKPARSE_VERSION_SPED_UP)); // spedUp +trackparse_version_type vt; +if (trackparse_version_type_from_name("remix", TRACKPARSE_NUL_TERMINATED, &vt)) { + printf("%d\n", vt == TRACKPARSE_VERSION_REMIX); // 1 +} +printf("%d\n", TRACKPARSE_VERSION_TYPE_COUNT); // 27 +``` + +The values of each enum are in the spec's order, so the last one plus one is the count. A later +spec version can add a version type or a warning, so a `switch` on these needs a `default` case. + diff --git a/site/src/content/docs/reference/tracklist.mdx b/site/src/content/docs/reference/tracklist.mdx index bdb3c4a..73e641b 100644 --- a/site/src/content/docs/reference/tracklist.mdx +++ b/site/src/content/docs/reference/tracklist.mdx @@ -39,6 +39,20 @@ func ApplyEdits(text string, edits []Edit) EditResult func ApplyEditsWith(text string, edits []Edit, options TracklistOptions) EditResult ``` + + + +```c +#include + +trackparse_tracklist *trackparse_parse_tracklist(const char *s, size_t len); +trackparse_tracklist *trackparse_parse_tracklist_with(const char *s, size_t len, + const trackparse_tracklist_options *o); +void trackparse_tracklist_free(trackparse_tracklist *t); +trackparse_edit_result *trackparse_apply_edits(const char *s, size_t len, const trackparse_edits *e); +void trackparse_edit_result_free(trackparse_edit_result *r); +``` + @@ -56,6 +70,12 @@ Neither function fails on string input. What to know for each language: are structs with exported fields (`SpecVersion`, `FirstTime`) whose `MarshalJSON` writes the spec's JSON. Edits are `Edit` structs made with a constructor per edit (listed under [Types](#types)). Options go through the `With` functions, and nothing panics. +- **C** ([`trackparse.h`](https://github.com/4matic/trackparse/blob/main/c/include/trackparse.h)). The functions are in the same header as + `trackparse_parse`. Text is UTF-8 with a byte length (or `TRACKPARSE_NUL_TERMINATED`), and + results are read-only structs that you free with `trackparse_tracklist_free` and + `trackparse_edit_result_free`. Edits go in a `trackparse_edits` handle, filled by one function + per edit (listed under [Types](#types)). `trackparse_apply_edits` takes no options, since edits + don't depend on them. Every function returns `NULL` only when memory runs out. The guides [Tracklists](/trackparse/guides/tracklists/) and [Editing tracklists](/trackparse/guides/editing-tracklists/) walk through examples. The rules are @@ -65,9 +85,10 @@ The guides [Tracklists](/trackparse/guides/tracklists/) and *(Python: `parse_tracklist`. Rust: [`parse_tracklist(text)`](https://docs.rs/trackparse/latest/trackparse/tracklist/fn.parse_tracklist.html) and [`parse_tracklist_with(text, &options)`](https://docs.rs/trackparse/latest/trackparse/tracklist/fn.parse_tracklist_with.html). -Go: [`ParseTracklist(text)`](https://pkg.go.dev/github.com/4matic/trackparse/go#ParseTracklist) and [`ParseTracklistWith(text, options)`](https://pkg.go.dev/github.com/4matic/trackparse/go#ParseTracklistWith))* +Go: [`ParseTracklist(text)`](https://pkg.go.dev/github.com/4matic/trackparse/go#ParseTracklist) and [`ParseTracklistWith(text, options)`](https://pkg.go.dev/github.com/4matic/trackparse/go#ParseTracklistWith). +C: `trackparse_parse_tracklist(s, len)` and `trackparse_parse_tracklist_with(s, len, options)`)* -Returns a `Tracklist` ([`Tracklist`](https://docs.rs/trackparse/latest/trackparse/tracklist/struct.Tracklist.html) in Rust, [`Tracklist`](https://pkg.go.dev/github.com/4matic/trackparse/go#Tracklist) in Go). Every key is +Returns a `Tracklist` ([`Tracklist`](https://docs.rs/trackparse/latest/trackparse/tracklist/struct.Tracklist.html) in Rust, [`Tracklist`](https://pkg.go.dev/github.com/4matic/trackparse/go#Tracklist) in Go, a `trackparse_tracklist *` in C). Every key is always present ([R13.8](/trackparse/reference/spec/#r138-output)). The [playground](/trackparse/playground/#list=00%3A00%20Noisia%20-%20Stigma%0A04%3A10%20Mefjus%20-%20Sleepless%20%28Phace%20Remix%29%0Aw%2F%20Phace%20-%20Psycho%20%28Acapella%29%0A09%3A30%20Outro) shows every entry of a list as a table, with its JSON. @@ -119,6 +140,20 @@ type Tracklist struct { } ``` + + + +```c +typedef struct trackparse_tracklist { + trackparse_str spec_version; + const trackparse_entry *entries; + size_t entries_count; + const trackparse_tracklist_warning *warnings; + size_t warnings_count; + trackparse_stats stats; /* lines, tracks, markers, timed, first_time, last_time */ +} trackparse_tracklist; +``` + @@ -131,7 +166,10 @@ an `Option` (a [`TimeValue`](https://docs.rs/trackparse/latest/trackp `Option`. Go calls the type [`Entry`](https://pkg.go.dev/github.com/4matic/trackparse/go#Entry): `Kind` and `Eol` are string types ([`EntryKind`](https://pkg.go.dev/github.com/4matic/trackparse/go#EntryKind), [`Eol`](https://pkg.go.dev/github.com/4matic/trackparse/go#Eol)) whose values are the strings below, `Time` is a [`*TracklistTime`](https://pkg.go.dev/github.com/4matic/trackparse/go#TracklistTime) whose `Seconds` is a `float64`, and `Track` is a `*Track`, -`nil` where the table says `null`. +`nil` where the table says `null`. C calls it `trackparse_entry`: `line` is an `int`, `kind` and +`eol` are the enums `trackparse_entry_kind` and `trackparse_eol` (their `_name()` functions give +the strings below), `time` is a `const trackparse_tracklist_time *` whose `seconds` is a +`double`, and `track` is a `const trackparse_track *`, `NULL` where the table says `null`. | Field | Type | Description | |---|---|---| @@ -185,13 +223,26 @@ type TracklistWarning struct { } ``` + + + +```c +typedef struct trackparse_tracklist_warning { + trackparse_tracklist_warning_code code; + int line; + trackparse_severity severity; /* TRACKPARSE_SEVERITY_INFO | _WARNING */ + const trackparse_suggestion *suggestion; /* { int line; trackparse_str raw; double seconds; } */ +} trackparse_tracklist_warning; +``` + Sorted by line ([R13.7](/trackparse/reference/spec/#r137-warnings)). The codes are listed under [Warnings](/trackparse/reference/warnings/#tracklist-warnings), and [Suggestions](/trackparse/reference/warnings/#suggestions) explains `suggestion`. In Rust the type is [`TracklistWarning`](https://docs.rs/trackparse/latest/trackparse/tracklist/struct.TracklistWarning.html) with a [`WarningCode`](https://docs.rs/trackparse/latest/trackparse/tracklist/enum.WarningCode.html), in Go -[`TracklistWarning`](https://pkg.go.dev/github.com/4matic/trackparse/go#TracklistWarning) with a [`WarningCode`](https://pkg.go.dev/github.com/4matic/trackparse/go#WarningCode). +[`TracklistWarning`](https://pkg.go.dev/github.com/4matic/trackparse/go#TracklistWarning) with a [`WarningCode`](https://pkg.go.dev/github.com/4matic/trackparse/go#WarningCode), in C `trackparse_tracklist_warning` +with a `trackparse_tracklist_warning_code` (`TRACKPARSE_TL_TIME_OUT_OF_ORDER` and so on). Warnings from each line's own [`ParsedTrack`](/trackparse/reference/parse/#parsedtrack) stay on `entries[i].track.warnings` and aren't repeated here. @@ -206,15 +257,18 @@ here. Python and Rust call the last two `first_time` and `last_time`. In Rust the counts are `usize` and the two times are `Option` ([`Stats`](https://docs.rs/trackparse/latest/trackparse/tracklist/struct.Stats.html)). In Go ([`Stats`](https://pkg.go.dev/github.com/4matic/trackparse/go#Stats)) the fields are -`FirstTime` and `LastTime`, of type `*float64`. +`FirstTime` and `LastTime`, of type `*float64`. In C (`trackparse_stats`) the counts are `int` and +`first_time` and `last_time` are `const double *`, `NULL` when there is no time. ## applyEdits(text, edits, options?) *(Python: `apply_edits`. Rust: [`apply_edits(text, &edits)`](https://docs.rs/trackparse/latest/trackparse/tracklist/fn.apply_edits.html) and [`apply_edits_with(text, &edits, &options)`](https://docs.rs/trackparse/latest/trackparse/tracklist/fn.apply_edits_with.html). -Go: [`ApplyEdits(text, edits)`](https://pkg.go.dev/github.com/4matic/trackparse/go#ApplyEdits) and [`ApplyEditsWith(text, edits, options)`](https://pkg.go.dev/github.com/4matic/trackparse/go#ApplyEditsWith))* +Go: [`ApplyEdits(text, edits)`](https://pkg.go.dev/github.com/4matic/trackparse/go#ApplyEdits) and [`ApplyEditsWith(text, edits, options)`](https://pkg.go.dev/github.com/4matic/trackparse/go#ApplyEditsWith). +C: `trackparse_apply_edits(s, len, edits)`)* -Returns `{ text, changed, warnings }` (Python, Rust and Go: an `EditResult`). +Returns `{ text, changed, warnings }` (Python, Rust and Go: an `EditResult`; C: a +`trackparse_edit_result *`). | Field | | |---|---| @@ -225,21 +279,23 @@ Returns `{ text, changed, warnings }` (Python, Rust and Go: an `EditResult`). In Rust ([`EditResult`](https://docs.rs/trackparse/latest/trackparse/tracklist/struct.EditResult.html)), `changed` is a `Vec` and each warning is an `EditWarning { code: EditWarningCode, edit: usize, line: Option }` ([`EditWarning`](https://docs.rs/trackparse/latest/trackparse/tracklist/struct.EditWarning.html)). In Go ([`EditResult`](https://pkg.go.dev/github.com/4matic/trackparse/go#EditResult)), `Changed` is an `[]int` and each warning -is an `EditWarning{Code EditWarningCode, Edit int, Line *int}` ([`EditWarning`](https://pkg.go.dev/github.com/4matic/trackparse/go#EditWarning)). The edit rules +is an `EditWarning{Code EditWarningCode, Edit int, Line *int}` ([`EditWarning`](https://pkg.go.dev/github.com/4matic/trackparse/go#EditWarning)). In C, `changed` is a +`const long long *` with `changed_count`, and each warning is a `trackparse_edit_warning` with a +`code`, a `size_t edit` and a `const long long *line`. The edit rules are [R13.9](/trackparse/reference/spec/#r139-edits). ### Edits -| JavaScript and Python | Rust | Go | Effect | -|---|---|---|---| -| `{ op: "set-time", line, seconds }` | `Edit::set_time(line, seconds)` | `SetTime(line, seconds)` | Rewrite the time on that line | -| `{ op: "shift", seconds }` | `Edit::shift(seconds)` | `Shift(seconds)` | Add `seconds` to every timed line | -| `{ op: "shift", seconds, from }` | `Edit::shift_from(seconds, from)` | `ShiftFrom(seconds, from)` | Add `seconds` to every timed line from `from` on | -| `{ op: "shift", seconds, lines }` | `Edit::shift_lines(seconds, lines)` | `ShiftLines(seconds, lines...)` | Add `seconds` to the listed lines | -| `{ op: "sort-by-time" }` | `Edit::sort_by_time()` | `SortByTime()` | Stable sort by time. Untimed lines move with the timed line above them | -| `{ op: "set-rest", line, rest }` | `Edit::set_rest(line, rest)` | `SetRest(line, rest)` | Replace everything after the time | -| `{ op: "insert", after, text }` | `Edit::insert(after, text)` | `Insert(after, text)` | Insert a line after `after` (`0` = at the top) | -| `{ op: "delete", line }` | `Edit::delete(line)` | `Delete(line)` | Remove a line | +| JavaScript and Python | Rust | Go | C | Effect | +|---|---|---|---|---| +| `{ op: "set-time", line, seconds }` | `Edit::set_time(line, seconds)` | `SetTime(line, seconds)` | `trackparse_edits_set_time(e, line, seconds)` | Rewrite the time on that line | +| `{ op: "shift", seconds }` | `Edit::shift(seconds)` | `Shift(seconds)` | `trackparse_edits_shift(e, seconds)` | Add `seconds` to every timed line | +| `{ op: "shift", seconds, from }` | `Edit::shift_from(seconds, from)` | `ShiftFrom(seconds, from)` | `trackparse_edits_shift_from(e, seconds, from)` | Add `seconds` to every timed line from `from` on | +| `{ op: "shift", seconds, lines }` | `Edit::shift_lines(seconds, lines)` | `ShiftLines(seconds, lines...)` | `trackparse_edits_shift_lines(e, seconds, lines, count)` | Add `seconds` to the listed lines | +| `{ op: "sort-by-time" }` | `Edit::sort_by_time()` | `SortByTime()` | `trackparse_edits_sort_by_time(e)` | Stable sort by time. Untimed lines move with the timed line above them | +| `{ op: "set-rest", line, rest }` | `Edit::set_rest(line, rest)` | `SetRest(line, rest)` | `trackparse_edits_set_rest(e, line, rest, len)` | Replace everything after the time | +| `{ op: "insert", after, text }` | `Edit::insert(after, text)` | `Insert(after, text)` | `trackparse_edits_insert(e, after, text, len)` | Insert a line after `after` (`0` = at the top) | +| `{ op: "delete", line }` | `Edit::delete(line)` | `Delete(line)` | `trackparse_edits_delete(e, line)` | Remove a line | In Python an edit is a dict with quoted keys: `{"op": "shift", "seconds": 45, "from": 5}`. With the `serde` feature, the Rust `Edit` reads and writes that same JSON. The Go `Edit` writes it with @@ -259,20 +315,21 @@ style ([R13.9.2](/trackparse/reference/spec/#r139-edits:~:text=R13.9.2%20Time%20 In Rust the codes are [`EditWarningCode`](https://docs.rs/trackparse/latest/trackparse/tracklist/enum.EditWarningCode.html)`::StyleUpgraded`, `TimeClamped` and `EditInvalid`. In Go they are [`EditWarningCodeStyleUpgraded`](https://pkg.go.dev/github.com/4matic/trackparse/go#EditWarningCodeStyleUpgraded), `EditWarningCodeTimeClamped` and -`EditWarningCodeEditInvalid`. +`EditWarningCodeEditInvalid`. In C they are `TRACKPARSE_EDIT_WARNING_STYLE_UPGRADED`, +`TRACKPARSE_EDIT_WARNING_TIME_CLAMPED` and `TRACKPARSE_EDIT_WARNING_EDIT_INVALID`. [Warnings](/trackparse/reference/warnings/#edit-warnings) shows how to check them. ## Options Both functions take the same options ([R13.10](/trackparse/reference/spec/#r1310-options)). `applyEdits` accepts them for symmetry; edits don't depend on -them. +them, and the C `trackparse_apply_edits` has no options argument. -| JavaScript | Python and Rust | Go | Default | Description | -|---|---|---|---|---| -| `mode` | `mode` | `Mode` | `"tracklist"` | Mode for each line's [`parse()`](/trackparse/reference/parse/). See [Tracklist mode](/trackparse/guides/tracklists/#tracklist-mode) | -| [`knownArtists`](/trackparse/guides/artists/#knownartists), [`splitAnd`](/trackparse/guides/artists/#and-is-special), [`keywords`](/trackparse/reference/options/#keywords) | `known_artists`, `split_and`, `keywords` | `KnownArtists`, `SplitAnd`, `Keywords` | as for `parse` | As for [`parse()`](/trackparse/reference/options/) | -| [`audioSeconds`](/trackparse/guides/tracklists/#options) | `audio_seconds` | `AudioSeconds` | none | Length of the audio. Enables [`time-after-audio-end`](/trackparse/reference/warnings/#tracklist-warnings:~:text=time%2Dafter%2Daudio%2Dend) | -| [`markerWords`](/trackparse/guides/tracklists/#options) | `marker_words` | `MarkerWords` | empty | Extra marker words | +| JavaScript | Python and Rust | Go | C | Default | Description | +|---|---|---|---|---|---| +| `mode` | `mode` | `Mode` | `trackparse_tracklist_options_set_mode` | `"tracklist"` | Mode for each line's [`parse()`](/trackparse/reference/parse/). See [Tracklist mode](/trackparse/guides/tracklists/#tracklist-mode) | +| [`knownArtists`](/trackparse/guides/artists/#knownartists), [`splitAnd`](/trackparse/guides/artists/#and-is-special), [`keywords`](/trackparse/reference/options/#keywords) | `known_artists`, `split_and`, `keywords` | `KnownArtists`, `SplitAnd`, `Keywords` | `_add_known_artist`, `_set_split_and`, `_add_version_head` and the other `add_` setters | as for `parse` | As for [`parse()`](/trackparse/reference/options/) | +| [`audioSeconds`](/trackparse/guides/tracklists/#options) | `audio_seconds` | `AudioSeconds` | `trackparse_tracklist_options_set_audio_seconds` | none | Length of the audio. Enables [`time-after-audio-end`](/trackparse/reference/warnings/#tracklist-warnings:~:text=time%2Dafter%2Daudio%2Dend) | +| [`markerWords`](/trackparse/guides/tracklists/#options) | `marker_words` | `MarkerWords` | `trackparse_tracklist_options_add_marker_word` | empty | Extra marker words | Python uses keyword arguments. Rust has a setter of the same name for each on [`TracklistOptions`](https://docs.rs/trackparse/latest/trackparse/tracklist/struct.TracklistOptions.html), for example `TracklistOptions::new().audio_seconds(3600.0).marker_words(["drop"])`, and passes it @@ -280,7 +337,10 @@ to `parse_tracklist_with` or `apply_edits_with`. Go takes a [`TracklistOptions`] `trackparse.TracklistOptions{AudioSeconds: trackparse.Ptr(3600.0), MarkerWords: []string{"drop"}}`, in `ParseTracklistWith` or `ApplyEditsWith`. Its zero value is the defaults: an empty `Mode` means `ModeTracklist` (`ModeAuto` asks for auto), and a `nil` `AudioSeconds` means no length, while -`trackparse.Ptr(0.0)` is an audio of length 0. +`trackparse.Ptr(0.0)` is an audio of length 0. C takes a `trackparse_tracklist_options` handle +from `trackparse_tracklist_options_new()` in `trackparse_parse_tracklist_with`; an option never set +keeps its default, so an audio length never set is none and +`trackparse_tracklist_options_set_audio_seconds(o, 0)` is an audio of length 0. [Tracklists](/trackparse/guides/tracklists/#options) has a full example. ## Types @@ -351,6 +411,36 @@ Build one with a constructor: [`trackparse.SetTime(line, seconds)`](https://pkg. [`trackparse.SortByTime()`](https://pkg.go.dev/github.com/4matic/trackparse/go#SortByTime), [`trackparse.SetRest(line, rest)`](https://pkg.go.dev/github.com/4matic/trackparse/go#SetRest), [`trackparse.Insert(after, text)`](https://pkg.go.dev/github.com/4matic/trackparse/go#Insert) and [`trackparse.Delete(line)`](https://pkg.go.dev/github.com/4matic/trackparse/go#Delete). `json.Marshal` writes an edit in the spec's JSON form. + + + +Everything is in `trackparse.h`: the read-only structs `trackparse_tracklist`, +`trackparse_entry`, `trackparse_parts`, `trackparse_tracklist_time`, `trackparse_suggestion`, +`trackparse_stats`, `trackparse_tracklist_warning`, `trackparse_edit_result` and +`trackparse_edit_warning`; the enums `trackparse_entry_kind`, `trackparse_eol`, +`trackparse_severity`, `trackparse_tracklist_warning_code`, `trackparse_edit_op` and +`trackparse_edit_warning_code`, each with a `_name()` function (`trackparse_eol_name` gives +`"\r\n"` and so on); and two opaque handles, `trackparse_tracklist_options` and +`trackparse_edits`. An edit list is a handle filled by one function per edit, in the order the +edits run: + +```c +trackparse_edits *trackparse_edits_new(void); +void trackparse_edits_free(trackparse_edits *e); +bool trackparse_edits_set_time(trackparse_edits *e, long long line, double seconds); +bool trackparse_edits_shift(trackparse_edits *e, double seconds); +bool trackparse_edits_shift_from(trackparse_edits *e, double seconds, long long from); +bool trackparse_edits_shift_lines(trackparse_edits *e, double seconds, const long long *lines, + size_t count); +bool trackparse_edits_sort_by_time(trackparse_edits *e); +bool trackparse_edits_set_rest(trackparse_edits *e, long long line, const char *rest, size_t len); +bool trackparse_edits_insert(trackparse_edits *e, long long after, const char *text, size_t len); +bool trackparse_edits_delete(trackparse_edits *e, long long line); +``` + +Each returns `false` only when memory runs out. The strings are copied, so they can be freed +after the call. `trackparse_edit_result_to_json` writes a result in the spec's JSON form. + diff --git a/site/src/content/docs/reference/warnings.mdx b/site/src/content/docs/reference/warnings.mdx index 0b7c88e..92efee3 100644 --- a/site/src/content/docs/reference/warnings.mdx +++ b/site/src/content/docs/reference/warnings.mdx @@ -10,26 +10,28 @@ three kinds: on a single track, on a tracklist, and on an edit. In JavaScript and Python a warning code is a string. In Rust it is an enum variant, and `as_str()` or `Display` gives the same string. In Go it is a constant of a string type, whose value is the -string. The tables below give the string, the Rust variant and the Go constant for each code, and +string. In C it is an enum value, and its `_name()` function gives the string. The tables below +give the string, the Rust variant, the Go constant and the C enum value for each code, and the rule of the [spec](/trackparse/reference/spec/) that raises it. ## Track warnings `ParsedTrack.warnings` is a list of codes: an array of strings in JavaScript, a tuple of strings in Python, a `Vec` in Rust ([`Warning`](https://docs.rs/trackparse/latest/trackparse/enum.Warning.html)), a `[]Warning` in Go -([`Warning`](https://pkg.go.dev/github.com/4matic/trackparse/go#Warning)). An empty list means every decision was unambiguous. Click an example +([`Warning`](https://pkg.go.dev/github.com/4matic/trackparse/go#Warning)), a `const trackparse_warning *` with `warnings_count` in C +([`trackparse.h`](https://github.com/4matic/trackparse/blob/main/c/include/trackparse.h)). An empty list means every decision was unambiguous. Click an example to open it in the playground. -| Warning | Rust | Go | Means | Example | -|---|---|---|---|---| -| `noSeparator` | `Warning::NoSeparator` | `WarningNoSeparator` | No artist/title separator was found. The whole string is the title ([R6.8](/trackparse/reference/spec/#r6-artisttitle-separator:~:text=R6.8%20No%20separator)) | [`Around the World`](/trackparse/playground/#track=Around%20the%20World) | -| `ambiguousSeparator` | `Warning::AmbiguousSeparator` | `WarningAmbiguousSeparator` | A pipe-separated YouTube title had two parts and no dash, so they were read as artist and title ([R2.4](/trackparse/reference/spec/#r2-mode-prelude:~:text=R2.4%20youtube%20pipes)) | [`Noisia \| Stigma`](/trackparse/playground/#track=Noisia%20%7C%20Stigma&mode=youtube) | -| `unspacedDashSplit` | `Warning::UnspacedDashSplit` | `WarningUnspacedDashSplit` | Split at a dash without spaces around it (youtube and filename modes, and timed tracklist lines: [R6.7](/trackparse/reference/spec/#r6-artisttitle-separator:~:text=R6.7%20Unspaced%20dash), [R6.10](/trackparse/reference/spec/#r6-artisttitle-separator:~:text=R6.10%20Tracklist%20mode)) | [`Blink-182-All The Small Things`](/trackparse/playground/#track=Blink-182-All%20The%20Small%20Things&mode=youtube) | -| `asymmetricDashSplit` | `Warning::AsymmetricDashSplit` | `WarningAsymmetricDashSplit` | Split at a dash with a space on one side only ([R6.4](/trackparse/reference/spec/#r6-artisttitle-separator:~:text=R6.4%20Asymmetric%20dash)) | [`Artist -Title`](/trackparse/playground/#track=Artist%20-Title) | -| `bySplit` | `Warning::BySplit` | `WarningBySplit` | Read `"Title" by Artist` (youtube mode, [R6.6](/trackparse/reference/spec/#r6-artisttitle-separator:~:text=R6.6%20by%20%28youtube%20only%29)) | [`"Numb" by Linkin Park`](/trackparse/playground/#track=%22Numb%22%20by%20Linkin%20Park&mode=youtube) | -| `quotedTitleSplit` | `Warning::QuotedTitleSplit` | `WarningQuotedTitleSplit` | Took a quoted span as the title and what came before it as the artist (youtube mode, [R6.5](/trackparse/reference/spec/#r6-artisttitle-separator:~:text=R6.5%20Quoted%20title)) | [`Linkin Park: "Numb"`](/trackparse/playground/#track=Linkin%20Park%3A%20%22Numb%22&mode=youtube) | -| `ambiguousMixCredit` | `Warning::AmbiguousMixCredit` | `WarningAmbiguousMixCredit` | ` Mix` was read as a remix, but the name is long enough that it might be a style ([R5.7](/trackparse/reference/spec/#r5-group-classification:~:text=R5.7%20Version)) | [`(Fonetick Lee & Sonic Art Space Drums Mix)`](/trackparse/playground/#track=Artist%20-%20Title%20%28Fonetick%20Lee%20%26%20Sonic%20Art%20Space%20Drums%20Mix%29) | -| `unbalancedBrackets` | `Warning::UnbalancedBrackets` | `WarningUnbalancedBrackets` | A bracket was opened and never closed ([R3.3](/trackparse/reference/spec/#r3-group-scanner-and-skeleton:~:text=R3.3%20An%20opener)) | [`Noisia - Stigma (VIP`](/trackparse/playground/#track=Noisia%20-%20Stigma%20%28VIP) | +| Warning | Rust | Go | C | Means | Example | +|---|---|---|---|---|---| +| `noSeparator` | `Warning::NoSeparator` | `WarningNoSeparator` | `TRACKPARSE_WARNING_NO_SEPARATOR` | No artist/title separator was found. The whole string is the title ([R6.8](/trackparse/reference/spec/#r6-artisttitle-separator:~:text=R6.8%20No%20separator)) | [`Around the World`](/trackparse/playground/#track=Around%20the%20World) | +| `ambiguousSeparator` | `Warning::AmbiguousSeparator` | `WarningAmbiguousSeparator` | `TRACKPARSE_WARNING_AMBIGUOUS_SEPARATOR` | A pipe-separated YouTube title had two parts and no dash, so they were read as artist and title ([R2.4](/trackparse/reference/spec/#r2-mode-prelude:~:text=R2.4%20youtube%20pipes)) | [`Noisia \| Stigma`](/trackparse/playground/#track=Noisia%20%7C%20Stigma&mode=youtube) | +| `unspacedDashSplit` | `Warning::UnspacedDashSplit` | `WarningUnspacedDashSplit` | `TRACKPARSE_WARNING_UNSPACED_DASH_SPLIT` | Split at a dash without spaces around it (youtube and filename modes, and timed tracklist lines: [R6.7](/trackparse/reference/spec/#r6-artisttitle-separator:~:text=R6.7%20Unspaced%20dash), [R6.10](/trackparse/reference/spec/#r6-artisttitle-separator:~:text=R6.10%20Tracklist%20mode)) | [`Blink-182-All The Small Things`](/trackparse/playground/#track=Blink-182-All%20The%20Small%20Things&mode=youtube) | +| `asymmetricDashSplit` | `Warning::AsymmetricDashSplit` | `WarningAsymmetricDashSplit` | `TRACKPARSE_WARNING_ASYMMETRIC_DASH_SPLIT` | Split at a dash with a space on one side only ([R6.4](/trackparse/reference/spec/#r6-artisttitle-separator:~:text=R6.4%20Asymmetric%20dash)) | [`Artist -Title`](/trackparse/playground/#track=Artist%20-Title) | +| `bySplit` | `Warning::BySplit` | `WarningBySplit` | `TRACKPARSE_WARNING_BY_SPLIT` | Read `"Title" by Artist` (youtube mode, [R6.6](/trackparse/reference/spec/#r6-artisttitle-separator:~:text=R6.6%20by%20%28youtube%20only%29)) | [`"Numb" by Linkin Park`](/trackparse/playground/#track=%22Numb%22%20by%20Linkin%20Park&mode=youtube) | +| `quotedTitleSplit` | `Warning::QuotedTitleSplit` | `WarningQuotedTitleSplit` | `TRACKPARSE_WARNING_QUOTED_TITLE_SPLIT` | Took a quoted span as the title and what came before it as the artist (youtube mode, [R6.5](/trackparse/reference/spec/#r6-artisttitle-separator:~:text=R6.5%20Quoted%20title)) | [`Linkin Park: "Numb"`](/trackparse/playground/#track=Linkin%20Park%3A%20%22Numb%22&mode=youtube) | +| `ambiguousMixCredit` | `Warning::AmbiguousMixCredit` | `WarningAmbiguousMixCredit` | `TRACKPARSE_WARNING_AMBIGUOUS_MIX_CREDIT` | ` Mix` was read as a remix, but the name is long enough that it might be a style ([R5.7](/trackparse/reference/spec/#r5-group-classification:~:text=R5.7%20Version)) | [`(Fonetick Lee & Sonic Art Space Drums Mix)`](/trackparse/playground/#track=Artist%20-%20Title%20%28Fonetick%20Lee%20%26%20Sonic%20Art%20Space%20Drums%20Mix%29) | +| `unbalancedBrackets` | `Warning::UnbalancedBrackets` | `WarningUnbalancedBrackets` | `TRACKPARSE_WARNING_UNBALANCED_BRACKETS` | A bracket was opened and never closed ([R3.3](/trackparse/reference/spec/#r3-group-scanner-and-skeleton:~:text=R3.3%20An%20opener)) | [`Noisia - Stigma (VIP`](/trackparse/playground/#track=Noisia%20-%20Stigma%20%28VIP) | What to do with them depends on your data. For a music library, a track with any warning is a good candidate for a human to look at. For scrobbling, most of them are fine to accept. @@ -126,6 +128,41 @@ for _, warning := range track.Warnings { (`trackparse.WarningBySplit`). Keep a `default` case: a later spec version can add a warning. `trackparse.AllWarnings()` lists the codes. + + + +```c +#include + +trackparse_parse_options *o = trackparse_parse_options_new(); +trackparse_parse_options_set_mode(o, TRACKPARSE_MODE_YOUTUBE); +trackparse_track *track = + trackparse_parse_with("Blink-182-All The Small Things", TRACKPARSE_NUL_TERMINATED, o); +trackparse_parse_options_free(o); + +printf("%zu\n", track->warnings_count); // 1 +printf("%s\n", trackparse_warning_name(track->warnings[0])); // unspacedDashSplit + +for (size_t i = 0; i < track->warnings_count; i++) { + switch (track->warnings[i]) { + case TRACKPARSE_WARNING_NO_SEPARATOR: + printf("no artist\n"); + break; + case TRACKPARSE_WARNING_UNSPACED_DASH_SPLIT: + case TRACKPARSE_WARNING_ASYMMETRIC_DASH_SPLIT: + printf("check the dash\n"); + break; + default: + printf("%s\n", trackparse_warning_name(track->warnings[i])); /* the code, such as bySplit */ + } +} +// check the dash +trackparse_track_free(track); +``` + +`trackparse_warning` is an enum, and `trackparse_warning_name()` gives its code. Keep a `default` +case: a later spec version can add a warning. + @@ -136,20 +173,21 @@ for _, warning := range track.Warnings { In Rust the code is a [`WarningCode`](https://docs.rs/trackparse/latest/trackparse/tracklist/enum.WarningCode.html) and the severity is [`Severity`](https://docs.rs/trackparse/latest/trackparse/tracklist/enum.Severity.html)`::Info` or `Severity::Warning`. In Go they are a [`WarningCode`](https://pkg.go.dev/github.com/4matic/trackparse/go#WarningCode) and [`SeverityInfo`](https://pkg.go.dev/github.com/4matic/trackparse/go#SeverityInfo) or `SeverityWarning`, -and `Suggestion` is a pointer. All of them are +and `Suggestion` is a pointer. In C they are a `trackparse_tracklist_warning_code` and +`TRACKPARSE_SEVERITY_INFO` or `TRACKPARSE_SEVERITY_WARNING`, and `suggestion` is a pointer. All of them are [R13.7](/trackparse/reference/spec/#r137-warnings) in the spec. -| Code | Rust | Go | Severity | When | -|---|---|---|---|---| -| `time-missing` | `WarningCode::TimeMissing` | `WarningCodeTimeMissing` | warning | A track line has no time while other lines do (not raised on a `w/` line, which plays at the previous track's time) | -| `time-out-of-order` | `WarningCode::TimeOutOfOrder` | `WarningCodeTimeOutOfOrder` | warning | Earlier than the previous timed line. May carry a `suggestion` | -| `time-duplicate` | `WarningCode::TimeDuplicate` | `WarningCodeTimeDuplicate` | warning | Same time as the previous timed line | -| `no-start-at-zero` | `WarningCode::NoStartAtZero` | `WarningCodeNoStartAtZero` | info | The first time isn't `0:00` | -| `time-after-audio-end` | `WarningCode::TimeAfterAudioEnd` | `WarningCodeTimeAfterAudioEnd` | warning | Later than [`audioSeconds`](/trackparse/guides/tracklists/#options) (`audio_seconds`, `AudioSeconds`) | -| `invalid-time` | `WarningCode::InvalidTime` | `WarningCodeInvalidTime` | warning | Looks like a time but isn't one (`1:75`, `0:61:00`). The line keeps it in `rest` | -| `position-gap` | `WarningCode::PositionGap` | `WarningCodePositionGap` | warning | A track number isn't the previous one plus 1 | -| `position-duplicate` | `WarningCode::PositionDuplicate` | `WarningCodePositionDuplicate` | warning | Same track number as the previous one | -| `line-unparsed` | `WarningCode::LineUnparsed` | `WarningCodeLineUnparsed` | warning | A track line with no artist/title separator, or nothing after the time | +| Code | Rust | Go | C | Severity | When | +|---|---|---|---|---|---| +| `time-missing` | `WarningCode::TimeMissing` | `WarningCodeTimeMissing` | `TRACKPARSE_TL_TIME_MISSING` | warning | A track line has no time while other lines do (not raised on a `w/` line, which plays at the previous track's time) | +| `time-out-of-order` | `WarningCode::TimeOutOfOrder` | `WarningCodeTimeOutOfOrder` | `TRACKPARSE_TL_TIME_OUT_OF_ORDER` | warning | Earlier than the previous timed line. May carry a `suggestion` | +| `time-duplicate` | `WarningCode::TimeDuplicate` | `WarningCodeTimeDuplicate` | `TRACKPARSE_TL_TIME_DUPLICATE` | warning | Same time as the previous timed line | +| `no-start-at-zero` | `WarningCode::NoStartAtZero` | `WarningCodeNoStartAtZero` | `TRACKPARSE_TL_NO_START_AT_ZERO` | info | The first time isn't `0:00` | +| `time-after-audio-end` | `WarningCode::TimeAfterAudioEnd` | `WarningCodeTimeAfterAudioEnd` | `TRACKPARSE_TL_TIME_AFTER_AUDIO_END` | warning | Later than [`audioSeconds`](/trackparse/guides/tracklists/#options) (`audio_seconds`, `AudioSeconds`) | +| `invalid-time` | `WarningCode::InvalidTime` | `WarningCodeInvalidTime` | `TRACKPARSE_TL_INVALID_TIME` | warning | Looks like a time but isn't one (`1:75`, `0:61:00`). The line keeps it in `rest` | +| `position-gap` | `WarningCode::PositionGap` | `WarningCodePositionGap` | `TRACKPARSE_TL_POSITION_GAP` | warning | A track number isn't the previous one plus 1 | +| `position-duplicate` | `WarningCode::PositionDuplicate` | `WarningCodePositionDuplicate` | `TRACKPARSE_TL_POSITION_DUPLICATE` | warning | Same track number as the previous one | +| `line-unparsed` | `WarningCode::LineUnparsed` | `WarningCodeLineUnparsed` | `TRACKPARSE_TL_LINE_UNPARSED` | warning | A track line with no artist/title separator, or nothing after the time | Warnings of each line's own track stay on `entries[i].track.warnings`. They are the [track warnings](#track-warnings) above and are not repeated in the list's `warnings`. @@ -244,6 +282,35 @@ fmt.Println(slices.ContainsFunc(list.Warnings, func(w trackparse.TracklistWarnin `WarningCode` is a string type too; keep a `default` case when you `switch` on it. + + + +```c +const char *text = + "00:00 Noisia - Stigma\n04:10 Mefjus - Sleepless\n03:55 Phace - Psycho\n09:30 Imanu"; +trackparse_tracklist *list = trackparse_parse_tracklist(text, TRACKPARSE_NUL_TERMINATED); + +for (size_t i = 0; i < list->warnings_count; i++) { + const trackparse_tracklist_warning *w = &list->warnings[i]; + printf("%s %d %s %d\n", trackparse_tracklist_warning_code_name(w->code), w->line, + trackparse_severity_name(w->severity), w->suggestion == NULL); +} +// time-out-of-order 3 warning 1 +// line-unparsed 4 warning 1 + +for (size_t i = 0; i < list->warnings_count; i++) { + const trackparse_tracklist_warning *w = &list->warnings[i]; + if (w->severity == TRACKPARSE_SEVERITY_WARNING) { + printf("line %d: %s\n", w->line, trackparse_tracklist_warning_code_name(w->code)); + } +} +// line 3: time-out-of-order +// line 4: line-unparsed +trackparse_tracklist_free(list); +``` + +`trackparse_tracklist_warning_code` is an enum too; keep a `default` case when you `switch` on it. + @@ -259,7 +326,7 @@ written, that puts the list back in order. It's written in the same style as the The search runs in two steps. First it tries the flagged line itself. If no time fits there, it tries the previous timed line, since sometimes that's where the typo is: `01:22:21` followed by `01:03:55` suggests changing the first line to `01:02:21`. If more than one -candidate fits, or none does, `suggestion` is `null` (`None` in Python and Rust, `nil` in Go). A wrong +candidate fits, or none does, `suggestion` is `null` (`None` in Python and Rust, `nil` in Go, `NULL` in C). A wrong suggestion would be worse than none. To apply one, pass its `line` and `seconds` to a `set-time` edit. See @@ -269,17 +336,17 @@ a warning with a suggestion has a button that applies it. ## Edit warnings -[`applyEdits`](/trackparse/reference/tracklist/#applyeditstext-edits-options) (`apply_edits` in Python and Rust, `ApplyEdits` in Go) returns `{ code, edit, line }` +[`applyEdits`](/trackparse/reference/tracklist/#applyeditstext-edits-options) (`apply_edits` in Python and Rust, `ApplyEdits` in Go, `trackparse_apply_edits` in C) returns `{ code, edit, line }` objects ([`EditWarning`](https://docs.rs/trackparse/latest/trackparse/tracklist/struct.EditWarning.html) in Rust, -[`EditWarning`](https://pkg.go.dev/github.com/4matic/trackparse/go#EditWarning) in Go). `edit` is the index in your list of edits, and `line` is -`null` (`None`, `nil` in Go) when the edit names no line. The rules are +[`EditWarning`](https://pkg.go.dev/github.com/4matic/trackparse/go#EditWarning) in Go, `trackparse_edit_warning` in C). `edit` is the index in your list of edits, and `line` is +`null` (`None`, `nil` in Go, `NULL` in C) when the edit names no line. The rules are [R13.9](/trackparse/reference/spec/#r139-edits). -| Code | Rust | Go | When | -|---|---|---|---| -| `style-upgraded` | `EditWarningCode::StyleUpgraded` | `EditWarningCodeStyleUpgraded` | a time without hours passed one hour and gained them ([R13.9.2](/trackparse/reference/spec/#r139-edits:~:text=R13.9.2%20Time%20style)) | -| `time-clamped` | `EditWarningCode::TimeClamped` | `EditWarningCodeTimeClamped` | a time would go below zero and was set to zero ([R13.9.3](/trackparse/reference/spec/#r139-edits:~:text=R13.9.3%20Clamp)) | -| `edit-invalid` | `EditWarningCode::EditInvalid` | `EditWarningCodeEditInvalid` | the edit could not apply and changed nothing ([R13.9.6](/trackparse/reference/spec/#r139-edits:~:text=R13.9.6%20Totality)) | +| Code | Rust | Go | C | When | +|---|---|---|---|---| +| `style-upgraded` | `EditWarningCode::StyleUpgraded` | `EditWarningCodeStyleUpgraded` | `TRACKPARSE_EDIT_WARNING_STYLE_UPGRADED` | a time without hours passed one hour and gained them ([R13.9.2](/trackparse/reference/spec/#r139-edits:~:text=R13.9.2%20Time%20style)) | +| `time-clamped` | `EditWarningCode::TimeClamped` | `EditWarningCodeTimeClamped` | `TRACKPARSE_EDIT_WARNING_TIME_CLAMPED` | a time would go below zero and was set to zero ([R13.9.3](/trackparse/reference/spec/#r139-edits:~:text=R13.9.3%20Clamp)) | +| `edit-invalid` | `EditWarningCode::EditInvalid` | `EditWarningCodeEditInvalid` | `TRACKPARSE_EDIT_WARNING_EDIT_INVALID` | the edit could not apply and changed nothing ([R13.9.6](/trackparse/reference/spec/#r139-edits:~:text=R13.9.6%20Totality)) | @@ -358,6 +425,33 @@ fmt.Println(slices.ContainsFunc(result.Warnings, func(w trackparse.EditWarning) `Line` is an `*int`, `nil` when the edit names no line, so check it before you read it. + + + +```c +trackparse_edits *edits = trackparse_edits_new(); +trackparse_edits_set_time(edits, 9, 60); /* there is no line 9 */ +long long lines[] = {2}; +trackparse_edits_shift_lines(edits, -300, lines, 1); /* 04:10 minus five minutes */ +trackparse_edit_result *result = trackparse_apply_edits(text, TRACKPARSE_NUL_TERMINATED, edits); +trackparse_edits_free(edits); + +for (size_t i = 0; i < result->warnings_count; i++) { + const trackparse_edit_warning *w = &result->warnings[i]; + printf("%s %zu %lld\n", trackparse_edit_warning_code_name(w->code), w->edit, *w->line); +} +// edit-invalid 0 9 +// time-clamped 1 2 +printf("%zu %lld\n", result->changed_count, result->changed[0]); // 1 2 + +const char *second = strchr(result->text.ptr, '\n') + 1; +printf("%.*s\n", (int)(strchr(second, '\n') - second), second); // 00:00 Mefjus - Sleepless +trackparse_edit_result_free(result); +``` + +`line` is a `const long long *`, `NULL` when the edit names no line, so check it before you read +it. + diff --git a/site/src/content/docs/start/getting-started.mdx b/site/src/content/docs/start/getting-started.mdx index 07854f2..cef6da3 100644 --- a/site/src/content/docs/start/getting-started.mdx +++ b/site/src/content/docs/start/getting-started.mdx @@ -1,6 +1,6 @@ --- title: Getting started -description: Install trackparse for JavaScript, Python, Rust or Go and parse your first track. +description: Install trackparse for JavaScript, Python, Rust, Go or C and parse your first track. --- import { Aside, Steps, Tabs, TabItem } from "@astrojs/starlight/components"; @@ -47,6 +47,30 @@ import { Aside, Steps, Tabs, TabItem } from "@astrojs/starlight/components"; Go 1.22 or newer, no dependencies. The package name is `trackparse`. The API docs are on [pkg.go.dev](https://pkg.go.dev/github.com/4matic/trackparse/go). + + ```cmake + include(FetchContent) + FetchContent_Declare( + trackparse + URL https://github.com/4matic/trackparse/releases/download/c-v0.7.0/trackparse-c-0.7.0.tar.gz + URL_HASH SHA256=… # the trackparse-c-0.7.0.tar.gz line of SHA256SUMS on the release + ) + FetchContent_MakeAvailable(trackparse) + target_link_libraries(my_app PRIVATE trackparse::trackparse) + ``` + + C11, no dependencies beyond the C standard library; it builds with GCC, Clang and MSVC. + Every release from 0.7.0, the first with the C library, attaches the source tarball above + (CMake 3.16 or newer), `SHA256SUMS` and an amalgamation to its + [GitHub Release](https://github.com/4matic/trackparse/releases). + `cmake --install` also gives you `find_package(trackparse)` and a `trackparse.pc` for + pkg-config. Without CMake, copy `trackparse.c` and `trackparse.h` from + `trackparse-c-0.7.0-amalgamation.zip` into your project and compile them with your + sources (`cc -std=c11 -DTRACKPARSE_STATIC main.c trackparse.c -lm -lpthread`). The API is + one header, + [`trackparse.h`](https://github.com/4matic/trackparse/blob/main/c/include/trackparse.h), + with a comment on every declaration. + 2. Parse a track with [`parse`](/trackparse/reference/parse/) @@ -106,6 +130,27 @@ import { Aside, Steps, Tabs, TabItem } from "@astrojs/starlight/components"; fmt.Println(track.Artists[1].Role) // featured ``` + + ```c + #include + + trackparse_track *track = + trackparse_parse("Noisia feat. Foreign Beggars - Shellshock", TRACKPARSE_NUL_TERMINATED); + + printf("%s\n", track->title.ptr); // Shellshock + for (size_t i = 0; i < track->artists_count; i++) { + printf("%s\n", track->artists[i].name.ptr); + } + // Noisia + // Foreign Beggars + printf("%s\n", trackparse_role_name(track->artists[1].role)); // featured + trackparse_track_free(track); + ``` + + Input is UTF-8 with a byte length, or `TRACKPARSE_NUL_TERMINATED` for a C string. The + result owns its memory, so free it with `trackparse_track_free`. `trackparse_parse` + returns `NULL` only when memory runs out; check for it in real code. + 3. Look at the [versions](/trackparse/guides/versions/) and the @@ -159,6 +204,27 @@ import { Aside, Steps, Tabs, TabItem } from "@astrojs/starlight/components"; // remix by Noisia ``` + + ```c + trackparse_track *t = trackparse_parse( + "Daft Punk - One More Time (Official Music Video) [HD]", TRACKPARSE_NUL_TERMINATED); + printf("%s\n", t->title.ptr); // One More Time + for (size_t i = 0; i < t->junk_count; i++) { + printf("%s: %s\n", t->junk[i].kind_name.ptr, t->junk[i].raw.ptr); + } + // video: Official Music Video + // quality: HD + + trackparse_track *r = trackparse_parse("Dimension - Offshore (Mefjus Remix / Noisia Remix)", + TRACKPARSE_NUL_TERMINATED); + for (size_t i = 0; i < r->versions_count; i++) { + printf("%s by %s\n", r->versions[i].type_name.ptr, r->versions[i].artists[0].name.ptr); + } + // remix by Mefjus + // remix by Noisia + trackparse_track_free(r); + ``` + 4. Tell it about names that contain a joiner with @@ -212,6 +278,27 @@ import { Aside, Steps, Tabs, TabItem } from "@astrojs/starlight/components"; fmt.Printf("%q\n", names) // ["Chase & Status"] ``` + + ```c + trackparse_track *cs = trackparse_parse("Chase & Status - Baddadan", TRACKPARSE_NUL_TERMINATED); + for (size_t i = 0; i < cs->artists_count; i++) { + printf("%s\n", cs->artists[i].name.ptr); + } + // Chase + // Status + trackparse_track_free(cs); + + trackparse_parse_options *options = trackparse_parse_options_new(); + trackparse_parse_options_add_known_artist(options, "Chase & Status", TRACKPARSE_NUL_TERMINATED); + cs = trackparse_parse_with("Chase & Status - Baddadan", TRACKPARSE_NUL_TERMINATED, options); + for (size_t i = 0; i < cs->artists_count; i++) { + printf("%s\n", cs->artists[i].name.ptr); + } + // Chase & Status + trackparse_track_free(cs); + trackparse_parse_options_free(options); + ``` + 5. Write it back with [`format`](/trackparse/guides/formatting/), or turn it into @@ -252,6 +339,18 @@ import { Aside, Steps, Tabs, TabItem } from "@astrojs/starlight/components"; fmt.Println(string(data)) // {"input":"Daft Punk - One More Time (Official Music Video) [HD]","mode":"youtube",…} ``` + + ```c + trackparse_string *s = trackparse_format(t); + printf("%s\n", s->str.ptr); // Daft Punk - One More Time + trackparse_string_free(s); + + trackparse_string *json = trackparse_track_to_json(t); + printf("%s\n", json->str.ptr); // {"input":"Daft Punk - One More Time (Official Music Video) [HD]","mode":"youtube",…} + trackparse_string_free(json); + trackparse_track_free(t); + ``` + 6. Parse a whole [tracklist](/trackparse/guides/tracklists/). @@ -303,13 +402,29 @@ import { Aside, Steps, Tabs, TabItem } from "@astrojs/starlight/components"; `Time` and `Track` are pointers in Go, `nil` on a blank line or a note. + + ```c + trackparse_tracklist *list = trackparse_parse_tracklist( + "00:00 Noisia - Stigma\n04:10 Mefjus - Sleepless (Phace Remix)", TRACKPARSE_NUL_TERMINATED); + for (size_t i = 0; i < list->entries_count; i++) { + const trackparse_entry *e = &list->entries[i]; + if (e->time && e->track) printf("%gs %s\n", e->time->seconds, e->track->title.ptr); + } + // 0s Stigma + // 250s Sleepless + printf("%zu\n", list->warnings_count); // 0 + trackparse_tracklist_free(list); + ``` + + `time` and `track` are pointers in C, `NULL` on a blank line or a note. + ## Where each task is explained diff --git a/site/src/content/docs/start/introduction.mdx b/site/src/content/docs/start/introduction.mdx index a2bf71e..5d719cd 100644 --- a/site/src/content/docs/start/introduction.mdx +++ b/site/src/content/docs/start/introduction.mdx @@ -10,11 +10,15 @@ titles, file names, scrobbles, the tracklist under a mix. It gives you back an o artists and their roles, the clean title, every remix or version with its credits, and the noise that was around it. -It comes as four packages with the same behaviour: `trackparse` on +It comes as five packages with the same behaviour: `trackparse` on [npm](https://www.npmjs.com/package/trackparse) for JavaScript and TypeScript, `trackparse` on [PyPI](https://pypi.org/project/trackparse/) for Python, `trackparse` on -[crates.io](https://crates.io/crates/trackparse) for Rust, and the module -[`github.com/4matic/trackparse/go`](https://pkg.go.dev/github.com/4matic/trackparse/go) for Go. +[crates.io](https://crates.io/crates/trackparse) for Rust, the module +[`github.com/4matic/trackparse/go`](https://pkg.go.dev/github.com/4matic/trackparse/go) for Go, +and a C library with one header, +[`trackparse.h`](https://github.com/4matic/trackparse/blob/main/c/include/trackparse.h), released +as a source tarball and an amalgamation on each +[GitHub Release](https://github.com/4matic/trackparse/releases) from 0.7.0 on. Every example on this site has a tab for each language. The API docs of the Rust crate are on [docs.rs](https://docs.rs/trackparse), and those of the Go module on @@ -51,7 +55,7 @@ The same rule shows up in smaller ways: - Every key of the output is always present, so you never have to check whether a field exists ([the output model](/trackparse/reference/spec/#output-model)). - No string makes it fail. [`parse`](/trackparse/reference/parse/) never throws in JavaScript or - Python and never panics in Rust or Go + Python, never panics in Rust or Go, and in C returns `NULL` only when memory runs out ([R0.8](/trackparse/reference/spec/#r0-portability:~:text=R0.8%20Parsing%20is)). ## What you get back @@ -98,6 +102,20 @@ data, _ := json.Marshal(trackparse.Parse("Queen - Bohemian Rhapsody (Live at Wem fmt.Println(string(data)) ``` + + + +```c +#include + +trackparse_track *t = trackparse_parse("Queen - Bohemian Rhapsody (Live at Wembley 1986)", + TRACKPARSE_NUL_TERMINATED); +trackparse_string *json = trackparse_track_to_json(t); +printf("%s\n", json->str.ptr); // {"input":"Queen - Bohemian Rhapsody (Live at Wembley 1986)","mode":"clean",…} +trackparse_string_free(json); +trackparse_track_free(t); +``` + @@ -129,12 +147,14 @@ fmt.Println(string(data)) } ``` -All four give this JSON: the packages pass the same fixtures and give the same output on every +All five give this JSON: the packages pass the same fixtures and give the same output on every fixture input ([Ports](/trackparse/project/ports/#what-the-rust-port-taught) has the one Unicode note). In JavaScript the result is a plain object. In Python it is a frozen dataclass with snake_case attributes, and `to_dict()` turns it into the JSON above. In Rust it is a struct with snake_case fields, and `to_json()` writes that JSON as a string. In Go it is a struct -with exported CamelCase fields, and `json.Marshal` writes that JSON. The +with exported CamelCase fields, and `json.Marshal` writes that JSON. In C it is a read-only +struct with snake_case members that owns its memory, and `trackparse_track_to_json` writes that +JSON. The [`parse` reference](/trackparse/reference/parse/) explains every field, and [Serializing to JSON](/trackparse/reference/parse/#serializing-to-json) shows the round trip in each language. [Try this track in the playground](/trackparse/playground/#track=Queen%20-%20Bohemian%20Rhapsody%20%28Live%20at%20Wembley%201986%29). @@ -142,16 +162,16 @@ language. [Try this track in the playground](/trackparse/playground/#track=Queen ## Names in each language The docs use the JavaScript and JSON names in running text. Python and Rust use snake_case for the -same things, and Go uses exported CamelCase: +same things, Go uses exported CamelCase, and C prefixes every name with `trackparse_`: -| | JavaScript | Python | Rust | Go | -|---|---|---|---|---| -| Parse | [`parse(s, options?)`](/trackparse/reference/parse/) | `parse(s, **options)` | [`parse(s)`](https://docs.rs/trackparse/latest/trackparse/fn.parse.html), [`parse_with(s, &options)`](https://docs.rs/trackparse/latest/trackparse/fn.parse_with.html) | [`Parse(s)`](https://pkg.go.dev/github.com/4matic/trackparse/go#Parse), [`ParseWith(s, options)`](https://pkg.go.dev/github.com/4matic/trackparse/go#ParseWith) | -| A field | `track.fullTitle` | `track.full_title` | `track.full_title` | `track.FullTitle` | -| An option | [`{ knownArtists: […] }`](/trackparse/reference/options/) | `known_artists=[…]` | [`ParseOptions::new().known_artists([…])`](https://docs.rs/trackparse/latest/trackparse/struct.ParseOptions.html) | [`ParseOptions{KnownArtists: …}`](https://pkg.go.dev/github.com/4matic/trackparse/go#ParseOptions) | -| A value | `"remix"`, `null` | `"remix"`, `None` | `VersionType::Remix`, `None` | `VersionTypeRemix`, `nil` | -| Lists | arrays | tuples | `Vec` | slices | -| JSON | `JSON.stringify(track)` | `track.to_dict()` | `track.to_json()`, or `serde` | `json.Marshal(track)` | +| | JavaScript | Python | Rust | Go | C | +|---|---|---|---|---|---| +| Parse | [`parse(s, options?)`](/trackparse/reference/parse/) | `parse(s, **options)` | [`parse(s)`](https://docs.rs/trackparse/latest/trackparse/fn.parse.html), [`parse_with(s, &options)`](https://docs.rs/trackparse/latest/trackparse/fn.parse_with.html) | [`Parse(s)`](https://pkg.go.dev/github.com/4matic/trackparse/go#Parse), [`ParseWith(s, options)`](https://pkg.go.dev/github.com/4matic/trackparse/go#ParseWith) | `trackparse_parse(s, len)`, `trackparse_parse_with(s, len, options)` | +| A field | `track.fullTitle` | `track.full_title` | `track.full_title` | `track.FullTitle` | `track->full_title` | +| An option | [`{ knownArtists: […] }`](/trackparse/reference/options/) | `known_artists=[…]` | [`ParseOptions::new().known_artists([…])`](https://docs.rs/trackparse/latest/trackparse/struct.ParseOptions.html) | [`ParseOptions{KnownArtists: …}`](https://pkg.go.dev/github.com/4matic/trackparse/go#ParseOptions) | `trackparse_parse_options_add_known_artist(options, …)` | +| A value | `"remix"`, `null` | `"remix"`, `None` | `VersionType::Remix`, `None` | `VersionTypeRemix`, `nil` | `TRACKPARSE_VERSION_REMIX`, `NULL` | +| Lists | arrays | tuples | `Vec` | slices | a pointer and a `_count` | +| JSON | `JSON.stringify(track)` | `track.to_dict()` | `track.to_json()`, or `serde` | `json.Marshal(track)` | `trackparse_track_to_json(track)` | [Other functions](/trackparse/reference/functions/) has the full table of function names. @@ -160,7 +180,7 @@ same things, and Go uses exported CamelCase: Behaviour isn't defined by the JavaScript code. It's defined by a written [spec](/trackparse/reference/spec/) with numbered rules (R0 to R13), and by 13,130 fixtures that pin those rules down. The JavaScript package is the reference implementation. The Python package, the Rust -crate and the Go module pass the same fixtures and produce the same JSON, byte for byte. +crate, the Go module and the C library pass the same fixtures and produce the same JSON, byte for byte. [How it's tested](/trackparse/project/testing/) and [Ports](/trackparse/project/ports/) have the details. @@ -174,7 +194,7 @@ If all you need is a cleaned-up string to send to a scrobbler, scope. trackparse is for when you need to know who did what. It also has no artist database. `&` is a joiner, so `Chase & Status` comes out as two artists unless -you pass it in [`knownArtists`](/trackparse/reference/options/#parse-options) (`known_artists` in Python and Rust, `KnownArtists` in Go). More on that in +you pass it in [`knownArtists`](/trackparse/reference/options/#parse-options) (`known_artists` in Python and Rust, `KnownArtists` in Go, `trackparse_parse_options_add_known_artist` in C). More on that in [Artists and credits](/trackparse/guides/artists/#knownartists). The other gaps are listed under [Limitations and roadmap](/trackparse/project/roadmap/). diff --git a/site/src/lib/codegen.ts b/site/src/lib/codegen.ts index e1343fd..fdd27f4 100644 --- a/site/src/lib/codegen.ts +++ b/site/src/lib/codegen.ts @@ -1,6 +1,7 @@ -// The code panels of the playground: the same calls in JavaScript, Python, Rust and Go, laid out -// as each language's formatter prints them (Biome at 100 columns, Ruff at 100 columns, rustfmt -// and gofmt), plus a link to the API docs of every function and type a snippet uses. +// The code panels of the playground: the same calls in JavaScript, Python, Rust, Go and C, laid +// out as each language's formatter prints them (Biome at 100 columns, Ruff at 100 columns, +// rustfmt, gofmt and clang-format at 100 columns), plus a link to the API docs of every function +// and type a snippet uses. // Pure functions: the playground passes in what its controls hold. import type { Lang } from "./lang"; @@ -334,10 +335,311 @@ function goMain(body: string[], std: string[]): string { return `package main\n\n${imports}\n\nfunc main() {\n${body.map((l) => (l ? `\t${l}` : "")).join("\n")}\n}`; } +// ---- C ------------------------------------------------------------------------------------------ +// Laid out as clang-format writes it with c/.clang-format (LLVM style, 100 columns, short ifs on +// one line). Checked by running clang-format over generated programs: they come out unchanged. + +/** A C octal escape for each UTF-8 byte of `cp`: three digits, so a following digit is safe. */ +function cOctal(cp: number): string { + return [...new TextEncoder().encode(String.fromCodePoint(cp))].map((b) => `\\${b.toString(8).padStart(3, "0")}`).join(""); +} + +/** + * The inside of a C string literal (no quotes). Control, invisible and bidi characters are octal + * escapes of their UTF-8 bytes; a lone surrogate is U+FFFD, as the library reads invalid UTF-8; + * a `?` after a `?` is escaped, so no trigraph forms. Other text is UTF-8 as written. + */ +function cEsc(s: string): string { + let out = ""; + let prev = ""; + for (const ch of s) { + const cp = ch.codePointAt(0) ?? 0; + if (ch === '"' || ch === "\\") out += `\\${ch}`; + else if (ch === "\n") out += "\\n"; + else if (ch === "\r") out += "\\r"; + else if (ch === "\t") out += "\\t"; + else if (ch === "?" && prev === "?") out += "\\?"; + else if (cp >= 0xd800 && cp <= 0xdfff) out += cOctal(0xfffd); + else if (invisible(cp)) out += cOctal(cp); + else out += ch; + prev = ch; + } + return out; +} +/** A C string literal. */ +export const cStr = (s: string) => `"${cEsc(s)}"`; + +/** A double argument: `45`, `7.5`, `1e+21`; `INFINITY` and `NAN` need . */ +function cNum(n: number): string { + if (!Number.isFinite(n)) return Number.isNaN(n) ? "NAN" : n > 0 ? "INFINITY" : "-INFINITY"; + return String(n); +} +/** The enum constant of an option value: `youtube` → `TRACKPARSE_MODE_YOUTUBE`. */ +const cConst = (prefix: string, v: string) => `TRACKPARSE_${prefix}_${v.toUpperCase()}`; + +/** + * Rows of `args` starting at column `col`, and the number of string splits: as many arguments + * per row as fit in 100 columns, a comma after each but the last, `tail` after the last. When an + * argument cannot fit, clang-format gives each argument a row and splits the string literals that + * are too long. Null when that does not fit either. + */ +function cPack(col: number, args: string[], tail: string): { rows: string[]; splits: number } | null { + const rows: string[] = []; + const end = (i: number) => (i === args.length - 1 ? tail : ","); + for (let i = 0; i < args.length; i++) { + const last = rows.length - 1; + if (last >= 0 && col + cols(`${rows[last]} ${args[i]}${end(i)}`) <= WIDTH) rows[last] += ` ${args[i]}${end(i)}`; + else if (col + cols(`${args[i]}${end(i)}`) <= WIDTH) rows.push(`${args[i]}${end(i)}`); + else return cPackSplit(col, args, tail); + } + return { rows, splits: 0 }; +} +function cPackSplit(col: number, args: string[], tail: string): { rows: string[]; splits: number } | null { + const rows: string[] = []; + let splits = 0; + for (let i = 0; i < args.length; i++) { + const a = args[i]; + const e = i === args.length - 1 ? tail : ","; + if (col + cols(a + e) <= WIDTH) rows.push(a + e); + else if (a.length > 1 && a.startsWith('"') && a.endsWith('"')) { + const pieces = cSplit(a.slice(1, -1), col, e).map((p) => `"${p}"`); + if (col + cols(pieces[pieces.length - 1] + e) > WIDTH || pieces.some((p) => col + cols(p) > WIDTH)) return null; + splits += pieces.length - 1; + pieces[pieces.length - 1] += e; + rows.push(...pieces); + } else return null; + } + return { rows, splits }; +} + +/** + * `lhs fn(args);` at `indent`, as clang-format breaks it: flat when it fits; else the layout with + * the lowest penalty among the arguments aligned after the parenthesis, a break after `=`, a break + * after the parenthesis (arguments 4 columns in), and both. Penalties as clang-format's LLVM style + * weighs them: 2 for the `=`, 19 for the parenthesis, about 18 for each break between arguments and + * 1000 for each split of a string literal. + */ +function cCall(indent: string, lhs: string, fn: string, args: string[]): string { + const flat = `${lhs}${fn}(${args.join(", ")});`; + if (cols(indent + flat) <= WIDTH) return flat; + // Continuation rows are padded relative to `indent`, which the caller adds to every row. + const at = cols(indent); + const pad = (col: number) => `\n${" ".repeat(col - at)}`; + const options: { cost: number; text: string }[] = []; + const add = (cost: number, head: string, col: number) => { + const p = cPack(col, args, ");"); + if (!p) return; + const breaks = p.splits ? args.length - 1 : p.rows.length - 1; + options.push({ cost: cost + 18 * breaks + 1000 * p.splits, text: head + p.rows.join(pad(col)) }); + }; + const open = `${lhs}${fn}(`; + // Aligned after the parenthesis, on the line of the call. + add(0, open, at + cols(open)); + if (lhs) { + // A break after `=`: the call on its own line, aligned after its parenthesis or broken after it. + add(2, `${lhs.trimEnd()}${pad(at + 4)}${fn}(`, at + 4 + cols(`${fn}(`)); + add(21, `${lhs.trimEnd()}${pad(at + 4)}${fn}(${pad(at + 8)}`, at + 8); + } + add(19, `${open}${pad(at + 4)}`, at + 4); + if (!options.length) return flat; + return options.reduce((a, b) => (b.cost < a.cost ? b : a)).text; +} + +/** + * The pieces of one string literal at column `col`, split after a space where a piece would pass + * 100 columns (clang-format's string breaking); `tail` follows the last piece. + */ +function cSplit(text: string, col: number, tail: string): string[] { + const out: string[] = []; + let rest = text; + while (col + cols(`"${rest}"${tail}`) > WIDTH) { + let cut = -1; + let w = col + 1; + const chars = [...rest]; + let i = 0; + for (let k = 0; k < chars.length; k++) { + w += cols(chars[k]); + i += chars[k].length; + if (w + 1 > WIDTH) break; + if (chars[k] === " " && k < chars.length - 1) cut = i; + } + if (cut <= 0) break; + out.push(rest.slice(0, cut)); + rest = rest.slice(cut); + } + out.push(rest); + return out; +} + +/** + * `lhs "…";` for a string declaration: one literal per line of `text` (a break after each `\n`, + * as clang-format keeps them), aligned after `=`, or on the next line when that saves a split. + */ +function cText(indent: string, lhs: string, text: string): string { + const lines = text + .split(/(?<=\n)/) + .filter((x, i, all) => x !== "" || all.length === 1) + .map(cEsc); + const layout = (col: number) => lines.flatMap((l, i) => cSplit(l, col, i === lines.length - 1 ? ";" : "")); + const same = layout(cols(indent + lhs)); + const next = layout(cols(indent) + 4); + // Continuation rows are padded relative to `indent`, which the caller adds to every row. + if (lines.length === 1 && same.length > 1 && next.length < same.length) { + const pad = "\n "; + return `${lhs.trimEnd()}${pad}${next.map((p) => `"${p}"`).join(pad)};`; + } + const pad = `\n${" ".repeat(cols(lhs))}`; + return `${lhs}${same.map((p) => `"${p}"`).join(pad)};`; +} + +/** A C program: the includes, then `fns` (each a block of lines), then `main` around `body`. */ +function cMain(body: string[], std: string[], fns: string[] = []): string { + const inc = [...new Set(std)].sort().map((h) => `#include <${h}>`); + const out = [...inc, "#include ", ""]; + for (const f of fns) out.push(f, ""); + out.push("int main(void) {", ...body.map((l) => (l ? ` ${l}` : "")), "}"); + return out.join("\n"); +} + +/** + * The string variable `name` holding `s`, and the length argument for it. Text with U+0000 is a + * char array passed with its byte length, so the NUL stays in. + */ +function cInput(name: string, s: string): { decl: string; len: string } { + if (s.includes("\0")) return { decl: cText(" ", `const char ${name}[] = `, s), len: `sizeof ${name} - 1` }; + return { decl: cText(" ", `const char *${name} = `, s), len: "TRACKPARSE_NUL_TERMINATED" }; +} + +/** `parse` and `format` as a C program. */ +function cTrackCode(s: string, o: TrackOptions, f: FormatChoice): Snippet { + const { decl, len } = cInput("input", s); + const body = [decl]; + const api: string[] = []; + const ind = " "; + const set: string[] = []; + if (o.mode) set.push(cCall(ind, "", "trackparse_parse_options_set_mode", ["options", cConst("MODE", o.mode)])); + if (o.uploader) set.push(cCall(ind, "", "trackparse_parse_options_set_uploader", ["options", cStr(o.uploader), "TRACKPARSE_NUL_TERMINATED"])); + for (const a of o.knownArtists ?? []) + set.push(cCall(ind, "", "trackparse_parse_options_add_known_artist", ["options", cStr(a), "TRACKPARSE_NUL_TERMINATED"])); + if (o.splitAnd) set.push(cCall(ind, "", "trackparse_parse_options_set_split_and", ["options", cConst("SPLIT_AND", o.splitAnd)])); + if (set.length) { + api.push("trackparse_parse_with", "trackparse_parse_options"); + body.push( + "trackparse_parse_options *options = trackparse_parse_options_new();", + ...set, + cCall(ind, "trackparse_track *track = ", "trackparse_parse_with", ["input", len, "options"]), + "trackparse_parse_options_free(options);", + ); + } else { + api.push("trackparse_parse"); + body.push(cCall(ind, "trackparse_track *track = ", "trackparse_parse", ["input", len])); + } + body.push("if (!track) return 1; /* out of memory */", ""); + const fset: string[] = []; + if (f.feat) fset.push(`trackparse_format_options_set_feat(format, ${cConst("FEAT", f.feat)});`); + if (f.joiners) fset.push(`trackparse_format_options_set_joiners(format, ${cConst("JOINERS", f.joiners)});`); + if (f.versions) fset.push(`trackparse_format_options_set_versions(format, ${cConst("VERSIONS", f.versions)});`); + if (fset.length) { + api.push("trackparse_format_with", "trackparse_format_options"); + body.push( + "trackparse_format_options *format = trackparse_format_options_new();", + ...fset, + "trackparse_string *formatted = trackparse_format_with(track, format);", + "trackparse_format_options_free(format);", + ); + } else { + api.push("trackparse_format"); + body.push("trackparse_string *formatted = trackparse_format(track);"); + } + // printf stops at U+0000; fwrite writes the whole string. + if (s.includes("\0")) + body.push( + "if (formatted) {", + " fwrite(formatted->str.ptr, 1, formatted->str.len, stdout);", + " putchar('\\n');", + "}", + ); + else body.push('if (formatted) printf("%s\\n", formatted->str.ptr);'); + body.push( + "trackparse_string_free(formatted);", + "trackparse_track_free(track);", + "return 0;", + ); + return { src: cMain(body.flatMap((l) => l.split("\n")), ["stdio.h"]), api }; +} + +/** `parseTracklist` and `applyEdits` as a C program. */ +function cListCode(x: ListInput): Snippet { + const { text, audioSeconds, knownArtists, seconds, from, fix } = x; + const { decl, len } = cInput("text", text); + const hasOptions = audioSeconds !== undefined || knownArtists !== undefined; + const ind = " "; + const body = [decl, ""]; + if (hasOptions) { + body.push("trackparse_tracklist_options *options = trackparse_tracklist_options_new();"); + // audio_seconds unset is "unknown"; set to 0 it is an audio of length 0. + if (audioSeconds !== undefined) body.push(cCall(ind, "", "trackparse_tracklist_options_set_audio_seconds", ["options", cNum(audioSeconds)])); + for (const a of knownArtists ?? []) + body.push(cCall(ind, "", "trackparse_tracklist_options_add_known_artist", ["options", cStr(a), "TRACKPARSE_NUL_TERMINATED"])); + body.push(cCall(ind, "trackparse_tracklist *list = ", "trackparse_parse_tracklist_with", ["text", len, "options"]), "trackparse_tracklist_options_free(options);"); + } else { + body.push(cCall(ind, "trackparse_tracklist *list = ", "trackparse_parse_tracklist", ["text", len])); + } + body.push( + "if (!list) return 1; /* out of memory */", + "/* The entries (one per line), the warnings (with line numbers) and the stats, as JSON. */", + "trackparse_string *json = trackparse_tracklist_to_json(list);", + 'if (json) printf("%s\\n\\n", json->str.ptr);', + "trackparse_string_free(json);", + "trackparse_tracklist_free(list);", + "", + "trackparse_edits *shift = trackparse_edits_new();", + cCall(ind, "", "trackparse_edits_shift_from", ["shift", cNum(seconds), String(from)]), + cCall(ind, "", "print_edited", ["text", len, "shift"]), + "trackparse_edits_free(shift);", + "", + "trackparse_edits *sort = trackparse_edits_new();", + "trackparse_edits_sort_by_time(sort);", + cCall(ind, "", "print_edited", ["text", len, "sort"]), + "trackparse_edits_free(sort);", + ); + if (fix) + body.push( + "", + "/* The suggested fix of the first warning that has one. */", + "trackparse_edits *fix = trackparse_edits_new();", + cCall(ind, "", "trackparse_edits_set_time", ["fix", String(fix.line), cNum(fix.seconds)]), + cCall(ind, "", "print_edited", ["text", len, "fix"]), + "trackparse_edits_free(fix);", + ); + body.push("return 0;"); + const helper = [ + "/* Apply the edits to text and print the new text. */", + "static void print_edited(const char *text, size_t len, const trackparse_edits *edits) {", + " trackparse_edit_result *result = trackparse_apply_edits(text, len, edits);", + ...(text.includes("\0") + ? [" if (result) {", " fwrite(result->text.ptr, 1, result->text.len, stdout);", ' printf("\\n\\n");', " }"] + : [' if (result) printf("%s\\n\\n", result->text.ptr);']), + " trackparse_edit_result_free(result);", + "}", + ].join("\n"); + const std = ["stdio.h"]; + if ([audioSeconds ?? 0, seconds, fix?.seconds ?? 0].some((n) => !Number.isFinite(n))) std.push("math.h"); + const api = [ + hasOptions ? "trackparse_parse_tracklist_with" : "trackparse_parse_tracklist", + ...(hasOptions ? ["trackparse_tracklist_options"] : []), + "trackparse_tracklist_to_json", + "trackparse_apply_edits", + "trackparse_edits", + ]; + return { src: cMain(body.flatMap((l) => l.split("\n")), std, [helper]), api }; +} + // ---- one track ---------------------------------------------------------------------------------- /** `parse` and `format` with the playground's options, in one language. */ export function trackCode(lang: Lang, s: string, o: TrackOptions, f: FormatChoice): Snippet { + if (lang === "c") return cTrackCode(s, o, f); if (lang === "js") { const po: { [k: string]: Value } = {}; if (o.mode) po.mode = o.mode; @@ -434,6 +736,7 @@ export function trackCode(lang: Lang, s: string, o: TrackOptions, f: FormatChoic /** `parseTracklist` and `applyEdits` for the playground's text, options and edit inputs. */ export function listCode(lang: Lang, x: ListInput): Snippet { + if (lang === "c") return cListCode(x); const { text, audioSeconds, knownArtists, seconds, from, fix } = x; const lines = text.split("\n"); // Lists without CR line endings are written one line per row; anything else as one string. @@ -593,9 +896,21 @@ const SITE_REF: Record = { apply_edits: "reference/tracklist/#applyeditstext-edits-options", }; +/** The C names: the site's reference pages have a C tab for each of these functions. */ +const C_REF: Record = { + trackparse_parse: SITE_REF.parse, + trackparse_parse_with: SITE_REF.parse, + trackparse_format: SITE_REF.format, + trackparse_format_with: SITE_REF.format, + trackparse_parse_tracklist: SITE_REF.parseTracklist, + trackparse_parse_tracklist_with: SITE_REF.parseTracklist, + trackparse_apply_edits: SITE_REF.applyEdits, +}; + /** Where `name` is documented for `lang`: docs.rs, pkg.go.dev, or the site's reference. */ export function apiUrl(lang: Lang, name: string, base: string): string | null { if (lang === "rs") return RS_ITEM[name] ? DOCS_RS + RS_ITEM[name] : null; + if (lang === "c") return C_REF[name] ? `${base}/${C_REF[name]}` : null; if (lang === "go") return `${PKG_GO}#${name}`; return SITE_REF[name] ? `${base}/${SITE_REF[name]}` : null; } diff --git a/site/src/lib/lang.ts b/site/src/lib/lang.ts index cd92cf4..8b1f017 100644 --- a/site/src/lib/lang.ts +++ b/site/src/lib/lang.ts @@ -1,15 +1,36 @@ // One language choice for the whole site. The docs' code tabs (``) keep // theirs in localStorage under Starlight's key, as the tab label. The install switch on the -// landing page and the playground's code panels read and write the same entry, so picking Rust -// or Go in one place picks it everywhere. +// landing page and the playground's code panels read and write the same entry, so picking Rust, +// Go or C in one place picks it everywhere. -export type Lang = "js" | "py" | "rs" | "go"; +import { version } from "../../../js/package.json"; + +export type Lang = "js" | "py" | "rs" | "go" | "c"; /** Starlight's key for `syncKey="lang"` (see its Tabs.astro). */ const KEY = "starlight-synced-tabs__lang"; /** The tab labels used on every docs page. */ -export const LANG_LABEL: Record = { js: "JavaScript", py: "Python", rs: "Rust", go: "Go" }; +export const LANG_LABEL: Record = { js: "JavaScript", py: "Python", rs: "Rust", go: "Go", c: "C" }; + +/** + * The C library's version. All packages share one version (release-please bumps js/package.json + * with the rest), and the first C release is 0.7.0, so an older version means "not yet". + */ +const C_VERSION = (() => { + const [a, b] = version.split(".").map(Number); + return a > 0 || b >= 7 ? version : "0.7.0"; +})(); +const C_TARBALL = `https://github.com/4matic/trackparse/releases/download/c-v${C_VERSION}/trackparse-c-${C_VERSION}.tar.gz`; + +/** The CMake lines that fetch and link the C library (the install switch shows them for C). */ +export const C_FETCHCONTENT = [ + "include(FetchContent)", + "FetchContent_Declare(trackparse", + ` URL ${C_TARBALL})`, + "FetchContent_MakeAvailable(trackparse)", + "target_link_libraries(app PRIVATE trackparse::trackparse)", +].join("\n"); /** Where each package lives, and where the docs explain how to install it. */ export const PACKAGE: Record = { @@ -17,6 +38,8 @@ export const PACKAGE: Record> = { py: new Set(["from", "import", "def", "return", "for", "in", "as", "lambda", "not", "and", "or"]), rs: new Set(["use", "let", "mut", "fn", "pub", "struct", "enum", "impl", "for", "in", "if", "else", "match", "return", "as", "ref", "const", "static", "mod", "crate", "self", "where", "while", "loop"]), go: new Set(["package", "import", "func", "var", "const", "type", "struct", "map", "for", "range", "if", "else", "return", "go", "defer"]), + c: new Set(["include", "int", "void", "char", "const", "static", "struct", "return", "if", "else", "for", "while", "sizeof", "size_t", "bool"]), }; -const CONSTANTS = new Set(["true", "false", "null", "undefined", "True", "False", "None", "Some", "nil"]); +const CONSTANTS = new Set(["true", "false", "null", "undefined", "True", "False", "None", "Some", "nil", "NULL"]); /** * A small highlighter for the snippets the playground generates (one import, a call or two). @@ -314,6 +315,9 @@ export function codeHtml(src: string, lang: Lang): string { : lang === "go" ? // Go: `//` comments, interpreted and raw (backquoted) strings. /(\/\/[^\n]*)|("(?:\\.|[^"\\\n])*"|`[^`]*`)|\b(\d+(?:\.\d+)?)\b|([A-Za-z_][\w]*)|([{}()[\],.;:=&])/g + : lang === "c" + ? // C: block comments, strings, character constants and the
of an #include. + /(\/\*[\s\S]*?\*\/)|("(?:\\.|[^"\\\n])*"|'(?:\\.|[^'\\\n])*'|<[\w./]+\.h>)|\b(\d+(?:\.\d+)?)\b|([A-Za-z_][\w]*)|([{}()[\],.;:=&*#!>-])/g : /(#[^\n]*)|("(?:\\.|[^"\\\n])*"|'(?:\\.|[^'\\\n])*')|\b(\d+(?:\.\d+)?)\b|([A-Za-z_][\w]*)|([{}()[\],.;:=])/g; let out = ""; let last = 0; diff --git a/spec/fixtures/README.md b/spec/fixtures/README.md index f6079c8..360c7c8 100644 --- a/spec/fixtures/README.md +++ b/spec/fixtures/README.md @@ -2,8 +2,9 @@ The shared test corpus: 13,130 cases, [1,203 written by hand](https://4matic.github.io/trackparse/project/testing/#handwritten-1203-cases) and [11,927 generated](https://4matic.github.io/trackparse/project/testing/#generated-11927-cases). Every port -([JavaScript](../../js/README.md), [Python](../../python/README.md), [Rust](../../rust/README.md) -and [Go](../../go/README.md)) runs every case here. The fixtures, not any one implementation, +([JavaScript](../../js/README.md), [Python](../../python/README.md), [Rust](../../rust/README.md), +[Go](../../go/README.md) and [C](https://github.com/4matic/trackparse/blob/main/c/README.md)) runs +every case here. The fixtures, not any one implementation, define correct behaviour. **Docs:** [How it's tested](https://4matic.github.io/trackparse/project/testing/) · [Contributing](https://4matic.github.io/trackparse/project/contributing/) @@ -92,8 +93,8 @@ unrelated fields: the case then survives changes elsewhere, and the exact cases promoted. - Port-specific gaps go in that port's skip list ([`js/test/skip.json`](../../js/test/skip.json), [`python/tests/skip.json`](../../python/tests/skip.json), [`rust/tests/skip.json`](../../rust/tests/skip.json), - [`go/testdata/skip.json`](../../go/testdata/skip.json)), not here. A skip list can only shrink, and all - four are empty today. + [`go/testdata/skip.json`](../../go/testdata/skip.json), [`c/tests/skip.json`](../../c/tests/skip.json)), not here. A skip list can only shrink, and all + five are empty today. ## Running the fixtures @@ -104,20 +105,24 @@ pnpm test # JavaScript: js/test/fixtures.test.ts (cd python && uv run pytest) # Python: python/tests/test_fixtures.py (cd rust && cargo test) # Rust: rust/tests/fixtures.rs (cd go && go test ./...) # Go: go/fixtures_test.go +(cd c && cmake -S . -B build && cmake --build build && ctest --test-dir build -R fixtures) + # C: c/tests/runner.c # one case, by id pnpm --filter trackparse exec vitest run test/fixtures.test.ts -t "brackets-version-001" (cd python && uv run pytest tests/test_fixtures.py -k "brackets-version-001") (cd rust && TRACKPARSE_ONLY=brackets-version-001 cargo test --test fixtures) (cd go && TRACKPARSE_ONLY=brackets-version-001 go test -run TestFixtures -v) +(cd c && TRACKPARSE_ONLY=brackets-version-001 ./build/trackparse-fixtures ../spec/fixtures/*/*.json) # pass rate per fixture file and per spec rule pnpm conformance (cd python && uv run python scripts/conformance.py) (cd rust && TRACKPARSE_REPORT=1 cargo test --test fixtures -- --nocapture) (cd go && TRACKPARSE_REPORT=1 go test -run TestFixtures -v) +(cd c && TRACKPARSE_REPORT=1 ./build/trackparse-fixtures ../spec/fixtures/*/*.json) -# after pnpm build: the complete output of all four ports, compared +# after pnpm build: the complete output of all five ports, compared node scripts/compare-ports.mjs node scripts/fuzz-ports.mjs # the same diff on random input diff --git a/spec/generator/README.md b/spec/generator/README.md index 4c14e18..0e1d9f8 100644 --- a/spec/generator/README.md +++ b/spec/generator/README.md @@ -2,7 +2,8 @@ Combinatorial fixture generator for the trackparse spec. It writes `spec/fixtures/generated/*.json`: 11,927 cases, about 7.7 MB (`test/generated.test.ts` caps the -size at 7.8 MB). Every port (JavaScript, Python, Rust and Go) runs these files next to the 1,203 +size at 7.8 MB). Every port (JavaScript, Python, Rust, Go and +[C](https://github.com/4matic/trackparse/blob/main/c/README.md)) runs these files next to the 1,203 handwritten fixtures. The case format is in [`../fixtures/README.md`](../fixtures/README.md). **Docs:** [How it's tested: generated cases](https://4matic.github.io/trackparse/project/testing/#generated-11927-cases) · [Spec](https://4matic.github.io/trackparse/reference/spec/) @@ -25,7 +26,7 @@ the side of rejecting. When the SPEC changes, update the atom expectations and `problem()` in the same change. Then run `gen`, and every port must pass the result: JavaScript first, since it is the reference, then -Python, Rust and Go. +Python, Rust, Go and C. ## Scenarios